Revision: 11248
Author: [email protected]
Date: Sun Apr 8 12:18:06 2012
Log: Revert "External references should not affect dominance relation."
This reverts commit 6e46549d13df2b211ea9b4fac9c09fe5013ec465.
BUG=
TEST=
Review URL: https://chromiumcodereview.appspot.com/10025014
http://code.google.com/p/v8/source/detail?r=11248
Modified:
/branches/bleeding_edge/src/api.cc
/branches/bleeding_edge/src/profile-generator-inl.h
/branches/bleeding_edge/src/profile-generator.cc
/branches/bleeding_edge/src/profile-generator.h
/branches/bleeding_edge/test/cctest/test-heap-profiler.cc
=======================================
--- /branches/bleeding_edge/src/api.cc Sun Apr 8 11:28:32 2012
+++ /branches/bleeding_edge/src/api.cc Sun Apr 8 12:18:06 2012
@@ -5998,7 +5998,7 @@
const HeapGraphNode* HeapGraphEdge::GetFromNode() const {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::HeapGraphEdge::GetFromNode");
- const i::HeapEntry* from = ToInternal(this)->from();
+ const i::HeapEntry* from = ToInternal(this)->From();
return reinterpret_cast<const HeapGraphNode*>(from);
}
=======================================
--- /branches/bleeding_edge/src/profile-generator-inl.h Sun Apr 8 11:28:32
2012
+++ /branches/bleeding_edge/src/profile-generator-inl.h Sun Apr 8 12:18:06
2012
@@ -93,11 +93,6 @@
default: return NULL;
}
}
-
-
-HeapEntry* HeapGraphEdge::from() {
- return reinterpret_cast<HeapEntry*>(this - child_index_) - 1;
-}
SnapshotObjectId HeapObjectsMap::GetNthGcSubrootId(int delta) {
=======================================
--- /branches/bleeding_edge/src/profile-generator.cc Sun Apr 8 11:28:32
2012
+++ /branches/bleeding_edge/src/profile-generator.cc Sun Apr 8 12:18:06
2012
@@ -955,6 +955,11 @@
void HeapGraphEdge::Init(int child_index, int index, HeapEntry* to) {
Init(child_index, kElement, index, to);
}
+
+
+HeapEntry* HeapGraphEdge::From() {
+ return reinterpret_cast<HeapEntry*>(this - child_index_) - 1;
+}
void HeapEntry::Init(HeapSnapshot* snapshot,
@@ -967,7 +972,6 @@
snapshot_ = snapshot;
type_ = type;
painted_ = false;
- reachable_from_window_ = false;
name_ = name;
self_size_ = self_size;
retained_size_ = 0;
@@ -2174,15 +2178,15 @@
Object* k = dictionary->KeyAt(i);
if (dictionary->IsKey(k)) {
Object* target = dictionary->ValueAt(i);
+ SetPropertyReference(
+ js_obj, entry, String::cast(k), target);
// We assume that global objects can only have slow properties.
- Object* value = target->IsJSGlobalPropertyCell()
- ? JSGlobalPropertyCell::cast(target)->value()
- : target;
- if (String::cast(k)->length() > 0) {
- SetPropertyReference(js_obj, entry, String::cast(k), value);
- } else {
- TagObject(value, "(hidden properties)");
- SetInternalReference(js_obj, entry, "hidden_properties", value);
+ if (target->IsJSGlobalPropertyCell()) {
+ SetPropertyShortcutReference(js_obj,
+ entry,
+ String::cast(k),
+ JSGlobalPropertyCell::cast(
+ target)->value());
}
}
}
@@ -2633,7 +2637,7 @@
Handle<JSGlobalObject> global_obj = enumerator.at(i);
Object* obj_document;
if (global_obj->GetProperty(*document_string)->ToObject(&obj_document)
&&
- obj_document->IsJSObject()) {
+ obj_document->IsJSObject()) {
JSObject* document = JSObject::cast(obj_document);
Object* obj_url;
if (document->GetProperty(*url_string)->ToObject(&obj_url) &&
@@ -3187,55 +3191,19 @@
}
-void HeapSnapshotGenerator::MarkWindowReachableObjects() {
- List<HeapEntry*> worklist;
-
- Vector<HeapGraphEdge> children = snapshot_->root()->children();
- for (int i = 0; i < children.length(); ++i) {
- if (children[i].type() == HeapGraphEdge::kShortcut) {
- worklist.Add(children[i].to());
- }
- }
-
- while (!worklist.is_empty()) {
- HeapEntry* entry = worklist.RemoveLast();
- if (entry->reachable_from_window()) continue;
- entry->set_reachable_from_window();
- Vector<HeapGraphEdge> children = entry->children();
- for (int i = 0; i < children.length(); ++i) {
- HeapEntry* child = children[i].to();
- if (!child->reachable_from_window()) {
- worklist.Add(child);
- }
- }
- }
-}
-
-
-static bool IsRetainingEdge(HeapGraphEdge* edge) {
- if (edge->type() == HeapGraphEdge::kShortcut) return false;
- // The edge is not retaining if it goes from system domain
- // (i.e. an object not reachable from window) to the user domain
- // (i.e. a reachable object).
- return edge->from()->reachable_from_window()
- || !edge->to()->reachable_from_window();
-}
-
-
-void HeapSnapshotGenerator::FillPostorderIndexes(
+void HeapSnapshotGenerator::FillReversePostorderIndexes(
Vector<HeapEntry*>* entries) {
snapshot_->ClearPaint();
int current_entry = 0;
List<HeapEntry*> nodes_to_visit;
- HeapEntry* root = snapshot_->root();
- nodes_to_visit.Add(root);
+ nodes_to_visit.Add(snapshot_->root());
snapshot_->root()->paint();
while (!nodes_to_visit.is_empty()) {
HeapEntry* entry = nodes_to_visit.last();
Vector<HeapGraphEdge> children = entry->children();
bool has_new_edges = false;
for (int i = 0; i < children.length(); ++i) {
- if (entry != root && !IsRetainingEdge(&children[i])) continue;
+ if (children[i].type() == HeapGraphEdge::kShortcut) continue;
HeapEntry* child = children[i].to();
if (!child->painted()) {
nodes_to_visit.Add(child);
@@ -3270,7 +3238,6 @@
const Vector<HeapEntry*>& entries,
Vector<int>* dominators) {
if (entries.length() == 0) return true;
- HeapEntry* root = snapshot_->root();
const int entries_length = entries.length(), root_index = entries_length
- 1;
static const int kNoDominator = -1;
for (int i = 0; i < root_index; ++i) (*dominators)[i] = kNoDominator;
@@ -3299,8 +3266,8 @@
int new_idom_index = kNoDominator;
Vector<HeapGraphEdge*> rets = entries[i]->retainers();
for (int j = 0; j < rets.length(); ++j) {
- if (rets[j]->from() != root && !IsRetainingEdge(rets[j])) continue;
- int ret_index = rets[j]->from()->ordered_index();
+ if (rets[j]->type() == HeapGraphEdge::kShortcut) continue;
+ int ret_index = rets[j]->From()->ordered_index();
if (dominators->at(ret_index) != kNoDominator) {
new_idom_index = new_idom_index == kNoDominator
? ret_index
@@ -3326,10 +3293,9 @@
bool HeapSnapshotGenerator::SetEntriesDominators() {
- MarkWindowReachableObjects();
- // This array is used for maintaining postorder of nodes.
+ // This array is used for maintaining reverse postorder of nodes.
ScopedVector<HeapEntry*> ordered_entries(snapshot_->entries()->length());
- FillPostorderIndexes(&ordered_entries);
+ FillReversePostorderIndexes(&ordered_entries);
ScopedVector<int> dominators(ordered_entries.length());
if (!BuildDominatorTree(ordered_entries, &dominators)) return false;
for (int i = 0; i < ordered_entries.length(); ++i) {
=======================================
--- /branches/bleeding_edge/src/profile-generator.h Sun Apr 8 11:28:32 2012
+++ /branches/bleeding_edge/src/profile-generator.h Sun Apr 8 12:18:06 2012
@@ -477,7 +477,8 @@
return name_;
}
HeapEntry* to() { return to_; }
- INLINE(HeapEntry* from());
+
+ HeapEntry* From();
private:
int child_index_ : 29;
@@ -563,8 +564,6 @@
void clear_paint() { painted_ = false; }
bool painted() { return painted_; }
void paint() { painted_ = true; }
- bool reachable_from_window() { return reachable_from_window_; }
- void set_reachable_from_window() { reachable_from_window_ = true; }
void SetIndexedReference(HeapGraphEdge::Type type,
int child_index,
@@ -601,9 +600,8 @@
const char* TypeAsString();
unsigned painted_: 1;
- unsigned reachable_from_window_: 1;
unsigned type_: 4;
- int children_count_: 26;
+ int children_count_: 27;
int retainers_count_;
int self_size_;
union {
@@ -1102,8 +1100,7 @@
bool CalculateRetainedSizes();
bool CountEntriesAndReferences();
bool FillReferences();
- void FillPostorderIndexes(Vector<HeapEntry*>* entries);
- void MarkWindowReachableObjects();
+ void FillReversePostorderIndexes(Vector<HeapEntry*>* entries);
void ProgressStep();
bool ProgressReport(bool force = false);
bool SetEntriesDominators();
=======================================
--- /branches/bleeding_edge/test/cctest/test-heap-profiler.cc Sun Apr 8
11:28:32 2012
+++ /branches/bleeding_edge/test/cctest/test-heap-profiler.cc Sun Apr 8
12:18:06 2012
@@ -109,13 +109,13 @@
// Verify, that JS global object of env2 has '..2' properties.
const v8::HeapGraphNode* a2_node =
- GetProperty(global_env2, v8::HeapGraphEdge::kProperty, "a2");
+ GetProperty(global_env2, v8::HeapGraphEdge::kShortcut, "a2");
CHECK_NE(NULL, a2_node);
CHECK_NE(
- NULL, GetProperty(global_env2,
v8::HeapGraphEdge::kProperty, "b2_1"));
+ NULL, GetProperty(global_env2,
v8::HeapGraphEdge::kShortcut, "b2_1"));
CHECK_NE(
- NULL, GetProperty(global_env2,
v8::HeapGraphEdge::kProperty, "b2_2"));
- CHECK_NE(NULL, GetProperty(global_env2,
v8::HeapGraphEdge::kProperty, "c2"));
+ NULL, GetProperty(global_env2,
v8::HeapGraphEdge::kShortcut, "b2_2"));
+ CHECK_NE(NULL, GetProperty(global_env2,
v8::HeapGraphEdge::kShortcut, "c2"));
// Paint all nodes reachable from global object.
NamedEntriesDetector det;
@@ -142,7 +142,7 @@
v8::HeapProfiler::TakeSnapshot(v8_str("sizes"));
const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
const v8::HeapGraphNode* x =
- GetProperty(global, v8::HeapGraphEdge::kProperty, "x");
+ GetProperty(global, v8::HeapGraphEdge::kShortcut, "x");
CHECK_NE(NULL, x);
const v8::HeapGraphNode* x1 =
GetProperty(x, v8::HeapGraphEdge::kProperty, "a");
@@ -169,7 +169,7 @@
v8::HeapProfiler::TakeSnapshot(v8_str("sizes"));
const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
const v8::HeapGraphNode* f =
- GetProperty(global, v8::HeapGraphEdge::kProperty, "boundFunction");
+ GetProperty(global, v8::HeapGraphEdge::kShortcut, "boundFunction");
CHECK(f);
CHECK_EQ(v8::String::New("native_bind"), f->GetName());
const v8::HeapGraphNode* bindings =
@@ -233,15 +233,15 @@
const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
const v8::HeapGraphNode* compiled =
- GetProperty(global, v8::HeapGraphEdge::kProperty, "compiled");
+ GetProperty(global, v8::HeapGraphEdge::kShortcut, "compiled");
CHECK_NE(NULL, compiled);
CHECK_EQ(v8::HeapGraphNode::kClosure, compiled->GetType());
const v8::HeapGraphNode* lazy =
- GetProperty(global, v8::HeapGraphEdge::kProperty, "lazy");
+ GetProperty(global, v8::HeapGraphEdge::kShortcut, "lazy");
CHECK_NE(NULL, lazy);
CHECK_EQ(v8::HeapGraphNode::kClosure, lazy->GetType());
const v8::HeapGraphNode* anonymous =
- GetProperty(global, v8::HeapGraphEdge::kProperty, "anonymous");
+ GetProperty(global, v8::HeapGraphEdge::kShortcut, "anonymous");
CHECK_NE(NULL, anonymous);
CHECK_EQ(v8::HeapGraphNode::kClosure, anonymous->GetType());
v8::String::AsciiValue anonymous_name(anonymous->GetName());
@@ -293,9 +293,9 @@
const v8::HeapSnapshot* snapshot =
v8::HeapProfiler::TakeSnapshot(v8_str("numbers"));
const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
- CHECK_EQ(NULL, GetProperty(global, v8::HeapGraphEdge::kProperty, "a"));
+ CHECK_EQ(NULL, GetProperty(global, v8::HeapGraphEdge::kShortcut, "a"));
const v8::HeapGraphNode* b =
- GetProperty(global, v8::HeapGraphEdge::kProperty, "b");
+ GetProperty(global, v8::HeapGraphEdge::kShortcut, "b");
CHECK_NE(NULL, b);
CHECK_EQ(v8::HeapGraphNode::kHeapNumber, b->GetType());
}
@@ -313,10 +313,10 @@
v8::HeapProfiler::TakeSnapshot(v8_str("strings"));
const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
const v8::HeapGraphNode* parent_string =
- GetProperty(global, v8::HeapGraphEdge::kProperty, "parent_string");
+ GetProperty(global, v8::HeapGraphEdge::kShortcut, "parent_string");
CHECK_NE(NULL, parent_string);
const v8::HeapGraphNode* child_string =
- GetProperty(global, v8::HeapGraphEdge::kProperty, "child_string");
+ GetProperty(global, v8::HeapGraphEdge::kShortcut, "child_string");
CHECK_NE(NULL, child_string);
const v8::HeapGraphNode* parent =
GetProperty(child_string, v8::HeapGraphEdge::kInternal, "parent");
@@ -384,17 +384,24 @@
const v8::HeapGraphNode* a1 =
GetProperty(global1, v8::HeapGraphEdge::kProperty, "a");
CHECK_NE(NULL, a1);
+ const v8::HeapGraphNode* e1 =
+ GetProperty(a1, v8::HeapGraphEdge::kHidden, "1");
+ CHECK_NE(NULL, e1);
const v8::HeapGraphNode* k1 =
- GetProperty(a1, v8::HeapGraphEdge::kInternal, "elements");
+ GetProperty(e1, v8::HeapGraphEdge::kInternal, "elements");
CHECK_NE(NULL, k1);
const v8::HeapGraphNode* a2 =
GetProperty(global2, v8::HeapGraphEdge::kProperty, "a");
CHECK_NE(NULL, a2);
+ const v8::HeapGraphNode* e2 =
+ GetProperty(a2, v8::HeapGraphEdge::kHidden, "1");
+ CHECK_NE(NULL, e2);
const v8::HeapGraphNode* k2 =
- GetProperty(a2, v8::HeapGraphEdge::kInternal, "elements");
+ GetProperty(e2, v8::HeapGraphEdge::kInternal, "elements");
CHECK_NE(NULL, k2);
CHECK_EQ_SNAPSHOT_OBJECT_ID(a1->GetId(), a2->GetId());
+ CHECK_EQ_SNAPSHOT_OBJECT_ID(e1->GetId(), e2->GetId());
CHECK_EQ_SNAPSHOT_OBJECT_ID(k1->GetId(), k2->GetId());
}
@@ -507,7 +514,7 @@
const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
CHECK_NE(NULL, global);
const v8::HeapGraphNode* node6 =
- GetProperty(global, v8::HeapGraphEdge::kProperty, "node6");
+ GetProperty(global, v8::HeapGraphEdge::kShortcut, "node6");
CHECK_NE(NULL, node6);
const v8::HeapGraphNode* node5 =
GetProperty(node6, v8::HeapGraphEdge::kProperty, "a");
@@ -651,7 +658,7 @@
" GetChildPosByProperty(\n"
" GetChildPosByProperty("
" parsed.nodes[1 + children_offset + child_to_node_offset],"
- " \"b\", property_type),\n"
+ " \"b\",shortcut_type),\n"
" \"x\", property_type),"
" \"s\", property_type)");
CHECK(!string_obj_pos_val.IsEmpty());
@@ -952,8 +959,9 @@
v8::HeapProfiler::TakeSnapshot(v8_str("implicit_refs"));
const v8::HeapGraphNode* global_object = GetGlobalObject(snapshot);
+ // Use kShortcut type to skip intermediate JSGlobalPropertyCell
const v8::HeapGraphNode* obj0 = GetProperty(
- global_object, v8::HeapGraphEdge::kProperty, "root_object");
+ global_object, v8::HeapGraphEdge::kShortcut, "root_object");
CHECK(obj0);
CHECK_EQ(v8::HeapGraphNode::kObject, obj0->GetType());
const v8::HeapGraphNode* obj1 = GetProperty(
@@ -1126,7 +1134,7 @@
env->Global()->GetPrototype().As<v8::Object>();
CHECK(js_global == global->GetHeapValue());
const v8::HeapGraphNode* obj = GetProperty(
- global, v8::HeapGraphEdge::kProperty, "a");
+ global, v8::HeapGraphEdge::kShortcut, "a");
CHECK(obj->GetHeapValue()->IsObject());
v8::Local<v8::Object> js_obj =
js_global->Get(v8_str("a")).As<v8::Object>();
CHECK(js_obj == obj->GetHeapValue());
@@ -1155,7 +1163,7 @@
v8::HeapProfiler::TakeSnapshot(v8_str("snapshot"));
const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
const v8::HeapGraphNode* obj = GetProperty(
- global, v8::HeapGraphEdge::kProperty, "a");
+ global, v8::HeapGraphEdge::kShortcut, "a");
const v8::HeapGraphNode* prop = GetProperty(
obj, v8::HeapGraphEdge::kProperty, "p");
{
@@ -1242,7 +1250,7 @@
const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
CHECK_NE(NULL, global);
const v8::HeapGraphNode* obj1 =
- GetProperty(global, v8::HeapGraphEdge::kProperty, "obj1");
+ GetProperty(global, v8::HeapGraphEdge::kShortcut, "obj1");
CHECK_NE(NULL, obj1);
const v8::HeapGraphNode* getterFunction =
GetProperty(obj1,
v8::HeapGraphEdge::kProperty, "get-propWithGetter");
@@ -1324,7 +1332,7 @@
const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
CHECK_NE(NULL, global);
const v8::HeapGraphNode* fun =
- GetProperty(global, v8::HeapGraphEdge::kProperty, "fun");
+ GetProperty(global, v8::HeapGraphEdge::kShortcut, "fun");
CHECK(HasWeakEdge(fun));
const v8::HeapGraphNode* shared =
GetProperty(fun, v8::HeapGraphEdge::kInternal, "shared");
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev