From e7292b3c1a0b79b1953d95b52e2f5f7bd58b9d1a Mon Sep 17 00:00:00 2001 From: mstarzinger Date: Wed, 29 Apr 2015 02:22:35 -0700 Subject: [PATCH] [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} --- src/compiler.cc | 9 +++++---- src/compiler/ast-graph-builder.cc | 7 +++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/compiler.cc b/src/compiler.cc index f44f092..ef27b81 100644 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -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()) diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc index 742797c..6809cfe 100644 --- a/src/compiler/ast-graph-builder.cc +++ b/src/compiler/ast-graph-builder.cc @@ -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()); -- 2.7.4