Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On less than the latest-and-greatest, V8-TurboFan Chrome, performance tracing runs of apps bundling hyperx produce the dismaying notice "Not optimized: Bad value context for arguments value" for functions returned by hyperx. Best I can tell, V8-Crankshaft bails on optimizing the functions because of the way they use
arguments
, and the fact that vanilla JS treatsarguments[0]
as an alias forx
infunction (x) { ... }
. This causes problems when references fromarguments
get passed on to other functions.I've spent a little time scratching my head, trying various approaches, like allocating a new
Array
and copying references over fromarguments
, to avoid the issue. Someone else might be able to do that more reliably. And anyone who cares to try, or comes upon this later, might like to know that Node.js has a nifty--trace_deopt
flag to print V8's warnings.But it occurred to me that it's far easier to just opt into Strict Mode, where argument aliasing is not a thing. I've confirmed that
'use strict'
coaxes V8-Crankshaft into optimizing the functions, which is a pretty big win, considering when and how often those functions run. And that the tests all pass.That's a lot of background for a one-line patch adding the Strict Mode statement. But I wouldn't usually send such a thing---I don't use Strict Mode much in my own code, and have seen a fair number of irksome "support
--use_strict
" GitHub issues. Here I get the feeling it might make sense.Thanks,
K