diff options
author | Alan Wu <XrXr@users.noreply.github.com> | 2021-12-14 19:47:42 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-14 19:47:42 -0500 |
commit | ac5d6faea8e8d142df798572b0522f8a185c8fb6 (patch) | |
tree | 137e03d3cf33db4a7377daa073e59330526b7d41 /yjit_asm.c | |
parent | 6eb500e2df17475a557de536ce24a4d878bf1607 (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_asm.c')
-rw-r--r-- | yjit_asm.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/yjit_asm.c b/yjit_asm.c index 3a43c80ef0..64cbb163a2 100644 --- a/yjit_asm.c +++ b/yjit_asm.c @@ -1343,7 +1343,10 @@ void mov(codeblock_t *cb, x86opnd_t dst, x86opnd_t src) else cb_write_rm(cb, dst.num_bits == 16, dst.num_bits == 64, NO_OPND, dst, 0, 1, 0xC7); - cb_write_int(cb, src.as.imm, (dst.num_bits > 32)? 32:dst.num_bits); + const uint32_t output_num_bits = (dst.num_bits > 32u) ? 32u : dst.num_bits; + // assert that we can write whole immediate without loss of infomation + assert (sig_imm_size(src.as.imm) <= output_num_bits); + cb_write_int(cb, src.as.imm, output_num_bits); } else |