Diff
Modified: trunk/Source/WebCore/ChangeLog (126221 => 126222)
--- trunk/Source/WebCore/ChangeLog 2012-08-21 23:48:02 UTC (rev 126221)
+++ trunk/Source/WebCore/ChangeLog 2012-08-21 23:51:39 UTC (rev 126222)
@@ -1,5 +1,44 @@
2012-08-21 Kentaro Hara <[email protected]>
+ [V8] Move compileScript() from V8Proxy to ScriptSourceCode
+ https://bugs.webkit.org/show_bug.cgi?id=94561
+
+ Reviewed by Adam Barth.
+
+ To kill V8Proxy, this patch moves compileScript() from V8Proxy
+ to ScriptSourceCode. This patch also removes fromWebCoreString().
+
+ No tests. No change in behavior.
+
+ * UseV8.cmake:
+ * WebCore.gypi:
+ * bindings/v8/ScriptController.h:
+ (ScriptController):
+ * bindings/v8/ScriptSourceCode.cpp: Added.
+ (WebCore):
+ (WebCore::ScriptSourceCode::compileScript):
+ * bindings/v8/ScriptSourceCode.h:
+ (ScriptSourceCode):
+ * bindings/v8/V8Binding.h:
+ * bindings/v8/V8LazyEventListener.cpp:
+ (WebCore::V8LazyEventListener::prepareListenerObject):
+ * bindings/v8/V8Proxy.cpp:
+ (WebCore::V8Proxy::evaluate):
+ * bindings/v8/V8Proxy.h:
+ (V8Proxy):
+ * bindings/v8/WorkerContextExecutionProxy.cpp:
+ (WebCore::WorkerContextExecutionProxy::evaluate):
+ (WebCore::WorkerContextExecutionProxy::runScript):
+ * bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
+ (WebCore::V8InjectedScriptHost::getEventListenersCallback):
+ * bindings/v8/custom/V8MessageEventCustom.cpp:
+ (WebCore::V8MessageEvent::dataAccessorGetter):
+ * bindings/v8/custom/V8WebGLRenderingContextCustom.cpp:
+ (WebCore::toV8Object):
+ (WebCore::V8WebGLRenderingContext::getSupportedExtensionsCallback):
+
+2012-08-21 Kentaro Hara <[email protected]>
+
[V8] Move toV8Context() from V8Proxy to V8Binding
https://bugs.webkit.org/show_bug.cgi?id=94597
Modified: trunk/Source/WebCore/UseV8.cmake (126221 => 126222)
--- trunk/Source/WebCore/UseV8.cmake 2012-08-21 23:48:02 UTC (rev 126221)
+++ trunk/Source/WebCore/UseV8.cmake 2012-08-21 23:51:39 UTC (rev 126222)
@@ -40,6 +40,7 @@
bindings/v8/ScriptInstance.cpp
bindings/v8/ScriptObject.cpp
bindings/v8/ScriptScope.cpp
+ bindings/v8/ScriptSourceCode.cpp
bindings/v8/ScriptState.cpp
bindings/v8/ScriptValue.cpp
bindings/v8/SerializedScriptValue.cpp
Modified: trunk/Source/WebCore/WebCore.gypi (126221 => 126222)
--- trunk/Source/WebCore/WebCore.gypi 2012-08-21 23:48:02 UTC (rev 126221)
+++ trunk/Source/WebCore/WebCore.gypi 2012-08-21 23:51:39 UTC (rev 126222)
@@ -2230,6 +2230,7 @@
'bindings/v8/ScriptProfiler.h',
'bindings/v8/ScriptScope.cpp',
'bindings/v8/ScriptScope.h',
+ 'bindings/v8/ScriptSourceCode.cpp',
'bindings/v8/ScriptSourceCode.h',
'bindings/v8/ScriptState.cpp',
'bindings/v8/ScriptState.h',
Modified: trunk/Source/WebCore/bindings/v8/ScriptController.h (126221 => 126222)
--- trunk/Source/WebCore/bindings/v8/ScriptController.h 2012-08-21 23:48:02 UTC (rev 126221)
+++ trunk/Source/WebCore/bindings/v8/ScriptController.h 2012-08-21 23:51:39 UTC (rev 126222)
@@ -89,8 +89,6 @@
static void initializeThreading();
// Evaluate a script file in the environment of this proxy.
- // If succeeded, 'succ' is set to true and result is returned
- // as a string.
ScriptValue evaluate(const ScriptSourceCode&);
// Evaluate _javascript_ in a new isolated world. The script gets its own
Added: trunk/Source/WebCore/bindings/v8/ScriptSourceCode.cpp (0 => 126222)
--- trunk/Source/WebCore/bindings/v8/ScriptSourceCode.cpp (rev 0)
+++ trunk/Source/WebCore/bindings/v8/ScriptSourceCode.cpp 2012-08-21 23:51:39 UTC (rev 126222)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2009 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 "ScriptSourceCode.h"
+
+#include "V8Binding.h"
+
+namespace WebCore {
+
+v8::Handle<v8::Script> ScriptSourceCode::compileScript(v8::Handle<v8::String> code, const String& fileName, const TextPosition& scriptStartPosition, v8::ScriptData* scriptData)
+{
+ v8::Handle<v8::String> name = v8String(fileName);
+ v8::Handle<v8::Integer> line = v8Integer(scriptStartPosition.m_line.zeroBasedInt());
+ v8::Handle<v8::Integer> column = v8Integer(scriptStartPosition.m_column.zeroBasedInt());
+ v8::ScriptOrigin origin(name, line, column);
+ v8::Handle<v8::Script> script = v8::Script::Compile(code, &origin, scriptData);
+ return script;
+}
+
+} // namespace WebCore
Modified: trunk/Source/WebCore/bindings/v8/ScriptSourceCode.h (126221 => 126222)
--- trunk/Source/WebCore/bindings/v8/ScriptSourceCode.h 2012-08-21 23:48:02 UTC (rev 126221)
+++ trunk/Source/WebCore/bindings/v8/ScriptSourceCode.h 2012-08-21 23:51:39 UTC (rev 126222)
@@ -35,6 +35,7 @@
#include "CachedScript.h"
#include "KURL.h"
#include "PlatformString.h"
+#include <v8.h>
#include <wtf/text/TextPosition.h>
namespace WebCore {
@@ -72,6 +73,8 @@
int startLine() const { return m_startPosition.m_line.oneBasedInt(); }
const TextPosition& startPosition() const { return m_startPosition; }
+ static v8::Handle<v8::Script> compileScript(v8::Handle<v8::String>, const String&, const TextPosition&, v8::ScriptData* = 0);
+
private:
String m_source;
CachedResourceHandle<CachedScript> m_cachedScript;
Modified: trunk/Source/WebCore/bindings/v8/V8Binding.h (126221 => 126222)
--- trunk/Source/WebCore/bindings/v8/V8Binding.h 2012-08-21 23:48:02 UTC (rev 126221)
+++ trunk/Source/WebCore/bindings/v8/V8Binding.h 2012-08-21 23:51:39 UTC (rev 126222)
@@ -282,13 +282,6 @@
return static_cast<long long>(value->IntegerValue());
}
- // The string returned by this function is still owned by the argument
- // and will be deallocated when the argument is deallocated.
- inline const uint16_t* fromWebCoreString(const String& str)
- {
- return reinterpret_cast<const uint16_t*>(str.characters());
- }
-
inline bool isUndefinedOrNull(v8::Handle<v8::Value> value)
{
return value->IsNull() || value->IsUndefined();
Modified: trunk/Source/WebCore/bindings/v8/V8LazyEventListener.cpp (126221 => 126222)
--- trunk/Source/WebCore/bindings/v8/V8LazyEventListener.cpp 2012-08-21 23:48:02 UTC (rev 126221)
+++ trunk/Source/WebCore/bindings/v8/V8LazyEventListener.cpp 2012-08-21 23:51:39 UTC (rev 126222)
@@ -158,7 +158,7 @@
code.append("\n};}}}})");
v8::Handle<v8::String> codeExternalString = v8ExternalString(code);
- v8::Handle<v8::Script> script = V8Proxy::compileScript(codeExternalString, m_sourceURL, m_position);
+ v8::Handle<v8::Script> script = ScriptSourceCode::compileScript(codeExternalString, m_sourceURL, m_position);
if (script.IsEmpty())
return;
@@ -231,7 +231,7 @@
wrappedFunction->Set(v8::String::NewSymbol("toString"), toStringFunction);
}
- wrappedFunction->SetName(v8::String::New(fromWebCoreString(m_functionName), m_functionName.length()));
+ wrappedFunction->SetName(v8String(m_functionName));
// FIXME: Remove the following comment-outs.
// See https://bugs.webkit.org/show_bug.cgi?id=85152 for more details.
Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.cpp (126221 => 126222)
--- trunk/Source/WebCore/bindings/v8/V8Proxy.cpp 2012-08-21 23:48:02 UTC (rev 126221)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.cpp 2012-08-21 23:51:39 UTC (rev 126222)
@@ -121,17 +121,6 @@
windowShell()->destroyGlobal();
}
-v8::Handle<v8::Script> V8Proxy::compileScript(v8::Handle<v8::String> code, const String& fileName, const TextPosition& scriptStartPosition, v8::ScriptData* scriptData)
-{
- const uint16_t* fileNameString = fromWebCoreString(fileName);
- v8::Handle<v8::String> name = v8::String::New(fileNameString, fileName.length());
- v8::Handle<v8::Integer> line = v8Integer(scriptStartPosition.m_line.zeroBasedInt());
- v8::Handle<v8::Integer> column = v8Integer(scriptStartPosition.m_column.zeroBasedInt());
- v8::ScriptOrigin origin(name, line, column);
- v8::Handle<v8::Script> script = v8::Script::Compile(code, &origin, scriptData);
- return script;
-}
-
PassOwnPtr<v8::ScriptData> V8Proxy::precompileScript(v8::Handle<v8::String> code, CachedScript* cachedScript)
{
// A pseudo-randomly chosen ID used to store and retrieve V8 ScriptData from
@@ -180,7 +169,7 @@
// NOTE: For compatibility with WebCore, ScriptSourceCode's line starts at
// 1, whereas v8 starts at 0.
- v8::Handle<v8::Script> script = compileScript(code, source.url(), source.startPosition(), scriptData.get());
+ v8::Handle<v8::Script> script = ScriptSourceCode::compileScript(code, source.url(), source.startPosition(), scriptData.get());
#if PLATFORM(CHROMIUM)
TRACE_EVENT_END0("v8", "v8.compile");
TRACE_EVENT0("v8", "v8.run");
Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.h (126221 => 126222)
--- trunk/Source/WebCore/bindings/v8/V8Proxy.h 2012-08-21 23:48:02 UTC (rev 126221)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.h 2012-08-21 23:51:39 UTC (rev 126222)
@@ -97,15 +97,10 @@
// Run an already compiled script.
v8::Local<v8::Value> runScript(v8::Handle<v8::Script>);
- // Call the function as constructor with the given arguments.
- v8::Local<v8::Value> newInstance(v8::Handle<v8::Function>, int argc, v8::Handle<v8::Value> argv[]);
-
// Returns V8 Context of a frame. If none exists, creates
// a new context. It is potentially slow and consumes memory.
static v8::Local<v8::Context> context(Frame*);
- static v8::Handle<v8::Script> compileScript(v8::Handle<v8::String> code, const String& fileName, const TextPosition& scriptStartPosition, v8::ScriptData* = 0);
-
v8::Local<v8::Context> context();
v8::Local<v8::Context> isolatedWorldContext(int worldId);
bool matchesCurrentContext();
Modified: trunk/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp (126221 => 126222)
--- trunk/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp 2012-08-21 23:48:02 UTC (rev 126221)
+++ trunk/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp 2012-08-21 23:51:39 UTC (rev 126222)
@@ -38,6 +38,7 @@
#include "DedicatedWorkerContext.h"
#include "Event.h"
#include "ScriptCallStack.h"
+#include "ScriptSourceCode.h"
#include "SharedWorker.h"
#include "SharedWorkerContext.h"
#include "V8Binding.h"
@@ -46,7 +47,6 @@
#include "V8DedicatedWorkerContext.h"
#include "V8ObjectConstructor.h"
#include "V8PerContextData.h"
-#include "V8Proxy.h"
#include "V8RecursionScope.h"
#include "V8SharedWorkerContext.h"
#include "Worker.h"
@@ -213,7 +213,7 @@
v8::TryCatch exceptionCatcher;
v8::Local<v8::String> scriptString = v8ExternalString(script);
- v8::Handle<v8::Script> compiledScript = V8Proxy::compileScript(scriptString, fileName, scriptStartPosition);
+ v8::Handle<v8::Script> compiledScript = ScriptSourceCode::compileScript(scriptString, fileName, scriptStartPosition);
v8::Local<v8::Value> result = runScript(compiledScript);
if (!exceptionCatcher.CanContinue()) {
@@ -250,7 +250,7 @@
// Compute the source string and prevent against infinite recursion.
if (V8RecursionScope::recursionLevel() >= kMaxRecursionDepth) {
v8::Local<v8::String> code = v8ExternalString("throw RangeError('Recursion too deep')");
- script = V8Proxy::compileScript(code, "", TextPosition::minimumPosition());
+ script = ScriptSourceCode::compileScript(code, "", TextPosition::minimumPosition());
}
if (handleOutOfMemory())
Modified: trunk/Source/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp (126221 => 126222)
--- trunk/Source/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp 2012-08-21 23:48:02 UTC (rev 126221)
+++ trunk/Source/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp 2012-08-21 23:51:39 UTC (rev 126222)
@@ -253,7 +253,7 @@
if (!listeners->Length())
continue;
AtomicString eventType = listenersArray[i].eventType;
- result->Set(v8::String::New(fromWebCoreString(eventType), eventType.length()), listeners);
+ result->Set(v8String(eventType), listeners);
}
return result;
Modified: trunk/Source/WebCore/bindings/v8/custom/V8MessageEventCustom.cpp (126221 => 126222)
--- trunk/Source/WebCore/bindings/v8/custom/V8MessageEventCustom.cpp 2012-08-21 23:48:02 UTC (rev 126221)
+++ trunk/Source/WebCore/bindings/v8/custom/V8MessageEventCustom.cpp 2012-08-21 23:51:39 UTC (rev 126222)
@@ -68,7 +68,7 @@
case MessageEvent::DataTypeString: {
String stringValue = event->dataAsString();
- result = v8::String::New(fromWebCoreString(stringValue), stringValue.length());
+ result = v8String(stringValue);
break;
}
Modified: trunk/Source/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp (126221 => 126222)
--- trunk/Source/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp 2012-08-21 23:48:02 UTC (rev 126221)
+++ trunk/Source/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp 2012-08-21 23:51:39 UTC (rev 126222)
@@ -134,7 +134,7 @@
case WebGLGetInfo::kTypeNull:
return v8::Null(isolate);
case WebGLGetInfo::kTypeString:
- return v8::String::New(fromWebCoreString(info.getString()), info.getString().length());
+ return v8String(info.getString());
case WebGLGetInfo::kTypeUnsignedInt:
return v8UnsignedInteger(info.getUnsignedInt(), isolate);
case WebGLGetInfo::kTypeWebGLBuffer:
@@ -397,7 +397,7 @@
Vector<String> value = imp->getSupportedExtensions();
v8::Local<v8::Array> array = v8::Array::New(value.size());
for (size_t ii = 0; ii < value.size(); ++ii)
- array->Set(v8Integer(ii, args.GetIsolate()), v8::String::New(fromWebCoreString(value[ii]), value[ii].length()));
+ array->Set(v8Integer(ii, args.GetIsolate()), v8String(value[ii]));
return array;
}