Title: [140521] trunk/Source/WebCore
Revision
140521
Author
[email protected]
Date
2013-01-23 00:45:31 -0800 (Wed, 23 Jan 2013)

Log Message

[V8] Remove if(isolate) checks from v8String() and v8Integer()
https://bugs.webkit.org/show_bug.cgi?id=107540

Reviewed by Adam Barth.

Now there is no optional Isolate parameter in the code base
(except for throwError()). We can safely remove if(isolate) checks
from v8String() and v8Integer().

div.id:       17.8 ns => 17.8 ns (no performance change)
div.nodeType:  9.7 ns =>  8.9 ns (+8.9% performance improvement)

No tests. No change in behavior.

* bindings/v8/ScriptDebugServer.cpp:
(WebCore::ScriptDebugServer::handleV8DebugEvent):
* bindings/v8/V8Binding.h:
(WebCore::v8String):
(WebCore::v8Integer):
* bindings/v8/V8WindowErrorHandler.cpp:
(WebCore::V8WindowErrorHandler::callListenerFunction):
* bindings/v8/V8WorkerContextErrorHandler.cpp:
(WebCore::V8WorkerContextErrorHandler::callListenerFunction):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (140520 => 140521)


--- trunk/Source/WebCore/ChangeLog	2013-01-23 08:37:56 UTC (rev 140520)
+++ trunk/Source/WebCore/ChangeLog	2013-01-23 08:45:31 UTC (rev 140521)
@@ -1,3 +1,29 @@
+2013-01-23  Kentaro Hara  <[email protected]>
+
+        [V8] Remove if(isolate) checks from v8String() and v8Integer()
+        https://bugs.webkit.org/show_bug.cgi?id=107540
+
+        Reviewed by Adam Barth.
+
+        Now there is no optional Isolate parameter in the code base
+        (except for throwError()). We can safely remove if(isolate) checks
+        from v8String() and v8Integer().
+
+        div.id:       17.8 ns => 17.8 ns (no performance change)
+        div.nodeType:  9.7 ns =>  8.9 ns (+8.9% performance improvement)
+
+        No tests. No change in behavior.
+
+        * bindings/v8/ScriptDebugServer.cpp:
+        (WebCore::ScriptDebugServer::handleV8DebugEvent):
+        * bindings/v8/V8Binding.h:
+        (WebCore::v8String):
+        (WebCore::v8Integer):
+        * bindings/v8/V8WindowErrorHandler.cpp:
+        (WebCore::V8WindowErrorHandler::callListenerFunction):
+        * bindings/v8/V8WorkerContextErrorHandler.cpp:
+        (WebCore::V8WorkerContextErrorHandler::callListenerFunction):
+
 2013-01-23  Hajime Morrita  <[email protected]>
 
         Invalidated SVG shadow tree should be always detached.

Modified: trunk/Source/WebCore/bindings/v8/ScriptDebugServer.cpp (140520 => 140521)


--- trunk/Source/WebCore/bindings/v8/ScriptDebugServer.cpp	2013-01-23 08:37:56 UTC (rev 140520)
+++ trunk/Source/WebCore/bindings/v8/ScriptDebugServer.cpp	2013-01-23 08:45:31 UTC (rev 140521)
@@ -464,7 +464,8 @@
                 return;
 
             OwnPtr<ScriptPreprocessor> preprocessor(m_scriptPreprocessor.release());
-            v8::Context::Scope contextScope(v8::Debug::GetDebugContext());
+            v8::Local<v8::Context> debugContext = v8::Debug::GetDebugContext();
+            v8::Context::Scope contextScope(debugContext);
             v8::Handle<v8::Function> getScriptSourceFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("getScriptSource")));
             v8::Handle<v8::Value> argv[] = { eventDetails.GetEventData() };
             v8::Handle<v8::Value> script = getScriptSourceFunction->Call(m_debuggerScript.get(), 1, argv);
@@ -476,7 +477,7 @@
             v8::Handle<v8::Function> setScriptSourceFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("setScriptSource")));
             String patchedScript = preprocessor->preprocessSourceCode(toWebCoreStringWithUndefinedOrNullCheck(script), toWebCoreStringWithUndefinedOrNullCheck(scriptName));
 
-            v8::Handle<v8::Value> argv2[] = { eventDetails.GetEventData(), v8String(patchedScript) };
+            v8::Handle<v8::Value> argv2[] = { eventDetails.GetEventData(), v8String(patchedScript, debugContext->GetIsolate()) };
             setScriptSourceFunction->Call(m_debuggerScript.get(), 2, argv2);
             m_scriptPreprocessor = preprocessor.release();
         } else if (event == v8::AfterCompile) {

Modified: trunk/Source/WebCore/bindings/v8/V8Binding.h (140520 => 140521)


--- trunk/Source/WebCore/bindings/v8/V8Binding.h	2013-01-23 08:37:56 UTC (rev 140520)
+++ trunk/Source/WebCore/bindings/v8/V8Binding.h	2013-01-23 08:45:31 UTC (rev 140521)
@@ -145,10 +145,8 @@
     // Return a V8 external string that shares the underlying buffer with the given
     // WebCore string. The reference counting mechanism is used to keep the
     // underlying buffer alive while the string is still live in the V8 engine.
-    inline v8::Handle<v8::String> v8String(const String& string, v8::Isolate* isolate = 0, ReturnHandleType handleType = ReturnLocalHandle)
+    inline v8::Handle<v8::String> v8String(const String& string, v8::Isolate* isolate, ReturnHandleType handleType = ReturnLocalHandle)
     {
-        if (UNLIKELY(!isolate))
-            isolate = v8::Isolate::GetCurrent();
         if (string.isNull())
             return v8::String::Empty(isolate);
         return V8PerIsolateData::from(isolate)->stringCache()->v8ExternalString(string.impl(), handleType, isolate);
@@ -176,10 +174,8 @@
         return V8PerIsolateData::from(isolate)->stringCache()->v8ExternalString(string.impl(), handleType, isolate);
     }
 
-    inline v8::Handle<v8::Integer> v8Integer(int value, v8::Isolate* isolate = 0)
+    inline v8::Handle<v8::Integer> v8Integer(int value, v8::Isolate* isolate)
     {
-        if (UNLIKELY(!isolate))
-            isolate = v8::Isolate::GetCurrent();
         return V8PerIsolateData::from(isolate)->integerCache()->v8Integer(value, isolate);
     }
 

Modified: trunk/Source/WebCore/bindings/v8/V8WindowErrorHandler.cpp (140520 => 140521)


--- trunk/Source/WebCore/bindings/v8/V8WindowErrorHandler.cpp	2013-01-23 08:37:56 UTC (rev 140520)
+++ trunk/Source/WebCore/bindings/v8/V8WindowErrorHandler.cpp	2013-01-23 08:45:31 UTC (rev 140521)
@@ -51,11 +51,12 @@
 
     ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event);
     v8::Local<v8::Object> listener = getListenerObject(context);
+    v8::Isolate* isolate = toV8Context(context, worldContext())->GetIsolate();
     v8::Local<v8::Value> returnValue;
     if (!listener.IsEmpty() && listener->IsFunction()) {
         v8::Local<v8::Function> callFunction = v8::Local<v8::Function>::Cast(listener);
         v8::Local<v8::Object> thisValue = v8::Context::GetCurrent()->Global();
-        v8::Handle<v8::Value> parameters[3] = { v8String(errorEvent->message()), deprecatedV8String(errorEvent->filename()), deprecatedV8Integer(errorEvent->lineno()) };
+        v8::Handle<v8::Value> parameters[3] = { v8String(errorEvent->message(), isolate), v8String(errorEvent->filename(), isolate), v8Integer(errorEvent->lineno(), isolate) };
         v8::TryCatch tryCatch;
         tryCatch.SetVerbose(true);
         returnValue = ScriptController::callFunctionWithInstrumentation(0, callFunction, thisValue, 3, parameters);

Modified: trunk/Source/WebCore/bindings/v8/V8WorkerContextErrorHandler.cpp (140520 => 140521)


--- trunk/Source/WebCore/bindings/v8/V8WorkerContextErrorHandler.cpp	2013-01-23 08:37:56 UTC (rev 140520)
+++ trunk/Source/WebCore/bindings/v8/V8WorkerContextErrorHandler.cpp	2013-01-23 08:45:31 UTC (rev 140521)
@@ -50,12 +50,13 @@
 {
     ASSERT(event->hasInterface(eventNames().interfaceForErrorEvent));
     v8::Local<v8::Object> listener = getListenerObject(context);
+    v8::Isolate* isolate = toV8Context(context, worldContext())->GetIsolate();
     v8::Local<v8::Value> returnValue;
     if (!listener.IsEmpty() && listener->IsFunction()) {
         ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event);
         v8::Local<v8::Function> callFunction = v8::Local<v8::Function>::Cast(listener);
         v8::Local<v8::Object> thisValue = v8::Context::GetCurrent()->Global();
-        v8::Handle<v8::Value> parameters[3] = { v8String(errorEvent->message()), deprecatedV8String(errorEvent->filename()), deprecatedV8Integer(errorEvent->lineno()) };
+        v8::Handle<v8::Value> parameters[3] = { v8String(errorEvent->message(), isolate), v8String(errorEvent->filename(), isolate), v8Integer(errorEvent->lineno(), isolate) };
         V8RecursionScope recursionScope(context);
         returnValue = callFunction->Call(thisValue, 3, parameters);
     }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to