8000 Merge pull request #123 from jhawthorn/flatten_locals_on_clear · eileencodes/ruby@fdf38be · GitHub
[go: up one dir, main page]

Skip to content

Commit fdf38be

Browse files
authored
Merge pull request ruby#123 from jhawthorn/flatten_locals_on_clear
Flatten mappings when clearing locals
2 parents 7d1dd60 + b195671 commit fdf38be

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

yjit_core.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,16 @@ void ctx_set_local_type(ctx_t* ctx, size_t idx, val_type_t type)
201201
// eg: because of a call we can't track
202202
void ctx_clear_local_types(ctx_t* ctx)
203203
{
204+
// When clearing local types we must detach any stack mappings to those
205+
// locals. Even if local values may have changed, stack values will not.
206+
for (int i = 0; i < ctx->stack_size && i < MAX_LOCAL_TYPES; i++) {
207+
temp_mapping_t *mapping = &ctx->temp_mapping[i];
208+
if (mapping->kind == TEMP_LOCAL) {
209+
RUBY_ASSERT(mapping->idx < MAX_LOCAL_TYPES);
210+
ctx->temp_types[i] = ctx->local_types[mapping->idx];
211+
*mapping = MAP_STACK;
212+
}
213+
}
204214
memset(&ctx->local_types, 0, sizeof(ctx->local_types));
205215
}
206216

0 commit comments

Comments
 (0)
0