1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Optimize gen_dup

This commit is contained in:
Maxime Chevalier-Boisvert 2021-02-10 20:01:18 -05:00 committed by Alan Wu
parent 3d026adb61
commit 2eac297f9f

View file

@ -247,12 +247,15 @@ ujit_gen_block(ctx_t* ctx, block_t* block)
static bool static bool
gen_dup(jitstate_t* jit, ctx_t* ctx) gen_dup(jitstate_t* jit, ctx_t* ctx)
{ {
x86opnd_t dup_val = ctx_stack_pop(ctx, 1); // Get the top value and its type
x86opnd_t loc0 = ctx_stack_push(ctx, T_NONE); x86opnd_t dup_val = ctx_stack_pop(ctx, 0);
x86opnd_t loc1 = ctx_stack_push(ctx, T_NONE); int dup_type = ctx_get_top_type(ctx);
// Push the same value on top
x86opnd_t loc0 = ctx_stack_push(ctx, dup_type);
mov(cb, REG0, dup_val); mov(cb, REG0, dup_val);
mov(cb, loc0, REG0); mov(cb, loc0, REG0);
mov(cb, loc1, REG0);
return true; return true;
} }