diff --git a/src/binding.cc b/src/binding.cc index e5950ec74f..f38f0eb188 100644 --- a/src/binding.cc +++ b/src/binding.cc @@ -2771,6 +2771,11 @@ void v8__WasmStreaming__SetUrl(WasmStreamingSharedPtr* self, const char* url, self->inner->SetUrl(url, len); } +const v8::ArrayBuffer* v8__WasmMemoryObject__Buffer( + const v8::WasmMemoryObject& self) { + return local_to_ptr(ptr_to_local(&self)->Buffer()); +} + using HeapSnapshotCallback = bool (*)(void*, const char*, size_t); void v8__HeapProfiler__TakeHeapSnapshot(v8::Isolate* isolate, diff --git a/src/wasm.rs b/src/wasm.rs index 0c1191ba29..6414d6c487 100644 --- a/src/wasm.rs +++ b/src/wasm.rs @@ -7,9 +7,11 @@ use crate::scope::HandleScope; use crate::support::char; use crate::support::Opaque; use crate::support::UnitType; +use crate::ArrayBuffer; use crate::Isolate; use crate::Local; use crate::Value; +use crate::WasmMemoryObject; use crate::WasmModuleObject; use std::ptr::null; use std::ptr::null_mut; @@ -173,6 +175,14 @@ impl Drop for CompiledWasmModule { } } +impl WasmMemoryObject { + /// Returns underlying ArrayBuffer. + #[inline(always)] + pub fn buffer(&self) -> Local { + unsafe { Local::from_raw(v8__WasmMemoryObject__Buffer(self)) }.unwrap() + } +} + pub(crate) fn trampoline() -> extern "C" fn(*const FunctionCallbackInfo) where F: UnitType + Fn(&mut HandleScope, Local, WasmStreaming), @@ -241,4 +251,8 @@ extern "C" { length: *mut usize, ) -> *const char; fn v8__CompiledWasmModule__DELETE(this: *mut InternalCompiledWasmModule); + + fn v8__WasmMemoryObject__Buffer( + this: *const WasmMemoryObject, + ) -> *mut ArrayBuffer; }