summaryrefslogtreecommitdiff
path: root/yjit_core.c
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2021-08-09 02:11:05 -0700
committerAlan Wu <XrXr@users.noreply.github.com>2021-10-20 18:19:38 -0400
commit6d852e847e163fad0f2ccebe59c57d6921d3c472 (patch)
tree1bb84c08d4b0f554d37f80b5412d9545742f7d32 /yjit_core.c
parent48dca3348ae47fec5f2fa39ae899cbf62f2fae44 (diff)
Fix stack size check for ctx_get_opnd_type
Previously all stack operands would become unknown once the stack grew beyond a certain size. This worked, but unnecessarily hid available information.
Diffstat (limited to 'yjit_core.c')
-rw-r--r--yjit_core.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/yjit_core.c b/yjit_core.c
index a08be3cc74..3f866b0a2b 100644
--- a/yjit_core.c
+++ b/yjit_core.c
@@ -135,11 +135,14 @@ ctx_get_opnd_type(const ctx_t* ctx, insn_opnd_t opnd)
if (opnd.is_self)
return ctx->self_type;
- if (ctx->stack_size >= MAX_TEMP_TYPES)
+ RUBY_ASSERT(opnd.idx < ctx->stack_size);
+ int stack_idx = ctx->stack_size - 1 - opnd.idx;
+
+ // If outside of tracked range, do nothing
+ if (stack_idx >= MAX_TEMP_TYPES)
return TYPE_UNKNOWN;
- RUBY_ASSERT(opnd.idx < ctx->stack_size);
- temp_mapping_t mapping = ctx->temp_mapping[ctx->stack_size - 1 - opnd.idx];
+ temp_mapping_t mapping = ctx->temp_mapping[stack_idx];
switch (mapping.kind)
{