Commit 279f2aad authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[turbofan] Fix deoptimization from array literal spread.

This fixes the array literal expression stack tracking in the presence
of spread expressions. Deoptimization within a spread expression was
borked.

R=bmeurer@chromium.org
TEST=mjsunit/regress/regress-deopt-in-array-literal-spread

Review URL: https://codereview.chromium.org/1455953002

Cr-Commit-Position: refs/heads/master@{#32079}
parent 6c85c148
...@@ -1951,7 +1951,6 @@ void AstGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { ...@@ -1951,7 +1951,6 @@ void AstGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
environment()->Pop(); // Array literal index. environment()->Pop(); // Array literal index.
for (; array_index < expr->values()->length(); array_index++) { for (; array_index < expr->values()->length(); array_index++) {
Expression* subexpr = expr->values()->at(array_index); Expression* subexpr = expr->values()->at(array_index);
Node* array = environment()->Pop();
Node* result; Node* result;
if (subexpr->IsSpread()) { if (subexpr->IsSpread()) {
...@@ -1959,6 +1958,7 @@ void AstGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { ...@@ -1959,6 +1958,7 @@ void AstGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
FrameStateBeforeAndAfter states(this, FrameStateBeforeAndAfter states(this,
subexpr->AsSpread()->expression()->id()); subexpr->AsSpread()->expression()->id());
Node* iterable = environment()->Pop(); Node* iterable = environment()->Pop();
Node* array = environment()->Pop();
Node* function = BuildLoadNativeContextField( Node* function = BuildLoadNativeContextField(
Context::CONCAT_ITERABLE_TO_ARRAY_BUILTIN_INDEX); Context::CONCAT_ITERABLE_TO_ARRAY_BUILTIN_INDEX);
result = NewNode(javascript()->CallFunction(3, language_mode()), function, result = NewNode(javascript()->CallFunction(3, language_mode()), function,
...@@ -1967,6 +1967,7 @@ void AstGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { ...@@ -1967,6 +1967,7 @@ void AstGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
} else { } else {
VisitForValue(subexpr); VisitForValue(subexpr);
Node* value = environment()->Pop(); Node* value = environment()->Pop();
Node* array = environment()->Pop();
const Operator* op = const Operator* op =
javascript()->CallRuntime(Runtime::kAppendElement, 2); javascript()->CallRuntime(Runtime::kAppendElement, 2);
result = NewNode(op, array, value); result = NewNode(op, array, value);
......
...@@ -994,6 +994,7 @@ ...@@ -994,6 +994,7 @@
'regress/regress-crbug-546968': [SKIP], 'regress/regress-crbug-546968': [SKIP],
'regress/regress-deopt-gcb': [SKIP], 'regress/regress-deopt-gcb': [SKIP],
'regress/regress-deopt-gc': [SKIP], 'regress/regress-deopt-gc': [SKIP],
'regress/regress-deopt-in-array-literal-spread': [SKIP],
'regress/regress-embedded-cons-string': [SKIP], 'regress/regress-embedded-cons-string': [SKIP],
'regress/regress-existing-shared-function-info': [SKIP], 'regress/regress-existing-shared-function-info': [SKIP],
'regress/regress-fast-literal-transition': [SKIP], 'regress/regress-fast-literal-transition': [SKIP],
......
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
function f(a,b,c,d) { return [a, ...(%DeoptimizeNow(), [b,c]), d]; }
assertEquals([1,2,3,4], f(1,2,3,4));
assertEquals([1,2,3,4], f(1,2,3,4));
%OptimizeFunctionOnNextCall(f);
assertEquals([1,2,3,4], f(1,2,3,4));
...@@ -17,6 +17,7 @@ var testCases = [ ...@@ -17,6 +17,7 @@ var testCases = [
{ s:"{ [do { _OSR_ 'b' }]: 3 }", r:{ b:3 } }, { s:"{ [do { _OSR_ 'b' }]: 3 }", r:{ b:3 } },
{ s:"{ [do { _OSR_ 'b' }]: 3, c: 4 }", r:{ b:3, c:4 } }, { s:"{ [do { _OSR_ 'b' }]: 3, c: 4 }", r:{ b:3, c:4 } },
{ s:"{ [do { _OSR_ 'b' }]: 3, __proto__:p }", r:{ b:3, __proto__:p } }, { s:"{ [do { _OSR_ 'b' }]: 3, __proto__:p }", r:{ b:3, __proto__:p } },
{ s:"{ get [do { _OSR_ 'c' }]() { return 4; } }", r:{ c:4 } },
{ s:"class { [do { _OSR_ 'f' }]() {} }" }, { s:"class { [do { _OSR_ 'f' }]() {} }" },
{ s:"class { [do { _OSR_ 'f' }]() {}; g() {} }" }, { s:"class { [do { _OSR_ 'f' }]() {}; g() {} }" },
]; ];
......
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