Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(284)

Unified Diff: src/heap-profiler.cc

Issue 6697023: Merge 6800:7180 from the bleeding edge branch to the experimental/gc branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap-profiler.h ('k') | src/hydrogen.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap-profiler.cc
===================================================================
--- src/heap-profiler.cc (revision 7180)
+++ src/heap-profiler.cc (working copy)
@@ -364,6 +364,27 @@
}
+void HeapProfiler::DefineWrapperClass(
+ uint16_t class_id, v8::HeapProfiler::WrapperInfoCallback callback) {
+ ASSERT(singleton_ != NULL);
+ ASSERT(class_id != v8::HeapProfiler::kPersistentHandleNoClassId);
+ if (singleton_->wrapper_callbacks_.length() <= class_id) {
+ singleton_->wrapper_callbacks_.AddBlock(
+ NULL, class_id - singleton_->wrapper_callbacks_.length() + 1);
+ }
+ singleton_->wrapper_callbacks_[class_id] = callback;
+}
+
+
+v8::RetainedObjectInfo* HeapProfiler::ExecuteWrapperClassCallback(
+ uint16_t class_id, Object** wrapper) {
+ ASSERT(singleton_ != NULL);
+ if (singleton_->wrapper_callbacks_.length() <= class_id) return NULL;
+ return singleton_->wrapper_callbacks_[class_id](
+ class_id, Utils::ToLocal(Handle<Object>(wrapper)));
+}
+
+
HeapSnapshot* HeapProfiler::TakeSnapshotImpl(const char* name,
int type,
v8::ActivityControl* control) {
@@ -401,7 +422,7 @@
HeapSnapshot* HeapProfiler::TakeSnapshotImpl(String* name,
int type,
v8::ActivityControl* control) {
- return TakeSnapshotImpl(snapshots_->GetName(name), type, control);
+ return TakeSnapshotImpl(snapshots_->names()->GetName(name), type, control);
}
@@ -872,7 +893,8 @@
const NumberAndSizeInfo& number_and_size) {
const char* name = cluster.GetSpecialCaseName();
if (name == NULL) {
- name = snapshot_->collection()->GetFunctionName(cluster.constructor());
+ name = snapshot_->collection()->names()->GetFunctionName(
+ cluster.constructor());
}
AddEntryFromAggregatedSnapshot(snapshot_,
root_child_index_,
@@ -911,22 +933,27 @@
class CountingRetainersIterator {
public:
CountingRetainersIterator(const JSObjectsCluster& child_cluster,
+ HeapEntriesAllocator* allocator,
HeapEntriesMap* map)
- : child_(ClusterAsHeapObject(child_cluster)), map_(map) {
+ : child_(ClusterAsHeapObject(child_cluster)),
+ allocator_(allocator),
+ map_(map) {
if (map_->Map(child_) == NULL)
- map_->Pair(child_, HeapEntriesMap::kHeapEntryPlaceholder);
+ map_->Pair(child_, allocator_, HeapEntriesMap::kHeapEntryPlaceholder);
}
void Call(const JSObjectsCluster& cluster,
const NumberAndSizeInfo& number_and_size) {
if (map_->Map(ClusterAsHeapObject(cluster)) == NULL)
map_->Pair(ClusterAsHeapObject(cluster),
+ allocator_,
HeapEntriesMap::kHeapEntryPlaceholder);
map_->CountReference(ClusterAsHeapObject(cluster), child_);
}
private:
HeapObject* child_;
+ HeapEntriesAllocator* allocator_;
HeapEntriesMap* map_;
};
@@ -934,6 +961,7 @@
class AllocatingRetainersIterator {
public:
AllocatingRetainersIterator(const JSObjectsCluster& child_cluster,
+ HeapEntriesAllocator*,
HeapEntriesMap* map)
: child_(ClusterAsHeapObject(child_cluster)), map_(map) {
child_entry_ = map_->Map(child_);
@@ -966,8 +994,9 @@
class AggregatingRetainerTreeIterator {
public:
explicit AggregatingRetainerTreeIterator(ClustersCoarser* coarser,
+ HeapEntriesAllocator* allocator,
HeapEntriesMap* map)
- : coarser_(coarser), map_(map) {
+ : coarser_(coarser), allocator_(allocator), map_(map) {
}
void Call(const JSObjectsCluster& cluster, JSObjectsClusterTree* tree) {
@@ -981,29 +1010,33 @@
tree->ForEach(&retainers_aggregator);
tree_to_iterate = &dest_tree_;
}
- RetainersIterator iterator(cluster, map_);
+ RetainersIterator iterator(cluster, allocator_, map_);
tree_to_iterate->ForEach(&iterator);
}
private:
ClustersCoarser* coarser_;
+ HeapEntriesAllocator* allocator_;
HeapEntriesMap* map_;
};
-class AggregatedRetainerTreeAllocator {
+class AggregatedRetainerTreeAllocator : public HeapEntriesAllocator {
public:
AggregatedRetainerTreeAllocator(HeapSnapshot* snapshot,
int* root_child_index)
: snapshot_(snapshot), root_child_index_(root_child_index) {
}
+ ~AggregatedRetainerTreeAllocator() { }
- HeapEntry* GetEntry(
- HeapObject* obj, int children_count, int retainers_count) {
+ HeapEntry* AllocateEntry(
+ HeapThing ptr, int children_count, int retainers_count) {
+ HeapObject* obj = reinterpret_cast<HeapObject*>(ptr);
JSObjectsCluster cluster = HeapObjectAsCluster(obj);
const char* name = cluster.GetSpecialCaseName();
if (name == NULL) {
- name = snapshot_->collection()->GetFunctionName(cluster.constructor());
+ name = snapshot_->collection()->names()->GetFunctionName(
+ cluster.constructor());
}
return AddEntryFromAggregatedSnapshot(
snapshot_, root_child_index_, HeapEntry::kObject, name,
@@ -1018,12 +1051,13 @@
template<class Iterator>
void AggregatedHeapSnapshotGenerator::IterateRetainers(
- HeapEntriesMap* entries_map) {
+ HeapEntriesAllocator* allocator, HeapEntriesMap* entries_map) {
RetainerHeapProfile* p = agg_snapshot_->js_retainer_profile();
AggregatingRetainerTreeIterator<Iterator> agg_ret_iter_1(
- p->coarser(), entries_map);
+ p->coarser(), allocator, entries_map);
p->retainers_tree()->ForEach(&agg_ret_iter_1);
- AggregatingRetainerTreeIterator<Iterator> agg_ret_iter_2(NULL, entries_map);
+ AggregatingRetainerTreeIterator<Iterator> agg_ret_iter_2(
+ NULL, allocator, entries_map);
p->aggregator()->output_tree().ForEach(&agg_ret_iter_2);
}
@@ -1042,7 +1076,9 @@
agg_snapshot_->js_cons_profile()->ForEach(&counting_cons_iter);
histogram_entities_count += counting_cons_iter.entities_count();
HeapEntriesMap entries_map;
- IterateRetainers<CountingRetainersIterator>(&entries_map);
+ int root_child_index = 0;
+ AggregatedRetainerTreeAllocator allocator(snapshot, &root_child_index);
+ IterateRetainers<CountingRetainersIterator>(&allocator, &entries_map);
histogram_entities_count += entries_map.entries_count();
histogram_children_count += entries_map.total_children_count();
histogram_retainers_count += entries_map.total_retainers_count();
@@ -1056,10 +1092,7 @@
snapshot->AllocateEntries(histogram_entities_count,
histogram_children_count,
histogram_retainers_count);
- snapshot->AddEntry(HeapSnapshot::kInternalRootObject,
- root_children_count,
- 0);
- int root_child_index = 0;
+ snapshot->AddRootEntry(root_children_count);
for (int i = FIRST_NONSTRING_TYPE; i <= kAllStringsType; ++i) {
if (agg_snapshot_->info()[i].bytes() > 0) {
AddEntryFromAggregatedSnapshot(snapshot,
@@ -1075,11 +1108,10 @@
AllocatingConstructorHeapProfileIterator alloc_cons_iter(
snapshot, &root_child_index);
agg_snapshot_->js_cons_profile()->ForEach(&alloc_cons_iter);
- AggregatedRetainerTreeAllocator allocator(snapshot, &root_child_index);
- entries_map.UpdateEntries(&allocator);
+ entries_map.AllocateEntries();
// Fill up references.
- IterateRetainers<AllocatingRetainersIterator>(&entries_map);
+ IterateRetainers<AllocatingRetainersIterator>(&allocator, &entries_map);
snapshot->SetDominatorsToSelf();
}
« no previous file with comments | « src/heap-profiler.h ('k') | src/hydrogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698