Ignore:
Timestamp:
Sep 28, 2017, 11:09:09 AM (8 years ago)
Author:
[email protected]
Message:

Add missing exception checks and book-keeping for exception check validation.
https://bugs.webkit.org/show_bug.cgi?id=177609
<rdar://problem/34717972>

Reviewed by Keith Miller.

This resolves exception check validation failures when running test262 tests and
a few other tests.

  • API/APIUtils.h:

(handleExceptionIfNeeded):

  • API/JSObjectRef.cpp:

(JSObjectMakeFunction):
(JSObjectMakeArray):
(JSObjectMakeDate):
(JSObjectMakeError):
(JSObjectMakeRegExp):
(JSObjectSetPrototype):
(JSObjectGetProperty):
(JSObjectSetProperty):
(JSObjectGetPropertyAtIndex):
(JSObjectSetPropertyAtIndex):
(JSObjectDeleteProperty):
(JSObjectCallAsFunction):
(JSObjectCallAsConstructor):

  • API/JSTypedArray.cpp:

(JSObjectMakeTypedArray):
(JSObjectMakeTypedArrayWithBytesNoCopy):
(JSObjectMakeTypedArrayWithArrayBuffer):
(JSObjectMakeTypedArrayWithArrayBufferAndOffset):
(JSObjectMakeArrayBufferWithBytesNoCopy):

  • API/JSValueRef.cpp:

(JSValueIsEqual):
(JSValueIsInstanceOfConstructor):
(JSValueCreateJSONString):
(JSValueToNumber):
(JSValueToStringCopy):
(JSValueToObject):

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::executeProgram):

  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::LLINT_SLOW_PATH_DECL):

  • runtime/ArrayPrototype.cpp:

(JSC::arrayProtoFuncIndexOf):
(JSC::arrayProtoFuncLastIndexOf):

  • runtime/DatePrototype.cpp:

(JSC::fillStructuresUsingTimeArgs):
(JSC::setNewValueFromDateArgs):
(JSC::dateProtoFuncSetYear):

  • runtime/JSGenericTypedArrayViewConstructorInlines.h:

(JSC::constructGenericTypedArrayViewWithArguments):

  • runtime/JSModuleEnvironment.cpp:

(JSC::JSModuleEnvironment::put):

  • runtime/ProgramExecutable.cpp:

(JSC::ProgramExecutable::initializeGlobalProperties):

  • runtime/ProxyObject.cpp:

(JSC::ProxyObject::toStringName):

  • runtime/StringPrototype.cpp:

(JSC::stringProtoFuncCharAt):
(JSC::stringProtoFuncCharCodeAt):
(JSC::stringProtoFuncIndexOf):
(JSC::stringProtoFuncLastIndexOf):
(JSC::stringProtoFuncSlice):
(JSC::stringProtoFuncSplitFast):
(JSC::stringProtoFuncSubstr):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSValueRef.cpp

    r211247 r222617  
    224224    }
    225225    ExecState* exec = toJS(ctx);
    226     JSLockHolder locker(exec);
     226    VM& vm = exec->vm();
     227    JSLockHolder locker(vm);
     228    auto scope = DECLARE_CATCH_SCOPE(vm);
    227229
    228230    JSValue jsA = toJS(exec, a);
     
    230232
    231233    bool result = JSValue::equal(exec, jsA, jsB); // false if an exception is thrown
    232     handleExceptionIfNeeded(exec, exception);
     234    handleExceptionIfNeeded(scope, exec, exception);
    233235   
    234236    return result;
     
    257259    }
    258260    ExecState* exec = toJS(ctx);
    259     JSLockHolder locker(exec);
     261    VM& vm = exec->vm();
     262    JSLockHolder locker(vm);
     263    auto scope = DECLARE_CATCH_SCOPE(vm);
    260264
    261265    JSValue jsValue = toJS(exec, value);
     
    265269        return false;
    266270    bool result = jsConstructor->hasInstance(exec, jsValue); // false if an exception is thrown
    267     handleExceptionIfNeeded(exec, exception);
     271    handleExceptionIfNeeded(scope, exec, exception);
    268272    return result;
    269273}
     
    354358    }
    355359    ExecState* exec = toJS(ctx);
    356     JSLockHolder locker(exec);
     360    VM& vm = exec->vm();
     361    JSLockHolder locker(vm);
     362    auto scope = DECLARE_CATCH_SCOPE(vm);
     363
    357364    JSValue value = toJS(exec, apiValue);
    358365    String result = JSONStringify(exec, value, indent);
    359366    if (exception)
    360367        *exception = 0;
    361     if (handleExceptionIfNeeded(exec, exception) == ExceptionStatus::DidThrow)
     368    if (handleExceptionIfNeeded(scope, exec, exception) == ExceptionStatus::DidThrow)
    362369        return 0;
    363370    return OpaqueJSString::create(result).leakRef();
     
    384391    }
    385392    ExecState* exec = toJS(ctx);
    386     JSLockHolder locker(exec);
     393    VM& vm = exec->vm();
     394    JSLockHolder locker(vm);
     395    auto scope = DECLARE_CATCH_SCOPE(vm);
    387396
    388397    JSValue jsValue = toJS(exec, value);
    389398
    390399    double number = jsValue.toNumber(exec);
    391     if (handleExceptionIfNeeded(exec, exception) == ExceptionStatus::DidThrow)
     400    if (handleExceptionIfNeeded(scope, exec, exception) == ExceptionStatus::DidThrow)
    392401        number = PNaN;
    393402    return number;
     
    401410    }
    402411    ExecState* exec = toJS(ctx);
    403     JSLockHolder locker(exec);
     412    VM& vm = exec->vm();
     413    JSLockHolder locker(vm);
     414    auto scope = DECLARE_CATCH_SCOPE(vm);
    404415
    405416    JSValue jsValue = toJS(exec, value);
    406417   
    407418    auto stringRef(OpaqueJSString::create(jsValue.toWTFString(exec)));
    408     if (handleExceptionIfNeeded(exec, exception) == ExceptionStatus::DidThrow)
     419    if (handleExceptionIfNeeded(scope, exec, exception) == ExceptionStatus::DidThrow)
    409420        stringRef = nullptr;
    410421    return stringRef.leakRef();
     
    418429    }
    419430    ExecState* exec = toJS(ctx);
    420     JSLockHolder locker(exec);
     431    VM& vm = exec->vm();
     432    JSLockHolder locker(vm);
     433    auto scope = DECLARE_CATCH_SCOPE(vm);
    421434
    422435    JSValue jsValue = toJS(exec, value);
    423436   
    424437    JSObjectRef objectRef = toRef(jsValue.toObject(exec));
    425     if (handleExceptionIfNeeded(exec, exception) == ExceptionStatus::DidThrow)
     438    if (handleExceptionIfNeeded(scope, exec, exception) == ExceptionStatus::DidThrow)
    426439        objectRef = 0;
    427440    return objectRef;
Note: See TracChangeset for help on using the changeset viewer.