Skip to content

Commit

Permalink
NULL out registers on re-OSR.
Browse files Browse the repository at this point in the history
If we previously ran the OSR'd code for this frame, then we don't need
to resize work/env. However, they were unused while the deopt code was
being run, and so may contain outdated pointers that will upset the
GC if it comes across them. Fix this by making sure that space is
cleared out.
  • Loading branch information
jnthn committed Jul 24, 2017
1 parent b351124 commit 217334e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/spesh/osr.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ void perform_osr(MVMThreadContext *tc, MVMSpeshCandidate *specialized) {
MVM_string_utf8_encode_C_string(tc, tc->cur_frame->static_info->body.cuuid));
#endif
}
else if (specialized->work_size > tc->cur_frame->static_info->body.work_size) {
size_t keep_bytes = tc->cur_frame->static_info->body.num_locals * sizeof(MVMRegister);
size_t to_null = specialized->work_size - keep_bytes;
memset((char *)tc->cur_frame->work + keep_bytes, 0, to_null);
}

/* Resize environment if needed. */
if (specialized->num_lexicals > tc->cur_frame->static_info->body.num_lexicals) {
Expand All @@ -71,6 +76,11 @@ void perform_osr(MVMThreadContext *tc, MVMSpeshCandidate *specialized) {
MVM_string_utf8_encode_C_string(tc, tc->cur_frame->static_info->body.cuuid));
#endif
}
else if (specialized->env_size > tc->cur_frame->static_info->body.env_size) {
size_t keep_bytes = tc->cur_frame->static_info->body.num_lexicals * sizeof(MVMRegister);
size_t to_null = specialized->env_size - keep_bytes;
memset((char *)tc->cur_frame->env + keep_bytes, 0, to_null);
}

/* Set up frame to point to specialized code. */
tc->cur_frame->effective_bytecode = specialized->bytecode;
Expand Down

0 comments on commit 217334e

Please sign in to comment.