Title: [128390] trunk/Source/WebCore
- Revision
- 128390
- Author
- [email protected]
- Date
- 2012-09-12 17:43:18 -0700 (Wed, 12 Sep 2012)
Log Message
[V8] OOM in Workers due to external memory retention.
https://bugs.webkit.org/show_bug.cgi?id=96459
Reviewed by David Levin.
Added memory checks to the locations in Workers code that are about to invoke the next JS block.
* bindings/v8/ScheduledAction.cpp:
(WebCore::ScheduledAction::execute):
* bindings/v8/V8GCController.cpp:
(WebCore):
(WebCore::workingSetEstimateMBMutex): Added a Mutex-protected accessors to a static caching WS estimate.
(WebCore::V8GCController::gcEpilogue):
(WebCore::V8GCController::checkMemoryUsage):
* bindings/v8/V8GCController.h:
(V8GCController):
* bindings/v8/V8WorkerContextEventListener.cpp:
(WebCore::V8WorkerContextEventListener::callListenerFunction):
* bindings/v8/WorkerContextExecutionProxy.cpp:
(WebCore::WorkerContextExecutionProxy::evaluate):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (128389 => 128390)
--- trunk/Source/WebCore/ChangeLog 2012-09-13 00:30:07 UTC (rev 128389)
+++ trunk/Source/WebCore/ChangeLog 2012-09-13 00:43:18 UTC (rev 128390)
@@ -1,3 +1,26 @@
+2012-09-12 Dmitry Titov <[email protected]>
+
+ [V8] OOM in Workers due to external memory retention.
+ https://bugs.webkit.org/show_bug.cgi?id=96459
+
+ Reviewed by David Levin.
+
+ Added memory checks to the locations in Workers code that are about to invoke the next JS block.
+
+ * bindings/v8/ScheduledAction.cpp:
+ (WebCore::ScheduledAction::execute):
+ * bindings/v8/V8GCController.cpp:
+ (WebCore):
+ (WebCore::workingSetEstimateMBMutex): Added a Mutex-protected accessors to a static caching WS estimate.
+ (WebCore::V8GCController::gcEpilogue):
+ (WebCore::V8GCController::checkMemoryUsage):
+ * bindings/v8/V8GCController.h:
+ (V8GCController):
+ * bindings/v8/V8WorkerContextEventListener.cpp:
+ (WebCore::V8WorkerContextEventListener::callListenerFunction):
+ * bindings/v8/WorkerContextExecutionProxy.cpp:
+ (WebCore::WorkerContextExecutionProxy::evaluate):
+
2012-09-12 Julien Chaffraix <[email protected]>
REGRESSION(r122501): replaced elements with percent width are wrongly size when inserted inside an auto-table layout
Modified: trunk/Source/WebCore/bindings/v8/ScheduledAction.cpp (128389 => 128390)
--- trunk/Source/WebCore/bindings/v8/ScheduledAction.cpp 2012-09-13 00:30:07 UTC (rev 128389)
+++ trunk/Source/WebCore/bindings/v8/ScheduledAction.cpp 2012-09-13 00:43:18 UTC (rev 128390)
@@ -42,6 +42,7 @@
#include "ScriptController.h"
#include "V8Binding.h"
+#include "V8GCController.h"
#include "V8RecursionScope.h"
#include "WorkerContext.h"
#include "WorkerContextExecutionProxy.h"
@@ -112,6 +113,8 @@
V8RecursionScope recursionScope(worker);
if (!m_function.isEmpty()) {
+ V8GCController::checkMemoryUsage();
+
v8::HandleScope handleScope;
v8::Handle<v8::Context> context = v8::Local<v8::Context>::New(m_context.get());
Modified: trunk/Source/WebCore/bindings/v8/V8GCController.cpp (128389 => 128390)
--- trunk/Source/WebCore/bindings/v8/V8GCController.cpp 2012-09-13 00:30:07 UTC (rev 128389)
+++ trunk/Source/WebCore/bindings/v8/V8GCController.cpp 2012-09-13 00:43:18 UTC (rev 128390)
@@ -416,8 +416,16 @@
}
};
-int V8GCController::workingSetEstimateMB = 0;
+#if PLATFORM(CHROMIUM)
+static int workingSetEstimateMB = 0;
+static Mutex& workingSetEstimateMBMutex()
+{
+ AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex);
+ return mutex;
+}
+#endif
+
void V8GCController::gcEpilogue()
{
v8::HandleScope scope;
@@ -429,7 +437,13 @@
GCEpilogueVisitor<Node, SpecialCaseEpilogueNodeHandler, &DOMDataStore::weakNodeCallback> epilogueNodeVisitor;
visitActiveDOMNodes(&epilogueNodeVisitor);
- workingSetEstimateMB = MemoryUsageSupport::actualMemoryUsageMB();
+#if PLATFORM(CHROMIUM)
+ // The GC can happen on multiple threads in case of dedicated workers which run in-process.
+ {
+ MutexLocker locker(workingSetEstimateMBMutex());
+ workingSetEstimateMB = MemoryUsageSupport::actualMemoryUsageMB();
+ }
+#endif
#ifndef NDEBUG
// Check all survivals are weak.
@@ -452,7 +466,13 @@
const int highMemoryUsageMB = MemoryUsageSupport::highMemoryUsageMB();
const int highUsageDeltaMB = MemoryUsageSupport::highUsageDeltaMB();
int memoryUsageMB = MemoryUsageSupport::memoryUsageMB();
- if ((memoryUsageMB > lowMemoryUsageMB && memoryUsageMB > 2 * workingSetEstimateMB) || (memoryUsageMB > highMemoryUsageMB && memoryUsageMB > workingSetEstimateMB + highUsageDeltaMB))
+ int workingSetEstimateMBCopy;
+ {
+ MutexLocker locker(workingSetEstimateMBMutex());
+ workingSetEstimateMBCopy = workingSetEstimateMB;
+ }
+
+ if ((memoryUsageMB > lowMemoryUsageMB && memoryUsageMB > 2 * workingSetEstimateMBCopy) || (memoryUsageMB > highMemoryUsageMB && memoryUsageMB > workingSetEstimateMBCopy + highUsageDeltaMB))
v8::V8::LowMemoryNotification();
#endif
}
Modified: trunk/Source/WebCore/bindings/v8/V8GCController.h (128389 => 128390)
--- trunk/Source/WebCore/bindings/v8/V8GCController.h 2012-09-13 00:30:07 UTC (rev 128389)
+++ trunk/Source/WebCore/bindings/v8/V8GCController.h 2012-09-13 00:43:18 UTC (rev 128390)
@@ -43,9 +43,6 @@
static void checkMemoryUsage();
static void hintForCollectGarbage();
static void collectGarbage();
-
-private:
- static int workingSetEstimateMB;
};
}
Modified: trunk/Source/WebCore/bindings/v8/V8WorkerContextEventListener.cpp (128389 => 128390)
--- trunk/Source/WebCore/bindings/v8/V8WorkerContextEventListener.cpp 2012-09-13 00:30:07 UTC (rev 128389)
+++ trunk/Source/WebCore/bindings/v8/V8WorkerContextEventListener.cpp 2012-09-13 00:43:18 UTC (rev 128390)
@@ -38,6 +38,7 @@
#include "V8Binding.h"
#include "V8DOMWrapper.h"
#include "V8Event.h"
+#include "V8GCController.h"
#include "V8RecursionScope.h"
#include "WorkerContext.h"
#include "WorkerContextExecutionProxy.h"
@@ -86,6 +87,8 @@
v8::Local<v8::Value> V8WorkerContextEventListener::callListenerFunction(ScriptExecutionContext* context, v8::Handle<v8::Value> jsEvent, Event* event)
{
+ V8GCController::checkMemoryUsage();
+
v8::Local<v8::Function> handlerFunction = getListenerFunction(context);
v8::Local<v8::Object> receiver = getReceiverObject(context, event);
if (handlerFunction.IsEmpty() || receiver.IsEmpty())
Modified: trunk/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp (128389 => 128390)
--- trunk/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp 2012-09-13 00:30:07 UTC (rev 128389)
+++ trunk/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp 2012-09-13 00:43:18 UTC (rev 128390)
@@ -205,6 +205,8 @@
ScriptValue WorkerContextExecutionProxy::evaluate(const String& script, const String& fileName, const TextPosition& scriptStartPosition, WorkerContextExecutionState* state)
{
+ V8GCController::checkMemoryUsage();
+
v8::HandleScope hs;
if (!initializeIfNeeded())
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes