-
-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In ASSIGN-POS, unbox the index just once
Measurements suggests this performs better, which is what would be expected.
- Loading branch information
Showing
1 changed file
with
4 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86d91f2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, I'm surprised
86d91f2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not in this commit, but I'll mention it: the code-gen for this ends up with the
my \reified := nqp::getattr(self,List,'$!reified');
being lowered to a register, which is very helpful. The initial getatttr is guarded; prior to this it was guarded on multiple accesses, so there's some guard savings there (guards are cheap but not free).The
$ipos
actually isn't register lowered to a register yet, but it's a native integer lexical, so there's noScalar
allocation that needs to happen. Since every routine has$/
and$!
then we'd be allocating lexical storage anyway, so one more isn't really an extra cost, just an 8 byte bigger buffer. Further, the compilation is smart enough in this (easy) case to not acquire any lexical references. just to do cheap loads of the lexical, and they're all done by index (and that JITs very nicely). By contrast, an unbox has to do a bounds check to make sure the unboxed value will fit into a native integer, as well as the unbox itself. Pre-spesh, there's alsodecont
s for$pos
too before the unbox; spesh can rip those out, but speeding up the pre-specialization path is also nice.