X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/f9bf01c6616d5ddcf65b13b33cedf9e387ff7a63..14957cd040308e3eeec43d26bae5d76da13fcd85:/runtime/Completion.cpp?ds=sidebyside diff --git a/runtime/Completion.cpp b/runtime/Completion.cpp index 2f88df9..ac19705 100644 --- a/runtime/Completion.cpp +++ b/runtime/Completion.cpp @@ -29,6 +29,7 @@ #include "Interpreter.h" #include "Parser.h" #include "Debugger.h" +#include "WTFThreadData.h" #include namespace JSC { @@ -36,9 +37,9 @@ namespace JSC { Completion checkSyntax(ExecState* exec, const SourceCode& source) { JSLock lock(exec); - ASSERT(exec->globalData().identifierTable == currentIdentifierTable()); + ASSERT(exec->globalData().identifierTable == wtfThreadData().currentIdentifierTable()); - RefPtr program = ProgramExecutable::create(exec, source); + ProgramExecutable* program = ProgramExecutable::create(exec, source); JSObject* error = program->checkSyntax(exec); if (error) return Completion(Throw, error); @@ -46,25 +47,30 @@ Completion checkSyntax(ExecState* exec, const SourceCode& source) return Completion(Normal); } -Completion evaluate(ExecState* exec, ScopeChain& scopeChain, const SourceCode& source, JSValue thisValue) +Completion evaluate(ExecState* exec, ScopeChainNode* scopeChain, const SourceCode& source, JSValue thisValue) { JSLock lock(exec); - ASSERT(exec->globalData().identifierTable == currentIdentifierTable()); + ASSERT(exec->globalData().identifierTable == wtfThreadData().currentIdentifierTable()); - RefPtr program = ProgramExecutable::create(exec, source); - JSObject* error = program->compile(exec, scopeChain.node()); - if (error) - return Completion(Throw, error); + ProgramExecutable* program = ProgramExecutable::create(exec, source); + if (!program) { + JSValue exception = exec->globalData().exception; + exec->globalData().exception = JSValue(); + return Completion(Throw, exception); + } JSObject* thisObj = (!thisValue || thisValue.isUndefinedOrNull()) ? exec->dynamicGlobalObject() : thisValue.toObject(exec); - JSValue exception; - JSValue result = exec->interpreter()->execute(program.get(), exec, scopeChain.node(), thisObj, &exception); + JSValue result = exec->interpreter()->execute(program, exec, scopeChain, thisObj); - if (exception) { - if (exception.isObject() && asObject(exception)->isWatchdogException()) - return Completion(Interrupted, exception); - return Completion(Throw, exception); + if (exec->hadException()) { + JSValue exception = exec->exception(); + exec->clearException(); + + ComplType exceptionType = Throw; + if (exception.isObject()) + exceptionType = asObject(exception)->exceptionType(); + return Completion(exceptionType, exception); } return Completion(Normal, result); }