summaryrefslogtreecommitdiff
path: root/core/runtime.rs
diff options
context:
space:
mode:
Diffstat (limited to 'core/runtime.rs')
-rw-r--r--core/runtime.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/core/runtime.rs b/core/runtime.rs
index f82f06207..7cb556fd3 100644
--- a/core/runtime.rs
+++ b/core/runtime.rs
@@ -333,6 +333,9 @@ impl JsRuntime {
assert!(options.startup_snapshot.is_none());
let mut creator =
v8::SnapshotCreator::new(Some(&bindings::EXTERNAL_REFERENCES));
+ // SAFETY: `get_owned_isolate` is unsafe because it may only be called
+ // once. This is the only place we call this function, so this call is
+ // safe.
let isolate = unsafe { creator.get_owned_isolate() };
let mut isolate = JsRuntime::setup_isolate(isolate);
{
@@ -1028,6 +1031,8 @@ extern "C" fn near_heap_limit_callback<F>(
where
F: FnMut(usize, usize) -> usize,
{
+ // SAFETY: The data is a pointer to the Rust callback function. It is stored
+ // in `JsRuntime::allocations` and thus is guaranteed to outlive the isolate.
let callback = unsafe { &mut *(data as *mut F) };
callback(current_heap_limit, initial_heap_limit)
}