Skip to content
  • Alan Wu's avatar
    f41b4d44
    YJIT: Bounds check every byte in the assembler · f41b4d44
    Alan Wu authored
    
    
    Previously, YJIT assumed that basic blocks never consume more than
    1 KiB of memory. This assumption does not hold for long Ruby methods
    such as the one in the following:
    
    ```ruby
    eval(<<RUBY)
    def set_local_a_lot
      #{'_=0;'*0x40000}
    end
    RUBY
    
    set_local_a_lot
    ```
    
    For low `--yjit-exec-mem-size` values, one basic block could exhaust the
    entire buffer.
    
    Introduce a new field `codeblock_t::dropped_bytes` that the assembler
    sets whenever it runs out of space. Check this field in
    gen_single_block() to respond to out of memory situations and other
    error conditions. This design avoids making the control flow graph of
    existing code generation functions more complex.
    
    Use POSIX shell in misc/test_yjit_asm.sh since bash is expanding
    `0%/*/*` differently.
    
    Co-authored-by: default avatarAaron Patterson <tenderlove@ruby-lang.org>
    f41b4d44
    YJIT: Bounds check every byte in the assembler
    Alan Wu authored
    
    
    Previously, YJIT assumed that basic blocks never consume more than
    1 KiB of memory. This assumption does not hold for long Ruby methods
    such as the one in the following:
    
    ```ruby
    eval(<<RUBY)
    def set_local_a_lot
      #{'_=0;'*0x40000}
    end
    RUBY
    
    set_local_a_lot
    ```
    
    For low `--yjit-exec-mem-size` values, one basic block could exhaust the
    entire buffer.
    
    Introduce a new field `codeblock_t::dropped_bytes` that the assembler
    sets whenever it runs out of space. Check this field in
    gen_single_block() to respond to out of memory situations and other
    error conditions. This design avoids making the control flow graph of
    existing code generation functions more complex.
    
    Use POSIX shell in misc/test_yjit_asm.sh since bash is expanding
    `0%/*/*` differently.
    
    Co-authored-by: default avatarAaron Patterson <tenderlove@ruby-lang.org>
Loading