Skip to content

propagate back assignments to block scoped binding from the loop body#6898

Merged
vladima merged 2 commits into
masterfrom
modifiedBlockScopedBinding
Feb 4, 2016
Merged

propagate back assignments to block scoped binding from the loop body#6898
vladima merged 2 commits into
masterfrom
modifiedBlockScopedBinding

Conversation

@vladima
Copy link
Copy Markdown
Contributor

@vladima vladima commented Feb 4, 2016

fixes #6877.
NOTE: it will be cleaner to emit loop body as

let loop = function(...) {
    try { loop body }
    finally { copy local values to out parameters }
}

instead of writing copy snippet at every point where control flow exits loop. However currently V8 does not optimize protected regions so between prettiness and perf of generated code I'd prefer to favor the second one

};
var out_i_1;
for (var i = 0; i < 9; ++i) {
out_i_1 = i;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i do not think we need this, since the function is guaranteed to set the correct value.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, will do

@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented Feb 4, 2016

👍 with the removal of the extra assignment.

vladima added a commit that referenced this pull request Feb 4, 2016
propagate back assignments to block scoped binding from the loop body
@vladima vladima merged commit 0dae547 into master Feb 4, 2016
@vladima vladima deleted the modifiedBlockScopedBinding branch February 4, 2016 21:18
vladima added a commit that referenced this pull request Feb 4, 2016
vladima added a commit that referenced this pull request Feb 5, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect behavior of loop contains block-scoped variables in es5 and es3

3 participants