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

Method get_memory

crates/fuzzing/src/oracles/diff_v8.rs:246–268  ·  view source on GitHub ↗
(&mut self, memory_name: &str, shared: bool)

Source from the content-addressed store, hash-verified

244 }
245
246 fn get_memory(&mut self, memory_name: &str, shared: bool) -> Option<Vec<u8>> {
247 let mut isolate = self.isolate.borrow_mut();
248 let mut scope = v8::HandleScope::new(&mut *isolate);
249 let context = v8::Local::new(&mut scope, &self.context);
250 let global = context.global(&mut scope);
251 let mut scope = v8::ContextScope::new(&mut scope, context);
252
253 let name = v8::String::new(&mut scope, "MEMORY_NAME").unwrap();
254 let memory_name = v8::String::new(&mut scope, memory_name).unwrap();
255 global.set(&mut scope, name.into(), memory_name.into());
256 let v8 = eval(&mut scope, "WASM_INSTANCE.exports[MEMORY_NAME].buffer").unwrap();
257 let v8_data = if shared {
258 v8::Local::<'_, v8::SharedArrayBuffer>::try_from(v8)
259 .unwrap()
260 .get_backing_store()
261 } else {
262 v8::Local::<'_, v8::ArrayBuffer>::try_from(v8)
263 .unwrap()
264 .get_backing_store()
265 };
266
267 Some(v8_data.iter().map(|i| i.get()).collect())
268 }
269}
270
271/// Evaluates the JS `code` within `scope`, returning either the result of the

Callers 5

differentialFunction · 0.45
smoke_test_engineFunction · 0.45
check_memory_accessesFunction · 0.45
check_stacksFunction · 0.45
instance_get_memoryFunction · 0.45

Calls 9

evalFunction · 0.85
globalMethod · 0.80
collectMethod · 0.80
newFunction · 0.50
unwrapMethod · 0.45
setMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45
getMethod · 0.45

Tested by 1

instance_get_memoryFunction · 0.36