Changeset 206476 in webkit


Ignore:
Timestamp:
Sep 27, 2016 5:26:15 PM (8 years ago)
Author:
mark.lam@apple.com
Message:

createError() and JSObject::calculatedClassName() should not throw any exceptions.
https://bugs.webkit.org/show_bug.cgi?id=162637

Reviewed by Geoffrey Garen.

  • runtime/ExceptionHelpers.cpp:

(JSC::createError):

  • assert that errorDescriptionForValue() did not throw an exception.
  • runtime/JSObject.cpp:

(JSC::JSObject::calculatedClassName):

  • the code already ensures that we always return a non-null String. Just need to make sure that it catches its own exceptions.
Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r206472 r206476  
     12016-09-27  Mark Lam  <mark.lam@apple.com>
     2
     3        createError() and JSObject::calculatedClassName() should not throw any exceptions.
     4        https://bugs.webkit.org/show_bug.cgi?id=162637
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * runtime/ExceptionHelpers.cpp:
     9        (JSC::createError):
     10        - assert that errorDescriptionForValue() did not throw an exception.
     11
     12        * runtime/JSObject.cpp:
     13        (JSC::JSObject::calculatedClassName):
     14        - the code already ensures that we always return a non-null String.  Just need to
     15          make sure that it catches its own exceptions.
     16
    1172016-09-27  Filip Pizlo  <fpizlo@apple.com>
    218
  • trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.cpp

    r206408 r206476  
    237237JSObject* createError(ExecState* exec, JSValue value, const String& message, ErrorInstance::SourceAppender appender)
    238238{
     239    VM& vm = exec->vm();
     240    auto scope = DECLARE_CATCH_SCOPE(vm);
     241
    239242    String errorMessage = makeString(errorDescriptionForValue(exec, value)->value(exec), ' ', message);
     243    ASSERT_UNUSED(scope, !scope.exception());
    240244    JSObject* exception = createTypeError(exec, errorMessage, appender, runtimeTypeForValue(value));
    241245    ASSERT(exception->isErrorInstance());
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r206386 r206476  
    231231{
    232232    String prototypeFunctionName;
    233     ExecState* exec = object->globalObject()->globalExec();
     233    auto globalObject = object->globalObject();
     234    VM& vm = globalObject->vm();
     235    auto scope = DECLARE_CATCH_SCOPE(vm);
     236
     237    ExecState* exec = globalObject->globalExec();
    234238    PropertySlot slot(object->getPrototypeDirect(), PropertySlot::InternalMethodType::VMInquiry);
    235239    PropertyName constructor(exec->propertyNames().constructor);
     
    240244                if (JSCell* constructorCell = constructorValue.asCell()) {
    241245                    if (JSObject* ctorObject = constructorCell->getObject()) {
    242                         VM& vm = exec->vm();
    243246                        if (JSFunction* constructorFunction = jsDynamicCast<JSFunction*>(ctorObject))
    244247                            prototypeFunctionName = constructorFunction->calculatedDisplayName(vm);
     
    250253        }
    251254    }
     255    ASSERT(!scope.exception() || prototypeFunctionName.isNull());
     256    if (UNLIKELY(scope.exception()))
     257        scope.clearException();
    252258
    253259    if (prototypeFunctionName.isNull() || prototypeFunctionName == "Object") {
Note: See TracChangeset for help on using the changeset viewer.