diff options
Diffstat (limited to 'yjit_codegen.c')
-rw-r--r-- | yjit_codegen.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/yjit_codegen.c b/yjit_codegen.c index f63166725a..9eff50b2e4 100644 --- a/yjit_codegen.c +++ b/yjit_codegen.c @@ -987,8 +987,19 @@ gen_expandarray(jitstate_t* jit, ctx_t* ctx) // num is the number of requested values. If there aren't enough in the // array then we're going to push on nils. rb_num_t num = (rb_num_t) jit_get_arg(jit, 0); + val_type_t array_type = ctx_get_opnd_type(ctx, OPND_STACK(0)); x86opnd_t array_opnd = ctx_stack_pop(ctx, 1); + if (array_type.type == ETYPE_NIL) { + // special case for a, b = nil pattern + // push N nils onto the stack + for (int i = 0; i < num; i++) { + x86opnd_t push = ctx_stack_push(ctx, TYPE_NIL); + mov(cb, push, imm_opnd(Qnil)); + } + return YJIT_KEEP_COMPILING; + } + // Move the array from the stack into REG0 and check that it's an array. mov(cb, REG0, array_opnd); guard_object_is_heap(cb, REG0, ctx, COUNTED_EXIT(side_exit, expandarray_not_array)); |