Skip to content

Commit 76c97c7

Browse files
authored
Merge pull request #228 from jhawthorn/fix_opt_aset
Fix opt_aset comptime_key check
2 parents 3424c46 + 53c6bbb commit 76c97c7

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

bootstraptest/test_yjit.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1996,3 +1996,13 @@ def eq(a, b)
19961996
eq(1, 2)
19971997
eq(1, 2)
19981998
}
1999+
2000+
# aset on array with invalid key
2001+
assert_normal_exit %q{
2002+
def foo(arr)
2003+
arr[:foo] = 123
2004+
end
2005+
2006+
foo([1]) rescue nil
2007+
foo([1]) rescue nil
2008+
}

yjit_codegen.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,14 +2186,13 @@ gen_opt_aset(jitstate_t *jit, ctx_t *ctx)
21862186

21872187
VALUE comptime_recv = jit_peek_at_stack(jit, ctx, 2);
21882188
VALUE comptime_key = jit_peek_at_stack(jit, ctx, 1);
2189-
VALUE comptime_val = jit_peek_at_stack(jit, ctx, 0);
21902189

21912190
// Get the operands from the stack
21922191
x86opnd_t recv = ctx_stack_opnd(ctx, 2);
21932192
x86opnd_t key = ctx_stack_opnd(ctx, 1);
21942193
x86opnd_t val = ctx_stack_opnd(ctx, 0);
21952194

2196-
if (CLASS_OF(comptime_recv) == rb_cArray && FIXNUM_P(comptime_val)) {
2195+
if (CLASS_OF(comptime_recv) == rb_cArray && FIXNUM_P(comptime_key)) {
21972196
uint8_t* side_exit = yjit_side_exit(jit, ctx);
21982197

21992198
// Guard receiver is an Array

0 commit comments

Comments
 (0)