Scope& operator=(const Scope&);
};
+ /**
+ * Types of garbage collections that can be requested via
+ * RequestGarbageCollectionForTesting.
+ */
+ enum GarbageCollectionType {
+ kFullGarbageCollection,
+ kMinorGarbageCollection
+ };
+
/**
* Creates a new isolate. Does not change the currently entered
* isolate.
*/
void ClearInterrupt();
+ /**
+ * Request garbage collection in this Isolate. It is only valid to call this
+ * function if --expose_gc was specified.
+ *
+ * This should only be used for testing purposes and not to enforce a garbage
+ * collection schedule. It has strong negative impact on the garbage
+ * collection performance. Use IdleNotification() or LowMemoryNotification()
+ * instead to influence the garbage collection schedule.
+ */
+ void RequestGarbageCollectionForTesting(GarbageCollectionType type);
+
private:
Isolate();
Isolate(const Isolate&);
}
+void Isolate::RequestGarbageCollectionForTesting(GarbageCollectionType type) {
+ CHECK(i::FLAG_expose_gc);
+ if (type == kMinorGarbageCollection) {
+ reinterpret_cast<i::Isolate*>(this)->heap()->CollectGarbage(
+ i::NEW_SPACE, "Isolate::RequestGarbageCollection",
+ kGCCallbackFlagForced);
+ } else {
+ ASSERT_EQ(kFullGarbageCollection, type);
+ reinterpret_cast<i::Isolate*>(this)->heap()->CollectAllGarbage(
+ i::Heap::kNoGCFlags, "Isolate::RequestGarbageCollection",
+ kGCCallbackFlagForced);
+ }
+}
+
+
Isolate* Isolate::GetCurrent() {
i::Isolate* isolate = i::Isolate::UncheckedCurrent();
return reinterpret_cast<Isolate*>(isolate);