From c299112fd7eb4432f3fdc83a9f5716e8e79249f4 Mon Sep 17 00:00:00 2001 From: Maxime Chevalier-Boisvert Date: Thu, 1 Apr 2021 16:56:20 -0400 Subject: [PATCH] use ctx_stack_push_self() --- yjit_codegen.c | 6 ++++-- yjit_core.h | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/yjit_codegen.c b/yjit_codegen.c index 12aa893993..18c8f7c4e9 100644 --- a/yjit_codegen.c +++ b/yjit_codegen.c @@ -429,7 +429,7 @@ gen_putobject(jitstate_t* jit, ctx_t* ctx) } else if (arg == Qtrue || arg == Qfalse) { - x86opnd_t stack_top = ctx_stack_push(ctx, TYPE_UNKNOWN); + x86opnd_t stack_top = ctx_stack_push(ctx, TYPE_IMM); mov(cb, stack_top, imm_opnd((int64_t)arg)); } else @@ -440,6 +440,8 @@ gen_putobject(jitstate_t* jit, ctx_t* ctx) mov(cb, RAX, pc_plus_one); mov(cb, RAX, mem_opnd(64, RAX, 0)); + // TODO: check if argument is a heap object + // Write argument at SP x86opnd_t stack_top = ctx_stack_push(ctx, TYPE_UNKNOWN); mov(cb, stack_top, RAX); @@ -468,7 +470,7 @@ gen_putself(jitstate_t* jit, ctx_t* ctx) mov(cb, RAX, member_opnd(REG_CFP, rb_control_frame_t, self)); // Write it on the stack - x86opnd_t stack_top = ctx_stack_push(ctx, TYPE_UNKNOWN); + x86opnd_t stack_top = ctx_stack_push_self(ctx); mov(cb, stack_top, RAX); return YJIT_KEEP_COMPILING; diff --git a/yjit_core.h b/yjit_core.h index 6001838c50..1a55408a7b 100644 --- a/yjit_core.h +++ b/yjit_core.h @@ -31,7 +31,8 @@ typedef enum yjit_type_enum ETYPE_UNKNOWN = 0, ETYPE_NIL, ETYPE_FIXNUM, - //ETYPE_ARRAY + ETYPE_ARRAY, + ETYPE_HASH //ETYPE_SYMBOL //ETYPE_STRING @@ -63,9 +64,10 @@ STATIC_ASSERT(val_type_size, sizeof(val_type_t) == 1); // Could be any immediate #define TYPE_IMM ( (val_type_t){ .is_imm = 1 } ) -// Immediate types #define TYPE_NIL ( (val_type_t){ .is_imm = 1, .type = ETYPE_NIL } ) #define TYPE_FIXNUM ( (val_type_t){ .is_imm = 1, .type = ETYPE_FIXNUM } ) +#define TYPE_ARRAY ( (val_type_t){ .is_heap = 1, .type = ETYPE_ARRAY } ) +#define TYPE_HASH ( (val_type_t){ .is_heap = 1, .type = ETYPE_HASH } ) typedef enum yjit_temp_loc { @@ -215,6 +217,7 @@ typedef struct yjit_block_version // Context object methods x86opnd_t ctx_sp_opnd(ctx_t* ctx, int32_t offset_bytes); x86opnd_t ctx_stack_push(ctx_t* ctx, val_type_t type); +x86opnd_t ctx_stack_push_self(ctx_t* ctx); x86opnd_t ctx_stack_pop(ctx_t* ctx, size_t n); x86opnd_t ctx_stack_opnd(ctx_t* ctx, int32_t idx); val_type_t ctx_get_temp_type(const ctx_t* ctx, size_t idx);