Commit 62b03d55 authored by Alexei Filippov's avatar Alexei Filippov Committed by Commit Bot

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

This reverts commit 181bbd5c.

Reason for revert: Still break Win tests https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64%20-%20debug/25096

Original change's description:
> Reland "[heap profiler] Refactor: Replace indices with HeapEntry*"
> 
> This is a reland of 69a502ce
> 
> TBR=ulan@chromium.org
> 
> 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}
> 
> Change-Id: I416da19eb38a1a55f5e2f5897062bc1ca454ac34
> Reviewed-on: https://chromium-review.googlesource.com/1246802
> Commit-Queue: Alexei Filippov <alph@chromium.org>
> Reviewed-by: Alexei Filippov <alph@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#56250}

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

Change-Id: I0d027d192a9354eb6157405566420e6aa38738c1
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/1248131Reviewed-by: 's avatarAlexei Filippov <alph@chromium.org>
Commit-Queue: Alexei Filippov <alph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56252}
parent 36c77c22
......@@ -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