Changeset 205569 in webkit


Ignore:
Timestamp:
Sep 7, 2016, 3:10:50 PM (9 years ago)
Author:
mark.lam@apple.com
Message:

Add CatchScope and force all exception checks to be via ThrowScope or CatchScope.
https://bugs.webkit.org/show_bug.cgi?id=161498

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

This patch refactors the ThrowScope class, and introduces a base ExceptionScope
that ThrowScope extends. A CatchScope which extends the ExceptionScope is also
introduced.

ENABLE(THROW_SCOPE_VERIFICATION) is now renamed to ENABLE(EXCEPTION_SCOPE_VERIFICATION)
which is a more suitable name now.

Note: exception scope verification is still disabled by default. There are still
many places that need to be fixed up or re-expressed in a way that is friendly
to the verification. I'll address those in subsequent patches.

After this patch, the code will statically enforce that:

  1. all calls to throwException() go through a ThrowScope.
  2. all calls to clearException() go through a CatchScope.
  3. all exception checks go through an ExceptionScope in the form of a ThrowScope or CatchScope.

A Summary of how to use ExceptionScopes
=======================================

  1. If a function can throw a JS exception, it should declare a ThrowScope at the top of the function (as early as possible).
  1. If a function can clear JS exceptions, it should declare a CatchScope at the top of the function (as early as possible).

Declaring a ThrowScope in a function means that the function may throw an exception
that its caller will have to handle. Declaring a CatchScope in a function means
that the function intends to clear pending exceptions before returning to its
caller.

For more details, see the notes below.

Everything you may want to know about ExceptionScopes
=====================================================
ExceptionScope verification works to simulate exception throws and detect cases
where exception checks are missing. The notes below will cover:

  1. The VM::m_needExceptionCheck bit
  2. ThrowScopes and CatchScopes
  3. Verification of needed exception checks
  4. Checking Exceptions
  5. Simulating throws
  6. Using ThrowScope::release()
  7. Checking exceptions with ThrowScope::exception() / CatchScope::exception()
  8. Checking exceptions by checking callee results
  9. Debugging verification errors
  1. The VM::m_needExceptionCheck bit

The VM has a m_needExceptionCheck bit that indicates when an exception may be
thrown. You can think of the m_needExceptionCheck bit being set as a simulated
throw.

  1. ThrowScopes and CatchScopes

Only ThrowScopes may throwException. Only CatchScopes may catchException.

Every throw site must declare a ThrowScope instance using DECLARE_THROW_SCOPE
at the top of its function (as early as possible) e.g.


void foo(...)
{

auto scope = DECLARE_THROW_SCOPE(vm);
...
throwException(exec, scope, ...);

}

Note: by convention, every throw helper function must take a ThrowScope argument
instead of instantiating its own ThrowScope. This allows the throw to be
attributed to the client code rather than the throw helper itself.

Every catch site (i.e. a site that calls clearException()) must declare a
CatchScope instance using DECLARE_CATCH_SCOPE at the top of its function.

If a function can both throw or clear exceptions, then the ThrowScope should
be declared first so that it can simulate a throw to the function's caller.

Note: ThrowScope and CatchScope both extend ExceptionScope so that ThrowScopes
can be aware if there's an enclosing CatchScope between it and the point where
C++ code returns to JS code. This is needed to determine if the ThrowScope
should simulate a re-throw or not. See (4) below for more details on returning
to JS code.

  1. Verification of needed exception checks
  1. On construction, each ThrowScope and CatchScope will verify that VM::m_needExceptionCheck is not set.


This ensures that the caller of the current function has checked for exceptions
where needed before doing more work which lead to calling the current function.

  1. On destruction, each ThrowScope and CatchScope will verify that VM::m_needExceptionCheck is not set. This verification will be skipped if the ThrowScope has been released (see (5) below).

This ensures that the function that owns this exception scope is not missing
any exception checks before returning.

  1. When throwing an exception, the ThrowScope will verify that VM::m_needExceptionCheck is not already set, unless it's been ask to rethrow the same Exception object.
  1. Simulating throws

Throws are simulated by setting the m_needExceptionCheck bit.

The bit will only be set in the ThrowScope destructor except when the ThrowScope
detects the caller is a LLInt or JIT function. LLInt or JIT functions will always
check for exceptions after a host C++ function returns to it. However, they will
not clear the m_needExceptionCheck bit.

Hence, if the ThrowScope destructor detects the caller is a LLInt or JIT function,
it will just skip the setting of the bit.

Note: it is not needed nor correct to set the m_needExceptionCheck bit in the
throwException methods. This is because, in practice, we always return
immediately after throwing an exception. It doesn't make sense to set the bit in
the throw just to have to clear it immediately after before we do verification in
the ThrowScope destructor.

  1. Using ThrowScope::release()

Calling release() means that the scope is released from its obligation to
verify the VM::m_needExceptionCheck bit on destruction.

release() should only be used at the bottom of a function if:

  1. This function is going to let its caller check and handle the exception, e.g.

void foo(...)
{

auto scope = DECLARE_THROW_SCOPE(vm);
auto result = goo(); may throw.

... Code that will are not affected by a pending exceptions.

scope.release(); tell the ThrowScope that the caller will handle the exception.
return result;

}

  1. This function is going to do a tail call that may throw.

void foo(...)
{

auto scope = DECLARE_THROW_SCOPE(vm);
...
scope.release(); tell the ThrowScope that the caller will handle the exception.
return goo();
may throw.

}

release() should not be used in code paths that branch. For example:

void foo(...)
{

auto scope = DECLARE_THROW_SCOPE(vm);

auto result = goo1(); may throw.
scope.release();
WRONG !!! Don't do this.
if (result)

return;

result = goo2(); may throw.
...
return result;

}

The above will result in a verification error in goo2()'s ThrowScope. The
proper way to fix this verification is to do either (6) or (7) below.

  1. Checking exceptions with ThrowScope::exception() / CatchScope::exception()

ThrowScope/CatchScope::exception() returns the thrown Exception object if
there is one pending. Else, it returns nullptr.

It also clears the m_needExceptionCheck bit thereby indicating that we've
satisfied the needed exception check. For example,

void foo(...)
{

auto scope = DECLARE_THROW_SCOPE(vm);

auto result = goo1(); may throw.
if (scope.exception())

return;

result = goo2(); may throw.
...
return result;

}

But sometimes, for optimization reasons, we may choose to test the result of
the callee function instead doing a load of the VM exception value. See (7)
below.

  1. Checking exceptions by checking callee results

This approach should only be applied when it makes a difference to performance.
If we need to do this, we should add an ASSERT() that invokes the scope's
exception() method to verify the result. Since exception scope verification
is only done on DEBUG builds, this ASSERT will satisfy the verification
requirements without impacting performance. For example,

void foo(...)
{

auto scope = DECLARE_THROW_SCOPE(vm);

bool failed = goo1(); may throw.
ASSERT(!!scope.exception() == failed)
if (failed)

return;

result = goo2(); may throw.
...
return result;

}

  1. Debugging verification errors
  1. When verification fails, you will see a message followed by an assertion failure. For example:

ERROR: Unchecked JS exception:

This scope can throw a JS exception: setUpCall @ /Volumes/Data/ws6/OpenSource/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp:1245

(ExceptionScope::m_recursionDepth was ...)

But the exception was unchecked as of this scope: varargsSetup @ /Volumes/Data/ws6/OpenSource/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp:1398

(ExceptionScope::m_recursionDepth was ...)

[ backtrace here ]

The message tells you that failure was detected at in varargsSetup() at
LLIntSlowPaths.cpp line 1398, and that the missing exception check should
have happened somewhere between the call to setUpCall() at LLIntSlowPaths.cpp
line 1245 and it.

If that is insufficient information, you can ...

  1. Dump simulated throws

Re-run the test case with JSC_dumpSimulatedThrows=true. You will also see
back traces at each simulated throw.

  1. Narrowing down the source of a simulated throw

Another technique for narrowing down the source of simulated throws is by
further dividing a function to smaller regions by separating each region
with additional local throw scopes. For example,

... Region 1
{ auto scope = DECLARE_THROW_SCOPE(vm); }
...
Region 2
{ auto scope = DECLARE_THROW_SCOPE(vm); }
... Region 3

  • API/APIUtils.h:

(handleExceptionIfNeeded):

  • CMakeLists.txt:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • bindings/ScriptFunctionCall.cpp:

(Deprecated::ScriptFunctionCall::call):

  • bindings/ScriptValue.cpp:

(Deprecated::ScriptValue::toString):

  • debugger/Debugger.cpp:

(JSC::Debugger::pauseIfNeeded):

  • debugger/DebuggerCallFrame.cpp:

(JSC::DebuggerCallFrame::evaluateWithScopeExtension):

  • dfg/DFGOSRExitCompiler.cpp:
  • dfg/DFGOperations.cpp:

(JSC::DFG::operationPutByValInternal):

  • inspector/InjectedScriptManager.cpp:

(Inspector::InjectedScriptManager::createInjectedScript):

  • inspector/JSGlobalObjectInspectorController.cpp:

(Inspector::JSGlobalObjectInspectorController::reportAPIException):

  • inspector/JSInjectedScriptHost.cpp:

(Inspector::JSInjectedScriptHost::evaluateWithScopeExtension):
(Inspector::JSInjectedScriptHost::getInternalProperties):
(Inspector::JSInjectedScriptHost::weakMapEntries):
(Inspector::JSInjectedScriptHost::weakSetEntries):
(Inspector::JSInjectedScriptHost::iteratorEntries):

  • inspector/JSJavaScriptCallFrame.cpp:

(Inspector::JSJavaScriptCallFrame::evaluateWithScopeExtension):

  • inspector/ScriptCallStackFactory.cpp:

(Inspector::extractSourceInformationFromException):

  • interpreter/CachedCall.h:

(JSC::CachedCall::CachedCall):

  • interpreter/CallFrame.h:

(JSC::ExecState::clearException): Deleted.
(JSC::ExecState::exception): Deleted.
(JSC::ExecState::hadException): Deleted.
(JSC::ExecState::lastException): Deleted.
(JSC::ExecState::clearLastException): Deleted.

  • interpreter/Interpreter.cpp:

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

  • interpreter/Interpreter.h:

(JSC::SuspendExceptionScope::SuspendExceptionScope):

  • interpreter/ShadowChicken.cpp:

(JSC::ShadowChicken::functionsOnStack):

  • jit/JITCode.cpp:

(JSC::JITCode::execute):

  • jit/JITExceptions.cpp:

(JSC::genericUnwind):

  • jit/JITOperations.cpp:

(JSC::getByVal):

  • jsc.cpp:

(WTF::ImpureGetter::getOwnPropertySlot):
(GlobalObject::moduleLoaderResolve):
(GlobalObject::moduleLoaderFetch):
(functionCreateElement):
(functionRun):
(functionRunString):
(functionLoad):
(functionLoadString):
(functionReadFile):
(functionCheckSyntax):
(functionSetRandomSeed):
(functionLoadModule):
(functionCreateBuiltin):
(functionCheckModuleSyntax):
(functionGenerateHeapSnapshot):
(functionSamplingProfilerStackTraces):
(dumpException):
(checkUncaughtException):
(runWithScripts):
(runInteractive):

  • llint/LLIntExceptions.cpp:

(JSC::LLInt::returnToThrow):
(JSC::LLInt::callToThrow):

  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::LLINT_SLOW_PATH_DECL):

  • profiler/ProfilerBytecodeSequence.cpp:

(JSC::Profiler::BytecodeSequence::addSequenceProperties):

  • profiler/ProfilerCompilation.cpp:

(JSC::Profiler::Compilation::toJS):

  • profiler/ProfilerDatabase.cpp:

(JSC::Profiler::Database::toJS):

  • profiler/ProfilerOSRExitSite.cpp:

(JSC::Profiler::OSRExitSite::toJS):

  • profiler/ProfilerOriginStack.cpp:

(JSC::Profiler::OriginStack::toJS):

  • runtime/ArrayPrototype.cpp:

(JSC::speciesConstructArray):
(JSC::shift):
(JSC::unshift):
(JSC::arrayProtoFuncToString):
(JSC::arrayProtoFuncToLocaleString):
(JSC::slowJoin):
(JSC::fastJoin):
(JSC::arrayProtoFuncJoin):
(JSC::arrayProtoFuncPop):
(JSC::arrayProtoFuncPush):
(JSC::arrayProtoFuncReverse):
(JSC::arrayProtoFuncShift):
(JSC::arrayProtoFuncSlice):
(JSC::arrayProtoFuncSplice):
(JSC::arrayProtoFuncUnShift):
(JSC::arrayProtoFuncIndexOf):
(JSC::arrayProtoFuncLastIndexOf):
(JSC::moveElements):
(JSC::concatAppendOne):
(JSC::arrayProtoPrivateFuncConcatMemcpy):

  • runtime/BooleanConstructor.cpp:

(JSC::constructWithBooleanConstructor):

  • runtime/CallData.cpp:

(JSC::call):

  • runtime/CatchScope.cpp: Added.

(JSC::CatchScope::CatchScope):
(JSC::CatchScope::~CatchScope):

  • runtime/CatchScope.h: Added.

(JSC::CatchScope::clearException):
(JSC::CatchScope::CatchScope):

  • runtime/CommonSlowPaths.cpp:

(JSC::SLOW_PATH_DECL):

  • runtime/CommonSlowPaths.h:

(JSC::CommonSlowPaths::opIn):

  • runtime/CommonSlowPathsExceptions.cpp:

(JSC::CommonSlowPaths::interpreterThrowInCaller):

  • runtime/Completion.cpp:

(JSC::evaluate):
(JSC::rejectPromise):
(JSC::loadAndEvaluateModule):
(JSC::loadModule):

  • runtime/ConsoleObject.cpp:

(JSC::consoleProtoFuncAssert):
(JSC::consoleProtoFuncProfile):
(JSC::consoleProtoFuncProfileEnd):
(JSC::consoleProtoFuncTakeHeapSnapshot):
(JSC::consoleProtoFuncTime):
(JSC::consoleProtoFuncTimeEnd):

  • runtime/DateConstructor.cpp:

(JSC::constructDate):
(JSC::dateParse):

  • runtime/DatePrototype.cpp:

(JSC::dateProtoFuncToPrimitiveSymbol):
(JSC::dateProtoFuncToJSON):

  • runtime/ErrorConstructor.cpp:

(JSC::Interpreter::constructWithErrorConstructor):

  • runtime/ErrorInstance.cpp:

(JSC::ErrorInstance::sanitizedToString):

  • runtime/ErrorPrototype.cpp:

(JSC::errorProtoFuncToString):

  • runtime/ExceptionEventLocation.cpp: Added.

(WTF::printInternal):

  • runtime/ExceptionEventLocation.h: Copied from Source/JavaScriptCore/runtime/ThrowScopeLocation.h.

(JSC::ExceptionEventLocation::ExceptionEventLocation):
(JSC::ThrowScopeLocation::ThrowScopeLocation): Deleted.

  • runtime/ExceptionHelpers.h:
  • runtime/ExceptionScope.cpp: Added.

(JSC::ExceptionScope::ExceptionScope):
(JSC::ExceptionScope::~ExceptionScope):

  • runtime/ExceptionScope.h: Added.

(JSC::ExceptionScope::vm):
(JSC::ExceptionScope::recursionDepth):
(JSC::ExceptionScope::exception):
(JSC::ExceptionScope::ExceptionScope):

  • runtime/FunctionConstructor.cpp:

(JSC::constructFunctionSkippingEvalEnabledCheck):

  • runtime/FunctionPrototype.cpp:

(JSC::functionProtoFuncBind):

  • runtime/GenericArgumentsInlines.h:

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

  • runtime/GetterSetter.cpp:

(JSC::callGetter):

  • runtime/InspectorInstrumentationObject.cpp:

(JSC::inspectorInstrumentationObjectLog):

  • runtime/InternalFunction.cpp:

(JSC::InternalFunction::createSubclassStructure):

  • runtime/IntlCollator.cpp:

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

  • runtime/IntlCollatorConstructor.cpp:

(JSC::constructIntlCollator):
(JSC::IntlCollatorConstructorFuncSupportedLocalesOf):

  • runtime/IntlCollatorPrototype.cpp:

(JSC::IntlCollatorFuncCompare):
(JSC::IntlCollatorPrototypeGetterCompare):

  • runtime/IntlDateTimeFormat.cpp:

(JSC::toDateTimeOptionsAnyDate):
(JSC::IntlDateTimeFormat::initializeDateTimeFormat):
(JSC::IntlDateTimeFormat::resolvedOptions):
(JSC::IntlDateTimeFormat::format):

  • runtime/IntlDateTimeFormatConstructor.cpp:

(JSC::constructIntlDateTimeFormat):
(JSC::IntlDateTimeFormatConstructorFuncSupportedLocalesOf):

  • runtime/IntlDateTimeFormatPrototype.cpp:

(JSC::IntlDateTimeFormatFuncFormatDateTime):
(JSC::IntlDateTimeFormatPrototypeGetterFormat):

  • runtime/IntlNumberFormat.cpp:

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

  • runtime/IntlNumberFormatConstructor.cpp:

(JSC::constructIntlNumberFormat):
(JSC::IntlNumberFormatConstructorFuncSupportedLocalesOf):

  • runtime/IntlNumberFormatPrototype.cpp:

(JSC::IntlNumberFormatFuncFormatNumber):
(JSC::IntlNumberFormatPrototypeGetterFormat):

  • runtime/IntlObject.cpp:

(JSC::intlBooleanOption):
(JSC::intlStringOption):
(JSC::intlNumberOption):
(JSC::canonicalizeLocaleList):
(JSC::supportedLocales):

  • runtime/IntlObjectInlines.h:

(JSC::constructIntlInstanceWithWorkaroundForLegacyIntlConstructor):

  • runtime/IteratorOperations.cpp:

(JSC::iteratorNext):
(JSC::iteratorStep):
(JSC::iteratorClose):
(JSC::iteratorForIterable):

  • runtime/IteratorOperations.h:

(JSC::forEachInIterable):

  • runtime/JSArray.cpp:

(JSC::JSArray::pop):
(JSC::JSArray::push):
(JSC::JSArray::copyToArguments):

  • runtime/JSArrayBufferConstructor.cpp:

(JSC::constructArrayBuffer):

  • runtime/JSArrayBufferPrototype.cpp:

(JSC::arrayBufferProtoFuncSlice):

  • runtime/JSArrayInlines.h:

(JSC::getLength):
(JSC::toLength):

  • runtime/JSBoundFunction.cpp:

(JSC::getBoundFunctionStructure):
(JSC::JSBoundFunction::create):

  • runtime/JSCJSValue.cpp:

(JSC::JSValue::putToPrimitive):
(JSC::JSValue::putToPrimitiveByIndex):
(JSC::JSValue::toStringSlowCase):

  • runtime/JSCJSValueInlines.h:

(JSC::toPreferredPrimitiveType):
(JSC::JSValue::getPropertySlot):
(JSC::JSValue::equalSlowCaseInline):

  • runtime/JSDataViewPrototype.cpp:

(JSC::getData):
(JSC::setData):

  • runtime/JSFunction.cpp:

(JSC::JSFunction::setFunctionName):

  • runtime/JSGenericTypedArrayView.h:

(JSC::JSGenericTypedArrayView::setIndex):

  • runtime/JSGenericTypedArrayViewConstructorInlines.h:

(JSC::constructGenericTypedArrayViewFromIterator):
(JSC::constructGenericTypedArrayViewWithArguments):
(JSC::constructGenericTypedArrayView):

  • runtime/JSGenericTypedArrayViewPrototypeFunctions.h:

(JSC::speciesConstruct):
(JSC::genericTypedArrayViewProtoFuncCopyWithin):
(JSC::genericTypedArrayViewProtoFuncIncludes):
(JSC::genericTypedArrayViewProtoFuncIndexOf):
(JSC::genericTypedArrayViewProtoFuncJoin):
(JSC::genericTypedArrayViewProtoFuncLastIndexOf):
(JSC::genericTypedArrayViewProtoFuncSlice):
(JSC::genericTypedArrayViewPrivateFuncSubarrayCreate):

  • runtime/JSGlobalObject.h:

(JSC::constructEmptyArray):
(JSC::constructArray):
(JSC::constructArrayNegativeIndexed):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::globalFuncEval):

  • runtime/JSJob.cpp:

(JSC::JSJobMicrotask::run):

  • runtime/JSModuleEnvironment.cpp:

(JSC::JSModuleEnvironment::getOwnPropertySlot):

  • runtime/JSModuleLoader.cpp:

(JSC::JSModuleLoader::fetch):

  • runtime/JSModuleNamespaceObject.cpp:

(JSC::JSModuleNamespaceObject::finishCreation):
(JSC::JSModuleNamespaceObject::getOwnPropertySlot):

  • runtime/JSModuleRecord.cpp:

(JSC::JSModuleRecord::instantiateDeclarations):

  • runtime/JSONObject.cpp:

(JSC::Stringifier::Stringifier):
(JSC::Stringifier::stringify):
(JSC::Stringifier::toJSON):
(JSC::Stringifier::appendStringifiedValue):
(JSC::Stringifier::Holder::appendNextProperty):
(JSC::Walker::walk):
(JSC::JSONProtoFuncParse):

  • runtime/JSObject.cpp:

(JSC::ordinarySetSlow):
(JSC::JSObject::setPrototypeWithCycleCheck):
(JSC::callToPrimitiveFunction):
(JSC::JSObject::ordinaryToPrimitive):
(JSC::JSObject::defaultHasInstance):
(JSC::JSObject::getPropertyNames):
(JSC::JSObject::toNumber):
(JSC::JSObject::toString):
(JSC::JSObject::defineOwnNonIndexProperty):
(JSC::JSObject::getGenericPropertyNames):
(JSC::JSObject::getMethod):

  • runtime/JSObjectInlines.h:

(JSC::createListFromArrayLike):
(JSC::JSObject::getPropertySlot):
(JSC::JSObject::getNonIndexPropertySlot):

  • runtime/JSPromiseConstructor.cpp:

(JSC::constructPromise):

  • runtime/JSPropertyNameEnumerator.h:

(JSC::propertyNameEnumerator):

  • runtime/JSPropertyNameIterator.cpp:

(JSC::JSPropertyNameIterator::create):

  • runtime/JSScope.cpp:

(JSC::isUnscopable):
(JSC::JSScope::resolve):

  • runtime/JSString.cpp:

(JSC::JSString::equalSlowCase):

  • runtime/JSStringJoiner.cpp:

(JSC::JSStringJoiner::join):

  • runtime/LiteralParser.cpp:

(JSC::LiteralParser<CharType>::parse):

  • runtime/MapConstructor.cpp:

(JSC::constructMap):

  • runtime/MathObject.cpp:

(JSC::mathProtoFuncClz32):
(JSC::mathProtoFuncHypot):
(JSC::mathProtoFuncIMul):

  • runtime/ModuleLoaderPrototype.cpp:

(JSC::moduleLoaderPrototypeParseModule):
(JSC::moduleLoaderPrototypeRequestedModules):
(JSC::moduleLoaderPrototypeModuleDeclarationInstantiation):

  • runtime/NativeErrorConstructor.cpp:

(JSC::Interpreter::constructWithNativeErrorConstructor):

  • runtime/NumberConstructor.cpp:

(JSC::constructWithNumberConstructor):

  • runtime/ObjectConstructor.cpp:

(JSC::constructObject):
(JSC::objectConstructorGetPrototypeOf):
(JSC::objectConstructorSetPrototypeOf):
(JSC::objectConstructorGetOwnPropertyDescriptor):
(JSC::objectConstructorGetOwnPropertyDescriptors):
(JSC::objectConstructorGetOwnPropertyNames):
(JSC::objectConstructorGetOwnPropertySymbols):
(JSC::objectConstructorKeys):
(JSC::ownEnumerablePropertyKeys):
(JSC::toPropertyDescriptor):
(JSC::objectConstructorDefineProperty):
(JSC::defineProperties):
(JSC::objectConstructorSeal):
(JSC::objectConstructorFreeze):
(JSC::objectConstructorIsSealed):
(JSC::objectConstructorIsFrozen):
(JSC::objectConstructorIsExtensible):
(JSC::ownPropertyKeys):

  • runtime/ObjectConstructor.h:

(JSC::constructObjectFromPropertyDescriptor):

  • runtime/ObjectPrototype.cpp:

(JSC::objectProtoFuncHasOwnProperty):
(JSC::objectProtoFuncIsPrototypeOf):
(JSC::objectProtoFuncDefineGetter):
(JSC::objectProtoFuncDefineSetter):
(JSC::objectProtoFuncLookupGetter):
(JSC::objectProtoFuncLookupSetter):
(JSC::objectProtoFuncPropertyIsEnumerable):
(JSC::objectProtoFuncToLocaleString):
(JSC::objectProtoFuncToString):

  • runtime/Operations.cpp:

(JSC::jsAddSlowCase):

  • runtime/Options.h:
  • runtime/PropertyDescriptor.cpp:

(JSC::PropertyDescriptor::slowGetterSetter):

  • runtime/ProxyConstructor.cpp:

(JSC::makeRevocableProxy):

  • runtime/ProxyObject.cpp:

(JSC::ProxyObject::toStringName):
(JSC::performProxyGet):
(JSC::ProxyObject::performGet):
(JSC::ProxyObject::performInternalMethodGetOwnProperty):
(JSC::ProxyObject::performHasProperty):
(JSC::ProxyObject::performPut):
(JSC::ProxyObject::putByIndexCommon):
(JSC::performProxyCall):
(JSC::performProxyConstruct):
(JSC::ProxyObject::performDelete):
(JSC::ProxyObject::performPreventExtensions):
(JSC::ProxyObject::performIsExtensible):
(JSC::ProxyObject::performDefineOwnProperty):
(JSC::ProxyObject::performGetOwnPropertyNames):
(JSC::ProxyObject::performSetPrototype):
(JSC::ProxyObject::performGetPrototype):

  • runtime/ReflectObject.cpp:

(JSC::reflectObjectConstruct):
(JSC::reflectObjectDefineProperty):
(JSC::reflectObjectGet):
(JSC::reflectObjectGetOwnPropertyDescriptor):
(JSC::reflectObjectIsExtensible):
(JSC::reflectObjectPreventExtensions):
(JSC::reflectObjectSet):
(JSC::reflectObjectSetPrototypeOf):

  • runtime/RegExpConstructor.cpp:

(JSC::toFlags):
(JSC::regExpCreate):
(JSC::constructRegExp):

  • runtime/RegExpConstructor.h:

(JSC::isRegExp):

  • runtime/RegExpObject.cpp:

(JSC::collectMatches):
(JSC::RegExpObject::matchGlobal):

  • runtime/RegExpPrototype.cpp:

(JSC::regExpProtoFuncCompile):
(JSC::flagsString):
(JSC::regExpProtoFuncToString):
(JSC::regExpProtoGetterFlags):
(JSC::regExpProtoFuncSearchFast):
(JSC::regExpProtoFuncSplitFast):

  • runtime/SetConstructor.cpp:

(JSC::constructSet):

  • runtime/StringConstructor.cpp:

(JSC::stringFromCodePoint):
(JSC::constructWithStringConstructor):

  • runtime/StringObject.cpp:

(JSC::StringObject::defineOwnProperty):

  • runtime/StringPrototype.cpp:

(JSC::replaceUsingRegExpSearch):
(JSC::operationStringProtoFuncReplaceRegExpEmptyStr):
(JSC::replaceUsingStringSearch):
(JSC::replace):
(JSC::stringProtoFuncReplaceUsingRegExp):
(JSC::stringProtoFuncReplaceUsingStringSearch):
(JSC::stringProtoFuncCodePointAt):
(JSC::stringProtoFuncSlice):
(JSC::stringProtoFuncSplitFast):
(JSC::stringProtoFuncSubstr):
(JSC::stringProtoFuncSubstring):
(JSC::stringProtoFuncLocaleCompare):
(JSC::toLocaleCase):
(JSC::stringProtoFuncBig):
(JSC::stringProtoFuncSmall):
(JSC::stringProtoFuncBlink):
(JSC::stringProtoFuncBold):
(JSC::stringProtoFuncFixed):
(JSC::stringProtoFuncItalics):
(JSC::stringProtoFuncStrike):
(JSC::stringProtoFuncSub):
(JSC::stringProtoFuncSup):
(JSC::stringProtoFuncFontcolor):
(JSC::stringProtoFuncFontsize):
(JSC::stringProtoFuncAnchor):
(JSC::stringProtoFuncLink):
(JSC::trimString):
(JSC::stringProtoFuncStartsWith):
(JSC::stringProtoFuncEndsWith):
(JSC::stringIncludesImpl):
(JSC::stringProtoFuncIncludes):
(JSC::builtinStringIncludesInternal):
(JSC::stringProtoFuncNormalize):

  • runtime/SymbolConstructor.cpp:

(JSC::symbolConstructorFor):

  • runtime/TemplateRegistry.cpp:

(JSC::TemplateRegistry::getTemplateObject):

  • runtime/ThrowScope.cpp:

(JSC::ThrowScope::ThrowScope):
(JSC::ThrowScope::~ThrowScope):
(JSC::ThrowScope::throwException):
(JSC::ThrowScope::simulateThrow):
(JSC::ThrowScope::printIfNeedCheck): Deleted.
(JSC::ThrowScope::verifyExceptionCheckNeedIsSatisfied): Deleted.

  • runtime/ThrowScope.h:

(JSC::ThrowScope::release):
(JSC::ThrowScope::ThrowScope):
(JSC::ThrowScope::throwException):
(JSC::ThrowScope::vm): Deleted.
(JSC::ThrowScope::exception): Deleted.

  • runtime/ThrowScopeLocation.h: Removed.
  • runtime/VM.cpp:

(JSC::VM::verifyExceptionCheckNeedIsSatisfied):

  • runtime/VM.h:

(JSC::VM::exception):
(JSC::VM::clearException):
(JSC::VM::setException): Deleted.

  • runtime/WeakMapConstructor.cpp:

(JSC::constructWeakMap):

  • runtime/WeakSetConstructor.cpp:

(JSC::constructWeakSet):

  • tools/JSDollarVMPrototype.cpp:

(JSC::functionPrint):

Source/WebCore:

No new test because there is no behavior change in general except for 1 bug fix.
That bug is already caught by existing tests with the introduction of the CatchScope.

Fixes a bug in JSEventListener::handleEvent() where the exception thrown from
a failed attempt to get the handleEvent callback is not handled.

  • ForwardingHeaders/runtime/CatchScope.h: Added.
  • Modules/encryptedmedia/CDMSessionClearKey.cpp:

(WebCore::CDMSessionClearKey::update):

  • Modules/indexeddb/IDBObjectStore.cpp:

(WebCore::IDBObjectStore::putOrAdd):

  • Modules/indexeddb/server/UniqueIDBDatabase.cpp:

(WebCore::IDBServer::UniqueIDBDatabase::performPutOrAdd):

  • Modules/mediastream/SDPProcessor.cpp:

(WebCore::SDPProcessor::callScript):

  • Modules/plugins/QuickTimePluginReplacement.mm:

(WebCore::QuickTimePluginReplacement::ensureReplacementScriptInjected):
(WebCore::QuickTimePluginReplacement::installReplacement):

  • bindings/js/ArrayValue.cpp:

(WebCore::ArrayValue::get):

  • bindings/js/Dictionary.cpp:

(WebCore::Dictionary::getOwnPropertiesAsStringHashMap):

  • bindings/js/IDBBindingUtilities.cpp:

(WebCore::toJS):

  • bindings/js/JSApplePaySessionCustom.cpp:

(WebCore::JSApplePaySession::completeShippingMethodSelection):
(WebCore::JSApplePaySession::completeShippingContactSelection):
(WebCore::JSApplePaySession::completePaymentMethodSelection):

  • bindings/js/JSAudioTrackCustom.cpp:

(WebCore::JSAudioTrack::setKind):
(WebCore::JSAudioTrack::setLanguage):

  • bindings/js/JSBlobCustom.cpp:

(WebCore::constructJSBlob):

  • bindings/js/JSCSSStyleDeclarationCustom.cpp:

(WebCore::JSCSSStyleDeclaration::getPropertyCSSValue):

  • bindings/js/JSCommandLineAPIHostCustom.cpp:

(WebCore::getJSListenerFunctions):

  • bindings/js/JSCryptoAlgorithmDictionary.cpp:

(WebCore::JSCryptoAlgorithmDictionary::getAlgorithmIdentifier):
(WebCore::getHashAlgorithm):
(WebCore::createAesCbcParams):
(WebCore::createAesKeyGenParams):
(WebCore::createHmacParams):
(WebCore::createHmacKeyParams):
(WebCore::createRsaKeyGenParams):
(WebCore::createRsaOaepParams):
(WebCore::createRsaSsaParams):

  • bindings/js/JSCryptoKeySerializationJWK.cpp:

(WebCore::getJSArrayFromJSON):
(WebCore::getStringFromJSON):
(WebCore::getBooleanFromJSON):
(WebCore::JSCryptoKeySerializationJWK::JSCryptoKeySerializationJWK):
(WebCore::JSCryptoKeySerializationJWK::reconcileUsages):
(WebCore::JSCryptoKeySerializationJWK::keyDataOctetSequence):
(WebCore::JSCryptoKeySerializationJWK::keyDataRSAComponents):
(WebCore::JSCryptoKeySerializationJWK::keyData):
(WebCore::buildJSONForRSAComponents):
(WebCore::addUsagesToJSON):
(WebCore::JSCryptoKeySerializationJWK::serialize):

  • bindings/js/JSCustomElementInterface.cpp:

(WebCore::JSCustomElementInterface::constructElement):
(WebCore::constructCustomElementSynchronously):
(WebCore::JSCustomElementInterface::upgradeElement):

  • bindings/js/JSCustomElementRegistryCustom.cpp:

(WebCore::getCustomElementCallback):
(WebCore::JSCustomElementRegistry::define):
(WebCore::whenDefinedPromise):
(WebCore::JSCustomElementRegistry::whenDefined):

  • bindings/js/JSDOMBinding.cpp:

(WebCore::valueToUSVString):
(WebCore::reportException):
(WebCore::reportCurrentException):
(WebCore::setDOMException):
(WebCore::hasIteratorMethod):
(WebCore::toSmallerInt):
(WebCore::toSmallerUInt):
(WebCore::toInt32EnforceRange):
(WebCore::toUInt32EnforceRange):
(WebCore::toInt64EnforceRange):
(WebCore::toUInt64EnforceRange):
(WebCore::throwNotSupportedError):
(WebCore::throwInvalidStateError):
(WebCore::throwSecurityError):

  • bindings/js/JSDOMBinding.h:

(WebCore::toJSSequence):
(WebCore::toJS):
(WebCore::jsFrozenArray):
(WebCore::NativeValueTraits<String>::nativeValue):
(WebCore::NativeValueTraits<unsigned>::nativeValue):
(WebCore::NativeValueTraits<float>::nativeValue):
(WebCore::NativeValueTraits<double>::nativeValue):
(WebCore::toNativeArray):

  • bindings/js/JSDOMGlobalObject.cpp:

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

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

(WebCore::iteratorForEach):

  • bindings/js/JSDOMPromise.cpp:

(WebCore::rejectPromiseWithExceptionIfAny):

  • bindings/js/JSDOMPromise.h:

(WebCore::callPromiseFunction):

  • bindings/js/JSDOMStringMapCustom.cpp:

(WebCore::JSDOMStringMap::putDelegate):

  • bindings/js/JSDOMWindowBase.cpp:

(WebCore::JSDOMWindowMicrotaskCallback::call):

  • bindings/js/JSDOMWindowCustom.cpp:

(WebCore::JSDOMWindow::setLocation):
(WebCore::JSDOMWindow::open):
(WebCore::JSDOMWindow::showModalDialog):
(WebCore::handlePostMessage):
(WebCore::JSDOMWindow::setTimeout):
(WebCore::JSDOMWindow::setInterval):

  • bindings/js/JSDataCueCustom.cpp:

(WebCore::constructJSDataCue):

  • bindings/js/JSDeviceMotionEventCustom.cpp:

(WebCore::readAccelerationArgument):
(WebCore::readRotationRateArgument):
(WebCore::JSDeviceMotionEvent::initDeviceMotionEvent):

  • bindings/js/JSDictionary.cpp:

(WebCore::JSDictionary::tryGetProperty):
(WebCore::JSDictionary::convertValue):

  • bindings/js/JSDictionary.h:

(WebCore::JSDictionary::tryGetPropertyAndResult):

  • bindings/js/JSDocumentCustom.cpp:

(WebCore::JSDocument::getCSSCanvasContext):

  • bindings/js/JSEventListener.cpp:

(WebCore::JSEventListener::handleEvent):

  • bindings/js/JSFileCustom.cpp:

(WebCore::constructJSFile):

  • bindings/js/JSGeolocationCustom.cpp:

(WebCore::createPositionOptions):
(WebCore::JSGeolocation::getCurrentPosition):
(WebCore::JSGeolocation::watchPosition):

  • bindings/js/JSHTMLAllCollectionCustom.cpp:

(WebCore::callHTMLAllCollection):

  • bindings/js/JSHTMLCanvasElementCustom.cpp:

(WebCore::get3DContextAttributes):
(WebCore::JSHTMLCanvasElement::getContext):
(WebCore::JSHTMLCanvasElement::probablySupportsContext):

  • bindings/js/JSHTMLElementCustom.cpp:

(WebCore::constructJSHTMLElement):

  • bindings/js/JSHistoryCustom.cpp:

(WebCore::JSHistory::pushState):
(WebCore::JSHistory::replaceState):

  • bindings/js/JSIDBDatabaseCustom.cpp:

(WebCore::JSIDBDatabase::createObjectStore):

  • bindings/js/JSLazyEventListener.cpp:

(WebCore::JSLazyEventListener::initializeJSFunction):

  • bindings/js/JSMainThreadExecState.h:

(WebCore::JSMainThreadExecState::linkAndEvaluateModule):
(WebCore::JSMainThreadExecState::~JSMainThreadExecState):

  • bindings/js/JSMessageEventCustom.cpp:

(WebCore::handleInitMessageEvent):

  • bindings/js/JSMessagePortCustom.cpp:

(WebCore::fillMessagePortArray):

  • bindings/js/JSMessagePortCustom.h:

(WebCore::handlePostMessage):

  • bindings/js/JSMockContentFilterSettingsCustom.cpp:

(WebCore::JSMockContentFilterSettings::setDecisionPoint):
(WebCore::toDecision):
(WebCore::JSMockContentFilterSettings::setDecision):
(WebCore::JSMockContentFilterSettings::setUnblockRequestDecision):

  • bindings/js/JSNodeFilterCustom.cpp:

(WebCore::JSNodeFilter::acceptNode):

  • bindings/js/JSNodeOrString.cpp:

(WebCore::toNodeOrStringVector):

  • bindings/js/JSSQLTransactionCustom.cpp:

(WebCore::JSSQLTransaction::executeSql):

  • bindings/js/JSSVGLengthCustom.cpp:

(WebCore::JSSVGLength::convertToSpecifiedUnits):

  • bindings/js/JSStorageCustom.cpp:

(WebCore::JSStorage::getOwnPropertyNames):
(WebCore::JSStorage::putDelegate):

  • bindings/js/JSTextTrackCustom.cpp:

(WebCore::JSTextTrack::setLanguage):

  • bindings/js/JSVideoTrackCustom.cpp:

(WebCore::JSVideoTrack::setKind):
(WebCore::JSVideoTrack::setLanguage):

  • bindings/js/JSWebGL2RenderingContextCustom.cpp:

(WebCore::JSWebGL2RenderingContext::getIndexedParameter):

  • bindings/js/JSWebGLRenderingContextBaseCustom.cpp:

(WebCore::getObjectParameter):
(WebCore::JSWebGLRenderingContextBase::getExtension):
(WebCore::JSWebGLRenderingContextBase::getFramebufferAttachmentParameter):
(WebCore::JSWebGLRenderingContextBase::getParameter):
(WebCore::JSWebGLRenderingContextBase::getProgramParameter):
(WebCore::JSWebGLRenderingContextBase::getShaderParameter):
(WebCore::toVector):
(WebCore::dataFunctionf):
(WebCore::dataFunctionMatrix):

  • bindings/js/JSWebKitSubtleCryptoCustom.cpp:

(WebCore::createAlgorithmFromJSValue):
(WebCore::cryptoKeyFormatFromJSValue):
(WebCore::cryptoKeyUsagesFromJSValue):
(WebCore::JSWebKitSubtleCrypto::encrypt):
(WebCore::JSWebKitSubtleCrypto::decrypt):
(WebCore::JSWebKitSubtleCrypto::sign):
(WebCore::JSWebKitSubtleCrypto::verify):
(WebCore::JSWebKitSubtleCrypto::digest):
(WebCore::JSWebKitSubtleCrypto::generateKey):
(WebCore::importKey):
(WebCore::JSWebKitSubtleCrypto::importKey):
(WebCore::exportKey):
(WebCore::JSWebKitSubtleCrypto::exportKey):
(WebCore::JSWebKitSubtleCrypto::wrapKey):
(WebCore::JSWebKitSubtleCrypto::unwrapKey):

  • bindings/js/JSWorkerCustom.cpp:

(WebCore::constructJSWorker):

  • bindings/js/JSWorkerGlobalScopeCustom.cpp:

(WebCore::JSWorkerGlobalScope::importScripts):
(WebCore::JSWorkerGlobalScope::setTimeout):
(WebCore::JSWorkerGlobalScope::setInterval):

  • bindings/js/ReadableStreamDefaultController.cpp:

(WebCore::ReadableStreamDefaultController::invoke):
(WebCore::ReadableStreamDefaultController::isControlledReadableStreamLocked):

  • bindings/js/ReadableStreamDefaultController.h:

(WebCore::ReadableStreamDefaultController::enqueue):

  • bindings/js/ScheduledAction.cpp:

(WebCore::ScheduledAction::create):

  • bindings/js/ScriptGlobalObject.cpp:

(WebCore::ScriptGlobalObject::set):

  • bindings/js/SerializedScriptValue.cpp:

(WebCore::CloneBase::shouldTerminate):
(WebCore::CloneDeserializer::deserialize):
(WebCore::SerializedScriptValue::create):
(WebCore::SerializedScriptValue::deserialize):

  • bindings/js/WorkerScriptController.cpp:

(WebCore::WorkerScriptController::evaluate):

  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateDictionaryImplementationContent):
(GenerateImplementation):
(GenerateParametersCheck):
(GenerateImplementationFunctionCall):
(GenerateConstructorDefinition):

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

(WebCore::jsTestActiveDOMObjectPrototypeFunctionPostMessage):

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

(WebCore::jsTestCustomNamedGetterPrototypeFunctionAnotherFunction):

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

(WebCore::JSTestEventConstructorConstructor::construct):

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

(WebCore::jsTestEventTargetPrototypeFunctionItem):

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

(WebCore::setJSTestGlobalObjectRegularAttribute):
(WebCore::setJSTestGlobalObjectPublicAndPrivateAttribute):
(WebCore::setJSTestGlobalObjectPublicAndPrivateConditionalAttribute):
(WebCore::setJSTestGlobalObjectEnabledAtRuntimeAttribute):
(WebCore::jsTestGlobalObjectInstanceFunctionRegularOperation):
(WebCore::jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation1):
(WebCore::jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation2):

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

(WebCore::JSTestInterfaceConstructor::construct):
(WebCore::setJSTestInterfaceConstructorImplementsStaticAttr):
(WebCore::setJSTestInterfaceImplementsStr2):
(WebCore::setJSTestInterfaceImplementsStr3):
(WebCore::setJSTestInterfaceImplementsNode):
(WebCore::setJSTestInterfaceConstructorSupplementalStaticAttr):
(WebCore::setJSTestInterfaceSupplementalStr2):
(WebCore::setJSTestInterfaceSupplementalStr3):
(WebCore::setJSTestInterfaceSupplementalNode):
(WebCore::jsTestInterfacePrototypeFunctionImplementsMethod2):
(WebCore::jsTestInterfacePrototypeFunctionSupplementalMethod2):

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

(WebCore::setJSTestJSBuiltinConstructorTestAttributeRWCustom):

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

(WebCore::JSTestNamedConstructorNamedConstructor::construct):

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

(WebCore::setJSTestNodeName):

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

(WebCore::setJSTestNondeterministicNondeterministicWriteableAttr):
(WebCore::setJSTestNondeterministicNondeterministicExceptionAttr):
(WebCore::setJSTestNondeterministicNondeterministicGetterExceptionAttr):
(WebCore::setJSTestNondeterministicNondeterministicSetterExceptionAttr):

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

(WebCore::convertDictionary<TestObj::Dictionary>):
(WebCore::convertDictionary<TestObj::DictionaryThatShouldNotTolerateNull>):
(WebCore::convertDictionary<TestObj::DictionaryThatShouldTolerateNull>):
(WebCore::convertDictionary<AlternateDictionaryName>):
(WebCore::setJSTestObjConstructorStaticStringAttr):
(WebCore::setJSTestObjTestSubObjEnabledBySettingConstructor):
(WebCore::setJSTestObjEnumAttr):
(WebCore::setJSTestObjByteAttr):
(WebCore::setJSTestObjOctetAttr):
(WebCore::setJSTestObjShortAttr):
(WebCore::setJSTestObjClampedShortAttr):
(WebCore::setJSTestObjEnforceRangeShortAttr):
(WebCore::setJSTestObjUnsignedShortAttr):
(WebCore::setJSTestObjLongAttr):
(WebCore::setJSTestObjLongLongAttr):
(WebCore::setJSTestObjUnsignedLongLongAttr):
(WebCore::setJSTestObjStringAttr):
(WebCore::setJSTestObjUsvstringAttr):
(WebCore::setJSTestObjTestObjAttr):
(WebCore::setJSTestObjTestNullableObjAttr):
(WebCore::setJSTestObjLenientTestObjAttr):
(WebCore::setJSTestObjStringAttrTreatingNullAsEmptyString):
(WebCore::setJSTestObjUsvstringAttrTreatingNullAsEmptyString):
(WebCore::setJSTestObjImplementationEnumAttr):
(WebCore::setJSTestObjXMLObjAttr):
(WebCore::setJSTestObjCreate):
(WebCore::setJSTestObjReflectedStringAttr):
(WebCore::setJSTestObjReflectedUSVStringAttr):
(WebCore::setJSTestObjReflectedIntegralAttr):
(WebCore::setJSTestObjReflectedUnsignedIntegralAttr):
(WebCore::setJSTestObjReflectedBooleanAttr):
(WebCore::setJSTestObjReflectedURLAttr):
(WebCore::setJSTestObjReflectedUSVURLAttr):
(WebCore::setJSTestObjReflectedCustomIntegralAttr):
(WebCore::setJSTestObjReflectedCustomBooleanAttr):
(WebCore::setJSTestObjReflectedCustomURLAttr):
(WebCore::setJSTestObjEnabledAtRuntimeAttribute):
(WebCore::setJSTestObjTypedArrayAttr):
(WebCore::setJSTestObjAttrWithGetterException):
(WebCore::setJSTestObjAttrWithGetterExceptionWithMessage):
(WebCore::setJSTestObjAttrWithSetterException):
(WebCore::setJSTestObjAttrWithSetterExceptionWithMessage):
(WebCore::setJSTestObjStringAttrWithGetterException):
(WebCore::setJSTestObjStringAttrWithSetterException):
(WebCore::setJSTestObjCustomAttr):
(WebCore::setJSTestObjOnfoo):
(WebCore::setJSTestObjOnwebkitfoo):
(WebCore::setJSTestObjWithScriptStateAttribute):
(WebCore::setJSTestObjWithCallWithAndSetterCallWithAttribute):
(WebCore::setJSTestObjWithScriptExecutionContextAttribute):
(WebCore::setJSTestObjWithScriptStateAttributeRaises):
(WebCore::setJSTestObjWithScriptExecutionContextAttributeRaises):
(WebCore::setJSTestObjWithScriptExecutionContextAndScriptStateAttribute):
(WebCore::setJSTestObjWithScriptExecutionContextAndScriptStateAttributeRaises):
(WebCore::setJSTestObjWithScriptExecutionContextAndScriptStateWithSpacesAttribute):
(WebCore::setJSTestObjWithScriptArgumentsAndCallStackAttribute):
(WebCore::setJSTestObjConditionalAttr1):
(WebCore::setJSTestObjConditionalAttr2):
(WebCore::setJSTestObjConditionalAttr3):
(WebCore::setJSTestObjConditionalAttr4Constructor):
(WebCore::setJSTestObjConditionalAttr5Constructor):
(WebCore::setJSTestObjConditionalAttr6Constructor):
(WebCore::setJSTestObjAnyAttribute):
(WebCore::setJSTestObjMutablePoint):
(WebCore::setJSTestObjImmutablePoint):
(WebCore::setJSTestObjStrawberry):
(WebCore::setJSTestObjId):
(WebCore::setJSTestObjReplaceableAttribute):
(WebCore::setJSTestObjNullableLongSettableAttribute):
(WebCore::setJSTestObjNullableStringSettableAttribute):
(WebCore::setJSTestObjNullableUSVStringSettableAttribute):
(WebCore::setJSTestObjNullableStringValue):
(WebCore::setJSTestObjAttributeWithReservedEnumType):
(WebCore::setJSTestObjPutForwardsAttribute):
(WebCore::setJSTestObjPutForwardsNullableAttribute):
(WebCore::setJSTestObjStringifierAttribute):
(WebCore::jsTestObjPrototypeFunctionEnabledAtRuntimeOperation1):
(WebCore::jsTestObjPrototypeFunctionEnabledAtRuntimeOperation2):
(WebCore::jsTestObjPrototypeFunctionVoidMethodWithArgs):
(WebCore::jsTestObjPrototypeFunctionByteMethodWithArgs):
(WebCore::jsTestObjPrototypeFunctionOctetMethodWithArgs):
(WebCore::jsTestObjPrototypeFunctionLongMethodWithArgs):
(WebCore::jsTestObjPrototypeFunctionObjMethodWithArgs):
(WebCore::jsTestObjPrototypeFunctionMethodWithArgTreatingNullAsEmptyString):
(WebCore::jsTestObjPrototypeFunctionMethodWithXPathNSResolverParameter):
(WebCore::jsTestObjPrototypeFunctionNullableStringSpecialMethod):
(WebCore::jsTestObjPrototypeFunctionMethodWithEnumArg):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalEnumArg):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalEnumArgAndDefaultValue):
(WebCore::jsTestObjPrototypeFunctionMethodThatRequiresAllArgsAndThrows):
(WebCore::jsTestObjPrototypeFunctionMethodWithUSVStringArg):
(WebCore::jsTestObjPrototypeFunctionMethodWithNullableUSVStringArg):
(WebCore::jsTestObjPrototypeFunctionMethodWithUSVStringArgTreatingNullAsEmptyString):
(WebCore::jsTestObjPrototypeFunctionSerializedValue):
(WebCore::jsTestObjPrototypeFunctionPrivateMethod):
(WebCore::jsTestObjPrototypeFunctionPublicAndPrivateMethod):
(WebCore::jsTestObjPrototypeFunctionAddEventListener):
(WebCore::jsTestObjPrototypeFunctionRemoveEventListener):
(WebCore::jsTestObjPrototypeFunctionWithScriptStateObj):
(WebCore::jsTestObjPrototypeFunctionWithScriptStateObjException):
(WebCore::jsTestObjPrototypeFunctionWithScriptExecutionContextAndScriptStateObjException):
(WebCore::jsTestObjPrototypeFunctionWithScriptExecutionContextAndScriptStateWithSpaces):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalArg):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalArgAndDefaultValue):
(WebCore::jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg):
(WebCore::jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndTwoOptionalArgs):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalString):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalUSVString):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalAtomicString):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalStringAndDefaultValue):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalAtomicStringAndDefaultValue):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalStringIsNull):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalStringIsUndefined):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalAtomicStringIsNull):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalStringIsEmptyString):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalUSVStringIsEmptyString):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalAtomicStringIsEmptyString):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalDoubleIsNaN):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalFloatIsNaN):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalLongLong):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalLongLongIsZero):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalUnsignedLongLong):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalUnsignedLongLongIsZero):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalSequence):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalSequenceIsEmpty):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalBoolean):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalBooleanIsFalse):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalXPathNSResolver):
(WebCore::jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackArg):
(WebCore::jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackFunctionArg):
(WebCore::jsTestObjPrototypeFunctionOverloadedMethod1):
(WebCore::jsTestObjPrototypeFunctionOverloadedMethod2):
(WebCore::jsTestObjPrototypeFunctionOverloadedMethod3):
(WebCore::jsTestObjPrototypeFunctionOverloadedMethod4):
(WebCore::jsTestObjPrototypeFunctionOverloadedMethod7):
(WebCore::jsTestObjPrototypeFunctionOverloadedMethod9):
(WebCore::jsTestObjPrototypeFunctionOverloadedMethod10):
(WebCore::jsTestObjPrototypeFunctionOverloadedMethod11):
(WebCore::jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter1):
(WebCore::jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter2):
(WebCore::jsTestObjConstructorFunctionClassMethodWithOptional):
(WebCore::jsTestObjConstructorFunctionOverloadedMethod11):
(WebCore::jsTestObjConstructorFunctionOverloadedMethod12):
(WebCore::jsTestObjPrototypeFunctionClassMethodWithClamp):
(WebCore::jsTestObjPrototypeFunctionClassMethodWithEnforceRange):
(WebCore::jsTestObjPrototypeFunctionMethodWithUnsignedLongSequence):
(WebCore::jsTestObjPrototypeFunctionStringArrayFunction):
(WebCore::jsTestObjPrototypeFunctionMethodWithAndWithoutNullableSequence):
(WebCore::jsTestObjPrototypeFunctionGetElementById):
(WebCore::jsTestObjPrototypeFunctionConvert3):
(WebCore::jsTestObjPrototypeFunctionConvert4):
(WebCore::jsTestObjPrototypeFunctionVariadicStringMethod):
(WebCore::jsTestObjPrototypeFunctionVariadicDoubleMethod):
(WebCore::jsTestObjPrototypeFunctionAny):
(WebCore::jsTestObjPrototypeFunctionTestPromiseFunctionWithFloatArgumentPromise):
(WebCore::jsTestObjPrototypeFunctionTestPromiseFunctionWithOptionalIntArgumentPromise):
(WebCore::jsTestObjPrototypeFunctionTestPromiseOverloadedFunction1Promise):
(WebCore::jsTestObjPrototypeFunctionConditionalOverload1):
(WebCore::jsTestObjPrototypeFunctionConditionalOverload2):
(WebCore::jsTestObjPrototypeFunctionSingleConditionalOverload1):
(WebCore::jsTestObjPrototypeFunctionSingleConditionalOverload2):
(WebCore::jsTestObjPrototypeFunctionAttachShadowRoot):

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

(WebCore::constructJSTestOverloadedConstructors1):
(WebCore::constructJSTestOverloadedConstructors2):
(WebCore::constructJSTestOverloadedConstructors4):
(WebCore::constructJSTestOverloadedConstructors5):

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

(WebCore::constructJSTestOverloadedConstructorsWithSequence1):
(WebCore::constructJSTestOverloadedConstructorsWithSequence2):

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

(WebCore::jsTestOverrideBuiltinsPrototypeFunctionNamedItem):

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

(WebCore::setJSTestSerializedScriptValueInterfaceValue):
(WebCore::setJSTestSerializedScriptValueInterfaceCachedValue):

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

(WebCore::JSTestTypedefsConstructor::construct):
(WebCore::setJSTestTypedefsUnsignedLongLongAttr):
(WebCore::setJSTestTypedefsImmutableSerializedScriptValue):
(WebCore::setJSTestTypedefsAttrWithGetterException):
(WebCore::setJSTestTypedefsAttrWithSetterException):
(WebCore::setJSTestTypedefsStringAttrWithGetterException):
(WebCore::setJSTestTypedefsStringAttrWithSetterException):
(WebCore::jsTestTypedefsPrototypeFunctionFunc):
(WebCore::jsTestTypedefsPrototypeFunctionSetShadow):
(WebCore::jsTestTypedefsPrototypeFunctionMethodWithSequenceArg):
(WebCore::jsTestTypedefsPrototypeFunctionNullableSequenceArg):
(WebCore::jsTestTypedefsPrototypeFunctionFuncWithClamp):
(WebCore::jsTestTypedefsPrototypeFunctionStringSequenceFunction):
(WebCore::jsTestTypedefsPrototypeFunctionStringSequenceFunction2):
(WebCore::jsTestTypedefsPrototypeFunctionCallWithSequenceThatRequiresInclude):

  • bridge/NP_jsobject.cpp:

(_NPN_InvokeDefault):
(_NPN_Invoke):
(_NPN_Evaluate):
(_NPN_GetProperty):
(_NPN_SetProperty):
(_NPN_RemoveProperty):
(_NPN_HasProperty):
(_NPN_HasMethod):
(_NPN_Enumerate):
(_NPN_Construct):

  • bridge/c/c_instance.cpp:

(JSC::Bindings::CInstance::moveGlobalExceptionToExecState):

  • bridge/objc/WebScriptObject.mm:

(WebCore::addExceptionToConsole):
(-[WebScriptObject callWebScriptMethod:withArguments:]):
(-[WebScriptObject evaluateWebScript:]):
(-[WebScriptObject setValue:forKey:]):
(-[WebScriptObject valueForKey:]):
(-[WebScriptObject removeWebScriptKey:]):
(-[WebScriptObject hasWebScriptKey:]):
(-[WebScriptObject webScriptValueAtIndex:]):
(-[WebScriptObject setWebScriptValueAtIndex:value:]):

  • contentextensions/ContentExtensionParser.cpp:

(WebCore::ContentExtensions::getDomainList):
(WebCore::ContentExtensions::getTypeFlags):
(WebCore::ContentExtensions::loadTrigger):
(WebCore::ContentExtensions::loadAction):
(WebCore::ContentExtensions::loadEncodedRules):

  • html/HTMLMediaElement.cpp:

(WebCore::controllerJSValue):
(WebCore::HTMLMediaElement::updateCaptionContainer):
(WebCore::HTMLMediaElement::ensureMediaControlsInjectedScript):
(WebCore::HTMLMediaElement::didAddUserAgentShadowRoot):
(WebCore::HTMLMediaElement::updateMediaControlsAfterPresentationModeChange):
(WebCore::HTMLMediaElement::getCurrentMediaControlsStatus):

  • html/HTMLPlugInImageElement.cpp:

(WebCore::HTMLPlugInImageElement::didAddUserAgentShadowRoot):

Source/WebKit/mac:

  • Plugins/Hosted/NetscapePluginInstanceProxy.mm:

(WebKit::NetscapePluginInstanceProxy::evaluate):
(WebKit::NetscapePluginInstanceProxy::invoke):
(WebKit::NetscapePluginInstanceProxy::invokeDefault):
(WebKit::NetscapePluginInstanceProxy::construct):
(WebKit::NetscapePluginInstanceProxy::getProperty):
(WebKit::NetscapePluginInstanceProxy::setProperty):
(WebKit::NetscapePluginInstanceProxy::removeProperty):
(WebKit::NetscapePluginInstanceProxy::hasProperty):
(WebKit::NetscapePluginInstanceProxy::hasMethod):
(WebKit::NetscapePluginInstanceProxy::enumerate):

  • WebView/WebView.mm:

(aeDescFromJSValue):

Source/WebKit/win:

  • Plugins/PluginPackage.cpp:

(WebCore::NPN_Evaluate):
(WebCore::NPN_Invoke):

Source/WebKit2:

  • WebProcess/Plugins/Netscape/NPJSObject.cpp:

(WebKit::NPJSObject::hasMethod):
(WebKit::NPJSObject::hasProperty):
(WebKit::NPJSObject::getProperty):
(WebKit::NPJSObject::setProperty):
(WebKit::NPJSObject::removeProperty):
(WebKit::NPJSObject::construct):
(WebKit::NPJSObject::invoke):

Source/WTF:

  • wtf/Platform.h:
Location:
trunk/Source
Files:
6 added
221 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/APIUtils.h

    r197983 r205569  
    3939inline ExceptionStatus handleExceptionIfNeeded(JSC::ExecState* exec, JSValueRef* returnedExceptionRef)
    4040{
    41     if (exec->hadException()) {
    42         JSC::Exception* exception = exec->exception();
     41    JSC::VM& vm = exec->vm();
     42    auto scope = DECLARE_CATCH_SCOPE(vm);
     43    if (UNLIKELY(scope.exception())) {
     44        JSC::Exception* exception = scope.exception();
    4345        if (returnedExceptionRef)
    4446            *returnedExceptionRef = toRef(exec, exception->value());
    45         exec->clearException();
     47        scope.clearException();
    4648#if ENABLE(REMOTE_INSPECTOR)
    4749        exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exception);
  • trunk/Source/JavaScriptCore/CMakeLists.txt

    r205558 r205569  
    632632    runtime/BooleanPrototype.cpp
    633633    runtime/CallData.cpp
     634    runtime/CatchScope.cpp
    634635    runtime/ClonedArguments.cpp
    635636    runtime/CodeCache.cpp
     
    661662    runtime/ErrorPrototype.cpp
    662663    runtime/Exception.cpp
     664    runtime/ExceptionEvent.cpp
     665    runtime/ExceptionEventLocation.cpp
    663666    runtime/ExceptionFuzz.cpp
    664667    runtime/ExceptionHelpers.cpp
     668    runtime/ExceptionScope.cpp
    665669    runtime/Executable.cpp
    666670    runtime/FunctionConstructor.cpp
  • trunk/Source/JavaScriptCore/ChangeLog

    r205568 r205569  
     12016-09-07  Mark Lam  <mark.lam@apple.com>
     2
     3        Add CatchScope and force all exception checks to be via ThrowScope or CatchScope.
     4        https://bugs.webkit.org/show_bug.cgi?id=161498
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        This patch refactors the ThrowScope class, and introduces a base ExceptionScope
     9        that ThrowScope extends.  A CatchScope which extends the ExceptionScope is also
     10        introduced.
     11
     12        ENABLE(THROW_SCOPE_VERIFICATION) is now renamed to ENABLE(EXCEPTION_SCOPE_VERIFICATION)
     13        which is a more suitable name now.
     14
     15        Note: exception scope verification is still disabled by default.  There are still
     16        many places that need to be fixed up or re-expressed in a way that is friendly
     17        to the verification.  I'll address those in subsequent patches.
     18
     19        After this patch, the code will statically enforce that:
     20        1. all calls to throwException() go through a ThrowScope.
     21        2. all calls to clearException() go through a CatchScope.
     22        3. all exception checks go through an ExceptionScope in the form of a ThrowScope
     23           or CatchScope.
     24
     25        A Summary of how to use ExceptionScopes
     26        =======================================
     27        1. If a function can throw a JS exception, it should declare a ThrowScope at the
     28           top of the function (as early as possible).
     29
     30        2. If a function can clear JS exceptions, it should declare a CatchScope at the
     31           top of the function (as early as possible).
     32
     33        Declaring a ThrowScope in a function means that the function may throw an exception
     34        that its caller will have to handle.  Declaring a CatchScope in a function means
     35        that the function intends to clear pending exceptions before returning to its
     36        caller.
     37
     38        For more details, see the notes below.
     39       
     40        Everything you may want to know about ExceptionScopes
     41        =====================================================
     42        ExceptionScope verification works to simulate exception throws and detect cases
     43        where exception checks are missing.  The notes below will cover:
     44
     45            1. The VM::m_needExceptionCheck bit
     46            2. ThrowScopes and CatchScopes
     47            3. Verification of needed exception checks
     48            3. Checking Exceptions
     49            4. Simulating throws
     50            5. Using ThrowScope::release()
     51            6. Checking exceptions with ThrowScope::exception() / CatchScope::exception()
     52            7. Checking exceptions by checking callee results
     53            8. Debugging verification errors
     54
     55        1. The VM::m_needExceptionCheck bit
     56
     57           The VM has a m_needExceptionCheck bit that indicates when an exception may be
     58           thrown.  You can think of the m_needExceptionCheck bit being set as a simulated
     59           throw.
     60
     61        2. ThrowScopes and CatchScopes
     62
     63           Only ThrowScopes may throwException.  Only CatchScopes may catchException.
     64
     65           Every throw site must declare a ThrowScope instance using DECLARE_THROW_SCOPE
     66           at the top of its function (as early as possible) e.g.
     67 
     68                void foo(...)
     69                {
     70                    auto scope = DECLARE_THROW_SCOPE(vm);
     71                    ...
     72                    throwException(exec, scope, ...);
     73                }
     74
     75           Note: by convention, every throw helper function must take a ThrowScope argument
     76           instead of instantiating its own ThrowScope.  This allows the throw to be
     77           attributed to the client code rather than the throw helper itself.
     78
     79           Every catch site (i.e. a site that calls clearException()) must declare a
     80           CatchScope instance using DECLARE_CATCH_SCOPE at the top of its function.
     81
     82           If a function can both throw or clear exceptions, then the ThrowScope should
     83           be declared first so that it can simulate a throw to the function's caller.
     84
     85           Note: ThrowScope and CatchScope both extend ExceptionScope so that ThrowScopes
     86           can be aware if there's an enclosing CatchScope between it and the point where
     87           C++ code returns to JS code.  This is needed to determine if the ThrowScope
     88           should simulate a re-throw or not.  See (4) below for more details on returning
     89           to JS code.
     90
     91        3. Verification of needed exception checks
     92
     93           a. On construction, each ThrowScope and CatchScope will verify that
     94              VM::m_needExceptionCheck is not set.
     95 
     96              This ensures that the caller of the current function has checked for exceptions
     97              where needed before doing more work which lead to calling the current function.
     98
     99           b. On destruction, each ThrowScope and CatchScope will verify that
     100              VM::m_needExceptionCheck is not set. This verification will be skipped if
     101              the ThrowScope has been released (see (5) below).
     102
     103              This ensures that the function that owns this exception scope is not missing
     104              any exception checks before returning.
     105
     106           c. When throwing an exception, the ThrowScope will verify that VM::m_needExceptionCheck
     107              is not already set, unless it's been ask to rethrow the same Exception object.
     108
     109        4. Simulating throws
     110
     111           Throws are simulated by setting the m_needExceptionCheck bit.
     112
     113           The bit will only be set in the ThrowScope destructor except when the ThrowScope
     114           detects the caller is a LLInt or JIT function.  LLInt or JIT functions will always
     115           check for exceptions after a host C++ function returns to it.  However, they will
     116           not clear the m_needExceptionCheck bit.
     117
     118           Hence, if the ThrowScope destructor detects the caller is a LLInt or JIT function,
     119           it will just skip the setting of the bit.
     120
     121           Note: it is not needed nor correct to set the m_needExceptionCheck bit in the
     122           throwException methods.  This is because, in practice, we always return
     123           immediately after throwing an exception.  It doesn't make sense to set the bit in
     124           the throw just to have to clear it immediately after before we do verification in
     125           the ThrowScope destructor.
     126
     127        5. Using ThrowScope::release()
     128
     129           Calling release() means that the scope is released from its obligation to
     130           verify the VM::m_needExceptionCheck bit on destruction.
     131
     132           release() should only be used at the bottom of a function if:
     133
     134           a. This function is going to let its caller check and handle the exception, e.g.
     135
     136                void foo(...)
     137                {
     138                    auto scope = DECLARE_THROW_SCOPE(vm);
     139                    auto result = goo(); // may throw.
     140
     141                    ... // Code that will are not affected by a pending exceptions.
     142
     143                    scope.release(); // tell the ThrowScope that the caller will handle the exception.
     144                    return result;
     145                }
     146
     147           b. This function is going to do a tail call that may throw.
     148
     149                void foo(...)
     150                {
     151                    auto scope = DECLARE_THROW_SCOPE(vm);
     152                    ...
     153                    scope.release(); // tell the ThrowScope that the caller will handle the exception.
     154                    return goo(); // may throw.
     155                }
     156
     157              release() should not be used in code paths that branch. For example:
     158
     159                void foo(...)
     160                {
     161                    auto scope = DECLARE_THROW_SCOPE(vm);
     162
     163                    auto result = goo1(); // may throw.
     164                    scope.release(); // WRONG !!! Don't do this.
     165                    if (result)
     166                        return;
     167
     168                    result = goo2(); // may throw.
     169                    ...
     170                    return result;
     171                }
     172
     173            The above will result in a verification error in goo2()'s ThrowScope.  The
     174            proper way to fix this verification is to do either (6) or (7) below.
     175
     176         6. Checking exceptions with ThrowScope::exception() / CatchScope::exception()
     177
     178            ThrowScope/CatchScope::exception() returns the thrown Exception object if
     179            there is one pending.  Else, it returns nullptr.
     180
     181            It also clears the m_needExceptionCheck bit thereby indicating that we've
     182            satisfied the needed exception check.  For example,
     183
     184                void foo(...)
     185                {
     186                    auto scope = DECLARE_THROW_SCOPE(vm);
     187
     188                    auto result = goo1(); // may throw.
     189                    if (scope.exception())
     190                        return;
     191
     192                    result = goo2(); // may throw.
     193                    ...
     194                    return result;
     195                }
     196
     197            But sometimes, for optimization reasons, we may choose to test the result of
     198            the callee function instead doing a load of the VM exception value.  See (7)
     199            below.
     200
     201         7. Checking exceptions by checking callee results
     202
     203            This approach should only be applied when it makes a difference to performance.
     204            If we need to do this, we should add an ASSERT() that invokes the scope's
     205            exception() method to verify the result.  Since exception scope verification
     206            is only done on DEBUG builds, this ASSERT will satisfy the verification
     207            requirements without impacting performance.  For example,
     208
     209                void foo(...)
     210                {
     211                    auto scope = DECLARE_THROW_SCOPE(vm);
     212
     213                    bool failed = goo1(); // may throw.
     214                    ASSERT(!!scope.exception() == failed)
     215                    if (failed)
     216                        return;
     217
     218                    result = goo2(); // may throw.
     219                    ...
     220                    return result;
     221                }
     222
     223         8. Debugging verification errors
     224
     225            a. When verification fails, you will see a message followed by an assertion
     226               failure.  For example:
     227
     228            ERROR: Unchecked JS exception:
     229                This scope can throw a JS exception: setUpCall @ /Volumes/Data/ws6/OpenSource/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp:1245
     230                    (ExceptionScope::m_recursionDepth was ...)
     231                But the exception was unchecked as of this scope: varargsSetup @ /Volumes/Data/ws6/OpenSource/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp:1398
     232                    (ExceptionScope::m_recursionDepth was ...)
     233                [ backtrace here ]
     234
     235               The message tells you that failure was detected at in varargsSetup() at
     236               LLIntSlowPaths.cpp line 1398, and that the missing exception check should
     237               have happened somewhere between the call to setUpCall() at LLIntSlowPaths.cpp
     238               line 1245 and it.
     239
     240               If that is insufficient information, you can ...
     241
     242            b. Dump simulated throws
     243
     244               Re-run the test case with JSC_dumpSimulatedThrows=true.  You will also see
     245               back traces at each simulated throw.
     246
     247            c. Narrowing down the source of a simulated throw
     248
     249               Another technique for narrowing down the source of simulated throws is by
     250               further dividing a function to smaller regions by separating each region
     251               with additional local throw scopes.  For example,
     252
     253                ... // Region 1
     254                { auto scope = DECLARE_THROW_SCOPE(vm); }
     255                ... // Region 2
     256                { auto scope = DECLARE_THROW_SCOPE(vm); }
     257                ... // Region 3
     258
     259        * API/APIUtils.h:
     260        (handleExceptionIfNeeded):
     261        * CMakeLists.txt:
     262        * JavaScriptCore.xcodeproj/project.pbxproj:
     263        * bindings/ScriptFunctionCall.cpp:
     264        (Deprecated::ScriptFunctionCall::call):
     265        * bindings/ScriptValue.cpp:
     266        (Deprecated::ScriptValue::toString):
     267        * debugger/Debugger.cpp:
     268        (JSC::Debugger::pauseIfNeeded):
     269        * debugger/DebuggerCallFrame.cpp:
     270        (JSC::DebuggerCallFrame::evaluateWithScopeExtension):
     271        * dfg/DFGOSRExitCompiler.cpp:
     272        * dfg/DFGOperations.cpp:
     273        (JSC::DFG::operationPutByValInternal):
     274        * inspector/InjectedScriptManager.cpp:
     275        (Inspector::InjectedScriptManager::createInjectedScript):
     276        * inspector/JSGlobalObjectInspectorController.cpp:
     277        (Inspector::JSGlobalObjectInspectorController::reportAPIException):
     278        * inspector/JSInjectedScriptHost.cpp:
     279        (Inspector::JSInjectedScriptHost::evaluateWithScopeExtension):
     280        (Inspector::JSInjectedScriptHost::getInternalProperties):
     281        (Inspector::JSInjectedScriptHost::weakMapEntries):
     282        (Inspector::JSInjectedScriptHost::weakSetEntries):
     283        (Inspector::JSInjectedScriptHost::iteratorEntries):
     284        * inspector/JSJavaScriptCallFrame.cpp:
     285        (Inspector::JSJavaScriptCallFrame::evaluateWithScopeExtension):
     286        * inspector/ScriptCallStackFactory.cpp:
     287        (Inspector::extractSourceInformationFromException):
     288        * interpreter/CachedCall.h:
     289        (JSC::CachedCall::CachedCall):
     290        * interpreter/CallFrame.h:
     291        (JSC::ExecState::clearException): Deleted.
     292        (JSC::ExecState::exception): Deleted.
     293        (JSC::ExecState::hadException): Deleted.
     294        (JSC::ExecState::lastException): Deleted.
     295        (JSC::ExecState::clearLastException): Deleted.
     296        * interpreter/Interpreter.cpp:
     297        (JSC::eval):
     298        (JSC::sizeOfVarargs):
     299        (JSC::notifyDebuggerOfUnwinding):
     300        (JSC::Interpreter::unwind):
     301        (JSC::Interpreter::execute):
     302        (JSC::Interpreter::executeCall):
     303        (JSC::Interpreter::executeConstruct):
     304        (JSC::Interpreter::prepareForRepeatCall):
     305        (JSC::Interpreter::debug):
     306        * interpreter/Interpreter.h:
     307        (JSC::SuspendExceptionScope::SuspendExceptionScope):
     308        * interpreter/ShadowChicken.cpp:
     309        (JSC::ShadowChicken::functionsOnStack):
     310        * jit/JITCode.cpp:
     311        (JSC::JITCode::execute):
     312        * jit/JITExceptions.cpp:
     313        (JSC::genericUnwind):
     314        * jit/JITOperations.cpp:
     315        (JSC::getByVal):
     316        * jsc.cpp:
     317        (WTF::ImpureGetter::getOwnPropertySlot):
     318        (GlobalObject::moduleLoaderResolve):
     319        (GlobalObject::moduleLoaderFetch):
     320        (functionCreateElement):
     321        (functionRun):
     322        (functionRunString):
     323        (functionLoad):
     324        (functionLoadString):
     325        (functionReadFile):
     326        (functionCheckSyntax):
     327        (functionSetRandomSeed):
     328        (functionLoadModule):
     329        (functionCreateBuiltin):
     330        (functionCheckModuleSyntax):
     331        (functionGenerateHeapSnapshot):
     332        (functionSamplingProfilerStackTraces):
     333        (dumpException):
     334        (checkUncaughtException):
     335        (runWithScripts):
     336        (runInteractive):
     337        * llint/LLIntExceptions.cpp:
     338        (JSC::LLInt::returnToThrow):
     339        (JSC::LLInt::callToThrow):
     340        * llint/LLIntSlowPaths.cpp:
     341        (JSC::LLInt::LLINT_SLOW_PATH_DECL):
     342        * profiler/ProfilerBytecodeSequence.cpp:
     343        (JSC::Profiler::BytecodeSequence::addSequenceProperties):
     344        * profiler/ProfilerCompilation.cpp:
     345        (JSC::Profiler::Compilation::toJS):
     346        * profiler/ProfilerDatabase.cpp:
     347        (JSC::Profiler::Database::toJS):
     348        * profiler/ProfilerOSRExitSite.cpp:
     349        (JSC::Profiler::OSRExitSite::toJS):
     350        * profiler/ProfilerOriginStack.cpp:
     351        (JSC::Profiler::OriginStack::toJS):
     352        * runtime/ArrayPrototype.cpp:
     353        (JSC::speciesConstructArray):
     354        (JSC::shift):
     355        (JSC::unshift):
     356        (JSC::arrayProtoFuncToString):
     357        (JSC::arrayProtoFuncToLocaleString):
     358        (JSC::slowJoin):
     359        (JSC::fastJoin):
     360        (JSC::arrayProtoFuncJoin):
     361        (JSC::arrayProtoFuncPop):
     362        (JSC::arrayProtoFuncPush):
     363        (JSC::arrayProtoFuncReverse):
     364        (JSC::arrayProtoFuncShift):
     365        (JSC::arrayProtoFuncSlice):
     366        (JSC::arrayProtoFuncSplice):
     367        (JSC::arrayProtoFuncUnShift):
     368        (JSC::arrayProtoFuncIndexOf):
     369        (JSC::arrayProtoFuncLastIndexOf):
     370        (JSC::moveElements):
     371        (JSC::concatAppendOne):
     372        (JSC::arrayProtoPrivateFuncConcatMemcpy):
     373        * runtime/BooleanConstructor.cpp:
     374        (JSC::constructWithBooleanConstructor):
     375        * runtime/CallData.cpp:
     376        (JSC::call):
     377        * runtime/CatchScope.cpp: Added.
     378        (JSC::CatchScope::CatchScope):
     379        (JSC::CatchScope::~CatchScope):
     380        * runtime/CatchScope.h: Added.
     381        (JSC::CatchScope::clearException):
     382        (JSC::CatchScope::CatchScope):
     383        * runtime/CommonSlowPaths.cpp:
     384        (JSC::SLOW_PATH_DECL):
     385        * runtime/CommonSlowPaths.h:
     386        (JSC::CommonSlowPaths::opIn):
     387        * runtime/CommonSlowPathsExceptions.cpp:
     388        (JSC::CommonSlowPaths::interpreterThrowInCaller):
     389        * runtime/Completion.cpp:
     390        (JSC::evaluate):
     391        (JSC::rejectPromise):
     392        (JSC::loadAndEvaluateModule):
     393        (JSC::loadModule):
     394        * runtime/ConsoleObject.cpp:
     395        (JSC::consoleProtoFuncAssert):
     396        (JSC::consoleProtoFuncProfile):
     397        (JSC::consoleProtoFuncProfileEnd):
     398        (JSC::consoleProtoFuncTakeHeapSnapshot):
     399        (JSC::consoleProtoFuncTime):
     400        (JSC::consoleProtoFuncTimeEnd):
     401        * runtime/DateConstructor.cpp:
     402        (JSC::constructDate):
     403        (JSC::dateParse):
     404        * runtime/DatePrototype.cpp:
     405        (JSC::dateProtoFuncToPrimitiveSymbol):
     406        (JSC::dateProtoFuncToJSON):
     407        * runtime/ErrorConstructor.cpp:
     408        (JSC::Interpreter::constructWithErrorConstructor):
     409        * runtime/ErrorInstance.cpp:
     410        (JSC::ErrorInstance::sanitizedToString):
     411        * runtime/ErrorPrototype.cpp:
     412        (JSC::errorProtoFuncToString):
     413        * runtime/ExceptionEventLocation.cpp: Added.
     414        (WTF::printInternal):
     415        * runtime/ExceptionEventLocation.h: Copied from Source/JavaScriptCore/runtime/ThrowScopeLocation.h.
     416        (JSC::ExceptionEventLocation::ExceptionEventLocation):
     417        (JSC::ThrowScopeLocation::ThrowScopeLocation): Deleted.
     418        * runtime/ExceptionHelpers.h:
     419        * runtime/ExceptionScope.cpp: Added.
     420        (JSC::ExceptionScope::ExceptionScope):
     421        (JSC::ExceptionScope::~ExceptionScope):
     422        * runtime/ExceptionScope.h: Added.
     423        (JSC::ExceptionScope::vm):
     424        (JSC::ExceptionScope::recursionDepth):
     425        (JSC::ExceptionScope::exception):
     426        (JSC::ExceptionScope::ExceptionScope):
     427        * runtime/FunctionConstructor.cpp:
     428        (JSC::constructFunctionSkippingEvalEnabledCheck):
     429        * runtime/FunctionPrototype.cpp:
     430        (JSC::functionProtoFuncBind):
     431        * runtime/GenericArgumentsInlines.h:
     432        (JSC::GenericArguments<Type>::copyToArguments):
     433        * runtime/GetterSetter.cpp:
     434        (JSC::callGetter):
     435        * runtime/InspectorInstrumentationObject.cpp:
     436        (JSC::inspectorInstrumentationObjectLog):
     437        * runtime/InternalFunction.cpp:
     438        (JSC::InternalFunction::createSubclassStructure):
     439        * runtime/IntlCollator.cpp:
     440        (JSC::IntlCollator::initializeCollator):
     441        (JSC::IntlCollator::createCollator):
     442        (JSC::IntlCollator::resolvedOptions):
     443        * runtime/IntlCollatorConstructor.cpp:
     444        (JSC::constructIntlCollator):
     445        (JSC::IntlCollatorConstructorFuncSupportedLocalesOf):
     446        * runtime/IntlCollatorPrototype.cpp:
     447        (JSC::IntlCollatorFuncCompare):
     448        (JSC::IntlCollatorPrototypeGetterCompare):
     449        * runtime/IntlDateTimeFormat.cpp:
     450        (JSC::toDateTimeOptionsAnyDate):
     451        (JSC::IntlDateTimeFormat::initializeDateTimeFormat):
     452        (JSC::IntlDateTimeFormat::resolvedOptions):
     453        (JSC::IntlDateTimeFormat::format):
     454        * runtime/IntlDateTimeFormatConstructor.cpp:
     455        (JSC::constructIntlDateTimeFormat):
     456        (JSC::IntlDateTimeFormatConstructorFuncSupportedLocalesOf):
     457        * runtime/IntlDateTimeFormatPrototype.cpp:
     458        (JSC::IntlDateTimeFormatFuncFormatDateTime):
     459        (JSC::IntlDateTimeFormatPrototypeGetterFormat):
     460        * runtime/IntlNumberFormat.cpp:
     461        (JSC::IntlNumberFormat::initializeNumberFormat):
     462        (JSC::IntlNumberFormat::createNumberFormat):
     463        (JSC::IntlNumberFormat::resolvedOptions):
     464        * runtime/IntlNumberFormatConstructor.cpp:
     465        (JSC::constructIntlNumberFormat):
     466        (JSC::IntlNumberFormatConstructorFuncSupportedLocalesOf):
     467        * runtime/IntlNumberFormatPrototype.cpp:
     468        (JSC::IntlNumberFormatFuncFormatNumber):
     469        (JSC::IntlNumberFormatPrototypeGetterFormat):
     470        * runtime/IntlObject.cpp:
     471        (JSC::intlBooleanOption):
     472        (JSC::intlStringOption):
     473        (JSC::intlNumberOption):
     474        (JSC::canonicalizeLocaleList):
     475        (JSC::supportedLocales):
     476        * runtime/IntlObjectInlines.h:
     477        (JSC::constructIntlInstanceWithWorkaroundForLegacyIntlConstructor):
     478        * runtime/IteratorOperations.cpp:
     479        (JSC::iteratorNext):
     480        (JSC::iteratorStep):
     481        (JSC::iteratorClose):
     482        (JSC::iteratorForIterable):
     483        * runtime/IteratorOperations.h:
     484        (JSC::forEachInIterable):
     485        * runtime/JSArray.cpp:
     486        (JSC::JSArray::pop):
     487        (JSC::JSArray::push):
     488        (JSC::JSArray::copyToArguments):
     489        * runtime/JSArrayBufferConstructor.cpp:
     490        (JSC::constructArrayBuffer):
     491        * runtime/JSArrayBufferPrototype.cpp:
     492        (JSC::arrayBufferProtoFuncSlice):
     493        * runtime/JSArrayInlines.h:
     494        (JSC::getLength):
     495        (JSC::toLength):
     496        * runtime/JSBoundFunction.cpp:
     497        (JSC::getBoundFunctionStructure):
     498        (JSC::JSBoundFunction::create):
     499        * runtime/JSCJSValue.cpp:
     500        (JSC::JSValue::putToPrimitive):
     501        (JSC::JSValue::putToPrimitiveByIndex):
     502        (JSC::JSValue::toStringSlowCase):
     503        * runtime/JSCJSValueInlines.h:
     504        (JSC::toPreferredPrimitiveType):
     505        (JSC::JSValue::getPropertySlot):
     506        (JSC::JSValue::equalSlowCaseInline):
     507        * runtime/JSDataViewPrototype.cpp:
     508        (JSC::getData):
     509        (JSC::setData):
     510        * runtime/JSFunction.cpp:
     511        (JSC::JSFunction::setFunctionName):
     512        * runtime/JSGenericTypedArrayView.h:
     513        (JSC::JSGenericTypedArrayView::setIndex):
     514        * runtime/JSGenericTypedArrayViewConstructorInlines.h:
     515        (JSC::constructGenericTypedArrayViewFromIterator):
     516        (JSC::constructGenericTypedArrayViewWithArguments):
     517        (JSC::constructGenericTypedArrayView):
     518        * runtime/JSGenericTypedArrayViewPrototypeFunctions.h:
     519        (JSC::speciesConstruct):
     520        (JSC::genericTypedArrayViewProtoFuncCopyWithin):
     521        (JSC::genericTypedArrayViewProtoFuncIncludes):
     522        (JSC::genericTypedArrayViewProtoFuncIndexOf):
     523        (JSC::genericTypedArrayViewProtoFuncJoin):
     524        (JSC::genericTypedArrayViewProtoFuncLastIndexOf):
     525        (JSC::genericTypedArrayViewProtoFuncSlice):
     526        (JSC::genericTypedArrayViewPrivateFuncSubarrayCreate):
     527        * runtime/JSGlobalObject.h:
     528        (JSC::constructEmptyArray):
     529        (JSC::constructArray):
     530        (JSC::constructArrayNegativeIndexed):
     531        * runtime/JSGlobalObjectFunctions.cpp:
     532        (JSC::globalFuncEval):
     533        * runtime/JSJob.cpp:
     534        (JSC::JSJobMicrotask::run):
     535        * runtime/JSModuleEnvironment.cpp:
     536        (JSC::JSModuleEnvironment::getOwnPropertySlot):
     537        * runtime/JSModuleLoader.cpp:
     538        (JSC::JSModuleLoader::fetch):
     539        * runtime/JSModuleNamespaceObject.cpp:
     540        (JSC::JSModuleNamespaceObject::finishCreation):
     541        (JSC::JSModuleNamespaceObject::getOwnPropertySlot):
     542        * runtime/JSModuleRecord.cpp:
     543        (JSC::JSModuleRecord::instantiateDeclarations):
     544        * runtime/JSONObject.cpp:
     545        (JSC::Stringifier::Stringifier):
     546        (JSC::Stringifier::stringify):
     547        (JSC::Stringifier::toJSON):
     548        (JSC::Stringifier::appendStringifiedValue):
     549        (JSC::Stringifier::Holder::appendNextProperty):
     550        (JSC::Walker::walk):
     551        (JSC::JSONProtoFuncParse):
     552        * runtime/JSObject.cpp:
     553        (JSC::ordinarySetSlow):
     554        (JSC::JSObject::setPrototypeWithCycleCheck):
     555        (JSC::callToPrimitiveFunction):
     556        (JSC::JSObject::ordinaryToPrimitive):
     557        (JSC::JSObject::defaultHasInstance):
     558        (JSC::JSObject::getPropertyNames):
     559        (JSC::JSObject::toNumber):
     560        (JSC::JSObject::toString):
     561        (JSC::JSObject::defineOwnNonIndexProperty):
     562        (JSC::JSObject::getGenericPropertyNames):
     563        (JSC::JSObject::getMethod):
     564        * runtime/JSObjectInlines.h:
     565        (JSC::createListFromArrayLike):
     566        (JSC::JSObject::getPropertySlot):
     567        (JSC::JSObject::getNonIndexPropertySlot):
     568        * runtime/JSPromiseConstructor.cpp:
     569        (JSC::constructPromise):
     570        * runtime/JSPropertyNameEnumerator.h:
     571        (JSC::propertyNameEnumerator):
     572        * runtime/JSPropertyNameIterator.cpp:
     573        (JSC::JSPropertyNameIterator::create):
     574        * runtime/JSScope.cpp:
     575        (JSC::isUnscopable):
     576        (JSC::JSScope::resolve):
     577        * runtime/JSString.cpp:
     578        (JSC::JSString::equalSlowCase):
     579        * runtime/JSStringJoiner.cpp:
     580        (JSC::JSStringJoiner::join):
     581        * runtime/LiteralParser.cpp:
     582        (JSC::LiteralParser<CharType>::parse):
     583        * runtime/MapConstructor.cpp:
     584        (JSC::constructMap):
     585        * runtime/MathObject.cpp:
     586        (JSC::mathProtoFuncClz32):
     587        (JSC::mathProtoFuncHypot):
     588        (JSC::mathProtoFuncIMul):
     589        * runtime/ModuleLoaderPrototype.cpp:
     590        (JSC::moduleLoaderPrototypeParseModule):
     591        (JSC::moduleLoaderPrototypeRequestedModules):
     592        (JSC::moduleLoaderPrototypeModuleDeclarationInstantiation):
     593        * runtime/NativeErrorConstructor.cpp:
     594        (JSC::Interpreter::constructWithNativeErrorConstructor):
     595        * runtime/NumberConstructor.cpp:
     596        (JSC::constructWithNumberConstructor):
     597        * runtime/ObjectConstructor.cpp:
     598        (JSC::constructObject):
     599        (JSC::objectConstructorGetPrototypeOf):
     600        (JSC::objectConstructorSetPrototypeOf):
     601        (JSC::objectConstructorGetOwnPropertyDescriptor):
     602        (JSC::objectConstructorGetOwnPropertyDescriptors):
     603        (JSC::objectConstructorGetOwnPropertyNames):
     604        (JSC::objectConstructorGetOwnPropertySymbols):
     605        (JSC::objectConstructorKeys):
     606        (JSC::ownEnumerablePropertyKeys):
     607        (JSC::toPropertyDescriptor):
     608        (JSC::objectConstructorDefineProperty):
     609        (JSC::defineProperties):
     610        (JSC::objectConstructorSeal):
     611        (JSC::objectConstructorFreeze):
     612        (JSC::objectConstructorIsSealed):
     613        (JSC::objectConstructorIsFrozen):
     614        (JSC::objectConstructorIsExtensible):
     615        (JSC::ownPropertyKeys):
     616        * runtime/ObjectConstructor.h:
     617        (JSC::constructObjectFromPropertyDescriptor):
     618        * runtime/ObjectPrototype.cpp:
     619        (JSC::objectProtoFuncHasOwnProperty):
     620        (JSC::objectProtoFuncIsPrototypeOf):
     621        (JSC::objectProtoFuncDefineGetter):
     622        (JSC::objectProtoFuncDefineSetter):
     623        (JSC::objectProtoFuncLookupGetter):
     624        (JSC::objectProtoFuncLookupSetter):
     625        (JSC::objectProtoFuncPropertyIsEnumerable):
     626        (JSC::objectProtoFuncToLocaleString):
     627        (JSC::objectProtoFuncToString):
     628        * runtime/Operations.cpp:
     629        (JSC::jsAddSlowCase):
     630        * runtime/Options.h:
     631        * runtime/PropertyDescriptor.cpp:
     632        (JSC::PropertyDescriptor::slowGetterSetter):
     633        * runtime/ProxyConstructor.cpp:
     634        (JSC::makeRevocableProxy):
     635        * runtime/ProxyObject.cpp:
     636        (JSC::ProxyObject::toStringName):
     637        (JSC::performProxyGet):
     638        (JSC::ProxyObject::performGet):
     639        (JSC::ProxyObject::performInternalMethodGetOwnProperty):
     640        (JSC::ProxyObject::performHasProperty):
     641        (JSC::ProxyObject::performPut):
     642        (JSC::ProxyObject::putByIndexCommon):
     643        (JSC::performProxyCall):
     644        (JSC::performProxyConstruct):
     645        (JSC::ProxyObject::performDelete):
     646        (JSC::ProxyObject::performPreventExtensions):
     647        (JSC::ProxyObject::performIsExtensible):
     648        (JSC::ProxyObject::performDefineOwnProperty):
     649        (JSC::ProxyObject::performGetOwnPropertyNames):
     650        (JSC::ProxyObject::performSetPrototype):
     651        (JSC::ProxyObject::performGetPrototype):
     652        * runtime/ReflectObject.cpp:
     653        (JSC::reflectObjectConstruct):
     654        (JSC::reflectObjectDefineProperty):
     655        (JSC::reflectObjectGet):
     656        (JSC::reflectObjectGetOwnPropertyDescriptor):
     657        (JSC::reflectObjectIsExtensible):
     658        (JSC::reflectObjectPreventExtensions):
     659        (JSC::reflectObjectSet):
     660        (JSC::reflectObjectSetPrototypeOf):
     661        * runtime/RegExpConstructor.cpp:
     662        (JSC::toFlags):
     663        (JSC::regExpCreate):
     664        (JSC::constructRegExp):
     665        * runtime/RegExpConstructor.h:
     666        (JSC::isRegExp):
     667        * runtime/RegExpObject.cpp:
     668        (JSC::collectMatches):
     669        (JSC::RegExpObject::matchGlobal):
     670        * runtime/RegExpPrototype.cpp:
     671        (JSC::regExpProtoFuncCompile):
     672        (JSC::flagsString):
     673        (JSC::regExpProtoFuncToString):
     674        (JSC::regExpProtoGetterFlags):
     675        (JSC::regExpProtoFuncSearchFast):
     676        (JSC::regExpProtoFuncSplitFast):
     677        * runtime/SetConstructor.cpp:
     678        (JSC::constructSet):
     679        * runtime/StringConstructor.cpp:
     680        (JSC::stringFromCodePoint):
     681        (JSC::constructWithStringConstructor):
     682        * runtime/StringObject.cpp:
     683        (JSC::StringObject::defineOwnProperty):
     684        * runtime/StringPrototype.cpp:
     685        (JSC::replaceUsingRegExpSearch):
     686        (JSC::operationStringProtoFuncReplaceRegExpEmptyStr):
     687        (JSC::replaceUsingStringSearch):
     688        (JSC::replace):
     689        (JSC::stringProtoFuncReplaceUsingRegExp):
     690        (JSC::stringProtoFuncReplaceUsingStringSearch):
     691        (JSC::stringProtoFuncCodePointAt):
     692        (JSC::stringProtoFuncSlice):
     693        (JSC::stringProtoFuncSplitFast):
     694        (JSC::stringProtoFuncSubstr):
     695        (JSC::stringProtoFuncSubstring):
     696        (JSC::stringProtoFuncLocaleCompare):
     697        (JSC::toLocaleCase):
     698        (JSC::stringProtoFuncBig):
     699        (JSC::stringProtoFuncSmall):
     700        (JSC::stringProtoFuncBlink):
     701        (JSC::stringProtoFuncBold):
     702        (JSC::stringProtoFuncFixed):
     703        (JSC::stringProtoFuncItalics):
     704        (JSC::stringProtoFuncStrike):
     705        (JSC::stringProtoFuncSub):
     706        (JSC::stringProtoFuncSup):
     707        (JSC::stringProtoFuncFontcolor):
     708        (JSC::stringProtoFuncFontsize):
     709        (JSC::stringProtoFuncAnchor):
     710        (JSC::stringProtoFuncLink):
     711        (JSC::trimString):
     712        (JSC::stringProtoFuncStartsWith):
     713        (JSC::stringProtoFuncEndsWith):
     714        (JSC::stringIncludesImpl):
     715        (JSC::stringProtoFuncIncludes):
     716        (JSC::builtinStringIncludesInternal):
     717        (JSC::stringProtoFuncNormalize):
     718        * runtime/SymbolConstructor.cpp:
     719        (JSC::symbolConstructorFor):
     720        * runtime/TemplateRegistry.cpp:
     721        (JSC::TemplateRegistry::getTemplateObject):
     722        * runtime/ThrowScope.cpp:
     723        (JSC::ThrowScope::ThrowScope):
     724        (JSC::ThrowScope::~ThrowScope):
     725        (JSC::ThrowScope::throwException):
     726        (JSC::ThrowScope::simulateThrow):
     727        (JSC::ThrowScope::printIfNeedCheck): Deleted.
     728        (JSC::ThrowScope::verifyExceptionCheckNeedIsSatisfied): Deleted.
     729        * runtime/ThrowScope.h:
     730        (JSC::ThrowScope::release):
     731        (JSC::ThrowScope::ThrowScope):
     732        (JSC::ThrowScope::throwException):
     733        (JSC::ThrowScope::vm): Deleted.
     734        (JSC::ThrowScope::exception): Deleted.
     735        * runtime/ThrowScopeLocation.h: Removed.
     736        * runtime/VM.cpp:
     737        (JSC::VM::verifyExceptionCheckNeedIsSatisfied):
     738        * runtime/VM.h:
     739        (JSC::VM::exception):
     740        (JSC::VM::clearException):
     741        (JSC::VM::setException): Deleted.
     742        * runtime/WeakMapConstructor.cpp:
     743        (JSC::constructWeakMap):
     744        * runtime/WeakSetConstructor.cpp:
     745        (JSC::constructWeakSet):
     746        * tools/JSDollarVMPrototype.cpp:
     747        (JSC::functionPrint):
     748
    17492016-09-07  Andy VanWagoner  <thetalecrafter@gmail.com>
    2750
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r205552 r205569  
    21492149                FE5932A7183C5A2600A1ECCC /* VMEntryScope.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE5932A5183C5A2600A1ECCC /* VMEntryScope.cpp */; };
    21502150                FE5932A8183C5A2600A1ECCC /* VMEntryScope.h in Headers */ = {isa = PBXBuildFile; fileRef = FE5932A6183C5A2600A1ECCC /* VMEntryScope.h */; settings = {ATTRIBUTES = (Private, ); }; };
    2151                 FE6029D91D6E1E4F0030204D /* ThrowScopeLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = FE6029D81D6E1E330030204D /* ThrowScopeLocation.h */; settings = {ATTRIBUTES = (Private, ); }; };
     2151                FE6029D91D6E1E4F0030204D /* ExceptionEventLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = FE6029D81D6E1E330030204D /* ExceptionEventLocation.h */; settings = {ATTRIBUTES = (Private, ); }; };
     2152                FE6491371D78F01D00A694D4 /* ExceptionScope.h in Headers */ = {isa = PBXBuildFile; fileRef = FE6491361D78F01300A694D4 /* ExceptionScope.h */; settings = {ATTRIBUTES = (Private, ); }; };
     2153                FE6491391D78F3AF00A694D4 /* ExceptionScope.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE6491381D78F3A300A694D4 /* ExceptionScope.cpp */; };
    21522154                FE68C6371B90DE040042BCB3 /* MacroAssemblerPrinter.h in Headers */ = {isa = PBXBuildFile; fileRef = FE68C6361B90DDD90042BCB3 /* MacroAssemblerPrinter.h */; settings = {ATTRIBUTES = (Private, ); }; };
    21532155                FE68C6381B90DE0B0042BCB3 /* MacroAssemblerPrinter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE68C6351B90DDD90042BCB3 /* MacroAssemblerPrinter.cpp */; };
     
    21552157                FE7BA6101A1A7CEC00F1F7B4 /* HeapVerifier.h in Headers */ = {isa = PBXBuildFile; fileRef = FE7BA60E1A1A7CEC00F1F7B4 /* HeapVerifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
    21562158                FE7C41961B97FC4B00F4D598 /* PingPongStackOverflowTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEDA50D41B97F442009A3B4F /* PingPongStackOverflowTest.cpp */; };
     2159                FE80C1971D775CDD008510C0 /* CatchScope.h in Headers */ = {isa = PBXBuildFile; fileRef = FE80C1961D775B27008510C0 /* CatchScope.h */; settings = {ATTRIBUTES = (Private, ); }; };
     2160                FE80C1991D775FBE008510C0 /* CatchScope.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE80C1981D775FB4008510C0 /* CatchScope.cpp */; };
     2161                FE80C19B1D776A98008510C0 /* ExceptionEventLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE80C19A1D7768FD008510C0 /* ExceptionEventLocation.cpp */; };
    21572162                FE99B2491C24C3D300C82159 /* JITNegGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = FE99B2481C24B6D300C82159 /* JITNegGenerator.h */; };
    21582163                FE99B24A1C24C3D700C82159 /* JITNegGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE99B2471C24B6D300C82159 /* JITNegGenerator.cpp */; };
     
    44764481                FE5932A5183C5A2600A1ECCC /* VMEntryScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VMEntryScope.cpp; sourceTree = "<group>"; };
    44774482                FE5932A6183C5A2600A1ECCC /* VMEntryScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VMEntryScope.h; sourceTree = "<group>"; };
    4478                 FE6029D81D6E1E330030204D /* ThrowScopeLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThrowScopeLocation.h; sourceTree = "<group>"; };
     4483                FE6029D81D6E1E330030204D /* ExceptionEventLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExceptionEventLocation.h; sourceTree = "<group>"; };
     4484                FE6491361D78F01300A694D4 /* ExceptionScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExceptionScope.h; sourceTree = "<group>"; };
     4485                FE6491381D78F3A300A694D4 /* ExceptionScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExceptionScope.cpp; sourceTree = "<group>"; };
    44794486                FE68C6351B90DDD90042BCB3 /* MacroAssemblerPrinter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MacroAssemblerPrinter.cpp; sourceTree = "<group>"; };
    44804487                FE68C6361B90DDD90042BCB3 /* MacroAssemblerPrinter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerPrinter.h; sourceTree = "<group>"; };
    44814488                FE7BA60D1A1A7CEC00F1F7B4 /* HeapVerifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HeapVerifier.cpp; sourceTree = "<group>"; };
    44824489                FE7BA60E1A1A7CEC00F1F7B4 /* HeapVerifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HeapVerifier.h; sourceTree = "<group>"; };
     4490                FE80C1961D775B27008510C0 /* CatchScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CatchScope.h; sourceTree = "<group>"; };
     4491                FE80C1981D775FB4008510C0 /* CatchScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CatchScope.cpp; sourceTree = "<group>"; };
     4492                FE80C19A1D7768FD008510C0 /* ExceptionEventLocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExceptionEventLocation.cpp; sourceTree = "<group>"; };
    44834493                FE90BB3A1B7CF64E006B3F03 /* VMInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VMInlines.h; sourceTree = "<group>"; };
    44844494                FE98B5B61BB9AE110073E7A6 /* JITSubGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITSubGenerator.h; sourceTree = "<group>"; };
     
    57385748                                BCA62DFE0E2826230004F30D /* CallData.cpp */,
    57395749                                145C507F0D9DF63B0088F6B9 /* CallData.h */,
     5750                                FE80C1981D775FB4008510C0 /* CatchScope.cpp */,
     5751                                FE80C1961D775B27008510C0 /* CatchScope.h */,
    57405752                                BC6AAAE40E1F426500AD87D8 /* ClassInfo.h */,
    57415753                                0FE0501C1AA9095600D33B33 /* ClonedArguments.cpp */,
     
    58025814                                FE1C0FFE1B194FD100B53FCA /* Exception.cpp */,
    58035815                                FE1C0FFC1B193E9800B53FCA /* Exception.h */,
     5816                                FE80C19A1D7768FD008510C0 /* ExceptionEventLocation.cpp */,
     5817                                FE6029D81D6E1E330030204D /* ExceptionEventLocation.h */,
    58045818                                0F12DE0D1979D5FD0006FF4E /* ExceptionFuzz.cpp */,
    58055819                                0F12DE0E1979D5FD0006FF4E /* ExceptionFuzz.h */,
    58065820                                1429D8770ED21ACD00B89619 /* ExceptionHelpers.cpp */,
    58075821                                A72701B30DADE94900E548D7 /* ExceptionHelpers.h */,
     5822                                FE6491381D78F3A300A694D4 /* ExceptionScope.cpp */,
     5823                                FE6491361D78F01300A694D4 /* ExceptionScope.h */,
    58085824                                86CA032D1038E8440028A609 /* Executable.cpp */,
    58095825                                86CAFEE21035DDE60028A609 /* Executable.h */,
     
    62056221                                FE2E6A7A1D6EA5FE0060F896 /* ThrowScope.cpp */,
    62066222                                FE3422111D6B818C0032BE88 /* ThrowScope.h */,
    6207                                 FE6029D81D6E1E330030204D /* ThrowScopeLocation.h */,
    62086223                                0F55989717C86C5600A1E543 /* ToNativeFromValue.h */,
    62096224                                0F2B66D817B6B5AB00A7AE3F /* TypedArrayAdaptors.h */,
     
    77607775                                708EBE241CE8F35800453146 /* IntlObjectInlines.h in Headers */,
    77617776                                0F070A481D543A90006E7232 /* CellContainerInlines.h in Headers */,
    7762                                 FE6029D91D6E1E4F0030204D /* ThrowScopeLocation.h in Headers */,
     7777                                FE6029D91D6E1E4F0030204D /* ExceptionEventLocation.h in Headers */,
    77637778                                0FE0501B1AA9091100D33B33 /* GenericOffset.h in Headers */,
    77647779                                0F2B66E017B6B5AB00A7AE3F /* GenericTypedArrayView.h in Headers */,
     
    82818296                                BCDE3AB80E6C82F5001453A7 /* Structure.h in Headers */,
    82828297                                7E4EE7090EBB7963005934AA /* StructureChain.h in Headers */,
     8298                                FE6491371D78F01D00A694D4 /* ExceptionScope.h in Headers */,
    82838299                                2AAAA31218BD49D100394CC8 /* StructureIDBlob.h in Headers */,
    82848300                                436E54531C468E7400B5AF73 /* B3LegalizeMemoryOffsets.h in Headers */,
     
    83748390                                BC18C47A0E16F5CD00B34460 /* WebKitAvailability.h in Headers */,
    83758391                                A7DCB97312E5193F00911940 /* WriteBarrier.h in Headers */,
     8392                                FE80C1971D775CDD008510C0 /* CatchScope.h in Headers */,
    83768393                                2A4EC90C1860D6C20094F782 /* WriteBarrierBuffer.h in Headers */,
    83778394                                C2B6D75318A33793004A9301 /* WriteBarrierInlines.h in Headers */,
     
    89068923                        files = (
    89078924                                0FFA549716B8835000B3A982 /* A64DOpcode.cpp in Sources */,
     8925                                FE6491391D78F3AF00A694D4 /* ExceptionScope.cpp in Sources */,
    89088926                                0F55F0F414D1063900AC7649 /* AbstractPC.cpp in Sources */,
    89098927                                0FEC856D1BDACDC70080FF74 /* AirAllocateStack.cpp in Sources */,
     
    93889406                                0F2B66E817B6B5AB00A7AE3F /* JSArrayBufferView.cpp in Sources */,
    93899407                                A5311C371C77CECA00E6B1B6 /* HeapSnapshotBuilder.cpp in Sources */,
     9408                                FE80C1991D775FBE008510C0 /* CatchScope.cpp in Sources */,
    93909409                                1421359B0A677F4F00A8195E /* JSBase.cpp in Sources */,
    93919410                                86FA9E91142BBB2E001773B7 /* JSBoundFunction.cpp in Sources */,
     
    95009519                                0F0B839C14BCF46300885B4F /* LLIntThunks.cpp in Sources */,
    95019520                                14469DDE107EC7E700650446 /* Lookup.cpp in Sources */,
     9521                                FE80C19B1D776A98008510C0 /* ExceptionEventLocation.cpp in Sources */,
    95029522                                0F4680CC14BBB17A00BFE272 /* LowLevelInterpreter.cpp in Sources */,
    95039523                                A5AB49DC1BEC8082007020FB /* PerGlobalObjectWrapperWorld.cpp in Sources */,
  • trunk/Source/JavaScriptCore/bindings/ScriptFunctionCall.cpp

    r199642 r205569  
    106106    JSObject* thisObject = m_thisObject.jsObject();
    107107
    108     JSLockHolder lock(m_exec);
     108    VM& vm = m_exec->vm();
     109    JSLockHolder lock(vm);
     110    auto scope = DECLARE_THROW_SCOPE(vm);
    109111
    110112    JSValue function = thisObject->get(m_exec, Identifier::fromString(m_exec, m_name));
    111     if (m_exec->hadException()) {
     113    if (UNLIKELY(scope.exception())) {
    112114        hadException = true;
    113115        return { };
  • trunk/Source/JavaScriptCore/bindings/ScriptValue.cpp

    r205462 r205569  
    122122String ScriptValue::toString(ExecState* scriptState) const
    123123{
     124    VM& vm = scriptState->vm();
     125    auto scope = DECLARE_CATCH_SCOPE(vm);
     126
    124127    String result = m_value.get().toString(scriptState)->value(scriptState);
    125128    // Handle the case where an exception is thrown as part of invoking toString on the object.
    126     if (scriptState->hadException())
    127         scriptState->clearException();
     129    if (UNLIKELY(scope.exception()))
     130        scope.clearException();
    128131    return result;
    129132}
  • trunk/Source/JavaScriptCore/debugger/Debugger.cpp

    r204440 r205569  
    624624void Debugger::pauseIfNeeded(CallFrame* callFrame)
    625625{
     626    VM& vm = callFrame->vm();
     627    auto scope = DECLARE_THROW_SCOPE(vm);
     628
    626629    if (m_isPaused)
    627630        return;
     
    663666        PauseReasonDeclaration reason(*this, didHitBreakpoint ? PausedForBreakpoint : m_reasonForPause);
    664667        handlePause(vmEntryGlobalObject, m_reasonForPause);
    665         RELEASE_ASSERT(!callFrame->hadException());
     668        RELEASE_ASSERT(!scope.exception());
    666669    }
    667670
  • trunk/Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp

    r202242 r205569  
    218218        return jsUndefined();
    219219
    220     JSLockHolder lock(callFrame);
     220    VM& vm = callFrame->vm();
     221    JSLockHolder lock(vm);
     222    auto catchScope = DECLARE_CATCH_SCOPE(vm);
    221223
    222224    CodeBlock* codeBlock = nullptr;
     
    229231   
    230232    DebuggerEvalEnabler evalEnabler(callFrame);
    231     VM& vm = callFrame->vm();
    232233
    233234    EvalContextType evalContextType;
     
    244245
    245246    EvalExecutable* eval = EvalExecutable::create(callFrame, makeSource(script), codeBlock->isStrictMode(), codeBlock->unlinkedCodeBlock()->derivedContextType(), codeBlock->unlinkedCodeBlock()->isArrowFunction(), evalContextType, &variablesUnderTDZ);
    246     if (vm.exception()) {
    247         exception = vm.exception();
    248         vm.clearException();
     247    if (UNLIKELY(catchScope.exception())) {
     248        exception = catchScope.exception();
     249        catchScope.clearException();
    249250        return jsUndefined();
    250251    }
     
    258259    JSValue thisValue = this->thisValue();
    259260    JSValue result = vm.interpreter->execute(eval, callFrame, thisValue, scope()->jsScope());
    260     if (vm.exception()) {
    261         exception = vm.exception();
    262         vm.clearException();
     261    if (UNLIKELY(catchScope.exception())) {
     262        exception = catchScope.exception();
     263        catchScope.clearException();
    263264    }
    264265
  • trunk/Source/JavaScriptCore/dfg/DFGOSRExitCompiler.cpp

    r203364 r205569  
    113113void compileOSRExit(ExecState* exec)
    114114{
    115     if (exec->vm().callFrameForCatch)
    116         RELEASE_ASSERT(exec->vm().callFrameForCatch == exec);
     115    VM* vm = &exec->vm();
     116    auto scope = DECLARE_THROW_SCOPE(*vm);
     117
     118    if (vm->callFrameForCatch)
     119        RELEASE_ASSERT(vm->callFrameForCatch == exec);
    117120   
    118121    CodeBlock* codeBlock = exec->codeBlock();
    119122    ASSERT(codeBlock);
    120123    ASSERT(codeBlock->jitType() == JITCode::DFGJIT);
    121 
    122     VM* vm = &exec->vm();
    123124   
    124125    // It's sort of preferable that we don't GC while in here. Anyways, doing so wouldn't
     
    132133        ASSERT(exit.m_kind == GenericUnwind);
    133134    if (exit.isExceptionHandler())
    134         ASSERT(!!vm->exception());
     135        ASSERT_UNUSED(scope, !!scope.exception());
    135136       
    136137   
  • trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp

    r205520 r205569  
    9898{
    9999    VM* vm = &exec->vm();
     100    auto scope = DECLARE_THROW_SCOPE(*vm);
    100101    NativeCallFrameTracer tracer(vm, exec);
    101102
     
    122123    // Don't put to an object if toString throws an exception.
    123124    auto propertyName = property.toPropertyKey(exec);
    124     if (vm->exception())
     125    if (UNLIKELY(scope.exception()))
    125126        return;
    126127
     
    182183    VM& vm = exec->vm();
    183184    NativeCallFrameTracer tracer(&vm, exec);
     185    auto scope = DECLARE_THROW_SCOPE(vm);
    184186    if (constructor->type() == JSFunctionType)
    185187        return constructEmptyObject(exec, jsCast<JSFunction*>(constructor)->rareData(exec, inlineCapacity)->objectAllocationProfile()->structure());
    186188
    187189    JSValue proto = constructor->get(exec, exec->propertyNames().prototype);
    188     if (vm.exception())
     190    if (UNLIKELY(scope.exception()))
    189191        return nullptr;
    190192    if (proto.isObject())
     
    210212    VM* vm = &exec->vm();
    211213    NativeCallFrameTracer tracer(vm, exec);
     214    auto scope = DECLARE_THROW_SCOPE(*vm);
    212215
    213216    JSValue op1 = JSValue::decode(encodedOp1);
     
    215218
    216219    int32_t a = op1.toInt32(exec);
    217     if (UNLIKELY(vm->exception()))
     220    if (UNLIKELY(scope.exception()))
    218221        return JSValue::encode(JSValue());
    219222    int32_t b = op2.toInt32(exec);
     
    225228    VM* vm = &exec->vm();
    226229    NativeCallFrameTracer tracer(vm, exec);
     230    auto scope = DECLARE_THROW_SCOPE(*vm);
    227231
    228232    JSValue op1 = JSValue::decode(encodedOp1);
     
    230234
    231235    int32_t a = op1.toInt32(exec);
    232     if (UNLIKELY(vm->exception()))
     236    if (UNLIKELY(scope.exception()))
    233237        return JSValue::encode(JSValue());
    234238    int32_t b = op2.toInt32(exec);
     
    240244    VM* vm = &exec->vm();
    241245    NativeCallFrameTracer tracer(vm, exec);
     246    auto scope = DECLARE_THROW_SCOPE(*vm);
    242247
    243248    JSValue op1 = JSValue::decode(encodedOp1);
     
    245250
    246251    int32_t a = op1.toInt32(exec);
    247     if (UNLIKELY(vm->exception()))
     252    if (UNLIKELY(scope.exception()))
    248253        return JSValue::encode(JSValue());
    249254    int32_t b = op2.toInt32(exec);
     
    255260    VM* vm = &exec->vm();
    256261    NativeCallFrameTracer tracer(vm, exec);
     262    auto scope = DECLARE_THROW_SCOPE(*vm);
    257263
    258264    JSValue op1 = JSValue::decode(encodedOp1);
     
    260266
    261267    int32_t a = op1.toInt32(exec);
    262     if (UNLIKELY(vm->exception()))
     268    if (UNLIKELY(scope.exception()))
    263269        return JSValue::encode(JSValue());
    264270    uint32_t b = op2.toUInt32(exec);
     
    270276    VM* vm = &exec->vm();
    271277    NativeCallFrameTracer tracer(vm, exec);
     278    auto scope = DECLARE_THROW_SCOPE(*vm);
    272279
    273280    JSValue op1 = JSValue::decode(encodedOp1);
     
    275282
    276283    int32_t a = op1.toInt32(exec);
    277     if (UNLIKELY(vm->exception()))
     284    if (UNLIKELY(scope.exception()))
    278285        return JSValue::encode(JSValue());
    279286    uint32_t b = op2.toUInt32(exec);
     
    285292    VM* vm = &exec->vm();
    286293    NativeCallFrameTracer tracer(vm, exec);
     294    auto scope = DECLARE_THROW_SCOPE(*vm);
    287295
    288296    JSValue op1 = JSValue::decode(encodedOp1);
     
    290298
    291299    uint32_t a = op1.toUInt32(exec);
    292     if (UNLIKELY(vm->exception()))
     300    if (UNLIKELY(scope.exception()))
    293301        return JSValue::encode(JSValue());
    294302    uint32_t b = op2.toUInt32(exec);
     
    316324    VM* vm = &exec->vm();
    317325    NativeCallFrameTracer tracer(vm, exec);
     326    auto scope = DECLARE_THROW_SCOPE(*vm);
    318327
    319328    JSValue op1 = JSValue::decode(encodedOp1);
     
    321330
    322331    double a = op1.toNumber(exec);
    323     if (UNLIKELY(vm->exception()))
     332    if (UNLIKELY(scope.exception()))
    324333        return JSValue::encode(JSValue());
    325334    double b = op2.toNumber(exec);
     
    331340    VM* vm = &exec->vm();
    332341    NativeCallFrameTracer tracer(vm, exec);
     342    auto scope = DECLARE_THROW_SCOPE(*vm);
    333343
    334344    JSValue op1 = JSValue::decode(encodedOp1);
    335345    double a = op1.toNumber(exec);
    336     if (UNLIKELY(vm->exception()))
     346    if (UNLIKELY(scope.exception()))
    337347        return PNaN;
    338348    return fabs(a);
     
    343353    VM* vm = &exec->vm();
    344354    NativeCallFrameTracer tracer(vm, exec);
     355    auto scope = DECLARE_THROW_SCOPE(*vm);
    345356
    346357    JSValue op1 = JSValue::decode(encodedOp1);
    347358    uint32_t value = op1.toUInt32(exec);
    348     if (UNLIKELY(vm->exception()))
     359    if (UNLIKELY(scope.exception()))
    349360        return 0;
    350361    return clz32(value);
     
    355366    VM* vm = &exec->vm();
    356367    NativeCallFrameTracer tracer(vm, exec);
     368    auto scope = DECLARE_THROW_SCOPE(*vm);
    357369
    358370    JSValue op1 = JSValue::decode(encodedOp1);
    359371    double a = op1.toNumber(exec);
    360     if (UNLIKELY(vm->exception()))
     372    if (UNLIKELY(scope.exception()))
    361373        return JSValue::encode(JSValue());
    362374    return cos(a);
     
    367379    VM* vm = &exec->vm();
    368380    NativeCallFrameTracer tracer(vm, exec);
     381    auto scope = DECLARE_THROW_SCOPE(*vm);
    369382
    370383    JSValue op1 = JSValue::decode(encodedOp1);
    371384    double a = op1.toNumber(exec);
    372     if (UNLIKELY(vm->exception()))
     385    if (UNLIKELY(scope.exception()))
    373386        return PNaN;
    374387    return static_cast<float>(a);
     
    379392    VM* vm = &exec->vm();
    380393    NativeCallFrameTracer tracer(vm, exec);
     394    auto scope = DECLARE_THROW_SCOPE(*vm);
    381395
    382396    JSValue op1 = JSValue::decode(encodedOp1);
    383397    double a = op1.toNumber(exec);
    384     if (UNLIKELY(vm->exception()))
     398    if (UNLIKELY(scope.exception()))
    385399        return PNaN;
    386400    return log(a);
     
    391405    VM* vm = &exec->vm();
    392406    NativeCallFrameTracer tracer(vm, exec);
     407    auto scope = DECLARE_THROW_SCOPE(*vm);
    393408
    394409    JSValue op1 = JSValue::decode(encodedOp1);
    395410    double a = op1.toNumber(exec);
    396     if (UNLIKELY(vm->exception()))
     411    if (UNLIKELY(scope.exception()))
    397412        return PNaN;
    398413    return sin(a);
     
    403418    VM* vm = &exec->vm();
    404419    NativeCallFrameTracer tracer(vm, exec);
     420    auto scope = DECLARE_THROW_SCOPE(*vm);
    405421
    406422    JSValue op1 = JSValue::decode(encodedOp1);
    407423    double a = op1.toNumber(exec);
    408     if (UNLIKELY(vm->exception()))
     424    if (UNLIKELY(scope.exception()))
    409425        return PNaN;
    410426    return sqrt(a);
     
    432448    VM& vm = exec->vm();
    433449    NativeCallFrameTracer tracer(&vm, exec);
    434    
     450    auto scope = DECLARE_THROW_SCOPE(vm);
     451
    435452    JSValue baseValue = JSValue::decode(encodedBase);
    436453    JSValue property = JSValue::decode(encodedProperty);
     
    458475
    459476    baseValue.requireObjectCoercible(exec);
    460     if (vm.exception())
     477    if (UNLIKELY(scope.exception()))
    461478        return JSValue::encode(jsUndefined());
    462479    auto propertyName = property.toPropertyKey(exec);
    463     if (vm.exception())
     480    if (UNLIKELY(scope.exception()))
    464481        return JSValue::encode(jsUndefined());
    465482    return JSValue::encode(baseValue.get(exec, propertyName));
     
    470487    VM& vm = exec->vm();
    471488    NativeCallFrameTracer tracer(&vm, exec);
    472    
     489    auto scope = DECLARE_THROW_SCOPE(vm);
     490
    473491    JSValue property = JSValue::decode(encodedProperty);
    474492
     
    491509
    492510    auto propertyName = property.toPropertyKey(exec);
    493     if (vm.exception())
     511    if (UNLIKELY(scope.exception()))
    494512        return JSValue::encode(jsUndefined());
    495513    return JSValue::encode(JSValue(base).get(exec, propertyName));
     
    860878    VM& vm = exec->vm();
    861879    NativeCallFrameTracer tracer(&vm, exec);
     880    auto scope = DECLARE_THROW_SCOPE(vm);
    862881
    863882    JSValue baseValue = JSValue::decode(encodedBase);
     
    885904
    886905    baseValue.requireObjectCoercible(exec);
    887     if (vm.exception())
     906    if (UNLIKELY(scope.exception()))
    888907        return JSValue::encode(JSValue());
    889908
    890909    auto property = subscript.toPropertyKey(exec);
    891     if (vm.exception())
     910    if (UNLIKELY(scope.exception()))
    892911        return JSValue::encode(JSValue());
    893912    return JSValue::encode(baseValue.get(exec, property, slot));
     
    914933    VM& vm = exec->vm();
    915934    NativeCallFrameTracer tracer(&vm, exec);
     935    auto scope = DECLARE_THROW_SCOPE(vm);
    916936
    917937    Identifier property = JSValue::decode(encodedSubscript).toPropertyKey(exec);
    918     if (vm.exception())
     938    if (UNLIKELY(scope.exception()))
    919939        return;
    920940    putWithThis<true>(exec, encodedBase, encodedThis, encodedValue, property);
     
    925945    VM& vm = exec->vm();
    926946    NativeCallFrameTracer tracer(&vm, exec);
     947    auto scope = DECLARE_THROW_SCOPE(vm);
    927948
    928949    Identifier property = JSValue::decode(encodedSubscript).toPropertyKey(exec);
    929     if (vm.exception())
     950    if (UNLIKELY(scope.exception()))
    930951        return;
    931952    putWithThis<false>(exec, encodedBase, encodedThis, encodedValue, property);
     
    14421463
    14431464    JSString* str1 = JSValue::decode(a).toString(exec);
    1444     ASSERT(!vm.exception()); // Impossible, since we must have been given primitives.
     1465    ASSERT(!scope.exception()); // Impossible, since we must have been given primitives.
    14451466    JSString* str2 = JSValue::decode(b).toString(exec);
    1446     ASSERT(!vm.exception());
     1467    ASSERT(!scope.exception());
    14471468
    14481469    if (sumOverflows<int32_t>(str1->length(), str2->length())) {
     
    14611482
    14621483    JSString* str1 = JSValue::decode(a).toString(exec);
    1463     ASSERT(!vm.exception()); // Impossible, since we must have been given primitives.
     1484    ASSERT(!scope.exception()); // Impossible, since we must have been given primitives.
    14641485    JSString* str2 = JSValue::decode(b).toString(exec);
    1465     ASSERT(!vm.exception());
     1486    ASSERT(!scope.exception());
    14661487    JSString* str3 = JSValue::decode(c).toString(exec);
    1467     ASSERT(!vm.exception());
     1488    ASSERT(!scope.exception());
    14681489
    14691490    if (sumOverflows<int32_t>(str1->length(), str2->length(), str3->length())) {
  • trunk/Source/JavaScriptCore/inspector/InjectedScriptManager.cpp

    r205462 r205569  
    135135JSC::JSObject* InjectedScriptManager::createInjectedScript(const String& source, ExecState* scriptState, int id)
    136136{
    137     JSLockHolder lock(scriptState);
     137    VM& vm = scriptState->vm();
     138    JSLockHolder lock(vm);
     139    auto scope = DECLARE_CATCH_SCOPE(vm);
    138140
    139141    SourceCode sourceCode = makeSource(source);
     
    158160
    159161    JSValue result = JSC::call(scriptState, functionValue, callType, callData, globalThisValue, args);
    160     scriptState->clearException();
     162    scope.clearException();
    161163    return result.getObject();
    162164}
  • trunk/Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.cpp

    r205462 r205569  
    222222        return;
    223223
    224     ErrorHandlingScope errorScope(exec->vm());
     224    VM& vm = exec->vm();
     225    auto scope = DECLARE_CATCH_SCOPE(vm);
     226    ErrorHandlingScope errorScope(vm);
    225227
    226228    RefPtr<ScriptCallStack> callStack = createScriptCallStackFromException(exec, exception, ScriptCallStack::maxCallStackSizeToCapture);
     
    231233    // If this is a custom exception object, call toString on it to try and get a nice string representation for the exception.
    232234    String errorMessage = exception->value().toString(exec)->value(exec);
    233     exec->clearException();
     235    scope.clearException();
    234236
    235237    if (JSGlobalObjectConsoleClient::logToSystemConsole()) {
  • trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp

    r205198 r205569  
    104104
    105105    String program = scriptValue.toString(exec)->value(exec);
    106     if (exec->hadException())
     106    if (UNLIKELY(scope.exception()))
    107107        return jsUndefined();
    108108
     
    260260
    261261    VM& vm = exec->vm();
     262    auto scope = DECLARE_THROW_SCOPE(vm);
    262263    JSValue value = exec->uncheckedArgument(0);
    263264
     
    265266        unsigned index = 0;
    266267        JSArray* array = constructEmptyArray(exec, nullptr);
    267         if (UNLIKELY(vm.exception()))
     268        if (UNLIKELY(scope.exception()))
    268269            return jsUndefined();
    269270        switch (promise->status(exec->vm())) {
     
    287288        unsigned index = 0;
    288289        JSArray* array = constructEmptyArray(exec, nullptr);
    289         if (UNLIKELY(vm.exception()))
     290        if (UNLIKELY(scope.exception()))
    290291            return jsUndefined();
    291292        array->putDirectIndex(exec, index++, constructInternalProperty(exec, "targetFunction", boundFunction->targetFunction()));
     
    299300        unsigned index = 0;
    300301        JSArray* array = constructEmptyArray(exec, nullptr, 2);
    301         if (UNLIKELY(vm.exception()))
     302        if (UNLIKELY(scope.exception()))
    302303            return jsUndefined();
    303304        array->putDirectIndex(exec, index++, constructInternalProperty(exec, ASCIILiteral("target"), proxy->target()));
     
    313314            unsigned index = 0;
    314315            JSArray* array = constructEmptyArray(exec, nullptr, 2);
    315             if (UNLIKELY(vm.exception()))
     316            if (UNLIKELY(scope.exception()))
    316317                return jsUndefined();
    317318            array->putDirectIndex(exec, index++, constructInternalProperty(exec, "array", iteratedValue));
     
    336337        unsigned index = 0;
    337338        JSArray* array = constructEmptyArray(exec, nullptr, 2);
    338         if (UNLIKELY(vm.exception()))
     339        if (UNLIKELY(scope.exception()))
    339340            return jsUndefined();
    340341        array->putDirectIndex(exec, index++, constructInternalProperty(exec, "map", mapIterator->iteratedValue()));
     
    358359        unsigned index = 0;
    359360        JSArray* array = constructEmptyArray(exec, nullptr, 2);
    360         if (UNLIKELY(vm.exception()))
     361        if (UNLIKELY(scope.exception()))
    361362            return jsUndefined();
    362363        array->putDirectIndex(exec, index++, constructInternalProperty(exec, "set", setIterator->iteratedValue()));
     
    368369        unsigned index = 0;
    369370        JSArray* array = constructEmptyArray(exec, nullptr, 1);
    370         if (UNLIKELY(vm.exception()))
     371        if (UNLIKELY(scope.exception()))
    371372            return jsUndefined();
    372373        array->putDirectIndex(exec, index++, constructInternalProperty(exec, "string", stringIterator->iteratedValue(exec)));
     
    377378        unsigned index = 0;
    378379        JSArray* array = constructEmptyArray(exec, nullptr, 1);
    379         if (UNLIKELY(vm.exception()))
     380        if (UNLIKELY(scope.exception()))
    380381            return jsUndefined();
    381382        array->putDirectIndex(exec, index++, constructInternalProperty(exec, "object", propertyNameIterator->iteratedValue()));
     
    405406
    406407    VM& vm = exec->vm();
     408    auto scope = DECLARE_THROW_SCOPE(vm);
    407409    JSValue value = exec->uncheckedArgument(0);
    408410    JSWeakMap* weakMap = jsDynamicCast<JSWeakMap*>(value);
     
    419421
    420422    JSArray* array = constructEmptyArray(exec, nullptr);
    421     if (UNLIKELY(vm.exception()))
     423    if (UNLIKELY(scope.exception()))
    422424        return jsUndefined();
    423425    for (auto it = weakMap->weakMapData()->begin(); it != weakMap->weakMapData()->end(); ++it) {
     
    452454
    453455    VM& vm = exec->vm();
     456    auto scope = DECLARE_THROW_SCOPE(vm);
    454457    JSValue value = exec->uncheckedArgument(0);
    455458    JSWeakSet* weakSet = jsDynamicCast<JSWeakSet*>(value);
     
    466469
    467470    JSArray* array = constructEmptyArray(exec, nullptr);
    468     if (UNLIKELY(vm.exception()))
     471    if (UNLIKELY(scope.exception()))
    469472        return jsUndefined();
    470473    for (auto it = weakSet->weakMapData()->begin(); it != weakSet->weakMapData()->end(); ++it) {
     
    496499
    497500    VM& vm = exec->vm();
     501    auto scope = DECLARE_THROW_SCOPE(vm);
    498502    JSValue iterator;
    499503    JSValue value = exec->uncheckedArgument(0);
     
    506510    else if (JSPropertyNameIterator* propertyNameIterator = jsDynamicCast<JSPropertyNameIterator*>(value)) {
    507511        iterator = propertyNameIterator->clone(exec);
    508         if (UNLIKELY(vm.exception()))
     512        if (UNLIKELY(scope.exception()))
    509513            return JSValue();
    510514    } else {
     
    526530
    527531    JSArray* array = constructEmptyArray(exec, nullptr);
    528     if (UNLIKELY(vm.exception()))
     532    if (UNLIKELY(scope.exception()))
    529533        return jsUndefined();
    530534
    531535    for (unsigned i = 0; i < numberToFetch; ++i) {
    532536        JSValue next = iteratorStep(exec, iterator);
    533         if (UNLIKELY(vm.exception()))
     537        if (UNLIKELY(scope.exception()))
    534538            break;
    535539        if (next.isFalse())
     
    537541
    538542        JSValue nextValue = iteratorValue(exec, next);
    539         if (UNLIKELY(vm.exception()))
     543        if (UNLIKELY(scope.exception()))
    540544            break;
    541545
  • trunk/Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.cpp

    r205462 r205569  
    8484
    8585    String script = scriptValue.toString(exec)->value(exec);
    86     if (exec->hadException())
     86    if (UNLIKELY(scope.exception()))
    8787        return jsUndefined();
    8888
  • trunk/Source/JavaScriptCore/inspector/ScriptCallStackFactory.cpp

    r204740 r205569  
    120120static void extractSourceInformationFromException(JSC::ExecState* exec, JSObject* exceptionObject, int* lineNumber, int* columnNumber, String* sourceURL)
    121121{
     122    VM& vm = exec->vm();
     123    auto scope = DECLARE_CATCH_SCOPE(vm);
     124
    122125    // FIXME: <http://webkit.org/b/115087> Web Inspector: Should not need to evaluate JavaScript handling exceptions
    123126    JSValue lineValue = exceptionObject->getDirect(exec->vm(), Identifier::fromString(exec, "line"));
     
    127130    JSValue sourceURLValue = exceptionObject->getDirect(exec->vm(), Identifier::fromString(exec, "sourceURL"));
    128131    *sourceURL = sourceURLValue && sourceURLValue.isString() ? sourceURLValue.toString(exec)->value(exec) : ASCIILiteral("undefined");
    129     exec->clearException();
     132    scope.clearException();
    130133}
    131134
  • trunk/Source/JavaScriptCore/interpreter/CachedCall.h

    r205462 r205569  
    5555            } else
    5656                throwStackOverflowError(callFrame, scope);
    57             m_valid = !callFrame->hadException();
     57            m_valid = !scope.exception();
    5858        }
    5959       
  • trunk/Source/JavaScriptCore/interpreter/CallFrame.h

    r204439 r205569  
    116116        // pointer, so these are inefficient, and should be used sparingly in new code.
    117117        // But they're used in many places in legacy code, so they're not going away any time soon.
    118 
    119         void clearException() { vm().clearException(); }
    120 
    121         Exception* exception() const { return vm().exception(); }
    122         bool hadException() const { return !!vm().exception(); }
    123 
    124         Exception* lastException() const { return vm().lastException(); }
    125         void clearLastException() { vm().clearLastException(); }
    126118
    127119        AtomicStringTable* atomicStringTable() const { return vm().atomicStringTable(); }
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r205462 r205569  
    106106    }
    107107    String programSource = asString(program)->value(callFrame);
    108     if (callFrame->hadException())
     108    if (UNLIKELY(scope.exception()))
    109109        return JSValue();
    110110   
     
    146146       
    147147        // If the literal parser bailed, it should not have thrown exceptions.
    148         ASSERT(!vm.exception());
     148        ASSERT(!scope.exception());
    149149
    150150        eval = callerCodeBlock->evalCodeCache().getSlow(callFrame, callerCodeBlock, callerCodeBlock->isStrictMode(), derivedContextType, evalContextType, isArrowFunctionContext, programSource, callerScopeChain);
     
    189189        RELEASE_ASSERT(arguments.isObject());
    190190        length = getLength(callFrame, jsCast<JSObject*>(cell));
    191         if (UNLIKELY(callFrame->hadException()))
     191        if (UNLIKELY(scope.exception()))
    192192            return 0;
    193193        break;
     
    587587ALWAYS_INLINE static void notifyDebuggerOfUnwinding(CallFrame* callFrame)
    588588{
     589    VM& vm = callFrame->vm();
     590    auto throwScope = DECLARE_THROW_SCOPE(vm);
    589591    if (Debugger* debugger = callFrame->vmEntryGlobalObject()->debugger()) {
    590         SuspendExceptionScope scope(&callFrame->vm());
     592        SuspendExceptionScope scope(&vm);
    591593        if (jsDynamicCast<JSFunction*>(callFrame->callee()))
    592594            debugger->returnEvent(callFrame);
    593595        else
    594596            debugger->didExecuteProgram(callFrame);
    595         ASSERT(!callFrame->hadException());
     597        ASSERT_UNUSED(throwScope, !throwScope.exception());
    596598    }
    597599}
     
    681683NEVER_INLINE HandlerInfo* Interpreter::unwind(VM& vm, CallFrame*& callFrame, Exception* exception, UnwindStart unwindStart)
    682684{
     685    auto scope = DECLARE_THROW_SCOPE(vm);
     686
    683687    if (unwindStart == UnwindFromCallerFrame) {
    684688        if (callFrame->callerFrameOrVMEntryFrame() == vm.topVMEntryFrame)
     
    699703        exceptionValue = jsNull();
    700704
    701     ASSERT(vm.exception() && vm.exception()->stack().size());
     705    ASSERT_UNUSED(scope, scope.exception() && scope.exception()->stack().size());
    702706
    703707    // Calculate an exception handler vPC, unwinding call frames as necessary.
     
    898902    // Execute the code:
    899903    JSValue result = program->generatedJITCode()->execute(&vm, &protoCallFrame);
    900 
     904    throwScope.release();
    901905    return checkedReturn(result);
    902906}
     
    907911    auto throwScope = DECLARE_THROW_SCOPE(vm);
    908912
    909     ASSERT(!callFrame->hadException());
     913    ASSERT(!throwScope.exception());
    910914    ASSERT(!vm.isCollectorBusy());
    911915    if (vm.isCollectorBusy())
     
    970974    auto throwScope = DECLARE_THROW_SCOPE(vm);
    971975
    972     ASSERT(!callFrame->hadException());
     976    ASSERT(!throwScope.exception());
    973977    ASSERT(!vm.isCollectorBusy());
    974978    // We throw in this case because we have to return something "valid" but we're
     
    10211025            result = JSValue::decode(vmEntryToNative(reinterpret_cast<void*>(constructData.native.function), &vm, &protoCallFrame));
    10221026
    1023             if (!callFrame->hadException())
     1027            if (LIKELY(!throwScope.exception()))
    10241028                RELEASE_ASSERT(result.isObject());
    10251029        }
    10261030    }
    10271031
    1028     if (callFrame->hadException())
     1032    if (UNLIKELY(throwScope.exception()))
    10291033        return 0;
    10301034    ASSERT(result.isObject());
     
    10361040    VM& vm = *scope->vm();
    10371041    auto throwScope = DECLARE_THROW_SCOPE(vm);
    1038     ASSERT(!vm.exception());
     1042    ASSERT(!throwScope.exception());
    10391043   
    10401044    if (vm.isCollectorBusy())
     
    10851089
    10861090    ASSERT(scope->vm() == &callFrame->vm());
    1087     ASSERT(!vm.exception());
     1091    ASSERT(!throwScope.exception());
    10881092    ASSERT(!vm.isCollectorBusy());
    10891093    RELEASE_ASSERT(vm.currentThreadIsHoldingAPILock());
     
    11911195
    11921196    ASSERT(scope->vm() == &callFrame->vm());
    1193     ASSERT(!vm.exception());
     1197    ASSERT(!throwScope.exception());
    11941198    ASSERT(!vm.isCollectorBusy());
    11951199    RELEASE_ASSERT(vm.currentThreadIsHoldingAPILock());
     
    12321236NEVER_INLINE void Interpreter::debug(CallFrame* callFrame, DebugHookID debugHookID)
    12331237{
     1238    VM& vm = callFrame->vm();
     1239    auto scope = DECLARE_CATCH_SCOPE(vm);
    12341240    Debugger* debugger = callFrame->vmEntryGlobalObject()->debugger();
    12351241    if (!debugger)
     
    12371243
    12381244    ASSERT(callFrame->codeBlock()->hasDebuggerRequests());
    1239     ASSERT(!callFrame->hadException());
     1245    ASSERT_UNUSED(scope, !scope.exception());
    12401246
    12411247    switch (debugHookID) {
     
    12591265            break;
    12601266    }
    1261     ASSERT(!callFrame->hadException());
    1262 }   
     1267    ASSERT(!scope.exception());
     1268}
    12631269
    12641270} // namespace JSC
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.h

    r205462 r205569  
    3232
    3333#include "ArgList.h"
     34#include "CatchScope.h"
    3435#include "JSCJSValue.h"
    3536#include "JSCell.h"
     
    3940#include "StackAlignment.h"
    4041#include "StackFrame.h"
     42#include "ThrowScope.h"
    4143#include <wtf/HashMap.h>
    4244#include <wtf/text/StringBuilder.h>
     
    9395            : m_vm(vm)
    9496        {
    95             oldException = vm->exception();
    96             vm->clearException();
     97            auto scope = DECLARE_CATCH_SCOPE(*vm);
     98            oldException = scope.exception();
     99            scope.clearException();
    97100        }
    98101        ~SuspendExceptionScope()
  • trunk/Source/JavaScriptCore/interpreter/ShadowChicken.cpp

    r201787 r205569  
    437437{
    438438    VM& vm = exec->vm();
     439    auto scope = DECLARE_THROW_SCOPE(vm);
    439440    JSArray* result = constructEmptyArray(exec, 0);
    440     if (UNLIKELY(vm.exception()))
     441    if (UNLIKELY(scope.exception()))
    441442        return nullptr;
    442443
  • trunk/Source/JavaScriptCore/jit/JITCode.cpp

    r191058 r205569  
    7070JSValue JITCode::execute(VM* vm, ProtoCallFrame* protoCallFrame)
    7171{
     72    auto scope = DECLARE_THROW_SCOPE(*vm);
    7273    void* entryAddress;
    7374    JSFunction* function = jsDynamicCast<JSFunction*>(protoCallFrame->callee());
     
    7980        entryAddress = addressForCall(MustCheckArity).executableAddress();
    8081    JSValue result = JSValue::decode(vmEntryToJavaScript(entryAddress, vm, protoCallFrame));
    81     return vm->exception() ? jsNull() : result;
     82    return scope.exception() ? jsNull() : result;
    8283}
    8384
  • trunk/Source/JavaScriptCore/jit/JITExceptions.cpp

    r205462 r205569  
    4343void genericUnwind(VM* vm, ExecState* callFrame, UnwindStart unwindStart)
    4444{
     45    auto scope = DECLARE_THROW_SCOPE(*vm);
    4546    if (Options::breakOnThrow()) {
    4647        CodeBlock* codeBlock = callFrame->codeBlock();
     
    5960    vm->shadowChicken().log(*vm, shadowChickenTopFrame, ShadowChicken::Packet::throwPacket());
    6061   
    61     Exception* exception = vm->exception();
     62    Exception* exception = scope.exception();
    6263    RELEASE_ASSERT(exception);
    6364    HandlerInfo* handler = vm->interpreter->unwind(*vm, callFrame, exception, unwindStart); // This may update callFrame.
  • trunk/Source/JavaScriptCore/jit/JITOperations.cpp

    r205462 r205569  
    276276    PropertySlot slot(base, PropertySlot::InternalMethodType::HasProperty);
    277277    bool result = asObject(base)->getPropertySlot(exec, ident, slot);
    278     if (vm->exception())
     278    if (UNLIKELY(scope.exception()))
    279279        return JSValue::encode(jsUndefined());
    280280   
     
    490490{
    491491    VM& vm = callFrame->vm();
     492    auto scope = DECLARE_THROW_SCOPE(vm);
    492493    if (LIKELY(subscript.isUInt32())) {
    493494        byValInfo->tookSlowPath = true;
     
    511512    auto property = subscript.toPropertyKey(callFrame);
    512513    // Don't put to an object if toString threw an exception.
    513     if (callFrame->vm().exception())
     514    if (UNLIKELY(scope.exception()))
    514515        return;
    515516
     
    523524static void directPutByVal(CallFrame* callFrame, JSObject* baseObject, JSValue subscript, JSValue value, ByValInfo* byValInfo)
    524525{
     526    VM& vm = callFrame->vm();
     527    auto scope = DECLARE_THROW_SCOPE(vm);
    525528    bool isStrictMode = callFrame->codeBlock()->isStrictMode();
    526529    if (LIKELY(subscript.isUInt32())) {
     
    554557    // Don't put to an object if toString threw an exception.
    555558    auto property = subscript.toPropertyKey(callFrame);
    556     if (callFrame->vm().exception())
     559    if (UNLIKELY(scope.exception()))
    557560        return;
    558561
     
    775778EncodedJSValue JIT_OPERATION operationCallEval(ExecState* exec, ExecState* execCallee)
    776779{
    777     UNUSED_PARAM(exec);
     780    VM* vm = &exec->vm();
     781    auto scope = DECLARE_THROW_SCOPE(*vm);
    778782
    779783    execCallee->setCodeBlock(0);
     
    782786        return JSValue::encode(JSValue());
    783787
    784     VM* vm = &execCallee->vm();
    785788    JSValue result = eval(execCallee);
    786     if (vm->exception())
     789    if (UNLIKELY(scope.exception()))
    787790        return EncodedJSValue();
    788791   
     
    808811            execCallee->setCallee(asObject(callee));
    809812            vm->hostCallReturnValue = JSValue::decode(callData.native.function(execCallee));
    810             if (vm->exception()) {
     813            if (UNLIKELY(scope.exception())) {
    811814                return encodeResult(
    812815                    vm->getCTIStub(throwExceptionFromCallSlowPathGenerator).code().executableAddress(),
     
    837840        execCallee->setCallee(asObject(callee));
    838841        vm->hostCallReturnValue = JSValue::decode(constructData.native.function(execCallee));
    839         if (vm->exception()) {
     842        if (UNLIKELY(scope.exception())) {
    840843            return encodeResult(
    841844                vm->getCTIStub(throwExceptionFromCallSlowPathGenerator).code().executableAddress(),
     
    14631466static void putAccessorByVal(ExecState* exec, JSObject* base, JSValue subscript, int32_t attribute, JSObject* accessor, AccessorType accessorType)
    14641467{
     1468    VM& vm = exec->vm();
     1469    auto scope = DECLARE_THROW_SCOPE(vm);
    14651470    auto propertyKey = subscript.toPropertyKey(exec);
    1466     if (exec->hadException())
     1471    if (UNLIKELY(scope.exception()))
    14671472        return;
    14681473
     
    16091614static JSValue getByVal(ExecState* exec, JSValue baseValue, JSValue subscript, ByValInfo* byValInfo, ReturnAddressPtr returnAddress)
    16101615{
     1616    VM& vm = exec->vm();
     1617    auto scope = DECLARE_THROW_SCOPE(vm);
     1618
    16111619    if (LIKELY(baseValue.isCell() && subscript.isString())) {
    1612         VM& vm = exec->vm();
    16131620        Structure& structure = *baseValue.asCell()->structure(vm);
    16141621        if (JSCell::canUseFastGetOwnProperty(structure)) {
     
    16521659
    16531660    baseValue.requireObjectCoercible(exec);
    1654     if (exec->hadException())
     1661    if (UNLIKELY(scope.exception()))
    16551662        return jsUndefined();
    16561663    auto property = subscript.toPropertyKey(exec);
    1657     if (exec->hadException())
     1664    if (UNLIKELY(scope.exception()))
    16581665        return jsUndefined();
    16591666
     
    18461853    VM& vm = exec->vm();
    18471854    NativeCallFrameTracer tracer(&vm, exec);
     1855    auto scope = DECLARE_THROW_SCOPE(vm);
    18481856    JSValue baseValue = JSValue::decode(encodedBase);
    18491857    JSValue subscript = JSValue::decode(encodedSubscript);
     
    18631871    } else {
    18641872        baseValue.requireObjectCoercible(exec);
    1865         if (exec->hadException())
     1873        if (UNLIKELY(scope.exception()))
    18661874            return JSValue::encode(jsUndefined());
    18671875        auto property = subscript.toPropertyKey(exec);
    1868         if (exec->hadException())
     1876        if (UNLIKELY(scope.exception()))
    18691877            return JSValue::encode(jsUndefined());
    18701878        result = baseValue.get(exec, property);
     
    19151923        couldDelete = baseObj->methodTable(vm)->deletePropertyByIndex(baseObj, exec, index);
    19161924    else {
    1917         if (vm.exception())
     1925        if (UNLIKELY(scope.exception()))
    19181926            return false;
    19191927        Identifier property = key.toPropertyKey(exec);
    1920         if (vm.exception())
     1928        if (UNLIKELY(scope.exception()))
    19211929            return false;
    19221930        couldDelete = baseObj->methodTable(vm)->deleteProperty(baseObj, exec, property);
     
    21232131    scope->methodTable()->put(scope, exec, ident, value, slot);
    21242132   
    2125     if (vm.exception())
     2133    if (UNLIKELY(throwScope.exception()))
    21262134        return;
    21272135
     
    23722380ALWAYS_INLINE static EncodedJSValue unprofiledMul(VM& vm, ExecState* exec, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2)
    23732381{
     2382    auto scope = DECLARE_THROW_SCOPE(vm);
    23742383    JSValue op1 = JSValue::decode(encodedOp1);
    23752384    JSValue op2 = JSValue::decode(encodedOp2);
    23762385
    23772386    double a = op1.toNumber(exec);
    2378     if (UNLIKELY(vm.exception()))
     2387    if (UNLIKELY(scope.exception()))
    23792388        return JSValue::encode(JSValue());
    23802389    double b = op2.toNumber(exec);
     
    23842393ALWAYS_INLINE static EncodedJSValue profiledMul(VM& vm, ExecState* exec, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2, ArithProfile* arithProfile, bool shouldObserveLHSAndRHSTypes = true)
    23852394{
     2395    auto scope = DECLARE_THROW_SCOPE(vm);
    23862396    JSValue op1 = JSValue::decode(encodedOp1);
    23872397    JSValue op2 = JSValue::decode(encodedOp2);
     
    23912401
    23922402    double a = op1.toNumber(exec);
    2393     if (UNLIKELY(vm.exception()))
     2403    if (UNLIKELY(scope.exception()))
    23942404        return JSValue::encode(JSValue());
    23952405    double b = op2.toNumber(exec);
    2396     if (UNLIKELY(vm.exception()))
     2406    if (UNLIKELY(scope.exception()))
    23972407        return JSValue::encode(JSValue());
    23982408   
     
    24692479ALWAYS_INLINE static EncodedJSValue unprofiledSub(VM& vm, ExecState* exec, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2)
    24702480{
     2481    auto scope = DECLARE_THROW_SCOPE(vm);
    24712482    JSValue op1 = JSValue::decode(encodedOp1);
    24722483    JSValue op2 = JSValue::decode(encodedOp2);
    24732484
    24742485    double a = op1.toNumber(exec);
    2475     if (UNLIKELY(vm.exception()))
     2486    if (UNLIKELY(scope.exception()))
    24762487        return JSValue::encode(JSValue());
    24772488    double b = op2.toNumber(exec);
     
    24812492ALWAYS_INLINE static EncodedJSValue profiledSub(VM& vm, ExecState* exec, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2, ArithProfile* arithProfile, bool shouldObserveLHSAndRHSTypes = true)
    24822493{
     2494    auto scope = DECLARE_THROW_SCOPE(vm);
    24832495    JSValue op1 = JSValue::decode(encodedOp1);
    24842496    JSValue op2 = JSValue::decode(encodedOp2);
     
    24882500
    24892501    double a = op1.toNumber(exec);
    2490     if (UNLIKELY(vm.exception()))
     2502    if (UNLIKELY(scope.exception()))
    24912503        return JSValue::encode(JSValue());
    24922504    double b = op2.toNumber(exec);
    2493     if (UNLIKELY(vm.exception()))
     2505    if (UNLIKELY(scope.exception()))
    24942506        return JSValue::encode(JSValue());
    24952507   
     
    25812593    VM& vm = exec->vm();
    25822594    NativeCallFrameTracer tracer(&vm, exec);
    2583     RELEASE_ASSERT(!!vm.exception());
    2584 
    2585     if (isTerminatedExecutionException(vm.exception())) {
     2595    auto scope = DECLARE_THROW_SCOPE(vm);
     2596    RELEASE_ASSERT(!!scope.exception());
     2597
     2598    if (isTerminatedExecutionException(scope.exception())) {
    25862599        genericUnwind(&vm, exec);
    25872600        return 1;
    2588     } else
    2589         return 0;
     2601    }
     2602    return 0;
    25902603}
    25912604
  • trunk/Source/JavaScriptCore/jsc.cpp

    r205462 r205569  
    302302    static bool getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName name, PropertySlot& slot)
    303303    {
     304        VM& vm = exec->vm();
     305        auto scope = DECLARE_THROW_SCOPE(vm);
    304306        ImpureGetter* thisObject = jsCast<ImpureGetter*>(object);
    305307       
     
    307309            if (thisObject->m_delegate->getPropertySlot(exec, name, slot))
    308310                return true;
    309             if (exec->hadException())
     311            if (UNLIKELY(scope.exception()))
    310312                return false;
    311313        }
     
    10381040JSInternalPromise* GlobalObject::moduleLoaderResolve(JSGlobalObject* globalObject, ExecState* exec, JSModuleLoader*, JSValue keyValue, JSValue referrerValue, JSValue)
    10391041{
     1042    VM& vm = globalObject->vm();
     1043    auto scope = DECLARE_CATCH_SCOPE(vm);
     1044
    10401045    JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject);
    10411046    const Identifier key = keyValue.toPropertyKey(exec);
    1042     if (exec->hadException()) {
    1043         JSValue exception = exec->exception();
    1044         exec->clearException();
     1047    if (UNLIKELY(scope.exception())) {
     1048        JSValue exception = scope.exception();
     1049        scope.clearException();
    10451050        return deferred->reject(exec, exception);
    10461051    }
     
    10551060    } else {
    10561061        const Identifier referrer = referrerValue.toPropertyKey(exec);
    1057         if (exec->hadException()) {
    1058             JSValue exception = exec->exception();
    1059             exec->clearException();
     1062        if (UNLIKELY(scope.exception())) {
     1063            JSValue exception = scope.exception();
     1064            scope.clearException();
    10601065            return deferred->reject(exec, exception);
    10611066        }
     
    11431148JSInternalPromise* GlobalObject::moduleLoaderFetch(JSGlobalObject* globalObject, ExecState* exec, JSModuleLoader*, JSValue key, JSValue)
    11441149{
     1150    VM& vm = globalObject->vm();
     1151    auto scope = DECLARE_CATCH_SCOPE(vm);
    11451152    JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject);
    11461153    String moduleKey = key.toWTFString(exec);
    1147     if (exec->hadException()) {
    1148         JSValue exception = exec->exception();
    1149         exec->clearException();
     1154    if (UNLIKELY(scope.exception())) {
     1155        JSValue exception = scope.exception();
     1156        scope.clearException();
    11501157        return deferred->reject(exec, exception);
    11511158    }
     
    12581265{
    12591266    VM& vm = exec->vm();
     1267    JSLockHolder lock(vm);
    12601268    auto scope = DECLARE_THROW_SCOPE(vm);
    12611269
    1262     JSLockHolder lock(exec);
    12631270    Root* root = jsDynamicCast<Root*>(exec->argument(0));
    12641271    if (!root)
     
    14481455
    14491456    String fileName = exec->argument(0).toWTFString(exec);
    1450     if (exec->hadException())
     1457    if (UNLIKELY(scope.exception()))
    14511458        return JSValue::encode(jsUndefined());
    14521459    Vector<char> script;
     
    14821489
    14831490    String source = exec->argument(0).toWTFString(exec);
    1484     if (exec->hadException())
     1491    if (UNLIKELY(scope.exception()))
    14851492        return JSValue::encode(jsUndefined());
    14861493
     
    15101517
    15111518    String fileName = exec->argument(0).toWTFString(exec);
    1512     if (exec->hadException())
     1519    if (UNLIKELY(scope.exception()))
    15131520        return JSValue::encode(jsUndefined());
    15141521    Vector<char> script;
     
    15311538
    15321539    String sourceCode = exec->argument(0).toWTFString(exec);
    1533     if (exec->hadException())
     1540    if (UNLIKELY(scope.exception()))
    15341541        return JSValue::encode(jsUndefined());
    15351542    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
     
    15481555
    15491556    String fileName = exec->argument(0).toWTFString(exec);
    1550     if (exec->hadException())
     1557    if (UNLIKELY(scope.exception()))
    15511558        return JSValue::encode(jsUndefined());
    15521559    Vector<char> script;
     
    15631570
    15641571    String fileName = exec->argument(0).toWTFString(exec);
    1565     if (exec->hadException())
     1572    if (UNLIKELY(scope.exception()))
    15661573        return JSValue::encode(jsUndefined());
    15671574    Vector<char> script;
     
    16231630EncodedJSValue JSC_HOST_CALL functionSetRandomSeed(ExecState* exec)
    16241631{
     1632    VM& vm = exec->vm();
     1633    auto scope = DECLARE_THROW_SCOPE(vm);
     1634
    16251635    unsigned seed = exec->argument(0).toUInt32(exec);
    1626     if (exec->hadException())
     1636    if (UNLIKELY(scope.exception()))
    16271637        return JSValue::encode(jsUndefined());
    16281638    exec->lexicalGlobalObject()->weakRandom().setSeed(seed);
     
    18771887
    18781888    String fileName = exec->argument(0).toWTFString(exec);
    1879     if (exec->hadException())
     1889    if (UNLIKELY(scope.exception()))
    18801890        return JSValue::encode(jsUndefined());
    18811891    Vector<char> script;
     
    18841894
    18851895    JSInternalPromise* promise = loadAndEvaluateModule(exec, fileName);
    1886     if (exec->hadException())
     1896    if (UNLIKELY(scope.exception()))
    18871897        return JSValue::encode(jsUndefined());
    18881898
     
    19021912EncodedJSValue JSC_HOST_CALL functionCreateBuiltin(ExecState* exec)
    19031913{
     1914    VM& vm = exec->vm();
     1915    auto scope = DECLARE_THROW_SCOPE(vm);
     1916
    19041917    if (exec->argumentCount() < 1 || !exec->argument(0).isString())
    19051918        return JSValue::encode(jsUndefined());
    19061919
    19071920    String functionText = exec->argument(0).toWTFString(exec);
    1908     if (exec->hadException())
     1921    if (UNLIKELY(scope.exception()))
    19091922        return JSValue::encode(JSValue());
    19101923
    1911     VM& vm = exec->vm();
    19121924    const SourceCode& source = makeSource(functionText);
    19131925    JSFunction* func = JSFunction::createBuiltinFunction(vm, createBuiltinExecutable(vm, source, Identifier::fromString(&vm, "foo"), ConstructorKind::None, ConstructAbility::CannotConstruct)->link(vm, source), exec->lexicalGlobalObject());
     
    19281940
    19291941    String source = exec->argument(0).toWTFString(exec);
    1930     if (exec->hadException())
     1942    if (UNLIKELY(scope.exception()))
    19311943        return JSValue::encode(jsUndefined());
    19321944
     
    19541966EncodedJSValue JSC_HOST_CALL functionGenerateHeapSnapshot(ExecState* exec)
    19551967{
    1956     JSLockHolder lock(exec);
     1968    VM& vm = exec->vm();
     1969    JSLockHolder lock(vm);
     1970    auto scope = DECLARE_THROW_SCOPE(vm);
    19571971
    19581972    HeapSnapshotBuilder snapshotBuilder(exec->vm().ensureHeapProfiler());
     
    19611975    String jsonString = snapshotBuilder.json();
    19621976    EncodedJSValue result = JSValue::encode(JSONParse(exec, jsonString));
    1963     RELEASE_ASSERT(!exec->hadException());
     1977    RELEASE_ASSERT(!scope.exception());
    19641978    return result;
    19651979}
     
    19992013    String jsonString = vm.samplingProfiler()->stackTracesAsJSON();
    20002014    EncodedJSValue result = JSValue::encode(JSONParse(exec, jsonString));
    2001     RELEASE_ASSERT(!exec->hadException());
     2015    RELEASE_ASSERT(!scope.exception());
    20022016    return result;
    20032017}
     
    21022116static void dumpException(GlobalObject* globalObject, JSValue exception)
    21032117{
     2118    VM& vm = globalObject->vm();
     2119    auto scope = DECLARE_CATCH_SCOPE(vm);
     2120
     2121#define CHECK_EXCEPTION() do { \
     2122        if (scope.exception()) { \
     2123            scope.clearException(); \
     2124            return; \
     2125        } \
     2126    } while (false)
     2127
    21042128    printf("Exception: %s\n", exception.toWTFString(globalObject->globalExec()).utf8().data());
    21052129
     
    21102134   
    21112135    JSValue nameValue = exception.get(globalObject->globalExec(), nameID);
     2136    CHECK_EXCEPTION();
    21122137    JSValue fileNameValue = exception.get(globalObject->globalExec(), fileNameID);
     2138    CHECK_EXCEPTION();
    21132139    JSValue lineNumberValue = exception.get(globalObject->globalExec(), lineNumberID);
     2140    CHECK_EXCEPTION();
    21142141    JSValue stackValue = exception.get(globalObject->globalExec(), stackID);
     2142    CHECK_EXCEPTION();
    21152143   
    21162144    if (nameValue.toWTFString(globalObject->globalExec()) == "SyntaxError"
     
    21242152    if (!stackValue.isUndefinedOrNull())
    21252153        printf("%s\n", stackValue.toWTFString(globalObject->globalExec()).utf8().data());
     2154
     2155#undef CHECK_EXCEPTION
    21262156}
    21272157
    21282158static bool checkUncaughtException(VM& vm, GlobalObject* globalObject, JSValue exception, const String& expectedExceptionName, bool alwaysDumpException)
    21292159{
    2130     vm.clearException();
     2160    auto scope = DECLARE_CATCH_SCOPE(vm);
     2161    scope.clearException();
    21312162    if (!exception) {
    21322163        printf("Expected uncaught exception with name '%s' but none was thrown\n", expectedExceptionName.utf8().data());
     
    21362167    ExecState* exec = globalObject->globalExec();
    21372168    JSValue exceptionClass = globalObject->get(exec, Identifier::fromString(exec, expectedExceptionName));
    2138     if (!exceptionClass.isObject() || vm.exception()) {
     2169    if (!exceptionClass.isObject() || scope.exception()) {
    21392170        printf("Expected uncaught exception with name '%s' but given exception class is not defined\n", expectedExceptionName.utf8().data());
    21402171        return false;
     
    21422173
    21432174    bool isInstanceOfExpectedException = jsCast<JSObject*>(exceptionClass)->hasInstance(exec, exception);
    2144     if (vm.exception()) {
     2175    if (scope.exception()) {
    21452176        printf("Expected uncaught exception with name '%s' but given exception class fails performing hasInstance\n", expectedExceptionName.utf8().data());
    21462177        return false;
     
    21662197
    21672198    VM& vm = globalObject->vm();
     2199    auto scope = DECLARE_CATCH_SCOPE(vm);
    21682200    bool success = true;
    21692201
     
    22082240            if (!promise)
    22092241                promise = loadAndEvaluateModule(globalObject->globalExec(), jscSource(scriptBuffer, fileName));
    2210             vm.clearException();
     2242            scope.clearException();
    22112243
    22122244            JSFunction* fulfillHandler = JSNativeStdFunction::create(vm, globalObject, 1, String(), [&, isLastFile](ExecState* exec) {
     
    22252257            NakedPtr<Exception> evaluationException;
    22262258            JSValue returnValue = evaluate(globalObject->globalExec(), jscSource(scriptBuffer, fileName), JSValue(), evaluationException);
     2259            ASSERT(!scope.exception());
    22272260            if (evaluationException)
    22282261                returnValue = evaluationException->value();
     
    22312264
    22322265        scriptBuffer.clear();
    2233         vm.clearException();
     2266        scope.clearException();
    22342267    }
    22352268
     
    22442277static void runInteractive(GlobalObject* globalObject)
    22452278{
     2279    VM& vm = globalObject->vm();
     2280    auto scope = DECLARE_CATCH_SCOPE(vm);
     2281
    22462282    String interpreterName(ASCIILiteral("Interpreter"));
    22472283   
     
    22942330            printf("%s\n", returnValue.toWTFString(globalObject->globalExec()).utf8().data());
    22952331
    2296         globalObject->globalExec()->clearException();
     2332        scope.clearException();
    22972333        globalObject->vm().drainMicrotasks();
    22982334    }
  • trunk/Source/JavaScriptCore/llint/LLIntExceptions.cpp

    r205462 r205569  
    4747#if LLINT_SLOW_PATH_TRACING
    4848    VM* vm = &exec->vm();
    49     dataLog("Throwing exception ", vm->exception(), " (returnToThrow).\n");
     49    auto scope = DECLARE_THROW_SCOPE(*vm);
     50    dataLog("Throwing exception ", scope.exception(), " (returnToThrow).\n");
    5051#endif
    5152    return LLInt::exceptionInstructions();
     
    5758#if LLINT_SLOW_PATH_TRACING
    5859    VM* vm = &exec->vm();
    59     dataLog("Throwing exception ", vm->exception(), " (callToThrow).\n");
     60    auto scope = DECLARE_THROW_SCOPE(*vm);
     61    dataLog("Throwing exception ", scope.exception(), " (callToThrow).\n");
    6062#endif
    6163    return LLInt::getCodePtr(llint_throw_during_call_trampoline);
  • trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp

    r205198 r205569  
    883883    // Don't put to an object if toString threw an exception.
    884884    auto property = subscript.toPropertyKey(exec);
    885     if (exec->vm().exception())
     885    if (throwScope.exception())
    886886        LLINT_END();
    887887
  • trunk/Source/JavaScriptCore/profiler/ProfilerBytecodeSequence.cpp

    r205462 r205569  
    8080{
    8181    VM& vm = exec->vm();
     82    auto scope = DECLARE_THROW_SCOPE(vm);
    8283    JSArray* header = constructEmptyArray(exec, 0);
    83     if (UNLIKELY(vm.exception()))
     84    if (UNLIKELY(scope.exception()))
    8485        return;
    8586    for (unsigned i = 0; i < m_header.size(); ++i)
     
    8889   
    8990    JSArray* sequence = constructEmptyArray(exec, 0);
    90     if (UNLIKELY(vm.exception()))
     91    if (UNLIKELY(scope.exception()))
    9192        return;
    9293    for (unsigned i = 0; i < m_sequence.size(); ++i)
  • trunk/Source/JavaScriptCore/profiler/ProfilerCompilation.cpp

    r201787 r205569  
    116116{
    117117    VM& vm = exec->vm();
     118    auto scope = DECLARE_THROW_SCOPE(vm);
    118119    JSObject* result = constructEmptyObject(exec);
    119     if (UNLIKELY(vm.exception()))
     120    if (UNLIKELY(scope.exception()))
    120121        return jsUndefined();
    121122    result->putDirect(vm, exec->propertyNames().bytecodesID, jsNumber(m_bytecodes->id()));
     
    123124   
    124125    JSArray* profiledBytecodes = constructEmptyArray(exec, 0);
    125     if (UNLIKELY(vm.exception()))
     126    if (UNLIKELY(scope.exception()))
    126127        return jsUndefined();
    127128    for (unsigned i = 0; i < m_profiledBytecodes.size(); ++i)
     
    130131   
    131132    JSArray* descriptions = constructEmptyArray(exec, 0);
    132     if (UNLIKELY(vm.exception()))
     133    if (UNLIKELY(scope.exception()))
    133134        return jsUndefined();
    134135    for (unsigned i = 0; i < m_descriptions.size(); ++i)
     
    137138   
    138139    JSArray* counters = constructEmptyArray(exec, 0);
    139     if (UNLIKELY(vm.exception()))
     140    if (UNLIKELY(scope.exception()))
    140141        return jsUndefined();
    141142    for (auto it = m_counters.begin(), end = m_counters.end(); it != end; ++it) {
     
    148149   
    149150    JSArray* exitSites = constructEmptyArray(exec, 0);
    150     if (UNLIKELY(vm.exception()))
     151    if (UNLIKELY(scope.exception()))
    151152        return jsUndefined();
    152153    for (unsigned i = 0; i < m_osrExitSites.size(); ++i)
     
    155156   
    156157    JSArray* exits = constructEmptyArray(exec, 0);
    157     if (UNLIKELY(vm.exception()))
     158    if (UNLIKELY(scope.exception()))
    158159        return jsUndefined();
    159160    for (unsigned i = 0; i < m_osrExits.size(); ++i)
  • trunk/Source/JavaScriptCore/profiler/ProfilerDatabase.cpp

    r201787 r205569  
    101101{
    102102    VM& vm = exec->vm();
     103    auto scope = DECLARE_THROW_SCOPE(vm);
    103104    JSObject* result = constructEmptyObject(exec);
    104105   
    105106    JSArray* bytecodes = constructEmptyArray(exec, 0);
    106     if (UNLIKELY(vm.exception()))
     107    if (UNLIKELY(scope.exception()))
    107108        return jsUndefined();
    108109    for (unsigned i = 0; i < m_bytecodes.size(); ++i)
     
    111112   
    112113    JSArray* compilations = constructEmptyArray(exec, 0);
    113     if (UNLIKELY(vm.exception()))
     114    if (UNLIKELY(scope.exception()))
    114115        return jsUndefined();
    115116    for (unsigned i = 0; i < m_compilations.size(); ++i)
     
    118119   
    119120    JSArray* events = constructEmptyArray(exec, 0);
    120     if (UNLIKELY(vm.exception()))
     121    if (UNLIKELY(scope.exception()))
    121122        return jsUndefined();
    122123    for (unsigned i = 0; i < m_events.size(); ++i)
  • trunk/Source/JavaScriptCore/profiler/ProfilerOSRExitSite.cpp

    r201787 r205569  
    3838{
    3939    VM& vm = exec->vm();
     40    auto scope = DECLARE_THROW_SCOPE(vm);
    4041    JSArray* result = constructEmptyArray(exec, 0);
    41     if (UNLIKELY(vm.exception()))
     42    if (UNLIKELY(scope.exception()))
    4243        return jsUndefined();
    4344    for (unsigned i = 0; i < m_codeAddresses.size(); ++i)
  • trunk/Source/JavaScriptCore/profiler/ProfilerOriginStack.cpp

    r201787 r205569  
    102102{
    103103    VM& vm = exec->vm();
     104    auto scope = DECLARE_THROW_SCOPE(vm);
    104105    JSArray* result = constructEmptyArray(exec, 0);
    105     if (UNLIKELY(vm.exception()))
     106    if (UNLIKELY(scope.exception()))
    106107        return jsUndefined();
    107108   
  • trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp

    r205462 r205569  
    197197static ALWAYS_INLINE std::pair<SpeciesConstructResult, JSObject*> speciesConstructArray(ExecState* exec, JSObject* thisObject, unsigned length)
    198198{
     199    VM& vm = exec->vm();
     200    auto scope = DECLARE_THROW_SCOPE(vm);
     201
    199202    // ECMA 9.4.2.3: https://tc39.github.io/ecma262/#sec-arrayspeciescreate
    200203    JSValue constructor = jsUndefined();
     
    206209
    207210        constructor = thisObject->get(exec, exec->propertyNames().constructor);
    208         if (exec->hadException())
     211        if (UNLIKELY(scope.exception()))
    209212            return std::make_pair(SpeciesConstructResult::Exception, nullptr);
    210213        if (constructor.isConstructor()) {
     
    215218        if (constructor.isObject()) {
    216219            constructor = constructor.get(exec, exec->propertyNames().speciesSymbol);
    217             if (exec->hadException())
     220            if (UNLIKELY(scope.exception()))
    218221                return std::make_pair(SpeciesConstructResult::Exception, nullptr);
    219222            if (constructor.isNull())
    220223                return std::make_pair(SpeciesConstructResult::FastPath, nullptr);;
    221224        }
    222     } else if (exec->hadException())
     225    } else if (UNLIKELY(scope.exception()))
    223226        return std::make_pair(SpeciesConstructResult::Exception, nullptr);
    224227
     
    229232    args.append(jsNumber(length));
    230233    JSObject* newObject = construct(exec, constructor, args, "Species construction did not get a valid constructor");
    231     if (exec->hadException())
     234    if (UNLIKELY(scope.exception()))
    232235        return std::make_pair(SpeciesConstructResult::Exception, nullptr);
    233236    return std::make_pair(SpeciesConstructResult::CreatedObject, newObject);
     
    285288        unsigned to = k + resultCount;
    286289        if (JSValue value = getProperty(exec, thisObj, from)) {
    287             if (exec->hadException())
     290            if (UNLIKELY(scope.exception()))
    288291                return;
    289292            thisObj->putByIndexInline(exec, to, value, true);
    290             if (exec->hadException())
     293            if (UNLIKELY(scope.exception()))
    291294                return;
    292295        } else if (!thisObj->methodTable(vm)->deletePropertyByIndex(thisObj, exec, to)) {
     
    331334        unsigned to = k + resultCount - 1;
    332335        if (JSValue value = getProperty(exec, thisObj, from)) {
    333             if (exec->hadException())
     336            if (UNLIKELY(scope.exception()))
    334337                return;
    335338            thisObj->putByIndexInline(exec, to, value, true);
     
    338341            return;
    339342        }
    340         if (exec->hadException())
     343        if (UNLIKELY(scope.exception()))
    341344            return;
    342345    }
     
    345348EncodedJSValue JSC_HOST_CALL arrayProtoFuncToString(ExecState* exec)
    346349{
     350    VM& vm = exec->vm();
     351    auto scope = DECLARE_THROW_SCOPE(vm);
    347352    JSValue thisValue = exec->thisValue().toThis(exec, StrictMode);
    348353
    349354    // 1. Let array be the result of calling ToObject on the this value.
    350355    JSObject* thisObject = thisValue.toObject(exec);
    351     VM& vm = exec->vm();
    352     if (UNLIKELY(vm.exception()))
     356    if (UNLIKELY(scope.exception()))
    353357        return JSValue::encode(jsUndefined());
    354358   
    355359    // 2. Let func be the result of calling the [[Get]] internal method of array with argument "join".
    356360    JSValue function = JSValue(thisObject).get(exec, exec->propertyNames().join);
    357     if (UNLIKELY(vm.exception()))
     361    if (UNLIKELY(scope.exception()))
    358362        return JSValue::encode(jsUndefined());
    359363
     
    384388
    385389    JSStringJoiner joiner(*exec, ',', length);
    386     if (UNLIKELY(vm.exception()))
     390    if (UNLIKELY(scope.exception()))
    387391        return JSValue::encode(jsUndefined());
    388392
     
    391395        if (!element) {
    392396            element = thisArray->get(exec, i);
    393             if (UNLIKELY(vm.exception()))
     397            if (UNLIKELY(scope.exception()))
    394398                return JSValue::encode(jsUndefined());
    395399        }
    396400        joiner.append(*exec, element);
    397         if (UNLIKELY(vm.exception()))
     401        if (UNLIKELY(scope.exception()))
    398402            return JSValue::encode(jsUndefined());
    399403    }
     
    404408EncodedJSValue JSC_HOST_CALL arrayProtoFuncToLocaleString(ExecState* exec)
    405409{
     410    VM& vm = exec->vm();
     411    auto scope = DECLARE_THROW_SCOPE(vm);
    406412    JSValue thisValue = exec->thisValue().toThis(exec, StrictMode);
    407413
    408414    JSObject* thisObject = thisValue.toObject(exec);
    409     if (exec->hadException())
     415    if (UNLIKELY(scope.exception()))
    410416        return JSValue::encode(jsUndefined());
    411417
    412418    unsigned length = getLength(exec, thisObject);
    413     if (exec->hadException())
     419    if (UNLIKELY(scope.exception()))
    414420        return JSValue::encode(jsUndefined());
    415421
     
    419425
    420426    JSStringJoiner stringJoiner(*exec, ',', length);
    421     if (exec->hadException())
     427    if (UNLIKELY(scope.exception()))
    422428        return JSValue::encode(jsUndefined());
    423429
     
    426432    for (unsigned i = 0; i < length; ++i) {
    427433        JSValue element = thisObject->getIndex(exec, i);
    428         if (exec->hadException())
     434        if (UNLIKELY(scope.exception()))
    429435            return JSValue::encode(jsUndefined());
    430436        if (element.isUndefinedOrNull())
     
    432438        else {
    433439            JSValue conversionFunction = element.get(exec, exec->propertyNames().toLocaleString);
    434             if (exec->hadException())
     440            if (UNLIKELY(scope.exception()))
    435441                return JSValue::encode(jsUndefined());
    436442            CallData callData;
     
    438444            if (callType != CallType::None) {
    439445                element = call(exec, conversionFunction, callType, callData, element, arguments);
    440                 if (exec->hadException())
     446                if (UNLIKELY(scope.exception()))
    441447                return JSValue::encode(jsUndefined());
    442448            }
    443449        }
    444450        stringJoiner.append(*exec, element);
    445         if (exec->hadException())
     451        if (UNLIKELY(scope.exception()))
    446452            return JSValue::encode(jsUndefined());
    447453    }
     
    449455    for (unsigned i = 0; i < length; ++i) {
    450456        JSValue element = thisObject->getIndex(exec, i);
    451         if (exec->hadException())
     457        if (UNLIKELY(scope.exception()))
    452458            return JSValue::encode(jsUndefined());
    453459        if (element.isUndefinedOrNull())
    454460            continue;
    455461        JSValue conversionFunction = element.get(exec, exec->propertyNames().toLocaleString);
    456         if (exec->hadException())
     462        if (UNLIKELY(scope.exception()))
    457463            return JSValue::encode(jsUndefined());
    458464        CallData callData;
     
    460466        if (callType != CallType::None) {
    461467            element = call(exec, conversionFunction, callType, callData, element, exec->emptyList());
    462             if (exec->hadException())
     468            if (UNLIKELY(scope.exception()))
    463469                return JSValue::encode(jsUndefined());
    464470        }
    465471        stringJoiner.append(*exec, element);
    466         if (exec->hadException())
     472        if (UNLIKELY(scope.exception()))
    467473            return JSValue::encode(jsUndefined());
    468474    }
     
    499505static JSValue slowJoin(ExecState& exec, JSObject* thisObject, JSString* separator, uint64_t length)
    500506{
     507    VM& vm = exec.vm();
     508    auto scope = DECLARE_THROW_SCOPE(vm);
     509
    501510    // 5. If len is zero, return the empty String.
    502511    if (!length)
    503512        return jsEmptyString(&exec);
    504513
    505     VM& vm = exec.vm();
    506 
    507514    // 6. Let element0 be Get(O, "0").
    508515    JSValue element0 = thisObject->getIndex(&exec, 0);
    509     if (vm.exception())
     516    if (UNLIKELY(scope.exception()))
    510517        return JSValue();
    511518
     
    516523    else
    517524        r = element0.toString(&exec);
    518     if (vm.exception())
     525    if (UNLIKELY(scope.exception()))
    519526        return JSValue();
    520527
     
    525532        // b. Let element be ? Get(O, ! ToString(k)).
    526533        JSValue element = thisObject->get(&exec, Identifier::fromString(&exec, AtomicString::number(k)));
    527         if (vm.exception())
     534        if (UNLIKELY(scope.exception()))
    528535            return JSValue();
    529536
     
    536543        } else
    537544            next = element.toString(&exec);
    538         if (vm.exception())
     545        if (UNLIKELY(scope.exception()))
    539546            return JSValue();
    540547
     
    562569static inline JSValue fastJoin(ExecState& state, JSObject* thisObject, StringView separator, unsigned length)
    563570{
     571    VM& vm = state.vm();
     572    auto scope = DECLARE_THROW_SCOPE(vm);
     573
    564574    switch (thisObject->indexingType()) {
    565575    case ALL_CONTIGUOUS_INDEXING_TYPES:
     
    569579            break;
    570580        JSStringJoiner joiner(state, separator, length);
    571         if (state.hadException())
     581        if (UNLIKELY(scope.exception()))
    572582            return jsUndefined();
    573583        auto data = butterfly.contiguous().data();
     
    593603            break;
    594604        JSStringJoiner joiner(state, separator, length);
    595         if (state.hadException())
     605        if (UNLIKELY(scope.exception()))
    596606            return jsUndefined();
    597607        auto data = butterfly.contiguousDouble().data();
     
    603613            else {
    604614                if (!holesKnownToBeOK) {
    605                     if (thisObject->structure(state.vm())->holesMustForwardToPrototype(state.vm()))
     615                    if (thisObject->structure(vm)->holesMustForwardToPrototype(vm))
    606616                        goto generalCase;
    607617                    holesKnownToBeOK = true;
     
    616626generalCase:
    617627    JSStringJoiner joiner(state, separator, length);
    618     if (state.hadException())
     628    if (UNLIKELY(scope.exception()))
    619629        return jsUndefined();
    620630    for (unsigned i = 0; i < length; ++i) {
    621631        JSValue element = thisObject->getIndex(&state, i);
    622         if (state.hadException())
     632        if (UNLIKELY(scope.exception()))
    623633            return jsUndefined();
    624634        joiner.append(state, element);
    625         if (state.hadException())
     635        if (UNLIKELY(scope.exception()))
    626636            return jsUndefined();
    627637    }
     
    631641EncodedJSValue JSC_HOST_CALL arrayProtoFuncJoin(ExecState* exec)
    632642{
     643    VM& vm = exec->vm();
     644    auto scope = DECLARE_THROW_SCOPE(vm);
     645
    633646    // 1. Let O be ? ToObject(this value).
    634647    JSObject* thisObject = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
     
    642655    // 2. Let len be ? ToLength(? Get(O, "length")).
    643656    double length = toLength(exec, thisObject);
    644     if (exec->hadException())
     657    if (UNLIKELY(scope.exception()))
    645658        return JSValue::encode(JSValue());
    646659
     
    654667            ASSERT(static_cast<double>(length64) == length);
    655668            JSString* jsSeparator = jsSingleCharacterString(exec, comma);
    656             if (exec->hadException())
     669            if (UNLIKELY(scope.exception()))
    657670                return JSValue::encode(JSValue());
    658671
     
    667680    // 4. Let sep be ? ToString(separator).
    668681    JSString* jsSeparator = separatorValue.toString(exec);
    669     if (exec->hadException())
     682    if (UNLIKELY(scope.exception()))
    670683        return JSValue::encode(jsUndefined());
    671684
     
    693706        return JSValue::encode(JSValue());
    694707    unsigned length = getLength(exec, thisObj);
    695     if (exec->hadException())
     708    if (UNLIKELY(scope.exception()))
    696709        return JSValue::encode(jsUndefined());
    697710
     
    702715    } else {
    703716        result = thisObj->get(exec, length - 1);
    704         if (exec->hadException())
     717        if (UNLIKELY(scope.exception()))
    705718            return JSValue::encode(jsUndefined());
    706719        if (!thisObj->methodTable(vm)->deletePropertyByIndex(thisObj, exec, length - 1)) {
     
    715728EncodedJSValue JSC_HOST_CALL arrayProtoFuncPush(ExecState* exec)
    716729{
     730    VM& vm = exec->vm();
     731    auto scope = DECLARE_THROW_SCOPE(vm);
    717732    JSValue thisValue = exec->thisValue().toThis(exec, StrictMode);
    718733
     
    727742        return JSValue::encode(JSValue());
    728743    unsigned length = getLength(exec, thisObj);
    729     if (exec->hadException())
     744    if (UNLIKELY(scope.exception()))
    730745        return JSValue::encode(jsUndefined());
    731746
     
    739754            thisObj->methodTable()->put(thisObj, exec, propertyName, exec->uncheckedArgument(n), slot);
    740755        }
    741         if (exec->hadException())
     756        if (UNLIKELY(scope.exception()))
    742757            return JSValue::encode(jsUndefined());
    743758    }
     
    758773
    759774    unsigned length = getLength(exec, thisObject);
    760     if (vm.exception())
     775    if (UNLIKELY(scope.exception()))
    761776        return JSValue::encode(jsUndefined());
    762777
     
    799814        unsigned upper = length - lower - 1;
    800815        bool lowerExists = thisObject->hasProperty(exec, lower);
    801         if (vm.exception())
     816        if (UNLIKELY(scope.exception()))
    802817            return JSValue::encode(jsUndefined());
    803818        JSValue lowerValue;
    804819        if (lowerExists) {
    805820            lowerValue = thisObject->get(exec, lower);
    806             if (UNLIKELY(vm.exception()))
     821            if (UNLIKELY(scope.exception()))
    807822                return JSValue::encode(jsUndefined());
    808823        }
    809824
    810825        bool upperExists = thisObject->hasProperty(exec, upper);
    811         if (UNLIKELY(vm.exception()))
     826        if (UNLIKELY(scope.exception()))
    812827            return JSValue::encode(jsUndefined());
    813828        JSValue upperValue;
    814829        if (upperExists) {
    815830            upperValue = thisObject->get(exec, upper);
    816             if (UNLIKELY(vm.exception()))
     831            if (UNLIKELY(scope.exception()))
    817832                return JSValue::encode(jsUndefined());
    818833        }
     
    820835        if (upperExists) {
    821836            thisObject->putByIndexInline(exec, lower, upperValue, true);
    822             if (vm.exception())
     837            if (UNLIKELY(scope.exception()))
    823838                return JSValue::encode(JSValue());
    824839        } else if (!thisObject->methodTable(vm)->deletePropertyByIndex(thisObject, exec, lower)) {
    825             if (!vm.exception())
     840            if (!scope.exception())
    826841                throwTypeError(exec, scope, ASCIILiteral("Unable to delete property."));
    827842            return JSValue::encode(JSValue());
     
    830845        if (lowerExists) {
    831846            thisObject->putByIndexInline(exec, upper, lowerValue, true);
    832             if (vm.exception())
     847            if (UNLIKELY(scope.exception()))
    833848                return JSValue::encode(JSValue());
    834849        } else if (!thisObject->methodTable(vm)->deletePropertyByIndex(thisObject, exec, upper)) {
    835             if (!vm.exception())
     850            if (!scope.exception())
    836851                throwTypeError(exec, scope, ASCIILiteral("Unable to delete property."));
    837852            return JSValue::encode(JSValue());
     
    843858EncodedJSValue JSC_HOST_CALL arrayProtoFuncShift(ExecState* exec)
    844859{
     860    VM& vm = exec->vm();
     861    auto scope = DECLARE_THROW_SCOPE(vm);
    845862    JSObject* thisObj = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
    846863    if (!thisObj)
    847864        return JSValue::encode(JSValue());
    848865    unsigned length = getLength(exec, thisObj);
    849     if (exec->hadException())
     866    if (UNLIKELY(scope.exception()))
    850867        return JSValue::encode(jsUndefined());
    851868
     
    857874        result = thisObj->getIndex(exec, 0);
    858875        shift<JSArray::ShiftCountForShift>(exec, thisObj, 0, 1, 0, length);
    859         if (exec->hadException())
     876        if (UNLIKELY(scope.exception()))
    860877            return JSValue::encode(jsUndefined());
    861878        putLength(exec, thisObj, jsNumber(length - 1));
     
    868885    // http://developer.netscape.com/docs/manuals/js/client/jsref/array.htm#1193713 or 15.4.4.10
    869886    VM& vm = exec->vm();
     887    auto scope = DECLARE_THROW_SCOPE(vm);
    870888    JSObject* thisObj = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
    871889    if (!thisObj)
    872890        return JSValue::encode(JSValue());
    873891    unsigned length = getLength(exec, thisObj);
    874     if (UNLIKELY(vm.exception()))
     892    if (UNLIKELY(scope.exception()))
    875893        return JSValue::encode(jsUndefined());
    876894
     
    893911    else {
    894912        result = constructEmptyArray(exec, nullptr, end - begin);
    895         if (UNLIKELY(vm.exception()))
     913        if (UNLIKELY(scope.exception()))
    896914            return JSValue::encode(jsUndefined());
    897915    }
     
    900918    for (unsigned k = begin; k < end; k++, n++) {
    901919        JSValue v = getProperty(exec, thisObj, k);
    902         if (UNLIKELY(vm.exception()))
     920        if (UNLIKELY(scope.exception()))
    903921            return JSValue::encode(jsUndefined());
    904922        if (v)
     
    920938        return JSValue::encode(JSValue());
    921939    unsigned length = getLength(exec, thisObj);
    922     if (UNLIKELY(vm.exception()))
     940    if (UNLIKELY(scope.exception()))
    923941        return JSValue::encode(jsUndefined());
    924942
     
    933951        else {
    934952            result = constructEmptyArray(exec, nullptr);
    935             if (UNLIKELY(vm.exception()))
     953            if (UNLIKELY(scope.exception()))
    936954                return JSValue::encode(jsUndefined());
    937955        }
     
    968986            for (unsigned k = 0; k < deleteCount; ++k) {
    969987                JSValue v = getProperty(exec, thisObj, k + begin);
    970                 if (UNLIKELY(vm.exception()))
     988                if (UNLIKELY(scope.exception()))
    971989                    return JSValue::encode(jsUndefined());
    972990                if (UNLIKELY(!v))
    973991                    continue;
    974992                result->putByIndexInline(exec, k, v, true);
    975                 if (UNLIKELY(vm.exception()))
     993                if (UNLIKELY(scope.exception()))
    976994                    return JSValue::encode(jsUndefined());
    977995            }
     
    9831001            for (unsigned k = 0; k < deleteCount; ++k) {
    9841002                JSValue v = getProperty(exec, thisObj, k + begin);
    985                 if (UNLIKELY(vm.exception()))
     1003                if (UNLIKELY(scope.exception()))
    9861004                    return JSValue::encode(jsUndefined());
    9871005                if (UNLIKELY(!v))
     
    9951013    if (additionalArgs < deleteCount) {
    9961014        shift<JSArray::ShiftCountForSplice>(exec, thisObj, begin, deleteCount, additionalArgs, length);
    997         if (UNLIKELY(vm.exception()))
     1015        if (UNLIKELY(scope.exception()))
    9981016            return JSValue::encode(jsUndefined());
    9991017    } else if (additionalArgs > deleteCount) {
    10001018        unshift<JSArray::ShiftCountForSplice>(exec, thisObj, begin, deleteCount, additionalArgs, length);
    1001         if (UNLIKELY(vm.exception()))
     1019        if (UNLIKELY(scope.exception()))
    10021020            return JSValue::encode(jsUndefined());
    10031021    }
    10041022    for (unsigned k = 0; k < additionalArgs; ++k) {
    10051023        thisObj->putByIndexInline(exec, k + begin, exec->uncheckedArgument(k + 2), true);
    1006         if (UNLIKELY(vm.exception()))
     1024        if (UNLIKELY(scope.exception()))
    10071025            return JSValue::encode(jsUndefined());
    10081026    }
     
    10141032EncodedJSValue JSC_HOST_CALL arrayProtoFuncUnShift(ExecState* exec)
    10151033{
     1034    VM& vm = exec->vm();
     1035    auto scope = DECLARE_THROW_SCOPE(vm);
    10161036    // 15.4.4.13
    10171037
     
    10201040        return JSValue::encode(JSValue());
    10211041    unsigned length = getLength(exec, thisObj);
    1022     if (exec->hadException())
     1042    if (UNLIKELY(scope.exception()))
    10231043        return JSValue::encode(jsUndefined());
    10241044
     
    10261046    if (nrArgs) {
    10271047        unshift<JSArray::ShiftCountForShift>(exec, thisObj, 0, 0, nrArgs, length);
    1028         if (exec->hadException())
     1048        if (UNLIKELY(scope.exception()))
    10291049            return JSValue::encode(jsUndefined());
    10301050    }
    10311051    for (unsigned k = 0; k < nrArgs; ++k) {
    10321052        thisObj->putByIndexInline(exec, k, exec->uncheckedArgument(k), true);
    1033         if (exec->hadException())
     1053        if (UNLIKELY(scope.exception()))
    10341054            return JSValue::encode(jsUndefined());
    10351055    }
     
    10411061EncodedJSValue JSC_HOST_CALL arrayProtoFuncIndexOf(ExecState* exec)
    10421062{
     1063    VM& vm = exec->vm();
     1064    auto scope = DECLARE_THROW_SCOPE(vm);
     1065
    10431066    // 15.4.4.14
    10441067    JSObject* thisObj = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
    10451068    if (!thisObj)
    10461069        return JSValue::encode(JSValue());
    1047     VM& vm = exec->vm();
    10481070    unsigned length = getLength(exec, thisObj);
    1049     if (UNLIKELY(vm.exception()))
     1071    if (UNLIKELY(scope.exception()))
    10501072        return JSValue::encode(jsUndefined());
    10511073
     
    10541076    for (; index < length; ++index) {
    10551077        JSValue e = getProperty(exec, thisObj, index);
    1056         if (UNLIKELY(vm.exception()))
     1078        if (UNLIKELY(scope.exception()))
    10571079            return JSValue::encode(jsUndefined());
    10581080        if (!e)
     
    10601082        if (JSValue::strictEqual(exec, searchElement, e))
    10611083            return JSValue::encode(jsNumber(index));
    1062         if (UNLIKELY(vm.exception()))
     1084        if (UNLIKELY(scope.exception()))
    10631085            return JSValue::encode(jsUndefined());
    10641086    }
     
    10691091EncodedJSValue JSC_HOST_CALL arrayProtoFuncLastIndexOf(ExecState* exec)
    10701092{
     1093    VM& vm = exec->vm();
     1094    auto scope = DECLARE_THROW_SCOPE(vm);
     1095
    10711096    // 15.4.4.15
    10721097    JSObject* thisObj = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
     
    10901115    }
    10911116
    1092     VM& vm = exec->vm();
    10931117    JSValue searchElement = exec->argument(0);
    10941118    do {
    10951119        RELEASE_ASSERT(index < length);
    10961120        JSValue e = getProperty(exec, thisObj, index);
    1097         if (UNLIKELY(vm.exception()))
     1121        if (UNLIKELY(scope.exception()))
    10981122            return JSValue::encode(jsUndefined());
    10991123        if (!e)
     
    11011125        if (JSValue::strictEqual(exec, searchElement, e))
    11021126            return JSValue::encode(jsNumber(index));
    1103         if (UNLIKELY(vm.exception()))
     1127        if (UNLIKELY(scope.exception()))
    11041128            return JSValue::encode(jsUndefined());
    11051129    } while (index--);
     
    11101134static bool moveElements(ExecState* exec, VM& vm, JSArray* target, unsigned targetOffset, JSArray* source, unsigned sourceLength)
    11111135{
     1136    auto scope = DECLARE_THROW_SCOPE(vm);
     1137
    11121138    if (LIKELY(!hasAnyArrayStorage(source->indexingType()) && !source->structure()->holesMustForwardToPrototype(vm))) {
    11131139        for (unsigned i = 0; i < sourceLength; ++i) {
     
    11151141            if (value) {
    11161142                target->putDirectIndex(exec, targetOffset + i, value);
    1117                 if (vm.exception())
     1143                if (UNLIKELY(scope.exception()))
    11181144                    return false;
    11191145            }
     
    11221148        for (unsigned i = 0; i < sourceLength; ++i) {
    11231149            JSValue value = getProperty(exec, source, i);
    1124             if (vm.exception())
     1150            if (UNLIKELY(scope.exception()))
    11251151                return false;
    11261152            if (value) {
    11271153                target->putDirectIndex(exec, targetOffset + i, value);
    1128                 if (vm.exception())
     1154                if (UNLIKELY(scope.exception()))
    11291155                    return false;
    11301156            }
     
    11551181    if (!result->appendMemcpy(exec, vm, 0, first)) {
    11561182        if (!moveElements(exec, vm, result, 0, first, firstArraySize)) {
    1157             ASSERT(vm.exception());
     1183            ASSERT(scope.exception());
    11581184            return JSValue::encode(JSValue());
    11591185        }
     
    12001226    if (type == NonArray || !firstArray->canFastCopy(vm, secondArray) || firstArraySize + secondArraySize >= MIN_SPARSE_ARRAY_INDEX) {
    12011227        JSArray* result = constructEmptyArray(exec, nullptr, firstArraySize + secondArraySize);
    1202         if (vm.exception())
     1228        if (UNLIKELY(scope.exception()))
    12031229            return JSValue::encode(JSValue());
    12041230
    12051231        if (!moveElements(exec, vm, result, 0, firstArray, firstArraySize)
    12061232            || !moveElements(exec, vm, result, firstArraySize, secondArray, secondArraySize)) {
    1207             ASSERT(vm.exception());
     1233            ASSERT(scope.exception());
    12081234            return JSValue::encode(JSValue());
    12091235        }
  • trunk/Source/JavaScriptCore/runtime/BooleanConstructor.cpp

    r197614 r205569  
    4949static EncodedJSValue JSC_HOST_CALL constructWithBooleanConstructor(ExecState* exec)
    5050{
     51    VM& vm = exec->vm();
     52    auto scope = DECLARE_THROW_SCOPE(vm);
    5153    JSValue boolean = jsBoolean(exec->argument(0).toBoolean(exec));
    5254    Structure* booleanStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), asInternalFunction(exec->callee())->globalObject()->booleanObjectStructure());
    53     if (exec->hadException())
     55    if (UNLIKELY(scope.exception()))
    5456        return JSValue::encode(JSValue());
    55     BooleanObject* obj = BooleanObject::create(exec->vm(), booleanStructure);
    56     obj->setInternalValue(exec->vm(), boolean);
     57    BooleanObject* obj = BooleanObject::create(vm, booleanStructure);
     58    obj->setInternalValue(vm, boolean);
    5759    return JSValue::encode(obj);
    5860}
  • trunk/Source/JavaScriptCore/runtime/CallData.cpp

    r197614 r205569  
    11/*
    2  * Copyright (C) 2008 Apple Inc. All Rights Reserved.
     2 * Copyright (C) 2008, 2016 Apple Inc. All Rights Reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4343JSValue call(ExecState* exec, JSValue functionObject, CallType callType, const CallData& callData, JSValue thisValue, const ArgList& args, NakedPtr<Exception>& returnedException)
    4444{
     45    VM& vm = exec->vm();
     46    auto scope = DECLARE_CATCH_SCOPE(vm);
    4547    JSValue result = call(exec, functionObject, callType, callData, thisValue, args);
    46     if (exec->hadException()) {
    47         returnedException = exec->exception();
    48         exec->clearException();
     48    if (UNLIKELY(scope.exception())) {
     49        returnedException = scope.exception();
     50        scope.clearException();
    4951        return jsUndefined();
    5052    }
  • trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp

    r205321 r205569  
    6363#define BEGIN_NO_SET_PC() \
    6464    VM& vm = exec->vm();      \
    65     NativeCallFrameTracer tracer(&vm, exec)
     65    NativeCallFrameTracer tracer(&vm, exec); \
     66    auto throwScope = DECLARE_THROW_SCOPE(vm); \
     67    UNUSED_PARAM(throwScope)
    6668
    6769#ifndef NDEBUG
     
    100102#define CHECK_EXCEPTION() do {                    \
    101103        doExceptionFuzzingIfEnabled(exec, "CommonSlowPaths", pc);   \
    102         if (UNLIKELY(vm.exception())) {           \
    103             RETURN_TO_THROW(exec, pc);               \
     104        if (UNLIKELY(throwScope.exception())) {   \
     105            RETURN_TO_THROW(exec, pc);            \
    104106            END_IMPL();                           \
    105         }                                               \
     107        }                                         \
    106108    } while (false)
    107109
     
    145147        ExecState* cceExec = (exec);                                 \
    146148        Instruction* ccePC = (pc);                                   \
    147         if (UNLIKELY(vm.exception()))                                \
     149        if (UNLIKELY(throwScope.exception()))                        \
    148150            CALL_END_IMPL(cceExec, LLInt::callToThrow(cceExec));     \
    149151    } while (false)
     
    428430    JSValue right = OP_C(3).jsValue();
    429431    double a = left.toNumber(exec);
    430     if (UNLIKELY(vm.exception()))
     432    if (UNLIKELY(throwScope.exception()))
    431433        RETURN(JSValue());
    432434    double b = right.toNumber(exec);
     
    443445    JSValue right = OP_C(3).jsValue();
    444446    double a = left.toNumber(exec);
    445     if (UNLIKELY(vm.exception()))
     447    if (UNLIKELY(throwScope.exception()))
    446448        RETURN(JSValue());
    447449    double b = right.toNumber(exec);
     
    458460    JSValue right = OP_C(3).jsValue();
    459461    double a = left.toNumber(exec);
    460     if (UNLIKELY(vm.exception()))
     462    if (UNLIKELY(throwScope.exception()))
    461463        RETURN(JSValue());
    462464    double b = right.toNumber(exec);
    463     if (UNLIKELY(vm.exception()))
     465    if (UNLIKELY(throwScope.exception()))
    464466        RETURN(JSValue());
    465467    JSValue result = jsNumber(a / b);
     
    473475    BEGIN();
    474476    double a = OP_C(2).jsValue().toNumber(exec);
    475     if (UNLIKELY(vm.exception()))
     477    if (UNLIKELY(throwScope.exception()))
    476478        RETURN(JSValue());
    477479    double b = OP_C(3).jsValue().toNumber(exec);
     
    483485    BEGIN();
    484486    double a = OP_C(2).jsValue().toNumber(exec);
    485     if (UNLIKELY(vm.exception()))
     487    if (UNLIKELY(throwScope.exception()))
    486488        RETURN(JSValue());
    487489    double b = OP_C(3).jsValue().toNumber(exec);
    488     if (UNLIKELY(vm.exception()))
     490    if (UNLIKELY(throwScope.exception()))
    489491        RETURN(JSValue());
    490492    RETURN(jsNumber(operationMathPow(a, b)));
     
    495497    BEGIN();
    496498    int32_t a = OP_C(2).jsValue().toInt32(exec);
    497     if (UNLIKELY(vm.exception()))
     499    if (UNLIKELY(throwScope.exception()))
    498500        RETURN(JSValue());
    499501    uint32_t b = OP_C(3).jsValue().toUInt32(exec);
     
    505507    BEGIN();
    506508    int32_t a = OP_C(2).jsValue().toInt32(exec);
    507     if (UNLIKELY(vm.exception()))
     509    if (UNLIKELY(throwScope.exception()))
    508510        RETURN(JSValue());
    509511    uint32_t b = OP_C(3).jsValue().toUInt32(exec);
     
    515517    BEGIN();
    516518    uint32_t a = OP_C(2).jsValue().toUInt32(exec);
    517     if (UNLIKELY(vm.exception()))
     519    if (UNLIKELY(throwScope.exception()))
    518520        RETURN(JSValue());
    519521    uint32_t b = OP_C(3).jsValue().toUInt32(exec);
     
    532534    BEGIN();
    533535    int32_t a = OP_C(2).jsValue().toInt32(exec);
    534     if (UNLIKELY(vm.exception()))
     536    if (UNLIKELY(throwScope.exception()))
    535537        RETURN(JSValue());
    536538    int32_t b = OP_C(3).jsValue().toInt32(exec);
     
    542544    BEGIN();
    543545    int32_t a = OP_C(2).jsValue().toInt32(exec);
    544     if (UNLIKELY(vm.exception()))
     546    if (UNLIKELY(throwScope.exception()))
    545547        RETURN(JSValue());
    546548    int32_t b = OP_C(3).jsValue().toInt32(exec);
     
    552554    BEGIN();
    553555    int32_t a = OP_C(2).jsValue().toInt32(exec);
    554     if (UNLIKELY(vm.exception()))
     556    if (UNLIKELY(throwScope.exception()))
    555557        RETURN(JSValue());
    556558    int32_t b = OP_C(3).jsValue().toInt32(exec);
  • trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.h

    r205198 r205569  
    8888
    8989    auto property = propName.toPropertyKey(exec);
    90     if (vm.exception())
     90    if (scope.exception())
    9191        return false;
    9292    return baseObj->hasProperty(exec, property);
  • trunk/Source/JavaScriptCore/runtime/CommonSlowPathsExceptions.cpp

    r205462 r205569  
    4444    throwException(exec, scope, error);
    4545#if LLINT_SLOW_PATH_TRACING
    46     dataLog("Throwing exception ", vm->exception(), ".\n");
     46    dataLog("Throwing exception ", scope.exception(), ".\n");
    4747#endif
    4848}
  • trunk/Source/JavaScriptCore/runtime/Completion.cpp

    r205335 r205569  
    8888JSValue evaluate(ExecState* exec, const SourceCode& source, JSValue thisValue, NakedPtr<Exception>& returnedException)
    8989{
    90     JSLockHolder lock(exec);
    91     RELEASE_ASSERT(exec->vm().atomicStringTable() == wtfThreadData().atomicStringTable());
    92     RELEASE_ASSERT(!exec->vm().isCollectorBusy());
     90    VM& vm = exec->vm();
     91    JSLockHolder lock(vm);
     92    auto scope = DECLARE_CATCH_SCOPE(vm);
     93    RELEASE_ASSERT(vm.atomicStringTable() == wtfThreadData().atomicStringTable());
     94    RELEASE_ASSERT(!vm.isCollectorBusy());
    9395
    9496    CodeProfiling profile(source);
    9597
    9698    ProgramExecutable* program = ProgramExecutable::create(exec, source);
     99    ASSERT(scope.exception() || program);
    97100    if (!program) {
    98         returnedException = exec->vm().exception();
    99         exec->vm().clearException();
     101        returnedException = scope.exception();
     102        scope.clearException();
    100103        return jsUndefined();
    101104    }
     
    106109    JSValue result = exec->interpreter()->execute(program, exec, thisObj);
    107110
    108     if (exec->hadException()) {
    109         returnedException = exec->exception();
    110         exec->clearException();
     111    if (scope.exception()) {
     112        returnedException = scope.exception();
     113        scope.clearException();
    111114        return jsUndefined();
    112115    }
     
    148151static JSInternalPromise* rejectPromise(ExecState* exec, JSGlobalObject* globalObject)
    149152{
    150     ASSERT(exec->hadException());
    151     JSValue exception = exec->exception()->value();
    152     exec->clearException();
     153    VM& vm = exec->vm();
     154    auto scope = DECLARE_CATCH_SCOPE(vm);
     155    ASSERT(scope.exception());
     156    JSValue exception = scope.exception()->value();
     157    scope.clearException();
    153158    JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject);
    154159    deferred->reject(exec, exception);
     
    177182JSInternalPromise* loadAndEvaluateModule(ExecState* exec, const SourceCode& source, JSValue initiator)
    178183{
    179     JSLockHolder lock(exec);
    180     RELEASE_ASSERT(exec->vm().atomicStringTable() == wtfThreadData().atomicStringTable());
    181     RELEASE_ASSERT(!exec->vm().isCollectorBusy());
    182 
    183     Symbol* key = createSymbolForEntryPointModule(exec->vm());
     184    VM& vm = exec->vm();
     185    JSLockHolder lock(vm);
     186    auto scope = DECLARE_THROW_SCOPE(vm);
     187    RELEASE_ASSERT(vm.atomicStringTable() == wtfThreadData().atomicStringTable());
     188    RELEASE_ASSERT(!vm.isCollectorBusy());
     189
     190    Symbol* key = createSymbolForEntryPointModule(vm);
    184191
    185192    JSGlobalObject* globalObject = exec->vmEntryGlobalObject();
     
    187194    // Insert the given source code to the ModuleLoader registry as the fetched registry entry.
    188195    globalObject->moduleLoader()->provide(exec, key, JSModuleLoader::Status::Fetch, source.view().toString());
    189     if (exec->hadException())
     196    if (UNLIKELY(scope.exception()))
    190197        return rejectPromise(exec, globalObject);
    191198
     
    214221JSInternalPromise* loadModule(ExecState* exec, const SourceCode& source, JSValue initiator)
    215222{
    216     JSLockHolder lock(exec);
    217     RELEASE_ASSERT(exec->vm().atomicStringTable() == wtfThreadData().atomicStringTable());
    218     RELEASE_ASSERT(!exec->vm().isCollectorBusy());
    219 
    220     Symbol* key = createSymbolForEntryPointModule(exec->vm());
     223    VM& vm = exec->vm();
     224    JSLockHolder lock(vm);
     225    auto scope = DECLARE_THROW_SCOPE(vm);
     226    RELEASE_ASSERT(vm.atomicStringTable() == wtfThreadData().atomicStringTable());
     227    RELEASE_ASSERT(!vm.isCollectorBusy());
     228
     229    Symbol* key = createSymbolForEntryPointModule(vm);
    221230
    222231    JSGlobalObject* globalObject = exec->vmEntryGlobalObject();
     
    225234    // FIXME: Introduce JSSourceCode object to wrap around this source.
    226235    globalObject->moduleLoader()->provide(exec, key, JSModuleLoader::Status::Fetch, source.view().toString());
    227     if (exec->hadException())
     236    if (UNLIKELY(scope.exception()))
    228237        return rejectPromise(exec, globalObject);
    229238
  • trunk/Source/JavaScriptCore/runtime/ConsoleObject.cpp

    r200404 r205569  
    197197static EncodedJSValue JSC_HOST_CALL consoleProtoFuncAssert(ExecState* exec)
    198198{
     199    VM& vm = exec->vm();
     200    auto scope = DECLARE_THROW_SCOPE(vm);
    199201    ConsoleClient* client = exec->lexicalGlobalObject()->consoleClient();
    200202    if (!client)
     
    202204
    203205    bool condition = exec->argument(0).toBoolean(exec);
    204     if (exec->hadException())
     206    if (UNLIKELY(scope.exception()))
    205207        return JSValue::encode(jsUndefined());
    206208
     
    226228static EncodedJSValue JSC_HOST_CALL consoleProtoFuncProfile(ExecState* exec)
    227229{
     230    VM& vm = exec->vm();
     231    auto scope = DECLARE_THROW_SCOPE(vm);
    228232    ConsoleClient* client = exec->lexicalGlobalObject()->consoleClient();
    229233    if (!client)
     
    237241
    238242    const String& title(valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0)));
    239     if (exec->hadException())
     243    if (UNLIKELY(scope.exception()))
    240244        return JSValue::encode(jsUndefined());
    241245
     
    246250static EncodedJSValue JSC_HOST_CALL consoleProtoFuncProfileEnd(ExecState* exec)
    247251{
     252    VM& vm = exec->vm();
     253    auto scope = DECLARE_THROW_SCOPE(vm);
    248254    ConsoleClient* client = exec->lexicalGlobalObject()->consoleClient();
    249255    if (!client)
     
    257263
    258264    const String& title(valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0)));
    259     if (exec->hadException())
     265    if (UNLIKELY(scope.exception()))
    260266        return JSValue::encode(jsUndefined());
    261267
     
    266272static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTakeHeapSnapshot(ExecState* exec)
    267273{
     274    VM& vm = exec->vm();
     275    auto scope = DECLARE_THROW_SCOPE(vm);
    268276    ConsoleClient* client = exec->lexicalGlobalObject()->consoleClient();
    269277    if (!client)
     
    277285
    278286    const String& title(valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0)));
    279     if (exec->hadException())
     287    if (UNLIKELY(scope.exception()))
    280288        return JSValue::encode(jsUndefined());
    281289
     
    293301static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTime(ExecState* exec)
    294302{
     303    VM& vm = exec->vm();
     304    auto scope = DECLARE_THROW_SCOPE(vm);
    295305    ConsoleClient* client = exec->lexicalGlobalObject()->consoleClient();
    296306    if (!client)
     
    302312    else {
    303313        title = valueOrDefaultLabelString(exec, exec->argument(0));
    304         if (exec->hadException())
     314        if (UNLIKELY(scope.exception()))
    305315            return JSValue::encode(jsUndefined());
    306316    }
     
    312322static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTimeEnd(ExecState* exec)
    313323{
     324    VM& vm = exec->vm();
     325    auto scope = DECLARE_THROW_SCOPE(vm);
    314326    ConsoleClient* client = exec->lexicalGlobalObject()->consoleClient();
    315327    if (!client)
     
    321333    else {
    322334        title = valueOrDefaultLabelString(exec, exec->argument(0));
    323         if (exec->hadException())
     335        if (UNLIKELY(scope.exception()))
    324336            return JSValue::encode(jsUndefined());
    325337    }
  • trunk/Source/JavaScriptCore/runtime/DateConstructor.cpp

    r201448 r205569  
    148148{
    149149    VM& vm = exec->vm();
     150    auto scope = DECLARE_THROW_SCOPE(vm);
    150151    int numArgs = args.size();
    151152
     
    168169
    169170    Structure* dateStructure = InternalFunction::createSubclassStructure(exec, newTarget, globalObject->dateStructure());
    170     if (exec->hadException())
     171    if (UNLIKELY(scope.exception()))
    171172        return nullptr;
    172173
     
    203204EncodedJSValue JSC_HOST_CALL dateParse(ExecState* exec)
    204205{
     206    VM& vm = exec->vm();
     207    auto scope = DECLARE_THROW_SCOPE(vm);
    205208    String dateStr = exec->argument(0).toString(exec)->value(exec);
    206     if (exec->hadException())
     209    if (UNLIKELY(scope.exception()))
    207210        return JSValue::encode(jsUndefined());
    208     return JSValue::encode(jsNumber(parseDate(exec->vm(), dateStr)));
     211    return JSValue::encode(jsNumber(parseDate(vm, dateStr)));
    209212}
    210213
  • trunk/Source/JavaScriptCore/runtime/DatePrototype.cpp

    r205198 r205569  
    604604EncodedJSValue JSC_HOST_CALL dateProtoFuncToPrimitiveSymbol(ExecState* exec)
    605605{
    606     auto scope = DECLARE_THROW_SCOPE(exec->vm());
     606    VM& vm = exec->vm();
     607    auto scope = DECLARE_THROW_SCOPE(vm);
    607608    JSValue thisValue = exec->thisValue();
    608609    if (!thisValue.isObject())
     
    615616    JSValue hintValue = exec->uncheckedArgument(0);
    616617    PreferredPrimitiveType type = toPreferredPrimitiveType(exec, hintValue);
    617     if (exec->hadException())
     618    if (UNLIKELY(scope.exception()))
    618619        return JSValue::encode(JSValue());
    619620
     
    11241125EncodedJSValue JSC_HOST_CALL dateProtoFuncToJSON(ExecState* exec)
    11251126{
    1126     auto scope = DECLARE_THROW_SCOPE(exec->vm());
     1127    VM& vm = exec->vm();
     1128    auto scope = DECLARE_THROW_SCOPE(vm);
    11271129    JSValue thisValue = exec->thisValue();
    11281130    JSObject* object = jsCast<JSObject*>(thisValue.toThis(exec, NotStrictMode));
    1129     if (exec->hadException())
     1131    if (UNLIKELY(scope.exception()))
    11301132        return JSValue::encode(jsNull());
    11311133
    11321134    JSValue timeValue = object->toPrimitive(exec, PreferNumber);
    1133     if (exec->hadException())
     1135    if (UNLIKELY(scope.exception()))
    11341136        return JSValue::encode(jsNull());
    11351137    if (timeValue.isNumber() && !(timeValue.isInt32() || std::isfinite(timeValue.asDouble())))
    11361138        return JSValue::encode(jsNull());
    11371139
    1138     JSValue toISOValue = object->get(exec, exec->vm().propertyNames->toISOString);
    1139     if (exec->hadException())
     1140    JSValue toISOValue = object->get(exec, vm.propertyNames->toISOString);
     1141    if (UNLIKELY(scope.exception()))
    11401142        return JSValue::encode(jsNull());
    11411143
     
    11461148
    11471149    JSValue result = call(exec, asObject(toISOValue), callType, callData, object, exec->emptyList());
    1148     if (exec->hadException())
     1150    if (UNLIKELY(scope.exception()))
    11491151        return JSValue::encode(jsNull());
    11501152    if (result.isObject())
  • trunk/Source/JavaScriptCore/runtime/ErrorConstructor.cpp

    r198469 r205569  
    5151EncodedJSValue JSC_HOST_CALL Interpreter::constructWithErrorConstructor(ExecState* exec)
    5252{
     53    VM& vm = exec->vm();
     54    auto scope = DECLARE_THROW_SCOPE(vm);
    5355    JSValue message = exec->argumentCount() ? exec->argument(0) : jsUndefined();
    5456    Structure* errorStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), asInternalFunction(exec->callee())->globalObject()->errorStructure());
    55     if (exec->hadException())
     57    if (UNLIKELY(scope.exception()))
    5658        return JSValue::encode(JSValue());
    5759    return JSValue::encode(ErrorInstance::create(exec, errorStructure, message, nullptr, TypeNothing, false));
  • trunk/Source/JavaScriptCore/runtime/ErrorInstance.cpp

    r205462 r205569  
    159159{
    160160    VM& vm = exec->vm();
     161    auto scope = DECLARE_THROW_SCOPE(vm);
    161162
    162163    JSValue nameValue;
     
    178179        currentObj = obj->getPrototypeDirect();
    179180    }
    180     ASSERT(!vm.exception());
     181    ASSERT(!scope.exception());
    181182
    182183    String nameString;
     
    185186    else {
    186187        nameString = nameValue.toString(exec)->value(exec);
    187         if (vm.exception())
     188        if (UNLIKELY(scope.exception()))
    188189            return String();
    189190    }
     
    194195    if (JSObject::getOwnPropertySlot(this, exec, messagePropertName, messageSlot) && messageSlot.isValue())
    195196        messageValue = messageSlot.getValue(exec, messagePropertName);
    196     ASSERT(!vm.exception());
     197    ASSERT(!scope.exception());
    197198
    198199    String messageString;
     
    201202    else {
    202203        messageString = messageValue.toString(exec)->value(exec);
    203         if (vm.exception())
     204        if (UNLIKELY(scope.exception()))
    204205            return String();
    205206    }
  • trunk/Source/JavaScriptCore/runtime/ErrorPrototype.cpp

    r205198 r205569  
    8686    // 3. Let name be the result of calling the [[Get]] internal method of O with argument "name".
    8787    JSValue name = thisObj->get(exec, exec->propertyNames().name);
    88     if (exec->hadException())
     88    if (UNLIKELY(scope.exception()))
    8989        return JSValue::encode(jsUndefined());
    9090
     
    9595    else {
    9696        nameString = name.toString(exec)->value(exec);
    97         if (exec->hadException())
     97        if (UNLIKELY(scope.exception()))
    9898            return JSValue::encode(jsUndefined());
    9999    }
     
    101101    // 5. Let msg be the result of calling the [[Get]] internal method of O with argument "message".
    102102    JSValue message = thisObj->get(exec, exec->propertyNames().message);
    103     if (exec->hadException())
     103    if (UNLIKELY(scope.exception()))
    104104        return JSValue::encode(jsUndefined());
    105105
     
    112112    else {
    113113        messageString = message.toString(exec)->value(exec);
    114         if (exec->hadException())
     114        if (UNLIKELY(scope.exception()))
    115115            return JSValue::encode(jsUndefined());
    116116    }
  • trunk/Source/JavaScriptCore/runtime/ExceptionEventLocation.h

    r205568 r205569  
    2828namespace JSC {
    2929
    30 struct ThrowScopeLocation {
    31     ThrowScopeLocation() { }
    32     ThrowScopeLocation(const char* functionName, const char* file, unsigned line)
     30struct ExceptionEventLocation {
     31    ExceptionEventLocation() { }
     32    ExceptionEventLocation(const char* functionName, const char* file, unsigned line)
    3333        : functionName(functionName)
    3434        , file(file)
     
    4242
    4343} // namespace JSC
     44
     45namespace WTF {
     46   
     47class PrintStream;
     48
     49void printInternal(PrintStream&, JSC::ExceptionEventLocation);
     50   
     51} // namespace WTF
  • trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.h

    r205198 r205569  
    3030#define ExceptionHelpers_h
    3131
     32#include "CatchScope.h"
    3233#include "ErrorInstance.h"
    3334#include "JSObject.h"
  • trunk/Source/JavaScriptCore/runtime/FunctionConstructor.cpp

    r205198 r205569  
    127127
    128128    Structure* subclassStructure = InternalFunction::createSubclassStructure(exec, newTarget, globalObject->functionStructure());
    129     if (exec->hadException())
     129    if (UNLIKELY(scope.exception()))
    130130        return nullptr;
    131131
  • trunk/Source/JavaScriptCore/runtime/FunctionPrototype.cpp

    r205198 r205569  
    161161    unsigned length = 0;
    162162    if (targetObject->hasOwnProperty(exec, exec->propertyNames().length)) {
    163         if (exec->hadException())
     163        if (UNLIKELY(scope.exception()))
    164164            return JSValue::encode(jsUndefined());
    165165
  • trunk/Source/JavaScriptCore/runtime/GenericArgumentsInlines.h

    r198270 r205569  
    220220void GenericArguments<Type>::copyToArguments(ExecState* exec, VirtualRegister firstElementDest, unsigned offset, unsigned length)
    221221{
     222    VM& vm = exec->vm();
     223    auto scope = DECLARE_THROW_SCOPE(vm);
     224
    222225    Type* thisObject = static_cast<Type*>(this);
    223226    for (unsigned i = 0; i < length; ++i) {
     
    226229        else {
    227230            exec->r(firstElementDest + i) = get(exec, i + offset);
    228             if (UNLIKELY(exec->vm().exception()))
     231            if (UNLIKELY(scope.exception()))
    229232                return;
    230233        }
  • trunk/Source/JavaScriptCore/runtime/GetterSetter.cpp

    r205198 r205569  
    7474JSValue callGetter(ExecState* exec, JSValue base, JSValue getterSetter)
    7575{
     76    VM& vm = exec->vm();
     77    auto scope = DECLARE_THROW_SCOPE(vm);
    7678    // FIXME: Some callers may invoke get() without checking for an exception first.
    7779    // We work around that by checking here.
    78     if (exec->hadException())
    79         return exec->exception()->value();
     80    if (UNLIKELY(scope.exception()))
     81        return scope.exception()->value();
    8082
    8183    JSObject* getter = jsCast<GetterSetter*>(getterSetter)->getter();
    8284
    8385    CallData callData;
    84     CallType callType = getter->methodTable(exec->vm())->getCallData(getter, callData);
     86    CallType callType = getter->methodTable(vm)->getCallData(getter, callData);
    8587    return call(exec, getter, callType, callData, base, ArgList());
    8688}
  • trunk/Source/JavaScriptCore/runtime/InspectorInstrumentationObject.cpp

    r201448 r205569  
    8484EncodedJSValue JSC_HOST_CALL inspectorInstrumentationObjectLog(ExecState* exec)
    8585{
     86    VM& vm = exec->vm();
     87    auto scope = DECLARE_THROW_SCOPE(vm);
    8688    JSValue target = exec->argument(0);
    8789    String value = target.toString(exec)->value(exec);
    88     if (exec->hadException())
     90    if (UNLIKELY(scope.exception()))
    8991        return JSValue::encode(jsUndefined());
    9092    dataLog(value, "\n");
  • trunk/Source/JavaScriptCore/runtime/InternalFunction.cpp

    r205462 r205569  
    9898
    9999    VM& vm = exec->vm();
     100    auto scope = DECLARE_THROW_SCOPE(vm);
    100101    // We allow newTarget == JSValue() because the API needs to be able to create classes without having a real JS frame.
    101102    // Since we don't allow subclassing in the API we just treat newTarget == JSValue() as newTarget == exec->callee()
     
    113114            // Note, Reflect.construct might cause the profile to churn but we don't care.
    114115            JSValue prototypeValue = newTarget.get(exec, exec->propertyNames().prototype);
    115             if (UNLIKELY(vm.exception()))
     116            if (UNLIKELY(scope.exception()))
    116117                return nullptr;
    117118            if (JSObject* prototype = jsDynamicCast<JSObject*>(prototypeValue))
     
    119120        } else {
    120121            JSValue prototypeValue = newTarget.get(exec, exec->propertyNames().prototype);
    121             if (UNLIKELY(vm.exception()))
     122            if (UNLIKELY(scope.exception()))
    122123                return nullptr;
    123124            if (JSObject* prototype = jsDynamicCast<JSObject*>(prototypeValue)) {
  • trunk/Source/JavaScriptCore/runtime/IntlCollator.cpp

    r205462 r205569  
    163163void IntlCollator::initializeCollator(ExecState& state, JSValue locales, JSValue optionsValue)
    164164{
     165    VM& vm = state.vm();
     166    auto scope = DECLARE_THROW_SCOPE(vm);
     167
    165168    // 10.1.1 InitializeCollator (collator, locales, options) (ECMA-402 2.0)
    166169    // 1. If collator has an [[initializedIntlObject]] internal slot with value true, throw a TypeError exception.
     
    170173    auto requestedLocales = canonicalizeLocaleList(state, locales);
    171174    // 4. ReturnIfAbrupt(requestedLocales).
    172     if (state.hadException())
     175    if (UNLIKELY(scope.exception()))
    173176        return;
    174177
     
    182185        options = optionsValue.toObject(&state);
    183186        // b. ReturnIfAbrupt(options).
    184         if (state.hadException())
     187        if (UNLIKELY(scope.exception()))
    185188            return;
    186189    }
    187190
    188191    // 7. Let u be GetOption(options, "usage", "string", «"sort", "search"», "sort").
    189     String usageString = intlStringOption(state, options, state.vm().propertyNames->usage, { "sort", "search" }, "usage must be either \"sort\" or \"search\"", "sort");
     192    String usageString = intlStringOption(state, options, vm.propertyNames->usage, { "sort", "search" }, "usage must be either \"sort\" or \"search\"", "sort");
    190193    // 8. ReturnIfAbrupt(u).
    191     if (state.hadException())
     194    if (UNLIKELY(scope.exception()))
    192195        return;
    193196    // 9. Set collator.[[usage]] to u.
     
    213216
    214217    // 13. Let matcher be GetOption(options, "localeMatcher", "string", «"lookup", "best fit"», "best fit").
    215     String matcher = intlStringOption(state, options, state.vm().propertyNames->localeMatcher, { "lookup", "best fit" }, "localeMatcher must be either \"lookup\" or \"best fit\"", "best fit");
     218    String matcher = intlStringOption(state, options, vm.propertyNames->localeMatcher, { "lookup", "best fit" }, "localeMatcher must be either \"lookup\" or \"best fit\"", "best fit");
    216219    // 14. ReturnIfAbrupt(matcher).
    217     if (state.hadException())
     220    if (UNLIKELY(scope.exception()))
    218221        return;
    219222    // 15. Set opt.[[localeMatcher]] to matcher.
     
    234237        String numericString;
    235238        bool usesFallback;
    236         bool numeric = intlBooleanOption(state, options, state.vm().propertyNames->numeric, usesFallback);
    237         if (state.hadException())
     239        bool numeric = intlBooleanOption(state, options, vm.propertyNames->numeric, usesFallback);
     240        if (UNLIKELY(scope.exception()))
    238241            return;
    239242        if (!usesFallback)
     
    242245    }
    243246    {
    244         String caseFirst = intlStringOption(state, options, state.vm().propertyNames->caseFirst, { "upper", "lower", "false" }, "caseFirst must be either \"upper\", \"lower\", or \"false\"", nullptr);
    245         if (state.hadException())
     247        String caseFirst = intlStringOption(state, options, vm.propertyNames->caseFirst, { "upper", "lower", "false" }, "caseFirst must be either \"upper\", \"lower\", or \"false\"", nullptr);
     248        if (UNLIKELY(scope.exception()))
    246249            return;
    247250        opt.add(ASCIILiteral("kf"), caseFirst);
     
    278281
    279282    // 24. Let s be GetOption(options, "sensitivity", "string", «"base", "accent", "case", "variant"», undefined).
    280     String sensitivityString = intlStringOption(state, options, state.vm().propertyNames->sensitivity, { "base", "accent", "case", "variant" }, "sensitivity must be either \"base\", \"accent\", \"case\", or \"variant\"", nullptr);
     283    String sensitivityString = intlStringOption(state, options, vm.propertyNames->sensitivity, { "base", "accent", "case", "variant" }, "sensitivity must be either \"base\", \"accent\", \"case\", or \"variant\"", nullptr);
    281284    // 25. ReturnIfAbrupt(s).
    282     if (state.hadException())
     285    if (UNLIKELY(scope.exception()))
    283286        return;
    284287    // 26. If s is undefined, then
     
    301304    // 28. Let ip be GetOption(options, "ignorePunctuation", "boolean", undefined, false).
    302305    bool usesFallback;
    303     bool ignorePunctuation = intlBooleanOption(state, options, state.vm().propertyNames->ignorePunctuation, usesFallback);
     306    bool ignorePunctuation = intlBooleanOption(state, options, vm.propertyNames->ignorePunctuation, usesFallback);
    304307    if (usesFallback)
    305308        ignorePunctuation = false;
    306309    // 29. ReturnIfAbrupt(ip).
    307     if (state.hadException())
     310    if (UNLIKELY(scope.exception()))
    308311        return;
    309312    // 30. Set collator.[[ignorePunctuation]] to ip.
     
    319322void IntlCollator::createCollator(ExecState& state)
    320323{
     324    VM& vm = state.vm();
     325    auto scope = DECLARE_CATCH_SCOPE(vm);
    321326    ASSERT(!m_collator);
    322327
    323328    if (!m_initializedCollator) {
    324329        initializeCollator(state, jsUndefined(), jsUndefined());
    325         ASSERT(!state.hadException());
     330        ASSERT_UNUSED(scope, !scope.exception());
    326331    }
    327332
     
    417422JSObject* IntlCollator::resolvedOptions(ExecState& state)
    418423{
     424    VM& vm = state.vm();
     425    auto scope = DECLARE_THROW_SCOPE(vm);
     426
    419427    // 10.3.5 Intl.Collator.prototype.resolvedOptions() (ECMA-402 2.0)
    420428    // The function returns a new object whose properties and attributes are set as if
     
    428436    if (!m_initializedCollator) {
    429437        initializeCollator(state, jsUndefined(), jsUndefined());
    430         ASSERT(!state.hadException());
    431     }
    432 
    433     VM& vm = state.vm();
     438        ASSERT_UNUSED(scope, !scope.exception());
     439    }
     440
    434441    JSObject* options = constructEmptyObject(&state);
    435442    options->putDirect(vm, vm.propertyNames->locale, jsString(&state, m_locale));
  • trunk/Source/JavaScriptCore/runtime/IntlCollatorConstructor.cpp

    r205462 r205569  
    8484static EncodedJSValue JSC_HOST_CALL constructIntlCollator(ExecState* state)
    8585{
     86    VM& vm = state->vm();
     87    auto scope = DECLARE_THROW_SCOPE(vm);
    8688    // 10.1.2 Intl.Collator ([locales [, options]]) (ECMA-402 2.0)
    8789    // 1. If NewTarget is undefined, let newTarget be the active function object, else let newTarget be NewTarget.
     
    8991    // 3. ReturnIfAbrupt(collator).
    9092    Structure* structure = InternalFunction::createSubclassStructure(state, state->newTarget(), jsCast<IntlCollatorConstructor*>(state->callee())->collatorStructure());
    91     if (state->hadException())
     93    if (UNLIKELY(scope.exception()))
    9294        return JSValue::encode(jsUndefined());
    93     IntlCollator* collator = IntlCollator::create(state->vm(), structure);
     95    IntlCollator* collator = IntlCollator::create(vm, structure);
    9496    ASSERT(collator);
    9597
     
    135137EncodedJSValue JSC_HOST_CALL IntlCollatorConstructorFuncSupportedLocalesOf(ExecState* state)
    136138{
     139    VM& vm = state->vm();
     140    auto scope = DECLARE_THROW_SCOPE(vm);
    137141    // 10.2.2 Intl.Collator.supportedLocalesOf(locales [, options]) (ECMA-402 2.0)
    138142
     
    141145
    142146    // 2. ReturnIfAbrupt(requestedLocales).
    143     if (state->hadException())
     147    if (UNLIKELY(scope.exception()))
    144148        return JSValue::encode(jsUndefined());
    145149
  • trunk/Source/JavaScriptCore/runtime/IntlCollatorPrototype.cpp

    r205462 r205569  
    7979static EncodedJSValue JSC_HOST_CALL IntlCollatorFuncCompare(ExecState* state)
    8080{
     81    VM& vm = state->vm();
     82    auto scope = DECLARE_THROW_SCOPE(vm);
    8183    // 10.3.4 Collator Compare Functions (ECMA-402 2.0)
    8284    // 1. Let collator be the this value.
     
    8991    JSString* x = state->argument(0).toString(state);
    9092    // 6. ReturnIfAbrupt(X).
    91     if (state->hadException())
     93    if (UNLIKELY(scope.exception()))
    9294        return JSValue::encode(jsUndefined());
    9395
     
    9597    JSString* y = state->argument(1).toString(state);
    9698    // 8. ReturnIfAbrupt(Y).
    97     if (state->hadException())
     99    if (UNLIKELY(scope.exception()))
    98100        return JSValue::encode(jsUndefined());
    99101
     
    123125        // c. Let bc be BoundFunctionCreate(F, «this value»).
    124126        boundCompare = JSBoundFunction::create(vm, state, globalObject, targetObject, collator, nullptr, 2, ASCIILiteral("compare"));
    125         if (vm.exception())
     127        if (UNLIKELY(scope.exception()))
    126128            return JSValue::encode(JSValue());
    127129        // d. Set collator.[[boundCompare]] to bc.
  • trunk/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp

    r205462 r205569  
    216216    // 12.1.1 ToDateTimeOptions abstract operation (ECMA-402 2.0)
    217217    VM& vm = exec.vm();
     218    auto scope = DECLARE_THROW_SCOPE(vm);
    218219
    219220    // 1. If options is undefined, then let options be null, else let options be ToObject(options).
     
    225226    else {
    226227        JSObject* originalToObject = originalOptions.toObject(&exec);
    227         if (exec.hadException())
     228        if (UNLIKELY(scope.exception()))
    228229            return nullptr;
    229230        options = constructEmptyObject(&exec, originalToObject);
     
    242243    // iv. If value is not undefined, then let needDefaults be false.
    243244    JSValue weekday = options->get(&exec, vm.propertyNames->weekday);
    244     if (exec.hadException())
     245    if (UNLIKELY(scope.exception()))
    245246        return nullptr;
    246247    if (!weekday.isUndefined())
     
    248249
    249250    JSValue year = options->get(&exec, vm.propertyNames->year);
    250     if (exec.hadException())
     251    if (UNLIKELY(scope.exception()))
    251252        return nullptr;
    252253    if (!year.isUndefined())
     
    254255
    255256    JSValue month = options->get(&exec, vm.propertyNames->month);
    256     if (exec.hadException())
     257    if (UNLIKELY(scope.exception()))
    257258        return nullptr;
    258259    if (!month.isUndefined())
     
    260261
    261262    JSValue day = options->get(&exec, vm.propertyNames->day);
    262     if (exec.hadException())
     263    if (UNLIKELY(scope.exception()))
    263264        return nullptr;
    264265    if (!day.isUndefined())
     
    274275    // iv. If value is not undefined, then let needDefaults be false.
    275276    JSValue hour = options->get(&exec, vm.propertyNames->hour);
    276     if (exec.hadException())
     277    if (UNLIKELY(scope.exception()))
    277278        return nullptr;
    278279    if (!hour.isUndefined())
     
    280281
    281282    JSValue minute = options->get(&exec, vm.propertyNames->minute);
    282     if (exec.hadException())
     283    if (UNLIKELY(scope.exception()))
    283284        return nullptr;
    284285    if (!minute.isUndefined())
     
    286287
    287288    JSValue second = options->get(&exec, vm.propertyNames->second);
    288     if (exec.hadException())
     289    if (UNLIKELY(scope.exception()))
    289290        return nullptr;
    290291    if (!second.isUndefined())
     
    300301
    301302        options->putDirect(vm, vm.propertyNames->year, numeric);
    302         if (exec.hadException())
     303        if (UNLIKELY(scope.exception()))
    303304            return nullptr;
    304305
    305306        options->putDirect(vm, vm.propertyNames->month, numeric);
    306         if (exec.hadException())
     307        if (UNLIKELY(scope.exception()))
    307308            return nullptr;
    308309
    309310        options->putDirect(vm, vm.propertyNames->day, numeric);
    310         if (exec.hadException())
     311        if (UNLIKELY(scope.exception()))
    311312            return nullptr;
    312313    }
     
    429430    Vector<String> requestedLocales = canonicalizeLocaleList(exec, locales);
    430431    // 4. ReturnIfAbrupt(requestedLocales),
    431     if (exec.hadException())
     432    if (UNLIKELY(scope.exception()))
    432433        return;
    433434
     
    435436    JSObject* options = toDateTimeOptionsAnyDate(exec, originalOptions);
    436437    // 6. ReturnIfAbrupt(options).
    437     if (exec.hadException())
     438    if (UNLIKELY(scope.exception()))
    438439        return;
    439440
     
    444445    String localeMatcher = intlStringOption(exec, options, vm.propertyNames->localeMatcher, { "lookup", "best fit" }, "localeMatcher must be either \"lookup\" or \"best fit\"", "best fit");
    445446    // 9. ReturnIfAbrupt(matcher).
    446     if (exec.hadException())
     447    if (UNLIKELY(scope.exception()))
    447448        return;
    448449    // 10. Set opt.[[localeMatcher]] to matcher.
     
    473474    JSValue tzValue = options->get(&exec, vm.propertyNames->timeZone);
    474475    // 18. ReturnIfAbrupt(tz).
    475     if (exec.hadException())
     476    if (UNLIKELY(scope.exception()))
    476477        return;
    477478
     
    482483        String originalTz = tzValue.toWTFString(&exec);
    483484        // b. ReturnIfAbrupt(tz).
    484         if (exec.hadException())
     485        if (UNLIKELY(scope.exception()))
    485486            return;
    486487        // c. If the result of IsValidTimeZoneName(tz) is false, then i. Throw a RangeError exception.
     
    515516
    516517    String weekday = intlStringOption(exec, options, vm.propertyNames->weekday, narrowShortLong, "weekday must be \"narrow\", \"short\", or \"long\"", nullptr);
    517     if (exec.hadException())
     518    if (UNLIKELY(scope.exception()))
    518519        return;
    519520    if (!weekday.isNull()) {
     
    527528
    528529    String era = intlStringOption(exec, options, vm.propertyNames->era, narrowShortLong, "era must be \"narrow\", \"short\", or \"long\"", nullptr);
    529     if (exec.hadException())
     530    if (UNLIKELY(scope.exception()))
    530531        return;
    531532    if (!era.isNull()) {
     
    539540
    540541    String year = intlStringOption(exec, options, vm.propertyNames->year, twoDigitNumeric, "year must be \"2-digit\" or \"numeric\"", nullptr);
    541     if (exec.hadException())
     542    if (UNLIKELY(scope.exception()))
    542543        return;
    543544    if (!year.isNull()) {
     
    549550
    550551    String month = intlStringOption(exec, options, vm.propertyNames->month, twoDigitNumericNarrowShortLong, "month must be \"2-digit\", \"numeric\", \"narrow\", \"short\", or \"long\"", nullptr);
    551     if (exec.hadException())
     552    if (UNLIKELY(scope.exception()))
    552553        return;
    553554    if (!month.isNull()) {
     
    565566
    566567    String day = intlStringOption(exec, options, vm.propertyNames->day, twoDigitNumeric, "day must be \"2-digit\" or \"numeric\"", nullptr);
    567     if (exec.hadException())
     568    if (UNLIKELY(scope.exception()))
    568569        return;
    569570    if (!day.isNull()) {
     
    575576
    576577    String hour = intlStringOption(exec, options, vm.propertyNames->hour, twoDigitNumeric, "hour must be \"2-digit\" or \"numeric\"", nullptr);
    577     if (exec.hadException())
     578    if (UNLIKELY(scope.exception()))
    578579        return;
    579580
     
    583584    bool hr12 = intlBooleanOption(exec, options, vm.propertyNames->hour12, isHour12Undefined);
    584585    // 33. ReturnIfAbrupt(hr12).
    585     if (exec.hadException())
     586    if (UNLIKELY(scope.exception()))
    586587        return;
    587588
     
    606607
    607608    String minute = intlStringOption(exec, options, vm.propertyNames->minute, twoDigitNumeric, "minute must be \"2-digit\" or \"numeric\"", nullptr);
    608     if (exec.hadException())
     609    if (UNLIKELY(scope.exception()))
    609610        return;
    610611    if (!minute.isNull()) {
     
    616617
    617618    String second = intlStringOption(exec, options, vm.propertyNames->second, twoDigitNumeric, "second must be \"2-digit\" or \"numeric\"", nullptr);
    618     if (exec.hadException())
     619    if (UNLIKELY(scope.exception()))
    619620        return;
    620621    if (!second.isNull()) {
     
    626627
    627628    String timeZoneName = intlStringOption(exec, options, vm.propertyNames->timeZoneName, shortLong, "timeZoneName must be \"short\" or \"long\"", nullptr);
    628     if (exec.hadException())
     629    if (UNLIKELY(scope.exception()))
    629630        return;
    630631    if (!timeZoneName.isNull()) {
     
    640641    intlStringOption(exec, options, vm.propertyNames->formatMatcher, { "basic", "best fit" }, "formatMatcher must be either \"basic\" or \"best fit\"", "best fit");
    641642    // 27. ReturnIfAbrupt(matcher).
    642     if (exec.hadException())
     643    if (UNLIKELY(scope.exception()))
    643644        return;
    644645
     
    835836JSObject* IntlDateTimeFormat::resolvedOptions(ExecState& exec)
    836837{
     838    VM& vm = exec.vm();
     839    auto scope = DECLARE_THROW_SCOPE(vm);
     840
    837841    // 12.3.5 Intl.DateTimeFormat.prototype.resolvedOptions() (ECMA-402 2.0)
    838842    // The function returns a new object whose properties and attributes are set as if constructed by an object literal assigning to each of the following properties the value of the corresponding internal slot of this DateTimeFormat object (see 12.4): locale, calendar, numberingSystem, timeZone, hour12, weekday, era, year, month, day, hour, minute, second, and timeZoneName. Properties whose corresponding internal slots are not present are not assigned.
     
    840844    if (!m_initializedDateTimeFormat) {
    841845        initializeDateTimeFormat(exec, jsUndefined(), jsUndefined());
    842         ASSERT(!exec.hadException());
    843     }
    844 
    845     VM& vm = exec.vm();
     846        ASSERT_UNUSED(scope, !scope.exception());
     847    }
     848
    846849    JSObject* options = constructEmptyObject(&exec);
    847850    options->putDirect(vm, vm.propertyNames->locale, jsNontrivialString(&exec, m_locale));
     
    890893    if (!m_initializedDateTimeFormat) {
    891894        initializeDateTimeFormat(exec, jsUndefined(), jsUndefined());
    892         ASSERT(!exec.hadException());
     895        ASSERT(!scope.exception());
    893896    }
    894897
  • trunk/Source/JavaScriptCore/runtime/IntlDateTimeFormatConstructor.cpp

    r205462 r205569  
    8484static EncodedJSValue JSC_HOST_CALL constructIntlDateTimeFormat(ExecState* state)
    8585{
     86    VM& vm = state->vm();
     87    auto scope = DECLARE_THROW_SCOPE(vm);
    8688    // 12.1.2 Intl.DateTimeFormat ([locales [, options]]) (ECMA-402 2.0)
    8789    // 1. If NewTarget is undefined, let newTarget be the active function object, else let newTarget be NewTarget.
     
    8991    // 3. ReturnIfAbrupt(dateTimeFormat).
    9092    Structure* structure = InternalFunction::createSubclassStructure(state, state->newTarget(), jsCast<IntlDateTimeFormatConstructor*>(state->callee())->dateTimeFormatStructure());
    91     if (state->hadException())
     93    if (UNLIKELY(scope.exception()))
    9294        return JSValue::encode(jsUndefined());
    93     IntlDateTimeFormat* dateTimeFormat = IntlDateTimeFormat::create(state->vm(), structure);
     95    IntlDateTimeFormat* dateTimeFormat = IntlDateTimeFormat::create(vm, structure);
    9496    ASSERT(dateTimeFormat);
    9597
     
    135137EncodedJSValue JSC_HOST_CALL IntlDateTimeFormatConstructorFuncSupportedLocalesOf(ExecState* state)
    136138{
     139    VM& vm = state->vm();
     140    auto scope = DECLARE_THROW_SCOPE(vm);
    137141    // 12.2.2 Intl.DateTimeFormat.supportedLocalesOf(locales [, options]) (ECMA-402 2.0)
    138142
     
    143147    // 2. Let requestedLocales be CanonicalizeLocaleList(locales).
    144148    Vector<String> requestedLocales = canonicalizeLocaleList(*state, state->argument(0));
    145     if (state->hadException())
     149    if (UNLIKELY(scope.exception()))
    146150        return JSValue::encode(jsUndefined());
    147151
  • trunk/Source/JavaScriptCore/runtime/IntlDateTimeFormatPrototype.cpp

    r205462 r205569  
    8383static EncodedJSValue JSC_HOST_CALL IntlDateTimeFormatFuncFormatDateTime(ExecState* state)
    8484{
     85    VM& vm = state->vm();
     86    auto scope = DECLARE_THROW_SCOPE(vm);
    8587    // 12.3.4 DateTime Format Functions (ECMA-402 2.0)
    8688    // 1. Let dtf be the this value.
     
    100102        value = date.toNumber(state);
    101103        // b. ReturnIfAbrupt(x).
    102         if (state->hadException())
     104        if (UNLIKELY(scope.exception()))
    103105            return JSValue::encode(jsUndefined());
    104106    }
     
    139141        // c. Let bf be BoundFunctionCreate(F, «this value»).
    140142        boundFormat = JSBoundFunction::create(vm, state, globalObject, targetObject, dtf, boundArgs, 1, ASCIILiteral("format"));
    141         if (vm.exception())
     143        if (UNLIKELY(scope.exception()))
    142144            return JSValue::encode(JSValue());
    143145        // d. Set dtf.[[boundFormat]] to bf.
  • trunk/Source/JavaScriptCore/runtime/IntlNumberFormat.cpp

    r205462 r205569  
    165165    auto requestedLocales = canonicalizeLocaleList(state, locales);
    166166    // 4. ReturnIfAbrupt(requestedLocales).
    167     if (state.hadException())
     167    if (UNLIKELY(scope.exception()))
    168168        return;
    169169
     
    177177        options = optionsValue.toObject(&state);
    178178        // b. ReturnIfAbrupt(options).
    179         if (state.hadException())
     179        if (UNLIKELY(scope.exception()))
    180180            return;
    181181    }
     
    187187    String matcher = intlStringOption(state, options, vm.propertyNames->localeMatcher, { "lookup", "best fit" }, "localeMatcher must be either \"lookup\" or \"best fit\"", "best fit");
    188188    // 9. ReturnIfAbrupt(matcher).
    189     if (state.hadException())
     189    if (UNLIKELY(scope.exception()))
    190190        return;
    191191    // 10. Set opt.[[localeMatcher]] to matcher.
     
    208208    String styleString = intlStringOption(state, options, Identifier::fromString(&vm, "style"), { "decimal", "percent", "currency" }, "style must be either \"decimal\", \"percent\", or \"currency\"", "decimal");
    209209    // 17. ReturnIfAbrupt(s).
    210     if (state.hadException())
     210    if (UNLIKELY(scope.exception()))
    211211        return;
    212212    // 18. Set numberFormat.[[style]] to s.
     
    223223    String currency = intlStringOption(state, options, Identifier::fromString(&vm, "currency"), { }, nullptr, nullptr);
    224224    // 20. ReturnIfAbrupt(c).
    225     if (state.hadException())
     225    if (UNLIKELY(scope.exception()))
    226226        return;
    227227    // 21. If c is not undefined, then
     
    254254    String currencyDisplayString = intlStringOption(state, options, Identifier::fromString(&vm, "currencyDisplay"), { "code", "symbol", "name" }, "currencyDisplay must be either \"code\", \"symbol\", or \"name\"", "symbol");
    255255    // 25. ReturnIfAbrupt(cd).
    256     if (state.hadException())
     256    if (UNLIKELY(scope.exception()))
    257257        return;
    258258    // 26. If s is "currency", set numberFormat.[[currencyDisplay]] to cd.
     
    272272    // 29. Set numberFormat.[[minimumIntegerDigits]] to mnid.
    273273    unsigned minimumIntegerDigits = intlNumberOption(state, options, Identifier::fromString(&vm, "minimumIntegerDigits"), 1, 21, 1);
    274     if (state.hadException())
     274    if (UNLIKELY(scope.exception()))
    275275        return;
    276276    m_minimumIntegerDigits = minimumIntegerDigits;
     
    283283    // 33. Set numberFormat.[[minimumFractionDigits]] to mnfd.
    284284    unsigned minimumFractionDigits = intlNumberOption(state, options, Identifier::fromString(&vm, "minimumFractionDigits"), 0, 20, minimumFractionDigitsDefault);
    285     if (state.hadException())
     285    if (UNLIKELY(scope.exception()))
    286286        return;
    287287    m_minimumFractionDigits = minimumFractionDigits;
     
    300300    // 37. Set numberFormat.[[maximumFractionDigits]] to mxfd.
    301301    unsigned maximumFractionDigits = intlNumberOption(state, options, Identifier::fromString(&vm, "maximumFractionDigits"), minimumFractionDigits, 20, maximumFractionDigitsDefault);
    302     if (state.hadException())
     302    if (UNLIKELY(scope.exception()))
    303303        return;
    304304    m_maximumFractionDigits = maximumFractionDigits;
     
    307307    JSValue minimumSignificantDigitsValue = options->get(&state, Identifier::fromString(&vm, "minimumSignificantDigits"));
    308308    // 39. ReturnIfAbrupt(mnsd).
    309     if (state.hadException())
     309    if (UNLIKELY(scope.exception()))
    310310        return;
    311311
     
    313313    JSValue maximumSignificantDigitsValue = options->get(&state, Identifier::fromString(&vm, "maximumSignificantDigits"));
    314314    // 41. ReturnIfAbrupt(mxsd).
    315     if (state.hadException())
     315    if (UNLIKELY(scope.exception()))
    316316        return;
    317317
     
    321321        unsigned minimumSignificantDigits = intlNumberOption(state, options, Identifier::fromString(&vm, "minimumSignificantDigits"), 1, 21, 1);
    322322        // b. ReturnIfAbrupt(mnsd).
    323         if (state.hadException())
     323        if (UNLIKELY(scope.exception()))
    324324            return;
    325325        // c. Let mxsd be GetNumberOption(options, "maximumSignificantDigits", mnsd, 21, 21).
    326326        unsigned maximumSignificantDigits = intlNumberOption(state, options, Identifier::fromString(&vm, "maximumSignificantDigits"), minimumSignificantDigits, 21, 21);
    327327        // d. ReturnIfAbrupt(mxsd).
    328         if (state.hadException())
     328        if (UNLIKELY(scope.exception()))
    329329            return;
    330330        // e. Set numberFormat.[[minimumSignificantDigits]] to mnsd.
     
    340340        useGrouping = true;
    341341    // 44. ReturnIfAbrupt(g).
    342     if (state.hadException())
     342    if (UNLIKELY(scope.exception()))
    343343        return;
    344344    // 45. Set numberFormat.[[useGrouping]] to g.
     
    362362void IntlNumberFormat::createNumberFormat(ExecState& state)
    363363{
     364    VM& vm = state.vm();
     365    auto scope = DECLARE_CATCH_SCOPE(vm);
     366
    364367    ASSERT(!m_numberFormat);
    365368
    366369    if (!m_initializedNumberFormat) {
    367370        initializeNumberFormat(state, jsUndefined(), jsUndefined());
    368         ASSERT(!state.hadException());
     371        ASSERT_UNUSED(scope, !scope.exception());
    369372    }
    370373
     
    480483JSObject* IntlNumberFormat::resolvedOptions(ExecState& state)
    481484{
     485    VM& vm = state.vm();
     486    auto scope = DECLARE_THROW_SCOPE(vm);
     487
    482488    // 11.3.5 Intl.NumberFormat.prototype.resolvedOptions() (ECMA-402 2.0)
    483489    // The function returns a new object whose properties and attributes are set as if
     
    491497    if (!m_initializedNumberFormat) {
    492498        initializeNumberFormat(state, jsUndefined(), jsUndefined());
    493         ASSERT(!state.hadException());
    494     }
    495 
    496     VM& vm = state.vm();
     499        ASSERT_UNUSED(scope, !scope.exception());
     500    }
     501
    497502    JSObject* options = constructEmptyObject(&state);
    498503    options->putDirect(vm, vm.propertyNames->locale, jsString(&state, m_locale));
  • trunk/Source/JavaScriptCore/runtime/IntlNumberFormatConstructor.cpp

    r205462 r205569  
    8484static EncodedJSValue JSC_HOST_CALL constructIntlNumberFormat(ExecState* state)
    8585{
     86    VM& vm = state->vm();
     87    auto scope = DECLARE_THROW_SCOPE(vm);
    8688    // 11.1.2 Intl.NumberFormat ([locales [, options]]) (ECMA-402 2.0)
    8789    // 1. If NewTarget is undefined, let newTarget be the active function object, else let newTarget be NewTarget.
     
    8991    // 3. ReturnIfAbrupt(numberFormat).
    9092    Structure* structure = InternalFunction::createSubclassStructure(state, state->newTarget(), jsCast<IntlNumberFormatConstructor*>(state->callee())->numberFormatStructure());
    91     if (state->hadException())
     93    if (UNLIKELY(scope.exception()))
    9294        return JSValue::encode(jsUndefined());
    93     IntlNumberFormat* numberFormat = IntlNumberFormat::create(state->vm(), structure);
     95    IntlNumberFormat* numberFormat = IntlNumberFormat::create(vm, structure);
    9496    ASSERT(numberFormat);
    9597
     
    135137EncodedJSValue JSC_HOST_CALL IntlNumberFormatConstructorFuncSupportedLocalesOf(ExecState* state)
    136138{
     139    VM& vm = state->vm();
     140    auto scope = DECLARE_THROW_SCOPE(vm);
    137141    // 11.2.2 Intl.NumberFormat.supportedLocalesOf(locales [, options]) (ECMA-402 2.0)
    138142
     
    143147    // 2. Let requestedLocales be CanonicalizeLocaleList(locales).
    144148    Vector<String> requestedLocales = canonicalizeLocaleList(*state, state->argument(0));
    145     if (state->hadException())
     149    if (UNLIKELY(scope.exception()))
    146150        return JSValue::encode(jsUndefined());
    147151
  • trunk/Source/JavaScriptCore/runtime/IntlNumberFormatPrototype.cpp

    r205462 r205569  
    8181static EncodedJSValue JSC_HOST_CALL IntlNumberFormatFuncFormatNumber(ExecState* state)
    8282{
     83    VM& vm = state->vm();
     84    auto scope = DECLARE_THROW_SCOPE(vm);
    8385    // 11.3.4 Format Number Functions (ECMA-402 2.0)
    8486    // 1. Let nf be the this value.
     
    9092    double number = state->argument(0).toNumber(state);
    9193    // 5. ReturnIfAbrupt(x).
    92     if (state->hadException())
     94    if (UNLIKELY(scope.exception()))
    9395        return JSValue::encode(jsUndefined());
    9496
     
    127129        // c. Let bf be BoundFunctionCreate(F, «this value»).
    128130        boundFormat = JSBoundFunction::create(vm, state, globalObject, targetObject, nf, boundArgs, 1, ASCIILiteral("format"));
    129         if (vm.exception())
     131        if (UNLIKELY(scope.exception()))
    130132            return JSValue::encode(JSValue());
    131133        // d. Set nf.[[boundFormat]] to bf.
  • trunk/Source/JavaScriptCore/runtime/IntlObject.cpp

    r205568 r205569  
    125125bool intlBooleanOption(ExecState& state, JSValue options, PropertyName property, bool& usesFallback)
    126126{
     127    VM& vm = state.vm();
     128    auto scope = DECLARE_THROW_SCOPE(vm);
     129
    127130    // 9.2.9 GetOption (options, property, type, values, fallback)
    128131    // For type="boolean". values is always undefined.
     
    132135
    133136    // 2. ReturnIfAbrupt(opts).
    134     if (state.hadException())
     137    if (UNLIKELY(scope.exception()))
    135138        return false;
    136139
     
    139142
    140143    // 4. ReturnIfAbrupt(value).
    141     if (state.hadException())
     144    if (UNLIKELY(scope.exception()))
    142145        return false;
    143146
     
    174177
    175178    // 2. ReturnIfAbrupt(opts).
    176     if (state.hadException())
     179    if (UNLIKELY(scope.exception()))
    177180        return { };
    178181
     
    181184
    182185    // 4. ReturnIfAbrupt(value).
    183     if (state.hadException())
     186    if (UNLIKELY(scope.exception()))
    184187        return { };
    185188
     
    194197
    195198        // ii. ReturnIfAbrupt(value).
    196         if (state.hadException())
     199        if (UNLIKELY(scope.exception()))
    197200            return { };
    198201
     
    222225
    223226    // 2. ReturnIfAbrupt(opts).
    224     if (state.hadException())
     227    if (UNLIKELY(scope.exception()))
    225228        return 0;
    226229
     
    229232
    230233    // 4. ReturnIfAbrupt(value).
    231     if (state.hadException())
     234    if (UNLIKELY(scope.exception()))
    232235        return 0;
    233236
     
    237240        double doubleValue = value.toNumber(&state);
    238241        // b. ReturnIfAbrupt(value).
    239         if (state.hadException())
     242        if (UNLIKELY(scope.exception()))
    240243            return 0;
    241244        // 1. If value is NaN or less than minimum or greater than maximum, throw a RangeError exception.
     
    558561
    559562    // 5. ReturnIfAbrupt(O).
    560     if (state.hadException())
     563    if (UNLIKELY(scope.exception()))
    561564        return Vector<String>();
    562565
    563566    // 6. Let len be ToLength(Get(O, "length")).
    564567    JSValue lengthProperty = localesObject->get(&state, vm.propertyNames->length);
    565     if (state.hadException())
     568    if (UNLIKELY(scope.exception()))
    566569        return Vector<String>();
    567570
    568571    double length = lengthProperty.toLength(&state);
    569     if (state.hadException())
     572    if (UNLIKELY(scope.exception()))
    570573        return Vector<String>();
    571574
     
    583586
    584587        // c. ReturnIfAbrupt(kPresent).
    585         if (state.hadException())
     588        if (UNLIKELY(scope.exception()))
    586589            return Vector<String>();
    587590
     
    592595
    593596            // ii. ReturnIfAbrupt(kValue).
    594             if (state.hadException())
     597            if (UNLIKELY(scope.exception()))
    595598                return Vector<String>();
    596599
     
    605608
    606609            // v. ReturnIfAbrupt(tag).
    607             if (state.hadException())
     610            if (UNLIKELY(scope.exception()))
    608611                return Vector<String>();
    609612
     
    935938    // 9.2.8 SupportedLocales (availableLocales, requestedLocales, options)
    936939    VM& vm = state.vm();
     940    auto scope = DECLARE_THROW_SCOPE(vm);
    937941    String matcher;
    938942
     
    942946        matcher = intlStringOption(state, options, vm.propertyNames->localeMatcher, { "lookup", "best fit" }, "localeMatcher must be either \"lookup\" or \"best fit\"", "best fit");
    943947        // b. ReturnIfAbrupt(matcher).
    944         if (state.hadException())
     948        if (UNLIKELY(scope.exception()))
    945949            return jsUndefined();
    946950    } else {
     
    962966    }
    963967
    964     if (state.hadException())
     968    if (UNLIKELY(scope.exception()))
    965969        return jsUndefined();
    966970
     
    971975    PropertyNameArray keys(&state, PropertyNameMode::Strings);
    972976    supportedLocales->getOwnPropertyNames(supportedLocales, &state, keys, EnumerationMode());
    973     if (state.hadException())
     977    if (UNLIKELY(scope.exception()))
    974978        return jsUndefined();
    975979
     
    988992
    989993        // c. Assert: status is not abrupt completion.
    990         if (state.hadException())
     994        if (UNLIKELY(scope.exception()))
    991995            return jsUndefined();
    992996    }
  • trunk/Source/JavaScriptCore/runtime/IntlObjectInlines.h

    r202280 r205569  
    4141    // https://bugs.webkit.org/show_bug.cgi?id=153679
    4242    VM& vm = state.vm();
     43    auto scope = DECLARE_THROW_SCOPE(vm);
     44
    4345    if (!jsDynamicCast<IntlInstance*>(thisValue)) {
    4446        JSValue prototype = callee->getDirect(vm, vm.propertyNames->prototype);
    4547        if (JSObject::defaultHasInstance(&state, thisValue, prototype)) {
    4648            JSObject* thisObject = thisValue.toObject(&state);
    47             if (state.hadException())
     49            if (UNLIKELY(scope.exception()))
    4850                return jsUndefined();
    4951
    5052            IntlInstance* instance = factory(vm);
    51             if (state.hadException())
     53            if (UNLIKELY(scope.exception()))
    5254                return jsUndefined();
    5355
  • trunk/Source/JavaScriptCore/runtime/IteratorOperations.cpp

    r205198 r205569  
    4242
    4343    JSValue nextFunction = iterator.get(exec, vm.propertyNames->next);
    44     if (exec->hadException())
     44    if (UNLIKELY(scope.exception()))
    4545        return jsUndefined();
    4646
     
    5454        nextFunctionArguments.append(value);
    5555    JSValue result = call(exec, nextFunction, nextFunctionCallType, nextFunctionCallData, iterator, nextFunctionArguments);
    56     if (exec->hadException())
     56    if (UNLIKELY(scope.exception()))
    5757        return jsUndefined();
    5858
     
    8181JSValue iteratorStep(ExecState* exec, JSValue iterator)
    8282{
     83    VM& vm = exec->vm();
     84    auto scope = DECLARE_THROW_SCOPE(vm);
     85
    8386    JSValue result = iteratorNext(exec, iterator);
    84     if (exec->hadException())
     87    if (UNLIKELY(scope.exception()))
    8588        return jsUndefined();
    8689    bool done = iteratorComplete(exec, result);
    87     if (exec->hadException())
     90    if (UNLIKELY(scope.exception()))
    8891        return jsUndefined();
    8992    if (done)
     
    9598{
    9699    VM& vm = exec->vm();
    97     auto scope = DECLARE_THROW_SCOPE(vm);
     100    auto throwScope = DECLARE_THROW_SCOPE(vm);
     101    auto catchScope = DECLARE_CATCH_SCOPE(vm);
    98102
    99103    Exception* exception = nullptr;
    100     if (exec->hadException()) {
    101         exception = exec->exception();
    102         exec->clearException();
     104    if (UNLIKELY(catchScope.exception())) {
     105        exception = catchScope.exception();
     106        catchScope.clearException();
    103107    }
    104108    JSValue returnFunction = iterator.get(exec, vm.propertyNames->returnKeyword);
    105     if (exec->hadException())
     109    if (UNLIKELY(throwScope.exception()))
    106110        return;
    107111
    108112    if (returnFunction.isUndefined()) {
    109113        if (exception)
    110             throwException(exec, scope, exception);
     114            throwException(exec, throwScope, exception);
    111115        return;
    112116    }
     
    116120    if (returnFunctionCallType == CallType::None) {
    117121        if (exception)
    118             throwException(exec, scope, exception);
     122            throwException(exec, throwScope, exception);
    119123        else
    120             throwTypeError(exec, scope);
     124            throwTypeError(exec, throwScope);
    121125        return;
    122126    }
     
    126130
    127131    if (exception) {
    128         throwException(exec, scope, exception);
     132        throwException(exec, throwScope, exception);
    129133        return;
    130134    }
    131135
    132     if (exec->hadException())
     136    if (UNLIKELY(throwScope.exception()))
    133137        return;
    134138
    135139    if (!innerResult.isObject()) {
    136         throwTypeError(exec, scope, ASCIILiteral("Iterator result interface is not an object."));
     140        throwTypeError(exec, throwScope, ASCIILiteral("Iterator result interface is not an object."));
    137141        return;
    138142    }
     
    168172   
    169173    JSValue iteratorFunction = iterable.get(state, state->propertyNames().iteratorSymbol);
    170     if (state->hadException())
     174    if (UNLIKELY(scope.exception()))
    171175        return JSValue();
    172176   
     
    180184    ArgList iteratorFunctionArguments;
    181185    JSValue iterator = call(state, iteratorFunction, iteratorFunctionCallType, iteratorFunctionCallData, iterable, iteratorFunctionArguments);
    182     if (state->hadException())
     186    if (UNLIKELY(scope.exception()))
    183187        return JSValue();
    184188
  • trunk/Source/JavaScriptCore/runtime/IteratorOperations.h

    r204500 r205569  
    2929#include "JSCJSValue.h"
    3030#include "JSObject.h"
     31#include "ThrowScope.h"
    3132
    3233namespace JSC {
     
    4849{
    4950    auto& vm = state->vm();
     51    auto scope = DECLARE_THROW_SCOPE(vm);
     52
    5053    JSValue iterator = iteratorForIterable(state, iterable);
    51     if (vm.exception())
     54    if (UNLIKELY(scope.exception()))
    5255        return;
    5356    while (true) {
    5457        JSValue next = iteratorStep(state, iterator);
    55         if (next.isFalse() || vm.exception())
     58        if (next.isFalse() || UNLIKELY(scope.exception()))
    5659            return;
    5760
    5861        JSValue nextValue = iteratorValue(state, next);
    59         if (vm.exception())
     62        if (UNLIKELY(scope.exception()))
    6063            return;
    6164
    6265        callback(vm, state, nextValue);
    63         if (vm.exception()) {
     66        if (UNLIKELY(scope.exception())) {
    6467            iteratorClose(state, iterator);
    6568            return;
  • trunk/Source/JavaScriptCore/runtime/JSArray.cpp

    r205462 r205569  
    655655    // Let element be the result of calling the [[Get]] internal method of O with argument indx.
    656656    JSValue element = get(exec, index);
    657     if (exec->hadException())
     657    if (UNLIKELY(scope.exception()))
    658658        return jsUndefined();
    659659    // Call the [[Delete]] internal method of O with arguments indx and true.
     
    707707        if (length > MAX_ARRAY_INDEX) {
    708708            methodTable(vm)->putByIndex(this, exec, length, value, true);
    709             if (!exec->hadException())
     709            if (!scope.exception())
    710710                throwException(exec, scope, createRangeError(exec, ASCIILiteral("Invalid array length")));
    711711            return;
     
    727727        if (length > MAX_ARRAY_INDEX) {
    728728            methodTable(vm)->putByIndex(this, exec, length, value, true);
    729             if (!exec->hadException())
     729            if (!scope.exception())
    730730                throwException(exec, scope, createRangeError(exec, ASCIILiteral("Invalid array length")));
    731731            return;
     
    759759        if (length > MAX_ARRAY_INDEX) {
    760760            methodTable(vm)->putByIndex(this, exec, length, value, true);
    761             if (!exec->hadException())
     761            if (!scope.exception())
    762762                throwException(exec, scope, createRangeError(exec, ASCIILiteral("Invalid array length")));
    763763            return;
     
    772772        bool putResult = false;
    773773        if (attemptToInterceptPutByIndexOnHole(exec, oldLength, value, true, putResult)) {
    774             if (!exec->hadException() && oldLength < 0xFFFFFFFFu)
     774            if (!scope.exception() && oldLength < 0xFFFFFFFFu)
    775775                setLength(exec, oldLength + 1, true);
    776776            return;
     
    795795            methodTable(vm)->putByIndex(this, exec, storage->length(), value, true);
    796796            // Per ES5.1 15.4.4.7 step 6 & 15.4.5.1 step 3.d.
    797             if (!exec->hadException())
     797            if (!scope.exception())
    798798                throwException(exec, scope, createRangeError(exec, ASCIILiteral("Invalid array length")));
    799799            return;
     
    12581258void JSArray::copyToArguments(ExecState* exec, VirtualRegister firstElementDest, unsigned offset, unsigned length)
    12591259{
     1260    VM& vm = exec->vm();
     1261    auto scope = DECLARE_THROW_SCOPE(vm);
     1262
    12601263    unsigned i = offset;
    12611264    WriteBarrier<Unknown>* vector;
     
    13221325    for (; i < length; ++i) {
    13231326        exec->r(firstElementDest + i - offset) = get(exec, i);
    1324         if (UNLIKELY(exec->vm().exception()))
     1327        if (UNLIKELY(scope.exception()))
    13251328            return;
    13261329    }
  • trunk/Source/JavaScriptCore/runtime/JSArrayBufferConstructor.cpp

    r205198 r205569  
    8989    if (exec->argumentCount()) {
    9090        length = exec->uncheckedArgument(0).toUInt32(exec);
    91         if (exec->hadException())
     91        if (UNLIKELY(scope.exception()))
    9292            return JSValue::encode(jsUndefined());
    9393    } else {
     
    103103
    104104    Structure* arrayBufferStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), constructor->globalObject()->arrayBufferStructure());
    105     if (exec->hadException())
     105    if (UNLIKELY(scope.exception()))
    106106        return JSValue::encode(JSValue());
    107107    JSArrayBuffer* result = JSArrayBuffer::create(vm, arrayBufferStructure, WTFMove(buffer));
  • trunk/Source/JavaScriptCore/runtime/JSArrayBufferPrototype.cpp

    r205198 r205569  
    5151   
    5252    int32_t begin = exec->argument(0).toInt32(exec);
    53     if (exec->hadException())
     53    if (UNLIKELY(scope.exception()))
    5454        return JSValue::encode(jsUndefined());
    5555   
     
    5757    if (exec->argumentCount() >= 2) {
    5858        end = exec->uncheckedArgument(1).toInt32(exec);
    59         if (exec->hadException())
     59        if (UNLIKELY(scope.exception()))
    6060            return JSValue::encode(jsUndefined());
    6161    } else
  • trunk/Source/JavaScriptCore/runtime/JSArrayInlines.h

    r205324 r205569  
    7171ALWAYS_INLINE unsigned getLength(ExecState* exec, JSObject* obj)
    7272{
     73    VM& vm = exec->vm();
     74    auto scope = DECLARE_THROW_SCOPE(vm);
    7375    if (isJSArray(obj))
    7476        return jsCast<JSArray*>(obj)->length();
    7577
    76     VM& vm = exec->vm();
    7778    JSValue lengthValue = obj->get(exec, vm.propertyNames->length);
    78     if (UNLIKELY(vm.exception()))
     79    if (UNLIKELY(scope.exception()))
    7980        return UINT_MAX;
    8081    return lengthValue.toUInt32(exec);
     
    8384ALWAYS_INLINE double toLength(ExecState* exec, JSObject* obj)
    8485{
     86    VM& vm = exec->vm();
     87    auto scope = DECLARE_THROW_SCOPE(vm);
    8588    if (isJSArray(obj))
    8689        return jsCast<JSArray*>(obj)->length();
    8790
    88     VM& vm = exec->vm();
    8991    JSValue lengthValue = obj->get(exec, vm.propertyNames->length);
    90     if (UNLIKELY(vm.exception()))
     92    if (UNLIKELY(scope.exception()))
    9193        return PNaN;
    9294    return lengthValue.toLength(exec);
  • trunk/Source/JavaScriptCore/runtime/JSBoundFunction.cpp

    r204321 r205569  
    127127inline Structure* getBoundFunctionStructure(VM& vm, ExecState* exec, JSGlobalObject* globalObject, JSObject* targetFunction)
    128128{
     129    auto scope = DECLARE_THROW_SCOPE(vm);
    129130    JSValue prototype = targetFunction->getPrototype(vm, exec);
    130     if (UNLIKELY(vm.exception()))
     131    if (UNLIKELY(scope.exception()))
    131132        return nullptr;
    132133    JSFunction* targetJSFunction = jsDynamicCast<JSFunction*>(targetFunction);
     
    159160JSBoundFunction* JSBoundFunction::create(VM& vm, ExecState* exec, JSGlobalObject* globalObject, JSObject* targetFunction, JSValue boundThis, JSArray* boundArgs, int length, const String& name)
    160161{
     162    auto scope = DECLARE_THROW_SCOPE(vm);
    161163    ConstructData constructData;
    162164    ConstructType constructType = JSC::getConstructData(targetFunction, constructData);
     
    171173        name);
    172174    Structure* structure = getBoundFunctionStructure(vm, exec, globalObject, targetFunction);
    173     if (UNLIKELY(vm.exception()))
     175    if (UNLIKELY(scope.exception()))
    174176        return nullptr;
    175177    JSBoundFunction* function = new (NotNull, allocateCell<JSBoundFunction>(vm.heap)) JSBoundFunction(vm, globalObject, structure, targetFunction, boundThis, boundArgs);
  • trunk/Source/JavaScriptCore/runtime/JSCJSValue.cpp

    r205462 r205569  
    193193
    194194        prototype = obj->getPrototype(vm, exec);
    195         if (vm.exception())
     195        if (UNLIKELY(scope.exception()))
    196196            return false;
    197197        if (prototype.isNull())
     
    216216    JSObject* prototype = synthesizePrototype(exec);
    217217    if (UNLIKELY(!prototype)) {
    218         ASSERT(exec->hadException());
     218        ASSERT(scope.exception());
    219219        return false;
    220220    }
     
    382382    ASSERT(isCell());
    383383    JSValue value = asCell()->toPrimitive(exec, PreferString);
    384     if (vm.exception())
     384    if (UNLIKELY(scope.exception()))
    385385        return errorValue();
    386386    ASSERT(!value.isObject());
    387387    JSString* result = value.toString(exec);
    388     if (vm.exception())
     388    if (UNLIKELY(scope.exception()))
    389389        return errorValue();
    390390    return result;
  • trunk/Source/JavaScriptCore/runtime/JSCJSValueInlines.h

    r205520 r205569  
    643643
    644644    StringImpl* hintString = jsCast<JSString*>(value)->value(exec).impl();
    645     if (exec->hadException())
     645    if (UNLIKELY(scope.exception()))
    646646        return NoPreference;
    647647
     
    785785ALWAYS_INLINE typename std::result_of<CallbackWhenNoException(bool, PropertySlot&)>::type JSValue::getPropertySlot(ExecState* exec, PropertyName propertyName, PropertySlot& slot, CallbackWhenNoException callback) const
    786786{
     787    auto scope = DECLARE_THROW_SCOPE(exec->vm());
    787788    bool found = getPropertySlot(exec, propertyName, slot);
    788     if (UNLIKELY(exec->hadException()))
     789    if (UNLIKELY(scope.exception()))
    789790        return { };
    790791    return callback(found, slot);
     
    898899{
    899900    VM& vm = exec->vm();
     901    auto scope = DECLARE_THROW_SCOPE(vm);
    900902    do {
    901903        if (v1.isNumber() && v2.isNumber())
     
    925927                return v1 == v2;
    926928            JSValue p1 = v1.toPrimitive(exec);
    927             if (exec->hadException())
     929            if (UNLIKELY(scope.exception()))
    928930                return false;
    929931            v1 = p1;
     
    935937        if (v2.isObject()) {
    936938            JSValue p2 = v2.toPrimitive(exec);
    937             if (exec->hadException())
     939            if (UNLIKELY(scope.exception()))
    938940                return false;
    939941            v2 = p2;
  • trunk/Source/JavaScriptCore/runtime/JSDataViewPrototype.cpp

    r205198 r205569  
    134134   
    135135    unsigned byteOffset = exec->uncheckedArgument(0).toUInt32(exec);
    136     if (exec->hadException())
     136    if (UNLIKELY(scope.exception()))
    137137        return JSValue::encode(jsUndefined());
    138138   
     
    141141    if (elementSize > 1 && exec->argumentCount() >= 2) {
    142142        littleEndian = exec->uncheckedArgument(1).toBoolean(exec);
    143         if (exec->hadException())
     143        if (UNLIKELY(scope.exception()))
    144144            return JSValue::encode(jsUndefined());
    145145    }
     
    182182   
    183183    unsigned byteOffset = exec->uncheckedArgument(0).toUInt32(exec);
    184     if (exec->hadException())
     184    if (UNLIKELY(scope.exception()))
    185185        return JSValue::encode(jsUndefined());
    186186
     
    192192
    193193    u.value = toNativeFromValue<Adaptor>(exec, exec->uncheckedArgument(1));
    194     if (exec->hadException())
     194    if (UNLIKELY(scope.exception()))
    195195        return JSValue::encode(jsUndefined());
    196196   
     
    199199    if (elementSize > 1 && exec->argumentCount() >= 3) {
    200200        littleEndian = exec->uncheckedArgument(2).toBoolean(exec);
    201         if (exec->hadException())
     201        if (UNLIKELY(scope.exception()))
    202202            return JSValue::encode(jsUndefined());
    203203    }
  • trunk/Source/JavaScriptCore/runtime/JSFunction.cpp

    r205462 r205569  
    593593{
    594594    VM& vm = exec->vm();
     595    auto scope = DECLARE_THROW_SCOPE(vm);
     596
    595597    // The "name" property may have been already been defined as part of a property list in an
    596598    // object literal (and therefore reified).
     
    609611    } else {
    610612        JSString* jsStr = value.toString(exec);
    611         if (vm.exception())
     613        if (UNLIKELY(scope.exception()))
    612614            return;
    613615        name = jsStr->value(exec);
    614         if (vm.exception())
     616        if (UNLIKELY(scope.exception()))
    615617            return;
    616618    }
  • trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayView.h

    r205508 r205569  
    174174
    175175        typename Adaptor::Type value = toNativeFromValue<Adaptor>(exec, jsValue);
    176         if (exec->hadException())
     176        if (UNLIKELY(scope.exception()))
    177177            return false;
    178178
  • trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructorInlines.h

    r205198 r205569  
    9090    while (true) {
    9191        JSValue next = iteratorStep(exec, iterator);
    92         if (exec->hadException())
     92        if (UNLIKELY(scope.exception()))
    9393            return nullptr;
    9494
     
    9797
    9898        JSValue nextItem = iteratorValue(exec, next);
    99         if (exec->hadException())
     99        if (UNLIKELY(scope.exception()))
    100100            return nullptr;
    101101
     
    105105    ViewClass* result = ViewClass::createUninitialized(exec, structure, storage.size());
    106106    if (!result) {
    107         ASSERT(exec->hadException());
     107        ASSERT(scope.exception());
    108108        return nullptr;
    109109    }
     
    111111    for (unsigned i = 0; i < storage.size(); ++i) {
    112112        if (!result->setIndex(exec, i, storage.at(i))) {
    113             ASSERT(exec->hadException());
     113            ASSERT(scope.exception());
    114114            return nullptr;
    115115        }
     
    163163
    164164            JSValue iteratorFunc = object->get(exec, vm.propertyNames->iteratorSymbol);
    165             if (exec->hadException())
     165            if (UNLIKELY(scope.exception()))
    166166                return nullptr;
    167167
     
    184184                    ArgList arguments;
    185185                    JSValue iterator = call(exec, iteratorFunc, callType, callData, object, arguments);
    186                     if (exec->hadException())
     186                    if (UNLIKELY(scope.exception()))
    187187                        return nullptr;
    188188
     
    191191
    192192            length = lengthSlot.isUnset() ? 0 : lengthSlot.getValue(exec, vm.propertyNames->length).toUInt32(exec);
    193             if (exec->hadException())
     193            if (UNLIKELY(scope.exception()))
    194194                return nullptr;
    195195        }
     
    198198        ViewClass* result = ViewClass::createUninitialized(exec, structure, length);
    199199        if (!result) {
    200             ASSERT(exec->hadException());
     200            ASSERT(scope.exception());
    201201            return nullptr;
    202202        }
     
    236236    Structure* parentStructure = function->globalObject()->typedArrayStructure(ViewClass::TypedArrayStorageType);
    237237    Structure* structure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), parentStructure);
    238     if (exec->hadException())
     238    if (UNLIKELY(scope.exception()))
    239239        return JSValue::encode(JSValue());
    240240
     
    253253    if (jsDynamicCast<JSArrayBuffer*>(firstValue) && argCount > 1) {
    254254        offset = exec->uncheckedArgument(1).toUInt32(exec);
    255         if (exec->hadException())
     255        if (UNLIKELY(scope.exception()))
    256256            return JSValue::encode(jsUndefined());
    257257
    258258        if (argCount > 2) {
    259259            length = exec->uncheckedArgument(2).toUInt32(exec);
    260             if (exec->hadException())
     260            if (UNLIKELY(scope.exception()))
    261261                return JSValue::encode(jsUndefined());
    262262        }
  • trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h

    r205198 r205569  
    5252
    5353    JSValue constructor = exemplar->get(exec, exec->propertyNames().constructor);
    54     if (exec->hadException())
     54    if (UNLIKELY(scope.exception()))
    5555        return nullptr;
    5656
     
    6363
    6464    JSValue species = constructor.get(exec, exec->propertyNames().speciesSymbol);
    65     if (exec->hadException())
     65    if (UNLIKELY(scope.exception()))
    6666        return nullptr;
    6767
     
    7070
    7171    JSValue result = construct(exec, species, args, "species is not a constructor");
    72     if (exec->hadException())
     72    if (UNLIKELY(scope.exception()))
    7373        return nullptr;
    7474
     
    148148EncodedJSValue JSC_HOST_CALL genericTypedArrayViewProtoFuncCopyWithin(VM& vm, ExecState* exec)
    149149{
    150 //    VM& vm = exec->vm();
    151150    auto scope = DECLARE_THROW_SCOPE(vm);
    152151
     
    158157    long length = thisObject->length();
    159158    long to = argumentClampedIndexFromStartOrEnd(exec, 0, length);
    160     if (vm.exception())
     159    if (UNLIKELY(scope.exception()))
    161160        return encodedJSValue();
    162161    long from = argumentClampedIndexFromStartOrEnd(exec, 1, length);
    163     if (vm.exception())
     162    if (UNLIKELY(scope.exception()))
    164163        return encodedJSValue();
    165164    long final = argumentClampedIndexFromStartOrEnd(exec, 2, length, length);
    166     if (vm.exception())
     165    if (UNLIKELY(scope.exception()))
    167166        return encodedJSValue();
    168167
     
    184183EncodedJSValue JSC_HOST_CALL genericTypedArrayViewProtoFuncIncludes(VM& vm, ExecState* exec)
    185184{
    186 //    VM& vm = exec->vm();
    187185    auto scope = DECLARE_THROW_SCOPE(vm);
    188186
     
    199197
    200198    unsigned index = argumentClampedIndexFromStartOrEnd(exec, 1, length);
    201     if (vm.exception())
     199    if (UNLIKELY(scope.exception()))
    202200        return JSValue::encode(jsUndefined());
    203201
     
    210208        return JSValue::encode(jsBoolean(false));
    211209
    212     ASSERT(!vm.exception());
     210    ASSERT(!scope.exception());
    213211    RELEASE_ASSERT(!thisObject->isNeutered());
    214212
     
    231229EncodedJSValue JSC_HOST_CALL genericTypedArrayViewProtoFuncIndexOf(VM& vm, ExecState* exec)
    232230{
    233 //    VM& vm = exec->vm();
    234231    auto scope = DECLARE_THROW_SCOPE(vm);
    235232
     
    246243    JSValue valueToFind = exec->argument(0);
    247244    unsigned index = argumentClampedIndexFromStartOrEnd(exec, 1, length);
    248     if (vm.exception())
     245    if (UNLIKELY(scope.exception()))
    249246        return encodedJSValue();
    250247
     
    256253    if (!targetOption)
    257254        return JSValue::encode(jsNumber(-1));
    258     ASSERT(!vm.exception());
     255    ASSERT(!scope.exception());
    259256    RELEASE_ASSERT(!thisObject->isNeutered());
    260257
     
    270267EncodedJSValue JSC_HOST_CALL genericTypedArrayViewProtoFuncJoin(VM& vm, ExecState* exec)
    271268{
    272 //    VM& vm = exec->vm();
    273269    auto scope = DECLARE_THROW_SCOPE(vm);
    274270
     
    283279
    284280        JSStringJoiner joiner(*exec, separator, length);
    285         if (exec->hadException())
     281        if (UNLIKELY(scope.exception()))
    286282            return JSValue::encode(jsUndefined());
    287283        for (unsigned i = 0; i < length; i++) {
    288284            joiner.append(*exec, thisObject->getIndexQuickly(i));
    289             if (exec->hadException())
     285            if (UNLIKELY(scope.exception()))
    290286                return JSValue::encode(jsUndefined());
    291287        }
     
    300296
    301297    JSString* separatorString = separatorValue.toString(exec);
    302     if (exec->hadException())
     298    if (UNLIKELY(scope.exception()))
    303299        return JSValue::encode(jsUndefined());
    304300
     
    311307EncodedJSValue JSC_HOST_CALL genericTypedArrayViewProtoFuncLastIndexOf(VM& vm, ExecState* exec)
    312308{
    313 //    VM& vm = exec->vm();
    314309    auto scope = DECLARE_THROW_SCOPE(vm);
    315310
     
    339334    }
    340335
    341     if (vm.exception())
     336    if (UNLIKELY(scope.exception()))
    342337        return JSValue::encode(JSValue());
    343338
     
    350345
    351346    typename ViewClass::ElementType* array = thisObject->typedVector();
    352     ASSERT(!vm.exception());
     347    ASSERT(!scope.exception());
    353348    RELEASE_ASSERT(!thisObject->isNeutered());
    354349
     
    433428EncodedJSValue JSC_HOST_CALL genericTypedArrayViewProtoFuncSlice(VM& vm, ExecState* exec)
    434429{
    435 //    VM& vm = exec->vm();
    436430    auto scope = DECLARE_THROW_SCOPE(vm);
    437431
     
    446440
    447441    unsigned begin = argumentClampedIndexFromStartOrEnd(exec, 0, thisLength);
    448     if (vm.exception())
     442    if (UNLIKELY(scope.exception()))
    449443        return encodedJSValue();
    450444    unsigned end = argumentClampedIndexFromStartOrEnd(exec, 1, thisLength, thisLength);
    451     if (vm.exception())
     445    if (UNLIKELY(scope.exception()))
    452446        return encodedJSValue();
    453447
     
    468462        return ViewClass::createUninitialized(exec, structure, length);
    469463    });
    470     if (exec->hadException())
     464    if (UNLIKELY(scope.exception()))
    471465        return JSValue::encode(JSValue());
    472466
     
    519513EncodedJSValue JSC_HOST_CALL genericTypedArrayViewPrivateFuncSubarrayCreate(VM&vm, ExecState* exec)
    520514{
    521 //    VM& vm = exec->vm();
    522515    auto scope = DECLARE_THROW_SCOPE(vm);
    523516
     
    538531    ASSERT(exec->argument(1).isUndefined() || exec->argument(1).isNumber());
    539532    unsigned begin = argumentClampedIndexFromStartOrEnd(exec, 0, thisLength);
    540     ASSERT(!vm.exception());
     533    ASSERT(!scope.exception());
    541534    unsigned end = argumentClampedIndexFromStartOrEnd(exec, 1, thisLength, thisLength);
    542     ASSERT(!vm.exception());
     535    ASSERT(!scope.exception());
    543536
    544537    RELEASE_ASSERT(!thisObject->isNeutered());
     
    573566
    574567    JSObject* result = construct(exec, species, args, "species is not a constructor");
    575     if (exec->hadException())
     568    if (UNLIKELY(scope.exception()))
    576569        return JSValue::encode(JSValue());
    577570
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h

    r205372 r205569  
    11/*
    22 *  Copyright (C) 2007 Eric Seidel <eric@webkit.org>
    3  *  Copyright (C) 2007, 2008, 2009, 2014-2016 Apple Inc. All rights reserved.
     3 *  Copyright (C) 2007-2009, 2014-2016 Apple Inc. All rights reserved.
    44 *
    55 *  This library is free software; you can redistribute it and/or
     
    816816inline JSArray* constructEmptyArray(ExecState* exec, ArrayAllocationProfile* profile, JSGlobalObject* globalObject, unsigned initialLength = 0, JSValue newTarget = JSValue())
    817817{
     818    VM& vm = globalObject->vm();
     819    auto scope = DECLARE_THROW_SCOPE(vm);
    818820    Structure* structure;
    819821    if (initialLength >= MIN_ARRAY_STORAGE_CONSTRUCTION_LENGTH)
     
    821823    else
    822824        structure = globalObject->arrayStructureForProfileDuringAllocation(exec, profile, newTarget);
    823     if (exec->hadException())
     825    if (UNLIKELY(scope.exception()))
    824826        return nullptr;
    825827
     
    834836inline JSArray* constructArray(ExecState* exec, ArrayAllocationProfile* profile, JSGlobalObject* globalObject, const ArgList& values, JSValue newTarget = JSValue())
    835837{
     838    VM& vm = globalObject->vm();
     839    auto scope = DECLARE_THROW_SCOPE(vm);
    836840    Structure* structure = globalObject->arrayStructureForProfileDuringAllocation(exec, profile, newTarget);
    837     if (exec->hadException())
     841    if (UNLIKELY(scope.exception()))
    838842        return nullptr;
    839843    return ArrayAllocationProfile::updateLastAllocationFor(profile, constructArray(exec, structure, values));
     
    847851inline JSArray* constructArray(ExecState* exec, ArrayAllocationProfile* profile, JSGlobalObject* globalObject, const JSValue* values, unsigned length, JSValue newTarget = JSValue())
    848852{
     853    VM& vm = globalObject->vm();
     854    auto scope = DECLARE_THROW_SCOPE(vm);
    849855    Structure* structure = globalObject->arrayStructureForProfileDuringAllocation(exec, profile, newTarget);
    850     if (exec->hadException())
     856    if (UNLIKELY(scope.exception()))
    851857        return nullptr;
    852858    return ArrayAllocationProfile::updateLastAllocationFor(profile, constructArray(exec, structure, values, length));
     
    860866inline JSArray* constructArrayNegativeIndexed(ExecState* exec, ArrayAllocationProfile* profile, JSGlobalObject* globalObject, const JSValue* values, unsigned length, JSValue newTarget = JSValue())
    861867{
     868    VM& vm = globalObject->vm();
     869    auto scope = DECLARE_THROW_SCOPE(vm);
    862870    Structure* structure = globalObject->arrayStructureForProfileDuringAllocation(exec, profile, newTarget);
    863     if (exec->hadException())
     871    if (UNLIKELY(scope.exception()))
    864872        return nullptr;
    865873    return ArrayAllocationProfile::updateLastAllocationFor(profile, constructArrayNegativeIndexed(exec, structure, values, length));
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp

    r205372 r205569  
    661661
    662662    String s = x.toString(exec)->value(exec);
    663     if (exec->hadException())
     663    if (UNLIKELY(scope.exception()))
    664664        return JSValue::encode(jsUndefined());
    665665
  • trunk/Source/JavaScriptCore/runtime/JSJob.cpp

    r205462 r205569  
    6363void JSJobMicrotask::run(ExecState* exec)
    6464{
     65    VM& vm = exec->vm();
     66    auto scope = DECLARE_CATCH_SCOPE(vm);
     67
    6568    CallData handlerCallData;
    6669    CallType handlerCallType = getCallData(m_job.get(), handlerCallData);
     
    7174        handlerArguments.append(m_arguments->JSArray::get(exec, index));
    7275    profiledCall(exec, ProfilingReason::Microtask, m_job.get(), handlerCallType, handlerCallData, jsUndefined(), handlerArguments);
    73     exec->vm().clearException();
     76    scope.clearException();
    7477}
    7578
  • trunk/Source/JavaScriptCore/runtime/JSModuleEnvironment.cpp

    r205198 r205569  
    7979bool JSModuleEnvironment::getOwnPropertySlot(JSObject* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
    8080{
     81    VM& vm = exec->vm();
     82    auto scope = DECLARE_THROW_SCOPE(vm);
    8183    JSModuleEnvironment* thisObject = jsCast<JSModuleEnvironment*>(cell);
    8284    JSModuleRecord::Resolution resolution = thisObject->moduleRecord()->resolveImport(exec, Identifier::fromUid(exec, propertyName.uid()));
     
    8587        JSModuleEnvironment* importedModuleEnvironment = resolution.moduleRecord->moduleEnvironment();
    8688        PropertySlot redirectSlot(importedModuleEnvironment, PropertySlot::InternalMethodType::Get);
    87         bool result = importedModuleEnvironment->methodTable(exec->vm())->getOwnPropertySlot(importedModuleEnvironment, exec, resolution.localName, redirectSlot);
     89        bool result = importedModuleEnvironment->methodTable(vm)->getOwnPropertySlot(importedModuleEnvironment, exec, resolution.localName, redirectSlot);
    8890        ASSERT_UNUSED(result, result);
    8991        ASSERT(redirectSlot.isValue());
    9092        JSValue value = redirectSlot.getValue(exec, resolution.localName);
    91         ASSERT(!exec->hadException());
     93        ASSERT_UNUSED(scope, !scope.exception());
    9294        slot.setValue(thisObject, redirectSlot.attributes(), value);
    9395        return true;
  • trunk/Source/JavaScriptCore/runtime/JSModuleLoader.cpp

    r205520 r205569  
    153153
    154154    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
     155    VM& vm = globalObject->vm();
     156    auto scope = DECLARE_CATCH_SCOPE(vm);
    155157    if (globalObject->globalObjectMethodTable()->moduleLoaderFetch)
    156158        return globalObject->globalObjectMethodTable()->moduleLoaderFetch(globalObject, exec, this, key, initiator);
    157159    JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject);
    158160    String moduleKey = key.toString(exec)->value(exec);
    159     if (exec->hadException()) {
    160         JSValue exception = exec->exception()->value();
    161         exec->clearException();
     161    if (UNLIKELY(scope.exception())) {
     162        JSValue exception = scope.exception()->value();
     163        scope.clearException();
    162164        deferred->reject(exec, exception);
    163165        return deferred->promise();
  • trunk/Source/JavaScriptCore/runtime/JSModuleNamespaceObject.cpp

    r205462 r205569  
    4949{
    5050    VM& vm = exec->vm();
     51    auto scope = DECLARE_THROW_SCOPE(vm);
    5152    Base::finishCreation(vm);
    5253    ASSERT(inherits(info()));
     
    7879    // http://www.ecma-international.org/ecma-262/6.0/#sec-module-namespace-exotic-objects-preventextensions
    7980    methodTable(vm)->preventExtensions(this, exec);
    80     ASSERT(!exec->hadException());
     81    ASSERT_UNUSED(scope, !scope.exception());
    8182}
    8283
     
    133134
    134135        JSValue value = trampolineSlot.getValue(exec, propertyName);
    135         ASSERT(!exec->hadException());
     136        ASSERT(!scope.exception());
    136137
    137138        // If the value is filled with TDZ value, throw a reference error.
  • trunk/Source/JavaScriptCore/runtime/JSModuleRecord.cpp

    r205520 r205569  
    779779        if (importEntry.isNamespace(vm)) {
    780780            JSModuleNamespaceObject* namespaceObject = importedModule->getModuleNamespace(exec);
    781             if (exec->hadException())
     781            if (UNLIKELY(scope.exception()))
    782782                return;
    783783            bool putResult = false;
  • trunk/Source/JavaScriptCore/runtime/JSONObject.cpp

    r205198 r205569  
    221221    , m_gap(gap(exec, space.get()))
    222222{
     223    VM& vm = exec->vm();
     224    auto scope = DECLARE_THROW_SCOPE(vm);
    223225    if (!m_replacer.isObject())
    224226        return;
     
    227229        m_usingArrayReplacer = true;
    228230        Handle<JSObject> array = m_replacer.asObject();
    229         unsigned length = array->get(exec, exec->vm().propertyNames->length).toUInt32(exec);
     231        unsigned length = array->get(exec, vm.propertyNames->length).toUInt32(exec);
    230232        for (unsigned i = 0; i < length; ++i) {
    231233            JSValue name = array->get(exec, i);
    232             if (exec->hadException())
     234            if (UNLIKELY(scope.exception()))
    233235                break;
    234236
     
    249251Local<Unknown> Stringifier::stringify(Handle<Unknown> value)
    250252{
     253    VM& vm = m_exec->vm();
     254    auto scope = DECLARE_THROW_SCOPE(vm);
    251255    JSObject* object = constructEmptyObject(m_exec);
    252     if (m_exec->hadException())
    253         return Local<Unknown>(m_exec->vm(), jsNull());
    254 
    255     PropertyNameForFunctionCall emptyPropertyName(m_exec->vm().propertyNames->emptyIdentifier);
    256     object->putDirect(m_exec->vm(), m_exec->vm().propertyNames->emptyIdentifier, value.get());
     256    if (UNLIKELY(scope.exception()))
     257        return Local<Unknown>(vm, jsNull());
     258
     259    PropertyNameForFunctionCall emptyPropertyName(vm.propertyNames->emptyIdentifier);
     260    object->putDirect(vm, vm.propertyNames->emptyIdentifier, value.get());
    257261
    258262    StringBuilder result;
    259263    if (appendStringifiedValue(result, value.get(), object, emptyPropertyName) != StringifySucceeded)
    260         return Local<Unknown>(m_exec->vm(), jsUndefined());
    261     if (m_exec->hadException())
    262         return Local<Unknown>(m_exec->vm(), jsNull());
    263 
    264     return Local<Unknown>(m_exec->vm(), jsString(m_exec, result.toString()));
     264        return Local<Unknown>(vm, jsUndefined());
     265    if (UNLIKELY(scope.exception()))
     266        return Local<Unknown>(vm, jsNull());
     267
     268    return Local<Unknown>(vm, jsString(m_exec, result.toString()));
    265269}
    266270
    267271ALWAYS_INLINE JSValue Stringifier::toJSON(JSValue value, const PropertyNameForFunctionCall& propertyName)
    268272{
    269     ASSERT(!m_exec->hadException());
     273    VM& vm = m_exec->vm();
     274    auto scope = DECLARE_THROW_SCOPE(vm);
     275    ASSERT(!scope.exception());
    270276    if (!value.isObject())
    271277        return value;
    272278   
    273279    JSObject* object = asObject(value);
    274     VM& vm = m_exec->vm();
    275280    PropertySlot slot(object, PropertySlot::InternalMethodType::Get);
    276281    if (!object->getPropertySlot(m_exec, vm.propertyNames->toJSON, slot))
     
    278283
    279284    JSValue toJSONFunction = slot.getValue(m_exec, vm.propertyNames->toJSON);
    280     if (vm.exception())
     285    if (UNLIKELY(scope.exception()))
    281286        return jsNull();
    282287    return toJSONImpl(value, toJSONFunction, propertyName);
     
    302307    // Call the toJSON function.
    303308    value = toJSON(value, propertyName);
    304     if (vm.exception())
     309    if (UNLIKELY(scope.exception()))
    305310        return StringifyFailed;
    306311
     
    311316        args.append(value);
    312317        value = call(m_exec, m_replacer.get(), m_replacerCallType, m_replacerCallData, holder, args);
    313         if (vm.exception())
     318        if (UNLIKELY(scope.exception()))
    314319            return StringifyFailed;
    315320    }
     
    325330    value = unwrapBoxedPrimitive(m_exec, value);
    326331
    327     if (vm.exception())
     332    if (UNLIKELY(scope.exception()))
    328333        return StringifyFailed;
    329334
     
    378383    bool holderStackWasEmpty = m_holderStack.isEmpty();
    379384    m_holderStack.append(Holder(vm, m_exec, object));
    380     if (UNLIKELY(vm.exception()))
     385    if (UNLIKELY(scope.exception()))
    381386        return StringifyFailed;
    382387    if (!holderStackWasEmpty)
     
    385390    do {
    386391        while (m_holderStack.last().appendNextProperty(*this, builder)) {
    387             if (vm.exception())
     392            if (UNLIKELY(scope.exception()))
    388393                return StringifyFailed;
    389394        }
     
    437442
    438443    ExecState* exec = stringifier.m_exec;
     444    VM& vm = exec->vm();
     445    auto scope = DECLARE_THROW_SCOPE(vm);
    439446
    440447    // First time through, initialize.
     
    445452                m_size = asArray(m_object.get())->length();
    446453            else
    447                 m_size = m_object->get(exec, exec->vm().propertyNames->length).toUInt32(exec);
     454                m_size = m_object->get(exec, vm.propertyNames->length).toUInt32(exec);
    448455            builder.append('[');
    449456        } else {
     
    453460                PropertyNameArray objectPropertyNames(exec, PropertyNameMode::Strings);
    454461                m_object->methodTable()->getOwnPropertyNames(m_object.get(), exec, objectPropertyNames, EnumerationMode());
    455                 if (UNLIKELY(exec->hadException()))
     462                if (UNLIKELY(scope.exception()))
    456463                    return false;
    457464                m_propertyNames = objectPropertyNames.releaseData();
     
    487494            else
    488495                value = jsUndefined();
    489             if (UNLIKELY(exec->hadException()))
     496            if (UNLIKELY(scope.exception()))
    490497                return false;
    491498        }
     
    505512            return true;
    506513        JSValue value = slot.getValue(exec, propertyName);
    507         if (exec->hadException())
     514        if (UNLIKELY(scope.exception()))
    508515            return false;
    509516
     
    641648                    else
    642649                        inValue = jsUndefined();
    643                     if (m_exec->hadException())
     650                    if (UNLIKELY(scope.exception()))
    644651                        return jsNull();
    645652                }
     
    659666                else
    660667                    array->putDirectIndex(m_exec, indexStack.last(), filteredValue);
    661                 if (m_exec->hadException())
     668                if (UNLIKELY(scope.exception()))
    662669                    return jsNull();
    663670                indexStack.last()++;
     
    676683                propertyStack.append(PropertyNameArray(m_exec, PropertyNameMode::Strings));
    677684                object->methodTable()->getOwnPropertyNames(object, m_exec, propertyStack.last(), EnumerationMode());
    678                 if (UNLIKELY(m_exec->hadException()))
     685                if (UNLIKELY(scope.exception()))
    679686                    return jsNull();
    680687            }
     
    699706
    700707                // The holder may be modified by the reviver function so any lookup may throw
    701                 if (m_exec->hadException())
     708                if (UNLIKELY(scope.exception()))
    702709                    return jsNull();
    703710
     
    718725                else
    719726                    object->methodTable()->put(object, m_exec, prop, filteredValue, slot);
    720                 if (m_exec->hadException())
     727                if (UNLIKELY(scope.exception()))
    721728                    return jsNull();
    722729                indexStack.last()++;
     
    755762        return throwVMError(exec, scope, createError(exec, ASCIILiteral("JSON.parse requires at least one parameter")));
    756763    JSString::SafeView source = exec->uncheckedArgument(0).toString(exec)->view(exec);
    757     if (exec->hadException())
     764    if (UNLIKELY(scope.exception()))
    758765        return JSValue::encode(jsNull());
    759766
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r205462 r205569  
    352352
    353353    VM& vm = exec->vm();
     354    auto scope = DECLARE_THROW_SCOPE(vm);
    354355    JSObject* current = object;
    355356    PropertyDescriptor ownDescriptor;
     
    363364        // 9.1.9.1-2 Let ownDesc be ? O.[[GetOwnProperty]](P).
    364365        bool ownDescriptorFound = current->getOwnPropertyDescriptor(exec, propertyName, ownDescriptor);
    365         if (UNLIKELY(vm.exception()))
     366        if (UNLIKELY(scope.exception()))
    366367            return false;
    367368
     
    369370            // 9.1.9.1-3-a Let parent be ? O.[[GetPrototypeOf]]().
    370371            JSValue prototype = current->getPrototype(vm, exec);
    371             if (UNLIKELY(vm.exception()))
     372            if (UNLIKELY(scope.exception()))
    372373                return false;
    373374
     
    401402        PropertyDescriptor existingDescriptor;
    402403        bool existingDescriptorFound = receiverObject->getOwnPropertyDescriptor(exec, propertyName, existingDescriptor);
    403         if (UNLIKELY(vm.exception()))
     404        if (UNLIKELY(scope.exception()))
    404405            return false;
    405406
     
    12931294
    12941295    bool isExtensible = this->isExtensible(exec);
    1295     if (vm.exception())
     1296    if (UNLIKELY(scope.exception()))
    12961297        return false;
    12971298
     
    15531554
    15541555    JSValue function = object->get(exec, propertyName);
    1555     if (scope.exception())
     1556    if (UNLIKELY(scope.exception()))
    15561557        return scope.exception();
    15571558    if (function.isUndefined() && mode == TypeHintMode::TakesHint)
     
    15811582    JSValue result = call(exec, function, callType, callData, const_cast<JSObject*>(object), callArgs);
    15821583    ASSERT(!result.isGetterSetter());
    1583     if (scope.exception())
     1584    if (UNLIKELY(scope.exception()))
    15841585        return scope.exception();
    15851586    if (result.isObject())
     
    16191620    }
    16201621
    1621     ASSERT(!exec->hadException());
     1622    ASSERT(!scope.exception());
    16221623
    16231624    return throwTypeError(exec, scope, ASCIILiteral("No default value"));
     
    17191720    while (true) {
    17201721        JSValue objectValue = object->getPrototype(vm, exec);
    1721         if (UNLIKELY(vm.exception()))
     1722        if (UNLIKELY(scope.exception()))
    17221723            return false;
    17231724        if (!objectValue.isObject())
     
    17411742{
    17421743    VM& vm = exec->vm();
     1744    auto scope = DECLARE_THROW_SCOPE(vm);
    17431745    object->methodTable(vm)->getOwnPropertyNames(object, exec, propertyNames, mode);
    1744     if (UNLIKELY(vm.exception()))
     1746    if (UNLIKELY(scope.exception()))
    17451747        return;
    17461748
    17471749    JSValue nextProto = object->getPrototype(vm, exec);
    1748     if (UNLIKELY(vm.exception()))
     1750    if (UNLIKELY(scope.exception()))
    17491751        return;
    17501752    if (nextProto.isNull())
     
    17581760        }
    17591761        prototype->methodTable(vm)->getOwnPropertyNames(prototype, exec, propertyNames, mode);
    1760         if (UNLIKELY(vm.exception()))
     1762        if (UNLIKELY(scope.exception()))
    17611763            return;
    17621764        nextProto = prototype->getPrototype(vm, exec);
    1763         if (UNLIKELY(vm.exception()))
     1765        if (UNLIKELY(scope.exception()))
    17641766            return;
    17651767        if (nextProto.isNull())
     
    18591861double JSObject::toNumber(ExecState* exec) const
    18601862{
     1863    VM& vm = exec->vm();
     1864    auto scope = DECLARE_THROW_SCOPE(vm);
    18611865    JSValue primitive = toPrimitive(exec, PreferNumber);
    1862     if (exec->hadException()) // should be picked up soon in Nodes.cpp
     1866    if (UNLIKELY(scope.exception())) // should be picked up soon in Nodes.cpp
    18631867        return 0.0;
    18641868    return primitive.toNumber(exec);
     
    18671871JSString* JSObject::toString(ExecState* exec) const
    18681872{
     1873    VM& vm = exec->vm();
     1874    auto scope = DECLARE_THROW_SCOPE(vm);
    18691875    JSValue primitive = toPrimitive(exec, PreferString);
    1870     if (exec->hadException())
     1876    if (UNLIKELY(scope.exception()))
    18711877        return jsEmptyString(exec);
    18721878    return primitive.toString(exec);
     
    30773083bool JSObject::defineOwnNonIndexProperty(ExecState* exec, PropertyName propertyName, const PropertyDescriptor& descriptor, bool throwException)
    30783084{
     3085    VM& vm  = exec->vm();
     3086    auto throwScope = DECLARE_THROW_SCOPE(vm);
     3087
    30793088    // Track on the globaldata that we're in define property.
    30803089    // Currently DefineOwnProperty uses delete to remove properties when they are being replaced
    30813090    // (particularly when changing attributes), however delete won't allow non-configurable (i.e.
    30823091    // DontDelete) properties to be deleted. For now, we can use this flag to make this work.
    3083     VM::DeletePropertyModeScope scope(exec->vm(), VM::DeletePropertyMode::IgnoreConfigurable);
     3092    VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
    30843093    PropertyDescriptor current;
    30853094    bool isCurrentDefined = getOwnPropertyDescriptor(exec, propertyName, current);
    30863095    bool isExtensible = this->isExtensible(exec);
    3087     if (UNLIKELY(exec->hadException()))
     3096    if (UNLIKELY(throwScope.exception()))
    30883097        return false;
    30893098    return validateAndApplyPropertyDescriptor(exec, this, propertyName, isExtensible, descriptor, isCurrentDefined, current, throwException);
     
    31853194{
    31863195    VM& vm = exec->vm();
     3196    auto scope = DECLARE_THROW_SCOPE(vm);
    31873197    object->methodTable(vm)->getOwnPropertyNames(object, exec, propertyNames, EnumerationMode(mode, JSObjectPropertiesMode::Exclude));
    3188     if (UNLIKELY(vm.exception()))
     3198    if (UNLIKELY(scope.exception()))
    31893199        return;
    31903200
    31913201    JSValue nextProto = object->getPrototype(vm, exec);
    3192     if (UNLIKELY(vm.exception()))
     3202    if (UNLIKELY(scope.exception()))
    31933203        return;
    31943204    if (nextProto.isNull())
     
    32023212        }
    32033213        prototype->methodTable(vm)->getOwnPropertyNames(prototype, exec, propertyNames, mode);
    3204         if (UNLIKELY(exec->hadException()))
     3214        if (UNLIKELY(scope.exception()))
    32053215            return;
    32063216        nextProto = prototype->getPrototype(vm, exec);
    3207         if (UNLIKELY(vm.exception()))
     3217        if (UNLIKELY(scope.exception()))
    32083218            return;
    32093219        if (nextProto.isNull())
     
    32213231
    32223232    JSValue method = get(exec, ident);
    3223     if (exec->hadException())
     3233    if (UNLIKELY(scope.exception()))
    32243234        return jsUndefined();
    32253235
  • trunk/Source/JavaScriptCore/runtime/JSObjectInlines.h

    r205462 r205569  
    4141    Vector<JSValue> result;
    4242    JSValue lengthProperty = arrayLikeValue.get(exec, vm.propertyNames->length);
    43     if (vm.exception())
     43    if (UNLIKELY(scope.exception()))
    4444        return;
    4545    double lengthAsDouble = lengthProperty.toLength(exec);
    46     if (vm.exception())
     46    if (UNLIKELY(scope.exception()))
    4747        return;
    4848    RELEASE_ASSERT(lengthAsDouble >= 0.0 && lengthAsDouble == std::trunc(lengthAsDouble));
     
    5050    for (uint64_t index = 0; index < length; index++) {
    5151        JSValue next = arrayLikeValue.get(exec, index);
    52         if (vm.exception())
     52        if (UNLIKELY(scope.exception()))
    5353            return;
    5454       
     
    9797ALWAYS_INLINE typename std::result_of<CallbackWhenNoException(bool, PropertySlot&)>::type JSObject::getPropertySlot(ExecState* exec, PropertyName propertyName, PropertySlot& slot, CallbackWhenNoException callback) const
    9898{
     99    VM& vm = exec->vm();
     100    auto scope = DECLARE_THROW_SCOPE(vm);
    99101    bool found = const_cast<JSObject*>(this)->getPropertySlot(exec, propertyName, slot);
    100     if (UNLIKELY(exec->hadException()))
     102    if (UNLIKELY(scope.exception()))
    101103        return { };
    102104    return callback(found, slot);
     
    106108{
    107109    VM& vm = exec->vm();
     110    auto scope = DECLARE_THROW_SCOPE(vm);
    108111    auto& structureIDTable = vm.heap.structureIDTable();
    109112    JSObject* object = this;
     
    113116        if (structure.classInfo()->methodTable.getOwnPropertySlotByIndex(object, exec, propertyName, slot))
    114117            return true;
    115         if (UNLIKELY(vm.exception()))
     118        if (UNLIKELY(scope.exception()))
    116119            return false;
    117120        JSValue prototype;
     
    120123        else {
    121124            prototype = object->getPrototype(vm, exec);
    122             if (vm.exception())
     125            if (UNLIKELY(scope.exception()))
    123126                return false;
    124127        }
     
    135138
    136139    VM& vm = exec->vm();
     140    auto scope = DECLARE_THROW_SCOPE(vm);
    137141    auto& structureIDTable = vm.heap.structureIDTable();
    138142    JSObject* object = this;
     
    146150            if (structure.classInfo()->methodTable.getOwnPropertySlot(object, exec, propertyName, slot))
    147151                return true;
    148             if (UNLIKELY(vm.exception()))
     152            if (UNLIKELY(scope.exception()))
    149153                return false;
    150154        }
     
    154158        else {
    155159            prototype = object->getPrototype(vm, exec);
    156             if (vm.exception())
     160            if (UNLIKELY(scope.exception()))
    157161                return false;
    158162        }
  • trunk/Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp

    r205462 r205569  
    104104
    105105    Structure* promiseStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), globalObject->promiseStructure());
    106     if (exec->hadException())
     106    if (UNLIKELY(scope.exception()))
    107107        return JSValue::encode(JSValue());
    108108    JSPromise* promise = JSPromise::create(vm, promiseStructure);
  • trunk/Source/JavaScriptCore/runtime/JSPropertyNameEnumerator.h

    r197539 r205569  
    103103{
    104104    VM& vm = exec->vm();
     105    auto scope = DECLARE_THROW_SCOPE(vm);
    105106
    106107    uint32_t indexedLength = base->methodTable(vm)->getEnumerableLength(exec, base);
     
    120121    if (structure->canAccessPropertiesQuicklyForEnumeration() && indexedLength == base->getArrayLength()) {
    121122        base->methodTable(vm)->getStructurePropertyNames(base, exec, propertyNames, EnumerationMode());
    122         ASSERT(!exec->hadException());
     123        ASSERT(!scope.exception());
    123124
    124125        numberStructureProperties = propertyNames.size();
    125126
    126127        base->methodTable(vm)->getGenericPropertyNames(base, exec, propertyNames, EnumerationMode());
    127         ASSERT(!exec->hadException());
     128        ASSERT(!scope.exception());
    128129    } else {
    129130        // Generic property names vector contains all indexed property names.
     
    131132        indexedLength = 0;
    132133        base->methodTable(vm)->getPropertyNames(base, exec, propertyNames, EnumerationMode());
    133         if (UNLIKELY(exec->hadException()))
     134        if (UNLIKELY(scope.exception()))
    134135            return nullptr;
    135136    }
  • trunk/Source/JavaScriptCore/runtime/JSPropertyNameIterator.cpp

    r205462 r205569  
    5656JSPropertyNameIterator* JSPropertyNameIterator::create(ExecState* exec, Structure* structure, JSObject* iteratedObject)
    5757{
     58    VM& vm = exec->vm();
     59    auto scope = DECLARE_THROW_SCOPE(vm);
    5860    JSPropertyNameEnumerator* enumerator = propertyNameEnumerator(exec, iteratedObject);
    59     if (UNLIKELY(exec->hadException()))
     61    if (UNLIKELY(scope.exception()))
    6062        return nullptr;
    6163    return JSPropertyNameIterator::create(exec, structure, iteratedObject, enumerator);
  • trunk/Source/JavaScriptCore/runtime/JSScope.cpp

    r205462 r205569  
    201201static inline bool isUnscopable(ExecState* exec, JSScope* scope, JSObject* object, const Identifier& ident)
    202202{
     203    VM& vm = exec->vm();
     204    auto throwScope = DECLARE_THROW_SCOPE(vm);
    203205    if (scope->type() != WithScopeType)
    204206        return false;
    205207
    206208    JSValue unscopables = object->get(exec, exec->propertyNames().unscopablesSymbol);
    207     if (exec->hadException())
     209    if (UNLIKELY(throwScope.exception()))
    208210        return false;
    209211    if (!unscopables.isObject())
    210212        return false;
    211213    JSValue blocked = jsCast<JSObject*>(unscopables)->get(exec, ident);
    212     if (exec->hadException())
     214    if (UNLIKELY(throwScope.exception()))
    213215        return false;
    214216
     
    219221{
    220222    VM& vm = exec->vm();
     223    auto throwScope = DECLARE_THROW_SCOPE(vm);
    221224    ScopeChainIterator end = scope->end();
    222225    ScopeChainIterator it = scope->begin();
     
    241244            if (!isUnscopable(exec, scope, object, ident))
    242245                return object;
    243             ASSERT_WITH_MESSAGE(!exec->hadException(), "When an exception occurs, the result of isUnscopable becomes false");
     246            ASSERT_WITH_MESSAGE_UNUSED(throwScope, !throwScope.exception(), "When an exception occurs, the result of isUnscopable becomes false");
    244247        }
    245248    }
  • trunk/Source/JavaScriptCore/runtime/JSString.cpp

    r205198 r205569  
    7575bool JSString::equalSlowCase(ExecState* exec, JSString* other) const
    7676{
     77    VM& vm = exec->vm();
     78    auto scope = DECLARE_THROW_SCOPE(vm);
    7779    String str1 = value(exec);
    7880    String str2 = other->value(exec);
    79     if (exec->hadException())
     81    if (UNLIKELY(scope.exception()))
    8082        return false;
    8183    return WTF::equal(*str1.impl(), *str2.impl());
  • trunk/Source/JavaScriptCore/runtime/JSStringJoiner.cpp

    r205198 r205569  
    109109
    110110    unsigned length = joinedLength(state);
    111     if (state.hadException())
     111    if (UNLIKELY(scope.exception()))
    112112        return jsUndefined();
    113113
  • trunk/Source/JavaScriptCore/runtime/LiteralParser.cpp

    r201787 r205569  
    573573JSValue LiteralParser<CharType>::parse(ParserState initialState)
    574574{
     575    VM& vm = m_exec->vm();
     576    auto scope = DECLARE_THROW_SCOPE(vm);
    575577    ParserState state = initialState;
    576578    MarkedArgumentBuffer objectStack;
     
    584586            case StartParseArray: {
    585587                JSArray* array = constructEmptyArray(m_exec, 0);
    586                 if (UNLIKELY(m_exec->hadException()))
     588                if (UNLIKELY(scope.exception()))
    587589                    return JSValue();
    588590                objectStack.append(array);
     
    682684                JSObject* object = asObject(objectStack.last());
    683685                PropertyName ident = identifierStack.last();
    684                 if (m_mode != StrictJSON && ident == m_exec->vm().propertyNames->underscoreProto) {
     686                if (m_mode != StrictJSON && ident == vm.propertyNames->underscoreProto) {
    685687                    if (!visitedUnderscoreProto.add(object).isNewEntry) {
    686688                        m_parseErrorMessage = ASCIILiteral("Attempted to redefine __proto__ property");
     
    694696                        object->putDirectIndex(m_exec, index.value(), lastValue);
    695697                    else
    696                         object->putDirect(m_exec->vm(), ident, lastValue);                   
     698                        object->putDirect(vm, ident, lastValue);
    697699                }
    698700                identifierStack.removeLast();
  • trunk/Source/JavaScriptCore/runtime/MapConstructor.cpp

    r205520 r205569  
    7272
    7373    JSValue adderFunction = map->JSObject::get(exec, exec->propertyNames().set);
    74     if (exec->hadException())
     74    if (UNLIKELY(scope.exception()))
    7575        return JSValue::encode(jsUndefined());
    7676
     
    8181
    8282    forEachInIterable(exec, iterable, [&](VM& vm, ExecState* exec, JSValue nextItem) {
     83        auto scope = DECLARE_THROW_SCOPE(vm);
    8384        if (!nextItem.isObject()) {
    8485            throwTypeError(exec, scope);
     
    8788
    8889        JSValue key = nextItem.get(exec, static_cast<unsigned>(0));
    89         if (vm.exception())
     90        if (UNLIKELY(scope.exception()))
    9091            return;
    9192
    9293        JSValue value = nextItem.get(exec, static_cast<unsigned>(1));
    93         if (vm.exception())
     94        if (UNLIKELY(scope.exception()))
    9495            return;
    9596
  • trunk/Source/JavaScriptCore/runtime/MathObject.cpp

    r204466 r205569  
    163163EncodedJSValue JSC_HOST_CALL mathProtoFuncClz32(ExecState* exec)
    164164{
     165    VM& vm = exec->vm();
     166    auto scope = DECLARE_THROW_SCOPE(vm);
    165167    uint32_t value = exec->argument(0).toUInt32(exec);
    166     if (exec->hadException())
     168    if (UNLIKELY(scope.exception()))
    167169        return JSValue::encode(jsNull());
    168170    return JSValue::encode(JSValue(clz32(value)));
     
    186188EncodedJSValue JSC_HOST_CALL mathProtoFuncHypot(ExecState* exec)
    187189{
     190    VM& vm = exec->vm();
     191    auto scope = DECLARE_THROW_SCOPE(vm);
    188192    unsigned argsCount = exec->argumentCount();
    189193    double max = 0;
     
    192196    for (unsigned i = 0; i < argsCount; ++i) {
    193197        args.uncheckedAppend(exec->uncheckedArgument(i).toNumber(exec));
    194         if (exec->hadException())
     198        if (UNLIKELY(scope.exception()))
    195199            return JSValue::encode(jsNull());
    196200        if (std::isinf(args[i]))
     
    293297EncodedJSValue JSC_HOST_CALL mathProtoFuncIMul(ExecState* exec)
    294298{
     299    VM& vm = exec->vm();
     300    auto scope = DECLARE_THROW_SCOPE(vm);
    295301    int32_t left = exec->argument(0).toInt32(exec);
    296     if (exec->hadException())
     302    if (UNLIKELY(scope.exception()))
    297303        return JSValue::encode(jsNull());
    298304    int32_t right = exec->argument(1).toInt32(exec);
  • trunk/Source/JavaScriptCore/runtime/ModuleLoaderPrototype.cpp

    r205278 r205569  
    113113
    114114    const Identifier moduleKey = exec->argument(0).toPropertyKey(exec);
    115     if (exec->hadException())
     115    if (UNLIKELY(scope.exception()))
    116116        return JSValue::encode(jsUndefined());
    117117
    118118    String source = exec->argument(1).toString(exec)->value(exec);
    119     if (exec->hadException())
     119    if (UNLIKELY(scope.exception()))
    120120        return JSValue::encode(jsUndefined());
    121121
     
    143143EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeRequestedModules(ExecState* exec)
    144144{
     145    VM& vm = exec->vm();
     146    auto scope = DECLARE_THROW_SCOPE(vm);
    145147    JSModuleRecord* moduleRecord = jsDynamicCast<JSModuleRecord*>(exec->argument(0));
    146148    if (!moduleRecord)
     
    148150
    149151    JSArray* result = constructEmptyArray(exec, nullptr, moduleRecord->requestedModules().size());
    150     if (UNLIKELY(exec->hadException()))
     152    if (UNLIKELY(scope.exception()))
    151153        JSValue::encode(jsUndefined());
    152154    size_t i = 0;
     
    159161EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeModuleDeclarationInstantiation(ExecState* exec)
    160162{
     163    VM& vm = exec->vm();
     164    auto scope = DECLARE_THROW_SCOPE(vm);
    161165    JSModuleRecord* moduleRecord = jsDynamicCast<JSModuleRecord*>(exec->argument(0));
    162166    if (!moduleRecord)
     
    167171
    168172    moduleRecord->link(exec);
    169     if (exec->hadException())
     173    if (UNLIKELY(scope.exception()))
    170174        return JSValue::encode(jsUndefined());
    171175
  • trunk/Source/JavaScriptCore/runtime/NativeErrorConstructor.cpp

    r205462 r205569  
    6464EncodedJSValue JSC_HOST_CALL Interpreter::constructWithNativeErrorConstructor(ExecState* exec)
    6565{
     66    VM& vm = exec->vm();
     67    auto scope = DECLARE_THROW_SCOPE(vm);
    6668    JSValue message = exec->argument(0);
    6769    Structure* errorStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), jsCast<NativeErrorConstructor*>(exec->callee())->errorStructure());
    68     if (exec->hadException())
     70    if (UNLIKELY(scope.exception()))
    6971        return JSValue::encode(JSValue());
    7072    ASSERT(errorStructure);
  • trunk/Source/JavaScriptCore/runtime/NumberConstructor.cpp

    r202680 r205569  
    8686static EncodedJSValue JSC_HOST_CALL constructWithNumberConstructor(ExecState* exec)
    8787{
     88    VM& vm = exec->vm();
     89    auto scope = DECLARE_THROW_SCOPE(vm);
    8890    double n = exec->argumentCount() ? exec->uncheckedArgument(0).toNumber(exec) : 0;
    8991    Structure* structure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), exec->lexicalGlobalObject()->numberObjectStructure());
    90     if (exec->hadException())
     92    if (UNLIKELY(scope.exception()))
    9193        return JSValue::encode(JSValue());
    9294
  • trunk/Source/JavaScriptCore/runtime/ObjectConstructor.cpp

    r205372 r205569  
    122122    ObjectConstructor* objectConstructor = jsCast<ObjectConstructor*>(exec->callee());
    123123    JSGlobalObject* globalObject = objectConstructor->globalObject();
     124    VM& vm = globalObject->vm();
     125    auto scope = DECLARE_THROW_SCOPE(vm);
    124126
    125127    // We need to check newTarget condition in this caller side instead of InternalFunction::createSubclassStructure side.
     
    130132        // a. Return ? OrdinaryCreateFromConstructor(NewTarget, "%ObjectPrototype%").
    131133        Structure* objectStructure = InternalFunction::createSubclassStructure(exec, newTarget, globalObject->objectStructureForObjectConstructor());
    132         if (exec->hadException())
     134        if (UNLIKELY(scope.exception()))
    133135            return nullptr;
    134136        return constructEmptyObject(exec, objectStructure);
     
    212214EncodedJSValue JSC_HOST_CALL objectConstructorGetPrototypeOf(ExecState* exec)
    213215{
     216    VM& vm = exec->vm();
     217    auto scope = DECLARE_THROW_SCOPE(vm);
    214218    JSObject* object = exec->argument(0).toObject(exec);
    215     if (exec->hadException())
     219    if (UNLIKELY(scope.exception()))
    216220        return JSValue::encode(jsUndefined());
    217221    return JSValue::encode(objectConstructorGetPrototypeOf(exec, object));
     
    232236
    233237    JSObject* object = objectValue.toObject(exec);
    234     if (exec->hadException())
     238    if (UNLIKELY(scope.exception()))
    235239        return JSValue::encode(objectValue);
    236240
     
    242246    bool shouldThrowIfCantSet = true;
    243247    bool didSetPrototype = object->setPrototype(vm, exec, protoValue, shouldThrowIfCantSet);
    244     ASSERT_UNUSED(didSetPrototype, vm.exception() || didSetPrototype);
     248    ASSERT_UNUSED(didSetPrototype, scope.exception() || didSetPrototype);
    245249    return JSValue::encode(objectValue);
    246250}
     
    248252JSValue objectConstructorGetOwnPropertyDescriptor(ExecState* exec, JSObject* object, const Identifier& propertyName)
    249253{
     254    VM& vm = exec->vm();
     255    auto scope = DECLARE_THROW_SCOPE(vm);
    250256    PropertyDescriptor descriptor;
    251257    if (!object->getOwnPropertyDescriptor(exec, propertyName, descriptor))
    252258        return jsUndefined();
    253     if (exec->hadException())
     259    if (UNLIKELY(scope.exception()))
    254260        return jsUndefined();
    255261
     
    262268JSValue objectConstructorGetOwnPropertyDescriptors(ExecState* exec, JSObject* object)
    263269{
     270    VM& vm = exec->vm();
     271    auto scope = DECLARE_THROW_SCOPE(vm);
    264272    PropertyNameArray properties(exec, PropertyNameMode::StringsAndSymbols);
    265     object->methodTable(exec->vm())->getOwnPropertyNames(object, exec, properties, EnumerationMode(DontEnumPropertiesMode::Include));
    266     if (exec->hadException())
     273    object->methodTable(vm)->getOwnPropertyNames(object, exec, properties, EnumerationMode(DontEnumPropertiesMode::Include));
     274    if (UNLIKELY(scope.exception()))
    267275        return jsUndefined();
    268276
    269277    JSObject* descriptors = constructEmptyObject(exec);
    270     if (exec->hadException())
     278    if (UNLIKELY(scope.exception()))
    271279        return jsUndefined();
    272280
     
    274282        PropertyDescriptor descriptor;
    275283        bool didGetDescriptor = object->getOwnPropertyDescriptor(exec, propertyName, descriptor);
    276         if (exec->hadException())
     284        if (UNLIKELY(scope.exception()))
    277285            return jsUndefined();
    278286
     
    286294        PutPropertySlot slot(descriptors);
    287295        descriptors->putOwnDataPropertyMayBeIndex(exec, propertyName, fromDescriptor, slot);
    288         ASSERT(!exec->hadException());
     296        ASSERT(!scope.exception());
    289297    }
    290298
     
    294302EncodedJSValue JSC_HOST_CALL objectConstructorGetOwnPropertyDescriptor(ExecState* exec)
    295303{
     304    VM& vm = exec->vm();
     305    auto scope = DECLARE_THROW_SCOPE(vm);
    296306    JSObject* object = exec->argument(0).toObject(exec);
    297     if (exec->hadException())
     307    if (UNLIKELY(scope.exception()))
    298308        return JSValue::encode(jsUndefined());
    299309    auto propertyName = exec->argument(1).toPropertyKey(exec);
    300     if (exec->hadException())
     310    if (UNLIKELY(scope.exception()))
    301311        return JSValue::encode(jsUndefined());
    302312    return JSValue::encode(objectConstructorGetOwnPropertyDescriptor(exec, object, propertyName));
     
    305315EncodedJSValue JSC_HOST_CALL objectConstructorGetOwnPropertyDescriptors(ExecState* exec)
    306316{
     317    VM& vm = exec->vm();
     318    auto scope = DECLARE_THROW_SCOPE(vm);
    307319    JSObject* object = exec->argument(0).toObject(exec);
    308     if (exec->hadException())
     320    if (UNLIKELY(scope.exception()))
    309321        return JSValue::encode(jsUndefined());
    310322    return JSValue::encode(objectConstructorGetOwnPropertyDescriptors(exec, object));
     
    314326EncodedJSValue JSC_HOST_CALL objectConstructorGetOwnPropertyNames(ExecState* exec)
    315327{
     328    VM& vm = exec->vm();
     329    auto scope = DECLARE_THROW_SCOPE(vm);
    316330    JSObject* object = exec->argument(0).toObject(exec);
    317     if (exec->hadException())
     331    if (UNLIKELY(scope.exception()))
    318332        return JSValue::encode(jsNull());
    319333    return JSValue::encode(ownPropertyKeys(exec, object, PropertyNameMode::Strings, DontEnumPropertiesMode::Include));
     
    323337EncodedJSValue JSC_HOST_CALL objectConstructorGetOwnPropertySymbols(ExecState* exec)
    324338{
     339    VM& vm = exec->vm();
     340    auto scope = DECLARE_THROW_SCOPE(vm);
    325341    JSObject* object = exec->argument(0).toObject(exec);
    326     if (exec->hadException())
     342    if (UNLIKELY(scope.exception()))
    327343        return JSValue::encode(jsNull());
    328344    return JSValue::encode(ownPropertyKeys(exec, object, PropertyNameMode::Symbols, DontEnumPropertiesMode::Include));
     
    332348EncodedJSValue JSC_HOST_CALL objectConstructorKeys(ExecState* exec)
    333349{
     350    VM& vm = exec->vm();
     351    auto scope = DECLARE_THROW_SCOPE(vm);
    334352    JSObject* object = exec->argument(0).toObject(exec);
    335     if (exec->hadException())
     353    if (UNLIKELY(scope.exception()))
    336354        return JSValue::encode(jsNull());
    337355    return JSValue::encode(ownPropertyKeys(exec, object, PropertyNameMode::Strings, DontEnumPropertiesMode::Exclude));
     
    340358EncodedJSValue JSC_HOST_CALL ownEnumerablePropertyKeys(ExecState* exec)
    341359{
     360    VM& vm = exec->vm();
     361    auto scope = DECLARE_THROW_SCOPE(vm);
    342362    JSObject* object = exec->argument(0).toObject(exec);
    343     if (exec->hadException())
     363    if (UNLIKELY(scope.exception()))
    344364        return JSValue::encode(jsNull());
    345365    return JSValue::encode(ownPropertyKeys(exec, object, PropertyNameMode::StringsAndSymbols, DontEnumPropertiesMode::Exclude));
     
    361381    if (description->hasProperty(exec, exec->propertyNames().enumerable)) {
    362382        JSValue value = description->get(exec, exec->propertyNames().enumerable);
    363         if (vm.exception())
     383        if (UNLIKELY(scope.exception()))
    364384            return false;
    365385        desc.setEnumerable(value.toBoolean(exec));
    366     } else if (vm.exception())
     386    } else if (UNLIKELY(scope.exception()))
    367387        return false;
    368388
    369389    if (description->hasProperty(exec, exec->propertyNames().configurable)) {
    370390        JSValue value = description->get(exec, exec->propertyNames().configurable);
    371         if (vm.exception())
     391        if (UNLIKELY(scope.exception()))
    372392            return false;
    373393        desc.setConfigurable(value.toBoolean(exec));
    374     } else if (vm.exception())
     394    } else if (UNLIKELY(scope.exception()))
    375395        return false;
    376396
     
    378398    if (description->hasProperty(exec, exec->propertyNames().value)) {
    379399        JSValue value = description->get(exec, exec->propertyNames().value);
    380         if (vm.exception())
     400        if (UNLIKELY(scope.exception()))
    381401            return false;
    382402        desc.setValue(value);
    383     } else if (vm.exception())
     403    } else if (UNLIKELY(scope.exception()))
    384404        return false;
    385405
    386406    if (description->hasProperty(exec, exec->propertyNames().writable)) {
    387407        JSValue value = description->get(exec, exec->propertyNames().writable);
    388         if (vm.exception())
     408        if (UNLIKELY(scope.exception()))
    389409            return false;
    390410        desc.setWritable(value.toBoolean(exec));
    391     } else if (vm.exception())
     411    } else if (UNLIKELY(scope.exception()))
    392412        return false;
    393413
    394414    if (description->hasProperty(exec, exec->propertyNames().get)) {
    395415        JSValue get = description->get(exec, exec->propertyNames().get);
    396         if (vm.exception())
     416        if (UNLIKELY(scope.exception()))
    397417            return false;
    398418        if (!get.isUndefined()) {
     
    404424        }
    405425        desc.setGetter(get);
    406     } else if (vm.exception())
     426    } else if (UNLIKELY(scope.exception()))
    407427        return false;
    408428
    409429    if (description->hasProperty(exec, exec->propertyNames().set)) {
    410430        JSValue set = description->get(exec, exec->propertyNames().set);
    411         if (vm.exception())
     431        if (UNLIKELY(scope.exception()))
    412432            return false;
    413433        if (!set.isUndefined()) {
     
    419439        }
    420440        desc.setSetter(set);
    421     } else if (vm.exception())
     441    } else if (UNLIKELY(scope.exception()))
    422442        return false;
    423443
     
    446466    JSObject* obj = asObject(exec->argument(0));
    447467    auto propertyName = exec->argument(1).toPropertyKey(exec);
    448     if (exec->hadException())
     468    if (UNLIKELY(scope.exception()))
    449469        return JSValue::encode(jsNull());
    450470    PropertyDescriptor descriptor;
     
    454474        return JSValue::encode(jsNull());
    455475    ASSERT((descriptor.attributes() & Accessor) || (!descriptor.isAccessorDescriptor()));
    456     ASSERT(!exec->hadException());
     476    ASSERT(!scope.exception());
    457477    obj->methodTable(vm)->defineOwnProperty(obj, exec, propertyName, descriptor, true);
    458478    scope.release();
     
    462482static JSValue defineProperties(ExecState* exec, JSObject* object, JSObject* properties)
    463483{
     484    VM& vm = exec->vm();
     485    auto scope = DECLARE_THROW_SCOPE(vm);
     486
    464487    PropertyNameArray propertyNames(exec, PropertyNameMode::StringsAndSymbols);
    465     asObject(properties)->methodTable(exec->vm())->getOwnPropertyNames(asObject(properties), exec, propertyNames, EnumerationMode(DontEnumPropertiesMode::Exclude));
    466     if (UNLIKELY(exec->hadException()))
     488    asObject(properties)->methodTable(vm)->getOwnPropertyNames(asObject(properties), exec, propertyNames, EnumerationMode(DontEnumPropertiesMode::Exclude));
     489    if (UNLIKELY(scope.exception()))
    467490        return jsNull();
    468491    size_t numProperties = propertyNames.size();
     
    471494    for (size_t i = 0; i < numProperties; i++) {
    472495        JSValue prop = properties->get(exec, propertyNames[i]);
    473         if (exec->hadException())
     496        if (UNLIKELY(scope.exception()))
    474497            return jsNull();
    475498        PropertyDescriptor descriptor;
     
    491514        if (exec->propertyNames().isPrivateName(propertyName))
    492515            continue;
    493         object->methodTable(exec->vm())->defineOwnProperty(object, exec, propertyName, descriptors[i], true);
    494         if (exec->hadException())
     516        object->methodTable(vm)->defineOwnProperty(object, exec, propertyName, descriptors[i], true);
     517        if (UNLIKELY(scope.exception()))
    495518            return jsNull();
    496519    }
     
    532555EncodedJSValue JSC_HOST_CALL objectConstructorSeal(ExecState* exec)
    533556{
     557    VM& vm = exec->vm();
     558    auto scope = DECLARE_THROW_SCOPE(vm);
     559
    534560    // 1. If Type(O) is not Object, return O.
    535561    JSValue obj = exec->argument(0);
     
    539565
    540566    if (isJSFinalObject(object)) {
    541         object->seal(exec->vm());
     567        object->seal(vm);
    542568        return JSValue::encode(obj);
    543569    }
     
    545571    // 2. For each named own property name P of O,
    546572    PropertyNameArray properties(exec, PropertyNameMode::StringsAndSymbols);
    547     object->methodTable(exec->vm())->getOwnPropertyNames(object, exec, properties, EnumerationMode(DontEnumPropertiesMode::Include));
    548     if (UNLIKELY(exec->hadException()))
     573    object->methodTable(vm)->getOwnPropertyNames(object, exec, properties, EnumerationMode(DontEnumPropertiesMode::Include));
     574    if (UNLIKELY(scope.exception()))
    549575        return JSValue::encode(obj);
    550576    PropertyNameArray::const_iterator end = properties.end();
     
    560586        desc.setConfigurable(false);
    561587        // c. Call the [[DefineOwnProperty]] internal method of O with P, desc, and true as arguments.
    562         object->methodTable(exec->vm())->defineOwnProperty(object, exec, propertyName, desc, true);
    563         if (exec->hadException())
     588        object->methodTable(vm)->defineOwnProperty(object, exec, propertyName, desc, true);
     589        if (UNLIKELY(scope.exception()))
    564590            return JSValue::encode(obj);
    565591    }
    566592
    567593    // 3. Set the [[Extensible]] internal property of O to false.
    568     object->methodTable(exec->vm())->preventExtensions(object, exec);
    569     if (exec->hadException())
     594    object->methodTable(vm)->preventExtensions(object, exec);
     595    if (UNLIKELY(scope.exception()))
    570596        return JSValue::encode(JSValue());
    571597
     
    576602JSObject* objectConstructorFreeze(ExecState* exec, JSObject* object)
    577603{
     604    VM& vm = exec->vm();
     605    auto scope = DECLARE_THROW_SCOPE(vm);
     606
    578607    if (isJSFinalObject(object) && !hasIndexedProperties(object->indexingType())) {
    579         object->freeze(exec->vm());
     608        object->freeze(vm);
    580609        return object;
    581610    }
     
    583612    // 2. For each named own property name P of O,
    584613    PropertyNameArray properties(exec, PropertyNameMode::StringsAndSymbols);
    585     object->methodTable(exec->vm())->getOwnPropertyNames(object, exec, properties, EnumerationMode(DontEnumPropertiesMode::Include));
    586     if (UNLIKELY(exec->hadException()))
     614    object->methodTable(vm)->getOwnPropertyNames(object, exec, properties, EnumerationMode(DontEnumPropertiesMode::Include));
     615    if (UNLIKELY(scope.exception()))
    587616        return object;
    588617    PropertyNameArray::const_iterator end = properties.end();
     
    602631        desc.setConfigurable(false);
    603632        // d. Call the [[DefineOwnProperty]] internal method of O with P, desc, and true as arguments.
    604         object->methodTable(exec->vm())->defineOwnProperty(object, exec, propertyName, desc, true);
    605         if (exec->hadException())
     633        object->methodTable(vm)->defineOwnProperty(object, exec, propertyName, desc, true);
     634        if (UNLIKELY(scope.exception()))
    606635            return object;
    607636    }
    608637
    609638    // 3. Set the [[Extensible]] internal property of O to false.
    610     object->methodTable(exec->vm())->preventExtensions(object, exec);
    611     if (exec->hadException())
     639    object->methodTable(vm)->preventExtensions(object, exec);
     640    if (UNLIKELY(scope.exception()))
    612641        return nullptr;
    613642
     
    618647EncodedJSValue JSC_HOST_CALL objectConstructorFreeze(ExecState* exec)
    619648{
     649    VM& vm = exec->vm();
     650    auto scope = DECLARE_THROW_SCOPE(vm);
    620651    // 1. If Type(O) is not Object, return O.
    621652    JSValue obj = exec->argument(0);
     
    623654        return JSValue::encode(obj);
    624655    JSObject* result = objectConstructorFreeze(exec, asObject(obj));
    625     if (exec->hadException())
     656    if (UNLIKELY(scope.exception()))
    626657        return JSValue::encode(JSValue());
    627658    return JSValue::encode(result);
     
    640671EncodedJSValue JSC_HOST_CALL objectConstructorIsSealed(ExecState* exec)
    641672{
     673    VM& vm = exec->vm();
     674    auto scope = DECLARE_THROW_SCOPE(vm);
     675
    642676    // 1. If Type(O) is not Object, return true.
    643677    JSValue obj = exec->argument(0);
     
    647681
    648682    if (isJSFinalObject(object))
    649         return JSValue::encode(jsBoolean(object->isSealed(exec->vm())));
     683        return JSValue::encode(jsBoolean(object->isSealed(vm)));
    650684
    651685    // 2. For each named own property name P of O,
    652686    PropertyNameArray properties(exec, PropertyNameMode::StringsAndSymbols);
    653     object->methodTable(exec->vm())->getOwnPropertyNames(object, exec, properties, EnumerationMode(DontEnumPropertiesMode::Include));
    654     if (UNLIKELY(exec->hadException()))
     687    object->methodTable(vm)->getOwnPropertyNames(object, exec, properties, EnumerationMode(DontEnumPropertiesMode::Include));
     688    if (UNLIKELY(scope.exception()))
    655689        return JSValue::encode(JSValue());
    656690    PropertyNameArray::const_iterator end = properties.end();
     
    671705    // 4. Otherwise, return false.
    672706    bool isExtensible = object->isExtensible(exec);
    673     if (exec->hadException())
     707    if (UNLIKELY(scope.exception()))
    674708        return JSValue::encode(JSValue());
    675709    return JSValue::encode(jsBoolean(!isExtensible));
     
    678712EncodedJSValue JSC_HOST_CALL objectConstructorIsFrozen(ExecState* exec)
    679713{
     714    VM& vm = exec->vm();
     715    auto scope = DECLARE_THROW_SCOPE(vm);
     716
    680717    // 1. If Type(O) is not Object, return true.
    681718    JSValue obj = exec->argument(0);
     
    685722
    686723    if (isJSFinalObject(object))
    687         return JSValue::encode(jsBoolean(object->isFrozen(exec->vm())));
     724        return JSValue::encode(jsBoolean(object->isFrozen(vm)));
    688725
    689726    // 2. For each named own property name P of O,
    690727    PropertyNameArray properties(exec, PropertyNameMode::StringsAndSymbols);
    691     object->methodTable(exec->vm())->getOwnPropertyNames(object, exec, properties, EnumerationMode(DontEnumPropertiesMode::Include));
    692     if (UNLIKELY(exec->hadException()))
     728    object->methodTable(vm)->getOwnPropertyNames(object, exec, properties, EnumerationMode(DontEnumPropertiesMode::Include));
     729    if (UNLIKELY(scope.exception()))
    693730        return JSValue::encode(JSValue());
    694731    PropertyNameArray::const_iterator end = properties.end();
     
    710747    // 4. Otherwise, return false.
    711748    bool isExtensible = object->isExtensible(exec);
    712     if (exec->hadException())
     749    if (UNLIKELY(scope.exception()))
    713750        return JSValue::encode(JSValue());
    714751    return JSValue::encode(jsBoolean(!isExtensible));
     
    717754EncodedJSValue JSC_HOST_CALL objectConstructorIsExtensible(ExecState* exec)
    718755{
     756    VM& vm = exec->vm();
     757    auto scope = DECLARE_THROW_SCOPE(vm);
    719758    JSValue obj = exec->argument(0);
    720759    if (!obj.isObject())
     
    722761    JSObject* object = asObject(obj);
    723762    bool isExtensible = object->isExtensible(exec);
    724     if (exec->hadException())
     763    if (UNLIKELY(scope.exception()))
    725764        return JSValue::encode(JSValue());
    726765    return JSValue::encode(jsBoolean(isExtensible));
     
    736775{
    737776    VM& vm = exec->vm();
     777    auto scope = DECLARE_THROW_SCOPE(vm);
    738778    PropertyNameArray properties(exec, propertyNameMode);
    739779    object->methodTable(vm)->getOwnPropertyNames(object, exec, properties, EnumerationMode(dontEnumPropertiesMode));
    740     if (UNLIKELY(vm.exception()))
     780    if (UNLIKELY(scope.exception()))
    741781        return nullptr;
    742782
    743783    JSArray* keys = constructEmptyArray(exec, 0);
    744     if (UNLIKELY(vm.exception()))
     784    if (UNLIKELY(scope.exception()))
    745785        return nullptr;
    746786
  • trunk/Source/JavaScriptCore/runtime/ObjectConstructor.h

    r205372 r205569  
    102102{
    103103    VM& vm = exec->vm();
     104    auto scope = DECLARE_THROW_SCOPE(vm);
    104105    JSObject* description = constructEmptyObject(exec);
    105     if (vm.exception())
     106    if (UNLIKELY(scope.exception()))
    106107        return nullptr;
    107108
  • trunk/Source/JavaScriptCore/runtime/ObjectPrototype.cpp

    r205198 r205569  
    9090EncodedJSValue JSC_HOST_CALL objectProtoFuncHasOwnProperty(ExecState* exec)
    9191{
     92    VM& vm = exec->vm();
     93    auto scope = DECLARE_THROW_SCOPE(vm);
     94
    9295    JSValue thisValue = exec->thisValue().toThis(exec, StrictMode);
    9396    auto propertyName = exec->argument(0).toPropertyKey(exec);
    94     if (exec->hadException())
     97    if (UNLIKELY(scope.exception()))
    9598        return JSValue::encode(jsUndefined());
    9699    JSObject* thisObject = thisValue.toObject(exec);
     
    102105EncodedJSValue JSC_HOST_CALL objectProtoFuncIsPrototypeOf(ExecState* exec)
    103106{
     107    VM& vm = exec->vm();
     108    auto scope = DECLARE_THROW_SCOPE(vm);
     109
    104110    JSValue thisValue = exec->thisValue().toThis(exec, StrictMode);
    105111    JSObject* thisObj = thisValue.toObject(exec);
     
    110116        return JSValue::encode(jsBoolean(false));
    111117
    112     VM& vm = exec->vm();
    113118    JSValue v = asObject(exec->argument(0))->getPrototype(vm, exec);
    114     if (UNLIKELY(vm.exception()))
     119    if (UNLIKELY(scope.exception()))
    115120        return JSValue::encode(JSValue());
    116121
     
    121126            return JSValue::encode(jsBoolean(true));
    122127        v = asObject(v)->getPrototype(vm, exec);
    123         if (UNLIKELY(vm.exception()))
     128        if (UNLIKELY(scope.exception()))
    124129            return JSValue::encode(JSValue());
    125130    }
     
    132137
    133138    JSObject* thisObject = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
    134     if (exec->hadException())
     139    if (UNLIKELY(scope.exception()))
    135140        return JSValue::encode(jsUndefined());
    136141
     
    141146
    142147    auto propertyName = exec->argument(0).toPropertyKey(exec);
    143     if (exec->hadException())
     148    if (UNLIKELY(scope.exception()))
    144149        return JSValue::encode(jsUndefined());
    145150
     
    161166
    162167    JSObject* thisObject = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
    163     if (exec->hadException())
     168    if (UNLIKELY(scope.exception()))
    164169        return JSValue::encode(jsUndefined());
    165170
     
    170175
    171176    auto propertyName = exec->argument(0).toPropertyKey(exec);
    172     if (exec->hadException())
     177    if (UNLIKELY(scope.exception()))
    173178        return JSValue::encode(jsUndefined());
    174179
     
    186191EncodedJSValue JSC_HOST_CALL objectProtoFuncLookupGetter(ExecState* exec)
    187192{
    188     JSObject* thisObject = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
    189     if (exec->hadException())
    190         return JSValue::encode(jsUndefined());
    191 
    192     auto propertyName = exec->argument(0).toPropertyKey(exec);
    193     if (exec->hadException())
     193    VM& vm = exec->vm();
     194    auto scope = DECLARE_THROW_SCOPE(vm);
     195
     196    JSObject* thisObject = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
     197    if (UNLIKELY(scope.exception()))
     198        return JSValue::encode(jsUndefined());
     199
     200    auto propertyName = exec->argument(0).toPropertyKey(exec);
     201    if (UNLIKELY(scope.exception()))
    194202        return JSValue::encode(jsUndefined());
    195203
     
    213221EncodedJSValue JSC_HOST_CALL objectProtoFuncLookupSetter(ExecState* exec)
    214222{
    215     JSObject* thisObject = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
    216     if (exec->hadException())
    217         return JSValue::encode(jsUndefined());
    218 
    219     auto propertyName = exec->argument(0).toPropertyKey(exec);
    220     if (exec->hadException())
     223    VM& vm = exec->vm();
     224    auto scope = DECLARE_THROW_SCOPE(vm);
     225
     226    JSObject* thisObject = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
     227    if (UNLIKELY(scope.exception()))
     228        return JSValue::encode(jsUndefined());
     229
     230    auto propertyName = exec->argument(0).toPropertyKey(exec);
     231    if (UNLIKELY(scope.exception()))
    221232        return JSValue::encode(jsUndefined());
    222233
     
    240251EncodedJSValue JSC_HOST_CALL objectProtoFuncPropertyIsEnumerable(ExecState* exec)
    241252{
    242     auto propertyName = exec->argument(0).toPropertyKey(exec);
    243     if (exec->hadException())
    244         return JSValue::encode(jsUndefined());
    245 
    246     JSObject* thisObject = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
    247     if (exec->hadException())
     253    VM& vm = exec->vm();
     254    auto scope = DECLARE_THROW_SCOPE(vm);
     255
     256    auto propertyName = exec->argument(0).toPropertyKey(exec);
     257    if (UNLIKELY(scope.exception()))
     258        return JSValue::encode(jsUndefined());
     259
     260    JSObject* thisObject = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
     261    if (UNLIKELY(scope.exception()))
    248262        return JSValue::encode(jsUndefined());
    249263    PropertyDescriptor descriptor;
     
    255269EncodedJSValue JSC_HOST_CALL objectProtoFuncToLocaleString(ExecState* exec)
    256270{
     271    VM& vm = exec->vm();
     272    auto scope = DECLARE_THROW_SCOPE(vm);
     273
    257274    // 1. Let O be the result of calling ToObject passing the this value as the argument.
    258275    JSObject* object = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
    259     if (exec->hadException())
     276    if (UNLIKELY(scope.exception()))
    260277        return JSValue::encode(jsUndefined());
    261278
     
    293310        if (found) {
    294311            JSValue stringTag = toStringTagSlot.getValue(exec, toStringTagSymbol);
    295             if (UNLIKELY(vm.exception()))
     312            if (UNLIKELY(scope.exception()))
    296313                return jsUndefined();
    297314            if (stringTag.isString()) {
     
    308325
    309326        String tag = thisObject->methodTable(exec->vm())->toStringName(thisObject, exec);
    310         if (vm.exception())
     327        if (UNLIKELY(scope.exception()))
    311328            return JSValue();
    312329        String newString = WTF::tryMakeString("[object ", WTFMove(tag), "]");
  • trunk/Source/JavaScriptCore/runtime/Operations.cpp

    r204206 r205569  
    11/*
    22 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
    3  * Copyright (C) 2008 Apple Inc. All Rights Reserved.
     3 * Copyright (C) 2008, 2016 Apple Inc. All Rights Reserved.
    44 *
    55 *  This library is free software; you can redistribute it and/or
     
    4545    // exception for the Date exception in defaultValue()
    4646    VM& vm = callFrame->vm();
     47    auto scope = DECLARE_THROW_SCOPE(vm);
    4748    JSValue p1 = v1.toPrimitive(callFrame);
    48     if (UNLIKELY(vm.exception()))
     49    if (UNLIKELY(scope.exception()))
    4950        return JSValue();
    5051    JSValue p2 = v2.toPrimitive(callFrame);
    51     if (UNLIKELY(vm.exception()))
     52    if (UNLIKELY(scope.exception()))
    5253        return JSValue();
    5354
  • trunk/Source/JavaScriptCore/runtime/Options.h

    r205462 r205569  
    347347    v(unsigned, fireExceptionFuzzAt, 0, Normal, nullptr) \
    348348    v(bool, validateDFGExceptionHandling, false, Normal, "Causes the DFG to emit code validating exception handling for each node that can exit") /* This is true by default on Debug builds */\
     349    v(bool, dumpSimulatedThrows, false, Normal, "Dumps the call stack at each simulated throw for exception scope verification") \
    349350    \
    350351    v(bool, useExecutableAllocationFuzz, false, Normal, nullptr) \
  • trunk/Source/JavaScriptCore/runtime/PropertyDescriptor.cpp

    r205520 r205569  
    7676{
    7777    VM& vm = exec->vm();
     78    auto scope = DECLARE_THROW_SCOPE(vm);
     79
    7880    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
    7981    GetterSetter* getterSetter = GetterSetter::create(vm, globalObject);
    80     if (exec->hadException())
     82    if (UNLIKELY(scope.exception()))
    8183        return nullptr;
    8284    if (m_getter && !m_getter.isUndefined())
  • trunk/Source/JavaScriptCore/runtime/ProxyConstructor.cpp

    r205462 r205569  
    5656static EncodedJSValue JSC_HOST_CALL makeRevocableProxy(ExecState* exec)
    5757{
    58     auto scope = DECLARE_THROW_SCOPE(exec->vm());
     58    VM& vm = exec->vm();
     59    auto scope = DECLARE_THROW_SCOPE(vm);
    5960    if (exec->argumentCount() < 2)
    6061        return throwVMTypeError(exec, scope, ASCIILiteral("Proxy.revocable needs to be called with two arguments: the target and the handler"));
    6162
    62     VM& vm = exec->vm();
    6363    ArgList args(exec);
    6464    JSValue target = args.at(0);
    6565    JSValue handler = args.at(1);
    6666    ProxyObject* proxy = ProxyObject::create(exec, exec->lexicalGlobalObject(), target, handler);
    67     if (vm.exception())
     67    if (UNLIKELY(scope.exception()))
    6868        return JSValue::encode(JSValue());
    6969    ProxyRevoke* revoke = ProxyRevoke::create(vm, exec->lexicalGlobalObject()->proxyRevokeStructure(), proxy);
    70     if (vm.exception())
     70    if (UNLIKELY(scope.exception()))
    7171        return JSValue::encode(JSValue());
    7272
    7373    JSObject* result = constructEmptyObject(exec);
    74     if (vm.exception())
     74    if (UNLIKELY(scope.exception()))
    7575        return JSValue::encode(JSValue());
    7676    result->putDirect(vm, makeIdentifier(vm, "proxy"), proxy, None);
  • trunk/Source/JavaScriptCore/runtime/ProxyObject.cpp

    r205535 r205569  
    5454{
    5555    VM& vm = exec->vm();
     56    auto scope = DECLARE_THROW_SCOPE(vm);
    5657    const ProxyObject* proxy = jsCast<const ProxyObject*>(object);
    5758    while (proxy) {
     
    5960        if (isArray(exec, target))
    6061            return target->classInfo()->methodTable.toStringName(target, exec);
    61         if (vm.exception())
     62        if (UNLIKELY(scope.exception()))
    6263            break;
    6364
     
    141142    CallType callType;
    142143    JSValue getHandler = handler->getMethod(exec, callData, callType, vm.propertyNames->get, ASCIILiteral("'get' property of a Proxy's handler object should be callable"));
    143     if (exec->hadException())
     144    if (UNLIKELY(scope.exception()))
    144145        return jsUndefined();
    145146
     
    152153    arguments.append(receiver);
    153154    JSValue trapResult = call(exec, getHandler, callType, callData, handler, arguments);
    154     if (exec->hadException())
     155    if (UNLIKELY(scope.exception()))
    155156        return jsUndefined();
    156157
     
    166167    }
    167168
    168     if (exec->hadException())
     169    if (UNLIKELY(scope.exception()))
    169170        return jsUndefined();
    170171
     
    174175bool ProxyObject::performGet(ExecState* exec, PropertyName propertyName, PropertySlot& slot)
    175176{
     177    VM& vm = exec->vm();
     178    auto scope = DECLARE_THROW_SCOPE(vm);
    176179    JSValue result = performProxyGet(exec, this, slot.thisValue(), propertyName);
    177     if (exec->hadException())
     180    if (UNLIKELY(scope.exception()))
    178181        return false;
    179182    unsigned ignoredAttributes = 0;
     
    209212    CallType callType;
    210213    JSValue getOwnPropertyDescriptorMethod = handler->getMethod(exec, callData, callType, makeIdentifier(vm, "getOwnPropertyDescriptor"), ASCIILiteral("'getOwnPropertyDescriptor' property of a Proxy's handler should be callable"));
    211     if (exec->hadException())
     214    if (UNLIKELY(scope.exception()))
    212215        return false;
    213216    if (getOwnPropertyDescriptorMethod.isUndefined())
     
    218221    arguments.append(identifierToSafePublicJSValue(vm, Identifier::fromUid(&vm, propertyName.uid())));
    219222    JSValue trapResult = call(exec, getOwnPropertyDescriptorMethod, callType, callData, handler, arguments);
    220     if (exec->hadException())
     223    if (UNLIKELY(scope.exception()))
    221224        return false;
    222225
     
    228231    PropertyDescriptor targetPropertyDescriptor;
    229232    bool isTargetPropertyDescriptorDefined = target->getOwnPropertyDescriptor(exec, propertyName, targetPropertyDescriptor);
    230     if (exec->hadException())
     233    if (UNLIKELY(scope.exception()))
    231234        return false;
    232235
     
    241244        // https://bugs.webkit.org/show_bug.cgi?id=154375
    242245        bool isExtensible = target->isExtensible(exec);
    243         if (exec->hadException())
     246        if (UNLIKELY(scope.exception()))
    244247            return false;
    245248        if (!isExtensible) {
     
    255258
    256259    bool isExtensible = target->isExtensible(exec);
    257     if (exec->hadException())
     260    if (UNLIKELY(scope.exception()))
    258261        return false;
    259262    PropertyDescriptor trapResultAsDescriptor;
    260263    toPropertyDescriptor(exec, trapResult, trapResultAsDescriptor);
    261     if (exec->hadException())
     264    if (UNLIKELY(scope.exception()))
    262265        return false;
    263266    bool throwException = false;
     
    278281    if (trapResultAsDescriptor.isAccessorDescriptor()) {
    279282        GetterSetter* getterSetter = trapResultAsDescriptor.slowGetterSetter(exec);
    280         if (exec->hadException())
     283        if (UNLIKELY(scope.exception()))
    281284            return false;
    282285        slot.setGetterSlot(this, trapResultAsDescriptor.attributes(), getterSetter);
     
    317320    CallType callType;
    318321    JSValue hasMethod = handler->getMethod(exec, callData, callType, vm.propertyNames->has, ASCIILiteral("'has' property of a Proxy's handler should be callable"));
    319     if (exec->hadException())
     322    if (UNLIKELY(scope.exception()))
    320323        return false;
    321324    if (hasMethod.isUndefined())
     
    326329    arguments.append(identifierToSafePublicJSValue(vm, Identifier::fromUid(&vm, propertyName.uid())));
    327330    JSValue trapResult = call(exec, hasMethod, callType, callData, handler, arguments);
    328     if (exec->hadException())
     331    if (UNLIKELY(scope.exception()))
    329332        return false;
    330333
    331334    bool trapResultAsBool = trapResult.toBoolean(exec);
    332     if (exec->hadException())
     335    if (UNLIKELY(scope.exception()))
    333336        return false;
    334337
     
    336339        PropertyDescriptor descriptor;
    337340        bool isPropertyDescriptorDefined = target->getOwnPropertyDescriptor(exec, propertyName, descriptor);
    338         if (exec->hadException())
     341        if (UNLIKELY(scope.exception()))
    339342            return false;
    340343        if (isPropertyDescriptorDefined) {
     
    344347            }
    345348            bool isExtensible = target->isExtensible(exec);
    346             if (exec->hadException())
     349            if (UNLIKELY(scope.exception()))
    347350                return false;
    348351            if (!isExtensible) {
     
    417420    CallType callType;
    418421    JSValue setMethod = handler->getMethod(exec, callData, callType, vm.propertyNames->set, ASCIILiteral("'set' property of a Proxy's handler should be callable"));
    419     if (exec->hadException())
     422    if (UNLIKELY(scope.exception()))
    420423        return false;
    421424    JSObject* target = this->target();
     
    429432    arguments.append(thisValue);
    430433    JSValue trapResult = call(exec, setMethod, callType, callData, handler, arguments);
    431     if (exec->hadException())
     434    if (UNLIKELY(scope.exception()))
    432435        return false;
    433436    bool trapResultAsBool = trapResult.toBoolean(exec);
    434     if (exec->hadException())
     437    if (UNLIKELY(scope.exception()))
    435438        return false;
    436439    if (!trapResultAsBool)
     
    468471{
    469472    VM& vm = exec->vm();
    470     Identifier ident = Identifier::from(exec, propertyName);
    471     if (exec->hadException())
     473    auto scope = DECLARE_THROW_SCOPE(vm);
     474    Identifier ident = Identifier::from(exec, propertyName);
     475    if (UNLIKELY(scope.exception()))
    472476        return false;
    473477    auto performDefaultPut = [&] () {
     
    503507    CallType callType;
    504508    JSValue applyMethod = handler->getMethod(exec, callData, callType, makeIdentifier(vm, "apply"), ASCIILiteral("'apply' property of a Proxy's handler should be callable"));
    505     if (exec->hadException())
     509    if (UNLIKELY(scope.exception()))
    506510        return JSValue::encode(jsUndefined());
    507511    JSObject* target = proxy->target();
     
    514518
    515519    JSArray* argArray = constructArray(exec, static_cast<ArrayAllocationProfile*>(nullptr), ArgList(exec));
    516     if (exec->hadException())
     520    if (UNLIKELY(scope.exception()))
    517521        return JSValue::encode(jsUndefined());
    518522    MarkedArgumentBuffer arguments;
     
    553557    CallType callType;
    554558    JSValue constructMethod = handler->getMethod(exec, callData, callType, makeIdentifier(vm, "construct"), ASCIILiteral("'construct' property of a Proxy's handler should be constructible"));
    555     if (exec->hadException())
     559    if (UNLIKELY(scope.exception()))
    556560        return JSValue::encode(jsUndefined());
    557561    JSObject* target = proxy->target();
     
    564568
    565569    JSArray* argArray = constructArray(exec, static_cast<ArrayAllocationProfile*>(nullptr), ArgList(exec));
    566     if (exec->hadException())
     570    if (UNLIKELY(scope.exception()))
    567571        return JSValue::encode(jsUndefined());
    568572    MarkedArgumentBuffer arguments;
     
    571575    arguments.append(exec->newTarget());
    572576    JSValue result = call(exec, constructMethod, callType, callData, handler, arguments);
    573     if (exec->hadException())
     577    if (UNLIKELY(scope.exception()))
    574578        return JSValue::encode(jsUndefined());
    575579    if (!result.isObject())
     
    614618    CallType callType;
    615619    JSValue deletePropertyMethod = handler->getMethod(exec, callData, callType, makeIdentifier(vm, "deleteProperty"), ASCIILiteral("'deleteProperty' property of a Proxy's handler should be callable"));
    616     if (exec->hadException())
     620    if (UNLIKELY(scope.exception()))
    617621        return false;
    618622    JSObject* target = this->target();
     
    624628    arguments.append(identifierToSafePublicJSValue(vm, Identifier::fromUid(&vm, propertyName.uid())));
    625629    JSValue trapResult = call(exec, deletePropertyMethod, callType, callData, handler, arguments);
    626     if (exec->hadException())
     630    if (UNLIKELY(scope.exception()))
    627631        return false;
    628632
    629633    bool trapResultAsBool = trapResult.toBoolean(exec);
    630     if (exec->hadException())
     634    if (UNLIKELY(scope.exception()))
    631635        return false;
    632636
     
    642646    }
    643647
    644     if (exec->hadException())
     648    if (UNLIKELY(scope.exception()))
    645649        return false;
    646650
     
    688692    CallType callType;
    689693    JSValue preventExtensionsMethod = handler->getMethod(exec, callData, callType, makeIdentifier(vm, "preventExtensions"), ASCIILiteral("'preventExtensions' property of a Proxy's handler should be callable"));
    690     if (exec->hadException())
     694    if (UNLIKELY(scope.exception()))
    691695        return false;
    692696    JSObject* target = this->target();
     
    697701    arguments.append(target);
    698702    JSValue trapResult = call(exec, preventExtensionsMethod, callType, callData, handler, arguments);
    699     if (exec->hadException())
     703    if (UNLIKELY(scope.exception()))
    700704        return false;
    701705
    702706    bool trapResultAsBool = trapResult.toBoolean(exec);
    703     if (exec->hadException())
     707    if (UNLIKELY(scope.exception()))
    704708        return false;
    705709
    706710    if (trapResultAsBool) {
    707711        bool targetIsExtensible = target->isExtensible(exec);
    708         if (exec->hadException())
     712        if (UNLIKELY(scope.exception()))
    709713            return false;
    710714        if (targetIsExtensible) {
     
    741745    CallType callType;
    742746    JSValue isExtensibleMethod = handler->getMethod(exec, callData, callType, makeIdentifier(vm, "isExtensible"), ASCIILiteral("'isExtensible' property of a Proxy's handler should be callable"));
    743     if (exec->hadException())
     747    if (UNLIKELY(scope.exception()))
    744748        return false;
    745749
     
    751755    arguments.append(target);
    752756    JSValue trapResult = call(exec, isExtensibleMethod, callType, callData, handler, arguments);
    753     if (exec->hadException())
     757    if (UNLIKELY(scope.exception()))
    754758        return false;
    755759
    756760    bool trapResultAsBool = trapResult.toBoolean(exec);
    757     if (exec->hadException())
     761    if (UNLIKELY(scope.exception()))
    758762        return false;
    759763
    760764    bool isTargetExtensible = target->isExtensible(exec);
    761     if (exec->hadException())
     765    if (UNLIKELY(scope.exception()))
    762766        return false;
    763767
     
    808812    CallType callType;
    809813    JSValue definePropertyMethod = handler->getMethod(exec, callData, callType, vm.propertyNames->defineProperty, ASCIILiteral("'defineProperty' property of a Proxy's handler should be callable"));
    810     if (vm.exception())
     814    if (UNLIKELY(scope.exception()))
    811815        return false;
    812816
     
    815819
    816820    JSObject* descriptorObject = constructObjectFromPropertyDescriptor(exec, descriptor);
    817     if (vm.exception())
     821    if (UNLIKELY(scope.exception()))
    818822        return false;
    819823
     
    823827    arguments.append(descriptorObject);
    824828    JSValue trapResult = call(exec, definePropertyMethod, callType, callData, handler, arguments);
    825     if (vm.exception())
     829    if (UNLIKELY(scope.exception()))
    826830        return false;
    827831
    828832    bool trapResultAsBool = trapResult.toBoolean(exec);
    829     if (vm.exception())
     833    if (UNLIKELY(scope.exception()))
    830834        return false;
    831835
     
    835839    PropertyDescriptor targetDescriptor;
    836840    bool isTargetDescriptorDefined = target->getOwnPropertyDescriptor(exec, propertyName, targetDescriptor);
    837     if (vm.exception())
     841    if (UNLIKELY(scope.exception()))
    838842        return false;
    839843
    840844    bool targetIsExtensible = target->isExtensible(exec);
    841     if (vm.exception())
     845    if (UNLIKELY(scope.exception()))
    842846        return false;
    843847    bool settingConfigurableToFalse = descriptor.configurablePresent() && !descriptor.configurable();
     
    897901    CallType callType;
    898902    JSValue ownKeysMethod = handler->getMethod(exec, callData, callType, makeIdentifier(vm, "ownKeys"), ASCIILiteral("'ownKeys' property of a Proxy's handler should be callable"));
    899     if (vm.exception())
     903    if (UNLIKELY(scope.exception()))
    900904        return;
    901905    JSObject* target = this->target();
     
    908912    arguments.append(target);
    909913    JSValue arrayLikeObject = call(exec, ownKeysMethod, callType, callData, handler, arguments);
    910     if (vm.exception())
     914    if (UNLIKELY(scope.exception()))
    911915        return;
    912916
     
    936940
    937941        Identifier ident = value.toPropertyKey(exec);
    938         if (vm.exception())
     942        if (UNLIKELY(scope.exception()))
    939943            return doExitEarly;
    940944
     
    945949
    946950    createListFromArrayLike(exec, arrayLikeObject, dontThrowAnExceptionTypeFilter, ASCIILiteral("Proxy handler's 'ownKeys' method must return an array-like object containing only Strings and Symbols"), addPropName);
    947     if (vm.exception())
     951    if (UNLIKELY(scope.exception()))
    948952        return;
    949953
     
    952956    PropertyNameArray targetKeys(&vm, propertyNameMode);
    953957    target->methodTable(vm)->getOwnPropertyNames(target, exec, targetKeys, enumerationMode);
    954     if (vm.exception())
     958    if (UNLIKELY(scope.exception()))
    955959        return;
    956960    Vector<UniquedStringImpl*> targetConfigurableKeys;
     
    959963        PropertyDescriptor descriptor;
    960964        bool isPropertyDefined = target->getOwnPropertyDescriptor(exec, ident.impl(), descriptor);
    961         if (vm.exception())
     965        if (UNLIKELY(scope.exception()))
    962966            return;
    963967        if (isPropertyDefined && !descriptor.configurable())
     
    10481052    CallType callType;
    10491053    JSValue setPrototypeOfMethod = handler->getMethod(exec, callData, callType, makeIdentifier(vm, "setPrototypeOf"), ASCIILiteral("'setPrototypeOf' property of a Proxy's handler should be callable"));
    1050     if (vm.exception())
     1054    if (UNLIKELY(scope.exception()))
    10511055        return false;
    10521056
     
    10591063    arguments.append(prototype);
    10601064    JSValue trapResult = call(exec, setPrototypeOfMethod, callType, callData, handler, arguments);
    1061     if (vm.exception())
     1065    if (UNLIKELY(scope.exception()))
    10621066        return false;
    10631067
    10641068    bool trapResultAsBool = trapResult.toBoolean(exec);
    1065     if (vm.exception())
     1069    if (UNLIKELY(scope.exception()))
    10661070        return false;
    10671071   
     
    10731077
    10741078    bool targetIsExtensible = target->isExtensible(exec);
    1075     if (vm.exception())
     1079    if (UNLIKELY(scope.exception()))
    10761080        return false;
    10771081    if (targetIsExtensible)
     
    10791083
    10801084    JSValue targetPrototype = target->getPrototype(vm, exec);
    1081     if (vm.exception())
     1085    if (UNLIKELY(scope.exception()))
    10821086        return false;
    10831087    if (!sameValue(exec, prototype, targetPrototype)) {
     
    11131117    CallType callType;
    11141118    JSValue getPrototypeOfMethod = handler->getMethod(exec, callData, callType, makeIdentifier(vm, "getPrototypeOf"), ASCIILiteral("'getPrototypeOf' property of a Proxy's handler should be callable"));
    1115     if (vm.exception())
     1119    if (UNLIKELY(scope.exception()))
    11161120        return JSValue();
    11171121
     
    11231127    arguments.append(target);
    11241128    JSValue trapResult = call(exec, getPrototypeOfMethod, callType, callData, handler, arguments);
    1125     if (vm.exception())
     1129    if (UNLIKELY(scope.exception()))
    11261130        return JSValue();
    11271131
     
    11321136
    11331137    bool targetIsExtensible = target->isExtensible(exec);
    1134     if (vm.exception())
     1138    if (UNLIKELY(scope.exception()))
    11351139        return JSValue();
    11361140    if (targetIsExtensible)
     
    11381142
    11391143    JSValue targetPrototype = target->getPrototype(vm, exec);
    1140     if (vm.exception())
     1144    if (UNLIKELY(scope.exception()))
    11411145        return JSValue();
    11421146    if (!sameValue(exec, targetPrototype, trapResult)) {
  • trunk/Source/JavaScriptCore/runtime/ReflectObject.cpp

    r205372 r205569  
    124124        return false;
    125125    });
    126     if (exec->hadException())
     126    if (UNLIKELY(scope.exception()))
    127127        return JSValue::encode(jsUndefined());
    128128
     
    140140        return JSValue::encode(throwTypeError(exec, scope, ASCIILiteral("Reflect.defineProperty requires the first argument be an object")));
    141141    auto propertyName = exec->argument(1).toPropertyKey(exec);
    142     if (exec->hadException())
     142    if (UNLIKELY(scope.exception()))
    143143        return JSValue::encode(jsUndefined());
    144144
     
    147147        return JSValue::encode(jsUndefined());
    148148    ASSERT((descriptor.attributes() & Accessor) || (!descriptor.isAccessorDescriptor()));
    149     ASSERT(!exec->hadException());
     149    ASSERT(!scope.exception());
    150150
    151151    // Reflect.defineProperty should not throw an error when the defineOwnProperty operation fails.
     
    179179
    180180    const Identifier propertyName = exec->argument(1).toPropertyKey(exec);
    181     if (exec->hadException())
     181    if (UNLIKELY(scope.exception()))
    182182        return JSValue::encode(jsNull());
    183183
     
    201201
    202202    auto key = exec->argument(1).toPropertyKey(exec);
    203     if (exec->hadException())
     203    if (UNLIKELY(scope.exception()))
    204204        return JSValue::encode(jsUndefined());
    205205
     
    230230
    231231    bool isExtensible = asObject(target)->isExtensible(exec);
    232     if (exec->hadException())
     232    if (UNLIKELY(scope.exception()))
    233233        return JSValue::encode(JSValue());
    234234    return JSValue::encode(jsBoolean(isExtensible));
     
    258258    JSObject* object = asObject(target);
    259259    bool result = object->methodTable(vm)->preventExtensions(object, exec);
    260     if (exec->hadException())
     260    if (UNLIKELY(scope.exception()))
    261261        return JSValue::encode(JSValue());
    262262    return JSValue::encode(jsBoolean(result));
     
    275275
    276276    auto propertyName = exec->argument(1).toPropertyKey(exec);
    277     if (exec->hadException())
     277    if (UNLIKELY(scope.exception()))
    278278        return JSValue::encode(jsUndefined());
    279279
     
    308308    bool shouldThrowIfCantSet = false;
    309309    bool didSetPrototype = object->setPrototype(vm, exec, proto, shouldThrowIfCantSet);
    310     if (vm.exception())
     310    if (UNLIKELY(scope.exception()))
    311311        return JSValue::encode(JSValue());
    312312    return JSValue::encode(jsBoolean(didSetPrototype));
  • trunk/Source/JavaScriptCore/runtime/RegExpConstructor.cpp

    r205198 r205569  
    217217        return NoFlags;
    218218    JSString* flagsString = flags.toString(exec);
     219    ASSERT(scope.exception() || flagsString);
    219220    if (!flagsString) {
    220         ASSERT(exec->hadException());
    221221        return InvalidFlags;
    222222    }
    223223
    224224    RegExpFlags result = regExpFlags(flagsString->value(exec));
    225     if (exec->hadException())
     225    if (UNLIKELY(scope.exception()))
    226226        return InvalidFlags;
    227227    if (result == InvalidFlags)
     
    236236
    237237    String pattern = patternArg.isUndefined() ? emptyString() : patternArg.toString(exec)->value(exec);
    238     if (exec->hadException())
     238    if (UNLIKELY(scope.exception()))
    239239        return nullptr;
    240240
     
    248248
    249249    Structure* structure = getRegExpStructure(exec, globalObject, newTarget);
    250     if (vm.exception())
     250    if (UNLIKELY(scope.exception()))
    251251        return nullptr;
    252252    return RegExpObject::create(vm, structure, regExp);
     
    256256{
    257257    VM& vm = exec->vm();
     258    auto scope = DECLARE_THROW_SCOPE(vm);
    258259    JSValue patternArg = args.at(0);
    259260    JSValue flagsArg = args.at(1);
     
    264265    if (newTarget.isUndefined() && constructAsRegexp && flagsArg.isUndefined()) {
    265266        JSValue constructor = patternArg.get(exec, vm.propertyNames->constructor);
    266         if (vm.exception())
     267        if (UNLIKELY(scope.exception()))
    267268            return nullptr;
    268269        if (callee == constructor) {
     
    275276        RegExp* regExp = jsCast<RegExpObject*>(patternArg)->regExp();
    276277        Structure* structure = getRegExpStructure(exec, globalObject, newTarget);
    277         if (exec->hadException())
     278        if (UNLIKELY(scope.exception()))
    278279            return nullptr;
    279280
  • trunk/Source/JavaScriptCore/runtime/RegExpConstructor.h

    r205462 r205569  
    134134ALWAYS_INLINE bool isRegExp(VM& vm, ExecState* exec, JSValue value)
    135135{
     136    auto scope = DECLARE_THROW_SCOPE(vm);
    136137    if (!value.isObject())
    137138        return false;
     
    139140    JSObject* object = asObject(value);
    140141    JSValue matchValue = object->get(exec, vm.propertyNames->matchSymbol);
    141     if (vm.exception())
     142    if (UNLIKELY(scope.exception()))
    142143        return false;
    143144    if (!matchValue.isUndefined())
  • trunk/Source/JavaScriptCore/runtime/RegExpObject.cpp

    r205198 r205569  
    181181   
    182182    JSArray* array = constructEmptyArray(exec, nullptr);
    183     if (UNLIKELY(vm.exception()))
     183    if (UNLIKELY(scope.exception()))
    184184        return jsUndefined();
    185185
     
    234234JSValue RegExpObject::matchGlobal(ExecState* exec, JSGlobalObject* globalObject, JSString* string)
    235235{
     236    VM& vm = globalObject->vm();
     237    auto scope = DECLARE_THROW_SCOPE(vm);
    236238    RegExp* regExp = this->regExp();
    237239
    238240    ASSERT(regExp->global());
    239241
    240     VM* vm = &globalObject->vm();
    241 
    242242    setLastIndex(exec, 0);
    243     if (exec->hadException())
     243    if (UNLIKELY(scope.exception()))
    244244        return jsUndefined();
    245245
     
    250250        unsigned stringLength = s.length();
    251251        return collectMatches(
    252             *vm, exec, string, s, regExpConstructor, regExp,
     252            vm, exec, string, s, regExpConstructor, regExp,
    253253            [&] (size_t end) -> size_t {
    254254                return advanceStringUnicode(s, stringLength, end);
     
    257257   
    258258    return collectMatches(
    259         *vm, exec, string, s, regExpConstructor, regExp,
     259        vm, exec, string, s, regExpConstructor, regExp,
    260260        [&] (size_t end) -> size_t {
    261261            return end + 1;
  • trunk/Source/JavaScriptCore/runtime/RegExpPrototype.cpp

    r205462 r205569  
    160160    } else {
    161161        String pattern = !exec->argumentCount() ? emptyString() : arg0.toString(exec)->value(exec);
    162         if (exec->hadException())
     162        if (UNLIKELY(scope.exception()))
    163163            return JSValue::encode(jsUndefined());
    164164
     
    166166        if (!arg1.isUndefined()) {
    167167            flags = regExpFlags(arg1.toString(exec)->value(exec));
    168             if (exec->hadException())
     168            if (UNLIKELY(scope.exception()))
    169169                return JSValue::encode(jsUndefined());
    170170            if (flags == InvalidFlags)
     
    190190
    191191    VM& vm = exec->vm();
     192    auto scope = DECLARE_THROW_SCOPE(vm);
    192193
    193194    JSValue globalValue = regexp->get(exec, exec->propertyNames().global);
    194     if (vm.exception())
     195    if (UNLIKELY(scope.exception()))
    195196        return string;
    196197    JSValue ignoreCaseValue = regexp->get(exec, exec->propertyNames().ignoreCase);
    197     if (vm.exception())
     198    if (UNLIKELY(scope.exception()))
    198199        return string;
    199200    JSValue multilineValue = regexp->get(exec, exec->propertyNames().multiline);
    200     if (vm.exception())
     201    if (UNLIKELY(scope.exception()))
    201202        return string;
    202203    JSValue unicodeValue = regexp->get(exec, exec->propertyNames().unicode);
    203     if (vm.exception())
     204    if (UNLIKELY(scope.exception()))
    204205        return string;
    205206    JSValue stickyValue = regexp->get(exec, exec->propertyNames().sticky);
    206     if (vm.exception())
     207    if (UNLIKELY(scope.exception()))
    207208        return string;
    208209
     
    239240
    240241    JSValue sourceValue = thisObject->get(exec, vm.propertyNames->source);
    241     if (vm.exception())
     242    if (UNLIKELY(scope.exception()))
    242243        return JSValue::encode(jsUndefined());
    243244    String source = sourceValue.toString(exec)->value(exec);
    244     if (vm.exception())
     245    if (UNLIKELY(scope.exception()))
    245246        return JSValue::encode(jsUndefined());
    246247
    247248    JSValue flagsValue = thisObject->get(exec, vm.propertyNames->flags);
    248     if (vm.exception())
     249    if (UNLIKELY(scope.exception()))
    249250        return JSValue::encode(jsUndefined());
    250251    String flags = flagsValue.toString(exec)->value(exec);
    251     if (vm.exception())
     252    if (UNLIKELY(scope.exception()))
    252253        return JSValue::encode(jsUndefined());
    253254
     
    340341
    341342    auto flags = flagsString(exec, asObject(thisValue));
    342     if (exec->hadException())
     343    if (UNLIKELY(scope.exception()))
    343344        return JSValue::encode(jsUndefined());
    344345
     
    473474{
    474475    VM& vm = exec->vm();
     476    auto scope = DECLARE_THROW_SCOPE(vm);
    475477    JSValue thisValue = exec->thisValue();
    476478    RegExp* regExp = asRegExpObject(thisValue)->regExp();
     
    478480    JSString* string = exec->uncheckedArgument(0).toString(exec);
    479481    String s = string->value(exec);
    480     if (vm.exception())
     482    if (UNLIKELY(scope.exception()))
    481483        return JSValue::encode(jsUndefined());
    482484
     
    587589    JSString* inputString = exec->argument(0).toString(exec);
    588590    String input = inputString->value(exec);
    589     if (vm.exception())
     591    if (UNLIKELY(scope.exception()))
    590592        return JSValue::encode(jsUndefined());
    591593    ASSERT(!input.isNull());
     
    602604    // 12. Let lengthA be 0.
    603605    JSArray* result = constructEmptyArray(exec, 0);
    604     if (UNLIKELY(vm.exception()))
     606    if (UNLIKELY(scope.exception()))
    605607        return JSValue::encode(jsUndefined());
    606608    unsigned resultLength = 0;
  • trunk/Source/JavaScriptCore/runtime/SetConstructor.cpp

    r205520 r205569  
    7373
    7474    JSValue adderFunction = set->get(exec, exec->propertyNames().add);
    75     if (exec->hadException())
     75    if (UNLIKELY(scope.exception()))
    7676        return JSValue::encode(jsUndefined());
    7777
  • trunk/Source/JavaScriptCore/runtime/StringConstructor.cpp

    r205462 r205569  
    101101    for (unsigned i = 0; i < length; ++i) {
    102102        double codePointAsDouble = exec->uncheckedArgument(i).toNumber(exec);
    103         if (exec->hadException())
     103        if (UNLIKELY(scope.exception()))
    104104            return JSValue::encode(jsUndefined());
    105105
     
    123123{
    124124    JSGlobalObject* globalObject = asInternalFunction(exec->callee())->globalObject();
    125     VM& vm = exec->vm();
     125    VM& vm = globalObject->vm();
     126    auto scope = DECLARE_THROW_SCOPE(vm);
    126127
    127128    Structure* structure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), globalObject->stringObjectStructure());
    128     if (exec->hadException())
     129    if (UNLIKELY(scope.exception()))
    129130        return JSValue::encode(JSValue());
    130131
  • trunk/Source/JavaScriptCore/runtime/StringObject.cpp

    r205198 r205569  
    109109bool StringObject::defineOwnProperty(JSObject* object, ExecState* exec, PropertyName propertyName, const PropertyDescriptor& descriptor, bool throwException)
    110110{
     111    VM& vm = exec->vm();
     112    auto scope = DECLARE_THROW_SCOPE(vm);
    111113    StringObject* thisObject = jsCast<StringObject*>(object);
    112114
     
    121123        ASSERT(isCurrentDefined);
    122124        bool isExtensible = thisObject->isExtensible(exec);
    123         if (exec->hadException())
     125        if (UNLIKELY(scope.exception()))
    124126            return false;
    125127        return validateAndApplyPropertyDescriptor(exec, nullptr, propertyName, isExtensible, descriptor, isCurrentDefined, current, throwException);
  • trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp

    r205198 r205569  
    478478    CallType callType, String& replacementString, JSValue replaceValue)
    479479{
     480    auto scope = DECLARE_THROW_SCOPE(vm);
     481
    480482    const String& source = string->value(exec);
    481483    unsigned sourceLen = source.length();
    482     if (exec->hadException())
     484    if (UNLIKELY(scope.exception()))
    483485        return JSValue::encode(jsUndefined());
    484486    RegExpObject* regExpObject = asRegExpObject(searchValue);
     
    489491        // ES5.1 15.5.4.10 step 8.a.
    490492        regExpObject->setLastIndex(exec, 0);
    491         if (exec->hadException())
     493        if (UNLIKELY(scope.exception()))
    492494            return JSValue::encode(jsUndefined());
    493495
     
    512514        JSFunction* func = jsCast<JSFunction*>(replaceValue);
    513515        CachedCall cachedCall(exec, func, argCount);
    514         if (exec->hadException())
     516        if (UNLIKELY(scope.exception()))
    515517            return JSValue::encode(jsUndefined());
    516518        if (source.is8Bit()) {
     
    540542                JSValue jsResult = cachedCall.call();
    541543                replacements.append(jsResult.toString(exec)->value(exec));
    542                 if (exec->hadException())
     544                if (UNLIKELY(scope.exception()))
    543545                    return JSValue::encode(jsUndefined());
    544546
     
    579581                JSValue jsResult = cachedCall.call();
    580582                replacements.append(jsResult.toString(exec)->value(exec));
    581                 if (exec->hadException())
     583                if (UNLIKELY(scope.exception()))
    582584                    return JSValue::encode(jsUndefined());
    583585
     
    619621
    620622                replacements.append(call(exec, replaceValue, callType, callData, jsUndefined(), args).toString(exec)->value(exec));
    621                 if (exec->hadException())
     623                if (UNLIKELY(scope.exception()))
    622624                    return JSValue::encode(jsUndefined());
    623625            } else {
     
    659661    VM& vm = exec->vm();
    660662    NativeCallFrameTracer tracer(&vm, exec);
    661    
     663    auto scope = DECLARE_THROW_SCOPE(vm);
     664
    662665    RegExp* regExp = searchValue->regExp();
    663666    if (regExp->global()) {
    664667        // ES5.1 15.5.4.10 step 8.a.
    665668        searchValue->setLastIndex(exec, 0);
    666         if (exec->hadException())
     669        if (UNLIKELY(scope.exception()))
    667670            return JSValue::encode(jsUndefined());
    668671        return removeUsingRegExpSearch(vm, exec, thisValue, thisValue->value(exec), regExp);
     
    689692static ALWAYS_INLINE EncodedJSValue replaceUsingRegExpSearch(VM& vm, ExecState* exec, JSString* string, JSValue searchValue, JSValue replaceValue)
    690693{
     694    auto scope = DECLARE_THROW_SCOPE(vm);
     695
    691696    String replacementString;
    692697    CallData callData;
     
    694699    if (callType == CallType::None) {
    695700        replacementString = replaceValue.toString(exec)->value(exec);
    696         if (exec->hadException())
     701        if (UNLIKELY(scope.exception()))
    697702            return JSValue::encode(jsUndefined());
    698703    }
     
    702707}
    703708
    704 static ALWAYS_INLINE EncodedJSValue replaceUsingStringSearch(VM&, ExecState* exec, JSString* jsString, JSValue searchValue, JSValue replaceValue)
    705 {
     709static ALWAYS_INLINE EncodedJSValue replaceUsingStringSearch(VM& vm, ExecState* exec, JSString* jsString, JSValue searchValue, JSValue replaceValue)
     710{
     711    auto scope = DECLARE_THROW_SCOPE(vm);
     712
    706713    const String& string = jsString->value(exec);
    707714    String searchString = searchValue.toString(exec)->value(exec);
    708     if (exec->hadException())
     715    if (UNLIKELY(scope.exception()))
    709716        return JSValue::encode(jsUndefined());
    710717
     
    722729        args.append(jsString);
    723730        replaceValue = call(exec, replaceValue, callType, callData, jsUndefined(), args);
    724         if (exec->hadException())
     731        if (UNLIKELY(scope.exception()))
    725732            return JSValue::encode(jsUndefined());
    726733    }
    727734
    728735    String replaceString = replaceValue.toString(exec)->value(exec);
    729     if (exec->hadException())
     736    if (UNLIKELY(scope.exception()))
    730737        return JSValue::encode(jsUndefined());
    731738
     
    812819        return throwVMTypeError(exec, scope);
    813820    JSString* string = thisValue.toString(exec);
    814     if (exec->hadException())
     821    if (UNLIKELY(scope.exception()))
    815822        return JSValue::encode(jsUndefined());
    816823    return replace(vm, exec, string, searchValue, replaceValue);
     
    819826EncodedJSValue JSC_HOST_CALL stringProtoFuncReplaceUsingRegExp(ExecState* exec)
    820827{
     828    VM& vm = exec->vm();
     829    auto scope = DECLARE_THROW_SCOPE(vm);
     830
    821831    JSString* string = exec->thisValue().toString(exec);
    822     if (exec->hadException())
     832    if (UNLIKELY(scope.exception()))
    823833        return JSValue::encode(jsUndefined());
    824834
     
    832842EncodedJSValue JSC_HOST_CALL stringProtoFuncReplaceUsingStringSearch(ExecState* exec)
    833843{
     844    VM& vm = exec->vm();
     845    auto scope = DECLARE_THROW_SCOPE(vm);
     846
    834847    JSString* string = exec->thisValue().toString(exec);
    835     if (exec->hadException())
     848    if (UNLIKELY(scope.exception()))
    836849        return JSValue::encode(jsUndefined());
    837850
     
    942955    }
    943956
    944     if (UNLIKELY(exec->hadException()))
     957    if (UNLIKELY(scope.exception()))
    945958        return JSValue::encode(jsUndefined());
    946959
     
    10541067        return throwVMTypeError(exec, scope);
    10551068    String s = thisValue.toString(exec)->value(exec);
    1056     if (exec->hadException())
     1069    if (UNLIKELY(scope.exception()))
    10571070        return JSValue::encode(jsUndefined());
    10581071
     
    11121125{
    11131126    VM& vm = exec->vm();
     1127    auto scope = DECLARE_THROW_SCOPE(vm);
    11141128    JSValue thisValue = exec->thisValue();
    11151129    ASSERT(checkObjectCoercible(thisValue));
     
    11181132    // 7. Let s be the number of characters in S.
    11191133    String input = thisValue.toString(exec)->value(exec);
    1120     if (UNLIKELY(vm.exception()))
     1134    if (UNLIKELY(scope.exception()))
    11211135        return JSValue::encode(jsUndefined());
    11221136    ASSERT(!input.isNull());
     
    11251139    //    where Array is the standard built-in constructor with that name.
    11261140    JSArray* result = constructEmptyArray(exec, 0);
    1127     if (UNLIKELY(vm.exception()))
     1141    if (UNLIKELY(scope.exception()))
    11281142        return JSValue::encode(jsUndefined());
    11291143
     
    11421156    JSValue separatorValue = exec->uncheckedArgument(0);
    11431157    String separator = separatorValue.toString(exec)->value(exec);
    1144     if (UNLIKELY(vm.exception()))
     1158    if (UNLIKELY(scope.exception()))
    11451159        return JSValue::encode(jsUndefined());
    11461160
     
    12511265    } else {
    12521266        uString = thisValue.toString(exec)->value(exec);
    1253         if (exec->hadException())
     1267        if (UNLIKELY(scope.exception()))
    12541268            return JSValue::encode(jsUndefined());
    12551269        len = uString.length();
     
    13041318
    13051319    JSString* jsString = thisValue.toString(exec);
    1306     if (exec->hadException())
     1320    if (UNLIKELY(scope.exception()))
    13071321        return JSValue::encode(jsUndefined());
    13081322
     
    13781392        return throwVMTypeError(exec, scope);
    13791393    String s = thisValue.toString(exec)->value(exec);
    1380     if (exec->hadException())
     1394    if (UNLIKELY(scope.exception()))
    13811395        return JSValue::encode(jsUndefined());
    13821396
    13831397    JSValue a0 = exec->argument(0);
    13841398    String str = a0.toString(exec)->value(exec);
    1385     if (exec->hadException())
     1399    if (UNLIKELY(scope.exception()))
    13861400        return JSValue::encode(jsUndefined());
    13871401    return JSValue::encode(jsNumber(Collator().collate(s, str)));
     
    14041418
    14051419    // 3. ReturnIfAbrupt(S).
    1406     if (state->hadException())
     1420    if (UNLIKELY(scope.exception()))
    14071421        return JSValue::encode(jsUndefined());
    14081422
     
    14151429
    14161430    // 5. ReturnIfAbrupt(requestedLocales).
    1417     if (state->hadException())
     1431    if (UNLIKELY(scope.exception()))
    14181432        return JSValue::encode(jsUndefined());
    14191433
     
    14991513        return throwVMTypeError(exec, scope);
    15001514    String s = thisValue.toString(exec)->value(exec);
    1501     if (exec->hadException())
     1515    if (UNLIKELY(scope.exception()))
    15021516        return JSValue::encode(jsUndefined());
    15031517    return JSValue::encode(jsMakeNontrivialString(exec, "<big>", s, "</big>"));
     
    15131527        return throwVMTypeError(exec, scope);
    15141528    String s = thisValue.toString(exec)->value(exec);
    1515     if (exec->hadException())
     1529    if (UNLIKELY(scope.exception()))
    15161530        return JSValue::encode(jsUndefined());
    15171531    return JSValue::encode(jsMakeNontrivialString(exec, "<small>", s, "</small>"));
     
    15271541        return throwVMTypeError(exec, scope);
    15281542    String s = thisValue.toString(exec)->value(exec);
    1529     if (exec->hadException())
     1543    if (UNLIKELY(scope.exception()))
    15301544        return JSValue::encode(jsUndefined());
    15311545    return JSValue::encode(jsMakeNontrivialString(exec, "<blink>", s, "</blink>"));
     
    15411555        return throwVMTypeError(exec, scope);
    15421556    String s = thisValue.toString(exec)->value(exec);
    1543     if (exec->hadException())
     1557    if (UNLIKELY(scope.exception()))
    15441558        return JSValue::encode(jsUndefined());
    15451559    return JSValue::encode(jsMakeNontrivialString(exec, "<b>", s, "</b>"));
     
    15551569        return throwVMTypeError(exec, scope);
    15561570    String s = thisValue.toString(exec)->value(exec);
    1557     if (exec->hadException())
     1571    if (UNLIKELY(scope.exception()))
    15581572        return JSValue::encode(jsUndefined());
    15591573    return JSValue::encode(jsMakeNontrivialString(exec, "<tt>", s, "</tt>"));
     
    15691583        return throwVMTypeError(exec, scope);
    15701584    String s = thisValue.toString(exec)->value(exec);
    1571     if (exec->hadException())
     1585    if (UNLIKELY(scope.exception()))
    15721586        return JSValue::encode(jsUndefined());
    15731587    return JSValue::encode(jsMakeNontrivialString(exec, "<i>", s, "</i>"));
     
    15831597        return throwVMTypeError(exec, scope);
    15841598    String s = thisValue.toString(exec)->value(exec);
    1585     if (exec->hadException())
     1599    if (UNLIKELY(scope.exception()))
    15861600        return JSValue::encode(jsUndefined());
    15871601    return JSValue::encode(jsMakeNontrivialString(exec, "<strike>", s, "</strike>"));
     
    15971611        return throwVMTypeError(exec, scope);
    15981612    String s = thisValue.toString(exec)->value(exec);
    1599     if (exec->hadException())
     1613    if (UNLIKELY(scope.exception()))
    16001614        return JSValue::encode(jsUndefined());
    16011615    return JSValue::encode(jsMakeNontrivialString(exec, "<sub>", s, "</sub>"));
     
    16111625        return throwVMTypeError(exec, scope);
    16121626    String s = thisValue.toString(exec)->value(exec);
    1613     if (exec->hadException())
     1627    if (UNLIKELY(scope.exception()))
    16141628        return JSValue::encode(jsUndefined());
    16151629    return JSValue::encode(jsMakeNontrivialString(exec, "<sup>", s, "</sup>"));
     
    16251639        return throwVMTypeError(exec, scope);
    16261640    String s = thisValue.toString(exec)->value(exec);
    1627     if (exec->hadException())
     1641    if (UNLIKELY(scope.exception()))
    16281642        return JSValue::encode(jsUndefined());
    16291643
     
    16441658        return throwVMTypeError(exec, scope);
    16451659    String s = thisValue.toString(exec)->value(exec);
    1646     if (exec->hadException())
     1660    if (UNLIKELY(scope.exception()))
    16471661        return JSValue::encode(jsUndefined());
    16481662
     
    16991713        return throwVMTypeError(exec, scope);
    17001714    String s = thisValue.toString(exec)->value(exec);
    1701     if (exec->hadException())
     1715    if (UNLIKELY(scope.exception()))
    17021716        return JSValue::encode(jsUndefined());
    17031717
     
    17181732        return throwVMTypeError(exec, scope);
    17191733    String s = thisValue.toString(exec)->value(exec);
    1720     if (exec->hadException())
     1734    if (UNLIKELY(scope.exception()))
    17211735        return JSValue::encode(jsUndefined());
    17221736
     
    17661780        return throwTypeError(exec, scope);
    17671781    String str = thisValue.toString(exec)->value(exec);
    1768     if (exec->hadException())
     1782    if (UNLIKELY(scope.exception()))
    17691783        return jsUndefined();
    17701784
     
    18241838
    18251839    String stringToSearchIn = thisValue.toString(exec)->value(exec);
    1826     if (exec->hadException())
     1840    if (UNLIKELY(scope.exception()))
    18271841        return JSValue::encode(jsUndefined());
    18281842
    18291843    JSValue a0 = exec->argument(0);
    18301844    bool isRegularExpression = isRegExp(vm, exec, a0);
    1831     if (vm.exception())
     1845    if (UNLIKELY(scope.exception()))
    18321846        return JSValue::encode(JSValue());
    18331847    if (isRegularExpression)
     
    18351849
    18361850    String searchString = a0.toString(exec)->value(exec);
    1837     if (exec->hadException())
     1851    if (UNLIKELY(scope.exception()))
    18381852        return JSValue::encode(jsUndefined());
    18391853
     
    18451859        unsigned length = stringToSearchIn.length();
    18461860        start = clampAndTruncateToUnsigned(positionArg.toInteger(exec), 0, length);
    1847         if (exec->hadException())
     1861        if (UNLIKELY(scope.exception()))
    18481862            return JSValue::encode(jsUndefined());
    18491863    }
     
    18621876
    18631877    String stringToSearchIn = thisValue.toString(exec)->value(exec);
    1864     if (exec->hadException())
     1878    if (UNLIKELY(scope.exception()))
    18651879        return JSValue::encode(jsUndefined());
    18661880
    18671881    JSValue a0 = exec->argument(0);
    18681882    bool isRegularExpression = isRegExp(vm, exec, a0);
    1869     if (vm.exception())
     1883    if (UNLIKELY(scope.exception()))
    18701884        return JSValue::encode(JSValue());
    18711885    if (isRegularExpression)
     
    18731887
    18741888    String searchString = a0.toString(exec)->value(exec);
    1875     if (exec->hadException())
     1889    if (UNLIKELY(scope.exception()))
    18761890        return JSValue::encode(jsUndefined());
    18771891
     
    18841898    else if (!endPositionArg.isUndefined()) {
    18851899        end = clampAndTruncateToUnsigned(endPositionArg.toInteger(exec), 0, length);
    1886         if (exec->hadException())
     1900        if (UNLIKELY(scope.exception()))
    18871901            return JSValue::encode(jsUndefined());
    18881902    }
     
    18931907static EncodedJSValue JSC_HOST_CALL stringIncludesImpl(VM& vm, ExecState* exec, String stringToSearchIn, String searchString, JSValue positionArg)
    18941908{
     1909    auto scope = DECLARE_THROW_SCOPE(vm);
    18951910    unsigned start = 0;
    18961911    if (positionArg.isInt32())
     
    18991914        unsigned length = stringToSearchIn.length();
    19001915        start = clampAndTruncateToUnsigned(positionArg.toInteger(exec), 0, length);
    1901         if (vm.exception())
     1916        if (UNLIKELY(scope.exception()))
    19021917            return JSValue::encode(jsUndefined());
    19031918    }
     
    19161931
    19171932    String stringToSearchIn = thisValue.toString(exec)->value(exec);
    1918     if (exec->hadException())
     1933    if (UNLIKELY(scope.exception()))
    19191934        return JSValue::encode(jsUndefined());
    19201935
    19211936    JSValue a0 = exec->argument(0);
    19221937    bool isRegularExpression = isRegExp(vm, exec, a0);
    1923     if (vm.exception())
     1938    if (UNLIKELY(scope.exception()))
    19241939        return JSValue::encode(JSValue());
    19251940    if (isRegularExpression)
     
    19271942
    19281943    String searchString = a0.toString(exec)->value(exec);
    1929     if (exec->hadException())
     1944    if (UNLIKELY(scope.exception()))
    19301945        return JSValue::encode(jsUndefined());
    19311946
     
    19371952EncodedJSValue JSC_HOST_CALL builtinStringIncludesInternal(ExecState* exec)
    19381953{
     1954    VM& vm = exec->vm();
     1955    auto scope = DECLARE_THROW_SCOPE(vm);
     1956
    19391957    JSValue thisValue = exec->thisValue();
    19401958    ASSERT(checkObjectCoercible(thisValue));
    19411959
    19421960    String stringToSearchIn = thisValue.toString(exec)->value(exec);
    1943     if (exec->hadException())
     1961    if (UNLIKELY(scope.exception()))
    19441962        return JSValue::encode(jsUndefined());
    19451963
    19461964    JSValue a0 = exec->uncheckedArgument(0);
    1947     VM& vm = exec->vm();
    19481965    String searchString = a0.toString(exec)->value(exec);
    1949     if (exec->hadException())
     1966    if (UNLIKELY(scope.exception()))
    19501967        return JSValue::encode(jsUndefined());
    19511968
     
    20032020        return throwVMTypeError(exec, scope);
    20042021    JSString::SafeView source = thisValue.toString(exec)->view(exec);
    2005     if (exec->hadException())
     2022    if (UNLIKELY(scope.exception()))
    20062023        return JSValue::encode(jsUndefined());
    20072024
     
    20102027    if (!exec->argument(0).isUndefined()) {
    20112028        String formString = exec->uncheckedArgument(0).toString(exec)->value(exec);
    2012         if (exec->hadException())
     2029        if (UNLIKELY(scope.exception()))
    20132030            return JSValue::encode(jsUndefined());
    20142031
  • trunk/Source/JavaScriptCore/runtime/SymbolConstructor.cpp

    r205335 r205569  
    9797EncodedJSValue JSC_HOST_CALL symbolConstructorFor(ExecState* exec)
    9898{
     99    VM& vm = exec->vm();
     100    auto scope = DECLARE_THROW_SCOPE(vm);
     101
    99102    JSString* stringKey = exec->argument(0).toString(exec);
    100     if (exec->hadException())
     103    if (UNLIKELY(scope.exception()))
    101104        return JSValue::encode(jsUndefined());
    102105    String string = stringKey->value(exec);
    103     if (exec->hadException())
     106    if (UNLIKELY(scope.exception()))
    104107        return JSValue::encode(jsUndefined());
    105108
  • trunk/Source/JavaScriptCore/runtime/TemplateRegistry.cpp

    r205462 r205569  
    4646
    4747    VM& vm = exec->vm();
     48    auto scope = DECLARE_THROW_SCOPE(vm);
    4849    unsigned count = templateKey.cookedStrings().size();
    4950    JSArray* templateObject = constructEmptyArray(exec, nullptr, count);
    50     if (UNLIKELY(vm.exception()))
     51    if (UNLIKELY(scope.exception()))
    5152        return nullptr;
    5253    JSArray* rawObject = constructEmptyArray(exec, nullptr, count);
    53     if (UNLIKELY(vm.exception()))
     54    if (UNLIKELY(scope.exception()))
    5455        return nullptr;
    5556
     
    6061
    6162    objectConstructorFreeze(exec, rawObject);
    62     ASSERT(!exec->hadException());
     63    ASSERT(!scope.exception());
    6364
    6465    templateObject->putDirect(vm, exec->propertyNames().raw, rawObject, ReadOnly | DontEnum | DontDelete);
    6566
    6667    objectConstructorFreeze(exec, templateObject);
    67     ASSERT(!exec->hadException());
     68    ASSERT(!scope.exception());
    6869
    6970    m_templateMap.set(templateKey, templateObject);
  • trunk/Source/JavaScriptCore/runtime/ThrowScope.cpp

    r205462 r205569  
    2727#include "ThrowScope.h"
    2828
     29#include "Exception.h"
    2930#include "JSCInlines.h"
    3031#include "VM.h"
     
    3233namespace JSC {
    3334   
    34 #if ENABLE(THROW_SCOPE_VERIFICATION)
     35#if ENABLE(EXCEPTION_SCOPE_VERIFICATION)
    3536
    36 namespace {
    37 
    38 // Logs all ThrowScope activity to help debug the source of a verification failure.
    39 bool traceOn = false;
    40 
    41 // A more verbose logging option to dump the C++ stack trace at strategic points to aid debugging.
    42 bool traceWithStackTraces = false;
    43 
    44 // Disabled temporarily until all known verification failures are fixed.
    45 bool verificationOn = false;
    46 
    47 unsigned traceCount = 0;
    48 };
    49 
    50 /*
    51     ThrowScope verification works to simulate exception throws and catch cases where
    52     exception checks are missing. This is how it works:
    53 
    54  1. The VM has a m_needExceptionCheck bit that indicates where an exception check is
    55     needed. You can think of the m_needExceptionCheck bit being set as a simulated
    56     throw.
    57 
    58  2. Every throw site must declare a ThrowScope instance using DECLARE_THROW_SCOPE at
    59     the top of its function (as early as possible) e.g.
    60  
    61         void foo(...)
    62         {
    63             auto scope = DECLARE_THROW_SCOPE(vm);
    64             throwException(exec, scope, ...);
    65         }
    66 
    67     Note: VM::throwException() methods are private, and only calleableby the ThrowScope
    68     friend class. All throws must go through a ThrowScope. Hence, we are guaranteed that
    69     any function that can throw will have a ThrowScope.
    70 
    71     Note: by convention, every throw helper function must take a ThrowScope argument
    72     instead of instantiating its own ThrowScope.  This allows the throw to be attributed
    73     to the client code rather than the throw helper itself.
    74 
    75  3. Verification of needed exception checks
    76 
    77     a. On construction, each ThrowScope will verify that VM::m_needExceptionCheck is
    78        not set.
    79  
    80        This ensures that the caller of the current function has checked for exceptions
    81        where needed before doing more work which led to calling the current function.
    82 
    83     b. On destruction, each ThrowScope will verify that VM::m_needExceptionCheck is
    84        not set. This verification will be skipped if the ThrowScope has been released
    85        (see (5) below).
    86 
    87        This ensures that the function that owns this ThrowScope is not missing any
    88        exception checks before returning.
    89  
    90     c. When throwing an exception, the ThrowScope will verify that VM::m_needExceptionCheck
    91        is not set, unless it's been ask to rethrow the same Exception object.
    92 
    93  4. Simulated throws
    94 
    95     Throws are simulated by setting the m_needExceptionCheck bit.
    96 
    97     The bit will only be set in the ThrowScope destructor except when the ThrowScope
    98     detects the caller is a LLInt or JIT function. LLInt or JIT functions will always
    99     check for exceptions after a host C++ function returns to it. However, they will
    100     not clear the m_needExceptionCheck bit.
    101 
    102     Hence, if the ThrowScope destructor detects the caller is a LLInt or JIT function,
    103     it will just skip the setting of the bit.
    104 
    105     Note: there is no need, and it is incorrect to set the m_needExceptionCheck bit
    106     in the throwException methods. This is because, in practice, we always return
    107     immediately after throwing an exception. It doesn't make sense to set the bit in
    108     the throw just to have to clear it immediately after before we do verification in
    109     the ThrowScope destructor.
    110 
    111  5. Using ThrowScope::release()
    112 
    113     ThrowScope::release() should only be used at the bottom of a function if:
    114  
    115     a. This function is going to let its caller check and handle the exception.
    116  
    117         void foo(...)
    118         {
    119             auto scope = DECLARE_THROW_SCOPE(vm);
    120             auto result = goo(); // may throw.
    121 
    122             ... // Cleanup code that will are not affected by a pending exceptions.
    123 
    124             scope.release(); // tell the ThrowScope that the caller will handle the exception.
    125             return result;
    126         }
    127  
    128     b. This function is going to do a tail call that may throw.
    129 
    130         void foo(...)
    131         {
    132             auto scope = DECLARE_THROW_SCOPE(vm);
    133             ...
    134             scope.release(); // tell the ThrowScope that the caller will handle the exception.
    135             return goo(); // may throw.
    136         }
    137  
    138     ThrowScope::release() should not be used in the code paths that branch. For example:
    139  
    140         void foo(...)
    141         {
    142             auto scope = DECLARE_THROW_SCOPE(vm);
    143 
    144             auto result = goo1(); // may throw.
    145             scope.release(); // <=================== the WRONG way !!!
    146             if (result)
    147                 return;
    148  
    149             result = goo2(); // may throw.
    150             ...
    151             return result;
    152         }
    153  
    154     The above will result in a verification failure in goo2()'s ThrowScope.  The proper way
    155     to fix this verification is to do wither (6) or (7) below.
    156  
    157   6. Checking exceptions with ThrowScope::exception()
    158  
    159      ThrowScope::exception() returns the thrown Exception object if there is one pending.
    160      Else it returns nullptr.
    161  
    162      It also clears the m_needExceptionCheck bit thereby indicating that we've satisifed
    163      the needed exception check.
    164  
    165      This is how we do it:
    166  
    167         void foo(...)
    168         {
    169             auto scope = DECLARE_THROW_SCOPE(vm);
    170 
    171             auto result = goo1(); // may throw.
    172             if (scope.exception())
    173                 return;
    174 
    175             result = goo2(); // may throw.
    176             ...
    177             return result;
    178         }
    179  
    180     But sometimes, for optimization reasons, we may choose to test the result of the callee
    181     function instead doing a load of the VM exception value. See (7) below.
    182  
    183  7. Checking exception by checking callee result
    184  
    185     This approach should only be applied when it makes a difference to performance.
    186     If we need to do this, we should add an ASSERT() that invokes ThrowScope::exception()
    187     and verify the result. Since ThrowScope verification is only done on DEBUG builds,
    188     this ASSERT will satisfy the verification requirements while not impacting performance.
    189  
    190     This is how we do it:
    191 
    192         void foo(...)
    193         {
    194             auto scope = DECLARE_THROW_SCOPE(vm);
    195 
    196             bool failed = goo1(); // may throw.
    197             ASSERT(!!scope.exception() == failed)
    198             if (failed)
    199                 return;
    200 
    201             result = goo2(); // may throw.
    202             ...
    203             return result;
    204         }
    205  
    206  8. Debugging verification failures.
    207 
    208     a. When verification fails, you will see a helpful message followed by an assertion failure.
    209        For example:
    210  
    211     FAILED exception check verification:
    212         Exception thrown from ThrowScope [2] Exit: setUpCall @ /Volumes/Data/ws6/OpenSource/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp:1245
    213         is unchecked in ThrowScope [1]: varargsSetup @ /Volumes/Data/ws6/OpenSource/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp:1398
    214 
    215        The message tells you that failure was detected at in varargsSetup() @ LLIntSlowPaths.cpp
    216        line 1398, and that the missing exception check should have happened somewhere between
    217        the call to setUpCall() @ LLIntSlowPaths.cpp line 1245 and it.
    218 
    219        If that is insufficient information, you can ...
    220 
    221     b. Turn on ThrowScope tracing
    222  
    223        Just set traceOn=true at the top of ThrowScope.cpp, and rebuild. Thereafter, you should
    224        see a trace of ThrowScopes being entered and exited as well as their depth e.g.
    225 
    226     ThrowScope [1] Enter: llint_slow_path_jfalse @ /Volumes/Data/ws6/OpenSource/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp:1032
    227     ThrowScope [1] Exit: llint_slow_path_jfalse @ /Volumes/Data/ws6/OpenSource/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp:1032
    228 
    229        You will also see traces of simulated throws e.g.
    230 
    231     ThrowScope [2] Throw from: setUpCall @ /Volumes/Data/ws6/OpenSource/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp:1245
    232 
    233        If that is insufficient information, you can ...
    234 
    235     c. Turn on ThrowScope stack dumps
    236 
    237        Just set traceWithStackTraces=true at the top of ThrowScope.cpp, and rebuild.
    238        Thereafter, you should see a stack traces at various relevant ThrowScope events.
    239 
    240     d. Using throwScopePrintIfNeedCheck()
    241 
    242        If you have isolated the missing exception check to a function that is large but
    243        is unsure which statement can throw and is missing the check, you can sprinkle
    244        the function with calls to throwScopePrintIfNeedCheck().
    245 
    246        throwScopePrintIfNeedCheck() will log a line "Need exception check at ..." that
    247        inlcudes the file and line number only when it see the m_needExceptionCheck set.
    248        This will tell you which statement simulated the throw that is not being checked
    249        i.e. the one that preceded the throwScopePrintIfNeedCheck() that printed a line.
    250 */
    251 
    252 ThrowScope::ThrowScope(VM& vm, ThrowScopeLocation location)
    253     : m_vm(vm)
    254     , m_previousScope(vm.m_topThrowScope)
    255     , m_location(location)
    256     , m_depth(m_previousScope ? m_previousScope->m_depth + 1 : 0)
     37ThrowScope::ThrowScope(VM& vm, ExceptionEventLocation location)
     38    : ExceptionScope(vm, location)
    25739{
    258     m_vm.m_topThrowScope = this;
    259 
    260     if (traceOn) {
    261         dataLog("<", traceCount++, "> ThrowScope [", m_depth, "] Enter: ", location.functionName, " @ ", location.file, ":", location.line);
    262         if (m_vm.m_needExceptionCheck)
    263             dataLog(", needs check");
    264         dataLog("\n");
    265 
    266         if (traceWithStackTraces)
    267             WTFReportBacktrace();
    268     }
    269 
    270     verifyExceptionCheckNeedIsSatisfied(Site::ScopeEntry);
     40    m_vm.verifyExceptionCheckNeedIsSatisfied(m_recursionDepth, m_location);
    27141}
    27242
    27343ThrowScope::~ThrowScope()
    27444{
    275     RELEASE_ASSERT(m_vm.m_topThrowScope);
     45    RELEASE_ASSERT(m_vm.m_topExceptionScope);
    27646
    27747    if (!m_isReleased)
    278         verifyExceptionCheckNeedIsSatisfied(Site::ScopeExit);
     48        m_vm.verifyExceptionCheckNeedIsSatisfied(m_recursionDepth, m_location);
    27949    else {
    28050        // If we released the scope, that means we're letting our callers do the
     
    29969    if (!willBeHandleByLLIntOrJIT)
    30070        simulateThrow();
    301 
    302     if (traceOn) {
    303         dataLog("<", traceCount++, "> ThrowScope [", m_depth, "] Exit: ", m_location.functionName, " @ ", m_location.file, ":", m_location.line);
    304         if (!willBeHandleByLLIntOrJIT)
    305             dataLog(", with rethrow");
    306         if (m_vm.m_needExceptionCheck)
    307             dataLog(", needs check");
    308         dataLog("\n");
    309 
    310         if (traceWithStackTraces)
    311             WTFReportBacktrace();
    312     }
    313 
    314     m_vm.m_topThrowScope = m_previousScope;
    31571}
    31672
     
    31874{
    31975    if (m_vm.exception() && m_vm.exception() != exception)
    320         verifyExceptionCheckNeedIsSatisfied(Site::Throw);
     76        m_vm.verifyExceptionCheckNeedIsSatisfied(m_recursionDepth, m_location);
    32177   
    32278    m_vm.throwException(exec, exception);
     
    32682{
    32783    if (!error.isCell() || !jsDynamicCast<Exception*>(error.asCell()))
    328         verifyExceptionCheckNeedIsSatisfied(Site::Throw);
     84        m_vm.verifyExceptionCheckNeedIsSatisfied(m_recursionDepth, m_location);
    32985   
    33086    return m_vm.throwException(exec, error);
     
    33490{
    33591    if (!jsDynamicCast<Exception*>(obj))
    336         verifyExceptionCheckNeedIsSatisfied(Site::Throw);
     92        m_vm.verifyExceptionCheckNeedIsSatisfied(m_recursionDepth, m_location);
    33793   
    33894    return m_vm.throwException(exec, obj);
    33995}
    34096
    341 void ThrowScope::printIfNeedCheck(const char* functionName, const char* file, unsigned line)
    342 {
    343     if (m_vm.m_needExceptionCheck)
    344         dataLog("<", traceCount++, "> Need exception check at ", functionName, " @ ", file, ":", line, "\n");
    345 }
    346 
    34797void ThrowScope::simulateThrow()
    34898{
    349     RELEASE_ASSERT(m_vm.m_topThrowScope);
     99    RELEASE_ASSERT(m_vm.m_topExceptionScope);
    350100    m_vm.m_simulatedThrowPointLocation = m_location;
    351     m_vm.m_simulatedThrowPointDepth = m_depth;
     101    m_vm.m_simulatedThrowPointRecursionDepth = m_recursionDepth;
    352102    m_vm.m_needExceptionCheck = true;
    353103
    354     if (traceOn) {
    355         dataLog("<", traceCount++, "> ThrowScope [", m_depth, "] Throw from: ", m_location.functionName, " @ ", m_location.file, ":", m_location.line, "\n");
    356         if (traceWithStackTraces)
    357             WTFReportBacktrace();
     104    if (Options::dumpSimulatedThrows()) {
     105        dataLog("Simulated throw from this scope: ", m_location, "\n");
     106        dataLog("    (ExceptionScope::m_recursionDepth was ", m_recursionDepth, ")\n");
     107        WTFReportBacktrace();
    358108    }
    359109}
    360110
    361 void ThrowScope::verifyExceptionCheckNeedIsSatisfied(ThrowScope::Site site)
    362 {
    363     if (!verificationOn)
    364         return;
    365 
    366     if (UNLIKELY(m_vm.m_needExceptionCheck)) {
    367         auto failDepth = m_vm.m_simulatedThrowPointDepth;
    368         auto& failLocation = m_vm.m_simulatedThrowPointLocation;
    369 
    370         auto siteName = [] (Site site) -> const char* {
    371             switch (site) {
    372             case Site::ScopeEntry:
    373                 return "Entry";
    374             case Site::ScopeExit:
    375                 return "Exit";
    376             case Site::Throw:
    377                 return "Throw";
    378             }
    379             RELEASE_ASSERT_NOT_REACHED();
    380             return nullptr;
    381         };
    382 
    383         dataLog(
    384             "FAILED exception check verification:\n"
    385             "    Exception thrown from ThrowScope [", failDepth, "] ", siteName(site), ": ", failLocation.functionName, " @ ", failLocation.file, ":", failLocation.line, "\n"
    386             "    is unchecked in ThrowScope [", m_depth, "]: ", m_location.functionName, " @ ", m_location.file, ":", m_location.line, "\n"
    387             "\n");
    388 
    389         RELEASE_ASSERT(!m_vm.m_needExceptionCheck);
    390     }
    391 }
    392 
    393 #endif // ENABLE(THROW_SCOPE_VERIFICATION)
     111#endif // ENABLE(EXCEPTION_SCOPE_VERIFICATION)
    394112   
    395113} // namespace JSC
  • trunk/Source/JavaScriptCore/runtime/ThrowScope.h

    r205198 r205569  
    2727#define ThrowScope_h
    2828
    29 #include "Exception.h"
    30 #include "VM.h"
     29#include "ExceptionScope.h"
    3130
    3231namespace JSC {
     
    3534class JSObject;
    3635
    37 #if ENABLE(THROW_SCOPE_VERIFICATION)
     36#if ENABLE(EXCEPTION_SCOPE_VERIFICATION)
    3837
    39 class ThrowScope {
     38// If a function can throw a JS exception, it should declare a ThrowScope at the
     39// top of the function (as early as possible) using the DECLARE_THROW_SCOPE macro.
     40// Declaring a ThrowScope in a function means that the function may throw an
     41// exception that its caller will have to handle.
     42
     43class ThrowScope : public ExceptionScope {
    4044public:
    41     JS_EXPORT_PRIVATE ThrowScope(VM&, ThrowScopeLocation);
     45    JS_EXPORT_PRIVATE ThrowScope(VM&, ExceptionEventLocation);
    4246    JS_EXPORT_PRIVATE ~ThrowScope();
    4347
     
    4549    ThrowScope(ThrowScope&&) = default;
    4650
    47     VM& vm() const { return m_vm; }
    48 
    4951    JS_EXPORT_PRIVATE void throwException(ExecState*, Exception*);
    5052    JS_EXPORT_PRIVATE JSValue throwException(ExecState*, JSValue);
    5153    JS_EXPORT_PRIVATE JSObject* throwException(ExecState*, JSObject*);
    5254
    53     inline Exception* exception()
    54     {
    55         m_vm.m_needExceptionCheck = false;
    56         return m_vm.exception();
    57     }
    58 
    59     inline void release() { m_isReleased = true; }
     55    void release() { m_isReleased = true; }
    6056
    6157    JS_EXPORT_PRIVATE void printIfNeedCheck(const char* functionName, const char* file, unsigned line);
     
    6460    void simulateThrow();
    6561
    66     enum class Site {
    67         ScopeEntry,
    68         ScopeExit,
    69         Throw
    70     };
    71     void verifyExceptionCheckNeedIsSatisfied(Site);
    72 
    73     VM& m_vm;
    74     ThrowScope* m_previousScope;
    75     ThrowScopeLocation m_location;
    76     unsigned m_depth;
    7762    bool m_isReleased { false };
    7863};
    7964
    8065#define DECLARE_THROW_SCOPE(vm__) \
    81     JSC::ThrowScope((vm__), JSC::ThrowScopeLocation(__FUNCTION__, __FILE__, __LINE__))
     66    JSC::ThrowScope((vm__), JSC::ExceptionEventLocation(__FUNCTION__, __FILE__, __LINE__))
    8267
    8368#define throwScopePrintIfNeedCheck(scope__) \
    8469    scope__.printIfNeedCheck(__FUNCTION__, __FILE__, __LINE__)
    8570
    86 #else // not ENABLE(THROW_SCOPE_VERIFICATION)
     71#else // not ENABLE(EXCEPTION_SCOPE_VERIFICATION)
    8772
    88 class ThrowScope {
     73class ThrowScope : public ExceptionScope {
    8974public:
    90     ThrowScope(VM& vm)
    91         : m_vm(vm)
     75    ALWAYS_INLINE ThrowScope(VM& vm)
     76        : ExceptionScope(vm)
    9277    { }
     78    ThrowScope(const ThrowScope&) = delete;
     79    ThrowScope(ThrowScope&&) = default;
    9380
    94     VM& vm() const { return m_vm; }
    95    
    96     void throwException(ExecState* exec, Exception* exception) { m_vm.throwException(exec, exception); }
    97     JSValue throwException(ExecState* exec, JSValue value) { return m_vm.throwException(exec, value); }
    98     JSObject* throwException(ExecState* exec, JSObject* obj) { return m_vm.throwException(exec, obj); }
    99    
    100     Exception* exception() { return m_vm.exception(); }
    101     void release() { }
    102    
    103 private:
    104     VM& m_vm;
     81    ALWAYS_INLINE void throwException(ExecState* exec, Exception* exception) { m_vm.throwException(exec, exception); }
     82    ALWAYS_INLINE JSValue throwException(ExecState* exec, JSValue value) { return m_vm.throwException(exec, value); }
     83    ALWAYS_INLINE JSObject* throwException(ExecState* exec, JSObject* obj) { return m_vm.throwException(exec, obj); }
     84
     85    ALWAYS_INLINE void release() { }
    10586};
    10687
     
    10889    JSC::ThrowScope((vm__))
    10990
    110 #endif // ENABLE(THROW_SCOPE_VERIFICATION)
     91#endif // ENABLE(EXCEPTION_SCOPE_VERIFICATION)
    11192
    11293ALWAYS_INLINE void throwException(ExecState* exec, ThrowScope& scope, Exception* exception)
  • trunk/Source/JavaScriptCore/runtime/VM.cpp

    r205520 r205569  
    895895#endif // !ENABLE(JIT)
    896896
     897#if ENABLE(EXCEPTION_SCOPE_VERIFICATION)
     898void VM::verifyExceptionCheckNeedIsSatisfied(unsigned recursionDepth, ExceptionEventLocation& location)
     899{
     900    if (!m_verifyExceptionEvents)
     901        return;
     902
     903    if (UNLIKELY(m_needExceptionCheck)) {
     904        auto throwDepth = m_simulatedThrowPointRecursionDepth;
     905        auto& throwLocation = m_simulatedThrowPointLocation;
     906
     907        dataLog(
     908            "ERROR: Unchecked JS exception:\n"
     909            "    This scope can throw a JS exception: ", throwLocation, "\n"
     910            "        (ExceptionScope::m_recursionDepth was  ", throwDepth, ")\n"
     911            "    But the exception was unchecked as of this scope: ", location, "\n"
     912            "        (ExceptionScope::m_recursionDepth was  ", recursionDepth, ")\n"
     913            "\n");
     914        WTFReportBacktrace();
     915
     916        RELEASE_ASSERT(!m_needExceptionCheck);
     917    }
     918}
     919#endif
     920
    897921} // namespace JSC
  • trunk/Source/JavaScriptCore/runtime/VM.h

    r205520 r205569  
    3333#include "ControlFlowProfiler.h"
    3434#include "DateInstanceCache.h"
     35#include "ExceptionEventLocation.h"
    3536#include "ExecutableAllocator.h"
    3637#include "FunctionHasExecutedCache.h"
     
    4849#include "SourceCode.h"
    4950#include "Strong.h"
    50 #include "ThrowScopeLocation.h"
    5151#include "ThunkGenerators.h"
    5252#include "TypedArrayController.h"
     
    8686class ExecState;
    8787class Exception;
     88class ExceptionScope;
    8889class HandleStack;
    8990class TypeProfiler;
     
    113114#endif
    114115class Symbol;
    115 class ThrowScope;
    116116class UnlinkedCodeBlock;
    117117class UnlinkedEvalCodeBlock;
     
    448448    void restorePreviousException(Exception* exception) { setException(exception); }
    449449
    450     void clearException() { m_exception = nullptr; }
    451450    void clearLastException() { m_lastException = nullptr; }
    452451
    453452    ExecState** addressOfCallFrameForCatch() { return &callFrameForCatch; }
    454453
    455     Exception* exception() const { return m_exception; }
    456454    JSCell** addressOfException() { return reinterpret_cast<JSCell**>(&m_exception); }
    457455
     
    649647        m_lastException = exception;
    650648    }
     649    Exception* exception() const
     650    {
     651#if ENABLE(EXCEPTION_SCOPE_VERIFICATION)
     652        m_needExceptionCheck = false;
     653#endif
     654        return m_exception;
     655    }
     656    void clearException()
     657    {
     658#if ENABLE(EXCEPTION_SCOPE_VERIFICATION)
     659        m_needExceptionCheck = false;
     660#endif
     661        m_exception = nullptr;
     662    }
    651663
    652664#if !ENABLE(JIT)   
     
    658670    JS_EXPORT_PRIVATE JSValue throwException(ExecState*, JSValue);
    659671    JS_EXPORT_PRIVATE JSObject* throwException(ExecState*, JSObject*);
     672
     673#if ENABLE(EXCEPTION_SCOPE_VERIFICATION)
     674    void verifyExceptionCheckNeedIsSatisfied(unsigned depth, ExceptionEventLocation&);
     675#endif
    660676
    661677#if ENABLE(ASSEMBLER)
     
    683699    Exception* m_exception { nullptr };
    684700    Exception* m_lastException { nullptr };
    685 #if ENABLE(THROW_SCOPE_VERIFICATION)
    686     ThrowScope* m_topThrowScope { nullptr };
    687     ThrowScopeLocation m_simulatedThrowPointLocation;
    688     unsigned m_simulatedThrowPointDepth { 0 };
     701#if ENABLE(EXCEPTION_SCOPE_VERIFICATION)
     702    ExceptionScope* m_topExceptionScope { nullptr };
     703    ExceptionEventLocation m_simulatedThrowPointLocation;
     704    unsigned m_simulatedThrowPointRecursionDepth { 0 };
    689705    mutable bool m_needExceptionCheck { false };
     706
     707    // Disabled temporarily until all known verification failures are fixed.
     708    bool m_verifyExceptionEvents { false };
    690709#endif
    691710
     
    713732    std::unique_ptr<BytecodeIntrinsicRegistry> m_bytecodeIntrinsicRegistry;
    714733
     734    // Friends for exception checking purpose only.
     735    friend class Heap;
     736    friend class CatchScope;
     737    friend class ExceptionScope;
    715738    friend class ThrowScope;
    716739};
  • trunk/Source/JavaScriptCore/runtime/WeakMapConstructor.cpp

    r205462 r205569  
    6060    JSGlobalObject* globalObject = asInternalFunction(exec->callee())->globalObject();
    6161    Structure* weakMapStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), globalObject->weakMapStructure());
    62     if (exec->hadException())
     62    if (UNLIKELY(scope.exception()))
    6363        return JSValue::encode(JSValue());
    6464    JSWeakMap* weakMap = JSWeakMap::create(exec, weakMapStructure);
     
    6868
    6969    JSValue adderFunction = weakMap->JSObject::get(exec, exec->propertyNames().set);
    70     if (exec->hadException())
     70    if (UNLIKELY(scope.exception()))
    7171        return JSValue::encode(jsUndefined());
    7272
     
    7777
    7878    forEachInIterable(exec, iterable, [&](VM& vm, ExecState* exec, JSValue nextItem) {
     79        auto scope = DECLARE_THROW_SCOPE(vm);
    7980        if (!nextItem.isObject()) {
    8081            throwTypeError(exec, scope);
     
    8384
    8485        JSValue key = nextItem.get(exec, static_cast<unsigned>(0));
    85         if (vm.exception())
     86        if (UNLIKELY(scope.exception()))
    8687            return;
    8788
    8889        JSValue value = nextItem.get(exec, static_cast<unsigned>(1));
    89         if (vm.exception())
     90        if (UNLIKELY(scope.exception()))
    9091            return;
    9192
  • trunk/Source/JavaScriptCore/runtime/WeakSetConstructor.cpp

    r205462 r205569  
    6060    JSGlobalObject* globalObject = asInternalFunction(exec->callee())->globalObject();
    6161    Structure* weakSetStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), globalObject->weakSetStructure());
    62     if (exec->hadException())
     62    if (UNLIKELY(scope.exception()))
    6363        return JSValue::encode(JSValue());
    6464    JSWeakSet* weakSet = JSWeakSet::create(exec, weakSetStructure);
     
    6868
    6969    JSValue adderFunction = weakSet->JSObject::get(exec, exec->propertyNames().add);
    70     if (exec->hadException())
     70    if (UNLIKELY(scope.exception()))
    7171        return JSValue::encode(jsUndefined());
    7272
  • trunk/Source/JavaScriptCore/tools/JSDollarVMPrototype.cpp

    r205462 r205569  
    308308static EncodedJSValue JSC_HOST_CALL functionPrint(ExecState* exec)
    309309{
     310    auto scope = DECLARE_THROW_SCOPE(exec->vm());
    310311    for (unsigned i = 0; i < exec->argumentCount(); ++i) {
    311312        String argStr = exec->uncheckedArgument(i).toString(exec)->value(exec);
    312         if (exec->hadException())
     313        if (UNLIKELY(scope.exception()))
    313314            return JSValue::encode(jsUndefined());
    314315        dataLog(argStr);
  • trunk/Source/WTF/ChangeLog

    r205549 r205569  
     12016-09-07  Mark Lam  <mark.lam@apple.com>
     2
     3        Add CatchScope and force all exception checks to be via ThrowScope or CatchScope.
     4        https://bugs.webkit.org/show_bug.cgi?id=161498
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * wtf/Platform.h:
     9
    1102016-09-07  Youenn Fablet  <youenn@apple.com>
    211
  • trunk/Source/WTF/wtf/Platform.h

    r205497 r205569  
    919919#endif
    920920
    921 #ifndef ENABLE_THROW_SCOPE_VERIFICATION
    922 #define ENABLE_THROW_SCOPE_VERIFICATION (!defined(NDEBUG))
     921#ifndef ENABLE_EXCEPTION_SCOPE_VERIFICATION
     922#define ENABLE_EXCEPTION_SCOPE_VERIFICATION (!defined(NDEBUG))
    923923#endif
    924924
  • trunk/Source/WebCore/ChangeLog

    r205565 r205569  
     12016-09-07  Mark Lam  <mark.lam@apple.com>
     2
     3        Add CatchScope and force all exception checks to be via ThrowScope or CatchScope.
     4        https://bugs.webkit.org/show_bug.cgi?id=161498
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        No new test because there is no behavior change in general except for 1 bug fix.
     9        That bug is already caught by existing tests with the introduction of the CatchScope.
     10
     11        Fixes a bug in JSEventListener::handleEvent() where the exception thrown from
     12        a failed attempt to get the handleEvent callback is not handled.
     13
     14        * ForwardingHeaders/runtime/CatchScope.h: Added.
     15        * Modules/encryptedmedia/CDMSessionClearKey.cpp:
     16        (WebCore::CDMSessionClearKey::update):
     17        * Modules/indexeddb/IDBObjectStore.cpp:
     18        (WebCore::IDBObjectStore::putOrAdd):
     19        * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
     20        (WebCore::IDBServer::UniqueIDBDatabase::performPutOrAdd):
     21        * Modules/mediastream/SDPProcessor.cpp:
     22        (WebCore::SDPProcessor::callScript):
     23        * Modules/plugins/QuickTimePluginReplacement.mm:
     24        (WebCore::QuickTimePluginReplacement::ensureReplacementScriptInjected):
     25        (WebCore::QuickTimePluginReplacement::installReplacement):
     26        * bindings/js/ArrayValue.cpp:
     27        (WebCore::ArrayValue::get):
     28        * bindings/js/Dictionary.cpp:
     29        (WebCore::Dictionary::getOwnPropertiesAsStringHashMap):
     30        * bindings/js/IDBBindingUtilities.cpp:
     31        (WebCore::toJS):
     32        * bindings/js/JSApplePaySessionCustom.cpp:
     33        (WebCore::JSApplePaySession::completeShippingMethodSelection):
     34        (WebCore::JSApplePaySession::completeShippingContactSelection):
     35        (WebCore::JSApplePaySession::completePaymentMethodSelection):
     36        * bindings/js/JSAudioTrackCustom.cpp:
     37        (WebCore::JSAudioTrack::setKind):
     38        (WebCore::JSAudioTrack::setLanguage):
     39        * bindings/js/JSBlobCustom.cpp:
     40        (WebCore::constructJSBlob):
     41        * bindings/js/JSCSSStyleDeclarationCustom.cpp:
     42        (WebCore::JSCSSStyleDeclaration::getPropertyCSSValue):
     43        * bindings/js/JSCommandLineAPIHostCustom.cpp:
     44        (WebCore::getJSListenerFunctions):
     45        * bindings/js/JSCryptoAlgorithmDictionary.cpp:
     46        (WebCore::JSCryptoAlgorithmDictionary::getAlgorithmIdentifier):
     47        (WebCore::getHashAlgorithm):
     48        (WebCore::createAesCbcParams):
     49        (WebCore::createAesKeyGenParams):
     50        (WebCore::createHmacParams):
     51        (WebCore::createHmacKeyParams):
     52        (WebCore::createRsaKeyGenParams):
     53        (WebCore::createRsaOaepParams):
     54        (WebCore::createRsaSsaParams):
     55        * bindings/js/JSCryptoKeySerializationJWK.cpp:
     56        (WebCore::getJSArrayFromJSON):
     57        (WebCore::getStringFromJSON):
     58        (WebCore::getBooleanFromJSON):
     59        (WebCore::JSCryptoKeySerializationJWK::JSCryptoKeySerializationJWK):
     60        (WebCore::JSCryptoKeySerializationJWK::reconcileUsages):
     61        (WebCore::JSCryptoKeySerializationJWK::keyDataOctetSequence):
     62        (WebCore::JSCryptoKeySerializationJWK::keyDataRSAComponents):
     63        (WebCore::JSCryptoKeySerializationJWK::keyData):
     64        (WebCore::buildJSONForRSAComponents):
     65        (WebCore::addUsagesToJSON):
     66        (WebCore::JSCryptoKeySerializationJWK::serialize):
     67        * bindings/js/JSCustomElementInterface.cpp:
     68        (WebCore::JSCustomElementInterface::constructElement):
     69        (WebCore::constructCustomElementSynchronously):
     70        (WebCore::JSCustomElementInterface::upgradeElement):
     71        * bindings/js/JSCustomElementRegistryCustom.cpp:
     72        (WebCore::getCustomElementCallback):
     73        (WebCore::JSCustomElementRegistry::define):
     74        (WebCore::whenDefinedPromise):
     75        (WebCore::JSCustomElementRegistry::whenDefined):
     76        * bindings/js/JSDOMBinding.cpp:
     77        (WebCore::valueToUSVString):
     78        (WebCore::reportException):
     79        (WebCore::reportCurrentException):
     80        (WebCore::setDOMException):
     81        (WebCore::hasIteratorMethod):
     82        (WebCore::toSmallerInt):
     83        (WebCore::toSmallerUInt):
     84        (WebCore::toInt32EnforceRange):
     85        (WebCore::toUInt32EnforceRange):
     86        (WebCore::toInt64EnforceRange):
     87        (WebCore::toUInt64EnforceRange):
     88        (WebCore::throwNotSupportedError):
     89        (WebCore::throwInvalidStateError):
     90        (WebCore::throwSecurityError):
     91        * bindings/js/JSDOMBinding.h:
     92        (WebCore::toJSSequence):
     93        (WebCore::toJS):
     94        (WebCore::jsFrozenArray):
     95        (WebCore::NativeValueTraits<String>::nativeValue):
     96        (WebCore::NativeValueTraits<unsigned>::nativeValue):
     97        (WebCore::NativeValueTraits<float>::nativeValue):
     98        (WebCore::NativeValueTraits<double>::nativeValue):
     99        (WebCore::toNativeArray):
     100        * bindings/js/JSDOMGlobalObject.cpp:
     101        (WebCore::makeThisTypeErrorForBuiltins):
     102        (WebCore::makeGetterTypeErrorForBuiltins):
     103        * bindings/js/JSDOMGlobalObjectTask.cpp:
     104        * bindings/js/JSDOMIterator.h:
     105        (WebCore::iteratorForEach):
     106        * bindings/js/JSDOMPromise.cpp:
     107        (WebCore::rejectPromiseWithExceptionIfAny):
     108        * bindings/js/JSDOMPromise.h:
     109        (WebCore::callPromiseFunction):
     110        * bindings/js/JSDOMStringMapCustom.cpp:
     111        (WebCore::JSDOMStringMap::putDelegate):
     112        * bindings/js/JSDOMWindowBase.cpp:
     113        (WebCore::JSDOMWindowMicrotaskCallback::call):
     114        * bindings/js/JSDOMWindowCustom.cpp:
     115        (WebCore::JSDOMWindow::setLocation):
     116        (WebCore::JSDOMWindow::open):
     117        (WebCore::JSDOMWindow::showModalDialog):
     118        (WebCore::handlePostMessage):
     119        (WebCore::JSDOMWindow::setTimeout):
     120        (WebCore::JSDOMWindow::setInterval):
     121        * bindings/js/JSDataCueCustom.cpp:
     122        (WebCore::constructJSDataCue):
     123        * bindings/js/JSDeviceMotionEventCustom.cpp:
     124        (WebCore::readAccelerationArgument):
     125        (WebCore::readRotationRateArgument):
     126        (WebCore::JSDeviceMotionEvent::initDeviceMotionEvent):
     127        * bindings/js/JSDictionary.cpp:
     128        (WebCore::JSDictionary::tryGetProperty):
     129        (WebCore::JSDictionary::convertValue):
     130        * bindings/js/JSDictionary.h:
     131        (WebCore::JSDictionary::tryGetPropertyAndResult):
     132        * bindings/js/JSDocumentCustom.cpp:
     133        (WebCore::JSDocument::getCSSCanvasContext):
     134        * bindings/js/JSEventListener.cpp:
     135        (WebCore::JSEventListener::handleEvent):
     136        * bindings/js/JSFileCustom.cpp:
     137        (WebCore::constructJSFile):
     138        * bindings/js/JSGeolocationCustom.cpp:
     139        (WebCore::createPositionOptions):
     140        (WebCore::JSGeolocation::getCurrentPosition):
     141        (WebCore::JSGeolocation::watchPosition):
     142        * bindings/js/JSHTMLAllCollectionCustom.cpp:
     143        (WebCore::callHTMLAllCollection):
     144        * bindings/js/JSHTMLCanvasElementCustom.cpp:
     145        (WebCore::get3DContextAttributes):
     146        (WebCore::JSHTMLCanvasElement::getContext):
     147        (WebCore::JSHTMLCanvasElement::probablySupportsContext):
     148        * bindings/js/JSHTMLElementCustom.cpp:
     149        (WebCore::constructJSHTMLElement):
     150        * bindings/js/JSHistoryCustom.cpp:
     151        (WebCore::JSHistory::pushState):
     152        (WebCore::JSHistory::replaceState):
     153        * bindings/js/JSIDBDatabaseCustom.cpp:
     154        (WebCore::JSIDBDatabase::createObjectStore):
     155        * bindings/js/JSLazyEventListener.cpp:
     156        (WebCore::JSLazyEventListener::initializeJSFunction):
     157        * bindings/js/JSMainThreadExecState.h:
     158        (WebCore::JSMainThreadExecState::linkAndEvaluateModule):
     159        (WebCore::JSMainThreadExecState::~JSMainThreadExecState):
     160        * bindings/js/JSMessageEventCustom.cpp:
     161        (WebCore::handleInitMessageEvent):
     162        * bindings/js/JSMessagePortCustom.cpp:
     163        (WebCore::fillMessagePortArray):
     164        * bindings/js/JSMessagePortCustom.h:
     165        (WebCore::handlePostMessage):
     166        * bindings/js/JSMockContentFilterSettingsCustom.cpp:
     167        (WebCore::JSMockContentFilterSettings::setDecisionPoint):
     168        (WebCore::toDecision):
     169        (WebCore::JSMockContentFilterSettings::setDecision):
     170        (WebCore::JSMockContentFilterSettings::setUnblockRequestDecision):
     171        * bindings/js/JSNodeFilterCustom.cpp:
     172        (WebCore::JSNodeFilter::acceptNode):
     173        * bindings/js/JSNodeOrString.cpp:
     174        (WebCore::toNodeOrStringVector):
     175        * bindings/js/JSSQLTransactionCustom.cpp:
     176        (WebCore::JSSQLTransaction::executeSql):
     177        * bindings/js/JSSVGLengthCustom.cpp:
     178        (WebCore::JSSVGLength::convertToSpecifiedUnits):
     179        * bindings/js/JSStorageCustom.cpp:
     180        (WebCore::JSStorage::getOwnPropertyNames):
     181        (WebCore::JSStorage::putDelegate):
     182        * bindings/js/JSTextTrackCustom.cpp:
     183        (WebCore::JSTextTrack::setLanguage):
     184        * bindings/js/JSVideoTrackCustom.cpp:
     185        (WebCore::JSVideoTrack::setKind):
     186        (WebCore::JSVideoTrack::setLanguage):
     187        * bindings/js/JSWebGL2RenderingContextCustom.cpp:
     188        (WebCore::JSWebGL2RenderingContext::getIndexedParameter):
     189        * bindings/js/JSWebGLRenderingContextBaseCustom.cpp:
     190        (WebCore::getObjectParameter):
     191        (WebCore::JSWebGLRenderingContextBase::getExtension):
     192        (WebCore::JSWebGLRenderingContextBase::getFramebufferAttachmentParameter):
     193        (WebCore::JSWebGLRenderingContextBase::getParameter):
     194        (WebCore::JSWebGLRenderingContextBase::getProgramParameter):
     195        (WebCore::JSWebGLRenderingContextBase::getShaderParameter):
     196        (WebCore::toVector):
     197        (WebCore::dataFunctionf):
     198        (WebCore::dataFunctionMatrix):
     199        * bindings/js/JSWebKitSubtleCryptoCustom.cpp:
     200        (WebCore::createAlgorithmFromJSValue):
     201        (WebCore::cryptoKeyFormatFromJSValue):
     202        (WebCore::cryptoKeyUsagesFromJSValue):
     203        (WebCore::JSWebKitSubtleCrypto::encrypt):
     204        (WebCore::JSWebKitSubtleCrypto::decrypt):
     205        (WebCore::JSWebKitSubtleCrypto::sign):
     206        (WebCore::JSWebKitSubtleCrypto::verify):
     207        (WebCore::JSWebKitSubtleCrypto::digest):
     208        (WebCore::JSWebKitSubtleCrypto::generateKey):
     209        (WebCore::importKey):
     210        (WebCore::JSWebKitSubtleCrypto::importKey):
     211        (WebCore::exportKey):
     212        (WebCore::JSWebKitSubtleCrypto::exportKey):
     213        (WebCore::JSWebKitSubtleCrypto::wrapKey):
     214        (WebCore::JSWebKitSubtleCrypto::unwrapKey):
     215        * bindings/js/JSWorkerCustom.cpp:
     216        (WebCore::constructJSWorker):
     217        * bindings/js/JSWorkerGlobalScopeCustom.cpp:
     218        (WebCore::JSWorkerGlobalScope::importScripts):
     219        (WebCore::JSWorkerGlobalScope::setTimeout):
     220        (WebCore::JSWorkerGlobalScope::setInterval):
     221        * bindings/js/ReadableStreamDefaultController.cpp:
     222        (WebCore::ReadableStreamDefaultController::invoke):
     223        (WebCore::ReadableStreamDefaultController::isControlledReadableStreamLocked):
     224        * bindings/js/ReadableStreamDefaultController.h:
     225        (WebCore::ReadableStreamDefaultController::enqueue):
     226        * bindings/js/ScheduledAction.cpp:
     227        (WebCore::ScheduledAction::create):
     228        * bindings/js/ScriptGlobalObject.cpp:
     229        (WebCore::ScriptGlobalObject::set):
     230        * bindings/js/SerializedScriptValue.cpp:
     231        (WebCore::CloneBase::shouldTerminate):
     232        (WebCore::CloneDeserializer::deserialize):
     233        (WebCore::SerializedScriptValue::create):
     234        (WebCore::SerializedScriptValue::deserialize):
     235        * bindings/js/WorkerScriptController.cpp:
     236        (WebCore::WorkerScriptController::evaluate):
     237        * bindings/scripts/CodeGeneratorJS.pm:
     238        (GenerateDictionaryImplementationContent):
     239        (GenerateImplementation):
     240        (GenerateParametersCheck):
     241        (GenerateImplementationFunctionCall):
     242        (GenerateConstructorDefinition):
     243        * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp:
     244        (WebCore::jsTestActiveDOMObjectPrototypeFunctionPostMessage):
     245        * bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp:
     246        (WebCore::jsTestCustomNamedGetterPrototypeFunctionAnotherFunction):
     247        * bindings/scripts/test/JS/JSTestEventConstructor.cpp:
     248        (WebCore::JSTestEventConstructorConstructor::construct):
     249        * bindings/scripts/test/JS/JSTestEventTarget.cpp:
     250        (WebCore::jsTestEventTargetPrototypeFunctionItem):
     251        * bindings/scripts/test/JS/JSTestGlobalObject.cpp:
     252        (WebCore::setJSTestGlobalObjectRegularAttribute):
     253        (WebCore::setJSTestGlobalObjectPublicAndPrivateAttribute):
     254        (WebCore::setJSTestGlobalObjectPublicAndPrivateConditionalAttribute):
     255        (WebCore::setJSTestGlobalObjectEnabledAtRuntimeAttribute):
     256        (WebCore::jsTestGlobalObjectInstanceFunctionRegularOperation):
     257        (WebCore::jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation1):
     258        (WebCore::jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation2):
     259        * bindings/scripts/test/JS/JSTestInterface.cpp:
     260        (WebCore::JSTestInterfaceConstructor::construct):
     261        (WebCore::setJSTestInterfaceConstructorImplementsStaticAttr):
     262        (WebCore::setJSTestInterfaceImplementsStr2):
     263        (WebCore::setJSTestInterfaceImplementsStr3):
     264        (WebCore::setJSTestInterfaceImplementsNode):
     265        (WebCore::setJSTestInterfaceConstructorSupplementalStaticAttr):
     266        (WebCore::setJSTestInterfaceSupplementalStr2):
     267        (WebCore::setJSTestInterfaceSupplementalStr3):
     268        (WebCore::setJSTestInterfaceSupplementalNode):
     269        (WebCore::jsTestInterfacePrototypeFunctionImplementsMethod2):
     270        (WebCore::jsTestInterfacePrototypeFunctionSupplementalMethod2):
     271        * bindings/scripts/test/JS/JSTestJSBuiltinConstructor.cpp:
     272        (WebCore::setJSTestJSBuiltinConstructorTestAttributeRWCustom):
     273        * bindings/scripts/test/JS/JSTestNamedConstructor.cpp:
     274        (WebCore::JSTestNamedConstructorNamedConstructor::construct):
     275        * bindings/scripts/test/JS/JSTestNode.cpp:
     276        (WebCore::setJSTestNodeName):
     277        * bindings/scripts/test/JS/JSTestNondeterministic.cpp:
     278        (WebCore::setJSTestNondeterministicNondeterministicWriteableAttr):
     279        (WebCore::setJSTestNondeterministicNondeterministicExceptionAttr):
     280        (WebCore::setJSTestNondeterministicNondeterministicGetterExceptionAttr):
     281        (WebCore::setJSTestNondeterministicNondeterministicSetterExceptionAttr):
     282        * bindings/scripts/test/JS/JSTestObj.cpp:
     283        (WebCore::convertDictionary<TestObj::Dictionary>):
     284        (WebCore::convertDictionary<TestObj::DictionaryThatShouldNotTolerateNull>):
     285        (WebCore::convertDictionary<TestObj::DictionaryThatShouldTolerateNull>):
     286        (WebCore::convertDictionary<AlternateDictionaryName>):
     287        (WebCore::setJSTestObjConstructorStaticStringAttr):
     288        (WebCore::setJSTestObjTestSubObjEnabledBySettingConstructor):
     289        (WebCore::setJSTestObjEnumAttr):
     290        (WebCore::setJSTestObjByteAttr):
     291        (WebCore::setJSTestObjOctetAttr):
     292        (WebCore::setJSTestObjShortAttr):
     293        (WebCore::setJSTestObjClampedShortAttr):
     294        (WebCore::setJSTestObjEnforceRangeShortAttr):
     295        (WebCore::setJSTestObjUnsignedShortAttr):
     296        (WebCore::setJSTestObjLongAttr):
     297        (WebCore::setJSTestObjLongLongAttr):
     298        (WebCore::setJSTestObjUnsignedLongLongAttr):
     299        (WebCore::setJSTestObjStringAttr):
     300        (WebCore::setJSTestObjUsvstringAttr):
     301        (WebCore::setJSTestObjTestObjAttr):
     302        (WebCore::setJSTestObjTestNullableObjAttr):
     303        (WebCore::setJSTestObjLenientTestObjAttr):
     304        (WebCore::setJSTestObjStringAttrTreatingNullAsEmptyString):
     305        (WebCore::setJSTestObjUsvstringAttrTreatingNullAsEmptyString):
     306        (WebCore::setJSTestObjImplementationEnumAttr):
     307        (WebCore::setJSTestObjXMLObjAttr):
     308        (WebCore::setJSTestObjCreate):
     309        (WebCore::setJSTestObjReflectedStringAttr):
     310        (WebCore::setJSTestObjReflectedUSVStringAttr):
     311        (WebCore::setJSTestObjReflectedIntegralAttr):
     312        (WebCore::setJSTestObjReflectedUnsignedIntegralAttr):
     313        (WebCore::setJSTestObjReflectedBooleanAttr):
     314        (WebCore::setJSTestObjReflectedURLAttr):
     315        (WebCore::setJSTestObjReflectedUSVURLAttr):
     316        (WebCore::setJSTestObjReflectedCustomIntegralAttr):
     317        (WebCore::setJSTestObjReflectedCustomBooleanAttr):
     318        (WebCore::setJSTestObjReflectedCustomURLAttr):
     319        (WebCore::setJSTestObjEnabledAtRuntimeAttribute):
     320        (WebCore::setJSTestObjTypedArrayAttr):
     321        (WebCore::setJSTestObjAttrWithGetterException):
     322        (WebCore::setJSTestObjAttrWithGetterExceptionWithMessage):
     323        (WebCore::setJSTestObjAttrWithSetterException):
     324        (WebCore::setJSTestObjAttrWithSetterExceptionWithMessage):
     325        (WebCore::setJSTestObjStringAttrWithGetterException):
     326        (WebCore::setJSTestObjStringAttrWithSetterException):
     327        (WebCore::setJSTestObjCustomAttr):
     328        (WebCore::setJSTestObjOnfoo):
     329        (WebCore::setJSTestObjOnwebkitfoo):
     330        (WebCore::setJSTestObjWithScriptStateAttribute):
     331        (WebCore::setJSTestObjWithCallWithAndSetterCallWithAttribute):
     332        (WebCore::setJSTestObjWithScriptExecutionContextAttribute):
     333        (WebCore::setJSTestObjWithScriptStateAttributeRaises):
     334        (WebCore::setJSTestObjWithScriptExecutionContextAttributeRaises):
     335        (WebCore::setJSTestObjWithScriptExecutionContextAndScriptStateAttribute):
     336        (WebCore::setJSTestObjWithScriptExecutionContextAndScriptStateAttributeRaises):
     337        (WebCore::setJSTestObjWithScriptExecutionContextAndScriptStateWithSpacesAttribute):
     338        (WebCore::setJSTestObjWithScriptArgumentsAndCallStackAttribute):
     339        (WebCore::setJSTestObjConditionalAttr1):
     340        (WebCore::setJSTestObjConditionalAttr2):
     341        (WebCore::setJSTestObjConditionalAttr3):
     342        (WebCore::setJSTestObjConditionalAttr4Constructor):
     343        (WebCore::setJSTestObjConditionalAttr5Constructor):
     344        (WebCore::setJSTestObjConditionalAttr6Constructor):
     345        (WebCore::setJSTestObjAnyAttribute):
     346        (WebCore::setJSTestObjMutablePoint):
     347        (WebCore::setJSTestObjImmutablePoint):
     348        (WebCore::setJSTestObjStrawberry):
     349        (WebCore::setJSTestObjId):
     350        (WebCore::setJSTestObjReplaceableAttribute):
     351        (WebCore::setJSTestObjNullableLongSettableAttribute):
     352        (WebCore::setJSTestObjNullableStringSettableAttribute):
     353        (WebCore::setJSTestObjNullableUSVStringSettableAttribute):
     354        (WebCore::setJSTestObjNullableStringValue):
     355        (WebCore::setJSTestObjAttributeWithReservedEnumType):
     356        (WebCore::setJSTestObjPutForwardsAttribute):
     357        (WebCore::setJSTestObjPutForwardsNullableAttribute):
     358        (WebCore::setJSTestObjStringifierAttribute):
     359        (WebCore::jsTestObjPrototypeFunctionEnabledAtRuntimeOperation1):
     360        (WebCore::jsTestObjPrototypeFunctionEnabledAtRuntimeOperation2):
     361        (WebCore::jsTestObjPrototypeFunctionVoidMethodWithArgs):
     362        (WebCore::jsTestObjPrototypeFunctionByteMethodWithArgs):
     363        (WebCore::jsTestObjPrototypeFunctionOctetMethodWithArgs):
     364        (WebCore::jsTestObjPrototypeFunctionLongMethodWithArgs):
     365        (WebCore::jsTestObjPrototypeFunctionObjMethodWithArgs):
     366        (WebCore::jsTestObjPrototypeFunctionMethodWithArgTreatingNullAsEmptyString):
     367        (WebCore::jsTestObjPrototypeFunctionMethodWithXPathNSResolverParameter):
     368        (WebCore::jsTestObjPrototypeFunctionNullableStringSpecialMethod):
     369        (WebCore::jsTestObjPrototypeFunctionMethodWithEnumArg):
     370        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalEnumArg):
     371        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalEnumArgAndDefaultValue):
     372        (WebCore::jsTestObjPrototypeFunctionMethodThatRequiresAllArgsAndThrows):
     373        (WebCore::jsTestObjPrototypeFunctionMethodWithUSVStringArg):
     374        (WebCore::jsTestObjPrototypeFunctionMethodWithNullableUSVStringArg):
     375        (WebCore::jsTestObjPrototypeFunctionMethodWithUSVStringArgTreatingNullAsEmptyString):
     376        (WebCore::jsTestObjPrototypeFunctionSerializedValue):
     377        (WebCore::jsTestObjPrototypeFunctionPrivateMethod):
     378        (WebCore::jsTestObjPrototypeFunctionPublicAndPrivateMethod):
     379        (WebCore::jsTestObjPrototypeFunctionAddEventListener):
     380        (WebCore::jsTestObjPrototypeFunctionRemoveEventListener):
     381        (WebCore::jsTestObjPrototypeFunctionWithScriptStateObj):
     382        (WebCore::jsTestObjPrototypeFunctionWithScriptStateObjException):
     383        (WebCore::jsTestObjPrototypeFunctionWithScriptExecutionContextAndScriptStateObjException):
     384        (WebCore::jsTestObjPrototypeFunctionWithScriptExecutionContextAndScriptStateWithSpaces):
     385        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalArg):
     386        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalArgAndDefaultValue):
     387        (WebCore::jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg):
     388        (WebCore::jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndTwoOptionalArgs):
     389        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalString):
     390        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalUSVString):
     391        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalAtomicString):
     392        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalStringAndDefaultValue):
     393        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalAtomicStringAndDefaultValue):
     394        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalStringIsNull):
     395        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalStringIsUndefined):
     396        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalAtomicStringIsNull):
     397        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalStringIsEmptyString):
     398        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalUSVStringIsEmptyString):
     399        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalAtomicStringIsEmptyString):
     400        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalDoubleIsNaN):
     401        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalFloatIsNaN):
     402        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalLongLong):
     403        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalLongLongIsZero):
     404        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalUnsignedLongLong):
     405        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalUnsignedLongLongIsZero):
     406        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalSequence):
     407        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalSequenceIsEmpty):
     408        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalBoolean):
     409        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalBooleanIsFalse):
     410        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalXPathNSResolver):
     411        (WebCore::jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackArg):
     412        (WebCore::jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackFunctionArg):
     413        (WebCore::jsTestObjPrototypeFunctionOverloadedMethod1):
     414        (WebCore::jsTestObjPrototypeFunctionOverloadedMethod2):
     415        (WebCore::jsTestObjPrototypeFunctionOverloadedMethod3):
     416        (WebCore::jsTestObjPrototypeFunctionOverloadedMethod4):
     417        (WebCore::jsTestObjPrototypeFunctionOverloadedMethod7):
     418        (WebCore::jsTestObjPrototypeFunctionOverloadedMethod9):
     419        (WebCore::jsTestObjPrototypeFunctionOverloadedMethod10):
     420        (WebCore::jsTestObjPrototypeFunctionOverloadedMethod11):
     421        (WebCore::jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter1):
     422        (WebCore::jsTestObjPrototypeFunctionOverloadedMethodWithOptionalParameter2):
     423        (WebCore::jsTestObjConstructorFunctionClassMethodWithOptional):
     424        (WebCore::jsTestObjConstructorFunctionOverloadedMethod11):
     425        (WebCore::jsTestObjConstructorFunctionOverloadedMethod12):
     426        (WebCore::jsTestObjPrototypeFunctionClassMethodWithClamp):
     427        (WebCore::jsTestObjPrototypeFunctionClassMethodWithEnforceRange):
     428        (WebCore::jsTestObjPrototypeFunctionMethodWithUnsignedLongSequence):
     429        (WebCore::jsTestObjPrototypeFunctionStringArrayFunction):
     430        (WebCore::jsTestObjPrototypeFunctionMethodWithAndWithoutNullableSequence):
     431        (WebCore::jsTestObjPrototypeFunctionGetElementById):
     432        (WebCore::jsTestObjPrototypeFunctionConvert3):
     433        (WebCore::jsTestObjPrototypeFunctionConvert4):
     434        (WebCore::jsTestObjPrototypeFunctionVariadicStringMethod):
     435        (WebCore::jsTestObjPrototypeFunctionVariadicDoubleMethod):
     436        (WebCore::jsTestObjPrototypeFunctionAny):
     437        (WebCore::jsTestObjPrototypeFunctionTestPromiseFunctionWithFloatArgumentPromise):
     438        (WebCore::jsTestObjPrototypeFunctionTestPromiseFunctionWithOptionalIntArgumentPromise):
     439        (WebCore::jsTestObjPrototypeFunctionTestPromiseOverloadedFunction1Promise):
     440        (WebCore::jsTestObjPrototypeFunctionConditionalOverload1):
     441        (WebCore::jsTestObjPrototypeFunctionConditionalOverload2):
     442        (WebCore::jsTestObjPrototypeFunctionSingleConditionalOverload1):
     443        (WebCore::jsTestObjPrototypeFunctionSingleConditionalOverload2):
     444        (WebCore::jsTestObjPrototypeFunctionAttachShadowRoot):
     445        * bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
     446        (WebCore::constructJSTestOverloadedConstructors1):
     447        (WebCore::constructJSTestOverloadedConstructors2):
     448        (WebCore::constructJSTestOverloadedConstructors4):
     449        (WebCore::constructJSTestOverloadedConstructors5):
     450        * bindings/scripts/test/JS/JSTestOverloadedConstructorsWithSequence.cpp:
     451        (WebCore::constructJSTestOverloadedConstructorsWithSequence1):
     452        (WebCore::constructJSTestOverloadedConstructorsWithSequence2):
     453        * bindings/scripts/test/JS/JSTestOverrideBuiltins.cpp:
     454        (WebCore::jsTestOverrideBuiltinsPrototypeFunctionNamedItem):
     455        * bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp:
     456        (WebCore::setJSTestSerializedScriptValueInterfaceValue):
     457        (WebCore::setJSTestSerializedScriptValueInterfaceCachedValue):
     458        * bindings/scripts/test/JS/JSTestTypedefs.cpp:
     459        (WebCore::JSTestTypedefsConstructor::construct):
     460        (WebCore::setJSTestTypedefsUnsignedLongLongAttr):
     461        (WebCore::setJSTestTypedefsImmutableSerializedScriptValue):
     462        (WebCore::setJSTestTypedefsAttrWithGetterException):
     463        (WebCore::setJSTestTypedefsAttrWithSetterException):
     464        (WebCore::setJSTestTypedefsStringAttrWithGetterException):
     465        (WebCore::setJSTestTypedefsStringAttrWithSetterException):
     466        (WebCore::jsTestTypedefsPrototypeFunctionFunc):
     467        (WebCore::jsTestTypedefsPrototypeFunctionSetShadow):
     468        (WebCore::jsTestTypedefsPrototypeFunctionMethodWithSequenceArg):
     469        (WebCore::jsTestTypedefsPrototypeFunctionNullableSequenceArg):
     470        (WebCore::jsTestTypedefsPrototypeFunctionFuncWithClamp):
     471        (WebCore::jsTestTypedefsPrototypeFunctionStringSequenceFunction):
     472        (WebCore::jsTestTypedefsPrototypeFunctionStringSequenceFunction2):
     473        (WebCore::jsTestTypedefsPrototypeFunctionCallWithSequenceThatRequiresInclude):
     474        * bridge/NP_jsobject.cpp:
     475        (_NPN_InvokeDefault):
     476        (_NPN_Invoke):
     477        (_NPN_Evaluate):
     478        (_NPN_GetProperty):
     479        (_NPN_SetProperty):
     480        (_NPN_RemoveProperty):
     481        (_NPN_HasProperty):
     482        (_NPN_HasMethod):
     483        (_NPN_Enumerate):
     484        (_NPN_Construct):
     485        * bridge/c/c_instance.cpp:
     486        (JSC::Bindings::CInstance::moveGlobalExceptionToExecState):
     487        * bridge/objc/WebScriptObject.mm:
     488        (WebCore::addExceptionToConsole):
     489        (-[WebScriptObject callWebScriptMethod:withArguments:]):
     490        (-[WebScriptObject evaluateWebScript:]):
     491        (-[WebScriptObject setValue:forKey:]):
     492        (-[WebScriptObject valueForKey:]):
     493        (-[WebScriptObject removeWebScriptKey:]):
     494        (-[WebScriptObject hasWebScriptKey:]):
     495        (-[WebScriptObject webScriptValueAtIndex:]):
     496        (-[WebScriptObject setWebScriptValueAtIndex:value:]):
     497        * contentextensions/ContentExtensionParser.cpp:
     498        (WebCore::ContentExtensions::getDomainList):
     499        (WebCore::ContentExtensions::getTypeFlags):
     500        (WebCore::ContentExtensions::loadTrigger):
     501        (WebCore::ContentExtensions::loadAction):
     502        (WebCore::ContentExtensions::loadEncodedRules):
     503        * html/HTMLMediaElement.cpp:
     504        (WebCore::controllerJSValue):
     505        (WebCore::HTMLMediaElement::updateCaptionContainer):
     506        (WebCore::HTMLMediaElement::ensureMediaControlsInjectedScript):
     507        (WebCore::HTMLMediaElement::didAddUserAgentShadowRoot):
     508        (WebCore::HTMLMediaElement::updateMediaControlsAfterPresentationModeChange):
     509        (WebCore::HTMLMediaElement::getCurrentMediaControlsStatus):
     510        * html/HTMLPlugInImageElement.cpp:
     511        (WebCore::HTMLPlugInImageElement::didAddUserAgentShadowRoot):
     512
    15132016-09-07  Chris Dumez  <cdumez@apple.com>
    2514
  • trunk/Source/WebCore/Modules/encryptedmedia/CDMSessionClearKey.cpp

    r195452 r205569  
    112112        VM& vm = clearKeyVM();
    113113        JSLockHolder lock(vm);
     114        auto scope = DECLARE_THROW_SCOPE(vm);
    114115        JSGlobalObject* globalObject = JSGlobalObject::create(vm, JSGlobalObject::createStructure(vm, jsNull()));
    115116        ExecState* exec = globalObject->globalExec();
     
    117118        JSLockHolder locker(clearKeyVM());
    118119        JSValue keysDataObject = JSONParse(exec, rawKeysString);
    119         if (exec->hadException() || !keysDataObject) {
     120        if (scope.exception() || !keysDataObject) {
    120121            LOG(Media, "CDMSessionClearKey::update(%p) - failed: invalid JSON", this);
    121122            break;
  • trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp

    r204018 r205569  
    237237RefPtr<IDBRequest> IDBObjectStore::putOrAdd(ExecState& state, JSValue value, RefPtr<IDBKey> key, IndexedDB::ObjectStoreOverwriteMode overwriteMode, InlineKeyCheck inlineKeyCheck, ExceptionCodeWithMessage& ec)
    238238{
     239    VM& vm = state.vm();
     240    auto scope = DECLARE_CATCH_SCOPE(vm);
     241
    239242    LOG(IndexedDB, "IDBObjectStore::putOrAdd");
    240243    ASSERT(currentThread() == m_transaction->database().originThreadID());
     
    271274
    272275    RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::create(&state, value, nullptr, nullptr);
    273     if (state.hadException()) {
     276    if (UNLIKELY(scope.exception())) {
    274277        // Clear the DOM exception from the serializer so we can give a more targeted exception.
    275         state.clearException();
     278        scope.clearException();
    276279
    277280        ec.code = IDBDatabaseException::DataCloneError;
  • trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp

    r205462 r205569  
    860860    ThreadSafeDataBuffer injectedRecordValue;
    861861    if (usedKeyIsGenerated && !objectStoreInfo->keyPath().isNull()) {
    862         JSLockHolder locker(databaseThreadVM());
     862        VM& vm = databaseThreadVM();
     863        JSLockHolder locker(vm);
     864        auto scope = DECLARE_THROW_SCOPE(vm);
    863865
    864866        auto value = deserializeIDBValueToJSValue(databaseThreadExecState(), originalRecordValue.data());
     
    874876
    875877        auto serializedValue = SerializedScriptValue::create(&databaseThreadExecState(), value, nullptr, nullptr);
    876         if (databaseThreadExecState().hadException()) {
     878        if (UNLIKELY(scope.exception())) {
    877879            postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, IDBError(IDBDatabaseException::ConstraintError, ASCIILiteral("Unable to serialize record value after injecting record key")), usedKey));
    878880            return;
  • trunk/Source/WebCore/Modules/mediastream/SDPProcessor.cpp

    r201728 r205569  
    11/*
    22 * Copyright (C) 2015, 2016 Ericsson AB. All rights reserved.
     3 * Copyright (C) 2016 Apple Inc. All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    501502    ScriptController& scriptController = document->frame()->script();
    502503    JSDOMGlobalObject* globalObject = JSC::jsCast<JSDOMGlobalObject*>(scriptController.globalObject(*m_isolatedWorld));
     504    JSC::VM& vm = globalObject->vm();
     505    JSC::JSLockHolder lock(vm);
     506    auto scope = DECLARE_CATCH_SCOPE(vm);
    503507    JSC::ExecState* exec = globalObject->globalExec();
    504     JSC::JSLockHolder lock(exec);
    505508
    506509    JSC::JSValue probeFunctionValue = globalObject->get(exec, JSC::Identifier::fromString(exec, "generate"));
     
    508511        URL scriptURL;
    509512        scriptController.evaluateInWorld(ScriptSourceCode(SDPProcessorScriptResource::scriptString(), scriptURL), *m_isolatedWorld);
    510         if (exec->hadException()) {
    511             exec->clearException();
     513        if (UNLIKELY(scope.exception())) {
     514            scope.clearException();
    512515            return false;
    513516        }
     
    528531
    529532    JSC::JSValue result = JSC::call(exec, function, callType, callData, globalObject, argList);
    530     if (exec->hadException()) {
     533    if (UNLIKELY(scope.exception())) {
    531534        LOG_ERROR("SDPProcessor script threw in function %s", functionName.ascii().data());
    532         exec->clearException();
     535        scope.clearException();
    533536        return false;
    534537    }
  • trunk/Source/WebCore/Modules/plugins/QuickTimePluginReplacement.mm

    r205271 r205569  
    161161    ScriptController& scriptController = m_parentElement->document().frame()->script();
    162162    JSDOMGlobalObject* globalObject = JSC::jsCast<JSDOMGlobalObject*>(scriptController.globalObject(world));
     163    JSC::VM& vm = globalObject->vm();
     164    JSC::JSLockHolder lock(vm);
     165    auto scope = DECLARE_CATCH_SCOPE(vm);
    163166    JSC::ExecState* exec = globalObject->globalExec();
    164     JSC::JSLockHolder lock(exec);
    165167   
    166168    JSC::JSValue replacementFunction = globalObject->get(exec, JSC::Identifier::fromString(exec, "createPluginReplacement"));
     
    169171   
    170172    scriptController.evaluateInWorld(ScriptSourceCode(quickTimePluginReplacementScript()), world);
    171     if (exec->hadException()) {
     173    if (UNLIKELY(scope.exception())) {
    172174        LOG(Plugins, "%p - Exception when evaluating QuickTime plugin replacement script", this);
    173         exec->clearException();
     175        scope.clearException();
    174176        return false;
    175177    }
     
    189191    ScriptController& scriptController = m_parentElement->document().frame()->script();
    190192    JSDOMGlobalObject* globalObject = JSC::jsCast<JSDOMGlobalObject*>(scriptController.globalObject(world));
     193    JSC::VM& vm = globalObject->vm();
     194    JSC::JSLockHolder lock(vm);
     195    auto scope = DECLARE_CATCH_SCOPE(vm);
    191196    JSC::ExecState* exec = globalObject->globalExec();
    192     JSC::JSLockHolder lock(exec);
    193    
     197
    194198    // Lookup the "createPluginReplacement" function.
    195199    JSC::JSValue replacementFunction = globalObject->get(exec, JSC::Identifier::fromString(exec, "createPluginReplacement"));
     
    197201        return false;
    198202    JSC::JSObject* replacementObject = replacementFunction.toObject(exec);
    199     ASSERT(!exec->hadException());
     203    ASSERT(!scope.exception());
    200204    JSC::CallData callData;
    201205    JSC::CallType callType = replacementObject->methodTable()->getCallData(replacementObject, callData);
     
    210214    argList.append(toJS<String>(exec, globalObject, m_values));
    211215    JSC::JSValue replacement = call(exec, replacementObject, callType, callData, globalObject, argList);
    212     if (exec->hadException()) {
    213         exec->clearException();
     216    if (UNLIKELY(scope.exception())) {
     217        scope.clearException();
    214218        return false;
    215219    }
     
    217221    // Get the <video> created to replace the plug-in.
    218222    JSC::JSValue value = replacement.get(exec, JSC::Identifier::fromString(exec, "video"));
    219     if (!exec->hadException() && !value.isUndefinedOrNull())
     223    if (!scope.exception() && !value.isUndefinedOrNull())
    220224        m_mediaElement = JSHTMLVideoElement::toWrapped(value);
    221225
    222226    if (!m_mediaElement) {
    223227        LOG(Plugins, "%p - Failed to find <video> element created by QuickTime plugin replacement script.", this);
    224         exec->clearException();
     228        scope.clearException();
    225229        return false;
    226230    }
     
    228232    // Get the scripting interface.
    229233    value = replacement.get(exec, JSC::Identifier::fromString(exec, "scriptObject"));
    230     if (!exec->hadException() && !value.isUndefinedOrNull()) {
     234    if (!scope.exception() && !value.isUndefinedOrNull()) {
    231235        m_scriptObject = value.toObject(exec);
    232         ASSERT(!exec->hadException());
     236        ASSERT(!scope.exception());
    233237    }
    234238
    235239    if (!m_scriptObject) {
    236240        LOG(Plugins, "%p - Failed to find script object created by QuickTime plugin replacement.", this);
    237         exec->clearException();
     241        scope.clearException();
    238242        return false;
    239243    }
  • trunk/Source/WebCore/bindings/js/ArrayValue.cpp

    r195781 r205569  
    8383bool ArrayValue::get(size_t index, String& value) const
    8484{
     85    VM& vm = m_exec->vm();
     86    auto scope = DECLARE_THROW_SCOPE(vm);
     87
    8588    if (isUndefinedOrNull())
    8689        return false;
     
    9194
    9295    value = indexedValue.toWTFString(m_exec);
    93     if (m_exec->hadException())
     96    if (UNLIKELY(scope.exception()))
    9497        return false;
    9598
  • trunk/Source/WebCore/bindings/js/Dictionary.cpp

    r187355 r205569  
    6262    JSObject* object =  m_dictionary.initializerObject();
    6363    ExecState* exec = m_dictionary.execState();
     64    VM& vm = exec->vm();
     65    auto scope = DECLARE_THROW_SCOPE(vm);
    6466
    6567    PropertyNameArray propertyNames(exec, PropertyNameMode::Strings);
     
    7072            continue;
    7173        JSValue value = object->get(exec, *it);
    72         if (exec->hadException())
     74        if (UNLIKELY(scope.exception()))
    7375            continue;
    7476        String stringValue = value.toString(exec)->value(exec);
    75         if (!exec->hadException())
     77        if (LIKELY(!scope.exception()))
    7678            map.set(stringKey, stringValue);
    7779    }
  • trunk/Source/WebCore/bindings/js/IDBBindingUtilities.cpp

    r203065 r205569  
    9191    VM& vm = state.vm();
    9292    Locker<JSLock> locker(vm.apiLock());
     93    auto scope = DECLARE_THROW_SCOPE(vm);
    9394
    9495    switch (key->type()) {
     
    9798        unsigned size = inArray.size();
    9899        auto outArray = constructEmptyArray(&state, 0, &globalObject, size);
    99         if (UNLIKELY(vm.exception()))
     100        if (UNLIKELY(scope.exception()))
    100101            return jsUndefined();
    101102        for (size_t i = 0; i < size; ++i)
  • trunk/Source/WebCore/bindings/js/JSApplePaySessionCustom.cpp

    r205198 r205569  
    5656    ExceptionCode ec = 0;
    5757    uint16_t status = convert<uint16_t>(state, state.argument(0), NormalConversion);
    58     if (UNLIKELY(state.hadException()))
     58    if (UNLIKELY(scope.exception()))
    5959        return jsUndefined();
    6060
    6161    Dictionary newTotal = { &state, state.argument(1) };
    62     if (UNLIKELY(state.hadException()))
     62    if (UNLIKELY(scope.exception()))
    6363        return jsUndefined();
    6464
    6565    ArrayValue newLineItems { &state, state.argument(2) };
    66     if (UNLIKELY(state.hadException()))
     66    if (UNLIKELY(scope.exception()))
    6767        return jsUndefined();
    6868    impl.completeShippingMethodSelection(status, newTotal, newLineItems, ec);
     
    8989    ExceptionCode ec = 0;
    9090    uint16_t status = convert<uint16_t>(state, state.argument(0), NormalConversion);
    91     if (UNLIKELY(state.hadException()))
     91    if (UNLIKELY(scope.exception()))
    9292        return jsUndefined();
    9393
    9494    ArrayValue newShippingMethods { &state, state.argument(1) };
    95     if (UNLIKELY(state.hadException()))
     95    if (UNLIKELY(scope.exception()))
    9696        return jsUndefined();
    9797
    9898    Dictionary newTotal = { &state, state.argument(2) };
    99     if (UNLIKELY(state.hadException()))
     99    if (UNLIKELY(scope.exception()))
    100100        return jsUndefined();
    101101
    102102    ArrayValue newLineItems { &state, state.argument(3) };
    103     if (UNLIKELY(state.hadException()))
     103    if (UNLIKELY(scope.exception()))
    104104        return jsUndefined();
    105105    impl.completeShippingContactSelection(status, newShippingMethods, newTotal, newLineItems, ec);
     
    126126    ExceptionCode ec = 0;
    127127    Dictionary newTotal = { &state, state.argument(0) };
    128     if (UNLIKELY(state.hadException()))
     128    if (UNLIKELY(scope.exception()))
    129129        return jsUndefined();
    130130
    131131    ArrayValue newLineItems { &state, state.argument(1) };
    132     if (UNLIKELY(state.hadException()))
     132    if (UNLIKELY(scope.exception()))
    133133        return jsUndefined();
    134134    impl.completePaymentMethodSelection(newTotal, newLineItems, ec);
  • trunk/Source/WebCore/bindings/js/JSAudioTrackCustom.cpp

    r191887 r205569  
    4444{
    4545#if ENABLE(MEDIA_SOURCE)
     46    VM& vm = state.vm();
     47    auto scope = DECLARE_THROW_SCOPE(vm);
     48
    4649    auto& string = value.toString(&state)->value(&state);
    47     if (state.hadException())
     50    if (UNLIKELY(scope.exception()))
    4851        return;
    4952    wrapped().setKind(string);
     
    5760{
    5861#if ENABLE(MEDIA_SOURCE)
     62    VM& vm = state.vm();
     63    auto scope = DECLARE_THROW_SCOPE(vm);
     64
    5965    auto& string = value.toString(&state)->value(&state);
    60     if (state.hadException())
     66    if (UNLIKELY(scope.exception()))
    6167        return;
    6268    wrapped().setLanguage(string);
  • trunk/Source/WebCore/bindings/js/JSBlobCustom.cpp

    r205422 r205569  
    8181    unsigned blobPartsLength = 0;
    8282    JSObject* blobParts = toJSSequence(exec, exec.uncheckedArgument(0), blobPartsLength);
    83     if (exec.hadException())
     83    if (UNLIKELY(scope.exception()))
    8484        return JSValue::encode(jsUndefined());
    8585    ASSERT(blobParts);
     
    102102        // Attempt to get the endings property and validate it.
    103103        bool containsEndings = dictionary.get("endings", endings);
    104         if (exec.hadException())
     104        if (UNLIKELY(scope.exception()))
    105105            return JSValue::encode(jsUndefined());
    106106
     
    112112        // Attempt to get the type property.
    113113        dictionary.get("type", type);
    114         if (exec.hadException())
     114        if (UNLIKELY(scope.exception()))
    115115            return JSValue::encode(jsUndefined());
    116116    }
     
    122122    for (unsigned i = 0; i < blobPartsLength; ++i) {
    123123        JSValue item = blobParts->get(&exec, i);
    124         if (exec.hadException())
     124        if (UNLIKELY(scope.exception()))
    125125            return JSValue::encode(jsUndefined());
    126126
     
    133133        else {
    134134            String string = item.toWTFString(&exec);
    135             if (exec.hadException())
     135            if (UNLIKELY(scope.exception()))
    136136                return JSValue::encode(jsUndefined());
    137137            blobBuilder.append(string, endings);
  • trunk/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp

    r205198 r205569  
    356356
    357357    String propertyName = state.uncheckedArgument(0).toWTFString(&state);
    358     if (state.hadException())
     358    if (UNLIKELY(scope.exception()))
    359359        return jsUndefined();
    360360
  • trunk/Source/WebCore/bindings/js/JSCommandLineAPIHostCustom.cpp

    r204499 r205569  
    6969{
    7070    VM& vm = state.vm();
     71    auto scope = DECLARE_THROW_SCOPE(vm);
    7172    JSArray* result = constructEmptyArray(&state, nullptr);
    72     if (UNLIKELY(vm.exception()))
     73    if (UNLIKELY(scope.exception()))
    7374        return nullptr;
    7475    size_t handlersCount = listenerInfo.eventListenerVector.size();
  • trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmDictionary.cpp

    r205198 r205569  
    8181    }
    8282
    83     if (exec->hadException())
     83    if (UNLIKELY(scope.exception()))
    8484        return false;
    8585
     
    107107
    108108    ExecState* exec = dictionary.execState();
     109    VM& vm = exec->vm();
     110    auto scope = DECLARE_THROW_SCOPE(vm);
    109111    JSObject* object = dictionary.initializerObject();
    110112
     
    112114
    113115    JSValue hash = getProperty(exec, object, "hash");
    114     if (exec->hadException())
     116    if (UNLIKELY(scope.exception()))
    115117        return false;
    116118
     
    135137
    136138    JSValue iv = getProperty(exec, value.getObject(), "iv");
    137     if (exec->hadException())
     139    if (UNLIKELY(scope.exception()))
    138140        return nullptr;
    139141
     
    141143
    142144    CryptoOperationData ivData;
    143     if (!cryptoOperationDataFromJSValue(exec, iv, ivData)) {
    144         ASSERT(exec->hadException());
    145         return nullptr;
    146     }
     145    auto success = cryptoOperationDataFromJSValue(exec, iv, ivData);
     146    ASSERT(scope.exception() || success);
     147    if (!success)
     148        return nullptr;
    147149
    148150    if (ivData.second != 16) {
     
    169171
    170172    JSValue lengthValue = getProperty(&state, value.getObject(), "length");
    171     if (state.hadException())
     173    if (UNLIKELY(scope.exception()))
    172174        return nullptr;
    173175
     
    190192    auto result = adoptRef(*new CryptoAlgorithmHmacParams);
    191193
    192     if (!getHashAlgorithm(jsDictionary, result->hash, HashRequirement::Required)) {
    193         ASSERT(state.hadException());
    194         return nullptr;
    195     }
     194    auto success = getHashAlgorithm(jsDictionary, result->hash, HashRequirement::Required);
     195    ASSERT_UNUSED(scope, scope.exception() || success);
     196    if (!success)
     197        return nullptr;
    196198
    197199    return WTFMove(result);
     
    211213    auto result = adoptRef(*new CryptoAlgorithmHmacKeyParams);
    212214
    213     if (!getHashAlgorithm(jsDictionary, result->hash, HashRequirement::Required)) {
    214         ASSERT(state.hadException());
    215         return nullptr;
    216     }
     215    auto success = getHashAlgorithm(jsDictionary, result->hash, HashRequirement::Required);
     216    ASSERT(scope.exception() || success);
     217    if (!success)
     218        return nullptr;
    217219
    218220    result->hasLength = jsDictionary.get("length", result->length);
    219     if (state.hadException())
     221    if (UNLIKELY(scope.exception()))
    220222        return nullptr;
    221223
     
    237239
    238240    JSValue modulusLengthValue = getProperty(&state, value.getObject(), "modulusLength");
    239     if (state.hadException())
     241    if (UNLIKELY(scope.exception()))
    240242        return nullptr;
    241243
    242244    // FIXME: Why no EnforceRange? Filed as <https://www.w3.org/Bugs/Public/show_bug.cgi?id=23779>.
    243245    result->modulusLength = convert<uint32_t>(state, modulusLengthValue, NormalConversion);
    244     if (state.hadException())
     246    if (UNLIKELY(scope.exception()))
    245247        return nullptr;
    246248
    247249    JSValue publicExponentValue = getProperty(&state, value.getObject(), "publicExponent");
    248     if (state.hadException())
     250    if (UNLIKELY(scope.exception()))
    249251        return nullptr;
    250252
     
    280282    auto result = adoptRef(*new CryptoAlgorithmRsaOaepParams);
    281283
    282     if (!getHashAlgorithm(jsDictionary, result->hash, HashRequirement::Required)) {
    283         ASSERT(exec->hadException());
    284         return nullptr;
    285     }
     284    auto success = getHashAlgorithm(jsDictionary, result->hash, HashRequirement::Required);
     285    ASSERT(scope.exception() || success);
     286    if (!success)
     287        return nullptr;
    286288
    287289    JSValue labelValue = getProperty(exec, value.getObject(), "label");
    288     if (exec->hadException())
     290    if (UNLIKELY(scope.exception()))
    289291        return nullptr;
    290292
     
    294296
    295297    CryptoOperationData labelData;
    296     if (!cryptoOperationDataFromJSValue(exec, labelValue, labelData)) {
    297         ASSERT(exec->hadException());
    298         return nullptr;
    299     }
     298    success = cryptoOperationDataFromJSValue(exec, labelValue, labelData);
     299    ASSERT(scope.exception() || success);
     300    if (!success)
     301        return nullptr;
    300302
    301303    result->label.append(labelData.first, labelData.second);
     
    317319    auto result = adoptRef(*new CryptoAlgorithmRsaSsaParams);
    318320
    319     if (!getHashAlgorithm(jsDictionary, result->hash, HashRequirement::Required)) {
    320         ASSERT(state.hadException());
    321         return nullptr;
    322     }
     321    auto success = getHashAlgorithm(jsDictionary, result->hash, HashRequirement::Required);
     322    ASSERT(scope.exception() || success);
     323    if (!success)
     324        return nullptr;
    323325
    324326    return WTFMove(result);
  • trunk/Source/WebCore/bindings/js/JSCryptoKeySerializationJWK.cpp

    r205198 r205569  
    6363
    6464    JSValue value = slot.getValue(exec, identifier);
    65     ASSERT(!exec->hadException());
     65    ASSERT(!scope.exception());
    6666    if (!isJSArray(value)) {
    6767        throwTypeError(exec, scope, String::format("Expected an array for \"%s\" JSON key",  key));
     
    8686
    8787    JSValue jsValue = slot.getValue(exec, identifier);
    88     ASSERT(!exec->hadException());
     88    ASSERT(!scope.exception());
    8989    if (!jsValue.getString(exec, result)) {
    9090        // Can get an out of memory exception.
    91         if (exec->hadException())
     91        if (UNLIKELY(scope.exception()))
    9292            return false;
    9393        throwTypeError(exec, scope, String::format("Expected a string value for \"%s\" JSON key",  key));
     
    110110
    111111    JSValue jsValue = slot.getValue(exec, identifier);
    112     ASSERT(!exec->hadException());
     112    ASSERT(!scope.exception());
    113113    if (!jsValue.isBoolean()) {
    114114        throwTypeError(exec, scope, String::format("Expected a boolean value for \"%s\" JSON key",  key));
     
    149149
    150150    JSValue jsonValue = JSONParse(exec, jsonString);
    151     if (exec->hadException())
     151    if (UNLIKELY(scope.exception()))
    152152        return;
    153153
     
    299299            String operation;
    300300            if (!jsValue.getString(m_exec, operation)) {
    301                 if (!m_exec->hadException())
     301                if (!scope.exception())
    302302                    throwTypeError(m_exec, scope, ASCIILiteral("JWK key_ops attribute could not be processed"));
    303303                return;
     
    321321        }
    322322    } else {
    323         if (m_exec->hadException())
     323        if (UNLIKELY(scope.exception()))
    324324            return;
    325325
     
    392392    String keyBase64URL;
    393393    if (!getStringFromJSON(m_exec, m_json.get(), "k", keyBase64URL)) {
    394         if (!m_exec->hadException())
     394        if (!scope.exception())
    395395            throwTypeError(m_exec, scope, ASCIILiteral("Secret key data is not present is JWK"));
    396396        return nullptr;
     
    421421
    422422    if (!getBigIntegerVectorFromJSON(m_exec, m_json.get(), "n", modulus)) {
    423         if (!m_exec->hadException())
     423        if (!scope.exception())
    424424            throwTypeError(m_exec, scope, ASCIILiteral("Required JWK \"n\" member is missing"));
    425425        return nullptr;
     
    432432
    433433    if (!getBigIntegerVectorFromJSON(m_exec, m_json.get(), "e", exponent)) {
    434         if (!m_exec->hadException())
     434        if (!scope.exception())
    435435            throwTypeError(m_exec, scope, ASCIILiteral("Required JWK \"e\" member is missing"));
    436436        return nullptr;
     
    438438
    439439    if (!getBigIntegerVectorFromJSON(m_exec, m_json.get(), "d", modulus)) {
    440         if (m_exec->hadException())
     440        if (scope.exception())
    441441            return nullptr;
    442442        return CryptoKeyDataRSAComponents::createPublic(modulus, exponent);
     
    447447    Vector<CryptoKeyDataRSAComponents::PrimeInfo> otherPrimeInfos;
    448448    if (!getBigIntegerVectorFromJSON(m_exec, m_json.get(), "p", firstPrimeInfo.primeFactor)) {
    449         if (m_exec->hadException())
     449        if (scope.exception())
    450450            return nullptr;
    451451        return CryptoKeyDataRSAComponents::createPrivate(modulus, exponent, privateExponent);
     
    453453
    454454    if (!getBigIntegerVectorFromJSON(m_exec, m_json.get(), "dp", firstPrimeInfo.factorCRTExponent)) {
    455         if (m_exec->hadException())
     455        if (scope.exception())
    456456            return nullptr;
    457457        return CryptoKeyDataRSAComponents::createPrivate(modulus, exponent, privateExponent);
     
    459459
    460460    if (!getBigIntegerVectorFromJSON(m_exec, m_json.get(), "q", secondPrimeInfo.primeFactor)) {
    461         if (m_exec->hadException())
     461        if (scope.exception())
    462462            return nullptr;
    463463        return CryptoKeyDataRSAComponents::createPrivate(modulus, exponent, privateExponent);
     
    465465
    466466    if (!getBigIntegerVectorFromJSON(m_exec, m_json.get(), "dq", secondPrimeInfo.factorCRTExponent)) {
    467         if (m_exec->hadException())
     467        if (scope.exception())
    468468            return nullptr;
    469469        return CryptoKeyDataRSAComponents::createPrivate(modulus, exponent, privateExponent);
     
    471471
    472472    if (!getBigIntegerVectorFromJSON(m_exec, m_json.get(), "qi", secondPrimeInfo.factorCRTCoefficient)) {
    473         if (m_exec->hadException())
     473        if (scope.exception())
    474474            return nullptr;
    475475        return CryptoKeyDataRSAComponents::createPrivate(modulus, exponent, privateExponent);
     
    478478    JSArray* otherPrimeInfoJSArray;
    479479    if (!getJSArrayFromJSON(m_exec, m_json.get(), "oth", otherPrimeInfoJSArray)) {
    480         if (m_exec->hadException())
     480        if (scope.exception())
    481481            return nullptr;
    482482        return CryptoKeyDataRSAComponents::createPrivateWithAdditionalData(modulus, exponent, privateExponent, firstPrimeInfo, secondPrimeInfo, otherPrimeInfos);
     
    486486        CryptoKeyDataRSAComponents::PrimeInfo info;
    487487        JSValue element = otherPrimeInfoJSArray->getIndex(m_exec, i);
    488         if (m_exec->hadException())
     488        if (UNLIKELY(scope.exception()))
    489489            return nullptr;
    490490        if (!element.isObject()) {
     
    493493        }
    494494        if (!getBigIntegerVectorFromJSON(m_exec, asObject(element), "r", info.primeFactor)) {
    495             if (!m_exec->hadException())
     495            if (!scope.exception())
    496496                throwTypeError(m_exec, scope, ASCIILiteral("Cannot get prime factor for a prime in \"oth\" dictionary"));
    497497            return nullptr;
    498498        }
    499499        if (!getBigIntegerVectorFromJSON(m_exec, asObject(element), "d", info.factorCRTExponent)) {
    500             if (!m_exec->hadException())
     500            if (!scope.exception())
    501501                throwTypeError(m_exec, scope, ASCIILiteral("Cannot get factor CRT exponent for a prime in \"oth\" dictionary"));
    502502            return nullptr;
    503503        }
    504504        if (!getBigIntegerVectorFromJSON(m_exec, asObject(element), "t", info.factorCRTCoefficient)) {
    505             if (!m_exec->hadException())
     505            if (!scope.exception())
    506506                throwTypeError(m_exec, scope, ASCIILiteral("Cannot get factor CRT coefficient for a prime in \"oth\" dictionary"));
    507507            return nullptr;
     
    520520    String jwkKeyType;
    521521    if (!getStringFromJSON(m_exec, m_json.get(), "kty", jwkKeyType)) {
    522         if (!m_exec->hadException())
     522        if (!scope.exception())
    523523            throwTypeError(m_exec, scope, ASCIILiteral("Required JWK \"kty\" member is missing"));
    524524        return nullptr;
     
    550550static void buildJSONForRSAComponents(JSC::ExecState* exec, const CryptoKeyDataRSAComponents& data, JSC::JSObject* result)
    551551{
     552    VM& vm = exec->vm();
     553    auto scope = DECLARE_THROW_SCOPE(vm);
     554
    552555    addToJSON(exec, result, "kty", "RSA");
    553556    addToJSON(exec, result, "n", base64URLEncode(data.modulus()));
     
    571574        return;
    572575
    573     VM& vm = exec->vm();
    574576    JSArray* oth = constructEmptyArray(exec, 0, exec->lexicalGlobalObject(), data.otherPrimeInfos().size());
    575     if (UNLIKELY(vm.exception()))
     577    if (UNLIKELY(scope.exception()))
    576578        return;
    577579    for (size_t i = 0, size = data.otherPrimeInfos().size(); i < size; ++i) {
     
    699701{
    700702    VM& vm = exec->vm();
     703    auto scope = DECLARE_THROW_SCOPE(vm);
    701704    JSArray* keyOps = constructEmptyArray(exec, 0, exec->lexicalGlobalObject(), 0);
    702     if (UNLIKELY(vm.exception()))
     705    if (UNLIKELY(scope.exception()))
    703706        return;
    704707
     
    739742
    740743    addJWKAlgorithmToJSON(exec, result, key);
    741     if (exec->hadException())
     744    if (UNLIKELY(scope.exception()))
    742745        return String();
    743746
     
    745748
    746749    addUsagesToJSON(exec, result, key.usagesBitmap());
    747     if (exec->hadException())
     750    if (UNLIKELY(scope.exception()))
    748751        return String();
    749752
     
    756759        return String();
    757760    }
    758     if (exec->hadException())
     761    if (UNLIKELY(scope.exception()))
    759762        return String();
    760763
  • trunk/Source/WebCore/bindings/js/JSCustomElementInterface.cpp

    r205416 r205569  
    6969    VM& vm = m_isolatedWorld->vm();
    7070    JSLockHolder lock(vm);
     71    auto scope = DECLARE_CATCH_SCOPE(vm);
    7172
    7273    if (!m_constructor)
     
    8081    auto& state = *context->execState();
    8182    RefPtr<Element> element = constructCustomElementSynchronously(downcast<Document>(*context), vm, state, m_constructor.get(), localName);
     83    ASSERT(!!scope.exception() == !element);
    8284    if (!element) {
    83         auto* exception = vm.exception();
    84         ASSERT(exception);
    8585        if (shouldClearException == ShouldClearException::Clear) {
    86             state.clearException();
     86            auto* exception = scope.exception();
     87            scope.clearException();
    8788            reportException(&state, exception);
    8889        }
     
    111112    JSValue newElement = construct(&state, constructor, constructType, constructData, args);
    112113    InspectorInstrumentation::didCallFunction(cookie, &document);
    113     if (vm.exception())
     114    if (UNLIKELY(scope.exception()))
    114115        return nullptr;
    115116
     
    167168    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, *m_isolatedWorld);
    168169    ExecState* state = globalObject->globalExec();
    169     if (state->hadException())
     170    if (UNLIKELY(scope.exception()))
    170171        return;
    171172
     
    186187    m_constructionStack.removeLast();
    187188
    188     if (state->hadException()) {
     189    if (UNLIKELY(scope.exception())) {
    189190        element.setIsFailedCustomElement(*this);
    190191        return;
  • trunk/Source/WebCore/bindings/js/JSCustomElementRegistryCustom.cpp

    r205410 r205569  
    4747
    4848    JSValue callback = prototype.get(&state, id);
    49     if (state.hadException())
     49    if (UNLIKELY(scope.exception()))
    5050        return nullptr;
    5151    if (callback.isUndefined())
     
    8989
    9090    AtomicString localName(state.uncheckedArgument(0).toString(&state)->toAtomicString(&state));
    91     if (UNLIKELY(state.hadException()))
     91    if (UNLIKELY(scope.exception()))
    9292        return jsUndefined();
    9393
     
    119119
    120120    JSValue prototypeValue = constructor->get(&state, vm.propertyNames->prototype);
    121     if (state.hadException())
     121    if (UNLIKELY(scope.exception()))
    122122        return jsUndefined();
    123123    if (!prototypeValue.isObject())
     
    130130    if (auto* connectedCallback = getCustomElementCallback(state, prototypeObject, Identifier::fromString(&vm, "connectedCallback")))
    131131        elementInterface->setConnectedCallback(connectedCallback);
    132     if (state.hadException())
     132    if (UNLIKELY(scope.exception()))
    133133        return jsUndefined();
    134134
    135135    if (auto* disconnectedCallback = getCustomElementCallback(state, prototypeObject, Identifier::fromString(&vm, "disconnectedCallback")))
    136136        elementInterface->setDisconnectedCallback(disconnectedCallback);
    137     if (state.hadException())
     137    if (UNLIKELY(scope.exception()))
    138138        return jsUndefined();
    139139
    140140    if (auto* adoptedCallback = getCustomElementCallback(state, prototypeObject, Identifier::fromString(&vm, "adoptedCallback")))
    141141        elementInterface->setAdoptedCallback(adoptedCallback);
    142     if (state.hadException())
     142    if (UNLIKELY(scope.exception()))
    143143        return jsUndefined();
    144144
    145145    auto* attributeChangedCallback = getCustomElementCallback(state, prototypeObject, Identifier::fromString(&vm, "attributeChangedCallback"));
    146     if (state.hadException())
     146    if (UNLIKELY(scope.exception()))
    147147        return jsUndefined();
    148148    if (attributeChangedCallback) {
    149149        auto value = convertOptional<Vector<String>>(state, constructor->get(&state, Identifier::fromString(&state, "observedAttributes")));
    150         if (state.hadException())
     150        if (UNLIKELY(scope.exception()))
    151151            return jsUndefined();
    152152        if (value)
     
    171171
    172172    AtomicString localName(state.uncheckedArgument(0).toString(&state)->toAtomicString(&state));
    173     if (UNLIKELY(state.hadException()))
     173    if (UNLIKELY(scope.exception()))
    174174        return jsUndefined();
    175175
     
    192192JSValue JSCustomElementRegistry::whenDefined(ExecState& state)
    193193{
     194    auto scope = DECLARE_CATCH_SCOPE(state.vm());
     195
    194196    JSDOMGlobalObject& globalObject = *jsCast<JSDOMGlobalObject*>(state.lexicalGlobalObject());
    195197    auto& promiseDeferred = *JSPromiseDeferred::create(&state, &globalObject);
    196198    JSValue promise = whenDefinedPromise(state, globalObject, wrapped());
    197199
    198     if (state.hadException()) {
     200    if (UNLIKELY(scope.exception())) {
    199201        rejectPromiseWithExceptionIfAny(state, globalObject, promiseDeferred);
    200         ASSERT(!state.hadException());
     202        ASSERT(!scope.exception());
    201203        return promiseDeferred.promise();
    202204    }
  • trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp

    r205462 r205569  
    120120String valueToUSVString(ExecState* exec, JSValue value)
    121121{
     122    VM& vm = exec->vm();
     123    auto scope = DECLARE_THROW_SCOPE(vm);
     124
    122125    String string = value.toWTFString(exec);
    123     if (exec->hadException())
     126    if (UNLIKELY(scope.exception()))
    124127        return { };
    125128    StringView view { string };
     
    188191void reportException(ExecState* exec, JSValue exceptionValue, CachedScript* cachedScript)
    189192{
    190     RELEASE_ASSERT(exec->vm().currentThreadIsHoldingAPILock());
     193    VM& vm = exec->vm();
     194    RELEASE_ASSERT(vm.currentThreadIsHoldingAPILock());
    191195    Exception* exception = jsDynamicCast<Exception*>(exceptionValue);
    192196    if (!exception) {
    193         exception = exec->lastException();
     197        exception = vm.lastException();
    194198        if (!exception)
    195199            exception = Exception::create(exec->vm(), exceptionValue, Exception::DoNotCaptureStack);
     
    201205void reportException(ExecState* exec, Exception* exception, CachedScript* cachedScript, ExceptionDetails* exceptionDetails)
    202206{
    203     RELEASE_ASSERT(exec->vm().currentThreadIsHoldingAPILock());
     207    VM& vm = exec->vm();
     208    auto scope = DECLARE_CATCH_SCOPE(vm);
     209
     210    RELEASE_ASSERT(vm.currentThreadIsHoldingAPILock());
    204211    if (isTerminatedExecutionException(exception))
    205212        return;
     
    208215
    209216    RefPtr<ScriptCallStack> callStack(createScriptCallStackFromException(exec, exception, ScriptCallStack::maxCallStackSizeToCapture));
    210     exec->clearException();
    211     exec->clearLastException();
     217    scope.clearException();
     218    vm.clearLastException();
    212219
    213220    JSDOMGlobalObject* globalObject = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject());
     
    240247        // We need to clear any new exception that may be thrown in the toString() call above.
    241248        // reportException() is not supposed to be making new exceptions.
    242         exec->clearException();
    243         exec->clearLastException();
     249        scope.clearException();
     250        vm.clearLastException();
    244251    }
    245252
     
    257264void reportCurrentException(ExecState* exec)
    258265{
    259     Exception* exception = exec->exception();
    260     exec->clearException();
     266    VM& vm = exec->vm();
     267    auto scope = DECLARE_CATCH_SCOPE(vm);
     268    Exception* exception = scope.exception();
     269    scope.clearException();
    261270    reportException(exec, exception);
    262271}
     
    342351    auto scope = DECLARE_THROW_SCOPE(vm);
    343352
    344     if (!ec || exec->hadException())
     353    if (!ec || scope.exception())
    345354        return;
    346355
     
    353362    auto scope = DECLARE_THROW_SCOPE(vm);
    354363
    355     if (!ec.code || exec->hadException())
     364    if (!ec.code || scope.exception())
    356365        return;
    357366
     
    363372bool hasIteratorMethod(JSC::ExecState& state, JSC::JSValue value)
    364373{
     374    auto& vm = state.vm();
     375    auto scope = DECLARE_THROW_SCOPE(vm);
     376
    365377    if (!value.isObject())
    366378        return false;
    367379
    368     auto& vm = state.vm();
    369380    JSObject* object = JSC::asObject(value);
    370381    CallData callData;
    371382    CallType callType;
    372383    JSValue applyMethod = object->getMethod(&state, callData, callType, vm.propertyNames->iteratorSymbol, ASCIILiteral("Symbol.iterator property should be callable"));
    373     if (vm.exception())
     384    if (UNLIKELY(scope.exception()))
    374385        return false;
    375386
     
    510521
    511522    double x = value.toNumber(&state);
    512     if (UNLIKELY(state.hadException()))
     523    if (UNLIKELY(scope.exception()))
    513524        return 0;
    514525
     
    557568
    558569    double x = value.toNumber(&state);
    559     if (UNLIKELY(state.hadException()))
     570    if (UNLIKELY(scope.exception()))
    560571        return 0;
    561572
     
    643654int32_t toInt32EnforceRange(ExecState& state, JSValue value)
    644655{
     656    VM& vm = state.vm();
     657    auto scope = DECLARE_THROW_SCOPE(vm);
     658
    645659    if (value.isInt32())
    646660        return value.asInt32();
    647661
    648662    double x = value.toNumber(&state);
    649     if (UNLIKELY(state.hadException()))
     663    if (UNLIKELY(scope.exception()))
    650664        return 0;
    651665    return enforceRange(state, x, kMinInt32, kMaxInt32);
     
    673687uint32_t toUInt32EnforceRange(ExecState& state, JSValue value)
    674688{
     689    VM& vm = state.vm();
     690    auto scope = DECLARE_THROW_SCOPE(vm);
     691
    675692    if (value.isUInt32())
    676693        return value.asUInt32();
    677694
    678695    double x = value.toNumber(&state);
    679     if (UNLIKELY(state.hadException()))
     696    if (UNLIKELY(scope.exception()))
    680697        return 0;
    681698    return enforceRange(state, x, 0, kMaxUInt32);
     
    684701int64_t toInt64EnforceRange(ExecState& state, JSC::JSValue value)
    685702{
    686     double x = value.toNumber(&state);
    687     if (UNLIKELY(state.hadException()))
     703    VM& vm = state.vm();
     704    auto scope = DECLARE_THROW_SCOPE(vm);
     705
     706    double x = value.toNumber(&state);
     707    if (UNLIKELY(scope.exception()))
    688708        return 0;
    689709    return enforceRange(state, x, -kJSMaxInteger, kJSMaxInteger);
     
    692712uint64_t toUInt64EnforceRange(ExecState& state, JSC::JSValue value)
    693713{
    694     double x = value.toNumber(&state);
    695     if (UNLIKELY(state.hadException()))
     714    VM& vm = state.vm();
     715    auto scope = DECLARE_THROW_SCOPE(vm);
     716
     717    double x = value.toNumber(&state);
     718    if (UNLIKELY(scope.exception()))
    696719        return 0;
    697720    return enforceRange(state, x, 0, kJSMaxInteger);
     
    857880void throwNotSupportedError(JSC::ExecState& state, JSC::ThrowScope& scope, const char* message)
    858881{
    859     ASSERT(!state.hadException());
     882    ASSERT(!scope.exception());
    860883    String messageString(message);
    861884    throwException(&state, scope, createDOMException(&state, NOT_SUPPORTED_ERR, &messageString));
     
    864887void throwInvalidStateError(JSC::ExecState& state, JSC::ThrowScope& scope, const char* message)
    865888{
    866     ASSERT(!state.hadException());
     889    ASSERT(!scope.exception());
    867890    String messageString(message);
    868891    throwException(&state, scope, createDOMException(&state, INVALID_STATE_ERR, &messageString));
     
    871894void throwSecurityError(JSC::ExecState& state, JSC::ThrowScope& scope, const String& message)
    872895{
    873     ASSERT(!state.hadException());
     896    ASSERT(!scope.exception());
    874897    throwException(&state, scope, createDOMException(&state, SECURITY_ERR, message));
    875898}
  • trunk/Source/WebCore/bindings/js/JSDOMBinding.h

    r205542 r205569  
    553553
    554554    JSC::JSValue lengthValue = object->get(&exec, exec.propertyNames().length);
    555     if (exec.hadException())
     555    if (UNLIKELY(scope.exception()))
    556556        return nullptr;
    557557
     
    562562
    563563    length = lengthValue.toUInt32(&exec);
    564     if (exec.hadException())
     564    if (UNLIKELY(scope.exception()))
    565565        return nullptr;
    566566
     
    605605template<typename T> inline JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, const Vector<T>& vector)
    606606{
     607    JSC::VM& vm = globalObject->vm();
     608    auto scope = DECLARE_THROW_SCOPE(vm);
     609
    607610    JSC::JSArray* array = constructEmptyArray(exec, nullptr, vector.size());
    608     if (UNLIKELY(exec->hadException()))
     611    if (UNLIKELY(scope.exception()))
    609612        return JSC::jsUndefined();
    610613    for (size_t i = 0; i < vector.size(); ++i)
     
    615618template<typename T> inline JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, const Vector<RefPtr<T>>& vector)
    616619{
     620    JSC::VM& vm = globalObject->vm();
     621    auto scope = DECLARE_THROW_SCOPE(vm);
     622
    617623    JSC::JSArray* array = constructEmptyArray(exec, nullptr, vector.size());
    618     if (UNLIKELY(exec->hadException()))
     624    if (UNLIKELY(scope.exception()))
    619625        return JSC::jsUndefined();
    620626    for (size_t i = 0; i < vector.size(); ++i)
     
    700706template<typename T, size_t inlineCapacity> JSC::JSValue jsFrozenArray(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, const Vector<T, inlineCapacity>& vector)
    701707{
     708    JSC::VM& vm = globalObject->vm();
     709    auto scope = DECLARE_THROW_SCOPE(vm);
     710
    702711    JSC::MarkedArgumentBuffer list;
    703712    for (auto& element : vector) {
    704713        list.append(JSValueTraits<T>::arrayJSValue(exec, globalObject, element));
    705         if (UNLIKELY(exec->hadException()))
     714        if (UNLIKELY(scope.exception()))
    706715            return JSC::jsUndefined();
    707716    }
    708717    auto* array = JSC::constructArray(exec, nullptr, globalObject, list);
    709     if (UNLIKELY(exec->hadException()))
     718    if (UNLIKELY(scope.exception()))
    710719        return JSC::jsUndefined();
    711720    return JSC::objectConstructorFreeze(exec, array);
     
    746755    static inline bool nativeValue(JSC::ExecState& exec, JSC::JSValue jsValue, String& indexedValue)
    747756    {
     757        JSC::VM& vm = exec.vm();
     758        auto scope = DECLARE_THROW_SCOPE(vm);
    748759        indexedValue = jsValue.toWTFString(&exec);
    749         return !exec.hadException();
     760        return !scope.exception();
    750761    }
    751762};
     
    754765    static inline bool nativeValue(JSC::ExecState& exec, JSC::JSValue jsValue, unsigned& indexedValue)
    755766    {
     767        JSC::VM& vm = exec.vm();
     768        auto scope = DECLARE_THROW_SCOPE(vm);
    756769        indexedValue = jsValue.toUInt32(&exec);
    757         return !exec.hadException();
     770        return !scope.exception();
    758771    }
    759772};
     
    762775    static inline bool nativeValue(JSC::ExecState& exec, JSC::JSValue jsValue, float& indexedValue)
    763776    {
     777        JSC::VM& vm = exec.vm();
     778        auto scope = DECLARE_THROW_SCOPE(vm);
    764779        indexedValue = jsValue.toFloat(&exec);
    765         return !exec.hadException();
     780        return !scope.exception();
    766781    }
    767782};
     
    770785    static inline bool nativeValue(JSC::ExecState& exec, JSC::JSValue jsValue, double& indexedValue)
    771786    {
     787        JSC::VM& vm = exec.vm();
     788        auto scope = DECLARE_THROW_SCOPE(vm);
    772789        indexedValue = jsValue.toNumber(&exec);
    773         return !exec.hadException();
     790        return !scope.exception();
    774791    }
    775792};
     
    808825
    809826    Vector<T> result;
    810     forEachInIterable(&exec, value, [&result](JSC::VM&, JSC::ExecState* state, JSC::JSValue jsValue) {
     827    forEachInIterable(&exec, value, [&result](JSC::VM& vm, JSC::ExecState* state, JSC::JSValue jsValue) {
     828        auto scope = DECLARE_THROW_SCOPE(vm);
    811829        T convertedValue;
    812         if (!NativeValueTraits<T>::nativeValue(*state, jsValue, convertedValue))
     830        bool success = NativeValueTraits<T>::nativeValue(*state, jsValue, convertedValue);
     831        ASSERT_UNUSED(scope, scope.exception() || success);
     832        if (!success)
    813833            return;
    814         ASSERT(!state->hadException());
    815834        result.append(convertedValue);
    816835    });
  • trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp

    r205549 r205569  
    7676    ASSERT(execState);
    7777    ASSERT(execState->argumentCount() == 2);
     78    VM& vm = execState->vm();
     79    auto scope = DECLARE_CATCH_SCOPE(vm);
    7880
    7981    auto interfaceName = execState->uncheckedArgument(0).getString(execState);
    80     ASSERT(!execState->hadException());
     82    ASSERT_UNUSED(scope, !scope.exception());
    8183    auto functionName = execState->uncheckedArgument(1).getString(execState);
    82     ASSERT(!execState->hadException());
     84    ASSERT(!scope.exception());
    8385    return JSValue::encode(createTypeError(execState, makeThisTypeErrorMessage(interfaceName.utf8().data(), functionName.utf8().data())));
    8486}
     
    8890    ASSERT(execState);
    8991    ASSERT(execState->argumentCount() == 2);
     92    VM& vm = execState->vm();
     93    auto scope = DECLARE_CATCH_SCOPE(vm);
    9094
    9195    auto interfaceName = execState->uncheckedArgument(0).getString(execState);
    92     ASSERT(!execState->hadException());
     96    ASSERT_UNUSED(scope, !scope.exception());
    9397    auto attributeName = execState->uncheckedArgument(1).getString(execState);
    94     ASSERT(!execState->hadException());
     98    ASSERT(!scope.exception());
    9599    return JSValue::encode(createTypeError(execState, makeGetterTypeErrorMessage(interfaceName.utf8().data(), attributeName.utf8().data())));
    96100}
  • trunk/Source/WebCore/bindings/js/JSDOMGlobalObjectTask.cpp

    r201496 r205569  
    5050
    5151        Ref<JSGlobalObjectCallback> protectedThis(*this);
    52         JSLockHolder lock(m_globalObject->vm());
     52        VM& vm = m_globalObject->vm();
     53        JSLockHolder lock(vm);
     54        auto scope = DECLARE_THROW_SCOPE(vm);
    5355
    5456        ExecState* exec = m_globalObject->globalExec();
     
    6567        else
    6668            m_task->run(exec);
    67         ASSERT(!exec->hadException());
     69        ASSERT_UNUSED(scope, !scope.exception());
    6870    }
    6971
  • trunk/Source/WebCore/bindings/js/JSDOMIterator.h

    r205198 r205569  
    206206        arguments.append(wrapper);
    207207        JSC::call(&state, callback, callType, callData, thisValue, arguments);
    208         if (state.hadException())
     208        if (UNLIKELY(scope.exception()))
    209209            break;
    210210    }
  • trunk/Source/WebCore/bindings/js/JSDOMPromise.cpp

    r205410 r205569  
    101101void rejectPromiseWithExceptionIfAny(JSC::ExecState& state, JSDOMGlobalObject& globalObject, JSPromiseDeferred& promiseDeferred)
    102102{
    103     if (!state.hadException())
     103    VM& vm = state.vm();
     104    auto scope = DECLARE_CATCH_SCOPE(vm);
     105
     106    if (!scope.exception())
    104107        return;
    105108
    106     JSValue error = state.exception()->value();
    107     state.clearException();
     109    JSValue error = scope.exception()->value();
     110    scope.clearException();
    108111
    109112    DeferredWrapper::create(&state, &globalObject, &promiseDeferred)->reject(error);
  • trunk/Source/WebCore/bindings/js/JSDOMPromise.h

    r205257 r205569  
    159159inline JSC::JSValue callPromiseFunction(JSC::ExecState& state, JSC::EncodedJSValue promiseFunction(JSC::ExecState*, JSC::JSPromiseDeferred*))
    160160{
     161    JSC::VM& vm = state.vm();
     162    auto scope = DECLARE_CATCH_SCOPE(vm);
     163
    161164    JSDOMGlobalObject& globalObject = *JSC::jsCast<JSDOMGlobalObject*>(state.lexicalGlobalObject());
    162165    JSC::JSPromiseDeferred& promiseDeferred = *JSC::JSPromiseDeferred::create(&state, &globalObject);
     
    164167
    165168    rejectPromiseWithExceptionIfAny(state, globalObject, promiseDeferred);
    166     ASSERT(!state.hadException());
     169    ASSERT_UNUSED(scope, !scope.exception());
    167170    return promiseDeferred.promise();
    168171}
  • trunk/Source/WebCore/bindings/js/JSDOMStringMapCustom.cpp

    r198023 r205569  
    7676bool JSDOMStringMap::putDelegate(ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot&, bool& putResult)
    7777{
     78    VM& vm = exec->vm();
     79    auto scope = DECLARE_THROW_SCOPE(vm);
     80
    7881    if (propertyName.isSymbol())
    7982        return false;
    8083
    8184    String stringValue = value.toString(exec)->value(exec);
    82     if (exec->hadException())
     85    if (UNLIKELY(scope.exception()))
    8386        return false;
    8487
  • trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp

    r205372 r205569  
    198198    {
    199199        Ref<JSDOMWindowMicrotaskCallback> protectedThis(*this);
    200         JSLockHolder lock(m_globalObject->vm());
     200        VM& vm = m_globalObject->vm();
     201        JSLockHolder lock(vm);
     202        auto scope = DECLARE_THROW_SCOPE(vm);
    201203
    202204        ExecState* exec = m_globalObject->globalExec();
     
    204206        JSMainThreadExecState::runTask(exec, m_task);
    205207
    206         ASSERT(!exec->hadException());
     208        ASSERT_UNUSED(scope, !scope.exception());
    207209    }
    208210
  • trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp

    r205468 r205569  
    370370void JSDOMWindow::setLocation(ExecState& state, JSValue value)
    371371{
     372    VM& vm = state.vm();
     373    auto scope = DECLARE_THROW_SCOPE(vm);
     374
    372375#if ENABLE(DASHBOARD_SUPPORT)
    373376    // To avoid breaking old widgets, make "var location =" in a top-level frame create
     
    383386
    384387    String locationString = value.toString(&state)->value(&state);
    385     if (state.hadException())
     388    if (UNLIKELY(scope.exception()))
    386389        return;
    387390
     
    407410JSValue JSDOMWindow::open(ExecState& state)
    408411{
     412    VM& vm = state.vm();
     413    auto scope = DECLARE_THROW_SCOPE(vm);
     414
    409415    String urlString = valueToUSVStringWithUndefinedOrNullCheck(&state, state.argument(0));
    410     if (state.hadException())
     416    if (UNLIKELY(scope.exception()))
    411417        return jsUndefined();
    412418    JSValue targetValue = state.argument(1);
    413419    AtomicString target = targetValue.isUndefinedOrNull() ? AtomicString("_blank", AtomicString::ConstructFromLiteral) : targetValue.toString(&state)->toAtomicString(&state);
    414     if (state.hadException())
     420    if (UNLIKELY(scope.exception()))
    415421        return jsUndefined();
    416422    String windowFeaturesString = valueToStringWithUndefinedOrNullCheck(&state, state.argument(2));
    417     if (state.hadException())
     423    if (UNLIKELY(scope.exception()))
    418424        return jsUndefined();
    419425
     
    471477
    472478    String urlString = valueToStringWithUndefinedOrNullCheck(&state, state.argument(0));
    473     if (state.hadException())
     479    if (UNLIKELY(scope.exception()))
    474480        return jsUndefined();
    475481    String dialogFeaturesString = valueToStringWithUndefinedOrNullCheck(&state, state.argument(2));
    476     if (state.hadException())
     482    if (UNLIKELY(scope.exception()))
    477483        return jsUndefined();
    478484
     
    512518        fillMessagePortArray(state, state.argument(transferablesArgIndex), messagePorts, arrayBuffers);
    513519    }
    514     if (state.hadException())
     520    if (UNLIKELY(scope.exception()))
    515521        return jsUndefined();
    516522
    517523    auto message = SerializedScriptValue::create(&state, state.uncheckedArgument(0), &messagePorts, &arrayBuffers);
    518524
    519     if (state.hadException())
     525    if (UNLIKELY(scope.exception()))
    520526        return jsUndefined();
    521527
    522528    String targetOrigin = valueToUSVStringWithUndefinedOrNullCheck(&state, state.uncheckedArgument(targetOriginArgIndex));
    523     if (state.hadException())
     529    if (UNLIKELY(scope.exception()))
    524530        return jsUndefined();
    525531
     
    546552    ContentSecurityPolicy* contentSecurityPolicy = wrapped().document() ? wrapped().document()->contentSecurityPolicy() : nullptr;
    547553    std::unique_ptr<ScheduledAction> action = ScheduledAction::create(&state, globalObject()->world(), contentSecurityPolicy);
    548     if (state.hadException())
     554    if (UNLIKELY(scope.exception()))
    549555        return jsUndefined();
    550556
     
    571577    ContentSecurityPolicy* contentSecurityPolicy = wrapped().document() ? wrapped().document()->contentSecurityPolicy() : nullptr;
    572578    std::unique_ptr<ScheduledAction> action = ScheduledAction::create(&state, globalObject()->world(), contentSecurityPolicy);
    573     if (state.hadException())
     579    if (UNLIKELY(scope.exception()))
    574580        return jsUndefined();
    575581    int delay = state.argument(1).toInt32(&state);
  • trunk/Source/WebCore/bindings/js/JSDataCueCustom.cpp

    r205422 r205569  
    5959
    6060    double startTime(exec.uncheckedArgument(0).toNumber(&exec));
    61     if (UNLIKELY(exec.hadException()))
     61    if (UNLIKELY(scope.exception()))
    6262        return JSValue::encode(jsUndefined());
    6363
    6464    double endTime(exec.uncheckedArgument(1).toNumber(&exec));
    65     if (UNLIKELY(exec.hadException()))
     65    if (UNLIKELY(scope.exception()))
    6666        return JSValue::encode(jsUndefined());
    6767
     
    8888
    8989        ArrayBuffer* data = toArrayBuffer(valueArgument);
    90         if (UNLIKELY(exec.hadException()))
     90        if (UNLIKELY(scope.exception()))
    9191            return JSValue::encode(jsUndefined());
    9292
  • trunk/Source/WebCore/bindings/js/JSDeviceMotionEventCustom.cpp

    r205462 r205569  
    4848        return nullptr;
    4949
     50    VM& vm = state.vm();
     51    auto scope = DECLARE_THROW_SCOPE(vm);
     52
    5053    // Given the above test, this will always yield an object.
    5154    JSObject* object = value.toObject(&state);
    52     ASSERT(!state.hadException());
     55    ASSERT(!scope.exception());
    5356
    5457    JSValue xValue = object->get(&state, Identifier::fromString(&state, "x"));
    55     if (state.hadException())
     58    if (UNLIKELY(scope.exception()))
    5659        return nullptr;
    5760    bool canProvideX = !xValue.isUndefinedOrNull();
    5861    double x = xValue.toNumber(&state);
    59     if (state.hadException())
     62    if (UNLIKELY(scope.exception()))
    6063        return nullptr;
    6164
    6265    JSValue yValue = object->get(&state, Identifier::fromString(&state, "y"));
    63     if (state.hadException())
     66    if (UNLIKELY(scope.exception()))
    6467        return nullptr;
    6568    bool canProvideY = !yValue.isUndefinedOrNull();
    6669    double y = yValue.toNumber(&state);
    67     if (state.hadException())
     70    if (UNLIKELY(scope.exception()))
    6871        return nullptr;
    6972
    7073    JSValue zValue = object->get(&state, Identifier::fromString(&state, "z"));
    71     if (state.hadException())
     74    if (UNLIKELY(scope.exception()))
    7275        return nullptr;
    7376    bool canProvideZ = !zValue.isUndefinedOrNull();
    7477    double z = zValue.toNumber(&state);
    75     if (state.hadException())
     78    if (UNLIKELY(scope.exception()))
    7679        return nullptr;
    7780
     
    8689    if (value.isUndefinedOrNull())
    8790        return nullptr;
     91
     92    VM& vm = state.vm();
     93    auto scope = DECLARE_THROW_SCOPE(vm);
    8894
    8995    // Given the above test, this will always yield an object.
    9096    JSObject* object = value.toObject(&state);
    91     ASSERT(!state.hadException());
     97    ASSERT(!scope.exception());
    9298
    9399    JSValue alphaValue = object->get(&state, Identifier::fromString(&state, "alpha"));
    94     if (state.hadException())
     100    if (UNLIKELY(scope.exception()))
    95101        return nullptr;
    96102    bool canProvideAlpha = !alphaValue.isUndefinedOrNull();
    97103    double alpha = alphaValue.toNumber(&state);
    98     if (state.hadException())
     104    if (UNLIKELY(scope.exception()))
    99105        return nullptr;
    100106
    101107    JSValue betaValue = object->get(&state, Identifier::fromString(&state, "beta"));
    102     if (state.hadException())
     108    if (UNLIKELY(scope.exception()))
    103109        return nullptr;
    104110    bool canProvideBeta = !betaValue.isUndefinedOrNull();
    105111    double beta = betaValue.toNumber(&state);
    106     if (state.hadException())
     112    if (UNLIKELY(scope.exception()))
    107113        return nullptr;
    108114
    109115    JSValue gammaValue = object->get(&state, Identifier::fromString(&state, "gamma"));
    110     if (state.hadException())
     116    if (UNLIKELY(scope.exception()))
    111117        return nullptr;
    112118    bool canProvideGamma = !gammaValue.isUndefinedOrNull();
    113119    double gamma = gammaValue.toNumber(&state);
    114     if (state.hadException())
     120    if (UNLIKELY(scope.exception()))
    115121        return nullptr;
    116122
     
    173179JSValue JSDeviceMotionEvent::initDeviceMotionEvent(ExecState& state)
    174180{
     181    VM& vm = state.vm();
     182    auto scope = DECLARE_THROW_SCOPE(vm);
     183
    175184    const String type = state.argument(0).toString(&state)->value(&state);
    176185    bool bubbles = state.argument(1).toBoolean(&state);
     
    180189    // Otherwise, use the standard JavaScript conversion.
    181190    RefPtr<DeviceMotionData::Acceleration> acceleration = readAccelerationArgument(state.argument(3), state);
    182     if (state.hadException())
     191    if (UNLIKELY(scope.exception()))
    183192        return jsUndefined();
    184193
    185194    RefPtr<DeviceMotionData::Acceleration> accelerationIncludingGravity = readAccelerationArgument(state.argument(4), state);
    186     if (state.hadException())
     195    if (UNLIKELY(scope.exception()))
    187196        return jsUndefined();
    188197
    189198    RefPtr<DeviceMotionData::RotationRate> rotationRate = readRotationRateArgument(state.argument(5), state);
    190     if (state.hadException())
     199    if (UNLIKELY(scope.exception()))
    191200        return jsUndefined();
    192201
  • trunk/Source/WebCore/bindings/js/JSDictionary.cpp

    r205198 r205569  
    7979JSDictionary::GetPropertyResult JSDictionary::tryGetProperty(const char* propertyName, JSValue& finalResult) const
    8080{
     81    VM& vm = m_exec->vm();
     82    auto scope = DECLARE_THROW_SCOPE(vm);
    8183    ASSERT(isValid());
    8284    Identifier identifier = Identifier::fromString(m_exec, propertyName);
     
    8789        return true;
    8890    });
    89     if (m_exec->hadException())
     91    if (UNLIKELY(scope.exception()))
    9092        return ExceptionThrown;
    9193    return propertyFound ? PropertyFound : NoPropertyFound;
     
    152154{
    153155    ASSERT(exec);
     156    VM& vm = exec->vm();
     157    auto scope = DECLARE_THROW_SCOPE(vm);
     158
    154159    if (value.isUndefinedOrNull())
    155160        return;
     
    157162    unsigned length = 0;
    158163    JSObject* object = toJSSequence(*exec, value, length);
    159     if (exec->hadException())
     164    if (UNLIKELY(scope.exception()))
    160165        return;
    161166
    162167    for (unsigned i = 0 ; i < length; ++i) {
    163168        JSValue itemValue = object->get(exec, i);
    164         if (exec->hadException())
     169        if (UNLIKELY(scope.exception()))
    165170            return;
    166171        result.append(itemValue.toString(exec)->value(exec));
     
    222227{
    223228    ASSERT(exec);
     229    VM& vm = exec->vm();
     230    auto scope = DECLARE_THROW_SCOPE(vm);
     231
    224232    result.clear();
    225233
     
    229237    unsigned length = 0;
    230238    JSObject* object = toJSSequence(*exec, value, length);
    231     if (exec->hadException())
     239    if (UNLIKELY(scope.exception()))
    232240        return;
    233241
    234242    for (unsigned i = 0 ; i < length; ++i) {
    235243        JSValue itemValue = object->get(exec, i);
    236         if (exec->hadException())
     244        if (UNLIKELY(scope.exception()))
    237245            return;
    238246        result.add(itemValue.toString(exec)->value(exec));
     
    298306{
    299307    ASSERT(exec);
     308    VM& vm = exec->vm();
     309    auto scope = DECLARE_THROW_SCOPE(vm);
     310
    300311    if (value.isUndefinedOrNull())
    301312        return;
     
    303314    unsigned length = 0;
    304315    JSObject* object = toJSSequence(*exec, value, length);
    305     if (exec->hadException())
     316    if (UNLIKELY(scope.exception()))
    306317        return;
    307318
    308319    for (unsigned i = 0 ; i < length; ++i) {
    309320        JSValue itemValue = object->get(exec, i);
    310         if (exec->hadException())
     321        if (UNLIKELY(scope.exception()))
    311322            return;
    312323
  • trunk/Source/WebCore/bindings/js/JSDictionary.h

    r205024 r205569  
    204204JSDictionary::GetPropertyResult JSDictionary::tryGetPropertyAndResult(const char* propertyName, T* context, void (*setter)(T* context, const Result&)) const
    205205{
     206    JSC::VM& vm = m_exec->vm();
     207    auto scope = DECLARE_THROW_SCOPE(vm);
     208
    206209    JSC::JSValue value;
    207210    GetPropertyResult getPropertyResult = tryGetProperty(propertyName, value);
     
    213216        convertValue(m_exec, value, result);
    214217
    215         if (m_exec->hadException())
     218        if (UNLIKELY(scope.exception()))
    216219            return ExceptionThrown;
    217220
  • trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp

    r205422 r205569  
    154154        return throwException(&state, scope, createNotEnoughArgumentsError(&state));
    155155    auto contextId = state.uncheckedArgument(0).toWTFString(&state);
    156     if (UNLIKELY(state.hadException()))
     156    if (UNLIKELY(scope.exception()))
    157157        return jsUndefined();
    158158    auto name = state.uncheckedArgument(1).toWTFString(&state);
    159     if (UNLIKELY(state.hadException()))
     159    if (UNLIKELY(scope.exception()))
    160160        return jsUndefined();
    161161    auto width = convert<int32_t>(state, state.uncheckedArgument(2), NormalConversion);
    162     if (UNLIKELY(state.hadException()))
     162    if (UNLIKELY(scope.exception()))
    163163        return jsUndefined();
    164164    auto height = convert<int32_t>(state, state.uncheckedArgument(3), NormalConversion);
    165     if (UNLIKELY(state.hadException()))
     165    if (UNLIKELY(scope.exception()))
    166166        return jsUndefined();
    167167
  • trunk/Source/WebCore/bindings/js/JSEventListener.cpp

    r204424 r205569  
    8080        return;
    8181
    82     JSLockHolder lock(scriptExecutionContext->vm());
     82    VM& vm = scriptExecutionContext->vm();
     83    JSLockHolder lock(vm);
     84    auto scope = DECLARE_CATCH_SCOPE(vm);
     85    // See https://dom.spec.whatwg.org/#dispatching-events spec on calling handleEvent.
     86    // "If this throws an exception, report the exception." It should not propagate the
     87    // exception.
    8388
    8489    JSObject* jsFunction = this->jsFunction(scriptExecutionContext);
     
    110115    if (callType == CallType::None) {
    111116        handleEventFunction = jsFunction->get(exec, Identifier::fromString(exec, "handleEvent"));
     117        if (UNLIKELY(scope.exception())) {
     118            Exception* exception = scope.exception();
     119            scope.clearException();
     120
     121            event->target()->uncaughtExceptionInEventHandler();
     122            reportException(exec, exception);
     123            return;
     124        }
    112125        callType = getCallData(handleEventFunction, callData);
    113126    }
     
    122135        globalObject->setCurrentEvent(event);
    123136
    124         VM& vm = globalObject->vm();
    125137        VMEntryScope entryScope(vm, vm.entryScope ? vm.entryScope->globalObject() : globalObject);
    126138
     
    139151        if (is<WorkerGlobalScope>(*scriptExecutionContext)) {
    140152            auto scriptController = downcast<WorkerGlobalScope>(*scriptExecutionContext).script();
    141             bool terminatorCausedException = (exec->hadException() && isTerminatedExecutionException(exec->exception()));
     153            bool terminatorCausedException = (scope.exception() && isTerminatedExecutionException(scope.exception()));
    142154            if (terminatorCausedException || scriptController->isTerminatingExecution())
    143155                scriptController->forbidExecution();
  • trunk/Source/WebCore/bindings/js/JSFileCustom.cpp

    r205422 r205569  
    6161    unsigned blobPartsLength = 0;
    6262    JSObject* blobParts = toJSSequence(exec, arg, blobPartsLength);
    63     if (exec.hadException())
     63    if (UNLIKELY(scope.exception()))
    6464        return JSValue::encode(jsUndefined());
    6565    ASSERT(blobParts);
     
    7070
    7171    String filename = arg.toWTFString(&exec).replace('/', ':');
    72     if (exec.hadException())
     72    if (UNLIKELY(scope.exception()))
    7373        return JSValue::encode(jsUndefined());
    7474
     
    8888        String type;
    8989        dictionary.get("type", type);
    90         if (exec.hadException())
     90        if (UNLIKELY(scope.exception()))
    9191            return JSValue::encode(jsUndefined());
    9292
     
    9696        if (type.isEmpty() ||  !normalizedType.isEmpty()) {
    9797            dictionary.get("lastModified", lastModified);
    98             if (exec.hadException())
     98            if (UNLIKELY(scope.exception()))
    9999                return JSValue::encode(jsUndefined());
    100100        }
     
    108108    for (unsigned i = 0; i < blobPartsLength; ++i) {
    109109        JSValue item = blobParts->get(&exec, i);
    110         if (exec.hadException())
     110        if (UNLIKELY(scope.exception()))
    111111            return JSValue::encode(jsUndefined());
    112112
     
    119119        else {
    120120            String string = item.toWTFString(&exec);
    121             if (exec.hadException())
     121            if (UNLIKELY(scope.exception()))
    122122                return JSValue::encode(jsUndefined());
    123123            blobBuilder.append(string, ASCIILiteral("transparent"));
  • trunk/Source/WebCore/bindings/js/JSGeolocationCustom.cpp

    r200626 r205569  
    7272static RefPtr<PositionOptions> createPositionOptions(ExecState* exec, JSValue value)
    7373{
     74    VM& vm = exec->vm();
     75    auto scope = DECLARE_THROW_SCOPE(vm);
     76
    7477    // Create default options.
    7578    auto options = PositionOptions::create();
     
    8386    // Given the above test, this will always yield an object.
    8487    JSObject* object = value.toObject(exec);
    85     ASSERT(!exec->hadException());
     88    ASSERT_UNUSED(scope, !scope.exception());
    8689
    8790    // Create the dictionary wrapper from the initializer object.
     
    100103JSValue JSGeolocation::getCurrentPosition(ExecState& state)
    101104{
     105    VM& vm = state.vm();
     106    auto scope = DECLARE_THROW_SCOPE(vm);
     107
    102108    // Arguments: PositionCallback, (optional)PositionErrorCallback, (optional)PositionOptions
    103109
    104110    auto positionCallback = createFunctionOnlyCallback<JSPositionCallback>(&state, globalObject(), state.argument(0));
    105     if (state.hadException())
     111    if (UNLIKELY(scope.exception()))
    106112        return jsUndefined();
    107113    ASSERT(positionCallback);
    108114
    109115    auto positionErrorCallback = createFunctionOnlyCallback<JSPositionErrorCallback>(&state, globalObject(), state.argument(1), CallbackAllowUndefined | CallbackAllowNull);
    110     if (state.hadException())
     116    if (UNLIKELY(scope.exception()))
    111117        return jsUndefined();
    112118
    113119    auto positionOptions = createPositionOptions(&state, state.argument(2));
    114     if (state.hadException())
     120    if (UNLIKELY(scope.exception()))
    115121        return jsUndefined();
    116122    ASSERT(positionOptions);
     
    122128JSValue JSGeolocation::watchPosition(ExecState& state)
    123129{
     130    VM& vm = state.vm();
     131    auto scope = DECLARE_THROW_SCOPE(vm);
     132
    124133    // Arguments: PositionCallback, (optional)PositionErrorCallback, (optional)PositionOptions
    125134
    126135    auto positionCallback = createFunctionOnlyCallback<JSPositionCallback>(&state, globalObject(), state.argument(0));
    127     if (state.hadException())
     136    if (UNLIKELY(scope.exception()))
    128137        return jsUndefined();
    129138    ASSERT(positionCallback);
    130139
    131140    auto positionErrorCallback = createFunctionOnlyCallback<JSPositionErrorCallback>(&state, globalObject(), state.argument(1), CallbackAllowUndefined | CallbackAllowNull);
    132     if (state.hadException())
     141    if (UNLIKELY(scope.exception()))
    133142        return jsUndefined();
    134143
    135144    auto positionOptions = createPositionOptions(&state, state.argument(2));
    136     if (state.hadException())
     145    if (UNLIKELY(scope.exception()))
    137146        return jsUndefined();
    138147    ASSERT(positionOptions);
  • trunk/Source/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp

    r205198 r205569  
    5454static EncodedJSValue JSC_HOST_CALL callHTMLAllCollection(ExecState* exec)
    5555{
     56    VM& vm = exec->vm();
     57    auto scope = DECLARE_THROW_SCOPE(vm);
     58
    5659    if (exec->argumentCount() < 1)
    5760        return JSValue::encode(jsUndefined());
     
    6669        // Support for document.all(<index>) etc.
    6770        String string = exec->argument(0).toString(exec)->value(exec);
    68         if (exec->hadException())
     71        if (UNLIKELY(scope.exception()))
    6972            return JSValue::encode(jsUndefined());
    7073        if (Optional<uint32_t> index = parseIndex(*string.impl()))
     
    7780    // The second arg, if set, is the index of the item we want
    7881    String string = exec->argument(0).toString(exec)->value(exec);
    79     if (exec->hadException())
     82    if (UNLIKELY(scope.exception()))
    8083        return JSValue::encode(jsUndefined());
    8184    if (Optional<uint32_t> index = parseIndex(*exec->argument(1).toWTFString(exec).impl())) {
  • trunk/Source/WebCore/bindings/js/JSHTMLCanvasElementCustom.cpp

    r205554 r205569  
    4747static void get3DContextAttributes(ExecState& state, RefPtr<CanvasContextAttributes>& attrs)
    4848{
     49    VM& vm = state.vm();
     50    auto scope = DECLARE_THROW_SCOPE(vm);
     51
    4952    JSValue initializerValue = state.argument(1);
    5053    if (initializerValue.isUndefinedOrNull())
     
    5255   
    5356    JSObject* initializerObject = initializerValue.toObject(&state);
    54     ASSERT(!state.hadException());
     57    ASSERT_UNUSED(scope, !scope.exception());
    5558    JSDictionary dictionary(&state, initializerObject);
    5659   
     
    8487    if (HTMLCanvasElement::is3dType(contextId)) {
    8588        get3DContextAttributes(state, attrs);
    86         if (state.hadException())
     89        if (UNLIKELY(scope.exception()))
    8790            return jsUndefined();
    8891    }
  • trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp

    r205416 r205569  
    7979        Structure* baseStructure = getDOMStructure<JSHTMLElement>(vm, *globalObject);
    8080        auto* newElementStructure = InternalFunction::createSubclassStructure(&exec, newTargetValue, baseStructure);
    81         if (UNLIKELY(exec.hadException()))
     81        if (UNLIKELY(scope.exception()))
    8282            return JSValue::encode(jsUndefined());
    8383
     
    9999
    100100    JSValue newPrototype = newTarget->get(&exec, vm.propertyNames->prototype);
    101     if (exec.hadException())
     101    if (UNLIKELY(scope.exception()))
    102102        return JSValue::encode(jsUndefined());
    103103
    104104    JSObject* elementWrapperObject = asObject(elementWrapperValue);
    105105    JSObject::setPrototype(elementWrapperObject, &exec, newPrototype, true /* shouldThrowIfCantSet */);
    106     if (exec.hadException())
     106    if (UNLIKELY(scope.exception()))
    107107        return JSValue::encode(jsUndefined());
    108108
  • trunk/Source/WebCore/bindings/js/JSHistoryCustom.cpp

    r205198 r205569  
    6464
    6565    auto historyState = SerializedScriptValue::create(&state, state.uncheckedArgument(0), 0, 0);
    66     if (state.hadException())
     66    if (UNLIKELY(scope.exception()))
    6767        return jsUndefined();
    6868
    6969    // FIXME: title should not be nullable.
    7070    String title = valueToStringWithUndefinedOrNullCheck(&state, state.uncheckedArgument(1));
    71     if (state.hadException())
     71    if (UNLIKELY(scope.exception()))
    7272        return jsUndefined();
    7373
     
    7575    if (argCount > 2) {
    7676        url = valueToUSVStringWithUndefinedOrNullCheck(&state, state.uncheckedArgument(2));
    77         if (state.hadException())
     77        if (UNLIKELY(scope.exception()))
    7878            return jsUndefined();
    7979    }
     
    9898
    9999    auto historyState = SerializedScriptValue::create(&state, state.uncheckedArgument(0), 0, 0);
    100     if (state.hadException())
     100    if (UNLIKELY(scope.exception()))
    101101        return jsUndefined();
    102102
    103103    // FIXME: title should not be nullable.
    104104    String title = valueToStringWithUndefinedOrNullCheck(&state, state.uncheckedArgument(1));
    105     if (state.hadException())
     105    if (UNLIKELY(scope.exception()))
    106106        return jsUndefined();
    107107
     
    109109    if (argCount > 2) {
    110110        url = valueToUSVStringWithUndefinedOrNullCheck(&state, state.uncheckedArgument(2));
    111         if (state.hadException())
     111        if (UNLIKELY(scope.exception()))
    112112            return jsUndefined();
    113113    }
  • trunk/Source/WebCore/bindings/js/JSIDBDatabaseCustom.cpp

    r205198 r205569  
    5656
    5757    String name = state.argument(0).toString(&state)->value(&state);
    58     if (state.hadException())
     58    if (UNLIKELY(scope.exception()))
    5959        return jsUndefined();
    6060
     
    6767    if (!optionsValue.isUndefinedOrNull()) {
    6868        JSValue keyPathValue = optionsValue.get(&state, Identifier::fromString(&state, "keyPath"));
    69         if (state.hadException())
     69        if (UNLIKELY(scope.exception()))
    7070            return jsUndefined();
    7171
    7272        if (!keyPathValue.isUndefinedOrNull()) {
    7373            keyPath = idbKeyPathFromValue(state, keyPathValue);
    74             if (state.hadException())
     74            if (UNLIKELY(scope.exception()))
    7575                return jsUndefined();
    7676        }
    7777
    7878        autoIncrement = optionsValue.get(&state, Identifier::fromString(&state, "autoIncrement")).toBoolean(&state);
    79         if (state.hadException())
     79        if (UNLIKELY(scope.exception()))
    8080            return jsUndefined();
    8181    }
  • trunk/Source/WebCore/bindings/js/JSLazyEventListener.cpp

    r200775 r205569  
    9999        return nullptr;
    100100
     101    VM& vm = globalObject->vm();
     102    JSLockHolder lock(vm);
     103    auto scope = DECLARE_CATCH_SCOPE(vm);
    101104    ExecState* exec = globalObject->globalExec();
    102105
     
    113116        m_sourceURL, m_sourcePosition, overrideLineNumber);
    114117
    115     if (exec->hadException()) {
     118    if (UNLIKELY(scope.exception())) {
    116119        reportCurrentException(exec);
    117         exec->clearException();
     120        scope.clearException();
    118121        return nullptr;
    119122    }
     
    124127        if (!wrapper()) {
    125128            // Ensure that 'node' has a JavaScript wrapper to mark the event listener we're creating.
    126             JSLockHolder lock(exec);
    127129            // FIXME: Should pass the global object associated with the node
    128             setWrapper(exec->vm(), asObject(toJS(exec, globalObject, *m_originalNode)));
     130            setWrapper(vm, asObject(toJS(exec, globalObject, *m_originalNode)));
    129131        }
    130132
    131133        // Add the event's home element to the scope
    132134        // (and the document, and the form - see JSHTMLElement::eventHandlerScope)
    133         listenerAsFunction->setScope(exec->vm(), jsCast<JSNode*>(wrapper())->pushEventHandlerScope(exec, listenerAsFunction->scope()));
     135        listenerAsFunction->setScope(vm, jsCast<JSNode*>(wrapper())->pushEventHandlerScope(exec, listenerAsFunction->scope()));
    134136    }
    135137    return jsFunction;
  • trunk/Source/WebCore/bindings/js/JSMainThreadExecState.h

    r205278 r205569  
    108108    static JSC::JSValue linkAndEvaluateModule(JSC::ExecState* exec, const JSC::Identifier& moduleKey, JSC::JSValue initiator, NakedPtr<JSC::Exception>& returnedException)
    109109    {
     110        JSC::VM& vm = exec->vm();
     111        auto scope = DECLARE_CATCH_SCOPE(vm);
     112   
    110113        JSMainThreadExecState currentState(exec);
    111114        JSC::JSValue returnValue = JSC::linkAndEvaluateModule(exec, moduleKey, initiator);
    112         if (exec->hadException()) {
    113             returnedException = exec->vm().exception();
    114             exec->clearException();
     115        if (UNLIKELY(scope.exception())) {
     116            returnedException = scope.exception();
     117            scope.clearException();
    115118            return JSC::jsUndefined();
    116119        }
     
    132135    ~JSMainThreadExecState()
    133136    {
     137        JSC::VM& vm = s_mainThreadState->vm();
     138        auto scope = DECLARE_CATCH_SCOPE(vm);
    134139        ASSERT(isMainThread());
    135         ASSERT(!s_mainThreadState->hadException());
     140        ASSERT_UNUSED(scope, !scope.exception());
    136141
    137142        bool didExitJavaScript = s_mainThreadState && !m_previousState;
  • trunk/Source/WebCore/bindings/js/JSMessageEventCustom.cpp

    r204215 r205569  
    105105static JSC::JSValue handleInitMessageEvent(JSMessageEvent* jsEvent, JSC::ExecState& state)
    106106{
     107    VM& vm = state.vm();
     108    auto scope = DECLARE_THROW_SCOPE(vm);
     109
    107110    const String& typeArg = state.argument(0).toString(&state)->value(&state);
    108111    bool canBubbleArg = state.argument(1).toBoolean(&state);
     
    117120        arrayBuffers = std::make_unique<ArrayBufferArray>();
    118121        fillMessagePortArray(state, state.argument(7), *messagePorts, *arrayBuffers);
    119         if (state.hadException())
     122        if (UNLIKELY(scope.exception()))
    120123            return jsUndefined();
    121124    }
    122     Deprecated::ScriptValue dataArg(state.vm(), state.argument(3));
    123     if (state.hadException())
     125    Deprecated::ScriptValue dataArg(vm, state.argument(3));
     126    if (UNLIKELY(scope.exception()))
    124127        return jsUndefined();
    125128
    126129    MessageEvent& event = jsEvent->wrapped();
    127130    event.initMessageEvent(typeArg, canBubbleArg, cancelableArg, dataArg, originArg, lastEventIdArg, sourceArg, WTFMove(messagePorts));
    128     jsEvent->m_data.set(state.vm(), jsEvent, dataArg.jsValue());
     131    jsEvent->m_data.set(vm, jsEvent, dataArg.jsValue());
    129132    return jsUndefined();
    130133}
  • trunk/Source/WebCore/bindings/js/JSMessagePortCustom.cpp

    r205198 r205569  
    7474    unsigned length = 0;
    7575    JSObject* object = toJSSequence(state, value, length);
    76     if (state.hadException())
     76    if (UNLIKELY(scope.exception()))
    7777        return;
    7878
    7979    for (unsigned i = 0 ; i < length; ++i) {
    8080        JSValue value = object->get(&state, i);
    81         if (state.hadException())
     81        if (UNLIKELY(scope.exception()))
    8282            return;
    8383        // Validation of non-null objects, per HTML5 spec 10.3.3.
  • trunk/Source/WebCore/bindings/js/JSMessagePortCustom.h

    r205198 r205569  
    6262        fillMessagePortArray(state, state.argument(1), portArray, arrayBufferArray);
    6363        auto message = SerializedScriptValue::create(&state, state.uncheckedArgument(0), &portArray, &arrayBufferArray);
    64         if (state.hadException())
     64        if (UNLIKELY(scope.exception()))
    6565            return JSC::jsUndefined();
    6666
  • trunk/Source/WebCore/bindings/js/JSMockContentFilterSettingsCustom.cpp

    r205198 r205569  
    6363
    6464    uint8_t nativeValue { convert<uint8_t>(state, value, EnforceRange) };
    65     if (state.hadException())
     65    if (UNLIKELY(scope.exception()))
    6666        return;
    6767
     
    9999
    100100    uint8_t nativeValue { convert<uint8_t>(state, value, EnforceRange) };
    101     if (state.hadException())
     101    if (UNLIKELY(scope.exception()))
    102102        return Decision::Allow;
    103103
     
    120120void JSMockContentFilterSettings::setDecision(ExecState& state, JSValue value)
    121121{
     122    VM& vm = state.vm();
     123    auto scope = DECLARE_THROW_SCOPE(vm);
     124
    122125    Decision decision { toDecision(state, value) };
    123     if (state.hadException())
     126    if (UNLIKELY(scope.exception()))
    124127        return;
    125128
     
    134137void JSMockContentFilterSettings::setUnblockRequestDecision(ExecState& state, JSValue value)
    135138{
     139    VM& vm = state.vm();
     140    auto scope = DECLARE_THROW_SCOPE(vm);
     141
    136142    Decision unblockRequestDecision { toDecision(state, value) };
    137     if (state.hadException())
     143    if (UNLIKELY(scope.exception()))
    138144        return;
    139145
  • trunk/Source/WebCore/bindings/js/JSNodeFilterCustom.cpp

    r205198 r205569  
    5050    MarkedArgumentBuffer args;
    5151    args.append(toJS(state, m_data->globalObject(), node));
    52     if (state->hadException())
     52    if (UNLIKELY(scope.exception()))
    5353        return NodeFilter::FILTER_REJECT;
    5454
    5555    NakedPtr<Exception> returnedException;
    5656    JSValue value = m_data->invokeCallback(args, JSCallbackData::CallbackType::FunctionOrObject, Identifier::fromString(state, "acceptNode"), returnedException);
     57    ASSERT(!scope.exception() || returnedException);
    5758    if (returnedException) {
    5859        // Rethrow exception.
     
    6364
    6465    uint16_t result = convert<uint16_t>(*state, value, NormalConversion);
    65     if (state->hadException())
     66    if (UNLIKELY(scope.exception()))
    6667        return NodeFilter::FILTER_REJECT;
    6768
  • trunk/Source/WebCore/bindings/js/JSNodeOrString.cpp

    r204493 r205569  
    2929#include "JSNode.h"
    3030#include <JavaScriptCore/JSString.h>
     31#include <JavaScriptCore/ThrowScope.h>
    3132
    3233using namespace JSC;
     
    3637Vector<std::experimental::variant<Ref<Node>, String>> toNodeOrStringVector(ExecState& state)
    3738{
     39    VM& vm = state.vm();
     40    auto scope = DECLARE_THROW_SCOPE(vm);
     41
    3842    size_t argumentCount = state.argumentCount();
    3943
     
    4751        else {
    4852            String string = value.toWTFString(&state);
    49             if (state.hadException())
     53            if (UNLIKELY(scope.exception()))
    5054                return { };
    5155            result.uncheckedAppend(string);
  • trunk/Source/WebCore/bindings/js/JSSQLTransactionCustom.cpp

    r205324 r205569  
    4545JSValue JSSQLTransaction::executeSql(ExecState& state)
    4646{
     47    VM& vm = state.vm();
     48    auto scope = DECLARE_THROW_SCOPE(vm);
     49
    4750    if (!state.argumentCount()) {
    4851        setDOMException(&state, SYNTAX_ERR);
     
    5154
    5255    String sqlStatement = state.argument(0).toString(&state)->value(&state);
    53     if (state.hadException())
     56    if (UNLIKELY(scope.exception()))
    5457        return jsUndefined();
    5558
     
    6467
    6568        JSValue lengthValue = object->get(&state, state.propertyNames().length);
    66         if (state.hadException())
     69        if (UNLIKELY(scope.exception()))
    6770            return jsUndefined();
    6871        unsigned length = lengthValue.toUInt32(&state);
    69         if (state.hadException())
     72        if (UNLIKELY(scope.exception()))
    7073            return jsUndefined();
    7174
    7275        for (unsigned i = 0 ; i < length; ++i) {
    7376            JSValue value = object->get(&state, i);
    74             if (state.hadException())
     77            if (UNLIKELY(scope.exception()))
    7578                return jsUndefined();
    7679
     
    8285                // Convert the argument to a string and append it
    8386                sqlValues.append(value.toString(&state)->value(&state));
    84                 if (state.hadException())
     87                if (UNLIKELY(scope.exception()))
    8588                    return jsUndefined();
    8689            }
  • trunk/Source/WebCore/bindings/js/JSSVGLengthCustom.cpp

    r205198 r205569  
    9191
    9292    unsigned short unitType = state.uncheckedArgument(0).toUInt32(&state);
    93     if (state.hadException())
     93    if (UNLIKELY(scope.exception()))
    9494        return jsUndefined();
    9595
  • trunk/Source/WebCore/bindings/js/JSStorageCustom.cpp

    r202031 r205569  
    8080void JSStorage::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
    8181{
     82    VM& vm = exec->vm();
     83    auto scope = DECLARE_THROW_SCOPE(vm);
     84
    8285    JSStorage* thisObject = jsCast<JSStorage*>(object);
    8386    ExceptionCode ec = 0;
    8487    unsigned length = thisObject->wrapped().length(ec);
    8588    setDOMException(exec, ec);
    86     if (exec->hadException())
     89    if (UNLIKELY(scope.exception()))
    8790        return;
    8891    for (unsigned i = 0; i < length; ++i) {
    8992        propertyNames.add(Identifier::fromString(exec, thisObject->wrapped().key(i, ec)));
    9093        setDOMException(exec, ec);
    91         if (exec->hadException())
     94        if (UNLIKELY(scope.exception()))
    9295            return;
    9396    }
     
    98101bool JSStorage::putDelegate(ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot&, bool& putResult)
    99102{
     103    VM& vm = exec->vm();
     104    auto scope = DECLARE_THROW_SCOPE(vm);
     105
    100106    // Only perform the custom put if the object doesn't have a native property by this name.
    101107    // Since hasProperty() would end up calling canGetItemsForName() and be fooled, we need to check
     
    111117
    112118    String stringValue = value.toString(exec)->value(exec);
    113     if (exec->hadException()) {
     119    if (UNLIKELY(scope.exception())) {
    114120        // The return value indicates whether putDelegate() should handle the put operation (which
    115121        // if true, tells the caller not to execute the generic put). It does not indicate whether
  • trunk/Source/WebCore/bindings/js/JSTextTrackCustom.cpp

    r200317 r205569  
    4545{
    4646#if ENABLE(MEDIA_SOURCE)
     47    VM& vm = state.vm();
     48    auto scope = DECLARE_THROW_SCOPE(vm);
     49
    4750    auto& string = value.toString(&state)->value(&state);
    48     if (state.hadException())
     51    if (UNLIKELY(scope.exception()))
    4952        return;
    5053    wrapped().setLanguage(string);
  • trunk/Source/WebCore/bindings/js/JSVideoTrackCustom.cpp

    r191887 r205569  
    4444{
    4545#if ENABLE(MEDIA_SOURCE)
     46    VM& vm = state.vm();
     47    auto scope = DECLARE_THROW_SCOPE(vm);
     48
    4649    auto& string = value.toString(&state)->value(&state);
    47     if (state.hadException())
     50    if (UNLIKELY(scope.exception()))
    4851        return;
    4952    wrapped().setKind(string);
     
    5760{
    5861#if ENABLE(MEDIA_SOURCE)
     62    VM& vm = state.vm();
     63    auto scope = DECLARE_THROW_SCOPE(vm);
     64
    5965    auto& string = value.toString(&state)->value(&state);
    60     if (state.hadException())
     66    if (UNLIKELY(scope.exception()))
    6167        return;
    6268    wrapped().setLanguage(string);
  • trunk/Source/WebCore/bindings/js/JSWebGL2RenderingContextCustom.cpp

    r205462 r205569  
    107107    WebGL2RenderingContext& context = wrapped();
    108108    unsigned pname = exec.uncheckedArgument(0).toInt32(&exec);
    109     if (exec.hadException())
     109    if (UNLIKELY(scope.exception()))
    110110        return jsUndefined();
    111111    unsigned index = exec.uncheckedArgument(1).toInt32(&exec);
    112     if (exec.hadException())
     112    if (UNLIKELY(scope.exception()))
    113113        return jsUndefined();
    114114    WebGLGetInfo info = context.getIndexedParameter(pname, index);
  • trunk/Source/WebCore/bindings/js/JSWebGLRenderingContextBaseCustom.cpp

    r205422 r205569  
    200200    WebGLRenderingContextBase& context = obj->wrapped();
    201201    unsigned target = state.uncheckedArgument(0).toInt32(&state);
    202     if (state.hadException())
     202    if (UNLIKELY(scope.exception()))
    203203        return jsUndefined();
    204204    unsigned pname = state.uncheckedArgument(1).toInt32(&state);
    205     if (state.hadException())
     205    if (UNLIKELY(scope.exception()))
    206206        return jsUndefined();
    207207    WebGLGetInfo info;
     
    336336    WebGLRenderingContextBase& context = wrapped();
    337337    const String name = state.uncheckedArgument(0).toString(&state)->value(&state);
    338     if (state.hadException())
     338    if (UNLIKELY(scope.exception()))
    339339        return jsUndefined();
    340340    WebGLExtension* extension = context.getExtension(name);
     
    358358    WebGLRenderingContextBase& context = wrapped();
    359359    unsigned target = state.uncheckedArgument(0).toInt32(&state);
    360     if (state.hadException())
     360    if (UNLIKELY(scope.exception()))
    361361        return jsUndefined();
    362362    unsigned attachment = state.uncheckedArgument(1).toInt32(&state);
    363     if (state.hadException())
     363    if (UNLIKELY(scope.exception()))
    364364        return jsUndefined();
    365365    unsigned pname = state.uncheckedArgument(2).toInt32(&state);
    366     if (state.hadException())
     366    if (UNLIKELY(scope.exception()))
    367367        return jsUndefined();
    368368    WebGLGetInfo info = context.getFramebufferAttachmentParameter(target, attachment, pname, ec);
     
    385385    WebGLRenderingContextBase& context = wrapped();
    386386    unsigned pname = state.uncheckedArgument(0).toInt32(&state);
    387     if (state.hadException())
     387    if (UNLIKELY(scope.exception()))
    388388        return jsUndefined();
    389389    WebGLGetInfo info = context.getParameter(pname, ec);
     
    409409        return throwTypeError(&state, scope);
    410410    unsigned pname = state.uncheckedArgument(1).toInt32(&state);
    411     if (state.hadException())
     411    if (UNLIKELY(scope.exception()))
    412412        return jsUndefined();
    413413    WebGLGetInfo info = context.getProgramParameter(program, pname, ec);
     
    438438    WebGLShader* shader = JSWebGLShader::toWrapped(state.uncheckedArgument(0));
    439439    unsigned pname = state.uncheckedArgument(1).toInt32(&state);
    440     if (state.hadException())
     440    if (UNLIKELY(scope.exception()))
    441441        return jsUndefined();
    442442    WebGLGetInfo info = context.getShaderParameter(shader, pname, ec);
     
    497497bool toVector(JSC::ExecState& state, JSC::JSValue value, Vector<T, inlineCapacity>& vector)
    498498{
     499    VM& vm = state.vm();
     500    auto scope = DECLARE_THROW_SCOPE(vm);
     501
    499502    if (!value.isObject())
    500503        return false;
     
    509512    for (int32_t i = 0; i < length; ++i) {
    510513        JSC::JSValue v = object->get(&state, i);
    511         if (state.hadException())
     514        if (UNLIKELY(scope.exception()))
    512515            return false;
    513516        vector[i] = static_cast<T>(v.toNumber(&state));
     
    557560        index = state.uncheckedArgument(0).toInt32(&state);
    558561   
    559     if (state.hadException())
     562    if (UNLIKELY(scope.exception()))
    560563        return jsUndefined();
    561564   
    562565    RefPtr<Float32Array> webGLArray = toFloat32Array(state.uncheckedArgument(1));
    563     if (state.hadException())
     566    if (UNLIKELY(scope.exception()))
    564567        return jsUndefined();
    565568   
     
    708711   
    709712    bool transpose = state.uncheckedArgument(1).toBoolean(&state);
    710     if (state.hadException())
     713    if (UNLIKELY(scope.exception()))
    711714        return jsUndefined();
    712715   
  • trunk/Source/WebCore/bindings/js/JSWebKitSubtleCryptoCustom.cpp

    r205257 r205569  
    6464static RefPtr<CryptoAlgorithm> createAlgorithmFromJSValue(ExecState& state, JSValue value)
    6565{
     66    VM& vm = state.vm();
     67    auto scope = DECLARE_THROW_SCOPE(vm);
     68
    6669    CryptoAlgorithmIdentifier algorithmIdentifier;
    67     if (!JSCryptoAlgorithmDictionary::getAlgorithmIdentifier(&state, value, algorithmIdentifier)) {
    68         ASSERT(state.hadException());
     70    auto success = JSCryptoAlgorithmDictionary::getAlgorithmIdentifier(&state, value, algorithmIdentifier);
     71    ASSERT_UNUSED(scope, scope.exception() || success);
     72    if (!success)
    6973        return nullptr;
    70     }
    7174
    7275    auto result = CryptoAlgorithmRegistry::singleton().create(algorithmIdentifier);
     
    8285
    8386    String keyFormatString = value.toString(&state)->value(&state);
    84     if (state.hadException())
     87    if (UNLIKELY(scope.exception()))
    8588        return false;
    8689    if (keyFormatString == "raw")
     
    115118        JSValue element = array->getIndex(&state, i);
    116119        String usageString = element.toString(&state)->value(&state);
    117         if (state.hadException())
     120        if (UNLIKELY(scope.exception()))
    118121            return false;
    119122        if (usageString == "encrypt")
     
    146149
    147150    auto algorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(0));
    148     if (!algorithm) {
    149         ASSERT(state.hadException());
    150         return jsUndefined();
    151     }
     151    ASSERT(scope.exception() || algorithm);
     152    if (!algorithm)
     153        return jsUndefined();
    152154
    153155    auto parameters = JSCryptoAlgorithmDictionary::createParametersForEncrypt(&state, algorithm->identifier(), state.uncheckedArgument(0));
    154     if (!parameters) {
    155         ASSERT(state.hadException());
    156         return jsUndefined();
    157     }
     156    ASSERT(scope.exception() || parameters);
     157    if (!parameters)
     158        return jsUndefined();
    158159
    159160    RefPtr<CryptoKey> key = JSCryptoKey::toWrapped(state.uncheckedArgument(1));
     
    168169
    169170    CryptoOperationData data;
    170     if (!cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(2), data)) {
    171         ASSERT(state.hadException());
    172         return jsUndefined();
    173     }
     171    auto success = cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(2), data);
     172    ASSERT(scope.exception() || success);
     173    if (!success)
     174        return jsUndefined();
    174175
    175176   
     
    202203
    203204    auto algorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(0));
    204     if (!algorithm) {
    205         ASSERT(state.hadException());
    206         return jsUndefined();
    207     }
     205    ASSERT(scope.exception() || algorithm);
     206    if (!algorithm)
     207        return jsUndefined();
    208208
    209209    auto parameters = JSCryptoAlgorithmDictionary::createParametersForDecrypt(&state, algorithm->identifier(), state.uncheckedArgument(0));
    210     if (!parameters) {
    211         ASSERT(state.hadException());
    212         return jsUndefined();
    213     }
     210    ASSERT(scope.exception() || parameters);
     211    if (!parameters)
     212        return jsUndefined();
    214213
    215214    RefPtr<CryptoKey> key = JSCryptoKey::toWrapped(state.uncheckedArgument(1));
     
    224223
    225224    CryptoOperationData data;
    226     if (!cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(2), data)) {
    227         ASSERT(state.hadException());
    228         return jsUndefined();
    229     }
     225    auto success = cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(2), data);
     226    ASSERT(scope.exception() || success);
     227    if (!success)
     228        return jsUndefined();
    230229
    231230    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
     
    257256
    258257    auto algorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(0));
    259     if (!algorithm) {
    260         ASSERT(state.hadException());
    261         return jsUndefined();
    262     }
     258    ASSERT(scope.exception() || algorithm);
     259    if (!algorithm)
     260        return jsUndefined();
    263261
    264262    auto parameters = JSCryptoAlgorithmDictionary::createParametersForSign(&state, algorithm->identifier(), state.uncheckedArgument(0));
    265     if (!parameters) {
    266         ASSERT(state.hadException());
    267         return jsUndefined();
    268     }
     263    ASSERT(scope.exception() || parameters);
     264    if (!parameters)
     265        return jsUndefined();
    269266
    270267    RefPtr<CryptoKey> key = JSCryptoKey::toWrapped(state.uncheckedArgument(1));
     
    279276
    280277    CryptoOperationData data;
    281     if (!cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(2), data)) {
    282         ASSERT(state.hadException());
    283         return jsUndefined();
    284     }
     278    auto success = cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(2), data);
     279    ASSERT(scope.exception() || success);
     280    if (!success)
     281        return jsUndefined();
    285282
    286283    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
     
    312309
    313310    auto algorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(0));
    314     if (!algorithm) {
    315         ASSERT(state.hadException());
    316         return jsUndefined();
    317     }
     311    ASSERT(scope.exception() || algorithm);
     312    if (!algorithm)
     313        return jsUndefined();
    318314
    319315    auto parameters = JSCryptoAlgorithmDictionary::createParametersForVerify(&state, algorithm->identifier(), state.uncheckedArgument(0));
    320     if (!parameters) {
    321         ASSERT(state.hadException());
    322         return jsUndefined();
    323     }
     316    ASSERT(scope.exception() || parameters);
     317    if (!parameters)
     318        return jsUndefined();
    324319
    325320    RefPtr<CryptoKey> key = JSCryptoKey::toWrapped(state.uncheckedArgument(1));
     
    334329
    335330    CryptoOperationData signature;
    336     if (!cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(2), signature)) {
    337         ASSERT(state.hadException());
    338         return jsUndefined();
    339     }
     331    auto success = cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(2), signature);
     332    ASSERT(scope.exception() || success);
     333    if (!success)
     334        return jsUndefined();
    340335
    341336    CryptoOperationData data;
    342     if (!cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(3), data)) {
    343         ASSERT(state.hadException());
    344         return jsUndefined();
    345     }
     337    success = cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(3), data);
     338    ASSERT(scope.exception() || success);
     339    if (!success)
     340        return jsUndefined();
    346341
    347342    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
     
    373368
    374369    auto algorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(0));
    375     if (!algorithm) {
    376         ASSERT(state.hadException());
    377         return jsUndefined();
    378     }
     370    ASSERT(scope.exception() || algorithm);
     371    if (!algorithm)
     372        return jsUndefined();
    379373
    380374    auto parameters = JSCryptoAlgorithmDictionary::createParametersForDigest(&state, algorithm->identifier(), state.uncheckedArgument(0));
    381     if (!parameters) {
    382         ASSERT(state.hadException());
    383         return jsUndefined();
    384     }
     375    ASSERT(scope.exception() || parameters);
     376    if (!parameters)
     377        return jsUndefined();
    385378
    386379    CryptoOperationData data;
    387     if (!cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(1), data)) {
    388         ASSERT(state.hadException());
    389         return jsUndefined();
    390     }
     380    auto success = cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(1), data);
     381    ASSERT(scope.exception() || success);
     382    if (!success)
     383        return jsUndefined();
    391384
    392385    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
     
    418411
    419412    auto algorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(0));
    420     if (!algorithm) {
    421         ASSERT(state.hadException());
    422         return jsUndefined();
    423     }
     413    ASSERT(scope.exception() || algorithm);
     414    if (!algorithm)
     415        return jsUndefined();
    424416
    425417    auto parameters = JSCryptoAlgorithmDictionary::createParametersForGenerateKey(&state, algorithm->identifier(), state.uncheckedArgument(0));
    426     if (!parameters) {
    427         ASSERT(state.hadException());
    428         return jsUndefined();
    429     }
     418    ASSERT(scope.exception() || parameters);
     419    if (!parameters)
     420        return jsUndefined();
    430421
    431422    bool extractable = false;
    432423    if (state.argumentCount() >= 2) {
    433424        extractable = state.uncheckedArgument(1).toBoolean(&state);
    434         if (state.hadException())
     425        if (UNLIKELY(scope.exception()))
    435426            return jsUndefined();
    436427    }
     
    438429    CryptoKeyUsage keyUsages = 0;
    439430    if (state.argumentCount() >= 3) {
    440         if (!cryptoKeyUsagesFromJSValue(state, state.argument(2), keyUsages)) {
    441             ASSERT(state.hadException());
    442             return jsUndefined();
    443         }
     431        auto success = cryptoKeyUsagesFromJSValue(state, state.argument(2), keyUsages);
     432        ASSERT(scope.exception() || success);
     433        if (!success)
     434            return jsUndefined();
    444435    }
    445436
     
    485476        }
    486477        keySerialization = std::make_unique<JSCryptoKeySerializationJWK>(&state, jwkString);
    487         if (state.hadException())
     478        if (UNLIKELY(scope.exception()))
    488479            return;
    489480        break;
     
    498489    Optional<CryptoAlgorithmPair> reconciledResult = keySerialization->reconcileAlgorithm(algorithm.get(), parameters.get());
    499490    if (!reconciledResult) {
    500         if (!state.hadException())
     491        if (!scope.exception())
    501492            throwTypeError(&state, scope, ASCIILiteral("Algorithm specified in key is not compatible with one passed to importKey as argument"));
    502493        return;
    503494    }
    504     if (state.hadException())
     495    if (UNLIKELY(scope.exception()))
    505496        return;
    506497
     
    514505
    515506    keySerialization->reconcileExtractable(extractable);
    516     if (state.hadException())
     507    if (UNLIKELY(scope.exception()))
    517508        return;
    518509
    519510    keySerialization->reconcileUsages(keyUsages);
    520     if (state.hadException())
     511    if (UNLIKELY(scope.exception()))
    521512        return;
    522513
    523514    auto keyData = keySerialization->keyData();
    524     if (state.hadException())
     515    if (UNLIKELY(scope.exception()))
    525516        return;
    526517
     
    540531
    541532    CryptoKeyFormat keyFormat;
    542     if (!cryptoKeyFormatFromJSValue(state, state.argument(0), keyFormat)) {
    543         ASSERT(state.hadException());
    544         return jsUndefined();
    545     }
     533    auto success = cryptoKeyFormatFromJSValue(state, state.argument(0), keyFormat);
     534    ASSERT(scope.exception() || success);
     535    if (!success)
     536        return jsUndefined();
    546537
    547538    CryptoOperationData data;
    548     if (!cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(1), data)) {
    549         ASSERT(state.hadException());
    550         return jsUndefined();
    551     }
     539    success = cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(1), data);
     540    ASSERT(scope.exception() || success);
     541    if (!success)
     542        return jsUndefined();
    552543
    553544    RefPtr<CryptoAlgorithm> algorithm;
     
    555546    if (!state.uncheckedArgument(2).isNull()) {
    556547        algorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(2));
    557         if (!algorithm) {
    558             ASSERT(state.hadException());
    559             return jsUndefined();
    560         }
     548        ASSERT(scope.exception() || algorithm);
     549        if (!algorithm)
     550            return jsUndefined();
     551
    561552        parameters = JSCryptoAlgorithmDictionary::createParametersForImportKey(&state, algorithm->identifier(), state.uncheckedArgument(2));
    562         if (!parameters) {
    563             ASSERT(state.hadException());
    564             return jsUndefined();
    565         }
     553        ASSERT(scope.exception() || parameters);
     554        if (!parameters)
     555            return jsUndefined();
    566556    }
    567557
     
    569559    if (state.argumentCount() >= 4) {
    570560        extractable = state.uncheckedArgument(3).toBoolean(&state);
    571         if (state.hadException())
     561        if (UNLIKELY(scope.exception()))
    572562            return jsUndefined();
    573563    }
     
    575565    CryptoKeyUsage keyUsages = 0;
    576566    if (state.argumentCount() >= 5) {
    577         if (!cryptoKeyUsagesFromJSValue(state, state.argument(4), keyUsages)) {
    578             ASSERT(state.hadException());
    579             return jsUndefined();
    580         }
     567        auto success = cryptoKeyUsagesFromJSValue(state, state.argument(4), keyUsages);
     568        ASSERT(scope.exception() || success);
     569        if (!success)
     570            return jsUndefined();
    581571    }
    582572
     
    591581
    592582    WebCore::importKey(state, keyFormat, data, WTFMove(algorithm), WTFMove(parameters), extractable, keyUsages, WTFMove(successCallback), WTFMove(failureCallback));
    593     if (state.hadException())
     583    if (UNLIKELY(scope.exception()))
    594584        return jsUndefined();
    595585
     
    618608    case CryptoKeyFormat::JWK: {
    619609        String result = JSCryptoKeySerializationJWK::serialize(&state, key);
    620         if (state.hadException())
     610        if (UNLIKELY(scope.exception()))
    621611            return;
    622612        CString utf8String = result.utf8(StrictConversion);
     
    641631
    642632    CryptoKeyFormat keyFormat;
    643     if (!cryptoKeyFormatFromJSValue(state, state.argument(0), keyFormat)) {
    644         ASSERT(state.hadException());
    645         return jsUndefined();
    646     }
     633    auto success = cryptoKeyFormatFromJSValue(state, state.argument(0), keyFormat);
     634    ASSERT(scope.exception() || success);
     635    if (!success)
     636        return jsUndefined();
    647637
    648638    RefPtr<CryptoKey> key = JSCryptoKey::toWrapped(state.uncheckedArgument(1));
     
    660650
    661651    WebCore::exportKey(state, keyFormat, *key, WTFMove(successCallback), WTFMove(failureCallback));
    662     if (state.hadException())
     652    if (UNLIKELY(scope.exception()))
    663653        return jsUndefined();
    664654
     
    675665
    676666    CryptoKeyFormat keyFormat;
    677     if (!cryptoKeyFormatFromJSValue(state, state.argument(0), keyFormat)) {
    678         ASSERT(state.hadException());
    679         return jsUndefined();
    680     }
     667    auto success = cryptoKeyFormatFromJSValue(state, state.argument(0), keyFormat);
     668    ASSERT(scope.exception() || success);
     669    if (!success)
     670        return jsUndefined();
    681671
    682672    RefPtr<CryptoKey> key = JSCryptoKey::toWrapped(state.uncheckedArgument(1));
     
    695685
    696686    auto algorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(3));
    697     if (!algorithm) {
    698         ASSERT(state.hadException());
    699         return jsUndefined();
    700     }
     687    ASSERT(scope.exception() || algorithm);
     688    if (!algorithm)
     689        return jsUndefined();
    701690
    702691    auto parameters = JSCryptoAlgorithmDictionary::createParametersForEncrypt(&state, algorithm->identifier(), state.uncheckedArgument(3));
    703     if (!parameters) {
    704         ASSERT(state.hadException());
    705         return jsUndefined();
    706     }
     692    ASSERT(scope.exception() || parameters);
     693    if (!parameters)
     694        return jsUndefined();
    707695
    708696    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
     
    747735
    748736    CryptoKeyFormat keyFormat;
    749     if (!cryptoKeyFormatFromJSValue(state, state.argument(0), keyFormat)) {
    750         ASSERT(state.hadException());
    751         return jsUndefined();
    752     }
     737    auto success = cryptoKeyFormatFromJSValue(state, state.argument(0), keyFormat);
     738    ASSERT(scope.exception() || success);
     739    if (!success)
     740        return jsUndefined();
    753741
    754742    CryptoOperationData wrappedKeyData;
    755     if (!cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(1), wrappedKeyData)) {
    756         ASSERT(state.hadException());
    757         return jsUndefined();
    758     }
     743    success = cryptoOperationDataFromJSValue(&state, state.uncheckedArgument(1), wrappedKeyData);
     744    ASSERT(scope.exception() || success);
     745    if (!success)
     746        return jsUndefined();
    759747
    760748    RefPtr<CryptoKey> unwrappingKey = JSCryptoKey::toWrapped(state.uncheckedArgument(2));
     
    769757
    770758    auto unwrapAlgorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(3));
    771     if (!unwrapAlgorithm) {
    772         ASSERT(state.hadException());
    773         return jsUndefined();
    774     }
     759    ASSERT(scope.exception() || unwrapAlgorithm);
     760    if (!unwrapAlgorithm)
     761        return jsUndefined();
    775762    auto unwrapAlgorithmParameters = JSCryptoAlgorithmDictionary::createParametersForDecrypt(&state, unwrapAlgorithm->identifier(), state.uncheckedArgument(3));
    776     if (!unwrapAlgorithmParameters) {
    777         ASSERT(state.hadException());
    778         return jsUndefined();
    779     }
     763    ASSERT(scope.exception() || unwrapAlgorithmParameters);
     764    if (!unwrapAlgorithmParameters)
     765        return jsUndefined();
    780766
    781767    RefPtr<CryptoAlgorithm> unwrappedKeyAlgorithm;
     
    783769    if (!state.uncheckedArgument(4).isNull()) {
    784770        unwrappedKeyAlgorithm = createAlgorithmFromJSValue(state, state.uncheckedArgument(4));
    785         if (!unwrappedKeyAlgorithm) {
    786             ASSERT(state.hadException());
    787             return jsUndefined();
    788         }
     771        ASSERT(scope.exception() || unwrappedKeyAlgorithm);
     772        if (!unwrappedKeyAlgorithm)
     773            return jsUndefined();
     774
    789775        unwrappedKeyAlgorithmParameters = JSCryptoAlgorithmDictionary::createParametersForImportKey(&state, unwrappedKeyAlgorithm->identifier(), state.uncheckedArgument(4));
    790         if (!unwrappedKeyAlgorithmParameters) {
    791             ASSERT(state.hadException());
    792             return jsUndefined();
    793         }
     776        ASSERT(scope.exception() || unwrappedKeyAlgorithmParameters);
     777        if (!unwrappedKeyAlgorithmParameters)
     778            return jsUndefined();
    794779    }
    795780
     
    797782    if (state.argumentCount() >= 6) {
    798783        extractable = state.uncheckedArgument(5).toBoolean(&state);
    799         if (state.hadException())
     784        if (UNLIKELY(scope.exception()))
    800785            return jsUndefined();
    801786    }
     
    803788    CryptoKeyUsage keyUsages = 0;
    804789    if (state.argumentCount() >= 7) {
    805         if (!cryptoKeyUsagesFromJSValue(state, state.argument(6), keyUsages)) {
    806             ASSERT(state.hadException());
    807             return jsUndefined();
    808         }
     790        auto success = cryptoKeyUsagesFromJSValue(state, state.argument(6), keyUsages);
     791        ASSERT(scope.exception() || success);
     792        if (!success)
     793            return jsUndefined();
    809794    }
    810795
     
    820805            wrapper->reject(nullptr);
    821806        };
     807
     808        VM& vm = domGlobalObject->vm();
     809        auto scope = DECLARE_CATCH_SCOPE(vm);
     810
    822811        ExecState& state = *domGlobalObject->globalExec();
    823812        WebCore::importKey(state, keyFormat, std::make_pair(result.data(), result.size()), unwrappedKeyAlgorithm, unwrappedKeyAlgorithmParameters, extractable, keyUsages, WTFMove(importSuccessCallback), WTFMove(importFailureCallback));
    824         if (state.hadException()) {
     813        if (UNLIKELY(scope.exception())) {
    825814            // FIXME: Report exception details to console, and possibly to calling script once there is a standardized way to pass errors to WebCrypto promise reject functions.
    826             state.clearException();
     815            scope.clearException();
    827816            wrapper->reject(nullptr);
    828817        }
  • trunk/Source/WebCore/bindings/js/JSWorkerCustom.cpp

    r205198 r205569  
    5757
    5858    String scriptURL = exec.uncheckedArgument(0).toWTFString(&exec);
    59     if (exec.hadException())
     59    if (UNLIKELY(scope.exception()))
    6060        return JSValue::encode(JSValue());
    6161
  • trunk/Source/WebCore/bindings/js/JSWorkerGlobalScopeCustom.cpp

    r205462 r205569  
    6262JSValue JSWorkerGlobalScope::importScripts(ExecState& state)
    6363{
     64    VM& vm = state.vm();
     65    auto scope = DECLARE_THROW_SCOPE(vm);
     66
    6467    if (!state.argumentCount())
    6568        return jsUndefined();
     
    6871    for (unsigned i = 0; i < state.argumentCount(); ++i) {
    6972        urls.append(valueToUSVString(&state, state.uncheckedArgument(i)));
    70         if (state.hadException())
     73        if (UNLIKELY(scope.exception()))
    7174            return jsUndefined();
    7275    }
     
    8790
    8891    std::unique_ptr<ScheduledAction> action = ScheduledAction::create(&state, globalObject()->world(), wrapped().contentSecurityPolicy());
    89     if (state.hadException())
     92    if (UNLIKELY(scope.exception()))
    9093        return jsUndefined();
    9194    if (!action)
     
    104107
    105108    std::unique_ptr<ScheduledAction> action = ScheduledAction::create(&state, globalObject()->world(), wrapped().contentSecurityPolicy());
    106     if (state.hadException())
     109    if (UNLIKELY(scope.exception()))
    107110        return jsUndefined();
    108111    if (!action)
  • trunk/Source/WebCore/bindings/js/ReadableStreamDefaultController.cpp

    r205549 r205569  
    5454
    5555    auto function = object.get(&state, JSC::Identifier::fromString(&state, propertyName));
    56     if (state.hadException())
     56    if (UNLIKELY(scope.exception()))
    5757        return JSC::jsUndefined();
    5858
     
    7171bool ReadableStreamDefaultController::isControlledReadableStreamLocked() const
    7272{
    73     auto& state = *globalObject()->globalExec();
    74     JSC::JSLockHolder lock(&state);
     73    auto globalObject = this->globalObject();
     74    JSC::VM& vm = globalObject->vm();
     75    JSC::JSLockHolder lock(vm);
     76    auto scope = DECLARE_CATCH_SCOPE(vm);
     77    auto& state = *globalObject->globalExec();
    7578
    76     auto& clientData = *static_cast<JSVMClientData*>(state.vm().clientData);
     79    auto& clientData = *static_cast<JSVMClientData*>(vm.clientData);
    7780    auto readableStream = m_jsController->get(&state, clientData.builtinNames().controlledReadableStreamPrivateName());
    78     ASSERT(!state.hadException());
     81    ASSERT_UNUSED(scope, !scope.exception());
    7982
    80     auto isLocked = globalObject()->builtinInternalFunctions().readableStreamInternals().m_isReadableStreamLockedFunction.get();
     83    auto isLocked = globalObject->builtinInternalFunctions().readableStreamInternals().m_isReadableStreamLockedFunction.get();
    8184
    8285    JSC::MarkedArgumentBuffer arguments;
    8386    arguments.append(readableStream);
    8487    auto result = callFunction(state, isLocked, JSC::jsUndefined(), arguments);
    85     ASSERT(!state.hadException());
     88    ASSERT(!scope.exception());
    8689
    8790    return result.isTrue();
  • trunk/Source/WebCore/bindings/js/ReadableStreamDefaultController.h

    r205549 r205569  
    7575inline bool ReadableStreamDefaultController::enqueue(RefPtr<JSC::ArrayBuffer>&& buffer)
    7676{
    77     JSC::ExecState& state = *globalObject()->globalExec();
    78     JSC::JSLockHolder locker(&state);
     77    auto globalObject = this->globalObject();
     78    JSC::VM& vm = globalObject->vm();
     79    JSC::JSLockHolder locker(vm);
     80    auto scope = DECLARE_THROW_SCOPE(vm);
     81    JSC::ExecState& state = *globalObject->globalExec();
    7982
    8083    if (!buffer) {
     
    8588    auto chunk = JSC::Uint8Array::create(WTFMove(buffer), 0, length);
    8689    ASSERT(chunk);
    87     enqueue(state, toJS(&state, globalObject(), chunk.get()));
    88     ASSERT(!state.hadException());
     90    enqueue(state, toJS(&state, globalObject, chunk.get()));
     91    ASSERT_UNUSED(scope, !scope.exception());
    8992    return true;
    9093}
  • trunk/Source/WebCore/bindings/js/ScheduledAction.cpp

    r197614 r205569  
    4949std::unique_ptr<ScheduledAction> ScheduledAction::create(ExecState* exec, DOMWrapperWorld& isolatedWorld, ContentSecurityPolicy* policy)
    5050{
     51    VM& vm = exec->vm();
     52    auto scope = DECLARE_THROW_SCOPE(vm);
     53
    5154    JSValue v = exec->argument(0);
    5255    CallData callData;
     
    5558            return nullptr;
    5659        String string = v.toString(exec)->value(exec);
    57         if (exec->hadException())
     60        if (UNLIKELY(scope.exception()))
    5861            return nullptr;
    5962        return std::unique_ptr<ScheduledAction>(new ScheduledAction(string, isolatedWorld));
  • trunk/Source/WebCore/bindings/js/ScriptGlobalObject.cpp

    r199619 r205569  
    4444    auto& vm = scriptState.vm();
    4545    JSLockHolder lock(vm);
     46    auto scope = DECLARE_CATCH_SCOPE(vm);
    4647    auto& globalObject = *jsCast<JSDOMGlobalObject*>(scriptState.lexicalGlobalObject());
    4748    globalObject.putDirect(vm, Identifier::fromString(&vm, name), toJS(&scriptState, &globalObject, value));
    48     if (scriptState.hadException()) {
    49         reportException(&scriptState, scriptState.exception());
     49    if (UNLIKELY(scope.exception())) {
     50        reportException(&scriptState, scope.exception());
    5051        return false;
    5152    }
  • trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp

    r205520 r205569  
    390390    bool shouldTerminate()
    391391    {
    392         return m_exec->hadException();
     392        VM& vm = m_exec->vm();
     393        auto scope = DECLARE_THROW_SCOPE(vm);
     394        return scope.exception();
    393395    }
    394396
     
    24492451DeserializationResult CloneDeserializer::deserialize()
    24502452{
     2453    VM& vm = m_exec->vm();
     2454    auto scope = DECLARE_THROW_SCOPE(vm);
     2455
    24512456    Vector<uint32_t, 16> indexStack;
    24522457    Vector<Identifier, 16> propertyNameStack;
     
    24692474            }
    24702475            JSArray* outArray = constructEmptyArray(m_exec, 0, m_globalObject, length);
    2471             if (UNLIKELY(m_exec->hadException()))
     2476            if (UNLIKELY(scope.exception()))
    24722477                goto error;
    24732478            m_gcBuffer.append(outArray);
     
    25472552                return std::make_pair(JSValue(), StackOverflowError);
    25482553            JSMap* map = JSMap::create(m_exec, m_exec->vm(), m_globalObject->mapStructure());
    2549             if (UNLIKELY(m_exec->hadException()))
     2554            if (UNLIKELY(scope.exception()))
    25502555                goto error;
    25512556            m_gcBuffer.append(map);
     
    25782583                return std::make_pair(JSValue(), StackOverflowError);
    25792584            JSSet* set = JSSet::create(m_exec, m_exec->vm(), m_globalObject->setStructure());
    2580             if (UNLIKELY(m_exec->hadException()))
     2585            if (UNLIKELY(scope.exception()))
    25812586                goto error;
    25822587            m_gcBuffer.append(set);
     
    27112716{
    27122717    ExecState* exec = toJS(originContext);
    2713     JSLockHolder locker(exec);
     2718    VM& vm = exec->vm();
     2719    JSLockHolder locker(vm);
     2720    auto scope = DECLARE_CATCH_SCOPE(vm);
     2721
    27142722    JSValue value = toJS(exec, apiValue);
    27152723    RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::create(exec, value, nullptr, nullptr);
    2716     if (exec->hadException()) {
     2724    if (UNLIKELY(scope.exception())) {
    27172725        if (exception)
    2718             *exception = toRef(exec, exec->exception()->value());
    2719         exec->clearException();
     2726            *exception = toRef(exec, scope.exception()->value());
     2727        scope.clearException();
    27202728        return nullptr;
    27212729    }
     
    27462754{
    27472755    ExecState* exec = toJS(destinationContext);
    2748     JSLockHolder locker(exec);
     2756    VM& vm = exec->vm();
     2757    JSLockHolder locker(vm);
     2758    auto scope = DECLARE_CATCH_SCOPE(vm);
     2759
    27492760    JSValue value = deserialize(exec, exec->lexicalGlobalObject(), nullptr);
    2750     if (exec->hadException()) {
     2761    if (UNLIKELY(scope.exception())) {
    27512762        if (exception)
    2752             *exception = toRef(exec, exec->exception()->value());
    2753         exec->clearException();
     2763            *exception = toRef(exec, scope.exception()->value());
     2764        scope.clearException();
    27542765        return nullptr;
    27552766    }
  • trunk/Source/WebCore/bindings/js/WorkerScriptController.cpp

    r205462 r205569  
    128128    VM& vm = exec->vm();
    129129    JSLockHolder lock(vm);
    130     auto scope = DECLARE_THROW_SCOPE(vm);
    131130
    132131    JSC::evaluate(exec, sourceCode.jsSourceCode(), m_workerGlobalScopeWrapper->globalThis(), returnedException);
     
    143142        String sourceURL = sourceCode.url().string();
    144143        Deprecated::ScriptValue error;
    145         if (m_workerGlobalScope->sanitizeScriptError(errorMessage, lineNumber, columnNumber, sourceURL, error, sourceCode.cachedScript())) {
    146             throwException(exec, scope, createError(exec, errorMessage.impl()));
    147             returnedException = vm.exception();
    148             vm.clearException();
    149         }
     144        if (m_workerGlobalScope->sanitizeScriptError(errorMessage, lineNumber, columnNumber, sourceURL, error, sourceCode.cachedScript()))
     145            returnedException = Exception::create(vm, createError(exec, errorMessage.impl()));
    150146    }
    151147}
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r205542 r205569  
    10251025        foreach my $member (@{$dictionary->members}) {
    10261026            if ($needExceptionCheck) {
    1027                 $result .= "    if (UNLIKELY(state.hadException()))\n";
     1027                $result .= "    if (UNLIKELY(throwScope.exception()))\n";
    10281028                $result .= "        return Nullopt;\n";
    10291029            }
     
    31343134            push(@implContent, "    VM& vm = state->vm();\n");
    31353135            push(@implContent, "    auto throwScope = DECLARE_THROW_SCOPE(vm);\n");
    3136             push(@implContent, "    UNUSED_PARAM(throwScope);");
     3136            push(@implContent, "    UNUSED_PARAM(throwScope);\n");
    31373137            push(@implContent, "    JSValue value = JSValue::decode(encodedValue);\n");
    31383138            push(@implContent, "    UNUSED_PARAM(thisValue);\n") if !$attribute->isStatic;
     
    32323232                    push(@implContent, "        nativeValue = $nativeValue;\n");
    32333233                    if ($mayThrowException) {
    3234                         push(@implContent, "        if (UNLIKELY(state->hadException()))\n");
     3234                        push(@implContent, "        if (UNLIKELY(throwScope.exception()))\n");
    32353235                        push(@implContent, "            return false;\n");
    32363236                    }
     
    32433243                    push(@implContent, "    auto nativeValue = $nativeValue;\n");
    32443244                    if ($mayThrowException) {
    3245                         push(@implContent, "    if (UNLIKELY(state->hadException()))\n");
     3245                        push(@implContent, "    if (UNLIKELY(throwScope.exception()))\n");
    32463246                        push(@implContent, "        return false;\n");
    32473247                    }
     
    39803980
    39813981            if (IsNativeType($type)) {
    3982                 push(@$outputArray, "    if (UNLIKELY(state->hadException()))\n");
     3982                push(@$outputArray, "    if (UNLIKELY(throwScope.exception()))\n");
    39833983                push(@$outputArray, "        return JSValue::encode(jsUndefined());\n");
    39843984            }
     
    40204020
    40214021            push(@$outputArray, "$indent    $defineOptionalValue = parse<$className>(*state, ${name}Value);\n");
    4022             push(@$outputArray, "$indent    if (UNLIKELY(state->hadException()))\n");
     4022            push(@$outputArray, "$indent    if (UNLIKELY(throwScope.exception()))\n");
    40234023            push(@$outputArray, "$indent        return JSValue::encode(jsUndefined());\n");
    40244024            push(@$outputArray, "$indent    if (UNLIKELY(!$optionalValue))\n");
     
    40434043                push(@$outputArray, "        $name = $nativeValue;\n");
    40444044                if ($mayThrowException) {
    4045                     push(@$outputArray, "        if (UNLIKELY(state->hadException()))\n");
     4045                    push(@$outputArray, "        if (UNLIKELY(throwScope.exception()))\n");
    40464046                    push(@$outputArray, "            return JSValue::encode(jsUndefined());\n");
    40474047                }
     
    40864086                $value = "WTFMove($name)";
    40874087                if ($mayThrowException) {
    4088                     push(@$outputArray, "    if (UNLIKELY(state->hadException()))\n");
     4088                    push(@$outputArray, "    if (UNLIKELY(throwScope.exception()))\n");
    40894089                    push(@$outputArray, "        return JSValue::encode(jsUndefined());\n");
    40904090                }
     
    44674467
    44684468        if ($codeGenerator->ExtendedAttributeContains($function->signature->extendedAttributes->{"CallWith"}, "ScriptState")) {
    4469             push(@implContent, $indent . "if (UNLIKELY(state->hadException()))\n");
     4469            push(@implContent, $indent . "if (UNLIKELY(throwScope.exception()))\n");
    44704470            push(@implContent, $indent . "    return JSValue::encode(jsUndefined());\n");
    44714471        }
     
    52915291
    52925292    AtomicString eventType = state->uncheckedArgument(0).toString(state)->toAtomicString(state);
    5293     if (UNLIKELY(state->hadException()))
     5293    if (UNLIKELY(throwScope.exception()))
    52945294        return JSValue::encode(jsUndefined());
    52955295
     
    53005300        // Given the above test, this will always yield an object.
    53015301        JSObject* initializerObject = initializerValue.toObject(state);
    5302         ASSERT(!state->hadException());
     5302        ASSERT(!throwScope.exception());
    53035303
    53045304        // Create the dictionary wrapper from the initializer object.
     
    54435443
    54445444            if ($codeGenerator->ExtendedAttributeContains($interface->extendedAttributes->{"ConstructorCallWith"}, "ScriptState")) {
    5445                  push(@$outputArray, "    if (UNLIKELY(state->hadException()))\n");
     5445                 push(@$outputArray, "    if (UNLIKELY(throwScope.exception()))\n");
    54465446                 push(@$outputArray, "        return JSValue::encode(jsUndefined());\n");
    54475447            }
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp

    r205458 r205569  
    225225        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    226226    auto message = state->argument(0).toWTFString(state);
    227     if (UNLIKELY(state->hadException()))
     227    if (UNLIKELY(throwScope.exception()))
    228228        return JSValue::encode(jsUndefined());
    229229    impl.postMessage(WTFMove(message));
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp

    r205458 r205569  
    202202        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    203203    auto str = state->argument(0).toWTFString(state);
    204     if (UNLIKELY(state->hadException()))
     204    if (UNLIKELY(throwScope.exception()))
    205205        return JSValue::encode(jsUndefined());
    206206    impl.anotherFunction(WTFMove(str));
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp

    r205458 r205569  
    8686
    8787    AtomicString eventType = state->uncheckedArgument(0).toString(state)->toAtomicString(state);
    88     if (UNLIKELY(state->hadException()))
     88    if (UNLIKELY(throwScope.exception()))
    8989        return JSValue::encode(jsUndefined());
    9090
     
    9595        // Given the above test, this will always yield an object.
    9696        JSObject* initializerObject = initializerValue.toObject(state);
    97         ASSERT(!state->hadException());
     97        ASSERT(!throwScope.exception());
    9898
    9999        // Create the dictionary wrapper from the initializer object.
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp

    r205458 r205569  
    215215        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    216216    auto index = convert<uint32_t>(*state, state->argument(0), NormalConversion);
    217     if (UNLIKELY(state->hadException()))
     217    if (UNLIKELY(throwScope.exception()))
    218218        return JSValue::encode(jsUndefined());
    219219    JSValue result = toJS(state, castedThis->globalObject(), impl.item(WTFMove(index)));
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp

    r205458 r205569  
    278278    VM& vm = state->vm();
    279279    auto throwScope = DECLARE_THROW_SCOPE(vm);
    280     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     280    UNUSED_PARAM(throwScope);
     281    JSValue value = JSValue::decode(encodedValue);
    281282    UNUSED_PARAM(thisValue);
    282283    JSTestGlobalObject* castedThis = jsDynamicCast<JSTestGlobalObject*>(JSValue::decode(thisValue));
     
    286287    auto& impl = castedThis->wrapped();
    287288    auto nativeValue = value.toWTFString(state);
    288     if (UNLIKELY(state->hadException()))
     289    if (UNLIKELY(throwScope.exception()))
    289290        return false;
    290291    impl.setRegularAttribute(WTFMove(nativeValue));
     
    297298    VM& vm = state->vm();
    298299    auto throwScope = DECLARE_THROW_SCOPE(vm);
    299     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     300    UNUSED_PARAM(throwScope);
     301    JSValue value = JSValue::decode(encodedValue);
    300302    UNUSED_PARAM(thisValue);
    301303    JSTestGlobalObject* castedThis = jsDynamicCast<JSTestGlobalObject*>(JSValue::decode(thisValue));
     
    305307    auto& impl = castedThis->wrapped();
    306308    auto nativeValue = value.toWTFString(state);
    307     if (UNLIKELY(state->hadException()))
     309    if (UNLIKELY(throwScope.exception()))
    308310        return false;
    309311    impl.setPublicAndPrivateAttribute(WTFMove(nativeValue));
     
    317319    VM& vm = state->vm();
    318320    auto throwScope = DECLARE_THROW_SCOPE(vm);
    319     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     321    UNUSED_PARAM(throwScope);
     322    JSValue value = JSValue::decode(encodedValue);
    320323    UNUSED_PARAM(thisValue);
    321324    JSTestGlobalObject* castedThis = jsDynamicCast<JSTestGlobalObject*>(JSValue::decode(thisValue));
     
    325328    auto& impl = castedThis->wrapped();
    326329    auto nativeValue = value.toWTFString(state);
    327     if (UNLIKELY(state->hadException()))
     330    if (UNLIKELY(throwScope.exception()))
    328331        return false;
    329332    impl.setPublicAndPrivateConditionalAttribute(WTFMove(nativeValue));
     
    338341    VM& vm = state->vm();
    339342    auto throwScope = DECLARE_THROW_SCOPE(vm);
    340     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     343    UNUSED_PARAM(throwScope);
     344    JSValue value = JSValue::decode(encodedValue);
    341345    UNUSED_PARAM(thisValue);
    342346    JSTestGlobalObject* castedThis = jsDynamicCast<JSTestGlobalObject*>(JSValue::decode(thisValue));
     
    346350    auto& impl = castedThis->wrapped();
    347351    auto nativeValue = value.toWTFString(state);
    348     if (UNLIKELY(state->hadException()))
     352    if (UNLIKELY(throwScope.exception()))
    349353        return false;
    350354    impl.setEnabledAtRuntimeAttribute(WTFMove(nativeValue));
     
    373377        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    374378    auto testParam = state->argument(0).toWTFString(state);
    375     if (UNLIKELY(state->hadException()))
     379    if (UNLIKELY(throwScope.exception()))
    376380        return JSValue::encode(jsUndefined());
    377381    impl.regularOperation(WTFMove(testParam));
     
    394398        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    395399    auto testParam = state->argument(0).toWTFString(state);
    396     if (UNLIKELY(state->hadException()))
     400    if (UNLIKELY(throwScope.exception()))
    397401        return JSValue::encode(jsUndefined());
    398402    impl.enabledAtRuntimeOperation(WTFMove(testParam));
     
    417421        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    418422    auto testParam = convert<int32_t>(*state, state->argument(0), NormalConversion);
    419     if (UNLIKELY(state->hadException()))
     423    if (UNLIKELY(throwScope.exception()))
    420424        return JSValue::encode(jsUndefined());
    421425    impl.enabledAtRuntimeOperation(WTFMove(testParam));
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp

    r205458 r205569  
    232232    ExceptionCode ec = 0;
    233233    auto str1 = state->argument(0).toWTFString(state);
    234     if (UNLIKELY(state->hadException()))
     234    if (UNLIKELY(throwScope.exception()))
    235235        return JSValue::encode(jsUndefined());
    236236    auto str2 = state->argument(1).isUndefined() ? ASCIILiteral("defaultString") : state->uncheckedArgument(1).toWTFString(state);
    237     if (UNLIKELY(state->hadException()))
     237    if (UNLIKELY(throwScope.exception()))
    238238        return JSValue::encode(jsUndefined());
    239239    ScriptExecutionContext* context = castedThis->scriptExecutionContext();
     
    664664    VM& vm = state->vm();
    665665    auto throwScope = DECLARE_THROW_SCOPE(vm);
    666     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     666    UNUSED_PARAM(throwScope);
     667    JSValue value = JSValue::decode(encodedValue);
    667668    auto nativeValue = value.toWTFString(state);
    668     if (UNLIKELY(state->hadException()))
     669    if (UNLIKELY(throwScope.exception()))
    669670        return false;
    670671    TestInterface::setImplementsStaticAttr(WTFMove(nativeValue));
     
    679680    VM& vm = state->vm();
    680681    auto throwScope = DECLARE_THROW_SCOPE(vm);
    681     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     682    UNUSED_PARAM(throwScope);
     683    JSValue value = JSValue::decode(encodedValue);
    682684    UNUSED_PARAM(thisValue);
    683685    JSTestInterface* castedThis = jsDynamicCast<JSTestInterface*>(JSValue::decode(thisValue));
     
    687689    auto& impl = castedThis->wrapped();
    688690    auto nativeValue = value.toWTFString(state);
    689     if (UNLIKELY(state->hadException()))
     691    if (UNLIKELY(throwScope.exception()))
    690692        return false;
    691693    impl.setImplementsStr2(WTFMove(nativeValue));
     
    700702    VM& vm = state->vm();
    701703    auto throwScope = DECLARE_THROW_SCOPE(vm);
    702     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     704    UNUSED_PARAM(throwScope);
     705    JSValue value = JSValue::decode(encodedValue);
    703706    UNUSED_PARAM(thisValue);
    704707    JSTestInterface* castedThis = jsDynamicCast<JSTestInterface*>(JSValue::decode(thisValue));
     
    717720    VM& vm = state->vm();
    718721    auto throwScope = DECLARE_THROW_SCOPE(vm);
    719     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     722    UNUSED_PARAM(throwScope);
     723    JSValue value = JSValue::decode(encodedValue);
    720724    UNUSED_PARAM(thisValue);
    721725    JSTestInterface* castedThis = jsDynamicCast<JSTestInterface*>(JSValue::decode(thisValue));
     
    740744    VM& vm = state->vm();
    741745    auto throwScope = DECLARE_THROW_SCOPE(vm);
    742     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     746    UNUSED_PARAM(throwScope);
     747    JSValue value = JSValue::decode(encodedValue);
    743748    auto nativeValue = value.toWTFString(state);
    744     if (UNLIKELY(state->hadException()))
     749    if (UNLIKELY(throwScope.exception()))
    745750        return false;
    746751    WebCore::TestSupplemental::setSupplementalStaticAttr(WTFMove(nativeValue));
     
    755760    VM& vm = state->vm();
    756761    auto throwScope = DECLARE_THROW_SCOPE(vm);
    757     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     762    UNUSED_PARAM(throwScope);
     763    JSValue value = JSValue::decode(encodedValue);
    758764    UNUSED_PARAM(thisValue);
    759765    JSTestInterface* castedThis = jsDynamicCast<JSTestInterface*>(JSValue::decode(thisValue));
     
    763769    auto& impl = castedThis->wrapped();
    764770    auto nativeValue = value.toWTFString(state);
    765     if (UNLIKELY(state->hadException()))
     771    if (UNLIKELY(throwScope.exception()))
    766772        return false;
    767773    WebCore::TestSupplemental::setSupplementalStr2(impl, WTFMove(nativeValue));
     
    776782    VM& vm = state->vm();
    777783    auto throwScope = DECLARE_THROW_SCOPE(vm);
    778     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     784    UNUSED_PARAM(throwScope);
     785    JSValue value = JSValue::decode(encodedValue);
    779786    UNUSED_PARAM(thisValue);
    780787    JSTestInterface* castedThis = jsDynamicCast<JSTestInterface*>(JSValue::decode(thisValue));
     
    793800    VM& vm = state->vm();
    794801    auto throwScope = DECLARE_THROW_SCOPE(vm);
    795     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     802    UNUSED_PARAM(throwScope);
     803    JSValue value = JSValue::decode(encodedValue);
    796804    UNUSED_PARAM(thisValue);
    797805    JSTestInterface* castedThis = jsDynamicCast<JSTestInterface*>(JSValue::decode(thisValue));
     
    853861        return JSValue::encode(jsUndefined());
    854862    auto strArg = state->argument(0).toWTFString(state);
    855     if (UNLIKELY(state->hadException()))
     863    if (UNLIKELY(throwScope.exception()))
    856864        return JSValue::encode(jsUndefined());
    857865    auto objArg = JSTestObj::toWrapped(state->argument(1));
     
    931939        return JSValue::encode(jsUndefined());
    932940    auto strArg = state->argument(0).toWTFString(state);
    933     if (UNLIKELY(state->hadException()))
     941    if (UNLIKELY(throwScope.exception()))
    934942        return JSValue::encode(jsUndefined());
    935943    auto objArg = JSTestObj::toWrapped(state->argument(1));
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestJSBuiltinConstructor.cpp

    r205198 r205569  
    191191    VM& vm = state->vm();
    192192    auto throwScope = DECLARE_THROW_SCOPE(vm);
    193     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     193    UNUSED_PARAM(throwScope);
     194    JSValue value = JSValue::decode(encodedValue);
    194195    UNUSED_PARAM(thisValue);
    195196    JSTestJSBuiltinConstructor* castedThis = jsDynamicCast<JSTestJSBuiltinConstructor*>(JSValue::decode(thisValue));
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp

    r205458 r205569  
    9292    ExceptionCode ec = 0;
    9393    auto str1 = state->argument(0).toWTFString(state);
    94     if (UNLIKELY(state->hadException()))
     94    if (UNLIKELY(throwScope.exception()))
    9595        return JSValue::encode(jsUndefined());
    9696    auto str2 = state->argument(1).isUndefined() ? ASCIILiteral("defaultString") : state->uncheckedArgument(1).toWTFString(state);
    97     if (UNLIKELY(state->hadException()))
     97    if (UNLIKELY(throwScope.exception()))
    9898        return JSValue::encode(jsUndefined());
    9999    auto str3 = state->argument(2).isUndefined() ? String() : state->uncheckedArgument(2).toWTFString(state);
    100     if (UNLIKELY(state->hadException()))
     100    if (UNLIKELY(throwScope.exception()))
    101101        return JSValue::encode(jsUndefined());
    102102    auto object = TestNamedConstructor::createForJSConstructor(*castedThis->document(), WTFMove(str1), WTFMove(str2), WTFMove(str3), ec);
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp

    r205458 r205569  
    208208    VM& vm = state->vm();
    209209    auto throwScope = DECLARE_THROW_SCOPE(vm);
    210     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     210    UNUSED_PARAM(throwScope);
     211    JSValue value = JSValue::decode(encodedValue);
    211212    UNUSED_PARAM(thisValue);
    212213    JSTestNode* castedThis = jsDynamicCast<JSTestNode*>(JSValue::decode(thisValue));
     
    216217    auto& impl = castedThis->wrapped();
    217218    auto nativeValue = value.toWTFString(state);
    218     if (UNLIKELY(state->hadException()))
     219    if (UNLIKELY(throwScope.exception()))
    219220        return false;
    220221    impl.setName(WTFMove(nativeValue));
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNondeterministic.cpp

    r205458 r205569  
    362362    VM& vm = state->vm();
    363363    auto throwScope = DECLARE_THROW_SCOPE(vm);
    364     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     364    UNUSED_PARAM(throwScope);
     365    JSValue value = JSValue::decode(encodedValue);
    365366    UNUSED_PARAM(thisValue);
    366367    JSTestNondeterministic* castedThis = jsDynamicCast<JSTestNondeterministic*>(JSValue::decode(thisValue));
     
    370371    auto& impl = castedThis->wrapped();
    371372    auto nativeValue = value.toWTFString(state);
    372     if (UNLIKELY(state->hadException()))
     373    if (UNLIKELY(throwScope.exception()))
    373374        return false;
    374375    impl.setNondeterministicWriteableAttr(WTFMove(nativeValue));
     
    381382    VM& vm = state->vm();
    382383    auto throwScope = DECLARE_THROW_SCOPE(vm);
    383     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     384    UNUSED_PARAM(throwScope);
     385    JSValue value = JSValue::decode(encodedValue);
    384386    UNUSED_PARAM(thisValue);
    385387    JSTestNondeterministic* castedThis = jsDynamicCast<JSTestNondeterministic*>(JSValue::decode(thisValue));
     
    389391    auto& impl = castedThis->wrapped();
    390392    auto nativeValue = value.toWTFString(state);
    391     if (UNLIKELY(state->hadException()))
     393    if (UNLIKELY(throwScope.exception()))
    392394        return false;
    393395    impl.setNondeterministicExceptionAttr(WTFMove(nativeValue));
     
    400402    VM& vm = state->vm();
    401403    auto throwScope = DECLARE_THROW_SCOPE(vm);
    402     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     404    UNUSED_PARAM(throwScope);
     405    JSValue value = JSValue::decode(encodedValue);
    403406    UNUSED_PARAM(thisValue);
    404407    JSTestNondeterministic* castedThis = jsDynamicCast<JSTestNondeterministic*>(JSValue::decode(thisValue));
     
    408411    auto& impl = castedThis->wrapped();
    409412    auto nativeValue = value.toWTFString(state);
    410     if (UNLIKELY(state->hadException()))
     413    if (UNLIKELY(throwScope.exception()))
    411414        return false;
    412415    impl.setNondeterministicGetterExceptionAttr(WTFMove(nativeValue));
     
    419422    VM& vm = state->vm();
    420423    auto throwScope = DECLARE_THROW_SCOPE(vm);
    421     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     424    UNUSED_PARAM(throwScope);
     425    JSValue value = JSValue::decode(encodedValue);
    422426    UNUSED_PARAM(thisValue);
    423427    JSTestNondeterministic* castedThis = jsDynamicCast<JSTestNondeterministic*>(JSValue::decode(thisValue));
     
    428432    ExceptionCode ec = 0;
    429433    auto nativeValue = value.toWTFString(state);
    430     if (UNLIKELY(state->hadException()))
     434    if (UNLIKELY(throwScope.exception()))
    431435        return false;
    432436    impl.setNondeterministicSetterExceptionAttr(WTFMove(nativeValue), ec);
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r205542 r205569  
    526526    }
    527527    auto enumerationValueWithoutDefault = convertOptional<TestObj::EnumType>(state, object->get(&state, Identifier::fromString(&state, "enumerationValueWithoutDefault")));
    528     if (UNLIKELY(state.hadException()))
     528    if (UNLIKELY(throwScope.exception()))
    529529        return Nullopt;
    530530    auto enumerationValueWithDefault = convertOptional<TestObj::EnumType>(state, object->get(&state, Identifier::fromString(&state, "enumerationValueWithDefault")), TestObj::EnumType::EnumValue1);
    531     if (UNLIKELY(state.hadException()))
     531    if (UNLIKELY(throwScope.exception()))
    532532        return Nullopt;
    533533    auto enumerationValueWithEmptyStringDefault = convertOptional<TestObj::EnumType>(state, object->get(&state, Identifier::fromString(&state, "enumerationValueWithEmptyStringDefault")), TestObj::EnumType::EmptyString);
    534     if (UNLIKELY(state.hadException()))
     534    if (UNLIKELY(throwScope.exception()))
    535535        return Nullopt;
    536536    auto stringWithDefault = convertOptional<String>(state, object->get(&state, Identifier::fromString(&state, "stringWithDefault")), "defaultString");
    537     if (UNLIKELY(state.hadException()))
     537    if (UNLIKELY(throwScope.exception()))
    538538        return Nullopt;
    539539    auto stringWithoutDefault = convertOptional<String>(state, object->get(&state, Identifier::fromString(&state, "stringWithoutDefault")));
    540     if (UNLIKELY(state.hadException()))
     540    if (UNLIKELY(throwScope.exception()))
    541541        return Nullopt;
    542542    auto booleanWithDefault = convertOptional<bool>(state, object->get(&state, Identifier::fromString(&state, "booleanWithDefault")), false);
    543     if (UNLIKELY(state.hadException()))
     543    if (UNLIKELY(throwScope.exception()))
    544544        return Nullopt;
    545545    auto booleanWithoutDefault = convertOptional<bool>(state, object->get(&state, Identifier::fromString(&state, "booleanWithoutDefault")));
    546     if (UNLIKELY(state.hadException()))
     546    if (UNLIKELY(throwScope.exception()))
    547547        return Nullopt;
    548548    auto sequenceOfStrings = convertOptional<Vector<String>>(state, object->get(&state, Identifier::fromString(&state, "sequenceOfStrings")));
    549     if (UNLIKELY(state.hadException()))
     549    if (UNLIKELY(throwScope.exception()))
    550550        return Nullopt;
    551551    auto restrictedDouble = convertOptional<double>(state, object->get(&state, Identifier::fromString(&state, "restrictedDouble")), ShouldAllowNonFinite::No);
    552     if (UNLIKELY(state.hadException()))
     552    if (UNLIKELY(throwScope.exception()))
    553553        return Nullopt;
    554554    auto unrestrictedDouble = convertOptional<double>(state, object->get(&state, Identifier::fromString(&state, "unrestrictedDouble")), ShouldAllowNonFinite::Yes);
    555     if (UNLIKELY(state.hadException()))
     555    if (UNLIKELY(throwScope.exception()))
    556556        return Nullopt;
    557557    auto restrictedDoubleWithDefault = convertOptional<double>(state, object->get(&state, Identifier::fromString(&state, "restrictedDoubleWithDefault")), ShouldAllowNonFinite::No, 0);
    558     if (UNLIKELY(state.hadException()))
     558    if (UNLIKELY(throwScope.exception()))
    559559        return Nullopt;
    560560    auto unrestrictedDoubleWithDefault = convertOptional<double>(state, object->get(&state, Identifier::fromString(&state, "unrestrictedDoubleWithDefault")), ShouldAllowNonFinite::Yes, 0);
    561     if (UNLIKELY(state.hadException()))
     561    if (UNLIKELY(throwScope.exception()))
    562562        return Nullopt;
    563563    auto restrictedFloat = convertOptional<float>(state, object->get(&state, Identifier::fromString(&state, "restrictedFloat")), ShouldAllowNonFinite::No);
    564     if (UNLIKELY(state.hadException()))
     564    if (UNLIKELY(throwScope.exception()))
    565565        return Nullopt;
    566566    auto unrestrictedFloat = convertOptional<float>(state, object->get(&state, Identifier::fromString(&state, "unrestrictedFloat")), ShouldAllowNonFinite::Yes);
    567     if (UNLIKELY(state.hadException()))
     567    if (UNLIKELY(throwScope.exception()))
    568568        return Nullopt;
    569569    auto restrictedFloatWithDefault = convertOptional<float>(state, object->get(&state, Identifier::fromString(&state, "restrictedFloatWithDefault")), ShouldAllowNonFinite::No, 0);
    570     if (UNLIKELY(state.hadException()))
     570    if (UNLIKELY(throwScope.exception()))
    571571        return Nullopt;
    572572    auto unrestrictedFloatWithDefault = convertOptional<float>(state, object->get(&state, Identifier::fromString(&state, "unrestrictedFloatWithDefault")), ShouldAllowNonFinite::Yes, 0);
    573     if (UNLIKELY(state.hadException()))
     573    if (UNLIKELY(throwScope.exception()))
    574574        return Nullopt;
    575575    auto smallIntegerClamped = convertOptional<int8_t>(state, object->get(&state, Identifier::fromString(&state, "smallIntegerClamped")), Clamp);
    576     if (UNLIKELY(state.hadException()))
     576    if (UNLIKELY(throwScope.exception()))
    577577        return Nullopt;
    578578    auto smallIntegerWithDefault = convertOptional<int8_t>(state, object->get(&state, Identifier::fromString(&state, "smallIntegerWithDefault")), NormalConversion);
    579     if (UNLIKELY(state.hadException()))
     579    if (UNLIKELY(throwScope.exception()))
    580580        return Nullopt;
    581581    auto smallUnsignedIntegerEnforcedRange = convertOptional<uint8_t>(state, object->get(&state, Identifier::fromString(&state, "smallUnsignedIntegerEnforcedRange")), EnforceRange);
    582     if (UNLIKELY(state.hadException()))
     582    if (UNLIKELY(throwScope.exception()))
    583583        return Nullopt;
    584584    auto smallUnsignedIntegerWithDefault = convertOptional<uint8_t>(state, object->get(&state, Identifier::fromString(&state, "smallUnsignedIntegerWithDefault")), NormalConversion, 0);
    585     if (UNLIKELY(state.hadException()))
     585    if (UNLIKELY(throwScope.exception()))
    586586        return Nullopt;
    587587    auto integer = convertOptional<int32_t>(state, object->get(&state, Identifier::fromString(&state, "integer")), NormalConversion);
    588     if (UNLIKELY(state.hadException()))
     588    if (UNLIKELY(throwScope.exception()))
    589589        return Nullopt;
    590590    auto integerWithDefault = convertOptional<int32_t>(state, object->get(&state, Identifier::fromString(&state, "integerWithDefault")), NormalConversion, 0);
    591     if (UNLIKELY(state.hadException()))
     591    if (UNLIKELY(throwScope.exception()))
    592592        return Nullopt;
    593593    auto unsignedInteger = convertOptional<uint32_t>(state, object->get(&state, Identifier::fromString(&state, "unsignedInteger")), NormalConversion);
    594     if (UNLIKELY(state.hadException()))
     594    if (UNLIKELY(throwScope.exception()))
    595595        return Nullopt;
    596596    auto unsignedIntegerWithDefault = convertOptional<uint32_t>(state, object->get(&state, Identifier::fromString(&state, "unsignedIntegerWithDefault")), NormalConversion, 0);
    597     if (UNLIKELY(state.hadException()))
     597    if (UNLIKELY(throwScope.exception()))
    598598        return Nullopt;
    599599    auto largeInteger = convertOptional<int64_t>(state, object->get(&state, Identifier::fromString(&state, "largeInteger")), NormalConversion);
    600     if (UNLIKELY(state.hadException()))
     600    if (UNLIKELY(throwScope.exception()))
    601601        return Nullopt;
    602602    auto largeIntegerWithDefault = convertOptional<int64_t>(state, object->get(&state, Identifier::fromString(&state, "largeIntegerWithDefault")), NormalConversion, 0);
    603     if (UNLIKELY(state.hadException()))
     603    if (UNLIKELY(throwScope.exception()))
    604604        return Nullopt;
    605605    auto unsignedLargeInteger = convertOptional<uint64_t>(state, object->get(&state, Identifier::fromString(&state, "unsignedLargeInteger")), NormalConversion);
    606     if (UNLIKELY(state.hadException()))
     606    if (UNLIKELY(throwScope.exception()))
    607607        return Nullopt;
    608608    auto unsignedLargeIntegerWithDefault = convertOptional<uint64_t>(state, object->get(&state, Identifier::fromString(&state, "unsignedLargeIntegerWithDefault")), NormalConversion, 0);
    609     if (UNLIKELY(state.hadException()))
     609    if (UNLIKELY(throwScope.exception()))
    610610        return Nullopt;
    611611    auto* nullableNode = convertWrapperType<Node, JSNode>(state, object->get(&state, Identifier::fromString(&state, "nullableNode")), IsNullable::Yes);
    612     if (UNLIKELY(state.hadException()))
     612    if (UNLIKELY(throwScope.exception()))
    613613        return Nullopt;
    614614    auto anyValue = convertOptional<JSC::JSValue>(state, object->get(&state, Identifier::fromString(&state, "anyValue")), jsUndefined());
    615     if (UNLIKELY(state.hadException()))
     615    if (UNLIKELY(throwScope.exception()))
    616616        return Nullopt;
    617617    auto anyTypedefValue = convertOptional<JSC::JSValue>(state, object->get(&state, Identifier::fromString(&state, "anyTypedefValue")), jsUndefined());
    618     if (UNLIKELY(state.hadException()))
     618    if (UNLIKELY(throwScope.exception()))
    619619        return Nullopt;
    620620    auto dictionaryMember = convertDictionary<TestObj::DictionaryThatShouldTolerateNull>(state, object->get(&state, Identifier::fromString(&state, "dictionaryMember")));
     
    632632    }
    633633    auto requiredEnumerationValue = convert<TestObj::EnumType>(state, object->get(&state, Identifier::fromString(&state, "requiredEnumerationValue")));
    634     if (UNLIKELY(state.hadException()))
     634    if (UNLIKELY(throwScope.exception()))
    635635        return Nullopt;
    636636    auto booleanWithoutDefault = convertOptional<bool>(state, object->get(&state, Identifier::fromString(&state, "booleanWithoutDefault")));
    637     if (UNLIKELY(state.hadException()))
     637    if (UNLIKELY(throwScope.exception()))
    638638        return Nullopt;
    639639    auto* nonNullableNode = convertWrapperType<Node, JSNode>(state, object->get(&state, Identifier::fromString(&state, "nonNullableNode")), IsNullable::No);
    640     if (UNLIKELY(state.hadException()))
     640    if (UNLIKELY(throwScope.exception()))
    641641        return Nullopt;
    642642    auto requiredDictionaryMember = convertDictionary<TestObj::Dictionary>(state, object->get(&state, Identifier::fromString(&state, "requiredDictionaryMember")));
     
    656656    }
    657657    auto enumerationValue = convertOptional<TestObj::EnumType>(state, object->get(&state, Identifier::fromString(&state, "enumerationValue")));
    658     if (UNLIKELY(state.hadException()))
     658    if (UNLIKELY(throwScope.exception()))
    659659        return Nullopt;
    660660    auto booleanWithoutDefault = convertOptional<bool>(state, object->get(&state, Identifier::fromString(&state, "booleanWithoutDefault")));
     
    674674    }
    675675    auto enumerationValue = convertOptional<TestObj::EnumType>(state, object->get(&state, Identifier::fromString(&state, "enumerationValue")));
    676     if (UNLIKELY(state.hadException()))
     676    if (UNLIKELY(throwScope.exception()))
    677677        return Nullopt;
    678678    auto booleanWithoutDefault = convertOptional<bool>(state, object->get(&state, Identifier::fromString(&state, "booleanWithoutDefault")));
     
    30913091    VM& vm = state->vm();
    30923092    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3093     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3093    UNUSED_PARAM(throwScope);
     3094    JSValue value = JSValue::decode(encodedValue);
    30943095    auto nativeValue = value.toWTFString(state);
    3095     if (UNLIKELY(state->hadException()))
     3096    if (UNLIKELY(throwScope.exception()))
    30963097        return false;
    30973098    TestObj::setStaticStringAttr(WTFMove(nativeValue));
     
    31043105    VM& vm = state->vm();
    31053106    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3106     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3107    UNUSED_PARAM(throwScope);
     3108    JSValue value = JSValue::decode(encodedValue);
    31073109    UNUSED_PARAM(thisValue);
    31083110    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    31193121    VM& vm = state->vm();
    31203122    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3121     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3123    UNUSED_PARAM(throwScope);
     3124    JSValue value = JSValue::decode(encodedValue);
    31223125    UNUSED_PARAM(thisValue);
    31233126    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    31273130    auto& impl = castedThis->wrapped();
    31283131    auto nativeValue = parse<TestObj::EnumType>(*state, value);
    3129     if (UNLIKELY(state->hadException()))
     3132    if (UNLIKELY(throwScope.exception()))
    31303133        return false;
    31313134    if (UNLIKELY(!nativeValue))
     
    31403143    VM& vm = state->vm();
    31413144    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3142     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3145    UNUSED_PARAM(throwScope);
     3146    JSValue value = JSValue::decode(encodedValue);
    31433147    UNUSED_PARAM(thisValue);
    31443148    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    31483152    auto& impl = castedThis->wrapped();
    31493153    auto nativeValue = convert<int8_t>(*state, value, NormalConversion);
    3150     if (UNLIKELY(state->hadException()))
     3154    if (UNLIKELY(throwScope.exception()))
    31513155        return false;
    31523156    impl.setByteAttr(WTFMove(nativeValue));
     
    31593163    VM& vm = state->vm();
    31603164    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3161     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3165    UNUSED_PARAM(throwScope);
     3166    JSValue value = JSValue::decode(encodedValue);
    31623167    UNUSED_PARAM(thisValue);
    31633168    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    31673172    auto& impl = castedThis->wrapped();
    31683173    auto nativeValue = convert<uint8_t>(*state, value, NormalConversion);
    3169     if (UNLIKELY(state->hadException()))
     3174    if (UNLIKELY(throwScope.exception()))
    31703175        return false;
    31713176    impl.setOctetAttr(WTFMove(nativeValue));
     
    31783183    VM& vm = state->vm();
    31793184    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3180     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3185    UNUSED_PARAM(throwScope);
     3186    JSValue value = JSValue::decode(encodedValue);
    31813187    UNUSED_PARAM(thisValue);
    31823188    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    31863192    auto& impl = castedThis->wrapped();
    31873193    auto nativeValue = convert<int16_t>(*state, value, NormalConversion);
    3188     if (UNLIKELY(state->hadException()))
     3194    if (UNLIKELY(throwScope.exception()))
    31893195        return false;
    31903196    impl.setShortAttr(WTFMove(nativeValue));
     
    31973203    VM& vm = state->vm();
    31983204    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3199     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3205    UNUSED_PARAM(throwScope);
     3206    JSValue value = JSValue::decode(encodedValue);
    32003207    UNUSED_PARAM(thisValue);
    32013208    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    32053212    auto& impl = castedThis->wrapped();
    32063213    auto nativeValue = convert<int16_t>(*state, value, Clamp);
    3207     if (UNLIKELY(state->hadException()))
     3214    if (UNLIKELY(throwScope.exception()))
    32083215        return false;
    32093216    impl.setClampedShortAttr(WTFMove(nativeValue));
     
    32163223    VM& vm = state->vm();
    32173224    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3218     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3225    UNUSED_PARAM(throwScope);
     3226    JSValue value = JSValue::decode(encodedValue);
    32193227    UNUSED_PARAM(thisValue);
    32203228    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    32243232    auto& impl = castedThis->wrapped();
    32253233    auto nativeValue = convert<int16_t>(*state, value, EnforceRange);
    3226     if (UNLIKELY(state->hadException()))
     3234    if (UNLIKELY(throwScope.exception()))
    32273235        return false;
    32283236    impl.setEnforceRangeShortAttr(WTFMove(nativeValue));
     
    32353243    VM& vm = state->vm();
    32363244    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3237     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3245    UNUSED_PARAM(throwScope);
     3246    JSValue value = JSValue::decode(encodedValue);
    32383247    UNUSED_PARAM(thisValue);
    32393248    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    32433252    auto& impl = castedThis->wrapped();
    32443253    auto nativeValue = convert<uint16_t>(*state, value, NormalConversion);
    3245     if (UNLIKELY(state->hadException()))
     3254    if (UNLIKELY(throwScope.exception()))
    32463255        return false;
    32473256    impl.setUnsignedShortAttr(WTFMove(nativeValue));
     
    32543263    VM& vm = state->vm();
    32553264    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3256     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3265    UNUSED_PARAM(throwScope);
     3266    JSValue value = JSValue::decode(encodedValue);
    32573267    UNUSED_PARAM(thisValue);
    32583268    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    32623272    auto& impl = castedThis->wrapped();
    32633273    auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
    3264     if (UNLIKELY(state->hadException()))
     3274    if (UNLIKELY(throwScope.exception()))
    32653275        return false;
    32663276    impl.setLongAttr(WTFMove(nativeValue));
     
    32733283    VM& vm = state->vm();
    32743284    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3275     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3285    UNUSED_PARAM(throwScope);
     3286    JSValue value = JSValue::decode(encodedValue);
    32763287    UNUSED_PARAM(thisValue);
    32773288    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    32813292    auto& impl = castedThis->wrapped();
    32823293    auto nativeValue = convert<int64_t>(*state, value, NormalConversion);
    3283     if (UNLIKELY(state->hadException()))
     3294    if (UNLIKELY(throwScope.exception()))
    32843295        return false;
    32853296    impl.setLongLongAttr(WTFMove(nativeValue));
     
    32923303    VM& vm = state->vm();
    32933304    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3294     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3305    UNUSED_PARAM(throwScope);
     3306    JSValue value = JSValue::decode(encodedValue);
    32953307    UNUSED_PARAM(thisValue);
    32963308    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    33003312    auto& impl = castedThis->wrapped();
    33013313    auto nativeValue = convert<uint64_t>(*state, value, NormalConversion);
    3302     if (UNLIKELY(state->hadException()))
     3314    if (UNLIKELY(throwScope.exception()))
    33033315        return false;
    33043316    impl.setUnsignedLongLongAttr(WTFMove(nativeValue));
     
    33113323    VM& vm = state->vm();
    33123324    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3313     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3325    UNUSED_PARAM(throwScope);
     3326    JSValue value = JSValue::decode(encodedValue);
    33143327    UNUSED_PARAM(thisValue);
    33153328    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    33193332    auto& impl = castedThis->wrapped();
    33203333    auto nativeValue = value.toWTFString(state);
    3321     if (UNLIKELY(state->hadException()))
     3334    if (UNLIKELY(throwScope.exception()))
    33223335        return false;
    33233336    impl.setStringAttr(WTFMove(nativeValue));
     
    33303343    VM& vm = state->vm();
    33313344    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3332     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3345    UNUSED_PARAM(throwScope);
     3346    JSValue value = JSValue::decode(encodedValue);
    33333347    UNUSED_PARAM(thisValue);
    33343348    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    33383352    auto& impl = castedThis->wrapped();
    33393353    auto nativeValue = valueToUSVString(state, value);
    3340     if (UNLIKELY(state->hadException()))
     3354    if (UNLIKELY(throwScope.exception()))
    33413355        return false;
    33423356    impl.setUsvstringAttr(WTFMove(nativeValue));
     
    33493363    VM& vm = state->vm();
    33503364    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3351     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3365    UNUSED_PARAM(throwScope);
     3366    JSValue value = JSValue::decode(encodedValue);
    33523367    UNUSED_PARAM(thisValue);
    33533368    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    33703385    VM& vm = state->vm();
    33713386    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3372     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3387    UNUSED_PARAM(throwScope);
     3388    JSValue value = JSValue::decode(encodedValue);
    33733389    UNUSED_PARAM(thisValue);
    33743390    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    33943410    VM& vm = state->vm();
    33953411    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3396     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3412    UNUSED_PARAM(throwScope);
     3413    JSValue value = JSValue::decode(encodedValue);
    33973414    UNUSED_PARAM(thisValue);
    33983415    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    34153432    VM& vm = state->vm();
    34163433    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3417     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3434    UNUSED_PARAM(throwScope);
     3435    JSValue value = JSValue::decode(encodedValue);
    34183436    UNUSED_PARAM(thisValue);
    34193437    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    34233441    auto& impl = castedThis->wrapped();
    34243442    auto nativeValue = valueToStringTreatingNullAsEmptyString(state, value);
    3425     if (UNLIKELY(state->hadException()))
     3443    if (UNLIKELY(throwScope.exception()))
    34263444        return false;
    34273445    impl.setStringAttrTreatingNullAsEmptyString(WTFMove(nativeValue));
     
    34343452    VM& vm = state->vm();
    34353453    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3436     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3454    UNUSED_PARAM(throwScope);
     3455    JSValue value = JSValue::decode(encodedValue);
    34373456    UNUSED_PARAM(thisValue);
    34383457    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    34423461    auto& impl = castedThis->wrapped();
    34433462    auto nativeValue = valueToUSVStringTreatingNullAsEmptyString(state, value);
    3444     if (UNLIKELY(state->hadException()))
     3463    if (UNLIKELY(throwScope.exception()))
    34453464        return false;
    34463465    impl.setUsvstringAttrTreatingNullAsEmptyString(WTFMove(nativeValue));
     
    34533472    VM& vm = state->vm();
    34543473    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3455     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3474    UNUSED_PARAM(throwScope);
     3475    JSValue value = JSValue::decode(encodedValue);
    34563476    UNUSED_PARAM(thisValue);
    34573477    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    34613481    auto& impl = castedThis->wrapped();
    34623482    auto nativeValue = parse<AlternateEnumName>(*state, value);
    3463     if (UNLIKELY(state->hadException()))
     3483    if (UNLIKELY(throwScope.exception()))
    34643484        return false;
    34653485    if (UNLIKELY(!nativeValue))
     
    34743494    VM& vm = state->vm();
    34753495    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3476     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3496    UNUSED_PARAM(throwScope);
     3497    JSValue value = JSValue::decode(encodedValue);
    34773498    UNUSED_PARAM(thisValue);
    34783499    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    34953516    VM& vm = state->vm();
    34963517    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3497     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3518    UNUSED_PARAM(throwScope);
     3519    JSValue value = JSValue::decode(encodedValue);
    34983520    UNUSED_PARAM(thisValue);
    34993521    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    35033525    auto& impl = castedThis->wrapped();
    35043526    auto nativeValue = value.toBoolean(state);
    3505     if (UNLIKELY(state->hadException()))
     3527    if (UNLIKELY(throwScope.exception()))
    35063528        return false;
    35073529    impl.setCreate(WTFMove(nativeValue));
     
    35143536    VM& vm = state->vm();
    35153537    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3516     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3538    UNUSED_PARAM(throwScope);
     3539    JSValue value = JSValue::decode(encodedValue);
    35173540    UNUSED_PARAM(thisValue);
    35183541    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    35223545    auto& impl = castedThis->wrapped();
    35233546    auto nativeValue = value.toWTFString(state);
    3524     if (UNLIKELY(state->hadException()))
     3547    if (UNLIKELY(throwScope.exception()))
    35253548        return false;
    35263549    impl.setAttributeWithoutSynchronization(WebCore::HTMLNames::reflectedstringattrAttr, WTFMove(nativeValue));
     
    35333556    VM& vm = state->vm();
    35343557    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3535     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3558    UNUSED_PARAM(throwScope);
     3559    JSValue value = JSValue::decode(encodedValue);
    35363560    UNUSED_PARAM(thisValue);
    35373561    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    35413565    auto& impl = castedThis->wrapped();
    35423566    auto nativeValue = valueToUSVString(state, value);
    3543     if (UNLIKELY(state->hadException()))
     3567    if (UNLIKELY(throwScope.exception()))
    35443568        return false;
    35453569    impl.setAttributeWithoutSynchronization(WebCore::HTMLNames::reflectedusvstringattrAttr, WTFMove(nativeValue));
     
    35523576    VM& vm = state->vm();
    35533577    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3554     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3578    UNUSED_PARAM(throwScope);
     3579    JSValue value = JSValue::decode(encodedValue);
    35553580    UNUSED_PARAM(thisValue);
    35563581    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    35603585    auto& impl = castedThis->wrapped();
    35613586    auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
    3562     if (UNLIKELY(state->hadException()))
     3587    if (UNLIKELY(throwScope.exception()))
    35633588        return false;
    35643589    impl.setIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr, WTFMove(nativeValue));
     
    35713596    VM& vm = state->vm();
    35723597    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3573     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3598    UNUSED_PARAM(throwScope);
     3599    JSValue value = JSValue::decode(encodedValue);
    35743600    UNUSED_PARAM(thisValue);
    35753601    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    35793605    auto& impl = castedThis->wrapped();
    35803606    auto nativeValue = convert<uint32_t>(*state, value, NormalConversion);
    3581     if (UNLIKELY(state->hadException()))
     3607    if (UNLIKELY(throwScope.exception()))
    35823608        return false;
    35833609    impl.setUnsignedIntegralAttribute(WebCore::HTMLNames::reflectedunsignedintegralattrAttr, WTFMove(nativeValue));
     
    35903616    VM& vm = state->vm();
    35913617    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3592     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3618    UNUSED_PARAM(throwScope);
     3619    JSValue value = JSValue::decode(encodedValue);
    35933620    UNUSED_PARAM(thisValue);
    35943621    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    35983625    auto& impl = castedThis->wrapped();
    35993626    auto nativeValue = value.toBoolean(state);
    3600     if (UNLIKELY(state->hadException()))
     3627    if (UNLIKELY(throwScope.exception()))
    36013628        return false;
    36023629    impl.setBooleanAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr, WTFMove(nativeValue));
     
    36093636    VM& vm = state->vm();
    36103637    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3611     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3638    UNUSED_PARAM(throwScope);
     3639    JSValue value = JSValue::decode(encodedValue);
    36123640    UNUSED_PARAM(thisValue);
    36133641    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    36173645    auto& impl = castedThis->wrapped();
    36183646    auto nativeValue = value.toWTFString(state);
    3619     if (UNLIKELY(state->hadException()))
     3647    if (UNLIKELY(throwScope.exception()))
    36203648        return false;
    36213649    impl.setAttributeWithoutSynchronization(WebCore::HTMLNames::reflectedurlattrAttr, WTFMove(nativeValue));
     
    36283656    VM& vm = state->vm();
    36293657    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3630     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3658    UNUSED_PARAM(throwScope);
     3659    JSValue value = JSValue::decode(encodedValue);
    36313660    UNUSED_PARAM(thisValue);
    36323661    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    36363665    auto& impl = castedThis->wrapped();
    36373666    auto nativeValue = valueToUSVString(state, value);
    3638     if (UNLIKELY(state->hadException()))
     3667    if (UNLIKELY(throwScope.exception()))
    36393668        return false;
    36403669    impl.setAttributeWithoutSynchronization(WebCore::HTMLNames::reflectedusvurlattrAttr, WTFMove(nativeValue));
     
    36473676    VM& vm = state->vm();
    36483677    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3649     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3678    UNUSED_PARAM(throwScope);
     3679    JSValue value = JSValue::decode(encodedValue);
    36503680    UNUSED_PARAM(thisValue);
    36513681    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    36553685    auto& impl = castedThis->wrapped();
    36563686    auto nativeValue = value.toWTFString(state);
    3657     if (UNLIKELY(state->hadException()))
     3687    if (UNLIKELY(throwScope.exception()))
    36583688        return false;
    36593689    impl.setAttributeWithoutSynchronization(WebCore::HTMLNames::customContentStringAttrAttr, WTFMove(nativeValue));
     
    36663696    VM& vm = state->vm();
    36673697    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3668     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3698    UNUSED_PARAM(throwScope);
     3699    JSValue value = JSValue::decode(encodedValue);
    36693700    UNUSED_PARAM(thisValue);
    36703701    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    36743705    auto& impl = castedThis->wrapped();
    36753706    auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
    3676     if (UNLIKELY(state->hadException()))
     3707    if (UNLIKELY(throwScope.exception()))
    36773708        return false;
    36783709    impl.setIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr, WTFMove(nativeValue));
     
    36853716    VM& vm = state->vm();
    36863717    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3687     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3718    UNUSED_PARAM(throwScope);
     3719    JSValue value = JSValue::decode(encodedValue);
    36883720    UNUSED_PARAM(thisValue);
    36893721    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    36933725    auto& impl = castedThis->wrapped();
    36943726    auto nativeValue = value.toBoolean(state);
    3695     if (UNLIKELY(state->hadException()))
     3727    if (UNLIKELY(throwScope.exception()))
    36963728        return false;
    36973729    impl.setBooleanAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr, WTFMove(nativeValue));
     
    37043736    VM& vm = state->vm();
    37053737    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3706     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3738    UNUSED_PARAM(throwScope);
     3739    JSValue value = JSValue::decode(encodedValue);
    37073740    UNUSED_PARAM(thisValue);
    37083741    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    37123745    auto& impl = castedThis->wrapped();
    37133746    auto nativeValue = value.toWTFString(state);
    3714     if (UNLIKELY(state->hadException()))
     3747    if (UNLIKELY(throwScope.exception()))
    37153748        return false;
    37163749    impl.setAttributeWithoutSynchronization(WebCore::HTMLNames::customContentURLAttrAttr, WTFMove(nativeValue));
     
    37243757    VM& vm = state->vm();
    37253758    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3726     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3759    UNUSED_PARAM(throwScope);
     3760    JSValue value = JSValue::decode(encodedValue);
    37273761    UNUSED_PARAM(thisValue);
    37283762    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    37323766    auto& impl = castedThis->wrapped();
    37333767    auto nativeValue = value.toWTFString(state);
    3734     if (UNLIKELY(state->hadException()))
     3768    if (UNLIKELY(throwScope.exception()))
    37353769        return false;
    37363770    impl.setEnabledAtRuntimeAttribute(WTFMove(nativeValue));
     
    37443778    VM& vm = state->vm();
    37453779    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3746     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3780    UNUSED_PARAM(throwScope);
     3781    JSValue value = JSValue::decode(encodedValue);
    37473782    UNUSED_PARAM(thisValue);
    37483783    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    37523787    auto& impl = castedThis->wrapped();
    37533788    auto nativeValue = toFloat32Array(value);
    3754     if (UNLIKELY(state->hadException()))
     3789    if (UNLIKELY(throwScope.exception()))
    37553790        return false;
    37563791    if (UNLIKELY(!nativeValue)) {
     
    37673802    VM& vm = state->vm();
    37683803    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3769     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3804    UNUSED_PARAM(throwScope);
     3805    JSValue value = JSValue::decode(encodedValue);
    37703806    UNUSED_PARAM(thisValue);
    37713807    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    37753811    auto& impl = castedThis->wrapped();
    37763812    auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
    3777     if (UNLIKELY(state->hadException()))
     3813    if (UNLIKELY(throwScope.exception()))
    37783814        return false;
    37793815    impl.setAttrWithGetterException(WTFMove(nativeValue));
     
    37863822    VM& vm = state->vm();
    37873823    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3788     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3824    UNUSED_PARAM(throwScope);
     3825    JSValue value = JSValue::decode(encodedValue);
    37893826    UNUSED_PARAM(thisValue);
    37903827    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    37943831    auto& impl = castedThis->wrapped();
    37953832    auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
    3796     if (UNLIKELY(state->hadException()))
     3833    if (UNLIKELY(throwScope.exception()))
    37973834        return false;
    37983835    impl.setAttrWithGetterExceptionWithMessage(WTFMove(nativeValue));
     
    38053842    VM& vm = state->vm();
    38063843    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3807     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3844    UNUSED_PARAM(throwScope);
     3845    JSValue value = JSValue::decode(encodedValue);
    38083846    UNUSED_PARAM(thisValue);
    38093847    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    38143852    ExceptionCode ec = 0;
    38153853    auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
    3816     if (UNLIKELY(state->hadException()))
     3854    if (UNLIKELY(throwScope.exception()))
    38173855        return false;
    38183856    impl.setAttrWithSetterException(WTFMove(nativeValue), ec);
     
    38263864    VM& vm = state->vm();
    38273865    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3828     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3866    UNUSED_PARAM(throwScope);
     3867    JSValue value = JSValue::decode(encodedValue);
    38293868    UNUSED_PARAM(thisValue);
    38303869    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    38353874    ExceptionCodeWithMessage ec;
    38363875    auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
    3837     if (UNLIKELY(state->hadException()))
     3876    if (UNLIKELY(throwScope.exception()))
    38383877        return false;
    38393878    impl.setAttrWithSetterExceptionWithMessage(WTFMove(nativeValue), ec);
     
    38473886    VM& vm = state->vm();
    38483887    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3849     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3888    UNUSED_PARAM(throwScope);
     3889    JSValue value = JSValue::decode(encodedValue);
    38503890    UNUSED_PARAM(thisValue);
    38513891    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    38553895    auto& impl = castedThis->wrapped();
    38563896    auto nativeValue = value.toWTFString(state);
    3857     if (UNLIKELY(state->hadException()))
     3897    if (UNLIKELY(throwScope.exception()))
    38583898        return false;
    38593899    impl.setStringAttrWithGetterException(WTFMove(nativeValue));
     
    38663906    VM& vm = state->vm();
    38673907    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3868     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3908    UNUSED_PARAM(throwScope);
     3909    JSValue value = JSValue::decode(encodedValue);
    38693910    UNUSED_PARAM(thisValue);
    38703911    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    38753916    ExceptionCode ec = 0;
    38763917    auto nativeValue = value.toWTFString(state);
    3877     if (UNLIKELY(state->hadException()))
     3918    if (UNLIKELY(throwScope.exception()))
    38783919        return false;
    38793920    impl.setStringAttrWithSetterException(WTFMove(nativeValue), ec);
     
    38873928    VM& vm = state->vm();
    38883929    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3889     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3930    UNUSED_PARAM(throwScope);
     3931    JSValue value = JSValue::decode(encodedValue);
    38903932    UNUSED_PARAM(thisValue);
    38913933    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    39023944    VM& vm = state->vm();
    39033945    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3904     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3946    UNUSED_PARAM(throwScope);
     3947    JSValue value = JSValue::decode(encodedValue);
    39053948    UNUSED_PARAM(thisValue);
    39063949    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    39173960    VM& vm = state->vm();
    39183961    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3919     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3962    UNUSED_PARAM(throwScope);
     3963    JSValue value = JSValue::decode(encodedValue);
    39203964    UNUSED_PARAM(thisValue);
    39213965    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    39323976    VM& vm = state->vm();
    39333977    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3934     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3978    UNUSED_PARAM(throwScope);
     3979    JSValue value = JSValue::decode(encodedValue);
    39353980    UNUSED_PARAM(thisValue);
    39363981    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    39403985    auto& impl = castedThis->wrapped();
    39413986    auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
    3942     if (UNLIKELY(state->hadException()))
     3987    if (UNLIKELY(throwScope.exception()))
    39433988        return false;
    39443989    impl.setWithScriptStateAttribute(*state, WTFMove(nativeValue));
     
    39513996    VM& vm = state->vm();
    39523997    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3953     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     3998    UNUSED_PARAM(throwScope);
     3999    JSValue value = JSValue::decode(encodedValue);
    39544000    UNUSED_PARAM(thisValue);
    39554001    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    39594005    auto& impl = castedThis->wrapped();
    39604006    auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
    3961     if (UNLIKELY(state->hadException()))
     4007    if (UNLIKELY(throwScope.exception()))
    39624008        return false;
    39634009    impl.setWithCallWithAndSetterCallWithAttribute(*state, activeDOMWindow(state), firstDOMWindow(state), WTFMove(nativeValue));
     
    39704016    VM& vm = state->vm();
    39714017    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3972     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     4018    UNUSED_PARAM(throwScope);
     4019    JSValue value = JSValue::decode(encodedValue);
    39734020    UNUSED_PARAM(thisValue);
    39744021    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    39944041    VM& vm = state->vm();
    39954042    auto throwScope = DECLARE_THROW_SCOPE(vm);
    3996     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     4043    UNUSED_PARAM(throwScope);
     4044    JSValue value = JSValue::decode(encodedValue);
    39974045    UNUSED_PARAM(thisValue);
    39984046    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    40154063    VM& vm = state->vm();
    40164064    auto throwScope = DECLARE_THROW_SCOPE(vm);
    4017     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     4065    UNUSED_PARAM(throwScope);
     4066    JSValue value = JSValue::decode(encodedValue);
    40184067    UNUSED_PARAM(thisValue);
    40194068    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    40394088    VM& vm = state->vm();
    40404089    auto throwScope = DECLARE_THROW_SCOPE(vm);
    4041     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     4090    UNUSED_PARAM(throwScope);
     4091    JSValue value = JSValue::decode(encodedValue);
    40424092    UNUSED_PARAM(thisValue);
    40434093    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    40634113    VM& vm = state->vm();
    40644114    auto throwScope = DECLARE_THROW_SCOPE(vm);
    4065     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     4115    UNUSED_PARAM(throwScope);
     4116    JSValue value = JSValue::decode(encodedValue);
    40664117    UNUSED_PARAM(thisValue);
    40674118    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    40874138    VM& vm = state->vm();
    40884139    auto throwScope = DECLARE_THROW_SCOPE(vm);
    4089     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     4140    UNUSED_PARAM(throwScope);
     4141    JSValue value = JSValue::decode(encodedValue);
    40904142    UNUSED_PARAM(thisValue);
    40914143    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    41114163    VM& vm = state->vm();
    41124164    auto throwScope = DECLARE_THROW_SCOPE(vm);
    4113     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     4165    UNUSED_PARAM(throwScope);
     4166    JSValue value = JSValue::decode(encodedValue);
    41144167    UNUSED_PARAM(thisValue);
    41154168    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    41334186    VM& vm = state->vm();
    41344187    auto throwScope = DECLARE_THROW_SCOPE(vm);
    4135     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     4188    UNUSED_PARAM(throwScope);
     4189    JSValue value = JSValue::decode(encodedValue);
    41364190    UNUSED_PARAM(thisValue);
    41374191    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    41414195    auto& impl = castedThis->wrapped();
    41424196    auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
    4143     if (UNLIKELY(state->hadException()))
     4197    if (UNLIKELY(throwScope.exception()))
    41444198        return false;
    41454199    impl.setConditionalAttr1(WTFMove(nativeValue));
     
    41544208    VM& vm = state->vm();
    41554209    auto throwScope = DECLARE_THROW_SCOPE(vm);
    4156     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     4210    UNUSED_PARAM(throwScope);
     4211    JSValue value = JSValue::decode(encodedValue);
    41574212    UNUSED_PARAM(thisValue);
    41584213    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    41624217    auto& impl = castedThis->wrapped();
    41634218    auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
    4164     if (UNLIKELY(state->hadException()))
     4219    if (UNLIKELY(throwScope.exception()))
    41654220        return false;
    41664221    impl.setConditionalAttr2(WTFMove(nativeValue));
     
    41754230    VM& vm = state->vm();
    41764231    auto throwScope = DECLARE_THROW_SCOPE(vm);
    4177     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     4232    UNUSED_PARAM(throwScope);
     4233    JSValue value = JSValue::decode(encodedValue);
    41784234    UNUSED_PARAM(thisValue);
    41794235    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    41834239    auto& impl = castedThis->wrapped();
    41844240    auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
    4185     if (UNLIKELY(state->hadException()))
     4241    if (UNLIKELY(throwScope.exception()))
    41864242        return false;
    41874243    impl.setConditionalAttr3(WTFMove(nativeValue));
     
    41964252    VM& vm = state->vm();
    41974253    auto throwScope = DECLARE_THROW_SCOPE(vm);
    4198     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     4254    UNUSED_PARAM(throwScope);
     4255    JSValue value = JSValue::decode(encodedValue);
    41994256    UNUSED_PARAM(thisValue);
    42004257    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    42134270    VM& vm = state->vm();
    42144271    auto throwScope = DECLARE_THROW_SCOPE(vm);
    4215     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     4272    UNUSED_PARAM(throwScope);
     4273    JSValue value = JSValue::decode(encodedValue);
    42164274    UNUSED_PARAM(thisValue);
    42174275    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    42304288    VM& vm = state->vm();
    42314289    auto throwScope = DECLARE_THROW_SCOPE(vm);
    4232     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     4290    UNUSED_PARAM(throwScope);
     4291    JSValue value = JSValue::decode(encodedValue);
    42334292    UNUSED_PARAM(thisValue);
    42344293    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    42464305    VM& vm = state->vm();
    42474306    auto throwScope = DECLARE_THROW_SCOPE(vm);
    4248     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     4307    UNUSED_PARAM(throwScope);
     4308    JSValue value = JSValue::decode(encodedValue);
    42494309    UNUSED_PARAM(thisValue);
    42504310    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    42634323    VM& vm = state->vm();
    42644324    auto throwScope = DECLARE_THROW_SCOPE(vm);
    4265     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     4325    UNUSED_PARAM(throwScope);
     4326    JSValue value = JSValue::decode(encodedValue);
    42664327    UNUSED_PARAM(thisValue);
    42674328    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    42874348    VM& vm = state->vm();
    42884349    auto throwScope = DECLARE_THROW_SCOPE(vm);
    4289     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     4350    UNUSED_PARAM(throwScope);
     4351    JSValue value = JSValue::decode(encodedValue);
    42904352    UNUSED_PARAM(thisValue);
    42914353    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    43114373    VM& vm = state->vm();
    43124374    auto throwScope = DECLARE_THROW_SCOPE(vm);
    4313     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     4375    UNUSED_PARAM(throwScope);
     4376    JSValue value = JSValue::decode(encodedValue);
    43144377    UNUSED_PARAM(thisValue);
    43154378    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    43194382    auto& impl = castedThis->wrapped();
    43204383    auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
    4321     if (UNLIKELY(state->hadException()))
     4384    if (UNLIKELY(throwScope.exception()))
    43224385        return false;
    43234386    impl.setBlueberry(WTFMove(nativeValue));
     
    43304393    VM& vm = state->vm();
    43314394    auto throwScope = DECLARE_THROW_SCOPE(vm);
    4332     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     4395    UNUSED_PARAM(throwScope);
     4396    JSValue value = JSValue::decode(encodedValue);
    43334397    UNUSED_PARAM(thisValue);
    43344398    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    43384402    auto& impl = castedThis->wrapped();
    43394403    auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
    4340     if (UNLIKELY(state->hadException()))
     4404    if (UNLIKELY(throwScope.exception()))
    43414405        return false;
    43424406    impl.setId(WTFMove(nativeValue));
     
    43494413    VM& vm = state->vm();
    43504414    auto throwScope = DECLARE_THROW_SCOPE(vm);
    4351     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     4415    UNUSED_PARAM(throwScope);
     4416    JSValue value = JSValue::decode(encodedValue);
    43524417    UNUSED_PARAM(thisValue);
    43534418    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    43644429    VM& vm = state->vm();
    43654430    auto throwScope = DECLARE_THROW_SCOPE(vm);
    4366     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     4431    UNUSED_PARAM(throwScope);
     4432    JSValue value = JSValue::decode(encodedValue);
    43674433    UNUSED_PARAM(thisValue);
    43684434    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    43724438    auto& impl = castedThis->wrapped();
    43734439    auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
    4374     if (UNLIKELY(state->hadException()))
     4440    if (UNLIKELY(throwScope.exception()))
    43754441        return false;
    43764442    impl.setNullableLongSettableAttribute(WTFMove(nativeValue));
     
    43834449    VM& vm = state->vm();
    43844450    auto throwScope = DECLARE_THROW_SCOPE(vm);
    4385     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     4451    UNUSED_PARAM(throwScope);
     4452    JSValue value = JSValue::decode(encodedValue);
    43864453    UNUSED_PARAM(thisValue);
    43874454    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    43914458    auto& impl = castedThis->wrapped();
    43924459    auto nativeValue = valueToStringWithUndefinedOrNullCheck(state, value);
    4393     if (UNLIKELY(state->hadException()))
     4460    if (UNLIKELY(throwScope.exception()))
    43944461        return false;
    43954462    impl.setNullableStringSettableAttribute(WTFMove(nativeValue));
     
    44024469    VM& vm = state->vm();
    44034470    auto throwScope = DECLARE_THROW_SCOPE(vm);
    4404     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     4471    UNUSED_PARAM(throwScope);
     4472    JSValue value = JSValue::decode(encodedValue);
    44054473    UNUSED_PARAM(thisValue);
    44064474    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    44104478    auto& impl = castedThis->wrapped();
    44114479    auto nativeValue = valueToUSVStringWithUndefinedOrNullCheck(state, value);
    4412     if (UNLIKELY(state->hadException()))
     4480    if (UNLIKELY(throwScope.exception()))
    44134481        return false;
    44144482    impl.setNullableUSVStringSettableAttribute(WTFMove(nativeValue));
     
    44214489    VM& vm = state->vm();
    44224490    auto throwScope = DECLARE_THROW_SCOPE(vm);
    4423     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     4491    UNUSED_PARAM(throwScope);
     4492    JSValue value = JSValue::decode(encodedValue);
    44244493    UNUSED_PARAM(thisValue);
    44254494    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    44294498    auto& impl = castedThis->wrapped();
    44304499    auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
    4431     if (UNLIKELY(state->hadException()))
     4500    if (UNLIKELY(throwScope.exception()))
    44324501        return false;
    44334502    impl.setNullableStringValue(WTFMove(nativeValue));
     
    44404509    VM& vm = state->vm();
    44414510    auto throwScope = DECLARE_THROW_SCOPE(vm);
    4442     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     4511    UNUSED_PARAM(throwScope);
     4512    JSValue value = JSValue::decode(encodedValue);
    44434513    UNUSED_PARAM(thisValue);
    44444514    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    44484518    auto& impl = castedThis->wrapped();
    44494519    auto nativeValue = parse<TestObj::Optional>(*state, value);
    4450     if (UNLIKELY(state->hadException()))
     4520    if (UNLIKELY(throwScope.exception()))
    44514521        return false;
    44524522    if (UNLIKELY(!nativeValue))
     
    44614531    VM& vm = state->vm();
    44624532    auto throwScope = DECLARE_THROW_SCOPE(vm);
    4463     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     4533    UNUSED_PARAM(throwScope);
     4534    JSValue value = JSValue::decode(encodedValue);
    44644535    UNUSED_PARAM(thisValue);
    44654536    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    44704541    auto& impl = forwardedImpl.get();
    44714542    auto nativeValue = value.toWTFString(state);
    4472     if (UNLIKELY(state->hadException()))
     4543    if (UNLIKELY(throwScope.exception()))
    44734544        return false;
    44744545    impl.setName(WTFMove(nativeValue));
     
    44814552    VM& vm = state->vm();
    44824553    auto throwScope = DECLARE_THROW_SCOPE(vm);
    4483     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     4554    UNUSED_PARAM(throwScope);
     4555    JSValue value = JSValue::decode(encodedValue);
    44844556    UNUSED_PARAM(thisValue);
    44854557    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    44924564    auto& impl = *forwardedImpl;
    44934565    auto nativeValue = value.toWTFString(state);
    4494     if (UNLIKELY(state->hadException()))
     4566    if (UNLIKELY(throwScope.exception()))
    44954567        return false;
    44964568    impl.setName(WTFMove(nativeValue));
     
    45034575    VM& vm = state->vm();
    45044576    auto throwScope = DECLARE_THROW_SCOPE(vm);
    4505     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     4577    UNUSED_PARAM(throwScope);
     4578    JSValue value = JSValue::decode(encodedValue);
    45064579    UNUSED_PARAM(thisValue);
    45074580    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
     
    45114584    auto& impl = castedThis->wrapped();
    45124585    auto nativeValue = valueToUSVString(state, value);
    4513     if (UNLIKELY(state->hadException()))
     4586    if (UNLIKELY(throwScope.exception()))
    45144587        return false;
    45154588    impl.setStringifierAttribute(WTFMove(nativeValue));
     
    45474620        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    45484621    auto testParam = state->argument(0).toWTFString(state);
    4549     if (UNLIKELY(state->hadException()))
     4622    if (UNLIKELY(throwScope.exception()))
    45504623        return JSValue::encode(jsUndefined());
    45514624    impl.enabledAtRuntimeOperation(WTFMove(testParam));
     
    45704643        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    45714644    auto testParam = convert<int32_t>(*state, state->argument(0), NormalConversion);
    4572     if (UNLIKELY(state->hadException()))
     4645    if (UNLIKELY(throwScope.exception()))
    45734646        return JSValue::encode(jsUndefined());
    45744647    impl.enabledAtRuntimeOperation(WTFMove(testParam));
     
    46284701        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    46294702    auto longArg = convert<int32_t>(*state, state->argument(0), NormalConversion);
    4630     if (UNLIKELY(state->hadException()))
     4703    if (UNLIKELY(throwScope.exception()))
    46314704        return JSValue::encode(jsUndefined());
    46324705    auto strArg = state->argument(1).toWTFString(state);
    4633     if (UNLIKELY(state->hadException()))
     4706    if (UNLIKELY(throwScope.exception()))
    46344707        return JSValue::encode(jsUndefined());
    46354708    auto objArg = JSTestObj::toWrapped(state->argument(2));
     
    46694742        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    46704743    auto byteArg = convert<int8_t>(*state, state->argument(0), NormalConversion);
    4671     if (UNLIKELY(state->hadException()))
     4744    if (UNLIKELY(throwScope.exception()))
    46724745        return JSValue::encode(jsUndefined());
    46734746    auto strArg = state->argument(1).toWTFString(state);
    4674     if (UNLIKELY(state->hadException()))
     4747    if (UNLIKELY(throwScope.exception()))
    46754748        return JSValue::encode(jsUndefined());
    46764749    auto objArg = JSTestObj::toWrapped(state->argument(2));
     
    47104783        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    47114784    auto octetArg = convert<uint8_t>(*state, state->argument(0), NormalConversion);
    4712     if (UNLIKELY(state->hadException()))
     4785    if (UNLIKELY(throwScope.exception()))
    47134786        return JSValue::encode(jsUndefined());
    47144787    auto strArg = state->argument(1).toWTFString(state);
    4715     if (UNLIKELY(state->hadException()))
     4788    if (UNLIKELY(throwScope.exception()))
    47164789        return JSValue::encode(jsUndefined());
    47174790    auto objArg = JSTestObj::toWrapped(state->argument(2));
     
    47514824        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    47524825    auto longArg = convert<int32_t>(*state, state->argument(0), NormalConversion);
    4753     if (UNLIKELY(state->hadException()))
     4826    if (UNLIKELY(throwScope.exception()))
    47544827        return JSValue::encode(jsUndefined());
    47554828    auto strArg = state->argument(1).toWTFString(state);
    4756     if (UNLIKELY(state->hadException()))
     4829    if (UNLIKELY(throwScope.exception()))
    47574830        return JSValue::encode(jsUndefined());
    47584831    auto objArg = JSTestObj::toWrapped(state->argument(2));
     
    47924865        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    47934866    auto longArg = convert<int32_t>(*state, state->argument(0), NormalConversion);
    4794     if (UNLIKELY(state->hadException()))
     4867    if (UNLIKELY(throwScope.exception()))
    47954868        return JSValue::encode(jsUndefined());
    47964869    auto strArg = state->argument(1).toWTFString(state);
    4797     if (UNLIKELY(state->hadException()))
     4870    if (UNLIKELY(throwScope.exception()))
    47984871        return JSValue::encode(jsUndefined());
    47994872    auto objArg = JSTestObj::toWrapped(state->argument(2));
     
    48334906        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    48344907    auto arg = valueToStringTreatingNullAsEmptyString(state, state->argument(0));
    4835     if (UNLIKELY(state->hadException()))
     4908    if (UNLIKELY(throwScope.exception()))
    48364909        return JSValue::encode(jsUndefined());
    48374910    impl.methodWithArgTreatingNullAsEmptyString(WTFMove(arg));
     
    48534926        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    48544927    auto resolver = JSXPathNSResolver::toWrapped(*state, state->argument(0));
    4855     if (UNLIKELY(state->hadException()))
     4928    if (UNLIKELY(throwScope.exception()))
    48564929        return JSValue::encode(jsUndefined());
    48574930    if (UNLIKELY(!resolver))
     
    48994972        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    49004973    auto index = convert<uint32_t>(*state, state->argument(0), NormalConversion);
    4901     if (UNLIKELY(state->hadException()))
     4974    if (UNLIKELY(throwScope.exception()))
    49024975        return JSValue::encode(jsUndefined());
    49034976    JSValue result = jsStringOrNull(state, impl.nullableStringSpecialMethod(WTFMove(index)));
     
    49214994    TestObj::EnumType enumArg;
    49224995    auto optionalValue = parse<TestObj::EnumType>(*state, enumArgValue);
    4923     if (UNLIKELY(state->hadException()))
     4996    if (UNLIKELY(throwScope.exception()))
    49244997        return JSValue::encode(jsUndefined());
    49254998    if (UNLIKELY(!optionalValue))
     
    49455018    if (!enumArgValue.isUndefined()) {
    49465019        enumArg = parse<TestObj::EnumType>(*state, enumArgValue);
    4947         if (UNLIKELY(state->hadException()))
     5020        if (UNLIKELY(throwScope.exception()))
    49485021            return JSValue::encode(jsUndefined());
    49495022        if (UNLIKELY(!enumArg))
     
    49715044    } else {
    49725045        auto optionalValue = parse<TestObj::EnumType>(*state, enumArgValue);
    4973         if (UNLIKELY(state->hadException()))
     5046        if (UNLIKELY(throwScope.exception()))
    49745047            return JSValue::encode(jsUndefined());
    49755048        if (UNLIKELY(!optionalValue))
     
    49965069    ExceptionCode ec = 0;
    49975070    auto strArg = state->argument(0).toWTFString(state);
    4998     if (UNLIKELY(state->hadException()))
     5071    if (UNLIKELY(throwScope.exception()))
    49995072        return JSValue::encode(jsUndefined());
    50005073    auto objArg = JSTestObj::toWrapped(state->argument(1));
     
    50215094        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    50225095    auto str = valueToUSVString(state, state->argument(0));
    5023     if (UNLIKELY(state->hadException()))
     5096    if (UNLIKELY(throwScope.exception()))
    50245097        return JSValue::encode(jsUndefined());
    50255098    impl.methodWithUSVStringArg(WTFMove(str));
     
    50415114        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    50425115    auto str = valueToUSVStringWithUndefinedOrNullCheck(state, state->argument(0));
    5043     if (UNLIKELY(state->hadException()))
     5116    if (UNLIKELY(throwScope.exception()))
    50445117        return JSValue::encode(jsUndefined());
    50455118    impl.methodWithNullableUSVStringArg(WTFMove(str));
     
    50615134        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    50625135    auto str = valueToUSVStringTreatingNullAsEmptyString(state, state->argument(0));
    5063     if (UNLIKELY(state->hadException()))
     5136    if (UNLIKELY(throwScope.exception()))
    50645137        return JSValue::encode(jsUndefined());
    50655138    impl.methodWithUSVStringArgTreatingNullAsEmptyString(WTFMove(str));
     
    50815154        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    50825155    auto serializedArg = SerializedScriptValue::create(state, state->argument(0), 0, 0);
    5083     if (UNLIKELY(state->hadException()))
     5156    if (UNLIKELY(throwScope.exception()))
    50845157        return JSValue::encode(jsUndefined());
    50855158    impl.serializedValue(WTFMove(serializedArg));
     
    51805253        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    51815254    auto argument = state->argument(0).toWTFString(state);
    5182     if (UNLIKELY(state->hadException()))
     5255    if (UNLIKELY(throwScope.exception()))
    51835256        return JSValue::encode(jsUndefined());
    51845257    JSValue result = jsStringWithCache(state, impl.privateMethod(WTFMove(argument)));
     
    52005273        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    52015274    auto argument = state->argument(0).toWTFString(state);
    5202     if (UNLIKELY(state->hadException()))
     5275    if (UNLIKELY(throwScope.exception()))
    52035276        return JSValue::encode(jsUndefined());
    52045277    JSValue result = jsStringWithCache(state, impl.publicAndPrivateMethod(WTFMove(argument)));
     
    52205293        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    52215294    auto type = state->argument(0).toWTFString(state);
    5222     if (UNLIKELY(state->hadException()))
     5295    if (UNLIKELY(throwScope.exception()))
    52235296        return JSValue::encode(jsUndefined());
    52245297    auto listener = JSEventListener::create(state->argument(1), *castedThis, false, currentWorld(state));
     
    52265299        return throwArgumentTypeError(*state, throwScope, 1, "listener", "TestObject", "addEventListener", "EventListener");
    52275300    auto useCapture = state->argument(2).toBoolean(state);
    5228     if (UNLIKELY(state->hadException()))
     5301    if (UNLIKELY(throwScope.exception()))
    52295302        return JSValue::encode(jsUndefined());
    52305303    impl.addEventListener(WTFMove(type), *listener, WTFMove(useCapture));
     
    52465319        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    52475320    auto type = state->argument(0).toWTFString(state);
    5248     if (UNLIKELY(state->hadException()))
     5321    if (UNLIKELY(throwScope.exception()))
    52495322        return JSValue::encode(jsUndefined());
    52505323    auto listener = JSEventListener::create(state->argument(1), *castedThis, false, currentWorld(state));
     
    52525325        return throwArgumentTypeError(*state, throwScope, 1, "listener", "TestObject", "removeEventListener", "EventListener");
    52535326    auto useCapture = state->argument(2).toBoolean(state);
    5254     if (UNLIKELY(state->hadException()))
     5327    if (UNLIKELY(throwScope.exception()))
    52555328        return JSValue::encode(jsUndefined());
    52565329    impl.removeEventListener(WTFMove(type), *listener, WTFMove(useCapture));
     
    52855358    auto& impl = castedThis->wrapped();
    52865359    JSValue result = toJS(state, castedThis->globalObject(), impl.withScriptStateObj(*state));
    5287     if (UNLIKELY(state->hadException()))
     5360    if (UNLIKELY(throwScope.exception()))
    52885361        return JSValue::encode(jsUndefined());
    52895362    return JSValue::encode(result);
     
    53225395
    53235396    setDOMException(state, ec);
    5324     if (UNLIKELY(state->hadException()))
     5397    if (UNLIKELY(throwScope.exception()))
    53255398        return JSValue::encode(jsUndefined());
    53265399    return JSValue::encode(result);
     
    53815454
    53825455    setDOMException(state, ec);
    5383     if (UNLIKELY(state->hadException()))
     5456    if (UNLIKELY(throwScope.exception()))
    53845457        return JSValue::encode(jsUndefined());
    53855458    return JSValue::encode(result);
     
    54015474        return JSValue::encode(jsUndefined());
    54025475    JSValue result = toJS(state, castedThis->globalObject(), impl.withScriptExecutionContextAndScriptStateWithSpaces(*state, *context));
    5403     if (UNLIKELY(state->hadException()))
     5476    if (UNLIKELY(throwScope.exception()))
    54045477        return JSValue::encode(jsUndefined());
    54055478    return JSValue::encode(result);
     
    54875560    auto& impl = castedThis->wrapped();
    54885561    auto opt = state->argument(0).isUndefined() ? Optional<int32_t>() : convert<int32_t>(*state, state->uncheckedArgument(0), NormalConversion);
    5489     if (UNLIKELY(state->hadException()))
     5562    if (UNLIKELY(throwScope.exception()))
    54905563        return JSValue::encode(jsUndefined());
    54915564    impl.methodWithOptionalArg(WTFMove(opt));
     
    55055578    auto& impl = castedThis->wrapped();
    55065579    auto opt = state->argument(0).isUndefined() ? 666 : convert<int32_t>(*state, state->uncheckedArgument(0), NormalConversion);
    5507     if (UNLIKELY(state->hadException()))
     5580    if (UNLIKELY(throwScope.exception()))
    55085581        return JSValue::encode(jsUndefined());
    55095582    impl.methodWithOptionalArgAndDefaultValue(WTFMove(opt));
     
    55255598        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    55265599    auto nonOpt = convert<int32_t>(*state, state->argument(0), NormalConversion);
    5527     if (UNLIKELY(state->hadException()))
     5600    if (UNLIKELY(throwScope.exception()))
    55285601        return JSValue::encode(jsUndefined());
    55295602    auto opt = state->argument(1).isUndefined() ? Optional<int32_t>() : convert<int32_t>(*state, state->uncheckedArgument(1), NormalConversion);
    5530     if (UNLIKELY(state->hadException()))
     5603    if (UNLIKELY(throwScope.exception()))
    55315604        return JSValue::encode(jsUndefined());
    55325605    impl.methodWithNonOptionalArgAndOptionalArg(WTFMove(nonOpt), WTFMove(opt));
     
    55485621        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    55495622    auto nonOpt = convert<int32_t>(*state, state->argument(0), NormalConversion);
    5550     if (UNLIKELY(state->hadException()))
     5623    if (UNLIKELY(throwScope.exception()))
    55515624        return JSValue::encode(jsUndefined());
    55525625    auto opt1 = state->argument(1).isUndefined() ? Optional<int32_t>() : convert<int32_t>(*state, state->uncheckedArgument(1), NormalConversion);
    5553     if (UNLIKELY(state->hadException()))
     5626    if (UNLIKELY(throwScope.exception()))
    55545627        return JSValue::encode(jsUndefined());
    55555628    auto opt2 = state->argument(2).isUndefined() ? Optional<int32_t>() : convert<int32_t>(*state, state->uncheckedArgument(2), NormalConversion);
    5556     if (UNLIKELY(state->hadException()))
     5629    if (UNLIKELY(throwScope.exception()))
    55575630        return JSValue::encode(jsUndefined());
    55585631    impl.methodWithNonOptionalArgAndTwoOptionalArgs(WTFMove(nonOpt), WTFMove(opt1), WTFMove(opt2));
     
    55725645    auto& impl = castedThis->wrapped();
    55735646    auto str = state->argument(0).isUndefined() ? String() : state->uncheckedArgument(0).toWTFString(state);
    5574     if (UNLIKELY(state->hadException()))
     5647    if (UNLIKELY(throwScope.exception()))
    55755648        return JSValue::encode(jsUndefined());
    55765649    impl.methodWithOptionalString(WTFMove(str));
     
    55905663    auto& impl = castedThis->wrapped();
    55915664    auto str = state->argument(0).isUndefined() ? String() : valueToUSVString(state, state->uncheckedArgument(0));
    5592     if (UNLIKELY(state->hadException()))
     5665    if (UNLIKELY(throwScope.exception()))
    55935666        return JSValue::encode(jsUndefined());
    55945667    impl.methodWithOptionalUSVString(WTFMove(str));
     
    56085681    auto& impl = castedThis->wrapped();
    56095682    auto str = state->argument(0).isUndefined() ? nullAtom : state->uncheckedArgument(0).toString(state)->toAtomicString(state);
    5610     if (UNLIKELY(state->hadException()))
     5683    if (UNLIKELY(throwScope.exception()))
    56115684        return JSValue::encode(jsUndefined());
    56125685    impl.methodWithOptionalAtomicString(WTFMove(str));
     
    56265699    auto& impl = castedThis->wrapped();
    56275700    auto str = state->argument(0).isUndefined() ? ASCIILiteral("foo") : state->uncheckedArgument(0).toWTFString(state);
    5628     if (UNLIKELY(state->hadException()))
     5701    if (UNLIKELY(throwScope.exception()))
    56295702        return JSValue::encode(jsUndefined());
    56305703    impl.methodWithOptionalStringAndDefaultValue(WTFMove(str));
     
    56445717    auto& impl = castedThis->wrapped();
    56455718    auto str = state->argument(0).isUndefined() ? AtomicString("foo", AtomicString::ConstructFromLiteral) : state->uncheckedArgument(0).toString(state)->toAtomicString(state);
    5646     if (UNLIKELY(state->hadException()))
     5719    if (UNLIKELY(throwScope.exception()))
    56475720        return JSValue::encode(jsUndefined());
    56485721    impl.methodWithOptionalAtomicStringAndDefaultValue(WTFMove(str));
     
    56625735    auto& impl = castedThis->wrapped();
    56635736    auto str = state->argument(0).isUndefined() ? String() : state->uncheckedArgument(0).toWTFString(state);
    5664     if (UNLIKELY(state->hadException()))
     5737    if (UNLIKELY(throwScope.exception()))
    56655738        return JSValue::encode(jsUndefined());
    56665739    impl.methodWithOptionalStringIsNull(WTFMove(str));
     
    56805753    auto& impl = castedThis->wrapped();
    56815754    auto str = state->argument(0).toWTFString(state);
    5682     if (UNLIKELY(state->hadException()))
     5755    if (UNLIKELY(throwScope.exception()))
    56835756        return JSValue::encode(jsUndefined());
    56845757    impl.methodWithOptionalStringIsUndefined(WTFMove(str));
     
    56985771    auto& impl = castedThis->wrapped();
    56995772    auto str = state->argument(0).isUndefined() ? nullAtom : state->uncheckedArgument(0).toString(state)->toAtomicString(state);
    5700     if (UNLIKELY(state->hadException()))
     5773    if (UNLIKELY(throwScope.exception()))
    57015774        return JSValue::encode(jsUndefined());
    57025775    impl.methodWithOptionalAtomicStringIsNull(WTFMove(str));
     
    57165789    auto& impl = castedThis->wrapped();
    57175790    auto str = state->argument(0).isUndefined() ? emptyString() : state->uncheckedArgument(0).toWTFString(state);
    5718     if (UNLIKELY(state->hadException()))
     5791    if (UNLIKELY(throwScope.exception()))
    57195792        return JSValue::encode(jsUndefined());
    57205793    impl.methodWithOptionalStringIsEmptyString(WTFMove(str));
     
    57345807    auto& impl = castedThis->wrapped();
    57355808    auto str = state->argument(0).isUndefined() ? emptyString() : valueToUSVString(state, state->uncheckedArgument(0));
    5736     if (UNLIKELY(state->hadException()))
     5809    if (UNLIKELY(throwScope.exception()))
    57375810        return JSValue::encode(jsUndefined());
    57385811    impl.methodWithOptionalUSVStringIsEmptyString(WTFMove(str));
     
    57525825    auto& impl = castedThis->wrapped();
    57535826    auto str = state->argument(0).isUndefined() ? emptyAtom : state->uncheckedArgument(0).toString(state)->toAtomicString(state);
    5754     if (UNLIKELY(state->hadException()))
     5827    if (UNLIKELY(throwScope.exception()))
    57555828        return JSValue::encode(jsUndefined());
    57565829    impl.methodWithOptionalAtomicStringIsEmptyString(WTFMove(str));
     
    57705843    auto& impl = castedThis->wrapped();
    57715844    auto number = convert<double>(*state, state->argument(0), ShouldAllowNonFinite::Yes);
    5772     if (UNLIKELY(state->hadException()))
     5845    if (UNLIKELY(throwScope.exception()))
    57735846        return JSValue::encode(jsUndefined());
    57745847    impl.methodWithOptionalDoubleIsNaN(WTFMove(number));
     
    57885861    auto& impl = castedThis->wrapped();
    57895862    auto number = convert<float>(*state, state->argument(0), ShouldAllowNonFinite::Yes);
    5790     if (UNLIKELY(state->hadException()))
     5863    if (UNLIKELY(throwScope.exception()))
    57915864        return JSValue::encode(jsUndefined());
    57925865    impl.methodWithOptionalFloatIsNaN(WTFMove(number));
     
    58065879    auto& impl = castedThis->wrapped();
    58075880    auto number = state->argument(0).isUndefined() ? Optional<int64_t>() : convert<int64_t>(*state, state->uncheckedArgument(0), NormalConversion);
    5808     if (UNLIKELY(state->hadException()))
     5881    if (UNLIKELY(throwScope.exception()))
    58095882        return JSValue::encode(jsUndefined());
    58105883    impl.methodWithOptionalLongLong(WTFMove(number));
     
    58245897    auto& impl = castedThis->wrapped();
    58255898    auto number = convert<int64_t>(*state, state->argument(0), NormalConversion);
    5826     if (UNLIKELY(state->hadException()))
     5899    if (UNLIKELY(throwScope.exception()))
    58275900        return JSValue::encode(jsUndefined());
    58285901    impl.methodWithOptionalLongLongIsZero(WTFMove(number));
     
    58425915    auto& impl = castedThis->wrapped();
    58435916    auto number = state->argument(0).isUndefined() ? Optional<uint64_t>() : convert<uint64_t>(*state, state->uncheckedArgument(0), NormalConversion);
    5844     if (UNLIKELY(state->hadException()))
     5917    if (UNLIKELY(throwScope.exception()))
    58455918        return JSValue::encode(jsUndefined());
    58465919    impl.methodWithOptionalUnsignedLongLong(WTFMove(number));
     
    58605933    auto& impl = castedThis->wrapped();
    58615934    auto number = convert<uint64_t>(*state, state->argument(0), NormalConversion);
    5862     if (UNLIKELY(state->hadException()))
     5935    if (UNLIKELY(throwScope.exception()))
    58635936        return JSValue::encode(jsUndefined());
    58645937    impl.methodWithOptionalUnsignedLongLongIsZero(WTFMove(number));
     
    58785951    auto& impl = castedThis->wrapped();
    58795952    auto array = state->argument(0).isUndefined() ? Optional<Vector<String>>() : toNativeArray<String>(*state, state->uncheckedArgument(0));
    5880     if (UNLIKELY(state->hadException()))
     5953    if (UNLIKELY(throwScope.exception()))
    58815954        return JSValue::encode(jsUndefined());
    58825955    impl.methodWithOptionalSequence(WTFMove(array));
     
    58965969    auto& impl = castedThis->wrapped();
    58975970    auto array = state->argument(0).isUndefined() ? Vector<String>() : toNativeArray<String>(*state, state->uncheckedArgument(0));
    5898     if (UNLIKELY(state->hadException()))
     5971    if (UNLIKELY(throwScope.exception()))
    58995972        return JSValue::encode(jsUndefined());
    59005973    impl.methodWithOptionalSequenceIsEmpty(WTFMove(array));
     
    59145987    auto& impl = castedThis->wrapped();
    59155988    auto b = state->argument(0).isUndefined() ? Optional<bool>() : state->uncheckedArgument(0).toBoolean(state);
    5916     if (UNLIKELY(state->hadException()))
     5989    if (UNLIKELY(throwScope.exception()))
    59175990        return JSValue::encode(jsUndefined());
    59185991    impl.methodWithOptionalBoolean(WTFMove(b));
     
    59326005    auto& impl = castedThis->wrapped();
    59336006    auto b = state->argument(0).toBoolean(state);
    5934     if (UNLIKELY(state->hadException()))
     6007    if (UNLIKELY(throwScope.exception()))
    59356008        return JSValue::encode(jsUndefined());
    59366009    impl.methodWithOptionalBooleanIsFalse(WTFMove(b));
     
    60106083    if (!state->argument(0).isUndefinedOrNull()) {
    60116084        resolver = JSXPathNSResolver::toWrapped(*state, state->uncheckedArgument(0));
    6012         if (UNLIKELY(state->hadException()))
     6085        if (UNLIKELY(throwScope.exception()))
    60136086            return JSValue::encode(jsUndefined());
    60146087        if (UNLIKELY(!resolver))
     
    60536126        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    60546127    auto nonCallback = convert<int32_t>(*state, state->argument(0), NormalConversion);
    6055     if (UNLIKELY(state->hadException()))
     6128    if (UNLIKELY(throwScope.exception()))
    60566129        return JSValue::encode(jsUndefined());
    60576130    if (UNLIKELY(!state->argument(1).isObject()))
     
    61176190        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    61186191    auto nonCallback = convert<int32_t>(*state, state->argument(0), NormalConversion);
    6119     if (UNLIKELY(state->hadException()))
     6192    if (UNLIKELY(throwScope.exception()))
    61206193        return JSValue::encode(jsUndefined());
    61216194    if (UNLIKELY(!state->argument(1).isFunction()))
     
    62506323    }
    62516324    auto strArg = state->argument(1).toWTFString(state);
    6252     if (UNLIKELY(state->hadException()))
     6325    if (UNLIKELY(throwScope.exception()))
    62536326        return JSValue::encode(jsUndefined());
    62546327    impl.overloadedMethod(WTFMove(objArg), WTFMove(strArg));
     
    62766349    }
    62776350    auto longArg = state->argument(1).isUndefined() ? Optional<int32_t>() : convert<int32_t>(*state, state->uncheckedArgument(1), NormalConversion);
    6278     if (UNLIKELY(state->hadException()))
     6351    if (UNLIKELY(throwScope.exception()))
    62796352        return JSValue::encode(jsUndefined());
    62806353    impl.overloadedMethod(WTFMove(objArg), WTFMove(longArg));
     
    62966369        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    62976370    auto strArg = state->argument(0).toWTFString(state);
    6298     if (UNLIKELY(state->hadException()))
     6371    if (UNLIKELY(throwScope.exception()))
    62996372        return JSValue::encode(jsUndefined());
    63006373    impl.overloadedMethod(WTFMove(strArg));
     
    63166389        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    63176390    auto longArg = convert<int32_t>(*state, state->argument(0), NormalConversion);
    6318     if (UNLIKELY(state->hadException()))
     6391    if (UNLIKELY(throwScope.exception()))
    63196392        return JSValue::encode(jsUndefined());
    63206393    impl.overloadedMethod(WTFMove(longArg));
     
    63796452        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    63806453    auto arrayArg = toNativeArray<String>(*state, state->argument(0));
    6381     if (UNLIKELY(state->hadException()))
     6454    if (UNLIKELY(throwScope.exception()))
    63826455        return JSValue::encode(jsUndefined());
    63836456    impl.overloadedMethod(WTFMove(arrayArg));
     
    64196492        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    64206493    auto arrayArg = toNativeArray<String>(*state, state->argument(0));
    6421     if (UNLIKELY(state->hadException()))
     6494    if (UNLIKELY(throwScope.exception()))
    64226495        return JSValue::encode(jsUndefined());
    64236496    impl.overloadedMethod(WTFMove(arrayArg));
     
    64396512        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    64406513    auto arrayArg = toNativeArray<uint32_t>(*state, state->argument(0));
    6441     if (UNLIKELY(state->hadException()))
     6514    if (UNLIKELY(throwScope.exception()))
    64426515        return JSValue::encode(jsUndefined());
    64436516    impl.overloadedMethod(WTFMove(arrayArg));
     
    64596532        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    64606533    auto strArg = state->argument(0).toWTFString(state);
    6461     if (UNLIKELY(state->hadException()))
     6534    if (UNLIKELY(throwScope.exception()))
    64626535        return JSValue::encode(jsUndefined());
    64636536    impl.overloadedMethod(WTFMove(strArg));
     
    65416614        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    65426615    auto strArg = state->argument(0).toWTFString(state);
    6543     if (UNLIKELY(state->hadException()))
     6616    if (UNLIKELY(throwScope.exception()))
    65446617        return JSValue::encode(jsUndefined());
    65456618    TestObj* objArg = nullptr;
     
    65736646    }
    65746647    auto longArg = state->argument(1).isUndefined() ? Optional<int32_t>() : convert<int32_t>(*state, state->uncheckedArgument(1), NormalConversion);
    6575     if (UNLIKELY(state->hadException()))
     6648    if (UNLIKELY(throwScope.exception()))
    65766649        return JSValue::encode(jsUndefined());
    65776650    impl.overloadedMethodWithOptionalParameter(WTFMove(objArg), WTFMove(longArg));
     
    66196692    UNUSED_PARAM(throwScope);
    66206693    auto arg = state->argument(0).isUndefined() ? Optional<int32_t>() : convert<int32_t>(*state, state->uncheckedArgument(0), NormalConversion);
    6621     if (UNLIKELY(state->hadException()))
     6694    if (UNLIKELY(throwScope.exception()))
    66226695        return JSValue::encode(jsUndefined());
    66236696    JSValue result = jsNumber(TestObj::classMethodWithOptional(WTFMove(arg)));
     
    66446717        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    66456718    auto arg = convert<int32_t>(*state, state->argument(0), NormalConversion);
    6646     if (UNLIKELY(state->hadException()))
     6719    if (UNLIKELY(throwScope.exception()))
    66476720        return JSValue::encode(jsUndefined());
    66486721    TestObj::overloadedMethod1(WTFMove(arg));
     
    66616734        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    66626735    auto type = state->argument(0).toWTFString(state);
    6663     if (UNLIKELY(state->hadException()))
     6736    if (UNLIKELY(throwScope.exception()))
    66646737        return JSValue::encode(jsUndefined());
    66656738    TestObj::overloadedMethod1(WTFMove(type));
     
    67046777        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    67056778    auto objArgsShort = convert<uint16_t>(*state, state->argument(0), Clamp);
    6706     if (UNLIKELY(state->hadException()))
     6779    if (UNLIKELY(throwScope.exception()))
    67076780        return JSValue::encode(jsUndefined());
    67086781    auto objArgsLong = convert<uint32_t>(*state, state->argument(1), Clamp);
    6709     if (UNLIKELY(state->hadException()))
     6782    if (UNLIKELY(throwScope.exception()))
    67106783        return JSValue::encode(jsUndefined());
    67116784    impl.classMethodWithClamp(WTFMove(objArgsShort), WTFMove(objArgsLong));
     
    67276800        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    67286801    auto objArgsShort = convert<uint16_t>(*state, state->argument(0), EnforceRange);
    6729     if (UNLIKELY(state->hadException()))
     6802    if (UNLIKELY(throwScope.exception()))
    67306803        return JSValue::encode(jsUndefined());
    67316804    auto objArgsLong = convert<uint32_t>(*state, state->argument(1), EnforceRange);
    6732     if (UNLIKELY(state->hadException()))
     6805    if (UNLIKELY(throwScope.exception()))
    67336806        return JSValue::encode(jsUndefined());
    67346807    impl.classMethodWithEnforceRange(WTFMove(objArgsShort), WTFMove(objArgsLong));
     
    67506823        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    67516824    auto unsignedLongSequence = toNativeArray<uint32_t>(*state, state->argument(0));
    6752     if (UNLIKELY(state->hadException()))
     6825    if (UNLIKELY(throwScope.exception()))
    67536826        return JSValue::encode(jsUndefined());
    67546827    impl.methodWithUnsignedLongSequence(WTFMove(unsignedLongSequence));
     
    67716844    ExceptionCode ec = 0;
    67726845    auto values = toNativeArray<String>(*state, state->argument(0));
    6773     if (UNLIKELY(state->hadException()))
     6846    if (UNLIKELY(throwScope.exception()))
    67746847        return JSValue::encode(jsUndefined());
    67756848    JSValue result = jsArray(state, castedThis->globalObject(), impl.stringArrayFunction(WTFMove(values), ec));
     
    68166889        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    68176890    auto arrayArg = toNativeArray<uint32_t>(*state, state->argument(0));
    6818     if (UNLIKELY(state->hadException()))
     6891    if (UNLIKELY(throwScope.exception()))
    68196892        return JSValue::encode(jsUndefined());
    68206893    auto nullableArrayArg = toNativeArray<uint32_t>(*state, state->argument(1));
    6821     if (UNLIKELY(state->hadException()))
     6894    if (UNLIKELY(throwScope.exception()))
    68226895        return JSValue::encode(jsUndefined());
    68236896    impl.methodWithAndWithoutNullableSequence(WTFMove(arrayArg), WTFMove(nullableArrayArg));
     
    68396912        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    68406913    auto elementId = AtomicString(state->argument(0).toString(state)->toExistingAtomicString(state));
    6841     if (UNLIKELY(state->hadException()))
     6914    if (UNLIKELY(throwScope.exception()))
    68426915        return JSValue::encode(jsUndefined());
    68436916    JSValue result = toJS(state, castedThis->globalObject(), impl.getElementById(WTFMove(elementId)));
     
    69226995        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    69236996    auto value = state->argument(0).toWTFString(state);
    6924     if (UNLIKELY(state->hadException()))
     6997    if (UNLIKELY(throwScope.exception()))
    69256998        return JSValue::encode(jsUndefined());
    69266999    impl.convert3(WTFMove(value));
     
    69427015        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    69437016    auto value = valueToStringWithUndefinedOrNullCheck(state, state->argument(0));
    6944     if (UNLIKELY(state->hadException()))
     7017    if (UNLIKELY(throwScope.exception()))
    69457018        return JSValue::encode(jsUndefined());
    69467019    impl.convert4(WTFMove(value));
     
    70077080        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    70087081    auto head = state->argument(0).toWTFString(state);
    7009     if (UNLIKELY(state->hadException()))
     7082    if (UNLIKELY(throwScope.exception()))
    70107083        return JSValue::encode(jsUndefined());
    70117084    auto tail = toArguments<VariadicHelper<JSC::JSValue, String>>(*state, 1);
    7012     if (UNLIKELY(state->hadException()))
     7085    if (UNLIKELY(throwScope.exception()))
    70137086        return JSValue::encode(jsUndefined());
    70147087    impl.variadicStringMethod(WTFMove(head), WTFMove(*tail.second));
     
    70307103        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    70317104    auto head = convert<double>(*state, state->argument(0), ShouldAllowNonFinite::Yes);
    7032     if (UNLIKELY(state->hadException()))
     7105    if (UNLIKELY(throwScope.exception()))
    70337106        return JSValue::encode(jsUndefined());
    70347107    auto tail = toArguments<VariadicHelper<JSC::JSValue, double>>(*state, 1);
    7035     if (UNLIKELY(state->hadException()))
     7108    if (UNLIKELY(throwScope.exception()))
    70367109        return JSValue::encode(jsUndefined());
    70377110    impl.variadicDoubleMethod(WTFMove(head), WTFMove(*tail.second));
     
    70767149        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    70777150    auto a = convert<float>(*state, state->argument(0), ShouldAllowNonFinite::Yes);
    7078     if (UNLIKELY(state->hadException()))
     7151    if (UNLIKELY(throwScope.exception()))
    70797152        return JSValue::encode(jsUndefined());
    70807153    auto b = convert<int32_t>(*state, state->argument(1), NormalConversion);
    7081     if (UNLIKELY(state->hadException()))
     7154    if (UNLIKELY(throwScope.exception()))
    70827155        return JSValue::encode(jsUndefined());
    70837156    impl.any(WTFMove(a), WTFMove(b));
     
    71267199        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    71277200    auto a = convert<float>(*state, state->argument(0), ShouldAllowNonFinite::No);
    7128     if (UNLIKELY(state->hadException()))
     7201    if (UNLIKELY(throwScope.exception()))
    71297202        return JSValue::encode(jsUndefined());
    71307203    impl.testPromiseFunctionWithFloatArgument(WTFMove(a), DeferredWrapper::create(state, castedThis->globalObject(), promiseDeferred));
     
    71737246    auto& impl = castedThis->wrapped();
    71747247    auto a = state->argument(0).isUndefined() ? Optional<int32_t>() : convert<int32_t>(*state, state->uncheckedArgument(0), NormalConversion);
    7175     if (UNLIKELY(state->hadException()))
     7248    if (UNLIKELY(throwScope.exception()))
    71767249        return JSValue::encode(jsUndefined());
    71777250    impl.testPromiseFunctionWithOptionalIntArgument(WTFMove(a), DeferredWrapper::create(state, castedThis->globalObject(), promiseDeferred));
     
    71997272        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    72007273    auto a = convert<float>(*state, state->argument(0), ShouldAllowNonFinite::No);
    7201     if (UNLIKELY(state->hadException()))
     7274    if (UNLIKELY(throwScope.exception()))
    72027275        return JSValue::encode(jsUndefined());
    72037276    impl.testPromiseOverloadedFunction(WTFMove(a), DeferredWrapper::create(state, castedThis->globalObject(), promiseDeferred));
     
    73137386        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    73147387    auto str = state->argument(0).toWTFString(state);
    7315     if (UNLIKELY(state->hadException()))
     7388    if (UNLIKELY(throwScope.exception()))
    73167389        return JSValue::encode(jsUndefined());
    73177390    impl.conditionalOverload(WTFMove(str));
     
    73367409        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    73377410    auto a = convert<int32_t>(*state, state->argument(0), NormalConversion);
    7338     if (UNLIKELY(state->hadException()))
     7411    if (UNLIKELY(throwScope.exception()))
    73397412        return JSValue::encode(jsUndefined());
    73407413    impl.conditionalOverload(WTFMove(a));
     
    73797452        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    73807453    auto str = state->argument(0).toWTFString(state);
    7381     if (UNLIKELY(state->hadException()))
     7454    if (UNLIKELY(throwScope.exception()))
    73827455        return JSValue::encode(jsUndefined());
    73837456    impl.singleConditionalOverload(WTFMove(str));
     
    74007473        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    74017474    auto a = convert<int32_t>(*state, state->argument(0), NormalConversion);
    7402     if (UNLIKELY(state->hadException()))
     7475    if (UNLIKELY(throwScope.exception()))
    74037476        return JSValue::encode(jsUndefined());
    74047477    impl.singleConditionalOverload(WTFMove(a));
     
    74397512        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    74407513    auto init = convertDictionary<TestObj::Dictionary>(*state, state->argument(0));
    7441     if (UNLIKELY(state->hadException()))
     7514    if (UNLIKELY(throwScope.exception()))
    74427515        return JSValue::encode(jsUndefined());
    74437516    impl.attachShadowRoot(init.value());
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp

    r205542 r205569  
    7676        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    7777    auto arrayBuffer = toArrayBuffer(state->argument(0));
    78     if (UNLIKELY(state->hadException()))
     78    if (UNLIKELY(throwScope.exception()))
    7979        return JSValue::encode(jsUndefined());
    8080    if (UNLIKELY(!arrayBuffer))
     
    9494        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    9595    auto arrayBufferView = toArrayBufferView(state->argument(0));
    96     if (UNLIKELY(state->hadException()))
     96    if (UNLIKELY(throwScope.exception()))
    9797        return JSValue::encode(jsUndefined());
    9898    if (UNLIKELY(!arrayBufferView))
     
    128128        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    129129    auto string = state->argument(0).toWTFString(state);
    130     if (UNLIKELY(state->hadException()))
     130    if (UNLIKELY(throwScope.exception()))
    131131        return JSValue::encode(jsUndefined());
    132132    auto object = TestOverloadedConstructors::create(WTFMove(string));
     
    142142    ASSERT(castedThis);
    143143    auto longArgs = toArguments<VariadicHelper<JSC::JSValue, int32_t>>(*state, 0);
    144     if (UNLIKELY(state->hadException()))
     144    if (UNLIKELY(throwScope.exception()))
    145145        return JSValue::encode(jsUndefined());
    146146    auto object = TestOverloadedConstructors::create(WTFMove(longArgs));
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructorsWithSequence.cpp

    r205458 r205569  
    7373    ASSERT(castedThis);
    7474    auto sequenceOfStrings = state->argument(0).isUndefined() ? Vector<String>() : toNativeArray<String>(*state, state->uncheckedArgument(0));
    75     if (UNLIKELY(state->hadException()))
     75    if (UNLIKELY(throwScope.exception()))
    7676        return JSValue::encode(jsUndefined());
    7777    auto object = TestOverloadedConstructorsWithSequence::create(WTFMove(sequenceOfStrings));
     
    8989        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    9090    auto string = state->argument(0).toWTFString(state);
    91     if (UNLIKELY(state->hadException()))
     91    if (UNLIKELY(throwScope.exception()))
    9292        return JSValue::encode(jsUndefined());
    9393    auto object = TestOverloadedConstructorsWithSequence::create(WTFMove(string));
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverrideBuiltins.cpp

    r205458 r205569  
    211211        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    212212    auto name = state->argument(0).toWTFString(state);
    213     if (UNLIKELY(state->hadException()))
     213    if (UNLIKELY(throwScope.exception()))
    214214        return JSValue::encode(jsUndefined());
    215215    JSValue result = toJS(state, castedThis->globalObject(), impl.namedItem(WTFMove(name)));
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp

    r205458 r205569  
    252252    VM& vm = state->vm();
    253253    auto throwScope = DECLARE_THROW_SCOPE(vm);
    254     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     254    UNUSED_PARAM(throwScope);
     255    JSValue value = JSValue::decode(encodedValue);
    255256    UNUSED_PARAM(thisValue);
    256257    JSTestSerializedScriptValueInterface* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(JSValue::decode(thisValue));
     
    260261    auto& impl = castedThis->wrapped();
    261262    auto nativeValue = SerializedScriptValue::create(state, value, 0, 0);
    262     if (UNLIKELY(state->hadException()))
     263    if (UNLIKELY(throwScope.exception()))
    263264        return false;
    264265    impl.setValue(WTFMove(nativeValue));
     
    271272    VM& vm = state->vm();
    272273    auto throwScope = DECLARE_THROW_SCOPE(vm);
    273     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     274    UNUSED_PARAM(throwScope);
     275    JSValue value = JSValue::decode(encodedValue);
    274276    UNUSED_PARAM(thisValue);
    275277    JSTestSerializedScriptValueInterface* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(JSValue::decode(thisValue));
     
    279281    auto& impl = castedThis->wrapped();
    280282    auto nativeValue = SerializedScriptValue::create(state, value, 0, 0);
    281     if (UNLIKELY(state->hadException()))
     283    if (UNLIKELY(throwScope.exception()))
    282284        return false;
    283285    impl.setCachedValue(WTFMove(nativeValue));
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp

    r205458 r205569  
    133133        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    134134    auto hello = state->argument(0).toWTFString(state);
    135     if (UNLIKELY(state->hadException()))
     135    if (UNLIKELY(throwScope.exception()))
    136136        return JSValue::encode(jsUndefined());
    137137    if (UNLIKELY(!state->argument(1).isObject()))
     
    361361    VM& vm = state->vm();
    362362    auto throwScope = DECLARE_THROW_SCOPE(vm);
    363     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     363    UNUSED_PARAM(throwScope);
     364    JSValue value = JSValue::decode(encodedValue);
    364365    UNUSED_PARAM(thisValue);
    365366    JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(JSValue::decode(thisValue));
     
    369370    auto& impl = castedThis->wrapped();
    370371    auto nativeValue = convert<uint64_t>(*state, value, NormalConversion);
    371     if (UNLIKELY(state->hadException()))
     372    if (UNLIKELY(throwScope.exception()))
    372373        return false;
    373374    impl.setUnsignedLongLongAttr(WTFMove(nativeValue));
     
    380381    VM& vm = state->vm();
    381382    auto throwScope = DECLARE_THROW_SCOPE(vm);
    382     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     383    UNUSED_PARAM(throwScope);
     384    JSValue value = JSValue::decode(encodedValue);
    383385    UNUSED_PARAM(thisValue);
    384386    JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(JSValue::decode(thisValue));
     
    388390    auto& impl = castedThis->wrapped();
    389391    auto nativeValue = SerializedScriptValue::create(state, value, 0, 0);
    390     if (UNLIKELY(state->hadException()))
     392    if (UNLIKELY(throwScope.exception()))
    391393        return false;
    392394    impl.setImmutableSerializedScriptValue(WTFMove(nativeValue));
     
    399401    VM& vm = state->vm();
    400402    auto throwScope = DECLARE_THROW_SCOPE(vm);
    401     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     403    UNUSED_PARAM(throwScope);
     404    JSValue value = JSValue::decode(encodedValue);
    402405    UNUSED_PARAM(thisValue);
    403406    JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(JSValue::decode(thisValue));
     
    407410    auto& impl = castedThis->wrapped();
    408411    auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
    409     if (UNLIKELY(state->hadException()))
     412    if (UNLIKELY(throwScope.exception()))
    410413        return false;
    411414    impl.setAttrWithGetterException(WTFMove(nativeValue));
     
    418421    VM& vm = state->vm();
    419422    auto throwScope = DECLARE_THROW_SCOPE(vm);
    420     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     423    UNUSED_PARAM(throwScope);
     424    JSValue value = JSValue::decode(encodedValue);
    421425    UNUSED_PARAM(thisValue);
    422426    JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(JSValue::decode(thisValue));
     
    427431    ExceptionCode ec = 0;
    428432    auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
    429     if (UNLIKELY(state->hadException()))
     433    if (UNLIKELY(throwScope.exception()))
    430434        return false;
    431435    impl.setAttrWithSetterException(WTFMove(nativeValue), ec);
     
    439443    VM& vm = state->vm();
    440444    auto throwScope = DECLARE_THROW_SCOPE(vm);
    441     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     445    UNUSED_PARAM(throwScope);
     446    JSValue value = JSValue::decode(encodedValue);
    442447    UNUSED_PARAM(thisValue);
    443448    JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(JSValue::decode(thisValue));
     
    447452    auto& impl = castedThis->wrapped();
    448453    auto nativeValue = value.toWTFString(state);
    449     if (UNLIKELY(state->hadException()))
     454    if (UNLIKELY(throwScope.exception()))
    450455        return false;
    451456    impl.setStringAttrWithGetterException(WTFMove(nativeValue));
     
    458463    VM& vm = state->vm();
    459464    auto throwScope = DECLARE_THROW_SCOPE(vm);
    460     UNUSED_PARAM(throwScope);    JSValue value = JSValue::decode(encodedValue);
     465    UNUSED_PARAM(throwScope);
     466    JSValue value = JSValue::decode(encodedValue);
    461467    UNUSED_PARAM(thisValue);
    462468    JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(JSValue::decode(thisValue));
     
    467473    ExceptionCode ec = 0;
    468474    auto nativeValue = value.toWTFString(state);
    469     if (UNLIKELY(state->hadException()))
     475    if (UNLIKELY(throwScope.exception()))
    470476        return false;
    471477    impl.setStringAttrWithSetterException(WTFMove(nativeValue), ec);
     
    492498    auto& impl = castedThis->wrapped();
    493499    auto x = state->argument(0).isUndefined() ? Vector<int32_t>() : toNativeArray<int32_t>(*state, state->uncheckedArgument(0));
    494     if (UNLIKELY(state->hadException()))
     500    if (UNLIKELY(throwScope.exception()))
    495501        return JSValue::encode(jsUndefined());
    496502    impl.func(WTFMove(x));
     
    512518        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    513519    auto width = convert<float>(*state, state->argument(0), ShouldAllowNonFinite::Yes);
    514     if (UNLIKELY(state->hadException()))
     520    if (UNLIKELY(throwScope.exception()))
    515521        return JSValue::encode(jsUndefined());
    516522    auto height = convert<float>(*state, state->argument(1), ShouldAllowNonFinite::Yes);
    517     if (UNLIKELY(state->hadException()))
     523    if (UNLIKELY(throwScope.exception()))
    518524        return JSValue::encode(jsUndefined());
    519525    auto blur = convert<float>(*state, state->argument(2), ShouldAllowNonFinite::Yes);
    520     if (UNLIKELY(state->hadException()))
     526    if (UNLIKELY(throwScope.exception()))
    521527        return JSValue::encode(jsUndefined());
    522528    auto color = state->argument(3).isUndefined() ? String() : state->uncheckedArgument(3).toWTFString(state);
    523     if (UNLIKELY(state->hadException()))
     529    if (UNLIKELY(throwScope.exception()))
    524530        return JSValue::encode(jsUndefined());
    525531    auto alpha = state->argument(4).isUndefined() ? Optional<float>() : convert<float>(*state, state->uncheckedArgument(4), ShouldAllowNonFinite::Yes);
    526     if (UNLIKELY(state->hadException()))
     532    if (UNLIKELY(throwScope.exception()))
    527533        return JSValue::encode(jsUndefined());
    528534    impl.setShadow(WTFMove(width), WTFMove(height), WTFMove(blur), WTFMove(color), WTFMove(alpha));
     
    544550        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    545551    auto sequenceArg = toRefPtrNativeArray<SerializedScriptValue, JSSerializedScriptValue>(*state, state->argument(0));
    546     if (UNLIKELY(state->hadException()))
     552    if (UNLIKELY(throwScope.exception()))
    547553        return JSValue::encode(jsUndefined());
    548554    JSValue result = jsNumber(impl.methodWithSequenceArg(WTFMove(sequenceArg)));
     
    564570        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    565571    auto sequenceArg = toNativeArray<String>(*state, state->argument(0));
    566     if (UNLIKELY(state->hadException()))
     572    if (UNLIKELY(throwScope.exception()))
    567573        return JSValue::encode(jsUndefined());
    568574    impl.nullableSequenceArg(WTFMove(sequenceArg));
     
    584590        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    585591    auto arg1 = convert<uint64_t>(*state, state->argument(0), Clamp);
    586     if (UNLIKELY(state->hadException()))
     592    if (UNLIKELY(throwScope.exception()))
    587593        return JSValue::encode(jsUndefined());
    588594    auto arg2 = state->argument(1).isUndefined() ? Optional<uint64_t>() : convert<uint64_t>(*state, state->uncheckedArgument(1), Clamp);
    589     if (UNLIKELY(state->hadException()))
     595    if (UNLIKELY(throwScope.exception()))
    590596        return JSValue::encode(jsUndefined());
    591597    impl.funcWithClamp(WTFMove(arg1), WTFMove(arg2));
     
    623629    ExceptionCode ec = 0;
    624630    auto values = toNativeArray<String>(*state, state->argument(0));
    625     if (UNLIKELY(state->hadException()))
     631    if (UNLIKELY(throwScope.exception()))
    626632        return JSValue::encode(jsUndefined());
    627633    JSValue result = jsArray(state, castedThis->globalObject(), impl.stringSequenceFunction(WTFMove(values), ec));
     
    646652    ExceptionCode ec = 0;
    647653    auto values = toNativeArray<String>(*state, state->argument(0));
    648     if (UNLIKELY(state->hadException()))
     654    if (UNLIKELY(throwScope.exception()))
    649655        return JSValue::encode(jsUndefined());
    650656    JSValue result = jsArray(state, castedThis->globalObject(), impl.stringSequenceFunction2(WTFMove(values), ec));
     
    668674        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    669675    auto sequenceArg = toRefPtrNativeArray<TestEventTarget, JSTestEventTarget>(*state, state->argument(0));
    670     if (UNLIKELY(state->hadException()))
     676    if (UNLIKELY(throwScope.exception()))
    671677        return JSValue::encode(jsUndefined());
    672678    JSValue result = jsBoolean(impl.callWithSequenceThatRequiresInclude(WTFMove(sequenceArg)));
  • trunk/Source/WebCore/bridge/NP_jsobject.cpp

    r197614 r205569  
    178178            return false;
    179179       
    180         ExecState* exec = rootObject->globalObject()->globalExec();
    181         JSLockHolder lock(exec);
     180        auto globalObject = rootObject->globalObject();
     181        VM& vm = globalObject->vm();
     182        JSLockHolder lock(vm);
     183        auto scope = DECLARE_CATCH_SCOPE(vm);
     184
     185        ExecState* exec = globalObject->globalExec();
    182186       
    183187        // Call the function object.
     
    194198        // Convert and return the result of the function call.
    195199        convertValueToNPVariant(exec, resultV, result);
    196         exec->clearException();
     200        scope.clearException();
    197201        return true;       
    198202    }
     
    226230        if (!rootObject || !rootObject->isValid())
    227231            return false;
    228         ExecState* exec = rootObject->globalObject()->globalExec();
    229         JSLockHolder lock(exec);
     232
     233        auto globalObject = rootObject->globalObject();
     234        VM& vm = globalObject->vm();
     235        JSLockHolder lock(vm);
     236        auto scope = DECLARE_CATCH_SCOPE(vm);
     237
     238        ExecState* exec = globalObject->globalExec();
    230239        JSValue function = obj->imp->get(exec, identifierFromNPIdentifier(exec, i->string()));
    231240        CallData callData;
     
    241250        // Convert and return the result of the function call.
    242251        convertValueToNPVariant(exec, resultV, result);
    243         exec->clearException();
     252        scope.clearException();
    244253        return true;
    245254    }
     
    261270            return false;
    262271
    263         ExecState* exec = rootObject->globalObject()->globalExec();
    264         JSLockHolder lock(exec);
     272        auto globalObject = rootObject->globalObject();
     273        VM& vm = globalObject->vm();
     274        JSLockHolder lock(vm);
     275        auto scope = DECLARE_CATCH_SCOPE(vm);
     276
     277        ExecState* exec = globalObject->globalExec();
    265278        String scriptString = convertNPStringToUTF16(s);
    266279       
    267         JSValue returnValue = JSC::evaluate(rootObject->globalObject()->globalExec(), makeSource(scriptString), JSC::JSValue());
     280        JSValue returnValue = JSC::evaluate(exec, makeSource(scriptString), JSC::JSValue());
    268281
    269282        convertValueToNPVariant(exec, returnValue, variant);
    270         exec->clearException();
     283        scope.clearException();
    271284        return true;
    272285    }
     
    285298            return false;
    286299
    287         ExecState* exec = rootObject->globalObject()->globalExec();
     300        auto globalObject = rootObject->globalObject();
     301        VM& vm = globalObject->vm();
     302        JSLockHolder lock(vm);
     303        auto scope = DECLARE_CATCH_SCOPE(vm);
     304
     305        ExecState* exec = globalObject->globalExec();
    288306        IdentifierRep* i = static_cast<IdentifierRep*>(propertyName);
    289307       
    290         JSLockHolder lock(exec);
    291308        JSValue result;
    292309        if (i->isString())
     
    296313
    297314        convertValueToNPVariant(exec, result, variant);
    298         exec->clearException();
     315        scope.clearException();
    299316        return true;
    300317    }
     
    319336            return false;
    320337
    321         ExecState* exec = rootObject->globalObject()->globalExec();
    322         JSLockHolder lock(exec);
     338        auto globalObject = rootObject->globalObject();
     339        VM& vm = globalObject->vm();
     340        JSLockHolder lock(vm);
     341        auto scope = DECLARE_CATCH_SCOPE(vm);
     342
     343        ExecState* exec = globalObject->globalExec();
    323344        IdentifierRep* i = static_cast<IdentifierRep*>(propertyName);
    324345
     
    328349        } else
    329350            obj->imp->methodTable()->putByIndex(obj->imp, exec, i->number(), convertNPVariantToValue(exec, variant, rootObject), false);
    330         exec->clearException();
     351        scope.clearException();
    331352        return true;
    332353    }
     
    347368            return false;
    348369
    349         ExecState* exec = rootObject->globalObject()->globalExec();
     370        auto globalObject = rootObject->globalObject();
     371        VM& vm = globalObject->vm();
     372        JSLockHolder lock(vm);
     373        auto scope = DECLARE_CATCH_SCOPE(vm);
     374
     375        ExecState* exec = globalObject->globalExec();
     376
    350377        IdentifierRep* i = static_cast<IdentifierRep*>(propertyName);
    351378        if (i->isString()) {
    352379            if (!obj->imp->hasProperty(exec, identifierFromNPIdentifier(exec, i->string()))) {
    353                 exec->clearException();
     380                scope.clearException();
    354381                return false;
    355382            }
    356383        } else {
    357384            if (!obj->imp->hasProperty(exec, i->number())) {
    358                 exec->clearException();
     385                scope.clearException();
    359386                return false;
    360387            }
    361388        }
    362389
    363         JSLockHolder lock(exec);
    364390        if (i->isString())
    365391            obj->imp->methodTable()->deleteProperty(obj->imp, exec, identifierFromNPIdentifier(exec, i->string()));
     
    367393            obj->imp->methodTable()->deletePropertyByIndex(obj->imp, exec, i->number());
    368394
    369         exec->clearException();
     395        scope.clearException();
    370396        return true;
    371397    }
     
    382408            return false;
    383409
    384         ExecState* exec = rootObject->globalObject()->globalExec();
     410        auto globalObject = rootObject->globalObject();
     411        VM& vm = globalObject->vm();
     412        JSLockHolder lock(vm);
     413        auto scope = DECLARE_CATCH_SCOPE(vm);
     414
     415        ExecState* exec = globalObject->globalExec();
    385416        IdentifierRep* i = static_cast<IdentifierRep*>(propertyName);
    386         JSLockHolder lock(exec);
    387417        if (i->isString()) {
    388418            bool result = obj->imp->hasProperty(exec, identifierFromNPIdentifier(exec, i->string()));
    389             exec->clearException();
     419            scope.clearException();
    390420            return result;
    391421        }
    392422
    393423        bool result = obj->imp->hasProperty(exec, i->number());
    394         exec->clearException();
     424        scope.clearException();
    395425        return result;
    396426    }
     
    415445            return false;
    416446
    417         ExecState* exec = rootObject->globalObject()->globalExec();
    418         JSLockHolder lock(exec);
     447        auto globalObject = rootObject->globalObject();
     448        VM& vm = globalObject->vm();
     449        JSLockHolder lock(vm);
     450        auto scope = DECLARE_CATCH_SCOPE(vm);
     451
     452        ExecState* exec = globalObject->globalExec();
    419453        JSValue func = obj->imp->get(exec, identifierFromNPIdentifier(exec, i->string()));
    420         exec->clearException();
     454        scope.clearException();
    421455        return !func.isUndefined();
    422456    }
     
    444478            return false;
    445479       
    446         ExecState* exec = rootObject->globalObject()->globalExec();
    447         JSLockHolder lock(exec);
     480        auto globalObject = rootObject->globalObject();
     481        VM& vm = globalObject->vm();
     482        JSLockHolder lock(vm);
     483        auto scope = DECLARE_CATCH_SCOPE(vm);
     484
     485        ExecState* exec = globalObject->globalExec();
    448486        PropertyNameArray propertyNames(exec, PropertyNameMode::Strings);
    449487
     
    459497        *count = size;
    460498
    461         exec->clearException();
     499        scope.clearException();
    462500        return true;
    463501    }
     
    480518        if (!rootObject || !rootObject->isValid())
    481519            return false;
    482        
    483         ExecState* exec = rootObject->globalObject()->globalExec();
    484         JSLockHolder lock(exec);
     520
     521        auto globalObject = rootObject->globalObject();
     522        VM& vm = globalObject->vm();
     523        JSLockHolder lock(vm);
     524        auto scope = DECLARE_CATCH_SCOPE(vm);
     525
     526        ExecState* exec = globalObject->globalExec();
    485527       
    486528        // Call the constructor object.
     
    497539        // Convert and return the result.
    498540        convertValueToNPVariant(exec, resultV, result);
    499         exec->clearException();
     541        scope.clearException();
    500542        return true;
    501543    }
  • trunk/Source/WebCore/bridge/c/c_instance.cpp

    r205198 r205569  
    6969void CInstance::moveGlobalExceptionToExecState(ExecState* exec)
    7070{
    71     VM& vm = exec->vm();
    72     auto scope = DECLARE_THROW_SCOPE(vm);
    73 
    7471    if (globalExceptionString().isNull())
    7572        return;
    7673
    7774    {
    78         JSLockHolder lock(exec);
     75        VM& vm = exec->vm();
     76        JSLockHolder lock(vm);
     77        auto scope = DECLARE_THROW_SCOPE(vm);
    7978        throwException(exec, scope, createError(exec, globalExceptionString()));
    8079    }
  • trunk/Source/WebCore/bridge/objc/WebScriptObject.mm

    r204717 r205569  
    4343#import <JavaScriptCore/JSValueInternal.h>
    4444#import <interpreter/CallFrame.h>
     45#import <runtime/CatchScope.h>
    4546#import <runtime/Completion.h>
    4647#import <runtime/InitializeThreading.h>
     
    130131static void addExceptionToConsole(ExecState* exec)
    131132{
    132     JSC::Exception* exception = exec->exception();
    133     exec->clearException();
     133    JSC::VM& vm = exec->vm();
     134    auto scope = DECLARE_CATCH_SCOPE(vm);
     135    JSC::Exception* exception = scope.exception();
     136    scope.clearException();
    134137    addExceptionToConsole(exec, exception);
    135138}
     
    335338
    336339    // Look up the function object.
    337     ExecState* exec = [self _rootObject]->globalObject()->globalExec();
    338     JSLockHolder lock(exec);
    339     ASSERT(!exec->hadException());
     340    auto globalObject = [self _rootObject]->globalObject();
     341    auto& vm = globalObject->vm();
     342    JSLockHolder lock(vm);
     343    auto scope = DECLARE_CATCH_SCOPE(vm);
     344    ExecState* exec = globalObject->globalExec();
     345    UNUSED_PARAM(scope);
    340346
    341347    JSC::JSValue function = [self _imp]->get(exec, Identifier::fromString(exec, String(name)));
     
    370376        return nil;
    371377   
    372     ExecState* exec = [self _rootObject]->globalObject()->globalExec();
    373     ASSERT(!exec->hadException());
    374 
    375     JSLockHolder lock(exec);
     378    auto globalObject = [self _rootObject]->globalObject();
     379    auto& vm = globalObject->vm();
     380    JSLockHolder lock(vm);
     381    auto scope = DECLARE_CATCH_SCOPE(vm);
     382    ExecState* exec = globalObject->globalExec();
     383    UNUSED_PARAM(scope);
    376384   
    377385    JSC::JSValue returnValue = JSMainThreadExecState::profiledEvaluate(exec, JSC::ProfilingReason::Other, makeSource(String(script)), JSC::JSValue());
     
    387395        return;
    388396
    389     ExecState* exec = [self _rootObject]->globalObject()->globalExec();
    390     ASSERT(!exec->hadException());
    391 
    392     JSLockHolder lock(exec);
     397    auto globalObject = [self _rootObject]->globalObject();
     398    auto& vm = globalObject->vm();
     399    JSLockHolder lock(vm);
     400    auto scope = DECLARE_CATCH_SCOPE(vm);
     401    ExecState* exec = globalObject->globalExec();
     402
    393403    JSObject* object = JSC::jsDynamicCast<JSObject*>([self _imp]);
    394404    PutPropertySlot slot(object);
    395405    object->methodTable()->put(object, exec, Identifier::fromString(exec, String(key)), convertObjcValueToValue(exec, &value, ObjcObjectType, [self _rootObject]), slot);
    396406
    397     if (exec->hadException()) {
     407    if (UNLIKELY(scope.exception())) {
    398408        addExceptionToConsole(exec);
    399         exec->clearException();
     409        scope.clearException();
    400410    }
    401411}
     
    405415    if (![self _isSafeScript])
    406416        return nil;
    407 
    408     ExecState* exec = [self _rootObject]->globalObject()->globalExec();
    409     ASSERT(!exec->hadException());
    410417
    411418    id resultObj;
    412419    {
     420        auto globalObject = [self _rootObject]->globalObject();
     421        auto& vm = globalObject->vm();
     422
    413423        // Need to scope this lock to ensure that we release the lock before calling
    414424        // [super valueForKey:key] which might throw an exception and bypass the JSLock destructor,
    415425        // leaving the lock permanently held
    416         JSLockHolder lock(exec);
    417        
     426        JSLockHolder lock(vm);
     427
     428        auto scope = DECLARE_CATCH_SCOPE(vm);
     429        ExecState* exec = globalObject->globalExec();
     430
    418431        JSC::JSValue result = [self _imp]->get(exec, Identifier::fromString(exec, String(key)));
    419432       
    420         if (exec->hadException()) {
     433        if (UNLIKELY(scope.exception())) {
    421434            addExceptionToConsole(exec);
    422435            result = jsUndefined();
    423             exec->clearException();
     436            scope.clearException();
    424437        }
    425438
     
    438451        return;
    439452
    440     ExecState* exec = [self _rootObject]->globalObject()->globalExec();
    441     ASSERT(!exec->hadException());
    442 
    443     JSLockHolder lock(exec);
     453    auto globalObject = [self _rootObject]->globalObject();
     454    auto& vm = globalObject->vm();
     455    JSLockHolder lock(vm);
     456    auto scope = DECLARE_CATCH_SCOPE(vm);
     457    ExecState* exec = globalObject->globalExec();
     458
    444459    [self _imp]->methodTable()->deleteProperty([self _imp], exec, Identifier::fromString(exec, String(key)));
    445460
    446     if (exec->hadException()) {
     461    if (UNLIKELY(scope.exception())) {
    447462        addExceptionToConsole(exec);
    448         exec->clearException();
     463        scope.clearException();
    449464    }
    450465}
     
    455470        return NO;
    456471
    457     ExecState* exec = [self _rootObject]->globalObject()->globalExec();
    458     ASSERT(!exec->hadException());
    459 
    460     JSLockHolder lock(exec);
     472    auto globalObject = [self _rootObject]->globalObject();
     473    auto& vm = globalObject->vm();
     474    JSLockHolder lock(vm);
     475    auto scope = DECLARE_CATCH_SCOPE(vm);
     476    ExecState* exec = globalObject->globalExec();
     477
    461478    BOOL result = [self _imp]->hasProperty(exec, Identifier::fromString(exec, String(key)));
    462479
    463     if (exec->hadException()) {
     480    if (UNLIKELY(scope.exception())) {
    464481        addExceptionToConsole(exec);
    465         exec->clearException();
     482        scope.clearException();
    466483    }
    467484
     
    491508        return nil;
    492509
    493     ExecState* exec = [self _rootObject]->globalObject()->globalExec();
    494     ASSERT(!exec->hadException());
    495 
    496     JSLockHolder lock(exec);
     510    auto globalObject = [self _rootObject]->globalObject();
     511    auto& vm = globalObject->vm();
     512    JSLockHolder lock(vm);
     513    auto scope = DECLARE_CATCH_SCOPE(vm);
     514    ExecState* exec = globalObject->globalExec();
     515
    497516    JSC::JSValue result = [self _imp]->get(exec, index);
    498517
    499     if (exec->hadException()) {
     518    if (UNLIKELY(scope.exception())) {
    500519        addExceptionToConsole(exec);
    501520        result = jsUndefined();
    502         exec->clearException();
     521        scope.clearException();
    503522    }
    504523
     
    513532        return;
    514533
    515     ExecState* exec = [self _rootObject]->globalObject()->globalExec();
    516     ASSERT(!exec->hadException());
    517 
    518     JSLockHolder lock(exec);
     534    auto globalObject = [self _rootObject]->globalObject();
     535    auto& vm = globalObject->vm();
     536    JSLockHolder lock(vm);
     537    auto scope = DECLARE_CATCH_SCOPE(vm);
     538    ExecState* exec = globalObject->globalExec();
     539
    519540    [self _imp]->methodTable()->putByIndex([self _imp], exec, index, convertObjcValueToValue(exec, &value, ObjcObjectType, [self _rootObject]), false);
    520541
    521     if (exec->hadException()) {
     542    if (UNLIKELY(scope.exception())) {
    522543        addExceptionToConsole(exec);
    523         exec->clearException();
     544        scope.clearException();
    524545    }
    525546}
  • trunk/Source/WebCore/contentextensions/ContentExtensionParser.cpp

    r205462 r205569  
    6161static std::error_code getDomainList(ExecState& exec, const JSObject* arrayObject, Vector<String>& vector)
    6262{
     63    VM& vm = exec.vm();
     64    auto scope = DECLARE_THROW_SCOPE(vm);
     65
    6366    ASSERT(vector.isEmpty());
    6467    if (!arrayObject || !isJSArray(arrayObject))
     
    6972    for (unsigned i = 0; i < length; ++i) {
    7073        const JSValue value = array->getIndex(&exec, i);
    71         if (exec.hadException() || !value.isString())
     74        if (scope.exception() || !value.isString())
    7275            return ContentExtensionError::JSONInvalidDomainList;
    7376       
     
    8588static std::error_code getTypeFlags(ExecState& exec, const JSValue& typeValue, ResourceFlags& flags, uint16_t (*stringToType)(const String&))
    8689{
     90    VM& vm = exec.vm();
     91    auto scope = DECLARE_THROW_SCOPE(vm);
     92
    8793    if (!typeValue.isObject())
    8894        return { };
    8995
    9096    const JSObject* object = typeValue.toObject(&exec);
    91     ASSERT(!exec.hadException());
     97    ASSERT(!scope.exception());
    9298    if (!isJSArray(object))
    9399        return ContentExtensionError::JSONInvalidTriggerFlagsArray;
     
    98104    for (unsigned i = 0; i < length; ++i) {
    99105        const JSValue value = array->getIndex(&exec, i);
    100         if (exec.hadException() || !value)
     106        if (scope.exception() || !value)
    101107            return ContentExtensionError::JSONInvalidObjectInTriggerFlagsArray;
    102108       
     
    114120static std::error_code loadTrigger(ExecState& exec, const JSObject& ruleObject, Trigger& trigger)
    115121{
     122    VM& vm = exec.vm();
     123    auto scope = DECLARE_THROW_SCOPE(vm);
     124
    116125    const JSValue triggerObject = ruleObject.get(&exec, Identifier::fromString(&exec, "trigger"));
    117     if (!triggerObject || exec.hadException() || !triggerObject.isObject())
     126    if (!triggerObject || scope.exception() || !triggerObject.isObject())
    118127        return ContentExtensionError::JSONInvalidTrigger;
    119128   
    120129    const JSValue urlFilterObject = triggerObject.get(&exec, Identifier::fromString(&exec, "url-filter"));
    121     if (!urlFilterObject || exec.hadException() || !urlFilterObject.isString())
     130    if (!urlFilterObject || scope.exception() || !urlFilterObject.isString())
    122131        return ContentExtensionError::JSONInvalidURLFilterInTrigger;
    123132
     
    129138
    130139    const JSValue urlFilterCaseValue = triggerObject.get(&exec, Identifier::fromString(&exec, "url-filter-is-case-sensitive"));
    131     if (urlFilterCaseValue && !exec.hadException() && urlFilterCaseValue.isBoolean())
     140    if (urlFilterCaseValue && !scope.exception() && urlFilterCaseValue.isBoolean())
    132141        trigger.urlFilterIsCaseSensitive = urlFilterCaseValue.toBoolean(&exec);
    133142
    134143    const JSValue resourceTypeValue = triggerObject.get(&exec, Identifier::fromString(&exec, "resource-type"));
    135     if (!exec.hadException() && resourceTypeValue.isObject()) {
     144    if (!scope.exception() && resourceTypeValue.isObject()) {
    136145        auto typeFlagsError = getTypeFlags(exec, resourceTypeValue, trigger.flags, readResourceType);
    137146        if (typeFlagsError)
     
    141150
    142151    const JSValue loadTypeValue = triggerObject.get(&exec, Identifier::fromString(&exec, "load-type"));
    143     if (!exec.hadException() && loadTypeValue.isObject()) {
     152    if (!scope.exception() && loadTypeValue.isObject()) {
    144153        auto typeFlagsError = getTypeFlags(exec, loadTypeValue, trigger.flags, readLoadType);
    145154        if (typeFlagsError)
     
    149158
    150159    const JSValue ifDomain = triggerObject.get(&exec, Identifier::fromString(&exec, "if-domain"));
    151     if (!exec.hadException() && ifDomain.isObject()) {
     160    if (!scope.exception() && ifDomain.isObject()) {
    152161        auto ifDomainError = getDomainList(exec, asObject(ifDomain), trigger.domains);
    153162        if (ifDomainError)
     
    161170   
    162171    const JSValue unlessDomain = triggerObject.get(&exec, Identifier::fromString(&exec, "unless-domain"));
    163     if (!exec.hadException() && unlessDomain.isObject()) {
     172    if (!scope.exception() && unlessDomain.isObject()) {
    164173        if (trigger.domainCondition != Trigger::DomainCondition::None)
    165174            return ContentExtensionError::JSONUnlessAndIfDomain;
     
    187196static std::error_code loadAction(ExecState& exec, const JSObject& ruleObject, Action& action, bool& validSelector)
    188197{
     198    VM& vm = exec.vm();
     199    auto scope = DECLARE_THROW_SCOPE(vm);
     200
    189201    validSelector = true;
    190202    const JSValue actionObject = ruleObject.get(&exec, Identifier::fromString(&exec, "action"));
    191     if (!actionObject || exec.hadException() || !actionObject.isObject())
     203    if (!actionObject || scope.exception() || !actionObject.isObject())
    192204        return ContentExtensionError::JSONInvalidAction;
    193205
    194206    const JSValue typeObject = actionObject.get(&exec, Identifier::fromString(&exec, "type"));
    195     if (!typeObject || exec.hadException() || !typeObject.isString())
     207    if (!typeObject || scope.exception() || !typeObject.isString())
    196208        return ContentExtensionError::JSONInvalidActionType;
    197209
     
    206218    else if (actionType == "css-display-none") {
    207219        JSValue selector = actionObject.get(&exec, Identifier::fromString(&exec, "selector"));
    208         if (!selector || exec.hadException() || !selector.isString())
     220        if (!selector || scope.exception() || !selector.isString())
    209221            return ContentExtensionError::JSONInvalidCSSDisplayNoneActionType;
    210222
     
    244256static std::error_code loadEncodedRules(ExecState& exec, const String& rules, Vector<ContentExtensionRule>& ruleList)
    245257{
     258    VM& vm = exec.vm();
     259    auto scope = DECLARE_THROW_SCOPE(vm);
     260
    246261    // FIXME: JSONParse should require callbacks instead of an ExecState.
    247262    const JSValue decodedRules = JSONParse(&exec, rules);
    248263
    249     if (exec.hadException() || !decodedRules)
     264    if (scope.exception() || !decodedRules)
    250265        return ContentExtensionError::JSONInvalid;
    251266
     
    254269
    255270    const JSObject* topLevelObject = decodedRules.toObject(&exec);
    256     if (!topLevelObject || exec.hadException())
     271    if (!topLevelObject || scope.exception())
    257272        return ContentExtensionError::JSONTopLevelStructureNotAnObject;
    258273   
     
    270285    for (unsigned i = 0; i < length; ++i) {
    271286        const JSValue value = topLevelArray->getIndex(&exec, i);
    272         if (exec.hadException() || !value)
     287        if (scope.exception() || !value)
    273288            return ContentExtensionError::JSONInvalidObjectInTopLevelArray;
    274289
    275290        const JSObject* ruleObject = value.toObject(&exec);
    276         if (!ruleObject || exec.hadException())
     291        if (!ruleObject || scope.exception())
    277292            return ContentExtensionError::JSONInvalidRule;
    278293
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r205417 r205569  
    40034003static JSC::JSValue controllerJSValue(JSC::ExecState& exec, JSDOMGlobalObject& globalObject, HTMLMediaElement& media)
    40044004{
     4005    JSC::VM& vm = globalObject.vm();
     4006    auto scope = DECLARE_THROW_SCOPE(vm);
    40054007    auto mediaJSWrapper = toJS(&exec, &globalObject, media);
    40064008   
     
    40104012        return JSC::jsNull();
    40114013   
    4012     JSC::Identifier controlsHost = JSC::Identifier::fromString(&exec.vm(), "controlsHost");
     4014    JSC::Identifier controlsHost = JSC::Identifier::fromString(&vm, "controlsHost");
    40134015    JSC::JSValue controlsHostJSWrapper = mediaJSWrapperObject->get(&exec, controlsHost);
    4014     if (exec.hadException())
     4016    if (UNLIKELY(scope.exception()))
    40154017        return JSC::jsNull();
    40164018
     
    40194021        return JSC::jsNull();
    40204022
    4021     JSC::Identifier controllerID = JSC::Identifier::fromString(&exec.vm(), "controller");
     4023    JSC::Identifier controllerID = JSC::Identifier::fromString(&vm, "controller");
    40224024    JSC::JSValue controllerJSWrapper = controlsHostJSWrapperObject->get(&exec, controllerID);
    4023     if (exec.hadException())
     4025    if (UNLIKELY(scope.exception()))
    40244026        return JSC::jsNull();
    40254027
     
    40584060    ScriptController& scriptController = document().frame()->script();
    40594061    JSDOMGlobalObject* globalObject = JSC::jsCast<JSDOMGlobalObject*>(scriptController.globalObject(world));
     4062    JSC::VM& vm = globalObject->vm();
     4063    JSC::JSLockHolder lock(vm);
     4064    auto scope = DECLARE_CATCH_SCOPE(vm);
    40604065    JSC::ExecState* exec = globalObject->globalExec();
    4061     JSC::JSLockHolder lock(exec);
    40624066
    40634067    JSC::JSValue controllerValue = controllerJSValue(*exec, *globalObject, *this);
     
    40844088    JSC::MarkedArgumentBuffer noArguments;
    40854089    JSC::call(exec, methodObject, callType, callData, controllerObject, noArguments);
    4086     exec->clearException();
     4090    scope.clearException();
    40874091
    40884092    m_haveSetUpCaptionContainer = true;
     
    66046608    ScriptController& scriptController = document().frame()->script();
    66056609    JSDOMGlobalObject* globalObject = JSC::jsCast<JSDOMGlobalObject*>(scriptController.globalObject(world));
     6610    JSC::VM& vm = globalObject->vm();
     6611    JSC::JSLockHolder lock(vm);
     6612    auto scope = DECLARE_CATCH_SCOPE(vm);
    66066613    JSC::ExecState* exec = globalObject->globalExec();
    6607     JSC::JSLockHolder lock(exec);
    66086614
    66096615    JSC::JSValue functionValue = globalObject->get(exec, JSC::Identifier::fromString(exec, "createControls"));
     
    66186624#endif
    66196625    scriptController.evaluateInWorld(ScriptSourceCode(mediaControlsScript, scriptURL), world);
    6620     if (exec->hadException()) {
    6621         exec->clearException();
     6626    if (UNLIKELY(scope.exception())) {
     6627        scope.clearException();
    66226628        return false;
    66236629    }
     
    66776683    ScriptController& scriptController = document().frame()->script();
    66786684    JSDOMGlobalObject* globalObject = JSC::jsCast<JSDOMGlobalObject*>(scriptController.globalObject(world));
     6685    JSC::VM& vm = globalObject->vm();
     6686    JSC::JSLockHolder lock(vm);
     6687    auto scope = DECLARE_CATCH_SCOPE(vm);
    66796688    JSC::ExecState* exec = globalObject->globalExec();
    6680     JSC::JSLockHolder lock(exec);
    66816689
    66826690    // The media controls script must provide a method with the following details.
     
    67056713
    67066714    JSC::JSObject* function = functionValue.toObject(exec);
    6707     ASSERT(!exec->hadException());
     6715    ASSERT(!scope.exception());
    67086716    JSC::CallData callData;
    67096717    JSC::CallType callType = function->methodTable()->getCallData(function, callData);
     
    67126720
    67136721    JSC::JSValue controllerValue = JSC::call(exec, function, callType, callData, globalObject, argList);
    6714     exec->clearException();
     6722    scope.clearException();
    67156723    JSC::JSObject* controllerObject = JSC::jsDynamicCast<JSC::JSObject*>(controllerValue);
    67166724    if (!controllerObject)
     
    67196727    // Connect the Media, MediaControllerHost, and Controller so the GC knows about their relationship
    67206728    JSC::JSObject* mediaJSWrapperObject = mediaJSWrapper.toObject(exec);
    6721     ASSERT(!exec->hadException());
     6729    ASSERT(!scope.exception());
    67226730    JSC::Identifier controlsHost = JSC::Identifier::fromString(&exec->vm(), "controlsHost");
    67236731   
     
    67396747    updateUsesLTRUserInterfaceLayoutDirectionJSProperty();
    67406748
    6741     if (exec->hadException())
    6742         exec->clearException();
     6749    if (UNLIKELY(scope.exception()))
     6750        scope.clearException();
    67436751}
    67446752
     
    67756783    ScriptController& scriptController = document().frame()->script();
    67766784    JSDOMGlobalObject* globalObject = JSC::jsCast<JSDOMGlobalObject*>(scriptController.globalObject(world));
     6785    JSC::VM& vm = globalObject->vm();
     6786    JSC::JSLockHolder lock(vm);
     6787    auto scope = DECLARE_THROW_SCOPE(vm);
    67776788    JSC::ExecState* exec = globalObject->globalExec();
    6778     JSC::JSLockHolder lock(exec);
    67796789
    67806790    JSC::JSValue controllerValue = controllerJSValue(*exec, *globalObject, *this);
    67816791    JSC::JSObject* controllerObject = controllerValue.toObject(exec);
    67826792
    6783     if (exec->hadException())
     6793    if (UNLIKELY(scope.exception()))
    67846794        return;
    67856795
    67866796    JSC::JSValue functionValue = controllerObject->get(exec, JSC::Identifier::fromString(exec, "handlePresentationModeChange"));
    6787     if (exec->hadException() || functionValue.isUndefinedOrNull())
     6797    if (UNLIKELY(scope.exception()) || functionValue.isUndefinedOrNull())
    67886798        return;
    67896799
    67906800    JSC::JSObject* function = functionValue.toObject(exec);
    6791     ASSERT(!exec->hadException());
     6801    ASSERT(!scope.exception());
    67926802    JSC::CallData callData;
    67936803    JSC::CallType callType = function->methodTable()->getCallData(function, callData);
     
    68166826    ScriptController& scriptController = document().frame()->script();
    68176827    JSDOMGlobalObject* globalObject = JSC::jsCast<JSDOMGlobalObject*>(scriptController.globalObject(world));
     6828    JSC::VM& vm = globalObject->vm();
     6829    JSC::JSLockHolder lock(vm);
     6830    auto scope = DECLARE_THROW_SCOPE(vm);
    68186831    JSC::ExecState* exec = globalObject->globalExec();
    6819     JSC::JSLockHolder lock(exec);
    68206832
    68216833    JSC::JSValue controllerValue = controllerJSValue(*exec, *globalObject, *this);
    68226834    JSC::JSObject* controllerObject = controllerValue.toObject(exec);
    68236835
    6824     if (exec->hadException())
     6836    if (UNLIKELY(scope.exception()))
    68256837        return emptyString();
    68266838
    68276839    JSC::JSValue functionValue = controllerObject->get(exec, JSC::Identifier::fromString(exec, "getCurrentControlsStatus"));
    6828     if (exec->hadException() || functionValue.isUndefinedOrNull())
     6840    if (UNLIKELY(scope.exception()) || functionValue.isUndefinedOrNull())
    68296841        return emptyString();
    68306842
    68316843    JSC::JSObject* function = functionValue.toObject(exec);
    6832     ASSERT(!exec->hadException());
     6844    ASSERT(!scope.exception());
    68336845    JSC::CallData callData;
    68346846    JSC::CallType callType = function->methodTable()->getCallData(function, callData);
     
    68396851    JSC::JSValue outputValue = JSC::call(exec, function, callType, callData, controllerObject, argList);
    68406852
    6841     if (exec->hadException())
     6853    if (UNLIKELY(scope.exception()))
    68426854        return emptyString();
    68436855
  • trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp

    r205249 r205569  
    393393    ScriptController& scriptController = document().frame()->script();
    394394    JSDOMGlobalObject* globalObject = JSC::jsCast<JSDOMGlobalObject*>(scriptController.globalObject(isolatedWorld));
     395
     396    JSC::VM& vm = globalObject->vm();
     397    JSC::JSLockHolder lock(vm);
     398    auto scope = DECLARE_CATCH_SCOPE(vm);
    395399    JSC::ExecState* exec = globalObject->globalExec();
    396 
    397     JSC::JSLockHolder lock(exec);
    398400
    399401    JSC::MarkedArgumentBuffer argList;
     
    409411    JSC::JSObject* overlay = globalObject->get(exec, JSC::Identifier::fromString(exec, "createOverlay")).toObject(exec);
    410412    if (!overlay) {
    411         ASSERT(exec->hadException());
    412         exec->clearException();
     413        ASSERT(scope.exception());
     414        scope.clearException();
    413415        return;
    414416    }
     
    419421
    420422    JSC::call(exec, overlay, callType, callData, globalObject, argList);
    421     exec->clearException();
     423    scope.clearException();
    422424}
    423425
  • trunk/Source/WebKit/mac/ChangeLog

    r205549 r205569  
     12016-09-07  Mark Lam  <mark.lam@apple.com>
     2
     3        Add CatchScope and force all exception checks to be via ThrowScope or CatchScope.
     4        https://bugs.webkit.org/show_bug.cgi?id=161498
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * Plugins/Hosted/NetscapePluginInstanceProxy.mm:
     9        (WebKit::NetscapePluginInstanceProxy::evaluate):
     10        (WebKit::NetscapePluginInstanceProxy::invoke):
     11        (WebKit::NetscapePluginInstanceProxy::invokeDefault):
     12        (WebKit::NetscapePluginInstanceProxy::construct):
     13        (WebKit::NetscapePluginInstanceProxy::getProperty):
     14        (WebKit::NetscapePluginInstanceProxy::setProperty):
     15        (WebKit::NetscapePluginInstanceProxy::removeProperty):
     16        (WebKit::NetscapePluginInstanceProxy::hasProperty):
     17        (WebKit::NetscapePluginInstanceProxy::hasMethod):
     18        (WebKit::NetscapePluginInstanceProxy::enumerate):
     19        * WebView/WebView.mm:
     20        (aeDescFromJSValue):
     21
    1222016-09-07  Youenn Fablet  <youenn@apple.com>
    223
  • trunk/Source/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm

    r205198 r205569  
    886886        return false;
    887887
    888     JSLockHolder lock(pluginWorld().vm());
    889     Strong<JSGlobalObject> globalObject(pluginWorld().vm(), frame->script().globalObject(pluginWorld()));
     888    VM& vm = pluginWorld().vm();
     889    JSLockHolder lock(vm);
     890    auto scope = DECLARE_CATCH_SCOPE(vm);
     891
     892    Strong<JSGlobalObject> globalObject(vm, frame->script().globalObject(pluginWorld()));
    890893    ExecState* exec = globalObject->globalExec();
    891894
     
    895898   
    896899    marshalValue(exec, result, resultData, resultLength);
    897     exec->clearException();
     900    scope.clearException();
    898901    return true;
    899902}
     
    916919    if (!frame)
    917920        return false;
    918    
     921
     922    VM& vm = pluginWorld().vm();
     923    JSLockHolder lock(vm);
     924    auto scope = DECLARE_CATCH_SCOPE(vm);
     925
    919926    ExecState* exec = frame->script().globalObject(pluginWorld())->globalExec();
    920     JSLockHolder lock(exec);
    921927    JSValue function = object->get(exec, methodName);
    922928    CallData callData;
     
    931937       
    932938    marshalValue(exec, value, resultData, resultLength);
    933     exec->clearException();
     939    scope.clearException();
    934940    return true;
    935941}
     
    949955    if (!frame)
    950956        return false;
    951    
     957
     958    VM& vm = pluginWorld().vm();
     959    JSLockHolder lock(vm);
     960    auto scope = DECLARE_CATCH_SCOPE(vm);
     961
    952962    ExecState* exec = frame->script().globalObject(pluginWorld())->globalExec();
    953     JSLockHolder lock(exec);   
    954963    CallData callData;
    955964    CallType callType = object->methodTable()->getCallData(object, callData);
     
    963972   
    964973    marshalValue(exec, value, resultData, resultLength);
    965     exec->clearException();
     974    scope.clearException();
    966975    return true;
    967976}
     
    981990    if (!frame)
    982991        return false;
    983    
     992
     993    VM& vm = pluginWorld().vm();
     994    JSLockHolder lock(vm);
     995    auto scope = DECLARE_CATCH_SCOPE(vm);
     996
    984997    ExecState* exec = frame->script().globalObject(pluginWorld())->globalExec();
    985     JSLockHolder lock(exec);
    986998
    987999    ConstructData constructData;
     
    9961008   
    9971009    marshalValue(exec, value, resultData, resultLength);
    998     exec->clearException();
     1010    scope.clearException();
    9991011    return true;
    10001012}
     
    10141026    if (!frame)
    10151027        return false;
    1016    
     1028
     1029    VM& vm = pluginWorld().vm();
     1030    JSLockHolder lock(vm);
     1031    auto scope = DECLARE_CATCH_SCOPE(vm);
     1032
    10171033    ExecState* exec = frame->script().globalObject(pluginWorld())->globalExec();
    1018     JSLockHolder lock(exec);   
    10191034    JSValue value = object->get(exec, propertyName);
    10201035   
    10211036    marshalValue(exec, value, resultData, resultLength);
    1022     exec->clearException();
     1037    scope.clearException();
    10231038    return true;
    10241039}
     
    10351050    if (!frame)
    10361051        return false;
    1037    
     1052
     1053    VM& vm = pluginWorld().vm();
     1054    JSLockHolder lock(vm);
     1055    auto scope = DECLARE_CATCH_SCOPE(vm);
     1056
    10381057    ExecState* exec = frame->script().globalObject(pluginWorld())->globalExec();
    1039     JSLockHolder lock(exec);   
    10401058    JSValue value = object->get(exec, propertyName);
    10411059   
    10421060    marshalValue(exec, value, resultData, resultLength);
    1043     exec->clearException();
     1061    scope.clearException();
    10441062    return true;
    10451063}
     
    10591077    if (!frame)
    10601078        return false;
    1061    
     1079
     1080    VM& vm = pluginWorld().vm();
     1081    JSLockHolder lock(vm);
     1082    auto scope = DECLARE_CATCH_SCOPE(vm);
     1083
    10621084    ExecState* exec = frame->script().globalObject(pluginWorld())->globalExec();
    1063     JSLockHolder lock(exec);   
    10641085
    10651086    JSValue value = demarshalValue(exec, valueData, valueLength);
     
    10671088    object->methodTable()->put(object, exec, propertyName, value, slot);
    10681089   
    1069     exec->clearException();
     1090    scope.clearException();
    10701091    return true;
    10711092}
     
    10851106    if (!frame)
    10861107        return false;
    1087    
     1108
     1109    VM& vm = pluginWorld().vm();
     1110    JSLockHolder lock(vm);
     1111    auto scope = DECLARE_CATCH_SCOPE(vm);
     1112
    10881113    ExecState* exec = frame->script().globalObject(pluginWorld())->globalExec();
    1089     JSLockHolder lock(exec);   
    10901114   
    10911115    JSValue value = demarshalValue(exec, valueData, valueLength);
    10921116    object->methodTable()->putByIndex(object, exec, propertyName, value, false);
    10931117   
    1094     exec->clearException();
     1118    scope.clearException();
    10951119    return true;
    10961120}
     
    11111135        return false;
    11121136
     1137    VM& vm = pluginWorld().vm();
     1138    JSLockHolder lock(vm);
     1139    auto scope = DECLARE_CATCH_SCOPE(vm);
     1140
    11131141    ExecState* exec = frame->script().globalObject(pluginWorld())->globalExec();
    1114     JSLockHolder lock(exec);
    11151142    if (!object->hasProperty(exec, propertyName)) {
    1116         exec->clearException();
     1143        scope.clearException();
    11171144        return false;
    11181145    }
    11191146   
    11201147    object->methodTable()->deleteProperty(object, exec, propertyName);
    1121     exec->clearException();   
     1148    scope.clearException();
    11221149    return true;
    11231150}
     
    11371164    if (!frame)
    11381165        return false;
    1139    
     1166
     1167    VM& vm = pluginWorld().vm();
     1168    JSLockHolder lock(vm);
     1169    auto scope = DECLARE_CATCH_SCOPE(vm);
     1170
    11401171    ExecState* exec = frame->script().globalObject(pluginWorld())->globalExec();
    1141     JSLockHolder lock(exec);
    11421172    if (!object->hasProperty(exec, propertyName)) {
    1143         exec->clearException();
     1173        scope.clearException();
    11441174        return false;
    11451175    }
    11461176   
    11471177    object->methodTable()->deletePropertyByIndex(object, exec, propertyName);
    1148     exec->clearException();   
     1178    scope.clearException();
    11491179    return true;
    11501180}
     
    11641194    if (!frame)
    11651195        return false;
    1166    
     1196
     1197    VM& vm = pluginWorld().vm();
     1198    JSLockHolder lock(vm);
     1199    auto scope = DECLARE_CATCH_SCOPE(vm);
     1200
    11671201    ExecState* exec = frame->script().globalObject(pluginWorld())->globalExec();
    11681202    bool result = object->hasProperty(exec, propertyName);
    1169     exec->clearException();
    1170    
     1203    scope.clearException();
     1204
    11711205    return result;
    11721206}
     
    11861220    if (!frame)
    11871221        return false;
    1188    
     1222
     1223    VM& vm = pluginWorld().vm();
     1224    JSLockHolder lock(vm);
     1225    auto scope = DECLARE_CATCH_SCOPE(vm);
     1226
    11891227    ExecState* exec = frame->script().globalObject(pluginWorld())->globalExec();
    11901228    bool result = object->hasProperty(exec, propertyName);
    1191     exec->clearException();
    1192    
     1229    scope.clearException();
     1230
    11931231    return result;
    11941232}
     
    12081246    if (!frame)
    12091247        return false;
    1210    
     1248
     1249    VM& vm = pluginWorld().vm();
     1250    JSLockHolder lock(vm);
     1251    auto scope = DECLARE_CATCH_SCOPE(vm);
     1252
    12111253    ExecState* exec = frame->script().globalObject(pluginWorld())->globalExec();
    1212     JSLockHolder lock(exec);
    12131254    JSValue func = object->get(exec, methodName);
    1214     exec->clearException();
     1255    scope.clearException();
    12151256    return !func.isUndefined();
    12161257}
     
    12301271    if (!frame)
    12311272        return false;
    1232    
     1273
     1274    VM& vm = pluginWorld().vm();
     1275    JSLockHolder lock(vm);
     1276    auto scope = DECLARE_CATCH_SCOPE(vm);
     1277
    12331278    ExecState* exec = frame->script().globalObject(pluginWorld())->globalExec();
    1234     JSLockHolder lock(exec);
    12351279 
    12361280    PropertyNameArray propertyNames(exec, PropertyNameMode::Strings);
     
    12521296    memcpy(resultData, [data bytes], resultLength);
    12531297
    1254     exec->clearException();
     1298    scope.clearException();
    12551299
    12561300    return true;
  • trunk/Source/WebKit/mac/WebView/WebView.mm

    r205365 r205569  
    69376937static NSAppleEventDescriptor* aeDescFromJSValue(ExecState* exec, JSC::JSValue jsValue)
    69386938{
     6939    VM& vm = exec->vm();
     6940    auto scope = DECLARE_CATCH_SCOPE(vm);
     6941
    69396942    NSAppleEventDescriptor* aeDesc = 0;
    69406943    if (jsValue.isBoolean())
     
    69776980        }
    69786981        JSC::JSValue primitive = object->toPrimitive(exec);
    6979         if (exec->hadException()) {
    6980             exec->clearException();
     6982        if (UNLIKELY(scope.exception())) {
     6983            scope.clearException();
    69816984            return [NSAppleEventDescriptor nullDescriptor];
    69826985        }
  • trunk/Source/WebKit/win/ChangeLog

    r205495 r205569  
     12016-09-07  Mark Lam  <mark.lam@apple.com>
     2
     3        Add CatchScope and force all exception checks to be via ThrowScope or CatchScope.
     4        https://bugs.webkit.org/show_bug.cgi?id=161498
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * Plugins/PluginPackage.cpp:
     9        (WebCore::NPN_Evaluate):
     10        (WebCore::NPN_Invoke):
     11
    1122016-09-06  Per Arne Vollan  <pvollan@apple.com>
    213
  • trunk/Source/WebKit/win/Plugins/PluginPackage.cpp

    r197614 r205569  
    211211        PluginView::keepAlive(instance);
    212212
    213         JSC::ExecState* exec = rootObject->globalObject()->globalExec();
    214         JSC::JSLockHolder lock(exec);
     213        auto globalObject = rootObject->globalObject();
     214        auto& vm = globalObject->vm();
     215        JSC::JSLockHolder lock(vm);
     216        auto scope = DECLARE_CATCH_SCOPE(vm);
     217
     218        JSC::ExecState* exec = globalObject->globalExec();
    215219        String scriptString = JSC::Bindings::convertNPStringToUTF16(s);
    216220
    217         JSC::JSValue returnValue = JSC::evaluate(rootObject->globalObject()->globalExec(), makeSource(scriptString), JSC::JSValue());
     221        JSC::JSValue returnValue = JSC::evaluate(exec, makeSource(scriptString), JSC::JSValue());
    218222
    219223        JSC::Bindings::convertValueToNPVariant(exec, returnValue, variant);
    220         exec->clearException();
     224        scope.clearException();
    221225        return true;
    222226    }
     
    248252        if (!rootObject || !rootObject->isValid())
    249253            return false;
    250         JSC::ExecState* exec = rootObject->globalObject()->globalExec();
    251         JSC::JSLockHolder lock(exec);
     254
     255        auto globalObject = rootObject->globalObject();
     256        auto& vm = globalObject->vm();
     257        JSC::JSLockHolder lock(vm);
     258        auto scope = DECLARE_CATCH_SCOPE(vm);
     259
     260        JSC::ExecState* exec = globalObject->globalExec();
    252261        JSC::JSValue function = obj->imp->get(exec, JSC::Bindings::identifierFromNPIdentifier(exec, i->string()));
    253262        JSC::CallData callData;
     
    263272        // Convert and return the result of the function call.
    264273        JSC::Bindings::convertValueToNPVariant(exec, resultV, result);
    265         exec->clearException();
     274        scope.clearException();
    266275        return true;
    267276    }
  • trunk/Source/WebKit2/ChangeLog

    r205561 r205569  
     12016-09-07  Mark Lam  <mark.lam@apple.com>
     2
     3        Add CatchScope and force all exception checks to be via ThrowScope or CatchScope.
     4        https://bugs.webkit.org/show_bug.cgi?id=161498
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * WebProcess/Plugins/Netscape/NPJSObject.cpp:
     9        (WebKit::NPJSObject::hasMethod):
     10        (WebKit::NPJSObject::hasProperty):
     11        (WebKit::NPJSObject::getProperty):
     12        (WebKit::NPJSObject::setProperty):
     13        (WebKit::NPJSObject::removeProperty):
     14        (WebKit::NPJSObject::construct):
     15        (WebKit::NPJSObject::invoke):
     16
    1172016-09-07  Konstantin Tokarev  <annulen@yandex.ru>
    218
  • trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.cpp

    r197614 r205569  
    102102        return false;
    103103
    104     JSLockHolder lock(exec);
     104    VM& vm = exec->vm();
     105    JSLockHolder lock(vm);
     106    auto scope = DECLARE_CATCH_SCOPE(vm);
    105107
    106108    JSValue value = m_jsObject->get(exec, identifierFromIdentifierRep(exec, identifierRep));   
    107     exec->clearException();
     109    scope.clearException();
    108110
    109111    CallData callData;
     
    148150        return false;
    149151   
    150     JSLockHolder lock(exec);
     152    VM& vm = exec->vm();
     153    JSLockHolder lock(vm);
     154    auto scope = DECLARE_CATCH_SCOPE(vm);
    151155
    152156    bool result;
     
    156160        result = m_jsObject->hasProperty(exec, identifierRep->number());
    157161
    158     exec->clearException();
     162    scope.clearException();
    159163    return result;
    160164}
     
    168172        return false;
    169173
    170     JSLockHolder lock(exec);
     174    VM& vm = exec->vm();
     175    JSLockHolder lock(vm);
     176    auto scope = DECLARE_CATCH_SCOPE(vm);
     177
    171178    JSValue jsResult;
    172179    if (identifierRep->isString())
     
    176183   
    177184    m_objectMap->convertJSValueToNPVariant(exec, jsResult, *result);
    178     exec->clearException();
     185    scope.clearException();
    179186    return true;
    180187}
     
    188195        return false;
    189196   
    190     JSLockHolder lock(exec);
     197    VM& vm = exec->vm();
     198    JSLockHolder lock(vm);
     199    auto scope = DECLARE_CATCH_SCOPE(vm);
    191200
    192201    JSValue jsValue = m_objectMap->convertNPVariantToJSValue(exec, m_objectMap->globalObject(), *value);
     
    196205    } else
    197206        m_jsObject->methodTable()->putByIndex(m_jsObject.get(), exec, identifierRep->number(), jsValue, false);
    198     exec->clearException();
     207    scope.clearException();
    199208   
    200209    return true;
     
    209218        return false;
    210219
    211     JSLockHolder lock(exec);
     220    VM& vm = exec->vm();
     221    JSLockHolder lock(vm);
     222    auto scope = DECLARE_CATCH_SCOPE(vm);
     223
    212224    if (identifierRep->isString()) {
    213225        Identifier identifier = identifierFromIdentifierRep(exec, identifierRep);
    214226       
    215227        if (!m_jsObject->hasProperty(exec, identifier)) {
    216             exec->clearException();
     228            scope.clearException();
    217229            return false;
    218230        }
     
    221233    } else {
    222234        if (!m_jsObject->hasProperty(exec, identifierRep->number())) {
    223             exec->clearException();
     235            scope.clearException();
    224236            return false;
    225237        }
     
    228240    }
    229241
    230     exec->clearException();
     242    scope.clearException();
    231243    return true;
    232244}
     
    260272        return false;
    261273
    262     JSLockHolder lock(exec);
     274    VM& vm = exec->vm();
     275    JSLockHolder lock(vm);
     276    auto scope = DECLARE_CATCH_SCOPE(vm);
    263277
    264278    ConstructData constructData;
     
    276290    // Convert and return the new object.
    277291    m_objectMap->convertJSValueToNPVariant(exec, value, *result);
    278     exec->clearException();
     292    scope.clearException();
    279293
    280294    return true;
     
    283297bool NPJSObject::invoke(ExecState* exec, JSGlobalObject* globalObject, JSValue function, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result)
    284298{
     299    VM& vm = exec->vm();
     300    auto scope = DECLARE_CATCH_SCOPE(vm);
     301
    285302    CallData callData;
    286303    CallType callType = getCallData(function, callData);
     
    297314    // Convert and return the result of the function call.
    298315    m_objectMap->convertJSValueToNPVariant(exec, value, *result);
    299     exec->clearException();
     316    scope.clearException();
    300317   
    301318    return true;
Note: See TracChangeset for help on using the changeset viewer.