[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

barraclough at apple.com barraclough at apple.com
Wed Apr 7 23:54:46 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 9fec6640a0a67e693cfbed8d8f3f546fcdb37736
Author: barraclough at apple.com <barraclough at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Nov 24 00:54:27 2009 +0000

    Part 1/3 of <rdar://problem/7377477> REGRESSION: Many web pages fail to render after interesting script runs in isolated world
    
    Reviewed by Geoff Garen.
    
    Some clients of the JavaScriptCore API expect to be able to make callbacks over the JSC API,
    and for this to automagically cause execution to take place in the world associated with the
    global object associated with the ExecState (JSContextRef) passed.  However this is not how
    things work - the world must be explicitly set within WebCore.
    
    Making this work just for API calls to evaluate & call will be a far from perfect solution,
    since direct (non-API) use of JSC still relies on WebCore setting the current world correctly.
    A better solution would be to make this all work automagically all throughout WebCore, but this
    will require more refactoring.
    
    Since the API is in JSC but worlds only exist in WebCore, add callbacks on the JSGlobalData::ClientData
    to allow it to update the current world on entry/exit via the JSC API.  This is temporary duck
    tape, and should be removed once the current world no longer needs to be explicitly tracked.
    
    * API/JSBase.cpp:
    (JSEvaluateScript):
    * API/JSObjectRef.cpp:
    (JSObjectCallAsFunction):
    * JavaScriptCore.exp:
    * runtime/JSGlobalData.cpp:
    (JSC::JSGlobalData::ClientData::beginningExecution):
    (JSC::JSGlobalData::ClientData::completedExecution):
    * runtime/JSGlobalData.h:
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51329 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/API/JSBase.cpp b/JavaScriptCore/API/JSBase.cpp
index 4a32d35..8678238 100644
--- a/JavaScriptCore/API/JSBase.cpp
+++ b/JavaScriptCore/API/JSBase.cpp
@@ -46,6 +46,8 @@ JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef th
     exec->globalData().heap.registerThread();
     JSLock lock(exec);
 
+    exec->globalData().clientData->willExecute(exec);
+
     JSObject* jsThisObject = toJS(thisObject);
 
     // evaluate sets "this" to the global object if it is NULL
@@ -53,17 +55,17 @@ JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef th
     SourceCode source = makeSource(script->ustring(), sourceURL->ustring(), startingLineNumber);
     Completion completion = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), source, jsThisObject);
 
+    JSValueRef result = 0;
     if (completion.complType() == Throw) {
         if (exception)
             *exception = toRef(exec, completion.value());
-        return 0;
-    }
+    } else if (completion.value())
+        result = toRef(exec, completion.value());
+    else // happens, for example, when the only statement is an empty (';') statement
+        result = toRef(exec, jsUndefined());
 
-    if (completion.value())
-        return toRef(exec, completion.value());
-    
-    // happens, for example, when the only statement is an empty (';') statement
-    return toRef(exec, jsUndefined());
+    exec->globalData().clientData->didExecute(exec);
+    return result;
 }
 
 bool JSCheckScriptSyntax(JSContextRef ctx, JSStringRef script, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
diff --git a/JavaScriptCore/API/JSObjectRef.cpp b/JavaScriptCore/API/JSObjectRef.cpp
index 06ef578..36e8c19 100644
--- a/JavaScriptCore/API/JSObjectRef.cpp
+++ b/JavaScriptCore/API/JSObjectRef.cpp
@@ -392,6 +392,8 @@ JSValueRef JSObjectCallAsFunction(JSContextRef ctx, JSObjectRef object, JSObject
     exec->globalData().heap.registerThread();
     JSLock lock(exec);
 
+    exec->globalData().clientData->willExecute(exec);
+
     JSObject* jsObject = toJS(object);
     JSObject* jsThisObject = toJS(thisObject);
 
@@ -402,18 +404,21 @@ JSValueRef JSObjectCallAsFunction(JSContextRef ctx, JSObjectRef object, JSObject
     for (size_t i = 0; i < argumentCount; i++)
         argList.append(toJS(exec, arguments[i]));
 
+    JSValueRef result = 0;
+
     CallData callData;
     CallType callType = jsObject->getCallData(callData);
-    if (callType == CallTypeNone)
-        return 0;
-
-    JSValueRef result = toRef(exec, call(exec, jsObject, callType, callData, jsThisObject, argList));
-    if (exec->hadException()) {
-        if (exception)
-            *exception = toRef(exec, exec->exception());
-        exec->clearException();
-        result = 0;
+    if (callType != CallTypeNone) {
+        result = toRef(exec, call(exec, jsObject, callType, callData, jsThisObject, argList));
+        if (exec->hadException()) {
+            if (exception)
+                *exception = toRef(exec, exec->exception());
+            exec->clearException();
+            result = 0;
+        }
     }
+
+    exec->globalData().clientData->didExecute(exec);
     return result;
 }
 
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 0188633..ae2f8f3 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,33 @@
+2009-11-23  Gavin Barraclough  <barraclough at apple.com>
+
+        Reviewed by Geoff Garen.
+
+        Part 1/3 of <rdar://problem/7377477> REGRESSION: Many web pages fail to render after interesting script runs in isolated world
+
+        Some clients of the JavaScriptCore API expect to be able to make callbacks over the JSC API,
+        and for this to automagically cause execution to take place in the world associated with the
+        global object associated with the ExecState (JSContextRef) passed.  However this is not how
+        things work - the world must be explicitly set within WebCore.
+
+        Making this work just for API calls to evaluate & call will be a far from perfect solution,
+        since direct (non-API) use of JSC still relies on WebCore setting the current world correctly.
+        A better solution would be to make this all work automagically all throughout WebCore, but this
+        will require more refactoring.
+
+        Since the API is in JSC but worlds only exist in WebCore, add callbacks on the JSGlobalData::ClientData
+        to allow it to update the current world on entry/exit via the JSC API.  This is temporary duck
+        tape, and should be removed once the current world no longer needs to be explicitly tracked.
+
+        * API/JSBase.cpp:
+        (JSEvaluateScript):
+        * API/JSObjectRef.cpp:
+        (JSObjectCallAsFunction):
+        * JavaScriptCore.exp:
+        * runtime/JSGlobalData.cpp:
+        (JSC::JSGlobalData::ClientData::beginningExecution):
+        (JSC::JSGlobalData::ClientData::completedExecution):
+        * runtime/JSGlobalData.h:
+
 2009-11-23  Steve Block  <steveblock at google.com>
 
         Reviewed by Dmitry Titov.
diff --git a/JavaScriptCore/JavaScriptCore.exp b/JavaScriptCore/JavaScriptCore.exp
index d2f6035..baf4173 100644
--- a/JavaScriptCore/JavaScriptCore.exp
+++ b/JavaScriptCore/JavaScriptCore.exp
@@ -405,6 +405,7 @@ __ZNK3JSC8JSObject9toBooleanEPNS_9ExecStateE
 __ZNK3JSC9HashTable11createTableEPNS_12JSGlobalDataE
 __ZNK3JSC9HashTable11deleteTableEv
 __ZNK3WTF8Collator7collateEPKtmS2_m
+__ZTVN3JSC12JSGlobalData10ClientDataE
 __ZTVN3JSC12StringObjectE
 __ZTVN3JSC14JSGlobalObjectE
 __ZTVN3JSC15JSWrapperObjectE
diff --git a/JavaScriptCore/runtime/JSGlobalData.cpp b/JavaScriptCore/runtime/JSGlobalData.cpp
index 658c222..0a7bd69 100644
--- a/JavaScriptCore/runtime/JSGlobalData.cpp
+++ b/JavaScriptCore/runtime/JSGlobalData.cpp
@@ -71,6 +71,14 @@ extern JSC_CONST_HASHTABLE HashTable regExpTable;
 extern JSC_CONST_HASHTABLE HashTable regExpConstructorTable;
 extern JSC_CONST_HASHTABLE HashTable stringTable;
 
+void JSGlobalData::ClientData::willExecute(ExecState*)
+{
+}
+
+void JSGlobalData::ClientData::didExecute(ExecState*)
+{
+}
+
 struct VPtrSet {
     VPtrSet();
 
diff --git a/JavaScriptCore/runtime/JSGlobalData.h b/JavaScriptCore/runtime/JSGlobalData.h
index f0c1b5c..3d42220 100644
--- a/JavaScriptCore/runtime/JSGlobalData.h
+++ b/JavaScriptCore/runtime/JSGlobalData.h
@@ -88,6 +88,8 @@ namespace JSC {
     public:
         struct ClientData {
             virtual ~ClientData() = 0;
+            virtual void willExecute(ExecState*);
+            virtual void didExecute(ExecState*);
         };
 
         static bool sharedInstanceExists();

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list