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

ruby-changes:68827

From: Maxime <ko1@a...>
Date: Thu, 21 Oct 2021 08:14:07 +0900 (JST)
Subject: [ruby-changes:68827] b3b3a8c620 (master): At jit_at_current_insn, jit_peek_at_stack functions

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

From b3b3a8c62020caca849e4b3a1325eb53811e6f7a Mon Sep 17 00:00:00 2001
From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...>
Date: Wed, 3 Mar 2021 14:58:42 -0500
Subject: At jit_at_current_insn, jit_peek_at_stack functions

---
 ujit_codegen.c | 41 +++++++++++++++++++++++++++++++++++++++++
 ujit_core.c    | 41 +++++++++++++++++++++++++++++++++++++++++
 ujit_core.h    |  1 +
 3 files changed, 83 insertions(+)

diff --git a/ujit_codegen.c b/ujit_codegen.c
index 25328c6ee8..8249c1b1d5 100644
--- a/ujit_codegen.c
+++ b/ujit_codegen.c
@@ -79,6 +79,26 @@ jit_mov_gc_ptr(jitstate_t* jit, codeblock_t* cb, x86opnd_t reg, VALUE ptr) https://github.com/ruby/ruby/blob/trunk/ujit_codegen.c#L79
     }
 }
 
+// Check if we are compiling the instruction at the stub PC
+// Meaning we are compiling the instruction that is next to execute
+static bool
+jit_at_current_insn(jitstate_t* jit, ctx_t* ctx)
+{
+    const VALUE* stub_pc = jit->ec->cfp->pc;
+    return (stub_pc == jit->pc);
+}
+
+// Peek at the topmost value on the Ruby stack
+static VALUE
+jit_peek_at_stack(jitstate_t* jit, ctx_t* ctx)
+{
+    RUBY_ASSERT(jit_at_current_insn(jit, ctx));
+
+    VALUE* sp = jit->ec->cfp->sp + ctx->sp_offset;
+
+    return *(sp - 1);
+}
+
 // Save uJIT registers prior to a C call
 static void
 ujit_save_regs(codeblock_t* cb)
@@ -552,6 +572,27 @@ gen_getinstancevariable(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/ujit_codegen.c#L572
         return UJIT_CANT_COMPILE;
     }
 
+
+
+
+
+
+
+    /*
+    if (defer_compilation(this_instruction, ctx))
+        return JIT_END_BLOCK;
+
+    VALUE top_val = jit_peek_at_stack();
+    */
+
+
+
+
+
+
+
+
+
     // If the class uses the default allocator, instances should all be T_OBJECT
     // NOTE: This assumes nobody changes the allocator of the class after allocation.
     //       Eventually, we can encode whether an object is T_OBJECT or not
diff --git a/ujit_core.c b/ujit_core.c
index 5690734d30..b07d8450ad 100644
--- a/ujit_core.c
+++ b/ujit_core.c
@@ -604,6 +604,47 @@ void gen_direct_jump( https://github.com/ruby/ruby/blob/trunk/ujit_core.c#L604
     branch_entries[branch_idx] = branch_entry;
 }
 
+// Create a stub to force the code up to this point to be executed
+void defer_compilation(
+    block_t* block,
+    ctx_t* cur_ctx,
+    uint32_t insn_idx
+)
+{
+
+
+
+
+
+
+
+
+
+
+
+
+    /*
+    RUBY_ASSERT(num_branches < MAX_BRANCHES);
+    uint32_t branch_idx = num_branches++;
+
+    // Register this branch entry
+    branch_t branch_entry = {
+        start_pos,
+        end_pos,
+        *ctx,
+        { target0, BLOCKID_NULL },
+        { *ctx, *ctx },
+        { dst_addr0, NULL },
+        gen_jump_branch,
+        branch_shape
+    };
+
+    branch_entries[branch_idx] = branch_entry;
+    */
+
+
+}
+
 // Remove all references to a block then free it.
 void
 ujit_free_block(block_t *block)
diff --git a/ujit_core.h b/ujit_core.h
index 0b8e3dd465..bfd44b145e 100644
--- a/ujit_core.h
+++ b/ujit_core.h
@@ -35,6 +35,7 @@ typedef struct CtxStruct https://github.com/ruby/ruby/blob/trunk/ujit_core.h#L35
     uint16_t stack_size;
 
     // Offset of the JIT SP relative to the interpreter SP
+    // This represents how far the JIT's SP is from the "real" SP
     int16_t sp_offset;
 
     // Whether we know self is a heap object
-- 
cgit v1.2.1


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

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