mirror of
https://github.com/denoland/rusty_v8.git
synced 2025-01-14 01:50:24 -05:00
parent
f796c17791
commit
83052c4535
2 changed files with 26 additions and 10 deletions
|
@ -305,12 +305,13 @@ impl Exception {
|
||||||
message: Local<String>,
|
message: Local<String>,
|
||||||
contructor: unsafe extern "C" fn(*const String) -> *const Value,
|
contructor: unsafe extern "C" fn(*const String) -> *const Value,
|
||||||
) -> Local<'s, Value> {
|
) -> Local<'s, Value> {
|
||||||
scope.enter_isolate();
|
unsafe {
|
||||||
let error =
|
scope.enter();
|
||||||
unsafe { scope.cast_local(|_| (contructor)(&*message)) }.unwrap();
|
let error = scope.cast_local(|_| (contructor)(&*message)).unwrap();
|
||||||
scope.exit_isolate();
|
scope.exit();
|
||||||
error
|
error
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Creates an error message for the given exception.
|
/// Creates an error message for the given exception.
|
||||||
/// Will try to reconstruct the original stack trace from the exception value,
|
/// Will try to reconstruct the original stack trace from the exception value,
|
||||||
|
|
|
@ -282,6 +282,9 @@ extern "C" {
|
||||||
/// parallel in multiple threads. An isolate can be entered by at most one
|
/// parallel in multiple threads. An isolate can be entered by at most one
|
||||||
/// thread at any given time. The Locker/Unlocker API must be used to
|
/// thread at any given time. The Locker/Unlocker API must be used to
|
||||||
/// synchronize.
|
/// synchronize.
|
||||||
|
///
|
||||||
|
/// rusty_v8 note: Unlike in the C++ API, the Isolate is entered when it is
|
||||||
|
/// constructed and exited when dropped.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Isolate(Opaque);
|
pub struct Isolate(Opaque);
|
||||||
|
@ -306,6 +309,9 @@ impl Isolate {
|
||||||
let mut owned_isolate = OwnedIsolate::new(cxx_isolate);
|
let mut owned_isolate = OwnedIsolate::new(cxx_isolate);
|
||||||
ScopeData::new_root(&mut owned_isolate);
|
ScopeData::new_root(&mut owned_isolate);
|
||||||
owned_isolate.create_annex(create_param_allocations);
|
owned_isolate.create_annex(create_param_allocations);
|
||||||
|
unsafe {
|
||||||
|
owned_isolate.enter();
|
||||||
|
}
|
||||||
owned_isolate
|
owned_isolate
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,8 +448,11 @@ impl Isolate {
|
||||||
/// Sets this isolate as the entered one for the current thread.
|
/// Sets this isolate as the entered one for the current thread.
|
||||||
/// Saves the previously entered one (if any), so that it can be
|
/// Saves the previously entered one (if any), so that it can be
|
||||||
/// restored when exiting. Re-entering an isolate is allowed.
|
/// restored when exiting. Re-entering an isolate is allowed.
|
||||||
pub(crate) fn enter_isolate(&mut self) {
|
///
|
||||||
unsafe { v8__Isolate__Enter(self) }
|
/// rusty_v8 note: Unlike in the C++ API, the isolate is entered when it is
|
||||||
|
/// constructed and exited when dropped.
|
||||||
|
pub unsafe fn enter(&mut self) {
|
||||||
|
v8__Isolate__Enter(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Exits this isolate by restoring the previously entered one in the
|
/// Exits this isolate by restoring the previously entered one in the
|
||||||
|
@ -451,8 +460,11 @@ impl Isolate {
|
||||||
/// entered more than once.
|
/// entered more than once.
|
||||||
///
|
///
|
||||||
/// Requires: self == Isolate::GetCurrent().
|
/// Requires: self == Isolate::GetCurrent().
|
||||||
pub(crate) fn exit_isolate(&mut self) {
|
///
|
||||||
unsafe { v8__Isolate__Exit(self) }
|
/// rusty_v8 note: Unlike in the C++ API, the isolate is entered when it is
|
||||||
|
/// constructed and exited when dropped.
|
||||||
|
pub unsafe fn exit(&mut self) {
|
||||||
|
v8__Isolate__Exit(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Clears the set of objects held strongly by the heap. This set of
|
/// Clears the set of objects held strongly by the heap. This set of
|
||||||
|
@ -860,7 +872,10 @@ impl OwnedIsolate {
|
||||||
|
|
||||||
impl Drop for OwnedIsolate {
|
impl Drop for OwnedIsolate {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe { self.cxx_isolate.as_mut().dispose() }
|
unsafe {
|
||||||
|
self.exit();
|
||||||
|
self.cxx_isolate.as_mut().dispose()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue