Changeset 94811 in webkit for trunk/Source/JavaScriptCore/jsc.cpp


Ignore:
Timestamp:
Sep 8, 2011, 3:38:44 PM (14 years ago)
Author:
[email protected]
Message:

Remove the Completion object from JSC, I have never liked it
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):

(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):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/jsc.cpp

    r94644 r94811  
    262262
    263263    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
    264     Completion result = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(script.data(), fileName));
    265     if (result.complType() == Throw)
    266         throwError(exec, result.value());
    267     return JSValue::encode(result.value());
     264   
     265    JSValue evaluationException;
     266    JSValue result = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(script.data(), fileName), JSValue(), &evaluationException);
     267    if (evaluationException)
     268        throwError(exec, evaluationException);
     269    return JSValue::encode(result);
    268270}
    269271
     
    279281    StopWatch stopWatch;
    280282    stopWatch.start();
    281     Completion result = checkSyntax(globalObject->globalExec(), makeSource(script.data(), fileName));
     283
     284    JSValue syntaxException;
     285    bool validSyntax = checkSyntax(globalObject->globalExec(), makeSource(script.data(), fileName), &syntaxException);
    282286    stopWatch.stop();
    283287
    284     if (result.complType() == Throw)
    285         throwError(exec, result.value());
     288    if (!validSyntax)
     289        throwError(exec, syntaxException);
    286290    return JSValue::encode(jsNumber(stopWatch.getElapsedMS()));
    287291}
     
    437441        globalData.startSampling();
    438442
    439         Completion completion = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(script, fileName));
    440         success = success && completion.complType() != Throw;
     443        JSValue evaluationException;
     444        JSValue returnValue = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(script, fileName), JSValue(), &evaluationException);
     445        success = success && !evaluationException;
    441446        if (dump) {
    442             if (completion.complType() == Throw)
    443                 printf("Exception: %s\n", completion.value().toString(globalObject->globalExec()).utf8().data());
     447            if (evaluationException)
     448                printf("Exception: %s\n", evaluationException.toString(globalObject->globalExec()).utf8().data());
    444449            else
    445                 printf("End: %s\n", completion.value().toString(globalObject->globalExec()).utf8().data());
     450                printf("End: %s\n", returnValue.toString(globalObject->globalExec()).utf8().data());
    446451        }
    447452
     
    474479        if (line[0])
    475480            add_history(line);
    476         Completion completion = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(line, interpreterName));
     481        JSValue evaluationException;
     482        JSValue returnValue = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(line, interpreterName), JSValue(), &evaluationException);
    477483        free(line);
    478484#else
     
    489495            break;
    490496        line.append('\0');
    491         Completion completion = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(line.data(), interpreterName));
    492 #endif
    493         if (completion.complType() == Throw)
    494             printf("Exception: %s\n", completion.value().toString(globalObject->globalExec()).utf8().data());
     497
     498        JSValue evaluationException;
     499        JSValue returnValue = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(line.data(), interpreterName), JSValue(), &evaluationException);
     500#endif
     501        if (evaluationException)
     502            printf("Exception: %s\n", evaluationException.toString(globalObject->globalExec()).utf8().data());
    495503        else
    496             printf("%s\n", completion.value().toString(globalObject->globalExec()).utf8().data());
     504            printf("%s\n", returnValue.toString(globalObject->globalExec()).utf8().data());
    497505
    498506        globalObject->globalExec()->clearException();
Note: See TracChangeset for help on using the changeset viewer.