summaryrefslogtreecommitdiff
path: root/yjit_codegen.c
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2021-12-14 19:47:42 -0500
committerGitHub <noreply@github.com>2021-12-14 19:47:42 -0500
commitac5d6faea8e8d142df798572b0522f8a185c8fb6 (patch)
tree137e03d3cf33db4a7377daa073e59330526b7d41 /yjit_codegen.c
parent6eb500e2df17475a557de536ce24a4d878bf1607 (diff)
YJIT: Fix unexpected truncation when outputing VALUE
Previously, YJIT incorrectly discarded the upper 32 bits of the object pointer when writing out VALUEs to setup default keyword arguments. In addition to incorrectly truncating, the output pointers were not properly tracked for handling GC compaction moving the referenced objects. YJIT previously attempted to encode a mov instruction with a memory destination and a 64 bit immediate when there is no such encoding possible in the ISA. Add an assert to mitigate not being able to catch this at build time.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5274 Merged-By: XrXr
Diffstat (limited to 'yjit_codegen.c')
-rw-r--r--yjit_codegen.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/yjit_codegen.c b/yjit_codegen.c
index 3378f1500d..38b830a097 100644
--- a/yjit_codegen.c
+++ b/yjit_codegen.c
@@ -3698,7 +3698,7 @@ gen_send_iseq(jitstate_t *jit, ctx_t *ctx, const struct rb_callinfo *ci, const r
// This struct represents the metadata about the callee-specified
// keyword parameters.
- const struct rb_iseq_param_keyword *keyword = iseq->body->param.keyword;
+ const struct rb_iseq_param_keyword *const keyword = iseq->body->param.keyword;
ADD_COMMENT(cb, "keyword args");
@@ -3748,7 +3748,9 @@ gen_send_iseq(jitstate_t *jit, ctx_t *ctx, const struct rb_callinfo *ci, const r
default_value = Qnil;
}
- mov(cb, default_arg, imm_opnd(default_value));
+ // GC might move default_value.
+ jit_mov_gc_ptr(jit, cb, REG0, default_value);
+ mov(cb, default_arg, REG0);
caller_kwargs[kwarg_idx++] = callee_kwarg;
}