Commit 610ef68f authored by loislo@chromium.org's avatar loislo@chromium.org

Eliminate dominator and retained_size fields. They are calculating on...

Eliminate dominator and retained_size fields. They are calculating on front-end side. See meta-bug https://bugs.webkit.org/show_bug.cgi?id=87089

BUG=none
TEST=none

Review URL: https://chromiumcodereview.appspot.com/10416035

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11626 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 7ab5dcf4
......@@ -6045,13 +6045,6 @@ int HeapGraphNode::GetSelfSize() const {
}
int HeapGraphNode::GetRetainedSize() const {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::HeapSnapshot::GetRetainedSize");
return ToInternal(this)->retained_size();
}
int HeapGraphNode::GetChildrenCount() const {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::HeapSnapshot::GetChildrenCount");
......@@ -6067,28 +6060,6 @@ const HeapGraphEdge* HeapGraphNode::GetChild(int index) const {
}
int HeapGraphNode::GetRetainersCount() const {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::HeapSnapshot::GetRetainersCount");
return ToInternal(this)->retainers().length();
}
const HeapGraphEdge* HeapGraphNode::GetRetainer(int index) const {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::HeapSnapshot::GetRetainer");
return reinterpret_cast<const HeapGraphEdge*>(
ToInternal(this)->retainers()[index]);
}
const HeapGraphNode* HeapGraphNode::GetDominatorNode() const {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::HeapSnapshot::GetDominatorNode");
return reinterpret_cast<const HeapGraphNode*>(ToInternal(this)->dominator());
}
v8::Handle<v8::Value> HeapGraphNode::GetHeapValue() const {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::HeapGraphNode::GetHeapValue");
......
......@@ -118,32 +118,12 @@ int HeapEntry::set_children_index(int index) {
}
int HeapEntry::set_retainers_index(int index) {
retainers_index_ = index;
int next_index = index + retainers_count_;
retainers_count_ = 0;
return next_index;
}
HeapGraphEdge** HeapEntry::children_arr() {
ASSERT(children_index_ >= 0);
return &snapshot_->children()[children_index_];
}
HeapGraphEdge** HeapEntry::retainers_arr() {
ASSERT(retainers_index_ >= 0);
return &snapshot_->retainers()[retainers_index_];
}
HeapEntry* HeapEntry::dominator() const {
ASSERT(dominator_ >= 0);
return &snapshot_->entries()[dominator_];
}
SnapshotObjectId HeapObjectsMap::GetNthGcSubrootId(int delta) {
return kGcRootsFirstSubrootId + delta * kObjectIdStep;
}
......
This diff is collapsed.
......@@ -529,35 +529,14 @@ class HeapEntry BASE_EMBEDDED {
void set_name(const char* name) { name_ = name; }
inline SnapshotObjectId id() { return id_; }
int self_size() { return self_size_; }
int retained_size() { return retained_size_; }
void add_retained_size(int size) { retained_size_ += size; }
void set_retained_size(int size) { retained_size_ = size; }
INLINE(int index() const);
int postorder_index() { return postorder_index_; }
void set_postorder_index(int value) { postorder_index_ = value; }
int children_count() const { return children_count_; }
INLINE(int set_children_index(int index));
INLINE(int set_retainers_index(int index));
void add_child(HeapGraphEdge* edge) {
children_arr()[children_count_++] = edge;
}
void add_retainer(HeapGraphEdge* edge) {
retainers_arr()[retainers_count_++] = edge;
}
Vector<HeapGraphEdge*> children() {
return Vector<HeapGraphEdge*>(children_arr(), children_count_); }
Vector<HeapGraphEdge*> retainers() {
return Vector<HeapGraphEdge*>(retainers_arr(), retainers_count_); }
INLINE(HeapEntry* dominator() const);
void set_dominator(HeapEntry* entry) {
ASSERT(entry != NULL);
dominator_ = entry->index();
}
void clear_paint() { painted_ = false; }
bool painted() { return painted_; }
void paint() { painted_ = true; }
bool user_reachable() { return user_reachable_; }
void set_user_reachable() { user_reachable_ = true; }
void SetIndexedReference(
HeapGraphEdge::Type type, int index, HeapEntry* entry);
......@@ -571,22 +550,12 @@ class HeapEntry BASE_EMBEDDED {
private:
INLINE(HeapGraphEdge** children_arr());
INLINE(HeapGraphEdge** retainers_arr());
const char* TypeAsString();
unsigned painted_: 1;
unsigned user_reachable_: 1;
int dominator_: 30;
unsigned type_: 4;
int retainers_count_: 28;
int retainers_index_;
int children_count_;
int children_count_: 28;
int children_index_;
int self_size_;
union {
int postorder_index_; // Used during dominator tree building.
int retained_size_; // At that moment, there is no retained size yet.
};
SnapshotObjectId id_;
HeapSnapshot* snapshot_;
const char* name_;
......@@ -626,7 +595,6 @@ class HeapSnapshot {
List<HeapEntry>& entries() { return entries_; }
List<HeapGraphEdge>& edges() { return edges_; }
List<HeapGraphEdge*>& children() { return children_; }
List<HeapGraphEdge*>& retainers() { return retainers_; }
void RememberLastJSObjectId();
SnapshotObjectId max_snapshot_js_object_id() const {
return max_snapshot_js_object_id_;
......@@ -640,11 +608,9 @@ class HeapSnapshot {
HeapEntry* AddGcRootsEntry();
HeapEntry* AddGcSubrootEntry(int tag);
HeapEntry* AddNativesRootEntry();
void ClearPaint();
HeapEntry* GetEntryById(SnapshotObjectId id);
List<HeapEntry*>* GetSortedEntriesList();
void SetDominatorsToSelf();
void FillChildrenAndRetainers();
void FillChildren();
void Print(int max_depth);
void PrintEntriesSize();
......@@ -661,7 +627,6 @@ class HeapSnapshot {
List<HeapEntry> entries_;
List<HeapGraphEdge> edges_;
List<HeapGraphEdge*> children_;
List<HeapGraphEdge*> retainers_;
List<HeapEntry*> sorted_entries_;
SnapshotObjectId max_snapshot_js_object_id_;
......@@ -1061,16 +1026,9 @@ class HeapSnapshotGenerator : public SnapshottingProgressReportingInterface {
bool GenerateSnapshot();
private:
bool BuildDominatorTree(const Vector<HeapEntry*>& entries,
Vector<int>* dominators);
bool CalculateRetainedSizes();
bool FillReferences();
void FillPostorderIndexes(Vector<HeapEntry*>* entries);
bool IsUserGlobalReference(const HeapGraphEdge* edge);
void MarkUserReachableObjects();
void ProgressStep();
bool ProgressReport(bool force = false);
bool SetEntriesDominators();
void SetProgressTotal(int iterations_count);
HeapSnapshot* snapshot_;
......
......@@ -7,6 +7,7 @@
#include "v8.h"
#include "cctest.h"
#include "hashmap.h"
#include "heap-profiler.h"
#include "snapshot.h"
#include "debug.h"
......@@ -27,10 +28,14 @@ class NamedEntriesDetector {
if (strcmp(entry->name(), "C2") == 0) has_C2 = true;
}
static bool AddressesMatch(void* key1, void* key2) {
return key1 == key2;
}
void CheckAllReachables(i::HeapEntry* root) {
i::HashMap visited(AddressesMatch);
i::List<i::HeapEntry*> list(10);
list.Add(root);
root->paint();
CheckEntry(root);
while (!list.is_empty()) {
i::HeapEntry* entry = list.RemoveLast();
......@@ -38,11 +43,15 @@ class NamedEntriesDetector {
for (int i = 0; i < children.length(); ++i) {
if (children[i]->type() == i::HeapGraphEdge::kShortcut) continue;
i::HeapEntry* child = children[i]->to();
if (!child->painted()) {
list.Add(child);
child->paint();
CheckEntry(child);
}
i::HashMap::Entry* entry = visited.Lookup(
reinterpret_cast<void*>(child),
static_cast<uint32_t>(reinterpret_cast<uintptr_t>(child)),
true);
if (entry->value)
continue;
entry->value = reinterpret_cast<void*>(1);
list.Add(child);
CheckEntry(child);
}
}
}
......@@ -105,9 +114,6 @@ TEST(HeapSnapshot) {
"var c2 = new C2(a2);");
const v8::HeapSnapshot* snapshot_env2 =
v8::HeapProfiler::TakeSnapshot(v8_str("env2"));
i::HeapSnapshot* i_snapshot_env2 =
const_cast<i::HeapSnapshot*>(
reinterpret_cast<const i::HeapSnapshot*>(snapshot_env2));
const v8::HeapGraphNode* global_env2 = GetGlobalObject(snapshot_env2);
// Verify, that JS global object of env2 has '..2' properties.
......@@ -120,9 +126,7 @@ TEST(HeapSnapshot) {
NULL, GetProperty(global_env2, v8::HeapGraphEdge::kProperty, "b2_2"));
CHECK_NE(NULL, GetProperty(global_env2, v8::HeapGraphEdge::kProperty, "c2"));
// Paint all nodes reachable from global object.
NamedEntriesDetector det;
i_snapshot_env2->ClearPaint();
det.CheckAllReachables(const_cast<i::HeapEntry*>(
reinterpret_cast<const i::HeapEntry*>(global_env2)));
CHECK(det.has_A2);
......@@ -156,9 +160,9 @@ TEST(HeapSnapshotObjectSizes) {
CHECK_NE(NULL, x2);
// Test sizes.
CHECK_EQ(x->GetSelfSize() * 3, x->GetRetainedSize());
CHECK_EQ(x1->GetSelfSize(), x1->GetRetainedSize());
CHECK_EQ(x2->GetSelfSize(), x2->GetRetainedSize());
CHECK_NE(0, x->GetSelfSize());
CHECK_NE(0, x1->GetSelfSize());
CHECK_NE(0, x2->GetSelfSize());
}
......@@ -477,66 +481,6 @@ TEST(HeapSnapshotRootPreservedAfterSorting) {
}
TEST(HeapEntryDominator) {
// The graph looks like this:
//
// -> node1
// a |^
// -> node5 ba
// a v|
// node6 -> node2
// b a |^
// -> node4 ba
// b v|
// -> node3
//
// The dominator for all nodes is node6.
v8::HandleScope scope;
LocalContext env;
CompileRun(
"function X(a, b) { this.a = a; this.b = b; }\n"
"node6 = new X(new X(new X()), new X(new X(),new X()));\n"
"(function(){\n"
"node6.a.a.b = node6.b.a; // node1 -> node2\n"
"node6.b.a.a = node6.a.a; // node2 -> node1\n"
"node6.b.a.b = node6.b.b; // node2 -> node3\n"
"node6.b.b.a = node6.b.a; // node3 -> node2\n"
"})();");
const v8::HeapSnapshot* snapshot =
v8::HeapProfiler::TakeSnapshot(v8_str("dominators"));
const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
CHECK_NE(NULL, global);
const v8::HeapGraphNode* node6 =
GetProperty(global, v8::HeapGraphEdge::kProperty, "node6");
CHECK_NE(NULL, node6);
const v8::HeapGraphNode* node5 =
GetProperty(node6, v8::HeapGraphEdge::kProperty, "a");
CHECK_NE(NULL, node5);
const v8::HeapGraphNode* node4 =
GetProperty(node6, v8::HeapGraphEdge::kProperty, "b");
CHECK_NE(NULL, node4);
const v8::HeapGraphNode* node3 =
GetProperty(node4, v8::HeapGraphEdge::kProperty, "b");
CHECK_NE(NULL, node3);
const v8::HeapGraphNode* node2 =
GetProperty(node4, v8::HeapGraphEdge::kProperty, "a");
CHECK_NE(NULL, node2);
const v8::HeapGraphNode* node1 =
GetProperty(node5, v8::HeapGraphEdge::kProperty, "a");
CHECK_NE(NULL, node1);
CHECK_EQ(node6, node1->GetDominatorNode());
CHECK_EQ(node6, node2->GetDominatorNode());
CHECK_EQ(node6, node3->GetDominatorNode());
CHECK_EQ(node6, node4->GetDominatorNode());
CHECK_EQ(node6, node5->GetDominatorNode());
}
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