Fix: SnapshotCreator's internal Isolate does not get initialized (#371)

This commit is contained in:
Bert Belder 2020-05-06 19:26:23 +02:00
parent f242d17732
commit 6638b05096
No known key found for this signature in database
GPG Key ID: 7A77887B2E2ED461
3 changed files with 12 additions and 3 deletions

View File

@ -159,10 +159,14 @@ impl Isolate {
IsolateHandle::new(self)
}
fn create_annex(&mut self, create_param_allocations: Box<dyn Any>) {
pub(crate) fn create_annex(
&mut self,
create_param_allocations: Box<dyn Any>,
) {
let annex_arc = Arc::new(IsolateAnnex::new(self, create_param_allocations));
let annex_ptr = Arc::into_raw(annex_arc);
unsafe { v8__Isolate__SetData(self, 0, annex_ptr as *mut c_void) }
unsafe { assert!(v8__Isolate__GetData(self, 0).is_null()) };
unsafe { v8__Isolate__SetData(self, 0, annex_ptr as *mut c_void) };
}
fn get_annex(&self) -> &IsolateAnnex {

View File

@ -133,6 +133,8 @@ impl SnapshotCreator {
// revisited after the libdeno integration is complete.
pub unsafe fn get_owned_isolate(&mut self) -> OwnedIsolate {
let isolate_ptr = v8__SnapshotCreator__GetIsolate(self);
OwnedIsolate::new(isolate_ptr)
let mut owned_isolate = OwnedIsolate::new(isolate_ptr);
owned_isolate.create_annex(Box::new(()));
owned_isolate
}
}

View File

@ -1761,6 +1761,9 @@ fn snapshot_creator() {
// the scope type system.
let mut isolate = unsafe { snapshot_creator.get_owned_isolate() };
// Check that the SnapshotCreator isolate has been set up correctly.
let _ = isolate.thread_safe_handle();
let mut hs = v8::HandleScope::new(&mut isolate);
let scope = hs.enter();