Diff
Modified: trunk/ChangeLog (95353 => 95354)
--- trunk/ChangeLog 2011-09-17 02:24:26 UTC (rev 95353)
+++ trunk/ChangeLog 2011-09-17 02:31:00 UTC (rev 95354)
@@ -1,3 +1,22 @@
+2011-09-16 Ulan Degenbaev <[email protected]>
+
+ [V8] REGRESSION(94783): calling the binding script during V8 context creation slows down page loads
+ https://bugs.webkit.org/show_bug.cgi?id=68237
+
+ Reviewed by Kenneth Russell.
+
+ Call the binding script lazily on the first run of the set() method of
+ a typed array.
+
+ * ../../Source/WebCore/WebCore.gypi:
+ * ../../Source/WebCore/bindings/v8/V8BindingScripts.cpp: Removed.
+ * ../../Source/WebCore/bindings/v8/V8BindingScripts.h: Removed.
+ * ../../Source/WebCore/bindings/v8/V8DOMWindowShell.cpp:
+ * ../../Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp:
+ * ../../Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.cpp:
+ * ../../Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h:
+ * ../../Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustomScript.js:
+
2011-09-16 Martin Robinson <[email protected]>
[GTK] Disable WebKit2 by default in configure.ac, but enable it with build-webkit
Modified: trunk/Source/WebCore/WebCore.gypi (95353 => 95354)
--- trunk/Source/WebCore/WebCore.gypi 2011-09-17 02:24:26 UTC (rev 95353)
+++ trunk/Source/WebCore/WebCore.gypi 2011-09-17 02:31:00 UTC (rev 95354)
@@ -2063,8 +2063,6 @@
'bindings/v8/V8AbstractEventListener.h',
'bindings/v8/V8Binding.cpp',
'bindings/v8/V8Binding.h',
- 'bindings/v8/V8BindingScripts.cpp',
- 'bindings/v8/V8BindingScripts.h',
'bindings/v8/V8Collection.cpp',
'bindings/v8/V8Collection.h',
'bindings/v8/V8DOMMap.cpp',
Deleted: trunk/Source/WebCore/bindings/v8/V8BindingScripts.cpp (95353 => 95354)
--- trunk/Source/WebCore/bindings/v8/V8BindingScripts.cpp 2011-09-17 02:24:26 UTC (rev 95353)
+++ trunk/Source/WebCore/bindings/v8/V8BindingScripts.cpp 2011-09-17 02:31:00 UTC (rev 95354)
@@ -1,43 +0,0 @@
-/*
- * 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "V8BindingScripts.h"
-
-#include "V8ArrayBufferViewCustomScript.h"
-#include "V8Binding.h"
-
-namespace WebCore {
-
-void V8BindingScripts::runScripts(v8::Handle<v8::Context> v8Context)
-{
- v8::Context::Scope contextScope(v8Context);
- String source(reinterpret_cast<const char*>(V8ArrayBufferViewCustomScript_js),
- sizeof(V8ArrayBufferViewCustomScript_js));
- v8::Handle<v8::Script> script = v8::Script::Compile(v8String(source));
- script->Run();
-}
-
-}
Deleted: trunk/Source/WebCore/bindings/v8/V8BindingScripts.h (95353 => 95354)
--- trunk/Source/WebCore/bindings/v8/V8BindingScripts.h 2011-09-17 02:24:26 UTC (rev 95353)
+++ trunk/Source/WebCore/bindings/v8/V8BindingScripts.h 2011-09-17 02:31:00 UTC (rev 95354)
@@ -1,42 +0,0 @@
-/*
- * 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 V8BindingScripts_h
-#define V8BindingScripts_h
-
-#include "v8.h"
-
-namespace WebCore {
-
-class V8BindingScripts {
-public:
- // Runs custom scripts that set up V8 bindings in global context.
- // Precondition: the specified V8 context is initialized and contains the
- // global object.
- static void runScripts(v8::Handle<v8::Context>);
-};
-
-}
-
-#endif
Modified: trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp (95353 => 95354)
--- trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp 2011-09-17 02:24:26 UTC (rev 95353)
+++ trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp 2011-09-17 02:31:00 UTC (rev 95354)
@@ -46,7 +46,6 @@
#include "SecurityOrigin.h"
#include "StorageNamespace.h"
#include "V8Binding.h"
-#include "V8BindingScripts.h"
#include "V8BindingState.h"
#include "V8Collection.h"
#include "V8DOMMap.h"
@@ -340,8 +339,6 @@
setSecurityToken();
- V8BindingScripts::runScripts(v8Context);
-
m_frame->loader()->client()->didCreateScriptContextForFrame();
// FIXME: This is wrong. We should actually do this for the proper world once
Modified: trunk/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp (95353 => 95354)
--- trunk/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp 2011-09-17 02:24:26 UTC (rev 95353)
+++ trunk/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp 2011-09-17 02:31:00 UTC (rev 95354)
@@ -41,7 +41,6 @@
#include "SharedWorker.h"
#include "SharedWorkerContext.h"
#include "V8Binding.h"
-#include "V8BindingScripts.h"
#include "V8DOMMap.h"
#include "V8DedicatedWorkerContext.h"
#include "V8Proxy.h"
@@ -176,8 +175,6 @@
v8::Handle<v8::Object> globalObject = v8::Handle<v8::Object>::Cast(m_context->Global()->GetPrototype());
globalObject->SetPrototype(jsWorkerContext);
- V8BindingScripts::runScripts(context);
-
return true;
}
Modified: trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.cpp (95353 => 95354)
--- trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.cpp 2011-09-17 02:24:26 UTC (rev 95353)
+++ trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.cpp 2011-09-17 02:31:00 UTC (rev 95354)
@@ -26,10 +26,39 @@
#include "config.h"
#include "V8ArrayBufferViewCustom.h"
+#include "V8ArrayBufferViewCustomScript.h"
#include <v8.h>
+
namespace WebCore {
+const char fastSetFlagName[] = "webgl::FastSetFlag";
+
+bool fastSetInstalled(v8::Handle<v8::Object> array)
+{
+ // Use a hidden flag in the common prototype (ArrayBufferView) of all typed
+ // arrays as an indicator of whether the fast 'set' is installed or not.
+ v8::Handle<v8::Object> prototype = array->GetPrototype().As<v8::Object>();
+ v8::Handle<v8::Object> arrayBufferView = prototype->GetPrototype().As<v8::Object>();
+ v8::Handle<v8::String> key = v8::String::New(fastSetFlagName);
+ v8::Handle<v8::Value> fastSetFlag = arrayBufferView->GetHiddenValue(key);
+ return !fastSetFlag.IsEmpty();
+}
+
+void installFastSet(v8::Handle<v8::Object> array)
+{
+ v8::Handle<v8::Object> prototype = array->GetPrototype().As<v8::Object>();
+ v8::Handle<v8::Object> arrayBufferView = prototype->GetPrototype().As<v8::Object>();
+ v8::Handle<v8::String> key = v8::String::New(fastSetFlagName);
+ arrayBufferView->SetHiddenValue(key, v8::Boolean::New(true));
+
+ String source(reinterpret_cast<const char*>(V8ArrayBufferViewCustomScript_js),
+ sizeof(V8ArrayBufferViewCustomScript_js));
+ v8::Handle<v8::Script> script = v8::Script::Compile(v8String(source));
+ script->Run();
+}
+
+
void copyElements(v8::Handle<v8::Object> destArray, v8::Handle<v8::Object> srcArray)
{
v8::Handle<v8::String> key = v8::String::New("set");
Modified: trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h (95353 => 95354)
--- trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h 2011-09-17 02:24:26 UTC (rev 95353)
+++ trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h 2011-09-17 02:31:00 UTC (rev 95354)
@@ -41,10 +41,19 @@
namespace WebCore {
+// Check if the _javascript_ 'set' method was already installed
+// on the prototype of the given typed array.
+bool fastSetInstalled(v8::Handle<v8::Object> array);
+
+// Install the _javascript_ 'set' method on the prototype of
+// the given typed array.
+void installFastSet(v8::Handle<v8::Object> array);
+
// Copy the elements from the source array to the typed destination array by
// invoking the 'set' method of the destination array in JS.
void copyElements(v8::Handle<v8::Object> destArray, v8::Handle<v8::Object> srcArray);
+
// Template function used by the ArrayBufferView*Constructor callbacks.
template<class ArrayClass, class ElementType>
v8::Handle<v8::Value> constructWebGLArrayWithArrayBufferArgument(const v8::Arguments& args, WrapperTypeInfo* type, v8::ExternalArrayType arrayType, bool hasIndexer)
@@ -198,10 +207,15 @@
|| offset + length < offset)
// Out of range offset or overflow
V8Proxy::setDOMException(INDEX_SIZE_ERR);
- else
- for (uint32_t i = 0; i < length; i++)
- impl->set(offset + i, array->Get(i)->NumberValue());
-
+ else {
+ if (!fastSetInstalled(args.Holder())) {
+ installFastSet(args.Holder());
+ copyElements(args.Holder(), array);
+ } else {
+ for (uint32_t i = 0; i < length; i++)
+ impl->set(offset + i, array->Get(i)->NumberValue());
+ }
+ }
return v8::Undefined();
}
Modified: trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustomScript.js (95353 => 95354)
--- trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustomScript.js 2011-09-17 02:24:26 UTC (rev 95353)
+++ trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustomScript.js 2011-09-17 02:31:00 UTC (rev 95354)
@@ -41,6 +41,7 @@
} else
return nativeSet.call(this, source, offset);
}
+ f.name = "set";
return f;
})();
};