Added RETURN_IF_EXCEPTION() macro and use it for exception checks.
https://bugs.webkit.org/show_bug.cgi?id=162521
Reviewed by Saam Barati.
Source/JavaScriptCore:
Also, where possible, if the return type is JSValue, changed the returned value
(on exception) to the empty JSValue (instead of sometimes jsUndefined, jsNull,
or the thrown exception value).
There are a few places where I had to continue to return the previously returned
value (instead of the empty JSValue) in order for tests to pass. This is needed
because there are missing exception checks that will need to be added before I
can change those to return the empty JSValue too. Identifying all the places
where those checks need to be added is beyond the scope of this patch. I will
work on adding missing exception checks in a subsequent patch.
In this patch, there is one missing exception check in replaceUsingRegExpSearch()
that was easily identified, and is necessary so that Interpreter::execute()
functions can return JSValue. I've added this missing check.
This patch has passed the JSC and layout tests.
* dfg/DFGOperations.cpp:
(JSC::DFG::operationPutByValInternal):
* inspector/JSInjectedScriptHost.cpp:
(Inspector::JSInjectedScriptHost::evaluateWithScopeExtension):
(Inspector::JSInjectedScriptHost::getInternalProperties):
(Inspector::JSInjectedScriptHost::weakMapEntries):
(Inspector::JSInjectedScriptHost::weakSetEntries):
(Inspector::JSInjectedScriptHost::iteratorEntries):
* inspector/JSJavaScriptCallFrame.cpp:
(Inspector::JSJavaScriptCallFrame::evaluateWithScopeExtension):
* interpreter/Interpreter.cpp:
(JSC::eval):
(JSC::sizeOfVarargs):
(JSC::Interpreter::execute):
(JSC::Interpreter::executeCall):
(JSC::Interpreter::executeConstruct):
* interpreter/ShadowChicken.cpp:
(JSC::ShadowChicken::functionsOnStack):
* jit/JITOperations.cpp:
(JSC::getByVal):
* jsc.cpp:
(WTF::ImpureGetter::getOwnPropertySlot):
(functionRun):
(functionRunString):
(functionLoad):
(functionLoadString):
(functionReadFile):
(functionCheckSyntax):
(functionSetRandomSeed):
(functionLoadModule):
(functionCreateBuiltin):
(functionCheckModuleSyntax):
* llint/LLIntSlowPaths.cpp:
(JSC::LLInt::getByVal):
(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::arrayProtoPrivateFuncConcatMemcpy):
* runtime/BooleanConstructor.cpp:
(JSC::constructWithBooleanConstructor):
* runtime/CommonSlowPaths.h:
(JSC::CommonSlowPaths::opIn):
* runtime/Completion.cpp:
(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/ExceptionScope.h:
* runtime/FunctionConstructor.cpp:
(JSC::constructFunctionSkippingEvalEnabledCheck):
* runtime/GenericArgumentsInlines.h:
(JSC::GenericArguments<Type>::copyToArguments):
* runtime/GetterSetter.cpp:
(JSC::callGetter):
* runtime/HashMapImpl.h:
(JSC::jsMapHash):
(JSC::HashMapImpl::finishCreation):
(JSC::HashMapImpl::findBucket):
(JSC::HashMapImpl::add):
(JSC::HashMapImpl::rehash):
* runtime/InspectorInstrumentationObject.cpp:
(JSC::inspectorInstrumentationObjectLog):
* runtime/InternalFunction.cpp:
(JSC::InternalFunction::createSubclassStructure):
* runtime/IntlCollator.cpp:
(JSC::IntlCollator::initializeCollator):
* runtime/IntlCollatorConstructor.cpp:
(JSC::constructIntlCollator):
(JSC::IntlCollatorConstructorFuncSupportedLocalesOf):
* runtime/IntlCollatorPrototype.cpp:
(JSC::IntlCollatorFuncCompare):
(JSC::IntlCollatorPrototypeGetterCompare):
* runtime/IntlDateTimeFormat.cpp:
(JSC::toDateTimeOptionsAnyDate):
(JSC::IntlDateTimeFormat::initializeDateTimeFormat):
* runtime/IntlDateTimeFormatConstructor.cpp:
(JSC::constructIntlDateTimeFormat):
(JSC::IntlDateTimeFormatConstructorFuncSupportedLocalesOf):
* runtime/IntlDateTimeFormatPrototype.cpp:
(JSC::IntlDateTimeFormatFuncFormatDateTime):
(JSC::IntlDateTimeFormatPrototypeGetterFormat):
* runtime/IntlNumberFormat.cpp:
(JSC::IntlNumberFormat::initializeNumberFormat):
* 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::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::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::genericTypedArrayViewProtoFuncSet):
(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/JSModuleRecord.cpp:
(JSC::JSModuleRecord::instantiateDeclarations):
* runtime/JSONObject.cpp:
(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::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/JSPromiseDeferred.cpp:
(JSC::JSPromiseDeferred::create):
* runtime/JSPropertyNameEnumerator.h:
(JSC::propertyNameEnumerator):
* runtime/JSPropertyNameIterator.cpp:
(JSC::JSPropertyNameIterator::create):
* runtime/JSScope.cpp:
(JSC::isUnscopable):
* runtime/JSString.cpp:
(JSC::JSString::equalSlowCase):
* runtime/JSStringJoiner.cpp:
(JSC::JSStringJoiner::join):
* runtime/LiteralParser.cpp:
(JSC::LiteralParser<CharType>::parse):
* runtime/MapBase.h:
(JSC::MapBase::finishCreation):
* 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/PropertyDescriptor.cpp:
(JSC::PropertyDescriptor::slowGetterSetter):
* runtime/ProxyConstructor.cpp:
(JSC::makeRevocableProxy):
* runtime/ProxyObject.cpp:
(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/WeakMapConstructor.cpp:
(JSC::constructWeakMap):
* runtime/WeakSetConstructor.cpp:
(JSC::constructWeakSet):
* tools/JSDollarVMPrototype.cpp:
(JSC::functionPrint):
Source/WebCore:
No new tests because this patch is mostly refactoring. The only change in
behavior is that functions that have a JSValue return type will now return the
empty JSValue when an exception is thrown. I tested this behavior by running
the existing JSC and layout tests.
* bindings/js/ArrayValue.cpp:
(WebCore::ArrayValue::get):
* 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::createHmacKeyParams):
(WebCore::createRsaKeyGenParams):
(WebCore::createRsaOaepParams):
* bindings/js/JSCryptoKeySerializationJWK.cpp:
(WebCore::getStringFromJSON):
(WebCore::JSCryptoKeySerializationJWK::reconcileUsages):
(WebCore::JSCryptoKeySerializationJWK::keyDataRSAComponents):
(WebCore::buildJSONForRSAComponents):
(WebCore::addUsagesToJSON):
(WebCore::JSCryptoKeySerializationJWK::serialize):
* bindings/js/JSCustomElementInterface.cpp:
(WebCore::constructCustomElementSynchronously):
(WebCore::JSCustomElementInterface::upgradeElement):
* bindings/js/JSCustomElementRegistryCustom.cpp:
(WebCore::getCustomElementCallback):
(WebCore::JSCustomElementRegistry::define):
(WebCore::whenDefinedPromise):
* bindings/js/JSDOMBinding.cpp:
(WebCore::valueToUSVString):
(WebCore::hasIteratorMethod):
(WebCore::toSmallerInt):
(WebCore::toSmallerUInt):
(WebCore::toInt32EnforceRange):
(WebCore::toUInt32EnforceRange):
(WebCore::toInt64EnforceRange):
(WebCore::toUInt64EnforceRange):
* bindings/js/JSDOMBinding.h:
(WebCore::toJSSequence):
(WebCore::toJS):
(WebCore::jsFrozenArray):
* bindings/js/JSDOMPromise.cpp:
(WebCore::rejectPromiseWithExceptionIfAny):
* bindings/js/JSDOMStringMapCustom.cpp:
(WebCore::JSDOMStringMap::putDelegate):
* 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/JSFileCustom.cpp:
(WebCore::constructJSFile):
* bindings/js/JSGeolocationCustom.cpp:
(WebCore::JSGeolocation::getCurrentPosition):
(WebCore::JSGeolocation::watchPosition):
* bindings/js/JSHTMLAllCollectionCustom.cpp:
(WebCore::callHTMLAllCollection):
* bindings/js/JSHTMLCanvasElementCustom.cpp:
(WebCore::JSHTMLCanvasElement::getContext):
* 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/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):
* 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::cryptoKeyFormatFromJSValue):
(WebCore::cryptoKeyUsagesFromJSValue):
(WebCore::JSWebKitSubtleCrypto::generateKey):
(WebCore::importKey):
(WebCore::JSWebKitSubtleCrypto::importKey):
(WebCore::exportKey):
(WebCore::JSWebKitSubtleCrypto::exportKey):
(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):
* bindings/js/ScheduledAction.cpp:
(WebCore::ScheduledAction::create):
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateDictionaryImplementationContent):
(GenerateImplementation):
(GenerateParametersCheck):
(GenerateImplementationFunctionCall):
(GenerateConstructorDefinition):
* html/HTMLMediaElement.cpp:
(WebCore::controllerJSValue):
(WebCore::HTMLMediaElement::updateMediaControlsAfterPresentationModeChange):
(WebCore::HTMLMediaElement::getCurrentMediaControlsStatus):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@206386 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/runtime/ArrayPrototype.cpp b/Source/JavaScriptCore/runtime/ArrayPrototype.cpp
index 7bc14f0..ec6542d 100644
--- a/Source/JavaScriptCore/runtime/ArrayPrototype.cpp
+++ b/Source/JavaScriptCore/runtime/ArrayPrototype.cpp
@@ -199,6 +199,10 @@
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
+ auto exceptionResult = [] () {
+ return std::make_pair(SpeciesConstructResult::Exception, nullptr);
+ };
+
// ECMA 9.4.2.3: https://tc39.github.io/ecma262/#sec-arrayspeciescreate
JSValue constructor = jsUndefined();
if (LIKELY(isArray(exec, thisObject))) {
@@ -208,8 +212,7 @@
return std::make_pair(SpeciesConstructResult::FastPath, nullptr);
constructor = thisObject->get(exec, exec->propertyNames().constructor);
- if (UNLIKELY(scope.exception()))
- return std::make_pair(SpeciesConstructResult::Exception, nullptr);
+ RETURN_IF_EXCEPTION(scope, exceptionResult());
if (constructor.isConstructor()) {
JSObject* constructorObject = jsCast<JSObject*>(constructor);
if (exec->lexicalGlobalObject() != constructorObject->globalObject())
@@ -217,13 +220,12 @@
}
if (constructor.isObject()) {
constructor = constructor.get(exec, exec->propertyNames().speciesSymbol);
- if (UNLIKELY(scope.exception()))
- return std::make_pair(SpeciesConstructResult::Exception, nullptr);
+ RETURN_IF_EXCEPTION(scope, exceptionResult());
if (constructor.isNull())
return std::make_pair(SpeciesConstructResult::FastPath, nullptr);;
}
- } else if (UNLIKELY(scope.exception()))
- return std::make_pair(SpeciesConstructResult::Exception, nullptr);
+ } else
+ RETURN_IF_EXCEPTION(scope, exceptionResult());
if (constructor.isUndefined())
return std::make_pair(SpeciesConstructResult::FastPath, nullptr);
@@ -231,8 +233,7 @@
MarkedArgumentBuffer args;
args.append(jsNumber(length));
JSObject* newObject = construct(exec, constructor, args, "Species construction did not get a valid constructor");
- if (UNLIKELY(scope.exception()))
- return std::make_pair(SpeciesConstructResult::Exception, nullptr);
+ RETURN_IF_EXCEPTION(scope, exceptionResult());
return std::make_pair(SpeciesConstructResult::CreatedObject, newObject);
}
@@ -287,11 +288,9 @@
unsigned from = k + currentCount;
unsigned to = k + resultCount;
if (JSValue value = getProperty(exec, thisObj, from)) {
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
thisObj->putByIndexInline(exec, to, value, true);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
} else if (!thisObj->methodTable(vm)->deletePropertyByIndex(thisObj, exec, to)) {
throwTypeError(exec, scope, ASCIILiteral("Unable to delete property."));
return;
@@ -333,15 +332,13 @@
unsigned from = k + currentCount - 1;
unsigned to = k + resultCount - 1;
if (JSValue value = getProperty(exec, thisObj, from)) {
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
thisObj->putByIndexInline(exec, to, value, true);
} else if (!thisObj->methodTable(vm)->deletePropertyByIndex(thisObj, exec, to)) {
throwTypeError(exec, scope, ASCIILiteral("Unable to delete property."));
return;
}
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
}
}
@@ -353,13 +350,11 @@
// 1. Let array be the result of calling ToObject on the this value.
JSObject* thisObject = thisValue.toObject(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
// 2. Let func be the result of calling the [[Get]] internal method of array with argument "join".
JSValue function = JSValue(thisObject).get(exec, exec->propertyNames().join);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
// 3. If IsCallable(func) is false, then let func be the standard built-in method Object.prototype.toString (15.2.4.2).
bool customJoinCase = false;
@@ -387,19 +382,16 @@
return JSValue::encode(earlyReturnValue);
JSStringJoiner joiner(*exec, ',', length);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
for (unsigned i = 0; i < length; ++i) {
JSValue element = thisArray->tryGetIndexQuickly(i);
if (!element) {
element = thisArray->get(exec, i);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
joiner.append(*exec, element);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
return JSValue::encode(joiner.join(*exec));
@@ -412,65 +404,54 @@
JSValue thisValue = exec->thisValue().toThis(exec, StrictMode);
JSObject* thisObject = thisValue.toObject(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
unsigned length = getLength(exec, thisObject);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
StringRecursionChecker checker(exec, thisObject);
if (JSValue earlyReturnValue = checker.earlyReturnValue())
return JSValue::encode(earlyReturnValue);
JSStringJoiner stringJoiner(*exec, ',', length);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
#if ENABLE(INTL)
ArgList arguments(exec);
for (unsigned i = 0; i < length; ++i) {
JSValue element = thisObject->getIndex(exec, i);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (element.isUndefinedOrNull())
element = jsEmptyString(exec);
else {
JSValue conversionFunction = element.get(exec, exec->propertyNames().toLocaleString);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
CallData callData;
CallType callType = getCallData(conversionFunction, callData);
if (callType != CallType::None) {
element = call(exec, conversionFunction, callType, callData, element, arguments);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
}
stringJoiner.append(*exec, element);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
#else // !ENABLE(INTL)
for (unsigned i = 0; i < length; ++i) {
JSValue element = thisObject->getIndex(exec, i);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (element.isUndefinedOrNull())
continue;
JSValue conversionFunction = element.get(exec, exec->propertyNames().toLocaleString);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
CallData callData;
CallType callType = getCallData(conversionFunction, callData);
if (callType != CallType::None) {
element = call(exec, conversionFunction, callType, callData, element, exec->emptyList());
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
stringJoiner.append(*exec, element);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
#endif // !ENABLE(INTL)
@@ -513,8 +494,7 @@
// 6. Let element0 be Get(O, "0").
JSValue element0 = thisObject->getIndex(&exec, 0);
- if (UNLIKELY(scope.exception()))
- return JSValue();
+ RETURN_IF_EXCEPTION(scope, JSValue());
// 7. If element0 is undefined or null, let R be the empty String; otherwise, let R be ? ToString(element0).
JSString* r = nullptr;
@@ -522,8 +502,7 @@
r = jsEmptyString(&exec);
else
r = element0.toString(&exec);
- if (UNLIKELY(scope.exception()))
- return JSValue();
+ RETURN_IF_EXCEPTION(scope, JSValue());
// 8. Let k be 1.
// 9. Repeat, while k < len
@@ -531,8 +510,7 @@
for (uint64_t k = 1; k < length; ++k) {
// b. Let element be ? Get(O, ! ToString(k)).
JSValue element = thisObject->get(&exec, Identifier::fromString(&exec, AtomicString::number(k)));
- if (UNLIKELY(scope.exception()))
- return JSValue();
+ RETURN_IF_EXCEPTION(scope, JSValue());
// c. If element is undefined or null, let next be the empty String; otherwise, let next be ? ToString(element).
JSString* next = nullptr;
@@ -542,14 +520,12 @@
next = jsEmptyString(&exec);
} else
next = element.toString(&exec);
- if (UNLIKELY(scope.exception()))
- return JSValue();
+ RETURN_IF_EXCEPTION(scope, JSValue());
// a. Let S be the String value produced by concatenating R and sep.
// d. Let R be a String value produced by concatenating S and next.
r = jsString(&exec, r, separator, next);
- if (UNLIKELY(scope.exception()))
- return JSValue();
+ RETURN_IF_EXCEPTION(scope, JSValue());
}
// 10. Return R.
return r;
@@ -580,8 +556,7 @@
if (length > butterfly.publicLength())
break;
JSStringJoiner joiner(state, separator, length);
- if (UNLIKELY(scope.exception()))
- return jsUndefined();
+ RETURN_IF_EXCEPTION(scope, JSValue());
auto data = butterfly.contiguous().data();
bool holesKnownToBeOK = false;
for (unsigned i = 0; i < length; ++i) {
@@ -604,8 +579,7 @@
if (length > butterfly.publicLength())
break;
JSStringJoiner joiner(state, separator, length);
- if (UNLIKELY(scope.exception()))
- return jsUndefined();
+ RETURN_IF_EXCEPTION(scope, JSValue());
auto data = butterfly.contiguousDouble().data();
bool holesKnownToBeOK = false;
for (unsigned i = 0; i < length; ++i) {
@@ -627,15 +601,12 @@
generalCase:
JSStringJoiner joiner(state, separator, length);
- if (UNLIKELY(scope.exception()))
- return jsUndefined();
+ RETURN_IF_EXCEPTION(scope, JSValue());
for (unsigned i = 0; i < length; ++i) {
JSValue element = thisObject->getIndex(&state, i);
- if (UNLIKELY(scope.exception()))
- return jsUndefined();
+ RETURN_IF_EXCEPTION(scope, JSValue());
joiner.append(state, element);
- if (UNLIKELY(scope.exception()))
- return jsUndefined();
+ RETURN_IF_EXCEPTION(scope, JSValue());
}
return joiner.join(state);
}
@@ -656,8 +627,7 @@
// 2. Let len be ? ToLength(? Get(O, "length")).
double length = toLength(exec, thisObject);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
// 3. If separator is undefined, let separator be the single-element String ",".
JSValue separatorValue = exec->argument(0);
@@ -668,8 +638,7 @@
uint64_t length64 = static_cast<uint64_t>(length);
ASSERT(static_cast<double>(length64) == length);
JSString* jsSeparator = jsSingleCharacterString(exec, comma);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(slowJoin(*exec, thisObject, jsSeparator, length64));
}
@@ -681,8 +650,7 @@
// 4. Let sep be ? ToString(separator).
JSString* jsSeparator = separatorValue.toString(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (UNLIKELY(length > std::numeric_limits<unsigned>::max() || !canUseFastJoin(thisObject))) {
uint64_t length64 = static_cast<uint64_t>(length);
@@ -707,8 +675,7 @@
if (!thisObj)
return JSValue::encode(JSValue());
unsigned length = getLength(exec, thisObj);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSValue result;
if (length == 0) {
@@ -716,8 +683,7 @@
result = jsUndefined();
} else {
result = thisObj->get(exec, length - 1);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (!thisObj->methodTable(vm)->deletePropertyByIndex(thisObj, exec, length - 1)) {
throwTypeError(exec, scope, ASCIILiteral("Unable to delete property."));
return JSValue::encode(jsUndefined());
@@ -743,8 +709,7 @@
if (!thisObj)
return JSValue::encode(JSValue());
unsigned length = getLength(exec, thisObj);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
for (unsigned n = 0; n < exec->argumentCount(); n++) {
// Check for integer overflow; where safe we can do a fast put by index.
@@ -755,8 +720,7 @@
Identifier propertyName = Identifier::fromString(exec, JSValue(static_cast<int64_t>(length) + static_cast<int64_t>(n)).toWTFString(exec));
thisObj->methodTable()->put(thisObj, exec, propertyName, exec->uncheckedArgument(n), slot);
}
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
JSValue newLength(static_cast<int64_t>(length) + static_cast<int64_t>(exec->argumentCount()));
@@ -774,8 +738,7 @@
return JSValue::encode(JSValue());
unsigned length = getLength(exec, thisObject);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
switch (thisObject->indexingType()) {
case ALL_CONTIGUOUS_INDEXING_TYPES:
@@ -815,29 +778,24 @@
for (unsigned lower = 0; lower < middle; lower++) {
unsigned upper = length - lower - 1;
bool lowerExists = thisObject->hasProperty(exec, lower);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSValue lowerValue;
if (lowerExists) {
lowerValue = thisObject->get(exec, lower);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
bool upperExists = thisObject->hasProperty(exec, upper);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSValue upperValue;
if (upperExists) {
upperValue = thisObject->get(exec, upper);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
if (upperExists) {
thisObject->putByIndexInline(exec, lower, upperValue, true);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
} else if (!thisObject->methodTable(vm)->deletePropertyByIndex(thisObject, exec, lower)) {
if (!scope.exception())
throwTypeError(exec, scope, ASCIILiteral("Unable to delete property."));
@@ -846,8 +804,7 @@
if (lowerExists) {
thisObject->putByIndexInline(exec, upper, lowerValue, true);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
} else if (!thisObject->methodTable(vm)->deletePropertyByIndex(thisObject, exec, upper)) {
if (!scope.exception())
throwTypeError(exec, scope, ASCIILiteral("Unable to delete property."));
@@ -865,8 +822,7 @@
if (!thisObj)
return JSValue::encode(JSValue());
unsigned length = getLength(exec, thisObj);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSValue result;
if (length == 0) {
@@ -875,8 +831,7 @@
} else {
result = thisObj->getIndex(exec, 0);
shift<JSArray::ShiftCountForShift>(exec, thisObj, 0, 1, 0, length);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
putLength(exec, thisObj, jsNumber(length - 1));
}
return JSValue::encode(result);
@@ -891,8 +846,7 @@
if (!thisObj)
return JSValue::encode(JSValue());
unsigned length = getLength(exec, thisObj);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
unsigned begin = argumentClampedIndexFromStartOrEnd(exec, 0, length);
unsigned end = argumentClampedIndexFromStartOrEnd(exec, 1, length, length);
@@ -912,15 +866,13 @@
result = speciesResult.second;
else {
result = constructEmptyArray(exec, nullptr, end - begin);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
unsigned n = 0;
for (unsigned k = begin; k < end; k++, n++) {
JSValue v = getProperty(exec, thisObj, k);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (v)
result->putDirectIndex(exec, n, v);
}
@@ -939,8 +891,7 @@
if (!thisObj)
return JSValue::encode(JSValue());
unsigned length = getLength(exec, thisObj);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (!exec->argumentCount()) {
std::pair<SpeciesConstructResult, JSObject*> speciesResult = speciesConstructArray(exec, thisObj, 0);
@@ -952,8 +903,7 @@
result = speciesResult.second;
else {
result = constructEmptyArray(exec, nullptr);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
setLength(exec, result, 0);
@@ -988,13 +938,11 @@
for (unsigned k = 0; k < deleteCount; ++k) {
JSValue v = getProperty(exec, thisObj, k + begin);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (UNLIKELY(!v))
continue;
result->putByIndexInline(exec, k, v, true);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
} else {
result = JSArray::tryCreateUninitialized(vm, exec->lexicalGlobalObject()->arrayStructureForIndexingTypeDuringAllocation(ArrayWithUndecided), deleteCount);
@@ -1003,8 +951,7 @@
for (unsigned k = 0; k < deleteCount; ++k) {
JSValue v = getProperty(exec, thisObj, k + begin);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (UNLIKELY(!v))
continue;
result->initializeIndex(vm, k, v);
@@ -1015,17 +962,14 @@
unsigned additionalArgs = std::max<int>(exec->argumentCount() - 2, 0);
if (additionalArgs < deleteCount) {
shift<JSArray::ShiftCountForSplice>(exec, thisObj, begin, deleteCount, additionalArgs, length);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
} else if (additionalArgs > deleteCount) {
unshift<JSArray::ShiftCountForSplice>(exec, thisObj, begin, deleteCount, additionalArgs, length);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
for (unsigned k = 0; k < additionalArgs; ++k) {
thisObj->putByIndexInline(exec, k + begin, exec->uncheckedArgument(k + 2), true);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
setLength(exec, thisObj, length - deleteCount + additionalArgs);
@@ -1042,19 +986,16 @@
if (!thisObj)
return JSValue::encode(JSValue());
unsigned length = getLength(exec, thisObj);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
unsigned nrArgs = exec->argumentCount();
if (nrArgs) {
unshift<JSArray::ShiftCountForShift>(exec, thisObj, 0, 0, nrArgs, length);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
for (unsigned k = 0; k < nrArgs; ++k) {
thisObj->putByIndexInline(exec, k, exec->uncheckedArgument(k), true);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
JSValue result = jsNumber(length + nrArgs);
putLength(exec, thisObj, result);
@@ -1071,21 +1012,18 @@
if (!thisObj)
return JSValue::encode(JSValue());
unsigned length = getLength(exec, thisObj);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
unsigned index = argumentClampedIndexFromStartOrEnd(exec, 1, length);
JSValue searchElement = exec->argument(0);
for (; index < length; ++index) {
JSValue e = getProperty(exec, thisObj, index);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (!e)
continue;
if (JSValue::strictEqual(exec, searchElement, e))
return JSValue::encode(jsNumber(index));
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
return JSValue::encode(jsNumber(-1));
@@ -1121,14 +1059,12 @@
do {
RELEASE_ASSERT(index < length);
JSValue e = getProperty(exec, thisObj, index);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (!e)
continue;
if (JSValue::strictEqual(exec, searchElement, e))
return JSValue::encode(jsNumber(index));
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
} while (index--);
return JSValue::encode(jsNumber(-1));
@@ -1143,19 +1079,16 @@
JSValue value = source->tryGetIndexQuickly(i);
if (value) {
target->putDirectIndex(exec, targetOffset + i, value);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
}
}
} else {
for (unsigned i = 0; i < sourceLength; ++i) {
JSValue value = getProperty(exec, source, i);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
if (value) {
target->putDirectIndex(exec, targetOffset + i, value);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
}
}
}
@@ -1228,8 +1161,7 @@
IndexingType type = firstArray->mergeIndexingTypeForCopying(secondType);
if (type == NonArray || !firstArray->canFastCopy(vm, secondArray) || firstArraySize + secondArraySize >= MIN_SPARSE_ARRAY_INDEX) {
JSArray* result = constructEmptyArray(exec, nullptr, firstArraySize + secondArraySize);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (!moveElements(exec, vm, result, 0, firstArray, firstArraySize)
|| !moveElements(exec, vm, result, firstArraySize, secondArray, secondArraySize)) {
diff --git a/Source/JavaScriptCore/runtime/BooleanConstructor.cpp b/Source/JavaScriptCore/runtime/BooleanConstructor.cpp
index 77ea77a..dffe9a9 100644
--- a/Source/JavaScriptCore/runtime/BooleanConstructor.cpp
+++ b/Source/JavaScriptCore/runtime/BooleanConstructor.cpp
@@ -52,8 +52,7 @@
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue boolean = jsBoolean(exec->argument(0).toBoolean(exec));
Structure* booleanStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), asInternalFunction(exec->callee())->globalObject()->booleanObjectStructure());
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
BooleanObject* obj = BooleanObject::create(vm, booleanStructure);
obj->setInternalValue(vm, boolean);
return JSValue::encode(obj);
diff --git a/Source/JavaScriptCore/runtime/CommonSlowPaths.h b/Source/JavaScriptCore/runtime/CommonSlowPaths.h
index c26a8c7..8ee5be3 100644
--- a/Source/JavaScriptCore/runtime/CommonSlowPaths.h
+++ b/Source/JavaScriptCore/runtime/CommonSlowPaths.h
@@ -87,8 +87,7 @@
return baseObj->hasProperty(exec, i);
auto property = propName.toPropertyKey(exec);
- if (scope.exception())
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
return baseObj->hasProperty(exec, property);
}
diff --git a/Source/JavaScriptCore/runtime/Completion.cpp b/Source/JavaScriptCore/runtime/Completion.cpp
index 8609c33..d0aea68 100644
--- a/Source/JavaScriptCore/runtime/Completion.cpp
+++ b/Source/JavaScriptCore/runtime/Completion.cpp
@@ -1,7 +1,7 @@
/*
* Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
* Copyright (C) 2001 Peter Kelly (pmk@post.com)
- * Copyright (C) 2003, 2007, 2013 Apple Inc.
+ * Copyright (C) 2003, 2007, 2013, 2016 Apple Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -193,8 +193,7 @@
// Insert the given source code to the ModuleLoader registry as the fetched registry entry.
globalObject->moduleLoader()->provide(exec, key, JSModuleLoader::Status::Fetch, source.view().toString());
- if (UNLIKELY(scope.exception()))
- return rejectPromise(exec, globalObject);
+ RETURN_IF_EXCEPTION(scope, rejectPromise(exec, globalObject));
return loadAndEvaluateModule(lock, exec, globalObject, key, jsUndefined(), initiator);
}
@@ -233,8 +232,7 @@
// Insert the given source code to the ModuleLoader registry as the fetched registry entry.
// FIXME: Introduce JSSourceCode object to wrap around this source.
globalObject->moduleLoader()->provide(exec, key, JSModuleLoader::Status::Fetch, source.view().toString());
- if (UNLIKELY(scope.exception()))
- return rejectPromise(exec, globalObject);
+ RETURN_IF_EXCEPTION(scope, rejectPromise(exec, globalObject));
return loadModule(lock, exec, globalObject, key, jsUndefined(), initiator);
}
diff --git a/Source/JavaScriptCore/runtime/ConsoleObject.cpp b/Source/JavaScriptCore/runtime/ConsoleObject.cpp
index a0fa2d9..30a9bbd 100644
--- a/Source/JavaScriptCore/runtime/ConsoleObject.cpp
+++ b/Source/JavaScriptCore/runtime/ConsoleObject.cpp
@@ -203,8 +203,7 @@
return JSValue::encode(jsUndefined());
bool condition = exec->argument(0).toBoolean(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (condition)
return JSValue::encode(jsUndefined());
@@ -240,8 +239,7 @@
}
const String& title(valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0)));
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
client->profile(exec, title);
return JSValue::encode(jsUndefined());
@@ -262,8 +260,7 @@
}
const String& title(valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0)));
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
client->profileEnd(exec, title);
return JSValue::encode(jsUndefined());
@@ -284,8 +281,7 @@
}
const String& title(valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0)));
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
client->takeHeapSnapshot(exec, title);
return JSValue::encode(jsUndefined());
@@ -311,8 +307,7 @@
title = ASCIILiteral("default");
else {
title = valueOrDefaultLabelString(exec, exec->argument(0));
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
client->time(exec, title);
@@ -332,8 +327,7 @@
title = ASCIILiteral("default");
else {
title = valueOrDefaultLabelString(exec, exec->argument(0));
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
client->timeEnd(exec, title);
diff --git a/Source/JavaScriptCore/runtime/DateConstructor.cpp b/Source/JavaScriptCore/runtime/DateConstructor.cpp
index 6444913..a4f3f84 100644
--- a/Source/JavaScriptCore/runtime/DateConstructor.cpp
+++ b/Source/JavaScriptCore/runtime/DateConstructor.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2008, 2011, 2016 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -168,8 +168,7 @@
value = millisecondsFromComponents(exec, args, WTF::LocalTime);
Structure* dateStructure = InternalFunction::createSubclassStructure(exec, newTarget, globalObject->dateStructure());
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
return DateInstance::create(vm, dateStructure, value);
}
@@ -206,8 +205,7 @@
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
String dateStr = exec->argument(0).toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(jsNumber(parseDate(vm, dateStr)));
}
diff --git a/Source/JavaScriptCore/runtime/DatePrototype.cpp b/Source/JavaScriptCore/runtime/DatePrototype.cpp
index 5ef4e72..24e4091 100644
--- a/Source/JavaScriptCore/runtime/DatePrototype.cpp
+++ b/Source/JavaScriptCore/runtime/DatePrototype.cpp
@@ -615,8 +615,7 @@
JSValue hintValue = exec->uncheckedArgument(0);
PreferredPrimitiveType type = toPreferredPrimitiveType(exec, hintValue);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (type == NoPreference)
type = PreferString;
@@ -1128,18 +1127,15 @@
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue thisValue = exec->thisValue();
JSObject* object = jsCast<JSObject*>(thisValue.toThis(exec, NotStrictMode));
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsNull());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSValue timeValue = object->toPrimitive(exec, PreferNumber);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsNull());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (timeValue.isNumber() && !(timeValue.isInt32() || std::isfinite(timeValue.asDouble())))
return JSValue::encode(jsNull());
JSValue toISOValue = object->get(exec, vm.propertyNames->toISOString);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsNull());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
CallData callData;
CallType callType = getCallData(toISOValue, callData);
@@ -1147,8 +1143,7 @@
return throwVMTypeError(exec, scope, ASCIILiteral("toISOString is not a function"));
JSValue result = call(exec, asObject(toISOValue), callType, callData, object, exec->emptyList());
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsNull());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (result.isObject())
return throwVMTypeError(exec, scope, ASCIILiteral("toISOString did not return a primitive value"));
return JSValue::encode(result);
diff --git a/Source/JavaScriptCore/runtime/ErrorConstructor.cpp b/Source/JavaScriptCore/runtime/ErrorConstructor.cpp
index d4edb04..1d0e233 100644
--- a/Source/JavaScriptCore/runtime/ErrorConstructor.cpp
+++ b/Source/JavaScriptCore/runtime/ErrorConstructor.cpp
@@ -54,8 +54,7 @@
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue message = exec->argumentCount() ? exec->argument(0) : jsUndefined();
Structure* errorStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), asInternalFunction(exec->callee())->globalObject()->errorStructure());
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(ErrorInstance::create(exec, errorStructure, message, nullptr, TypeNothing, false));
}
diff --git a/Source/JavaScriptCore/runtime/ErrorInstance.cpp b/Source/JavaScriptCore/runtime/ErrorInstance.cpp
index f94f13b..2ee40be 100644
--- a/Source/JavaScriptCore/runtime/ErrorInstance.cpp
+++ b/Source/JavaScriptCore/runtime/ErrorInstance.cpp
@@ -185,8 +185,7 @@
nameString = ASCIILiteral("Error");
else {
nameString = nameValue.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return String();
+ RETURN_IF_EXCEPTION(scope, String());
}
JSValue messageValue;
@@ -201,8 +200,7 @@
messageString = String();
else {
messageString = messageValue.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return String();
+ RETURN_IF_EXCEPTION(scope, String());
}
if (!nameString.length())
diff --git a/Source/JavaScriptCore/runtime/ErrorPrototype.cpp b/Source/JavaScriptCore/runtime/ErrorPrototype.cpp
index da0167d..d4a7f4e 100644
--- a/Source/JavaScriptCore/runtime/ErrorPrototype.cpp
+++ b/Source/JavaScriptCore/runtime/ErrorPrototype.cpp
@@ -85,8 +85,7 @@
// 3. Let name be the result of calling the [[Get]] internal method of O with argument "name".
JSValue name = thisObj->get(exec, exec->propertyNames().name);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
// 4. If name is undefined, then let name be "Error"; else let name be ToString(name).
String nameString;
@@ -94,14 +93,12 @@
nameString = ASCIILiteral("Error");
else {
nameString = name.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
// 5. Let msg be the result of calling the [[Get]] internal method of O with argument "message".
JSValue message = thisObj->get(exec, exec->propertyNames().message);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
// (sic)
// 6. If msg is undefined, then let msg be the empty String; else let msg be ToString(msg).
@@ -111,8 +108,7 @@
messageString = String();
else {
messageString = message.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
// 8. If name is the empty String, return msg.
diff --git a/Source/JavaScriptCore/runtime/ExceptionScope.h b/Source/JavaScriptCore/runtime/ExceptionScope.h
index 4adedc5..0fffb23 100644
--- a/Source/JavaScriptCore/runtime/ExceptionScope.h
+++ b/Source/JavaScriptCore/runtime/ExceptionScope.h
@@ -70,7 +70,12 @@
};
#endif // ENABLE(EXCEPTION_SCOPE_VERIFICATION)
-
+
+#define RETURN_IF_EXCEPTION(scope__, value__) do { \
+ if (UNLIKELY((scope__).exception())) \
+ return value__; \
+ } while (false)
+
} // namespace JSC
#endif // ExceptionScope_h
diff --git a/Source/JavaScriptCore/runtime/FunctionConstructor.cpp b/Source/JavaScriptCore/runtime/FunctionConstructor.cpp
index 3d57c90..a7311bf 100644
--- a/Source/JavaScriptCore/runtime/FunctionConstructor.cpp
+++ b/Source/JavaScriptCore/runtime/FunctionConstructor.cpp
@@ -126,8 +126,7 @@
}
Structure* subclassStructure = InternalFunction::createSubclassStructure(exec, newTarget, globalObject->functionStructure());
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
return JSFunction::create(vm, function, globalObject->globalScope(), subclassStructure);
}
diff --git a/Source/JavaScriptCore/runtime/GenericArgumentsInlines.h b/Source/JavaScriptCore/runtime/GenericArgumentsInlines.h
index 68898a9..bc21b12 100644
--- a/Source/JavaScriptCore/runtime/GenericArgumentsInlines.h
+++ b/Source/JavaScriptCore/runtime/GenericArgumentsInlines.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -228,8 +228,7 @@
exec->r(firstElementDest + i) = thisObject->getIndexQuickly(i + offset);
else {
exec->r(firstElementDest + i) = get(exec, i + offset);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
}
}
}
diff --git a/Source/JavaScriptCore/runtime/GetterSetter.cpp b/Source/JavaScriptCore/runtime/GetterSetter.cpp
index 4302bfc..d93aeba 100644
--- a/Source/JavaScriptCore/runtime/GetterSetter.cpp
+++ b/Source/JavaScriptCore/runtime/GetterSetter.cpp
@@ -77,8 +77,7 @@
auto scope = DECLARE_THROW_SCOPE(vm);
// FIXME: Some callers may invoke get() without checking for an exception first.
// We work around that by checking here.
- if (UNLIKELY(scope.exception()))
- return scope.exception()->value();
+ RETURN_IF_EXCEPTION(scope, scope.exception()->value());
JSObject* getter = jsCast<GetterSetter*>(getterSetter)->getter();
diff --git a/Source/JavaScriptCore/runtime/HashMapImpl.h b/Source/JavaScriptCore/runtime/HashMapImpl.h
index 7bc703f..3a9d2d7 100644
--- a/Source/JavaScriptCore/runtime/HashMapImpl.h
+++ b/Source/JavaScriptCore/runtime/HashMapImpl.h
@@ -245,8 +245,7 @@
if (value.isString()) {
JSString* string = asString(value);
const String& wtfString = string->value(exec);
- if (UNLIKELY(scope.exception()))
- return UINT_MAX;
+ RETURN_IF_EXCEPTION(scope, UINT_MAX);
return wtfString.impl()->hash();
}
@@ -337,8 +336,7 @@
Base::finishCreation(vm);
makeAndSetNewBuffer(exec, vm);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
m_head.set(vm, this, HashMapBucketType::create(vm));
m_tail.set(vm, this, HashMapBucketType::create(vm));
@@ -376,8 +374,7 @@
auto scope = DECLARE_THROW_SCOPE(vm);
key = normalizeMapKey(key);
uint32_t hash = jsMapHash(exec, vm, key);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
return findBucket(exec, key, hash);
}
@@ -408,8 +405,7 @@
const uint32_t mask = m_capacity - 1;
uint32_t index = jsMapHash(exec, vm, key) & mask;
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
HashMapBucketType** buffer = this->buffer();
HashMapBucketType* bucket = buffer[index];
while (!isEmpty(bucket)) {
@@ -570,8 +566,7 @@
if (m_capacity != oldCapacity) {
makeAndSetNewBuffer(exec, vm);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
} else {
m_buffer.get()->reset(m_capacity);
assertBufferIsEmpty();
diff --git a/Source/JavaScriptCore/runtime/InspectorInstrumentationObject.cpp b/Source/JavaScriptCore/runtime/InspectorInstrumentationObject.cpp
index d7cf03f..dc797ca 100644
--- a/Source/JavaScriptCore/runtime/InspectorInstrumentationObject.cpp
+++ b/Source/JavaScriptCore/runtime/InspectorInstrumentationObject.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -87,8 +87,7 @@
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue target = exec->argument(0);
String value = target.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
dataLog(value, "\n");
return JSValue::encode(jsUndefined());
}
diff --git a/Source/JavaScriptCore/runtime/InternalFunction.cpp b/Source/JavaScriptCore/runtime/InternalFunction.cpp
index 33716db..af50f98 100644
--- a/Source/JavaScriptCore/runtime/InternalFunction.cpp
+++ b/Source/JavaScriptCore/runtime/InternalFunction.cpp
@@ -1,7 +1,7 @@
/*
* Copyright (C) 1999-2002 Harri Porten (porten@kde.org)
* Copyright (C) 2001 Peter Kelly (pmk@post.com)
- * Copyright (C) 2004, 2007, 2008, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2007-2008, 2016 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -113,14 +113,12 @@
// Note, Reflect.construct might cause the profile to churn but we don't care.
JSValue prototypeValue = newTarget.get(exec, exec->propertyNames().prototype);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
if (JSObject* prototype = jsDynamicCast<JSObject*>(prototypeValue))
return targetFunction->rareData(vm)->createInternalFunctionAllocationStructureFromBase(vm, prototype, baseClass);
} else {
JSValue prototypeValue = newTarget.get(exec, exec->propertyNames().prototype);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
if (JSObject* prototype = jsDynamicCast<JSObject*>(prototypeValue)) {
// This only happens if someone Reflect.constructs our builtin constructor with another builtin constructor as the new.target.
// Thus, we don't care about the cost of looking up the structure from our hash table every time.
diff --git a/Source/JavaScriptCore/runtime/IntlCollator.cpp b/Source/JavaScriptCore/runtime/IntlCollator.cpp
index bcde000..943337e 100644
--- a/Source/JavaScriptCore/runtime/IntlCollator.cpp
+++ b/Source/JavaScriptCore/runtime/IntlCollator.cpp
@@ -172,8 +172,7 @@
// 3. Let requestedLocales be CanonicalizeLocaleList(locales).
auto requestedLocales = canonicalizeLocaleList(state, locales);
// 4. ReturnIfAbrupt(requestedLocales).
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
// 5. If options is undefined, then
JSObject* options;
@@ -184,15 +183,13 @@
// a. Let options be ToObject(options).
options = optionsValue.toObject(&state);
// b. ReturnIfAbrupt(options).
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
}
// 7. Let u be GetOption(options, "usage", "string", «"sort", "search"», "sort").
String usageString = intlStringOption(state, options, vm.propertyNames->usage, { "sort", "search" }, "usage must be either \"sort\" or \"search\"", "sort");
// 8. ReturnIfAbrupt(u).
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
// 9. Set collator.[[usage]] to u.
if (usageString == "sort")
m_usage = Usage::Sort;
@@ -217,8 +214,7 @@
// 13. Let matcher be GetOption(options, "localeMatcher", "string", «"lookup", "best fit"», "best fit").
String matcher = intlStringOption(state, options, vm.propertyNames->localeMatcher, { "lookup", "best fit" }, "localeMatcher must be either \"lookup\" or \"best fit\"", "best fit");
// 14. ReturnIfAbrupt(matcher).
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
// 15. Set opt.[[localeMatcher]] to matcher.
opt.add(ASCIILiteral("localeMatcher"), matcher);
@@ -237,16 +233,14 @@
String numericString;
bool usesFallback;
bool numeric = intlBooleanOption(state, options, vm.propertyNames->numeric, usesFallback);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
if (!usesFallback)
numericString = ASCIILiteral(numeric ? "true" : "false");
opt.add(ASCIILiteral("kn"), numericString);
}
{
String caseFirst = intlStringOption(state, options, vm.propertyNames->caseFirst, { "upper", "lower", "false" }, "caseFirst must be either \"upper\", \"lower\", or \"false\"", nullptr);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
opt.add(ASCIILiteral("kf"), caseFirst);
}
@@ -286,8 +280,7 @@
// 24. Let s be GetOption(options, "sensitivity", "string", «"base", "accent", "case", "variant"», undefined).
String sensitivityString = intlStringOption(state, options, vm.propertyNames->sensitivity, { "base", "accent", "case", "variant" }, "sensitivity must be either \"base\", \"accent\", \"case\", or \"variant\"", nullptr);
// 25. ReturnIfAbrupt(s).
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
// 26. If s is undefined, then
// a. If u is "sort", then let s be "variant".
// b. Else
@@ -311,8 +304,7 @@
if (usesFallback)
ignorePunctuation = false;
// 29. ReturnIfAbrupt(ip).
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
// 30. Set collator.[[ignorePunctuation]] to ip.
m_ignorePunctuation = ignorePunctuation;
diff --git a/Source/JavaScriptCore/runtime/IntlCollatorConstructor.cpp b/Source/JavaScriptCore/runtime/IntlCollatorConstructor.cpp
index 8df42f5..b3b5bdf 100644
--- a/Source/JavaScriptCore/runtime/IntlCollatorConstructor.cpp
+++ b/Source/JavaScriptCore/runtime/IntlCollatorConstructor.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2015 Andy VanWagoner (thetalecrafter@gmail.com)
* Copyright (C) 2015 Sukolsak Sakshuwong (sukolsak@gmail.com)
+ * Copyright (C) 2016 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -90,8 +91,7 @@
// 2. Let collator be OrdinaryCreateFromConstructor(newTarget, %CollatorPrototype%).
// 3. ReturnIfAbrupt(collator).
Structure* structure = InternalFunction::createSubclassStructure(state, state->newTarget(), jsCast<IntlCollatorConstructor*>(state->callee())->collatorStructure());
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
IntlCollator* collator = IntlCollator::create(vm, structure);
ASSERT(collator);
@@ -144,8 +144,7 @@
Vector<String> requestedLocales = canonicalizeLocaleList(*state, state->argument(0));
// 2. ReturnIfAbrupt(requestedLocales).
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
// 3. Return SupportedLocales(%Collator%.[[availableLocales]], requestedLocales, options).
JSGlobalObject* globalObject = state->callee()->globalObject();
diff --git a/Source/JavaScriptCore/runtime/IntlCollatorPrototype.cpp b/Source/JavaScriptCore/runtime/IntlCollatorPrototype.cpp
index 058e73a..ff82568 100644
--- a/Source/JavaScriptCore/runtime/IntlCollatorPrototype.cpp
+++ b/Source/JavaScriptCore/runtime/IntlCollatorPrototype.cpp
@@ -90,14 +90,12 @@
// 5. Let X be ToString(x).
JSString* x = state->argument(0).toString(state);
// 6. ReturnIfAbrupt(X).
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
// 7. Let Y be ToString(y).
JSString* y = state->argument(1).toString(state);
// 8. ReturnIfAbrupt(Y).
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
// 9. Return CompareStrings(collator, X, Y).
return JSValue::encode(collator->compareStrings(*state, x->view(state).get(), y->view(state).get()));
@@ -124,8 +122,7 @@
// c. Let bc be BoundFunctionCreate(F, «this value»).
boundCompare = JSBoundFunction::create(vm, state, globalObject, targetObject, collator, nullptr, 2, ASCIILiteral("compare"));
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
// d. Set collator.[[boundCompare]] to bc.
collator->setBoundCompare(vm, boundCompare);
}
diff --git a/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp b/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp
index 8204224..648f25c 100644
--- a/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp
+++ b/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp
@@ -225,8 +225,7 @@
options = constructEmptyObject(&exec, exec.lexicalGlobalObject()->nullPrototypeObjectStructure());
else {
JSObject* originalToObject = originalOptions.toObject(&exec);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
options = constructEmptyObject(&exec, originalToObject);
}
@@ -242,26 +241,22 @@
// iii. ReturnIfAbrupt(value).
// iv. If value is not undefined, then let needDefaults be false.
JSValue weekday = options->get(&exec, vm.propertyNames->weekday);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
if (!weekday.isUndefined())
needDefaults = false;
JSValue year = options->get(&exec, vm.propertyNames->year);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
if (!year.isUndefined())
needDefaults = false;
JSValue month = options->get(&exec, vm.propertyNames->month);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
if (!month.isUndefined())
needDefaults = false;
JSValue day = options->get(&exec, vm.propertyNames->day);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
if (!day.isUndefined())
needDefaults = false;
@@ -274,20 +269,17 @@
// iii. ReturnIfAbrupt(value).
// iv. If value is not undefined, then let needDefaults be false.
JSValue hour = options->get(&exec, vm.propertyNames->hour);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
if (!hour.isUndefined())
needDefaults = false;
JSValue minute = options->get(&exec, vm.propertyNames->minute);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
if (!minute.isUndefined())
needDefaults = false;
JSValue second = options->get(&exec, vm.propertyNames->second);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
if (!second.isUndefined())
needDefaults = false;
@@ -300,16 +292,13 @@
JSString* numeric = jsNontrivialString(&exec, ASCIILiteral("numeric"));
options->putDirect(vm, vm.propertyNames->year, numeric);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
options->putDirect(vm, vm.propertyNames->month, numeric);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
options->putDirect(vm, vm.propertyNames->day, numeric);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
}
// 8. If needDefaults is true and defaults is either "time" or "all", then
@@ -429,14 +418,12 @@
// 3. Let requestedLocales be CanonicalizeLocaleList(locales).
Vector<String> requestedLocales = canonicalizeLocaleList(exec, locales);
// 4. ReturnIfAbrupt(requestedLocales),
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
// 5. Let options be ToDateTimeOptions(options, "any", "date").
JSObject* options = toDateTimeOptionsAnyDate(exec, originalOptions);
// 6. ReturnIfAbrupt(options).
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
// 7. Let opt be a new Record.
HashMap<String, String> localeOpt;
@@ -444,8 +431,7 @@
// 8. Let matcher be GetOption(options, "localeMatcher", "string", «"lookup", "best fit"», "best fit").
String localeMatcher = intlStringOption(exec, options, vm.propertyNames->localeMatcher, { "lookup", "best fit" }, "localeMatcher must be either \"lookup\" or \"best fit\"", "best fit");
// 9. ReturnIfAbrupt(matcher).
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
// 10. Set opt.[[localeMatcher]] to matcher.
localeOpt.add(vm.propertyNames->localeMatcher.string(), localeMatcher);
@@ -477,8 +463,7 @@
// 17. Let tz be Get(options, "timeZone").
JSValue tzValue = options->get(&exec, vm.propertyNames->timeZone);
// 18. ReturnIfAbrupt(tz).
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
// 19. If tz is not undefined, then
String tz;
@@ -486,8 +471,7 @@
// a. Let tz be ToString(tz).
String originalTz = tzValue.toWTFString(&exec);
// b. ReturnIfAbrupt(tz).
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
// c. If the result of IsValidTimeZoneName(tz) is false, then i. Throw a RangeError exception.
// d. Let tz be CanonicalizeTimeZoneName(tz).
tz = canonicalizeTimeZoneName(originalTz);
@@ -519,8 +503,7 @@
auto shortLong = { "short", "long" };
String weekday = intlStringOption(exec, options, vm.propertyNames->weekday, narrowShortLong, "weekday must be \"narrow\", \"short\", or \"long\"", nullptr);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
if (!weekday.isNull()) {
if (weekday == "narrow")
skeletonBuilder.appendLiteral("EEEEE");
@@ -531,8 +514,7 @@
}
String era = intlStringOption(exec, options, vm.propertyNames->era, narrowShortLong, "era must be \"narrow\", \"short\", or \"long\"", nullptr);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
if (!era.isNull()) {
if (era == "narrow")
skeletonBuilder.appendLiteral("GGGGG");
@@ -543,8 +525,7 @@
}
String year = intlStringOption(exec, options, vm.propertyNames->year, twoDigitNumeric, "year must be \"2-digit\" or \"numeric\"", nullptr);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
if (!year.isNull()) {
if (year == "2-digit")
skeletonBuilder.appendLiteral("yy");
@@ -553,8 +534,7 @@
}
String month = intlStringOption(exec, options, vm.propertyNames->month, twoDigitNumericNarrowShortLong, "month must be \"2-digit\", \"numeric\", \"narrow\", \"short\", or \"long\"", nullptr);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
if (!month.isNull()) {
if (month == "2-digit")
skeletonBuilder.appendLiteral("MM");
@@ -569,8 +549,7 @@
}
String day = intlStringOption(exec, options, vm.propertyNames->day, twoDigitNumeric, "day must be \"2-digit\" or \"numeric\"", nullptr);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
if (!day.isNull()) {
if (day == "2-digit")
skeletonBuilder.appendLiteral("dd");
@@ -579,16 +558,14 @@
}
String hour = intlStringOption(exec, options, vm.propertyNames->hour, twoDigitNumeric, "hour must be \"2-digit\" or \"numeric\"", nullptr);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
// We need hour12 to make the hour skeleton pattern decision, so do this early.
// 32. Let hr12 be GetOption(options, "hour12", "boolean", undefined, undefined).
bool isHour12Undefined;
bool hr12 = intlBooleanOption(exec, options, vm.propertyNames->hour12, isHour12Undefined);
// 33. ReturnIfAbrupt(hr12).
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
if (!hour.isNull()) {
if (isHour12Undefined) {
@@ -610,8 +587,7 @@
}
String minute = intlStringOption(exec, options, vm.propertyNames->minute, twoDigitNumeric, "minute must be \"2-digit\" or \"numeric\"", nullptr);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
if (!minute.isNull()) {
if (minute == "2-digit")
skeletonBuilder.appendLiteral("mm");
@@ -620,8 +596,7 @@
}
String second = intlStringOption(exec, options, vm.propertyNames->second, twoDigitNumeric, "second must be \"2-digit\" or \"numeric\"", nullptr);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
if (!second.isNull()) {
if (second == "2-digit")
skeletonBuilder.appendLiteral("ss");
@@ -630,8 +605,7 @@
}
String timeZoneName = intlStringOption(exec, options, vm.propertyNames->timeZoneName, shortLong, "timeZoneName must be \"short\" or \"long\"", nullptr);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
if (!timeZoneName.isNull()) {
if (timeZoneName == "short")
skeletonBuilder.append('z');
@@ -644,8 +618,7 @@
// 26. Let matcher be GetOption(options, "formatMatcher", "string", «"basic", "best fit"», "best fit").
intlStringOption(exec, options, vm.propertyNames->formatMatcher, { "basic", "best fit" }, "formatMatcher must be either \"basic\" or \"best fit\"", "best fit");
// 27. ReturnIfAbrupt(matcher).
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
// Always use ICU date format generator, rather than our own pattern list and matcher.
// Covers steps 28-36.
diff --git a/Source/JavaScriptCore/runtime/IntlDateTimeFormatConstructor.cpp b/Source/JavaScriptCore/runtime/IntlDateTimeFormatConstructor.cpp
index 1bf6f09..8d26eed 100644
--- a/Source/JavaScriptCore/runtime/IntlDateTimeFormatConstructor.cpp
+++ b/Source/JavaScriptCore/runtime/IntlDateTimeFormatConstructor.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Andy VanWagoner (thetalecrafter@gmail.com)
+ * Copyright (C) 2016 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -90,8 +91,7 @@
// 2. Let dateTimeFormat be OrdinaryCreateFromConstructor(newTarget, %DateTimeFormatPrototype%).
// 3. ReturnIfAbrupt(dateTimeFormat).
Structure* structure = InternalFunction::createSubclassStructure(state, state->newTarget(), jsCast<IntlDateTimeFormatConstructor*>(state->callee())->dateTimeFormatStructure());
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
IntlDateTimeFormat* dateTimeFormat = IntlDateTimeFormat::create(vm, structure);
ASSERT(dateTimeFormat);
@@ -146,8 +146,7 @@
// 2. Let requestedLocales be CanonicalizeLocaleList(locales).
Vector<String> requestedLocales = canonicalizeLocaleList(*state, state->argument(0));
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
// 3. Return SupportedLocales(availableLocales, requestedLocales, options).
return JSValue::encode(supportedLocales(*state, availableLocales, requestedLocales, state->argument(1)));
diff --git a/Source/JavaScriptCore/runtime/IntlDateTimeFormatPrototype.cpp b/Source/JavaScriptCore/runtime/IntlDateTimeFormatPrototype.cpp
index 7b847f2..d75055c 100644
--- a/Source/JavaScriptCore/runtime/IntlDateTimeFormatPrototype.cpp
+++ b/Source/JavaScriptCore/runtime/IntlDateTimeFormatPrototype.cpp
@@ -101,8 +101,7 @@
// a. Let x be ToNumber(date).
value = date.toNumber(state);
// b. ReturnIfAbrupt(x).
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
// 5. Return FormatDateTime(dtf, x).
@@ -140,8 +139,7 @@
// c. Let bf be BoundFunctionCreate(F, «this value»).
boundFormat = JSBoundFunction::create(vm, state, globalObject, targetObject, dtf, boundArgs, 1, ASCIILiteral("format"));
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
// d. Set dtf.[[boundFormat]] to bf.
dtf->setBoundFormat(vm, boundFormat);
}
diff --git a/Source/JavaScriptCore/runtime/IntlNumberFormat.cpp b/Source/JavaScriptCore/runtime/IntlNumberFormat.cpp
index 4a5c014..3718539 100644
--- a/Source/JavaScriptCore/runtime/IntlNumberFormat.cpp
+++ b/Source/JavaScriptCore/runtime/IntlNumberFormat.cpp
@@ -164,8 +164,7 @@
// 3. Let requestedLocales be CanonicalizeLocaleList(locales).
auto requestedLocales = canonicalizeLocaleList(state, locales);
// 4. ReturnIfAbrupt(requestedLocales).
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
// 5. If options is undefined, then
JSObject* options;
@@ -176,8 +175,7 @@
// a. Let options be ToObject(options).
options = optionsValue.toObject(&state);
// b. ReturnIfAbrupt(options).
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
}
// 7. Let opt be a new Record.
@@ -186,8 +184,7 @@
// 8. Let matcher be GetOption(options, "localeMatcher", "string", «"lookup", "best fit"», "best fit").
String matcher = intlStringOption(state, options, vm.propertyNames->localeMatcher, { "lookup", "best fit" }, "localeMatcher must be either \"lookup\" or \"best fit\"", "best fit");
// 9. ReturnIfAbrupt(matcher).
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
// 10. Set opt.[[localeMatcher]] to matcher.
opt.add(ASCIILiteral("localeMatcher"), matcher);
@@ -211,8 +208,7 @@
// 16. Let s be GetOption(options, "style", "string", « "decimal", "percent", "currency"», "decimal").
String styleString = intlStringOption(state, options, Identifier::fromString(&vm, "style"), { "decimal", "percent", "currency" }, "style must be either \"decimal\", \"percent\", or \"currency\"", "decimal");
// 17. ReturnIfAbrupt(s).
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
// 18. Set numberFormat.[[style]] to s.
if (styleString == "decimal")
m_style = Style::Decimal;
@@ -226,8 +222,7 @@
// 19. Let c be GetOption(options, "currency", "string", undefined, undefined).
String currency = intlStringOption(state, options, Identifier::fromString(&vm, "currency"), { }, nullptr, nullptr);
// 20. ReturnIfAbrupt(c).
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
// 21. If c is not undefined, then
if (!currency.isNull()) {
// a. If the result of IsWellFormedCurrencyCode(c), is false, then throw a RangeError exception.
@@ -257,8 +252,7 @@
// 24. Let cd be GetOption(options, "currencyDisplay", "string", «"code", "symbol", "name"», "symbol").
String currencyDisplayString = intlStringOption(state, options, Identifier::fromString(&vm, "currencyDisplay"), { "code", "symbol", "name" }, "currencyDisplay must be either \"code\", \"symbol\", or \"name\"", "symbol");
// 25. ReturnIfAbrupt(cd).
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
// 26. If s is "currency", set numberFormat.[[currencyDisplay]] to cd.
if (m_style == Style::Currency) {
if (currencyDisplayString == "code")
@@ -275,8 +269,7 @@
// 28. ReturnIfAbrupt(mnid).
// 29. Set numberFormat.[[minimumIntegerDigits]] to mnid.
unsigned minimumIntegerDigits = intlNumberOption(state, options, Identifier::fromString(&vm, "minimumIntegerDigits"), 1, 21, 1);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
m_minimumIntegerDigits = minimumIntegerDigits;
// 30. If s is "currency", let mnfdDefault be cDigits; else let mnfdDefault be 0.
@@ -286,8 +279,7 @@
// 32. ReturnIfAbrupt(mnfd).
// 33. Set numberFormat.[[minimumFractionDigits]] to mnfd.
unsigned minimumFractionDigits = intlNumberOption(state, options, Identifier::fromString(&vm, "minimumFractionDigits"), 0, 20, minimumFractionDigitsDefault);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
m_minimumFractionDigits = minimumFractionDigits;
// 34. If s is "currency", let mxfdDefault be max(mnfd, cDigits);
@@ -303,34 +295,29 @@
// 36. ReturnIfAbrupt(mxfd).
// 37. Set numberFormat.[[maximumFractionDigits]] to mxfd.
unsigned maximumFractionDigits = intlNumberOption(state, options, Identifier::fromString(&vm, "maximumFractionDigits"), minimumFractionDigits, 20, maximumFractionDigitsDefault);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
m_maximumFractionDigits = maximumFractionDigits;
// 38. Let mnsd be Get(options, "minimumSignificantDigits").
JSValue minimumSignificantDigitsValue = options->get(&state, Identifier::fromString(&vm, "minimumSignificantDigits"));
// 39. ReturnIfAbrupt(mnsd).
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
// 40. Let mxsd be Get(options, "maximumSignificantDigits").
JSValue maximumSignificantDigitsValue = options->get(&state, Identifier::fromString(&vm, "maximumSignificantDigits"));
// 41. ReturnIfAbrupt(mxsd).
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
// 42. If mnsd is not undefined or mxsd is not undefined, then
if (!minimumSignificantDigitsValue.isUndefined() || !maximumSignificantDigitsValue.isUndefined()) {
// a. Let mnsd be GetNumberOption(options, "minimumSignificantDigits", 1, 21, 1).
unsigned minimumSignificantDigits = intlNumberOption(state, options, Identifier::fromString(&vm, "minimumSignificantDigits"), 1, 21, 1);
// b. ReturnIfAbrupt(mnsd).
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
// c. Let mxsd be GetNumberOption(options, "maximumSignificantDigits", mnsd, 21, 21).
unsigned maximumSignificantDigits = intlNumberOption(state, options, Identifier::fromString(&vm, "maximumSignificantDigits"), minimumSignificantDigits, 21, 21);
// d. ReturnIfAbrupt(mxsd).
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
// e. Set numberFormat.[[minimumSignificantDigits]] to mnsd.
m_minimumSignificantDigits = minimumSignificantDigits;
// f. Set numberFormat.[[maximumSignificantDigits]] to mxsd.
@@ -343,8 +330,7 @@
if (usesFallback)
useGrouping = true;
// 44. ReturnIfAbrupt(g).
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
// 45. Set numberFormat.[[useGrouping]] to g.
m_useGrouping = useGrouping;
diff --git a/Source/JavaScriptCore/runtime/IntlNumberFormatConstructor.cpp b/Source/JavaScriptCore/runtime/IntlNumberFormatConstructor.cpp
index 415fff5..df4fd4e 100644
--- a/Source/JavaScriptCore/runtime/IntlNumberFormatConstructor.cpp
+++ b/Source/JavaScriptCore/runtime/IntlNumberFormatConstructor.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Andy VanWagoner (thetalecrafter@gmail.com)
+ * Copyright (C) 2016 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -90,8 +91,7 @@
// 2. Let numberFormat be OrdinaryCreateFromConstructor(newTarget, %NumberFormatPrototype%).
// 3. ReturnIfAbrupt(numberFormat).
Structure* structure = InternalFunction::createSubclassStructure(state, state->newTarget(), jsCast<IntlNumberFormatConstructor*>(state->callee())->numberFormatStructure());
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
IntlNumberFormat* numberFormat = IntlNumberFormat::create(vm, structure);
ASSERT(numberFormat);
@@ -146,8 +146,7 @@
// 2. Let requestedLocales be CanonicalizeLocaleList(locales).
Vector<String> requestedLocales = canonicalizeLocaleList(*state, state->argument(0));
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
// 3. Return SupportedLocales(availableLocales, requestedLocales, options).
return JSValue::encode(supportedLocales(*state, availableLocales, requestedLocales, state->argument(1)));
diff --git a/Source/JavaScriptCore/runtime/IntlNumberFormatPrototype.cpp b/Source/JavaScriptCore/runtime/IntlNumberFormatPrototype.cpp
index a23e88b..84f8852 100644
--- a/Source/JavaScriptCore/runtime/IntlNumberFormatPrototype.cpp
+++ b/Source/JavaScriptCore/runtime/IntlNumberFormatPrototype.cpp
@@ -91,8 +91,7 @@
// 4. Let x be ToNumber(value).
double number = state->argument(0).toNumber(state);
// 5. ReturnIfAbrupt(x).
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
// 6. Return FormatNumber(nf, x).
return JSValue::encode(numberFormat->formatNumber(*state, number));
@@ -128,8 +127,7 @@
// c. Let bf be BoundFunctionCreate(F, «this value»).
boundFormat = JSBoundFunction::create(vm, state, globalObject, targetObject, nf, boundArgs, 1, ASCIILiteral("format"));
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
// d. Set nf.[[boundFormat]] to bf.
nf->setBoundFormat(vm, boundFormat);
}
diff --git a/Source/JavaScriptCore/runtime/IntlObject.cpp b/Source/JavaScriptCore/runtime/IntlObject.cpp
index 63dc856..c3de7ed 100644
--- a/Source/JavaScriptCore/runtime/IntlObject.cpp
+++ b/Source/JavaScriptCore/runtime/IntlObject.cpp
@@ -134,15 +134,13 @@
JSObject* opts = options.toObject(&state);
// 2. ReturnIfAbrupt(opts).
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
// 3. Let value be Get(opts, property).
JSValue value = opts->get(&state, property);
// 4. ReturnIfAbrupt(value).
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
// 5. If value is not undefined, then
if (!value.isUndefined()) {
@@ -176,15 +174,13 @@
JSObject* opts = options.toObject(&state);
// 2. ReturnIfAbrupt(opts).
- if (UNLIKELY(scope.exception()))
- return { };
+ RETURN_IF_EXCEPTION(scope, String());
// 3. Let value be Get(opts, property).
JSValue value = opts->get(&state, property);
// 4. ReturnIfAbrupt(value).
- if (UNLIKELY(scope.exception()))
- return { };
+ RETURN_IF_EXCEPTION(scope, String());
// 5. If value is not undefined, then
if (!value.isUndefined()) {
@@ -196,8 +192,7 @@
String stringValue = value.toWTFString(&state);
// ii. ReturnIfAbrupt(value).
- if (UNLIKELY(scope.exception()))
- return { };
+ RETURN_IF_EXCEPTION(scope, String());
// d. If values is not undefined, then
// i. If values does not contain an element equal to value, throw a RangeError exception.
@@ -224,23 +219,20 @@
JSObject* opts = options.toObject(&state);
// 2. ReturnIfAbrupt(opts).
- if (UNLIKELY(scope.exception()))
- return 0;
+ RETURN_IF_EXCEPTION(scope, 0);
// 3. Let value be Get(opts, property).
JSValue value = opts->get(&state, property);
// 4. ReturnIfAbrupt(value).
- if (UNLIKELY(scope.exception()))
- return 0;
+ RETURN_IF_EXCEPTION(scope, 0);
// 5. If value is not undefined, then
if (!value.isUndefined()) {
// a. Let value be ToNumber(value).
double doubleValue = value.toNumber(&state);
// b. ReturnIfAbrupt(value).
- if (UNLIKELY(scope.exception()))
- return 0;
+ RETURN_IF_EXCEPTION(scope, 0);
// 1. If value is NaN or less than minimum or greater than maximum, throw a RangeError exception.
if (!(doubleValue >= minimum && doubleValue <= maximum)) {
throwException(&state, scope, createRangeError(&state, *property.publicName() + " is out of range"));
@@ -560,17 +552,14 @@
}
// 5. ReturnIfAbrupt(O).
- if (UNLIKELY(scope.exception()))
- return Vector<String>();
+ RETURN_IF_EXCEPTION(scope, Vector<String>());
// 6. Let len be ToLength(Get(O, "length")).
JSValue lengthProperty = localesObject->get(&state, vm.propertyNames->length);
- if (UNLIKELY(scope.exception()))
- return Vector<String>();
+ RETURN_IF_EXCEPTION(scope, Vector<String>());
double length = lengthProperty.toLength(&state);
- if (UNLIKELY(scope.exception()))
- return Vector<String>();
+ RETURN_IF_EXCEPTION(scope, Vector<String>());
// Keep track of locales that have been added to the list.
HashSet<String> seenSet;
@@ -585,8 +574,7 @@
bool kPresent = localesObject->hasProperty(&state, k);
// c. ReturnIfAbrupt(kPresent).
- if (UNLIKELY(scope.exception()))
- return Vector<String>();
+ RETURN_IF_EXCEPTION(scope, Vector<String>());
// d. If kPresent is true, then
if (kPresent) {
@@ -594,8 +582,7 @@
JSValue kValue = localesObject->get(&state, k);
// ii. ReturnIfAbrupt(kValue).
- if (UNLIKELY(scope.exception()))
- return Vector<String>();
+ RETURN_IF_EXCEPTION(scope, Vector<String>());
// iii. If Type(kValue) is not String or Object, throw a TypeError exception.
if (!kValue.isString() && !kValue.isObject()) {
@@ -607,8 +594,7 @@
JSString* tag = kValue.toString(&state);
// v. ReturnIfAbrupt(tag).
- if (UNLIKELY(scope.exception()))
- return Vector<String>();
+ RETURN_IF_EXCEPTION(scope, Vector<String>());
// vi. If IsStructurallyValidLanguageTag(tag) is false, throw a RangeError exception.
// vii. Let canonicalizedTag be CanonicalizeLanguageTag(tag).
@@ -945,8 +931,7 @@
// a. Let matcher be GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
matcher = intlStringOption(state, options, vm.propertyNames->localeMatcher, { "lookup", "best fit" }, "localeMatcher must be either \"lookup\" or \"best fit\"", "best fit");
// b. ReturnIfAbrupt(matcher).
- if (UNLIKELY(scope.exception()))
- return jsUndefined();
+ RETURN_IF_EXCEPTION(scope, JSValue());
} else {
// 2. Else, let matcher be "best fit".
matcher = ASCIILiteral("best fit");
@@ -965,8 +950,7 @@
supportedLocales = lookupSupportedLocales(state, availableLocales, requestedLocales);
}
- if (UNLIKELY(scope.exception()))
- return jsUndefined();
+ RETURN_IF_EXCEPTION(scope, JSValue());
// 6. Let subset be CreateArrayFromList(supportedLocales).
// Already an array.
@@ -974,8 +958,7 @@
// 7. Let keys be subset.[[OwnPropertyKeys]]().
PropertyNameArray keys(&state, PropertyNameMode::Strings);
supportedLocales->getOwnPropertyNames(supportedLocales, &state, keys, EnumerationMode());
- if (UNLIKELY(scope.exception()))
- return jsUndefined();
+ RETURN_IF_EXCEPTION(scope, JSValue());
PropertyDescriptor desc;
desc.setConfigurable(false);
@@ -991,8 +974,7 @@
supportedLocales->defineOwnProperty(supportedLocales, &state, keys[i], desc, true);
// c. Assert: status is not abrupt completion.
- if (UNLIKELY(scope.exception()))
- return jsUndefined();
+ RETURN_IF_EXCEPTION(scope, JSValue());
}
// 9. Return subset.
diff --git a/Source/JavaScriptCore/runtime/IntlObjectInlines.h b/Source/JavaScriptCore/runtime/IntlObjectInlines.h
index 1cf54b1..72be09b 100644
--- a/Source/JavaScriptCore/runtime/IntlObjectInlines.h
+++ b/Source/JavaScriptCore/runtime/IntlObjectInlines.h
@@ -46,12 +46,10 @@
JSValue prototype = callee->getDirect(vm, vm.propertyNames->prototype);
if (JSObject::defaultHasInstance(&state, thisValue, prototype)) {
JSObject* thisObject = thisValue.toObject(&state);
- if (UNLIKELY(scope.exception()))
- return jsUndefined();
+ RETURN_IF_EXCEPTION(scope, JSValue());
IntlInstance* instance = factory(vm);
- if (UNLIKELY(scope.exception()))
- return jsUndefined();
+ RETURN_IF_EXCEPTION(scope, JSValue());
thisObject->putDirect(vm, vm.propertyNames->builtinNames().intlSubstituteValuePrivateName(), instance);
return thisObject;
diff --git a/Source/JavaScriptCore/runtime/IteratorOperations.cpp b/Source/JavaScriptCore/runtime/IteratorOperations.cpp
index 660198f..f4ac2ed 100644
--- a/Source/JavaScriptCore/runtime/IteratorOperations.cpp
+++ b/Source/JavaScriptCore/runtime/IteratorOperations.cpp
@@ -41,8 +41,7 @@
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue nextFunction = iterator.get(exec, vm.propertyNames->next);
- if (UNLIKELY(scope.exception()))
- return jsUndefined();
+ RETURN_IF_EXCEPTION(scope, JSValue());
CallData nextFunctionCallData;
CallType nextFunctionCallType = getCallData(nextFunction, nextFunctionCallData);
@@ -53,8 +52,7 @@
if (!value.isEmpty())
nextFunctionArguments.append(value);
JSValue result = call(exec, nextFunction, nextFunctionCallType, nextFunctionCallData, iterator, nextFunctionArguments);
- if (UNLIKELY(scope.exception()))
- return jsUndefined();
+ RETURN_IF_EXCEPTION(scope, JSValue());
if (!result.isObject())
return throwTypeError(exec, scope, ASCIILiteral("Iterator result interface is not an object."));
@@ -84,11 +82,9 @@
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue result = iteratorNext(exec, iterator);
- if (UNLIKELY(scope.exception()))
- return jsUndefined();
+ RETURN_IF_EXCEPTION(scope, JSValue());
bool done = iteratorComplete(exec, result);
- if (UNLIKELY(scope.exception()))
- return jsUndefined();
+ RETURN_IF_EXCEPTION(scope, JSValue());
if (done)
return jsBoolean(false);
return result;
@@ -106,8 +102,7 @@
catchScope.clearException();
}
JSValue returnFunction = iterator.get(exec, vm.propertyNames->returnKeyword);
- if (UNLIKELY(throwScope.exception()))
- return;
+ RETURN_IF_EXCEPTION(throwScope, void());
if (returnFunction.isUndefined()) {
if (exception)
@@ -133,8 +128,7 @@
return;
}
- if (UNLIKELY(throwScope.exception()))
- return;
+ RETURN_IF_EXCEPTION(throwScope, void());
if (!innerResult.isObject()) {
throwTypeError(exec, throwScope, ASCIILiteral("Iterator result interface is not an object."));
@@ -171,8 +165,7 @@
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue iteratorFunction = iterable.get(state, state->propertyNames().iteratorSymbol);
- if (UNLIKELY(scope.exception()))
- return JSValue();
+ RETURN_IF_EXCEPTION(scope, JSValue());
CallData iteratorFunctionCallData;
CallType iteratorFunctionCallType = getCallData(iteratorFunction, iteratorFunctionCallData);
@@ -183,8 +176,7 @@
ArgList iteratorFunctionArguments;
JSValue iterator = call(state, iteratorFunction, iteratorFunctionCallType, iteratorFunctionCallData, iterable, iteratorFunctionArguments);
- if (UNLIKELY(scope.exception()))
- return JSValue();
+ RETURN_IF_EXCEPTION(scope, JSValue());
if (!iterator.isObject()) {
throwTypeError(state, scope);
diff --git a/Source/JavaScriptCore/runtime/IteratorOperations.h b/Source/JavaScriptCore/runtime/IteratorOperations.h
index 4d48f95..beece7c 100644
--- a/Source/JavaScriptCore/runtime/IteratorOperations.h
+++ b/Source/JavaScriptCore/runtime/IteratorOperations.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>.
+ * Copyright (C) 2016 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -51,16 +52,14 @@
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue iterator = iteratorForIterable(state, iterable);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
while (true) {
JSValue next = iteratorStep(state, iterator);
if (next.isFalse() || UNLIKELY(scope.exception()))
return;
JSValue nextValue = iteratorValue(state, next);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
callback(vm, state, nextValue);
if (UNLIKELY(scope.exception())) {
diff --git a/Source/JavaScriptCore/runtime/JSArray.cpp b/Source/JavaScriptCore/runtime/JSArray.cpp
index f21a891..ff73148 100644
--- a/Source/JavaScriptCore/runtime/JSArray.cpp
+++ b/Source/JavaScriptCore/runtime/JSArray.cpp
@@ -653,8 +653,7 @@
unsigned index = getArrayLength() - 1;
// Let element be the result of calling the [[Get]] internal method of O with argument indx.
JSValue element = get(exec, index);
- if (UNLIKELY(scope.exception()))
- return jsUndefined();
+ RETURN_IF_EXCEPTION(scope, JSValue());
// Call the [[Delete]] internal method of O with arguments indx and true.
if (!deletePropertyByIndex(this, exec, index)) {
throwTypeError(exec, scope, ASCIILiteral("Unable to delete property."));
@@ -1323,8 +1322,7 @@
for (; i < length; ++i) {
exec->r(firstElementDest + i - offset) = get(exec, i);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
}
}
diff --git a/Source/JavaScriptCore/runtime/JSArrayBufferConstructor.cpp b/Source/JavaScriptCore/runtime/JSArrayBufferConstructor.cpp
index 14c19d8..18ce88c 100644
--- a/Source/JavaScriptCore/runtime/JSArrayBufferConstructor.cpp
+++ b/Source/JavaScriptCore/runtime/JSArrayBufferConstructor.cpp
@@ -88,8 +88,7 @@
unsigned length;
if (exec->argumentCount()) {
length = exec->uncheckedArgument(0).toUInt32(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
} else {
// Although the documentation doesn't say so, it is in fact correct to say
// "new ArrayBuffer()". The result is the same as allocating an array buffer
@@ -102,8 +101,7 @@
return JSValue::encode(throwOutOfMemoryError(exec, scope));
Structure* arrayBufferStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), constructor->globalObject()->arrayBufferStructure());
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSArrayBuffer* result = JSArrayBuffer::create(vm, arrayBufferStructure, WTFMove(buffer));
return JSValue::encode(result);
diff --git a/Source/JavaScriptCore/runtime/JSArrayBufferPrototype.cpp b/Source/JavaScriptCore/runtime/JSArrayBufferPrototype.cpp
index 63f0921..7cb52b6 100644
--- a/Source/JavaScriptCore/runtime/JSArrayBufferPrototype.cpp
+++ b/Source/JavaScriptCore/runtime/JSArrayBufferPrototype.cpp
@@ -50,14 +50,12 @@
return throwVMTypeError(exec, scope, ASCIILiteral("Slice requires at least one argument."));
int32_t begin = exec->argument(0).toInt32(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
int32_t end;
if (exec->argumentCount() >= 2) {
end = exec->uncheckedArgument(1).toInt32(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
} else
end = thisObject->impl()->byteLength();
diff --git a/Source/JavaScriptCore/runtime/JSArrayInlines.h b/Source/JavaScriptCore/runtime/JSArrayInlines.h
index 8604e98..8837a0d 100644
--- a/Source/JavaScriptCore/runtime/JSArrayInlines.h
+++ b/Source/JavaScriptCore/runtime/JSArrayInlines.h
@@ -76,8 +76,7 @@
return jsCast<JSArray*>(obj)->length();
JSValue lengthValue = obj->get(exec, vm.propertyNames->length);
- if (UNLIKELY(scope.exception()))
- return UINT_MAX;
+ RETURN_IF_EXCEPTION(scope, UINT_MAX);
return lengthValue.toUInt32(exec);
}
@@ -89,8 +88,7 @@
return jsCast<JSArray*>(obj)->length();
JSValue lengthValue = obj->get(exec, vm.propertyNames->length);
- if (UNLIKELY(scope.exception()))
- return PNaN;
+ RETURN_IF_EXCEPTION(scope, PNaN);
return lengthValue.toLength(exec);
}
diff --git a/Source/JavaScriptCore/runtime/JSBoundFunction.cpp b/Source/JavaScriptCore/runtime/JSBoundFunction.cpp
index fd3e8b7..26f99d6 100644
--- a/Source/JavaScriptCore/runtime/JSBoundFunction.cpp
+++ b/Source/JavaScriptCore/runtime/JSBoundFunction.cpp
@@ -128,8 +128,7 @@
{
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue prototype = targetFunction->getPrototype(vm, exec);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
JSFunction* targetJSFunction = jsDynamicCast<JSFunction*>(targetFunction);
// We only cache the structure of the bound function if the bindee is a JSFunction since there
@@ -172,8 +171,7 @@
canConstruct ? (slowCase ? boundFunctionConstruct : boundThisNoArgsFunctionConstruct) : callHostFunctionAsConstructor,
name);
Structure* structure = getBoundFunctionStructure(vm, exec, globalObject, targetFunction);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
JSBoundFunction* function = new (NotNull, allocateCell<JSBoundFunction>(vm.heap)) JSBoundFunction(vm, globalObject, structure, targetFunction, boundThis, boundArgs);
function->finishCreation(vm, executable, length);
diff --git a/Source/JavaScriptCore/runtime/JSCJSValue.cpp b/Source/JavaScriptCore/runtime/JSCJSValue.cpp
index 1e39ef7..ef1d615 100644
--- a/Source/JavaScriptCore/runtime/JSCJSValue.cpp
+++ b/Source/JavaScriptCore/runtime/JSCJSValue.cpp
@@ -192,8 +192,7 @@
}
prototype = obj->getPrototype(vm, exec);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
if (prototype.isNull())
break;
}
@@ -381,12 +380,10 @@
ASSERT(isCell());
JSValue value = asCell()->toPrimitive(exec, PreferString);
- if (UNLIKELY(scope.exception()))
- return errorValue();
+ RETURN_IF_EXCEPTION(scope, errorValue());
ASSERT(!value.isObject());
JSString* result = value.toString(exec);
- if (UNLIKELY(scope.exception()))
- return errorValue();
+ RETURN_IF_EXCEPTION(scope, errorValue());
return result;
}
diff --git a/Source/JavaScriptCore/runtime/JSCJSValueInlines.h b/Source/JavaScriptCore/runtime/JSCJSValueInlines.h
index 78adc77..e2dd698 100644
--- a/Source/JavaScriptCore/runtime/JSCJSValueInlines.h
+++ b/Source/JavaScriptCore/runtime/JSCJSValueInlines.h
@@ -642,8 +642,7 @@
}
StringImpl* hintString = jsCast<JSString*>(value)->value(exec).impl();
- if (UNLIKELY(scope.exception()))
- return NoPreference;
+ RETURN_IF_EXCEPTION(scope, NoPreference);
if (WTF::equal(hintString, "default"))
return NoPreference;
@@ -786,8 +785,7 @@
{
auto scope = DECLARE_THROW_SCOPE(exec->vm());
bool found = getPropertySlot(exec, propertyName, slot);
- if (UNLIKELY(scope.exception()))
- return { };
+ RETURN_IF_EXCEPTION(scope, { });
return callback(found, slot);
}
@@ -926,8 +924,7 @@
if (v2.isObject())
return v1 == v2;
JSValue p1 = v1.toPrimitive(exec);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
v1 = p1;
if (v1.isInt32() && v2.isInt32())
return v1 == v2;
@@ -936,8 +933,7 @@
if (v2.isObject()) {
JSValue p2 = v2.toPrimitive(exec);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
v2 = p2;
if (v1.isInt32() && v2.isInt32())
return v1 == v2;
diff --git a/Source/JavaScriptCore/runtime/JSDataViewPrototype.cpp b/Source/JavaScriptCore/runtime/JSDataViewPrototype.cpp
index ca60eaf..1f8e0c2 100644
--- a/Source/JavaScriptCore/runtime/JSDataViewPrototype.cpp
+++ b/Source/JavaScriptCore/runtime/JSDataViewPrototype.cpp
@@ -133,15 +133,13 @@
return throwVMTypeError(exec, scope, ASCIILiteral("Need at least one argument (the byteOffset)"));
unsigned byteOffset = exec->uncheckedArgument(0).toUInt32(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
bool littleEndian = false;
unsigned elementSize = sizeof(typename Adaptor::Type);
if (elementSize > 1 && exec->argumentCount() >= 2) {
littleEndian = exec->uncheckedArgument(1).toBoolean(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
unsigned byteLength = dataView->length();
@@ -181,8 +179,7 @@
return throwVMTypeError(exec, scope, ASCIILiteral("Need at least two argument (the byteOffset and value)"));
unsigned byteOffset = exec->uncheckedArgument(0).toUInt32(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
const unsigned dataSize = sizeof(typename Adaptor::Type);
union {
@@ -191,15 +188,13 @@
} u;
u.value = toNativeFromValue<Adaptor>(exec, exec->uncheckedArgument(1));
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
bool littleEndian = false;
unsigned elementSize = sizeof(typename Adaptor::Type);
if (elementSize > 1 && exec->argumentCount() >= 3) {
littleEndian = exec->uncheckedArgument(2).toBoolean(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
unsigned byteLength = dataView->length();
diff --git a/Source/JavaScriptCore/runtime/JSFunction.cpp b/Source/JavaScriptCore/runtime/JSFunction.cpp
index 130dbc2..c9d9825 100644
--- a/Source/JavaScriptCore/runtime/JSFunction.cpp
+++ b/Source/JavaScriptCore/runtime/JSFunction.cpp
@@ -612,11 +612,9 @@
name = makeString('[', String(&uid), ']');
} else {
JSString* jsStr = value.toString(exec);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
name = jsStr->value(exec);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
}
reifyName(vm, exec, name);
}
diff --git a/Source/JavaScriptCore/runtime/JSGenericTypedArrayView.h b/Source/JavaScriptCore/runtime/JSGenericTypedArrayView.h
index fd2e681..ee18baa 100644
--- a/Source/JavaScriptCore/runtime/JSGenericTypedArrayView.h
+++ b/Source/JavaScriptCore/runtime/JSGenericTypedArrayView.h
@@ -174,8 +174,7 @@
auto scope = DECLARE_THROW_SCOPE(vm);
typename Adaptor::Type value = toNativeFromValue<Adaptor>(exec, jsValue);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
if (isNeutered()) {
throwTypeError(exec, scope, typedArrayBufferHasBeenDetachedErrorMessage);
diff --git a/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructorInlines.h b/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructorInlines.h
index 7e2efbc..7870c13 100644
--- a/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructorInlines.h
+++ b/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructorInlines.h
@@ -89,24 +89,20 @@
MarkedArgumentBuffer storage;
while (true) {
JSValue next = iteratorStep(exec, iterator);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
if (next.isFalse())
break;
JSValue nextItem = iteratorValue(exec, next);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
storage.append(nextItem);
}
ViewClass* result = ViewClass::createUninitialized(exec, structure, storage.size());
- if (!result) {
- ASSERT(scope.exception());
- return nullptr;
- }
+ if (!result)
+ RETURN_IF_EXCEPTION(scope, nullptr);
for (unsigned i = 0; i < storage.size(); ++i) {
if (!result->setIndex(exec, i, storage.at(i))) {
@@ -162,8 +158,7 @@
object->getPropertySlot(exec, vm.propertyNames->length, lengthSlot);
JSValue iteratorFunc = object->get(exec, vm.propertyNames->iteratorSymbol);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
// We would like not use the iterator as it is painfully slow. Fortunately, unless
// 1) The iterator is not a known iterator.
@@ -183,15 +178,13 @@
ArgList arguments;
JSValue iterator = call(exec, iteratorFunc, callType, callData, object, arguments);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
return constructGenericTypedArrayViewFromIterator<ViewClass>(exec, structure, iterator);
}
length = lengthSlot.isUnset() ? 0 : lengthSlot.getValue(exec, vm.propertyNames->length).toUInt32(exec);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
}
@@ -235,8 +228,7 @@
InternalFunction* function = asInternalFunction(exec->callee());
Structure* parentStructure = function->globalObject()->typedArrayStructure(ViewClass::TypedArrayStorageType);
Structure* structure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), parentStructure);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
size_t argCount = exec->argumentCount();
@@ -252,13 +244,11 @@
Optional<unsigned> length = Nullopt;
if (jsDynamicCast<JSArrayBuffer*>(firstValue) && argCount > 1) {
offset = exec->uncheckedArgument(1).toUInt32(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (argCount > 2) {
length = exec->uncheckedArgument(2).toUInt32(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
}
diff --git a/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h b/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h
index 0bf3485..b481991 100644
--- a/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h
+++ b/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h
@@ -51,8 +51,7 @@
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue constructor = exemplar->get(exec, exec->propertyNames().constructor);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
if (constructor.isUndefined())
return defaultConstructor();
@@ -62,15 +61,13 @@
}
JSValue species = constructor.get(exec, exec->propertyNames().speciesSymbol);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
if (species.isUndefinedOrNull())
return defaultConstructor();
JSValue result = construct(exec, species, args, "species is not a constructor");
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
if (JSArrayBufferView* view = jsDynamicCast<JSArrayBufferView*>(result)) {
if (!view->isNeutered())
@@ -112,8 +109,7 @@
unsigned offset;
if (exec->argumentCount() >= 2) {
double offsetNumber = exec->uncheckedArgument(1).toInteger(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (UNLIKELY(offsetNumber < 0))
return throwVMRangeError(exec, scope, "Offset should not be negative");
offset = static_cast<unsigned>(std::min(offsetNumber, static_cast<double>(std::numeric_limits<unsigned>::max())));
@@ -137,8 +133,7 @@
} else
length = sourceArray->get(exec, vm.propertyNames->length).toUInt32(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
thisObject->set(exec, offset, sourceArray, 0, length, CopyType::Unobservable);
return JSValue::encode(jsUndefined());
@@ -156,14 +151,11 @@
long length = thisObject->length();
long to = argumentClampedIndexFromStartOrEnd(exec, 0, length);
- if (UNLIKELY(scope.exception()))
- return encodedJSValue();
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
long from = argumentClampedIndexFromStartOrEnd(exec, 1, length);
- if (UNLIKELY(scope.exception()))
- return encodedJSValue();
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
long final = argumentClampedIndexFromStartOrEnd(exec, 2, length, length);
- if (UNLIKELY(scope.exception()))
- return encodedJSValue();
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (final < from)
return JSValue::encode(exec->thisValue());
@@ -196,8 +188,7 @@
JSValue valueToFind = exec->argument(0);
unsigned index = argumentClampedIndexFromStartOrEnd(exec, 1, length);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (thisObject->isNeutered())
return throwVMTypeError(exec, scope, typedArrayBufferHasBeenDetachedErrorMessage);
@@ -242,8 +233,7 @@
JSValue valueToFind = exec->argument(0);
unsigned index = argumentClampedIndexFromStartOrEnd(exec, 1, length);
- if (UNLIKELY(scope.exception()))
- return encodedJSValue();
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (thisObject->isNeutered())
return throwVMTypeError(exec, scope, typedArrayBufferHasBeenDetachedErrorMessage);
@@ -278,12 +268,10 @@
unsigned length = thisObject->length();
JSStringJoiner joiner(*exec, separator, length);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
for (unsigned i = 0; i < length; i++) {
joiner.append(*exec, thisObject->getIndexQuickly(i));
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
return JSValue::encode(joiner.join(*exec));
};
@@ -295,8 +283,7 @@
}
JSString* separatorString = separatorValue.toString(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (thisObject->isNeutered())
return throwVMTypeError(exec, scope, typedArrayBufferHasBeenDetachedErrorMessage);
@@ -333,8 +320,7 @@
index = static_cast<unsigned>(fromDouble);
}
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (thisObject->isNeutered())
return throwVMTypeError(exec, scope, typedArrayBufferHasBeenDetachedErrorMessage);
@@ -439,11 +425,9 @@
unsigned thisLength = thisObject->length();
unsigned begin = argumentClampedIndexFromStartOrEnd(exec, 0, thisLength);
- if (UNLIKELY(scope.exception()))
- return encodedJSValue();
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
unsigned end = argumentClampedIndexFromStartOrEnd(exec, 1, thisLength, thisLength);
- if (UNLIKELY(scope.exception()))
- return encodedJSValue();
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (thisObject->isNeutered())
return throwVMTypeError(exec, scope, typedArrayBufferHasBeenDetachedErrorMessage);
@@ -461,8 +445,7 @@
Structure* structure = callee->globalObject()->typedArrayStructure(ViewClass::TypedArrayStorageType);
return ViewClass::createUninitialized(exec, structure, length);
});
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
ASSERT(!result->isNeutered());
if (thisObject->isNeutered())
@@ -565,8 +548,7 @@
args.append(jsNumber(length));
JSObject* result = construct(exec, species, args, "species is not a constructor");
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (jsDynamicCast<JSArrayBufferView*>(result))
return JSValue::encode(result);
diff --git a/Source/JavaScriptCore/runtime/JSGlobalObject.h b/Source/JavaScriptCore/runtime/JSGlobalObject.h
index 35cd05f..0dead2b 100644
--- a/Source/JavaScriptCore/runtime/JSGlobalObject.h
+++ b/Source/JavaScriptCore/runtime/JSGlobalObject.h
@@ -816,8 +816,7 @@
structure = globalObject->arrayStructureForIndexingTypeDuringAllocation(exec, ArrayWithArrayStorage, newTarget);
else
structure = globalObject->arrayStructureForProfileDuringAllocation(exec, profile, newTarget);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
return ArrayAllocationProfile::updateLastAllocationFor(profile, JSArray::create(exec->vm(), structure, initialLength));
}
@@ -832,8 +831,7 @@
VM& vm = globalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
Structure* structure = globalObject->arrayStructureForProfileDuringAllocation(exec, profile, newTarget);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
return ArrayAllocationProfile::updateLastAllocationFor(profile, constructArray(exec, structure, values));
}
@@ -847,8 +845,7 @@
VM& vm = globalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
Structure* structure = globalObject->arrayStructureForProfileDuringAllocation(exec, profile, newTarget);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
return ArrayAllocationProfile::updateLastAllocationFor(profile, constructArray(exec, structure, values, length));
}
@@ -862,8 +859,7 @@
VM& vm = globalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
Structure* structure = globalObject->arrayStructureForProfileDuringAllocation(exec, profile, newTarget);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
return ArrayAllocationProfile::updateLastAllocationFor(profile, constructArrayNegativeIndexed(exec, structure, values, length));
}
diff --git a/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp b/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
index f04d9d3..085adfb 100644
--- a/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
+++ b/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
@@ -660,8 +660,7 @@
}
String s = x.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (s.is8Bit()) {
LiteralParser<LChar> preparser(exec, s.characters8(), s.length(), NonStrictJSON);
diff --git a/Source/JavaScriptCore/runtime/JSModuleRecord.cpp b/Source/JavaScriptCore/runtime/JSModuleRecord.cpp
index 183f258..d00e9f4 100644
--- a/Source/JavaScriptCore/runtime/JSModuleRecord.cpp
+++ b/Source/JavaScriptCore/runtime/JSModuleRecord.cpp
@@ -778,8 +778,7 @@
JSModuleRecord* importedModule = hostResolveImportedModule(exec, importEntry.moduleRequest);
if (importEntry.isNamespace(vm)) {
JSModuleNamespaceObject* namespaceObject = importedModule->getModuleNamespace(exec);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
bool putResult = false;
symbolTablePutTouchWatchpointSet(moduleEnvironment, exec, importEntry.localName, namespaceObject, /* shouldThrowReadOnlyError */ false, /* ignoreReadOnlyErrors */ true, putResult);
} else {
diff --git a/Source/JavaScriptCore/runtime/JSONObject.cpp b/Source/JavaScriptCore/runtime/JSONObject.cpp
index 330b6c2..ee8a8d2 100644
--- a/Source/JavaScriptCore/runtime/JSONObject.cpp
+++ b/Source/JavaScriptCore/runtime/JSONObject.cpp
@@ -253,8 +253,7 @@
VM& vm = m_exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSObject* object = constructEmptyObject(m_exec);
- if (UNLIKELY(scope.exception()))
- return Local<Unknown>(vm, jsNull());
+ RETURN_IF_EXCEPTION(scope, Local<Unknown>(vm, jsNull()));
PropertyNameForFunctionCall emptyPropertyName(vm.propertyNames->emptyIdentifier);
object->putDirect(vm, vm.propertyNames->emptyIdentifier, value.get());
@@ -262,8 +261,7 @@
StringBuilder result;
if (appendStringifiedValue(result, value.get(), object, emptyPropertyName) != StringifySucceeded)
return Local<Unknown>(vm, jsUndefined());
- if (UNLIKELY(scope.exception()))
- return Local<Unknown>(vm, jsNull());
+ RETURN_IF_EXCEPTION(scope, Local<Unknown>(vm, jsNull()));
return Local<Unknown>(vm, jsString(m_exec, result.toString()));
}
@@ -282,8 +280,7 @@
return value;
JSValue toJSONFunction = slot.getValue(m_exec, vm.propertyNames->toJSON);
- if (UNLIKELY(scope.exception()))
- return jsNull();
+ RETURN_IF_EXCEPTION(scope, JSValue());
return toJSONImpl(value, toJSONFunction, propertyName);
}
@@ -306,8 +303,7 @@
// Call the toJSON function.
value = toJSON(value, propertyName);
- if (UNLIKELY(scope.exception()))
- return StringifyFailed;
+ RETURN_IF_EXCEPTION(scope, StringifyFailed);
// Call the replacer function.
if (m_replacerCallType != CallType::None) {
@@ -315,8 +311,7 @@
args.append(propertyName.value(m_exec));
args.append(value);
value = call(m_exec, m_replacer.get(), m_replacerCallType, m_replacerCallData, holder, args);
- if (UNLIKELY(scope.exception()))
- return StringifyFailed;
+ RETURN_IF_EXCEPTION(scope, StringifyFailed);
}
if ((value.isUndefined() || value.isSymbol()) && !holder->inherits(JSArray::info()))
@@ -329,8 +324,7 @@
value = unwrapBoxedPrimitive(m_exec, value);
- if (UNLIKELY(scope.exception()))
- return StringifyFailed;
+ RETURN_IF_EXCEPTION(scope, StringifyFailed);
if (value.isBoolean()) {
if (value.isTrue())
@@ -382,16 +376,13 @@
bool holderStackWasEmpty = m_holderStack.isEmpty();
m_holderStack.append(Holder(vm, m_exec, object));
- if (UNLIKELY(scope.exception()))
- return StringifyFailed;
+ RETURN_IF_EXCEPTION(scope, StringifyFailed);
if (!holderStackWasEmpty)
return StringifySucceeded;
do {
- while (m_holderStack.last().appendNextProperty(*this, builder)) {
- if (UNLIKELY(scope.exception()))
- return StringifyFailed;
- }
+ while (m_holderStack.last().appendNextProperty(*this, builder))
+ RETURN_IF_EXCEPTION(scope, StringifyFailed);
m_holderStack.removeLast();
} while (!m_holderStack.isEmpty());
return StringifySucceeded;
@@ -459,8 +450,7 @@
else {
PropertyNameArray objectPropertyNames(exec, PropertyNameMode::Strings);
m_object->methodTable()->getOwnPropertyNames(m_object.get(), exec, objectPropertyNames, EnumerationMode());
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
m_propertyNames = objectPropertyNames.releaseData();
}
m_size = m_propertyNames->propertyNameVector().size();
@@ -493,8 +483,7 @@
value = slot.getValue(exec, index);
else
value = jsUndefined();
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
}
// Append the separator string.
@@ -511,8 +500,7 @@
if (!m_object->methodTable()->getOwnPropertySlot(m_object.get(), exec, propertyName, slot))
return true;
JSValue value = slot.getValue(exec, propertyName);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
rollBackPoint = builder.length();
@@ -647,8 +635,7 @@
inValue = slot.getValue(m_exec, index);
else
inValue = jsUndefined();
- if (UNLIKELY(scope.exception()))
- return jsNull();
+ RETURN_IF_EXCEPTION(scope, JSValue());
}
if (inValue.isObject()) {
@@ -665,8 +652,7 @@
array->methodTable()->deletePropertyByIndex(array, m_exec, indexStack.last());
else
array->putDirectIndex(m_exec, indexStack.last(), filteredValue);
- if (UNLIKELY(scope.exception()))
- return jsNull();
+ RETURN_IF_EXCEPTION(scope, JSValue());
indexStack.last()++;
goto arrayStartVisitMember;
}
@@ -682,8 +668,7 @@
indexStack.append(0);
propertyStack.append(PropertyNameArray(m_exec, PropertyNameMode::Strings));
object->methodTable()->getOwnPropertyNames(object, m_exec, propertyStack.last(), EnumerationMode());
- if (UNLIKELY(scope.exception()))
- return jsNull();
+ RETURN_IF_EXCEPTION(scope, JSValue());
}
objectStartVisitMember:
FALLTHROUGH;
@@ -705,8 +690,7 @@
inValue = jsUndefined();
// The holder may be modified by the reviver function so any lookup may throw
- if (UNLIKELY(scope.exception()))
- return jsNull();
+ RETURN_IF_EXCEPTION(scope, JSValue());
if (inValue.isObject()) {
stateStack.append(ObjectEndVisitMember);
@@ -724,8 +708,7 @@
object->methodTable()->deleteProperty(object, m_exec, prop);
else
object->methodTable()->put(object, m_exec, prop, filteredValue, slot);
- if (UNLIKELY(scope.exception()))
- return jsNull();
+ RETURN_IF_EXCEPTION(scope, JSValue());
indexStack.last()++;
goto objectStartVisitMember;
}
@@ -761,8 +744,7 @@
if (!exec->argumentCount())
return throwVMError(exec, scope, createError(exec, ASCIILiteral("JSON.parse requires at least one parameter")));
JSString::SafeView source = exec->uncheckedArgument(0).toString(exec)->view(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsNull());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSValue unfiltered;
LocalScope localScope(vm);
diff --git a/Source/JavaScriptCore/runtime/JSObject.cpp b/Source/JavaScriptCore/runtime/JSObject.cpp
index 76b737e..e620a6c 100644
--- a/Source/JavaScriptCore/runtime/JSObject.cpp
+++ b/Source/JavaScriptCore/runtime/JSObject.cpp
@@ -360,14 +360,12 @@
// 9.1.9.1-2 Let ownDesc be ? O.[[GetOwnProperty]](P).
bool ownDescriptorFound = current->getOwnPropertyDescriptor(exec, propertyName, ownDescriptor);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
if (!ownDescriptorFound) {
// 9.1.9.1-3-a Let parent be ? O.[[GetPrototypeOf]]().
JSValue prototype = current->getPrototype(vm, exec);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
// 9.1.9.1-3-b If parent is not null, then
if (!prototype.isNull()) {
@@ -398,8 +396,7 @@
JSObject* receiverObject = asObject(receiver);
PropertyDescriptor existingDescriptor;
bool existingDescriptorFound = receiverObject->getOwnPropertyDescriptor(exec, propertyName, existingDescriptor);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
// 9.1.9.1-4-d If existingDescriptor is not undefined, then
if (existingDescriptorFound) {
@@ -1290,8 +1287,7 @@
return true;
bool isExtensible = this->isExtensible(exec);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
if (!isExtensible) {
if (shouldThrowIfCantSet)
@@ -1533,8 +1529,7 @@
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue function = object->get(exec, propertyName);
- if (UNLIKELY(scope.exception()))
- return scope.exception();
+ RETURN_IF_EXCEPTION(scope, scope.exception());
if (function.isUndefined() && mode == TypeHintMode::TakesHint)
return JSValue();
CallData callData;
@@ -1560,9 +1555,8 @@
}
JSValue result = call(exec, function, callType, callData, const_cast<JSObject*>(object), callArgs);
+ RETURN_IF_EXCEPTION(scope, scope.exception());
ASSERT(!result.isGetterSetter());
- if (UNLIKELY(scope.exception()))
- return scope.exception();
if (result.isObject())
return mode == TypeHintMode::DoesNotTakeHint ? JSValue() : throwTypeError(exec, scope, ASCIILiteral("Symbol.toPrimitive returned an object"));
return result;
@@ -1699,8 +1693,7 @@
JSObject* object = asObject(value);
while (true) {
JSValue objectValue = object->getPrototype(vm, exec);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
if (!objectValue.isObject())
return false;
object = asObject(objectValue);
@@ -1723,12 +1716,10 @@
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
object->methodTable(vm)->getOwnPropertyNames(object, exec, propertyNames, mode);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
JSValue nextProto = object->getPrototype(vm, exec);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
if (nextProto.isNull())
return;
@@ -1739,11 +1730,9 @@
break;
}
prototype->methodTable(vm)->getOwnPropertyNames(prototype, exec, propertyNames, mode);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
nextProto = prototype->getPrototype(vm, exec);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
if (nextProto.isNull())
break;
prototype = asObject(nextProto);
@@ -1843,8 +1832,7 @@
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue primitive = toPrimitive(exec, PreferNumber);
- if (UNLIKELY(scope.exception())) // should be picked up soon in Nodes.cpp
- return 0.0;
+ RETURN_IF_EXCEPTION(scope, 0.0); // should be picked up soon in Nodes.cpp
return primitive.toNumber(exec);
}
@@ -1853,8 +1841,7 @@
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue primitive = toPrimitive(exec, PreferString);
- if (UNLIKELY(scope.exception()))
- return jsEmptyString(exec);
+ RETURN_IF_EXCEPTION(scope, jsEmptyString(exec));
return primitive.toString(exec);
}
@@ -3078,8 +3065,7 @@
PropertyDescriptor current;
bool isCurrentDefined = getOwnPropertyDescriptor(exec, propertyName, current);
bool isExtensible = this->isExtensible(exec);
- if (UNLIKELY(throwScope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(throwScope, false);
return validateAndApplyPropertyDescriptor(exec, this, propertyName, isExtensible, descriptor, isCurrentDefined, current, throwException);
}
@@ -3180,12 +3166,10 @@
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
object->methodTable(vm)->getOwnPropertyNames(object, exec, propertyNames, EnumerationMode(mode, JSObjectPropertiesMode::Exclude));
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
JSValue nextProto = object->getPrototype(vm, exec);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
if (nextProto.isNull())
return;
@@ -3196,11 +3180,9 @@
break;
}
prototype->methodTable(vm)->getOwnPropertyNames(prototype, exec, propertyNames, mode);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
nextProto = prototype->getPrototype(vm, exec);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
if (nextProto.isNull())
break;
prototype = asObject(nextProto);
@@ -3215,8 +3197,7 @@
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue method = get(exec, ident);
- if (UNLIKELY(scope.exception()))
- return jsUndefined();
+ RETURN_IF_EXCEPTION(scope, JSValue());
if (!method.isCell()) {
if (method.isUndefinedOrNull())
diff --git a/Source/JavaScriptCore/runtime/JSObjectInlines.h b/Source/JavaScriptCore/runtime/JSObjectInlines.h
index 6c7c321..156119a 100644
--- a/Source/JavaScriptCore/runtime/JSObjectInlines.h
+++ b/Source/JavaScriptCore/runtime/JSObjectInlines.h
@@ -40,17 +40,14 @@
Vector<JSValue> result;
JSValue lengthProperty = arrayLikeValue.get(exec, vm.propertyNames->length);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
double lengthAsDouble = lengthProperty.toLength(exec);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
RELEASE_ASSERT(lengthAsDouble >= 0.0 && lengthAsDouble == std::trunc(lengthAsDouble));
uint64_t length = static_cast<uint64_t>(lengthAsDouble);
for (uint64_t index = 0; index < length; index++) {
JSValue next = arrayLikeValue.get(exec, index);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
RuntimeType type = runtimeTypeForValue(next);
if (!(type & legalTypesFilter)) {
@@ -99,8 +96,7 @@
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
bool found = const_cast<JSObject*>(this)->getPropertySlot(exec, propertyName, slot);
- if (UNLIKELY(scope.exception()))
- return { };
+ RETURN_IF_EXCEPTION(scope, { });
return callback(found, slot);
}
@@ -115,15 +111,13 @@
Structure& structure = *structureIDTable.get(object->structureID());
if (structure.classInfo()->methodTable.getOwnPropertySlotByIndex(object, exec, propertyName, slot))
return true;
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
JSValue prototype;
if (LIKELY(structure.classInfo()->methodTable.getPrototype == defaultGetPrototype || slot.internalMethodType() == PropertySlot::InternalMethodType::VMInquiry))
prototype = structure.storedPrototype();
else {
prototype = object->getPrototype(vm, exec);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
}
if (!prototype.isObject())
return false;
@@ -149,16 +143,14 @@
} else {
if (structure.classInfo()->methodTable.getOwnPropertySlot(object, exec, propertyName, slot))
return true;
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
}
JSValue prototype;
if (LIKELY(structure.classInfo()->methodTable.getPrototype == defaultGetPrototype || slot.internalMethodType() == PropertySlot::InternalMethodType::VMInquiry))
prototype = structure.storedPrototype();
else {
prototype = object->getPrototype(vm, exec);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
}
if (!prototype.isObject())
return false;
diff --git a/Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp b/Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp
index 3e37dc1..434ab2a 100644
--- a/Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp
+++ b/Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp
@@ -103,8 +103,7 @@
return throwVMTypeError(exec, scope);
Structure* promiseStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), globalObject->promiseStructure());
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSPromise* promise = JSPromise::create(vm, promiseStructure);
promise->initialize(exec, globalObject, exec->argument(0));
diff --git a/Source/JavaScriptCore/runtime/JSPromiseDeferred.cpp b/Source/JavaScriptCore/runtime/JSPromiseDeferred.cpp
index 7022fab..06afc98 100644
--- a/Source/JavaScriptCore/runtime/JSPromiseDeferred.cpp
+++ b/Source/JavaScriptCore/runtime/JSPromiseDeferred.cpp
@@ -57,8 +57,7 @@
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue deferred = newPromiseCapability(exec, globalObject, globalObject->promiseConstructor());
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
JSValue promise = deferred.get(exec, vm.propertyNames->builtinNames().promisePrivateName());
ASSERT(promise.inherits(JSPromise::info()));
diff --git a/Source/JavaScriptCore/runtime/JSPropertyNameEnumerator.h b/Source/JavaScriptCore/runtime/JSPropertyNameEnumerator.h
index 9c0885f..447da25 100644
--- a/Source/JavaScriptCore/runtime/JSPropertyNameEnumerator.h
+++ b/Source/JavaScriptCore/runtime/JSPropertyNameEnumerator.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2014, 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -129,8 +129,7 @@
// So disable indexed property enumeration phase by setting |indexedLength| to 0.
indexedLength = 0;
base->methodTable(vm)->getPropertyNames(base, exec, propertyNames, EnumerationMode());
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
}
ASSERT(propertyNames.size() < UINT32_MAX);
diff --git a/Source/JavaScriptCore/runtime/JSPropertyNameIterator.cpp b/Source/JavaScriptCore/runtime/JSPropertyNameIterator.cpp
index b136859..ab3e11b 100644
--- a/Source/JavaScriptCore/runtime/JSPropertyNameIterator.cpp
+++ b/Source/JavaScriptCore/runtime/JSPropertyNameIterator.cpp
@@ -58,8 +58,7 @@
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSPropertyNameEnumerator* enumerator = propertyNameEnumerator(exec, iteratedObject);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
return JSPropertyNameIterator::create(exec, structure, iteratedObject, enumerator);
}
diff --git a/Source/JavaScriptCore/runtime/JSScope.cpp b/Source/JavaScriptCore/runtime/JSScope.cpp
index bb432d1..0af786d 100644
--- a/Source/JavaScriptCore/runtime/JSScope.cpp
+++ b/Source/JavaScriptCore/runtime/JSScope.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012-2015 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2012-2016 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -206,13 +206,11 @@
return false;
JSValue unscopables = object->get(exec, exec->propertyNames().unscopablesSymbol);
- if (UNLIKELY(throwScope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(throwScope, false);
if (!unscopables.isObject())
return false;
JSValue blocked = jsCast<JSObject*>(unscopables)->get(exec, ident);
- if (UNLIKELY(throwScope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(throwScope, false);
return blocked.toBoolean(exec);
}
diff --git a/Source/JavaScriptCore/runtime/JSString.cpp b/Source/JavaScriptCore/runtime/JSString.cpp
index d3c7e6e..60c8f88 100644
--- a/Source/JavaScriptCore/runtime/JSString.cpp
+++ b/Source/JavaScriptCore/runtime/JSString.cpp
@@ -78,8 +78,7 @@
auto scope = DECLARE_THROW_SCOPE(vm);
String str1 = value(exec);
String str2 = other->value(exec);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
return WTF::equal(*str1.impl(), *str2.impl());
}
diff --git a/Source/JavaScriptCore/runtime/JSStringJoiner.cpp b/Source/JavaScriptCore/runtime/JSStringJoiner.cpp
index 7845356..136cbf0 100644
--- a/Source/JavaScriptCore/runtime/JSStringJoiner.cpp
+++ b/Source/JavaScriptCore/runtime/JSStringJoiner.cpp
@@ -108,8 +108,7 @@
ASSERT(m_strings.size() <= m_strings.capacity());
unsigned length = joinedLength(state);
- if (UNLIKELY(scope.exception()))
- return jsUndefined();
+ RETURN_IF_EXCEPTION(scope, JSValue());
if (!length)
return jsEmptyString(&state);
diff --git a/Source/JavaScriptCore/runtime/LiteralParser.cpp b/Source/JavaScriptCore/runtime/LiteralParser.cpp
index 4da3d07..56e0389 100644
--- a/Source/JavaScriptCore/runtime/LiteralParser.cpp
+++ b/Source/JavaScriptCore/runtime/LiteralParser.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2009, 2016 Apple Inc. All rights reserved.
* Copyright (C) 2012 Mathias Bynens (mathias@qiwi.be)
*
* Redistribution and use in source and binary forms, with or without
@@ -584,8 +584,7 @@
startParseArray:
case StartParseArray: {
JSArray* array = constructEmptyArray(m_exec, 0);
- if (UNLIKELY(scope.exception()))
- return JSValue();
+ RETURN_IF_EXCEPTION(scope, JSValue());
objectStack.append(array);
}
doParseArrayStartExpression:
diff --git a/Source/JavaScriptCore/runtime/MapBase.h b/Source/JavaScriptCore/runtime/MapBase.h
index 419c04e..7d5c12e 100644
--- a/Source/JavaScriptCore/runtime/MapBase.h
+++ b/Source/JavaScriptCore/runtime/MapBase.h
@@ -75,8 +75,7 @@
Base::finishCreation(vm);
auto scope = DECLARE_THROW_SCOPE(vm);
HashMapImplType* impl = HashMapImplType::create(exec, vm);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
m_map.set(vm, this, impl);
}
diff --git a/Source/JavaScriptCore/runtime/MapConstructor.cpp b/Source/JavaScriptCore/runtime/MapConstructor.cpp
index 201afec..4838d10 100644
--- a/Source/JavaScriptCore/runtime/MapConstructor.cpp
+++ b/Source/JavaScriptCore/runtime/MapConstructor.cpp
@@ -61,18 +61,15 @@
JSGlobalObject* globalObject = asInternalFunction(exec->callee())->globalObject();
Structure* mapStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), globalObject->mapStructure());
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSMap* map = JSMap::create(exec, vm, mapStructure);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSValue iterable = exec->argument(0);
if (iterable.isUndefinedOrNull())
return JSValue::encode(map);
JSValue adderFunction = map->JSObject::get(exec, exec->propertyNames().set);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
CallData adderFunctionCallData;
CallType adderFunctionCallType = getCallData(adderFunction, adderFunctionCallData);
@@ -87,12 +84,10 @@
}
JSValue key = nextItem.get(exec, static_cast<unsigned>(0));
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
JSValue value = nextItem.get(exec, static_cast<unsigned>(1));
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
MarkedArgumentBuffer arguments;
arguments.append(key);
diff --git a/Source/JavaScriptCore/runtime/MathObject.cpp b/Source/JavaScriptCore/runtime/MathObject.cpp
index d0406cc..a5cbb9b 100644
--- a/Source/JavaScriptCore/runtime/MathObject.cpp
+++ b/Source/JavaScriptCore/runtime/MathObject.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
- * Copyright (C) 2007, 2008, 2013, 2015 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2007-2008, 2013, 2015-2016 Apple Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -165,8 +165,7 @@
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
uint32_t value = exec->argument(0).toUInt32(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsNull());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(JSValue(clz32(value)));
}
@@ -195,8 +194,7 @@
args.reserveInitialCapacity(argsCount);
for (unsigned i = 0; i < argsCount; ++i) {
args.uncheckedAppend(exec->uncheckedArgument(i).toNumber(exec));
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsNull());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (std::isinf(args[i]))
return JSValue::encode(jsDoubleNumber(+std::numeric_limits<double>::infinity()));
max = std::max(fabs(args[i]), max);
@@ -299,8 +297,7 @@
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
int32_t left = exec->argument(0).toInt32(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsNull());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
int32_t right = exec->argument(1).toInt32(exec);
return JSValue::encode(jsNumber(left * right));
}
diff --git a/Source/JavaScriptCore/runtime/ModuleLoaderPrototype.cpp b/Source/JavaScriptCore/runtime/ModuleLoaderPrototype.cpp
index a55f404..a00b870 100644
--- a/Source/JavaScriptCore/runtime/ModuleLoaderPrototype.cpp
+++ b/Source/JavaScriptCore/runtime/ModuleLoaderPrototype.cpp
@@ -112,12 +112,10 @@
auto scope = DECLARE_THROW_SCOPE(vm);
const Identifier moduleKey = exec->argument(0).toPropertyKey(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
String source = exec->argument(1).toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
SourceCode sourceCode = makeSource(source, moduleKey.impl());
@@ -149,8 +147,7 @@
return JSValue::encode(constructEmptyArray(exec, nullptr));
JSArray* result = constructEmptyArray(exec, nullptr, moduleRecord->requestedModules().size());
- if (UNLIKELY(scope.exception()))
- JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
size_t i = 0;
for (auto& key : moduleRecord->requestedModules())
result->putDirectIndex(exec, i++, jsString(exec, key.get()));
@@ -170,8 +167,7 @@
dataLog("Loader [link] ", moduleRecord->moduleKey(), "\n");
moduleRecord->link(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(jsUndefined());
}
diff --git a/Source/JavaScriptCore/runtime/NativeErrorConstructor.cpp b/Source/JavaScriptCore/runtime/NativeErrorConstructor.cpp
index 77d8c03..0a87991 100644
--- a/Source/JavaScriptCore/runtime/NativeErrorConstructor.cpp
+++ b/Source/JavaScriptCore/runtime/NativeErrorConstructor.cpp
@@ -67,8 +67,7 @@
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue message = exec->argument(0);
Structure* errorStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), jsCast<NativeErrorConstructor*>(exec->callee())->errorStructure());
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
ASSERT(errorStructure);
return JSValue::encode(ErrorInstance::create(exec, errorStructure, message, nullptr, TypeNothing, false));
}
diff --git a/Source/JavaScriptCore/runtime/NumberConstructor.cpp b/Source/JavaScriptCore/runtime/NumberConstructor.cpp
index a6daf6d..c2d8d70 100644
--- a/Source/JavaScriptCore/runtime/NumberConstructor.cpp
+++ b/Source/JavaScriptCore/runtime/NumberConstructor.cpp
@@ -89,8 +89,7 @@
auto scope = DECLARE_THROW_SCOPE(vm);
double n = exec->argumentCount() ? exec->uncheckedArgument(0).toNumber(exec) : 0;
Structure* structure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), exec->lexicalGlobalObject()->numberObjectStructure());
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
NumberObject* object = NumberObject::create(exec->vm(), structure);
object->setInternalValue(exec->vm(), jsNumber(n));
diff --git a/Source/JavaScriptCore/runtime/ObjectConstructor.cpp b/Source/JavaScriptCore/runtime/ObjectConstructor.cpp
index d99149a..781fcbc 100644
--- a/Source/JavaScriptCore/runtime/ObjectConstructor.cpp
+++ b/Source/JavaScriptCore/runtime/ObjectConstructor.cpp
@@ -130,8 +130,7 @@
if (newTarget && newTarget != objectConstructor) {
// a. Return ? OrdinaryCreateFromConstructor(NewTarget, "%ObjectPrototype%").
Structure* objectStructure = InternalFunction::createSubclassStructure(exec, newTarget, globalObject->objectStructureForObjectConstructor());
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
return constructEmptyObject(exec, objectStructure);
}
@@ -172,8 +171,7 @@
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSObject* object = exec->argument(0).toObject(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(object->getPrototype(exec->vm(), exec));
}
@@ -191,8 +189,7 @@
return throwVMTypeError(exec, scope);
JSObject* object = objectValue.toObject(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(objectValue);
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
bool shouldThrowIfCantSet = true;
bool didSetPrototype = object->setPrototype(vm, exec, protoValue, shouldThrowIfCantSet);
@@ -207,8 +204,7 @@
PropertyDescriptor descriptor;
if (!object->getOwnPropertyDescriptor(exec, propertyName, descriptor))
return jsUndefined();
- if (UNLIKELY(scope.exception()))
- return jsUndefined();
+ RETURN_IF_EXCEPTION(scope, JSValue());
JSObject* result = constructObjectFromPropertyDescriptor(exec, descriptor);
if (!result)
@@ -222,18 +218,15 @@
auto scope = DECLARE_THROW_SCOPE(vm);
PropertyNameArray properties(exec, PropertyNameMode::StringsAndSymbols);
object->methodTable(vm)->getOwnPropertyNames(object, exec, properties, EnumerationMode(DontEnumPropertiesMode::Include));
- if (UNLIKELY(scope.exception()))
- return jsUndefined();
+ RETURN_IF_EXCEPTION(scope, JSValue());
JSObject* descriptors = constructEmptyObject(exec);
- if (UNLIKELY(scope.exception()))
- return jsUndefined();
+ RETURN_IF_EXCEPTION(scope, JSValue());
for (auto& propertyName : properties) {
PropertyDescriptor descriptor;
bool didGetDescriptor = object->getOwnPropertyDescriptor(exec, propertyName, descriptor);
- if (UNLIKELY(scope.exception()))
- return jsUndefined();
+ RETURN_IF_EXCEPTION(scope, JSValue());
if (!didGetDescriptor)
continue;
@@ -255,11 +248,9 @@
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSObject* object = exec->argument(0).toObject(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
auto propertyName = exec->argument(1).toPropertyKey(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(objectConstructorGetOwnPropertyDescriptor(exec, object, propertyName));
}
@@ -268,8 +259,7 @@
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSObject* object = exec->argument(0).toObject(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(objectConstructorGetOwnPropertyDescriptors(exec, object));
}
@@ -279,8 +269,7 @@
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSObject* object = exec->argument(0).toObject(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsNull());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(ownPropertyKeys(exec, object, PropertyNameMode::Strings, DontEnumPropertiesMode::Include));
}
@@ -290,8 +279,7 @@
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSObject* object = exec->argument(0).toObject(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsNull());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(ownPropertyKeys(exec, object, PropertyNameMode::Symbols, DontEnumPropertiesMode::Include));
}
@@ -301,8 +289,7 @@
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSObject* object = exec->argument(0).toObject(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsNull());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(ownPropertyKeys(exec, object, PropertyNameMode::Strings, DontEnumPropertiesMode::Exclude));
}
@@ -311,8 +298,7 @@
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSObject* object = exec->argument(0).toObject(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsNull());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(ownPropertyKeys(exec, object, PropertyNameMode::StringsAndSymbols, DontEnumPropertiesMode::Exclude));
}
@@ -331,41 +317,36 @@
if (description->hasProperty(exec, exec->propertyNames().enumerable)) {
JSValue value = description->get(exec, exec->propertyNames().enumerable);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
desc.setEnumerable(value.toBoolean(exec));
- } else if (UNLIKELY(scope.exception()))
- return false;
+ } else
+ RETURN_IF_EXCEPTION(scope, false);
if (description->hasProperty(exec, exec->propertyNames().configurable)) {
JSValue value = description->get(exec, exec->propertyNames().configurable);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
desc.setConfigurable(value.toBoolean(exec));
- } else if (UNLIKELY(scope.exception()))
- return false;
+ } else
+ RETURN_IF_EXCEPTION(scope, false);
JSValue value;
if (description->hasProperty(exec, exec->propertyNames().value)) {
JSValue value = description->get(exec, exec->propertyNames().value);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
desc.setValue(value);
- } else if (UNLIKELY(scope.exception()))
- return false;
+ } else
+ RETURN_IF_EXCEPTION(scope, false);
if (description->hasProperty(exec, exec->propertyNames().writable)) {
JSValue value = description->get(exec, exec->propertyNames().writable);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
desc.setWritable(value.toBoolean(exec));
- } else if (UNLIKELY(scope.exception()))
- return false;
+ } else
+ RETURN_IF_EXCEPTION(scope, false);
if (description->hasProperty(exec, exec->propertyNames().get)) {
JSValue get = description->get(exec, exec->propertyNames().get);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
if (!get.isUndefined()) {
CallData callData;
if (getCallData(get, callData) == CallType::None) {
@@ -374,13 +355,12 @@
}
}
desc.setGetter(get);
- } else if (UNLIKELY(scope.exception()))
- return false;
+ } else
+ RETURN_IF_EXCEPTION(scope, false);
if (description->hasProperty(exec, exec->propertyNames().set)) {
JSValue set = description->get(exec, exec->propertyNames().set);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
if (!set.isUndefined()) {
CallData callData;
if (getCallData(set, callData) == CallType::None) {
@@ -389,8 +369,8 @@
}
}
desc.setSetter(set);
- } else if (UNLIKELY(scope.exception()))
- return false;
+ } else
+ RETURN_IF_EXCEPTION(scope, false);
if (!desc.isAccessorDescriptor())
return true;
@@ -416,8 +396,7 @@
return throwVMTypeError(exec, scope, ASCIILiteral("Properties can only be defined on Objects."));
JSObject* obj = asObject(exec->argument(0));
auto propertyName = exec->argument(1).toPropertyKey(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsNull());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
PropertyDescriptor descriptor;
auto success = toPropertyDescriptor(exec, exec->argument(2), descriptor);
ASSERT(!scope.exception() == success);
@@ -437,15 +416,13 @@
PropertyNameArray propertyNames(exec, PropertyNameMode::StringsAndSymbols);
asObject(properties)->methodTable(vm)->getOwnPropertyNames(asObject(properties), exec, propertyNames, EnumerationMode(DontEnumPropertiesMode::Exclude));
- if (UNLIKELY(scope.exception()))
- return jsNull();
+ RETURN_IF_EXCEPTION(scope, JSValue());
size_t numProperties = propertyNames.size();
Vector<PropertyDescriptor> descriptors;
MarkedArgumentBuffer markBuffer;
for (size_t i = 0; i < numProperties; i++) {
JSValue prop = properties->get(exec, propertyNames[i]);
- if (UNLIKELY(scope.exception()))
- return jsNull();
+ RETURN_IF_EXCEPTION(scope, JSValue());
PropertyDescriptor descriptor;
if (!toPropertyDescriptor(exec, prop, descriptor))
return jsNull();
@@ -465,8 +442,7 @@
if (exec->propertyNames().isPrivateName(propertyName))
continue;
object->methodTable(vm)->defineOwnProperty(object, exec, propertyName, descriptors[i], true);
- if (UNLIKELY(scope.exception()))
- return jsNull();
+ RETURN_IF_EXCEPTION(scope, JSValue());
}
return object;
}
@@ -522,8 +498,7 @@
// 2. For each named own property name P of O,
PropertyNameArray properties(exec, PropertyNameMode::StringsAndSymbols);
object->methodTable(vm)->getOwnPropertyNames(object, exec, properties, EnumerationMode(DontEnumPropertiesMode::Include));
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(obj);
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
PropertyNameArray::const_iterator end = properties.end();
for (PropertyNameArray::const_iterator iter = properties.begin(); iter != end; ++iter) {
Identifier propertyName = *iter;
@@ -537,14 +512,12 @@
desc.setConfigurable(false);
// c. Call the [[DefineOwnProperty]] internal method of O with P, desc, and true as arguments.
object->methodTable(vm)->defineOwnProperty(object, exec, propertyName, desc, true);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(obj);
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
// 3. Set the [[Extensible]] internal property of O to false.
object->methodTable(vm)->preventExtensions(object, exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
// 4. Return O.
return JSValue::encode(obj);
@@ -563,8 +536,7 @@
// 2. For each named own property name P of O,
PropertyNameArray properties(exec, PropertyNameMode::StringsAndSymbols);
object->methodTable(vm)->getOwnPropertyNames(object, exec, properties, EnumerationMode(DontEnumPropertiesMode::Include));
- if (UNLIKELY(scope.exception()))
- return object;
+ RETURN_IF_EXCEPTION(scope, nullptr);
PropertyNameArray::const_iterator end = properties.end();
for (PropertyNameArray::const_iterator iter = properties.begin(); iter != end; ++iter) {
Identifier propertyName = *iter;
@@ -582,14 +554,12 @@
desc.setConfigurable(false);
// d. Call the [[DefineOwnProperty]] internal method of O with P, desc, and true as arguments.
object->methodTable(vm)->defineOwnProperty(object, exec, propertyName, desc, true);
- if (UNLIKELY(scope.exception()))
- return object;
+ RETURN_IF_EXCEPTION(scope, nullptr);
}
// 3. Set the [[Extensible]] internal property of O to false.
object->methodTable(vm)->preventExtensions(object, exec);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
// 4. Return O.
return object;
@@ -604,8 +574,7 @@
if (!obj.isObject())
return JSValue::encode(obj);
JSObject* result = objectConstructorFreeze(exec, asObject(obj));
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(result);
}
@@ -636,8 +605,7 @@
// 2. For each named own property name P of O,
PropertyNameArray properties(exec, PropertyNameMode::StringsAndSymbols);
object->methodTable(vm)->getOwnPropertyNames(object, exec, properties, EnumerationMode(DontEnumPropertiesMode::Include));
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
PropertyNameArray::const_iterator end = properties.end();
for (PropertyNameArray::const_iterator iter = properties.begin(); iter != end; ++iter) {
Identifier propertyName = *iter;
@@ -655,8 +623,7 @@
// 3. If the [[Extensible]] internal property of O is false, then return true.
// 4. Otherwise, return false.
bool isExtensible = object->isExtensible(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(jsBoolean(!isExtensible));
}
@@ -677,8 +644,7 @@
// 2. For each named own property name P of O,
PropertyNameArray properties(exec, PropertyNameMode::StringsAndSymbols);
object->methodTable(vm)->getOwnPropertyNames(object, exec, properties, EnumerationMode(DontEnumPropertiesMode::Include));
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
PropertyNameArray::const_iterator end = properties.end();
for (PropertyNameArray::const_iterator iter = properties.begin(); iter != end; ++iter) {
Identifier propertyName = *iter;
@@ -697,8 +663,7 @@
// 3. If the [[Extensible]] internal property of O is false, then return true.
// 4. Otherwise, return false.
bool isExtensible = object->isExtensible(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(jsBoolean(!isExtensible));
}
@@ -711,8 +676,7 @@
return JSValue::encode(jsBoolean(false));
JSObject* object = asObject(obj);
bool isExtensible = object->isExtensible(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(jsBoolean(isExtensible));
}
@@ -728,12 +692,10 @@
auto scope = DECLARE_THROW_SCOPE(vm);
PropertyNameArray properties(exec, propertyNameMode);
object->methodTable(vm)->getOwnPropertyNames(object, exec, properties, EnumerationMode(dontEnumPropertiesMode));
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
JSArray* keys = constructEmptyArray(exec, 0);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
switch (propertyNameMode) {
case PropertyNameMode::Strings: {
diff --git a/Source/JavaScriptCore/runtime/ObjectConstructor.h b/Source/JavaScriptCore/runtime/ObjectConstructor.h
index b1614da..89d744a 100644
--- a/Source/JavaScriptCore/runtime/ObjectConstructor.h
+++ b/Source/JavaScriptCore/runtime/ObjectConstructor.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
- * Copyright (C) 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2016 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -103,8 +103,7 @@
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSObject* description = constructEmptyObject(exec);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
if (!descriptor.isAccessorDescriptor()) {
description->putDirect(vm, vm.propertyNames->value, descriptor.value() ? descriptor.value() : jsUndefined(), 0);
diff --git a/Source/JavaScriptCore/runtime/ObjectPrototype.cpp b/Source/JavaScriptCore/runtime/ObjectPrototype.cpp
index 98a88da..cea2775 100644
--- a/Source/JavaScriptCore/runtime/ObjectPrototype.cpp
+++ b/Source/JavaScriptCore/runtime/ObjectPrototype.cpp
@@ -95,8 +95,7 @@
JSValue thisValue = exec->thisValue().toThis(exec, StrictMode);
auto propertyName = exec->argument(0).toPropertyKey(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSObject* thisObject = thisValue.toObject(exec);
if (UNLIKELY(!thisObject))
return JSValue::encode(JSValue());
@@ -111,8 +110,7 @@
PropertySlot slot(thisObject, PropertySlot::InternalMethodType::GetOwnProperty);
bool result = thisObject->hasOwnProperty(exec, propertyName, slot);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
hasOwnPropertyCache->tryAdd(vm, slot, thisObject, propertyName, result);
return JSValue::encode(jsBoolean(result));
@@ -132,8 +130,7 @@
return JSValue::encode(jsBoolean(false));
JSValue v = asObject(exec->argument(0))->getPrototype(vm, exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
while (true) {
if (!v.isObject())
@@ -141,8 +138,7 @@
if (v == thisObj)
return JSValue::encode(jsBoolean(true));
v = asObject(v)->getPrototype(vm, exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
}
@@ -152,8 +148,7 @@
auto scope = DECLARE_THROW_SCOPE(vm);
JSObject* thisObject = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSValue get = exec->argument(1);
CallData callData;
@@ -161,8 +156,7 @@
return throwVMTypeError(exec, scope, ASCIILiteral("invalid getter usage"));
auto propertyName = exec->argument(0).toPropertyKey(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
PropertyDescriptor descriptor;
descriptor.setGetter(get);
@@ -181,8 +175,7 @@
auto scope = DECLARE_THROW_SCOPE(vm);
JSObject* thisObject = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSValue set = exec->argument(1);
CallData callData;
@@ -190,8 +183,7 @@
return throwVMTypeError(exec, scope, ASCIILiteral("invalid setter usage"));
auto propertyName = exec->argument(0).toPropertyKey(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
PropertyDescriptor descriptor;
descriptor.setSetter(set);
@@ -210,12 +202,10 @@
auto scope = DECLARE_THROW_SCOPE(vm);
JSObject* thisObject = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
auto propertyName = exec->argument(0).toPropertyKey(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
PropertySlot slot(thisObject, PropertySlot::InternalMethodType::GetOwnProperty);
if (thisObject->getPropertySlot(exec, propertyName, slot)) {
@@ -240,12 +230,10 @@
auto scope = DECLARE_THROW_SCOPE(vm);
JSObject* thisObject = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
auto propertyName = exec->argument(0).toPropertyKey(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
PropertySlot slot(thisObject, PropertySlot::InternalMethodType::GetOwnProperty);
if (thisObject->getPropertySlot(exec, propertyName, slot)) {
@@ -270,12 +258,10 @@
auto scope = DECLARE_THROW_SCOPE(vm);
auto propertyName = exec->argument(0).toPropertyKey(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSObject* thisObject = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
PropertyDescriptor descriptor;
bool enumerable = thisObject->getOwnPropertyDescriptor(exec, propertyName, descriptor) && descriptor.enumerable();
return JSValue::encode(jsBoolean(enumerable));
@@ -289,8 +275,7 @@
// 1. Let O be the result of calling ToObject passing the this value as the argument.
JSObject* object = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
// 2. Let toString be the result of calling the [[Get]] internal method of O passing "toString" as the argument.
JSValue toString = object->get(exec, exec->propertyNames().toString);
@@ -325,8 +310,7 @@
return JSValue::encode(thisObject->getPropertySlot(exec, toStringTagSymbol, [&] (bool found, PropertySlot& toStringTagSlot) -> JSValue {
if (found) {
JSValue stringTag = toStringTagSlot.getValue(exec, toStringTagSymbol);
- if (UNLIKELY(scope.exception()))
- return jsUndefined();
+ RETURN_IF_EXCEPTION(scope, JSValue());
if (stringTag.isString()) {
JSRopeString::RopeBuilder ropeBuilder(vm);
ropeBuilder.append(vm.smallStrings.objectStringStart());
@@ -340,8 +324,7 @@
}
String tag = thisObject->methodTable(exec->vm())->toStringName(thisObject, exec);
- if (UNLIKELY(scope.exception()))
- return JSValue();
+ RETURN_IF_EXCEPTION(scope, JSValue());
String newString = WTF::tryMakeString("[object ", WTFMove(tag), "]");
if (!newString)
return throwOutOfMemoryError(exec, scope);
diff --git a/Source/JavaScriptCore/runtime/Operations.cpp b/Source/JavaScriptCore/runtime/Operations.cpp
index a6f1a4f..5389aee 100644
--- a/Source/JavaScriptCore/runtime/Operations.cpp
+++ b/Source/JavaScriptCore/runtime/Operations.cpp
@@ -46,11 +46,9 @@
VM& vm = callFrame->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue p1 = v1.toPrimitive(callFrame);
- if (UNLIKELY(scope.exception()))
- return JSValue();
+ RETURN_IF_EXCEPTION(scope, JSValue());
JSValue p2 = v2.toPrimitive(callFrame);
- if (UNLIKELY(scope.exception()))
- return JSValue();
+ RETURN_IF_EXCEPTION(scope, JSValue());
if (p1.isString())
return jsString(callFrame, asString(p1), p2.toString(callFrame));
diff --git a/Source/JavaScriptCore/runtime/PropertyDescriptor.cpp b/Source/JavaScriptCore/runtime/PropertyDescriptor.cpp
index 94edda6..16a3ffb 100644
--- a/Source/JavaScriptCore/runtime/PropertyDescriptor.cpp
+++ b/Source/JavaScriptCore/runtime/PropertyDescriptor.cpp
@@ -79,8 +79,7 @@
JSGlobalObject* globalObject = exec->lexicalGlobalObject();
GetterSetter* getterSetter = GetterSetter::create(vm, globalObject);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
if (m_getter && !m_getter.isUndefined())
getterSetter->setGetter(vm, globalObject, jsCast<JSObject*>(m_getter));
if (m_setter && !m_setter.isUndefined())
diff --git a/Source/JavaScriptCore/runtime/ProxyConstructor.cpp b/Source/JavaScriptCore/runtime/ProxyConstructor.cpp
index f38a066..8ca6a2b 100644
--- a/Source/JavaScriptCore/runtime/ProxyConstructor.cpp
+++ b/Source/JavaScriptCore/runtime/ProxyConstructor.cpp
@@ -64,15 +64,12 @@
JSValue target = args.at(0);
JSValue handler = args.at(1);
ProxyObject* proxy = ProxyObject::create(exec, exec->lexicalGlobalObject(), target, handler);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
ProxyRevoke* revoke = ProxyRevoke::create(vm, exec->lexicalGlobalObject()->proxyRevokeStructure(), proxy);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSObject* result = constructEmptyObject(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
result->putDirect(vm, makeIdentifier(vm, "proxy"), proxy, None);
result->putDirect(vm, makeIdentifier(vm, "revoke"), revoke, None);
diff --git a/Source/JavaScriptCore/runtime/ProxyObject.cpp b/Source/JavaScriptCore/runtime/ProxyObject.cpp
index 8c8e164..9dc72314 100644
--- a/Source/JavaScriptCore/runtime/ProxyObject.cpp
+++ b/Source/JavaScriptCore/runtime/ProxyObject.cpp
@@ -141,8 +141,7 @@
CallData callData;
CallType callType;
JSValue getHandler = handler->getMethod(exec, callData, callType, vm.propertyNames->get, ASCIILiteral("'get' property of a Proxy's handler object should be callable"));
- if (UNLIKELY(scope.exception()))
- return jsUndefined();
+ RETURN_IF_EXCEPTION(scope, JSValue());
if (getHandler.isUndefined())
return performDefaultGet();
@@ -152,8 +151,7 @@
arguments.append(identifierToSafePublicJSValue(vm, Identifier::fromUid(&vm, propertyName.uid())));
arguments.append(receiver);
JSValue trapResult = call(exec, getHandler, callType, callData, handler, arguments);
- if (UNLIKELY(scope.exception()))
- return jsUndefined();
+ RETURN_IF_EXCEPTION(scope, JSValue());
PropertyDescriptor descriptor;
if (target->getOwnPropertyDescriptor(exec, propertyName, descriptor)) {
@@ -166,8 +164,7 @@
}
}
- if (UNLIKELY(scope.exception()))
- return jsUndefined();
+ RETURN_IF_EXCEPTION(scope, JSValue());
return trapResult;
}
@@ -177,8 +174,7 @@
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue result = performProxyGet(exec, this, slot.thisValue(), propertyName);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
unsigned ignoredAttributes = 0;
slot.setValue(this, ignoredAttributes, result);
return true;
@@ -211,8 +207,7 @@
CallData callData;
CallType callType;
JSValue getOwnPropertyDescriptorMethod = handler->getMethod(exec, callData, callType, makeIdentifier(vm, "getOwnPropertyDescriptor"), ASCIILiteral("'getOwnPropertyDescriptor' property of a Proxy's handler should be callable"));
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
if (getOwnPropertyDescriptorMethod.isUndefined())
return performDefaultGetOwnProperty();
@@ -220,8 +215,7 @@
arguments.append(target);
arguments.append(identifierToSafePublicJSValue(vm, Identifier::fromUid(&vm, propertyName.uid())));
JSValue trapResult = call(exec, getOwnPropertyDescriptorMethod, callType, callData, handler, arguments);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
if (!trapResult.isUndefined() && !trapResult.isObject()) {
throwVMTypeError(exec, scope, ASCIILiteral("result of 'getOwnPropertyDescriptor' call should either be an Object or undefined"));
@@ -230,8 +224,7 @@
PropertyDescriptor targetPropertyDescriptor;
bool isTargetPropertyDescriptorDefined = target->getOwnPropertyDescriptor(exec, propertyName, targetPropertyDescriptor);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
if (trapResult.isUndefined()) {
if (!isTargetPropertyDescriptorDefined)
@@ -243,8 +236,7 @@
// FIXME: this doesn't work if 'target' is another Proxy. We don't have isExtensible implemented in a way that fits w/ Proxys.
// https://bugs.webkit.org/show_bug.cgi?id=154375
bool isExtensible = target->isExtensible(exec);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
if (!isExtensible) {
// FIXME: Come up with a test for this error. I'm not sure how to because
// Object.seal(o) will make all fields [[Configurable]] false.
@@ -257,12 +249,10 @@
}
bool isExtensible = target->isExtensible(exec);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
PropertyDescriptor trapResultAsDescriptor;
toPropertyDescriptor(exec, trapResult, trapResultAsDescriptor);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
bool throwException = false;
bool valid = validateAndApplyPropertyDescriptor(exec, nullptr, propertyName, isExtensible,
trapResultAsDescriptor, isTargetPropertyDescriptorDefined, targetPropertyDescriptor, throwException);
@@ -280,8 +270,7 @@
if (trapResultAsDescriptor.isAccessorDescriptor()) {
GetterSetter* getterSetter = trapResultAsDescriptor.slowGetterSetter(exec);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
slot.setGetterSlot(this, trapResultAsDescriptor.attributes(), getterSetter);
} else if (trapResultAsDescriptor.isDataDescriptor() && !trapResultAsDescriptor.value().isEmpty())
slot.setValue(this, trapResultAsDescriptor.attributes(), trapResultAsDescriptor.value());
@@ -319,8 +308,7 @@
CallData callData;
CallType callType;
JSValue hasMethod = handler->getMethod(exec, callData, callType, vm.propertyNames->has, ASCIILiteral("'has' property of a Proxy's handler should be callable"));
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
if (hasMethod.isUndefined())
return performDefaultHasProperty();
@@ -328,26 +316,22 @@
arguments.append(target);
arguments.append(identifierToSafePublicJSValue(vm, Identifier::fromUid(&vm, propertyName.uid())));
JSValue trapResult = call(exec, hasMethod, callType, callData, handler, arguments);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
bool trapResultAsBool = trapResult.toBoolean(exec);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
if (!trapResultAsBool) {
PropertyDescriptor descriptor;
bool isPropertyDescriptorDefined = target->getOwnPropertyDescriptor(exec, propertyName, descriptor);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
if (isPropertyDescriptorDefined) {
if (!descriptor.configurable()) {
throwVMTypeError(exec, scope, ASCIILiteral("Proxy 'has' must return 'true' for non-configurable properties"));
return false;
}
bool isExtensible = target->isExtensible(exec);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
if (!isExtensible) {
throwVMTypeError(exec, scope, ASCIILiteral("Proxy 'has' must return 'true' for a non-extensible 'target' object with a configurable property"));
return false;
@@ -419,8 +403,7 @@
CallData callData;
CallType callType;
JSValue setMethod = handler->getMethod(exec, callData, callType, vm.propertyNames->set, ASCIILiteral("'set' property of a Proxy's handler should be callable"));
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
JSObject* target = this->target();
if (setMethod.isUndefined())
return performDefaultPut();
@@ -431,11 +414,9 @@
arguments.append(putValue);
arguments.append(thisValue);
JSValue trapResult = call(exec, setMethod, callType, callData, handler, arguments);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
bool trapResultAsBool = trapResult.toBoolean(exec);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
if (!trapResultAsBool)
return false;
@@ -472,8 +453,7 @@
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
Identifier ident = Identifier::from(exec, propertyName);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
auto performDefaultPut = [&] () {
JSObject* target = this->target();
bool isStrictMode = shouldThrow;
@@ -506,8 +486,7 @@
CallData callData;
CallType callType;
JSValue applyMethod = handler->getMethod(exec, callData, callType, makeIdentifier(vm, "apply"), ASCIILiteral("'apply' property of a Proxy's handler should be callable"));
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSObject* target = proxy->target();
if (applyMethod.isUndefined()) {
CallData callData;
@@ -517,8 +496,7 @@
}
JSArray* argArray = constructArray(exec, static_cast<ArrayAllocationProfile*>(nullptr), ArgList(exec));
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
MarkedArgumentBuffer arguments;
arguments.append(target);
arguments.append(exec->thisValue());
@@ -556,8 +534,7 @@
CallData callData;
CallType callType;
JSValue constructMethod = handler->getMethod(exec, callData, callType, makeIdentifier(vm, "construct"), ASCIILiteral("'construct' property of a Proxy's handler should be constructible"));
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSObject* target = proxy->target();
if (constructMethod.isUndefined()) {
ConstructData constructData;
@@ -567,15 +544,13 @@
}
JSArray* argArray = constructArray(exec, static_cast<ArrayAllocationProfile*>(nullptr), ArgList(exec));
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
MarkedArgumentBuffer arguments;
arguments.append(target);
arguments.append(argArray);
arguments.append(exec->newTarget());
JSValue result = call(exec, constructMethod, callType, callData, handler, arguments);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (!result.isObject())
return throwVMTypeError(exec, scope, ASCIILiteral("Result from Proxy handler's 'construct' method should be an object"));
return JSValue::encode(result);
@@ -617,8 +592,7 @@
CallData callData;
CallType callType;
JSValue deletePropertyMethod = handler->getMethod(exec, callData, callType, makeIdentifier(vm, "deleteProperty"), ASCIILiteral("'deleteProperty' property of a Proxy's handler should be callable"));
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
JSObject* target = this->target();
if (deletePropertyMethod.isUndefined())
return performDefaultDelete();
@@ -627,12 +601,10 @@
arguments.append(target);
arguments.append(identifierToSafePublicJSValue(vm, Identifier::fromUid(&vm, propertyName.uid())));
JSValue trapResult = call(exec, deletePropertyMethod, callType, callData, handler, arguments);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
bool trapResultAsBool = trapResult.toBoolean(exec);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
if (!trapResultAsBool)
return false;
@@ -645,8 +617,7 @@
}
}
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
return true;
}
@@ -691,8 +662,7 @@
CallData callData;
CallType callType;
JSValue preventExtensionsMethod = handler->getMethod(exec, callData, callType, makeIdentifier(vm, "preventExtensions"), ASCIILiteral("'preventExtensions' property of a Proxy's handler should be callable"));
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
JSObject* target = this->target();
if (preventExtensionsMethod.isUndefined())
return target->methodTable(vm)->preventExtensions(target, exec);
@@ -700,17 +670,14 @@
MarkedArgumentBuffer arguments;
arguments.append(target);
JSValue trapResult = call(exec, preventExtensionsMethod, callType, callData, handler, arguments);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
bool trapResultAsBool = trapResult.toBoolean(exec);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
if (trapResultAsBool) {
bool targetIsExtensible = target->isExtensible(exec);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
if (targetIsExtensible) {
throwVMTypeError(exec, scope, ASCIILiteral("Proxy's 'preventExtensions' trap returned true even though its target is extensible. It should have returned false"));
return false;
@@ -744,8 +711,7 @@
CallData callData;
CallType callType;
JSValue isExtensibleMethod = handler->getMethod(exec, callData, callType, makeIdentifier(vm, "isExtensible"), ASCIILiteral("'isExtensible' property of a Proxy's handler should be callable"));
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
JSObject* target = this->target();
if (isExtensibleMethod.isUndefined())
@@ -754,16 +720,13 @@
MarkedArgumentBuffer arguments;
arguments.append(target);
JSValue trapResult = call(exec, isExtensibleMethod, callType, callData, handler, arguments);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
bool trapResultAsBool = trapResult.toBoolean(exec);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
bool isTargetExtensible = target->isExtensible(exec);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
if (trapResultAsBool != isTargetExtensible) {
if (isTargetExtensible) {
@@ -811,39 +774,33 @@
CallData callData;
CallType callType;
JSValue definePropertyMethod = handler->getMethod(exec, callData, callType, vm.propertyNames->defineProperty, ASCIILiteral("'defineProperty' property of a Proxy's handler should be callable"));
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
if (definePropertyMethod.isUndefined())
return performDefaultDefineOwnProperty();
JSObject* descriptorObject = constructObjectFromPropertyDescriptor(exec, descriptor);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
MarkedArgumentBuffer arguments;
arguments.append(target);
arguments.append(identifierToSafePublicJSValue(vm, Identifier::fromUid(&vm, propertyName.uid())));
arguments.append(descriptorObject);
JSValue trapResult = call(exec, definePropertyMethod, callType, callData, handler, arguments);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
bool trapResultAsBool = trapResult.toBoolean(exec);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
if (!trapResultAsBool)
return false;
PropertyDescriptor targetDescriptor;
bool isTargetDescriptorDefined = target->getOwnPropertyDescriptor(exec, propertyName, targetDescriptor);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
bool targetIsExtensible = target->isExtensible(exec);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
bool settingConfigurableToFalse = descriptor.configurablePresent() && !descriptor.configurable();
if (!isTargetDescriptorDefined) {
@@ -900,8 +857,7 @@
CallData callData;
CallType callType;
JSValue ownKeysMethod = handler->getMethod(exec, callData, callType, makeIdentifier(vm, "ownKeys"), ASCIILiteral("'ownKeys' property of a Proxy's handler should be callable"));
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
JSObject* target = this->target();
if (ownKeysMethod.isUndefined()) {
target->methodTable(exec->vm())->getOwnPropertyNames(target, exec, trapResult, enumerationMode);
@@ -911,8 +867,7 @@
MarkedArgumentBuffer arguments;
arguments.append(target);
JSValue arrayLikeObject = call(exec, ownKeysMethod, callType, callData, handler, arguments);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
PropertyNameMode propertyNameMode = trapResult.mode();
RuntimeTypeMask resultFilter = 0;
@@ -939,8 +894,7 @@
return dontExitEarly;
Identifier ident = value.toPropertyKey(exec);
- if (UNLIKELY(scope.exception()))
- return doExitEarly;
+ RETURN_IF_EXCEPTION(scope, doExitEarly);
uncheckedResultKeys.add(ident.impl());
trapResult.addUnchecked(ident.impl());
@@ -948,22 +902,19 @@
};
createListFromArrayLike(exec, arrayLikeObject, dontThrowAnExceptionTypeFilter, ASCIILiteral("Proxy handler's 'ownKeys' method must return an array-like object containing only Strings and Symbols"), addPropName);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
bool targetIsExensible = target->isExtensible(exec);
PropertyNameArray targetKeys(&vm, propertyNameMode);
target->methodTable(vm)->getOwnPropertyNames(target, exec, targetKeys, enumerationMode);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
Vector<UniquedStringImpl*> targetConfigurableKeys;
Vector<UniquedStringImpl*> targetNonConfigurableKeys;
for (const Identifier& ident : targetKeys) {
PropertyDescriptor descriptor;
bool isPropertyDefined = target->getOwnPropertyDescriptor(exec, ident.impl(), descriptor);
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
if (isPropertyDefined && !descriptor.configurable())
targetNonConfigurableKeys.append(ident.impl());
else
@@ -1051,8 +1002,7 @@
CallData callData;
CallType callType;
JSValue setPrototypeOfMethod = handler->getMethod(exec, callData, callType, makeIdentifier(vm, "setPrototypeOf"), ASCIILiteral("'setPrototypeOf' property of a Proxy's handler should be callable"));
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
JSObject* target = this->target();
if (setPrototypeOfMethod.isUndefined())
@@ -1062,12 +1012,10 @@
arguments.append(target);
arguments.append(prototype);
JSValue trapResult = call(exec, setPrototypeOfMethod, callType, callData, handler, arguments);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
bool trapResultAsBool = trapResult.toBoolean(exec);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
if (!trapResultAsBool) {
if (shouldThrowIfCantSet)
@@ -1076,14 +1024,12 @@
}
bool targetIsExtensible = target->isExtensible(exec);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
if (targetIsExtensible)
return true;
JSValue targetPrototype = target->getPrototype(vm, exec);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
if (!sameValue(exec, prototype, targetPrototype)) {
throwVMTypeError(exec, scope, ASCIILiteral("Proxy 'setPrototypeOf' trap returned true when its target is non-extensible and the new prototype value is not the same as the current prototype value. It should have returned false"));
return false;
@@ -1116,8 +1062,7 @@
CallData callData;
CallType callType;
JSValue getPrototypeOfMethod = handler->getMethod(exec, callData, callType, makeIdentifier(vm, "getPrototypeOf"), ASCIILiteral("'getPrototypeOf' property of a Proxy's handler should be callable"));
- if (UNLIKELY(scope.exception()))
- return JSValue();
+ RETURN_IF_EXCEPTION(scope, JSValue());
JSObject* target = this->target();
if (getPrototypeOfMethod.isUndefined())
@@ -1126,8 +1071,7 @@
MarkedArgumentBuffer arguments;
arguments.append(target);
JSValue trapResult = call(exec, getPrototypeOfMethod, callType, callData, handler, arguments);
- if (UNLIKELY(scope.exception()))
- return JSValue();
+ RETURN_IF_EXCEPTION(scope, JSValue());
if (!trapResult.isObject() && !trapResult.isNull()) {
throwVMTypeError(exec, scope, ASCIILiteral("Proxy handler's 'getPrototypeOf' trap should either return an object or null"));
@@ -1135,14 +1079,12 @@
}
bool targetIsExtensible = target->isExtensible(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue();
+ RETURN_IF_EXCEPTION(scope, JSValue());
if (targetIsExtensible)
return trapResult;
JSValue targetPrototype = target->getPrototype(vm, exec);
- if (UNLIKELY(scope.exception()))
- return JSValue();
+ RETURN_IF_EXCEPTION(scope, JSValue());
if (!sameValue(exec, targetPrototype, trapResult)) {
throwVMTypeError(exec, scope, ASCIILiteral("Proxy's 'getPrototypeOf' trap for a non-extensible target should return the same value as the target's prototype"));
return JSValue();
diff --git a/Source/JavaScriptCore/runtime/ReflectObject.cpp b/Source/JavaScriptCore/runtime/ReflectObject.cpp
index c2549ec..e3fc820 100644
--- a/Source/JavaScriptCore/runtime/ReflectObject.cpp
+++ b/Source/JavaScriptCore/runtime/ReflectObject.cpp
@@ -123,8 +123,7 @@
arguments.append(value);
return false;
});
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(construct(exec, target, constructType, constructData, arguments, newTarget));
}
@@ -139,8 +138,7 @@
if (!target.isObject())
return JSValue::encode(throwTypeError(exec, scope, ASCIILiteral("Reflect.defineProperty requires the first argument be an object")));
auto propertyName = exec->argument(1).toPropertyKey(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
PropertyDescriptor descriptor;
if (!toPropertyDescriptor(exec, exec->argument(2), descriptor))
@@ -178,8 +176,7 @@
return JSValue::encode(throwTypeError(exec, scope, ASCIILiteral("Reflect.get requires the first argument be an object")));
const Identifier propertyName = exec->argument(1).toPropertyKey(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsNull());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSValue receiver = target;
if (exec->argumentCount() >= 3)
@@ -200,8 +197,7 @@
return JSValue::encode(throwTypeError(exec, scope, ASCIILiteral("Reflect.getOwnPropertyDescriptor requires the first argument be an object")));
auto key = exec->argument(1).toPropertyKey(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(objectConstructorGetOwnPropertyDescriptor(exec, asObject(target), key));
}
@@ -229,8 +225,7 @@
return JSValue::encode(throwTypeError(exec, scope, ASCIILiteral("Reflect.isExtensible requires the first argument be an object")));
bool isExtensible = asObject(target)->isExtensible(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(jsBoolean(isExtensible));
}
@@ -257,8 +252,7 @@
return JSValue::encode(throwTypeError(exec, scope, ASCIILiteral("Reflect.preventExtensions requires the first argument be an object")));
JSObject* object = asObject(target);
bool result = object->methodTable(vm)->preventExtensions(object, exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(jsBoolean(result));
}
@@ -274,8 +268,7 @@
JSObject* targetObject = asObject(target);
auto propertyName = exec->argument(1).toPropertyKey(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSValue receiver = target;
if (exec->argumentCount() >= 4)
@@ -304,8 +297,7 @@
bool shouldThrowIfCantSet = false;
bool didSetPrototype = object->setPrototype(vm, exec, proto, shouldThrowIfCantSet);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(jsBoolean(didSetPrototype));
}
diff --git a/Source/JavaScriptCore/runtime/RegExpConstructor.cpp b/Source/JavaScriptCore/runtime/RegExpConstructor.cpp
index 267febe..7c6cccd 100644
--- a/Source/JavaScriptCore/runtime/RegExpConstructor.cpp
+++ b/Source/JavaScriptCore/runtime/RegExpConstructor.cpp
@@ -221,8 +221,7 @@
}
RegExpFlags result = regExpFlags(flagsString->value(exec));
- if (UNLIKELY(scope.exception()))
- return InvalidFlags;
+ RETURN_IF_EXCEPTION(scope, InvalidFlags);
if (result == InvalidFlags)
throwSyntaxError(exec, scope, ASCIILiteral("Invalid flags supplied to RegExp constructor."));
return result;
@@ -234,8 +233,7 @@
auto scope = DECLARE_THROW_SCOPE(vm);
String pattern = patternArg.isUndefined() ? emptyString() : patternArg.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
RegExpFlags flags = toFlags(exec, flagsArg);
if (flags == InvalidFlags)
@@ -246,8 +244,7 @@
return throwException(exec, scope, createSyntaxError(exec, regExp->errorMessage()));
Structure* structure = getRegExpStructure(exec, globalObject, newTarget);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
return RegExpObject::create(vm, structure, regExp);
}
@@ -263,8 +260,7 @@
if (newTarget.isUndefined() && constructAsRegexp && flagsArg.isUndefined()) {
JSValue constructor = patternArg.get(exec, vm.propertyNames->constructor);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
if (callee == constructor) {
// We know that patternArg is a object otherwise constructAsRegexp would be false.
return patternArg.getObject();
@@ -274,8 +270,7 @@
if (isPatternRegExp) {
RegExp* regExp = jsCast<RegExpObject*>(patternArg)->regExp();
Structure* structure = getRegExpStructure(exec, globalObject, newTarget);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
if (!flagsArg.isUndefined()) {
RegExpFlags flags = toFlags(exec, flagsArg);
diff --git a/Source/JavaScriptCore/runtime/RegExpConstructor.h b/Source/JavaScriptCore/runtime/RegExpConstructor.h
index 6320aa5..36345b7 100644
--- a/Source/JavaScriptCore/runtime/RegExpConstructor.h
+++ b/Source/JavaScriptCore/runtime/RegExpConstructor.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
- * Copyright (C) 2003, 2007, 2008 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2003, 2007-2008, 2016 Apple Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -139,8 +139,7 @@
JSObject* object = asObject(value);
JSValue matchValue = object->get(exec, vm.propertyNames->matchSymbol);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
if (!matchValue.isUndefined())
return matchValue.toBoolean(exec);
diff --git a/Source/JavaScriptCore/runtime/RegExpObject.cpp b/Source/JavaScriptCore/runtime/RegExpObject.cpp
index f89557f..05dac5c 100644
--- a/Source/JavaScriptCore/runtime/RegExpObject.cpp
+++ b/Source/JavaScriptCore/runtime/RegExpObject.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
- * Copyright (C) 2003, 2007, 2008, 2012, 2016 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2003, 2007-2008, 2012, 2016 Apple Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -176,8 +176,7 @@
static unsigned maxSizeForDirectPath = 100000;
JSArray* array = constructEmptyArray(exec, nullptr);
- if (UNLIKELY(scope.exception()))
- return jsUndefined();
+ RETURN_IF_EXCEPTION(scope, JSValue());
auto iterate = [&] () {
size_t end = result.end;
@@ -236,8 +235,7 @@
ASSERT(regExp->global());
setLastIndex(exec, 0);
- if (UNLIKELY(scope.exception()))
- return jsUndefined();
+ RETURN_IF_EXCEPTION(scope, JSValue());
String s = string->value(exec);
RegExpConstructor* regExpConstructor = globalObject->regExpConstructor();
diff --git a/Source/JavaScriptCore/runtime/RegExpPrototype.cpp b/Source/JavaScriptCore/runtime/RegExpPrototype.cpp
index 23341f0..90b4084 100644
--- a/Source/JavaScriptCore/runtime/RegExpPrototype.cpp
+++ b/Source/JavaScriptCore/runtime/RegExpPrototype.cpp
@@ -159,14 +159,12 @@
regExp = asRegExpObject(arg0)->regExp();
} else {
String pattern = !exec->argumentCount() ? emptyString() : arg0.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
RegExpFlags flags = NoFlags;
if (!arg1.isUndefined()) {
flags = regExpFlags(arg1.toString(exec)->value(exec));
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (flags == InvalidFlags)
return throwVMError(exec, scope, createSyntaxError(exec, ASCIILiteral("Invalid flags supplied to RegExp constructor.")));
}
@@ -192,20 +190,15 @@
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue globalValue = regexp->get(exec, exec->propertyNames().global);
- if (UNLIKELY(scope.exception()))
- return string;
+ RETURN_IF_EXCEPTION(scope, string);
JSValue ignoreCaseValue = regexp->get(exec, exec->propertyNames().ignoreCase);
- if (UNLIKELY(scope.exception()))
- return string;
+ RETURN_IF_EXCEPTION(scope, string);
JSValue multilineValue = regexp->get(exec, exec->propertyNames().multiline);
- if (UNLIKELY(scope.exception()))
- return string;
+ RETURN_IF_EXCEPTION(scope, string);
JSValue unicodeValue = regexp->get(exec, exec->propertyNames().unicode);
- if (UNLIKELY(scope.exception()))
- return string;
+ RETURN_IF_EXCEPTION(scope, string);
JSValue stickyValue = regexp->get(exec, exec->propertyNames().sticky);
- if (UNLIKELY(scope.exception()))
- return string;
+ RETURN_IF_EXCEPTION(scope, string);
unsigned index = 0;
if (globalValue.toBoolean(exec))
@@ -239,18 +232,14 @@
return JSValue::encode(earlyReturnValue);
JSValue sourceValue = thisObject->get(exec, vm.propertyNames->source);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
String source = sourceValue.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSValue flagsValue = thisObject->get(exec, vm.propertyNames->flags);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
String flags = flagsValue.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(jsMakeNontrivialString(exec, '/', source, '/', flags));
}
@@ -340,8 +329,7 @@
return throwVMTypeError(exec, scope, ASCIILiteral("The RegExp.prototype.flags getter can only be called on an object"));
auto flags = flagsString(exec, asObject(thisValue));
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(jsString(exec, flags.data()));
}
@@ -479,8 +467,7 @@
JSString* string = exec->uncheckedArgument(0).toString(exec);
String s = string->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
RegExpConstructor* regExpConstructor = exec->lexicalGlobalObject()->regExpConstructor();
MatchResult result = regExpConstructor->performMatch(vm, regExp, string, s, 0);
@@ -588,8 +575,7 @@
// 3. [handled by JS builtin] Let S be ? ToString(string).
JSString* inputString = exec->argument(0).toString(exec);
String input = inputString->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
ASSERT(!input.isNull());
// 4. [handled by JS builtin] Let C be ? SpeciesConstructor(rx, %RegExp%).
@@ -603,8 +589,7 @@
// 11. Let A be ArrayCreate(0).
// 12. Let lengthA be 0.
JSArray* result = constructEmptyArray(exec, 0);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
unsigned resultLength = 0;
// 13. If limit is undefined, let lim be 2^32-1; else let lim be ? ToUint32(limit).
diff --git a/Source/JavaScriptCore/runtime/SetConstructor.cpp b/Source/JavaScriptCore/runtime/SetConstructor.cpp
index 62ffa7d..98bb1e8 100644
--- a/Source/JavaScriptCore/runtime/SetConstructor.cpp
+++ b/Source/JavaScriptCore/runtime/SetConstructor.cpp
@@ -61,18 +61,15 @@
JSGlobalObject* globalObject = asInternalFunction(exec->callee())->globalObject();
Structure* setStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), globalObject->setStructure());
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSSet* set = JSSet::create(exec, vm, setStructure);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSValue iterable = exec->argument(0);
if (iterable.isUndefinedOrNull())
return JSValue::encode(set);
JSValue adderFunction = set->get(exec, exec->propertyNames().add);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
CallData adderFunctionCallData;
CallType adderFunctionCallType = getCallData(adderFunction, adderFunctionCallData);
diff --git a/Source/JavaScriptCore/runtime/StringConstructor.cpp b/Source/JavaScriptCore/runtime/StringConstructor.cpp
index 39052fe..b5fa558 100644
--- a/Source/JavaScriptCore/runtime/StringConstructor.cpp
+++ b/Source/JavaScriptCore/runtime/StringConstructor.cpp
@@ -100,8 +100,7 @@
for (unsigned i = 0; i < length; ++i) {
double codePointAsDouble = exec->uncheckedArgument(i).toNumber(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
uint32_t codePoint = static_cast<uint32_t>(codePointAsDouble);
@@ -126,8 +125,7 @@
auto scope = DECLARE_THROW_SCOPE(vm);
Structure* structure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), globalObject->stringObjectStructure());
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (!exec->argumentCount())
return JSValue::encode(StringObject::create(vm, structure));
diff --git a/Source/JavaScriptCore/runtime/StringObject.cpp b/Source/JavaScriptCore/runtime/StringObject.cpp
index ff3772d..09ba7ce 100644
--- a/Source/JavaScriptCore/runtime/StringObject.cpp
+++ b/Source/JavaScriptCore/runtime/StringObject.cpp
@@ -121,8 +121,7 @@
bool isCurrentDefined = thisObject->getOwnPropertyDescriptor(exec, propertyName, current);
ASSERT(isCurrentDefined);
bool isExtensible = thisObject->isExtensible(exec);
- if (UNLIKELY(scope.exception()))
- return false;
+ RETURN_IF_EXCEPTION(scope, false);
return validateAndApplyPropertyDescriptor(exec, nullptr, propertyName, isExtensible, descriptor, isCurrentDefined, current, throwException);
}
diff --git a/Source/JavaScriptCore/runtime/StringPrototype.cpp b/Source/JavaScriptCore/runtime/StringPrototype.cpp
index 5b7ba22..35ba683 100644
--- a/Source/JavaScriptCore/runtime/StringPrototype.cpp
+++ b/Source/JavaScriptCore/runtime/StringPrototype.cpp
@@ -480,8 +480,7 @@
const String& source = string->value(exec);
unsigned sourceLen = source.length();
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
RegExpObject* regExpObject = asRegExpObject(searchValue);
RegExp* regExp = regExpObject->regExp();
bool global = regExp->global();
@@ -489,8 +488,7 @@
if (global) {
// ES5.1 15.5.4.10 step 8.a.
regExpObject->setLastIndex(exec, 0);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (callType == CallType::None && !replacementString.length())
return removeUsingRegExpSearch(vm, exec, string, source, regExp);
@@ -512,8 +510,7 @@
int argCount = regExp->numSubpatterns() + 1 + 2;
JSFunction* func = jsCast<JSFunction*>(replaceValue);
CachedCall cachedCall(exec, func, argCount);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (source.is8Bit()) {
while (true) {
int* ovector;
@@ -540,8 +537,7 @@
cachedCall.setThis(jsUndefined());
JSValue jsResult = cachedCall.call();
replacements.append(jsResult.toString(exec)->value(exec));
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
lastIndex = result.end;
startPosition = lastIndex;
@@ -579,8 +575,7 @@
cachedCall.setThis(jsUndefined());
JSValue jsResult = cachedCall.call();
replacements.append(jsResult.toString(exec)->value(exec));
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
lastIndex = result.end;
startPosition = lastIndex;
@@ -618,9 +613,10 @@
args.append(jsNumber(result.start));
args.append(string);
- replacements.append(call(exec, replaceValue, callType, callData, jsUndefined(), args).toString(exec)->value(exec));
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ JSValue value = call(exec, replaceValue, callType, callData, jsUndefined(), args);
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
+ replacements.append(value.toString(exec)->value(exec));
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
} else {
int replLen = replacementString.length();
if (lastIndex < result.start || replLen) {
@@ -665,8 +661,7 @@
if (regExp->global()) {
// ES5.1 15.5.4.10 step 8.a.
searchValue->setLastIndex(exec, 0);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return removeUsingRegExpSearch(vm, exec, thisValue, thisValue->value(exec), regExp);
}
@@ -697,8 +692,7 @@
CallType callType = getCallData(replaceValue, callData);
if (callType == CallType::None) {
replacementString = replaceValue.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
return replaceUsingRegExpSearch(
@@ -711,8 +705,7 @@
const String& string = jsString->value(exec);
String searchString = searchValue.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
size_t matchStart = string.find(searchString);
@@ -727,13 +720,11 @@
args.append(jsNumber(matchStart));
args.append(jsString);
replaceValue = call(exec, replaceValue, callType, callData, jsUndefined(), args);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
String replaceString = replaceValue.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
StringImpl* stringImpl = string.impl();
String leftPart(StringImpl::createSubstringSharingImpl(*stringImpl, 0, matchStart));
@@ -817,8 +808,7 @@
if (!checkObjectCoercible(thisValue))
return throwVMTypeError(exec, scope);
JSString* string = thisValue.toString(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return replace(vm, exec, string, searchValue, replaceValue);
}
@@ -828,8 +818,7 @@
auto scope = DECLARE_THROW_SCOPE(vm);
JSString* string = exec->thisValue().toString(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSValue searchValue = exec->argument(0);
if (!searchValue.inherits(RegExpObject::info()))
@@ -844,8 +833,7 @@
auto scope = DECLARE_THROW_SCOPE(vm);
JSString* string = exec->thisValue().toString(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return replaceUsingStringSearch(exec->vm(), exec, string, exec->argument(0), exec->argument(1));
}
@@ -953,8 +941,7 @@
return JSValue::encode(jsUndefined());
}
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
double doublePosition = argument0.toInteger(exec);
if (doublePosition >= 0 && doublePosition < length)
@@ -1065,8 +1052,7 @@
if (!checkObjectCoercible(thisValue))
return throwVMTypeError(exec, scope);
String s = thisValue.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
int len = s.length();
RELEASE_ASSERT(len >= 0);
@@ -1130,15 +1116,13 @@
// 3. Let S be the result of calling ToString, giving it the this value as its argument.
// 7. Let s be the number of characters in S.
String input = thisValue.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
ASSERT(!input.isNull());
// 4. Let A be a new array created as if by the expression new Array()
// where Array is the standard built-in constructor with that name.
JSArray* result = constructEmptyArray(exec, 0);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
// 5. Let lengthA be 0.
unsigned resultLength = 0;
@@ -1154,8 +1138,7 @@
// otherwise let R = ToString(separator).
JSValue separatorValue = exec->uncheckedArgument(0);
String separator = separatorValue.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
// 10. If lim == 0, return A.
if (!limit)
@@ -1263,8 +1246,7 @@
len = jsString->length();
} else {
uString = thisValue.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
len = uString.length();
}
@@ -1316,8 +1298,7 @@
return throwVMTypeError(exec, scope);
JSString* jsString = thisValue.toString(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSValue a0 = exec->argument(0);
JSValue a1 = exec->argument(1);
@@ -1390,13 +1371,11 @@
if (!checkObjectCoercible(thisValue))
return throwVMTypeError(exec, scope);
String s = thisValue.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSValue a0 = exec->argument(0);
String str = a0.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(jsNumber(Collator().collate(s, str)));
}
@@ -1416,8 +1395,7 @@
const String& s = sVal->value(state);
// 3. ReturnIfAbrupt(S).
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
// Optimization for empty strings.
if (s.isEmpty())
@@ -1427,8 +1405,7 @@
Vector<String> requestedLocales = canonicalizeLocaleList(*state, state->argument(0));
// 5. ReturnIfAbrupt(requestedLocales).
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
// 6. Let len be the number of elements in requestedLocales.
size_t len = requestedLocales.size();
@@ -1511,8 +1488,7 @@
if (!checkObjectCoercible(thisValue))
return throwVMTypeError(exec, scope);
String s = thisValue.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(jsMakeNontrivialString(exec, "<big>", s, "</big>"));
}
@@ -1525,8 +1501,7 @@
if (!checkObjectCoercible(thisValue))
return throwVMTypeError(exec, scope);
String s = thisValue.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(jsMakeNontrivialString(exec, "<small>", s, "</small>"));
}
@@ -1539,8 +1514,7 @@
if (!checkObjectCoercible(thisValue))
return throwVMTypeError(exec, scope);
String s = thisValue.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(jsMakeNontrivialString(exec, "<blink>", s, "</blink>"));
}
@@ -1553,8 +1527,7 @@
if (!checkObjectCoercible(thisValue))
return throwVMTypeError(exec, scope);
String s = thisValue.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(jsMakeNontrivialString(exec, "<b>", s, "</b>"));
}
@@ -1567,8 +1540,7 @@
if (!checkObjectCoercible(thisValue))
return throwVMTypeError(exec, scope);
String s = thisValue.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(jsMakeNontrivialString(exec, "<tt>", s, "</tt>"));
}
@@ -1581,8 +1553,7 @@
if (!checkObjectCoercible(thisValue))
return throwVMTypeError(exec, scope);
String s = thisValue.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(jsMakeNontrivialString(exec, "<i>", s, "</i>"));
}
@@ -1595,8 +1566,7 @@
if (!checkObjectCoercible(thisValue))
return throwVMTypeError(exec, scope);
String s = thisValue.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(jsMakeNontrivialString(exec, "<strike>", s, "</strike>"));
}
@@ -1609,8 +1579,7 @@
if (!checkObjectCoercible(thisValue))
return throwVMTypeError(exec, scope);
String s = thisValue.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(jsMakeNontrivialString(exec, "<sub>", s, "</sub>"));
}
@@ -1623,8 +1592,7 @@
if (!checkObjectCoercible(thisValue))
return throwVMTypeError(exec, scope);
String s = thisValue.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(jsMakeNontrivialString(exec, "<sup>", s, "</sup>"));
}
@@ -1637,8 +1605,7 @@
if (!checkObjectCoercible(thisValue))
return throwVMTypeError(exec, scope);
String s = thisValue.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSValue a0 = exec->argument(0);
String color = a0.toWTFString(exec);
@@ -1656,8 +1623,7 @@
if (!checkObjectCoercible(thisValue))
return throwVMTypeError(exec, scope);
String s = thisValue.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSValue a0 = exec->argument(0);
@@ -1711,8 +1677,7 @@
if (!checkObjectCoercible(thisValue))
return throwVMTypeError(exec, scope);
String s = thisValue.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSValue a0 = exec->argument(0);
String anchor = a0.toWTFString(exec);
@@ -1730,8 +1695,7 @@
if (!checkObjectCoercible(thisValue))
return throwVMTypeError(exec, scope);
String s = thisValue.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSValue a0 = exec->argument(0);
String linkText = a0.toWTFString(exec);
@@ -1778,8 +1742,7 @@
if (!checkObjectCoercible(thisValue))
return throwTypeError(exec, scope);
String str = thisValue.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return jsUndefined();
+ RETURN_IF_EXCEPTION(scope, JSValue());
unsigned left = 0;
if (trimKind & TrimLeft) {
@@ -1836,19 +1799,16 @@
return throwVMTypeError(exec, scope);
String stringToSearchIn = thisValue.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSValue a0 = exec->argument(0);
bool isRegularExpression = isRegExp(vm, exec, a0);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (isRegularExpression)
return throwVMTypeError(exec, scope, "Argument to String.prototype.startsWith cannot be a RegExp");
String searchString = a0.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSValue positionArg = exec->argument(1);
unsigned start = 0;
@@ -1857,8 +1817,7 @@
else {
unsigned length = stringToSearchIn.length();
start = clampAndTruncateToUnsigned(positionArg.toInteger(exec), 0, length);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
return JSValue::encode(jsBoolean(stringToSearchIn.hasInfixStartingAt(searchString, start)));
@@ -1874,19 +1833,16 @@
return throwVMTypeError(exec, scope);
String stringToSearchIn = thisValue.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSValue a0 = exec->argument(0);
bool isRegularExpression = isRegExp(vm, exec, a0);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (isRegularExpression)
return throwVMTypeError(exec, scope, "Argument to String.prototype.endsWith cannot be a RegExp");
String searchString = a0.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
unsigned length = stringToSearchIn.length();
@@ -1896,8 +1852,7 @@
end = std::max(0, endPositionArg.asInt32());
else if (!endPositionArg.isUndefined()) {
end = clampAndTruncateToUnsigned(endPositionArg.toInteger(exec), 0, length);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
return JSValue::encode(jsBoolean(stringToSearchIn.hasInfixEndingAt(searchString, std::min(end, length))));
@@ -1912,8 +1867,7 @@
else {
unsigned length = stringToSearchIn.length();
start = clampAndTruncateToUnsigned(positionArg.toInteger(exec), 0, length);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
return JSValue::encode(jsBoolean(stringToSearchIn.contains(searchString, true, start)));
@@ -1929,19 +1883,16 @@
return throwVMTypeError(exec, scope);
String stringToSearchIn = thisValue.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSValue a0 = exec->argument(0);
bool isRegularExpression = isRegExp(vm, exec, a0);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (isRegularExpression)
return throwVMTypeError(exec, scope, "Argument to String.prototype.includes cannot be a RegExp");
String searchString = a0.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSValue positionArg = exec->argument(1);
@@ -1957,13 +1908,11 @@
ASSERT(checkObjectCoercible(thisValue));
String stringToSearchIn = thisValue.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSValue a0 = exec->uncheckedArgument(0);
String searchString = a0.toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSValue positionArg = exec->argument(1);
@@ -2018,15 +1967,13 @@
if (!checkObjectCoercible(thisValue))
return throwVMTypeError(exec, scope);
JSString::SafeView source = thisValue.toString(exec)->view(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
UNormalizationMode form = UNORM_NFC;
// Verify that the argument is provided and is not undefined.
if (!exec->argument(0).isUndefined()) {
String formString = exec->uncheckedArgument(0).toString(exec)->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (formString == "NFC")
form = UNORM_NFC;
diff --git a/Source/JavaScriptCore/runtime/SymbolConstructor.cpp b/Source/JavaScriptCore/runtime/SymbolConstructor.cpp
index a83ceef..4fcf546 100644
--- a/Source/JavaScriptCore/runtime/SymbolConstructor.cpp
+++ b/Source/JavaScriptCore/runtime/SymbolConstructor.cpp
@@ -100,11 +100,9 @@
auto scope = DECLARE_THROW_SCOPE(vm);
JSString* stringKey = exec->argument(0).toString(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
String string = stringKey->value(exec);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
return JSValue::encode(Symbol::create(exec->vm(), exec->vm().symbolRegistry().symbolForKey(string)));
}
diff --git a/Source/JavaScriptCore/runtime/TemplateRegistry.cpp b/Source/JavaScriptCore/runtime/TemplateRegistry.cpp
index e6f5ec4..fdbaa2b 100644
--- a/Source/JavaScriptCore/runtime/TemplateRegistry.cpp
+++ b/Source/JavaScriptCore/runtime/TemplateRegistry.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>.
+ * Copyright (C) 2016 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -48,11 +49,9 @@
auto scope = DECLARE_THROW_SCOPE(vm);
unsigned count = templateKey.cookedStrings().size();
JSArray* templateObject = constructEmptyArray(exec, nullptr, count);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
JSArray* rawObject = constructEmptyArray(exec, nullptr, count);
- if (UNLIKELY(scope.exception()))
- return nullptr;
+ RETURN_IF_EXCEPTION(scope, nullptr);
for (unsigned index = 0; index < count; ++index) {
templateObject->putDirectIndex(exec, index, jsString(exec, templateKey.cookedStrings()[index]), ReadOnly | DontDelete, PutDirectIndexLikePutDirect);
diff --git a/Source/JavaScriptCore/runtime/WeakMapConstructor.cpp b/Source/JavaScriptCore/runtime/WeakMapConstructor.cpp
index 26a5021..32b9fd5 100644
--- a/Source/JavaScriptCore/runtime/WeakMapConstructor.cpp
+++ b/Source/JavaScriptCore/runtime/WeakMapConstructor.cpp
@@ -59,16 +59,14 @@
JSGlobalObject* globalObject = asInternalFunction(exec->callee())->globalObject();
Structure* weakMapStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), globalObject->weakMapStructure());
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSWeakMap* weakMap = JSWeakMap::create(exec, weakMapStructure);
JSValue iterable = exec->argument(0);
if (iterable.isUndefinedOrNull())
return JSValue::encode(weakMap);
JSValue adderFunction = weakMap->JSObject::get(exec, exec->propertyNames().set);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
CallData adderFunctionCallData;
CallType adderFunctionCallType = getCallData(adderFunction, adderFunctionCallData);
@@ -83,12 +81,10 @@
}
JSValue key = nextItem.get(exec, static_cast<unsigned>(0));
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
JSValue value = nextItem.get(exec, static_cast<unsigned>(1));
- if (UNLIKELY(scope.exception()))
- return;
+ RETURN_IF_EXCEPTION(scope, void());
MarkedArgumentBuffer arguments;
arguments.append(key);
diff --git a/Source/JavaScriptCore/runtime/WeakSetConstructor.cpp b/Source/JavaScriptCore/runtime/WeakSetConstructor.cpp
index c049046..7bdd426 100644
--- a/Source/JavaScriptCore/runtime/WeakSetConstructor.cpp
+++ b/Source/JavaScriptCore/runtime/WeakSetConstructor.cpp
@@ -59,16 +59,14 @@
JSGlobalObject* globalObject = asInternalFunction(exec->callee())->globalObject();
Structure* weakSetStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), globalObject->weakSetStructure());
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(JSValue());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
JSWeakSet* weakSet = JSWeakSet::create(exec, weakSetStructure);
JSValue iterable = exec->argument(0);
if (iterable.isUndefinedOrNull())
return JSValue::encode(weakSet);
JSValue adderFunction = weakSet->JSObject::get(exec, exec->propertyNames().add);
- if (UNLIKELY(scope.exception()))
- return JSValue::encode(jsUndefined());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
CallData adderFunctionCallData;
CallType adderFunctionCallType = getCallData(adderFunction, adderFunctionCallData);