[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.21-584-g1e41756
japhet at chromium.org
japhet at chromium.org
Fri Feb 26 22:24:52 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 696a436aee97a8cad27dba84c6ce09310728d7c4
Author: japhet at chromium.org <japhet at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Feb 18 18:40:49 2010 +0000
2010-02-18 Nate Chapin <japhet at chromium.org>
Reviewed by Adam Barth.
[V8] Merge the DOMWindow and WorkerContext object wrapping code paths,
and use a faster method of disambiguating between the types of contexts.
https://bugs.webkit.org/show_bug.cgi?id=35009
* bindings/scripts/CodeGeneratorV8.pm: Remove logic determining whether we need to
handle the WorkerContext case.
* bindings/v8/V8DOMWrapper.cpp:
(WebCore::globalObjectPrototypeIsDOMWindow):
(WebCore::V8DOMWrapper::instantiateV8Object): Merge instantiateV8Object paths.
* bindings/v8/V8DOMWrapper.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54972 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index fc72e57..2fe9f61 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,19 @@
+2010-02-18 Nate Chapin <japhet at chromium.org>
+
+ Reviewed by Adam Barth.
+
+ [V8] Merge the DOMWindow and WorkerContext object wrapping code paths,
+ and use a faster method of disambiguating between the types of contexts.
+
+ https://bugs.webkit.org/show_bug.cgi?id=35009
+
+ * bindings/scripts/CodeGeneratorV8.pm: Remove logic determining whether we need to
+ handle the WorkerContext case.
+ * bindings/v8/V8DOMWrapper.cpp:
+ (WebCore::globalObjectPrototypeIsDOMWindow):
+ (WebCore::V8DOMWrapper::instantiateV8Object): Merge instantiateV8Object paths.
+ * bindings/v8/V8DOMWrapper.h:
+
2010-02-18 Xan Lopez <xlopez at igalia.com>
Reviewed by Gustavo Noronha.
diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm
index 2b89b54..ee51ec3 100644
--- a/WebCore/bindings/scripts/CodeGeneratorV8.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm
@@ -1949,12 +1949,8 @@ sub GenerateToV8Converters
v8::Handle<v8::Object> ${className}::wrap(${nativeType}* impl${forceNewObjectInput}) {
v8::Handle<v8::Object> wrapper;
-END
- if (!MayBeInWorkerContext($dataNode, $interfaceName)) {
- push(@implContent, <<END);
V8Proxy* proxy = 0;
END
- }
if (IsNodeSubType($dataNode)) {
push(@implContent, <<END);
@@ -1993,15 +1989,9 @@ END
END
}
- if (MayBeInWorkerContext($dataNode, $interfaceName)) {
- push(@implContent, <<END);
- wrapper = V8DOMWrapper::instantiateV8ObjectInWorkerContext(${wrapperType}, impl);
-END
- } else {
- push(@implContent, <<END);
+ push(@implContent, <<END);
wrapper = V8DOMWrapper::instantiateV8Object(proxy, ${wrapperType}, impl);
END
- }
if (IsNodeSubType($dataNode)) {
push(@implContent, <<END);
@@ -2049,35 +2039,6 @@ END
}
}
-sub MayBeInWorkerContext {
- # These objects can be constructed under WorkerContextExecutionProxy. They need special
- # handling, since if we call V8Proxy::retrieve(), we will crash.
- # FIXME: websocket?
- my $dataNode = shift;
- my $interfaceName = shift;
- # FIXME: Doing the extra work to handle the WorkerContext case for all Event
- # types is sad. We can probably be cleverer and only do the extra work for certain types.
- return 1 if IsEventSubType($dataNode);
- return 1 if $interfaceName eq "DOMCoreException";
- return 1 if $interfaceName eq "EventException";
- return 1 if $interfaceName eq "RangeException";
- return 1 if $interfaceName eq "XMLHttpRequestException";
- return 1 if $interfaceName eq "MessagePort";
- return 1 if $interfaceName eq "DedicatedWorkerContext";
- return 1 if $interfaceName eq "WorkerContext";
- return 1 if $interfaceName eq "SharedWorkerContext";
- return 1 if $interfaceName eq "WorkerLocation";
- return 1 if $interfaceName eq "WorkerNavigator";
- return 1 if $interfaceName eq "Notification";
- return 1 if $interfaceName eq "NotificationCenter";
- return 1 if $interfaceName eq "XMLHttpRequest";
- return 1 if $interfaceName eq "WebSocket";
- return 1 if $interfaceName eq "Worker";
- return 1 if $interfaceName eq "SharedWorker";
- return 1 if $interfaceName eq "EventSource";
- return 0;
-}
-
sub HasCustomToV8Implementation {
# FIXME: This subroutine is lame. Probably should be an .idl attribute (CustomToV8)?
$dataNode = shift;
diff --git a/WebCore/bindings/v8/V8DOMWrapper.cpp b/WebCore/bindings/v8/V8DOMWrapper.cpp
index 30775fa..0f982d5 100644
--- a/WebCore/bindings/v8/V8DOMWrapper.cpp
+++ b/WebCore/bindings/v8/V8DOMWrapper.cpp
@@ -61,6 +61,7 @@
#include "V8Proxy.h"
#include "V8SVGElementInstance.h"
#include "V8SharedWorker.h"
+#include "V8SharedWorkerContext.h"
#include "V8StyleSheet.h"
#include "V8WebSocket.h"
#include "V8Worker.h"
@@ -267,36 +268,49 @@ PassRefPtr<NodeFilter> V8DOMWrapper::wrapNativeNodeFilter(v8::Handle<v8::Value>
return NodeFilter::create(condition);
}
-v8::Local<v8::Object> V8DOMWrapper::instantiateV8ObjectInWorkerContext(V8ClassIndex::V8WrapperType type, void* impl)
+static bool globalObjectPrototypeIsDOMWindow(v8::Handle<v8::Object> objectPrototype)
{
- WorkerContextExecutionProxy* workerContextProxy = WorkerContextExecutionProxy::retrieve();
- if (!workerContextProxy)
- return instantiateV8Object(0, type, impl);
- v8::Local<v8::Object> instance = SafeAllocation::newInstance(getConstructor(type, workerContextProxy->workerContext()));
- if (!instance.IsEmpty()) {
- // Avoid setting the DOM wrapper for failed allocations.
- setDOMWrapper(instance, V8ClassIndex::ToInt(type), impl);
- }
- return instance;
+ // We can identify what type of context the global object is wrapping by looking at the
+ // internal field count of its prototype. This assumes WorkerContexts and DOMWindows have different numbers
+ // of internal fields, so a COMPILE_ASSERT is included to warn if this ever changes. DOMWindow has
+ // traditionally had far more internal fields than any other class.
+ COMPILE_ASSERT(V8DOMWindow::internalFieldCount != V8WorkerContext::internalFieldCount && V8DOMWindow::internalFieldCount != V8SharedWorkerContext::internalFieldCount,
+ DOMWindowAndWorkerContextHaveUnequalFieldCounts);
+ return objectPrototype->InternalFieldCount() == V8DOMWindow::internalFieldCount;
}
v8::Local<v8::Object> V8DOMWrapper::instantiateV8Object(V8Proxy* proxy, V8ClassIndex::V8WrapperType type, void* impl)
{
+ WorkerContext* workerContext = 0;
if (V8IsolatedContext::getEntered()) {
// This effectively disables the wrapper cache for isolated worlds.
proxy = 0;
// FIXME: Do we need a wrapper cache for the isolated world? We should
// see if the performance gains are worth while.
// We'll get one once we give the isolated context a proper window shell.
- } else if (!proxy)
- proxy = V8Proxy::retrieve();
+ } else if (!proxy) {
+ v8::Handle<v8::Context> context = v8::Context::GetCurrent();
+ if (!context.IsEmpty()) {
+ v8::Handle<v8::Object> globalPrototype = v8::Handle<v8::Object>::Cast(context->Global()->GetPrototype());
+ if (globalObjectPrototypeIsDOMWindow(globalPrototype))
+ proxy = V8Proxy::retrieve(V8DOMWindow::toNative(globalPrototype)->frame());
+ else
+ workerContext = V8WorkerContext::toNative(globalPrototype);
+ }
+ }
v8::Local<v8::Object> instance;
if (proxy)
// FIXME: Fix this to work properly with isolated worlds (see above).
instance = proxy->windowShell()->createWrapperFromCache(type);
- else
- instance = SafeAllocation::newInstance(V8ClassIndex::getTemplate(type)->GetFunction());
+ else {
+ v8::Local<v8::Function> function;
+ if (workerContext)
+ function = getConstructor(type, workerContext);
+ else
+ function = V8ClassIndex::getTemplate(type)->GetFunction();
+ instance = SafeAllocation::newInstance(function);
+ }
if (!instance.IsEmpty()) {
// Avoid setting the DOM wrapper for failed allocations.
setDOMWrapper(instance, V8ClassIndex::ToInt(type), impl);
diff --git a/WebCore/bindings/v8/V8DOMWrapper.h b/WebCore/bindings/v8/V8DOMWrapper.h
index d900466..8a3fa3f 100644
--- a/WebCore/bindings/v8/V8DOMWrapper.h
+++ b/WebCore/bindings/v8/V8DOMWrapper.h
@@ -194,7 +194,6 @@ namespace WebCore {
static void setHiddenWindowReference(Frame*, const int internalIndex, v8::Handle<v8::Object>);
static v8::Local<v8::Object> instantiateV8Object(V8Proxy* proxy, V8ClassIndex::V8WrapperType type, void* impl);
- static v8::Local<v8::Object> instantiateV8ObjectInWorkerContext(V8ClassIndex::V8WrapperType type, void* impl);
static v8::Handle<v8::Object> getWrapper(Node*);
};
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list