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/JSObjectRef.cpp

    r222473 r222617  
    143143    VM& vm = exec->vm();
    144144    JSLockHolder locker(vm);
     145    auto scope = DECLARE_CATCH_SCOPE(vm);
    145146
    146147    startingLineNumber = std::max(1, startingLineNumber);
     
    154155    auto sourceURLString = sourceURL ? sourceURL->string() : String();
    155156    JSObject* result = constructFunction(exec, exec->lexicalGlobalObject(), args, nameID, SourceOrigin { sourceURLString }, sourceURLString, TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber()));
    156     if (handleExceptionIfNeeded(exec, exception) == ExceptionStatus::DidThrow)
     157    if (handleExceptionIfNeeded(scope, exec, exception) == ExceptionStatus::DidThrow)
    157158        result = 0;
    158159    return toRef(result);
     
    166167    }
    167168    ExecState* exec = toJS(ctx);
    168     JSLockHolder locker(exec);
     169    VM& vm = exec->vm();
     170    JSLockHolder locker(vm);
     171    auto scope = DECLARE_CATCH_SCOPE(vm);
    169172
    170173    JSObject* result;
     
    178181        result = constructEmptyArray(exec, 0);
    179182
    180     if (handleExceptionIfNeeded(exec, exception) == ExceptionStatus::DidThrow)
     183    if (handleExceptionIfNeeded(scope, exec, exception) == ExceptionStatus::DidThrow)
    181184        result = 0;
    182185
     
    191194    }
    192195    ExecState* exec = toJS(ctx);
    193     JSLockHolder locker(exec);
     196    VM& vm = exec->vm();
     197    JSLockHolder locker(vm);
     198    auto scope = DECLARE_CATCH_SCOPE(vm);
    194199
    195200    MarkedArgumentBuffer argList;
     
    198203
    199204    JSObject* result = constructDate(exec, exec->lexicalGlobalObject(), JSValue(), argList);
    200     if (handleExceptionIfNeeded(exec, exception) == ExceptionStatus::DidThrow)
     205    if (handleExceptionIfNeeded(scope, exec, exception) == ExceptionStatus::DidThrow)
    201206        result = 0;
    202207
     
    211216    }
    212217    ExecState* exec = toJS(ctx);
    213     JSLockHolder locker(exec);
     218    VM& vm = exec->vm();
     219    JSLockHolder locker(vm);
     220    auto scope = DECLARE_CATCH_SCOPE(vm);
    214221
    215222    JSValue message = argumentCount ? toJS(exec, arguments[0]) : jsUndefined();
     
    217224    JSObject* result = ErrorInstance::create(exec, errorStructure, message);
    218225
    219     if (handleExceptionIfNeeded(exec, exception) == ExceptionStatus::DidThrow)
     226    if (handleExceptionIfNeeded(scope, exec, exception) == ExceptionStatus::DidThrow)
    220227        result = 0;
    221228
     
    230237    }
    231238    ExecState* exec = toJS(ctx);
    232     JSLockHolder locker(exec);
     239    VM& vm = exec->vm();
     240    JSLockHolder locker(vm);
     241    auto scope = DECLARE_CATCH_SCOPE(vm);
    233242
    234243    MarkedArgumentBuffer argList;
     
    237246
    238247    JSObject* result = constructRegExp(exec, exec->lexicalGlobalObject(), argList);
    239     if (handleExceptionIfNeeded(exec, exception) == ExceptionStatus::DidThrow)
     248    if (handleExceptionIfNeeded(scope, exec, exception) == ExceptionStatus::DidThrow)
    240249        result = 0;
    241250   
     
    265274    VM& vm = exec->vm();
    266275    JSLockHolder locker(vm);
     276    auto scope = DECLARE_CATCH_SCOPE(vm);
    267277
    268278    JSObject* jsObject = toJS(object);
    269279    JSValue jsValue = toJS(exec, value);
    270280    jsObject->setPrototype(vm, exec, jsValue.isObject() ? jsValue : jsNull());
    271     handleExceptionIfNeeded(exec, nullptr);
     281    handleExceptionIfNeeded(scope, exec, nullptr);
    272282}
    273283
     
    296306    VM& vm = exec->vm();
    297307    JSLockHolder locker(vm);
     308    auto scope = DECLARE_CATCH_SCOPE(vm);
    298309
    299310    JSObject* jsObject = toJS(object);
    300311
    301312    JSValue jsValue = jsObject->get(exec, propertyName->identifier(&vm));
    302     handleExceptionIfNeeded(exec, exception);
     313    handleExceptionIfNeeded(scope, exec, exception);
    303314    return toRef(exec, jsValue);
    304315}
     
    329340        }
    330341    }
    331     handleExceptionIfNeeded(exec, exception);
     342    handleExceptionIfNeeded(scope, exec, exception);
    332343}
    333344
     
    339350    }
    340351    ExecState* exec = toJS(ctx);
    341     JSLockHolder locker(exec);
     352    VM& vm = exec->vm();
     353    JSLockHolder locker(vm);
     354    auto scope = DECLARE_CATCH_SCOPE(vm);
    342355
    343356    JSObject* jsObject = toJS(object);
    344357
    345358    JSValue jsValue = jsObject->get(exec, propertyIndex);
    346     handleExceptionIfNeeded(exec, exception);
     359    handleExceptionIfNeeded(scope, exec, exception);
    347360    return toRef(exec, jsValue);
    348361}
     
    358371    VM& vm = exec->vm();
    359372    JSLockHolder locker(vm);
     373    auto scope = DECLARE_CATCH_SCOPE(vm);
    360374
    361375    JSObject* jsObject = toJS(object);
     
    363377   
    364378    jsObject->methodTable(vm)->putByIndex(jsObject, exec, propertyIndex, jsValue, false);
    365     handleExceptionIfNeeded(exec, exception);
     379    handleExceptionIfNeeded(scope, exec, exception);
    366380}
    367381
     
    375389    VM& vm = exec->vm();
    376390    JSLockHolder locker(vm);
     391    auto scope = DECLARE_CATCH_SCOPE(vm);
    377392
    378393    JSObject* jsObject = toJS(object);
    379394
    380395    bool result = jsObject->methodTable(vm)->deleteProperty(jsObject, exec, propertyName->identifier(&vm));
    381     handleExceptionIfNeeded(exec, exception);
     396    handleExceptionIfNeeded(scope, exec, exception);
    382397    return result;
    383398}
     
    553568    VM& vm = exec->vm();
    554569    JSLockHolder locker(vm);
     570    auto scope = DECLARE_CATCH_SCOPE(vm);
    555571
    556572    if (!object)
     
    573589
    574590    JSValueRef result = toRef(exec, profiledCall(exec, ProfilingReason::API, jsObject, callType, callData, jsThisObject, argList));
    575     if (handleExceptionIfNeeded(exec, exception) == ExceptionStatus::DidThrow)
     591    if (handleExceptionIfNeeded(scope, exec, exception) == ExceptionStatus::DidThrow)
    576592        result = 0;
    577593    return result;
     
    592608    VM& vm = exec->vm();
    593609    JSLockHolder locker(vm);
     610    auto scope = DECLARE_CATCH_SCOPE(vm);
    594611
    595612    if (!object)
     
    608625
    609626    JSObjectRef result = toRef(profiledConstruct(exec, ProfilingReason::API, jsObject, constructType, constructData, argList));
    610     if (handleExceptionIfNeeded(exec, exception) == ExceptionStatus::DidThrow)
     627    if (handleExceptionIfNeeded(scope, exec, exception) == ExceptionStatus::DidThrow)
    611628        result = 0;
    612629    return result;
Note: See TracChangeset for help on using the changeset viewer.