Diff
Modified: trunk/Source/WebCore/ChangeLog (102066 => 102067)
--- trunk/Source/WebCore/ChangeLog 2011-12-06 00:32:23 UTC (rev 102066)
+++ trunk/Source/WebCore/ChangeLog 2011-12-06 00:33:28 UTC (rev 102067)
@@ -1,3 +1,38 @@
+2011-12-05 Adam Klein <ad...@chromium.org>
+
+ V8RecursionScope should call didLeaveScriptContext when recursionLevel reaches zero
+ https://bugs.webkit.org/show_bug.cgi?id=73867
+
+ Reviewed by Adam Barth.
+
+ Moved V8RecursionScope into its own file, and moved
+ V8Proxy::didLeaveScriptContext into that file, along with a static
+ recursionLevel accessor, hiding the V8BindingPerIsolateData methods
+ from V8Proxy.
+
+ This will make it easy and less error-prone to use V8RecursionScope
+ properly. I plan to make use of it in V8LazyEventListener to fix
+ https://bugs.webkit.org/show_bug.cgi?id=73492.
+
+ No new tests, refactoring only.
+
+ * Target.pri:
+ * UseV8.cmake:
+ * WebCore.gypi:
+ * bindings/v8/V8Binding.h:
+ (WebCore::V8BindingPerIsolateData::incrementRecursionLevel): return the new recursion level.
+ (WebCore::V8BindingPerIsolateData::decrementRecursionLevel): return the new recursion level.
+ * bindings/v8/V8Proxy.cpp: remove didLeaveScriptContext.
+ (WebCore::V8Proxy::runScript): remove explicit call to didLeaveScriptContext.
+ (WebCore::V8Proxy::instrumentedCallFunction): remove explicit call to didLeaveScriptContext.
+ * bindings/v8/V8Proxy.h: remove didLeaveScriptContext.
+ * bindings/v8/V8RecursionScope.cpp: Added.
+ (WebCore::V8RecursionScope::didLeaveScriptContext): copied from V8Proxy.cpp.
+ * bindings/v8/V8RecursionScope.h: Added.
+ (WebCore::V8RecursionScope::V8RecursionScope):
+ (WebCore::V8RecursionScope::~V8RecursionScope):
+ (WebCore::V8RecursionScope::recursionLevel):
+
2011-12-05 Benjamin Poulain <bpoul...@apple.com>
Build fix for SecurityOrigin.cpp when neither BLOB nor FILE_SYSTEM are defined
Modified: trunk/Source/WebCore/Target.pri (102066 => 102067)
--- trunk/Source/WebCore/Target.pri 2011-12-06 00:32:23 UTC (rev 102066)
+++ trunk/Source/WebCore/Target.pri 2011-12-06 00:33:28 UTC (rev 102067)
@@ -134,6 +134,7 @@
bindings/v8/V8NPUtils.cpp \
bindings/v8/V8NodeFilterCondition.cpp \
bindings/v8/V8Proxy.cpp \
+ bindings/v8/V8RecursionScope.cpp \
bindings/v8/V8Utilities.cpp \
bindings/v8/V8WindowErrorHandler.cpp \
bindings/v8/V8WorkerContextEventListener.cpp \
@@ -1389,6 +1390,7 @@
bindings/v8/V8NPObject.h \
bindings/v8/V8NPUtils.h \
bindings/v8/V8Proxy.h \
+ bindings/v8/V8RecursionScope.h \
bindings/v8/V8Utilities.h \
bindings/v8/V8WindowErrorHandler.h \
bindings/v8/V8WorkerContextEventListener.h \
Modified: trunk/Source/WebCore/UseV8.cmake (102066 => 102067)
--- trunk/Source/WebCore/UseV8.cmake 2011-12-06 00:32:23 UTC (rev 102066)
+++ trunk/Source/WebCore/UseV8.cmake 2011-12-06 00:33:28 UTC (rev 102067)
@@ -53,6 +53,7 @@
bindings/v8/V8LazyEventListener.cpp
bindings/v8/V8NodeFilterCondition.cpp
bindings/v8/V8Proxy.cpp
+ bindings/v8/V8RecursionScope.cpp
bindings/v8/V8Utilities.cpp
bindings/v8/V8WindowErrorHandler.cpp
bindings/v8/V8WorkerContextErrorHandler.cpp
Modified: trunk/Source/WebCore/WebCore.gypi (102066 => 102067)
--- trunk/Source/WebCore/WebCore.gypi 2011-12-06 00:32:23 UTC (rev 102066)
+++ trunk/Source/WebCore/WebCore.gypi 2011-12-06 00:33:28 UTC (rev 102067)
@@ -2139,6 +2139,8 @@
'bindings/v8/V8NodeFilterCondition.h',
'bindings/v8/V8Proxy.cpp',
'bindings/v8/V8Proxy.h',
+ 'bindings/v8/V8RecursionScope.cpp',
+ 'bindings/v8/V8RecursionScope.h',
'bindings/v8/V8Utilities.cpp',
'bindings/v8/V8Utilities.h',
'bindings/v8/V8WindowErrorHandler.cpp',
Modified: trunk/Source/WebCore/bindings/v8/V8Binding.h (102066 => 102067)
--- trunk/Source/WebCore/bindings/v8/V8Binding.h 2011-12-06 00:32:23 UTC (rev 102066)
+++ trunk/Source/WebCore/bindings/v8/V8Binding.h 2011-12-06 00:33:28 UTC (rev 102067)
@@ -145,8 +145,8 @@
void setDOMDataStore(DOMDataStore* store) { m_domDataStore = store; }
int recursionLevel() const { return m_recursionLevel; }
- void incrementRecursionLevel() { ++m_recursionLevel; }
- void decrementRecursionLevel() { --m_recursionLevel; }
+ int incrementRecursionLevel() { return ++m_recursionLevel; }
+ int decrementRecursionLevel() { return --m_recursionLevel; }
#ifndef NDEBUG
GlobalHandleMap& globalHandleMap() { return m_globalHandleMap; }
@@ -178,13 +178,6 @@
#endif
};
- class V8RecursionScope {
- WTF_MAKE_NONCOPYABLE(V8RecursionScope);
- public:
- V8RecursionScope() { V8BindingPerIsolateData::current()->incrementRecursionLevel(); }
- ~V8RecursionScope() { V8BindingPerIsolateData::current()->decrementRecursionLevel(); }
- };
-
class ConstructorMode {
public:
enum Mode {
Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.cpp (102066 => 102067)
--- trunk/Source/WebCore/bindings/v8/V8Proxy.cpp 2011-12-06 00:32:23 UTC (rev 102066)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.cpp 2011-12-06 00:33:28 UTC (rev 102067)
@@ -42,7 +42,6 @@
#include "Frame.h"
#include "FrameLoaderClient.h"
#include "IDBFactoryBackendInterface.h"
-#include "IDBPendingTransactionMonitor.h"
#include "InspectorInstrumentation.h"
#include "Page.h"
#include "PlatformSupport.h"
@@ -57,7 +56,7 @@
#include "V8DOMWindow.h"
#include "V8HiddenPropertyName.h"
#include "V8IsolatedContext.h"
-#include "WebKitMutationObserver.h"
+#include "V8RecursionScope.h"
#include "WorkerContext.h"
#include "WorkerContextExecutionProxy.h"
@@ -175,11 +174,6 @@
CRASH();
}
-static int recursionLevel()
-{
- return V8BindingPerIsolateData::current()->recursionLevel();
-}
-
static v8::Local<v8::Value> handleMaxRecursionDepthExceeded()
{
throwError("Maximum call stack size exceeded.", V8Proxy::RangeError);
@@ -390,7 +384,7 @@
return notHandledByInterceptor();
V8GCController::checkMemoryUsage();
- if (recursionLevel() >= kMaxRecursionDepth)
+ if (V8RecursionScope::recursionLevel() >= kMaxRecursionDepth)
return handleMaxRecursionDepthExceeded();
if (handleOutOfMemory())
@@ -408,8 +402,6 @@
result = script->Run();
}
- didLeaveScriptContext();
-
if (handleOutOfMemory())
ASSERT(result.IsEmpty());
@@ -439,7 +431,7 @@
{
V8GCController::checkMemoryUsage();
- if (recursionLevel() >= kMaxRecursionDepth)
+ if (V8RecursionScope::recursionLevel() >= kMaxRecursionDepth)
return handleMaxRecursionDepthExceeded();
InspectorInstrumentationCookie cookie;
@@ -460,9 +452,6 @@
result = function->Call(receiver, argc, args);
}
- // FIXME: Instrument any work that takes place when script exits to c++ (e.g. Mutation Observers).
- didLeaveScriptContext();
-
InspectorInstrumentation::didCallFunction(cookie);
if (v8::V8::IsDead())
@@ -552,23 +541,6 @@
return retrieve(static_cast<Document*>(context)->frame());
}
-void V8Proxy::didLeaveScriptContext()
-{
- if (recursionLevel())
- return;
-
-#if ENABLE(INDEXED_DATABASE)
- // If we've just left a script context and indexed database has been
- // instantiated, we must let its transaction coordinator know so it can terminate
- // any not-yet-started transactions.
- IDBPendingTransactionMonitor::abortPendingTransactions();
-#endif // ENABLE(INDEXED_DATABASE)
-
-#if ENABLE(MUTATION_OBSERVERS)
- WebCore::WebKitMutationObserver::deliverAllMutations();
-#endif
-}
-
void V8Proxy::resetIsolatedWorlds()
{
for (IsolatedWorldMap::iterator iter = m_isolatedWorlds.begin();
Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.h (102066 => 102067)
--- trunk/Source/WebCore/bindings/v8/V8Proxy.h 2011-12-06 00:32:23 UTC (rev 102066)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.h 2011-12-06 00:33:28 UTC (rev 102067)
@@ -264,8 +264,6 @@
static void reportUnsafeAccessTo(Frame* target);
private:
- static void didLeaveScriptContext();
-
void resetIsolatedWorlds();
PassOwnPtr<v8::ScriptData> precompileScript(v8::Handle<v8::String>, CachedScript*);
Added: trunk/Source/WebCore/bindings/v8/V8RecursionScope.cpp (0 => 102067)
--- trunk/Source/WebCore/bindings/v8/V8RecursionScope.cpp (rev 0)
+++ trunk/Source/WebCore/bindings/v8/V8RecursionScope.cpp 2011-12-06 00:33:28 UTC (rev 102067)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "V8RecursionScope.h"
+
+#include "IDBPendingTransactionMonitor.h"
+#include "WebKitMutationObserver.h"
+
+namespace WebCore {
+
+void V8RecursionScope::didLeaveScriptContext()
+{
+ // FIXME: Instrument any work that takes place when script exits to c++ (e.g. Mutation Observers).
+
+#if ENABLE(INDEXED_DATABASE)
+ // If we've just left a script context and indexed database has been
+ // instantiated, we must let its transaction coordinator know so it can terminate
+ // any not-yet-started transactions.
+ IDBPendingTransactionMonitor::abortPendingTransactions();
+#endif
+
+#if ENABLE(MUTATION_OBSERVERS)
+ WebKitMutationObserver::deliverAllMutations();
+#endif
+}
+
+} // namespace WebCore
Property changes on: trunk/Source/WebCore/bindings/v8/V8RecursionScope.cpp
___________________________________________________________________
Added: svn:eol-style
Added: trunk/Source/WebCore/bindings/v8/V8RecursionScope.h (0 => 102067)
--- trunk/Source/WebCore/bindings/v8/V8RecursionScope.h (rev 0)
+++ trunk/Source/WebCore/bindings/v8/V8RecursionScope.h 2011-12-06 00:33:28 UTC (rev 102067)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef V8RecursionScope_h
+#define V8RecursionScope_h
+
+#include "V8Binding.h"
+
+namespace WebCore {
+
+class V8RecursionScope {
+ WTF_MAKE_NONCOPYABLE(V8RecursionScope);
+public:
+ V8RecursionScope() { V8BindingPerIsolateData::current()->incrementRecursionLevel(); }
+ ~V8RecursionScope()
+ {
+ if (!V8BindingPerIsolateData::current()->decrementRecursionLevel())
+ didLeaveScriptContext();
+ }
+
+ static int recursionLevel() { return V8BindingPerIsolateData::current()->recursionLevel(); }
+
+private:
+ static void didLeaveScriptContext();
+};
+
+} // namespace WebCore
+
+#endif // V8RecursionScope_h
Property changes on: trunk/Source/WebCore/bindings/v8/V8RecursionScope.h
___________________________________________________________________
Added: svn:eol-style