Commit 0c827cd0 authored by marja's avatar marja Committed by Commit bot

PreParsing inner funcs: Remove nonsense code from PreParser.

The assignment in default parameters (e.g., function foo(a = somedefault) { }
doesn't flow through PreParserFactory::NewAssignment even if the comment claims so.
Thus, piping through the variables is not needed.

Kudos to neis@ for pointing this out.

BUG=v8:5501
R=neis@chromium.org

Review-Url: https://codereview.chromium.org/2569983003
Cr-Commit-Position: refs/heads/master@{#41670}
parent 1df36a80
......@@ -156,10 +156,9 @@ class PreParserExpression {
return PreParserExpression(TypeField::encode(kExpression));
}
static PreParserExpression Assignment(ZoneList<VariableProxy*>* variables) {
static PreParserExpression Assignment() {
return PreParserExpression(TypeField::encode(kExpression) |
ExpressionTypeField::encode(kAssignment),
variables);
ExpressionTypeField::encode(kAssignment));
}
static PreParserExpression ObjectLiteral(
......@@ -618,8 +617,7 @@ class PreParserFactory {
PreParserExpression left,
PreParserExpression right,
int pos) {
// For tracking variables for parameters with a default value.
return PreParserExpression::Assignment(left.variables_);
return PreParserExpression::Assignment();
}
PreParserExpression NewYield(PreParserExpression generator_object,
PreParserExpression expression, int pos,
......
......@@ -8467,6 +8467,12 @@ TEST(NoPessimisticContextAllocation) {
{"function inner() { var {my_var : a} = {my_var}; }", true},
{"function inner() { let {my_var : a} = {my_var}; }", true},
{"function inner() { const {my_var : a} = {my_var}; }", true},
{"function inner(a = my_var) { }", true},
{"function inner() { function inner2(a = my_var) { } }", true},
{"function inner({a} = {a: my_var}) { }", true},
{"function inner() { function inner2({a} = {a: my_var}) { } }", true},
{"function inner([a] = [my_var]) { }", true},
{"function inner() { function inner2([a] = [my_var]) { } }", true},
// No pessimistic context allocation:
{"function inner() { var my_var; my_var; }", false},
{"function inner() { var my_var; }", false},
......@@ -8485,35 +8491,66 @@ TEST(NoPessimisticContextAllocation) {
{"function inner() { const {my_var} = {my_var: 3}; my_var; }", false},
{"function inner(my_var) { my_var; }", false},
{"function inner(my_var) { }", false},
{"function inner(my_var = 5) { my_var; }", false},
{"function inner(my_var = 5) { }", false},
{"function inner(...my_var) { my_var; }", false},
{"function inner(...my_var) { }", false},
{"function inner([a, my_var, b]) { my_var; }", false},
{"function inner([a, my_var, b]) { }", false},
{"function inner([a, my_var, b] = [1, 2, 3]) { my_var; }", false},
{"function inner([a, my_var, b] = [1, 2, 3]) { }", false},
{"function inner({x: my_var}) { my_var; }", false},
{"function inner({x: my_var}) { }", false},
{"function inner({x: my_var} = {x: 0}) { my_var; }", false},
{"function inner({x: my_var} = {x: 0}) { }", false},
{"function inner({my_var}) { my_var; }", false},
{"function inner({my_var}) { }", false},
{"function inner({my_var} = {my_var: 0}) { my_var; }", false},
{"function inner({my_var} = {my_var: 0}) { }", false},
{"function inner() { function inner2(my_var) { my_var; } }", false},
{"function inner() { function inner2(my_var) { } }", false},
{"function inner() { function inner2(my_var = 5) { my_var; } }", false},
{"function inner() { function inner2(my_var = 5) { } }", false},
{"function inner() { function inner2(...my_var) { my_var; } }", false},
{"function inner() { function inner2(...my_var) { } }", false},
{"function inner() { function inner2([a, my_var, b]) { my_var; } }",
false},
{"function inner() { function inner2([a, my_var, b]) { } }", false},
{"function inner() { function inner2([a, my_var, b] = [1, 2, 3]) { "
"my_var; } }",
false},
{"function inner() { function inner2([a, my_var, b] = [1, 2, 3]) { } }",
false},
{"function inner() { function inner2({x: my_var}) { my_var; } }", false},
{"function inner() { function inner2({x: my_var}) { } }", false},
{"function inner() { function inner2({x: my_var} = {x: 0}) { my_var; } }",
false},
{"function inner() { function inner2({x: my_var} = {x: 0}) { } }", false},
{"function inner() { function inner2({my_var}) { my_var; } }", false},
{"function inner() { function inner2({my_var}) { } }", false},
{"function inner() { function inner2({my_var} = {my_var: 8}) { my_var; } "
"}",
false},
{"function inner() { function inner2({my_var} = {my_var: 8}) { } }",
false},
{"my_var => my_var; ", false},
{"my_var => { }", false},
{"(my_var = 5) => my_var; ", false},
{"(my_var = 5) => { }", false},
{"(...my_var) => my_var;", false},
{"(...my_var) => { }", false},
{"([a, my_var, b]) => my_var;", false},
{"([a, my_var, b]) => { }", false},
{"([a, my_var, b] = [1, 2, 3]) => my_var;", false},
{"([a, my_var, b] = [1, 2, 3]) => { }", false},
{"({x: my_var}) => my_var;", false},
{"({x: my_var}) => { }", false},
{"({x: my_var} = {x: 0}) => my_var;", false},
{"({x: my_var} = {x: 0}) => { }", false},
{"({my_var}) => my_var;", false},
{"({my_var}) => { }", false},
{"({my_var} = {my_var: 5}) => my_var;", false},
{"({my_var} = {my_var: 5}) => { }", false},
{"function inner() { try { } catch (my_var) { } }", false},
{"function inner() { class my_var {}; }", false},
// In the following cases we still context allocate pessimistically:
......@@ -8525,16 +8562,24 @@ TEST(NoPessimisticContextAllocation) {
{"function inner() { for (my_var of {}) { } }", true},
{"function inner() { for (my_var in []) { my_var; } }", true},
{"function inner() { for (my_var in []) { } }", true},
{"function inner() { my_var => my_var; }", true},
{"function inner() { my_var => my_var; }", true},
{"function inner() { my_var => { }}", true},
{"function inner() { (...my_var) => my_var;}", true},
{"function inner() { (my_var = 5) => my_var; }", true},
{"function inner() { (my_var = 5) => { }}", true},
{"function inner() { (...my_var) => my_var;}", true},
{"function inner() { (...my_var) => { }}", true},
{"function inner() { ([a, my_var, b]) => my_var;}", true},
{"function inner() { ([a, my_var, b]) => { }}", true},
{"function inner() { ([a, my_var, b] = [1, 2, 3]) => my_var;}", true},
{"function inner() { ([a, my_var, b] = [1, 2, 3]) => { }}", true},
{"function inner() { ({x: my_var}) => my_var;}", true},
{"function inner() { ({x: my_var}) => { }}", true},
{"function inner() { ({x: my_var} = {x: 0}) => my_var;}", true},
{"function inner() { ({x: my_var} = {x: 0}) => { }}", true},
{"function inner() { ({my_var}) => my_var;}", true},
{"function inner() { ({my_var}) => { }}", true},
{"function inner() { ({my_var} = {my_var: 5}) => my_var;}", true},
{"function inner() { ({my_var} = {my_var: 5}) => { }}", true},
{"function inner() { class my_var {}; my_var }", true},
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment