Closed
Bug 696108
Opened 13 years ago
Closed 13 years ago
extract EmitFor
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla10
People
(Reporter: luke, Assigned: luke)
Details
Attachments
(1 file, 3 obsolete files)
22.11 KB,
patch
|
jorendorff
:
review+
|
Details | Diff | Splinter Review |
Two simple patches:
1. extract the TOK_FOR case in EmitTree into EmitFor and pushes declarations down to uses
2. simplify the handling of 'for (let (x=expr) expr; ...; ...)'
Attachment #568408 -
Flags: review?(jorendorff)
Assignee | ||
Comment 1•13 years ago
|
||
Attachment #568409 -
Flags: review?(jorendorff)
Assignee | ||
Comment 2•13 years ago
|
||
A reftest caught a change in the SyntaxError message produced.
Attachment #568409 -
Attachment is obsolete: true
Attachment #568409 -
Flags: review?(jorendorff)
Attachment #568415 -
Flags: review?(jorendorff)
Assignee | ||
Comment 3•13 years ago
|
||
Comment on attachment 568415 [details] [diff] [review]
simplify let expr in for init (with reftest fix)
Actually, this does change behavior so nevermind. I'm little new here, please excuse me :)
Attachment #568415 -
Flags: review?(jorendorff)
Assignee | ||
Updated•13 years ago
|
Summary: simplify 'for (let (x=expr) expr; ...; ...)' and extract EmitFor → extract EmitFor
Assignee | ||
Comment 4•13 years ago
|
||
Actually, there is practically zero commonality to the for-in and normal for (1 call to PopStatementCG and a source note) so they can be further split. The patch also s/pn->pn_left/forHead/ and s/pn->pn_right/forBody/.
Attachment #568408 -
Attachment is obsolete: true
Attachment #568415 -
Attachment is obsolete: true
Attachment #568408 -
Flags: review?(jorendorff)
Attachment #568547 -
Flags: review?(jorendorff)
Comment 5•13 years ago
|
||
Comment on attachment 568547 [details] [diff] [review]
hoist EmitFor, split into EmitForIn and EmitNormalFor
Review of attachment 568547 [details] [diff] [review]:
-----------------------------------------------------------------
r=me, with a few nits to pick in the pre-existing code.
::: js/src/frontend/BytecodeGenerator.cpp
@@ +5641,5 @@
> + (forHead->pn_kid1->isOp(JSOP_DEFVAR))
> + ? SRC_DECL_VAR
> + : SRC_DECL_LET) < 0) {
> + return false;
> + }
Put the '{' on its own line, please.
@@ +5796,5 @@
> + ptrdiff_t off = pn->pn_pos.end.lineno;
> + if (CG_CURRENT_LINE(cg) != (uintN) off) {
> + if (NewSrcNote2(cx, cg, SRC_SETLINE, off) < 0)
> + return false;
> + CG_CURRENT_LINE(cg) = (uintN) off;
This just used 'off' because it was a convenient tmp variable. It could be renamed to lineno, and its type might as well be uintN (though you'd still need one cast, to avoid warnings).
@@ +5830,5 @@
> + if (forHead->pn_kid2) {
> + ptrdiff_t beq = EmitJump(cx, cg, JSOP_IFNE, top - CG_OFFSET(cg));
> + if (beq < 0)
> + return false;
> + } else {
The temporary beq is unnecessary here. And after removing it, you might want to combine this with the else-block, which is very similar.
Attachment #568547 -
Flags: review?(jorendorff) → review+
Assignee | ||
Comment 6•13 years ago
|
||
(In reply to Jason Orendorff [:jorendorff] from comment #5)
> > + (forHead->pn_kid1->isOp(JSOP_DEFVAR))
> > + ? SRC_DECL_VAR
> > + : SRC_DECL_LET) < 0) {
> > + return false;
> > + }
>
> Put the '{' on its own line, please.
For the style record: we agreed on irc that for multi-line conditions, the { could stay on the same line if there was no lexical run-on from the condition to the body as is the case here.
Assignee | ||
Comment 7•13 years ago
|
||
Target Milestone: --- → mozilla10
Comment 8•13 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•