Chromium Code Reviews| Index: src/parsing/pattern-rewriter.cc |
| diff --git a/src/parsing/pattern-rewriter.cc b/src/parsing/pattern-rewriter.cc |
| index ff2d66c00fcfc4fbd101a875f081504f3ea14ce8..6ea8907f637ab746a9cdecf4ed1b68949010796f 100644 |
| --- a/src/parsing/pattern-rewriter.cc |
| +++ b/src/parsing/pattern-rewriter.cc |
| @@ -361,12 +361,11 @@ void Parser::PatternRewriter::VisitObjectLiteral(ObjectLiteral* pattern, |
| if (property->kind() == ObjectLiteralProperty::Kind::SPREAD) { |
| // var { y, [x++]: a, ...c } = temp |
| // becomes |
| - // var temp1 = %ToName('y'); |
| - // var y = temp[temp1] |
| - // var temp2 = %ToName(x++); |
| - // var a = temp[temp2]; |
| + // var y = temp[y]; |
|
adamk
2017/01/19 02:04:13
Isn't this temp.y?
gsathya
2017/01/21 00:27:33
Done.
|
| + // var temp1 = %ToName(x++); |
| + // var a = temp[temp1]; |
| // var c; |
| - // c = %CopyDataPropertiesWithExcludedProperties(temp, temp1, temp2); |
| + // c = %CopyDataPropertiesWithExcludedProperties(temp, "y", temp1); |
| value = factory()->NewCallRuntime( |
| Runtime::kCopyDataPropertiesWithExcludedProperties, |
| rest_runtime_callargs, kNoSourcePosition); |
| @@ -379,17 +378,20 @@ void Parser::PatternRewriter::VisitObjectLiteral(ObjectLiteral* pattern, |
| RewriteParameterScopes(key); |
| } |
| - // TODO(gsathya): Skip %ToName runtime call for literals. |
| if (pattern->has_rest_property()) { |
| - auto args = new (zone()) ZoneList<Expression*>(1, zone()); |
| - args->Add(key, zone()); |
| - auto to_name_key = CreateTempVar(factory()->NewCallRuntime( |
| - Runtime::kToName, args, kNoSourcePosition)); |
| - key = factory()->NewVariableProxy(to_name_key); |
| + Expression* excluded_property = key; |
| + |
| + if (!key->IsLiteral()) { |
| + auto args = new (zone()) ZoneList<Expression*>(1, zone()); |
| + args->Add(key, zone()); |
| + auto to_name_key = CreateTempVar(factory()->NewCallRuntime( |
| + Runtime::kToName, args, kNoSourcePosition)); |
| + key = factory()->NewVariableProxy(to_name_key); |
| + excluded_property = factory()->NewVariableProxy(to_name_key); |
| + } |
|
adamk
2017/01/19 02:04:13
Can you add a DCHECK in the else branch about the
gsathya
2017/01/21 00:27:32
Done.
|
| DCHECK(rest_runtime_callargs != nullptr); |
| - rest_runtime_callargs->Add(factory()->NewVariableProxy(to_name_key), |
| - zone()); |
| + rest_runtime_callargs->Add(excluded_property, zone()); |
| } |
| value = factory()->NewProperty(factory()->NewVariableProxy(temp), key, |