Revision: 13259
Author: [email protected]
Date: Thu Dec 20 23:18:56 2012
Log: Refactored deopt tracing and FindOptimizedCode. Fixed a bug when
printing stubs.
Review URL: https://codereview.chromium.org/11636046
http://code.google.com/p/v8/source/detail?r=13259
Modified:
/branches/bleeding_edge/src/deoptimizer.cc
/branches/bleeding_edge/src/deoptimizer.h
/branches/bleeding_edge/src/objects.cc
/branches/bleeding_edge/src/objects.h
=======================================
--- /branches/bleeding_edge/src/deoptimizer.cc Thu Dec 20 05:05:16 2012
+++ /branches/bleeding_edge/src/deoptimizer.cc Thu Dec 20 23:18:56 2012
@@ -477,37 +477,32 @@
}
-static Code* FindOptimizedCode(Isolate* isolate,
- JSFunction* function,
- Deoptimizer::BailoutType type,
- Address from,
- Code* optimized_code) {
+bool Deoptimizer::TraceEnabledFor(BailoutType type) {
switch (type) {
- case Deoptimizer::EAGER:
- ASSERT(from == NULL);
- return function->code();
- case Deoptimizer::LAZY: {
- Code* compiled_code =
- isolate->deoptimizer_data()->FindDeoptimizingCode(from);
- return (compiled_code == NULL)
- ? static_cast<Code*>(isolate->heap()->FindCodeObject(from))
- : compiled_code;
- }
- case Deoptimizer::OSR: {
- // The function has already been optimized and we're transitioning
- // from the unoptimized shared version to the optimized one in the
- // function. The return address (from) points to unoptimized code.
- Code* compiled_code = function->code();
- ASSERT(compiled_code->kind() == Code::OPTIMIZED_FUNCTION);
- ASSERT(!compiled_code->contains(from));
- return compiled_code;
- }
- case Deoptimizer::DEBUGGER:
- ASSERT(optimized_code->contains(from));
- return optimized_code;
+ case EAGER:
+ case LAZY:
+ case DEBUGGER:
+ return FLAG_trace_deopt;
+ case OSR:
+ return FLAG_trace_osr;
}
UNREACHABLE();
- return NULL;
+ return false;
+}
+
+
+const char* Deoptimizer::MessageFor(BailoutType type) {
+ switch (type) {
+ case EAGER:
+ case LAZY:
+ return "DEOPT";
+ case DEBUGGER:
+ return "DEOPT FOR DEBUGGER";
+ case OSR:
+ return "OSR";
+ }
+ UNREACHABLE();
+ return false;
}
@@ -532,43 +527,72 @@
deferred_arguments_objects_values_(0),
deferred_arguments_objects_(0),
deferred_heap_numbers_(0) {
- if (FLAG_trace_deopt && type != OSR) {
- if (type == DEBUGGER) {
- PrintF("**** DEOPT FOR DEBUGGER: ");
- } else {
- PrintF("**** DEOPT: ");
- }
- function->PrintName();
- PrintF(" at bailout #%u, address 0x%" V8PRIxPTR ", frame size %d\n",
- bailout_id,
- reinterpret_cast<intptr_t>(from),
- fp_to_sp_delta - (2 * kPointerSize));
- } else if (FLAG_trace_osr && type == OSR) {
- PrintF("**** OSR: ");
- function->PrintName();
- PrintF(" at ast id #%u, address 0x%" V8PRIxPTR ", frame size %d\n",
- bailout_id,
- reinterpret_cast<intptr_t>(from),
- fp_to_sp_delta - (2 * kPointerSize));
- }
- // For COMPILED_STUBs called from builtins, the function pointer
- // is a SMI indicating an internal frame.
+ // For COMPILED_STUBs called from builtins, the function pointer is a SMI
+ // indicating an internal frame.
if (function->IsSmi()) {
function = NULL;
}
if (function != NULL && function->IsOptimized()) {
function->shared()->increment_deopt_count();
}
- compiled_code_ =
- FindOptimizedCode(isolate, function, type, from, optimized_code);
- if (FLAG_trace_deopt && type == EAGER) {
- compiled_code_->PrintDeoptLocation(bailout_id);
- }
+ compiled_code_ = FindOptimizedCode(function, optimized_code);
+ if (TraceEnabledFor(type)) Trace();
ASSERT(HEAP->allow_allocation(false));
unsigned size = ComputeInputFrameSize();
input_ = new(size) FrameDescription(size, function);
input_->SetFrameType(StackFrame::JAVA_SCRIPT);
}
+
+
+Code* Deoptimizer::FindOptimizedCode(JSFunction* function,
+ Code* optimized_code) {
+ switch (bailout_type_) {
+ case Deoptimizer::EAGER:
+ ASSERT(from_ == NULL);
+ return function->code();
+ case Deoptimizer::LAZY: {
+ Code* compiled_code =
+ isolate_->deoptimizer_data()->FindDeoptimizingCode(from_);
+ return (compiled_code == NULL)
+ ? static_cast<Code*>(isolate_->heap()->FindCodeObject(from_))
+ : compiled_code;
+ }
+ case Deoptimizer::OSR: {
+ // The function has already been optimized and we're transitioning
+ // from the unoptimized shared version to the optimized one in the
+ // function. The return address (from_) points to unoptimized code.
+ Code* compiled_code = function->code();
+ ASSERT(compiled_code->kind() == Code::OPTIMIZED_FUNCTION);
+ ASSERT(!compiled_code->contains(from_));
+ return compiled_code;
+ }
+ case Deoptimizer::DEBUGGER:
+ ASSERT(optimized_code->contains(from_));
+ return optimized_code;
+ }
+ UNREACHABLE();
+ return NULL;
+}
+
+
+void Deoptimizer::Trace() {
+ PrintF("**** %s: ", Deoptimizer::MessageFor(bailout_type_));
+ PrintFunctionName();
+ PrintF(" at id #%u, address 0x%" V8PRIxPTR ", frame size %d\n",
+ bailout_id_,
+ reinterpret_cast<intptr_t>(from_),
+ fp_to_sp_delta_ - (2 * kPointerSize));
+ if (bailout_type_ == EAGER)
compiled_code_->PrintDeoptLocation(bailout_id_);
+}
+
+
+void Deoptimizer::PrintFunctionName() {
+ if (function_->IsJSFunction()) {
+ function_->PrintName();
+ } else {
+ PrintF("%s", Code::Kind2String(compiled_code_->kind()));
+ }
+}
Deoptimizer::~Deoptimizer() {
@@ -681,7 +705,7 @@
PrintF("[deoptimizing%s: begin 0x%08" V8PRIxPTR " ",
(bailout_type_ == LAZY ? " (lazy)" : ""),
reinterpret_cast<intptr_t>(function_));
- function_->PrintName();
+ PrintFunctionName();
PrintF(" @%d]\n", bailout_id_);
}
@@ -761,7 +785,7 @@
JSFunction* function = output_[index]->GetFunction();
PrintF("[deoptimizing: end 0x%08" V8PRIxPTR " ",
reinterpret_cast<intptr_t>(function));
- function->PrintName();
+ if (function != NULL) function->PrintName();
PrintF(" => node=%d, pc=0x%08" V8PRIxPTR ", state=%s, alignment=%s,"
" took %0.3f ms]\n",
node_id.ToInt(),
=======================================
--- /branches/bleeding_edge/src/deoptimizer.h Thu Dec 20 01:47:09 2012
+++ /branches/bleeding_edge/src/deoptimizer.h Thu Dec 20 23:18:56 2012
@@ -144,6 +144,9 @@
DEBUGGER
};
+ static bool TraceEnabledFor(BailoutType type);
+ static const char* MessageFor(BailoutType type);
+
int output_count() const { return output_count_; }
Code::Kind compiled_code_kind() const { return compiled_code_->kind(); }
@@ -326,6 +329,9 @@
Address from,
int fp_to_sp_delta,
Code* optimized_code);
+ Code* FindOptimizedCode(JSFunction* function, Code* optimized_code);
+ void Trace();
+ void PrintFunctionName();
void DeleteFrameDescriptions();
void DoComputeOutputFrames();
=======================================
--- /branches/bleeding_edge/src/objects.cc Thu Dec 20 03:53:42 2012
+++ /branches/bleeding_edge/src/objects.cc Thu Dec 20 23:18:56 2012
@@ -9155,6 +9155,30 @@
}
}
}
+
+
+// Identify kind of code.
+const char* Code::Kind2String(Kind kind) {
+ switch (kind) {
+ case FUNCTION: return "FUNCTION";
+ case OPTIMIZED_FUNCTION: return "OPTIMIZED_FUNCTION";
+ case COMPILED_STUB: return "COMPILED_STUB";
+ case STUB: return "STUB";
+ case BUILTIN: return "BUILTIN";
+ case LOAD_IC: return "LOAD_IC";
+ case KEYED_LOAD_IC: return "KEYED_LOAD_IC";
+ case STORE_IC: return "STORE_IC";
+ case KEYED_STORE_IC: return "KEYED_STORE_IC";
+ case CALL_IC: return "CALL_IC";
+ case KEYED_CALL_IC: return "KEYED_CALL_IC";
+ case UNARY_OP_IC: return "UNARY_OP_IC";
+ case BINARY_OP_IC: return "BINARY_OP_IC";
+ case COMPARE_IC: return "COMPARE_IC";
+ case TO_BOOLEAN_IC: return "TO_BOOLEAN_IC";
+ }
+ UNREACHABLE();
+ return NULL;
+}
#ifdef ENABLE_DISASSEMBLER
@@ -9333,30 +9357,6 @@
FullCodeGenerator::StateField::decode(pc_and_state)));
}
}
-
-
-// Identify kind of code.
-const char* Code::Kind2String(Kind kind) {
- switch (kind) {
- case FUNCTION: return "FUNCTION";
- case OPTIMIZED_FUNCTION: return "OPTIMIZED_FUNCTION";
- case COMPILED_STUB: return "COMPILED_STUB";
- case STUB: return "STUB";
- case BUILTIN: return "BUILTIN";
- case LOAD_IC: return "LOAD_IC";
- case KEYED_LOAD_IC: return "KEYED_LOAD_IC";
- case STORE_IC: return "STORE_IC";
- case KEYED_STORE_IC: return "KEYED_STORE_IC";
- case CALL_IC: return "CALL_IC";
- case KEYED_CALL_IC: return "KEYED_CALL_IC";
- case UNARY_OP_IC: return "UNARY_OP_IC";
- case BINARY_OP_IC: return "BINARY_OP_IC";
- case COMPARE_IC: return "COMPARE_IC";
- case TO_BOOLEAN_IC: return "TO_BOOLEAN_IC";
- }
- UNREACHABLE();
- return NULL;
-}
const char* Code::ICState2String(InlineCacheState state) {
=======================================
--- /branches/bleeding_edge/src/objects.h Thu Dec 20 03:53:42 2012
+++ /branches/bleeding_edge/src/objects.h Thu Dec 20 23:18:56 2012
@@ -4211,6 +4211,8 @@
// Flags.
STATIC_ASSERT(LAST_CODE_KIND < 16);
+ static const char* Kind2String(Kind kind);
+
// Types of stubs.
enum StubType {
NORMAL,
@@ -4232,7 +4234,6 @@
#ifdef ENABLE_DISASSEMBLER
// Printing
- static const char* Kind2String(Kind kind);
static const char* ICState2String(InlineCacheState state);
static const char* StubType2String(StubType type);
static void PrintExtraICState(FILE* out, Kind kind, ExtraICState extra);
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev