@@ -911,6 +911,67 @@ mod tests {
911911 }
912912 }
913913
914+ #[ test]
915+ fn callable_frame_backoff_clears_on_jit_invalidation ( ) {
916+ if !native_jit_supported ( ) {
917+ return ;
918+ }
919+ let mut bc = BytecodeBuilder :: new ( ) ;
920+ let root_ip = bc. position ( ) ;
921+ bc. ldloc ( 0 ) ;
922+ bc. ldc ( 0 ) ;
923+ bc. add ( ) ;
924+ bc. stloc ( 0 ) ;
925+ bc. br ( root_ip) ;
926+ let mut program = Program :: new ( vec ! [ Value :: Int ( 1 ) ] , bc. finish ( ) ) . with_local_count ( 1 ) ;
927+ program. script_functions . push ( ScriptFunction {
928+ entry_ip : root_ip,
929+ end_ip : program. code . len ( ) as u32 ,
930+ } ) ;
931+ program. callable_prototypes . push ( CallablePrototype {
932+ kind : CallableKind :: FunctionItem ,
933+ target : CallableTarget :: ScriptFunction ( 0 ) ,
934+ arity : 0 ,
935+ frame_local_count : 1 ,
936+ parameter_slots : Vec :: new ( ) ,
937+ capture_source_slots : Vec :: new ( ) ,
938+ capture_slots : Vec :: new ( ) ,
939+ capture_modes : Vec :: new ( ) ,
940+ self_slot : None ,
941+ schema : None ,
942+ } ) ;
943+ let config = JitConfig {
944+ enabled : true ,
945+ hot_loop_threshold : 1 ,
946+ max_trace_len : 64 ,
947+ } ;
948+ let mut engine = TraceJitEngine :: new ( config) ;
949+
950+ let trace_id = engine
951+ . observe_hot_entry ( 0 , root_ip as usize , 0 , & program)
952+ . expect ( "script-frame trace should compile" ) ;
953+ for _ in 0 ..CALLABLE_SIDE_EXIT_BACKOFF_THRESHOLD {
954+ engine. record_native_side_exit ( trace_id) ;
955+ }
956+ engine. block_callable_frame ( trace_id) ;
957+ assert ! ( engine. callable_frame_is_blocked( 0 ) ) ;
958+
959+ engine. set_config ( config) ;
960+ assert ! ( !engine. callable_frame_is_blocked( 0 ) ) ;
961+
962+ let trace_id = engine
963+ . observe_hot_entry ( 0 , root_ip as usize , 0 , & program)
964+ . expect ( "script-frame trace should recompile after config invalidation" ) ;
965+ for _ in 0 ..CALLABLE_SIDE_EXIT_BACKOFF_THRESHOLD {
966+ engine. record_native_side_exit ( trace_id) ;
967+ }
968+ engine. block_callable_frame ( trace_id) ;
969+ assert ! ( engine. callable_frame_is_blocked( 0 ) ) ;
970+
971+ assert ! ( engine. set_non_yielding_host_imports( vec![ true ] ) ) ;
972+ assert ! ( !engine. callable_frame_is_blocked( 0 ) ) ;
973+ }
974+
914975 #[ test]
915976 fn trace_entry_cache_separates_root_and_script_frames ( ) {
916977 if !native_jit_supported ( ) {
0 commit comments