diff --git a/src/V8.rs b/src/V8.rs index 21b194cf19..0793c2fed7 100644 --- a/src/V8.rs +++ b/src/V8.rs @@ -27,6 +27,7 @@ unsafe extern "C" { fn v8__V8__Dispose() -> bool; fn v8__V8__DisposePlatform(); fn v8__V8__SetFatalErrorHandler(that: V8FatalErrorCallback); + fn v8__V8__EnableWebAssemblyTrapHandler(use_v8_signal_handler: bool) -> bool; } pub type V8FatalErrorCallback = unsafe extern "C" fn( @@ -281,6 +282,14 @@ pub fn set_fatal_error_handler(that: impl MapFnTo) { } } +/// Activate trap-based bounds checking for WebAssembly. +/// +/// If `use_v8_signal_handler` is true, V8 installs its own signal handler. +/// Otherwise, V8 relies on the embedder to invoke its trap handler. +pub fn enable_web_assembly_trap_handler(use_v8_signal_handler: bool) -> bool { + unsafe { v8__V8__EnableWebAssemblyTrapHandler(use_v8_signal_handler) } +} + #[cfg(test)] mod test_sandbox_use { // __IsSandboxEnabled is used for testing that sandbox is actually diff --git a/src/binding.cc b/src/binding.cc index 87e5bbd1eb..4b397e3d7e 100644 --- a/src/binding.cc +++ b/src/binding.cc @@ -159,6 +159,10 @@ void v8__V8__SetFatalErrorHandler(v8::V8FatalErrorCallback that) { v8::V8::SetFatalErrorHandler(that); } +bool v8__V8__EnableWebAssemblyTrapHandler(bool use_v8_signal_handler) { + return v8::V8::EnableWebAssemblyTrapHandler(use_v8_signal_handler); +} + v8::Isolate* v8__Isolate__New(const v8::Isolate::CreateParams& params) { return v8::Isolate::New(params); }