@@ -407,7 +407,7 @@ pub type CompiledWasmModuleStore = CrossIsolateStore<v8::CompiledWasmModule>;
407407/// Internal state for JsRuntime which is stored in one of v8::Isolate's
408408/// embedder slots.
409409pub struct JsRuntimeState {
410- pub ( crate ) source_mapper : RefCell < SourceMapper < Rc < dyn SourceMapGetter > > > ,
410+ pub ( crate ) source_mapper : RefCell < SourceMapper > ,
411411 pub ( crate ) op_state : Rc < RefCell < OpState > > ,
412412 pub ( crate ) shared_array_buffer_store : Option < SharedArrayBufferStore > ,
413413 pub ( crate ) compiled_wasm_module_store : Option < CompiledWasmModuleStore > ,
@@ -672,8 +672,7 @@ impl JsRuntime {
672672
673673 // Load the sources and source maps
674674 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 ) ;
677676 let mut sources = extension_set:: into_sources (
678677 options. extension_transpiler . as_deref ( ) ,
679678 & extensions,
@@ -775,9 +774,9 @@ impl JsRuntime {
775774 ) ) ) ;
776775
777776 let external_refs: & v8:: ExternalReferences =
778- isolate_allocations. external_refs . as_ref ( ) . unwrap ( ) . as_ref ( ) ;
777+ isolate_allocations. external_refs . as_ref ( ) . unwrap ( ) ;
779778 // 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 _ ) } ;
781780
782781 let has_snapshot = maybe_startup_snapshot. is_some ( ) ;
783782 let mut isolate = setup:: create_isolate (
@@ -1073,23 +1072,6 @@ impl JsRuntime {
10731072 self . inner . main_realm . handle_scope ( isolate)
10741073 }
10751074
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-
10931075 /// Create a synthetic module - `ext:core/ops` - that exports all ops registered
10941076 /// with the runtime.
10951077 fn execute_virtual_ops_module (
@@ -1731,12 +1713,13 @@ impl JsRuntime {
17311713 cx : & mut Context ,
17321714 poll_options : PollEventLoopOptions ,
17331715 ) -> 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)
17401723 }
17411724
17421725 fn poll_event_loop_inner (
0 commit comments