Commit 7ed7af2f authored by hpayer@chromium.org's avatar hpayer@chromium.org

Tell the GC prologues to construct RetainedObjectInfos only when needed.

The GC prologue is called by the GC, but also by the heap snapshotter. The
RetainedObjectInfos are only needed by the heap snapshotter, so it's wasteful to
construct them always. (And it will be even more wasteful when Blink migrates to
the new GC APIs, since after that point it no longer knows about object groups.)

BUG=

Review URL: https://codereview.chromium.org/14471028
Patch from Marja Hölttä <marja@chromium.org>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14439 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 44f2d534
......@@ -3053,7 +3053,8 @@ enum GCType {
enum GCCallbackFlags {
kNoGCCallbackFlags = 0,
kGCCallbackFlagCompacted = 1 << 0
kGCCallbackFlagCompacted = 1 << 0,
kGCCallbackFlagConstructRetainedObjectInfos = 1 << 1
};
typedef void (*GCPrologueCallback)(GCType type, GCCallbackFlags flags);
......
......@@ -1936,7 +1936,8 @@ void NativeObjectsExplorer::FillRetainedObjects() {
Isolate* isolate = Isolate::Current();
const GCType major_gc_type = kGCTypeMarkSweepCompact;
// Record objects that are joined into ObjectGroups.
isolate->heap()->CallGCPrologueCallbacks(major_gc_type);
isolate->heap()->CallGCPrologueCallbacks(
major_gc_type, kGCCallbackFlagConstructRetainedObjectInfos);
List<ObjectGroup*>* groups = isolate->global_handles()->object_groups();
for (int i = 0; i < groups->length(); ++i) {
ObjectGroup* group = groups->at(i);
......
......@@ -893,7 +893,7 @@ bool Heap::PerformGarbageCollection(GarbageCollector collector,
{
GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL);
VMState<EXTERNAL> state(isolate_);
CallGCPrologueCallbacks(gc_type);
CallGCPrologueCallbacks(gc_type, kNoGCCallbackFlags);
}
EnsureFromSpaceIsCommitted();
......@@ -1028,13 +1028,13 @@ bool Heap::PerformGarbageCollection(GarbageCollector collector,
}
void Heap::CallGCPrologueCallbacks(GCType gc_type) {
void Heap::CallGCPrologueCallbacks(GCType gc_type, GCCallbackFlags flags) {
if (gc_type == kGCTypeMarkSweepCompact && global_gc_prologue_callback_) {
global_gc_prologue_callback_();
}
for (int i = 0; i < gc_prologue_callbacks_.length(); ++i) {
if (gc_type & gc_prologue_callbacks_[i].gc_type) {
gc_prologue_callbacks_[i].callback(gc_type, kNoGCCallbackFlags);
gc_prologue_callbacks_[i].callback(gc_type, flags);
}
}
}
......
......@@ -1761,7 +1761,7 @@ class Heap {
inline Isolate* isolate();
void CallGCPrologueCallbacks(GCType gc_type);
void CallGCPrologueCallbacks(GCType gc_type, GCCallbackFlags flags);
void CallGCEpilogueCallbacks(GCType gc_type);
inline bool OldGenerationAllocationLimitReached();
......
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