Reviewers: dcarney,
Message:
Please take a look.
Description:
Introduce kGCCallbackForced flag.
This flag will be passed to GC prologue/epilogue callbacks if GC was forced
through GC extension.
BUG=
Please review this at https://codereview.chromium.org/104023011/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+47, -26 lines):
M include/v8.h
M src/extensions/gc-extension.cc
M src/heap-inl.h
M src/heap-snapshot-generator.cc
M src/heap.h
M src/heap.cc
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index
815f43db7b2fb392ec521940c3b43821f190196b..05d90a6fae1c5a03fab5421d641db20618cac126
100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -4111,7 +4111,8 @@ enum GCType {
enum GCCallbackFlags {
kNoGCCallbackFlags = 0,
kGCCallbackFlagCompacted = 1 << 0,
- kGCCallbackFlagConstructRetainedObjectInfos = 1 << 1
+ kGCCallbackFlagConstructRetainedObjectInfos = 1 << 1,
+ kGCCallbackForced = 1 << 2
};
typedef void (*GCPrologueCallback)(GCType type, GCCallbackFlags flags);
Index: src/extensions/gc-extension.cc
diff --git a/src/extensions/gc-extension.cc b/src/extensions/gc-extension.cc
index
b8442c1bf85bfe6c4482a2333ec4ec0608fa55f6..51b61602dc0c96b9366b474f9daf8af4fd2356bf
100644
--- a/src/extensions/gc-extension.cc
+++ b/src/extensions/gc-extension.cc
@@ -42,9 +42,11 @@ v8::Handle<v8::FunctionTemplate>
GCExtension::GetNativeFunctionTemplate(
void GCExtension::GC(const v8::FunctionCallbackInfo<v8::Value>& args) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate());
if (args[0]->BooleanValue()) {
- isolate->heap()->CollectGarbage(NEW_SPACE, "gc extension");
+ isolate->heap()->CollectGarbage(
+ NEW_SPACE, "gc extension", v8::kGCCallbackForced);
} else {
- isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, "gc extension");
+ isolate->heap()->CollectAllGarbage(
+ Heap::kNoGCFlags, "gc extension", v8::kGCCallbackForced);
}
}
Index: src/heap-inl.h
diff --git a/src/heap-inl.h b/src/heap-inl.h
index
3229aeecc3096fa74bc9f022616eb277b4e79d58..2e538173d9af246e87a7d15b9c44ba78d0a5c5a7
100644
--- a/src/heap-inl.h
+++ b/src/heap-inl.h
@@ -522,10 +522,13 @@ void Heap::ScavengeObject(HeapObject** p, HeapObject*
object) {
}
-bool Heap::CollectGarbage(AllocationSpace space, const char* gc_reason) {
+bool Heap::CollectGarbage(AllocationSpace space,
+ const char* gc_reason,
+ const v8::GCCallbackFlags callbackFlags) {
const char* collector_reason = NULL;
GarbageCollector collector = SelectGarbageCollector(space,
&collector_reason);
- return CollectGarbage(space, collector, gc_reason, collector_reason);
+ return CollectGarbage(
+ space, collector, gc_reason, collector_reason, callbackFlags);
}
Index: src/heap-snapshot-generator.cc
diff --git a/src/heap-snapshot-generator.cc b/src/heap-snapshot-generator.cc
index
84e819d7a6d08a1d9ec4c846b1a17952f57f80ac..f9a69df8a2a7d9f14e41bc30ac91688334768aa7
100644
--- a/src/heap-snapshot-generator.cc
+++ b/src/heap-snapshot-generator.cc
@@ -2128,7 +2128,7 @@ void NativeObjectsExplorer::FillRetainedObjects() {
group->info = NULL; // Acquire info object ownership.
}
isolate->global_handles()->RemoveObjectGroups();
- isolate->heap()->CallGCEpilogueCallbacks(major_gc_type);
+ isolate->heap()->CallGCEpilogueCallbacks(major_gc_type,
kNoGCCallbackFlags);
// Record objects that are not in ObjectGroups, but have class ID.
GlobalHandlesExtractor extractor(this);
isolate->global_handles()->IterateAllRootsWithClassIds(&extractor);
Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index
d5c40ad154ad0e8de49a1ba86de2a659c352dbb7..f45c0e57ff0ca644f3c9674df7cba5b7a91f2b5c
100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -673,12 +673,14 @@ void Heap::GarbageCollectionEpilogue() {
}
-void Heap::CollectAllGarbage(int flags, const char* gc_reason) {
+void Heap::CollectAllGarbage(int flags,
+ const char* gc_reason,
+ const v8::GCCallbackFlags gc_callback_flags) {
// Since we are ignoring the return value, the exact choice of space does
// not matter, so long as we do not specify NEW_SPACE, which would not
// cause a full GC.
mark_compact_collector_.SetFlags(flags);
- CollectGarbage(OLD_POINTER_SPACE, gc_reason);
+ CollectGarbage(OLD_POINTER_SPACE, gc_reason, gc_callback_flags);
mark_compact_collector_.SetFlags(kNoGCFlags);
}
@@ -721,7 +723,8 @@ void Heap::CollectAllAvailableGarbage(const char*
gc_reason) {
bool Heap::CollectGarbage(AllocationSpace space,
GarbageCollector collector,
const char* gc_reason,
- const char* collector_reason) {
+ const char* collector_reason,
+ const v8::GCCallbackFlags gc_callback_flags) {
// The VM is in the GC state until exiting this function.
VMState<GC> state(isolate_);
@@ -776,7 +779,7 @@ bool Heap::CollectGarbage(AllocationSpace space,
(collector == SCAVENGER) ? isolate_->counters()->gc_scavenger()
: isolate_->counters()->gc_compactor());
next_gc_likely_to_collect_more =
- PerformGarbageCollection(collector, &tracer);
+ PerformGarbageCollection(collector, &tracer, gc_callback_flags);
}
GarbageCollectionEpilogue();
@@ -1003,8 +1006,10 @@ void Heap::UpdateSurvivalRateTrend(int
start_new_space_size) {
survival_rate_ = survival_rate;
}
-bool Heap::PerformGarbageCollection(GarbageCollector collector,
- GCTracer* tracer) {
+bool Heap::PerformGarbageCollection(
+ GarbageCollector collector,
+ GCTracer* tracer,
+ const v8::GCCallbackFlags gc_callback_flags) {
bool next_gc_likely_to_collect_more = false;
if (collector != SCAVENGER) {
@@ -1132,7 +1137,7 @@ bool Heap::PerformGarbageCollection(GarbageCollector
collector,
GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL);
VMState<EXTERNAL> state(isolate_);
HandleScope handle_scope(isolate_);
- CallGCEpilogueCallbacks(gc_type);
+ CallGCEpilogueCallbacks(gc_type, gc_callback_flags);
}
#ifdef VERIFY_HEAP
@@ -1162,18 +1167,19 @@ void Heap::CallGCPrologueCallbacks(GCType gc_type,
GCCallbackFlags flags) {
}
-void Heap::CallGCEpilogueCallbacks(GCType gc_type) {
+void Heap::CallGCEpilogueCallbacks(GCType gc_type,
+ GCCallbackFlags gc_callback_flags) {
for (int i = 0; i < gc_epilogue_callbacks_.length(); ++i) {
if (gc_type & gc_epilogue_callbacks_[i].gc_type) {
if (!gc_epilogue_callbacks_[i].pass_isolate_) {
v8::GCPrologueCallback callback =
reinterpret_cast<v8::GCPrologueCallback>(
gc_epilogue_callbacks_[i].callback);
- callback(gc_type, kNoGCCallbackFlags);
+ callback(gc_type, gc_callback_flags);
} else {
v8::Isolate* isolate =
reinterpret_cast<v8::Isolate*>(this->isolate());
gc_epilogue_callbacks_[i].callback(
- isolate, gc_type, kNoGCCallbackFlags);
+ isolate, gc_type, gc_callback_flags);
}
}
}
Index: src/heap.h
diff --git a/src/heap.h b/src/heap.h
index
c8ccb7fd48c84cb80854c6e3c5abb1ef154c5dfd..96e42aa9c95b4386fce9e2726ef2049497cc5495
100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -1175,8 +1175,10 @@ class Heap {
// Performs garbage collection operation.
// Returns whether there is a chance that another major GC could
// collect more garbage.
- inline bool CollectGarbage(AllocationSpace space,
- const char* gc_reason = NULL);
+ inline bool CollectGarbage(
+ AllocationSpace space,
+ const char* gc_reason = NULL,
+ const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags);
static const int kNoGCFlags = 0;
static const int kSweepPreciselyMask = 1;
@@ -1191,7 +1193,10 @@ class Heap {
// Performs a full garbage collection. If (flags &
kMakeHeapIterableMask) is
// non-zero, then the slower precise sweeper is used, which leaves the
heap
// in a state where we can iterate over the heap visiting all objects.
- void CollectAllGarbage(int flags, const char* gc_reason = NULL);
+ void CollectAllGarbage(
+ int flags,
+ const char* gc_reason = NULL,
+ const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags);
// Last hope GC, should try to squeeze as much as possible.
void CollectAllAvailableGarbage(const char* gc_reason = NULL);
@@ -1727,7 +1732,7 @@ class Heap {
inline Isolate* isolate();
void CallGCPrologueCallbacks(GCType gc_type, GCCallbackFlags flags);
- void CallGCEpilogueCallbacks(GCType gc_type);
+ void CallGCEpilogueCallbacks(GCType gc_type, GCCallbackFlags flags);
inline bool OldGenerationAllocationLimitReached();
@@ -2072,16 +2077,20 @@ class Heap {
// Performs garbage collection operation.
// Returns whether there is a chance that another major GC could
// collect more garbage.
- bool CollectGarbage(AllocationSpace space,
- GarbageCollector collector,
- const char* gc_reason,
- const char* collector_reason);
+ bool CollectGarbage(
+ AllocationSpace space,
+ GarbageCollector collector,
+ const char* gc_reason,
+ const char* collector_reason,
+ const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags);
// Performs garbage collection
// Returns whether there is a chance another major GC could
// collect more garbage.
- bool PerformGarbageCollection(GarbageCollector collector,
- GCTracer* tracer);
+ bool PerformGarbageCollection(
+ GarbageCollector collector,
+ GCTracer* tracer,
+ const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags);
inline void UpdateOldSpaceLimits();
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.