summaryrefslogtreecommitdiff
path: root/deps/v8/src/heap-profiler.cc
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2009-10-28 19:25:22 +0100
committerRyan Dahl <ry@tinyclouds.org>2009-10-28 19:25:22 +0100
commit50f45d14b475a42d304e7d9872f8d91ff3a013c2 (patch)
tree2e799be8cbddd016ef8432b4ed755247a466c0ba /deps/v8/src/heap-profiler.cc
parent35589528992e8bf5ca70271beaef05a6d82f9dcf (diff)
downloadnode-new-50f45d14b475a42d304e7d9872f8d91ff3a013c2.tar.gz
Upgrade v8 to 1.3.17
Diffstat (limited to 'deps/v8/src/heap-profiler.cc')
-rw-r--r--deps/v8/src/heap-profiler.cc44
1 files changed, 29 insertions, 15 deletions
diff --git a/deps/v8/src/heap-profiler.cc b/deps/v8/src/heap-profiler.cc
index 8f55ce1ce4..7f7cd7f169 100644
--- a/deps/v8/src/heap-profiler.cc
+++ b/deps/v8/src/heap-profiler.cc
@@ -78,6 +78,10 @@ JSObjectsCluster Clusterizer::Clusterize(HeapObject* obj, bool fine_grain) {
}
} else if (obj->IsString()) {
return JSObjectsCluster(Heap::String_symbol());
+ } else if (obj->IsJSGlobalPropertyCell()) {
+ return JSObjectsCluster(JSObjectsCluster::GLOBAL_PROPERTY);
+ } else if (obj->IsCode() || obj->IsSharedFunctionInfo() || obj->IsScript()) {
+ return JSObjectsCluster(JSObjectsCluster::CODE);
}
return JSObjectsCluster();
}
@@ -112,6 +116,16 @@ int Clusterizer::CalculateNetworkSize(JSObject* obj) {
if (FixedArray::cast(obj->elements())->length() != 0) {
size += obj->elements()->Size();
}
+ // For functions, also account non-empty context and literals sizes.
+ if (obj->IsJSFunction()) {
+ JSFunction* f = JSFunction::cast(obj);
+ if (f->unchecked_context()->IsContext()) {
+ size += f->context()->Size();
+ }
+ if (f->literals()->length() != 0) {
+ size += f->literals()->Size();
+ }
+ }
return size;
}
@@ -127,15 +141,15 @@ class ReferencesExtractor : public ObjectVisitor {
}
void VisitPointer(Object** o) {
- if ((*o)->IsJSObject() || (*o)->IsString()) {
- profile_->StoreReference(cluster_, HeapObject::cast(*o));
- } else if ((*o)->IsFixedArray() && !inside_array_) {
+ if ((*o)->IsFixedArray() && !inside_array_) {
// Traverse one level deep for data members that are fixed arrays.
// This covers the case of 'elements' and 'properties' of JSObject,
// and function contexts.
inside_array_ = true;
FixedArray::cast(*o)->Iterate(this);
inside_array_ = false;
+ } else if ((*o)->IsHeapObject()) {
+ profile_->StoreReference(cluster_, HeapObject::cast(*o));
}
}
@@ -340,6 +354,8 @@ void JSObjectsCluster::Print(StringStream* accumulator) const {
accumulator->Add("(roots)");
} else if (constructor_ == FromSpecialCase(GLOBAL_PROPERTY)) {
accumulator->Add("(global property)");
+ } else if (constructor_ == FromSpecialCase(CODE)) {
+ accumulator->Add("(code)");
} else if (constructor_ == FromSpecialCase(SELF)) {
accumulator->Add("(self)");
} else {
@@ -527,6 +543,7 @@ RetainerHeapProfile::RetainerHeapProfile()
void RetainerHeapProfile::StoreReference(const JSObjectsCluster& cluster,
HeapObject* ref) {
JSObjectsCluster ref_cluster = Clusterizer::Clusterize(ref);
+ if (ref_cluster.is_null()) return;
JSObjectsRetainerTree::Locator ref_loc;
if (retainers_tree_.Insert(ref_cluster, &ref_loc)) {
ref_loc.set_value(new JSObjectsClusterTree());
@@ -537,15 +554,10 @@ void RetainerHeapProfile::StoreReference(const JSObjectsCluster& cluster,
void RetainerHeapProfile::CollectStats(HeapObject* obj) {
- if (obj->IsJSObject()) {
- const JSObjectsCluster cluster = Clusterizer::Clusterize(obj);
- ReferencesExtractor extractor(cluster, this);
- obj->Iterate(&extractor);
- } else if (obj->IsJSGlobalPropertyCell()) {
- JSObjectsCluster global_prop(JSObjectsCluster::GLOBAL_PROPERTY);
- ReferencesExtractor extractor(global_prop, this);
- obj->Iterate(&extractor);
- }
+ const JSObjectsCluster cluster = Clusterizer::Clusterize(obj);
+ if (cluster.is_null()) return;
+ ReferencesExtractor extractor(cluster, this);
+ obj->Iterate(&extractor);
}
@@ -576,8 +588,10 @@ void RetainerHeapProfile::PrintStats() {
void HeapProfiler::CollectStats(HeapObject* obj, HistogramInfo* info) {
InstanceType type = obj->map()->instance_type();
ASSERT(0 <= type && type <= LAST_TYPE);
- info[type].increment_number(1);
- info[type].increment_bytes(obj->Size());
+ if (!FreeListNode::IsFreeListNode(obj)) {
+ info[type].increment_number(1);
+ info[type].increment_bytes(obj->Size());
+ }
}
@@ -601,7 +615,7 @@ static void PrintProducerStackTrace(Object* obj, void* trace) {
void HeapProfiler::WriteSample() {
LOG(HeapSampleBeginEvent("Heap", "allocated"));
LOG(HeapSampleStats(
- "Heap", "allocated", Heap::Capacity(), Heap::SizeOfObjects()));
+ "Heap", "allocated", Heap::CommittedMemory(), Heap::SizeOfObjects()));
HistogramInfo info[LAST_TYPE+1];
#define DEF_TYPE_NAME(name) info[name].set_name(#name);