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) {
ASSERT(pos != RelocInfo::kNoPosition);
ASSERT(pos >= 0);
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(),
CodeLinePosInfoAddPositionEvent(jit_handler_data_,
assembler_->pc_offset(),
......@@ -1588,11 +1583,6 @@ void PositionsRecorder::RecordStatementPosition(int pos) {
ASSERT(pos != RelocInfo::kNoPosition);
ASSERT(pos >= 0);
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(),
CodeLinePosInfoAddStatementPositionEvent(
jit_handler_data_,
......
......@@ -1022,29 +1022,9 @@ class PositionsRecorder BASE_EMBEDDED {
public:
explicit PositionsRecorder(Assembler* assembler)
: assembler_(assembler) {
#ifdef ENABLE_GDB_JIT_INTERFACE
gdbjit_lineinfo_ = NULL;
#endif
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) {
jit_handler_data_ = user_data;
}
......@@ -1072,9 +1052,6 @@ class PositionsRecorder BASE_EMBEDDED {
private:
Assembler* assembler_;
PositionState state_;
#ifdef ENABLE_GDB_JIT_INTERFACE
GDBJITLineInfo* gdbjit_lineinfo_;
#endif
// Currently jit_handler_data_ is used to store JITHandler-specific data
// over the lifetime of a PositionsRecorder
......
......@@ -29,6 +29,10 @@
#include "include/v8-testing.h"
#endif // V8_SHARED
#ifdef ENABLE_GDB_JIT_INTERFACE
#include "src/gdb-jit.h"
#endif
#ifdef ENABLE_VTUNE_JIT_INTERFACE
#include "src/third_party/vtune/v8-vtune.h"
#endif
......@@ -1577,6 +1581,10 @@ int Shell::Main(int argc, char* argv[]) {
{
Isolate::Scope scope(isolate);
Initialize(isolate);
#ifdef ENABLE_GDB_JIT_INTERFACE
v8::V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault,
i::GDBJITInterface::EventHandler);
#endif
#ifdef ENABLE_VTUNE_JIT_INTERFACE
vTune::InitializeVtuneForV8();
#endif
......
......@@ -303,9 +303,6 @@ bool FullCodeGenerator::MakeCode(CompilationInfo* info) {
MacroAssembler masm(info->isolate(), NULL, kInitialBufferSize);
if (info->will_serialize()) masm.enable_serializer();
#ifdef ENABLE_GDB_JIT_INTERFACE
masm.positions_recorder()->StartGDBJITLineInfoRecording();
#endif
LOG_CODE_EVENT(isolate,
CodeStartLinePosInfoRecordEvent(masm.positions_recorder()));
......@@ -332,13 +329,6 @@ bool FullCodeGenerator::MakeCode(CompilationInfo* info) {
code->set_back_edge_table_offset(table_offset);
CodeGenerator::PrintCode(code, info);
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();
LOG_CODE_EVENT(isolate, CodeEndLinePosInfoRecordEvent(*code, line_info));
return true;
......
......@@ -899,6 +899,32 @@ class ELFSymbolTable : public ELFSection {
#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 {
public:
#if V8_TARGET_ARCH_X64
......@@ -910,27 +936,21 @@ class CodeDescription BASE_EMBEDDED {
};
#endif
CodeDescription(const char* name,
Code* code,
Handle<Script> script,
GDBJITLineInfo* lineinfo,
GDBJITInterface::CodeTag tag,
CodeDescription(const char* name, Code* code, Handle<Script> script,
LineInfo* lineinfo, GDBJITInterface::CodeTag tag,
CompilationInfo* info)
: name_(name),
code_(code),
script_(script),
lineinfo_(lineinfo),
tag_(tag),
info_(info) {
}
info_(info) {}
const char* name() const {
return name_;
}
GDBJITLineInfo* lineinfo() const {
return lineinfo_;
}
LineInfo* lineinfo() const { return lineinfo_; }
GDBJITInterface::CodeTag tag() const {
return tag_;
......@@ -989,7 +1009,7 @@ class CodeDescription BASE_EMBEDDED {
const char* name_;
Code* code_;
Handle<Script> script_;
GDBJITLineInfo* lineinfo_;
LineInfo* lineinfo_;
GDBJITInterface::CodeTag tag_;
CompilationInfo* info_;
#if V8_TARGET_ARCH_X64
......@@ -1451,12 +1471,12 @@ class DebugLineSection : public DebugSection {
intptr_t line = 1;
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);
int pc_info_length = pc_info->length();
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);
// Reduce bloating in the debug line table by removing duplicate line
......@@ -1527,8 +1547,8 @@ class DebugLineSection : public DebugSection {
w->Write<uint8_t>(op);
}
static int ComparePCInfo(const GDBJITLineInfo::PCInfo* a,
const GDBJITLineInfo::PCInfo* b) {
static int ComparePCInfo(const LineInfo::PCInfo* a,
const LineInfo::PCInfo* b) {
if (a->pc_ == b->pc_) {
if (a->is_statement_ != b->is_statement_) {
return b->is_statement_ ? +1 : -1;
......@@ -1967,15 +1987,15 @@ static bool IsLineInfoTagged(void* ptr) {
}
static void* TagLineInfo(GDBJITLineInfo* ptr) {
static void* TagLineInfo(LineInfo* ptr) {
return reinterpret_cast<void*>(
reinterpret_cast<intptr_t>(ptr) | kLineInfoTag);
}
static GDBJITLineInfo* UntagLineInfo(void* ptr) {
return reinterpret_cast<GDBJITLineInfo*>(
reinterpret_cast<intptr_t>(ptr) & ~kLineInfoTag);
static LineInfo* UntagLineInfo(void* ptr) {
return reinterpret_cast<LineInfo*>(reinterpret_cast<intptr_t>(ptr) &
~kLineInfoTag);
}
......@@ -2051,7 +2071,7 @@ void GDBJITInterface::AddCode(const char* name,
HashMap::Entry* e = GetEntries()->Lookup(code, HashForCodeObject(code), true);
if (e->value != NULL && !IsLineInfoTagged(e->value)) return;
GDBJITLineInfo* lineinfo = UntagLineInfo(e->value);
LineInfo* lineinfo = UntagLineInfo(e->value);
CodeDescription code_desc(name,
code,
script != NULL ? Handle<Script>(script)
......@@ -2167,8 +2187,7 @@ void GDBJITInterface::RemoveCodeRange(Address start, Address end) {
}
void GDBJITInterface::RegisterDetailedLineInfo(Code* code,
GDBJITLineInfo* line_info) {
static void RegisterDetailedLineInfo(Code* code, LineInfo* line_info) {
base::LockGuard<base::Mutex> lock_guard(mutex.Pointer());
ASSERT(!IsLineInfoTagged(line_info));
HashMap::Entry* e = GetEntries()->Lookup(code, HashForCodeObject(code), true);
......@@ -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
#endif
......@@ -34,37 +34,6 @@ class CompilationInfo;
V(EVAL) \
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 {
public:
enum CodeTag {
......@@ -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,
Code* code,
CodeTag tag,
......@@ -104,8 +76,6 @@ class GDBJITInterface: public AllStatic {
static void RemoveCode(Code* code);
static void RemoveCodeRange(Address start, Address end);
static void RegisterDetailedLineInfo(Code* code, GDBJITLineInfo* line_info);
};
#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