1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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.
This commit is contained in:
John Hawthorn 2021-08-09 02:11:05 -07:00 committed by Alan Wu
parent 48dca3348a
commit 6d852e847e

View file

@ -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)
{