[crankshaft] Fix crash when case labels inline endless loops

The fix is to bail out of compilation in that case.

BUG=chromium:551287
LOG=n
R=yangguo@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#32454}
This commit is contained in:
jkummerow 2015-12-01 04:16:53 -08:00 committed by Commit bot
parent 51d6d61933
commit 3cb3a6fe4a
3 changed files with 20 additions and 1 deletions

View File

@ -250,6 +250,7 @@ namespace internal {
V(kUnsupportedPhiUseOfConstVariable, \
"Unsupported phi use of const variable") \
V(kUnexpectedReturnFromThrow, "Unexpectedly returned from a throw") \
V(kUnsupportedSwitchStatement, "Unsupported switch statement") \
V(kUnsupportedTaggedImmediate, "Unsupported tagged immediate") \
V(kVariableResolvedToWithContext, "Variable resolved to with context") \
V(kWeShouldNotHaveAnEmptyLexicalContext, \

View File

@ -5044,7 +5044,8 @@ void HOptimizedGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) {
}
// Generate a compare and branch.
CHECK_ALIVE(VisitForValue(clause->label()));
CHECK_BAILOUT(VisitForValue(clause->label()));
if (current_block() == NULL) return Bailout(kUnsupportedSwitchStatement);
HValue* label_value = Pop();
Type* label_type = clause->label()->bounds().lower;

View File

@ -0,0 +1,17 @@
// 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() { do { } while (true); }
function boom(x) {
switch(x) {
case 1:
case f(): return;
}
}
%OptimizeFunctionOnNextCall(boom)
boom(1);