Changeset 221849 in webkit


Ignore:
Timestamp:
Sep 10, 2017 11:23:39 PM (7 years ago)
Author:
mark.lam@apple.com
Message:

Fix all ExceptionScope verification failures in JavaScriptCore.
https://bugs.webkit.org/show_bug.cgi?id=176662
<rdar://problem/34352085>

Reviewed by Filip Pizlo.

Source/JavaScriptCore:

  1. Introduced EXCEPTION_ASSERT macros so that we can enable exception scope verification for release builds too (though this requires manually setting ENABLE_EXCEPTION_SCOPE_VERIFICATION to 1 in Platform.h).

This is useful because it allows us to run the tests more quickly to check
if any regressions have occurred. Debug builds run so much slower and not
good for a quick turn around. Debug builds are necessary though to get
trace information without inlining by the C++ compiler. This is necessary to
diagnose where the missing exception check is.

  1. Repurposed the JSC_dumpSimulatedThrows=true options to capture and dump the last simulated throw when an exception scope verification fails.

Previously, this option dumps the stack trace on all simulated throws. That
turned out to not be very useful, and slows down the debugging process.
Instead, the new implementation captures the stack trace and only dumps it
if we have a verification failure.

  1. Fixed missing exception checks and book-keeping needed to allow the JSC tests to pass with JSC_validateExceptionChecks=true.
  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::finishCreation):

  • dfg/DFGOSRExit.cpp:

(JSC::DFG::OSRExit::executeOSRExit):

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

(JSC::eval):
(JSC::loadVarargs):
(JSC::Interpreter::unwind):
(JSC::Interpreter::executeProgram):
(JSC::Interpreter::executeCall):
(JSC::Interpreter::executeConstruct):
(JSC::Interpreter::prepareForRepeatCall):
(JSC::Interpreter::execute):
(JSC::Interpreter::executeModuleProgram):

  • jit/JITOperations.cpp:

(JSC::getByVal):

  • jsc.cpp:

(WTF::CustomGetter::customGetterAcessor):
(GlobalObject::moduleLoaderImportModule):
(GlobalObject::moduleLoaderResolve):

  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::getByVal):
(JSC::LLInt::setUpCall):

  • parser/Parser.h:

(JSC::Parser::popScopeInternal):

  • runtime/AbstractModuleRecord.cpp:

(JSC::AbstractModuleRecord::hostResolveImportedModule):
(JSC::AbstractModuleRecord::resolveImport):
(JSC::AbstractModuleRecord::resolveExportImpl):
(JSC::getExportedNames):
(JSC::AbstractModuleRecord::getModuleNamespace):

  • runtime/ArrayPrototype.cpp:

(JSC::getProperty):
(JSC::unshift):
(JSC::arrayProtoFuncToString):
(JSC::arrayProtoFuncToLocaleString):
(JSC::arrayProtoFuncJoin):
(JSC::arrayProtoFuncPop):
(JSC::arrayProtoFuncPush):
(JSC::arrayProtoFuncReverse):
(JSC::arrayProtoFuncShift):
(JSC::arrayProtoFuncSlice):
(JSC::arrayProtoFuncSplice):
(JSC::arrayProtoFuncUnShift):
(JSC::arrayProtoFuncIndexOf):
(JSC::arrayProtoFuncLastIndexOf):
(JSC::concatAppendOne):
(JSC::arrayProtoPrivateFuncConcatMemcpy):
(JSC::arrayProtoPrivateFuncAppendMemcpy):

  • runtime/CatchScope.h:
  • runtime/CommonSlowPaths.cpp:

(JSC::SLOW_PATH_DECL):

  • runtime/DatePrototype.cpp:

(JSC::dateProtoFuncSetTime):
(JSC::setNewValueFromTimeArgs):

  • runtime/DirectArguments.h:

(JSC::DirectArguments::length const):

  • runtime/ErrorPrototype.cpp:

(JSC::errorProtoFuncToString):

  • runtime/ExceptionFuzz.cpp:

(JSC::doExceptionFuzzing):

  • runtime/ExceptionScope.h:

(JSC::ExceptionScope::needExceptionCheck):
(JSC::ExceptionScope::assertNoException):

  • runtime/GenericArgumentsInlines.h:

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

  • runtime/HashMapImpl.h:

(JSC::HashMapImpl::rehash):

  • runtime/IntlDateTimeFormat.cpp:

(JSC::IntlDateTimeFormat::formatToParts):

  • runtime/JSArray.cpp:

(JSC::JSArray::defineOwnProperty):
(JSC::JSArray::put):

  • runtime/JSCJSValue.cpp:

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

  • runtime/JSCJSValueInlines.h:

(JSC::JSValue::toIndex const):
(JSC::JSValue::get const):
(JSC::JSValue::getPropertySlot const):
(JSC::JSValue::equalSlowCaseInline):

  • runtime/JSGenericTypedArrayViewConstructorInlines.h:

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

  • runtime/JSGenericTypedArrayViewInlines.h:

(JSC::JSGenericTypedArrayView<Adaptor>::set):

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::put):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::decode):
(JSC::globalFuncEval):
(JSC::globalFuncProtoGetter):
(JSC::globalFuncProtoSetter):
(JSC::globalFuncImportModule):

  • runtime/JSInternalPromise.cpp:

(JSC::JSInternalPromise::then):

  • runtime/JSInternalPromiseDeferred.cpp:

(JSC::JSInternalPromiseDeferred::create):

  • runtime/JSJob.cpp:

(JSC::JSJobMicrotask::run):

  • runtime/JSModuleEnvironment.cpp:

(JSC::JSModuleEnvironment::getOwnPropertySlot):
(JSC::JSModuleEnvironment::put):
(JSC::JSModuleEnvironment::deleteProperty):

  • runtime/JSModuleLoader.cpp:

(JSC::JSModuleLoader::provide):
(JSC::JSModuleLoader::loadAndEvaluateModule):
(JSC::JSModuleLoader::loadModule):
(JSC::JSModuleLoader::linkAndEvaluateModule):
(JSC::JSModuleLoader::requestImportModule):

  • runtime/JSModuleRecord.cpp:

(JSC::JSModuleRecord::link):
(JSC::JSModuleRecord::instantiateDeclarations):

  • runtime/JSONObject.cpp:

(JSC::Stringifier::stringify):
(JSC::Stringifier::toJSON):
(JSC::JSONProtoFuncParse):

  • runtime/JSObject.cpp:

(JSC::JSObject::calculatedClassName):
(JSC::ordinarySetSlow):
(JSC::JSObject::putInlineSlow):
(JSC::JSObject::ordinaryToPrimitive const):
(JSC::JSObject::toPrimitive const):
(JSC::JSObject::hasInstance):
(JSC::JSObject::getPropertyNames):
(JSC::JSObject::toNumber const):
(JSC::JSObject::defineOwnIndexedProperty):
(JSC::JSObject::putByIndexBeyondVectorLengthWithoutAttributes):
(JSC::JSObject::putByIndexBeyondVectorLengthWithArrayStorage):
(JSC::JSObject::putDirectIndexBeyondVectorLengthWithArrayStorage):
(JSC::validateAndApplyPropertyDescriptor):
(JSC::JSObject::defineOwnNonIndexProperty):
(JSC::JSObject::getGenericPropertyNames):

  • runtime/JSObject.h:

(JSC::JSObject::get const):

  • runtime/JSObjectInlines.h:

(JSC::JSObject::getPropertySlot const):
(JSC::JSObject::getPropertySlot):
(JSC::JSObject::getNonIndexPropertySlot):
(JSC::JSObject::putInlineForJSObject):

  • runtime/JSPromiseConstructor.cpp:

(JSC::constructPromise):

  • runtime/JSPromiseDeferred.cpp:

(JSC::JSPromiseDeferred::create):

  • runtime/JSScope.cpp:

(JSC::abstractAccess):
(JSC::JSScope::resolve):
(JSC::JSScope::resolveScopeForHoistingFuncDeclInEval):
(JSC::JSScope::abstractResolve):

  • runtime/LiteralParser.cpp:

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

  • runtime/Lookup.h:

(JSC::putEntry):

  • runtime/MapConstructor.cpp:

(JSC::constructMap):

  • runtime/NumberPrototype.cpp:

(JSC::numberProtoFuncToString):

  • runtime/ObjectConstructor.cpp:

(JSC::objectConstructorSetPrototypeOf):
(JSC::objectConstructorGetOwnPropertyDescriptor):
(JSC::objectConstructorGetOwnPropertyDescriptors):
(JSC::objectConstructorAssign):
(JSC::objectConstructorValues):
(JSC::toPropertyDescriptor):
(JSC::objectConstructorDefineProperty):
(JSC::defineProperties):
(JSC::objectConstructorDefineProperties):
(JSC::ownPropertyKeys):

  • runtime/ObjectPrototype.cpp:

(JSC::objectProtoFuncHasOwnProperty):
(JSC::objectProtoFuncIsPrototypeOf):
(JSC::objectProtoFuncLookupGetter):
(JSC::objectProtoFuncLookupSetter):
(JSC::objectProtoFuncToLocaleString):
(JSC::objectProtoFuncToString):

  • runtime/Options.h:
  • runtime/ParseInt.h:

(JSC::toStringView):

  • runtime/ProxyObject.cpp:

(JSC::performProxyGet):
(JSC::ProxyObject::performPut):

  • runtime/ReflectObject.cpp:

(JSC::reflectObjectDefineProperty):

  • runtime/RegExpConstructor.cpp:

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

  • runtime/RegExpObject.cpp:

(JSC::collectMatches):

  • runtime/RegExpObjectInlines.h:

(JSC::RegExpObject::execInline):
(JSC::RegExpObject::matchInline):

  • runtime/RegExpPrototype.cpp:

(JSC::regExpProtoFuncTestFast):
(JSC::regExpProtoFuncExec):
(JSC::regExpProtoFuncMatchFast):
(JSC::regExpProtoFuncToString):
(JSC::regExpProtoFuncSplitFast):

  • runtime/ScriptExecutable.cpp:

(JSC::ScriptExecutable::newCodeBlockFor):
(JSC::ScriptExecutable::prepareForExecutionImpl):

  • runtime/SetConstructor.cpp:

(JSC::constructSet):

  • runtime/ThrowScope.cpp:

(JSC::ThrowScope::simulateThrow):

  • runtime/VM.cpp:

(JSC::VM::verifyExceptionCheckNeedIsSatisfied):

  • runtime/VM.h:
  • runtime/WeakMapPrototype.cpp:

(JSC::protoFuncWeakMapSet):

  • runtime/WeakSetPrototype.cpp:

(JSC::protoFuncWeakSetAdd):

  • wasm/js/WebAssemblyModuleConstructor.cpp:

(JSC::WebAssemblyModuleConstructor::createModule):

  • wasm/js/WebAssemblyModuleRecord.cpp:

(JSC::WebAssemblyModuleRecord::link):

  • wasm/js/WebAssemblyPrototype.cpp:

(JSC::reject):
(JSC::webAssemblyCompileFunc):
(JSC::resolve):
(JSC::webAssemblyInstantiateFunc):

Source/WebCore:

No new tests because this is covered by existing tests with the JSC_validateExceptionChecks=true enabled.

  • bindings/js/JSCustomElementInterface.cpp:

(WebCore::JSCustomElementInterface::tryToConstructCustomElement):

  • bindings/js/JSCustomElementRegistryCustom.cpp:

(WebCore::whenDefinedPromise):

  • bindings/js/JSDOMConvertRecord.h:
  • bindings/js/JSDOMMapLike.cpp:

(WebCore::createBackingMap):

  • bindings/js/JSDOMPromiseDeferred.cpp:

(WebCore::DeferredPromise::callFunction):
(WebCore::DeferredPromise::reject):

  • bindings/js/JSDOMPromiseDeferred.h:

(WebCore::callPromiseFunction):

Location:
trunk/Source
Files:
72 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r221836 r221849  
     12017-09-10  Mark Lam  <mark.lam@apple.com>
     2
     3        Fix all ExceptionScope verification failures in JavaScriptCore.
     4        https://bugs.webkit.org/show_bug.cgi?id=176662
     5        <rdar://problem/34352085>
     6
     7        Reviewed by Filip Pizlo.
     8
     9        1. Introduced EXCEPTION_ASSERT macros so that we can enable exception scope
     10           verification for release builds too (though this requires manually setting
     11           ENABLE_EXCEPTION_SCOPE_VERIFICATION to 1 in Platform.h).
     12
     13           This is useful because it allows us to run the tests more quickly to check
     14           if any regressions have occurred.  Debug builds run so much slower and not
     15           good for a quick turn around.  Debug builds are necessary though to get
     16           trace information without inlining by the C++ compiler.  This is necessary to
     17           diagnose where the missing exception check is.
     18
     19        2. Repurposed the JSC_dumpSimulatedThrows=true options to capture and dump the last
     20           simulated throw when an exception scope verification fails.
     21
     22           Previously, this option dumps the stack trace on all simulated throws.  That
     23           turned out to not be very useful, and slows down the debugging process.
     24           Instead, the new implementation captures the stack trace and only dumps it
     25           if we have a verification failure.
     26
     27        3. Fixed missing exception checks and book-keeping needed to allow the JSC tests
     28           to pass with JSC_validateExceptionChecks=true.
     29
     30        * bytecode/CodeBlock.cpp:
     31        (JSC::CodeBlock::finishCreation):
     32        * dfg/DFGOSRExit.cpp:
     33        (JSC::DFG::OSRExit::executeOSRExit):
     34        * dfg/DFGOperations.cpp:
     35        * interpreter/Interpreter.cpp:
     36        (JSC::eval):
     37        (JSC::loadVarargs):
     38        (JSC::Interpreter::unwind):
     39        (JSC::Interpreter::executeProgram):
     40        (JSC::Interpreter::executeCall):
     41        (JSC::Interpreter::executeConstruct):
     42        (JSC::Interpreter::prepareForRepeatCall):
     43        (JSC::Interpreter::execute):
     44        (JSC::Interpreter::executeModuleProgram):
     45        * jit/JITOperations.cpp:
     46        (JSC::getByVal):
     47        * jsc.cpp:
     48        (WTF::CustomGetter::customGetterAcessor):
     49        (GlobalObject::moduleLoaderImportModule):
     50        (GlobalObject::moduleLoaderResolve):
     51        * llint/LLIntSlowPaths.cpp:
     52        (JSC::LLInt::getByVal):
     53        (JSC::LLInt::setUpCall):
     54        * parser/Parser.h:
     55        (JSC::Parser::popScopeInternal):
     56        * runtime/AbstractModuleRecord.cpp:
     57        (JSC::AbstractModuleRecord::hostResolveImportedModule):
     58        (JSC::AbstractModuleRecord::resolveImport):
     59        (JSC::AbstractModuleRecord::resolveExportImpl):
     60        (JSC::getExportedNames):
     61        (JSC::AbstractModuleRecord::getModuleNamespace):
     62        * runtime/ArrayPrototype.cpp:
     63        (JSC::getProperty):
     64        (JSC::unshift):
     65        (JSC::arrayProtoFuncToString):
     66        (JSC::arrayProtoFuncToLocaleString):
     67        (JSC::arrayProtoFuncJoin):
     68        (JSC::arrayProtoFuncPop):
     69        (JSC::arrayProtoFuncPush):
     70        (JSC::arrayProtoFuncReverse):
     71        (JSC::arrayProtoFuncShift):
     72        (JSC::arrayProtoFuncSlice):
     73        (JSC::arrayProtoFuncSplice):
     74        (JSC::arrayProtoFuncUnShift):
     75        (JSC::arrayProtoFuncIndexOf):
     76        (JSC::arrayProtoFuncLastIndexOf):
     77        (JSC::concatAppendOne):
     78        (JSC::arrayProtoPrivateFuncConcatMemcpy):
     79        (JSC::arrayProtoPrivateFuncAppendMemcpy):
     80        * runtime/CatchScope.h:
     81        * runtime/CommonSlowPaths.cpp:
     82        (JSC::SLOW_PATH_DECL):
     83        * runtime/DatePrototype.cpp:
     84        (JSC::dateProtoFuncSetTime):
     85        (JSC::setNewValueFromTimeArgs):
     86        * runtime/DirectArguments.h:
     87        (JSC::DirectArguments::length const):
     88        * runtime/ErrorPrototype.cpp:
     89        (JSC::errorProtoFuncToString):
     90        * runtime/ExceptionFuzz.cpp:
     91        (JSC::doExceptionFuzzing):
     92        * runtime/ExceptionScope.h:
     93        (JSC::ExceptionScope::needExceptionCheck):
     94        (JSC::ExceptionScope::assertNoException):
     95        * runtime/GenericArgumentsInlines.h:
     96        (JSC::GenericArguments<Type>::defineOwnProperty):
     97        * runtime/HashMapImpl.h:
     98        (JSC::HashMapImpl::rehash):
     99        * runtime/IntlDateTimeFormat.cpp:
     100        (JSC::IntlDateTimeFormat::formatToParts):
     101        * runtime/JSArray.cpp:
     102        (JSC::JSArray::defineOwnProperty):
     103        (JSC::JSArray::put):
     104        * runtime/JSCJSValue.cpp:
     105        (JSC::JSValue::putToPrimitive):
     106        (JSC::JSValue::putToPrimitiveByIndex):
     107        * runtime/JSCJSValueInlines.h:
     108        (JSC::JSValue::toIndex const):
     109        (JSC::JSValue::get const):
     110        (JSC::JSValue::getPropertySlot const):
     111        (JSC::JSValue::equalSlowCaseInline):
     112        * runtime/JSGenericTypedArrayViewConstructorInlines.h:
     113        (JSC::constructGenericTypedArrayViewFromIterator):
     114        (JSC::constructGenericTypedArrayViewWithArguments):
     115        * runtime/JSGenericTypedArrayViewInlines.h:
     116        (JSC::JSGenericTypedArrayView<Adaptor>::set):
     117        * runtime/JSGlobalObject.cpp:
     118        (JSC::JSGlobalObject::put):
     119        * runtime/JSGlobalObjectFunctions.cpp:
     120        (JSC::decode):
     121        (JSC::globalFuncEval):
     122        (JSC::globalFuncProtoGetter):
     123        (JSC::globalFuncProtoSetter):
     124        (JSC::globalFuncImportModule):
     125        * runtime/JSInternalPromise.cpp:
     126        (JSC::JSInternalPromise::then):
     127        * runtime/JSInternalPromiseDeferred.cpp:
     128        (JSC::JSInternalPromiseDeferred::create):
     129        * runtime/JSJob.cpp:
     130        (JSC::JSJobMicrotask::run):
     131        * runtime/JSModuleEnvironment.cpp:
     132        (JSC::JSModuleEnvironment::getOwnPropertySlot):
     133        (JSC::JSModuleEnvironment::put):
     134        (JSC::JSModuleEnvironment::deleteProperty):
     135        * runtime/JSModuleLoader.cpp:
     136        (JSC::JSModuleLoader::provide):
     137        (JSC::JSModuleLoader::loadAndEvaluateModule):
     138        (JSC::JSModuleLoader::loadModule):
     139        (JSC::JSModuleLoader::linkAndEvaluateModule):
     140        (JSC::JSModuleLoader::requestImportModule):
     141        * runtime/JSModuleRecord.cpp:
     142        (JSC::JSModuleRecord::link):
     143        (JSC::JSModuleRecord::instantiateDeclarations):
     144        * runtime/JSONObject.cpp:
     145        (JSC::Stringifier::stringify):
     146        (JSC::Stringifier::toJSON):
     147        (JSC::JSONProtoFuncParse):
     148        * runtime/JSObject.cpp:
     149        (JSC::JSObject::calculatedClassName):
     150        (JSC::ordinarySetSlow):
     151        (JSC::JSObject::putInlineSlow):
     152        (JSC::JSObject::ordinaryToPrimitive const):
     153        (JSC::JSObject::toPrimitive const):
     154        (JSC::JSObject::hasInstance):
     155        (JSC::JSObject::getPropertyNames):
     156        (JSC::JSObject::toNumber const):
     157        (JSC::JSObject::defineOwnIndexedProperty):
     158        (JSC::JSObject::putByIndexBeyondVectorLengthWithoutAttributes):
     159        (JSC::JSObject::putByIndexBeyondVectorLengthWithArrayStorage):
     160        (JSC::JSObject::putDirectIndexBeyondVectorLengthWithArrayStorage):
     161        (JSC::validateAndApplyPropertyDescriptor):
     162        (JSC::JSObject::defineOwnNonIndexProperty):
     163        (JSC::JSObject::getGenericPropertyNames):
     164        * runtime/JSObject.h:
     165        (JSC::JSObject::get const):
     166        * runtime/JSObjectInlines.h:
     167        (JSC::JSObject::getPropertySlot const):
     168        (JSC::JSObject::getPropertySlot):
     169        (JSC::JSObject::getNonIndexPropertySlot):
     170        (JSC::JSObject::putInlineForJSObject):
     171        * runtime/JSPromiseConstructor.cpp:
     172        (JSC::constructPromise):
     173        * runtime/JSPromiseDeferred.cpp:
     174        (JSC::JSPromiseDeferred::create):
     175        * runtime/JSScope.cpp:
     176        (JSC::abstractAccess):
     177        (JSC::JSScope::resolve):
     178        (JSC::JSScope::resolveScopeForHoistingFuncDeclInEval):
     179        (JSC::JSScope::abstractResolve):
     180        * runtime/LiteralParser.cpp:
     181        (JSC::LiteralParser<CharType>::tryJSONPParse):
     182        (JSC::LiteralParser<CharType>::parse):
     183        * runtime/Lookup.h:
     184        (JSC::putEntry):
     185        * runtime/MapConstructor.cpp:
     186        (JSC::constructMap):
     187        * runtime/NumberPrototype.cpp:
     188        (JSC::numberProtoFuncToString):
     189        * runtime/ObjectConstructor.cpp:
     190        (JSC::objectConstructorSetPrototypeOf):
     191        (JSC::objectConstructorGetOwnPropertyDescriptor):
     192        (JSC::objectConstructorGetOwnPropertyDescriptors):
     193        (JSC::objectConstructorAssign):
     194        (JSC::objectConstructorValues):
     195        (JSC::toPropertyDescriptor):
     196        (JSC::objectConstructorDefineProperty):
     197        (JSC::defineProperties):
     198        (JSC::objectConstructorDefineProperties):
     199        (JSC::ownPropertyKeys):
     200        * runtime/ObjectPrototype.cpp:
     201        (JSC::objectProtoFuncHasOwnProperty):
     202        (JSC::objectProtoFuncIsPrototypeOf):
     203        (JSC::objectProtoFuncLookupGetter):
     204        (JSC::objectProtoFuncLookupSetter):
     205        (JSC::objectProtoFuncToLocaleString):
     206        (JSC::objectProtoFuncToString):
     207        * runtime/Options.h:
     208        * runtime/ParseInt.h:
     209        (JSC::toStringView):
     210        * runtime/ProxyObject.cpp:
     211        (JSC::performProxyGet):
     212        (JSC::ProxyObject::performPut):
     213        * runtime/ReflectObject.cpp:
     214        (JSC::reflectObjectDefineProperty):
     215        * runtime/RegExpConstructor.cpp:
     216        (JSC::toFlags):
     217        (JSC::regExpCreate):
     218        (JSC::constructRegExp):
     219        * runtime/RegExpObject.cpp:
     220        (JSC::collectMatches):
     221        * runtime/RegExpObjectInlines.h:
     222        (JSC::RegExpObject::execInline):
     223        (JSC::RegExpObject::matchInline):
     224        * runtime/RegExpPrototype.cpp:
     225        (JSC::regExpProtoFuncTestFast):
     226        (JSC::regExpProtoFuncExec):
     227        (JSC::regExpProtoFuncMatchFast):
     228        (JSC::regExpProtoFuncToString):
     229        (JSC::regExpProtoFuncSplitFast):
     230        * runtime/ScriptExecutable.cpp:
     231        (JSC::ScriptExecutable::newCodeBlockFor):
     232        (JSC::ScriptExecutable::prepareForExecutionImpl):
     233        * runtime/SetConstructor.cpp:
     234        (JSC::constructSet):
     235        * runtime/ThrowScope.cpp:
     236        (JSC::ThrowScope::simulateThrow):
     237        * runtime/VM.cpp:
     238        (JSC::VM::verifyExceptionCheckNeedIsSatisfied):
     239        * runtime/VM.h:
     240        * runtime/WeakMapPrototype.cpp:
     241        (JSC::protoFuncWeakMapSet):
     242        * runtime/WeakSetPrototype.cpp:
     243        (JSC::protoFuncWeakSetAdd):
     244        * wasm/js/WebAssemblyModuleConstructor.cpp:
     245        (JSC::WebAssemblyModuleConstructor::createModule):
     246        * wasm/js/WebAssemblyModuleRecord.cpp:
     247        (JSC::WebAssemblyModuleRecord::link):
     248        * wasm/js/WebAssemblyPrototype.cpp:
     249        (JSC::reject):
     250        (JSC::webAssemblyCompileFunc):
     251        (JSC::resolve):
     252        (JSC::webAssemblyInstantiateFunc):
     253
    12542017-09-08  Filip Pizlo  <fpizlo@apple.com>
    2255
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r221832 r221849  
    624624
    625625            ResolveOp op = JSScope::abstractResolve(m_globalObject->globalExec(), localScopeDepth, scope, ident, Get, type, InitializationMode::NotInitialization);
     626            RETURN_IF_EXCEPTION(throwScope, false);
     627
    626628            instructions[i + 4].u.operand = op.type;
    627629            instructions[i + 5].u.operand = op.depth;
     
    658660            const Identifier& ident = identifier(pc[3].u.operand);
    659661            ResolveOp op = JSScope::abstractResolve(m_globalObject->globalExec(), localScopeDepth, scope, ident, Get, getPutInfo.resolveType(), InitializationMode::NotInitialization);
     662            RETURN_IF_EXCEPTION(throwScope, false);
    660663
    661664            instructions[i + 4].u.operand = GetPutInfo(getPutInfo.resolveMode(), op.type, getPutInfo.initializationMode()).operand();
     
    693696            instructions[i + 5].u.pointer = nullptr;
    694697            ResolveOp op = JSScope::abstractResolve(m_globalObject->globalExec(), localScopeDepth, scope, ident, Put, getPutInfo.resolveType(), getPutInfo.initializationMode());
     698            RETURN_IF_EXCEPTION(throwScope, false);
    695699
    696700            instructions[i + 4].u.operand = GetPutInfo(getPutInfo.resolveMode(), op.type, getPutInfo.initializationMode()).operand();
     
    727731                // we're abstractly "read"ing from a JSScope.
    728732                ResolveOp op = JSScope::abstractResolve(m_globalObject->globalExec(), localScopeDepth, scope, ident, Get, type, InitializationMode::NotInitialization);
     733                RETURN_IF_EXCEPTION(throwScope, false);
    729734
    730735                if (op.type == ClosureVar || op.type == ModuleVar)
  • trunk/Source/JavaScriptCore/dfg/DFGOSRExit.cpp

    r221832 r221849  
    345345
    346346    ASSERT(!vm.callFrameForCatch || exit.m_kind == GenericUnwind);
    347     ASSERT_UNUSED(scope, !exit.isExceptionHandler() || !!scope.exception());
     347    EXCEPTION_ASSERT_UNUSED(scope, !!scope.exception() || !exit.isExceptionHandler());
    348348
    349349    if (UNLIKELY(!exit.exitState)) {
  • trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp

    r221832 r221849  
    916916
    917917    JSString* input = argument.toStringOrNull(exec);
    918     ASSERT(!!scope.exception() == !input);
     918    EXCEPTION_ASSERT(!!scope.exception() == !input);
    919919    if (!input)
    920920        return encodedJSValue();
     
    938938
    939939    JSString* input = argument.toStringOrNull(exec);
    940     ASSERT(!!scope.exception() == !input);
     940    EXCEPTION_ASSERT(!!scope.exception() == !input);
    941941    if (!input)
    942942        return JSValue::encode(jsUndefined());
     
    10331033
    10341034    JSString* input = argument.toStringOrNull(exec);
    1035     ASSERT(!!scope.exception() == !input);
     1035    EXCEPTION_ASSERT(!!scope.exception() == !input);
    10361036    if (!input)
    10371037        return false;
     
    21942194            for (unsigned i = 0; i < array->size(); i++) {
    21952195                result->putDirectIndex(exec, index, array->get(i));
     2196                RETURN_IF_EXCEPTION(scope, nullptr);
    21962197                ++index;
    21972198            }
     
    21992200            // We are not spreading.
    22002201            result->putDirectIndex(exec, index, value);
     2202            RETURN_IF_EXCEPTION(scope, nullptr);
    22012203            ++index;
    22022204        }
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r221836 r221849  
    162162        JSScope::collectClosureVariablesUnderTDZ(callerScopeChain, variablesUnderTDZ);
    163163        eval = DirectEvalExecutable::create(callFrame, makeSource(programSource, callerCodeBlock->source()->sourceOrigin()), callerCodeBlock->isStrictMode(), derivedContextType, isArrowFunctionContext, evalContextType, &variablesUnderTDZ);
    164         ASSERT(!!scope.exception() == !eval);
     164        EXCEPTION_ASSERT(!!scope.exception() == !eval);
    165165        if (!eval)
    166166            return jsUndefined();
     
    252252    if (UNLIKELY(!arguments.isCell()) || !length)
    253253        return;
    254    
     254
     255    VM& vm = callFrame->vm();
     256    auto scope = DECLARE_THROW_SCOPE(vm);
    255257    JSCell* cell = arguments.asCell();
    256258
    257259    switch (cell->type()) {
    258260    case DirectArgumentsType:
     261        scope.release();
    259262        jsCast<DirectArguments*>(cell)->copyToArguments(callFrame, firstElementDest, offset, length);
    260263        return;
    261264    case ScopedArgumentsType:
     265        scope.release();
    262266        jsCast<ScopedArguments*>(cell)->copyToArguments(callFrame, firstElementDest, offset, length);
    263267        return;
    264268    case JSFixedArrayType:
     269        scope.release();
    265270        jsCast<JSFixedArray*>(cell)->copyToArguments(callFrame, firstElementDest, offset, length);
    266271        return;
     
    269274        JSObject* object = jsCast<JSObject*>(cell);
    270275        if (isJSArray(object)) {
     276            scope.release();
    271277            jsCast<JSArray*>(object)->copyToArguments(callFrame, firstElementDest, offset, length);
    272278            return;
     
    275281        for (i = 0; i < length && object->canGetIndexQuickly(i + offset); ++i)
    276282            callFrame->r(firstElementDest + i) = object->getIndexQuickly(i + offset);
    277         for (; i < length; ++i)
    278             callFrame->r(firstElementDest + i) = object->get(callFrame, i + offset);
     283        for (; i < length; ++i) {
     284            JSValue value = object->get(callFrame, i + offset);
     285            RETURN_IF_EXCEPTION(scope, void());
     286            callFrame->r(firstElementDest + i) = value;
     287        }
    279288        return;
    280289    } }
     
    711720        exceptionValue = jsNull();
    712721
    713     ASSERT_UNUSED(scope, scope.exception() && (!Options::exceptionStackTraceLimit() || scope.exception()->stack().size()));
     722    EXCEPTION_ASSERT_UNUSED(scope, scope.exception() && (!Options::exceptionStackTraceLimit() || scope.exception()->stack().size()));
    714723
    715724    // Calculate an exception handler vPC, unwinding call frames as necessary.
     
    768777
    769778    ProgramExecutable* program = ProgramExecutable::create(callFrame, source);
    770     ASSERT(throwScope.exception() || program);
     779    EXCEPTION_ASSERT(throwScope.exception() || program);
    771780    RETURN_IF_EXCEPTION(throwScope, { });
    772781
     
    883892    // Compile source to bytecode if necessary:
    884893    JSObject* error = program->initializeGlobalProperties(vm, callFrame, scope);
    885     ASSERT(!throwScope.exception() || !error);
     894    EXCEPTION_ASSERT(!throwScope.exception() || !error);
    886895    if (UNLIKELY(error))
    887896        return checkedReturn(throwException(callFrame, throwScope, error));
     
    891900        CodeBlock* tempCodeBlock;
    892901        JSObject* error = program->prepareForExecution<ProgramExecutable>(vm, nullptr, scope, CodeForCall, tempCodeBlock);
    893         ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(error));
     902        EXCEPTION_ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(error));
    894903        if (UNLIKELY(error))
    895904            return checkedReturn(error);
     
    949958        // Compile the callee:
    950959        JSObject* compileError = callData.js.functionExecutable->prepareForExecution<FunctionExecutable>(vm, jsCast<JSFunction*>(function), scope, CodeForCall, newCodeBlock);
    951         ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(compileError));
     960        EXCEPTION_ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(compileError));
    952961        if (UNLIKELY(!!compileError))
    953962            return checkedReturn(compileError);
     
    10161025        // Compile the callee:
    10171026        JSObject* compileError = constructData.js.functionExecutable->prepareForExecution<FunctionExecutable>(vm, jsCast<JSFunction*>(constructor), scope, CodeForConstruct, newCodeBlock);
    1018         ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(compileError));
     1027        EXCEPTION_ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(compileError));
    10191028        if (UNLIKELY(!!compileError))
    10201029            return checkedReturn(compileError);
     
    10641073    CodeBlock* newCodeBlock;
    10651074    JSObject* error = functionExecutable->prepareForExecution<FunctionExecutable>(vm, function, scope, CodeForCall, newCodeBlock);
    1066     ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(error));
     1075    EXCEPTION_ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(error));
    10671076    if (UNLIKELY(error))
    10681077        return CallFrameClosure();
     
    11471156        CodeBlock* tempCodeBlock;
    11481157        JSObject* compileError = eval->prepareForExecution<EvalExecutable>(vm, nullptr, scope, CodeForCall, tempCodeBlock);
    1149         ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(compileError));
     1158        EXCEPTION_ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(compileError));
    11501159        if (UNLIKELY(!!compileError))
    11511160            return checkedReturn(compileError);
     
    12001209                // We need create this variables because it will be used to emits code by bytecode generator
    12011210                variableObject->methodTable(vm)->put(variableObject, callFrame, function->name(), jsUndefined(), slot);
     1211                RETURN_IF_EXCEPTION(throwScope, checkedReturn(throwScope.exception()));
    12021212            }
    12031213        } else {
     
    12051215                FunctionExecutable* function = codeBlock->functionDecl(i);
    12061216                JSValue resolvedScope = JSScope::resolveScopeForHoistingFuncDeclInEval(callFrame, scope, function->name());
     1217                RETURN_IF_EXCEPTION(throwScope, checkedReturn(throwScope.exception()));
    12071218                if (resolvedScope.isUndefined())
    12081219                    return checkedReturn(throwSyntaxError(callFrame, throwScope, makeString("Can't create duplicate variable in eval: '", String(function->name().impl()), "'")));
     
    12161227                const Identifier& ident = codeBlock->functionHoistingCandidate(i);
    12171228                JSValue resolvedScope = JSScope::resolveScopeForHoistingFuncDeclInEval(callFrame, scope, ident);
     1229                RETURN_IF_EXCEPTION(throwScope, checkedReturn(throwScope.exception()));
    12181230                if (!resolvedScope.isUndefined()) {
    1219                     if (!variableObject->hasProperty(callFrame, ident)) {
     1231                    bool hasProperty = variableObject->hasProperty(callFrame, ident);
     1232                    RETURN_IF_EXCEPTION(throwScope, checkedReturn(throwScope.exception()));
     1233                    if (!hasProperty) {
    12201234                        PutPropertySlot slot(variableObject);
    12211235                        variableObject->methodTable(vm)->put(variableObject, callFrame, ident, jsUndefined(), slot);
     
    12651279        CodeBlock* tempCodeBlock;
    12661280        JSObject* compileError = executable->prepareForExecution<ModuleProgramExecutable>(vm, nullptr, scope, CodeForCall, tempCodeBlock);
    1267         ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(compileError));
     1281        EXCEPTION_ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(compileError));
    12681282        if (UNLIKELY(!!compileError))
    12691283            return checkedReturn(compileError);
  • trunk/Source/JavaScriptCore/jit/JITOperations.cpp

    r221832 r221849  
    354354    Identifier ident = Identifier::fromUid(vm, key);
    355355    LOG_IC((ICEvent::OperationIn, base->classInfo(*vm), ident));
     356    scope.release();
    356357    return JSValue::encode(jsBoolean(asObject(base)->hasProperty(exec, ident)));
    357358}
     
    554555        if (baseValue.isObject()) {
    555556            JSObject* object = asObject(baseValue);
    556             if (object->canSetIndexQuickly(i))
     557            if (object->canSetIndexQuickly(i)) {
    557558                object->setIndexQuickly(vm, i, value);
    558             else {
    559                 // FIXME: This will make us think that in-bounds typed array accesses are actually
    560                 // out-of-bounds.
    561                 // https://bugs.webkit.org/show_bug.cgi?id=149886
    562                 byValInfo->arrayProfile->setOutOfBounds();
    563                 object->methodTable(vm)->putByIndex(object, callFrame, i, value, callFrame->codeBlock()->isStrictMode());
     559                return;
    564560            }
    565         } else
    566             baseValue.putByIndex(callFrame, i, value, callFrame->codeBlock()->isStrictMode());
     561
     562            // FIXME: This will make us think that in-bounds typed array accesses are actually
     563            // out-of-bounds.
     564            // https://bugs.webkit.org/show_bug.cgi?id=149886
     565            byValInfo->arrayProfile->setOutOfBounds();
     566            scope.release();
     567            object->methodTable(vm)->putByIndex(object, callFrame, i, value, callFrame->codeBlock()->isStrictMode());
     568            return;
     569        }
     570
     571        scope.release();
     572        baseValue.putByIndex(callFrame, i, value, callFrame->codeBlock()->isStrictMode());
    567573        return;
    568574    }
     
    604610        }
    605611
     612        scope.release();
    606613        baseObject->putDirectIndex(callFrame, index, value, 0, isStrictMode ? PutDirectIndexShouldThrow : PutDirectIndexShouldNotThrow);
    607614        return;
     
    613620        if (subscriptAsDouble == subscriptAsUInt32 && isIndex(subscriptAsUInt32)) {
    614621            byValInfo->tookSlowPath = true;
     622            scope.release();
    615623            baseObject->putDirectIndex(callFrame, subscriptAsUInt32, value, 0, isStrictMode ? PutDirectIndexShouldThrow : PutDirectIndexShouldNotThrow);
    616624            return;
     
    624632    if (std::optional<uint32_t> index = parseIndex(property)) {
    625633        byValInfo->tookSlowPath = true;
     634        scope.release();
    626635        baseObject->putDirectIndex(callFrame, index.value(), value, 0, isStrictMode ? PutDirectIndexShouldThrow : PutDirectIndexShouldNotThrow);
    627636        return;
     
    958967        CodeBlock** codeBlockSlot = execCallee->addressOfCodeBlock();
    959968        JSObject* error = functionExecutable->prepareForExecution<FunctionExecutable>(*vm, callee, scope, kind, *codeBlockSlot);
    960         ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(error));
     969        EXCEPTION_ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(error));
    961970        if (error) {
    962971            return encodeResult(
     
    10171026       
    10181027        JSObject* error = functionExecutable->prepareForExecution<FunctionExecutable>(*vm, callee, scope, kind, codeBlock);
    1019         ASSERT_UNUSED(throwScope, throwScope.exception() == reinterpret_cast<Exception*>(error));
     1028        EXCEPTION_ASSERT_UNUSED(throwScope, throwScope.exception() == reinterpret_cast<Exception*>(error));
    10201029        if (error)
    10211030            return;
     
    10441053    JSValue calleeAsValue = execCallee->guaranteedJSValueCallee();
    10451054    calleeAsFunctionCell = getJSFunction(calleeAsValue);
    1046     if (UNLIKELY(!calleeAsFunctionCell))
     1055    if (UNLIKELY(!calleeAsFunctionCell)) {
     1056        throwScope.release();
    10471057        return handleHostCall(execCallee, calleeAsValue, callLinkInfo);
     1058    }
    10481059   
    10491060    JSFunction* function = jsCast<JSFunction*>(calleeAsFunctionCell);
     
    10621073        CodeBlock** codeBlockSlot = execCallee->addressOfCodeBlock();
    10631074        JSObject* error = functionExecutable->prepareForExecution<FunctionExecutable>(*vm, function, scope, kind, *codeBlockSlot);
    1064         ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(error));
     1075        EXCEPTION_ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(error));
    10651076        if (error) {
    10661077            return encodeResult(
     
    15941605    RETURN_IF_EXCEPTION(scope, void());
    15951606
     1607    scope.release();
    15961608    if (accessorType == AccessorType::Getter)
    15971609        base->putGetter(exec, propertyKey, accessor, attribute);
     
    17611773            if (asString(baseValue)->canGetIndex(i)) {
    17621774                ctiPatchCallByReturnAddress(returnAddress, FunctionPtr(operationGetByValString));
     1775                scope.release();
    17631776                return asString(baseValue)->getIndex(exec, i);
    17641777            }
     
    17771790        }
    17781791
     1792        scope.release();
    17791793        return baseValue.get(exec, i);
    17801794    }
     
    17891803        byValInfo->tookSlowPath = true;
    17901804
     1805    scope.release();
    17911806    return baseValue.get(exec, property);
    17921807}
     
    19801995    if (LIKELY(subscript.isUInt32())) {
    19811996        uint32_t i = subscript.asUInt32();
    1982         if (isJSString(baseValue) && asString(baseValue)->canGetIndex(i))
    1983             result = asString(baseValue)->getIndex(exec, i);
    1984         else {
    1985             result = baseValue.get(exec, i);
    1986             if (!isJSString(baseValue)) {
    1987                 ASSERT(exec->bytecodeOffset());
    1988                 ctiPatchCallByReturnAddress(ReturnAddressPtr(OUR_RETURN_ADDRESS), FunctionPtr(byValInfo->stubRoutine ? operationGetByValGeneric : operationGetByValOptimize));
    1989             }
     1997        if (isJSString(baseValue) && asString(baseValue)->canGetIndex(i)) {
     1998            scope.release();
     1999            return JSValue::encode(asString(baseValue)->getIndex(exec, i));
     2000        }
     2001        result = baseValue.get(exec, i);
     2002        RETURN_IF_EXCEPTION(scope, encodedJSValue());
     2003        if (!isJSString(baseValue)) {
     2004            ASSERT(exec->bytecodeOffset());
     2005            ctiPatchCallByReturnAddress(ReturnAddressPtr(OUR_RETURN_ADDRESS), FunctionPtr(byValInfo->stubRoutine ? operationGetByValGeneric : operationGetByValOptimize));
    19902006        }
    19912007    } else {
     
    19942010        auto property = subscript.toPropertyKey(exec);
    19952011        RETURN_IF_EXCEPTION(scope, encodedJSValue());
     2012        scope.release();
    19962013        result = baseValue.get(exec, property);
    19972014    }
     
    20122029
    20132030    JSObject* baseObj = JSValue::decode(encodedBase).toObject(exec);
     2031    RETURN_IF_EXCEPTION(scope, false);
    20142032    if (!baseObj)
    20152033        return false;
    20162034    bool couldDelete = baseObj->methodTable(vm)->deleteProperty(baseObj, exec, Identifier::fromUid(&vm, uid));
     2035    RETURN_IF_EXCEPTION(scope, false);
    20172036    if (!couldDelete && exec->codeBlock()->isStrictMode())
    20182037        throwTypeError(exec, scope, ASCIILiteral(UnableToDeletePropertyError));
     
    20322051
    20332052    JSObject* baseObj = JSValue::decode(encodedBase).toObject(exec);
     2053    RETURN_IF_EXCEPTION(scope, false);
    20342054    JSValue key = JSValue::decode(encodedKey);
    20352055    if (!baseObj)
     
    20412061        couldDelete = baseObj->methodTable(vm)->deletePropertyByIndex(baseObj, exec, index);
    20422062    else {
    2043         RETURN_IF_EXCEPTION(scope, false);
    20442063        Identifier property = key.toPropertyKey(exec);
    20452064        RETURN_IF_EXCEPTION(scope, false);
    20462065        couldDelete = baseObj->methodTable(vm)->deleteProperty(baseObj, exec, property);
    20472066    }
     2067    RETURN_IF_EXCEPTION(scope, false);
    20482068    if (!couldDelete && exec->codeBlock()->isStrictMode())
    20492069        throwTypeError(exec, scope, ASCIILiteral(UnableToDeletePropertyError));
     
    21982218    ASSERT(getPutInfo.resolveType() != ModuleVar);
    21992219
     2220    throwScope.release();
    22002221    return JSValue::encode(scope->getPropertySlot(exec, ident, [&] (bool found, PropertySlot& slot) -> JSValue {
    22012222        if (!found) {
     
    22492270
    22502271    bool hasProperty = scope->hasProperty(exec, ident);
     2272    EXCEPTION_ASSERT(!throwScope.exception() || !hasProperty);
    22512273    if (hasProperty
    22522274        && scope->isGlobalLexicalEnvironment()
     
    25212543    double a = op1.toNumber(exec);
    25222544    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     2545    scope.release();
    25232546    double b = op2.toNumber(exec);
    25242547    return JSValue::encode(jsNumber(a * b));
     
    26222645    JSValue operand = JSValue::decode(encodedOperand);
    26232646    double number = operand.toNumber(exec);
    2624     if (UNLIKELY(scope.exception()))
    2625         return JSValue::encode(JSValue());
     2647    RETURN_IF_EXCEPTION(scope, encodedJSValue());
    26262648    return JSValue::encode(jsNumber(-number));
    26272649}
     
    26362658    arithProfile.observeLHS(operand);
    26372659    double number = operand.toNumber(exec);
    2638     if (UNLIKELY(scope.exception()))
    2639         return JSValue::encode(JSValue());
     2660    RETURN_IF_EXCEPTION(scope, encodedJSValue());
    26402661
    26412662    JSValue result = jsNumber(-number);
     
    26732694   
    26742695    double number = operand.toNumber(exec);
    2675     if (UNLIKELY(scope.exception()))
    2676         return JSValue::encode(JSValue());
     2696    RETURN_IF_EXCEPTION(scope, encodedJSValue());
    26772697    JSValue result = jsNumber(-number);
    26782698    arithProfile->observeResult(result);
     
    26972717
    26982718    double number = operand.toNumber(exec);
    2699     if (UNLIKELY(scope.exception()))
    2700         return JSValue::encode(JSValue());
     2719    RETURN_IF_EXCEPTION(scope, encodedJSValue());
    27012720    return JSValue::encode(jsNumber(-number));
    27022721}
     
    27102729    double a = op1.toNumber(exec);
    27112730    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     2731    scope.release();
    27122732    double b = op2.toNumber(exec);
    27132733    return JSValue::encode(jsNumber(a - b));
  • trunk/Source/JavaScriptCore/jsc.cpp

    r221822 r221849  
    414414            return throwVMTypeError(exec, scope);
    415415        bool shouldThrow = thisObject->get(exec, PropertyName(Identifier::fromString(exec, "shouldThrow"))).toBoolean(exec);
     416        RETURN_IF_EXCEPTION(scope, encodedJSValue());
    416417        if (shouldThrow)
    417418            return throwVMTypeError(exec, scope);
     
    16571658        return rejectPromise(createError(exec, makeString("Could not resolve the referrer name '", String(referrer.impl()), "'.")));
    16581659
    1659     return JSC::importModule(exec, Identifier::fromString(&vm, resolvePath(directoryName.value(), ModuleName(moduleName))), jsUndefined());
     1660    auto result = JSC::importModule(exec, Identifier::fromString(&vm, resolvePath(directoryName.value(), ModuleName(moduleName))), jsUndefined());
     1661    scope.releaseAssertNoException();
     1662    return result;
    16601663}
    16611664
     
    16741677    }
    16751678
    1676     if (key.isSymbol())
    1677         return deferred->resolve(exec, keyValue);
    1678 
     1679    if (key.isSymbol()) {
     1680        auto result = deferred->resolve(exec, keyValue);
     1681        scope.releaseAssertNoException();
     1682        return result;
     1683    }
    16791684    if (referrerValue.isUndefined()) {
    16801685        auto directoryName = currentWorkingDirectory();
    16811686        if (!directoryName)
    16821687            return deferred->reject(exec, createError(exec, ASCIILiteral("Could not resolve the current working directory.")));
    1683         return deferred->resolve(exec, jsString(exec, resolvePath(directoryName.value(), ModuleName(key.impl()))));
     1688        auto result = deferred->resolve(exec, jsString(exec, resolvePath(directoryName.value(), ModuleName(key.impl()))));
     1689        scope.releaseAssertNoException();
     1690        return result;
    16841691    }
    16851692
     
    16951702        if (!directoryName)
    16961703            return deferred->reject(exec, createError(exec, ASCIILiteral("Could not resolve the current working directory.")));
    1697         return deferred->resolve(exec, jsString(exec, resolvePath(directoryName.value(), ModuleName(key.impl()))));
     1704        auto result = deferred->resolve(exec, jsString(exec, resolvePath(directoryName.value(), ModuleName(key.impl()))));
     1705        scope.releaseAssertNoException();
     1706        return result;
    16981707    }
    16991708
     
    27132722    args.append(jsBuffer);
    27142723    args.append(jsNumber(message->index()));
     2724    scope.release();
    27152725    return JSValue::encode(call(exec, callback, callType, callData, jsNull(), args));
    27162726}
  • trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp

    r221822 r221849  
    820820    if (subscript.isUInt32()) {
    821821        uint32_t i = subscript.asUInt32();
    822         if (isJSString(baseValue) && asString(baseValue)->canGetIndex(i))
     822        if (isJSString(baseValue) && asString(baseValue)->canGetIndex(i)) {
     823            scope.release();
    823824            return asString(baseValue)->getIndex(exec, i);
     825        }
    824826        scope.release();
    825827        return baseValue.get(exec, i);
     
    13321334        CodeBlock** codeBlockSlot = execCallee->addressOfCodeBlock();
    13331335        JSObject* error = functionExecutable->prepareForExecution<FunctionExecutable>(vm, callee, scope, kind, *codeBlockSlot);
    1334         ASSERT(throwScope.exception() == error);
     1336        EXCEPTION_ASSERT(throwScope.exception() == error);
    13351337        if (UNLIKELY(error))
    13361338            LLINT_CALL_THROW(exec, error);
  • trunk/Source/JavaScriptCore/parser/Parser.h

    r221358 r221849  
    11771177    void popScopeInternal(ScopeRef& scope, bool shouldTrackClosedVariables)
    11781178    {
    1179         ASSERT_UNUSED(scope, scope.index() == m_scopeStack.size() - 1);
     1179        EXCEPTION_ASSERT_UNUSED(scope, scope.index() == m_scopeStack.size() - 1);
    11801180        ASSERT(m_scopeStack.size() > 1);
    11811181        m_scopeStack[m_scopeStack.size() - 2].collectFreeVariables(&m_scopeStack.last(), shouldTrackClosedVariables);
  • trunk/Source/JavaScriptCore/runtime/AbstractModuleRecord.cpp

    r221822 r221849  
    147147AbstractModuleRecord* AbstractModuleRecord::hostResolveImportedModule(ExecState* exec, const Identifier& moduleName)
    148148{
     149    VM& vm = exec->vm();
     150    auto scope = DECLARE_THROW_SCOPE(vm);
    149151    JSValue moduleNameValue = identifierToJSValue(exec, moduleName);
    150152    JSValue pair = m_dependenciesMap->JSMap::get(exec, moduleNameValue);
     153    RETURN_IF_EXCEPTION(scope, nullptr);
     154    scope.release();
    151155    return jsCast<AbstractModuleRecord*>(pair.get(exec, Identifier::fromString(exec, "value")));
    152156}
     
    154158auto AbstractModuleRecord::resolveImport(ExecState* exec, const Identifier& localName) -> Resolution
    155159{
     160    VM& vm = exec->vm();
     161    auto scope = DECLARE_THROW_SCOPE(vm);
     162
    156163    std::optional<ImportEntry> optionalImportEntry = tryGetImportEntry(localName.impl());
    157164    if (!optionalImportEntry)
     
    163170
    164171    AbstractModuleRecord* importedModule = hostResolveImportedModule(exec, importEntry.moduleRequest);
     172    RETURN_IF_EXCEPTION(scope, Resolution::error());
    165173    return importedModule->resolveExport(exec, importEntry.importName);
    166174}
     
    237245auto AbstractModuleRecord::resolveExportImpl(ExecState* exec, const ResolveQuery& root) -> Resolution
    238246{
     247    VM& vm = exec->vm();
     248    auto scope = DECLARE_THROW_SCOPE(vm);
     249
    239250    // http://www.ecma-international.org/ecma-262/6.0/#sec-resolveexport
    240251
     
    497508        // Rationale to this error: A default export cannot be provided by an export *.
    498509        VM& vm = exec->vm();
     510        auto scope = DECLARE_THROW_SCOPE(vm);
    499511        if (query.exportName == vm.propertyNames->defaultKeyword.impl())
    500512            return false;
     
    515527            const RefPtr<UniquedStringImpl>& starModuleName = *iterator;
    516528            AbstractModuleRecord* importedModuleRecord = query.moduleRecord->hostResolveImportedModule(exec, Identifier::fromUid(exec, starModuleName.get()));
     529            RETURN_IF_EXCEPTION(scope, false);
    517530            pendingTasks.append(Task { ResolveQuery(importedModuleRecord, query.exportName.get()), Type::Query });
    518531        }
     
    577590                // If there is no matched exported binding in the current module,
    578591                // we need to look into the stars.
    579                 if (!resolveNonLocal(task.query))
     592                bool success = resolveNonLocal(task.query);
     593                EXCEPTION_ASSERT(!scope.exception() || !success);
     594                if (!success)
    580595                    return Resolution::error();
    581596                continue;
     
    596611            case ExportEntry::Type::Indirect: {
    597612                AbstractModuleRecord* importedModuleRecord = moduleRecord->hostResolveImportedModule(exec, exportEntry.moduleName);
     613                RETURN_IF_EXCEPTION(scope, Resolution::error());
    598614
    599615                // When the imported module does not produce any resolved binding, we need to look into the stars in the *current*
     
    615631                // Indirect export entry does not produce any resolved binding.
    616632                // So we will investigate the stars.
    617                 if (!resolveNonLocal(task.query))
     633                bool success = resolveNonLocal(task.query);
     634                EXCEPTION_ASSERT(!scope.exception() || !success);
     635                if (!success)
    618636                    return Resolution::error();
    619637                continue;
     
    664682{
    665683    VM& vm = exec->vm();
     684    auto scope = DECLARE_THROW_SCOPE(vm);
     685
    666686    HashSet<AbstractModuleRecord*> exportStarSet;
    667687    Vector<AbstractModuleRecord*, 8> pendingModules;
     
    683703        for (const auto& starModuleName : moduleRecord->starExportEntries()) {
    684704            AbstractModuleRecord* requestedModuleRecord = moduleRecord->hostResolveImportedModule(exec, Identifier::fromUid(exec, starModuleName.get()));
     705            RETURN_IF_EXCEPTION(scope, void());
    685706            pendingModules.append(requestedModuleRecord);
    686707        }
     
    700721    IdentifierSet exportedNames;
    701722    getExportedNames(exec, this, exportedNames);
     723    RETURN_IF_EXCEPTION(scope, nullptr);
    702724
    703725    Vector<std::pair<Identifier, Resolution>> resolutions;
     
    705727        Identifier ident = Identifier::fromUid(exec, name.get());
    706728        const Resolution resolution = resolveExport(exec, ident);
     729        RETURN_IF_EXCEPTION(scope, nullptr);
    707730        switch (resolution.type) {
    708731        case Resolution::Type::NotFound:
     
    723746    }
    724747
    725     m_moduleNamespaceObject.set(vm, this, JSModuleNamespaceObject::create(exec, globalObject, globalObject->moduleNamespaceObjectStructure(), this, WTFMove(resolutions)));
    726     return m_moduleNamespaceObject.get();
     748    auto* moduleNamespaceObject = JSModuleNamespaceObject::create(exec, globalObject, globalObject->moduleNamespaceObjectStructure(), this, WTFMove(resolutions));
     749    RETURN_IF_EXCEPTION(scope, nullptr);
     750    m_moduleNamespaceObject.set(vm, this, moduleNamespaceObject);
     751    return moduleNamespaceObject;
    727752}
    728753
  • trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp

    r221822 r221849  
    161161    PropertySlot slot(object, PropertySlot::InternalMethodType::HasProperty);
    162162    bool hasProperty = object->getPropertySlot(exec, index, slot);
    163     ASSERT(!scope.exception() || !hasProperty);
     163    EXCEPTION_ASSERT(!scope.exception() || !hasProperty);
    164164    if (!hasProperty)
    165165        return { };
     
    230230        // We need prototype check for subclasses of Array, which are Array objects but have a different prototype by default.
    231231        bool isValid = speciesWatchpointIsValid(exec, thisObject);
     232        scope.assertNoException();
    232233        if (LIKELY(isValid))
    233234            return std::make_pair(SpeciesConstructResult::FastPath, nullptr);
     
    355356        if (array->length() == length) {
    356357            bool handled = array->unshiftCount<shiftCountMode>(exec, header, count);
    357             ASSERT(!scope.exception() || handled);
     358            EXCEPTION_ASSERT(!scope.exception() || handled);
    358359            if (handled)
    359360                return;
     
    420421
    421422    StringRecursionChecker checker(exec, thisArray);
    422     ASSERT(!scope.exception() || checker.earlyReturnValue());
     423    EXCEPTION_ASSERT(!scope.exception() || checker.earlyReturnValue());
    423424    if (JSValue earlyReturnValue = checker.earlyReturnValue())
    424425        return JSValue::encode(earlyReturnValue);
     
    453454
    454455    StringRecursionChecker checker(exec, thisObject);
    455     ASSERT(!scope.exception() || checker.earlyReturnValue());
     456    EXCEPTION_ASSERT(!scope.exception() || checker.earlyReturnValue());
    456457    if (JSValue earlyReturnValue = checker.earlyReturnValue())
    457458        return JSValue::encode(earlyReturnValue);
     
    666667    // 1. Let O be ? ToObject(this value).
    667668    JSObject* thisObject = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
    668     ASSERT(!!scope.exception() == !thisObject);
     669    EXCEPTION_ASSERT(!!scope.exception() == !thisObject);
    669670    if (UNLIKELY(!thisObject))
    670671        return encodedJSValue();
    671672
    672673    StringRecursionChecker checker(exec, thisObject);
    673     ASSERT(!scope.exception() || checker.earlyReturnValue());
     674    EXCEPTION_ASSERT(!scope.exception() || checker.earlyReturnValue());
    674675    if (JSValue earlyReturnValue = checker.earlyReturnValue())
    675676        return JSValue::encode(earlyReturnValue);
     
    733734
    734735    JSObject* thisObj = thisValue.toObject(exec);
    735     ASSERT(!!scope.exception() == !thisObj);
     736    EXCEPTION_ASSERT(!!scope.exception() == !thisObj);
    736737    if (UNLIKELY(!thisObj))
    737738        return encodedJSValue();
     
    772773   
    773774    JSObject* thisObj = thisValue.toObject(exec);
    774     ASSERT(!!scope.exception() == !thisObj);
     775    EXCEPTION_ASSERT(!!scope.exception() == !thisObj);
    775776    if (UNLIKELY(!thisObj))
    776777        return encodedJSValue();
     
    802803
    803804    JSObject* thisObject = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
    804     ASSERT(!!scope.exception() == !thisObject);
     805    EXCEPTION_ASSERT(!!scope.exception() == !thisObject);
    805806    if (UNLIKELY(!thisObject))
    806807        return encodedJSValue();
     
    894895    auto scope = DECLARE_THROW_SCOPE(vm);
    895896    JSObject* thisObj = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
    896     ASSERT(!!scope.exception() == !thisObj);
     897    EXCEPTION_ASSERT(!!scope.exception() == !thisObj);
    897898    if (UNLIKELY(!thisObj))
    898899        return encodedJSValue();
     
    921922    auto scope = DECLARE_THROW_SCOPE(vm);
    922923    JSObject* thisObj = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
    923     ASSERT(!!scope.exception() == !thisObj);
     924    EXCEPTION_ASSERT(!!scope.exception() == !thisObj);
    924925    if (UNLIKELY(!thisObj))
    925926        return { };
     
    936937    std::pair<SpeciesConstructResult, JSObject*> speciesResult = speciesConstructArray(exec, thisObj, end - begin);
    937938    // We can only get an exception if we call some user function.
    938     ASSERT(!!scope.exception() == (speciesResult.first == SpeciesConstructResult::Exception));
     939    EXCEPTION_ASSERT(!!scope.exception() == (speciesResult.first == SpeciesConstructResult::Exception));
    939940    if (UNLIKELY(speciesResult.first == SpeciesConstructResult::Exception))
    940941        return { };
     
    977978
    978979    JSObject* thisObj = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
    979     ASSERT(!!scope.exception() == !thisObj);
     980    EXCEPTION_ASSERT(!!scope.exception() == !thisObj);
    980981    if (UNLIKELY(!thisObj))
    981982        return encodedJSValue();
     
    985986    if (!exec->argumentCount()) {
    986987        std::pair<SpeciesConstructResult, JSObject*> speciesResult = speciesConstructArray(exec, thisObj, 0);
    987         ASSERT(!!scope.exception() == (speciesResult.first == SpeciesConstructResult::Exception));
     988        EXCEPTION_ASSERT(!!scope.exception() == (speciesResult.first == SpeciesConstructResult::Exception));
    988989        if (UNLIKELY(speciesResult.first == SpeciesConstructResult::Exception))
    989990            return encodedJSValue();
     
    10201021
    10211022    std::pair<SpeciesConstructResult, JSObject*> speciesResult = speciesConstructArray(exec, thisObj, actualDeleteCount);
    1022     ASSERT(!!scope.exception() == (speciesResult.first == SpeciesConstructResult::Exception));
     1023    EXCEPTION_ASSERT(!!scope.exception() == (speciesResult.first == SpeciesConstructResult::Exception));
    10231024    if (speciesResult.first == SpeciesConstructResult::Exception)
    10241025        return JSValue::encode(jsUndefined());
     
    10751076
    10761077    JSObject* thisObj = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
    1077     ASSERT(!!scope.exception() == !thisObj);
     1078    EXCEPTION_ASSERT(!!scope.exception() == !thisObj);
    10781079    if (UNLIKELY(!thisObj))
    10791080        return encodedJSValue();
     
    11061107    // 15.4.4.14
    11071108    JSObject* thisObj = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
    1108     ASSERT(!!scope.exception() == !thisObj);
     1109    EXCEPTION_ASSERT(!!scope.exception() == !thisObj);
    11091110    if (UNLIKELY(!thisObj))
    11101111        return encodedJSValue();
     
    11131114
    11141115    unsigned index = argumentClampedIndexFromStartOrEnd(exec, 1, length);
     1116    RETURN_IF_EXCEPTION(scope, encodedJSValue());
    11151117    JSValue searchElement = exec->argument(0);
    11161118    for (; index < length; ++index) {
     
    11341136    // 15.4.4.15
    11351137    JSObject* thisObj = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
    1136     ASSERT(!!scope.exception() == !thisObj);
     1138    EXCEPTION_ASSERT(!!scope.exception() == !thisObj);
    11371139    if (UNLIKELY(!thisObj))
    11381140        return encodedJSValue();
     
    12241226
    12251227    bool success = result->appendMemcpy(exec, vm, 0, first);
    1226     ASSERT(!success || !scope.exception());
     1228    EXCEPTION_ASSERT(!scope.exception() || !success);
    12271229    if (!success) {
    12281230        RETURN_IF_EXCEPTION(scope, encodedJSValue());
    12291231
    12301232        bool success = moveElements(exec, vm, result, 0, first, firstArraySize);
    1231         ASSERT(!scope.exception() == success);
     1233        EXCEPTION_ASSERT(!scope.exception() == success);
    12321234        if (UNLIKELY(!success))
    12331235            return encodedJSValue();
     
    12571259    // We need to check the species constructor here since checking it in the JS wrapper is too expensive for the non-optimizing tiers.
    12581260    bool isValid = speciesWatchpointIsValid(exec, firstArray);
     1261    scope.assertNoException();
    12591262    if (UNLIKELY(!isValid))
    12601263        return JSValue::encode(jsNull());
     
    12911294
    12921295        bool success = moveElements(exec, vm, result, 0, firstArray, firstArraySize);
    1293         ASSERT(!scope.exception() == success);
     1296        EXCEPTION_ASSERT(!scope.exception() == success);
    12941297        if (UNLIKELY(!success))
    12951298            return encodedJSValue();
    12961299        success = moveElements(exec, vm, result, firstArraySize, secondArray, secondArraySize);
    1297         ASSERT(!scope.exception() == success);
     1300        EXCEPTION_ASSERT(!scope.exception() == success);
    12981301        if (UNLIKELY(!success))
    12991302            return encodedJSValue();
     
    13521355    unsigned startIndex = static_cast<unsigned>(startValue.asAnyInt());
    13531356    bool success = resultArray->appendMemcpy(exec, vm, startIndex, otherArray);
    1354     ASSERT(!success || !scope.exception());
    1355     if (!success) {
    1356         RETURN_IF_EXCEPTION(scope, encodedJSValue());
    1357         moveElements(exec, vm, resultArray, startIndex, otherArray, otherArray->length());
    1358     }
     1357    EXCEPTION_ASSERT(!scope.exception() || !success);
     1358    if (success)
     1359        return JSValue::encode(jsUndefined());
     1360    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     1361    scope.release();
     1362    moveElements(exec, vm, resultArray, startIndex, otherArray, otherArray->length());
    13591363    return JSValue::encode(jsUndefined());
    13601364}
  • trunk/Source/JavaScriptCore/runtime/CatchScope.h

    r206525 r221849  
    6969#endif // ENABLE(EXCEPTION_SCOPE_VERIFICATION)
    7070
     71#define CLEAR_AND_RETURN_IF_EXCEPTION(scope__, value__) do { \
     72        if (UNLIKELY((scope__).exception())) { \
     73            (scope__).clearException(); \
     74            return value__; \
     75        } \
     76    } while (false)
     77
    7178} // namespace JSC
  • trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp

    r221822 r221849  
    10451045                RELEASE_ASSERT(array->get(i));
    10461046                result->putDirectIndex(exec, index, array->get(i));
     1047                CHECK_EXCEPTION();
    10471048                ++index;
    10481049            }
     
    10501051            // We are not spreading.
    10511052            result->putDirectIndex(exec, index, value);
     1053            CHECK_EXCEPTION();
    10521054            ++index;
    10531055        }
  • trunk/Source/JavaScriptCore/runtime/DatePrototype.cpp

    r221822 r221849  
    928928
    929929    double milli = timeClip(exec->argument(0).toNumber(exec));
     930    RETURN_IF_EXCEPTION(scope, encodedJSValue());
    930931    JSValue result = jsNumber(milli);
    931932    thisDateObj->setInternalValue(vm, result);
     
    961962    GregorianDateTime gregorianDateTime;
    962963    gregorianDateTime.copyFrom(*other);
    963     if (!fillStructuresUsingTimeArgs(exec, numArgsToUse, &ms, &gregorianDateTime)) {
     964    bool success = fillStructuresUsingTimeArgs(exec, numArgsToUse, &ms, &gregorianDateTime);
     965    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     966    if (!success) {
    964967        JSValue result = jsNaN();
    965968        thisDateObj->setInternalValue(vm, result);
  • trunk/Source/JavaScriptCore/runtime/DirectArguments.h

    r221822 r221849  
    7777        if (UNLIKELY(m_mappedArguments)) {
    7878            VM& vm = exec->vm();
    79             return get(exec, vm.propertyNames->length).toUInt32(exec);
     79            auto scope = DECLARE_THROW_SCOPE(vm);
     80            JSValue value = get(exec, vm.propertyNames->length);
     81            RETURN_IF_EXCEPTION(scope, 0);
     82            scope.release();
     83            return value.toUInt32(exec);
    8084        }
    8185        return m_length;
  • trunk/Source/JavaScriptCore/runtime/ErrorPrototype.cpp

    r221822 r221849  
    8181    // Guard against recursion!
    8282    StringRecursionChecker checker(exec, thisObj);
    83     ASSERT(!scope.exception() || checker.earlyReturnValue());
     83    EXCEPTION_ASSERT(!scope.exception() || checker.earlyReturnValue());
    8484    if (JSValue earlyReturnValue = checker.earlyReturnValue())
    8585        return JSValue::encode(earlyReturnValue);
  • trunk/Source/JavaScriptCore/runtime/ExceptionFuzz.cpp

    r208834 r221849  
    5757        // even when one may already exist. This is ok for ExceptionFuzz testing, but we need
    5858        // to placate the exception check verifier here.
    59         ASSERT(scope.exception() || !scope.exception());
     59        EXCEPTION_ASSERT(scope.exception() || !scope.exception());
    6060
    6161        throwException(exec, scope, createError(exec, ASCIILiteral("Exception Fuzz")));
  • trunk/Source/JavaScriptCore/runtime/ExceptionScope.h

    r216876 r221849  
    3333   
    3434#if ENABLE(EXCEPTION_SCOPE_VERIFICATION)
    35    
     35
     36#define EXCEPTION_ASSERT(assertion) RELEASE_ASSERT(assertion)
     37#define EXCEPTION_ASSERT_UNUSED(variable, assertion) RELEASE_ASSERT(assertion)
     38#define EXCEPTION_ASSERT_WITH_MESSAGE(assertion, message) RELEASE_ASSERT_WITH_MESSAGE(assertion, message)
     39
    3640class ExceptionScope {
    3741public:
     
    4044    Exception* exception() { return m_vm.exception(); }
    4145
    42     ALWAYS_INLINE void assertNoException() { ASSERT_WITH_MESSAGE(!exception(), "%s", unexpectedExceptionMessage().data()); }
     46    ALWAYS_INLINE void assertNoException() { RELEASE_ASSERT_WITH_MESSAGE(!exception(), "%s", unexpectedExceptionMessage().data()); }
    4347    ALWAYS_INLINE void releaseAssertNoException() { RELEASE_ASSERT_WITH_MESSAGE(!exception(), "%s", unexpectedExceptionMessage().data()); }
    4448
     
    5660    unsigned m_recursionDepth;
    5761};
    58    
     62
    5963#else // not ENABLE(EXCEPTION_SCOPE_VERIFICATION)
    6064   
     65#define EXCEPTION_ASSERT(x) ASSERT(x)
     66#define EXCEPTION_ASSERT_UNUSED(variable, assertion) ASSERT_UNUSED(variable, assertion)
     67#define EXCEPTION_ASSERT_WITH_MESSAGE(assertion, message) ASSERT_WITH_MESSAGE(assertion, message)
     68
    6169class ExceptionScope {
    6270public:
     
    7886    VM& m_vm;
    7987};
    80    
     88
    8189#endif // ENABLE(EXCEPTION_SCOPE_VERIFICATION)
    8290
  • trunk/Source/JavaScriptCore/runtime/GenericArgumentsInlines.h

    r221822 r221849  
    244244                        ASSERT(value);
    245245                        object->putDirectMayBeIndex(exec, ident, value);
     246                        scope.assertNoException();
    246247                    }
    247248                    thisObject->unmapArgument(vm, index);
  • trunk/Source/JavaScriptCore/runtime/HashMapImpl.h

    r221110 r221849  
    637637        while (iter != end) {
    638638            uint32_t index = jsMapHash(exec, vm, iter->key()) & mask;
    639             ASSERT_WITH_MESSAGE(!scope.exception(), "All keys should already be hashed before, so this should not throw because it won't resolve ropes.");
     639            EXCEPTION_ASSERT_WITH_MESSAGE(!scope.exception(), "All keys should already be hashed before, so this should not throw because it won't resolve ropes.");
    640640            {
    641641                HashMapBucketType* bucket = buffer[index];
  • trunk/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp

    r219282 r221849  
    10201020            part->putDirect(vm, vm.propertyNames->value, value);
    10211021            parts->push(&exec, part);
     1022            RETURN_IF_EXCEPTION(scope, { });
    10221023        }
    10231024        previousEndIndex = endIndex;
     
    10301031            part->putDirect(vm, vm.propertyNames->value, value);
    10311032            parts->push(&exec, part);
     1033            RETURN_IF_EXCEPTION(scope, { });
    10321034        }
    10331035    }
  • trunk/Source/JavaScriptCore/runtime/JSArray.cpp

    r221822 r221849  
    166166        // c. Let newLen be ToUint32(Desc.[[Value]]).
    167167        unsigned newLen = descriptor.value().toUInt32(exec);
     168        RETURN_IF_EXCEPTION(scope, false);
    168169        // d. If newLen is not equal to ToNumber( Desc.[[Value]]), throw a RangeError exception.
    169         if (newLen != descriptor.value().toNumber(exec)) {
     170        double valueAsNumber = descriptor.value().toNumber(exec);
     171        RETURN_IF_EXCEPTION(scope, false);
     172        if (newLen != valueAsNumber) {
    170173            JSC::throwException(exec, scope, createRangeError(exec, ASCIILiteral("Invalid array length")));
    171174            return false;
     
    199202        // l.iii. If deleteSucceeded is false, then
    200203        bool success = array->setLength(exec, newLen, throwException);
    201         ASSERT(!scope.exception() || !success);
     204        EXCEPTION_ASSERT(!scope.exception() || !success);
    202205        if (!success) {
    203206            // 1. Set newLenDesc.[[Value] to oldLen+1.
     
    273276        unsigned newLength = value.toUInt32(exec);
    274277        RETURN_IF_EXCEPTION(scope, false);
    275         if (value.toNumber(exec) != static_cast<double>(newLength)) {
     278        double valueAsNumber = value.toNumber(exec);
     279        RETURN_IF_EXCEPTION(scope, false);
     280        if (valueAsNumber != static_cast<double>(newLength)) {
    276281            throwException(exec, scope, createRangeError(exec, ASCIILiteral("Invalid array length")));
    277282            return false;
  • trunk/Source/JavaScriptCore/runtime/JSCJSValue.cpp

    r221822 r221849  
    151151    auto scope = DECLARE_THROW_SCOPE(vm);
    152152
    153     if (std::optional<uint32_t> index = parseIndex(propertyName))
     153    if (std::optional<uint32_t> index = parseIndex(propertyName)) {
     154        scope.release();
    154155        return putToPrimitiveByIndex(exec, index.value(), value, slot.isStrictMode());
     156    }
    155157
    156158    // Check if there are any setters or getters in the prototype chain
    157159    JSObject* obj = synthesizePrototype(exec);
     160    EXCEPTION_ASSERT(!!scope.exception() == !obj);
    158161    if (UNLIKELY(!obj))
    159162        return false;
     
    177180
    178181            JSValue gs = obj->getDirect(offset);
    179             if (gs.isGetterSetter())
     182            if (gs.isGetterSetter()) {
     183                scope.release();
    180184                return callSetter(exec, *this, gs, value, slot.isStrictMode() ? StrictMode : NotStrictMode);
     185            }
    181186
    182187            if (gs.isCustomGetterSetter())
     
    208213   
    209214    JSObject* prototype = synthesizePrototype(exec);
    210     ASSERT(!prototype == !!scope.exception());
     215    EXCEPTION_ASSERT(!!scope.exception() == !prototype);
    211216    if (UNLIKELY(!prototype))
    212217        return false;
    213218    bool putResult = false;
    214     if (prototype->attemptToInterceptPutByIndexOnHoleForPrototype(exec, *this, propertyName, value, shouldThrow, putResult))
     219    bool success = prototype->attemptToInterceptPutByIndexOnHoleForPrototype(exec, *this, propertyName, value, shouldThrow, putResult);
     220    RETURN_IF_EXCEPTION(scope, false);
     221    if (success)
    215222        return putResult;
    216223   
  • trunk/Source/JavaScriptCore/runtime/JSCJSValueInlines.h

    r221832 r221849  
    6060
    6161    double d = toNumber(exec);
    62 
     62    RETURN_IF_EXCEPTION(scope, 0);
    6363    if (d <= -1) {
    6464        throwException(exec, scope, createRangeError(exec, makeString(errorName, " cannot be negative")));
     
    7272    if (isInt32())
    7373        return asInt32();
     74    scope.release();
    7475    return JSC::toInt32(d);
    7576}
     
    797798ALWAYS_INLINE JSValue JSValue::get(ExecState* exec, PropertyName propertyName, PropertySlot& slot) const
    798799{
    799     return getPropertySlot(exec, propertyName, slot) ?
    800         slot.getValue(exec, propertyName) : jsUndefined();
     800    auto scope = DECLARE_THROW_SCOPE(exec->vm());
     801    bool hasSlot = getPropertySlot(exec, propertyName, slot);
     802    EXCEPTION_ASSERT(!scope.exception() || !hasSlot);
     803    if (!hasSlot)
     804        return jsUndefined();
     805    scope.release();
     806    return slot.getValue(exec, propertyName);
    801807}
    802808
     
    814820    bool found = getPropertySlot(exec, propertyName, slot);
    815821    RETURN_IF_EXCEPTION(scope, { });
     822    scope.release();
    816823    return callback(found, slot);
    817824}
     
    819826ALWAYS_INLINE bool JSValue::getPropertySlot(ExecState* exec, PropertyName propertyName, PropertySlot& slot) const
    820827{
     828    auto scope = DECLARE_THROW_SCOPE(exec->vm());
    821829    // If this is a primitive, we'll need to synthesize the prototype -
    822830    // and if it's a string there are special properties to check first.
    823831    JSObject* object;
    824832    if (UNLIKELY(!isObject())) {
    825         if (isString() && asString(*this)->getStringPropertySlot(exec, propertyName, slot))
    826             return true;
     833        if (isString()) {
     834            bool hasProperty = asString(*this)->getStringPropertySlot(exec, propertyName, slot);
     835            RETURN_IF_EXCEPTION(scope, false);
     836            if (hasProperty)
     837                return true;
     838        }
    827839        object = synthesizePrototype(exec);
     840        EXCEPTION_ASSERT(!!scope.exception() == !object);
    828841        if (UNLIKELY(!object))
    829842            return false;
    830843    } else
    831844        object = asObject(asCell());
    832    
     845
     846    scope.release();
    833847    return object->getPropertySlot(exec, propertyName, slot);
    834848}
     
    842856ALWAYS_INLINE JSValue JSValue::get(ExecState* exec, unsigned propertyName, PropertySlot& slot) const
    843857{
     858    auto scope = DECLARE_THROW_SCOPE(exec->vm());
    844859    // If this is a primitive, we'll need to synthesize the prototype -
    845860    // and if it's a string there are special properties to check first.
    846861    JSObject* object;
    847862    if (UNLIKELY(!isObject())) {
    848         if (isString() && asString(*this)->getStringPropertySlot(exec, propertyName, slot))
    849             return slot.getValue(exec, propertyName);
     863        if (isString()) {
     864            bool hasProperty = asString(*this)->getStringPropertySlot(exec, propertyName, slot);
     865            RETURN_IF_EXCEPTION(scope, { });
     866            if (hasProperty) {
     867                scope.release();
     868                return slot.getValue(exec, propertyName);
     869            }
     870        }
    850871        object = synthesizePrototype(exec);
     872        EXCEPTION_ASSERT(!!scope.exception() == !object);
    851873        if (UNLIKELY(!object))
    852874            return JSValue();
     
    854876        object = asObject(asCell());
    855877   
    856     if (object->getPropertySlot(exec, propertyName, slot))
    857         return slot.getValue(exec, propertyName);
    858     return jsUndefined();
     878    bool hasSlot = object->getPropertySlot(exec, propertyName, slot);
     879    EXCEPTION_ASSERT(!scope.exception() || !hasSlot);
     880    if (!hasSlot)
     881        return jsUndefined();
     882    scope.release();
     883    return slot.getValue(exec, propertyName);
    859884}
    860885
     
    922947        bool s1 = v1.isString();
    923948        bool s2 = v2.isString();
    924         if (s1 && s2)
     949        if (s1 && s2) {
     950            scope.release();
    925951            return asString(v1)->equal(exec, asString(v2));
     952        }
    926953
    927954        if (v1.isUndefinedOrNull()) {
     
    969996        if (s1 || s2) {
    970997            double d1 = v1.toNumber(exec);
     998            RETURN_IF_EXCEPTION(scope, false);
    971999            double d2 = v2.toNumber(exec);
     1000            RETURN_IF_EXCEPTION(scope, false);
    9721001            return d1 == d2;
    9731002        }
  • trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructorInlines.h

    r221711 r221849  
    101101
    102102    ViewClass* result = ViewClass::createUninitialized(exec, structure, storage.size());
    103     ASSERT(!!scope.exception() == !result);
     103    EXCEPTION_ASSERT(!!scope.exception() == !result);
    104104    if (UNLIKELY(!result))
    105105        return nullptr;
     
    107107    for (unsigned i = 0; i < storage.size(); ++i) {
    108108        bool success = result->setIndex(exec, i, storage.at(i));
    109         ASSERT(scope.exception() || success);
     109        EXCEPTION_ASSERT(scope.exception() || success);
    110110        if (!success)
    111111            return nullptr;
     
    198198       
    199199        ViewClass* result = ViewClass::createUninitialized(exec, structure, length);
    200         ASSERT(!!scope.exception() == !result);
     200        EXCEPTION_ASSERT(!!scope.exception() == !result);
    201201        if (UNLIKELY(!result))
    202202            return nullptr;
  • trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h

    r221439 r221849  
    253253        RELEASE_ASSERT(other->canAccessRangeQuickly(objectOffset, length));
    254254        bool success = validateRange(exec, offset, length);
    255         ASSERT(!scope.exception() == success);
     255        EXCEPTION_ASSERT(!scope.exception() == success);
    256256        if (!success)
    257257            return false;
     
    301301    case TypeDataView: {
    302302        bool success = validateRange(exec, offset, length);
    303         ASSERT(!scope.exception() == success);
     303        EXCEPTION_ASSERT(!scope.exception() == success);
    304304        if (!success)
    305305            return false;
     
    310310            RETURN_IF_EXCEPTION(scope, false);
    311311            bool success = setIndex(exec, offset + i, value);
    312             ASSERT(!scope.exception() || !success);
     312            EXCEPTION_ASSERT(!scope.exception() || !success);
    313313            if (!success)
    314314                return false;
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r221769 r221849  
    10461046    bool putResult = false;
    10471047    bool done = symbolTablePutTouchWatchpointSet(thisObject, exec, propertyName, value, shouldThrowReadOnlyError, ignoreReadOnlyErrors, putResult);
    1048     ASSERT((!!scope.exception() == (done && !putResult)) || !shouldThrowReadOnlyError);
     1048    EXCEPTION_ASSERT((!!scope.exception() == (done && !putResult)) || !shouldThrowReadOnlyError);
    10491049    if (done)
    10501050        return putResult;
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp

    r221822 r221849  
    232232        builder.append(c);
    233233    }
     234    scope.release();
    234235    return builder.build(exec);
    235236}
     
    487488    RETURN_IF_EXCEPTION(scope, encodedJSValue());
    488489
     490    JSValue parsedObject;
    489491    if (s.is8Bit()) {
    490492        LiteralParser<LChar> preparser(exec, s.characters8(), s.length(), NonStrictJSON);
    491         if (JSValue parsedObject = preparser.tryLiteralParse())
    492             return JSValue::encode(parsedObject);
     493        parsedObject = preparser.tryLiteralParse();
    493494    } else {
    494495        LiteralParser<UChar> preparser(exec, s.characters16(), s.length(), NonStrictJSON);
    495         if (JSValue parsedObject = preparser.tryLiteralParse())
    496             return JSValue::encode(parsedObject);
    497     }
     496        parsedObject = preparser.tryLiteralParse();
     497    }
     498    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     499    if (parsedObject)
     500        return JSValue::encode(parsedObject);
    498501
    499502    SourceOrigin sourceOrigin = exec->callerSourceOrigin();
    500503    JSGlobalObject* calleeGlobalObject = exec->jsCallee()->globalObject();
    501504    EvalExecutable* eval = IndirectEvalExecutable::create(exec, makeSource(s, sourceOrigin), false, DerivedContextType::None, false, EvalContextType::None);
     505    EXCEPTION_ASSERT(!!scope.exception() == !eval);
    502506    if (!eval)
    503         return JSValue::encode(jsUndefined());
    504 
     507        return encodedJSValue();
     508
     509    scope.release();
    505510    return JSValue::encode(vm.interpreter->execute(eval, exec, calleeGlobalObject->globalThis(), calleeGlobalObject->globalScope()));
    506511}
     
    707712    if (!thisObject) {
    708713        JSObject* prototype = exec->thisValue().synthesizePrototype(exec);
     714        EXCEPTION_ASSERT(!!scope.exception() == !prototype);
    709715        if (UNLIKELY(!prototype))
    710716            return JSValue::encode(JSValue());
     
    712718    }
    713719
     720    scope.release();
    714721    return JSValue::encode(thisObject->getPrototype(vm, exec));
    715722}
     
    736743        return JSValue::encode(jsUndefined());
    737744
     745    scope.release();
    738746    bool shouldThrowIfCantSet = true;
    739747    thisObject->setPrototype(vm, exec, value, shouldThrowIfCantSet);
     
    778786
    779787    auto* promise = JSPromiseDeferred::create(exec, globalObject);
    780     RETURN_IF_EXCEPTION(catchScope, { });
     788    CLEAR_AND_RETURN_IF_EXCEPTION(catchScope, encodedJSValue());
    781789
    782790    auto sourceOrigin = exec->callerSourceOrigin();
     
    786794        catchScope.clearException();
    787795        promise->reject(exec, exception->value());
     796        CLEAR_AND_RETURN_IF_EXCEPTION(catchScope, encodedJSValue());
    788797        return JSValue::encode(promise->promise());
    789798    }
     
    793802        catchScope.clearException();
    794803        promise->reject(exec, exception->value());
     804        CLEAR_AND_RETURN_IF_EXCEPTION(catchScope, encodedJSValue());
    795805        return JSValue::encode(promise->promise());
    796806    }
    797807    promise->resolve(exec, internalPromise);
     808    CLEAR_AND_RETURN_IF_EXCEPTION(catchScope, encodedJSValue());
    798809
    799810    return JSValue::encode(promise->promise());
  • trunk/Source/JavaScriptCore/runtime/JSInternalPromise.cpp

    r221822 r221849  
    5454{
    5555    VM& vm = exec->vm();
     56    auto scope = DECLARE_THROW_SCOPE(vm);
     57
    5658    JSObject* function = jsCast<JSObject*>(get(exec, vm.propertyNames->builtinNames().thenPublicName()));
     59    RETURN_IF_EXCEPTION(scope, nullptr);
    5760    CallData callData;
    5861    CallType callType = JSC::getCallData(function, callData);
     
    6366    arguments.append(onRejected ? onRejected : jsUndefined());
    6467
     68    scope.release();
    6569    return jsCast<JSInternalPromise*>(call(exec, function, callType, callData, this, arguments));
    6670}
  • trunk/Source/JavaScriptCore/runtime/JSInternalPromiseDeferred.cpp

    r217108 r221849  
    4141{
    4242    VM& vm = exec->vm();
     43    auto scope = DECLARE_THROW_SCOPE(vm);
    4344
    4445    JSValue deferred = newPromiseCapability(exec, globalObject, globalObject->internalPromiseConstructor());
     46    RETURN_IF_EXCEPTION(scope, nullptr);
    4547
    4648    JSValue promise = deferred.get(exec, vm.propertyNames->builtinNames().promisePrivateName());
     49    RETURN_IF_EXCEPTION(scope, nullptr);
    4750    ASSERT(promise.inherits(vm, JSInternalPromise::info()));
    4851    JSValue resolve = deferred.get(exec, vm.propertyNames->builtinNames().resolvePrivateName());
     52    RETURN_IF_EXCEPTION(scope, nullptr);
    4953    JSValue reject = deferred.get(exec, vm.propertyNames->builtinNames().rejectPrivateName());
     54    RETURN_IF_EXCEPTION(scope, nullptr);
    5055
    5156    JSInternalPromiseDeferred* result = new (NotNull, allocateCell<JSInternalPromiseDeferred>(vm.heap)) JSInternalPromiseDeferred(vm);
  • trunk/Source/JavaScriptCore/runtime/JSJob.cpp

    r218794 r221849  
    7272
    7373    MarkedArgumentBuffer handlerArguments;
    74     for (unsigned index = 0, length = m_arguments->length(); index < length; ++index)
    75         handlerArguments.append(m_arguments->JSArray::get(exec, index));
     74    for (unsigned index = 0, length = m_arguments->length(); index < length; ++index) {
     75        JSValue arg = m_arguments->JSArray::get(exec, index);
     76        CLEAR_AND_RETURN_IF_EXCEPTION(scope, void());
     77        handlerArguments.append(arg);
     78    }
    7679    profiledCall(exec, ProfilingReason::Microtask, m_job.get(), handlerCallType, handlerCallData, jsUndefined(), handlerArguments);
    7780    scope.clearException();
  • trunk/Source/JavaScriptCore/runtime/JSModuleEnvironment.cpp

    r221822 r221849  
    8484    JSModuleEnvironment* thisObject = jsCast<JSModuleEnvironment*>(cell);
    8585    AbstractModuleRecord::Resolution resolution = thisObject->moduleRecord()->resolveImport(exec, Identifier::fromUid(exec, propertyName.uid()));
     86    RETURN_IF_EXCEPTION(scope, false);
    8687    if (resolution.type == AbstractModuleRecord::Resolution::Type::Resolved) {
    8788        // When resolveImport resolves the resolution, the imported module environment must have the binding.
     
    121122    // All imported bindings are immutable.
    122123    AbstractModuleRecord::Resolution resolution = thisObject->moduleRecord()->resolveImport(exec, Identifier::fromUid(exec, propertyName.uid()));
     124    RETURN_IF_EXCEPTION(scope, false);
    123125    if (resolution.type == AbstractModuleRecord::Resolution::Type::Resolved) {
    124126        throwTypeError(exec, scope, ASCIILiteral(ReadonlyPropertyWriteError));
     
    130132bool JSModuleEnvironment::deleteProperty(JSCell* cell, ExecState* exec, PropertyName propertyName)
    131133{
     134    VM& vm = exec->vm();
     135    auto scope = DECLARE_THROW_SCOPE(vm);
     136
    132137    JSModuleEnvironment* thisObject = jsCast<JSModuleEnvironment*>(cell);
    133138    // All imported bindings are immutable.
    134139    AbstractModuleRecord::Resolution resolution = thisObject->moduleRecord()->resolveImport(exec, Identifier::fromUid(exec, propertyName.uid()));
     140    RETURN_IF_EXCEPTION(scope, false);
    135141    if (resolution.type == AbstractModuleRecord::Resolution::Type::Resolved)
    136142        return false;
  • trunk/Source/JavaScriptCore/runtime/JSModuleLoader.cpp

    r221822 r221849  
    8282{
    8383    VM& vm = exec->vm();
     84    auto scope = DECLARE_THROW_SCOPE(vm);
     85
    8486    JSObject* function = jsCast<JSObject*>(get(exec, vm.propertyNames->builtinNames().providePublicName()));
     87    RETURN_IF_EXCEPTION(scope, { });
    8588    CallData callData;
    8689    CallType callType = JSC::getCallData(function, callData);
     
    9396    arguments.append(JSSourceCode::create(vm, WTFMove(source)));
    9497
     98    scope.release();
    9599    return call(exec, function, callType, callData, this, arguments);
    96100}
     
    99103{
    100104    VM& vm = exec->vm();
     105    auto scope = DECLARE_THROW_SCOPE(vm);
     106
    101107    JSObject* function = jsCast<JSObject*>(get(exec, vm.propertyNames->builtinNames().loadAndEvaluateModulePublicName()));
     108    RETURN_IF_EXCEPTION(scope, nullptr);
    102109    CallData callData;
    103110    CallType callType = JSC::getCallData(function, callData);
     
    109116    arguments.append(scriptFetcher);
    110117
     118    scope.release();
    111119    return jsCast<JSInternalPromise*>(call(exec, function, callType, callData, this, arguments));
    112120}
     
    115123{
    116124    VM& vm = exec->vm();
     125    auto scope = DECLARE_THROW_SCOPE(vm);
     126
    117127    JSObject* function = jsCast<JSObject*>(get(exec, vm.propertyNames->builtinNames().loadModulePublicName()));
     128    RETURN_IF_EXCEPTION(scope, nullptr);
    118129    CallData callData;
    119130    CallType callType = JSC::getCallData(function, callData);
     
    125136    arguments.append(scriptFetcher);
    126137
     138    scope.release();
    127139    return jsCast<JSInternalPromise*>(call(exec, function, callType, callData, this, arguments));
    128140}
     
    131143{
    132144    VM& vm = exec->vm();
     145    auto scope = DECLARE_THROW_SCOPE(vm);
     146
    133147    JSObject* function = jsCast<JSObject*>(get(exec, vm.propertyNames->builtinNames().linkAndEvaluateModulePublicName()));
     148    RETURN_IF_EXCEPTION(scope, { });
    134149    CallData callData;
    135150    CallType callType = JSC::getCallData(function, callData);
     
    140155    arguments.append(scriptFetcher);
    141156
     157    scope.release();
    142158    return call(exec, function, callType, callData, this, arguments);
    143159}
     
    146162{
    147163    VM& vm = exec->vm();
     164    auto scope = DECLARE_THROW_SCOPE(vm);
     165
    148166    auto* function = jsCast<JSObject*>(get(exec, vm.propertyNames->builtinNames().requestImportModulePublicName()));
     167    RETURN_IF_EXCEPTION(scope, nullptr);
    149168    CallData callData;
    150169    auto callType = JSC::getCallData(function, callData);
     
    155174    arguments.append(scriptFetcher);
    156175
     176    scope.release();
    157177    return jsCast<JSInternalPromise*>(call(exec, function, callType, callData, this, arguments));
    158178}
  • trunk/Source/JavaScriptCore/runtime/JSModuleRecord.cpp

    r221822 r221849  
    8383
    8484    ModuleProgramExecutable* executable = ModuleProgramExecutable::create(exec, sourceCode());
     85    EXCEPTION_ASSERT(!!scope.exception() == !executable);
    8586    if (!executable) {
    8687        throwSyntaxError(exec, scope);
     
    111112        if (exportEntry.type == JSModuleRecord::ExportEntry::Type::Indirect) {
    112113            Resolution resolution = resolveExport(exec, exportEntry.exportName);
     114            RETURN_IF_EXCEPTION(scope, void());
    113115            switch (resolution.type) {
    114116            case Resolution::Type::NotFound:
     
    137139        const ImportEntry& importEntry = pair.value;
    138140        AbstractModuleRecord* importedModule = hostResolveImportedModule(exec, importEntry.moduleRequest);
     141        RETURN_IF_EXCEPTION(scope, void());
    139142        if (importEntry.isNamespace(vm)) {
    140143            JSModuleNamespaceObject* namespaceObject = importedModule->getModuleNamespace(exec);
     
    142145            bool putResult = false;
    143146            symbolTablePutTouchWatchpointSet(moduleEnvironment, exec, importEntry.localName, namespaceObject, /* shouldThrowReadOnlyError */ false, /* ignoreReadOnlyErrors */ true, putResult);
     147            RETURN_IF_EXCEPTION(scope, void());
    144148        } else {
    145149            Resolution resolution = importedModule->resolveExport(exec, importEntry.importName);
     150            RETURN_IF_EXCEPTION(scope, void());
    146151            switch (resolution.type) {
    147152            case Resolution::Type::NotFound:
     
    174179            bool putResult = false;
    175180            symbolTablePutTouchWatchpointSet(moduleEnvironment, exec, Identifier::fromUid(exec, variable.key.get()), jsUndefined(), /* shouldThrowReadOnlyError */ false, /* ignoreReadOnlyErrors */ true, putResult);
     181            RETURN_IF_EXCEPTION(scope, void());
    176182        }
    177183    }
     
    196202            bool putResult = false;
    197203            symbolTablePutTouchWatchpointSet(moduleEnvironment, exec, unlinkedFunctionExecutable->name(), function, /* shouldThrowReadOnlyError */ false, /* ignoreReadOnlyErrors */ true, putResult);
     204            RETURN_IF_EXCEPTION(scope, void());
    198205        }
    199206    }
  • trunk/Source/JavaScriptCore/runtime/JSONObject.cpp

    r221822 r221849  
    276276    Holder root(Holder::RootHolder, vm, object);
    277277    auto stringifyResult = appendStringifiedValue(result, value.get(), root, emptyPropertyName);
    278     ASSERT(!scope.exception() || (stringifyResult != StringifySucceeded));
     278    EXCEPTION_ASSERT(!scope.exception() || (stringifyResult != StringifySucceeded));
    279279    if (UNLIKELY(stringifyResult != StringifySucceeded))
    280280        return Local<Unknown>(vm, jsUndefined());
     
    295295    PropertySlot slot(object, PropertySlot::InternalMethodType::Get);
    296296    bool hasProperty = object->getPropertySlot(m_exec, vm.propertyNames->toJSON, slot);
    297     ASSERT(!scope.exception() || !hasProperty);
     297    EXCEPTION_ASSERT(!scope.exception() || !hasProperty);
    298298    if (!hasProperty)
    299299        return value;
     
    795795        LiteralParser<LChar> jsonParser(exec, view.characters8(), view.length(), StrictJSON);
    796796        unfiltered = jsonParser.tryLiteralParse();
    797         ASSERT(!scope.exception() || !unfiltered);
     797        EXCEPTION_ASSERT(!scope.exception() || !unfiltered);
    798798        if (!unfiltered) {
    799799            RETURN_IF_EXCEPTION(scope, { });
     
    803803        LiteralParser<UChar> jsonParser(exec, view.characters16(), view.length(), StrictJSON);
    804804        unfiltered = jsonParser.tryLiteralParse();
    805         ASSERT(!scope.exception() || !unfiltered);
     805        EXCEPTION_ASSERT(!scope.exception() || !unfiltered);
    806806        if (!unfiltered) {
    807807            RETURN_IF_EXCEPTION(scope, { });
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r221822 r221849  
    536536    PropertyName constructor(vm.propertyNames->constructor);
    537537    if (object->getPropertySlot(exec, constructor, slot)) {
     538        EXCEPTION_ASSERT(!scope.exception());
    538539        if (slot.isValue()) {
    539540            JSValue constructorValue = slot.getValue(exec, constructor);
     
    550551        }
    551552    }
    552     ASSERT(!scope.exception() || prototypeFunctionName.isNull());
     553    EXCEPTION_ASSERT(!scope.exception() || prototypeFunctionName.isNull());
    553554    if (UNLIKELY(scope.exception()))
    554555        scope.clearException();
     
    659660            ProxyObject* proxy = jsCast<ProxyObject*>(current);
    660661            PutPropertySlot slot(receiver, shouldThrow);
     662            scope.release();
    661663            return proxy->ProxyObject::put(proxy, exec, propertyName, value, slot);
    662664        }
     
    717719
    718720            // 9.1.9.1-4-d-iv Return ? Receiver.[[DefineOwnProperty]](P, valueDesc).
     721            scope.release();
    719722            return receiverObject->methodTable(vm)->defineOwnProperty(receiverObject, exec, propertyName, valueDescriptor, shouldThrow);
    720723        }
     
    722725        // 9.1.9.1-4-e Else Receiver does not currently have a property P,
    723726        // 9.1.9.1-4-e-i Return ? CreateDataProperty(Receiver, P, V).
     727        scope.release();
    724728        return receiverObject->methodTable(vm)->defineOwnProperty(receiverObject, exec, propertyName, PropertyDescriptor(value, None), shouldThrow);
    725729    }
     
    741745    CallData callData;
    742746    CallType callType = setterObject->methodTable(vm)->getCallData(setterObject, callData);
     747    scope.release();
    743748    call(exec, setterObject, callType, callData, receiver, args);
    744749
     
    773778            if (gs.isGetterSetter()) {
    774779                bool result = callSetter(exec, slot.thisValue(), gs, value, slot.isStrictMode() ? StrictMode : NotStrictMode);
     780                RETURN_IF_EXCEPTION(scope, false);
    775781                if (!structure()->isDictionary())
    776782                    slot.setCacheableSetter(obj, offset);
     
    793799        if (!obj->staticPropertiesReified()) {
    794800            if (obj->classInfo(vm)->hasStaticSetterOrReadonlyProperties()) {
    795                 if (auto entry = obj->findPropertyHashEntry(vm, propertyName))
     801                if (auto entry = obj->findPropertyHashEntry(vm, propertyName)) {
     802                    scope.release();
    796803                    return putEntry(exec, entry->table->classForThis, entry->value, obj, this, propertyName, value, slot);
     804                }
    797805            }
    798806        }
     
    802810            // https://bugs.webkit.org/show_bug.cgi?id=155012
    803811            ProxyObject* proxy = jsCast<ProxyObject*>(obj);
     812            scope.release();
    804813            return proxy->ProxyObject::put(proxy, exec, propertyName, value, slot);
    805814        }
     
    19481957    if (hint == PreferString) {
    19491958        value = callToPrimitiveFunction(exec, this, vm.propertyNames->toString, hint);
    1950         ASSERT(!scope.exception() || scope.exception() == value.asCell());
     1959        EXCEPTION_ASSERT(!scope.exception() || scope.exception() == value.asCell());
    19511960        if (value)
    19521961            return value;
    19531962        value = callToPrimitiveFunction(exec, this, vm.propertyNames->valueOf, hint);
    1954         ASSERT(!scope.exception() || scope.exception() == value.asCell());
     1963        EXCEPTION_ASSERT(!scope.exception() || scope.exception() == value.asCell());
    19551964        if (value)
    19561965            return value;
    19571966    } else {
    19581967        value = callToPrimitiveFunction(exec, this, vm.propertyNames->valueOf, hint);
    1959         ASSERT(!scope.exception() || scope.exception() == value.asCell());
     1968        EXCEPTION_ASSERT(!scope.exception() || scope.exception() == value.asCell());
    19601969        if (value)
    19611970            return value;
    19621971        value = callToPrimitiveFunction(exec, this, vm.propertyNames->toString, hint);
    1963         ASSERT(!scope.exception() || scope.exception() == value.asCell());
     1972        EXCEPTION_ASSERT(!scope.exception() || scope.exception() == value.asCell());
    19641973        if (value)
    19651974            return value;
     
    19861995        return value;
    19871996
     1997    scope.release();
    19881998    return this->methodTable(vm)->defaultValue(this, exec, preferredType);
    19891999}
     
    20472057        JSValue prototype = get(exec, vm.propertyNames->prototype);
    20482058        RETURN_IF_EXCEPTION(scope, false);
     2059        scope.release();
    20492060        return defaultHasInstance(exec, value, prototype);
    20502061    }
    2051     if (info.implementsHasInstance())
     2062    if (info.implementsHasInstance()) {
     2063        scope.release();
    20522064        return methodTable(vm)->customHasInstance(this, exec, value);
     2065    }
    20532066    throwException(exec, scope, createInvalidInstanceofParameterErrorNotFunction(exec, this));
    20542067    return false;
     
    20622075    RETURN_IF_EXCEPTION(scope, false);
    20632076
     2077    scope.release();
    20642078    return hasInstance(exec, value, hasInstanceValue);
    20652079}
     
    21142128    while(1) {
    21152129        if (prototype->structure(vm)->typeInfo().overridesGetPropertyNames()) {
     2130            scope.release();
    21162131            prototype->methodTable(vm)->getPropertyNames(prototype, exec, propertyNames, mode);
    2117             break;
     2132            return;
    21182133        }
    21192134        prototype->methodTable(vm)->getOwnPropertyNames(prototype, exec, propertyNames, mode);
     
    22222237    JSValue primitive = toPrimitive(exec, PreferNumber);
    22232238    RETURN_IF_EXCEPTION(scope, 0.0); // should be picked up soon in Nodes.cpp
     2239    scope.release();
    22242240    return primitive.toNumber(exec);
    22252241}
     
    23892405        if (!descriptor.attributes() && descriptor.value() && canDoFastPutDirectIndex(this)) {
    23902406            ASSERT(!descriptor.isAccessorDescriptor());
     2407            scope.release();
    23912408            return putDirectIndex(exec, index, descriptor.value(), 0, throwException ? PutDirectIndexShouldThrow : PutDirectIndexShouldNotThrow);
    23922409        }
     
    24402457    PropertyDescriptor current;
    24412458    entryInMap->get(current);
    2442     if (descriptor.isEmpty() || descriptor.equalTo(exec, current))
     2459    bool isEmptyOrEqual = descriptor.isEmpty() || descriptor.equalTo(exec, current);
     2460    RETURN_IF_EXCEPTION(scope, false);
     2461    if (isEmptyOrEqual)
    24432462        return true;
    24442463
     
    25752594        SparseArrayValueMap* map = allocateSparseIndexMap(vm);
    25762595        bool result = map->putEntry(exec, this, i, value, false);
     2596        RETURN_IF_EXCEPTION(scope, false);
    25772597        ASSERT(i >= arrayStorage()->length());
    25782598        arrayStorage()->setLength(i + 1);
     
    26482668        // We don't want to, or can't use a vector to hold this property - allocate a sparse map & add the value.
    26492669        map = allocateSparseIndexMap(vm);
     2670        scope.release();
    26502671        return map->putEntry(exec, this, i, value, shouldThrow);
    26512672    }
     
    26642685    // We will continue  to use a sparse map if SparseMode is set, a vector would be too sparse, or if allocation fails.
    26652686    unsigned numValuesInArray = storage->m_numValuesInVector + map->size();
    2666     if (map->sparseMode() || !isDenseEnoughForVector(length, numValuesInArray) || !increaseVectorLength(vm, length))
     2687    if (map->sparseMode() || !isDenseEnoughForVector(length, numValuesInArray) || !increaseVectorLength(vm, length)) {
     2688        scope.release();
    26672689        return map->putEntry(exec, this, i, value, shouldThrow);
     2690    }
    26682691
    26692692    // Reread m_storage after increaseVectorLength, update m_numValuesInVector.
     
    27842807        // We don't want to, or can't use a vector to hold this property - allocate a sparse map & add the value.
    27852808        map = allocateSparseIndexMap(vm);
     2809        scope.release();
    27862810        return map->putDirect(exec, this, i, value, attributes, mode);
    27872811    }
     
    28042828    // We will continue  to use a sparse map if SparseMode is set, a vector would be too sparse, or if allocation fails.
    28052829    unsigned numValuesInArray = storage->m_numValuesInVector + map->size();
    2806     if (map->sparseMode() || attributes || !isDenseEnoughForVector(length, numValuesInArray) || !increaseVectorLength(vm, length))
     2830    if (map->sparseMode() || attributes || !isDenseEnoughForVector(length, numValuesInArray) || !increaseVectorLength(vm, length)) {
     2831        scope.release();
    28072832        return map->putDirect(exec, this, i, value, attributes, mode);
     2833    }
    28082834
    28092835    // Reread m_storage after increaseVectorLength, update m_numValuesInVector.
     
    33523378        return true;
    33533379    // Step 4.
    3354     if (current.equalTo(exec, descriptor))
     3380    bool isEqual = current.equalTo(exec, descriptor);
     3381    RETURN_IF_EXCEPTION(scope, false);
     3382    if (isEqual)
    33553383        return true;
    33563384
     
    33693397        if (!current.attributesEqual(descriptor) && object) {
    33703398            object->methodTable(vm)->deleteProperty(object, exec, propertyName);
     3399            RETURN_IF_EXCEPTION(scope, false);
    33713400            return putDescriptor(exec, object, propertyName, descriptor, descriptor.attributesOverridingCurrent(current), current);
    33723401        }
     
    33843413
    33853414        object->methodTable(vm)->deleteProperty(object, exec, propertyName);
     3415        RETURN_IF_EXCEPTION(scope, false);
    33863416        return putDescriptor(exec, object, propertyName, descriptor, descriptor.attributesOverridingCurrent(current), current);
    33873417    }
     
    34033433            return true;
    34043434        object->methodTable(vm)->deleteProperty(object, exec, propertyName);
     3435        RETURN_IF_EXCEPTION(scope, false);
    34053436        return putDescriptor(exec, object, propertyName, descriptor, descriptor.attributesOverridingCurrent(current), current);
    34063437    }
     
    34483479        return true;
    34493480    object->methodTable(vm)->deleteProperty(object, exec, propertyName);
     3481    RETURN_IF_EXCEPTION(scope, false);
    34503482    unsigned attrs = descriptor.attributesOverridingCurrent(current);
    34513483    object->putDirectAccessor(exec, propertyName, getterSetter, attrs | Accessor);
     
    34673499    bool isExtensible = this->isExtensible(exec);
    34683500    RETURN_IF_EXCEPTION(throwScope, false);
     3501    throwScope.release();
    34693502    return validateAndApplyPropertyDescriptor(exec, this, propertyName, isExtensible, descriptor, isCurrentDefined, current, throwException);
    34703503}
     
    35953628    while (true) {
    35963629        if (prototype->structure(vm)->typeInfo().overridesGetPropertyNames()) {
     3630            scope.release();
    35973631            prototype->methodTable(vm)->getPropertyNames(prototype, exec, propertyNames, mode);
    3598             break;
     3632            return;
    35993633        }
    36003634        prototype->methodTable(vm)->getOwnPropertyNames(prototype, exec, propertyNames, mode);
  • trunk/Source/JavaScriptCore/runtime/JSObject.h

    r221822 r221849  
    14141414inline JSValue JSObject::get(ExecState* exec, PropertyName propertyName) const
    14151415{
     1416    VM& vm = exec->vm();
     1417    auto scope = DECLARE_THROW_SCOPE(vm);
    14161418    PropertySlot slot(this, PropertySlot::InternalMethodType::Get);
    1417     if (const_cast<JSObject*>(this)->getPropertySlot(exec, propertyName, slot))
     1419    bool hasProperty = const_cast<JSObject*>(this)->getPropertySlot(exec, propertyName, slot);
     1420    EXCEPTION_ASSERT(!scope.exception() || !hasProperty);
     1421    if (hasProperty) {
     1422        scope.release();
    14181423        return slot.getValue(exec, propertyName);
    1419    
     1424    }
    14201425    return jsUndefined();
    14211426}
     
    14231428inline JSValue JSObject::get(ExecState* exec, unsigned propertyName) const
    14241429{
     1430    VM& vm = exec->vm();
     1431    auto scope = DECLARE_THROW_SCOPE(vm);
    14251432    PropertySlot slot(this, PropertySlot::InternalMethodType::Get);
    1426     if (const_cast<JSObject*>(this)->getPropertySlot(exec, propertyName, slot))
     1433    bool hasProperty = const_cast<JSObject*>(this)->getPropertySlot(exec, propertyName, slot);
     1434    EXCEPTION_ASSERT(!scope.exception() || !hasProperty);
     1435    if (hasProperty) {
     1436        scope.release();
    14271437        return slot.getValue(exec, propertyName);
    1428 
     1438    }
    14291439    return jsUndefined();
    14301440}
  • trunk/Source/JavaScriptCore/runtime/JSObjectInlines.h

    r221822 r221849  
    9898    bool found = const_cast<JSObject*>(this)->getPropertySlot(exec, propertyName, slot);
    9999    RETURN_IF_EXCEPTION(scope, { });
     100    scope.release();
    100101    return callback(found, slot);
    101102}
     
    110111    while (true) {
    111112        Structure* structure = structureIDTable.get(object->structureID());
    112         if (structure->classInfo()->methodTable.getOwnPropertySlotByIndex(object, exec, propertyName, slot))
     113        bool hasSlot = structure->classInfo()->methodTable.getOwnPropertySlotByIndex(object, exec, propertyName, slot);
     114        RETURN_IF_EXCEPTION(scope, false);
     115        if (hasSlot)
    113116            return true;
    114         RETURN_IF_EXCEPTION(scope, false);
    115117        JSValue prototype;
    116118        if (LIKELY(structure->classInfo()->methodTable.getPrototype == defaultGetPrototype || slot.internalMethodType() == PropertySlot::InternalMethodType::VMInquiry))
     
    142144                return true;
    143145        } else {
    144             if (structure->classInfo()->methodTable.getOwnPropertySlot(object, exec, propertyName, slot))
     146            bool hasSlot = structure->classInfo()->methodTable.getOwnPropertySlot(object, exec, propertyName, slot);
     147            RETURN_IF_EXCEPTION(scope, false);
     148            if (hasSlot)
    145149                return true;
    146             RETURN_IF_EXCEPTION(scope, false);
    147150        }
    148151        JSValue prototype;
     
    204207    ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(thisObject));
    205208
    206     if (UNLIKELY(isThisValueAltered(slot, thisObject)))
     209    if (UNLIKELY(isThisValueAltered(slot, thisObject))) {
     210        scope.release();
    207211        return ordinarySetSlow(exec, thisObject, propertyName, value, slot.thisValue(), slot.isStrictMode());
     212    }
    208213
    209214    // Try indexed put first. This is required for correctness, since loads on property names that appear like
    210215    // valid indices will never look in the named property storage.
    211     if (std::optional<uint32_t> index = parseIndex(propertyName))
     216    if (std::optional<uint32_t> index = parseIndex(propertyName)) {
     217        scope.release();
    212218        return putByIndex(thisObject, exec, index.value(), value, slot.isStrictMode());
     219    }
    213220
    214221    if (thisObject->canPerformFastPutInline(vm, propertyName)) {
  • trunk/Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp

    r217108 r221849  
    107107    JSPromise* promise = JSPromise::create(vm, promiseStructure);
    108108    promise->initialize(exec, globalObject, exec->argument(0));
     109    RETURN_IF_EXCEPTION(scope, encodedJSValue());
    109110
    110111    return JSValue::encode(promise);
  • trunk/Source/JavaScriptCore/runtime/JSPromiseDeferred.cpp

    r217108 r221849  
    6262
    6363    JSValue promise = deferred.get(exec, vm.propertyNames->builtinNames().promisePrivateName());
     64    RETURN_IF_EXCEPTION(scope, nullptr);
    6465    ASSERT(promise.inherits(vm, JSPromise::info()));
    6566    JSValue resolve = deferred.get(exec, vm.propertyNames->builtinNames().resolvePrivateName());
     67    RETURN_IF_EXCEPTION(scope, nullptr);
    6668    JSValue reject = deferred.get(exec, vm.propertyNames->builtinNames().rejectPrivateName());
     69    RETURN_IF_EXCEPTION(scope, nullptr);
    6770
    6871    return JSPromiseDeferred::create(vm, jsCast<JSPromise*>(promise), resolve, reject);
  • trunk/Source/JavaScriptCore/runtime/JSScope.cpp

    r221822 r221849  
    11/*
    2  * Copyright (C) 2012-2016 Apple Inc. All Rights Reserved.
     2 * Copyright (C) 2012-2017 Apple Inc. All Rights Reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5151static inline bool abstractAccess(ExecState* exec, JSScope* scope, const Identifier& ident, GetOrPut getOrPut, size_t depth, bool& needsVarInjectionChecks, ResolveOp& op, InitializationMode initializationMode)
    5252{
     53    VM& vm = exec->vm();
     54    auto throwScope = DECLARE_THROW_SCOPE(vm);
     55
    5356    if (scope->isJSLexicalEnvironment()) {
    5457        JSLexicalEnvironment* lexicalEnvironment = jsCast<JSLexicalEnvironment*>(scope);
     
    7679            AbstractModuleRecord* moduleRecord = moduleEnvironment->moduleRecord();
    7780            AbstractModuleRecord::Resolution resolution = moduleRecord->resolveImport(exec, ident);
     81            RETURN_IF_EXCEPTION(throwScope, false);
    7882            if (resolution.type == AbstractModuleRecord::Resolution::Type::Resolved) {
    7983                AbstractModuleRecord* importedRecord = resolution.moduleRecord;
     
    247251        if (hasProperty) {
    248252            bool unscopable = isUnscopable(exec, scope, object, ident);
    249             ASSERT(!throwScope.exception() || !unscopable);
     253            EXCEPTION_ASSERT(!throwScope.exception() || !unscopable);
    250254            if (!unscopable)
    251255                return object;
     
    260264{
    261265    VM& vm = exec->vm();
     266    auto throwScope = DECLARE_THROW_SCOPE(vm);
     267
    262268    auto returnPredicate = [&] (JSScope* scope) -> bool {
    263269        return scope->isVarScope();
     
    267273    };
    268274    JSObject* object = resolve(exec, scope, ident, returnPredicate, skipPredicate);
    269    
     275    RETURN_IF_EXCEPTION(throwScope, { });
     276
    270277    bool result = false;
    271278    if (JSScope* scope = jsDynamicCast<JSScope*>(vm, object)) {
     
    293300ResolveOp JSScope::abstractResolve(ExecState* exec, size_t depthOffset, JSScope* scope, const Identifier& ident, GetOrPut getOrPut, ResolveType unlinkedType, InitializationMode initializationMode)
    294301{
     302    VM& vm = exec->vm();
     303    auto throwScope = DECLARE_THROW_SCOPE(vm);
     304
    295305    ResolveOp op(Dynamic, 0, 0, 0, 0, 0);
    296306    if (unlinkedType == Dynamic)
     
    300310    size_t depth = depthOffset;
    301311    for (; scope; scope = scope->next()) {
    302         if (abstractAccess(exec, scope, ident, getOrPut, depth, needsVarInjectionChecks, op, initializationMode))
     312        bool success = abstractAccess(exec, scope, ident, getOrPut, depth, needsVarInjectionChecks, op, initializationMode);
     313        RETURN_IF_EXCEPTION(throwScope, ResolveOp(Dynamic, 0, 0, 0, 0, 0));
     314        if (success)
    303315            break;
    304316        ++depth;
  • trunk/Source/JavaScriptCore/runtime/LiteralParser.cpp

    r221400 r221849  
    5252bool LiteralParser<CharType>::tryJSONPParse(Vector<JSONPData>& results, bool needsFullSourceInfo)
    5353{
     54    VM& vm = m_exec->vm();
     55    auto scope = DECLARE_THROW_SCOPE(vm);
    5456    if (m_lexer.next() != TokIdentifier)
    5557        return false;
     
    5759        Vector<JSONPPathEntry> path;
    5860        // Unguarded next to start off the lexer
    59         Identifier name = Identifier::fromString(&m_exec->vm(), m_lexer.currentToken()->start, m_lexer.currentToken()->end - m_lexer.currentToken()->start);
     61        Identifier name = Identifier::fromString(&vm, m_lexer.currentToken()->start, m_lexer.currentToken()->end - m_lexer.currentToken()->start);
    6062        JSONPPathEntry entry;
    61         if (name == m_exec->vm().propertyNames->varKeyword) {
     63        if (name == vm.propertyNames->varKeyword) {
    6264            if (m_lexer.next() != TokIdentifier)
    6365                return false;
    6466            entry.m_type = JSONPPathEntryTypeDeclare;
    65             entry.m_pathEntryName = Identifier::fromString(&m_exec->vm(), m_lexer.currentToken()->start, m_lexer.currentToken()->end - m_lexer.currentToken()->start);
     67            entry.m_pathEntryName = Identifier::fromString(&vm, m_lexer.currentToken()->start, m_lexer.currentToken()->end - m_lexer.currentToken()->start);
    6668            path.append(entry);
    6769        } else {
    6870            entry.m_type = JSONPPathEntryTypeDot;
    69             entry.m_pathEntryName = Identifier::fromString(&m_exec->vm(), m_lexer.currentToken()->start, m_lexer.currentToken()->end - m_lexer.currentToken()->start);
     71            entry.m_pathEntryName = Identifier::fromString(&vm, m_lexer.currentToken()->start, m_lexer.currentToken()->end - m_lexer.currentToken()->start);
    7072            path.append(entry);
    7173        }
     
    9496                if (m_lexer.next() != TokIdentifier)
    9597                    return false;
    96                 entry.m_pathEntryName = Identifier::fromString(&m_exec->vm(), m_lexer.currentToken()->start, m_lexer.currentToken()->end - m_lexer.currentToken()->start);
     98                entry.m_pathEntryName = Identifier::fromString(&vm, m_lexer.currentToken()->start, m_lexer.currentToken()->end - m_lexer.currentToken()->start);
    9799                break;
    98100            }
     
    113115        m_lexer.next();
    114116        results.append(JSONPData());
    115         results.last().m_value.set(m_exec->vm(), parse(StartParseExpression));
     117        JSValue startParseExpressionValue = parse(StartParseExpression);
     118        RETURN_IF_EXCEPTION(scope, false);
     119        results.last().m_value.set(vm, startParseExpressionValue);
    116120        if (!results.last().m_value)
    117121            return false;
     
    613617                JSArray* array = asArray(objectStack.last());
    614618                array->putDirectIndex(m_exec, array->length(), lastValue);
    615                
     619                RETURN_IF_EXCEPTION(scope, JSValue());
     620
    616621                if (m_lexer.currentToken()->type == TokComma)
    617622                    goto doParseArrayStartExpression;
     
    700705                        object->putDirect(vm, ident, lastValue);
    701706                }
     707                RETURN_IF_EXCEPTION(scope, JSValue());
    702708                identifierStack.removeLast();
    703709                if (m_lexer.currentToken()->type == TokComma)
  • trunk/Source/JavaScriptCore/runtime/Lookup.h

    r219981 r221849  
    291291        JSValue updateThisValue = entry->attributes() & CustomAccessor ? slot.thisValue() : JSValue(base);
    292292        bool result = callCustomSetter(exec, entry->propertyPutter(), isAccessor, updateThisValue, value);
     293        RETURN_IF_EXCEPTION(scope, false);
    293294        if (isAccessor)
    294295            slot.setCustomAccessor(base, entry->propertyPutter());
  • trunk/Source/JavaScriptCore/runtime/MapConstructor.cpp

    r221822 r221849  
    6565
    6666    JSValue iterable = exec->argument(0);
    67     if (iterable.isUndefinedOrNull())
     67    if (iterable.isUndefinedOrNull()) {
     68        scope.release();
    6869        return JSValue::encode(JSMap::create(exec, vm, mapStructure));
     70    }
    6971
    7072    if (isJSMap(iterable)) {
    7173        JSMap* iterableMap = jsCast<JSMap*>(iterable);
    72         if (iterableMap->canCloneFastAndNonObservable(mapStructure))
     74        if (iterableMap->canCloneFastAndNonObservable(mapStructure)) {
     75            scope.release();
    7376            return JSValue::encode(iterableMap->clone(exec, vm, mapStructure));
     77        }
    7478    }
    7579
  • trunk/Source/JavaScriptCore/runtime/NumberPrototype.cpp

    r221601 r221849  
    599599
    600600    int32_t radix = extractRadixFromArgs(exec);
     601    RETURN_IF_EXCEPTION(scope, encodedJSValue());
    601602    if (radix < 2 || radix > 36)
    602603        return throwVMError(exec, scope, createRangeError(exec, ASCIILiteral("toString() radix argument must be between 2 and 36")));
    603604
     605    scope.release();
    604606    return JSValue::encode(numberToStringInternal(vm, doubleValue, radix));
    605607}
  • trunk/Source/JavaScriptCore/runtime/ObjectConstructor.cpp

    r220053 r221849  
    189189    bool shouldThrowIfCantSet = true;
    190190    bool didSetPrototype = object->setPrototype(vm, exec, protoValue, shouldThrowIfCantSet);
    191     ASSERT_UNUSED(didSetPrototype, scope.exception() || didSetPrototype);
     191    EXCEPTION_ASSERT_UNUSED(didSetPrototype, scope.exception() || didSetPrototype);
    192192    return JSValue::encode(objectValue);
    193193}
     
    205205
    206206    JSObject* result = constructObjectFromPropertyDescriptor(exec, descriptor);
    207     ASSERT(!!scope.exception() == !result);
     207    EXCEPTION_ASSERT(!!scope.exception() == !result);
    208208    if (!result)
    209209        return jsUndefined();
     
    231231
    232232        JSObject* fromDescriptor = constructObjectFromPropertyDescriptor(exec, descriptor);
    233         ASSERT(!!scope.exception() == !fromDescriptor);
     233        EXCEPTION_ASSERT(!!scope.exception() == !fromDescriptor);
    234234        if (!fromDescriptor)
    235235            return jsUndefined();
     
    323323        auto assign = [&] (PropertyName propertyName) {
    324324            PropertySlot slot(source, PropertySlot::InternalMethodType::GetOwnProperty);
    325             if (!source->methodTable(vm)->getOwnPropertySlot(source, exec, propertyName, slot))
     325            bool hasProperty = source->methodTable(vm)->getOwnPropertySlot(source, exec, propertyName, slot);
     326            RETURN_IF_EXCEPTION(scope, void());
     327            if (!hasProperty)
    326328                return;
    327329            if (slot.attributes() & DontEnum)
     
    387389    auto addValue = [&] (PropertyName propertyName) {
    388390        PropertySlot slot(target, PropertySlot::InternalMethodType::GetOwnProperty);
    389         if (!target->methodTable(vm)->getOwnPropertySlot(target, exec, propertyName, slot))
     391        bool hasProperty = target->methodTable(vm)->getOwnPropertySlot(target, exec, propertyName, slot);
     392        RETURN_IF_EXCEPTION(scope, void());
     393        if (!hasProperty)
    390394            return;
    391395        if (slot.attributes() & DontEnum)
     
    429433
    430434    bool hasProperty = description->hasProperty(exec, vm.propertyNames->enumerable);
    431     ASSERT(!scope.exception() || !hasProperty);
     435    EXCEPTION_ASSERT(!scope.exception() || !hasProperty);
    432436    if (hasProperty) {
    433437        JSValue value = description->get(exec, vm.propertyNames->enumerable);
     
    438442
    439443    hasProperty = description->hasProperty(exec, vm.propertyNames->configurable);
    440     ASSERT(!scope.exception() || !hasProperty);
     444    EXCEPTION_ASSERT(!scope.exception() || !hasProperty);
    441445    if (hasProperty) {
    442446        JSValue value = description->get(exec, vm.propertyNames->configurable);
     
    448452    JSValue value;
    449453    hasProperty = description->hasProperty(exec, vm.propertyNames->value);
    450     ASSERT(!scope.exception() || !hasProperty);
     454    EXCEPTION_ASSERT(!scope.exception() || !hasProperty);
    451455    if (hasProperty) {
    452456        JSValue value = description->get(exec, vm.propertyNames->value);
     
    457461
    458462    hasProperty = description->hasProperty(exec, vm.propertyNames->writable);
    459     ASSERT(!scope.exception() || !hasProperty);
     463    EXCEPTION_ASSERT(!scope.exception() || !hasProperty);
    460464    if (hasProperty) {
    461465        JSValue value = description->get(exec, vm.propertyNames->writable);
     
    466470
    467471    hasProperty = description->hasProperty(exec, vm.propertyNames->get);
    468     ASSERT(!scope.exception() || !hasProperty);
     472    EXCEPTION_ASSERT(!scope.exception() || !hasProperty);
    469473    if (hasProperty) {
    470474        JSValue get = description->get(exec, vm.propertyNames->get);
     
    482486
    483487    hasProperty = description->hasProperty(exec, vm.propertyNames->set);
    484     ASSERT(!scope.exception() || !hasProperty);
     488    EXCEPTION_ASSERT(!scope.exception() || !hasProperty);
    485489    if (hasProperty) {
    486490        JSValue set = description->get(exec, vm.propertyNames->set);
     
    524528    PropertyDescriptor descriptor;
    525529    auto success = toPropertyDescriptor(exec, exec->argument(2), descriptor);
    526     ASSERT(!scope.exception() == success);
     530    EXCEPTION_ASSERT(!scope.exception() == success);
    527531    if (!success)
    528532        return JSValue::encode(jsNull());
     
    550554        PropertyDescriptor descriptor;
    551555        bool success = toPropertyDescriptor(exec, prop, descriptor);
    552         ASSERT(!scope.exception() || !success);
     556        EXCEPTION_ASSERT(!scope.exception() || !success);
    553557        if (UNLIKELY(!success))
    554558            return jsNull();
     
    583587    JSObject* targetObj = asObject(exec->argument(0));
    584588    JSObject* props = exec->argument(1).toObject(exec);
    585     ASSERT(!!scope.exception() == !props);
     589    EXCEPTION_ASSERT(!!scope.exception() == !props);
    586590    if (UNLIKELY(!props))
    587591        return encodedJSValue();
     
    857861            const auto& identifier = properties[i];
    858862            ASSERT(!identifier.isSymbol());
    859             if (filterPropertyIfNeeded(identifier))
     863            bool hasProperty = filterPropertyIfNeeded(identifier);
     864            EXCEPTION_ASSERT(!scope.exception() || !hasProperty);
     865            if (hasProperty)
    860866                keys->push(exec, jsOwnedString(exec, identifier.string()));
    861867            RETURN_IF_EXCEPTION(scope, nullptr);
     
    870876            ASSERT(identifier.isSymbol());
    871877            if (!identifier.isPrivateName()) {
    872                 if (filterPropertyIfNeeded(identifier))
     878                bool hasProperty = filterPropertyIfNeeded(identifier);
     879                EXCEPTION_ASSERT(!scope.exception() || !hasProperty);
     880                if (hasProperty)
    873881                    keys->push(exec, Symbol::create(vm, static_cast<SymbolImpl&>(*identifier.impl())));
    874882                RETURN_IF_EXCEPTION(scope, nullptr);
     
    886894                propertySymbols.append(identifier);
    887895            else {
    888                 if (filterPropertyIfNeeded(identifier))
     896                bool hasProperty = filterPropertyIfNeeded(identifier);
     897                EXCEPTION_ASSERT(!scope.exception() || !hasProperty);
     898                if (hasProperty)
    889899                    keys->push(exec, jsOwnedString(exec, identifier.string()));
    890900                RETURN_IF_EXCEPTION(scope, nullptr);
     
    894904        // To ensure the order defined in the spec (9.1.12), we append symbols at the last elements of keys.
    895905        for (const auto& identifier : propertySymbols) {
    896             if (filterPropertyIfNeeded(identifier))
     906            bool hasProperty = filterPropertyIfNeeded(identifier);
     907            EXCEPTION_ASSERT(!scope.exception() || !hasProperty);
     908            if (hasProperty)
    897909                keys->push(exec, Symbol::create(vm, static_cast<SymbolImpl&>(*identifier.impl())));
    898910            RETURN_IF_EXCEPTION(scope, nullptr);
  • trunk/Source/JavaScriptCore/runtime/ObjectPrototype.cpp

    r221822 r221849  
    9898    RETURN_IF_EXCEPTION(scope, encodedJSValue());
    9999    JSObject* thisObject = thisValue.toObject(exec);
    100     ASSERT(!!scope.exception() == !thisObject);
     100    EXCEPTION_ASSERT(!!scope.exception() == !thisObject);
    101101    if (UNLIKELY(!thisObject))
    102102        return encodedJSValue();
     
    125125    JSValue thisValue = exec->thisValue().toThis(exec, StrictMode);
    126126    JSObject* thisObj = thisValue.toObject(exec);
    127     ASSERT(!!scope.exception() == !thisObj);
     127    EXCEPTION_ASSERT(!!scope.exception() == !thisObj);
    128128    if (UNLIKELY(!thisObj))
    129129        return encodedJSValue();
     
    214214    PropertySlot slot(thisObject, PropertySlot::InternalMethodType::GetOwnProperty);
    215215    bool hasProperty = thisObject->getPropertySlot(exec, propertyName, slot);
    216     ASSERT(!scope.exception() || !hasProperty);
     216    EXCEPTION_ASSERT(!scope.exception() || !hasProperty);
    217217    if (hasProperty) {
    218218        if (slot.isAccessor()) {
     
    244244    PropertySlot slot(thisObject, PropertySlot::InternalMethodType::GetOwnProperty);
    245245    bool hasProperty = thisObject->getPropertySlot(exec, propertyName, slot);
    246     ASSERT(!scope.exception() || !hasProperty);
     246    EXCEPTION_ASSERT(!scope.exception() || !hasProperty);
    247247    if (hasProperty) {
    248248        if (slot.isAccessor()) {
     
    296296    PropertySlot slot(thisValue, PropertySlot::InternalMethodType::Get);
    297297    bool hasProperty = object->getPropertySlot(exec, vm.propertyNames->toString, slot);
     298    EXCEPTION_ASSERT(!scope.exception() || !hasProperty);
    298299    JSValue toString = hasProperty ? slot.getValue(exec, vm.propertyNames->toString) : jsUndefined();
    299300    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     
    319320        return JSValue::encode(thisValue.isUndefined() ? vm.smallStrings.undefinedObjectString() : vm.smallStrings.nullObjectString());
    320321    JSObject* thisObject = thisValue.toObject(exec);
    321     ASSERT(!!scope.exception() == !thisObject);
     322    EXCEPTION_ASSERT(!!scope.exception() == !thisObject);
    322323    if (!thisObject)
    323324        return JSValue::encode(jsUndefined());
  • trunk/Source/JavaScriptCore/runtime/Options.h

    r221597 r221849  
    395395    v(unsigned, fireExceptionFuzzAt, 0, Normal, nullptr) \
    396396    v(bool, validateDFGExceptionHandling, false, Normal, "Causes the DFG to emit code validating exception handling for each node that can exit") /* This is true by default on Debug builds */\
    397     v(bool, dumpSimulatedThrows, false, Normal, "Dumps the call stack at each simulated throw for exception scope verification") \
     397    v(bool, dumpSimulatedThrows, false, Normal, "Dumps the call stack of the last simulated throw if exception scope verification fails") \
    398398    v(bool, validateExceptionChecks, false, Normal, "Verifies that needed exception checks are performed.") \
    399399    v(unsigned, unexpectedExceptionStackTraceLimit, 100, Normal, "Stack trace limit for debugging unexpected exceptions observed in the VM") \
  • trunk/Source/JavaScriptCore/runtime/ParseInt.h

    r216699 r221849  
    218218    auto scope = DECLARE_THROW_SCOPE(vm);
    219219    JSString* string = value.toStringOrNull(exec);
     220    EXCEPTION_ASSERT(!!scope.exception() == !string);
    220221    if (UNLIKELY(!string))
    221222        return { };
    222223    auto viewWithString = string->viewWithUnderlyingString(exec);
    223224    RETURN_IF_EXCEPTION(scope, { });
     225    scope.release();
    224226    return callback(viewWithString.view);
    225227}
  • trunk/Source/JavaScriptCore/runtime/ProxyObject.cpp

    r220053 r221849  
    131131        scope.release();
    132132        PropertySlot slot(receiver, PropertySlot::InternalMethodType::Get);
    133         if (target->getPropertySlot(exec, propertyName, slot))
     133        bool hasProperty = target->getPropertySlot(exec, propertyName, slot);
     134        EXCEPTION_ASSERT(!scope.exception() || !hasProperty);
     135        if (hasProperty) {
     136            scope.release();
    134137            return slot.getValue(exec, propertyName);
     138        }
    135139        return jsUndefined();
    136140    };
     
    443447
    444448    PropertyDescriptor descriptor;
    445     if (target->getOwnPropertyDescriptor(exec, propertyName, descriptor)) {
     449    bool hasProperty = target->getOwnPropertyDescriptor(exec, propertyName, descriptor);
     450    EXCEPTION_ASSERT(!scope.exception() || !hasProperty);
     451    if (hasProperty) {
    446452        if (descriptor.isDataDescriptor() && !descriptor.configurable() && !descriptor.writable()) {
    447453            if (!sameValue(exec, descriptor.value(), putValue)) {
  • trunk/Source/JavaScriptCore/runtime/ReflectObject.cpp

    r218784 r221849  
    141141    PropertyDescriptor descriptor;
    142142    bool success = toPropertyDescriptor(exec, exec->argument(2), descriptor);
    143     ASSERT(!scope.exception() == success);
     143    EXCEPTION_ASSERT(!scope.exception() == success);
    144144    if (UNLIKELY(!success))
    145145        return encodedJSValue();
  • trunk/Source/JavaScriptCore/runtime/RegExpConstructor.cpp

    r217108 r221849  
    214214        return NoFlags;
    215215    JSString* flagsString = flags.toStringOrNull(exec);
    216     ASSERT(!!scope.exception() == !flagsString);
     216    EXCEPTION_ASSERT(!!scope.exception() == !flagsString);
    217217    if (UNLIKELY(!flagsString))
    218218        return InvalidFlags;
     
    234234
    235235    RegExpFlags flags = toFlags(exec, flagsArg);
    236     ASSERT(!!scope.exception() == (flags == InvalidFlags));
     236    EXCEPTION_ASSERT(!!scope.exception() == (flags == InvalidFlags));
    237237    if (UNLIKELY(flags == InvalidFlags))
    238238        return nullptr;
     
    274274        if (!flagsArg.isUndefined()) {
    275275            RegExpFlags flags = toFlags(exec, flagsArg);
    276             ASSERT(!!scope.exception() == (flags == InvalidFlags));
     276            EXCEPTION_ASSERT(!!scope.exception() == (flags == InvalidFlags));
    277277            if (flags == InvalidFlags)
    278278                return nullptr;
  • trunk/Source/JavaScriptCore/runtime/RegExpObject.cpp

    r221822 r221849  
    233233            do {
    234234                iterate();
    235                 ASSERT(!!scope.exception() == hasException);
     235                EXCEPTION_ASSERT(!!scope.exception() == hasException);
    236236                if (UNLIKELY(hasException))
    237237                    return { };
  • trunk/Source/JavaScriptCore/runtime/RegExpObjectInlines.h

    r209101 r221849  
    7676    if (globalOrSticky) {
    7777        lastIndex = getRegExpObjectLastIndexAsUnsigned(exec, this, input);
    78         ASSERT(!scope.exception() || lastIndex == UINT_MAX);
     78        EXCEPTION_ASSERT(!scope.exception() || lastIndex == UINT_MAX);
    7979        if (lastIndex == UINT_MAX)
    8080            return jsNull();
     
    115115
    116116    unsigned lastIndex = getRegExpObjectLastIndexAsUnsigned(exec, this, input);
    117     ASSERT(!scope.exception() || (lastIndex == UINT_MAX));
     117    EXCEPTION_ASSERT(!scope.exception() || (lastIndex == UINT_MAX));
    118118    if (lastIndex == UINT_MAX)
    119119        return MatchResult::failed();
  • trunk/Source/JavaScriptCore/runtime/RegExpPrototype.cpp

    r221417 r221849  
    108108        return throwVMTypeError(exec, scope);
    109109    JSString* string = exec->argument(0).toStringOrNull(exec);
    110     ASSERT(!!scope.exception() == !string);
     110    EXCEPTION_ASSERT(!!scope.exception() == !string);
    111111    if (!string)
    112112        return JSValue::encode(jsUndefined());
     
    124124        return throwVMTypeError(exec, scope, "Builtin RegExp exec can only be called on a RegExp object");
    125125    JSString* string = exec->argument(0).toStringOrNull(exec);
    126     ASSERT(!!scope.exception() == !string);
     126    EXCEPTION_ASSERT(!!scope.exception() == !string);
    127127    if (!string)
    128128        return JSValue::encode(jsUndefined());
     
    140140        return throwVMTypeError(exec, scope);
    141141    JSString* string = exec->argument(0).toStringOrNull(exec);
    142     ASSERT(!!scope.exception() == !string);
     142    EXCEPTION_ASSERT(!!scope.exception() == !string);
    143143    if (!string)
    144144        return encodedJSValue();
     
    244244
    245245    StringRecursionChecker checker(exec, thisObject);
    246     ASSERT(!scope.exception() || checker.earlyReturnValue());
     246    EXCEPTION_ASSERT(!scope.exception() || checker.earlyReturnValue());
    247247    if (JSValue earlyReturnValue = checker.earlyReturnValue())
    248248        return JSValue::encode(earlyReturnValue);
     
    628628    JSValue limitValue = exec->argument(1);
    629629    unsigned limit = limitValue.isUndefined() ? 0xFFFFFFFFu : limitValue.toUInt32(exec);
     630    RETURN_IF_EXCEPTION(scope, encodedJSValue());
    630631
    631632    // 14. Let size be the number of elements in S.
  • trunk/Source/JavaScriptCore/runtime/ScriptExecutable.cpp

    r220556 r221849  
    189189            executable, executable->m_unlinkedEvalCodeBlock.get(), scope,
    190190            executable->source().provider());
    191         ASSERT(throwScope.exception() || codeBlock);
     191        EXCEPTION_ASSERT(throwScope.exception() || codeBlock);
    192192        if (!codeBlock) {
    193193            exception = throwException(
     
    207207            executable, executable->m_unlinkedProgramCodeBlock.get(), scope,
    208208            executable->source().provider(), startColumn());
    209         ASSERT(throwScope.exception() || codeBlock);
     209        EXCEPTION_ASSERT(throwScope.exception() || codeBlock);
    210210        if (!codeBlock) {
    211211            exception = throwException(
     
    225225            executable, executable->m_unlinkedModuleProgramCodeBlock.get(), scope,
    226226            executable->source().provider(), startColumn());
    227         ASSERT(throwScope.exception() || codeBlock);
     227        EXCEPTION_ASSERT(throwScope.exception() || codeBlock);
    228228        if (!codeBlock) {
    229229            exception = throwException(
     
    339339    CodeBlock* codeBlock = newCodeBlockFor(kind, function, scope, exception);
    340340    resultCodeBlock = codeBlock;
    341     ASSERT(!!throwScope.exception() == !codeBlock);
     341    EXCEPTION_ASSERT(!!throwScope.exception() == !codeBlock);
    342342    if (UNLIKELY(!codeBlock))
    343343        return exception;
  • trunk/Source/JavaScriptCore/runtime/SetConstructor.cpp

    r221110 r221849  
    6565
    6666    JSValue iterable = exec->argument(0);
    67     if (iterable.isUndefinedOrNull())
     67    if (iterable.isUndefinedOrNull()) {
     68        scope.release();
    6869        return JSValue::encode(JSSet::create(exec, vm, setStructure));
     70    }
    6971
    7072    if (isJSSet(iterable)) {
    7173        JSSet* iterableSet = jsCast<JSSet*>(iterable);
    72         if (iterableSet->canCloneFastAndNonObservable(setStructure))
     74        if (iterableSet->canCloneFastAndNonObservable(setStructure)) {
     75            scope.release();
    7376            return JSValue::encode(iterableSet->clone(exec, vm, setStructure));
     77        }
    7478    }
    7579
  • trunk/Source/JavaScriptCore/runtime/ThrowScope.cpp

    r211247 r221849  
    101101    m_vm.m_simulatedThrowPointRecursionDepth = m_recursionDepth;
    102102    m_vm.m_needExceptionCheck = true;
    103 
    104     if (Options::dumpSimulatedThrows()) {
    105         dataLog("Simulated throw from this scope: ", m_location, "\n");
    106         dataLog("    (ExceptionScope::m_recursionDepth was ", m_recursionDepth, ")\n");
    107         WTFReportBacktrace();
    108     }
     103    if (UNLIKELY(Options::dumpSimulatedThrows()))
     104        m_vm.m_nativeStackTraceOfLastSimulatedThrow = StackTrace::captureStackTrace(Options::unexpectedExceptionStackTraceLimit());
    109105}
    110106
  • trunk/Source/JavaScriptCore/runtime/VM.cpp

    r221223 r221849  
    971971            "\n");
    972972
     973        StringPrintStream out;
     974        std::unique_ptr<StackTrace> currentTrace = StackTrace::captureStackTrace(Options::unexpectedExceptionStackTraceLimit());
     975
     976        if (Options::dumpSimulatedThrows()) {
     977            out.println("The simulated exception was thrown at:");
     978            m_nativeStackTraceOfLastSimulatedThrow->dump(out, "    ");
     979            out.println();
     980        }
     981        out.println("Unchecked exception detected at:");
     982        currentTrace->dump(out, "    ");
     983        out.println();
     984
     985        dataLog(out.toCString());
    973986        RELEASE_ASSERT(!m_needExceptionCheck);
    974987    }
  • trunk/Source/JavaScriptCore/runtime/VM.h

    r221832 r221849  
    786786    mutable bool m_needExceptionCheck { false };
    787787    std::unique_ptr<StackTrace> m_nativeStackTraceOfLastThrow;
     788    std::unique_ptr<StackTrace> m_nativeStackTraceOfLastSimulatedThrow;
    788789    ThreadIdentifier m_throwingThread;
    789790#endif
  • trunk/Source/JavaScriptCore/runtime/WeakMapPrototype.cpp

    r221223 r221849  
    106106
    107107    auto* map = getWeakMap(callFrame, callFrame->thisValue());
    108     ASSERT(!!scope.exception() == !map);
     108    EXCEPTION_ASSERT(!!scope.exception() == !map);
    109109    if (!map)
    110110        return JSValue::encode(jsUndefined());
  • trunk/Source/JavaScriptCore/runtime/WeakSetPrototype.cpp

    r221223 r221849  
    9393
    9494    auto* set = getWeakSet(callFrame, callFrame->thisValue());
    95     ASSERT(!!scope.exception() == !set);
     95    EXCEPTION_ASSERT(!!scope.exception() == !set);
    9696    if (!set)
    9797        return JSValue::encode(jsUndefined());
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.cpp

    r217645 r221849  
    184184    RETURN_IF_EXCEPTION(scope, { });
    185185
     186    scope.release();
    186187    return JSWebAssemblyModule::createStub(vm, exec, structure, Wasm::Module::validateSync(vm, WTFMove(source)));
    187188}
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp

    r221822 r221849  
    179179        bool putResult = false;
    180180        symbolTablePutTouchWatchpointSet(moduleEnvironment, exec, Identifier::fromString(&vm, String::fromUTF8(exp.field)), exportedValue, shouldThrowReadOnlyError, ignoreReadOnlyErrors, putResult);
     181        scope.assertNoException();
    181182        RELEASE_ASSERT(putResult);
    182183    }
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyPrototype.cpp

    r218794 r221849  
    7474    catchScope.clearException();
    7575    promise->reject(exec, exception->value());
     76    CLEAR_AND_RETURN_IF_EXCEPTION(catchScope, void());
    7677}
    7778
     
    8384
    8485    JSPromiseDeferred* promise = JSPromiseDeferred::create(exec, globalObject);
    85     RETURN_IF_EXCEPTION(scope, { });
     86    CLEAR_AND_RETURN_IF_EXCEPTION(scope, encodedJSValue());
    8687
    8788    Vector<Strong<JSCell>> dependencies;
     
    99100                ExecState* exec = globalObject->globalExec();
    100101                JSValue module = JSWebAssemblyModule::createStub(vm, exec, globalObject->WebAssemblyModuleStructure(), WTFMove(result));
    101                 if (scope.exception()) {
     102                if (UNLIKELY(scope.exception())) {
    102103                    reject(exec, scope, promise);
    103104                    return;
     
    105106
    106107                promise->resolve(exec, module);
     108                CLEAR_AND_RETURN_IF_EXCEPTION(scope, void());
    107109            });
    108110        }));
     
    127129        promise->resolve(exec, result);
    128130    }
     131    CLEAR_AND_RETURN_IF_EXCEPTION(scope, void());
    129132}
    130133
     
    182185
    183186    JSPromiseDeferred* promise = JSPromiseDeferred::create(exec, exec->lexicalGlobalObject());
    184     RETURN_IF_EXCEPTION(scope, { });
     187    CLEAR_AND_RETURN_IF_EXCEPTION(scope, encodedJSValue());
    185188
    186189    JSValue importArgument = exec->argument(1);
     
    189192        promise->reject(exec, createTypeError(exec,
    190193            ASCIILiteral("second argument to WebAssembly.instantiate must be undefined or an Object"), defaultSourceAppender, runtimeTypeForValue(importArgument)));
     194        CLEAR_AND_RETURN_IF_EXCEPTION(scope, encodedJSValue());
    191195        return JSValue::encode(promise->promise());
    192196    }
  • trunk/Source/WebCore/ChangeLog

    r221845 r221849  
     12017-09-10  Mark Lam  <mark.lam@apple.com>
     2
     3        Fix all ExceptionScope verification failures in JavaScriptCore.
     4        https://bugs.webkit.org/show_bug.cgi?id=176662
     5        <rdar://problem/34352085>
     6
     7        Reviewed by Filip Pizlo.
     8
     9        No new tests because this is covered by existing tests with the JSC_validateExceptionChecks=true enabled.
     10
     11        * bindings/js/JSCustomElementInterface.cpp:
     12        (WebCore::JSCustomElementInterface::tryToConstructCustomElement):
     13        * bindings/js/JSCustomElementRegistryCustom.cpp:
     14        (WebCore::whenDefinedPromise):
     15        * bindings/js/JSDOMConvertRecord.h:
     16        * bindings/js/JSDOMMapLike.cpp:
     17        (WebCore::createBackingMap):
     18        * bindings/js/JSDOMPromiseDeferred.cpp:
     19        (WebCore::DeferredPromise::callFunction):
     20        (WebCore::DeferredPromise::reject):
     21        * bindings/js/JSDOMPromiseDeferred.h:
     22        (WebCore::callPromiseFunction):
     23
    1242017-09-10  Frederic Wang  <fwang@igalia.coml>
    225
  • trunk/Source/WebCore/bindings/js/JSCustomElementInterface.cpp

    r221822 r221849  
    105105    auto& state = *document.execState();
    106106    auto element = constructCustomElementSynchronously(document, vm, state, m_constructor.get(), localName);
    107     ASSERT(!!scope.exception() == !element);
     107    EXCEPTION_ASSERT(!!scope.exception() == !element);
    108108    if (!element) {
    109109        auto* exception = scope.exception();
  • trunk/Source/WebCore/bindings/js/JSCustomElementRegistryCustom.cpp

    r219237 r221849  
    187187
    188188    if (!validateCustomElementNameAndThrowIfNeeded(state, localName)) {
    189         ASSERT(scope.exception());
     189        EXCEPTION_ASSERT(scope.exception());
    190190        return jsUndefined();
    191191    }
  • trunk/Source/WebCore/bindings/js/JSDOMConvertRecord.h

    r221822 r221849  
    11/*
    2  * Copyright (C) 2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    106106                // 1. Let typedKey be key converted to an IDL value of type K.
    107107                auto typedKey = Detail::IdentifierConverter<K>::convert(state, key);
     108                RETURN_IF_EXCEPTION(scope, { });
    108109
    109110                // 2. Let value be ? Get(O, key).
  • trunk/Source/WebCore/bindings/js/JSDOMMapLike.cpp

    r213108 r221849  
    2828
    2929#include "WebCoreJSClientData.h"
     30#include <runtime/CatchScope.h>
    3031
    3132namespace WebCore {
     
    4647{
    4748    auto& vm = state.vm();
     49    auto scope = DECLARE_CATCH_SCOPE(vm);
    4850
    4951    ASSERT(mapLike.get(&state, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().backingMapPrivateName()).isUndefined());
    5052    auto backingMap = JSC::JSMap::create(&state, vm, globalObject.mapStructure());
     53    scope.releaseAssertNoException();
    5154    mapLike.putDirect(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().backingMapPrivateName(), backingMap, JSC::DontEnum);
    5255    return *backingMap;
  • trunk/Source/WebCore/bindings/js/JSDOMPromiseDeferred.cpp

    r220811 r221849  
    6464    // DeferredPromise should only be used by internal implementations that are well behaved.
    6565    // In practice, the only exception we should ever see here is the TerminatedExecutionException.
    66     ASSERT_UNUSED(scope, !scope.exception() || isTerminatedExecutionException(vm, scope.exception()));
     66    EXCEPTION_ASSERT_UNUSED(scope, !scope.exception() || isTerminatedExecutionException(vm, scope.exception()));
    6767
    6868    if (m_mode == Mode::ClearPromiseOnResolve)
     
    107107        auto scope = DECLARE_CATCH_SCOPE(state.vm());
    108108
    109         ASSERT(scope.exception());
     109        EXCEPTION_ASSERT(scope.exception());
    110110
    111111        auto error = scope.exception()->value();
     
    139139        auto scope = DECLARE_CATCH_SCOPE(state.vm());
    140140
    141         ASSERT(scope.exception());
     141        EXCEPTION_ASSERT(scope.exception());
    142142
    143143        auto error = scope.exception()->value();
  • trunk/Source/WebCore/bindings/js/JSDOMPromiseDeferred.h

    r220863 r221849  
    275275
    276276    rejectPromiseWithExceptionIfAny(state, globalObject, *promiseDeferred);
    277     ASSERT_UNUSED(scope, !scope.exception());
     277    EXCEPTION_ASSERT_UNUSED(scope, !scope.exception());
    278278    return promiseDeferred->promise();
    279279}
     
    295295
    296296    rejectPromiseWithExceptionIfAny(state, globalObject, *promiseDeferred);
    297     ASSERT_UNUSED(scope, !scope.exception());
     297    EXCEPTION_ASSERT_UNUSED(scope, !scope.exception());
    298298    return promiseDeferred->promise();
    299299}
Note: See TracChangeset for help on using the changeset viewer.