Remove GDB JIT hooks from the position recorder.

R=jarin@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22325 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 1d7cd306
...@@ -1572,11 +1572,6 @@ void PositionsRecorder::RecordPosition(int pos) { ...@@ -1572,11 +1572,6 @@ void PositionsRecorder::RecordPosition(int pos) {
ASSERT(pos != RelocInfo::kNoPosition); ASSERT(pos != RelocInfo::kNoPosition);
ASSERT(pos >= 0); ASSERT(pos >= 0);
state_.current_position = pos; state_.current_position = pos;
#ifdef ENABLE_GDB_JIT_INTERFACE
if (gdbjit_lineinfo_ != NULL) {
gdbjit_lineinfo_->SetPosition(assembler_->pc_offset(), pos, false);
}
#endif
LOG_CODE_EVENT(assembler_->isolate(), LOG_CODE_EVENT(assembler_->isolate(),
CodeLinePosInfoAddPositionEvent(jit_handler_data_, CodeLinePosInfoAddPositionEvent(jit_handler_data_,
assembler_->pc_offset(), assembler_->pc_offset(),
...@@ -1588,11 +1583,6 @@ void PositionsRecorder::RecordStatementPosition(int pos) { ...@@ -1588,11 +1583,6 @@ void PositionsRecorder::RecordStatementPosition(int pos) {
ASSERT(pos != RelocInfo::kNoPosition); ASSERT(pos != RelocInfo::kNoPosition);
ASSERT(pos >= 0); ASSERT(pos >= 0);
state_.current_statement_position = pos; state_.current_statement_position = pos;
#ifdef ENABLE_GDB_JIT_INTERFACE
if (gdbjit_lineinfo_ != NULL) {
gdbjit_lineinfo_->SetPosition(assembler_->pc_offset(), pos, true);
}
#endif
LOG_CODE_EVENT(assembler_->isolate(), LOG_CODE_EVENT(assembler_->isolate(),
CodeLinePosInfoAddStatementPositionEvent( CodeLinePosInfoAddStatementPositionEvent(
jit_handler_data_, jit_handler_data_,
......
...@@ -1022,29 +1022,9 @@ class PositionsRecorder BASE_EMBEDDED { ...@@ -1022,29 +1022,9 @@ class PositionsRecorder BASE_EMBEDDED {
public: public:
explicit PositionsRecorder(Assembler* assembler) explicit PositionsRecorder(Assembler* assembler)
: assembler_(assembler) { : assembler_(assembler) {
#ifdef ENABLE_GDB_JIT_INTERFACE
gdbjit_lineinfo_ = NULL;
#endif
jit_handler_data_ = NULL; jit_handler_data_ = NULL;
} }
#ifdef ENABLE_GDB_JIT_INTERFACE
~PositionsRecorder() {
delete gdbjit_lineinfo_;
}
void StartGDBJITLineInfoRecording() {
if (FLAG_gdbjit) {
gdbjit_lineinfo_ = new GDBJITLineInfo();
}
}
GDBJITLineInfo* DetachGDBJITLineInfo() {
GDBJITLineInfo* lineinfo = gdbjit_lineinfo_;
gdbjit_lineinfo_ = NULL; // To prevent deallocation in destructor.
return lineinfo;
}
#endif
void AttachJITHandlerData(void* user_data) { void AttachJITHandlerData(void* user_data) {
jit_handler_data_ = user_data; jit_handler_data_ = user_data;
} }
...@@ -1072,9 +1052,6 @@ class PositionsRecorder BASE_EMBEDDED { ...@@ -1072,9 +1052,6 @@ class PositionsRecorder BASE_EMBEDDED {
private: private:
Assembler* assembler_; Assembler* assembler_;
PositionState state_; PositionState state_;
#ifdef ENABLE_GDB_JIT_INTERFACE
GDBJITLineInfo* gdbjit_lineinfo_;
#endif
// Currently jit_handler_data_ is used to store JITHandler-specific data // Currently jit_handler_data_ is used to store JITHandler-specific data
// over the lifetime of a PositionsRecorder // over the lifetime of a PositionsRecorder
......
...@@ -29,6 +29,10 @@ ...@@ -29,6 +29,10 @@
#include "include/v8-testing.h" #include "include/v8-testing.h"
#endif // V8_SHARED #endif // V8_SHARED
#ifdef ENABLE_GDB_JIT_INTERFACE
#include "src/gdb-jit.h"
#endif
#ifdef ENABLE_VTUNE_JIT_INTERFACE #ifdef ENABLE_VTUNE_JIT_INTERFACE
#include "src/third_party/vtune/v8-vtune.h" #include "src/third_party/vtune/v8-vtune.h"
#endif #endif
...@@ -1577,6 +1581,10 @@ int Shell::Main(int argc, char* argv[]) { ...@@ -1577,6 +1581,10 @@ int Shell::Main(int argc, char* argv[]) {
{ {
Isolate::Scope scope(isolate); Isolate::Scope scope(isolate);
Initialize(isolate); Initialize(isolate);
#ifdef ENABLE_GDB_JIT_INTERFACE
v8::V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault,
i::GDBJITInterface::EventHandler);
#endif
#ifdef ENABLE_VTUNE_JIT_INTERFACE #ifdef ENABLE_VTUNE_JIT_INTERFACE
vTune::InitializeVtuneForV8(); vTune::InitializeVtuneForV8();
#endif #endif
......
...@@ -303,9 +303,6 @@ bool FullCodeGenerator::MakeCode(CompilationInfo* info) { ...@@ -303,9 +303,6 @@ bool FullCodeGenerator::MakeCode(CompilationInfo* info) {
MacroAssembler masm(info->isolate(), NULL, kInitialBufferSize); MacroAssembler masm(info->isolate(), NULL, kInitialBufferSize);
if (info->will_serialize()) masm.enable_serializer(); if (info->will_serialize()) masm.enable_serializer();
#ifdef ENABLE_GDB_JIT_INTERFACE
masm.positions_recorder()->StartGDBJITLineInfoRecording();
#endif
LOG_CODE_EVENT(isolate, LOG_CODE_EVENT(isolate,
CodeStartLinePosInfoRecordEvent(masm.positions_recorder())); CodeStartLinePosInfoRecordEvent(masm.positions_recorder()));
...@@ -332,13 +329,6 @@ bool FullCodeGenerator::MakeCode(CompilationInfo* info) { ...@@ -332,13 +329,6 @@ bool FullCodeGenerator::MakeCode(CompilationInfo* info) {
code->set_back_edge_table_offset(table_offset); code->set_back_edge_table_offset(table_offset);
CodeGenerator::PrintCode(code, info); CodeGenerator::PrintCode(code, info);
info->SetCode(code); info->SetCode(code);
#ifdef ENABLE_GDB_JIT_INTERFACE
if (FLAG_gdbjit) {
GDBJITLineInfo* lineinfo =
masm.positions_recorder()->DetachGDBJITLineInfo();
GDBJIT(RegisterDetailedLineInfo(*code, lineinfo));
}
#endif
void* line_info = masm.positions_recorder()->DetachJITHandlerData(); void* line_info = masm.positions_recorder()->DetachJITHandlerData();
LOG_CODE_EVENT(isolate, CodeEndLinePosInfoRecordEvent(*code, line_info)); LOG_CODE_EVENT(isolate, CodeEndLinePosInfoRecordEvent(*code, line_info));
return true; return true;
......
...@@ -899,6 +899,32 @@ class ELFSymbolTable : public ELFSection { ...@@ -899,6 +899,32 @@ class ELFSymbolTable : public ELFSection {
#endif // defined(__ELF) #endif // defined(__ELF)
class LineInfo : public Malloced {
public:
LineInfo() : pc_info_(10) {}
void SetPosition(intptr_t pc, int pos, bool is_statement) {
AddPCInfo(PCInfo(pc, pos, is_statement));
}
struct PCInfo {
PCInfo(intptr_t pc, int pos, bool is_statement)
: pc_(pc), pos_(pos), is_statement_(is_statement) {}
intptr_t pc_;
int pos_;
bool is_statement_;
};
List<PCInfo>* pc_info() { return &pc_info_; }
private:
void AddPCInfo(const PCInfo& pc_info) { pc_info_.Add(pc_info); }
List<PCInfo> pc_info_;
};
class CodeDescription BASE_EMBEDDED { class CodeDescription BASE_EMBEDDED {
public: public:
#if V8_TARGET_ARCH_X64 #if V8_TARGET_ARCH_X64
...@@ -910,27 +936,21 @@ class CodeDescription BASE_EMBEDDED { ...@@ -910,27 +936,21 @@ class CodeDescription BASE_EMBEDDED {
}; };
#endif #endif
CodeDescription(const char* name, CodeDescription(const char* name, Code* code, Handle<Script> script,
Code* code, LineInfo* lineinfo, GDBJITInterface::CodeTag tag,
Handle<Script> script,
GDBJITLineInfo* lineinfo,
GDBJITInterface::CodeTag tag,
CompilationInfo* info) CompilationInfo* info)
: name_(name), : name_(name),
code_(code), code_(code),
script_(script), script_(script),
lineinfo_(lineinfo), lineinfo_(lineinfo),
tag_(tag), tag_(tag),
info_(info) { info_(info) {}
}
const char* name() const { const char* name() const {
return name_; return name_;
} }
GDBJITLineInfo* lineinfo() const { LineInfo* lineinfo() const { return lineinfo_; }
return lineinfo_;
}
GDBJITInterface::CodeTag tag() const { GDBJITInterface::CodeTag tag() const {
return tag_; return tag_;
...@@ -989,7 +1009,7 @@ class CodeDescription BASE_EMBEDDED { ...@@ -989,7 +1009,7 @@ class CodeDescription BASE_EMBEDDED {
const char* name_; const char* name_;
Code* code_; Code* code_;
Handle<Script> script_; Handle<Script> script_;
GDBJITLineInfo* lineinfo_; LineInfo* lineinfo_;
GDBJITInterface::CodeTag tag_; GDBJITInterface::CodeTag tag_;
CompilationInfo* info_; CompilationInfo* info_;
#if V8_TARGET_ARCH_X64 #if V8_TARGET_ARCH_X64
...@@ -1451,12 +1471,12 @@ class DebugLineSection : public DebugSection { ...@@ -1451,12 +1471,12 @@ class DebugLineSection : public DebugSection {
intptr_t line = 1; intptr_t line = 1;
bool is_statement = true; bool is_statement = true;
List<GDBJITLineInfo::PCInfo>* pc_info = desc_->lineinfo()->pc_info(); List<LineInfo::PCInfo>* pc_info = desc_->lineinfo()->pc_info();
pc_info->Sort(&ComparePCInfo); pc_info->Sort(&ComparePCInfo);
int pc_info_length = pc_info->length(); int pc_info_length = pc_info->length();
for (int i = 0; i < pc_info_length; i++) { for (int i = 0; i < pc_info_length; i++) {
GDBJITLineInfo::PCInfo* info = &pc_info->at(i); LineInfo::PCInfo* info = &pc_info->at(i);
ASSERT(info->pc_ >= pc); ASSERT(info->pc_ >= pc);
// Reduce bloating in the debug line table by removing duplicate line // Reduce bloating in the debug line table by removing duplicate line
...@@ -1527,8 +1547,8 @@ class DebugLineSection : public DebugSection { ...@@ -1527,8 +1547,8 @@ class DebugLineSection : public DebugSection {
w->Write<uint8_t>(op); w->Write<uint8_t>(op);
} }
static int ComparePCInfo(const GDBJITLineInfo::PCInfo* a, static int ComparePCInfo(const LineInfo::PCInfo* a,
const GDBJITLineInfo::PCInfo* b) { const LineInfo::PCInfo* b) {
if (a->pc_ == b->pc_) { if (a->pc_ == b->pc_) {
if (a->is_statement_ != b->is_statement_) { if (a->is_statement_ != b->is_statement_) {
return b->is_statement_ ? +1 : -1; return b->is_statement_ ? +1 : -1;
...@@ -1967,15 +1987,15 @@ static bool IsLineInfoTagged(void* ptr) { ...@@ -1967,15 +1987,15 @@ static bool IsLineInfoTagged(void* ptr) {
} }
static void* TagLineInfo(GDBJITLineInfo* ptr) { static void* TagLineInfo(LineInfo* ptr) {
return reinterpret_cast<void*>( return reinterpret_cast<void*>(
reinterpret_cast<intptr_t>(ptr) | kLineInfoTag); reinterpret_cast<intptr_t>(ptr) | kLineInfoTag);
} }
static GDBJITLineInfo* UntagLineInfo(void* ptr) { static LineInfo* UntagLineInfo(void* ptr) {
return reinterpret_cast<GDBJITLineInfo*>( return reinterpret_cast<LineInfo*>(reinterpret_cast<intptr_t>(ptr) &
reinterpret_cast<intptr_t>(ptr) & ~kLineInfoTag); ~kLineInfoTag);
} }
...@@ -2051,7 +2071,7 @@ void GDBJITInterface::AddCode(const char* name, ...@@ -2051,7 +2071,7 @@ void GDBJITInterface::AddCode(const char* name,
HashMap::Entry* e = GetEntries()->Lookup(code, HashForCodeObject(code), true); HashMap::Entry* e = GetEntries()->Lookup(code, HashForCodeObject(code), true);
if (e->value != NULL && !IsLineInfoTagged(e->value)) return; if (e->value != NULL && !IsLineInfoTagged(e->value)) return;
GDBJITLineInfo* lineinfo = UntagLineInfo(e->value); LineInfo* lineinfo = UntagLineInfo(e->value);
CodeDescription code_desc(name, CodeDescription code_desc(name,
code, code,
script != NULL ? Handle<Script>(script) script != NULL ? Handle<Script>(script)
...@@ -2167,8 +2187,7 @@ void GDBJITInterface::RemoveCodeRange(Address start, Address end) { ...@@ -2167,8 +2187,7 @@ void GDBJITInterface::RemoveCodeRange(Address start, Address end) {
} }
void GDBJITInterface::RegisterDetailedLineInfo(Code* code, static void RegisterDetailedLineInfo(Code* code, LineInfo* line_info) {
GDBJITLineInfo* line_info) {
base::LockGuard<base::Mutex> lock_guard(mutex.Pointer()); base::LockGuard<base::Mutex> lock_guard(mutex.Pointer());
ASSERT(!IsLineInfoTagged(line_info)); ASSERT(!IsLineInfoTagged(line_info));
HashMap::Entry* e = GetEntries()->Lookup(code, HashForCodeObject(code), true); HashMap::Entry* e = GetEntries()->Lookup(code, HashForCodeObject(code), true);
...@@ -2177,5 +2196,36 @@ void GDBJITInterface::RegisterDetailedLineInfo(Code* code, ...@@ -2177,5 +2196,36 @@ void GDBJITInterface::RegisterDetailedLineInfo(Code* code,
} }
void GDBJITInterface::EventHandler(const v8::JitCodeEvent* event) {
if (!FLAG_gdbjit) return;
switch (event->type) {
case v8::JitCodeEvent::CODE_ADDED:
case v8::JitCodeEvent::CODE_MOVED:
case v8::JitCodeEvent::CODE_REMOVED:
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),
static_cast<int>(event->line_info.pos),
event->line_info.position_type ==
v8::JitCodeEvent::STATEMENT_POSITION);
break;
}
case v8::JitCodeEvent::CODE_START_LINE_INFO_RECORDING: {
v8::JitCodeEvent* mutable_event = const_cast<v8::JitCodeEvent*>(event);
mutable_event->user_data = new LineInfo();
break;
}
case v8::JitCodeEvent::CODE_END_LINE_INFO_RECORDING: {
LineInfo* line_info = reinterpret_cast<LineInfo*>(event->user_data);
Code* code = Code::GetCodeFromTargetAddress(
reinterpret_cast<Address>(event->code_start));
RegisterDetailedLineInfo(code, line_info);
break;
}
}
}
} } // namespace v8::internal } } // namespace v8::internal
#endif #endif
...@@ -34,37 +34,6 @@ class CompilationInfo; ...@@ -34,37 +34,6 @@ class CompilationInfo;
V(EVAL) \ V(EVAL) \
V(FUNCTION) V(FUNCTION)
class GDBJITLineInfo : public Malloced {
public:
GDBJITLineInfo()
: pc_info_(10) { }
void SetPosition(intptr_t pc, int pos, bool is_statement) {
AddPCInfo(PCInfo(pc, pos, is_statement));
}
struct PCInfo {
PCInfo(intptr_t pc, int pos, bool is_statement)
: pc_(pc), pos_(pos), is_statement_(is_statement) { }
intptr_t pc_;
int pos_;
bool is_statement_;
};
List<PCInfo>* pc_info() {
return &pc_info_;
}
private:
void AddPCInfo(const PCInfo& pc_info) {
pc_info_.Add(pc_info);
}
List<PCInfo> pc_info_;
};
class GDBJITInterface: public AllStatic { class GDBJITInterface: public AllStatic {
public: public:
enum CodeTag { enum CodeTag {
...@@ -84,6 +53,9 @@ class GDBJITInterface: public AllStatic { ...@@ -84,6 +53,9 @@ class GDBJITInterface: public AllStatic {
} }
} }
// Main entry point into GDB JIT realized as a JitCodeEventHandler.
static void EventHandler(const v8::JitCodeEvent* event);
static void AddCode(const char* name, static void AddCode(const char* name,
Code* code, Code* code,
CodeTag tag, CodeTag tag,
...@@ -104,8 +76,6 @@ class GDBJITInterface: public AllStatic { ...@@ -104,8 +76,6 @@ class GDBJITInterface: public AllStatic {
static void RemoveCode(Code* code); static void RemoveCode(Code* code);
static void RemoveCodeRange(Address start, Address end); static void RemoveCodeRange(Address start, Address end);
static void RegisterDetailedLineInfo(Code* code, GDBJITLineInfo* line_info);
}; };
#define GDBJIT(action) GDBJITInterface::action #define GDBJIT(action) GDBJITInterface::action
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment