File tree Expand file tree Collapse file tree 3 files changed +21
-7
lines changed
Expand file tree Collapse file tree 3 files changed +21
-7
lines changed Original file line number Diff line number Diff line change @@ -703,8 +703,7 @@ impl Assembler
703703 // For each instruction
704704 let start_write_pos = cb. get_write_pos ( ) ;
705705 let mut i: usize = 0 ;
706- while i < self . insns . len ( ) {
707- let insn = & self . insns [ i] ;
706+ while let Some ( insn) = self . insns . get ( i) {
708707 let had_dropped_bytes = cb. has_dropped_bytes ( ) ;
709708 let src_ptr = cb. get_write_ptr ( ) ;
710709 match insn {
@@ -1003,7 +1002,7 @@ impl Assembler
10031002 }
10041003 } ;
10051004
1006- // On failure, jump to the next page and retry the last insn
1005+ // On failure, jump to the next page and retry the current insn
10071006 if !had_dropped_bytes && cb. has_dropped_bytes ( ) && cb. next_page ( None ) {
10081007 let dst_ptr = cb. get_write_ptr ( ) ;
10091008 cb. set_write_ptr ( src_ptr) ;
Original file line number Diff line number Diff line change @@ -253,7 +253,7 @@ fn test_jcc_ptr()
253253{
254254 let ( mut asm, mut cb) = setup_asm ( ) ;
255255
256- let side_exit = Target :: CodePtr ( ( 5 as * mut u8 ) . into ( ) ) ;
256+ let side_exit = Target :: CodePtr ( ( ( cb . get_write_ptr ( ) . raw_ptr ( ) as usize + 5 ) as * mut u8 ) . into ( ) ) ;
257257 let not_mask = asm. not ( Opnd :: mem ( 32 , EC , RUBY_OFFSET_EC_INTERRUPT_MASK ) ) ;
258258 asm. test (
259259 Opnd :: mem ( 32 , EC , RUBY_OFFSET_EC_INTERRUPT_FLAG ) ,
@@ -270,7 +270,7 @@ fn test_jmp_ptr()
270270{
271271 let ( mut asm, mut cb) = setup_asm ( ) ;
272272
273- let stub = Target :: CodePtr ( ( 5 as * mut u8 ) . into ( ) ) ;
273+ let stub = Target :: CodePtr ( ( ( cb . get_write_ptr ( ) . raw_ptr ( ) as usize + 5 ) as * mut u8 ) . into ( ) ) ;
274274 asm. jmp ( stub) ;
275275
276276 asm. compile_with_num_regs ( & mut cb, 0 ) ;
@@ -281,7 +281,7 @@ fn test_jo()
281281{
282282 let ( mut asm, mut cb) = setup_asm ( ) ;
283283
284- let side_exit = Target :: CodePtr ( ( 5 as * mut u8 ) . into ( ) ) ;
284+ let side_exit = Target :: CodePtr ( ( ( cb . get_write_ptr ( ) . raw_ptr ( ) as usize + 5 ) as * mut u8 ) . into ( ) ) ;
285285
286286 let arg1 = Opnd :: mem ( 64 , SP , 0 ) ;
287287 let arg0 = Opnd :: mem ( 64 , SP , 8 ) ;
Original file line number Diff line number Diff line change @@ -372,7 +372,10 @@ impl Assembler
372372
373373 // For each instruction
374374 let start_write_pos = cb. get_write_pos ( ) ;
375- for insn in & self . insns {
375+ let mut i: usize = 0 ;
376+ while let Some ( insn) = self . insns . get ( i) {
377+ let had_dropped_bytes = cb. has_dropped_bytes ( ) ;
378+ let src_ptr = cb. get_write_ptr ( ) ;
376379 match insn {
377380 Insn :: Comment ( text) => {
378381 if cfg ! ( feature = "asm_comments" ) {
@@ -662,6 +665,18 @@ impl Assembler
662665 // instructions can never make it to the emit stage.
663666 _ => panic ! ( "unsupported instruction passed to x86 backend: {:?}" , insn)
664667 } ;
668+
669+ // On failure, jump to the next page and retry the current insn
670+ if !had_dropped_bytes && cb. has_dropped_bytes ( ) && cb. next_page ( None ) {
671+ let dst_ptr = cb. get_write_ptr ( ) ;
672+ cb. set_write_ptr ( src_ptr) ;
673+ cb. without_page_end_reserve ( |cb| {
674+ jmp_ptr ( cb, dst_ptr) ;
675+ } ) ;
676+ cb. set_write_ptr ( dst_ptr) ;
677+ } else {
678+ i += 1 ;
679+ }
665680 }
666681
667682 gc_offsets
You can’t perform that action at this time.
0 commit comments