Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1204)

Unified Diff: third_party/WebKit/Source/core/workers/WorkerBackingThread.cpp

Issue 1749073002: Do V8 GC ASAP if system memory is pressured (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/workers/WorkerBackingThread.cpp
diff --git a/third_party/WebKit/Source/core/workers/WorkerBackingThread.cpp b/third_party/WebKit/Source/core/workers/WorkerBackingThread.cpp
index 040ce92ea79208362ca3f48cfceb67291d092614..7267083c7053962b89296c7c05e654b6b6691cce 100644
--- a/third_party/WebKit/Source/core/workers/WorkerBackingThread.cpp
+++ b/third_party/WebKit/Source/core/workers/WorkerBackingThread.cpp
@@ -17,6 +17,34 @@
namespace blink {
+#define DEFINE_STATIC_LOCAL_WITH_LOCK(type, name, arguments) \
+ ASSERT(isolatesMutex().locked()); \
+ static type& name = *new type arguments
+
+static Mutex& isolatesMutex()
+{
+ DEFINE_THREAD_SAFE_STATIC_LOCAL(Mutex, mutex, new Mutex);
+ return mutex;
+}
+
+static HashSet<v8::Isolate*>& isolates()
+{
+ DEFINE_STATIC_LOCAL_WITH_LOCK(HashSet<v8::Isolate*>, isolates, ());
+ return isolates;
+}
+
+static void addWorkerIsolate(v8::Isolate* isolate)
+{
+ MutexLocker lock(isolatesMutex());
+ isolates().add(isolate);
+}
+
+static void removeWorkerIsolate(v8::Isolate* isolate)
+{
+ MutexLocker lock(isolatesMutex());
+ isolates().remove(isolate);
+}
+
WorkerBackingThread::WorkerBackingThread(const char* name, bool shouldCallGCOnShutdown)
: m_backingThread(WebThreadSupportingGC::create(name))
, m_isOwningThread(true)
@@ -63,6 +91,7 @@ void WorkerBackingThread::initialize()
{
DCHECK(!m_isolate);
m_isolate = V8PerIsolateData::initialize();
+ addWorkerIsolate(m_isolate);
V8Initializer::initializeWorker(m_isolate);
m_backingThread->initialize();
@@ -89,7 +118,17 @@ void WorkerBackingThread::shutdown()
m_backingThread->shutdown();
V8PerIsolateData::destroy(m_isolate);
+ removeWorkerIsolate(m_isolate);
jochen (gone - plz use gerrit) 2016/05/04 18:28:14 i suspect this needs to come before V8PerIsolateDa
m_isolate = nullptr;
}
+// static
+void WorkerBackingThread::MemoryPressureNotificationToWorkerThreadIsolates(
+ v8::MemoryPressureLevel level)
+{
+ MutexLocker lock(isolatesMutex());
+ for (v8::Isolate* isolate : isolates())
+ isolate->MemoryPressureNotification(level);
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/workers/WorkerBackingThread.h ('k') | third_party/WebKit/Source/web/WebKit.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698