Title: [129026] trunk/Source/WebCore
Revision
129026
Author
[email protected]
Date
2012-09-19 11:52:18 -0700 (Wed, 19 Sep 2012)

Log Message

[V8] Remove WorkerContextExecutionProxy::runScript()
https://bugs.webkit.org/show_bug.cgi?id=97060

Reviewed by Adam Barth.

To kill WorkerContextExecutionProxy, this patch removes
WorkerContextExecutionProxy::runScript() by replacing it
with ScriptRunner::runCompiledScript().

For the replacement, this patch moves TryCatch logic in
runCompiledScript() to the caller side. The reason why
we have to avoid nesting TryCatches is a V8 bug:
http://code.google.com/p/v8/issues/detail?id=2166

No tests. No change in behavior.

* bindings/v8/ScriptController.cpp:
(WebCore::ScriptController::compileAndRunScript):
* bindings/v8/ScriptRunner.cpp:
(WebCore::ScriptRunner::runCompiledScript):
* bindings/v8/WorkerContextExecutionProxy.cpp:
(WebCore::WorkerContextExecutionProxy::evaluate):
* bindings/v8/WorkerContextExecutionProxy.h:
(WorkerContextExecutionProxy):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (129025 => 129026)


--- trunk/Source/WebCore/ChangeLog	2012-09-19 18:04:16 UTC (rev 129025)
+++ trunk/Source/WebCore/ChangeLog	2012-09-19 18:52:18 UTC (rev 129026)
@@ -1,3 +1,30 @@
+2012-09-19  Kentaro Hara  <[email protected]>
+
+        [V8] Remove WorkerContextExecutionProxy::runScript()
+        https://bugs.webkit.org/show_bug.cgi?id=97060
+
+        Reviewed by Adam Barth.
+
+        To kill WorkerContextExecutionProxy, this patch removes
+        WorkerContextExecutionProxy::runScript() by replacing it
+        with ScriptRunner::runCompiledScript().
+
+        For the replacement, this patch moves TryCatch logic in
+        runCompiledScript() to the caller side. The reason why
+        we have to avoid nesting TryCatches is a V8 bug:
+        http://code.google.com/p/v8/issues/detail?id=2166
+
+        No tests. No change in behavior.
+
+        * bindings/v8/ScriptController.cpp:
+        (WebCore::ScriptController::compileAndRunScript):
+        * bindings/v8/ScriptRunner.cpp:
+        (WebCore::ScriptRunner::runCompiledScript):
+        * bindings/v8/WorkerContextExecutionProxy.cpp:
+        (WebCore::WorkerContextExecutionProxy::evaluate):
+        * bindings/v8/WorkerContextExecutionProxy.h:
+        (WorkerContextExecutionProxy):
+
 2012-09-19  Rob Buis  <[email protected]>
 
         [BlackBerry] Remove custom painting code for searchCancel

Modified: trunk/Source/WebCore/bindings/v8/ScriptController.cpp (129025 => 129026)


--- trunk/Source/WebCore/bindings/v8/ScriptController.cpp	2012-09-19 18:04:16 UTC (rev 129025)
+++ trunk/Source/WebCore/bindings/v8/ScriptController.cpp	2012-09-19 18:52:18 UTC (rev 129026)
@@ -281,6 +281,7 @@
         // Keep Frame (and therefore ScriptController) alive.
         RefPtr<Frame> protect(m_frame);
         result = ScriptRunner::runCompiledScript(script, m_frame->document());
+        ASSERT(!tryCatch.HasCaught() || result.IsEmpty());
     }
 
     InspectorInstrumentation::didEvaluateScript(cookie);

Modified: trunk/Source/WebCore/bindings/v8/ScriptRunner.cpp (129025 => 129026)


--- trunk/Source/WebCore/bindings/v8/ScriptRunner.cpp	2012-09-19 18:04:16 UTC (rev 129025)
+++ trunk/Source/WebCore/bindings/v8/ScriptRunner.cpp	2012-09-19 18:52:18 UTC (rev 129026)
@@ -47,8 +47,6 @@
 
     // Run the script and keep track of the current recursion depth.
     v8::Local<v8::Value> result;
-    v8::TryCatch tryCatch;
-    tryCatch.SetVerbose(true);
     {
         V8RecursionScope recursionScope(context);
         result = script->Run();
@@ -57,12 +55,6 @@
     if (handleOutOfMemory())
         ASSERT(result.IsEmpty());
 
-    // Handle V8 internal error situation.
-    if (tryCatch.HasCaught()) {
-        ASSERT(result.IsEmpty());
-        return v8::Local<v8::Value>();
-    }
-
     if (result.IsEmpty())
         return v8::Local<v8::Value>();
 

Modified: trunk/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp (129025 => 129026)


--- trunk/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp	2012-09-19 18:04:16 UTC (rev 129025)
+++ trunk/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp	2012-09-19 18:52:18 UTC (rev 129026)
@@ -38,6 +38,7 @@
 #include "DedicatedWorkerContext.h"
 #include "Event.h"
 #include "ScriptCallStack.h"
+#include "ScriptRunner.h"
 #include "ScriptSourceCode.h"
 #include "SharedWorker.h"
 #include "SharedWorkerContext.h"
@@ -223,7 +224,7 @@
 
     v8::Local<v8::String> scriptString = v8ExternalString(script);
     v8::Handle<v8::Script> compiledScript = ScriptSourceCode::compileScript(scriptString, fileName, scriptStartPosition);
-    v8::Local<v8::Value> result = runScript(compiledScript);
+    v8::Local<v8::Value> result = ScriptRunner::runCompiledScript(compiledScript, m_workerContext);
 
     if (!exceptionCatcher.CanContinue()) {
         m_workerContext->script()->forbidExecution();
@@ -256,37 +257,6 @@
     m_disableEvalPending = !enable;
 }
 
-v8::Local<v8::Value> WorkerContextExecutionProxy::runScript(v8::Handle<v8::Script> script)
-{
-    if (script.IsEmpty())
-        return v8::Local<v8::Value>();
-
-    // 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 = ScriptSourceCode::compileScript(code, "", TextPosition::minimumPosition());
-    }
-
-    if (handleOutOfMemory())
-        ASSERT(script.IsEmpty());
-
-    if (script.IsEmpty())
-        return v8::Local<v8::Value>();
-
-    // Run the script and keep track of the current recursion depth.
-    v8::Local<v8::Value> result;
-    {
-        V8RecursionScope recursionScope(m_workerContext);
-        result = script->Run();
-    }
-
-    // Handle V8 internal error situation (Out-of-memory).
-    if (result.IsEmpty())
-        return v8::Local<v8::Value>();
-
-    return result;
-}
-
 void WorkerContextExecutionProxy::trackEvent(Event* event)
 {
     m_events.append(event);

Modified: trunk/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.h (129025 => 129026)


--- trunk/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.h	2012-09-19 18:04:16 UTC (rev 129025)
+++ trunk/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.h	2012-09-19 18:52:18 UTC (rev 129026)
@@ -82,9 +82,6 @@
         bool initializeIfNeeded();
         void dispose();
 
-        // Run an already compiled script.
-        v8::Local<v8::Value> runScript(v8::Handle<v8::Script>);
-
         static bool forgetV8EventObject(Event*);
 
         static const int kWorkerMaxStackSize = 500 * 1024;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to