@@ -468,17 +468,6 @@ pub(crate) fn generate_dispatch_fast(
468
468
quote ! ( )
469
469
} ;
470
470
471
- let with_isolate = if generator_state. needs_fast_isolate
472
- && !generator_state. needs_fast_scope
473
- {
474
- generator_state. needs_opctx = true ;
475
- gs_quote ! ( generator_state( opctx, scope) =>
476
- ( let mut #scope = unsafe { & mut * #opctx. isolate } ; )
477
- )
478
- } else {
479
- quote ! ( )
480
- } ;
481
-
482
471
let with_opctx = if generator_state. needs_opctx {
483
472
generator_state. needs_fast_api_callback_options = true ;
484
473
gs_quote ! ( generator_state( opctx, fast_api_callback_options) => {
@@ -492,15 +481,13 @@ pub(crate) fn generate_dispatch_fast(
492
481
} ;
493
482
494
483
let with_self = if generator_state. needs_self {
495
- generator_state. needs_fast_api_callback_options = true ;
484
+ generator_state. needs_fast_isolate = true ;
496
485
let throw_exception = throw_type_error (
497
486
generator_state,
498
487
format ! ( "expected {}" , & generator_state. self_ty) ,
499
488
) ;
500
- gs_quote ! ( generator_state( self_ty, fast_api_callback_options) => {
501
- // SAFETY: Isolate is valid if this function is being called.
502
- let isolate = unsafe { & mut * #fast_api_callback_options. isolate } ;
503
- let Some ( self_) = deno_core:: _ops:: try_unwrap_cppgc_object:: <#self_ty>( isolate, this. into( ) ) else {
489
+ gs_quote ! ( generator_state( self_ty, scope) => {
490
+ let Some ( self_) = deno_core:: _ops:: try_unwrap_cppgc_object:: <#self_ty>( & mut #scope, this. into( ) ) else {
504
491
#throw_exception
505
492
} ;
506
493
let self_ = & * self_;
@@ -509,6 +496,17 @@ pub(crate) fn generate_dispatch_fast(
509
496
quote ! ( )
510
497
} ;
511
498
499
+ let with_isolate = if generator_state. needs_fast_isolate
500
+ && !generator_state. needs_fast_scope
501
+ && !generator_state. needs_stack_trace
502
+ {
503
+ generator_state. needs_fast_api_callback_options = true ;
504
+ gs_quote ! ( generator_state( scope, fast_api_callback_options) =>
505
+ ( let mut #scope = unsafe { & mut * #fast_api_callback_options. isolate } ; )
506
+ )
507
+ } else {
508
+ quote ! ( )
509
+ } ;
512
510
let with_scope = if generator_state. needs_scope {
513
511
let create_scope = create_scope ( generator_state) ;
514
512
gs_quote ! ( generator_state( scope) => {
@@ -591,8 +589,8 @@ pub(crate) fn generate_dispatch_fast(
591
589
#with_opstate;
592
590
#with_stack_trace
593
591
#with_js_runtime_state
594
- #with_self
595
592
#with_isolate
593
+ #with_self
596
594
let #result = {
597
595
#( #call_args) *
598
596
#call ( #( #call_names) , * )
@@ -632,6 +630,7 @@ fn map_v8_fastcall_arg_to_arg(
632
630
needs_scope,
633
631
needs_opctx,
634
632
needs_fast_api_callback_options,
633
+ needs_fast_isolate,
635
634
needs_js_runtime_state,
636
635
..
637
636
} = generator_state;
@@ -799,13 +798,11 @@ fn map_v8_fastcall_arg_to_arg(
799
798
let ty =
800
799
syn:: parse_str :: < syn:: Path > ( ty) . expect ( "Failed to reparse state type" ) ;
801
800
802
- * needs_fast_api_callback_options = true ;
801
+ * needs_fast_isolate = true ;
803
802
let throw_exception =
804
803
throw_type_error ( generator_state, format ! ( "expected {ty:?}" ) ) ;
805
- gs_quote ! ( generator_state( fast_api_callback_options) => {
806
- // SAFETY: Isolate is valid if this function is being called.
807
- let isolate = unsafe { & mut * #fast_api_callback_options. isolate } ;
808
- let Some ( #arg_ident) = deno_core:: _ops:: try_unwrap_cppgc_object:: <#ty>( isolate, #arg_ident) else {
804
+ gs_quote ! ( generator_state( scope) => {
805
+ let Some ( #arg_ident) = deno_core:: _ops:: try_unwrap_cppgc_object:: <#ty>( & mut #scope, #arg_ident) else {
809
806
#throw_exception
810
807
} ;
811
808
let #arg_ident = & * #arg_ident;
@@ -815,15 +812,13 @@ fn map_v8_fastcall_arg_to_arg(
815
812
let ty =
816
813
syn:: parse_str :: < syn:: Path > ( ty) . expect ( "Failed to reparse state type" ) ;
817
814
818
- * needs_fast_api_callback_options = true ;
815
+ * needs_fast_isolate = true ;
819
816
let throw_exception =
820
817
throw_type_error ( generator_state, format ! ( "expected {ty:?}" ) ) ;
821
- gs_quote ! ( generator_state( fast_api_callback_options) => {
822
- // SAFETY: Isolate is valid if this function is being called.
823
- let isolate = unsafe { & mut * #fast_api_callback_options. isolate } ;
818
+ gs_quote ! ( generator_state( scope) => {
824
819
let #arg_ident = if #arg_ident. is_null_or_undefined( ) {
825
820
None
826
- } else if let Some ( #arg_ident) = deno_core:: _ops:: try_unwrap_cppgc_object:: <#ty>( isolate , #arg_ident) {
821
+ } else if let Some ( #arg_ident) = deno_core:: _ops:: try_unwrap_cppgc_object:: <#ty>( & mut #scope , #arg_ident) {
827
822
Some ( #arg_ident)
828
823
} else {
829
824
#throw_exception
0 commit comments