[前][次][番号順一覧][スレッド一覧]

ruby-changes:68881

From: Maxime <ko1@a...>
Date: Thu, 21 Oct 2021 08:15:01 +0900 (JST)
Subject: [ruby-changes:68881] e98d2c5ec8 (master): Add ctcx_stack_push_local()

https://git.ruby-lang.org/ruby.git/commit/?id=e98d2c5ec8

From e98d2c5ec818abe9a274055c2308bf3488358529 Mon Sep 17 00:00:00 2001
From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...>
Date: Tue, 6 Apr 2021 12:00:09 -0400
Subject: Add ctcx_stack_push_local()

---
 yjit_core.c | 19 +++++++++++++++++++
 yjit_core.h |  5 +++--
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/yjit_core.c b/yjit_core.c
index f74c5e9318..4d95fc1312 100644
--- a/yjit_core.c
+++ b/yjit_core.c
@@ -70,6 +70,25 @@ ctx_stack_push_self(ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/yjit_core.c#L70
     return mem_opnd(64, REG_SP, offset);
 }
 
+/*
+Push a local variable on the stack
+*/
+x86opnd_t
+ctx_stack_push_local(ctx_t* ctx, size_t local_idx)
+{
+    // Keep track of the type of the value
+    if (ctx->stack_size < MAX_TEMP_TYPES && local_idx < MAX_LOCAL_TYPES) {
+        ctx->temp_mapping[ctx->stack_size] = (temp_mapping_t){ .kind = TEMP_LOCAL, .idx = local_idx };
+    }
+
+    ctx->stack_size += 1;
+    ctx->sp_offset += 1;
+
+    // SP points just above the topmost value
+    int32_t offset = (ctx->sp_offset - 1) * sizeof(VALUE);
+    return mem_opnd(64, REG_SP, offset);
+}
+
 /*
 Pop N values off the stack
 Return a pointer to the stack top before the pop operation
diff --git a/yjit_core.h b/yjit_core.h
index 658a0cc691..cb47d013a9 100644
--- a/yjit_core.h
+++ b/yjit_core.h
@@ -73,8 +73,8 @@ typedef enum yjit_temp_loc https://github.com/ruby/ruby/blob/trunk/yjit_core.h#L73
 {
     TEMP_STACK = 0,
     TEMP_SELF,
-    //TEMP_LOCAL, // Local with index
-    //TEMP_CONST, // Small constant (0, 1, 2, Qnil, Qfalse, Qtrue)
+    TEMP_LOCAL,     // Local with index
+    //TEMP_CONST,   // Small constant (0, 1, 2, Qnil, Qfalse, Qtrue)
 
 } temp_loc_t;
 
@@ -218,6 +218,7 @@ typedef struct yjit_block_version https://github.com/ruby/ruby/blob/trunk/yjit_core.h#L218
 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_push_local(ctx_t* ctx, size_t local_idx);
 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);
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]