Closed Bug 845596 Opened 12 years ago Closed 12 years ago

Keep track of free variables during syntax parsing

Categories

(Core :: JavaScript Engine, defect)

Other Branch
x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla23

People

(Reporter: bhackett1024, Unassigned)

References

Details

Attachments

(1 file)

Attached patch patchSplinter 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 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+
Dunno whether the failures in https://tbpl.mozilla.org/php/getParsedLog.php?id=21781062&tree=Mozilla-Inbound are the same thing, or another.
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla23
This has broken jsfunfuzz severely with bug 862228.
Depends on: 862759
Depends on: 864411
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: