Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(782)

Unified Diff: src/compiler.cc

Issue 20843012: Extract hardcoded error strings into a single place and replace them with enum. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: styles fixed Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler.h ('k') | src/hydrogen.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index 3c51baa30e9881d3a8ac739166ba01c2673d1c1f..008383e91efac55535ec4dd0dc2c28f0ffd641cc 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -127,7 +127,7 @@ void CompilationInfo::Initialize(Isolate* isolate,
ASSERT(language_mode() == CLASSIC_MODE);
SetLanguageMode(shared_info_->language_mode());
}
- set_bailout_reason("unknown");
+ set_bailout_reason(kUnknown);
}
@@ -342,7 +342,7 @@ OptimizingCompiler::Status OptimizingCompiler::CreateGraph() {
const int kMaxOptCount =
FLAG_deopt_every_n_times == 0 ? FLAG_max_opt_count : 1000;
if (info()->opt_count() > kMaxOptCount) {
- info()->set_bailout_reason("optimized too many times");
+ info()->set_bailout_reason(kOptimizedTooManyTimes);
return AbortOptimization();
}
@@ -356,14 +356,14 @@ OptimizingCompiler::Status OptimizingCompiler::CreateGraph() {
const int parameter_limit = -LUnallocated::kMinFixedSlotIndex;
Scope* scope = info()->scope();
if ((scope->num_parameters() + 1) > parameter_limit) {
- info()->set_bailout_reason("too many parameters");
+ info()->set_bailout_reason(kTooManyParameters);
return AbortOptimization();
}
const int locals_limit = LUnallocated::kMaxFixedSlotIndex;
if (!info()->osr_ast_id().IsNone() &&
scope->num_parameters() + 1 + scope->num_stack_slots() > locals_limit) {
- info()->set_bailout_reason("too many parameters/locals");
+ info()->set_bailout_reason(kTooManyParametersLocals);
return AbortOptimization();
}
@@ -458,9 +458,9 @@ OptimizingCompiler::Status OptimizingCompiler::OptimizeGraph() {
ASSERT(last_status() == SUCCEEDED);
Timer t(this, &time_taken_to_optimize_);
ASSERT(graph_ != NULL);
- SmartArrayPointer<char> bailout_reason;
+ BailoutReason bailout_reason = kNoReason;
if (!graph_->Optimize(&bailout_reason)) {
- if (!bailout_reason.is_empty()) graph_builder_->Bailout(*bailout_reason);
+ if (bailout_reason != kNoReason) graph_builder_->Bailout(bailout_reason);
return SetLastStatus(BAILED_OUT);
} else {
chunk_ = LChunk::NewChunk(graph_);
@@ -485,7 +485,9 @@ OptimizingCompiler::Status OptimizingCompiler::GenerateAndInstallCode() {
DisallowDeferredHandleDereference no_deferred_handle_deref;
Handle<Code> optimized_code = chunk_->Codegen();
if (optimized_code.is_null()) {
- info()->set_bailout_reason("code generation failed");
+ if (info()->bailout_reason() != kNoReason) {
Jakob Kummerow 2013/08/02 08:13:47 Sorry, I mixed up the condition in my earlier comm
+ info()->set_bailout_reason(kCodeGenerationFailed);
+ }
return AbortOptimization();
}
info()->SetCode(optimized_code);
@@ -780,7 +782,7 @@ Handle<SharedFunctionInfo> Compiler::CompileEval(Handle<String> source,
if (!result.is_null()) {
// Explicitly disable optimization for eval code. We're not yet prepared
// to handle eval-code in the optimizing compiler.
- result->DisableOptimization("eval");
+ result->DisableOptimization(kEval);
// If caller is strict mode, the result must be in strict mode or
// extended mode as well, but not the other way around. Consider:
@@ -1055,13 +1057,13 @@ void Compiler::InstallOptimizedCode(OptimizingCompiler* optimizing_compiler) {
// the unoptimized code.
OptimizingCompiler::Status status = optimizing_compiler->last_status();
if (info->HasAbortedDueToDependencyChange()) {
- info->set_bailout_reason("bailed out due to dependent map");
+ info->set_bailout_reason(kBailedOutDueToDependentMap);
status = optimizing_compiler->AbortOptimization();
} else if (status != OptimizingCompiler::SUCCEEDED) {
- info->set_bailout_reason("failed/bailed out last time");
+ info->set_bailout_reason(kFailedBailedOutLastTime);
status = optimizing_compiler->AbortOptimization();
} else if (isolate->DebuggerHasBreakPoints()) {
- info->set_bailout_reason("debugger is active");
+ info->set_bailout_reason(kDebuggerIsActive);
status = optimizing_compiler->AbortOptimization();
} else {
status = optimizing_compiler->GenerateAndInstallCode();
« no previous file with comments | « src/compiler.h ('k') | src/hydrogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698