From 76d5eda67ed20f43fbdc7508b99f8a3c65077c3f Mon Sep 17 00:00:00 2001 From: "svenpanne@chromium.org" Date: Fri, 6 May 2011 11:02:23 +0000 Subject: [PATCH] Tiny refactorings to improve the readability of the compiler pipeline a bit. Review URL: http://codereview.chromium.org/6933048 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7802 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/compiler.cc | 56 +++++++++++++++++++++++++------------------------------- 1 file changed, 25 insertions(+), 31 deletions(-) diff --git a/src/compiler.cc b/src/compiler.cc index e9b48cb..985a951 100755 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -95,21 +95,13 @@ CompilationInfo::CompilationInfo(Handle closure) void CompilationInfo::DisableOptimization() { - if (FLAG_optimize_closures) { - // If we allow closures optimizations and it's an optimizable closure - // mark it correspondingly. - bool is_closure = closure_.is_null() && !scope_->HasTrivialOuterContext(); - if (is_closure) { - bool is_optimizable_closure = - !scope_->outer_scope_calls_eval() && !scope_->inside_with(); - if (is_optimizable_closure) { - SetMode(BASE); - return; - } - } - } - - SetMode(NONOPT); + bool is_optimizable_closure = + FLAG_optimize_closures && + closure_.is_null() && + !scope_->HasTrivialOuterContext() && + !scope_->outer_scope_calls_eval() && + !scope_->inside_with(); + SetMode(is_optimizable_closure ? BASE : NONOPT); } @@ -121,20 +113,23 @@ void CompilationInfo::DisableOptimization() { // all. However crankshaft support recompilation of functions, so in this case // the full compiler need not be be used if a debugger is attached, but only if // break points has actually been set. -static bool AlwaysFullCompiler() { +static bool is_debugging_active() { #ifdef ENABLE_DEBUGGER_SUPPORT Isolate* isolate = Isolate::Current(); - if (V8::UseCrankshaft()) { - return FLAG_always_full_compiler || isolate->debug()->has_break_points(); - } else { - return FLAG_always_full_compiler || isolate->debugger()->IsDebuggerActive(); - } + return V8::UseCrankshaft() ? + isolate->debug()->has_break_points() : + isolate->debugger()->IsDebuggerActive(); #else - return FLAG_always_full_compiler; + return false; #endif } +static bool AlwaysFullCompiler() { + return FLAG_always_full_compiler || is_debugging_active(); +} + + static void FinishOptimization(Handle function, int64_t start) { int opt_count = function->shared()->opt_count(); function->shared()->set_opt_count(opt_count + 1); @@ -318,19 +313,18 @@ static bool MakeCrankshaftCode(CompilationInfo* info) { } +static bool GenerateCode(CompilationInfo* info) { + return V8::UseCrankshaft() ? + MakeCrankshaftCode(info) : + FullCodeGenerator::MakeCode(info); +} + + static bool MakeCode(CompilationInfo* info) { // Precondition: code has been parsed. Postcondition: the code field in // the compilation info is set if compilation succeeded. ASSERT(info->function() != NULL); - - if (Rewriter::Rewrite(info) && Scope::Analyze(info)) { - if (V8::UseCrankshaft()) return MakeCrankshaftCode(info); - // If crankshaft is not supported fall back to full code generator - // for all compilation. - return FullCodeGenerator::MakeCode(info); - } - - return false; + return Rewriter::Rewrite(info) && Scope::Analyze(info) && GenerateCode(info); } -- 2.7.4