summaryrefslogtreecommitdiff
path: root/yjit_core.c
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2021-07-27 23:41:29 -0700
committerAlan Wu <XrXr@users.noreply.github.com>2021-10-20 18:19:38 -0400
commitd78ea4abec1d030af2c5d99b03b3b4d959bd138c (patch)
tree0947dcb40397599770228a2a5e3c58873dc699b2 /yjit_core.c
parenta02002dc4f051515c0b65c17b2ed797bac454b56 (diff)
Implement verify_ctx for debugging
Diffstat (limited to 'yjit_core.c')
-rw-r--r--yjit_core.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/yjit_core.c b/yjit_core.c
index 95bdcc1fa4..0d43129f01 100644
--- a/yjit_core.c
+++ b/yjit_core.c
@@ -33,6 +33,8 @@ ctx_stack_push_mapping(ctx_t* ctx, temp_type_mapping_t mapping)
ctx->temp_types[ctx->stack_size] = mapping.type;
RUBY_ASSERT(mapping.mapping.kind != TEMP_LOCAL || mapping.mapping.idx < MAX_LOCAL_TYPES);
+ RUBY_ASSERT(mapping.mapping.kind != TEMP_STACK || mapping.mapping.idx == 0);
+ RUBY_ASSERT(mapping.mapping.kind != TEMP_SELF || mapping.mapping.idx == 0);
}
ctx->stack_size += 1;
@@ -155,7 +157,6 @@ 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); \
@@ -283,6 +284,44 @@ void ctx_clear_local_types(ctx_t* ctx)
memset(&ctx->local_types, 0, sizeof(ctx->local_types));
}
+/* The name of a type, for debugging */
+const char *
+yjit_type_name(val_type_t type)
+{
+ RUBY_ASSERT(!(type.is_imm && type.is_heap));
+
+ switch (type.type) {
+ case ETYPE_UNKNOWN:
+ if (type.is_imm) {
+ return "unknown immediate";
+ } else if (type.is_heap) {
+ return "unknown heap";
+ } else {
+ return "unknown";
+ }
+ case ETYPE_NIL:
+ return "nil";
+ case ETYPE_TRUE:
+ return "true";
+ case ETYPE_FALSE:
+ return "false";
+ case ETYPE_FIXNUM:
+ return "fixnum";
+ case ETYPE_FLONUM:
+ return "flonum";
+ case ETYPE_ARRAY:
+ return "array";
+ case ETYPE_HASH:
+ return "hash";
+ case ETYPE_SYMBOL:
+ return "symbol";
+ case ETYPE_STRING:
+ return "string";
+ }
+
+ UNREACHABLE_RETURN("");
+}
+
/*
Compute a difference between two value types
Returns 0 if the two are the same