Skip to content

Commit

Permalink
VM: return the loop, it is needed for best performance
Browse files Browse the repository at this point in the history
  • Loading branch information
bjourne committed Sep 26, 2016
1 parent da670c0 commit c6faf98
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions vm/nursery_collector.cpp
Expand Up @@ -14,10 +14,13 @@ struct nursery_copier : no_fixup {
return obj;
}

if (obj->forwarding_pointer_p()) {
object* dest = obj->forwarding_pointer();
FACTOR_ASSERT(!nursery->contains_p(dest));
return dest;
// The while-loop is a needed micro-optimization.
while (obj->forwarding_pointer_p()) {
obj = obj->forwarding_pointer();
}

if (!nursery->contains_p(obj)) {
return obj;
}

cell size = obj->size();
Expand Down

1 comment on commit c6faf98

@bjourne
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slava and Joe Groff knew what they were doing! The while-loop is functionally the same as the if-statement but for some reason I have no idea about it is required to make the compilers generate the best code.

Please sign in to comment.