Revision: 18563
Author:   [email protected]
Date:     Mon Jan 13 12:03:31 2014 UTC
Log:      Introduce an API mirroring the gc extension

BUG=none
[email protected], [email protected]
LOG=y

Review URL: https://codereview.chromium.org/131443008
http://code.google.com/p/v8/source/detail?r=18563

Modified:
 /branches/bleeding_edge/include/v8.h
 /branches/bleeding_edge/src/api.cc

=======================================
--- /branches/bleeding_edge/include/v8.h        Mon Jan 13 10:57:49 2014 UTC
+++ /branches/bleeding_edge/include/v8.h        Mon Jan 13 12:03:31 2014 UTC
@@ -3963,6 +3963,15 @@
     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.
@@ -4175,6 +4184,17 @@
    */
   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&);
=======================================
--- /branches/bleeding_edge/src/api.cc  Mon Jan 13 10:51:40 2014 UTC
+++ /branches/bleeding_edge/src/api.cc  Mon Jan 13 12:03:31 2014 UTC
@@ -6410,6 +6410,21 @@
 void Isolate::ClearInterrupt() {
   reinterpret_cast<i::Isolate*>(this)->stack_guard()->ClearInterrupt();
 }
+
+
+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() {

--
--
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.

Reply via email to