0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-11-25 15:29:43 -05:00

Add WasmMemoryObject::buffer method (#1128)

This commit is contained in:
Divy Srivastava 2022-11-23 08:14:37 -08:00 committed by GitHub
parent dd5fa705d4
commit 3a05ab4cd6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View file

@ -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,

View file

@ -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<ArrayBuffer> {
unsafe { Local::from_raw(v8__WasmMemoryObject__Buffer(self)) }.unwrap()
}
}
pub(crate) fn trampoline<F>() -> extern "C" fn(*const FunctionCallbackInfo)
where
F: UnitType + Fn(&mut HandleScope, Local<Value>, 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;
}