Commit c42f188c authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[turbofan] Fix OSR entry in case label.

With do-expressions any expression used as a case label can turn into an
OSR entry-point. This means the value being switched over is renamed to
an OSR value and needs to be reloaded from the environment at each case.

R=rossberg@chromium.org
TEST=mjsunit/regress/regress-osr-in-case-label

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

Cr-Commit-Position: refs/heads/master@{#31986}
parent f25e0f2f
...@@ -1204,7 +1204,6 @@ void AstGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) { ...@@ -1204,7 +1204,6 @@ void AstGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) {
// Keep the switch value on the stack until a case matches. // Keep the switch value on the stack until a case matches.
VisitForValue(stmt->tag()); VisitForValue(stmt->tag());
Node* tag = environment()->Top();
// Iterate over all cases and create nodes for label comparison. // Iterate over all cases and create nodes for label comparison.
for (int i = 0; i < clauses->length(); i++) { for (int i = 0; i < clauses->length(); i++) {
...@@ -1220,6 +1219,7 @@ void AstGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) { ...@@ -1220,6 +1219,7 @@ void AstGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) {
// value is still on the operand stack while the label is evaluated. // value is still on the operand stack while the label is evaluated.
VisitForValue(clause->label()); VisitForValue(clause->label());
Node* label = environment()->Pop(); Node* label = environment()->Pop();
Node* tag = environment()->Top();
const Operator* op = javascript()->StrictEqual(); const Operator* op = javascript()->StrictEqual();
Node* condition = NewNode(op, tag, label); Node* condition = NewNode(op, tag, label);
compare_switch.BeginLabel(i, condition); compare_switch.BeginLabel(i, condition);
......
...@@ -1005,6 +1005,7 @@ ...@@ -1005,6 +1005,7 @@
'regress/regress-lazy-deopt-reloc': [SKIP], 'regress/regress-lazy-deopt-reloc': [SKIP],
'regress/regress-map-invalidation-2': [SKIP], 'regress/regress-map-invalidation-2': [SKIP],
'regress/regress-opt-after-debug-deopt': [SKIP], 'regress/regress-opt-after-debug-deopt': [SKIP],
'regress/regress-osr-in-case-label': [SKIP],
'regress/regress-param-local-type': [SKIP], 'regress/regress-param-local-type': [SKIP],
'regress/regress-prepare-break-while-recompile': [SKIP], 'regress/regress-prepare-break-while-recompile': [SKIP],
'regress/regress-put-prototype-transition': [SKIP], 'regress/regress-put-prototype-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 --harmony-do-expressions
function f(x) {
switch (x) {
case 1: return "one";
case 2: return "two";
case do { for (var i = 0; i < 10; i++) { if (i == 5) %OptimizeOsr(); } }:
case 3: return "WAT";
}
}
assertEquals("one", f(1));
assertEquals("two", f(2));
assertEquals("WAT", f(3));
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