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() {
// the frame (that is done in AssemblePrologue).
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.
if (linkage()->GetIncomingDescriptor()->IsJSFunctionCall()) {
ProfileEntryHookStub::MaybeCallEntryHook(masm());
......@@ -213,6 +209,7 @@ Handle<Code> CodeGenerator::GenerateCode() {
Handle<ByteArray> source_positions =
source_position_table_builder_.ToSourcePositionTable();
result->set_source_position_table(*source_positions);
source_position_table_builder_.EndJitLogging(AbstractCode::cast(*result));
// Emit exception handler table.
if (!handlers_.empty()) {
......@@ -238,11 +235,6 @@ Handle<Code> CodeGenerator::GenerateCode() {
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;
}
......
......@@ -452,10 +452,6 @@ Handle<Code> LChunk::Codegen() {
DCHECK(!info()->will_serialize());
LCodeGen generator(this, &assembler, info());
LOG_CODE_EVENT(info()->isolate(),
CodeStartLinePosInfoRecordEvent(
generator.source_position_table_builder()));
MarkEmptyBlocks();
if (generator.GenerateCode()) {
......@@ -464,12 +460,9 @@ Handle<Code> LChunk::Codegen() {
Handle<Code> code = CodeGenerator::MakeCodeEpilogue(&assembler, info());
generator.FinishCode(code);
CommitDependencies(code);
generator.source_position_table_builder()->EndJitLogging(
AbstractCode::cast(*code));
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());
DCHECK(!(info()->GetMustNotHaveEagerFrame() &&
......
......@@ -47,8 +47,6 @@ bool FullCodeGenerator::MakeCode(CompilationInfo* info) {
if (info->will_serialize()) masm.enable_serializer();
FullCodeGenerator cgen(&masm, info);
LOG_CODE_EVENT(isolate, CodeStartLinePosInfoRecordEvent(
&cgen.source_position_table_builder_));
cgen.Generate();
if (cgen.HasStackOverflow()) {
DCHECK(!isolate->has_pending_exception());
......@@ -68,11 +66,9 @@ bool FullCodeGenerator::MakeCode(CompilationInfo* info) {
Handle<ByteArray> source_positions =
cgen.source_position_table_builder_.ToSourcePositionTable();
code->set_source_position_table(*source_positions);
cgen.source_position_table_builder_.EndJitLogging(AbstractCode::cast(*code));
CodeGenerator::PrintCode(code, info);
info->SetCode(code);
void* line_info = cgen.source_position_table_builder_.DetachJITHandlerData();
LOG_CODE_EVENT(isolate, CodeEndLinePosInfoRecordEvent(
AbstractCode::cast(*code), line_info));
#ifdef DEBUG
// Check that no context-specific object has been embedded.
......
......@@ -23,10 +23,7 @@ BytecodeArrayWriter::BytecodeArrayWriter(
max_register_count_(0),
unbound_jumps_(0),
source_position_table_builder_(isolate, zone),
constant_array_builder_(constant_array_builder) {
LOG_CODE_EVENT(isolate_, CodeStartLinePosInfoRecordEvent(
source_position_table_builder()));
}
constant_array_builder_(constant_array_builder) {}
// override
BytecodeArrayWriter::~BytecodeArrayWriter() {}
......@@ -45,17 +42,15 @@ Handle<BytecodeArray> BytecodeArrayWriter::ToBytecodeArray(
int frame_size_used = max_register_count() * kPointerSize;
int frame_size = std::max(frame_size_for_locals, frame_size_used);
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(
bytecode_size, &bytecodes()->front(), frame_size, parameter_count,
constant_pool);
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);
void* line_info = source_position_table_builder()->DetachJITHandlerData();
LOG_CODE_EVENT(isolate_, CodeEndLinePosInfoRecordEvent(
AbstractCode::cast(*bytecode_array), line_info));
source_position_table_builder()->EndJitLogging(
AbstractCode::cast(*bytecode_array));
return bytecode_array;
}
......
......@@ -1241,11 +1241,9 @@ void Logger::CodeLinePosInfoAddStatementPositionEvent(void* jit_handler_data,
JitCodeEvent::STATEMENT_POSITION));
}
void Logger::CodeStartLinePosInfoRecordEvent(PositionsRecorder* pos_recorder) {
if (jit_logger_ != NULL) {
pos_recorder->AttachJITHandlerData(jit_logger_->StartCodePosInfoEvent());
}
void Logger::CodeStartLinePosInfoRecordEvent(void** jit_handler_data_out) {
*jit_handler_data_out =
(jit_logger_ == NULL) ? NULL : jit_logger_->StartCodePosInfoEvent();
}
void Logger::CodeEndLinePosInfoRecordEvent(AbstractCode* code,
......
......@@ -66,7 +66,6 @@ class CodeEventListener;
class CpuProfiler;
class Isolate;
class Log;
class PositionsRecorder;
class Profiler;
class Ticker;
struct TickSample;
......@@ -193,7 +192,7 @@ class Logger : public CodeEventListener {
int pc_offset,
int position);
// 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.
// It's the callee's responsibility to dispose the parameter jit_handler_data.
void CodeEndLinePosInfoRecordEvent(AbstractCode* code,
......@@ -351,6 +350,7 @@ class Logger : public CodeEventListener {
base::ElapsedTimer timer_;
friend class CpuProfiler;
friend class SourcePositionTableBuilder;
};
#define TIMER_EVENTS_LIST(V) \
......@@ -390,27 +390,6 @@ class TimerEventScope {
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 {
public:
CodeEventLogger();
......
......@@ -4,6 +4,7 @@
#include "src/source-position-table.h"
#include "src/log.h"
#include "src/objects-inl.h"
#include "src/objects.h"
......@@ -103,6 +104,23 @@ void DecodeEntry(ByteArray* bytes, int* index, PositionTableEntry* entry) {
} // 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,
int source_position,
bool is_statement) {
......
......@@ -8,12 +8,12 @@
#include "src/assert-scope.h"
#include "src/checks.h"
#include "src/handles.h"
#include "src/log.h"
#include "src/zone-containers.h"
namespace v8 {
namespace internal {
class AbstractCode;
class BytecodeArray;
class ByteArray;
class Isolate;
......@@ -30,23 +30,17 @@ struct PositionTableEntry {
bool is_statement;
};
class SourcePositionTableBuilder final : public PositionsRecorder {
class SourcePositionTableBuilder {
public:
SourcePositionTableBuilder(Isolate* isolate, Zone* zone)
: isolate_(isolate),
bytes_(zone),
#ifdef ENABLE_SLOW_DCHECKS
raw_entries_(zone),
#endif
previous_() {
}
SourcePositionTableBuilder(Isolate* isolate, Zone* zone);
void EndJitLogging(AbstractCode* code);
void AddPosition(size_t code_offset, int source_position, bool is_statement);
Handle<ByteArray> ToSourcePositionTable();
private:
void AddEntry(const PositionTableEntry& entry);
void CommitEntry();
Isolate* isolate_;
ZoneVector<byte> bytes_;
......@@ -54,6 +48,9 @@ class SourcePositionTableBuilder final : public PositionsRecorder {
ZoneVector<PositionTableEntry> raw_entries_;
#endif
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 {
......
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