Skip to content

Commit

Permalink
Reduce number of checks in GC frame marking.
Browse files Browse the repository at this point in the history
If the frame is no longer in dynamic socpe, we can't possibly have any
args to care about.
  • Loading branch information
jnthn committed Jan 6, 2017
1 parent fdfe07b commit e592dbc
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions src/gc/roots.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,9 @@ void MVM_gc_root_add_frame_registers_to_worklist(MVMThreadContext *tc, MVMGCWork
MVMuint16 *type_map;
MVMuint8 *flag_map;

/* Scan locals. */
/* We only need to any of this work if the frame is in dynamic scope. */

This comment has been minimized.

Copy link
@MasterDuke17

MasterDuke17 Jan 6, 2017

Contributor

"do any"?

This comment has been minimized.

Copy link
@jnthn

jnthn Jan 6, 2017

Author Member

Heh, yes. :-)

if (frame->work) {
/* Scan locals. */
if (frame->spesh_cand && frame->spesh_log_idx == -1 && frame->spesh_cand->local_types) {
type_map = frame->spesh_cand->local_types;
count = frame->spesh_cand->num_locals;
Expand All @@ -401,37 +402,37 @@ void MVM_gc_root_add_frame_registers_to_worklist(MVMThreadContext *tc, MVMGCWork
for (i = 0; i < count; i++)
if (type_map[i] == MVM_reg_str || type_map[i] == MVM_reg_obj)
MVM_gc_worklist_add(tc, worklist, &frame->work[i].o);
}

/* Scan arg buffer if needed. */
if (frame->args && frame->cur_args_callsite) {
flag_map = frame->cur_args_callsite->arg_flags;
count = frame->cur_args_callsite->arg_count;
for (i = 0, flag = 0; i < count; i++, flag++) {
if (flag_map[flag] & MVM_CALLSITE_ARG_NAMED) {
/* Current position is name, then next is value. */
MVM_gc_worklist_add(tc, worklist, &frame->args[i].s);
i++;
/* Scan arg buffer if needed. */
if (frame->cur_args_callsite) {
flag_map = frame->cur_args_callsite->arg_flags;
count = frame->cur_args_callsite->arg_count;
for (i = 0, flag = 0; i < count; i++, flag++) {
if (flag_map[flag] & MVM_CALLSITE_ARG_NAMED) {
/* Current position is name, then next is value. */
MVM_gc_worklist_add(tc, worklist, &frame->args[i].s);
i++;
}
if (flag_map[flag] & MVM_CALLSITE_ARG_STR || flag_map[flag] & MVM_CALLSITE_ARG_OBJ)
MVM_gc_worklist_add(tc, worklist, &frame->args[i].o);
}
if (flag_map[flag] & MVM_CALLSITE_ARG_STR || flag_map[flag] & MVM_CALLSITE_ARG_OBJ)
MVM_gc_worklist_add(tc, worklist, &frame->args[i].o);
}
}

/* Scan arguments in case there was a flattening. Don't need to if
* there wasn't a flattening because orig args is a subset of locals. */
if (frame->params.arg_flags && frame->params.callsite->has_flattening) {
MVMArgProcContext *ctx = &frame->params;
flag_map = ctx->arg_flags;
count = ctx->arg_count;
for (i = 0, flag = 0; i < count; i++, flag++) {
if (flag_map[flag] & MVM_CALLSITE_ARG_NAMED) {
/* Current position is name, then next is value. */
MVM_gc_worklist_add(tc, worklist, &ctx->args[i].s);
i++;
/* Scan arguments in case there was a flattening. Don't need to if
* there wasn't a flattening because orig args is a subset of locals. */
if (frame->params.arg_flags && frame->params.callsite->has_flattening) {
MVMArgProcContext *ctx = &frame->params;
flag_map = ctx->arg_flags;
count = ctx->arg_count;
for (i = 0, flag = 0; i < count; i++, flag++) {
if (flag_map[flag] & MVM_CALLSITE_ARG_NAMED) {
/* Current position is name, then next is value. */
MVM_gc_worklist_add(tc, worklist, &ctx->args[i].s);
i++;
}
if (flag_map[flag] & MVM_CALLSITE_ARG_STR || flag_map[flag] & MVM_CALLSITE_ARG_OBJ)
MVM_gc_worklist_add(tc, worklist, &ctx->args[i].o);
}
if (flag_map[flag] & MVM_CALLSITE_ARG_STR || flag_map[flag] & MVM_CALLSITE_ARG_OBJ)
MVM_gc_worklist_add(tc, worklist, &ctx->args[i].o);
}
}
}
Expand Down

0 comments on commit e592dbc

Please sign in to comment.