Ignore:
Timestamp:
May 8, 2017, 9:56:32 AM (8 years ago)
Author:
[email protected]
Message:

Introduce ExceptionScope::assertNoException() and releaseAssertNoException().
https://bugs.webkit.org/show_bug.cgi?id=171776

Reviewed by Keith Miller.

Source/JavaScriptCore:

Instead of ASSERT(!scope.exception()), we can now do scope.assertNoException().
Ditto for RELEASE_ASSERT and scope.releaseAssertNoException().

The advantage of using ExceptionScope::assertNoException() and
releaseAssertNoException() is that if the assertion fails, these utility
functions will print the stack trace for where the unexpected exception is
detected as well as where the unexpected exception was thrown from. This makes
it much easier to debug the source of unhandled exceptions.

  • debugger/Debugger.cpp:

(JSC::Debugger::pauseIfNeeded):

  • dfg/DFGOperations.cpp:
  • interpreter/Interpreter.cpp:

(JSC::eval):
(JSC::notifyDebuggerOfUnwinding):
(JSC::Interpreter::executeProgram):
(JSC::Interpreter::executeCall):
(JSC::Interpreter::executeConstruct):
(JSC::Interpreter::prepareForRepeatCall):
(JSC::Interpreter::execute):
(JSC::Interpreter::debug):

  • interpreter/ShadowChicken.cpp:

(JSC::ShadowChicken::functionsOnStack):

  • jsc.cpp:

(GlobalObject::moduleLoaderResolve):
(GlobalObject::moduleLoaderFetch):
(functionGenerateHeapSnapshot):
(functionSamplingProfilerStackTraces):
(box):
(runWithScripts):

  • runtime/AbstractModuleRecord.cpp:

(JSC::AbstractModuleRecord::finishCreation):

  • runtime/ArrayPrototype.cpp:

(JSC::ArrayPrototype::tryInitializeSpeciesWatchpoint):

  • runtime/Completion.cpp:

(JSC::rejectPromise):

  • runtime/ErrorInstance.cpp:

(JSC::ErrorInstance::sanitizedToString):

  • runtime/ExceptionHelpers.cpp:

(JSC::createError):

  • runtime/ExceptionScope.cpp:

(JSC::ExceptionScope::unexpectedExceptionMessage):

  • runtime/ExceptionScope.h:

(JSC::ExceptionScope::assertNoException):
(JSC::ExceptionScope::releaseAssertNoException):
(JSC::ExceptionScope::unexpectedExceptionMessage):

  • runtime/GenericArgumentsInlines.h:

(JSC::GenericArguments<Type>::defineOwnProperty):

  • runtime/IntlCollator.cpp:

(JSC::IntlCollator::createCollator):
(JSC::IntlCollator::resolvedOptions):

  • runtime/IntlDateTimeFormat.cpp:

(JSC::IntlDateTimeFormat::resolvedOptions):
(JSC::IntlDateTimeFormat::format):

  • runtime/IntlNumberFormat.cpp:

(JSC::IntlNumberFormat::createNumberFormat):
(JSC::IntlNumberFormat::resolvedOptions):

  • runtime/JSCJSValue.cpp:

(JSC::JSValue::putToPrimitiveByIndex):

  • runtime/JSGenericTypedArrayViewPrototypeFunctions.h:

(JSC::genericTypedArrayViewProtoFuncIncludes):
(JSC::genericTypedArrayViewProtoFuncIndexOf):
(JSC::genericTypedArrayViewProtoFuncLastIndexOf):
(JSC::genericTypedArrayViewPrivateFuncSubarrayCreate):

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::init):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::globalFuncHostPromiseRejectionTracker):

  • runtime/JSModuleEnvironment.cpp:

(JSC::JSModuleEnvironment::getOwnPropertySlot):

  • runtime/JSModuleLoader.cpp:

(JSC::JSModuleLoader::finishCreation):

  • runtime/JSModuleNamespaceObject.cpp:

(JSC::JSModuleNamespaceObject::finishCreation):

  • runtime/JSONObject.cpp:

(JSC::Stringifier::toJSON):

  • runtime/JSObject.cpp:

(JSC::JSObject::ordinaryToPrimitive):

  • runtime/JSPropertyNameEnumerator.h:

(JSC::propertyNameEnumerator):

  • runtime/ObjectConstructor.cpp:

(JSC::objectConstructorGetOwnPropertyDescriptors):
(JSC::objectConstructorDefineProperty):

  • runtime/ObjectPrototype.cpp:

(JSC::objectProtoFuncHasOwnProperty):

  • runtime/ProgramExecutable.cpp:

(JSC::ProgramExecutable::initializeGlobalProperties):

  • runtime/ReflectObject.cpp:

(JSC::reflectObjectDefineProperty):

  • runtime/SamplingProfiler.cpp:

(JSC::SamplingProfiler::StackFrame::nameFromCallee):

  • runtime/StringPrototype.cpp:

(JSC::stringProtoFuncRepeatCharacter):

  • runtime/TemplateRegistry.cpp:

(JSC::TemplateRegistry::getTemplateObject):

  • runtime/VM.cpp:

(JSC::VM::throwException):

  • runtime/VM.h:

(JSC::VM::nativeStackTraceOfLastThrow):
(JSC::VM::clearException):

  • wasm/WasmB3IRGenerator.cpp:
  • wasm/js/JSWebAssemblyInstance.cpp:

(JSC::JSWebAssemblyInstance::create):

Source/WebCore:

No new tests because there's no behavior change in functionality. We're only
refactoring the code to use the new assertion utility function.

  • Modules/plugins/QuickTimePluginReplacement.mm:

(WebCore::QuickTimePluginReplacement::installReplacement):

  • bindings/js/JSCryptoKeySerializationJWK.cpp:

(WebCore::getJSArrayFromJSON):
(WebCore::getStringFromJSON):
(WebCore::getBooleanFromJSON):

  • bindings/js/JSCustomElementRegistryCustom.cpp:

(WebCore::JSCustomElementRegistry::whenDefined):

  • bindings/js/JSDOMExceptionHandling.cpp:

(WebCore::propagateExceptionSlowPath):
(WebCore::throwNotSupportedError):
(WebCore::throwInvalidStateError):
(WebCore::throwSecurityError):
(WebCore::throwDOMSyntaxError):
(WebCore::throwDataCloneError):
(WebCore::throwIndexSizeError):
(WebCore::throwTypeMismatchError):

  • bindings/js/JSDOMGlobalObject.cpp:

(WebCore::makeThisTypeErrorForBuiltins):
(WebCore::makeGetterTypeErrorForBuiltins):

  • bindings/js/JSDOMGlobalObjectTask.cpp:
  • bindings/js/JSDOMPromise.h:

(WebCore::callPromiseFunction):

  • bindings/js/JSDOMWindowBase.cpp:

(WebCore::JSDOMWindowMicrotaskCallback::call):

  • bindings/js/JSMainThreadExecState.h:

(WebCore::JSMainThreadExecState::~JSMainThreadExecState):

  • bindings/js/ReadableStreamDefaultController.cpp:

(WebCore::ReadableStreamDefaultController::isControlledReadableStreamLocked):

  • bindings/js/ReadableStreamDefaultController.h:

(WebCore::ReadableStreamDefaultController::enqueue):

  • bindings/js/SerializedScriptValue.cpp:

(WebCore::CloneDeserializer::readTerminal):

  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateSerializerFunction):

  • bindings/scripts/test/JS/JSTestNode.cpp:

(WebCore::JSTestNode::serialize):

  • bindings/scripts/test/JS/JSTestObj.cpp:

(WebCore::JSTestObj::serialize):

  • bindings/scripts/test/JS/JSTestSerialization.cpp:

(WebCore::JSTestSerialization::serialize):

  • bindings/scripts/test/JS/JSTestSerializationInherit.cpp:

(WebCore::JSTestSerializationInherit::serialize):

  • bindings/scripts/test/JS/JSTestSerializationInheritFinal.cpp:

(WebCore::JSTestSerializationInheritFinal::serialize):

  • contentextensions/ContentExtensionParser.cpp:

(WebCore::ContentExtensions::getTypeFlags):

  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::didAddUserAgentShadowRoot):
(WebCore::HTMLMediaElement::updateMediaControlsAfterPresentationModeChange):
(WebCore::HTMLMediaElement::getCurrentMediaControlsStatus):

  • html/HTMLPlugInImageElement.cpp:

(WebCore::HTMLPlugInImageElement::didAddUserAgentShadowRoot):

Source/WTF:

  1. Add an option to skip some number of top frames when capturing the StackTrace.
  2. Add an option to use an indentation string when dumping the StackTrace.
  • wtf/StackTrace.cpp:

(WTF::StackTrace::captureStackTrace):
(WTF::StackTrace::dump):

  • wtf/StackTrace.h:
Location:
trunk/Source/JavaScriptCore/interpreter
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r215986 r216428  
    153153       
    154154        // If the literal parser bailed, it should not have thrown exceptions.
    155         ASSERT(!scope.exception());
     155        scope.assertNoException();
    156156
    157157        VariableEnvironment variablesUnderTDZ;
     
    594594        else
    595595            debugger->didExecuteProgram(callFrame);
    596         ASSERT_UNUSED(catchScope, !catchScope.exception());
     596        catchScope.assertNoException();
    597597    }
    598598}
     
    752752    RETURN_IF_EXCEPTION(throwScope, { });
    753753
    754     ASSERT(!throwScope.exception());
     754    throwScope.assertNoException();
    755755    ASSERT(!vm.isCollectorBusyOnCurrentThread());
    756756    RELEASE_ASSERT(vm.currentThreadIsHoldingAPILock());
     
    903903    auto throwScope = DECLARE_THROW_SCOPE(vm);
    904904
    905     ASSERT(!throwScope.exception());
     905    throwScope.assertNoException();
    906906    ASSERT(!vm.isCollectorBusyOnCurrentThread());
    907907    if (vm.isCollectorBusyOnCurrentThread())
     
    968968    auto throwScope = DECLARE_THROW_SCOPE(vm);
    969969
    970     ASSERT(!throwScope.exception());
     970    throwScope.assertNoException();
    971971    ASSERT(!vm.isCollectorBusyOnCurrentThread());
    972972    // We throw in this case because we have to return something "valid" but we're
     
    10371037    VM& vm = *scope->vm();
    10381038    auto throwScope = DECLARE_THROW_SCOPE(vm);
    1039     ASSERT_UNUSED(throwScope, !throwScope.exception());
     1039    throwScope.assertNoException();
    10401040   
    10411041    if (vm.isCollectorBusyOnCurrentThread())
     
    10891089
    10901090    ASSERT(scope->vm() == &callFrame->vm());
    1091     ASSERT(!throwScope.exception());
     1091    throwScope.assertNoException();
    10921092    ASSERT(!vm.isCollectorBusyOnCurrentThread());
    10931093    RELEASE_ASSERT(vm.currentThreadIsHoldingAPILock());
     
    12321232
    12331233    ASSERT(scope->vm() == &callFrame->vm());
    1234     ASSERT(!throwScope.exception());
     1234    throwScope.assertNoException();
    12351235    ASSERT(!vm.isCollectorBusyOnCurrentThread());
    12361236    RELEASE_ASSERT(vm.currentThreadIsHoldingAPILock());
     
    12851285
    12861286    ASSERT(callFrame->codeBlock()->hasDebuggerRequests());
    1287     ASSERT_UNUSED(scope, !scope.exception());
     1287    scope.assertNoException();
    12881288
    12891289    switch (debugHookType) {
     
    13101310            break;
    13111311    }
    1312     ASSERT(!scope.exception());
     1312    scope.assertNoException();
    13131313}
    13141314
  • trunk/Source/JavaScriptCore/interpreter/ShadowChicken.cpp

    r214905 r216428  
    458458        [&] (const Frame& frame) -> bool {
    459459            result->push(exec, frame.callee);
    460             RELEASE_ASSERT(!scope.exception()); // This function is only called from tests.
     460            scope.releaseAssertNoException(); // This function is only called from tests.
    461461            return true;
    462462        });
Note: See TracChangeset for help on using the changeset viewer.