@@ -1722,10 +1722,13 @@ gen_branchif_branch(codeblock_t* cb, uint8_t* target0, uint8_t* target1, uint8_t
1722
1722
static codegen_status_t
1723
1723
gen_branchif (jitstate_t * jit , ctx_t * ctx )
1724
1724
{
1725
- // FIXME: eventually, put VM_CHECK_INTS() only on backward branch targets
1726
- // Check for interrupts
1727
- uint8_t * side_exit = yjit_side_exit (jit , ctx );
1728
- yjit_check_ints (cb , side_exit );
1725
+ int32_t jump_offset = (int32_t )jit_get_arg (jit , 0 );
1726
+
1727
+ // Check for interrupts, but only on backward branches that may create loops
1728
+ if (jump_offset < 0 ) {
1729
+ uint8_t * side_exit = yjit_side_exit (jit , ctx );
1730
+ yjit_check_ints (cb , side_exit );
1731
+ }
1729
1732
1730
1733
// Test if any bit (outside of the Qnil bit) is on
1731
1734
// RUBY_Qfalse /* ...0000 0000 */
@@ -1735,7 +1738,7 @@ gen_branchif(jitstate_t* jit, ctx_t* ctx)
1735
1738
1736
1739
// Get the branch target instruction offsets
1737
1740
uint32_t next_idx = jit_next_insn_idx (jit );
1738
- uint32_t jump_idx = next_idx + ( uint32_t ) jit_get_arg ( jit , 0 ) ;
1741
+ uint32_t jump_idx = next_idx + jump_offset ;
1739
1742
blockid_t next_block = { jit -> iseq , next_idx };
1740
1743
blockid_t jump_block = { jit -> iseq , jump_idx };
1741
1744
@@ -1776,10 +1779,13 @@ gen_branchunless_branch(codeblock_t* cb, uint8_t* target0, uint8_t* target1, uin
1776
1779
static codegen_statu
8000
s_t
1777
1780
gen_branchunless (jitstate_t * jit , ctx_t * ctx )
1778
1781
{
1779
- // FIXME: eventually, put VM_CHECK_INTS() only on backward branch targets
1780
- // Check for interrupts
1781
- uint8_t * side_exit = yjit_side_exit (jit , ctx );
1782
- yjit_check_ints (cb , side_exit );
1782
+ int32_t jump_offset = (int32_t )jit_get_arg (jit , 0 );
1783
+
1784
+ // Check for interrupts, but only on backward branches that may create loops
1785
+ if (jump_offset < 0 ) {
1786
+ uint8_t * side_exit = yjit_side_exit (jit , ctx );
1787
+ yjit_check_ints (cb , side_exit );
1788
+ }
1783
1789
1784
1790
// Test if any bit (outside of the Qnil bit) is on
1785
1791
// RUBY_Qfalse /* ...0000 0000 */
@@ -1789,7 +1795,7 @@ gen_branchunless(jitstate_t* jit, ctx_t* ctx)
1789
1795
1790
1796
// Get the branch target instruction offsets
1791
1797
uint32_t next_idx = jit_next_insn_idx (jit );
1792
- uint32_t jump_idx = next_idx + ( uint32_t ) jit_get_arg ( jit , 0 ) ;
1798
+ uint32_t jump_idx = next_idx + jump_offset ;
1793
1799
blockid_t next_block = { jit -> iseq , next_idx };
1794
1800
blockid_t jump_block = { jit -> iseq , jump_idx };
1795
1801
@@ -1830,10 +1836,13 @@ gen_branchnil_branch(codeblock_t* cb, uint8_t* target0, uint8_t* target1, uint8_
1830
1836
static codegen_status_t
1831
1837
gen_branchnil (jitstate_t * jit , ctx_t * ctx )
1832
1838
{
1833
- // FIXME: eventually, put VM_CHECK_INTS() only on backward branch targets
1834
- // Check for interrupts
1835
- uint8_t * side_exit = yjit_side_exit (jit , ctx );
1836
- yjit_check_ints (cb , side_exit );
1839
+ int32_t jump_offset = (int32_t )jit_get_arg (jit , 0 );
1840
+
1841
+ // Check for interrupts, but only on backward branches that may create loops
1842
+ if (jump_offset < 0 ) {
1843
+ uint8_t * side_exit = yjit_side_exit (jit , ctx );
1844
+ yjit_check_ints (cb , side_exit );
1845
+ }
1837
1846
1838
1847
// Test if the value is Qnil
1839
1848
// RUBY_Qnil /* ...0000 1000 */
@@ -1842,7 +1851,7 @@ gen_branchnil(jitstate_t* jit, ctx_t* ctx)
1842
1851
1843
1852
// Get the branch target instruction offsets
1844
1853
uint32_t next_idx = jit_next_insn_idx (jit );
1845
- uint32_t jump_idx = next_idx + ( uint32_t ) jit_get_arg ( jit , 0 ) ;
1854
+ uint32_t jump_idx = next_idx + jump_offset ;
1846
1855
blockid_t next_block = { jit -> iseq , next_idx };
1847
1856
blockid_t jump_block = { jit -> iseq , jump_idx };
1848
1857
@@ -1863,13 +1872,16 @@ gen_branchnil(jitstate_t* jit, ctx_t* ctx)
1863
1872
static codegen_status_t
1864
1873
gen_jump (jitstate_t * jit , ctx_t * ctx )
1865
1874
{
1866
- // FIXME: eventually, put VM_CHECK_INTS() only on backward branch targets
1867
- // Check for interrupts
1868
- uint8_t * side_exit = yjit_side_exit (jit , ctx );
1869
- yjit_check_ints (cb , side_exit );
1875
+ int32_t jump_offset = (int32_t )jit_get_arg (jit , 0 );
1876
+
1877
+ // Check for interrupts, but only on backward branches that may create loops
1878
+ if (jump_offset < 0 ) {
1879
+ uint8_t * side_exit = yjit_side_exit (jit , ctx );
1880
+ yjit_check_ints (cb , side_exit );
1881
+ }
1870
1882
1871
1883
// Get the branch target instruction offsets
1872
- uint32_t jump_idx = jit_next_insn_idx (jit ) + ( int32_t ) jit_get_arg ( jit , 0 ) ;
1884
+ uint32_t jump_idx = jit_next_insn_idx (jit ) + jump_offset ;
1873
1885
blockid_t jump_block = { jit -> iseq , jump_idx };
1874
1886
1875
1887
// Generate the jump instruction
0 commit comments