diff options
author | eileencodes <[email protected]> | 2021-08-04 13:23:34 -0400 |
---|---|---|
committer | Alan Wu <[email protected]> | 2021-10-20 18:19:38 -0400 |
commit | d2e8b99b5bc485b864d25c4293002214b0c64ced (patch) | |
tree | a619460f17c34d476443851cb234c9fffdc98519 /yjit_codegen.c | |
parent | 5b4305f71c90d498c91d7b5038758e3557938802 (diff) |
Implement tostring instruction for yjit
Co-authored-by: Aaron Patterson <[email protected]>
Diffstat (limited to 'yjit_codegen.c')
-rw-r--r-- | yjit_codegen.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/yjit_codegen.c b/yjit_codegen.c index 297d4f4291..ebb75cbdad 100644 --- a/yjit_codegen.c +++ b/yjit_codegen.c @@ -3495,6 +3495,35 @@ gen_setglobal(jitstate_t* jit, ctx_t* ctx) } static codegen_status_t +gen_tostring(jitstate_t* jit, ctx_t* ctx) +{ + // Save the PC and SP because we might make a Ruby call for + // Kernel#set_trace_var + jit_save_pc(jit, REG0); + jit_save_sp(jit, ctx); + + // Save YJIT registers + yjit_save_regs(cb); + + x86opnd_t str = ctx_stack_pop(ctx, 1); + x86opnd_t val = ctx_stack_pop(ctx, 1); + + mov(cb, C_ARG_REGS[0], str); + mov(cb, C_ARG_REGS[1], val); + + call_ptr(cb, REG0, (void *)&rb_obj_as_string_result); + + // Load YJIT registers + yjit_load_regs(cb); + + // Push the return value + x86opnd_t stack_ret = ctx_stack_push(ctx, TYPE_STRING); + mov(cb, stack_ret, RAX); + + return YJIT_KEEP_COMPILING; +} + +static codegen_status_t gen_opt_getinlinecache(jitstate_t *jit, ctx_t *ctx) { VALUE jump_offset = jit_get_arg(jit, 0); @@ -3738,6 +3767,7 @@ yjit_init_codegen(void) yjit_reg_op(BIN(leave), gen_leave); yjit_reg_op(BIN(getglobal), gen_getglobal); yjit_reg_op(BIN(setglobal), gen_setglobal); + yjit_reg_op(BIN(tostring), gen_tostring); yjit_method_codegen_table = st_init_numtable(); |