Commit bcb5b3d5 authored by yangguo's avatar yangguo Committed by Commit bot

Simplify JIT event logging.

R=jgruber@chromium.org
BUG=v8:5117

Review-Url: https://codereview.chromium.org/2111793002
Cr-Commit-Position: refs/heads/master@{#37435}
parent 33ceb9e5
...@@ -73,10 +73,6 @@ Handle<Code> CodeGenerator::GenerateCode() { ...@@ -73,10 +73,6 @@ Handle<Code> CodeGenerator::GenerateCode() {
// the frame (that is done in AssemblePrologue). // the frame (that is done in AssemblePrologue).
FrameScope frame_scope(masm(), StackFrame::MANUAL); FrameScope frame_scope(masm(), StackFrame::MANUAL);
// Emit a code line info recording start event.
LOG_CODE_EVENT(isolate(), CodeStartLinePosInfoRecordEvent(
&source_position_table_builder_));
// Place function entry hook if requested to do so. // Place function entry hook if requested to do so.
if (linkage()->GetIncomingDescriptor()->IsJSFunctionCall()) { if (linkage()->GetIncomingDescriptor()->IsJSFunctionCall()) {
ProfileEntryHookStub::MaybeCallEntryHook(masm()); ProfileEntryHookStub::MaybeCallEntryHook(masm());
...@@ -213,6 +209,7 @@ Handle<Code> CodeGenerator::GenerateCode() { ...@@ -213,6 +209,7 @@ Handle<Code> CodeGenerator::GenerateCode() {
Handle<ByteArray> source_positions = Handle<ByteArray> source_positions =
source_position_table_builder_.ToSourcePositionTable(); source_position_table_builder_.ToSourcePositionTable();
result->set_source_position_table(*source_positions); result->set_source_position_table(*source_positions);
source_position_table_builder_.EndJitLogging(AbstractCode::cast(*result));
// Emit exception handler table. // Emit exception handler table.
if (!handlers_.empty()) { if (!handlers_.empty()) {
...@@ -238,11 +235,6 @@ Handle<Code> CodeGenerator::GenerateCode() { ...@@ -238,11 +235,6 @@ Handle<Code> CodeGenerator::GenerateCode() {
Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(result); Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(result);
} }
// Emit a code line info recording stop event.
void* line_info = source_position_table_builder_.DetachJITHandlerData();
LOG_CODE_EVENT(isolate(), CodeEndLinePosInfoRecordEvent(
AbstractCode::cast(*result), line_info));
return result; return result;
} }
......
...@@ -452,10 +452,6 @@ Handle<Code> LChunk::Codegen() { ...@@ -452,10 +452,6 @@ Handle<Code> LChunk::Codegen() {
DCHECK(!info()->will_serialize()); DCHECK(!info()->will_serialize());
LCodeGen generator(this, &assembler, info()); LCodeGen generator(this, &assembler, info());
LOG_CODE_EVENT(info()->isolate(),
CodeStartLinePosInfoRecordEvent(
generator.source_position_table_builder()));
MarkEmptyBlocks(); MarkEmptyBlocks();
if (generator.GenerateCode()) { if (generator.GenerateCode()) {
...@@ -464,12 +460,9 @@ Handle<Code> LChunk::Codegen() { ...@@ -464,12 +460,9 @@ Handle<Code> LChunk::Codegen() {
Handle<Code> code = CodeGenerator::MakeCodeEpilogue(&assembler, info()); Handle<Code> code = CodeGenerator::MakeCodeEpilogue(&assembler, info());
generator.FinishCode(code); generator.FinishCode(code);
CommitDependencies(code); CommitDependencies(code);
generator.source_position_table_builder()->EndJitLogging(
AbstractCode::cast(*code));
code->set_is_crankshafted(true); code->set_is_crankshafted(true);
void* jit_handler_data =
generator.source_position_table_builder()->DetachJITHandlerData();
LOG_CODE_EVENT(info()->isolate(),
CodeEndLinePosInfoRecordEvent(AbstractCode::cast(*code),
jit_handler_data));
CodeGenerator::PrintCode(code, info()); CodeGenerator::PrintCode(code, info());
DCHECK(!(info()->GetMustNotHaveEagerFrame() && DCHECK(!(info()->GetMustNotHaveEagerFrame() &&
......
...@@ -47,8 +47,6 @@ bool FullCodeGenerator::MakeCode(CompilationInfo* info) { ...@@ -47,8 +47,6 @@ bool FullCodeGenerator::MakeCode(CompilationInfo* info) {
if (info->will_serialize()) masm.enable_serializer(); if (info->will_serialize()) masm.enable_serializer();
FullCodeGenerator cgen(&masm, info); FullCodeGenerator cgen(&masm, info);
LOG_CODE_EVENT(isolate, CodeStartLinePosInfoRecordEvent(
&cgen.source_position_table_builder_));
cgen.Generate(); cgen.Generate();
if (cgen.HasStackOverflow()) { if (cgen.HasStackOverflow()) {
DCHECK(!isolate->has_pending_exception()); DCHECK(!isolate->has_pending_exception());
...@@ -68,11 +66,9 @@ bool FullCodeGenerator::MakeCode(CompilationInfo* info) { ...@@ -68,11 +66,9 @@ bool FullCodeGenerator::MakeCode(CompilationInfo* info) {
Handle<ByteArray> source_positions = Handle<ByteArray> source_positions =
cgen.source_position_table_builder_.ToSourcePositionTable(); cgen.source_position_table_builder_.ToSourcePositionTable();
code->set_source_position_table(*source_positions); code->set_source_position_table(*source_positions);
cgen.source_position_table_builder_.EndJitLogging(AbstractCode::cast(*code));
CodeGenerator::PrintCode(code, info); CodeGenerator::PrintCode(code, info);
info->SetCode(code); info->SetCode(code);
void* line_info = cgen.source_position_table_builder_.DetachJITHandlerData();
LOG_CODE_EVENT(isolate, CodeEndLinePosInfoRecordEvent(
AbstractCode::cast(*code), line_info));
#ifdef DEBUG #ifdef DEBUG
// Check that no context-specific object has been embedded. // Check that no context-specific object has been embedded.
......
...@@ -23,10 +23,7 @@ BytecodeArrayWriter::BytecodeArrayWriter( ...@@ -23,10 +23,7 @@ BytecodeArrayWriter::BytecodeArrayWriter(
max_register_count_(0), max_register_count_(0),
unbound_jumps_(0), unbound_jumps_(0),
source_position_table_builder_(isolate, zone), source_position_table_builder_(isolate, zone),
constant_array_builder_(constant_array_builder) { constant_array_builder_(constant_array_builder) {}
LOG_CODE_EVENT(isolate_, CodeStartLinePosInfoRecordEvent(
source_position_table_builder()));
}
// override // override
BytecodeArrayWriter::~BytecodeArrayWriter() {} BytecodeArrayWriter::~BytecodeArrayWriter() {}
...@@ -45,17 +42,15 @@ Handle<BytecodeArray> BytecodeArrayWriter::ToBytecodeArray( ...@@ -45,17 +42,15 @@ Handle<BytecodeArray> BytecodeArrayWriter::ToBytecodeArray(
int frame_size_used = max_register_count() * kPointerSize; int frame_size_used = max_register_count() * kPointerSize;
int frame_size = std::max(frame_size_for_locals, frame_size_used); int frame_size = std::max(frame_size_for_locals, frame_size_used);
Handle<FixedArray> constant_pool = constant_array_builder()->ToFixedArray(); Handle<FixedArray> constant_pool = constant_array_builder()->ToFixedArray();
Handle<ByteArray> source_position_table =
source_position_table_builder()->ToSourcePositionTable();
Handle<BytecodeArray> bytecode_array = isolate_->factory()->NewBytecodeArray( Handle<BytecodeArray> bytecode_array = isolate_->factory()->NewBytecodeArray(
bytecode_size, &bytecodes()->front(), frame_size, parameter_count, bytecode_size, &bytecodes()->front(), frame_size, parameter_count,
constant_pool); constant_pool);
bytecode_array->set_handler_table(*handler_table); bytecode_array->set_handler_table(*handler_table);
Handle<ByteArray> source_position_table =
source_position_table_builder()->ToSourcePositionTable();
bytecode_array->set_source_position_table(*source_position_table); bytecode_array->set_source_position_table(*source_position_table);
source_position_table_builder()->EndJitLogging(
void* line_info = source_position_table_builder()->DetachJITHandlerData(); AbstractCode::cast(*bytecode_array));
LOG_CODE_EVENT(isolate_, CodeEndLinePosInfoRecordEvent(
AbstractCode::cast(*bytecode_array), line_info));
return bytecode_array; return bytecode_array;
} }
......
...@@ -1241,11 +1241,9 @@ void Logger::CodeLinePosInfoAddStatementPositionEvent(void* jit_handler_data, ...@@ -1241,11 +1241,9 @@ void Logger::CodeLinePosInfoAddStatementPositionEvent(void* jit_handler_data,
JitCodeEvent::STATEMENT_POSITION)); JitCodeEvent::STATEMENT_POSITION));
} }
void Logger::CodeStartLinePosInfoRecordEvent(void** jit_handler_data_out) {
void Logger::CodeStartLinePosInfoRecordEvent(PositionsRecorder* pos_recorder) { *jit_handler_data_out =
if (jit_logger_ != NULL) { (jit_logger_ == NULL) ? NULL : jit_logger_->StartCodePosInfoEvent();
pos_recorder->AttachJITHandlerData(jit_logger_->StartCodePosInfoEvent());
}
} }
void Logger::CodeEndLinePosInfoRecordEvent(AbstractCode* code, void Logger::CodeEndLinePosInfoRecordEvent(AbstractCode* code,
......
...@@ -66,7 +66,6 @@ class CodeEventListener; ...@@ -66,7 +66,6 @@ class CodeEventListener;
class CpuProfiler; class CpuProfiler;
class Isolate; class Isolate;
class Log; class Log;
class PositionsRecorder;
class Profiler; class Profiler;
class Ticker; class Ticker;
struct TickSample; struct TickSample;
...@@ -193,7 +192,7 @@ class Logger : public CodeEventListener { ...@@ -193,7 +192,7 @@ class Logger : public CodeEventListener {
int pc_offset, int pc_offset,
int position); int position);
// Emits a code line info start to record event // Emits a code line info start to record event
void CodeStartLinePosInfoRecordEvent(PositionsRecorder* pos_recorder); void CodeStartLinePosInfoRecordEvent(void** jit_handler_data_out);
// Emits a code line info finish record event. // Emits a code line info finish record event.
// It's the callee's responsibility to dispose the parameter jit_handler_data. // It's the callee's responsibility to dispose the parameter jit_handler_data.
void CodeEndLinePosInfoRecordEvent(AbstractCode* code, void CodeEndLinePosInfoRecordEvent(AbstractCode* code,
...@@ -351,6 +350,7 @@ class Logger : public CodeEventListener { ...@@ -351,6 +350,7 @@ class Logger : public CodeEventListener {
base::ElapsedTimer timer_; base::ElapsedTimer timer_;
friend class CpuProfiler; friend class CpuProfiler;
friend class SourcePositionTableBuilder;
}; };
#define TIMER_EVENTS_LIST(V) \ #define TIMER_EVENTS_LIST(V) \
...@@ -390,27 +390,6 @@ class TimerEventScope { ...@@ -390,27 +390,6 @@ class TimerEventScope {
Isolate* isolate_; Isolate* isolate_;
}; };
class PositionsRecorder BASE_EMBEDDED {
public:
PositionsRecorder() { jit_handler_data_ = NULL; }
void AttachJITHandlerData(void* user_data) { jit_handler_data_ = user_data; }
void* DetachJITHandlerData() {
void* old_data = jit_handler_data_;
jit_handler_data_ = NULL;
return old_data;
}
protected:
// Currently jit_handler_data_ is used to store JITHandler-specific data
// over the lifetime of a PositionsRecorder
void* jit_handler_data_;
private:
DISALLOW_COPY_AND_ASSIGN(PositionsRecorder);
};
class CodeEventLogger : public CodeEventListener { class CodeEventLogger : public CodeEventListener {
public: public:
CodeEventLogger(); CodeEventLogger();
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "src/source-position-table.h" #include "src/source-position-table.h"
#include "src/log.h"
#include "src/objects-inl.h" #include "src/objects-inl.h"
#include "src/objects.h" #include "src/objects.h"
...@@ -103,6 +104,23 @@ void DecodeEntry(ByteArray* bytes, int* index, PositionTableEntry* entry) { ...@@ -103,6 +104,23 @@ void DecodeEntry(ByteArray* bytes, int* index, PositionTableEntry* entry) {
} // namespace } // namespace
SourcePositionTableBuilder::SourcePositionTableBuilder(Isolate* isolate,
Zone* zone)
: isolate_(isolate),
bytes_(zone),
#ifdef ENABLE_SLOW_DCHECKS
raw_entries_(zone),
#endif
previous_(),
jit_handler_data_(nullptr) {
LOG_CODE_EVENT(isolate_, CodeStartLinePosInfoRecordEvent(&jit_handler_data_));
}
void SourcePositionTableBuilder::EndJitLogging(AbstractCode* code) {
LOG_CODE_EVENT(isolate_,
CodeEndLinePosInfoRecordEvent(code, jit_handler_data_));
}
void SourcePositionTableBuilder::AddPosition(size_t code_offset, void SourcePositionTableBuilder::AddPosition(size_t code_offset,
int source_position, int source_position,
bool is_statement) { bool is_statement) {
......
...@@ -8,12 +8,12 @@ ...@@ -8,12 +8,12 @@
#include "src/assert-scope.h" #include "src/assert-scope.h"
#include "src/checks.h" #include "src/checks.h"
#include "src/handles.h" #include "src/handles.h"
#include "src/log.h"
#include "src/zone-containers.h" #include "src/zone-containers.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
class AbstractCode;
class BytecodeArray; class BytecodeArray;
class ByteArray; class ByteArray;
class Isolate; class Isolate;
...@@ -30,23 +30,17 @@ struct PositionTableEntry { ...@@ -30,23 +30,17 @@ struct PositionTableEntry {
bool is_statement; bool is_statement;
}; };
class SourcePositionTableBuilder final : public PositionsRecorder { class SourcePositionTableBuilder {
public: public:
SourcePositionTableBuilder(Isolate* isolate, Zone* zone) SourcePositionTableBuilder(Isolate* isolate, Zone* zone);
: isolate_(isolate),
bytes_(zone), void EndJitLogging(AbstractCode* code);
#ifdef ENABLE_SLOW_DCHECKS
raw_entries_(zone),
#endif
previous_() {
}
void AddPosition(size_t code_offset, int source_position, bool is_statement); void AddPosition(size_t code_offset, int source_position, bool is_statement);
Handle<ByteArray> ToSourcePositionTable(); Handle<ByteArray> ToSourcePositionTable();
private: private:
void AddEntry(const PositionTableEntry& entry); void AddEntry(const PositionTableEntry& entry);
void CommitEntry();
Isolate* isolate_; Isolate* isolate_;
ZoneVector<byte> bytes_; ZoneVector<byte> bytes_;
...@@ -54,6 +48,9 @@ class SourcePositionTableBuilder final : public PositionsRecorder { ...@@ -54,6 +48,9 @@ class SourcePositionTableBuilder final : public PositionsRecorder {
ZoneVector<PositionTableEntry> raw_entries_; ZoneVector<PositionTableEntry> raw_entries_;
#endif #endif
PositionTableEntry previous_; // Previously written entry, to compute delta. PositionTableEntry previous_; // Previously written entry, to compute delta.
// Currently jit_handler_data_ is used to store JITHandler-specific data
// over the lifetime of a SourcePositionTableBuilder.
void* jit_handler_data_;
}; };
class SourcePositionTableIterator { class SourcePositionTableIterator {
......
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