Remove AddCode and RemoveCode GDB JIT entry hooks.
authormstarzinger@chromium.org <mstarzinger@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 11 Jul 2014 07:51:25 +0000 (07:51 +0000)
committermstarzinger@chromium.org <mstarzinger@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 11 Jul 2014 07:51:25 +0000 (07:51 +0000)
R=verwaest@chromium.org

Review URL: https://codereview.chromium.org/387533003

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22344 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/builtins.cc
src/code-stubs.cc
src/gdb-jit.cc
src/gdb-jit.h
src/mark-compact.cc
src/stub-cache.cc
src/stub-cache.h

index 94ff13e072036dc164141e3f75a91710bce84c3d..eb5513e5c56ef7eb30cd6b08b581d7ee81534896 100644 (file)
@@ -1635,7 +1635,6 @@ void Builtins::SetUp(Isolate* isolate, bool create_heap_objects) {
       // Log the event and add the code to the builtins array.
       PROFILE(isolate,
               CodeCreateEvent(Logger::BUILTIN_TAG, *code, functions[i].s_name));
-      GDBJIT(AddCode(GDBJITInterface::BUILTIN, functions[i].s_name, *code));
       builtins_[i] = *code;
 #ifdef ENABLE_DISASSEMBLER
       if (FLAG_print_builtin_code) {
index 79eccefab8b62f1cbfe4275f560713a95988f686..5a3f4e4c34d23aff9289bdf472104d5d0accf652 100644 (file)
@@ -116,7 +116,6 @@ void CodeStub::RecordCodeGeneration(Handle<Code> code) {
   OStringStream os;
   os << *this;
   PROFILE(isolate(), CodeCreateEvent(Logger::STUB_TAG, *code, os.c_str()));
-  GDBJIT(AddCode(GDBJITInterface::STUB, os.c_str(), *code));
   Counters* counters = isolate()->counters();
   counters->total_stubs_code_size()->Increment(code->instruction_size());
 }
index 5ca6dfd1851e208a09e05485ed5768ba0b474039..f3a5cb55a266add09583dc392338c1e24596d32c 100644 (file)
@@ -2063,8 +2063,6 @@ void GDBJITInterface::AddCode(const char* name,
                               GDBJITInterface::CodeTag tag,
                               Script* script,
                               CompilationInfo* info) {
-  if (!FLAG_gdbjit) return;
-
   base::LockGuard<base::Mutex> lock_guard(mutex.Pointer());
   DisallowHeapAllocation no_gc;
 
@@ -2109,45 +2107,6 @@ void GDBJITInterface::AddCode(const char* name,
 }
 
 
-void GDBJITInterface::AddCode(GDBJITInterface::CodeTag tag,
-                              const char* name,
-                              Code* code) {
-  if (!FLAG_gdbjit) return;
-
-  EmbeddedVector<char, 256> buffer;
-  StringBuilder builder(buffer.start(), buffer.length());
-
-  builder.AddString(Tag2String(tag));
-  if ((name != NULL) && (*name != '\0')) {
-    builder.AddString(": ");
-    builder.AddString(name);
-  } else {
-    builder.AddFormatted(": code object %p", static_cast<void*>(code));
-  }
-
-  AddCode(builder.Finalize(), code, tag, NULL, NULL);
-}
-
-
-void GDBJITInterface::AddCode(GDBJITInterface::CodeTag tag,
-                              Name* name,
-                              Code* code) {
-  if (!FLAG_gdbjit) return;
-  if (name != NULL && name->IsString()) {
-    AddCode(tag, String::cast(name)->ToCString(DISALLOW_NULLS).get(), code);
-  } else {
-    AddCode(tag, "", code);
-  }
-}
-
-
-void GDBJITInterface::AddCode(GDBJITInterface::CodeTag tag, Code* code) {
-  if (!FLAG_gdbjit) return;
-
-  AddCode(tag, "", code);
-}
-
-
 void GDBJITInterface::RemoveCode(Code* code) {
   if (!FLAG_gdbjit) return;
 
@@ -2199,10 +2158,27 @@ static void RegisterDetailedLineInfo(Code* code, LineInfo* line_info) {
 void GDBJITInterface::EventHandler(const v8::JitCodeEvent* event) {
   if (!FLAG_gdbjit) return;
   switch (event->type) {
-    case v8::JitCodeEvent::CODE_ADDED:
+    case v8::JitCodeEvent::CODE_ADDED: {
+      Code* code = Code::GetCodeFromTargetAddress(
+          reinterpret_cast<Address>(event->code_start));
+      if (code->kind() == Code::OPTIMIZED_FUNCTION ||
+          code->kind() == Code::FUNCTION) {
+        break;
+      }
+      EmbeddedVector<char, 256> buffer;
+      StringBuilder builder(buffer.start(), buffer.length());
+      builder.AddSubstring(event->name.str, static_cast<int>(event->name.len));
+      AddCode(builder.Finalize(), code, NON_FUNCTION, NULL, NULL);
+      break;
+    }
     case v8::JitCodeEvent::CODE_MOVED:
-    case v8::JitCodeEvent::CODE_REMOVED:
       break;
+    case v8::JitCodeEvent::CODE_REMOVED: {
+      Code* code = Code::GetCodeFromTargetAddress(
+          reinterpret_cast<Address>(event->code_start));
+      RemoveCode(code);
+      break;
+    }
     case v8::JitCodeEvent::CODE_ADD_LINE_POS_INFO: {
       LineInfo* line_info = reinterpret_cast<LineInfo*>(event->user_data);
       line_info->SetPosition(static_cast<intptr_t>(event->line_info.offset),
index 323038a654299206ab607e169400553ced3110a8..14536cf0b38e287937cbad1c7fcef697082bcc0a 100644 (file)
@@ -23,59 +23,25 @@ namespace internal {
 
 class CompilationInfo;
 
-#define CODE_TAGS_LIST(V)                       \
-  V(LOAD_IC)                                    \
-  V(KEYED_LOAD_IC)                              \
-  V(STORE_IC)                                   \
-  V(KEYED_STORE_IC)                             \
-  V(STUB)                                       \
-  V(BUILTIN)                                    \
-  V(SCRIPT)                                     \
-  V(EVAL)                                       \
-  V(FUNCTION)
-
 class GDBJITInterface: public AllStatic {
  public:
-  enum CodeTag {
-#define V(x) x,
-    CODE_TAGS_LIST(V)
-#undef V
-    TAG_COUNT
-  };
-
-  static const char* Tag2String(CodeTag tag) {
-    switch (tag) {
-#define V(x) case x: return #x;
-      CODE_TAGS_LIST(V)
-#undef V
-      default:
-        return NULL;
-    }
-  }
+  enum CodeTag { NON_FUNCTION, FUNCTION };
 
   // Main entry point into GDB JIT realized as a JitCodeEventHandler.
   static void EventHandler(const v8::JitCodeEvent* event);
 
-  static void AddCode(const char* name,
-                      Code* code,
-                      CodeTag tag,
-                      Script* script,
-                      CompilationInfo* info);
-
   static void AddCode(Handle<Name> name,
                       Handle<Script> script,
                       Handle<Code> code,
                       CompilationInfo* info);
 
-  static void AddCode(CodeTag tag, Name* name, Code* code);
-
-  static void AddCode(CodeTag tag, const char* name, Code* code);
+  static void RemoveCodeRange(Address start, Address end);
 
-  static void AddCode(CodeTag tag, Code* code);
+ private:
+  static void AddCode(const char* name, Code* code, CodeTag tag, Script* script,
+                      CompilationInfo* info);
 
   static void RemoveCode(Code* code);
-
-  static void RemoveCodeRange(Address start, Address end);
 };
 
 #define GDBJIT(action) GDBJITInterface::action
index 0df3adcd9ebd1fd8b814813f9c7ee27248b5a099..2ff1ce98500e5aa6e9c03faad4bd07b3c3736a8b 100644 (file)
@@ -4315,11 +4315,6 @@ void MarkCompactCollector::EnableCodeFlushing(bool enable) {
 // code objects. We should either reenable it or change our tools.
 void MarkCompactCollector::ReportDeleteIfNeeded(HeapObject* obj,
                                                 Isolate* isolate) {
-#ifdef ENABLE_GDB_JIT_INTERFACE
-  if (obj->IsCode()) {
-    GDBJITInterface::RemoveCode(reinterpret_cast<Code*>(obj));
-  }
-#endif
   if (obj->IsCode()) {
     PROFILE(isolate, CodeDeleteEvent(obj->address()));
   }
index f274d48696e1b972088af9ff6cc628af47438d07..41ffdf25e78ad483ed93bf894a9553338fb82c46 100644 (file)
@@ -607,7 +607,6 @@ Handle<Code> StubCompiler::CompileLoadInitialize(Code::Flags flags) {
   Handle<Code> code = GetCodeWithFlags(flags, "CompileLoadInitialize");
   PROFILE(isolate(),
           CodeCreateEvent(Logger::LOAD_INITIALIZE_TAG, *code, 0));
-  GDBJIT(AddCode(GDBJITInterface::LOAD_IC, *code));
   return code;
 }
 
@@ -617,7 +616,6 @@ Handle<Code> StubCompiler::CompileLoadPreMonomorphic(Code::Flags flags) {
   Handle<Code> code = GetCodeWithFlags(flags, "CompileLoadPreMonomorphic");
   PROFILE(isolate(),
           CodeCreateEvent(Logger::LOAD_PREMONOMORPHIC_TAG, *code, 0));
-  GDBJIT(AddCode(GDBJITInterface::LOAD_IC, *code));
   return code;
 }
 
@@ -627,7 +625,6 @@ Handle<Code> StubCompiler::CompileLoadMegamorphic(Code::Flags flags) {
   Handle<Code> code = GetCodeWithFlags(flags, "CompileLoadMegamorphic");
   PROFILE(isolate(),
           CodeCreateEvent(Logger::LOAD_MEGAMORPHIC_TAG, *code, 0));
-  GDBJIT(AddCode(GDBJITInterface::LOAD_IC, *code));
   return code;
 }
 
@@ -637,7 +634,6 @@ Handle<Code> StubCompiler::CompileStoreInitialize(Code::Flags flags) {
   Handle<Code> code = GetCodeWithFlags(flags, "CompileStoreInitialize");
   PROFILE(isolate(),
           CodeCreateEvent(Logger::STORE_INITIALIZE_TAG, *code, 0));
-  GDBJIT(AddCode(GDBJITInterface::STORE_IC, *code));
   return code;
 }
 
@@ -647,7 +643,6 @@ Handle<Code> StubCompiler::CompileStorePreMonomorphic(Code::Flags flags) {
   Handle<Code> code = GetCodeWithFlags(flags, "CompileStorePreMonomorphic");
   PROFILE(isolate(),
           CodeCreateEvent(Logger::STORE_PREMONOMORPHIC_TAG, *code, 0));
-  GDBJIT(AddCode(GDBJITInterface::STORE_IC, *code));
   return code;
 }
 
@@ -659,7 +654,6 @@ Handle<Code> StubCompiler::CompileStoreGeneric(Code::Flags flags) {
   Handle<Code> code = GetCodeWithFlags(flags, "CompileStoreGeneric");
   PROFILE(isolate(),
           CodeCreateEvent(Logger::STORE_GENERIC_TAG, *code, 0));
-  GDBJIT(AddCode(GDBJITInterface::STORE_IC, *code));
   return code;
 }
 
@@ -669,7 +663,6 @@ Handle<Code> StubCompiler::CompileStoreMegamorphic(Code::Flags flags) {
   Handle<Code> code = GetCodeWithFlags(flags, "CompileStoreMegamorphic");
   PROFILE(isolate(),
           CodeCreateEvent(Logger::STORE_MEGAMORPHIC_TAG, *code, 0));
-  GDBJIT(AddCode(GDBJITInterface::STORE_IC, *code));
   return code;
 }
 
@@ -1166,23 +1159,6 @@ void StubCompiler::TailCallBuiltin(MacroAssembler* masm, Builtins::Name name) {
 }
 
 
-void BaseLoadStoreStubCompiler::JitEvent(Handle<Name> name, Handle<Code> code) {
-#ifdef ENABLE_GDB_JIT_INTERFACE
-  GDBJITInterface::CodeTag tag;
-  if (kind_ == Code::LOAD_IC) {
-    tag = GDBJITInterface::LOAD_IC;
-  } else if (kind_ == Code::KEYED_LOAD_IC) {
-    tag = GDBJITInterface::KEYED_LOAD_IC;
-  } else if (kind_ == Code::STORE_IC) {
-    tag = GDBJITInterface::STORE_IC;
-  } else {
-    tag = GDBJITInterface::KEYED_STORE_IC;
-  }
-  GDBJIT(AddCode(tag, *name, *code));
-#endif
-}
-
-
 void BaseLoadStoreStubCompiler::InitializeRegisters() {
   if (kind_ == Code::LOAD_IC) {
     registers_ = LoadStubCompiler::registers();
@@ -1204,7 +1180,6 @@ Handle<Code> BaseLoadStoreStubCompiler::GetICCode(Code::Kind kind,
   Handle<Code> code = GetCodeWithFlags(flags, name);
   IC::RegisterWeakMapDependency(code);
   PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, *name));
-  JitEvent(name, code);
   return code;
 }
 
@@ -1216,7 +1191,6 @@ Handle<Code> BaseLoadStoreStubCompiler::GetCode(Code::Kind kind,
   Code::Flags flags = Code::ComputeHandlerFlags(kind, type, cache_holder_);
   Handle<Code> code = GetCodeWithFlags(flags, name);
   PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, *name));
-  JitEvent(name, code);
   return code;
 }
 
index 9f2a87b4683a1a3e3967858527c17f5e4a252ca5..8c863e1bd895eb8e46c4896336393483248f40fa 100644 (file)
@@ -486,7 +486,6 @@ class BaseLoadStoreStubCompiler: public StubCompiler {
           ? Logger::KEYED_STORE_IC_TAG : Logger::KEYED_STORE_POLYMORPHIC_IC_TAG;
     }
   }
-  void JitEvent(Handle<Name> name, Handle<Code> code);
 
   Register receiver() { return registers_[0]; }
   Register name()     { return registers_[1]; }