Commit a87b0e63 authored by Alexei Filippov's avatar Alexei Filippov Committed by Commit Bot

Revert "[heap profiler] Refactor: Replace indices with HeapEntry*"

This reverts commit 69a502ce.

Reason for revert: Broke the build https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Linux%20gcc%204.8/22123

Original change's description:
> [heap profiler] Refactor: Replace indices with HeapEntry*
> 
> Change-Id: I0c176f66711d45e2f59d527f3133a1afbf825ec3
> Reviewed-on: https://chromium-review.googlesource.com/1229613
> Commit-Queue: Alexei Filippov <alph@chromium.org>
> Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#56245}

TBR=ulan@chromium.org,alph@chromium.org,mlippautz@chromium.org

Change-Id: Ib4495f17a653a95f8d5af634da74905c63048f8e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/1246235Reviewed-by: 's avatarAlexei Filippov <alph@chromium.org>
Commit-Queue: Alexei Filippov <alph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56248}
parent f5e65cc8
......@@ -13,41 +13,51 @@
namespace v8 {
namespace internal {
HeapEntry* HeapGraphEdge::from() const {
return &snapshot()->entries()[from_index()];
}
Isolate* HeapGraphEdge::isolate() const { return to_entry_->isolate(); }
Isolate* HeapGraphEdge::isolate() const {
return snapshot()->profiler()->isolate();
}
HeapSnapshot* HeapGraphEdge::snapshot() const {
return to_entry_->snapshot();
}
int HeapEntry::index() const {
return static_cast<int>(this - &snapshot_->entries().front());
}
int HeapEntry::set_children_index(int index) {
// Note: children_count_ and children_end_index_ are parts of a union.
children_index_ = index;
int next_index = index + children_count_;
children_end_index_ = index;
children_count_ = 0;
return next_index;
}
void HeapEntry::add_child(HeapGraphEdge* edge) {
snapshot_->children()[children_end_index_++] = edge;
*(children_begin() + children_count_++) = edge;
}
HeapGraphEdge* HeapEntry::child(int i) { return children_begin()[i]; }
std::vector<HeapGraphEdge*>::iterator HeapEntry::children_begin() const {
return index_ == 0 ? snapshot_->children().begin()
: snapshot_->entries()[index_ - 1].children_end();
}
HeapGraphEdge* HeapEntry::child(int i) { return *(children_begin() + i); }
std::vector<HeapGraphEdge*>::iterator HeapEntry::children_end() const {
DCHECK_GE(children_end_index_, 0);
return snapshot_->children().begin() + children_end_index_;
std::deque<HeapGraphEdge*>::iterator HeapEntry::children_begin() {
DCHECK_GE(children_index_, 0);
SLOW_DCHECK(
children_index_ < static_cast<int>(snapshot_->children().size()) ||
(children_index_ == static_cast<int>(snapshot_->children().size()) &&
children_count_ == 0));
return snapshot_->children().begin() + children_index_;
}
int HeapEntry::children_count() const {
return static_cast<int>(children_end() - children_begin());
std::deque<HeapGraphEdge*>::iterator HeapEntry::children_end() {
return children_begin() + children_count_;
}
Isolate* HeapEntry::isolate() const { return snapshot_->profiler()->isolate(); }
......
This diff is collapsed.
This diff is collapsed.
......@@ -157,9 +157,12 @@ static Optional<SourceLocation> GetLocation(const v8::HeapSnapshot* s,
const v8::HeapGraphNode* node) {
const i::HeapSnapshot* snapshot = reinterpret_cast<const i::HeapSnapshot*>(s);
const std::vector<SourceLocation>& locations = snapshot->locations();
const i::HeapEntry* entry = reinterpret_cast<const i::HeapEntry*>(node);
const int index =
const_cast<i::HeapEntry*>(reinterpret_cast<const i::HeapEntry*>(node))
->index();
for (const auto& loc : locations) {
if (loc.entry_index == entry->index()) {
if (loc.entry_index == index) {
return Optional<SourceLocation>(loc);
}
}
......@@ -220,7 +223,7 @@ static bool ValidateSnapshot(const v8::HeapSnapshot* snapshot, int depth = 3) {
entry->value = reinterpret_cast<void*>(ref_count + 1);
}
uint32_t unretained_entries_count = 0;
std::deque<i::HeapEntry>& entries = heap_snapshot->entries();
std::vector<i::HeapEntry>& entries = heap_snapshot->entries();
for (i::HeapEntry& entry : entries) {
v8::base::HashMap::Entry* map_entry = visited.Lookup(
reinterpret_cast<void*>(&entry),
......@@ -1000,6 +1003,21 @@ TEST(HeapEntryIdsAndGC) {
CHECK_EQ(b1->GetId(), b2->GetId());
}
TEST(HeapSnapshotRootPreservedAfterSorting) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot();
CHECK(ValidateSnapshot(snapshot));
const v8::HeapGraphNode* root1 = snapshot->GetRoot();
const_cast<i::HeapSnapshot*>(reinterpret_cast<const i::HeapSnapshot*>(
snapshot))->GetSortedEntriesList();
const v8::HeapGraphNode* root2 = snapshot->GetRoot();
CHECK_EQ(root1, root2);
}
namespace {
class TestJSONStream : public v8::OutputStream {
......
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