summaryrefslogtreecommitdiff
path: root/yjit_codegen.c
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2022-01-06 21:57:43 -0500
committerAlan Wu <XrXr@users.noreply.github.com>2022-01-07 19:29:03 -0500
commit54c91042ed61a869d4a66fc089b21f56d165265f (patch)
tree9d4e7f2acbbbabdd62b1fb1c24082a580ce10094 /yjit_codegen.c
parentbc643bbe2e2c1afbed18ce2bcf4aed138fece412 (diff)
YJIT: Discard local var type info on routine call
Routines that are called from YJIT's output code can call methods, and calling methods mean they can capture and change the environment of the calling frame. Discard type info whenever we perform routine calls. This is more conservative than strictly necessary as some routines need to perform GC allocation but can never call methods and so should never be able to change local variables. However, manually analyzing C functions for whether they have code paths that call methods is error prone and can go out of date as changes land in the codebase. Closes: shopify/yjit#300
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5416
Diffstat (limited to 'yjit_codegen.c')
-rw-r--r--yjit_codegen.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/yjit_codegen.c b/yjit_codegen.c
index aa352dac70..25fcfca083 100644
--- a/yjit_codegen.c
+++ b/yjit_codegen.c
@@ -184,6 +184,10 @@ jit_prepare_routine_call(jitstate_t *jit, ctx_t *ctx, x86opnd_t scratch_reg)
jit->record_boundary_patch_point = true;
jit_save_pc(jit, scratch_reg);
jit_save_sp(jit, ctx);
+
+ // In case the routine calls Ruby methods, it can set local variables
+ // through Kernel#binding and other means.
+ ctx_clear_local_types(ctx);
}
// Record the current codeblock write position for rewriting into a jump into