diff --git a/src/compiler.cc b/src/compiler.cc index f6e5daac85..16383cb667 100644 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -232,12 +232,6 @@ bool CompilationInfo::ShouldSelfOptimize() { } -void CompilationInfo::AbortOptimization() { - Handle code(shared_info()->code()); - SetCode(code); -} - - // Determine whether to use the full compiler for all code. If the flag // --always-full-compiler is specified this is the case. For the virtual frame // based compiler the full compiler is also used if a debugger is connected, as @@ -323,8 +317,7 @@ OptimizingCompiler::Status OptimizingCompiler::CreateGraph() { // We should never arrive here if there is no code object on the // shared function object. - Handle code(info()->shared_info()->code()); - ASSERT(code->kind() == Code::FUNCTION); + ASSERT(info()->shared_info()->code()->kind() == Code::FUNCTION); // We should never arrive here if optimization has been disabled on the // shared function info. @@ -334,7 +327,7 @@ OptimizingCompiler::Status OptimizingCompiler::CreateGraph() { // to use the Hydrogen-based optimizing compiler. We already have // generated code for this from the shared function object. if (AlwaysFullCompiler(isolate())) { - info()->SetCode(code); + info()->AbortOptimization(); return SetLastStatus(BAILED_OUT); } @@ -370,8 +363,8 @@ OptimizingCompiler::Status OptimizingCompiler::CreateGraph() { // Take --hydrogen-filter into account. if (!info()->closure()->PassesHydrogenFilter()) { - info()->SetCode(code); - return SetLastStatus(BAILED_OUT); + info()->AbortOptimization(); + return SetLastStatus(BAILED_OUT); } // Recompile the unoptimized version of the code if the current version @@ -411,7 +404,7 @@ OptimizingCompiler::Status OptimizingCompiler::CreateGraph() { // optimizable marker in the code object and optimize anyway. This // is safe as long as the unoptimized code has deoptimization // support. - ASSERT(FLAG_always_opt || code->optimizable()); + ASSERT(FLAG_always_opt || info()->shared_info()->code()->optimizable()); ASSERT(info()->shared_info()->has_deoptimization_support()); if (FLAG_trace_hydrogen) { @@ -1099,7 +1092,7 @@ void Compiler::InstallOptimizedCode(OptimizingCompiler* optimizing_compiler) { PrintF(" installed.\n"); } } else { - info->SetCode(Handle(info->shared_info()->code())); + info->AbortOptimization(); InstallFullCode(*info); } // Optimized code is finally replacing unoptimized code. Reset the latter's diff --git a/src/compiler.h b/src/compiler.h index 7d442f9d46..e803620cb1 100644 --- a/src/compiler.h +++ b/src/compiler.h @@ -235,9 +235,10 @@ class CompilationInfo { // Determines whether or not to insert a self-optimization header. bool ShouldSelfOptimize(); - // Disable all optimization attempts of this info for the rest of the - // current compilation pipeline. - void AbortOptimization(); + // Reset code to the unoptimized version when optimization is aborted. + void AbortOptimization() { + SetCode(handle(shared_info()->code())); + } void set_deferred_handles(DeferredHandles* deferred_handles) { ASSERT(deferred_handles_ == NULL);