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

ruby-changes:69287

From: Maxime <ko1@a...>
Date: Thu, 21 Oct 2021 08:23:19 +0900 (JST)
Subject: [ruby-changes:69287] c55d4cafc2 (master): Pass the global cb through codegen functions

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

From c55d4cafc241706d1255d8609d3d7c6f04d0706a Mon Sep 17 00:00:00 2001
From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...>
Date: Tue, 21 Sep 2021 14:04:02 -0400
Subject: Pass the global cb through codegen functions

---
 yjit_codegen.c | 210 +++++++++++++++++++++++++--------------------------------
 yjit_codegen.h |   2 +-
 2 files changed, 93 insertions(+), 119 deletions(-)

diff --git a/yjit_codegen.c b/yjit_codegen.c
index 0afe617bb1..5f4d1b752f 100644
--- a/yjit_codegen.c
+++ b/yjit_codegen.c
@@ -333,7 +333,6 @@ _counted_side_exit(uint8_t *existing_side_exit, int64_t *counter) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L333
     return start;
 }
 
-
 #else
 
 #define GEN_COUNTER_INC(cb, counter_name) ((void)0)
@@ -341,7 +340,6 @@ _counted_side_exit(uint8_t *existing_side_exit, int64_t *counter) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L340
 
 #endif // if YJIT_STATS
 
-
 // Generate an exit to return to the interpreter
 static uint32_t
 yjit_gen_exit(VALUE *exit_pc, ctx_t *ctx, codeblock_t *cb)
@@ -696,7 +694,7 @@ yjit_gen_block(block_t *block, rb_execution_context_t *ec) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L694
         ADD_COMMENT(cb, insn_name(opcode));
 
         // Call the code generation function
-        bool continue_generating = p_desc->gen_fn(&jit, ctx);
+        codegen_status_t status = gen_fn(&jit, ctx, cb);
 
         // For now, reset the chain depth after each instruction as only the
         // first instruction in the block can concern itself with the depth.
@@ -743,17 +741,17 @@ yjit_gen_block(block_t *block, rb_execution_context_t *ec) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L741
     }
 }
 
-static codegen_status_t gen_opt_send_without_block(jitstate_t *jit, ctx_t *ctx);
+static codegen_status_t gen_opt_send_without_block(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb);
 
 static codegen_status_t
-gen_nop(jitstate_t* jit, ctx_t* ctx)
+gen_nop(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb)
 {
     // Do nothing
     return YJIT_KEEP_COMPILING;
 }
 
 static codegen_status_t
-gen_dup(jitstate_t* jit, ctx_t* ctx)
+gen_dup(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb)
 {
     // Get the top value and its type
     x86opnd_t dup_val = ctx_stack_pop(ctx, 0);
@@ -769,7 +767,7 @@ gen_dup(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L767
 
 // duplicate stack top n elements
 static codegen_status_t
-gen_dupn(jitstate_t* jit, ctx_t* ctx)
+gen_dupn(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb)
 {
     rb_num_t n = (rb_num_t)jit_get_arg(jit, 0);
 
@@ -796,7 +794,7 @@ gen_dupn(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L794
 
 // Swap top 2 stack entries
 static codegen_status_t
-gen_swap(jitstate_t* jit, ctx_t* ctx)
+gen_swap(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb)
 {
     x86opnd_t opnd0 = ctx_stack_opnd(ctx, 0);
     x86opnd_t opnd1 = ctx_stack_opnd(ctx, 1);
@@ -816,7 +814,7 @@ gen_swap(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L814
 
 // set Nth stack entry to stack top
 static codegen_status_t
-gen_setn(jitstate_t* jit, ctx_t* ctx)
+gen_setn(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb)
 {
     rb_num_t n = (rb_num_t)jit_get_arg(jit, 0);
 
@@ -834,7 +832,7 @@ gen_setn(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L832
 
 // get nth stack value, then push it
 static codegen_status_t
-gen_topn(jitstate_t* jit, ctx_t* ctx)
+gen_topn(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb)
 {
     int32_t n = (int32_t)jit_get_arg(jit, 0);
 
@@ -850,7 +848,7 @@ gen_topn(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L848
 }
 
 static codegen_status_t
-gen_pop(jitstate_t* jit, ctx_t* ctx)
+gen_pop(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb)
 {
     // Decrement SP
     ctx_stack_pop(ctx, 1);
@@ -859,7 +857,7 @@ gen_pop(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L857
 
 // Pop n values off the stack
 static codegen_status_t
-gen_adjuststack(jitstate_t* jit, ctx_t* ctx)
+gen_adjuststack(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb)
 {
     rb_num_t n = (rb_num_t)jit_get_arg(jit, 0);
     ctx_stack_pop(ctx, n);
@@ -868,7 +866,7 @@ gen_adjuststack(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L866
 
 // new array initialized from top N values
 static codegen_status_t
-gen_newarray(jitstate_t* jit, ctx_t* ctx)
+gen_newarray(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb)
 {
     rb_num_t n = (rb_num_t)jit_get_arg(jit, 0);
 
@@ -892,7 +890,7 @@ gen_newarray(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L890
 
 // dup array
 static codegen_status_t
-gen_duparray(jitstate_t* jit, ctx_t* ctx)
+gen_duparray(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb)
 {
     VALUE ary = jit_get_arg(jit, 0);
 
@@ -913,7 +911,7 @@ VALUE rb_vm_splat_array(VALUE flag, VALUE ary); https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L911
 
 // call to_a on the array on the stack
 static codegen_status_t
-gen_splatarray(jitstate_t* jit, ctx_t* ctx)
+gen_splatarray(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb)
 {
     VALUE flag = (VALUE) jit_get_arg(jit, 0);
 
@@ -937,7 +935,7 @@ gen_splatarray(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L935
 
 // new range initialized from top 2 values
 static codegen_status_t
-gen_newrange(jitstate_t* jit, ctx_t* ctx)
+gen_newrange(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb)
 {
     rb_num_t flag = (rb_num_t)jit_get_arg(jit, 0);
 
@@ -988,7 +986,7 @@ guard_object_is_array(codeblock_t *cb, x86opnd_t object_opnd, x86opnd_t flags_op https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L986
 
 // push enough nils onto the stack to fill out an array
 static codegen_status_t
-gen_expandarray(jitstate_t* jit, ctx_t* ctx)
+gen_expandarray(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb)
 {
     int flag = (int) jit_get_arg(jit, 1);
 
@@ -1070,7 +1068,7 @@ gen_expandarray(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L1068
 
 // new hash initialized from top N values
 static codegen_status_t
-gen_newhash(jitstate_t* jit, ctx_t* ctx)
+gen_newhash(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb)
 {
     rb_num_t n = (rb_num_t)jit_get_arg(jit, 0);
 
@@ -1091,7 +1089,7 @@ gen_newhash(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L1089
 }
 
 static codegen_status_t
-gen_putnil(jitstate_t* jit, ctx_t* ctx)
+gen_putnil(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb)
 {
     // Write constant at SP
     x86opnd_t stack_top = ctx_stack_push(ctx, TYPE_NIL);
@@ -1100,7 +1098,7 @@ gen_putnil(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L1098
 }
 
 static codegen_status_t
-gen_putobject(jitstate_t* jit, ctx_t* ctx)
+gen_putobject(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb)
 {
     VALUE arg = jit_get_arg(jit, 0);
 
@@ -1144,7 +1142,7 @@ gen_putobject(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L1142
 }
 
 static codegen_status_t
-gen_putstring(jitstate_t* jit, ctx_t* ctx)
+gen_putstring(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb)
 {
     VALUE put_val = jit_get_arg(jit, 0);
 
@@ -1162,7 +1160,7 @@ gen_putstring(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L1160
 }
 
 static codegen_status_t
-gen_putobject_int2fix(jitstate_t* jit, ctx_t* ctx)
+gen_putobject_int2fix(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb)
 {
     int opcode = jit_get_opcode(jit);
     int cst_val = (opcode == BIN(putobject_INT2FIX_0_))? 0:1;
@@ -1175,7 +1173,7 @@ gen_putobject_int2fix(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L1173
 }
 
 static codegen_status_t
-gen_putself(jitstate_t* jit, ctx_t* ctx)
+gen_putself(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb)
 {
     // Load self from CFP
     mov(cb, REG0, member_opnd(REG_CFP, rb_control_frame_t, self));
@@ -1188,7 +1186,7 @@ gen_putself(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L1186
 }
 
 static codegen_status_t
-gen_putspecialobject(jitstate_t* jit, ctx_t* ctx)
+gen_putspecialobject(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb)
 {
     enum vm_special_object_type type = (enum vm_special_object_type)jit_get_arg(jit, 0);
 
@@ -1233,7 +1231,7 @@ slot_to_local_idx(const rb_iseq_t *iseq, int32_t slot_idx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L1231
 }
 
 static codegen_status_t
-gen_getlocal_wc0(jitstate_t* jit, ctx_t* ctx)
+gen_getlocal_wc0(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb)
 {
     // Compute the offset from BP to the local
     int32_t slot_idx = (int32_t)jit_get_arg(jit, 0);
@@ -1271,7 +1269,7 @@ gen_getlocal_generic(ctx_t* ctx, uint32_t local_idx, uint32_t level) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L1269
 }
 
 static codegen_status_t
-gen_getlocal(jitstate_t* jit, ctx_t* ctx)
+gen_getlocal(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb)
 {
     int32_t idx = (int32_t)jit_get_arg(jit, 0);
     int32_t level = (int32_t)jit_get_arg(jit, 1);
@@ -1279,14 +1277,14 @@ gen_getlocal(jitstate_t* jit, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L1277
 }
 
 static codegen_status_t
-gen_getlocal_wc1(jitstate_t* jit, ctx_t* ctx)
+gen_getlocal_wc1(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb)
 {
     int32_t idx = (int32_t)jit_get_arg(jit, 0);
     return gen_getlocal_generic(ctx, idx, 1);
 }
 
 static codegen_status_t
-gen_setlocal_wc0(jitstate_t* jit, ctx_t* ctx)
+gen_setlocal_wc0(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb)
 {
     /*
     vm_env_write(const VALUE *ep, int index, VALUE v)
@@ -1360,7 +1358,7 @@ gen_setlocal_generic(jitstate_t *jit, ctx_t* ctx, uint32_t local_idx, uint32_t l https://github.com/ruby/ruby/blob/trunk/yjit_codegen (... truncated)

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

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