summaryrefslogtreecommitdiffstats
path: root/WebCore/bindings
diff options
context:
space:
mode:
authorAndrei Popescu <andreip@google.com>2009-08-04 15:23:24 +0100
committerAndrei Popescu <andreip@google.com>2009-08-05 20:11:54 +0100
commit14be0af3dbf46bfc174c0081053eccccef89edc7 (patch)
tree02ae286cd26ecd31c1e7b0e8b6674c36e8eca8c3 /WebCore/bindings
parente65a5905dd4459ab5e4ef22d6dcb85e1d1a0b7cb (diff)
downloadexternal_webkit-14be0af3dbf46bfc174c0081053eccccef89edc7.zip
external_webkit-14be0af3dbf46bfc174c0081053eccccef89edc7.tar.gz
external_webkit-14be0af3dbf46bfc174c0081053eccccef89edc7.tar.bz2
Add V8 locks at the v8 entry points for use with workers.
Diffstat (limited to 'WebCore/bindings')
-rw-r--r--WebCore/bindings/v8/ScheduledAction.cpp2
-rw-r--r--WebCore/bindings/v8/ScriptController.cpp3
-rw-r--r--WebCore/bindings/v8/V8AbstractEventListener.cpp1
-rw-r--r--WebCore/bindings/v8/V8Utilities.h5
-rw-r--r--WebCore/bindings/v8/V8WorkerContextEventListener.cpp2
-rw-r--r--WebCore/bindings/v8/WorkerContextExecutionProxy.cpp7
6 files changed, 20 insertions, 0 deletions
diff --git a/WebCore/bindings/v8/ScheduledAction.cpp b/WebCore/bindings/v8/ScheduledAction.cpp
index ab51600..b1db8cf 100644
--- a/WebCore/bindings/v8/ScheduledAction.cpp
+++ b/WebCore/bindings/v8/ScheduledAction.cpp
@@ -105,6 +105,7 @@ void ScheduledAction::execute(V8Proxy* proxy)
{
ASSERT(proxy);
+ LOCK_V8;
v8::HandleScope handleScope;
v8::Local<v8::Context> v8Context = proxy->GetContext();
if (v8Context.IsEmpty())
@@ -133,6 +134,7 @@ void ScheduledAction::execute(WorkerContext* workerContext)
WorkerScriptController* scriptController = workerContext->script();
if (!m_function.IsEmpty() && m_function->IsFunction()) {
+ LOCK_V8;
v8::HandleScope handleScope;
v8::Local<v8::Context> v8Context = scriptController->proxy()->GetContext();
ASSERT(!v8Context.IsEmpty());
diff --git a/WebCore/bindings/v8/ScriptController.cpp b/WebCore/bindings/v8/ScriptController.cpp
index 833c99f..97bb8ec 100644
--- a/WebCore/bindings/v8/ScriptController.cpp
+++ b/WebCore/bindings/v8/ScriptController.cpp
@@ -191,6 +191,7 @@ void ScriptController::evaluateInNewContext(const Vector<ScriptSourceCode>& sour
// Evaluate a script file in the environment of this proxy.
ScriptValue ScriptController::evaluate(const ScriptSourceCode& sourceCode)
{
+ LOCK_V8;
v8::HandleScope handleScope;
v8::Handle<v8::Context> context = V8Proxy::GetContext(m_proxy->frame());
if (context.IsEmpty())
@@ -225,6 +226,7 @@ void ScriptController::finishedWithEvent(Event* event)
// Create a V8 object with an interceptor of NPObjectPropertyGetter.
void ScriptController::bindToWindowObject(Frame* frame, const String& key, NPObject* object)
{
+ LOCK_V8;
v8::HandleScope handleScope;
v8::Handle<v8::Context> context = V8Proxy::GetContext(frame);
@@ -371,6 +373,7 @@ NPObject* ScriptController::createScriptObjectForPluginElement(HTMLPlugInElement
if (!isEnabled())
return createNoScriptObject();
+ LOCK_V8;
v8::HandleScope handleScope;
v8::Handle<v8::Context> context = V8Proxy::GetContext(m_frame);
if (context.IsEmpty())
diff --git a/WebCore/bindings/v8/V8AbstractEventListener.cpp b/WebCore/bindings/v8/V8AbstractEventListener.cpp
index 462a729..07e944d 100644
--- a/WebCore/bindings/v8/V8AbstractEventListener.cpp
+++ b/WebCore/bindings/v8/V8AbstractEventListener.cpp
@@ -110,6 +110,7 @@ void V8AbstractEventListener::handleEvent(Event* event, bool isWindowEvent)
// See issue 889829.
RefPtr<V8AbstractEventListener> protect(this);
+ LOCK_V8;
v8::HandleScope handleScope;
v8::Handle<v8::Context> context = V8Proxy::GetContext(m_frame);
diff --git a/WebCore/bindings/v8/V8Utilities.h b/WebCore/bindings/v8/V8Utilities.h
index 5769910..fdabc7a 100644
--- a/WebCore/bindings/v8/V8Utilities.h
+++ b/WebCore/bindings/v8/V8Utilities.h
@@ -33,6 +33,11 @@
// FIXME: Remove once chromium dependencies on v8_utility.h are removed.
#define V8UTILITIES_DEFINED 1
+#if ENABLE(V8_LOCKERS)
+#define LOCK_V8 v8::Locker lock
+#else
+#define LOCK_V8 ((void) 0)
+#endif
#include <v8.h>
diff --git a/WebCore/bindings/v8/V8WorkerContextEventListener.cpp b/WebCore/bindings/v8/V8WorkerContextEventListener.cpp
index 9bb48fb..a21d3eb 100644
--- a/WebCore/bindings/v8/V8WorkerContextEventListener.cpp
+++ b/WebCore/bindings/v8/V8WorkerContextEventListener.cpp
@@ -35,6 +35,7 @@
#include "V8WorkerContextEventListener.h"
#include "Event.h"
+#include "V8Utilities.h"
#include "WorkerContextExecutionProxy.h"
namespace WebCore {
@@ -62,6 +63,7 @@ void V8WorkerContextEventListener::handleEvent(Event* event, bool isWindowEvent)
// See issue 889829.
RefPtr<V8AbstractEventListener> protect(this);
+ LOCK_V8;
v8::HandleScope handleScope;
v8::Handle<v8::Context> context = m_proxy->GetContext();
diff --git a/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp b/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp
index 7af9536..c87cdea 100644
--- a/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp
+++ b/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp
@@ -141,6 +141,7 @@ void WorkerContextExecutionProxy::initV8IfNeeded()
{
static bool v8Initialized = false;
+ LOCK_V8;
if (v8Initialized)
return;
@@ -151,6 +152,10 @@ void WorkerContextExecutionProxy::initV8IfNeeded()
// Set up the handler for V8 error message.
v8::V8::AddMessageListener(handleConsoleMessage);
+#if PLATFORM(ANDROID)
+ const int workerThreadPreemptionIntervalMs = 5;
+ v8::Locker::StartPreemption(workerThreadPreemptionIntervalMs);
+#endif
v8Initialized = true;
}
@@ -337,6 +342,7 @@ bool WorkerContextExecutionProxy::forgetV8EventObject(Event* event)
v8::Local<v8::Value> WorkerContextExecutionProxy::evaluate(const String& script, const String& fileName, int baseLine)
{
+ LOCK_V8;
v8::HandleScope hs;
initContextIfNeeded();
@@ -394,6 +400,7 @@ PassRefPtr<V8EventListener> WorkerContextExecutionProxy::findOrCreateEventListen
newListener = V8WorkerContextObjectEventListener::create(this, v8::Local<v8::Object>::Cast(object), isInline);
else
newListener = V8WorkerContextEventListener::create(this, v8::Local<v8::Object>::Cast(object), isInline);
+
m_listeners->add(newListener.get());
return newListener.release();