[cpu-profiler] Use unique pointer for line info

Change-Id: Ia1289985fa715ce4de66bec91675279c203afa36
Reviewed-on: https://chromium-review.googlesource.com/897811
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Commit-Queue: Franziska Hinkelmann <franzih@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51091}
This commit is contained in:
Franziska Hinkelmann 2018-02-02 13:49:52 +01:00 committed by Commit Bot
parent 190a896879
commit 23dd8ef207
5 changed files with 14 additions and 18 deletions

View File

@ -13,7 +13,8 @@ namespace internal {
CodeEntry::CodeEntry(CodeEventListener::LogEventsAndTags tag, const char* name,
const char* name_prefix, const char* resource_name,
int line_number, int column_number,
JITLineInfoTable* line_info, Address instruction_start)
std::unique_ptr<JITLineInfoTable> line_info,
Address instruction_start)
: bit_field_(TagField::encode(tag) |
BuiltinIdField::encode(Builtins::builtin_count)),
name_prefix_(name_prefix),
@ -26,7 +27,7 @@ CodeEntry::CodeEntry(CodeEventListener::LogEventsAndTags tag, const char* name,
bailout_reason_(kEmptyBailoutReason),
deopt_reason_(kNoDeoptReason),
deopt_id_(kNoDeoptimizationId),
line_info_(line_info),
line_info_(std::move(line_info)),
instruction_start_(instruction_start) {}
ProfileNode::ProfileNode(ProfileTree* tree, CodeEntry* entry,

View File

@ -85,11 +85,6 @@ CodeEntry* CodeEntry::UnresolvedEntryCreateTrait::Create() {
CodeEntry::kUnresolvedFunctionName);
}
CodeEntry::~CodeEntry() {
delete line_info_;
}
uint32_t CodeEntry::GetHash() const {
uint32_t hash = ComputeIntegerHash(tag());
if (script_id_ != v8::UnboundScript::kNoScriptId) {

View File

@ -47,9 +47,8 @@ class CodeEntry {
const char* resource_name = CodeEntry::kEmptyResourceName,
int line_number = v8::CpuProfileNode::kNoLineNumberInfo,
int column_number = v8::CpuProfileNode::kNoColumnNumberInfo,
JITLineInfoTable* line_info = nullptr,
std::unique_ptr<JITLineInfoTable> line_info = nullptr,
Address instruction_start = nullptr);
~CodeEntry();
const char* name_prefix() const { return name_prefix_; }
bool has_name_prefix() const { return name_prefix_[0] != '\0'; }
@ -57,7 +56,7 @@ class CodeEntry {
const char* resource_name() const { return resource_name_; }
int line_number() const { return line_number_; }
int column_number() const { return column_number_; }
const JITLineInfoTable* line_info() const { return line_info_; }
const JITLineInfoTable* line_info() const { return line_info_.get(); }
int script_id() const { return script_id_; }
void set_script_id(int script_id) { script_id_ = script_id; }
int position() const { return position_; }
@ -162,7 +161,7 @@ class CodeEntry {
const char* bailout_reason_;
const char* deopt_reason_;
int deopt_id_;
JITLineInfoTable* line_info_;
std::unique_ptr<JITLineInfoTable> line_info_;
Address instruction_start_;
// Should be an unordered_map, but it doesn't currently work on Win & MacOS.
std::map<int, std::vector<std::unique_ptr<CodeEntry>>> inline_locations_;

View File

@ -81,10 +81,10 @@ void ProfilerListener::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
rec->start = abstract_code->address();
JITLineInfoTable* line_table = nullptr;
std::unique_ptr<JITLineInfoTable> line_table;
if (shared->script()->IsScript()) {
Script* script = Script::cast(shared->script());
line_table = new JITLineInfoTable();
line_table.reset(new JITLineInfoTable());
int offset = abstract_code->IsCode() ? Code::kHeaderSize
: BytecodeArray::kHeaderSize;
for (SourcePositionTableIterator it(abstract_code->source_position_table());
@ -101,8 +101,8 @@ void ProfilerListener::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
}
rec->entry = NewCodeEntry(
tag, GetFunctionName(shared->DebugName()), CodeEntry::kEmptyNamePrefix,
GetName(InferScriptName(script_name, shared)), line, column, line_table,
abstract_code->instruction_start());
GetName(InferScriptName(script_name, shared)), line, column,
std::move(line_table), abstract_code->instruction_start());
RecordInliningInfo(rec->entry, abstract_code);
RecordDeoptInlinedFrames(rec->entry, abstract_code);
rec->entry->FillFunctionInfo(shared);
@ -276,10 +276,11 @@ void ProfilerListener::RecordDeoptInlinedFrames(CodeEntry* entry,
CodeEntry* ProfilerListener::NewCodeEntry(
CodeEventListener::LogEventsAndTags tag, const char* name,
const char* name_prefix, const char* resource_name, int line_number,
int column_number, JITLineInfoTable* line_info, Address instruction_start) {
int column_number, std::unique_ptr<JITLineInfoTable> line_info,
Address instruction_start) {
std::unique_ptr<CodeEntry> code_entry = base::make_unique<CodeEntry>(
tag, name, name_prefix, resource_name, line_number, column_number,
line_info, instruction_start);
std::move(line_info), instruction_start);
CodeEntry* raw_code_entry = code_entry.get();
code_entries_.push_back(std::move(code_entry));
return raw_code_entry;

View File

@ -54,7 +54,7 @@ class ProfilerListener : public CodeEventListener {
const char* resource_name = CodeEntry::kEmptyResourceName,
int line_number = v8::CpuProfileNode::kNoLineNumberInfo,
int column_number = v8::CpuProfileNode::kNoColumnNumberInfo,
JITLineInfoTable* line_info = nullptr,
std::unique_ptr<JITLineInfoTable> line_info = nullptr,
Address instruction_start = nullptr);
void AddObserver(CodeEventObserver* observer);