Reviewers: jarin,
Message:
PTAL.
Description:
--trace-ic: much faster and available in Release mode.
Also add IC tracing to a path where it was missing.
Please review this at https://codereview.chromium.org/368833003/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+60, -35 lines):
M src/flag-definitions.h
M src/ic.h
M src/ic.cc
Index: src/flag-definitions.h
diff --git a/src/flag-definitions.h b/src/flag-definitions.h
index
2fe93c6ec69bf5b4911aec274449a8f216a40be8..67e33e40f0366b4fecb420d040fc87c3df56034a
100644
--- a/src/flag-definitions.h
+++ b/src/flag-definitions.h
@@ -536,6 +536,7 @@ DEFINE_BOOL(use_idle_notification, true,
"Use idle notification to reduce memory footprint.")
// ic.cc
DEFINE_BOOL(use_ic, true, "use inline caching")
+DEFINE_BOOL(trace_ic, false, "trace inline cache state transitions")
// macro-assembler-ia32.cc
DEFINE_BOOL(native_code_counters, false,
@@ -724,9 +725,6 @@ DEFINE_BOOL(verify_native_context_separation, false,
DEFINE_BOOL(print_handles, false, "report handles after GC")
DEFINE_BOOL(print_global_handles, false, "report global handles after GC")
-// ic.cc
-DEFINE_BOOL(trace_ic, false, "trace inline cache state transitions")
-
// interface.cc
DEFINE_BOOL(print_interfaces, false, "print interfaces")
DEFINE_BOOL(print_interface_details, false, "print interface inference
details")
Index: src/ic.cc
diff --git a/src/ic.cc b/src/ic.cc
index
39b94162285291ebafd899f5fc2446127e404a42..96c7a219097af60ed62745d257fa0f0942b71816
100644
--- a/src/ic.cc
+++ b/src/ic.cc
@@ -17,7 +17,6 @@
namespace v8 {
namespace internal {
-#ifdef DEBUG
char IC::TransitionMarkFromState(IC::State state) {
switch (state) {
case UNINITIALIZED: return '0';
@@ -48,25 +47,65 @@ const char*
GetTransitionMarkModifier(KeyedAccessStoreMode mode) {
}
-void IC::TraceIC(const char* type,
- Handle<Object> name) {
+#ifdef DEBUG
+
+#define TRACE_GENERIC_IC(isolate, type, reason) \
+ do { \
+ if (FLAG_trace_ic) { \
+ PrintF("[%s patching generic stub in ", type); \
+ JavaScriptFrame::PrintTop(isolate, stdout, false, true); \
+ PrintF(" (%s)]\n", reason); \
+ } \
+ } while (false)
+
+#else
+
+#define TRACE_GENERIC_IC(isolate, type, reason)
+
+#endif // DEBUG
+
+void IC::TraceIC(const char* type, Handle<Object> name) {
if (FLAG_trace_ic) {
Code* new_target = raw_target();
State new_state = new_target->ic_state();
PrintF("[%s%s in ", new_target->is_keyed_stub() ? "Keyed" : "", type);
- StackFrameIterator it(isolate());
- while (it.frame()->fp() != this->fp()) it.Advance();
- StackFrame* raw_frame = it.frame();
- if (raw_frame->is_internal()) {
- Code* apply_builtin = isolate()->builtins()->builtin(
- Builtins::kFunctionApply);
- if (raw_frame->unchecked_code() == apply_builtin) {
- PrintF("apply from ");
- it.Advance();
- raw_frame = it.frame();
+
+ // TODO(jkummerow): Add support for "apply". The logic is roughly:
+ // marker = [fp_ + kMarkerOffset];
+ // if marker is smi and marker.value == INTERNAL and
+ // the frame's code == builtin(Builtins::kFunctionApply):
+ // then print "apply from" and advance one frame
+
+ Object* maybe_function =
+ Memory::Object_at(fp_ + JavaScriptFrameConstants::kFunctionOffset);
+ if (maybe_function->IsJSFunction()) {
+ JSFunction* function = JSFunction::cast(maybe_function);
+ PrintF("%s", function->IsOptimized() ? "*" : "~");
+ function->PrintName();
+ Code* js_code = function->code();
+ int code_offset = static_cast<int>(pc() -
js_code->instruction_start());
+ PrintF("+%d", code_offset);
+
+ int source_pos = js_code->SourcePosition(pc());
+ SharedFunctionInfo* shared = function->shared();
+ Object* maybe_script = shared->script();
+ if (maybe_script->IsScript()) {
+ Script* script = Script::cast(maybe_script);
+ int line = script->GetLineNumber(source_pos) + 1;
+ Object* script_name_raw = script->name();
+ if (script_name_raw->IsString()) {
+ String* script_name = String::cast(script->name());
+ SmartArrayPointer<char> c_script_name =
+ script_name->ToCString(DISALLOW_NULLS,
ROBUST_STRING_TRAVERSAL);
+ PrintF(stdout, " at %s:%d", c_script_name.get(), line);
+ } else {
+ PrintF(stdout, " at <unknown>:%d", line);
+ }
+ } else {
+ PrintF(stdout, " at <unknown>:<unknown>");
}
}
- JavaScriptFrame::PrintTop(isolate(), stdout, false, true);
+
ExtraICState extra_state = new_target->extra_ic_state();
const char* modifier = "";
if (new_target->kind() == Code::KEYED_STORE_IC) {
@@ -82,21 +121,8 @@ void IC::TraceIC(const char* type,
}
}
-#define TRACE_GENERIC_IC(isolate, type, reason) \
- do { \
- if (FLAG_trace_ic) { \
- PrintF("[%s patching generic stub in ", type); \
- JavaScriptFrame::PrintTop(isolate, stdout, false, true); \
- PrintF(" (%s)]\n", reason); \
- } \
- } while (false)
+#define TRACE_IC(type, name) TraceIC(type, name)
-#else
-#define TRACE_GENERIC_IC(isolate, type, reason)
-#endif // DEBUG
-
-#define TRACE_IC(type, name) \
- ASSERT((TraceIC(type, name), true))
IC::IC(FrameDepth depth, Isolate* isolate)
: isolate_(isolate),
@@ -615,7 +641,11 @@ MaybeHandle<Object> LoadIC::Load(Handle<Object>
object, Handle<String> name) {
uint32_t index;
if (kind() == Code::KEYED_LOAD_IC && name->AsArrayIndex(&index)) {
// Rewrite to the generic keyed load stub.
- if (FLAG_use_ic) set_target(*generic_stub());
+ if (FLAG_use_ic) {
+ set_target(*generic_stub());
+ TRACE_IC("LoadIC", name);
+ TRACE_GENERIC_IC(isolate(), "LoadIC", "name as array index");
+ }
Handle<Object> result;
ASSIGN_RETURN_ON_EXCEPTION(
isolate(),
Index: src/ic.h
diff --git a/src/ic.h b/src/ic.h
index
19146acc7ca5217076ed9d9620dbaf53749420a2..d126a29375939f5b98e07cb6f707c7386fcf13df
100644
--- a/src/ic.h
+++ b/src/ic.h
@@ -170,11 +170,8 @@ class IC {
bool is_target_set() { return target_set_; }
-#ifdef DEBUG
char TransitionMarkFromState(IC::State state);
-
void TraceIC(const char* type, Handle<Object> name);
-#endif
MaybeHandle<Object> TypeError(const char* type,
Handle<Object> object,
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.