0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-11-21 15:04:33 -05:00

isolate->GetCppHeap() can return nullptr if no heap is attached (#1385)

Changes `v8::Isolate::get_cpp_heap` to return a `Option<&Heap>`.
This commit is contained in:
Divy Srivastava 2024-01-06 23:35:15 +05:30 committed by GitHub
parent e4cdf58665
commit 70a07c050b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 5 deletions

View file

@ -63,7 +63,7 @@ fn main() {
let obj = templ.new_instance(scope).unwrap(); let obj = templ.new_instance(scope).unwrap();
let member = v8::cppgc::make_garbage_collected( let member = v8::cppgc::make_garbage_collected(
scope.get_cpp_heap(), scope.get_cpp_heap().unwrap(),
Box::new(Wrappable { Box::new(Wrappable {
trace_count: Cell::new(0), trace_count: Cell::new(0),
id, id,

View file

@ -1100,8 +1100,8 @@ impl Isolate {
} }
} }
pub fn get_cpp_heap(&mut self) -> &Heap { pub fn get_cpp_heap(&mut self) -> Option<&Heap> {
unsafe { &*v8__Isolate__GetCppHeap(self) } unsafe { v8__Isolate__GetCppHeap(self).as_ref() }
} }
#[inline(always)] #[inline(always)]

View file

@ -59,8 +59,10 @@ fn cppgc_object_wrap() {
let obj = templ.new_instance(scope).unwrap(); let obj = templ.new_instance(scope).unwrap();
let member = let member = v8::cppgc::make_garbage_collected(
v8::cppgc::make_garbage_collected(scope.get_cpp_heap(), Box::new(Wrap)); scope.get_cpp_heap().unwrap(),
Box::new(Wrap),
);
obj.set_aligned_pointer_in_internal_field( obj.set_aligned_pointer_in_internal_field(
0, 0,