Changeset 154797 in webkit for trunk/Source/JavaScriptCore/jit/JITStubs.cpp
- Timestamp:
- Aug 28, 2013, 5:28:42 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/jit/JITStubs.cpp
r154429 r154797 45 45 #include "Debugger.h" 46 46 #include "DeferGC.h" 47 #include "ErrorInstance.h" 47 48 #include "ExceptionHelpers.h" 48 49 #include "GetterSetter.h" … … 325 326 static NEVER_INLINE void returnToThrowTrampoline(VM* vm, ReturnAddressPtr exceptionLocation, ReturnAddressPtr& returnAddressSlot) 326 327 { 327 RELEASE_ASSERT(vm->exception );328 RELEASE_ASSERT(vm->exception()); 328 329 vm->exceptionLocation = exceptionLocation; 329 330 returnAddressSlot = ReturnAddressPtr(FunctionPtr(ctiVMThrowTrampoline)); … … 342 343 #define CHECK_FOR_EXCEPTION() \ 343 344 do { \ 344 if (UNLIKELY(stackFrame.vm->exception )) \345 if (UNLIKELY(stackFrame.vm->exception())) \ 345 346 VM_THROW_EXCEPTION(); \ 346 347 } while (0) 347 348 #define CHECK_FOR_EXCEPTION_AT_END() \ 348 349 do { \ 349 if (UNLIKELY(stackFrame.vm->exception )) \350 if (UNLIKELY(stackFrame.vm->exception())) \ 350 351 VM_THROW_EXCEPTION_AT_END(); \ 351 352 } while (0) 352 353 #define CHECK_FOR_EXCEPTION_VOID() \ 353 354 do { \ 354 if (UNLIKELY(stackFrame.vm->exception )) { \355 if (UNLIKELY(stackFrame.vm->exception())) { \ 355 356 VM_THROW_EXCEPTION_AT_END(); \ 356 357 return; \ … … 398 399 }; 399 400 400 class ErrorWithExceptionFunctor : public ErrorFunctor {401 public:402 ErrorWithExceptionFunctor(JSValue exception)403 : m_exception(exception)404 {405 }406 JSValue operator()(ExecState*)407 {408 return m_exception;409 }410 411 private:412 JSValue m_exception;413 };414 415 401 // Helper function for JIT stubs that may throw an exception in the middle of 416 402 // processing a function call. This function rolls back the stack to 417 403 // our caller, so exception processing can proceed from a valid state. 418 template<typename T> static T throwExceptionFromOpCall(JITStackFrame& jitStackFrame, CallFrame* newCallFrame, ReturnAddressPtr& returnAddressSlot, ErrorFunctor & createError)404 template<typename T> static T throwExceptionFromOpCall(JITStackFrame& jitStackFrame, CallFrame* newCallFrame, ReturnAddressPtr& returnAddressSlot, ErrorFunctor* createError = 0) 419 405 { 420 406 CallFrame* callFrame = newCallFrame->callerFrame()->removeHostCallFrameFlag(); 421 407 jitStackFrame.callFrame = callFrame; 422 408 callFrame->vm().topCallFrame = callFrame; 423 callFrame->vm().exception = createError(callFrame); 424 ASSERT(callFrame->vm().exception); 409 if (createError) 410 callFrame->vm().throwException(callFrame, (*createError)(callFrame)); 411 ASSERT(callFrame->vm().exception()); 425 412 returnToThrowTrampoline(&callFrame->vm(), ReturnAddressPtr(newCallFrame->returnPC()), returnAddressSlot); 426 413 return T(); 427 }428 429 template<typename T> static T throwExceptionFromOpCall(JITStackFrame& jitStackFrame, CallFrame* newCallFrame, ReturnAddressPtr& returnAddressSlot)430 {431 CallFrame* callFrame = newCallFrame->callerFrame();432 ASSERT(callFrame->vm().exception);433 ErrorWithExceptionFunctor functor = ErrorWithExceptionFunctor(callFrame->vm().exception);434 return throwExceptionFromOpCall<T>(jitStackFrame, newCallFrame, returnAddressSlot, functor);435 414 } 436 415 … … 446 425 VM* vm = stackFrame.vm; 447 426 if (UNLIKELY(vm->watchdog.didFire(callFrame))) { 448 vm-> exception = createTerminatedExecutionException(vm);427 vm->throwException(callFrame, createTerminatedExecutionException(vm)); 449 428 VM_THROW_EXCEPTION_AT_END(); 450 429 return; … … 459 438 if (UNLIKELY(!stackFrame.stack->grow(&callFrame->registers()[callFrame->codeBlock()->m_numCalleeRegisters]))) { 460 439 ErrorWithExecFunctor functor = ErrorWithExecFunctor(createStackOverflowError); 461 return throwExceptionFromOpCall<void*>(stackFrame, callFrame, STUB_RETURN_ADDRESS, functor);440 return throwExceptionFromOpCall<void*>(stackFrame, callFrame, STUB_RETURN_ADDRESS, &functor); 462 441 } 463 442 … … 895 874 } 896 875 897 stackFrame.vm-> exception = createInvalidParameterError(callFrame, "instanceof", baseVal);876 stackFrame.vm->throwException(callFrame, createInvalidParameterError(callFrame, "instanceof", baseVal)); 898 877 VM_THROW_EXCEPTION_AT_END(); 899 878 return JSValue::encode(JSValue()); … … 1153 1132 JSValue result = jsBoolean(couldDelete); 1154 1133 if (!couldDelete && callFrame->codeBlock()->isStrictMode()) 1155 stackFrame.vm-> exception = createTypeError(stackFrame.callFrame, "Unable to delete property.");1134 stackFrame.vm->throwException(stackFrame.callFrame, createTypeError(stackFrame.callFrame, "Unable to delete property.")); 1156 1135 1157 1136 CHECK_FOR_EXCEPTION_AT_END(); … … 1193 1172 if (!error) 1194 1173 return function; 1195 callFrame->vm(). exception = error;1174 callFrame->vm().throwException(callFrame, error); 1196 1175 return 0; 1197 1176 } … … 1240 1219 if (missingArgCount < 0) { 1241 1220 ErrorWithExecFunctor functor = ErrorWithExecFunctor(createStackOverflowError); 1242 return throwExceptionFromOpCall<int>(stackFrame, callFrame, STUB_RETURN_ADDRESS, functor);1221 return throwExceptionFromOpCall<int>(stackFrame, callFrame, STUB_RETURN_ADDRESS, &functor); 1243 1222 } 1244 1223 return missingArgCount; … … 1254 1233 if (missingArgCount < 0) { 1255 1234 ErrorWithExecFunctor functor = ErrorWithExecFunctor(createStackOverflowError); 1256 return throwExceptionFromOpCall<int>(stackFrame, callFrame, STUB_RETURN_ADDRESS, functor);1235 return throwExceptionFromOpCall<int>(stackFrame, callFrame, STUB_RETURN_ADDRESS, &functor); 1257 1236 } 1258 1237 return missingArgCount; … … 1290 1269 FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable); 1291 1270 if (JSObject* error = functionExecutable->compileFor(callFrame, callee->scope(), kind)) { 1292 callFrame->vm(). exception = error;1271 callFrame->vm().throwException(callFrame, error); 1293 1272 return 0; 1294 1273 } … … 1368 1347 JSObject* error = functionExecutable->compileFor(callFrame, scopeChain, CodeForCall); 1369 1348 if (error) { 1370 callFrame->vm(). exception = error;1349 callFrame->vm().throwException(callFrame, error); 1371 1350 return 0; 1372 1351 } … … 1422 1401 ASSERT(callType == CallTypeNone); 1423 1402 ErrorWithExecAndCalleeFunctor functor = ErrorWithExecAndCalleeFunctor(createNotAFunctionError, callee); 1424 return throwExceptionFromOpCall<EncodedJSValue>(stackFrame, callFrame, STUB_RETURN_ADDRESS, functor);1403 return throwExceptionFromOpCall<EncodedJSValue>(stackFrame, callFrame, STUB_RETURN_ADDRESS, &functor); 1425 1404 } 1426 1405 … … 1431 1410 } 1432 1411 1433 if (stackFrame.vm->exception )1412 if (stackFrame.vm->exception()) 1434 1413 return throwExceptionFromOpCall<EncodedJSValue>(stackFrame, callFrame, STUB_RETURN_ADDRESS); 1435 1414 … … 1518 1497 ASSERT(constructType == ConstructTypeNone); 1519 1498 ErrorWithExecAndCalleeFunctor functor = ErrorWithExecAndCalleeFunctor(createNotAConstructorError, callee); 1520 return throwExceptionFromOpCall<EncodedJSValue>(stackFrame, callFrame, STUB_RETURN_ADDRESS, functor);1499 return throwExceptionFromOpCall<EncodedJSValue>(stackFrame, callFrame, STUB_RETURN_ADDRESS, &functor); 1521 1500 } 1522 1501 … … 1527 1506 } 1528 1507 1529 if (stackFrame.vm->exception )1508 if (stackFrame.vm->exception()) 1530 1509 return throwExceptionFromOpCall<EncodedJSValue>(stackFrame, callFrame, STUB_RETURN_ADDRESS); 1531 1510 … … 1667 1646 } else { 1668 1647 Identifier property(callFrame, subscript.toString(callFrame)->value(callFrame)); 1669 if (!callFrame->vm().exception ) { // Don't put to an object if toString threw an exception.1648 if (!callFrame->vm().exception()) { // Don't put to an object if toString threw an exception. 1670 1649 PutPropertySlot slot(callFrame->codeBlock()->isStrictMode()); 1671 1650 baseValue.put(callFrame, property, value, slot); … … 1953 1932 RegExp* regExp = stackFrame.args[0].regExp(); 1954 1933 if (!regExp->isValid()) { 1955 stackFrame.vm-> exception = createSyntaxError(callFrame, "Invalid flags supplied to RegExp constructor.");1934 stackFrame.vm->throwException(callFrame, createSyntaxError(callFrame, "Invalid flags supplied to RegExp constructor.")); 1956 1935 VM_THROW_EXCEPTION(); 1957 1936 } … … 1978 1957 1979 1958 JSValue result = eval(callFrame); 1980 if (stackFrame.vm->exception )1959 if (stackFrame.vm->exception()) 1981 1960 return throwExceptionFromOpCall<EncodedJSValue>(stackFrame, callFrame, STUB_RETURN_ADDRESS); 1982 1961 … … 1987 1966 { 1988 1967 STUB_INIT_STACK_FRAME(stackFrame); 1968 stackFrame.vm->throwException(stackFrame.callFrame, stackFrame.args[0].jsValue()); 1989 1969 ExceptionHandler handler = jitThrow(stackFrame.vm, stackFrame.callFrame, stackFrame.args[0].jsValue(), STUB_RETURN_ADDRESS); 1990 1970 STUB_SET_RETURN_ADDRESS(handler.catchRoutine); … … 2142 2122 String message = errorDescriptionForValue(callFrame, stackFrame.args[0].jsValue())->value(callFrame); 2143 2123 if (stackFrame.args[1].asInt32) 2144 stackFrame.vm-> exception = createReferenceError(callFrame, message);2124 stackFrame.vm->throwException(callFrame, createReferenceError(callFrame, message)); 2145 2125 else 2146 stackFrame.vm-> exception = createTypeError(callFrame, message);2126 stackFrame.vm->throwException(callFrame, createTypeError(callFrame, message)); 2147 2127 VM_THROW_EXCEPTION_AT_END(); 2148 2128 } … … 2166 2146 STUB_INIT_STACK_FRAME(stackFrame); 2167 2147 VM* vm = stackFrame.vm; 2168 ExceptionHandler handler = jitThrow(vm, stackFrame.callFrame, vm->exception , vm->exceptionLocation);2148 ExceptionHandler handler = jitThrow(vm, stackFrame.callFrame, vm->exception(), vm->exceptionLocation); 2169 2149 STUB_SET_RETURN_ADDRESS(handler.catchRoutine); 2170 2150 return handler.callFrame; … … 2182 2162 VM* vm = callFrame->codeBlock()->vm(); 2183 2163 vm->topCallFrame = callFrame; 2184 return encode(jitThrowNew(vm, callFrame, vm->exception ));2164 return encode(jitThrowNew(vm, callFrame, vm->exception())); 2185 2165 } 2186 2166 #else … … 2195 2175 VM* vm = callFrame->codeBlock()->vm(); 2196 2176 vm->topCallFrame = callFrame; 2197 return jitThrowNew(vm, callFrame, vm->exception );2177 return jitThrowNew(vm, callFrame, vm->exception()); 2198 2178 } 2199 2179 #endif … … 2230 2210 if (!scope->getPropertySlot(exec, ident, slot)) { 2231 2211 if (modeAndType.mode() == ThrowIfNotFound) { 2232 throwError(exec, createUndefinedVariableError(exec, ident));2212 exec->vm().throwException(exec, createUndefinedVariableError(exec, ident)); 2233 2213 VM_THROW_EXCEPTION(); 2234 2214 } … … 2262 2242 2263 2243 if (modeAndType.mode() == ThrowIfNotFound && !scope->hasProperty(exec, ident)) { 2264 throwError(exec, createUndefinedVariableError(exec, ident));2244 exec->vm().throwException(exec, createUndefinedVariableError(exec, ident)); 2265 2245 VM_THROW_EXCEPTION_AT_END(); 2266 2246 return; … … 2270 2250 scope->methodTable()->put(scope, exec, ident, value, slot); 2271 2251 2272 if (exec->vm().exception ) {2252 if (exec->vm().exception()) { 2273 2253 VM_THROW_EXCEPTION_AT_END(); 2274 2254 return;
Note:
See TracChangeset
for help on using the changeset viewer.