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

[turbofan] Correctly handle illegal redeclarations.

R=titzer@chromium.org
TEST=mjsunit/const-redecl

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

Cr-Commit-Position: refs/heads/master@{#28125}
parent fefe91ce
......@@ -348,10 +348,6 @@ OptimizedCompileJob::Status OptimizedCompileJob::CreateGraph() {
return AbortOptimization(kTooManyParametersLocals);
}
if (scope->HasIllegalRedeclaration()) {
return AbortOptimization(kFunctionWithIllegalRedeclaration);
}
// Check the whitelist for Crankshaft.
if (!info()->closure()->PassesFilter(FLAG_hydrogen_filter)) {
return AbortOptimization(kHydrogenFilter);
......@@ -409,6 +405,11 @@ OptimizedCompileJob::Status OptimizedCompileJob::CreateGraph() {
// Do not use Crankshaft if the code is intended to be serialized.
if (!isolate()->use_crankshaft()) return SetLastStatus(FAILED);
if (scope->HasIllegalRedeclaration()) {
// Crankshaft cannot handle illegal redeclarations.
return AbortOptimization(kFunctionWithIllegalRedeclaration);
}
if (FLAG_trace_opt) {
OFStream os(stdout);
os << "[compiling method " << Brief(*info()->closure())
......
......@@ -514,6 +514,13 @@ void AstGraphBuilder::CreateGraphBody(bool stack_check) {
NewNode(javascript()->CallRuntime(Runtime::kTraceEnter, 0));
}
// Visit illegal re-declaration and bail out if it exists.
if (scope->HasIllegalRedeclaration()) {
AstEffectContext for_effect(this);
scope->VisitIllegalRedeclaration(this);
return;
}
// Visit implicit declaration of the function name.
if (scope->is_function_scope() && scope->function() != NULL) {
VisitVariableDeclaration(scope->function());
......
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