File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -708,6 +708,23 @@ impl Assembler
708708 }
709709 }
710710
711+ /// Call emit_jmp_ptr and immediately invalidate the written range.
712+ /// This is needed when next_page also moves other_cb that is not invalidated
713+ /// by compile_with_regs. Doing it here allows you to avoid invalidating a lot
714+ /// more than necessary when other_cb jumps from a position early in the page.
715+ /// This invalidates a small range of cb twice, but we accept the small cost.
716+ fn emit_jmp_ptr_with_invalidation ( cb : & mut CodeBlock , dst_ptr : CodePtr ) {
717+ #[ cfg( not( test) ) ]
718+ let start = cb. get_write_ptr ( ) ;
719+ emit_jmp_ptr ( cb, dst_ptr) ;
720+ #[ cfg( not( test) ) ]
721+ {
722+ let end = cb. get_write_ptr ( ) ;
723+ use crate :: cruby:: rb_yjit_icache_invalidate;
724+ unsafe { rb_yjit_icache_invalidate ( start. raw_ptr ( ) as _ , end. raw_ptr ( ) as _ ) } ;
725+ }
726+ }
727+
711728 // dbg!(&self.insns);
712729
713730 // List of GC offsets
@@ -1018,7 +1035,7 @@ impl Assembler
10181035 } ;
10191036
10201037 // On failure, jump to the next page and retry the current insn
1021- if !had_dropped_bytes && cb. has_dropped_bytes ( ) && cb. next_page ( src_ptr, emit_jmp_ptr ) {
1038+ if !had_dropped_bytes && cb. has_dropped_bytes ( ) && cb. next_page ( src_ptr, emit_jmp_ptr_with_invalidation ) {
10221039 // Reset cb states before retrying the current Insn
10231040 cb. set_label_state ( old_label_state) ;
10241041 } else {
You can’t perform that action at this time.
0 commit comments