summaryrefslogtreecommitdiff
path: root/yjit_iface.c
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2021-12-01 14:15:23 -0500
committerAlan Wu <XrXr@users.noreply.github.com>2021-12-03 20:02:25 -0500
commitf41b4d44f95978dfa97af04af00055dc3fbf7978 (patch)
tree744a3d5e2d8f1ef0b3a4ab00a7cd99df0353f6b8 /yjit_iface.c
parent3be067234f156d75e6143cca5037df7eef1bd112 (diff)
YJIT: Bounds check every byte in the assembler
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: Aaron Patterson <tenderlove@ruby-lang.org>
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5209
Diffstat (limited to 'yjit_iface.c')
-rw-r--r--yjit_iface.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/yjit_iface.c b/yjit_iface.c
index 739d639ae6..5c9e024a5f 100644
--- a/yjit_iface.c
+++ b/yjit_iface.c
@@ -1150,7 +1150,7 @@ yjit_get_code_page(uint32_t cb_bytes_needed, uint32_t ocb_bytes_needed)
code_page_t *new_code_page = rb_yjit_code_page_unwrap(yjit_cur_code_page);
// Jump to the new code page
- jmp_ptr(&code_page->cb, new_code_page->cb.mem_block);
+ jmp_ptr(&code_page->cb, cb_get_ptr(&new_code_page->cb, 0));
return yjit_cur_code_page;
}