MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / serialize_not_overly_massive

Function serialize_not_overly_massive

tests/all/module.rs:145–197  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

143#[test]
144#[cfg_attr(miri, ignore)]
145fn serialize_not_overly_massive() -> Result<()> {
146 let mut config = Config::new();
147 config.memory_guaranteed_dense_image_size(1 << 20);
148 let engine = Engine::new(&config)?;
149
150 let assert_smaller_than_1mb = |module: &str| -> Result<()> {
151 println!("{module}");
152 let bytes = Module::new(&engine, module)?.serialize()?;
153 assert!(bytes.len() < (1 << 20));
154 Ok(())
155 };
156
157 // Tons of space between data segments should use sparse initialization,
158 // along with various permutations of empty and nonempty segments.
159 assert_smaller_than_1mb(
160 r#"(module
161 (memory 20000)
162 (data (i32.const 0) "a")
163 (data (i32.const 0x200000) "b")
164 )"#,
165 )?;
166 assert_smaller_than_1mb(
167 r#"(module
168 (memory 20000)
169 (data (i32.const 0) "a")
170 (data (i32.const 0x200000) "")
171 )"#,
172 )?;
173 assert_smaller_than_1mb(
174 r#"(module
175 (memory 20000)
176 (data (i32.const 0) "")
177 (data (i32.const 0x200000) "b")
178 )"#,
179 )?;
180 assert_smaller_than_1mb(
181 r#"(module
182 (memory 20000)
183 (data (i32.const 0) "")
184 (data (i32.const 0x200000) "")
185 )"#,
186 )?;
187
188 // lone data segment
189 assert_smaller_than_1mb(
190 r#"(module
191 (memory 20000)
192 (data (i32.const 0x200000) "b")
193 )"#,
194 )?;
195
196 Ok(())
197}
198
199// This test specifically disables SSE4.1 in Cranelift which force wasm
200// instructions like `f32.ceil` to go through libcalls instead of using native

Callers

nothing calls this directly

Calls 4

OkFunction · 0.85
newFunction · 0.50
serializeMethod · 0.45

Tested by

no test coverage detected