Closed
Bug 845596
Opened 12 years ago
Closed 12 years ago
Keep track of free variables during syntax parsing
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
mozilla23
People
(Reporter: bhackett1024, Unassigned)
References
Details
Attachments
(1 file)
71.73 KB,
patch
|
jorendorff
:
review+
|
Details | Diff | Splinter Review |
In order to generate bytecode for an outer function without also generating code for its inner functions, all free variables within those inner functions need to be known. This allows the outer function to correctly choose LOCAL/ARG or ALIASEDVAR ops for its locals. Free variables can be computed during the syntax parse, and when bytecode is lazily generated the representation for an inner function that has not been compiled will be its set of free variables and a few related bits.
The attached patch makes this change, extending the machinery used during full parses to handle the case where there are no parse nodes. Testing on jQuery, this slows down syntax parses by about 15%, so that syntax parses are about 3.3x faster than a full parse/emit, rather than 3.8x. This degrades the percentages in bug 835587 comment 1 by 4-5%, so not huge, and there isn't any more expensive work that the syntax parse still needs to do. This patch hasn't been exhaustively tested, but seems to do the right thing on small examples (the lack of handling for 'let' simplifies things a lot).
Attachment #718764 -
Flags: review?(jorendorff)
Comment 1•12 years ago
|
||
Comment on attachment 718764 [details] [diff] [review]
patch
Review of attachment 718764 [details] [diff] [review]:
-----------------------------------------------------------------
::: js/src/frontend/FullParseHandler.h
@@ +60,5 @@
> pn->setOp(JSOP_NAME);
> return pn;
> }
> + Definition *newPlaceholder(ParseNode *pn, ParseContext<FullParseHandler> *pc)
> + {
Style nit: brace goes on the previous line.
::: js/src/frontend/Parser.cpp
@@ +935,5 @@
> if (pc->sc->needStrictChecks()) {
> for (AtomDefnListMap::Range r = pc->decls().all(); !r.empty(); r.popFront()) {
> DefinitionList &dlist = r.front().value();
> for (DefinitionList::Range dr = dlist.all(); !dr.empty(); dr.popFront()) {
> + Definition *dn = dr.front<FullParseHandler>();
Is this template parameter necessary?
::: js/src/frontend/SyntaxParseHandler.h
@@ +173,5 @@
> +
> + static uintptr_t definitionToBits(DefinitionNode dn) {
> + // Use a shift, as DefinitionList tags the lower bit of its associated union.
> + return uintptr_t(dn << 1);
> + }
This is all so horrible. But I don't see a good way around it.
Attachment #718764 -
Flags: review?(jorendorff) → review+
Reporter | ||
Comment 2•12 years ago
|
||
Comment 3•12 years ago
|
||
Backed out in https://hg.mozilla.org/integration/mozilla-inbound/rev/adb1bbf756b9 for assertion failures like https://tbpl.mozilla.org/php/getParsedLog.php?id=21780656&tree=Mozilla-Inbound
Comment 4•12 years ago
|
||
Dunno whether the failures in https://tbpl.mozilla.org/php/getParsedLog.php?id=21781062&tree=Mozilla-Inbound are the same thing, or another.
Reporter | ||
Comment 5•12 years ago
|
||
Sorry, forgot to tryserver this first. Try push:
https://tbpl.mozilla.org/?tree=Try&rev=94740085e31e
And repush:
https://hg.mozilla.org/integration/mozilla-inbound/rev/bd17606091d2
Comment 6•12 years ago
|
||
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla23
![]() |
||
Comment 7•12 years ago
|
||
This has broken jsfunfuzz severely with bug 862228.
You need to log in
before you can comment on or make changes to this bug.
Description
•