[WTF] Drop Thread::create(obsolete things) API since we can use lambda
[WebKit-https.git] / Source / WebCore / bindings / js / GCController.cpp
index acfba39..b26f757 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007, 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -26,7 +26,7 @@
 #include "config.h"
 #include "GCController.h"
 
-#include "JSDOMWindow.h"
+#include "CommonVM.h"
 #include <runtime/VM.h>
 #include <runtime/JSLock.h>
 #include <heap/Heap.h>
@@ -38,10 +38,10 @@ using namespace JSC;
 
 namespace WebCore {
 
-static void collect(void*)
+static void collect()
 {
-    JSLockHolder lock(JSDOMWindow::commonVM());
-    JSDOMWindow::commonVM().heap.collectAllGarbage();
+    JSLockHolder lock(commonVM());
+    commonVM().heap.collectNow(Async, CollectionScope::Full);
 }
 
 GCController& GCController::singleton()
@@ -61,8 +61,8 @@ void GCController::garbageCollectSoon()
     // of the garbage collector timers in JavaScriptCore. We wouldn't need this if JavaScriptCore
     // used a timer implementation from WTF like RunLoop::Timer.
 #if USE(CF) || USE(GLIB)
-    JSLockHolder lock(JSDOMWindow::commonVM());
-    JSDOMWindow::commonVM().heap.reportAbandonedObjectGraph();
+    JSLockHolder lock(commonVM());
+    commonVM().heap.reportAbandonedObjectGraph();
 #else
     garbageCollectOnNextRunLoop();
 #endif
@@ -71,19 +71,19 @@ void GCController::garbageCollectSoon()
 void GCController::garbageCollectOnNextRunLoop()
 {
     if (!m_GCTimer.isActive())
-        m_GCTimer.startOneShot(0);
+        m_GCTimer.startOneShot(0_s);
 }
 
 void GCController::gcTimerFired()
 {
-    collect(nullptr);
+    collect();
 }
 
 void GCController::garbageCollectNow()
 {
-    JSLockHolder lock(JSDOMWindow::commonVM());
-    if (!JSDOMWindow::commonVM().heap.isBusy()) {
-        JSDOMWindow::commonVM().heap.collectAllGarbage();
+    JSLockHolder lock(commonVM());
+    if (!commonVM().heap.isCurrentThreadBusy()) {
+        commonVM().heap.collectNow(Sync, CollectionScope::Full);
         WTF::releaseFastMallocFreeMemory();
     }
 }
@@ -91,9 +91,9 @@ void GCController::garbageCollectNow()
 void GCController::garbageCollectNowIfNotDoneRecently()
 {
 #if USE(CF) || USE(GLIB)
-    JSLockHolder lock(JSDOMWindow::commonVM());
-    if (!JSDOMWindow::commonVM().heap.isBusy())
-        JSDOMWindow::commonVM().heap.collectAllGarbageIfNotDoneRecently();
+    JSLockHolder lock(commonVM());
+    if (!commonVM().heap.isCurrentThreadBusy())
+        commonVM().heap.collectNowFullIfNotDoneRecently(Async);
 #else
     garbageCollectSoon();
 #endif
@@ -101,31 +101,31 @@ void GCController::garbageCollectNowIfNotDoneRecently()
 
 void GCController::garbageCollectOnAlternateThreadForDebugging(bool waitUntilDone)
 {
-    ThreadIdentifier threadID = createThread(collect, 0, "WebCore: GCController");
+    RefPtr<Thread> thread = Thread::create("WebCore: GCController", &collect);
 
     if (waitUntilDone) {
-        waitForThreadCompletion(threadID);
+        thread->waitForCompletion();
         return;
     }
 
-    detachThread(threadID);
+    thread->detach();
 }
 
 void GCController::setJavaScriptGarbageCollectorTimerEnabled(bool enable)
 {
-    JSDOMWindow::commonVM().heap.setGarbageCollectionTimerEnabled(enable);
+    commonVM().heap.setGarbageCollectionTimerEnabled(enable);
 }
 
-void GCController::deleteAllCode()
+void GCController::deleteAllCode(DeleteAllCodeEffort effort)
 {
-    JSLockHolder lock(JSDOMWindow::commonVM());
-    JSDOMWindow::commonVM().deleteAllCode();
+    JSLockHolder lock(commonVM());
+    commonVM().deleteAllCode(effort);
 }
 
-void GCController::deleteAllLinkedCode()
+void GCController::deleteAllLinkedCode(DeleteAllCodeEffort effort)
 {
-    JSLockHolder lock(JSDOMWindow::commonVM());
-    JSDOMWindow::commonVM().deleteAllLinkedCode();
+    JSLockHolder lock(commonVM());
+    commonVM().deleteAllLinkedCode(effort);
 }
 
 } // namespace WebCore