ruby-changes:69026
From: John <ko1@a...>
Date: Thu, 21 Oct 2021 08:20:35 +0900 (JST)
Subject: [ruby-changes:69026] 9283fc1bb5 (master): Implement opt_freeze and opt_uminus (#49)
https://git.ruby-lang.org/ruby.git/commit/?id=9283fc1bb5 From 9283fc1bb554da800fe02bdd1653520f8b743344 Mon Sep 17 00:00:00 2001 From: John Hawthorn <john@h...> Date: Wed, 26 May 2021 12:40:50 -0700 Subject: Implement opt_freeze and opt_uminus (#49) --- yjit_codegen.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/yjit_codegen.c b/yjit_codegen.c index 6b32b4e4e7..c2bdd96e86 100644 --- a/yjit_codegen.c +++ b/yjit_codegen.c @@ -1733,6 +1733,40 @@ gen_opt_empty_p(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L1733 return gen_opt_send_without_block(jit, ctx); } +static codegen_status_t +gen_opt_str_freeze(jitstate_t* jit, ctx_t* ctx) +{ + if (!assume_bop_not_redefined(jit->block, STRING_REDEFINED_OP_FLAG, BOP_FREEZE)) { + return YJIT_CANT_COMPILE; + } + + VALUE str = jit_get_arg(jit, 0); + jit_mov_gc_ptr(jit, cb, REG0, str); + + // Push the return value onto the stack + x86opnd_t stack_ret = ctx_stack_push(ctx, TYPE_STRING); + mov(cb, stack_ret, REG0); + + return YJIT_KEEP_COMPILING; +} + +static codegen_status_t +gen_opt_str_uminus(jitstate_t* jit, ctx_t* ctx) +{ + if (!assume_bop_not_redefined(jit->block, STRING_REDEFINED_OP_FLAG, BOP_UMINUS)) { + return YJIT_CANT_COMPILE; + } + + VALUE str = jit_get_arg(jit, 0); + jit_mov_gc_ptr(jit, cb, REG0, str); + + // Push the return value onto the stack + x86opnd_t stack_ret = ctx_stack_push(ctx, TYPE_STRING); + mov(cb, stack_ret, REG0); + + return YJIT_KEEP_COMPILING; +} + static codegen_status_t gen_opt_not(jitstate_t* jit, ctx_t* ctx) { @@ -2837,6 +2871,8 @@ yjit_init_codegen(void) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L2871 yjit_reg_op(BIN(opt_ltlt), gen_opt_ltlt); yjit_reg_op(BIN(opt_nil_p), gen_opt_nil_p); yjit_reg_op(BIN(opt_empty_p), gen_opt_empty_p); + yjit_reg_op(BIN(opt_str_freeze), gen_opt_str_freeze); + yjit_reg_op(BIN(opt_str_uminus), gen_opt_str_uminus); yjit_reg_op(BIN(opt_not), gen_opt_not); yjit_reg_op(BIN(opt_getinlinecache), gen_opt_getinlinecache); yjit_reg_op(BIN(branchif), gen_branchif); -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/