Remove the Completion object from JSC, I have never liked it
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Sep 2011 22:38:44 +0000 (22:38 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Sep 2011 22:38:44 +0000 (22:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=67755

Reviewed by Gavin Barraclough.

../JavaScriptCore:

- Removes the Completion object and replaces its use with out parameter exceptions.
- Remove ComplType and virtual exceptionType() function on JSObject. Replace with
  ClassInfo for InterruptedExecutionError and TerminatedExecutionError.

* API/JSBase.cpp:
(JSEvaluateScript):
(JSCheckScriptSyntax):
* JavaScriptCore.exp:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
* interpreter/Interpreter.cpp:
(JSC::Interpreter::throwException):
* jsc.cpp:
(functionLoad):
(functionCheckSyntax):
(runWithScripts):
(runInteractive):
* runtime/Completion.cpp:
(JSC::checkSyntax):
(JSC::evaluate):
* runtime/Completion.h:
* runtime/ExceptionHelpers.cpp:
(JSC::InterruptedExecutionError::toString):
(JSC::TerminatedExecutionError::toString):
(JSC::createInterruptedExecutionException):
* runtime/ExceptionHelpers.h:
(JSC::InterruptedExecutionError::InterruptedExecutionError):
(JSC::InterruptedExecutionError::create):
(JSC::InterruptedExecutionError::createStructure):
(JSC::TerminatedExecutionError::TerminatedExecutionError):
(JSC::TerminatedExecutionError::create):
(JSC::TerminatedExecutionError::createStructure):
* runtime/JSGlobalData.cpp:
(JSC::JSGlobalData::JSGlobalData):
* runtime/JSObject.h:

../JavaScriptGlue:

* JSRun.cpp:
(JSRun::Evaluate):
(JSRun::CheckSyntax):
* JSRun.h:
* JavaScriptGlue.cpp:
(JSRunEvaluate):

../WebCore:

* bindings/js/JSDOMBinding.cpp:
(WebCore::reportException):
* bindings/js/JSEventListener.cpp:
(WebCore::JSEventListener::handleEvent):
* bindings/js/JSInjectedScriptManager.cpp:
(WebCore::InjectedScriptManager::createInjectedScript):
* bindings/js/JSMainThreadExecState.h:
(WebCore::JSMainThreadExecState::evaluate):
* bindings/js/ScriptController.cpp:
(WebCore::ScriptController::evaluateInWorld):
* bindings/js/WorkerScriptController.cpp:
(WebCore::WorkerScriptController::evaluate):
* bindings/objc/WebScriptObject.mm:
(-[WebScriptObject evaluateWebScript:]):
* bridge/NP_jsobject.cpp:
(_NPN_Evaluate):
* bridge/jni/jni_jsobject.mm:
(JavaJSObject::eval):

../WebKit/mac:

* Plugins/Hosted/NetscapePluginInstanceProxy.mm:
(WebKit::NetscapePluginInstanceProxy::evaluate):

../WebKit/qt:

* Api/qwebelement.cpp:
(QWebElement::evaluateJavaScript):

../WebKit2:

* WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp:
(WebKit::NPRuntimeObjectMap::evaluate):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@94811 268f45cc-cd09-0410-ab3c-d52691b4dbfc

33 files changed:
Source/JavaScriptCore/API/JSBase.cpp
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/JavaScriptCore.exp
Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
Source/JavaScriptCore/interpreter/Interpreter.cpp
Source/JavaScriptCore/jsc.cpp
Source/JavaScriptCore/runtime/Completion.cpp
Source/JavaScriptCore/runtime/Completion.h
Source/JavaScriptCore/runtime/ExceptionHelpers.cpp
Source/JavaScriptCore/runtime/ExceptionHelpers.h
Source/JavaScriptCore/runtime/JSGlobalData.cpp
Source/JavaScriptCore/runtime/JSObject.h
Source/JavaScriptGlue/ChangeLog
Source/JavaScriptGlue/JSRun.cpp
Source/JavaScriptGlue/JSRun.h
Source/JavaScriptGlue/JavaScriptGlue.cpp
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSDOMBinding.cpp
Source/WebCore/bindings/js/JSEventListener.cpp
Source/WebCore/bindings/js/JSInjectedScriptManager.cpp
Source/WebCore/bindings/js/JSMainThreadExecState.h
Source/WebCore/bindings/js/ScriptController.cpp
Source/WebCore/bindings/js/WorkerScriptController.cpp
Source/WebCore/bindings/objc/WebScriptObject.mm
Source/WebCore/bridge/NP_jsobject.cpp
Source/WebCore/bridge/jni/jni_jsobject.mm
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm
Source/WebKit/qt/Api/qwebelement.cpp
Source/WebKit/qt/ChangeLog
Source/WebKit2/ChangeLog
Source/WebKit2/Platform/CoreIPC/Connection.cpp
Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp

index c5f1b15..9849b03 100644 (file)
@@ -29,7 +29,6 @@
 
 #include "APICast.h"
 #include "APIShims.h"
-#include "Completion.h"
 #include "OpaqueJSString.h"
 #include "SourceCode.h"
 #include <interpreter/CallFrame.h>
@@ -52,17 +51,19 @@ JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef th
     // evaluate sets "this" to the global object if it is NULL
     JSGlobalObject* globalObject = exec->dynamicGlobalObject();
     SourceCode source = makeSource(script->ustring(), sourceURL->ustring(), startingLineNumber);
-    Completion completion = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), source, jsThisObject);
 
-    if (completion.complType() == Throw) {
+    JSValue evaluationException;
+    JSValue returnValue = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), source, jsThisObject, &evaluationException);
+
+    if (evaluationException) {
         if (exception)
-            *exception = toRef(exec, completion.value());
+            *exception = toRef(exec, evaluationException);
         return 0;
     }
 
-    if (completion.value())
-        return toRef(exec, completion.value());
-    
+    if (returnValue)
+        return toRef(exec, returnValue);
+
     // happens, for example, when the only statement is an empty (';') statement
     return toRef(exec, jsUndefined());
 }
@@ -73,13 +74,16 @@ bool JSCheckScriptSyntax(JSContextRef ctx, JSStringRef script, JSStringRef sourc
     APIEntryShim entryShim(exec);
 
     SourceCode source = makeSource(script->ustring(), sourceURL->ustring(), startingLineNumber);
-    Completion completion = checkSyntax(exec->dynamicGlobalObject()->globalExec(), source);
-    if (completion.complType() == Throw) {
+    
+    JSValue syntaxException;
+    bool isValidSyntax = checkSyntax(exec->dynamicGlobalObject()->globalExec(), source, &syntaxException);
+
+    if (!isValidSyntax) {
         if (exception)
-            *exception = toRef(exec, completion.value());
+            *exception = toRef(exec, syntaxException);
         return false;
     }
-    
+
     return true;
 }
 
index 9e58ade..6e84676 100644 (file)
@@ -1,3 +1,45 @@
+2011-09-08  Sam Weinig  <sam@webkit.org>
+
+        Remove the Completion object from JSC, I have never liked it
+        https://bugs.webkit.org/show_bug.cgi?id=67755
+
+        Reviewed by Gavin Barraclough.
+
+        - Removes the Completion object and replaces its use with out parameter exceptions.
+        - Remove ComplType and virtual exceptionType() function on JSObject. Replace with
+          ClassInfo for InterruptedExecutionError and TerminatedExecutionError.
+
+        * API/JSBase.cpp:
+        (JSEvaluateScript):
+        (JSCheckScriptSyntax):
+        * JavaScriptCore.exp:
+        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
+        * interpreter/Interpreter.cpp:
+        (JSC::Interpreter::throwException):
+        * jsc.cpp:
+        (functionLoad):
+        (functionCheckSyntax):
+        (runWithScripts):
+        (runInteractive):
+        * runtime/Completion.cpp:
+        (JSC::checkSyntax):
+        (JSC::evaluate):
+        * runtime/Completion.h:
+        * runtime/ExceptionHelpers.cpp:
+        (JSC::InterruptedExecutionError::toString):
+        (JSC::TerminatedExecutionError::toString):
+        (JSC::createInterruptedExecutionException):
+        * runtime/ExceptionHelpers.h:
+        (JSC::InterruptedExecutionError::InterruptedExecutionError):
+        (JSC::InterruptedExecutionError::create):
+        (JSC::InterruptedExecutionError::createStructure):
+        (JSC::TerminatedExecutionError::TerminatedExecutionError):
+        (JSC::TerminatedExecutionError::create):
+        (JSC::TerminatedExecutionError::createStructure):
+        * runtime/JSGlobalData.cpp:
+        (JSC::JSGlobalData::JSGlobalData):
+        * runtime/JSObject.h:
+
 2011-09-08  Ryosuke Niwa  <rniwa@webkit.org>
 
         Build fix.
index aff5e7f..24a5879 100644 (file)
@@ -119,7 +119,7 @@ __ZN3JSC11JSByteArray13s_defaultInfoE
 __ZN3JSC11JSByteArray15createStructureERNS_12JSGlobalDataEPNS_14JSGlobalObjectENS_7JSValueEPKNS_9ClassInfoE
 __ZN3JSC11JSByteArrayC1EPNS_9ExecStateEPNS_9StructureEPN3WTF9ByteArrayE
 __ZN3JSC11ParserArena5resetEv
-__ZN3JSC11checkSyntaxEPNS_9ExecStateERKNS_10SourceCodeE
+__ZN3JSC11checkSyntaxEPNS_9ExecStateERKNS_10SourceCodeEPNS_7JSValueE
 __ZN3JSC11createErrorEPNS_9ExecStateERKNS_7UStringE
 __ZN3JSC11regExpFlagsERKNS_7UStringE
 __ZN3JSC12DateInstance6s_infoE
@@ -135,6 +135,7 @@ __ZN3JSC12JSGlobalData14resetDateCacheEv
 __ZN3JSC12JSGlobalData14sharedInstanceEv
 __ZN3JSC12JSGlobalData15dumpRegExpTraceEv
 __ZN3JSC12JSGlobalData22clearBuiltinStructuresEv
+__ZN3JSC12JSGlobalData23releaseExecutableMemoryEv
 __ZN3JSC12JSGlobalData6createENS_15ThreadStackTypeENS_8HeapSizeE
 __ZN3JSC12JSGlobalDataD1Ev
 __ZN3JSC12RegExpObject6s_infoE
@@ -217,6 +218,7 @@ __ZN3JSC23AbstractSamplingCounter4dumpEv
 __ZN3JSC23objectProtoFuncToStringEPNS_9ExecStateE
 __ZN3JSC23setUpStaticFunctionSlotEPNS_9ExecStateEPKNS_9HashEntryEPNS_8JSObjectERKNS_10IdentifierERNS_12PropertySlotE
 __ZN3JSC24DynamicGlobalObjectScopeC1ERNS_12JSGlobalDataEPNS_14JSGlobalObjectE
+__ZN3JSC24TerminatedExecutionError6s_infoE
 __ZN3JSC24createStackOverflowErrorEPNS_9ExecStateE
 __ZN3JSC25evaluateInGlobalCallFrameERKNS_7UStringERNS_7JSValueEPNS_14JSGlobalObjectE
 __ZN3JSC35createInterruptedExecutionExceptionEPNS_12JSGlobalDataE
@@ -326,7 +328,7 @@ __ZN3JSC8JSObject6s_infoE
 __ZN3JSC8Profiler13stopProfilingEPNS_9ExecStateERKNS_7UStringE
 __ZN3JSC8Profiler14startProfilingEPNS_9ExecStateERKNS_7UStringE
 __ZN3JSC8Profiler8profilerEv
-__ZN3JSC8evaluateEPNS_9ExecStateEPNS_14ScopeChainNodeERKNS_10SourceCodeENS_7JSValueE
+__ZN3JSC8evaluateEPNS_9ExecStateEPNS_14ScopeChainNodeERKNS_10SourceCodeENS_7JSValueEPS7_
 __ZN3JSC8isZombieEPKNS_6JSCellE
 __ZN3JSC9CodeBlockD1Ev
 __ZN3JSC9CodeBlockD2Ev
@@ -617,7 +619,3 @@ __ZTVN3JSC8JSObjectE
 __ZTVN3JSC8JSStringE
 _jscore_fastmalloc_introspection
 _kJSClassDefinitionEmpty
-
-#ifndef NDEBUG
-__ZN3JSC12JSGlobalData23releaseExecutableMemoryEv
-#endif
index 7d07015..318d04c 100644 (file)
@@ -39,6 +39,8 @@ EXPORTS
     ??1WeakHandleOwner@JSC@@UAE@XZ
     ??8JSC@@YA_NABVUString@0@0@Z
     ??8WTF@@YA_NABVCString@0@0@Z
+    ?checkSyntax@JSC@@YA_NPAVExecState@1@ABVSourceCode@1@PAVJSValue@1@@Z
+    ?evaluate@JSC@@YA?AVJSValue@1@PAVExecState@1@PAVScopeChainNode@1@ABVSourceCode@1@V21@PAV21@@Z
     ?EcmaScriptConverter@DoubleToStringConverter@double_conversion@WTF@@SAABV123@XZ
     ?ToExponential@DoubleToStringConverter@double_conversion@WTF@@QBE_NNHPAVStringBuilder@23@@Z
     ?ToFixed@DoubleToStringConverter@double_conversion@WTF@@QBE_NNHPAVStringBuilder@23@@Z
@@ -80,7 +82,6 @@ EXPORTS
     ?changePrototypeTransition@Structure@JSC@@SAPAV12@AAVJSGlobalData@2@PAV12@VJSValue@2@@Z
     ?checkCurrentIdentifierTable@Identifier@JSC@@CAXPAVExecState@2@@Z
     ?checkCurrentIdentifierTable@Identifier@JSC@@CAXPAVJSGlobalData@2@@Z
-    ?checkSyntax@JSC@@YA?AVCompletion@1@PAVExecState@1@ABVSourceCode@1@@Z
     ?checksum@MD5@WTF@@QAEXAAV?$Vector@E$0BA@@2@@Z
     ?className@JSObject@JSC@@UBE?AVUString@2@XZ
     ?clear@SourceProviderCache@JSC@@QAEXXZ
@@ -160,7 +161,6 @@ EXPORTS
     ?equal@Identifier@JSC@@SA_NPBVStringImpl@WTF@@PBD@Z
     ?equalUTF16WithUTF8@Unicode@WTF@@YA_NPB_W0PBD1@Z
     ?evaluate@DebuggerCallFrame@JSC@@QBE?AVJSValue@2@ABVUString@2@AAV32@@Z
-    ?evaluate@JSC@@YA?AVCompletion@1@PAVExecState@1@PAVScopeChainNode@1@ABVSourceCode@1@VJSValue@1@@Z
     ?exclude@Profile@JSC@@QAEXPBVProfileNode@2@@Z
     ?fastCalloc@WTF@@YAPAXII@Z
     ?fastFree@WTF@@YAXPAX@Z
index 956470b..82e6a5c 100644 (file)
@@ -708,8 +708,7 @@ NEVER_INLINE HandlerInfo* Interpreter::throwException(CallFrame*& callFrame, JSV
             addErrorInfo(callFrame, exception, codeBlock->lineNumberForBytecodeOffset(bytecodeOffset), codeBlock->ownerExecutable()->source());
         }
 
-        ComplType exceptionType = exception->exceptionType();
-        isInterrupt = exceptionType == Interrupted || exceptionType == Terminated;
+        isInterrupt = (exception->inherits(&InterruptedExecutionError::s_info) || exception->inherits(&TerminatedExecutionError::s_info));
     }
 
     if (Debugger* debugger = callFrame->dynamicGlobalObject()->debugger()) {
index e103709..f59f835 100644 (file)
@@ -261,10 +261,12 @@ EncodedJSValue JSC_HOST_CALL functionLoad(ExecState* exec)
         return JSValue::encode(throwError(exec, createError(exec, "Could not open file.")));
 
     JSGlobalObject* globalObject = exec->lexicalGlobalObject();
-    Completion result = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(script.data(), fileName));
-    if (result.complType() == Throw)
-        throwError(exec, result.value());
-    return JSValue::encode(result.value());
+    
+    JSValue evaluationException;
+    JSValue result = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(script.data(), fileName), JSValue(), &evaluationException);
+    if (evaluationException)
+        throwError(exec, evaluationException);
+    return JSValue::encode(result);
 }
 
 EncodedJSValue JSC_HOST_CALL functionCheckSyntax(ExecState* exec)
@@ -278,11 +280,13 @@ EncodedJSValue JSC_HOST_CALL functionCheckSyntax(ExecState* exec)
 
     StopWatch stopWatch;
     stopWatch.start();
-    Completion result = checkSyntax(globalObject->globalExec(), makeSource(script.data(), fileName));
+
+    JSValue syntaxException;
+    bool validSyntax = checkSyntax(globalObject->globalExec(), makeSource(script.data(), fileName), &syntaxException);
     stopWatch.stop();
 
-    if (result.complType() == Throw)
-        throwError(exec, result.value());
+    if (!validSyntax)
+        throwError(exec, syntaxException);
     return JSValue::encode(jsNumber(stopWatch.getElapsedMS()));
 }
 
@@ -436,13 +440,14 @@ static bool runWithScripts(GlobalObject* globalObject, const Vector<Script>& scr
 
         globalData.startSampling();
 
-        Completion completion = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(script, fileName));
-        success = success && completion.complType() != Throw;
+        JSValue evaluationException;
+        JSValue returnValue = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(script, fileName), JSValue(), &evaluationException);
+        success = success && !evaluationException;
         if (dump) {
-            if (completion.complType() == Throw)
-                printf("Exception: %s\n", completion.value().toString(globalObject->globalExec()).utf8().data());
+            if (evaluationException)
+                printf("Exception: %s\n", evaluationException.toString(globalObject->globalExec()).utf8().data());
             else
-                printf("End: %s\n", completion.value().toString(globalObject->globalExec()).utf8().data());
+                printf("End: %s\n", returnValue.toString(globalObject->globalExec()).utf8().data());
         }
 
         globalData.stopSampling();
@@ -473,7 +478,8 @@ static void runInteractive(GlobalObject* globalObject)
             break;
         if (line[0])
             add_history(line);
-        Completion completion = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(line, interpreterName));
+        JSValue evaluationException;
+        JSValue returnValue = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(line, interpreterName), JSValue(), &evaluationException);
         free(line);
 #else
         printf("%s", interactivePrompt);
@@ -488,12 +494,14 @@ static void runInteractive(GlobalObject* globalObject)
         if (line.isEmpty())
             break;
         line.append('\0');
-        Completion completion = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(line.data(), interpreterName));
+
+        JSValue evaluationException;
+        JSValue returnValue = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(line.data(), interpreterName), JSValue(), &evaluationException);
 #endif
-        if (completion.complType() == Throw)
-            printf("Exception: %s\n", completion.value().toString(globalObject->globalExec()).utf8().data());
+        if (evaluationException)
+            printf("Exception: %s\n", evaluationException.toString(globalObject->globalExec()).utf8().data());
         else
-            printf("%s\n", completion.value().toString(globalObject->globalExec()).utf8().data());
+            printf("%s\n", returnValue.toString(globalObject->globalExec()).utf8().data());
 
         globalObject->globalExec()->clearException();
     }
index 2dd18a2..c3d9e69 100644 (file)
 
 namespace JSC {
 
-Completion checkSyntax(ExecState* exec, const SourceCode& source)
+bool checkSyntax(ExecState* exec, const SourceCode& source, JSValue* returnedException)
 {
     JSLock lock(exec);
     ASSERT(exec->globalData().identifierTable == wtfThreadData().currentIdentifierTable());
 
     ProgramExecutable* program = ProgramExecutable::create(exec, source);
     JSObject* error = program->checkSyntax(exec);
-    if (error)
-        return Completion(Throw, error);
+    if (error) {
+        if (returnedException)
+            *returnedException = error;
+        return false;
+    }
 
-    return Completion(Normal);
+    return true;
 }
 
-Completion evaluate(ExecState* exec, ScopeChainNode* scopeChain, const SourceCode& source, JSValue thisValue)
+JSValue evaluate(ExecState* exec, ScopeChainNode* scopeChain, const SourceCode& source, JSValue thisValue, JSValue* returnedException)
 {
     JSLock lock(exec);
     ASSERT(exec->globalData().identifierTable == wtfThreadData().currentIdentifierTable());
 
     ProgramExecutable* program = ProgramExecutable::create(exec, source);
     if (!program) {
-        JSValue exception = exec->globalData().exception;
+        if (returnedException)
+            *returnedException = exec->globalData().exception;
+
         exec->globalData().exception = JSValue();
-        return Completion(Throw, exception);
+        return jsUndefined();
     }
 
     if (!thisValue || thisValue.isUndefinedOrNull())
         thisValue = exec->dynamicGlobalObject();
     JSObject* thisObj = thisValue.toThisObject(exec);
-
     JSValue result = exec->interpreter()->execute(program, exec, scopeChain, thisObj);
 
     if (exec->hadException()) {
-        JSValue exception = exec->exception();
-        exec->clearException();
+        if (returnedException)
+            *returnedException = exec->exception();
 
-        ComplType exceptionType = Throw;
-        if (exception.isObject())
-            exceptionType = asObject(exception)->exceptionType();
-        return Completion(exceptionType, exception);
+        exec->clearException();
+        return jsUndefined();
     }
-    return Completion(Normal, result);
+
+    ASSERT(result);
+    return result;
 }
 
 } // namespace JSC
index 1dd25fd..c3dbdfc 100644 (file)
@@ -31,32 +31,8 @@ namespace JSC {
     class ScopeChainNode;
     class SourceCode;
 
-    enum ComplType { Normal, Break, Continue, ReturnValue, Throw, Interrupted, Terminated };
-
-    /*
-     * Completion objects are used to convey the return status and value
-     * from functions.
-     */
-    class Completion {
-    public:
-        Completion(ComplType type = Normal, JSValue value = JSValue())
-            : m_type(type)
-            , m_value(value)
-        {
-        }
-
-        ComplType complType() const { return m_type; }
-        JSValue value() const { return m_value; }
-        void setValue(JSValue v) { m_value = v; }
-        bool isValueCompletion() const { return m_value; }
-
-    private:
-        ComplType m_type;
-        JSValue m_value;
-    };
-
-    Completion checkSyntax(ExecState*, const SourceCode&);
-    Completion evaluate(ExecState*, ScopeChainNode*, const SourceCode&, JSValue thisValue = JSValue());
+    bool checkSyntax(ExecState*, const SourceCode&, JSValue* exception = 0);
+    JSValue evaluate(ExecState*, ScopeChainNode*, const SourceCode&, JSValue thisValue = JSValue(), JSValue* exception = 0);
 
 } // namespace JSC
 
index 4bc4fae..10c333d 100644 (file)
 
 namespace JSC {
 
-class InterruptedExecutionError : public JSNonFinalObject {
-private:
-    InterruptedExecutionError(JSGlobalData& globalData)
-        : JSNonFinalObject(globalData, globalData.interruptedExecutionErrorStructure.get())
-    {
-    }
+const ClassInfo InterruptedExecutionError::s_info = { "InterruptedExecutionError", 0, 0, 0 };
 
-public:
-    typedef JSNonFinalObject Base;
+UString InterruptedExecutionError::toString(ExecState*) const
+{
+    return "JavaScript execution exceeded timeout.";
+}
 
-    static InterruptedExecutionError* create(JSGlobalData& globalData)
-    {
-        InterruptedExecutionError* error = new (allocateCell<InterruptedExecutionError>(globalData.heap)) InterruptedExecutionError(globalData);
-        error->finishCreation(globalData);
-        return error;
-    }
+const ClassInfo TerminatedExecutionError::s_info = { "TerminatedExecutionError", 0, 0, 0 };
 
-    virtual ComplType exceptionType() const { return Interrupted; }
+UString TerminatedExecutionError::toString(ExecState*) const
+{
+    return "JavaScript execution terminated.";
+}
 
-    virtual UString toString(ExecState*) const { return "JavaScript execution exceeded timeout."; }
-};
 
 JSObject* createInterruptedExecutionException(JSGlobalData* globalData)
 {
     return InterruptedExecutionError::create(*globalData);
 }
 
-class TerminatedExecutionError : public JSNonFinalObject {
-private:
-    TerminatedExecutionError(JSGlobalData& globalData)
-        : JSNonFinalObject(globalData, globalData.terminatedExecutionErrorStructure.get())
-    {
-    }
-
-public:
-    typedef JSNonFinalObject Base;
-
-    static TerminatedExecutionError* create(JSGlobalData& globalData)
-    {
-        TerminatedExecutionError* error = new (allocateCell<TerminatedExecutionError>(globalData.heap)) TerminatedExecutionError(globalData);
-        error->finishCreation(globalData);
-        return error;
-    }
-
-    virtual ComplType exceptionType() const { return Terminated; }
-
-    virtual UString toString(ExecState*) const { return "JavaScript execution terminated."; }
-};
-
 JSObject* createTerminatedExecutionException(JSGlobalData* globalData)
 {
     return TerminatedExecutionError::create(*globalData);
index 5f1ec6f..39ebe16 100644 (file)
 #ifndef ExceptionHelpers_h
 #define ExceptionHelpers_h
 
-#include "JSValue.h"
+#include "JSObject.h"
 
 namespace JSC {
 
-    class CodeBlock;
-    class ExecState;
-    class Identifier;
-    class JSGlobalData;
-    class JSGlobalObject;
-    class JSNotAnObjectErrorStub;
-    class JSObject;
-    class Node;
-    struct Instruction;
-    
-    JSObject* createInterruptedExecutionException(JSGlobalData*);
-    JSObject* createTerminatedExecutionException(JSGlobalData*);
-    JSObject* createStackOverflowError(ExecState*);
-    JSObject* createStackOverflowError(JSGlobalObject*);
-    JSObject* createOutOfMemoryError(JSGlobalObject*);
-    JSObject* createUndefinedVariableError(ExecState*, const Identifier&);
-    JSObject* createNotAnObjectError(ExecState*, JSValue);
-    JSObject* createInvalidParamError(ExecState*, const char* op, JSValue);
-    JSObject* createNotAConstructorError(ExecState*, JSValue);
-    JSObject* createNotAFunctionError(ExecState*, JSValue);
-    JSObject* createErrorForInvalidGlobalAssignment(ExecState*, const UString&);
-
-    JSObject* throwOutOfMemoryError(ExecState*);
-    JSObject* throwStackOverflowError(ExecState*);
+JSObject* createInterruptedExecutionException(JSGlobalData*);
+JSObject* createTerminatedExecutionException(JSGlobalData*);
+JSObject* createStackOverflowError(ExecState*);
+JSObject* createStackOverflowError(JSGlobalObject*);
+JSObject* createOutOfMemoryError(JSGlobalObject*);
+JSObject* createUndefinedVariableError(ExecState*, const Identifier&);
+JSObject* createNotAnObjectError(ExecState*, JSValue);
+JSObject* createInvalidParamError(ExecState*, const char* op, JSValue);
+JSObject* createNotAConstructorError(ExecState*, JSValue);
+JSObject* createNotAFunctionError(ExecState*, JSValue);
+JSObject* createErrorForInvalidGlobalAssignment(ExecState*, const UString&);
+
+JSObject* throwOutOfMemoryError(ExecState*);
+JSObject* throwStackOverflowError(ExecState*);
+
+
+class InterruptedExecutionError : public JSNonFinalObject {
+private:
+    InterruptedExecutionError(JSGlobalData& globalData)
+        : JSNonFinalObject(globalData, globalData.interruptedExecutionErrorStructure.get())
+    {
+    }
+
+    virtual UString toString(ExecState*) const;
+
+public:
+    typedef JSNonFinalObject Base;
+
+    static InterruptedExecutionError* create(JSGlobalData& globalData)
+    {
+        InterruptedExecutionError* error = new (allocateCell<InterruptedExecutionError>(globalData.heap)) InterruptedExecutionError(globalData);
+        error->finishCreation(globalData);
+        return error;
+    }
+
+    static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype)
+    {
+        return Structure::create(globalData, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
+    }
+
+    static JS_EXPORTDATA const ClassInfo s_info;
+};
+
+class TerminatedExecutionError : public JSNonFinalObject {
+private:
+    TerminatedExecutionError(JSGlobalData& globalData)
+        : JSNonFinalObject(globalData, globalData.terminatedExecutionErrorStructure.get())
+    {
+    }
+
+    virtual UString toString(ExecState*) const;
+
+public:
+    typedef JSNonFinalObject Base;
+
+    static TerminatedExecutionError* create(JSGlobalData& globalData)
+    {
+        TerminatedExecutionError* error = new (allocateCell<TerminatedExecutionError>(globalData.heap)) TerminatedExecutionError(globalData);
+        error->finishCreation(globalData);
+        return error;
+    }
+
+    static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype)
+    {
+        return Structure::create(globalData, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
+    }
+
+    static JS_EXPORTDATA const ClassInfo s_info;
+};
 
 } // namespace JSC
 
index 8fec1fc..beed7fe 100644 (file)
@@ -216,8 +216,8 @@ JSGlobalData::JSGlobalData(GlobalDataType globalDataType, ThreadStackType thread
     structureStructure.set(*this, Structure::createStructure(*this));
     debuggerActivationStructure.set(*this, DebuggerActivation::createStructure(*this, 0, jsNull()));
     activationStructure.set(*this, JSActivation::createStructure(*this, 0, jsNull()));
-    interruptedExecutionErrorStructure.set(*this, JSNonFinalObject::createStructure(*this, 0, jsNull()));
-    terminatedExecutionErrorStructure.set(*this, JSNonFinalObject::createStructure(*this, 0, jsNull()));
+    interruptedExecutionErrorStructure.set(*this, InterruptedExecutionError::createStructure(*this, 0, jsNull()));
+    terminatedExecutionErrorStructure.set(*this, TerminatedExecutionError::createStructure(*this, 0, jsNull()));
     staticScopeStructure.set(*this, JSStaticScopeObject::createStructure(*this, 0, jsNull()));
     strictEvalActivationStructure.set(*this, StrictEvalActivation::createStructure(*this, 0, jsNull()));
     stringStructure.set(*this, JSString::createStructure(*this, 0, jsNull()));
index d76befc..942d77d 100644 (file)
@@ -26,7 +26,6 @@
 #include "ArgList.h"
 #include "ClassInfo.h"
 #include "CommonIdentifiers.h"
-#include "Completion.h"
 #include "CallFrame.h"
 #include "JSCell.h"
 #include "PropertySlot.h"
@@ -219,8 +218,6 @@ namespace JSC {
         bool isFrozen(JSGlobalData& globalData) { return m_structure->isFrozen(globalData); }
         bool isExtensible() { return m_structure->isExtensible(); }
 
-        virtual ComplType exceptionType() const { return Throw; }
-
         void allocatePropertyStorage(size_t oldSize, size_t newSize);
         bool isUsingInlineStorage() const { return static_cast<const void*>(m_propertyStorage) == static_cast<const void*>(this + 1); }
 
index 3047f26..a739386 100644 (file)
@@ -1,3 +1,17 @@
+2011-09-08  Sam Weinig  <sam@webkit.org>
+
+        Remove the Completion object from JSC, I have never liked it
+        https://bugs.webkit.org/show_bug.cgi?id=67755
+
+        Reviewed by Gavin Barraclough.
+
+        * JSRun.cpp:
+        (JSRun::Evaluate):
+        (JSRun::CheckSyntax):
+        * JSRun.h:
+        * JavaScriptGlue.cpp:
+        (JSRunEvaluate):
+
 2011-09-07  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r94627 and r94632.
index 8c88f85..63192e2 100644 (file)
@@ -67,12 +67,12 @@ JSGlobalObject* JSRun::GlobalObject() const
     return fGlobalObject.get();
 }
 
-Completion JSRun::Evaluate()
+JSValue JSRun::Evaluate(JSValue* expception)
 {
-    return JSC::evaluate(fGlobalObject->globalExec(), fGlobalObject->globalScopeChain(), makeSource(fSource));
+    return JSC::evaluate(fGlobalObject->globalExec(), fGlobalObject->globalScopeChain(), makeSource(fSource), JSValue(), expception);
 }
 
 bool JSRun::CheckSyntax()
 {
-    return JSC::checkSyntax(fGlobalObject->globalExec(), makeSource(fSource)).complType() != Throw;
+    return JSC::checkSyntax(fGlobalObject->globalExec(), makeSource(fSource));
 }
index a17e060..af9ea49 100644 (file)
@@ -61,7 +61,7 @@ class JSRun : public JSBase {
 
         UString GetSource() const;
         JSGlobalObject* GlobalObject() const;
-        Completion Evaluate();
+        JSValue Evaluate(JSValue* exception);
         bool CheckSyntax();
         JSFlags Flags() const;
     private:
index 134d310..c226836 100644 (file)
@@ -292,14 +292,14 @@ JSObjectRef JSRunEvaluate(JSRunRef ref)
     if (ptr)
     {
         JSGlueAPIEntry entry;
-        Completion completion = ptr->Evaluate();
-        if (completion.isValueCompletion())
-        {
-            result = (JSObjectRef)KJSValueToJSObject(completion.value(), ptr->GlobalObject()->globalExec());
-        }
-
-        if (completion.complType() == Throw)
+        
+        JSValue evaluationException;
+        JSValue returnValue = ptr->Evaluate(&evaluationException);
+        
+        if (evaluationException)
         {
+            result = (JSObjectRef)KJSValueToJSObject(evaluationException, ptr->GlobalObject()->globalExec());
+            
             JSFlags flags = ptr->Flags();
             if (flags & kJSFlagDebug)
             {
@@ -311,6 +311,10 @@ JSObjectRef JSRunEvaluate(JSRunRef ref)
                 }
             }
         }
+        else
+        {
+            result = (JSObjectRef)KJSValueToJSObject(returnValue, ptr->GlobalObject()->globalExec());
+        }
     }
     return result;
 }
index dcf5d7d..5414725 100644 (file)
@@ -1,3 +1,29 @@
+2011-09-08  Sam Weinig  <sam@webkit.org>
+
+        Remove the Completion object from JSC, I have never liked it
+        https://bugs.webkit.org/show_bug.cgi?id=67755
+
+        Reviewed by Gavin Barraclough.
+
+        * bindings/js/JSDOMBinding.cpp:
+        (WebCore::reportException):
+        * bindings/js/JSEventListener.cpp:
+        (WebCore::JSEventListener::handleEvent):
+        * bindings/js/JSInjectedScriptManager.cpp:
+        (WebCore::InjectedScriptManager::createInjectedScript):
+        * bindings/js/JSMainThreadExecState.h:
+        (WebCore::JSMainThreadExecState::evaluate):
+        * bindings/js/ScriptController.cpp:
+        (WebCore::ScriptController::evaluateInWorld):
+        * bindings/js/WorkerScriptController.cpp:
+        (WebCore::WorkerScriptController::evaluate):
+        * bindings/objc/WebScriptObject.mm:
+        (-[WebScriptObject evaluateWebScript:]):
+        * bridge/NP_jsobject.cpp:
+        (_NPN_Evaluate):
+        * bridge/jni/jni_jsobject.mm:
+        (JavaJSObject::eval):
+
 2011-09-08  Adam Barth  <abarth@webkit.org>
 
         Inline DocumentWriter::encoding() into it's only caller: deprecatedFrameEncoding()
index 60e276d..59aaeb0 100644 (file)
@@ -57,6 +57,7 @@
 #include "XPathException.h"
 #include <runtime/DateInstance.h>
 #include <runtime/Error.h>
+#include <runtime/ExceptionHelpers.h>
 #include <runtime/JSFunction.h>
 
 using namespace JSC;
@@ -170,7 +171,7 @@ double valueToDate(ExecState* exec, JSValue value)
 
 void reportException(ExecState* exec, JSValue exception)
 {
-    if (exception.isObject() && asObject(exception)->exceptionType() == Terminated)
+    if (exception.inherits(&TerminatedExecutionError::s_info))
         return;
 
     UString errorMessage = exception.toString(exec);
index 7188113..c5d463d 100644 (file)
@@ -26,6 +26,7 @@
 #include "JSEventTarget.h"
 #include "JSMainThreadExecState.h"
 #include "WorkerContext.h"
+#include <runtime/ExceptionHelpers.h>
 #include <runtime/JSLock.h>
 #include <wtf/RefCountedLeakCounter.h>
 
@@ -133,7 +134,7 @@ void JSEventListener::handleEvent(ScriptExecutionContext* scriptExecutionContext
 
 #if ENABLE(WORKERS)
         if (scriptExecutionContext->isWorkerContext()) {
-            bool terminatorCausedException = (exec->hadException() && exec->exception().isObject() && asObject(exec->exception())->exceptionType() == Terminated);
+            bool terminatorCausedException = (exec->hadException() && exec->exception().inherits(&TerminatedExecutionError::s_info));
             if (terminatorCausedException || globalData.terminator.shouldTerminate())
                 static_cast<WorkerContext*>(scriptExecutionContext)->script()->forbidExecution();
         }
index c5644f3..500737d 100644 (file)
@@ -51,14 +51,18 @@ namespace WebCore {
 
 ScriptObject InjectedScriptManager::createInjectedScript(const String& source, ScriptState* scriptState, long id)
 {
-    SourceCode sourceCode = makeSource(stringToUString(source));
     JSLock lock(SilenceAssertionsOnly);
+
+    SourceCode sourceCode = makeSource(stringToUString(source));
     JSDOMGlobalObject* globalObject = static_cast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject());
     JSValue globalThisValue = scriptState->globalThisValue();
-    Completion comp = JSMainThreadExecState::evaluate(scriptState, globalObject->globalScopeChain(), sourceCode, globalThisValue);
-    if (comp.complType() != JSC::Normal && comp.complType() != JSC::ReturnValue)
+
+    JSValue evaluationException;
+    JSValue evaluationReturnValue = JSMainThreadExecState::evaluate(scriptState, globalObject->globalScopeChain(), sourceCode, globalThisValue, &evaluationException);
+    if (evaluationException)
         return ScriptObject();
-    JSValue functionValue = comp.value();
+
+    JSValue functionValue = evaluationReturnValue;
     CallData callData;
     CallType callType = getCallData(functionValue, callData);
     if (callType == CallTypeNone)
index 8bf7b2e..a4c3217 100644 (file)
@@ -27,6 +27,7 @@
 #define JSMainThreadExecState_h
 
 #include "JSDOMBinding.h"
+#include <runtime/Completion.h>
 #ifndef NDEBUG
 #include <wtf/MainThread.h>
 #endif
@@ -51,10 +52,10 @@ public:
         return JSC::call(exec, functionObject, callType, callData, thisValue, args);
     };
 
-    static JSC::Completion evaluate(JSC::ExecState* exec, JSC::ScopeChainNode* chain, const JSC::SourceCode& source, JSC::JSValue thisValue)
+    static JSC::JSValue evaluate(JSC::ExecState* exec, JSC::ScopeChainNode* chain, const JSC::SourceCode& source, JSC::JSValue thisValue, JSC::JSValue* exception)
     {
         JSMainThreadExecState currentState(exec);
-        return JSC::evaluate(exec, chain, source, thisValue);
+        return JSC::evaluate(exec, chain, source, thisValue, exception);
     };
 
 protected:
index d25c722..c0673a8 100644 (file)
@@ -138,22 +138,22 @@ ScriptValue ScriptController::evaluateInWorld(const ScriptSourceCode& sourceCode
 
     InspectorInstrumentationCookie cookie = InspectorInstrumentation::willEvaluateScript(m_frame, sourceURL, sourceCode.startLine());
 
+    JSValue evaluationException;
+
     exec->globalData().timeoutChecker.start();
-    Completion comp = JSMainThreadExecState::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), jsSourceCode, shell);
+    JSValue returnValue = JSMainThreadExecState::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), jsSourceCode, shell, &evaluationException);
     exec->globalData().timeoutChecker.stop();
 
     InspectorInstrumentation::didEvaluateScript(cookie);
 
-    if (comp.complType() == Normal || comp.complType() == ReturnValue) {
+    if (evaluationException) {
+        reportException(exec, evaluationException);
         m_sourceURL = savedSourceURL;
-        return ScriptValue(exec->globalData(), comp.value());
+        return ScriptValue();
     }
 
-    if (comp.complType() == Throw || comp.complType() == Interrupted)
-        reportException(exec, comp.value());
-
     m_sourceURL = savedSourceURL;
-    return ScriptValue();
+    return ScriptValue(exec->globalData(), returnValue);
 }
 
 ScriptValue ScriptController::evaluate(const ScriptSourceCode& sourceCode) 
index 047d74a..c6a1766 100644 (file)
@@ -40,7 +40,7 @@
 #include "WorkerThread.h"
 #include <interpreter/Interpreter.h>
 #include <runtime/Completion.h>
-#include <runtime/Completion.h>
+#include <runtime/ExceptionHelpers.h>
 #include <runtime/Error.h>
 #include <runtime/JSLock.h>
 
@@ -131,31 +131,30 @@ ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode,
     JSLock lock(SilenceAssertionsOnly);
 
     ExecState* exec = m_workerContextWrapper->globalExec();
-    m_workerContextWrapper->globalData().timeoutChecker.start();
-    Completion comp = JSC::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), sourceCode.jsSourceCode(), m_workerContextWrapper.get());
-    m_workerContextWrapper->globalData().timeoutChecker.stop();
 
+    JSValue evaluationException;
 
-    ComplType completionType = comp.complType();
+    m_workerContextWrapper->globalData().timeoutChecker.start();
+    JSValue returnValue = JSC::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), sourceCode.jsSourceCode(), m_workerContextWrapper.get(), &evaluationException);
+    m_workerContextWrapper->globalData().timeoutChecker.stop();
 
-    if (completionType == Terminated || m_workerContextWrapper->globalData().terminator.shouldTerminate()) {
+    if ((evaluationException && evaluationException.inherits(&TerminatedExecutionError::s_info)) ||  m_workerContextWrapper->globalData().terminator.shouldTerminate()) {
         forbidExecution();
         return ScriptValue();
     }
 
-    if (completionType == Normal || completionType == ReturnValue)
-        return ScriptValue(*m_globalData, comp.value());
-
-    if (completionType == Throw) {
+    if (evaluationException) {
         String errorMessage;
         int lineNumber = 0;
         String sourceURL = sourceCode.url().string();
         if (m_workerContext->sanitizeScriptError(errorMessage, lineNumber, sourceURL))
             *exception = ScriptValue(*m_globalData, throwError(exec, createError(exec, errorMessage.impl())));
         else
-            *exception = ScriptValue(*m_globalData, comp.value());
+            *exception = ScriptValue(*m_globalData, evaluationException);
     }
-    return ScriptValue();
+
+    return ScriptValue(*m_globalData, returnValue);
+
 }
 
 void WorkerScriptController::setException(ScriptValue exception)
index 696e06f..4ce6daf 100644 (file)
@@ -325,28 +325,13 @@ static void getListFromNSArray(ExecState *exec, NSArray *array, RootObject* root
     ExecState* exec = [self _rootObject]->globalObject()->globalExec();
     ASSERT(!exec->hadException());
 
-    JSValue result;
     JSLock lock(SilenceAssertionsOnly);
     
     [self _rootObject]->globalObject()->globalData().timeoutChecker.start();
-    Completion completion = JSMainThreadExecState::evaluate([self _rootObject]->globalObject()->globalExec(), [self _rootObject]->globalObject()->globalScopeChain(), makeSource(String(script)), JSC::JSValue());
+    JSValue returnValue = JSMainThreadExecState::evaluate(exec, [self _rootObject]->globalObject()->globalScopeChain(), makeSource(String(script)), JSC::JSValue(), 0);
     [self _rootObject]->globalObject()->globalData().timeoutChecker.stop();
-    ComplType type = completion.complType();
-    
-    if (type == Normal) {
-        result = completion.value();
-        if (!result)
-            result = jsUndefined();
-    } else
-        result = jsUndefined();
-    
-    if (exec->hadException()) {
-        addExceptionToConsole(exec);
-        result = jsUndefined();
-        exec->clearException();
-    }
-    
-    id resultObj = [WebScriptObject _convertValueToObjcValue:result originRootObject:[self _originRootObject] rootObject:[self _rootObject]];
+
+    id resultObj = [WebScriptObject _convertValueToObjcValue:returnValue originRootObject:[self _originRootObject] rootObject:[self _rootObject]];
     
     _didExecute(self);
     
index 6b6da2c..14efb19 100644 (file)
@@ -274,20 +274,12 @@ bool _NPN_Evaluate(NPP instance, NPObject* o, NPString* s, NPVariant* variant)
         JSLock lock(SilenceAssertionsOnly);
         String scriptString = convertNPStringToUTF16(s);
         RefPtr<JSGlobalData> globalData(&exec->globalData());
+        
         globalData->timeoutChecker.start();
-        Completion completion = JSC::evaluate(rootObject->globalObject()->globalExec(), rootObject->globalObject()->globalScopeChain(), makeSource(scriptString), JSC::JSValue());
+        JSValue returnValue = JSC::evaluate(rootObject->globalObject()->globalExec(), rootObject->globalObject()->globalScopeChain(), makeSource(scriptString), JSC::JSValue());
         globalData->timeoutChecker.stop();
-        ComplType type = completion.complType();
-        
-        JSValue result;
-        if (type == Normal) {
-            result = completion.value();
-            if (!result)
-                result = jsUndefined();
-        } else
-            result = jsUndefined();
 
-        convertValueToNPVariant(exec, result, variant);
+        convertValueToNPVariant(exec, returnValue, variant);
         exec->clearException();
         return true;
     }
index 80f9398..1c6f1fb 100644 (file)
@@ -306,8 +306,6 @@ jobject JavaJSObject::call(jstring methodName, jobjectArray args) const
 jobject JavaJSObject::eval(jstring script) const
 {
     LOG(LiveConnect, "JavaJSObject::eval script = %s", JavaString(script).utf8());
-    
-    JSValue result;
 
     JSLock lock(SilenceAssertionsOnly);
     
@@ -316,18 +314,10 @@ jobject JavaJSObject::eval(jstring script) const
         return 0;
 
     rootObject->globalObject()->globalData().timeoutChecker.start();
-    Completion completion = JSC::evaluate(rootObject->globalObject()->globalExec(), rootObject->globalObject()->globalScopeChain(), makeSource(JavaString(script).impl()), JSC::JSValue());
+    JSValue result = JSC::evaluate(rootObject->globalObject()->globalExec(), rootObject->globalObject()->globalScopeChain(), makeSource(JavaString(script).impl()));
     rootObject->globalObject()->globalData().timeoutChecker.stop();
-    ComplType type = completion.complType();
-    
-    if (type == Normal) {
-        result = completion.value();
-        if (!result)
-            result = jsUndefined();
-    } else
-        result = jsUndefined();
-    
-    return convertValueToJObject (result);
+
+    return convertValueToJObject(result);
 }
 
 jobject JavaJSObject::getMember(jstring memberName) const
index 4adfb56..3365283 100644 (file)
@@ -1,3 +1,13 @@
+2011-09-08  Sam Weinig  <sam@webkit.org>
+
+        Remove the Completion object from JSC, I have never liked it
+        https://bugs.webkit.org/show_bug.cgi?id=67755
+
+        Reviewed by Gavin Barraclough.
+
+        * Plugins/Hosted/NetscapePluginInstanceProxy.mm:
+        (WebKit::NetscapePluginInstanceProxy::evaluate):
+
 2011-09-07  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r94627 and r94632.
index 142db94..af0a873 100644 (file)
@@ -41,6 +41,7 @@
 #import "WebUIDelegate.h"
 #import "WebUIDelegatePrivate.h"
 #import "WebViewInternal.h"
+#import <JavaScriptCore/Completion.h>
 #import <JavaScriptCore/Error.h>
 #import <JavaScriptCore/JSLock.h>
 #import <JavaScriptCore/PropertyNameArray.h>
@@ -875,17 +876,10 @@ bool NetscapePluginInstanceProxy::evaluate(uint32_t objectID, const String& scri
     globalObject->globalData().timeoutChecker.start();
 
     UserGestureIndicator gestureIndicator(allowPopups ? DefinitelyProcessingUserGesture : PossiblyProcessingUserGesture);
-    Completion completion = JSC::evaluate(exec, globalObject->globalScopeChain(), makeSource(script));
-
-    globalObject->globalData().timeoutChecker.stop();
-    ComplType type = completion.complType();
-
-    JSValue result;
-    if (type == Normal)
-        result = completion.value();
     
-    if (!result)
-        result = jsUndefined();
+    JSValue result = JSC::evaluate(exec, globalObject->globalScopeChain(), makeSource(script));
+    
+    globalObject->globalData().timeoutChecker.stop();
     
     marshalValue(exec, result, resultData, resultLength);
     exec->clearException();
index 96fdd94..b6a82b4 100644 (file)
@@ -33,6 +33,7 @@
 #include "GraphicsContext.h"
 #include "HTMLElement.h"
 #if USE(JSC)
+#include "Completion.h"
 #include "JSGlobalObject.h"
 #include "JSHTMLElement.h"
 #include "JSObject.h"
@@ -789,16 +790,14 @@ QVariant QWebElement::evaluateJavaScript(const QString& scriptSource)
 #if USE(JSC)
     JSC::ScopeChainNode* scopeChain = state->dynamicGlobalObject()->globalScopeChain();
     JSC::UString script(reinterpret_cast_ptr<const UChar*>(scriptSource.data()), scriptSource.length());
-    JSC::Completion completion = JSC::evaluate(state, scopeChain, JSC::makeSource(script), thisValue);
-    if ((completion.complType() != JSC::ReturnValue) && (completion.complType() != JSC::Normal))
-        return QVariant();
 
-    JSC::JSValue result = completion.value();
-    if (!result)
+    JSC::JSValue evaluationException;
+    JSC::JSValue evaluationResult = JSC::evaluate(state, scopeChain, JSC::makeSource(script), thisValue, &evaluationException);
+    if (evaluationException)
         return QVariant();
 
     int distance = 0;
-    return JSC::Bindings::convertValueToQVariant(state, result, QMetaType::Void, &distance);
+    return JSC::Bindings::convertValueToQVariant(state, evaluationResult, QMetaType::Void, &distance);
 #elif USE(V8)
     notImplemented();
     return QVariant();
index 3500bd0..f4c72d9 100644 (file)
@@ -1,3 +1,13 @@
+2011-09-08  Sam Weinig  <sam@webkit.org>
+
+        Remove the Completion object from JSC, I have never liked it
+        https://bugs.webkit.org/show_bug.cgi?id=67755
+
+        Reviewed by Gavin Barraclough.
+
+        * Api/qwebelement.cpp:
+        (QWebElement::evaluateJavaScript):
+
 2011-09-05  Jocelyn Turcotte  <jocelyn.turcotte@nokia.com>
 
         [Qt][WK2] Make TiledDrawingArea request tiles only in the direction the viewport is panned to.
index df18f4a..b88b38d 100644 (file)
@@ -1,3 +1,13 @@
+2011-09-08  Sam Weinig  <sam@webkit.org>
+
+        Remove the Completion object from JSC, I have never liked it
+        https://bugs.webkit.org/show_bug.cgi?id=67755
+
+        Reviewed by Gavin Barraclough.
+
+        * WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp:
+        (WebKit::NPRuntimeObjectMap::evaluate):
+
 2011-09-08  Anders Carlsson  <andersca@apple.com>
 
         Don't release the modal placeholder window if it's closed
index e936524..04eb2a4 100644 (file)
@@ -465,7 +465,7 @@ PassOwnPtr<ArgumentDecoder> Connection::waitForSyncReply(uint64_t syncRequestID,
 
         // We didn't find a sync reply yet, keep waiting.
 #if PLATFORM(WIN)
-        timedOut = !m_syncMessageState->waitWhileDispatchingSentWin32Messages(absoluteTime, m_client->windowsToReceiveSentMessagesWhileWaitingForSyncReply());
+        timedOut = !m_syncMessageState->wait\oluteTime, m_client->windowsToReceiveSentMessagesWhileWaitingForSyncReply());
 #else
 
         // This allows the WebProcess to still serve clients while waiting for the message to return. 
index 93f46eb..3f34aa4 100644 (file)
@@ -31,6 +31,7 @@
 #include "NPRuntimeUtilities.h"
 #include "PluginView.h"
 #include "WebProcess.h"
+#include <JavaScriptCore/Completion.h>
 #include <JavaScriptCore/Error.h>
 #include <JavaScriptCore/JSLock.h>
 #include <JavaScriptCore/SourceCode.h>
@@ -188,21 +189,9 @@ bool NPRuntimeObjectMap::evaluate(NPObject* npObject, const String&scriptString,
     JSValue thisValue = getOrCreateJSObject(globalObject.get(), npObject);
 
     globalObject->globalData().timeoutChecker.start();
-    Completion completion = JSC::evaluate(exec, globalObject->globalScopeChain(), makeSource(UString(scriptString.impl())), thisValue);
+    JSValue resultValue = JSC::evaluate(exec, globalObject->globalScopeChain(), makeSource(UString(scriptString.impl())), thisValue);
     globalObject->globalData().timeoutChecker.stop();
 
-    ComplType completionType = completion.complType();
-
-    JSValue resultValue;
-    if (completionType == Normal) {
-        resultValue = completion.value();
-        if (!resultValue)
-            resultValue = jsUndefined();
-    } else
-        resultValue = jsUndefined();
-
-    exec->clearException();
-    
     convertJSValueToNPVariant(exec, resultValue, *result);
     return true;
 }