ruby-changes:68757
From: Maxime <ko1@a...>
Date: Thu, 21 Oct 2021 08:13:27 +0900 (JST)
Subject: [ruby-changes:68757] 2eac297f9f (master): Optimize gen_dup
https://git.ruby-lang.org/ruby.git/commit/?id=2eac297f9f From 2eac297f9f9edc3ec61d087924b30ce40c84b772 Mon Sep 17 00:00:00 2001 From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...> Date: Wed, 10 Feb 2021 20:01:18 -0500 Subject: Optimize gen_dup --- ujit_codegen.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ujit_codegen.c b/ujit_codegen.c index 14d6b305c1..ee47f49af6 100644 --- a/ujit_codegen.c +++ b/ujit_codegen.c @@ -247,12 +247,15 @@ ujit_gen_block(ctx_t* ctx, block_t* block) https://github.com/ruby/ruby/blob/trunk/ujit_codegen.c#L247 static bool gen_dup(jitstate_t* jit, ctx_t* ctx) { - x86opnd_t dup_val = ctx_stack_pop(ctx, 1); - x86opnd_t loc0 = ctx_stack_push(ctx, T_NONE); - x86opnd_t loc1 = ctx_stack_push(ctx, T_NONE); + // Get the top value and its type + x86opnd_t dup_val = ctx_stack_pop(ctx, 0); + 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, loc0, REG0); - mov(cb, loc1, REG0); + return true; } -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/