@@ -1724,10 +1724,13 @@ gen_branchif_branch(codeblock_t* cb, uint8_t* target0, uint8_t* target1, uint8_t
1724
1724
static codegen_status_t
1725
1725
gen_branchif (jitstate_t * jit , ctx_t * ctx )
1726
1726
{
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
+ }
1731
1734
1732
1735
// Test if any bit (outside of the Qnil bit) is on
1733
1736
// RUBY_Qfalse /* ...0000 0000 */
@@ -1736,8 +1739,8 @@ gen_branchif(jitstate_t* jit, ctx_t* ctx)
1736
1739
test (cb , val_opnd , imm_opnd (~Qnil ));
1737
1740
1738
1741
// 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 ;
1741
1744
blockid_t next_block = { jit -> iseq , next_idx };
1742
1745
blockid_t jump_block = { jit -> iseq , jump_idx };
1743
1746
@@ -1778,10 +1781,13 @@ gen_branchunless_branch(codeblock_t* cb, uint8_t* target0, uint8_t* target1, uin
1778
1781
static codegen_status_t
1779
1782
gen_branchunless (jitstate_t * jit , ctx_t * ctx )
1780
1783
{
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
+ }
1785
1791
1786
1792
// Test if any bit (outside of the Qnil bit) is on
1787
1793
// RUBY_Qfalse /* ...0000 0000 */
@@ -1790,8 +1796,13 @@ gen_branchunless(jitstate_t* jit, ctx_t* ctx)
1790
1796
test (cb , val_opnd , imm_opnd (~Qnil ));
1791
1797
1792
1798
// Get the branch target instruction offsets
1799
+ <<<<<<< HEAD
1793
1800
uint32_t next_idx = jit_next_idx (jit );
1794
1801
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 ))
1795
1806
blockid_t next_block = { jit -> iseq , next_idx };
1796
1807
blockid_t jump_block = { jit -> iseq , jump_idx };
1797
1808
@@ -1832,10 +1843,13 @@ gen_branchnil_branch(codeblock_t* cb, uint8_t* target0, uint8_t* target1, uint8_
1832
1843
static codegen_status_t
1833
1844
gen_branchnil (jitstate_t * jit , ctx_t * ctx )
1834
1845
{
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
+ }
1839
1853
1840
1854
// Test if the value is Qnil
1841
1855
// RUBY_Qnil /* ...0000 1000 */
@@ -1844,7 +1858,7 @@ gen_branchnil(jitstate_t* jit, ctx_t* ctx)
1844
1858
1845
1859
// Get the branch target instruction offsets
1846
1860
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 ;
1848
1862
blockid_t next_block = { jit -> iseq , next_idx };
1849
1863
blockid_t jump_block = { jit -> iseq , jump_idx };
1850
1864
@@ -1865,13 +1879,20 @@ gen_branchnil(jitstate_t* jit, ctx_t* ctx)
1865
1879
static codegen_status_t
1866
1880
gen_jump (jitstate_t * jit , ctx_t * ctx )
1867
1881
{
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
+ }
1872
1889
1873
1890
// Get the branch target instruction offsets
1891
+ <<<<<<< HEAD
1874
1892
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 ))
1875
1896
blockid_t jump_block = { jit -> iseq , jump_idx };
1876
1897
1877
1898
// Generate the jump instruction
0 commit comments