Closed Bug 1227677 Opened 9 years ago Closed 9 years ago

Disentangle comprehension for-in/of handling from for-in/of loop handling

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: Waldo, Assigned: Waldo)

References

Details

Attachments

(6 files)

Quarantine the contagion!
This might/might not belong in this bug, but I happened to develop the rest of these atop this, and it's a minimal patch. <none>
Attachment #8691517 - Flags: review?(shu)
Lots of copypasta, alas. Aside from removing the code definitely not relevant to comprehensions (the spreading cases, mostly), and adding stack-related comments, I didn't make actual changes.
Attachment #8691607 - Flags: review?(shu)
It matches the variable's used meaning more (used to determine when to push/pop a block scope). And |letDecl| implies relevance to |let| declarations, but |for (let x of []);| doesn't actually trigger |*letDecl|.
Attachment #8691611 - Flags: review?(shu)
Parser::forStatement never produces PNK_FOR{IN,OF} with first kid not either null or a declaration -- only comprehensions can have PNK_LEXICALSCOPE. Cleaning up the comprehension code as the complement to this is left to a separate patch.
Attachment #8691612 - Flags: review?(shu)
The code/comments as they exist now, for for-in/of regardless of comprehensions or not, are a bit wrong. Rewrite some, and simplify the code too.
Attachment #8691617 - Flags: review?(shu)
Comment on attachment 8691517 [details] [diff] [review] Some minor renaming in for-in stuffs Review of attachment 8691517 [details] [diff] [review]: ----------------------------------------------------------------- ::: js/src/frontend/Parser.cpp @@ -5371,5 @@ > bool constDecl = tt == TOK_CONST; > isForDecl = true; > - blockObj = StaticBlockObject::create(context); > - if (!blockObj) > - return null(); lol I think jorendorff also removed this recently.
Attachment #8691517 - Flags: review?(shu) → review+
Comment on attachment 8691575 [details] [diff] [review] Extract PNK_COMPREHENSIONFOR from PNK_FOR so that comprehension gunk doesn't taint for-loop emitting logic Review of attachment 8691575 [details] [diff] [review]: ----------------------------------------------------------------- In itself the patch doesn't do anything. I'm assuming the juicy stuff is in the later patches. ::: js/src/frontend/Parser.cpp @@ +7910,1 @@ > nullptr, nullptr); Why is this not switched to handler.newComprehensionFor? I suppose it's because the for-head and the body aren't yet parsed at this point, and are assigned later. Indeed, legacyComprehensionTail is a terrifying function, so it's fine to leave this as is.
Attachment #8691575 - Flags: review?(shu) → review+
Comment on attachment 8691607 [details] [diff] [review] Emit code for PNK_COMPREHENSIONFOR using separate code from that used for for-loops Review of attachment 8691607 [details] [diff] [review]: ----------------------------------------------------------------- This is literally copied emitForIn, emitForOf, and emitForInOrOfVariables, but renamed, right? I did not read them super closely. ::: js/src/frontend/BytecodeEmitter.cpp @@ +5905,5 @@ > + // > + // In `for (let x in/of EXPR)`, ES6 specifies that EXPR is evaluated in a > + // scope containing an uninitialized `x`. If EXPR accesses `x`, we should > + // get a ReferenceError due to the TDZ violation. This is not yet > + // implemented. See bug 1069480. Does this comment apply to the comprehension case? Doesn't seem to.
Attachment #8691607 - Flags: review?(shu) → review+
Attachment #8691611 - Flags: review?(shu) → review+
Attachment #8691612 - Flags: review?(shu) → review+
Attachment #8691617 - Flags: review?(shu) → review+
Horrifically bad try-results that I don't really believe at all (I think it's just a steady stream of unrelated intermittent-orange) have me pushing this in some increments. That's just the first one, rest to come whenever I manage to convince myself there's not real bustage in them. Somehow. Seeing as I don't think there is now but fear the tree-gods.
Keywords: leave-open
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Keywords: leave-open
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: