-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
According to the spec, "undefined" as the mapFn arg should not throw.
- Loading branch information
Showing
2 changed files
with
5 additions
and
2 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
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
3ac0659
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.
Ah, yes, I think they changed the spec here. Could you double check the line before it:
var mapFn = arguments.length > 1 ? arguments[1] : undefined;
-- I think they changed that to ignorearguments.length
and just look at the value as well.3ac0659
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.
ah, good call. unfortunately checking
arguments
indexes that are larger than the length severely deoptimizes the JIT in v8, so it will incur a performance hit when it's not supplied. :-/3ac0659
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.
So actually - to my reading, the difference is that if it's supplied as literal
undefined
, that should be treated the same as if it wasn't supplied - whereas forthisArg
, if it's supplied asundefined
, that's different than if it's not supplied.So, I think the
var mapFn =
line is correct as-is.3ac0659
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.
You're right, the arguments check should be harmless in terms of semantics, and it prevents deoptimization that's all good.