Commit 0ee2eefd authored by Franziska Hinkelmann's avatar Franziska Hinkelmann Committed by Commit Bot

[cpu-profiler] Use unique_ptrs in the inline stack

Small cleanup.

Change-Id: I80f7ede4de1aed3e37c2b20cb3706cb9ef3aa9be
Reviewed-on: https://chromium-review.googlesource.com/897810Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Commit-Queue: Franziska Hinkelmann <franzih@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51056}
parent 9232b4ba
......@@ -87,11 +87,6 @@ CodeEntry* CodeEntry::UnresolvedEntryCreateTrait::Create() {
CodeEntry::~CodeEntry() {
delete line_info_;
for (auto location : inline_locations_) {
for (auto entry : location.second) {
delete entry;
}
}
}
......@@ -137,12 +132,13 @@ int CodeEntry::GetSourceLine(int pc_offset) const {
return v8::CpuProfileNode::kNoLineNumberInfo;
}
void CodeEntry::AddInlineStack(int pc_offset,
std::vector<CodeEntry*> inline_stack) {
void CodeEntry::AddInlineStack(
int pc_offset, std::vector<std::unique_ptr<CodeEntry>> inline_stack) {
inline_locations_.insert(std::make_pair(pc_offset, std::move(inline_stack)));
}
const std::vector<CodeEntry*>* CodeEntry::GetInlineStack(int pc_offset) const {
const std::vector<std::unique_ptr<CodeEntry>>* CodeEntry::GetInlineStack(
int pc_offset) const {
auto it = inline_locations_.find(pc_offset);
return it != inline_locations_.end() ? &it->second : nullptr;
}
......@@ -684,11 +680,13 @@ void ProfileGenerator::RecordTickSample(const TickSample& sample) {
// Find out if the entry has an inlining stack associated.
int pc_offset =
static_cast<int>(stack_pos - entry->instruction_start());
const std::vector<CodeEntry*>* inline_stack =
const std::vector<std::unique_ptr<CodeEntry>>* inline_stack =
entry->GetInlineStack(pc_offset);
if (inline_stack) {
entries.insert(entries.end(), inline_stack->rbegin(),
inline_stack->rend());
std::transform(
inline_stack->rbegin(), inline_stack->rend(),
std::back_inserter(entries),
[](const std::unique_ptr<CodeEntry>& ptr) { return ptr.get(); });
}
// Skip unresolved frames (e.g. internal frame) and get source line of
// the first JS caller.
......
......@@ -91,8 +91,10 @@ class CodeEntry {
int GetSourceLine(int pc_offset) const;
void AddInlineStack(int pc_offset, std::vector<CodeEntry*> inline_stack);
const std::vector<CodeEntry*>* GetInlineStack(int pc_offset) const;
void AddInlineStack(int pc_offset,
std::vector<std::unique_ptr<CodeEntry>> inline_stack);
const std::vector<std::unique_ptr<CodeEntry>>* GetInlineStack(
int pc_offset) const;
void AddDeoptInlinedFrames(int deopt_id, std::vector<CpuProfileDeoptFrame>);
bool HasDeoptInlinedFramesFor(int deopt_id) const;
......@@ -163,7 +165,7 @@ class CodeEntry {
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<CodeEntry*>> inline_locations_;
std::map<int, std::vector<std::unique_ptr<CodeEntry>>> inline_locations_;
std::map<int, std::vector<CpuProfileDeoptFrame>> deopt_inlined_frames_;
DISALLOW_COPY_AND_ASSIGN(CodeEntry);
......
......@@ -199,7 +199,7 @@ void ProfilerListener::RecordInliningInfo(CodeEntry* entry,
DCHECK_EQ(Translation::BEGIN, opcode);
it.Skip(Translation::NumberOfOperandsFor(opcode));
int depth = 0;
std::vector<CodeEntry*> inline_stack;
std::vector<std::unique_ptr<CodeEntry>> inline_stack;
while (it.HasNext() &&
Translation::BEGIN !=
(opcode = static_cast<Translation::Opcode>(it.Next()))) {
......@@ -227,7 +227,7 @@ void ProfilerListener::RecordInliningInfo(CodeEntry* entry,
CpuProfileNode::kNoColumnNumberInfo, nullptr,
code->instruction_start());
inline_entry->FillFunctionInfo(shared_info);
inline_stack.push_back(inline_entry);
inline_stack.emplace_back(inline_entry);
}
if (!inline_stack.empty()) {
entry->AddInlineStack(pc_offset, std::move(inline_stack));
......
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