summaryrefslogtreecommitdiff
path: root/yjit_codegen.h
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2021-11-19 23:44:13 -0500
committerAlan Wu <XrXr@users.noreply.github.com>2021-12-01 12:25:28 -0500
commitd0772632bf2ff15f73c0d3601d958670a5c77855 (patch)
tree8bf717561d2ab3d49d97cd69d8a2db794504b624 /yjit_codegen.h
parenta84dc9d80d41db01db4623517ade928ee7f40e36 (diff)
YJIT: Fail gracefully while OOM for new entry points
Previously, YJIT crashes with rb_bug() when asked to compile new methods while out of executable memory. To handle this situation gracefully, this change keeps track of all the blocks compiled each invocation in case YJIT runs out of memory in the middle of a compliation sequence. The list is used to free all blocks in case compilation fails. yjit_gen_block() is renamed to gen_single_block() to make it distinct from gen_block_version(). Call to limit_block_version() and block_t allocation is moved into the function to help tidy error checking in the outer loop. limit_block_version() now returns by value. I feel that an out parameter with conditional mutation is unnecessarily hard to read in code that does not need to go for last drop performance. There is a good chance that the optimizer is able to output identical code anyways.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5191
Diffstat (limited to 'yjit_codegen.h')
-rw-r--r--yjit_codegen.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/yjit_codegen.h b/yjit_codegen.h
index bbd29e671b..e3b971af3f 100644
--- a/yjit_codegen.h
+++ b/yjit_codegen.h
@@ -14,7 +14,7 @@ static void jit_ensure_block_entry_exit(jitstate_t *jit);
static uint8_t *yjit_entry_prologue(codeblock_t *cb, const rb_iseq_t *iseq);
-static void yjit_gen_block(block_t *block, rb_execution_context_t *ec);
+static block_t *gen_single_block(blockid_t blockid, const ctx_t *start_ctx, rb_execution_context_t *ec);
static void gen_code_for_exit_from_stub(void);