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

ruby-changes:69093

From: John <ko1@a...>
Date: Thu, 21 Oct 2021 08:20:48 +0900 (JST)
Subject: [ruby-changes:69093] 4ea69e5c0b (master): Rename to ctx_upgrade_opnd_type

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

From 4ea69e5c0b6163dbc6cdd75b2a44720d2b84a5f6 Mon Sep 17 00:00:00 2001
From: John Hawthorn <john@h...>
Date: Wed, 14 Jul 2021 11:52:00 -0700
Subject: Rename to ctx_upgrade_opnd_type

---
 yjit_codegen.c | 22 +++++++++++-----------
 yjit_core.c    | 18 +++++++++++++-----
 yjit_core.h    |  2 +-
 3 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/yjit_codegen.c b/yjit_codegen.c
index 2512f9f52d..5c7a2faafe 100644
--- a/yjit_codegen.c
+++ b/yjit_codegen.c
@@ -1237,7 +1237,7 @@ gen_set_ivar(jitstate_t *jit, ctx_t *ctx, const int max_chain_depth, VALUE compt https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L1237
             ADD_COMMENT(cb, "guard value is immediate");
             test(cb, REG1, imm_opnd(RUBY_IMMEDIATE_MASK));
             jz_ptr(cb, COUNTED_EXIT(side_exit, setivar_val_heapobject));
-            ctx_set_opnd_type(ctx, OPND_STACK(0), TYPE_IMM);
+            ctx_upgrade_opnd_type(ctx, OPND_STACK(0), TYPE_IMM);
         }
 
         // Pop the value to write
@@ -1704,8 +1704,8 @@ guard_two_fixnums(ctx_t* ctx, uint8_t* side_exit) https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L1704
     }
 
     // Set stack types in context
-    ctx_set_opnd_type(ctx, OPND_STACK(0), TYPE_FIXNUM);
-    ctx_set_opnd_type(ctx, OPND_STACK(1), TYPE_FIXNUM);
+    ctx_upgrade_opnd_type(ctx, OPND_STACK(0), TYPE_FIXNUM);
+    ctx_upgrade_opnd_type(ctx, OPND_STACK(1), TYPE_FIXNUM);
 }
 
 // Conditional move operation used by comparison operators
@@ -2441,7 +2441,7 @@ jit_guard_known_klass(jitstate_t *jit, ctx_t *ctx, VALUE known_klass, insn_opnd_ https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L2441
             cmp(cb, REG0, imm_opnd(Qnil));
             jit_chain_guard(JCC_JNE, jit, ctx, max_chain_depth, side_exit);
 
-            ctx_set_opnd_type(ctx, insn_opnd, TYPE_NIL);
+            ctx_upgrade_opnd_type(ctx, insn_opnd, TYPE_NIL);
         }
     }
     else if (known_klass == rb_cTrueClass) {
@@ -2453,7 +2453,7 @@ jit_guard_known_klass(jitstate_t *jit, ctx_t *ctx, VALUE known_klass, insn_opnd_ https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L2453
             cmp(cb, REG0, imm_opnd(Qtrue));
             jit_chain_guard(JCC_JNE, jit, ctx, max_chain_depth, side_exit);
 
-            ctx_set_opnd_type(ctx, insn_opnd, TYPE_TRUE);
+            ctx_upgrade_opnd_type(ctx, insn_opnd, TYPE_TRUE);
         }
     }
     else if (known_klass == rb_cFalseClass) {
@@ -2466,7 +2466,7 @@ jit_guard_known_klass(jitstate_t *jit, ctx_t *ctx, VALUE known_klass, insn_opnd_ https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L2466
             test(cb, REG0, REG0);
             jit_chain_guard(JCC_JNZ, jit, ctx, max_chain_depth, side_exit);
 
-            ctx_set_opnd_type(ctx, insn_opnd, TYPE_FALSE);
+            ctx_upgrade_opnd_type(ctx, insn_opnd, TYPE_FALSE);
         }
     }
     else if (known_klass == rb_cInteger && FIXNUM_P(sample_instance)) {
@@ -2479,7 +2479,7 @@ jit_guard_known_klass(jitstate_t *jit, ctx_t *ctx, VALUE known_klass, insn_opnd_ https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L2479
             ADD_COMMENT(cb, "guard object is fixnum");
             test(cb, REG0, imm_opnd(RUBY_FIXNUM_FLAG));
             jit_chain_guard(JCC_JZ, jit, ctx, max_chain_depth, side_exit);
-            ctx_set_opnd_type(ctx, insn_opnd, TYPE_FIXNUM);
+            ctx_upgrade_opnd_type(ctx, insn_opnd, TYPE_FIXNUM);
         }
     }
     else if (known_klass == rb_cSymbol && STATIC_SYM_P(sample_instance)) {
@@ -2493,7 +2493,7 @@ jit_guard_known_klass(jitstate_t *jit, ctx_t *ctx, VALUE known_klass, insn_opnd_ https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L2493
             STATIC_ASSERT(special_shift_is_8, RUBY_SPECIAL_SHIFT == 8);
             cmp(cb, REG0_8, imm_opnd(RUBY_SYMBOL_FLAG));
             jit_chain_guard(JCC_JNE, jit, ctx, max_chain_depth, side_exit);
-            ctx_set_opnd_type(ctx, insn_opnd, TYPE_STATIC_SYMBOL);
+            ctx_upgrade_opnd_type(ctx, insn_opnd, TYPE_STATIC_SYMBOL);
         }
     }
     else if (known_klass == rb_cFloat && FLONUM_P(sample_instance)) {
@@ -2507,7 +2507,7 @@ jit_guard_known_klass(jitstate_t *jit, ctx_t *ctx, VALUE known_klass, insn_opnd_ https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L2507
             and(cb, REG1, imm_opnd(RUBY_FLONUM_MASK));
             cmp(cb, REG1, imm_opnd(RUBY_FLONUM_FLAG));
             jit_chain_guard(JCC_JNE, jit, ctx, max_chain_depth, side_exit);
-            ctx_set_opnd_type(ctx, insn_opnd, TYPE_FLONUM);
+            ctx_upgrade_opnd_type(ctx, insn_opnd, TYPE_FLONUM);
         }
     }
     else if (FL_TEST(known_klass, FL_SINGLETON) && sample_instance == rb_attr_get(known_klass, id__attached__)) {
@@ -2540,7 +2540,7 @@ jit_guard_known_klass(jitstate_t *jit, ctx_t *ctx, VALUE known_klass, insn_opnd_ https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L2540
             cmp(cb, REG0, imm_opnd(Qnil));
             jit_chain_guard(JCC_JBE, jit, ctx, max_chain_depth, side_exit);
 
-            ctx_set_opnd_type(ctx, insn_opnd, TYPE_HEAP);
+            ctx_upgrade_opnd_type(ctx, insn_opnd, TYPE_HEAP);
         }
 
         x86opnd_t klass_opnd = mem_opnd(64, REG0, offsetof(struct RBasic, klass));
@@ -3085,7 +3085,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#L3085
         ctx_set_local_type(&callee_ctx, arg_idx, arg_type);
     }
     val_type_t recv_type = ctx_get_opnd_type(ctx, OPND_STACK(argc));
-    ctx_set_opnd_type(&callee_ctx, OPND_SELF, recv_type);
+    ctx_upgrade_opnd_type(&callee_ctx, OPND_SELF, recv_type);
 
     // The callee might change locals through Kernel#binding and other means.
     ctx_clear_local_types(ctx);
diff --git a/yjit_core.c b/yjit_core.c
index 6e1659ca23..e846c95330 100644
--- a/yjit_core.c
+++ b/yjit_core.c
@@ -153,13 +153,20 @@ ctx_get_opnd_type(const ctx_t* ctx, insn_opnd_t opnd) https://github.com/ruby/ruby/blob/trunk/yjit_core.c#L153
     rb_bug("unreachable");
 }
 
+int type_diff(val_type_t src, val_type_t dst);
+#define UPGRADE_TYPE(dest, src) do { \
+    RUBY_ASSERT(type_diff((src), (dest)) != INT_MAX); \
+    (dest) = (src); \
+} while (false)
+
+
 /**
 Set the type of an instruction operand
 */
-void ctx_set_opnd_type(ctx_t* ctx, insn_opnd_t opnd, val_type_t type)
+void ctx_upgrade_opnd_type(ctx_t* ctx, insn_opnd_t opnd, val_type_t type)
 {
     if (opnd.is_self) {
-        ctx->self_type = type;
+        UPGRADE_TYPE(ctx->self_type, type);
         return;
     }
 
@@ -172,16 +179,17 @@ void ctx_set_opnd_type(ctx_t* ctx, insn_opnd_t opnd, val_type_t type) https://github.com/ruby/ruby/blob/trunk/yjit_core.c#L179
     switch (mapping.kind)
     {
         case TEMP_SELF:
-        ctx->self_type = type;
+        UPGRADE_TYPE(ctx->self_type, type);
         break;
 
         case TEMP_STACK:
-        ctx->temp_types[ctx->stack_size - 1 - opnd.idx] = type;
+        int stack_index = ctx->stack_size - 1 - opnd.idx;
+        UPGRADE_TYPE(ctx->temp_types[stack_index], type);
         break;
 
         case TEMP_LOCAL:
         RUBY_ASSERT(mapping.idx < MAX_LOCAL_TYPES);
-        ctx->local_types[mapping.idx] = type;
+        UPGRADE_TYPE(ctx->local_types[mapping.idx], type);
         break;
     }
 }
diff --git a/yjit_core.h b/yjit_core.h
index c6790e4f00..9f9a4704f7 100644
--- a/yjit_core.h
+++ b/yjit_core.h
@@ -258,7 +258,7 @@ x86opnd_t ctx_stack_push_local(ctx_t* ctx, size_t local_idx); https://github.com/ruby/ruby/blob/trunk/yjit_core.h#L258
 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_opnd_type(const ctx_t* ctx, insn_opnd_t opnd);
-void ctx_set_opnd_type(ctx_t* ctx, insn_opnd_t opnd, val_type_t type);
+void ctx_upgrade_opnd_type(ctx_t* ctx, insn_opnd_t opnd, val_type_t type);
 void ctx_set_local_type(ctx_t* ctx, size_t idx, val_type_t type);
 void ctx_clear_local_types(ctx_t* ctx);
 int ctx_diff(const ctx_t* src, const ctx_t* dst);
-- 
cgit v1.2.1


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

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