@@ -1724,10 +1724,13 @@ gen_branchif_branch(codeblock_t* cb, uint8_t* target0, uint8_t* target1, uint8_t
17241724static codegen_status_t
17251725gen_branchif (jitstate_t * jit , ctx_t * ctx )
17261726{
1727- // FIXME: eventually, put VM_CHECK_INTS() only on backward branch targets
1728- // Check for interrupts
1729- uint8_t * side_exit = yjit_side_exit (jit , ctx );
1730- yjit_check_ints (cb , side_exit );
1727+ int32_t jump_offset = (int32_t )jit_get_arg (jit , 0 );
1728+
1729+ // Check for interrupts, but only on backward branches that may create loops
1730+ if (jump_offset < 0 ) {
1731+ uint8_t * side_exit = yjit_side_exit (jit , ctx );
1732+ yjit_check_ints (cb , side_exit );
1733+ }
17311734
17321735 // Test if any bit (outside of the Qnil bit) is on
17331736 // RUBY_Qfalse /* ...0000 0000 */
@@ -1736,8 +1739,8 @@ gen_branchif(jitstate_t* jit, ctx_t* ctx)
17361739 test (cb , val_opnd , imm_opnd (~Qnil ));
17371740
17381741 // Get the branch target instruction offsets
1739- uint32_t next_idx = jit_next_idx (jit );
1740- uint32_t jump_idx = next_idx + ( uint32_t ) jit_get_arg ( jit , 0 ) ;
1742+ uint32_t next_idx = jit_next_insn_idx (jit );
1743+ uint32_t jump_idx = next_idx + jump_offset ;
17411744 blockid_t next_block = { jit -> iseq , next_idx };
17421745 blockid_t jump_block = { jit -> iseq , jump_idx };
17431746
@@ -1778,10 +1781,13 @@ gen_branchunless_branch(codeblock_t* cb, uint8_t* target0, uint8_t* target1, uin
17781781static codegen_status_t
17791782gen_branchunless (jitstate_t * jit , ctx_t * ctx )
17801783{
1781- // FIXME: eventually, put VM_CHECK_INTS() only on backward branch targets
1782- // Check for interrupts
1783- uint8_t * side_exit = yjit_side_exit (jit , ctx );
1784- yjit_check_ints (cb , side_exit );
1784+ int32_t jump_offset = (int32_t )jit_get_arg (jit , 0 );
1785+
1786+ // Check for interrupts, but only on backward branches that may create loops
1787+ if (jump_offset < 0 ) {
1788+ uint8_t * side_exit = yjit_side_exit (jit , ctx );
1789+ yjit_check_ints (cb , side_exit );
1790+ }
17851791
17861792 // Test if any bit (outside of the Qnil bit) is on
17871793 // RUBY_Qfalse /* ...0000 0000 */
@@ -1790,8 +1796,13 @@ gen_branchunless(jitstate_t* jit, ctx_t* ctx)
17901796 test (cb , val_opnd , imm_opnd (~Qnil ));
17911797
17921798 // Get the branch target instruction offsets
1799+ <<<<<<< HEAD
17931800 uint32_t next_idx = jit_next_idx (jit );
17941801 uint32_t jump_idx = next_idx + (uint32_t )jit_get_arg (jit , 0 );
1802+ = == == ==
1803+ uint32_t next_idx = jit_next_insn_idx (jit );
1804+ uint32_t jump_idx = next_idx + jump_offset ;
1805+ >>>>>>> ef0d1ca495 (Avoid interrupt checks for forward branches (#41 ))
17951806 blockid_t next_block = { jit -> iseq , next_idx };
17961807 blockid_t jump_block = { jit -> iseq , jump_idx };
17971808
@@ -1832,10 +1843,13 @@ gen_branchnil_branch(codeblock_t* cb, uint8_t* target0, uint8_t* target1, uint8_
18321843static codegen_status_t
18331844gen_branchnil (jitstate_t * jit , ctx_t * ctx )
18341845{
1835- // FIXME: eventually, put VM_CHECK_INTS() only on backward branch targets
1836- // Check for interrupts
1837- uint8_t * side_exit = yjit_side_exit (jit , ctx );
1838- yjit_check_ints (cb , side_exit );
1846+ int32_t jump_offset = (int32_t )jit_get_arg (jit , 0 );
1847+
1848+ // Check for interrupts, but only on backward branches that may create loops
1849+ if (jump_offset < 0 ) {
1850+ uint8_t * side_exit = yjit_side_exit (jit , ctx );
1851+ yjit_check_ints (cb , side_exit );
1852+ }
18391853
18401854 // Test if the value is Qnil
18411855 // RUBY_Qnil /* ...0000 1000 */
@@ -1844,7 +1858,7 @@ gen_branchnil(jitstate_t* jit, ctx_t* ctx)
18441858
18451859 // Get the branch target instruction offsets
18461860 uint32_t next_idx = jit_next_insn_idx (jit );
1847- uint32_t jump_idx = next_idx + ( uint32_t ) jit_get_arg ( jit , 0 ) ;
1861+ uint32_t jump_idx = next_idx + jump_offset ;
18481862 blockid_t next_block = { jit -> iseq , next_idx };
18491863 blockid_t jump_block = { jit -> iseq , jump_idx };
18501864
@@ -1865,13 +1879,20 @@ gen_branchnil(jitstate_t* jit, ctx_t* ctx)
18651879static codegen_status_t
18661880gen_jump (jitstate_t * jit , ctx_t * ctx )
18671881{
1868- // FIXME: eventually, put VM_CHECK_INTS() only on backward branch targets
1869- // Check for interrupts
1870- uint8_t * side_exit = yjit_side_exit (jit , ctx );
1871- yjit_check_ints (cb , side_exit );
1882+ int32_t jump_offset = (int32_t )jit_get_arg (jit , 0 );
1883+
1884+ // Check for interrupts, but only on backward branches that may create loops
1885+ if (jump_offset < 0 ) {
1886+ uint8_t * side_exit = yjit_side_exit (jit , ctx );
1887+ yjit_check_ints (cb , side_exit );
1888+ }
18721889
18731890 // Get the branch target instruction offsets
1891+ <<<<<<< HEAD
18741892 uint32_t jump_idx = jit_next_idx (jit ) + (int32_t )jit_get_arg (jit , 0 );
1893+ = == == ==
1894+ uint32_t jump_idx = jit_next_insn_idx (jit ) + jump_offset ;
1895+ >>>>>>> ef0d1ca495 (Avoid interrupt checks for forward branches (#41 ))
18751896 blockid_t jump_block = { jit -> iseq , jump_idx };
18761897
18771898 // Generate the jump instruction
0 commit comments