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

ruby-changes:69223

From: Maxime <ko1@a...>
Date: Thu, 21 Oct 2021 08:24:07 +0900 (JST)
Subject: [ruby-changes:69223] f1eb48cb23 (master): Step 2 to remove the global cb/ocb objects.

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

From f1eb48cb23c949ce8163c6b6d2042cecd0d79ea9 Mon Sep 17 00:00:00 2001
From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...>
Date: Tue, 21 Sep 2021 16:09:16 -0400
Subject: Step 2 to remove the global cb/ocb objects.

---
 yjit_codegen.c | 42 ++++++++++++++++++++++--------------------
 yjit_codegen.h | 31 -------------------------------
 yjit_core.c    | 16 ++++++++--------
 yjit_core.h    | 43 +++++++++++++++++++++++++++++++++++++++----
 4 files changed, 69 insertions(+), 63 deletions(-)

diff --git a/yjit_codegen.c b/yjit_codegen.c
index 5f4d1b752f..ce5fb4e344 100644
--- a/yjit_codegen.c
+++ b/yjit_codegen.c
@@ -596,7 +596,7 @@ jit_jump_to_next_insn(jitstate_t *jit, const ctx_t *current_context) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L596
 
     // Generate the jump instruction
     gen_direct_jump(
-        jit->block,
+        jit,
         &reset_depth,
         jump_block
     );
@@ -630,6 +630,8 @@ yjit_gen_block(block_t *block, rb_execution_context_t *ec) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L630
 
     // Initialize a JIT state object
     jitstate_t jit = {
+        .cb = cb,
+        .ocb = ocb,
         .block = block,
         .iseq = iseq,
         .ec = ec
@@ -1477,7 +1479,7 @@ jit_chain_guard(enum jcc_kinds jcc, jitstate_t *jit, const ctx_t *ctx, uint8_t d https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L1479
         deeper.chain_depth++;
 
         gen_branch(
-            jit->block,
+            jit,
             ctx,
             (blockid_t) { jit->iseq, jit->insn_idx },
             &deeper,
@@ -1684,7 +1686,7 @@ gen_getinstancevariable(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L1686
 {
     // Defer compilation so we can specialize on a runtime `self`
     if (!jit_at_current_insn(jit)) {
-        defer_compilation(jit->block, jit->insn_idx, ctx);
+        defer_compilation(jit, ctx);
         return YJIT_END_BLOCK;
     }
 
@@ -1908,7 +1910,7 @@ gen_fixnum_cmp(jitstate_t* jit, ctx_t* ctx, cmov_fn cmov_op) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L1910
 {
     // Defer compilation so we can specialize base on a runtime receiver
     if (!jit_at_current_insn(jit)) {
-        defer_compilation(jit->block, jit->insn_idx, ctx);
+        defer_compilation(jit, ctx);
         return YJIT_END_BLOCK;
     }
 
@@ -2054,7 +2056,7 @@ gen_opt_eq(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L2056
 {
     // Defer compilation so we can specialize base on a runtime receiver
     if (!jit_at_current_insn(jit)) {
-        defer_compilation(jit->block, jit->insn_idx, ctx);
+        defer_compilation(jit, ctx);
         return YJIT_END_BLOCK;
     }
 
@@ -2094,7 +2096,7 @@ gen_opt_aref(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L2096
 
     // Defer compilation so we can specialize base on a runtime receiver
     if (!jit_at_current_insn(jit)) {
-        defer_compilation(jit->block, jit->insn_idx, ctx);
+        defer_compilation(jit, ctx);
         return YJIT_END_BLOCK;
     }
 
@@ -2214,7 +2216,7 @@ gen_opt_aset(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L2216
 {
     // Defer compilation so we can specialize on a runtime `self`
     if (!jit_at_current_insn(jit)) {
-        defer_compilation(jit->block, jit->insn_idx, ctx);
+        defer_compilation(jit, ctx);
         return YJIT_END_BLOCK;
     }
 
@@ -2293,7 +2295,7 @@ gen_opt_and(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L2295
 {
     // Defer compilation so we can specialize on a runtime `self`
     if (!jit_at_current_insn(jit)) {
-        defer_compilation(jit->block, jit->insn_idx, ctx);
+        defer_compilation(jit, ctx);
         return YJIT_END_BLOCK;
     }
 
@@ -2336,7 +2338,7 @@ gen_opt_or(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L2338
 {
     // Defer compilation so we can specialize on a runtime `self`
     if (!jit_at_current_insn(jit)) {
-        defer_compilation(jit->block, jit->insn_idx, ctx);
+        defer_compilation(jit, ctx);
         return YJIT_END_BLOCK;
     }
 
@@ -2379,7 +2381,7 @@ gen_opt_minus(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L2381
 {
     // Defer compilation so we can specialize on a runtime `self`
     if (!jit_at_current_insn(jit)) {
-        defer_compilation(jit->block, jit->insn_idx, ctx);
+        defer_compilation(jit, ctx);
         return YJIT_END_BLOCK;
     }
 
@@ -2424,7 +2426,7 @@ gen_opt_plus(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L2426
 {
     // Defer compilation so we can specialize on a runtime `self`
     if (!jit_at_current_insn(jit)) {
-        defer_compilation(jit->block, jit->insn_idx, ctx);
+        defer_compilation(jit, ctx);
         return YJIT_END_BLOCK;
     }
 
@@ -2649,7 +2651,7 @@ gen_branchif(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L2651
 
     // Generate the branch instructions
     gen_branch(
-        jit->block,
+        jit,
         ctx,
         jump_block,
         ctx,
@@ -2706,7 +2708,7 @@ gen_branchunless(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L2708
 
     // Generate the branch instructions
     gen_branch(
-        jit->block,
+        jit,
         ctx,
         jump_block,
         ctx,
@@ -2762,7 +2764,7 @@ gen_branchnil(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L2764
 
     // Generate the branch instructions
     gen_branch(
-        jit->block,
+        jit,
         ctx,
         jump_block,
         ctx,
@@ -2791,7 +2793,7 @@ gen_jump(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L2793
 
     // Generate the jump instruction
     gen_direct_jump(
-        jit->block,
+        jit,
         ctx,
         jump_block
     );
@@ -3516,7 +3518,7 @@ gen_send_iseq(jitstate_t *jit, ctx_t *ctx, const struct rb_callinfo *ci, const r https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L3518
 
     // Write the JIT return address on the callee frame
     gen_branch(
-        jit->block,
+        jit,
         ctx,
         return_block,
         &return_ctx,
@@ -3533,7 +3535,7 @@ gen_send_iseq(jitstate_t *jit, ctx_t *ctx, const struct rb_callinfo *ci, const r https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L3535
 
     // Directly jump to the entry point of the callee
     gen_direct_jump(
-        jit->block,
+        jit,
         &callee_ctx,
         (blockid_t){ iseq, start_pc_offset }
     );
@@ -3577,7 +3579,7 @@ gen_send_general(jitstate_t *jit, ctx_t *ctx, struct rb_call_data *cd, rb_iseq_t https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L3579
 
     // Defer compilation so we can specialize on class of receiver
     if (!jit_at_current_insn(jit)) {
-        defer_compilation(jit->block, jit->insn_idx, ctx);
+        defer_compilation(jit, ctx);
         return YJIT_END_BLOCK;
     }
 
@@ -3710,7 +3712,7 @@ gen_invokesuper(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L3712
 
     // Defer compilation so we can specialize on class of receiver
     if (!jit_at_current_insn(jit)) {
-        defer_compilation(jit->block, jit->insn_idx, ctx);
+        defer_compilation(jit, ctx);
         return YJIT_END_BLOCK;
     }
 
@@ -4068,7 +4070,7 @@ gen_opt_getinlinecache(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L4070
     // Jump over the code for filling the cache
     uint32_t jump_idx = jit_next_insn_idx(jit) + (int32_t)jump_offset;
     gen_direct_jump(
-        jit->block,
+        jit,
         ctx,
         (blockid_t){ .iseq = jit->iseq, .idx = jump_idx }
     );
diff --git a/yjit_codegen.h b/yjit_codegen.h
index 54a8f8023f..75edcc8da8 100644
--- a/yjit_codegen.h
+++ b/yjit_codegen.h
@@ -9,37 +9,6 @@ extern codeblock_t *cb; https://github.com/ruby/ruby/blob/trunk/yjit_codegen.h#L9
 extern codeblock_t *ocb;
 extern uint32_t yjit_codepage_frozen_bytes;
 
-// Code generation state
-typedef struct JITState
-{
-    // Block version being compiled
-    block_t *block;
-
-    // Instruction sequence this is associated with
-    const rb_iseq_t *iseq;
-
-    // Index of the current instruction being compiled
-    uint32_t insn_idx;
-
-    // Opcode for the instruction being compiled
-    int opcode;
-
-    // PC of the instruction being compiled
-    VALUE *pc;
-
-    // Side exit to the instruction being compiled. See :side-exit:.
-    uint8_t *side_exit_for_pc;
-
-    // Execution context when compilation started
-    // This allows us to peek at run-time values
-    rb_execution_context_t *ec;
-
-    // Whether we need to record the code address at
-    // the end of this bytecode instruction for global invalidation
-    bool record_boundary_patch_point;
-
-} jitstate_t;
-
 typedef enum codegen_status {
     YJIT_END_BLOCK,
     YJIT_KEEP_COMPILING,
diff --git a/yjit_core.c b/yjit_core.c
index 6c2e1b0ae0..8090cdd80a 100644
--- a/yjit_core.c
+++ b/yjit_core.c
@@ -871,7 +871,7 @@ uint8_t* get_branch_target( https://github.com/ruby/ruby/blob/trunk/yjit_core.c#L871
 }
 
 void gen_branch(
-    block_t* block,
+    jitstate_t* jit,
     const ctx_t* src_ctx,
     blockid_t target0,
     const ctx_t* ctx0,
@@ -882,7 +882,7 @@ void gen_branch( https://github.com/ruby/ruby/blob/trunk/yjit_core.c#L882
 {
     RUBY_ASSERT(target0.iseq != NULL);
 
-    branch_t* branch = make_branch_entry(block, src_ctx, gen_fn);
+    branch_t* branch = make_branch_entry(jit->block, src_ctx, g (... truncated)

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

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