@@ -774,9 +774,9 @@ impl JsRuntime {
774774 ) ) ) ;
775775
776776 let external_refs: & v8:: ExternalReferences =
777- isolate_allocations. external_refs . as_ref ( ) . unwrap ( ) . as_ref ( ) ;
777+ isolate_allocations. external_refs . as_ref ( ) . unwrap ( ) ;
778778 // SAFETY: We attach external_refs to IsolateAllocations which will live as long as the isolate
779- let external_refs_static = unsafe { std :: mem :: transmute ( external_refs) } ;
779+ let external_refs_static = unsafe { & * ( external_refs as * const _ ) } ;
780780
781781 let has_snapshot = maybe_startup_snapshot. is_some ( ) ;
782782 let mut isolate = setup:: create_isolate (
@@ -1067,23 +1067,6 @@ impl JsRuntime {
10671067 self . inner . main_realm . handle_scope ( isolate)
10681068 }
10691069
1070- #[ inline( always) ]
1071- /// Create a scope on the stack with the given context
1072- fn with_context_scope < ' s , T > (
1073- isolate : * mut v8:: Isolate ,
1074- context : * mut v8:: Context ,
1075- f : impl FnOnce ( & mut v8:: HandleScope < ' s > ) -> T ,
1076- ) -> T {
1077- // SAFETY: We know this isolate is valid and non-null at this time
1078- let mut isolate_scope =
1079- v8:: HandleScope :: new ( unsafe { isolate. as_mut ( ) . unwrap_unchecked ( ) } ) ;
1080- // SAFETY: We know the context is valid and non-null at this time, and that a Local and pointer share the
1081- // same representation
1082- let context = unsafe { std:: mem:: transmute ( context) } ;
1083- let mut scope = v8:: ContextScope :: new ( & mut isolate_scope, context) ;
1084- f ( & mut scope)
1085- }
1086-
10871070 /// Create a synthetic module - `ext:core/ops` - that exports all ops registered
10881071 /// with the runtime.
10891072 fn execute_virtual_ops_module (
@@ -1725,12 +1708,13 @@ impl JsRuntime {
17251708 cx : & mut Context ,
17261709 poll_options : PollEventLoopOptions ,
17271710 ) -> Poll < Result < ( ) , Error > > {
1728- let isolate = self . v8_isolate_ptr ( ) ;
1729- Self :: with_context_scope (
1730- isolate,
1731- self . inner . main_realm . context_ptr ( ) ,
1732- move |scope| self . poll_event_loop_inner ( cx, scope, poll_options) ,
1733- )
1711+ // SAFETY: We know this isolate is valid and non-null at this time
1712+ let mut isolate_scope =
1713+ v8:: HandleScope :: new ( unsafe { & mut * self . v8_isolate_ptr ( ) } ) ;
1714+ let context =
1715+ v8:: Local :: new ( & mut isolate_scope, self . inner . main_realm . context ( ) ) ;
1716+ let mut scope = v8:: ContextScope :: new ( & mut isolate_scope, context) ;
1717+ self . poll_event_loop_inner ( cx, & mut scope, poll_options)
17341718 }
17351719
17361720 fn poll_event_loop_inner (
0 commit comments