Revision: 12391
Author: [email protected]
Date: Tue Aug 28 00:18:06 2012
Log: Print reason for disabling optimization. Kill --trace-bailout
flag.
The reason for disabling optimization of a given function is carried around
in
CompilationInfo. The new mechanism is general enough that --trace-opt now
subsumes everything --trace-bailout could print, so we nuked the latter
flag.
Review URL: https://chromiumcodereview.appspot.com/10868106
http://code.google.com/p/v8/source/detail?r=12391
Modified:
/branches/bleeding_edge/src/arm/lithium-arm.cc
/branches/bleeding_edge/src/arm/lithium-arm.h
/branches/bleeding_edge/src/arm/lithium-codegen-arm.cc
/branches/bleeding_edge/src/arm/lithium-codegen-arm.h
/branches/bleeding_edge/src/compiler.cc
/branches/bleeding_edge/src/compiler.h
/branches/bleeding_edge/src/flag-definitions.h
/branches/bleeding_edge/src/hydrogen.cc
/branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc
/branches/bleeding_edge/src/ia32/lithium-codegen-ia32.h
/branches/bleeding_edge/src/ia32/lithium-ia32.cc
/branches/bleeding_edge/src/ia32/lithium-ia32.h
/branches/bleeding_edge/src/lithium.cc
/branches/bleeding_edge/src/mips/lithium-codegen-mips.cc
/branches/bleeding_edge/src/mips/lithium-codegen-mips.h
/branches/bleeding_edge/src/mips/lithium-mips.cc
/branches/bleeding_edge/src/mips/lithium-mips.h
/branches/bleeding_edge/src/objects.cc
/branches/bleeding_edge/src/objects.h
/branches/bleeding_edge/src/x64/lithium-codegen-x64.cc
/branches/bleeding_edge/src/x64/lithium-codegen-x64.h
/branches/bleeding_edge/src/x64/lithium-x64.cc
/branches/bleeding_edge/src/x64/lithium-x64.h
=======================================
--- /branches/bleeding_edge/src/arm/lithium-arm.cc Thu Aug 23 09:14:01 2012
+++ /branches/bleeding_edge/src/arm/lithium-arm.cc Tue Aug 28 00:18:06 2012
@@ -441,17 +441,8 @@
}
-void LChunkBuilder::Abort(const char* format, ...) {
- if (FLAG_trace_bailout) {
- SmartArrayPointer<char> name(
- info()->shared_info()->DebugName()->ToCString());
- PrintF("Aborting LPlatformChunk building in @\"%s\": ", *name);
- va_list arguments;
- va_start(arguments, format);
- OS::VPrint(format, arguments);
- va_end(arguments);
- PrintF("\n");
- }
+void LChunkBuilder::Abort(const char* reason) {
+ info()->set_bailout_reason(reason);
status_ = ABORTED;
}
=======================================
--- /branches/bleeding_edge/src/arm/lithium-arm.h Mon Aug 27 02:39:05 2012
+++ /branches/bleeding_edge/src/arm/lithium-arm.h Tue Aug 28 00:18:06 2012
@@ -2322,7 +2322,7 @@
bool is_done() const { return status_ == DONE; }
bool is_aborted() const { return status_ == ABORTED; }
- void Abort(const char* format, ...);
+ void Abort(const char* reason);
// Methods for getting operands for Use / Define / Temp.
LUnallocated* ToUnallocated(Register reg);
=======================================
--- /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Mon Aug 27
02:39:05 2012
+++ /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Tue Aug 28
00:18:06 2012
@@ -91,17 +91,8 @@
}
-void LCodeGen::Abort(const char* format, ...) {
- if (FLAG_trace_bailout) {
- SmartArrayPointer<char> name(
- info()->shared_info()->DebugName()->ToCString());
- PrintF("Aborting LCodeGen in @\"%s\": ", *name);
- va_list arguments;
- va_start(arguments, format);
- OS::VPrint(format, arguments);
- va_end(arguments);
- PrintF("\n");
- }
+void LCodeGen::Abort(const char* reason) {
+ info()->set_bailout_reason(reason);
status_ = ABORTED;
}
=======================================
--- /branches/bleeding_edge/src/arm/lithium-codegen-arm.h Mon Aug 27
02:39:05 2012
+++ /branches/bleeding_edge/src/arm/lithium-codegen-arm.h Tue Aug 28
00:18:06 2012
@@ -191,7 +191,7 @@
int GetStackSlotCount() const { return chunk()->spill_slot_count(); }
int GetParameterCount() const { return scope()->num_parameters(); }
- void Abort(const char* format, ...);
+ void Abort(const char* reason);
void Comment(const char* format, ...);
void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code, zone());
}
=======================================
--- /branches/bleeding_edge/src/compiler.cc Mon Aug 27 12:47:02 2012
+++ /branches/bleeding_edge/src/compiler.cc Tue Aug 28 00:18:06 2012
@@ -242,6 +242,7 @@
const int kMaxOptCount =
FLAG_deopt_every_n_times == 0 ? FLAG_max_opt_count : 1000;
if (info()->shared_info()->opt_count() > kMaxOptCount) {
+ info()->set_bailout_reason("optimized too many times");
return AbortOptimization();
}
@@ -253,13 +254,18 @@
// The encoding is as a signed value, with parameters and receiver using
// the negative indices and locals the non-negative ones.
const int parameter_limit = -LUnallocated::kMinFixedIndex;
- const int locals_limit = LUnallocated::kMaxFixedIndex;
Scope* scope = info()->scope();
- if ((scope->num_parameters() + 1) > parameter_limit ||
- (!info()->osr_ast_id().IsNone() &&
- scope->num_parameters() + 1 + scope->num_stack_slots() >
locals_limit)) {
+ if ((scope->num_parameters() + 1) > parameter_limit) {
+ info()->set_bailout_reason("too many parameters");
return AbortOptimization();
}
+
+ const int locals_limit = LUnallocated::kMaxFixedIndex;
+ if (!info()->osr_ast_id().IsNone() &&
+ scope->num_parameters() + 1 + scope->num_stack_slots() >
locals_limit) {
+ info()->set_bailout_reason("too many parameters/locals");
+ return AbortOptimization();
+ }
// Take --hydrogen-filter into account.
Handle<String> name = info()->function()->debug_name();
@@ -367,7 +373,10 @@
ASSERT(chunk_ != NULL);
ASSERT(graph_ != NULL);
Handle<Code> optimized_code = chunk_->Codegen();
- if (optimized_code.is_null()) return AbortOptimization();
+ if (optimized_code.is_null()) {
+ info()->set_bailout_reason("code generation failed");
+ return AbortOptimization();
+ }
info()->SetCode(optimized_code);
RecordOptimizationStats();
return SetLastStatus(SUCCEEDED);
@@ -637,7 +646,7 @@
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();
+ result->DisableOptimization("eval");
// If caller is strict mode, the result must be in strict mode or
// extended mode as well, but not the other way around. Consider:
@@ -880,6 +889,8 @@
// the unoptimized code.
OptimizingCompiler::Status status = optimizing_compiler->last_status();
if (status != OptimizingCompiler::SUCCEEDED) {
+ optimizing_compiler->info()->set_bailout_reason(
+ "failed/bailed out last time");
status = optimizing_compiler->AbortOptimization();
} else {
status = optimizing_compiler->GenerateAndInstallCode();
=======================================
--- /branches/bleeding_edge/src/compiler.h Fri Aug 17 05:59:00 2012
+++ /branches/bleeding_edge/src/compiler.h Tue Aug 28 00:18:06 2012
@@ -183,6 +183,9 @@
SaveHandle(&calling_context_);
SaveHandle(&script_);
}
+
+ const char* bailout_reason() const { return bailout_reason_; }
+ void set_bailout_reason(const char* reason) { bailout_reason_ = reason; }
private:
Isolate* isolate_;
@@ -208,6 +211,7 @@
ASSERT(language_mode() == CLASSIC_MODE);
SetLanguageMode(shared_info_->language_mode());
}
+ set_bailout_reason("unknown");
}
void SetMode(Mode mode) {
@@ -279,6 +283,8 @@
*object = handle;
}
}
+
+ const char* bailout_reason_;
DISALLOW_COPY_AND_ASSIGN(CompilationInfo);
};
@@ -360,7 +366,7 @@
MUST_USE_RESULT Status AbortOptimization() {
info_->AbortOptimization();
- info_->shared_info()->DisableOptimization();
+ info_->shared_info()->DisableOptimization(info_->bailout_reason());
return SetLastStatus(BAILED_OUT);
}
=======================================
--- /branches/bleeding_edge/src/flag-definitions.h Wed Aug 22 08:44:17 2012
+++ /branches/bleeding_edge/src/flag-definitions.h Tue Aug 28 00:18:06 2012
@@ -325,8 +325,6 @@
"minimum length for automatic enable preparsing")
DEFINE_bool(always_full_compiler, false,
"try to use the dedicated run-once backend for all code")
-DEFINE_bool(trace_bailout, false,
- "print reasons for falling back to using the classic V8
backend")
DEFINE_int(max_opt_count, 10,
"maximum number of optimization attempts before giving up.")
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc Thu Aug 23 14:08:58 2012
+++ /branches/bleeding_edge/src/hydrogen.cc Tue Aug 28 00:18:06 2012
@@ -3199,11 +3199,7 @@
void HGraphBuilder::Bailout(const char* reason) {
- if (FLAG_trace_bailout) {
- SmartArrayPointer<char> name(
- info()->shared_info()->DebugName()->ToCString());
- PrintF("Bailout in HGraphBuilder: @\"%s\": %s\n", *name, reason);
- }
+ info()->set_bailout_reason(reason);
SetStackOverflow();
}
@@ -6996,7 +6992,7 @@
if (target_info.isolate()->has_pending_exception()) {
// Parse or scope error, never optimize this function.
SetStackOverflow();
- target_shared->DisableOptimization();
+ target_shared->DisableOptimization("parse/scope error");
}
TraceInline(target, caller, "parse failure");
return false;
@@ -7151,7 +7147,7 @@
// Bail out if the inline function did, as we cannot residualize a call
// instead.
TraceInline(target, caller, "inline graph construction failed");
- target_shared->DisableOptimization();
+ target_shared->DisableOptimization("inlining bailed out");
inline_bailout_ = true;
delete target_state;
return true;
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Mon Aug 27
02:39:05 2012
+++ /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Tue Aug 28
00:18:06 2012
@@ -99,17 +99,8 @@
}
-void LCodeGen::Abort(const char* format, ...) {
- if (FLAG_trace_bailout) {
- SmartArrayPointer<char> name(
- info()->shared_info()->DebugName()->ToCString());
- PrintF("Aborting LCodeGen in @\"%s\": ", *name);
- va_list arguments;
- va_start(arguments, format);
- OS::VPrint(format, arguments);
- va_end(arguments);
- PrintF("\n");
- }
+void LCodeGen::Abort(const char* reason) {
+ info()->set_bailout_reason(reason);
status_ = ABORTED;
}
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.h Mon Aug 27
02:39:05 2012
+++ /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.h Tue Aug 28
00:18:06 2012
@@ -171,7 +171,7 @@
int GetStackSlotCount() const { return chunk()->spill_slot_count(); }
int GetParameterCount() const { return scope()->num_parameters(); }
- void Abort(const char* format, ...);
+ void Abort(const char* reason);
void Comment(const char* format, ...);
void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code, zone());
}
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.cc Thu Aug 23 09:14:01
2012
+++ /branches/bleeding_edge/src/ia32/lithium-ia32.cc Tue Aug 28 00:18:06
2012
@@ -461,17 +461,8 @@
}
-void LChunkBuilder::Abort(const char* format, ...) {
- if (FLAG_trace_bailout) {
- SmartArrayPointer<char> name(
- info()->shared_info()->DebugName()->ToCString());
- PrintF("Aborting LPlatformChunk building in @\"%s\": ", *name);
- va_list arguments;
- va_start(arguments, format);
- OS::VPrint(format, arguments);
- va_end(arguments);
- PrintF("\n");
- }
+void LChunkBuilder::Abort(const char* reason) {
+ info()->set_bailout_reason(reason);
status_ = ABORTED;
}
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.h Mon Aug 27 02:39:05 2012
+++ /branches/bleeding_edge/src/ia32/lithium-ia32.h Tue Aug 28 00:18:06 2012
@@ -2437,7 +2437,7 @@
bool is_done() const { return status_ == DONE; }
bool is_aborted() const { return status_ == ABORTED; }
- void Abort(const char* format, ...);
+ void Abort(const char* reason);
// Methods for getting operands for Use / Define / Temp.
LUnallocated* ToUnallocated(Register reg);
=======================================
--- /branches/bleeding_edge/src/lithium.cc Mon Aug 6 07:13:09 2012
+++ /branches/bleeding_edge/src/lithium.cc Tue Aug 28 00:18:06 2012
@@ -395,21 +395,18 @@
AssertNoAllocation no_gc;
int values = graph->GetMaximumValueID();
+ CompilationInfo* info = graph->info();
if (values > LUnallocated::kMaxVirtualRegisters) {
- if (FLAG_trace_bailout) {
- PrintF("Not enough virtual registers for (values).\n");
- }
+ info->set_bailout_reason("not enough virtual registers for values");
return NULL;
}
LAllocator allocator(values, graph);
- LChunkBuilder builder(graph->info(), graph, &allocator);
+ LChunkBuilder builder(info, graph, &allocator);
LChunk* chunk = builder.Build();
if (chunk == NULL) return NULL;
if (!allocator.Allocate(chunk)) {
- if (FLAG_trace_bailout) {
- PrintF("Not enough virtual registers (regalloc).\n");
- }
+ info->set_bailout_reason("not enough virtual registers (regalloc)");
return NULL;
}
=======================================
--- /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc Fri Aug 24
02:06:23 2012
+++ /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc Tue Aug 28
00:18:06 2012
@@ -89,17 +89,8 @@
}
-void LCodeGen::Abort(const char* format, ...) {
- if (FLAG_trace_bailout) {
- SmartArrayPointer<char> name(
- info()->shared_info()->DebugName()->ToCString());
- PrintF("Aborting LCodeGen in @\"%s\": ", *name);
- va_list arguments;
- va_start(arguments, format);
- OS::VPrint(format, arguments);
- va_end(arguments);
- PrintF("\n");
- }
+void LChunkBuilder::Abort(const char* reason) {
+ info()->set_bailout_reason(reason);
status_ = ABORTED;
}
@@ -261,7 +252,7 @@
bool LCodeGen::GenerateDeoptJumpTable() {
// TODO(plind): not clear that this will have advantage for MIPS.
// Skipping it for now. Raised issue #100 for this.
- Abort("Unimplemented: %s", "GenerateDeoptJumpTable");
+ Abort("Unimplemented: GenerateDeoptJumpTable");
return false;
}
=======================================
--- /branches/bleeding_edge/src/mips/lithium-codegen-mips.h Fri Aug 24
02:06:23 2012
+++ /branches/bleeding_edge/src/mips/lithium-codegen-mips.h Tue Aug 28
00:18:06 2012
@@ -183,7 +183,7 @@
int GetStackSlotCount() const { return chunk()->spill_slot_count(); }
int GetParameterCount() const { return scope()->num_parameters(); }
- void Abort(const char* format, ...);
+ void Abort(const char* reason);
void Comment(const char* format, ...);
void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code, zone());
}
=======================================
--- /branches/bleeding_edge/src/mips/lithium-mips.cc Mon Aug 27 02:05:07
2012
+++ /branches/bleeding_edge/src/mips/lithium-mips.cc Tue Aug 28 00:18:06
2012
@@ -441,17 +441,8 @@
}
-void LChunkBuilder::Abort(const char* format, ...) {
- if (FLAG_trace_bailout) {
- SmartArrayPointer<char> name(
- info()->shared_info()->DebugName()->ToCString());
- PrintF("Aborting LPlatformChunk building in @\"%s\": ", *name);
- va_list arguments;
- va_start(arguments, format);
- OS::VPrint(format, arguments);
- va_end(arguments);
- PrintF("\n");
- }
+void LCodeGen::Abort(const char* reason) {
+ info()->set_bailout_reason(reason);
status_ = ABORTED;
}
=======================================
--- /branches/bleeding_edge/src/mips/lithium-mips.h Mon Aug 27 02:39:05 2012
+++ /branches/bleeding_edge/src/mips/lithium-mips.h Tue Aug 28 00:18:06 2012
@@ -2262,7 +2262,7 @@
bool is_done() const { return status_ == DONE; }
bool is_aborted() const { return status_ == ABORTED; }
- void Abort(const char* format, ...);
+ void Abort(const char* reason);
// Methods for getting operands for Use / Define / Temp.
LUnallocated* ToUnallocated(Register reg);
=======================================
--- /branches/bleeding_edge/src/objects.cc Mon Aug 27 06:47:34 2012
+++ /branches/bleeding_edge/src/objects.cc Tue Aug 28 00:18:06 2012
@@ -7791,7 +7791,7 @@
}
-void SharedFunctionInfo::DisableOptimization() {
+void SharedFunctionInfo::DisableOptimization(const char* reason) {
// Disable optimization for the shared function info and mark the
// code as non-optimizable. The marker on the shared function info
// is there because we flush non-optimized code thereby loosing the
@@ -7807,7 +7807,8 @@
code()->set_optimizable(false);
}
if (FLAG_trace_opt) {
- PrintF("[disabled optimization for %s]\n", *DebugName()->ToCString());
+ PrintF("[disabled optimization for %s, reason: %s]\n",
+ *DebugName()->ToCString(), reason);
}
}
=======================================
--- /branches/bleeding_edge/src/objects.h Mon Aug 27 06:47:34 2012
+++ /branches/bleeding_edge/src/objects.h Tue Aug 28 00:18:06 2012
@@ -5645,7 +5645,7 @@
// Disable (further) attempted optimization of all functions sharing this
// shared function info.
- void DisableOptimization();
+ void DisableOptimization(const char* reason);
// Lookup the bailout ID and ASSERT that it exists in the non-optimized
// code, returns whether it asserted (i.e., always true if assertions are
=======================================
--- /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Thu Aug 23
09:14:01 2012
+++ /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Tue Aug 28
00:18:06 2012
@@ -92,17 +92,8 @@
}
-void LCodeGen::Abort(const char* format, ...) {
- if (FLAG_trace_bailout) {
- SmartArrayPointer<char> name(
- info()->shared_info()->DebugName()->ToCString());
- PrintF("Aborting LCodeGen in @\"%s\": ", *name);
- va_list arguments;
- va_start(arguments, format);
- OS::VPrint(format, arguments);
- va_end(arguments);
- PrintF("\n");
- }
+void LChunkBuilder::Abort(const char* reason) {
+ info()->set_bailout_reason(reason);
status_ = ABORTED;
}
=======================================
--- /branches/bleeding_edge/src/x64/lithium-codegen-x64.h Wed Aug 22
08:44:17 2012
+++ /branches/bleeding_edge/src/x64/lithium-codegen-x64.h Tue Aug 28
00:18:06 2012
@@ -157,7 +157,7 @@
int GetStackSlotCount() const { return chunk()->spill_slot_count(); }
int GetParameterCount() const { return scope()->num_parameters(); }
- void Abort(const char* format, ...);
+ void Abort(const char* reason);
void Comment(const char* format, ...);
void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code, zone());
}
=======================================
--- /branches/bleeding_edge/src/x64/lithium-x64.cc Thu Aug 23 09:14:01 2012
+++ /branches/bleeding_edge/src/x64/lithium-x64.cc Tue Aug 28 00:18:06 2012
@@ -444,17 +444,8 @@
}
-void LChunkBuilder::Abort(const char* format, ...) {
- if (FLAG_trace_bailout) {
- SmartArrayPointer<char> name(
- info()->shared_info()->DebugName()->ToCString());
- PrintF("Aborting LPlatformChunk building in @\"%s\": ", *name);
- va_list arguments;
- va_start(arguments, format);
- OS::VPrint(format, arguments);
- va_end(arguments);
- PrintF("\n");
- }
+void LCodeGen::Abort(const char* reason) {
+ info()->set_bailout_reason(reason);
status_ = ABORTED;
}
=======================================
--- /branches/bleeding_edge/src/x64/lithium-x64.h Mon Aug 27 02:39:05 2012
+++ /branches/bleeding_edge/src/x64/lithium-x64.h Tue Aug 28 00:18:06 2012
@@ -2277,7 +2277,7 @@
bool is_done() const { return status_ == DONE; }
bool is_aborted() const { return status_ == ABORTED; }
- void Abort(const char* format, ...);
+ void Abort(const char* reason);
// Methods for getting operands for Use / Define / Temp.
LUnallocated* ToUnallocated(Register reg);
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev