@@ -407,7 +407,7 @@ pub type CompiledWasmModuleStore = CrossIsolateStore<v8::CompiledWasmModule>;
407
407
/// Internal state for JsRuntime which is stored in one of v8::Isolate's
408
408
/// embedder slots.
409
409
pub struct JsRuntimeState {
410
- pub ( crate ) source_mapper : RefCell < SourceMapper < Rc < dyn SourceMapGetter > > > ,
410
+ pub ( crate ) source_mapper : RefCell < SourceMapper > ,
411
411
pub ( crate ) op_state : Rc < RefCell < OpState > > ,
412
412
pub ( crate ) shared_array_buffer_store : Option < SharedArrayBufferStore > ,
413
413
pub ( crate ) compiled_wasm_module_store : Option < CompiledWasmModuleStore > ,
@@ -672,8 +672,7 @@ impl JsRuntime {
672
672
673
673
// Load the sources and source maps
674
674
let mut files_loaded = Vec :: with_capacity ( 128 ) ;
675
- let mut source_mapper: SourceMapper < Rc < dyn SourceMapGetter > > =
676
- SourceMapper :: new ( options. source_map_getter ) ;
675
+ let mut source_mapper = SourceMapper :: new ( options. source_map_getter ) ;
677
676
let mut sources = extension_set:: into_sources (
678
677
options. extension_transpiler . as_deref ( ) ,
679
678
& extensions,
@@ -775,9 +774,9 @@ impl JsRuntime {
775
774
) ) ) ;
776
775
777
776
let external_refs: & v8:: ExternalReferences =
778
- isolate_allocations. external_refs . as_ref ( ) . unwrap ( ) . as_ref ( ) ;
777
+ isolate_allocations. external_refs . as_ref ( ) . unwrap ( ) ;
779
778
// SAFETY: We attach external_refs to IsolateAllocations which will live as long as the isolate
780
- let external_refs_static = unsafe { std :: mem :: transmute ( external_refs) } ;
779
+ let external_refs_static = unsafe { & * ( external_refs as * const _ ) } ;
781
780
782
781
let has_snapshot = maybe_startup_snapshot. is_some ( ) ;
783
782
let mut isolate = setup:: create_isolate (
@@ -1073,23 +1072,6 @@ impl JsRuntime {
1073
1072
self . inner . main_realm . handle_scope ( isolate)
1074
1073
}
1075
1074
1076
- #[ inline( always) ]
1077
- /// Create a scope on the stack with the given context
1078
- fn with_context_scope < ' s , T > (
1079
- isolate : * mut v8:: Isolate ,
1080
- context : * mut v8:: Context ,
1081
- f : impl FnOnce ( & mut v8:: HandleScope < ' s > ) -> T ,
1082
- ) -> T {
1083
- // SAFETY: We know this isolate is valid and non-null at this time
1084
- let mut isolate_scope =
1085
- v8:: HandleScope :: new ( unsafe { isolate. as_mut ( ) . unwrap_unchecked ( ) } ) ;
1086
- // SAFETY: We know the context is valid and non-null at this time, and that a Local and pointer share the
1087
- // same representation
1088
- let context = unsafe { std:: mem:: transmute ( context) } ;
1089
- let mut scope = v8:: ContextScope :: new ( & mut isolate_scope, context) ;
1090
- f ( & mut scope)
1091
- }
1092
-
1093
1075
/// Create a synthetic module - `ext:core/ops` - that exports all ops registered
1094
1076
/// with the runtime.
1095
1077
fn execute_virtual_ops_module (
@@ -1731,12 +1713,13 @@ impl JsRuntime {
1731
1713
cx : & mut Context ,
1732
1714
poll_options : PollEventLoopOptions ,
1733
1715
) -> Poll < Result < ( ) , Error > > {
1734
- let isolate = self . v8_isolate_ptr ( ) ;
1735
- Self :: with_context_scope (
1736
- isolate,
1737
- self . inner . main_realm . context_ptr ( ) ,
1738
- move |scope| self . poll_event_loop_inner ( cx, scope, poll_options) ,
1739
- )
1716
+ // SAFETY: We know this isolate is valid and non-null at this time
1717
+ let mut isolate_scope =
1718
+ v8:: HandleScope :: new ( unsafe { & mut * self . v8_isolate_ptr ( ) } ) ;
1719
+ let context =
1720
+ v8:: Local :: new ( & mut isolate_scope, self . inner . main_realm . context ( ) ) ;
1721
+ let mut scope = v8:: ContextScope :: new ( & mut isolate_scope, context) ;
1722
+ self . poll_event_loop_inner ( cx, & mut scope, poll_options)
1740
1723
}
1741
1724
1742
1725
fn poll_event_loop_inner (
0 commit comments