summaryrefslogtreecommitdiff
path: root/yjit_core.c
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2021-07-14 11:52:00 -0700
committerAlan Wu <XrXr@users.noreply.github.com>2021-10-20 18:19:38 -0400
commit4ea69e5c0b6163dbc6cdd75b2a44720d2b84a5f6 (patch)
tree7abf5a6408aa9fab1aa750febf6b4f8054365ccc /yjit_core.c
parent53079ca585161b882b37945b31802f6d477bbb1e (diff)
Rename to ctx_upgrade_opnd_type
Diffstat (limited to 'yjit_core.c')
-rw-r--r--yjit_core.c18
1 files changed, 13 insertions, 5 deletions
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)
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)
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;
}
}