X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/12899fa232562c774004a3a9d7d3149944dec712..HEAD:/API/APICallbackFunction.h diff --git a/API/APICallbackFunction.h b/API/APICallbackFunction.h index 0298ecb..94b10c4 100644 --- a/API/APICallbackFunction.h +++ b/API/APICallbackFunction.h @@ -27,9 +27,9 @@ #define APICallbackFunction_h #include "APICast.h" -#include "APIShims.h" #include "Error.h" #include "JSCallbackConstructor.h" +#include "JSLock.h" #include namespace JSC { @@ -42,26 +42,26 @@ template static EncodedJSValue JSC_HOST_CALL construct(ExecState*); }; template -EncodedJSValue APICallbackFunction::call(ExecState* exec) +EncodedJSValue JSC_HOST_CALL APICallbackFunction::call(ExecState* exec) { JSContextRef execRef = toRef(exec); JSObjectRef functionRef = toRef(exec->callee()); - JSObjectRef thisObjRef = toRef(exec->hostThisValue().toThisObject(exec)); + JSObjectRef thisObjRef = toRef(jsCast(exec->thisValue().toThis(exec, NotStrictMode))); int argumentCount = static_cast(exec->argumentCount()); Vector arguments; arguments.reserveInitialCapacity(argumentCount); for (int i = 0; i < argumentCount; i++) - arguments.uncheckedAppend(toRef(exec, exec->argument(i))); + arguments.uncheckedAppend(toRef(exec, exec->uncheckedArgument(i))); JSValueRef exception = 0; JSValueRef result; { - APICallbackShim callbackShim(exec); + JSLock::DropAllLocks dropAllLocks(exec); result = jsCast(toJS(functionRef))->functionCallback()(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), &exception); } if (exception) - throwError(exec, toJS(exec, exception)); + exec->vm().throwException(exec, toJS(exec, exception)); // result must be a valid JSValue. if (!result) @@ -83,16 +83,18 @@ EncodedJSValue JSC_HOST_CALL APICallbackFunction::construct(ExecState* exec) Vector arguments; arguments.reserveInitialCapacity(argumentCount); for (size_t i = 0; i < argumentCount; ++i) - arguments.uncheckedAppend(toRef(exec, exec->argument(i))); + arguments.uncheckedAppend(toRef(exec, exec->uncheckedArgument(i))); JSValueRef exception = 0; JSObjectRef result; { - APICallbackShim callbackShim(exec); + JSLock::DropAllLocks dropAllLocks(exec); result = callback(ctx, constructorRef, argumentCount, arguments.data(), &exception); } - if (exception) - throwError(exec, toJS(exec, exception)); + if (exception) { + exec->vm().throwException(exec, toJS(exec, exception)); + return JSValue::encode(toJS(exec, exception)); + } // result must be a valid JSValue. if (!result) return throwVMTypeError(exec);