<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[209011] trunk/Source/JavaScriptCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/209011">209011</a></dd>
<dt>Author</dt> <dd>mark.lam@apple.com</dd>
<dt>Date</dt> <dd>2016-11-28 13:26:10 -0800 (Mon, 28 Nov 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Fix exception scope verification failures in ArrayConstructor.cpp and ArrayPrototype.cpp.
https://bugs.webkit.org/show_bug.cgi?id=164972
Reviewed by Geoffrey Garen.
* runtime/ArrayConstructor.cpp:
(JSC::constructArrayWithSizeQuirk):
* runtime/ArrayPrototype.cpp:
(JSC::getProperty):
(JSC::putLength):
(JSC::speciesWatchpointsValid):
(JSC::speciesConstructArray):
(JSC::shift):
(JSC::unshift):
(JSC::arrayProtoFuncToString):
(JSC::arrayProtoFuncToLocaleString):
(JSC::slowJoin):
(JSC::fastJoin):
(JSC::arrayProtoFuncJoin):
(JSC::arrayProtoFuncPop):
(JSC::arrayProtoFuncPush):
(JSC::arrayProtoFuncReverse):
(JSC::arrayProtoFuncShift):
(JSC::arrayProtoFuncSlice):
(JSC::arrayProtoFuncSplice):
(JSC::arrayProtoFuncUnShift):
(JSC::arrayProtoFuncIndexOf):
(JSC::arrayProtoFuncLastIndexOf):
(JSC::concatAppendOne):
(JSC::arrayProtoPrivateFuncConcatMemcpy):
(JSC::ArrayPrototype::attemptToInitializeSpeciesWatchpoint):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeArrayConstructorcpp">trunk/Source/JavaScriptCore/runtime/ArrayConstructor.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeArrayPrototypecpp">trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (209010 => 209011)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-11-28 20:46:44 UTC (rev 209010)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-11-28 21:26:10 UTC (rev 209011)
</span><span class="lines">@@ -1,3 +1,37 @@
</span><ins>+2016-11-24 Mark Lam <mark.lam@apple.com>
+
+ Fix exception scope verification failures in ArrayConstructor.cpp and ArrayPrototype.cpp.
+ https://bugs.webkit.org/show_bug.cgi?id=164972
+
+ Reviewed by Geoffrey Garen.
+
+ * runtime/ArrayConstructor.cpp:
+ (JSC::constructArrayWithSizeQuirk):
+ * runtime/ArrayPrototype.cpp:
+ (JSC::getProperty):
+ (JSC::putLength):
+ (JSC::speciesWatchpointsValid):
+ (JSC::speciesConstructArray):
+ (JSC::shift):
+ (JSC::unshift):
+ (JSC::arrayProtoFuncToString):
+ (JSC::arrayProtoFuncToLocaleString):
+ (JSC::slowJoin):
+ (JSC::fastJoin):
+ (JSC::arrayProtoFuncJoin):
+ (JSC::arrayProtoFuncPop):
+ (JSC::arrayProtoFuncPush):
+ (JSC::arrayProtoFuncReverse):
+ (JSC::arrayProtoFuncShift):
+ (JSC::arrayProtoFuncSlice):
+ (JSC::arrayProtoFuncSplice):
+ (JSC::arrayProtoFuncUnShift):
+ (JSC::arrayProtoFuncIndexOf):
+ (JSC::arrayProtoFuncLastIndexOf):
+ (JSC::concatAppendOne):
+ (JSC::arrayProtoPrivateFuncConcatMemcpy):
+ (JSC::ArrayPrototype::attemptToInitializeSpeciesWatchpoint):
+
</ins><span class="cx"> 2016-11-28 Mark Lam <mark.lam@apple.com>
</span><span class="cx">
</span><span class="cx"> Fix exception scope verification failures in LLIntSlowPaths.cpp.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeArrayConstructorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/ArrayConstructor.cpp (209010 => 209011)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/ArrayConstructor.cpp        2016-11-28 20:46:44 UTC (rev 209010)
+++ trunk/Source/JavaScriptCore/runtime/ArrayConstructor.cpp        2016-11-28 21:26:10 UTC (rev 209011)
</span><span class="lines">@@ -70,12 +70,15 @@
</span><span class="cx"> {
</span><span class="cx"> VM& vm = exec->vm();
</span><span class="cx"> auto scope = DECLARE_THROW_SCOPE(vm);
</span><del>- if (!length.isNumber())
</del><ins>+ if (!length.isNumber()) {
+ scope.release();
</ins><span class="cx"> return constructArrayNegativeIndexed(exec, profile, globalObject, &length, 1, newTarget);
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> uint32_t n = length.toUInt32(exec);
</span><span class="cx"> if (n != length.toNumber(exec))
</span><span class="cx"> return throwException(exec, scope, createRangeError(exec, ASCIILiteral("Array size is not a small enough positive integer.")));
</span><ins>+ scope.release();
</ins><span class="cx"> return constructEmptyArray(exec, profile, globalObject, n, newTarget);
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeArrayPrototypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp (209010 => 209011)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp        2016-11-28 20:46:44 UTC (rev 209010)
+++ trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp        2016-11-28 21:26:10 UTC (rev 209011)
</span><span class="lines">@@ -149,6 +149,9 @@
</span><span class="cx">
</span><span class="cx"> static ALWAYS_INLINE JSValue getProperty(ExecState* exec, JSObject* object, unsigned index)
</span><span class="cx"> {
</span><ins>+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
</ins><span class="cx"> if (JSValue result = object->tryGetIndexQuickly(index))
</span><span class="cx"> return result;
</span><span class="cx"> // We want to perform get and has in the same operation.
</span><span class="lines">@@ -156,10 +159,15 @@
</span><span class="cx"> // only time it is observable is when we encounter an opaque objects (ProxyObject and JSModuleNamespaceObject)
</span><span class="cx"> // somewhere in the prototype chain.
</span><span class="cx"> PropertySlot slot(object, PropertySlot::InternalMethodType::HasProperty);
</span><del>- if (!object->getPropertySlot(exec, index, slot))
- return JSValue();
- if (UNLIKELY(slot.isTaintedByOpaqueObject()))
</del><ins>+ bool hasProperty = object->getPropertySlot(exec, index, slot);
+ ASSERT(!scope.exception() || !hasProperty);
+ if (!hasProperty)
+ return { };
+ if (UNLIKELY(slot.isTaintedByOpaqueObject())) {
+ scope.release();
</ins><span class="cx"> return object->get(exec, index);
</span><ins>+ }
+ scope.release();
</ins><span class="cx"> return slot.getValue(exec, index);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -166,7 +174,7 @@
</span><span class="cx"> static ALWAYS_INLINE bool putLength(ExecState* exec, VM& vm, JSObject* obj, JSValue value)
</span><span class="cx"> {
</span><span class="cx"> PutPropertySlot slot(obj);
</span><del>- return obj->methodTable()->put(obj, exec, vm.propertyNames->length, value, slot);
</del><ins>+ return obj->methodTable(vm)->put(obj, exec, vm.propertyNames->length, value, slot);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static ALWAYS_INLINE void setLength(ExecState* exec, VM& vm, JSObject* obj, unsigned value)
</span><span class="lines">@@ -185,10 +193,15 @@
</span><span class="cx">
</span><span class="cx"> inline bool speciesWatchpointsValid(ExecState* exec, JSObject* thisObject)
</span><span class="cx"> {
</span><ins>+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
</ins><span class="cx"> ArrayPrototype* arrayPrototype = thisObject->globalObject()->arrayPrototype();
</span><span class="cx"> ArrayPrototype::SpeciesWatchpointStatus status = arrayPrototype->speciesWatchpointStatus();
</span><del>- if (UNLIKELY(status == ArrayPrototype::SpeciesWatchpointStatus::Uninitialized))
</del><ins>+ if (UNLIKELY(status == ArrayPrototype::SpeciesWatchpointStatus::Uninitialized)) {
</ins><span class="cx"> status = arrayPrototype->attemptToInitializeSpeciesWatchpoint(exec);
</span><ins>+ RETURN_IF_EXCEPTION(scope, false);
+ }
</ins><span class="cx"> ASSERT(status != ArrayPrototype::SpeciesWatchpointStatus::Uninitialized);
</span><span class="cx"> return !thisObject->hasCustomProperties()
</span><span class="cx"> && arrayPrototype == thisObject->getPrototypeDirect()
</span><span class="lines">@@ -212,13 +225,17 @@
</span><span class="cx">
</span><span class="cx"> // ECMA 9.4.2.3: https://tc39.github.io/ecma262/#sec-arrayspeciescreate
</span><span class="cx"> JSValue constructor = jsUndefined();
</span><del>- if (LIKELY(isArray(exec, thisObject))) {
</del><ins>+ bool thisIsArray = isArray(exec, thisObject);
+ RETURN_IF_EXCEPTION(scope, exceptionResult());
+ if (LIKELY(thisIsArray)) {
</ins><span class="cx"> // Fast path in the normal case where the user has not set an own constructor and the Array.prototype.constructor is normal.
</span><span class="cx"> // We need prototype check for subclasses of Array, which are Array objects but have a different prototype by default.
</span><del>- if (LIKELY(speciesWatchpointsValid(exec, thisObject)))
</del><ins>+ bool isValid = speciesWatchpointsValid(exec, thisObject);
+ RETURN_IF_EXCEPTION(scope, exceptionResult());
+ if (LIKELY(isValid))
</ins><span class="cx"> return std::make_pair(SpeciesConstructResult::FastPath, nullptr);
</span><span class="cx">
</span><del>- constructor = thisObject->get(exec, exec->propertyNames().constructor);
</del><ins>+ constructor = thisObject->get(exec, vm.propertyNames->constructor);
</ins><span class="cx"> RETURN_IF_EXCEPTION(scope, exceptionResult());
</span><span class="cx"> if (constructor.isConstructor()) {
</span><span class="cx"> JSObject* constructorObject = jsCast<JSObject*>(constructor);
</span><span class="lines">@@ -226,7 +243,7 @@
</span><span class="cx"> return std::make_pair(SpeciesConstructResult::FastPath, nullptr);;
</span><span class="cx"> }
</span><span class="cx"> if (constructor.isObject()) {
</span><del>- constructor = constructor.get(exec, exec->propertyNames().speciesSymbol);
</del><ins>+ constructor = constructor.get(exec, vm.propertyNames->speciesSymbol);
</ins><span class="cx"> RETURN_IF_EXCEPTION(scope, exceptionResult());
</span><span class="cx"> if (constructor.isNull())
</span><span class="cx"> return std::make_pair(SpeciesConstructResult::FastPath, nullptr);;
</span><span class="lines">@@ -294,17 +311,24 @@
</span><span class="cx"> for (unsigned k = header; k < length - currentCount; ++k) {
</span><span class="cx"> unsigned from = k + currentCount;
</span><span class="cx"> unsigned to = k + resultCount;
</span><del>- if (JSValue value = getProperty(exec, thisObj, from)) {
- RETURN_IF_EXCEPTION(scope, void());
</del><ins>+ JSValue value = getProperty(exec, thisObj, from);
+ RETURN_IF_EXCEPTION(scope, void());
+ if (value) {
</ins><span class="cx"> thisObj->putByIndexInline(exec, to, value, true);
</span><span class="cx"> RETURN_IF_EXCEPTION(scope, void());
</span><del>- } else if (!thisObj->methodTable(vm)->deletePropertyByIndex(thisObj, exec, to)) {
- throwTypeError(exec, scope, ASCIILiteral(UnableToDeletePropertyError));
- return;
</del><ins>+ } else {
+ bool success = thisObj->methodTable(vm)->deletePropertyByIndex(thisObj, exec, to);
+ RETURN_IF_EXCEPTION(scope, void());
+ if (!success) {
+ throwTypeError(exec, scope, ASCIILiteral(UnableToDeletePropertyError));
+ return;
+ }
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> for (unsigned k = length; k > length - count; --k) {
</span><del>- if (!thisObj->methodTable(vm)->deletePropertyByIndex(thisObj, exec, k - 1)) {
</del><ins>+ bool success = thisObj->methodTable(vm)->deletePropertyByIndex(thisObj, exec, k - 1);
+ RETURN_IF_EXCEPTION(scope, void());
+ if (!success) {
</ins><span class="cx"> throwTypeError(exec, scope, ASCIILiteral(UnableToDeletePropertyError));
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="lines">@@ -331,21 +355,30 @@
</span><span class="cx">
</span><span class="cx"> if (isJSArray(thisObj)) {
</span><span class="cx"> JSArray* array = asArray(thisObj);
</span><del>- if (array->length() == length && array->unshiftCount<shiftCountMode>(exec, header, count))
- return;
</del><ins>+ if (array->length() == length) {
+ bool handled = array->unshiftCount<shiftCountMode>(exec, header, count);
+ ASSERT(!scope.exception() || handled);
+ if (handled)
+ return;
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> for (unsigned k = length - currentCount; k > header; --k) {
</span><span class="cx"> unsigned from = k + currentCount - 1;
</span><span class="cx"> unsigned to = k + resultCount - 1;
</span><del>- if (JSValue value = getProperty(exec, thisObj, from)) {
</del><ins>+ JSValue value = getProperty(exec, thisObj, from);
+ RETURN_IF_EXCEPTION(scope, void());
+ if (value) {
+ thisObj->putByIndexInline(exec, to, value, true);
</ins><span class="cx"> RETURN_IF_EXCEPTION(scope, void());
</span><del>- thisObj->putByIndexInline(exec, to, value, true);
- } else if (!thisObj->methodTable(vm)->deletePropertyByIndex(thisObj, exec, to)) {
- throwTypeError(exec, scope, ASCIILiteral(UnableToDeletePropertyError));
- return;
</del><ins>+ } else {
+ bool success = thisObj->methodTable(vm)->deletePropertyByIndex(thisObj, exec, to);
+ RETURN_IF_EXCEPTION(scope, void());
+ if (UNLIKELY(!success)) {
+ throwTypeError(exec, scope, ASCIILiteral(UnableToDeletePropertyError));
+ return;
+ }
</ins><span class="cx"> }
</span><del>- RETURN_IF_EXCEPTION(scope, void());
</del><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -360,7 +393,7 @@
</span><span class="cx"> RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><span class="cx">
</span><span class="cx"> // 2. Let func be the result of calling the [[Get]] internal method of array with argument "join".
</span><del>- JSValue function = JSValue(thisObject).get(exec, exec->propertyNames().join);
</del><ins>+ JSValue function = JSValue(thisObject).get(exec, vm.propertyNames->join);
</ins><span class="cx"> RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><span class="cx">
</span><span class="cx"> // 3. If IsCallable(func) is false, then let func be the standard built-in method Object.prototype.toString (15.2.4.2).
</span><span class="lines">@@ -378,8 +411,10 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // 4. Return the result of calling the [[Call]] internal method of func providing array as the this value and an empty arguments list.
</span><del>- if (!isJSArray(thisObject) || callType != CallType::Host || callData.native.function != arrayProtoFuncJoin)
</del><ins>+ if (!isJSArray(thisObject) || callType != CallType::Host || callData.native.function != arrayProtoFuncJoin) {
+ scope.release();
</ins><span class="cx"> return JSValue::encode(call(exec, function, callType, callData, thisObject, exec->emptyList()));
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> ASSERT(isJSArray(thisValue));
</span><span class="cx"> JSArray* thisArray = asArray(thisValue);
</span><span class="lines">@@ -387,6 +422,7 @@
</span><span class="cx"> unsigned length = thisArray->length();
</span><span class="cx">
</span><span class="cx"> StringRecursionChecker checker(exec, thisArray);
</span><ins>+ ASSERT(!scope.exception() || checker.earlyReturnValue());
</ins><span class="cx"> if (JSValue earlyReturnValue = checker.earlyReturnValue())
</span><span class="cx"> return JSValue::encode(earlyReturnValue);
</span><span class="cx">
</span><span class="lines">@@ -403,6 +439,7 @@
</span><span class="cx"> RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ scope.release();
</ins><span class="cx"> return JSValue::encode(joiner.join(*exec));
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -419,6 +456,7 @@
</span><span class="cx"> RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><span class="cx">
</span><span class="cx"> StringRecursionChecker checker(exec, thisObject);
</span><ins>+ ASSERT(!scope.exception() || checker.earlyReturnValue());
</ins><span class="cx"> if (JSValue earlyReturnValue = checker.earlyReturnValue())
</span><span class="cx"> return JSValue::encode(earlyReturnValue);
</span><span class="cx">
</span><span class="lines">@@ -433,7 +471,7 @@
</span><span class="cx"> if (element.isUndefinedOrNull())
</span><span class="cx"> element = jsEmptyString(exec);
</span><span class="cx"> else {
</span><del>- JSValue conversionFunction = element.get(exec, exec->propertyNames().toLocaleString);
</del><ins>+ JSValue conversionFunction = element.get(exec, vm.propertyNames->toLocaleString);
</ins><span class="cx"> RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><span class="cx"> CallData callData;
</span><span class="cx"> CallType callType = getCallData(conversionFunction, callData);
</span><span class="lines">@@ -451,7 +489,7 @@
</span><span class="cx"> RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><span class="cx"> if (element.isUndefinedOrNull())
</span><span class="cx"> continue;
</span><del>- JSValue conversionFunction = element.get(exec, exec->propertyNames().toLocaleString);
</del><ins>+ JSValue conversionFunction = element.get(exec, vm.propertyNames->toLocaleString);
</ins><span class="cx"> RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><span class="cx"> CallData callData;
</span><span class="cx"> CallType callType = getCallData(conversionFunction, callData);
</span><span class="lines">@@ -464,6 +502,7 @@
</span><span class="cx"> }
</span><span class="cx"> #endif // !ENABLE(INTL)
</span><span class="cx">
</span><ins>+ scope.release();
</ins><span class="cx"> return JSValue::encode(stringJoiner.join(*exec));
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -503,7 +542,7 @@
</span><span class="cx">
</span><span class="cx"> // 6. Let element0 be Get(O, "0").
</span><span class="cx"> JSValue element0 = thisObject->getIndex(&exec, 0);
</span><del>- RETURN_IF_EXCEPTION(scope, JSValue());
</del><ins>+ RETURN_IF_EXCEPTION(scope, { });
</ins><span class="cx">
</span><span class="cx"> // 7. If element0 is undefined or null, let R be the empty String; otherwise, let R be ? ToString(element0).
</span><span class="cx"> JSString* r = nullptr;
</span><span class="lines">@@ -511,7 +550,7 @@
</span><span class="cx"> r = jsEmptyString(&exec);
</span><span class="cx"> else
</span><span class="cx"> r = element0.toString(&exec);
</span><del>- RETURN_IF_EXCEPTION(scope, JSValue());
</del><ins>+ RETURN_IF_EXCEPTION(scope, { });
</ins><span class="cx">
</span><span class="cx"> // 8. Let k be 1.
</span><span class="cx"> // 9. Repeat, while k < len
</span><span class="lines">@@ -519,7 +558,7 @@
</span><span class="cx"> for (uint64_t k = 1; k < length; ++k) {
</span><span class="cx"> // b. Let element be ? Get(O, ! ToString(k)).
</span><span class="cx"> JSValue element = thisObject->get(&exec, Identifier::fromString(&exec, AtomicString::number(k)));
</span><del>- RETURN_IF_EXCEPTION(scope, JSValue());
</del><ins>+ RETURN_IF_EXCEPTION(scope, { });
</ins><span class="cx">
</span><span class="cx"> // c. If element is undefined or null, let next be the empty String; otherwise, let next be ? ToString(element).
</span><span class="cx"> JSString* next = nullptr;
</span><span class="lines">@@ -529,12 +568,12 @@
</span><span class="cx"> next = jsEmptyString(&exec);
</span><span class="cx"> } else
</span><span class="cx"> next = element.toString(&exec);
</span><del>- RETURN_IF_EXCEPTION(scope, JSValue());
</del><ins>+ RETURN_IF_EXCEPTION(scope, { });
</ins><span class="cx">
</span><span class="cx"> // a. Let S be the String value produced by concatenating R and sep.
</span><span class="cx"> // d. Let R be a String value produced by concatenating S and next.
</span><span class="cx"> r = jsString(&exec, r, separator, next);
</span><del>- RETURN_IF_EXCEPTION(scope, JSValue());
</del><ins>+ RETURN_IF_EXCEPTION(scope, { });
</ins><span class="cx"> }
</span><span class="cx"> // 10. Return R.
</span><span class="cx"> return r;
</span><span class="lines">@@ -565,7 +604,7 @@
</span><span class="cx"> if (length > butterfly.publicLength())
</span><span class="cx"> break;
</span><span class="cx"> JSStringJoiner joiner(state, separator, length);
</span><del>- RETURN_IF_EXCEPTION(scope, JSValue());
</del><ins>+ RETURN_IF_EXCEPTION(scope, { });
</ins><span class="cx"> auto data = butterfly.contiguous().data();
</span><span class="cx"> bool holesKnownToBeOK = false;
</span><span class="cx"> for (unsigned i = 0; i < length; ++i) {
</span><span class="lines">@@ -581,6 +620,7 @@
</span><span class="cx"> joiner.appendEmptyString();
</span><span class="cx"> }
</span><span class="cx"> }
</span><ins>+ scope.release();
</ins><span class="cx"> return joiner.join(state);
</span><span class="cx"> }
</span><span class="cx"> case ALL_DOUBLE_INDEXING_TYPES: {
</span><span class="lines">@@ -588,7 +628,7 @@
</span><span class="cx"> if (length > butterfly.publicLength())
</span><span class="cx"> break;
</span><span class="cx"> JSStringJoiner joiner(state, separator, length);
</span><del>- RETURN_IF_EXCEPTION(scope, JSValue());
</del><ins>+ RETURN_IF_EXCEPTION(scope, { });
</ins><span class="cx"> auto data = butterfly.contiguousDouble().data();
</span><span class="cx"> bool holesKnownToBeOK = false;
</span><span class="cx"> for (unsigned i = 0; i < length; ++i) {
</span><span class="lines">@@ -604,6 +644,7 @@
</span><span class="cx"> joiner.appendEmptyString();
</span><span class="cx"> }
</span><span class="cx"> }
</span><ins>+ scope.release();
</ins><span class="cx"> return joiner.join(state);
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -610,13 +651,14 @@
</span><span class="cx">
</span><span class="cx"> generalCase:
</span><span class="cx"> JSStringJoiner joiner(state, separator, length);
</span><del>- RETURN_IF_EXCEPTION(scope, JSValue());
</del><ins>+ RETURN_IF_EXCEPTION(scope, { });
</ins><span class="cx"> for (unsigned i = 0; i < length; ++i) {
</span><span class="cx"> JSValue element = thisObject->getIndex(&state, i);
</span><del>- RETURN_IF_EXCEPTION(scope, JSValue());
</del><ins>+ RETURN_IF_EXCEPTION(scope, { });
</ins><span class="cx"> joiner.append(state, element);
</span><del>- RETURN_IF_EXCEPTION(scope, JSValue());
</del><ins>+ RETURN_IF_EXCEPTION(scope, { });
</ins><span class="cx"> }
</span><ins>+ scope.release();
</ins><span class="cx"> return joiner.join(state);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -627,10 +669,12 @@
</span><span class="cx">
</span><span class="cx"> // 1. Let O be ? ToObject(this value).
</span><span class="cx"> JSObject* thisObject = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
</span><del>- if (!thisObject)
- return JSValue::encode(JSValue());
</del><ins>+ ASSERT(!!scope.exception() == !thisObject);
+ if (UNLIKELY(!thisObject))
+ return encodedJSValue();
</ins><span class="cx">
</span><span class="cx"> StringRecursionChecker checker(exec, thisObject);
</span><ins>+ ASSERT(!scope.exception() || checker.earlyReturnValue());
</ins><span class="cx"> if (JSValue earlyReturnValue = checker.earlyReturnValue())
</span><span class="cx"> return JSValue::encode(earlyReturnValue);
</span><span class="cx">
</span><span class="lines">@@ -649,11 +693,14 @@
</span><span class="cx"> JSString* jsSeparator = jsSingleCharacterString(exec, comma);
</span><span class="cx"> RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><span class="cx">
</span><ins>+ scope.release();
</ins><span class="cx"> return JSValue::encode(slowJoin(*exec, thisObject, jsSeparator, length64));
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> unsigned unsignedLength = static_cast<unsigned>(length);
</span><span class="cx"> ASSERT(static_cast<double>(unsignedLength) == length);
</span><ins>+
+ scope.release();
</ins><span class="cx"> return JSValue::encode(fastJoin(*exec, thisObject, { &comma, 1 }, unsignedLength));
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -664,6 +711,8 @@
</span><span class="cx"> if (UNLIKELY(length > std::numeric_limits<unsigned>::max() || !canUseFastJoin(thisObject))) {
</span><span class="cx"> uint64_t length64 = static_cast<uint64_t>(length);
</span><span class="cx"> ASSERT(static_cast<double>(length64) == length);
</span><ins>+
+ scope.release();
</ins><span class="cx"> return JSValue::encode(slowJoin(*exec, thisObject, jsSeparator, length64));
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -681,28 +730,34 @@
</span><span class="cx">
</span><span class="cx"> JSValue thisValue = exec->thisValue().toThis(exec, StrictMode);
</span><span class="cx">
</span><del>- if (isJSArray(thisValue))
</del><ins>+ if (isJSArray(thisValue)) {
+ scope.release();
</ins><span class="cx"> return JSValue::encode(asArray(thisValue)->pop(exec));
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> JSObject* thisObj = thisValue.toObject(exec);
</span><del>- if (!thisObj)
- return JSValue::encode(JSValue());
</del><ins>+ ASSERT(!!scope.exception() == !thisObj);
+ if (UNLIKELY(!thisObj))
+ return encodedJSValue();
</ins><span class="cx"> unsigned length = getLength(exec, thisObj);
</span><span class="cx"> RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><span class="cx">
</span><del>- JSValue result;
</del><span class="cx"> if (length == 0) {
</span><ins>+ scope.release();
</ins><span class="cx"> putLength(exec, vm, thisObj, jsNumber(length));
</span><del>- result = jsUndefined();
- } else {
- result = thisObj->get(exec, length - 1);
- RETURN_IF_EXCEPTION(scope, encodedJSValue());
- if (!thisObj->methodTable(vm)->deletePropertyByIndex(thisObj, exec, length - 1)) {
- throwTypeError(exec, scope, ASCIILiteral(UnableToDeletePropertyError));
- return JSValue::encode(jsUndefined());
- }
- putLength(exec, vm, thisObj, jsNumber(length - 1));
</del><ins>+ return JSValue::encode(jsUndefined());
</ins><span class="cx"> }
</span><ins>+
+ JSValue result = thisObj->get(exec, length - 1);
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
+ bool success = thisObj->methodTable(vm)->deletePropertyByIndex(thisObj, exec, length - 1);
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
+ if (UNLIKELY(!success)) {
+ throwTypeError(exec, scope, ASCIILiteral(UnableToDeletePropertyError));
+ return encodedJSValue();
+ }
+ scope.release();
+ putLength(exec, vm, thisObj, jsNumber(length - 1));
</ins><span class="cx"> return JSValue::encode(result);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -714,13 +769,15 @@
</span><span class="cx">
</span><span class="cx"> if (isJSArray(thisValue) && exec->argumentCount() == 1) {
</span><span class="cx"> JSArray* array = asArray(thisValue);
</span><ins>+ scope.release();
</ins><span class="cx"> array->push(exec, exec->uncheckedArgument(0));
</span><span class="cx"> return JSValue::encode(jsNumber(array->length()));
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> JSObject* thisObj = thisValue.toObject(exec);
</span><del>- if (!thisObj)
- return JSValue::encode(JSValue());
</del><ins>+ ASSERT(!!scope.exception() == !thisObj);
+ if (UNLIKELY(!thisObj))
+ return encodedJSValue();
</ins><span class="cx"> unsigned length = getLength(exec, thisObj);
</span><span class="cx"> RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><span class="cx">
</span><span class="lines">@@ -727,16 +784,17 @@
</span><span class="cx"> for (unsigned n = 0; n < exec->argumentCount(); n++) {
</span><span class="cx"> // Check for integer overflow; where safe we can do a fast put by index.
</span><span class="cx"> if (length + n >= length)
</span><del>- thisObj->methodTable()->putByIndex(thisObj, exec, length + n, exec->uncheckedArgument(n), true);
</del><ins>+ thisObj->methodTable(vm)->putByIndex(thisObj, exec, length + n, exec->uncheckedArgument(n), true);
</ins><span class="cx"> else {
</span><span class="cx"> PutPropertySlot slot(thisObj);
</span><span class="cx"> Identifier propertyName = Identifier::fromString(exec, JSValue(static_cast<int64_t>(length) + static_cast<int64_t>(n)).toWTFString(exec));
</span><del>- thisObj->methodTable()->put(thisObj, exec, propertyName, exec->uncheckedArgument(n), slot);
</del><ins>+ thisObj->methodTable(vm)->put(thisObj, exec, propertyName, exec->uncheckedArgument(n), slot);
</ins><span class="cx"> }
</span><span class="cx"> RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> JSValue newLength(static_cast<int64_t>(length) + static_cast<int64_t>(exec->argumentCount()));
</span><ins>+ scope.release();
</ins><span class="cx"> putLength(exec, vm, thisObj, newLength);
</span><span class="cx"> return JSValue::encode(newLength);
</span><span class="cx"> }
</span><span class="lines">@@ -747,8 +805,9 @@
</span><span class="cx"> auto scope = DECLARE_THROW_SCOPE(vm);
</span><span class="cx">
</span><span class="cx"> JSObject* thisObject = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
</span><del>- if (!thisObject)
- return JSValue::encode(JSValue());
</del><ins>+ ASSERT(!!scope.exception() == !thisObject);
+ if (UNLIKELY(!thisObject))
+ return encodedJSValue();
</ins><span class="cx">
</span><span class="cx"> unsigned length = getLength(exec, thisObject);
</span><span class="cx"> RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><span class="lines">@@ -809,19 +868,25 @@
</span><span class="cx"> if (upperExists) {
</span><span class="cx"> thisObject->putByIndexInline(exec, lower, upperValue, true);
</span><span class="cx"> RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><del>- } else if (!thisObject->methodTable(vm)->deletePropertyByIndex(thisObject, exec, lower)) {
- if (!scope.exception())
</del><ins>+ } else {
+ bool success = thisObject->methodTable(vm)->deletePropertyByIndex(thisObject, exec, lower);
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
+ if (UNLIKELY(!success)) {
</ins><span class="cx"> throwTypeError(exec, scope, ASCIILiteral(UnableToDeletePropertyError));
</span><del>- return JSValue::encode(JSValue());
</del><ins>+ return encodedJSValue();
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (lowerExists) {
</span><span class="cx"> thisObject->putByIndexInline(exec, upper, lowerValue, true);
</span><span class="cx"> RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><del>- } else if (!thisObject->methodTable(vm)->deletePropertyByIndex(thisObject, exec, upper)) {
- if (!scope.exception())
</del><ins>+ } else {
+ bool success = thisObject->methodTable(vm)->deletePropertyByIndex(thisObject, exec, upper);
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
+ if (UNLIKELY(!success)) {
</ins><span class="cx"> throwTypeError(exec, scope, ASCIILiteral(UnableToDeletePropertyError));
</span><del>- return JSValue::encode(JSValue());
</del><ins>+ return encodedJSValue();
+ }
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> return JSValue::encode(thisObject);
</span><span class="lines">@@ -832,21 +897,24 @@
</span><span class="cx"> VM& vm = exec->vm();
</span><span class="cx"> auto scope = DECLARE_THROW_SCOPE(vm);
</span><span class="cx"> JSObject* thisObj = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
</span><del>- if (!thisObj)
- return JSValue::encode(JSValue());
</del><ins>+ ASSERT(!!scope.exception() == !thisObj);
+ if (UNLIKELY(!thisObj))
+ return encodedJSValue();
</ins><span class="cx"> unsigned length = getLength(exec, thisObj);
</span><span class="cx"> RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><span class="cx">
</span><del>- JSValue result;
</del><span class="cx"> if (length == 0) {
</span><ins>+ scope.release();
</ins><span class="cx"> putLength(exec, vm, thisObj, jsNumber(length));
</span><del>- result = jsUndefined();
- } else {
- result = thisObj->getIndex(exec, 0);
- shift<JSArray::ShiftCountForShift>(exec, thisObj, 0, 1, 0, length);
- RETURN_IF_EXCEPTION(scope, encodedJSValue());
- putLength(exec, vm, thisObj, jsNumber(length - 1));
</del><ins>+ return JSValue::encode(jsUndefined());
</ins><span class="cx"> }
</span><ins>+
+ JSValue result = thisObj->getIndex(exec, 0);
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
+ shift<JSArray::ShiftCountForShift>(exec, thisObj, 0, 1, 0, length);
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
+ scope.release();
+ putLength(exec, vm, thisObj, jsNumber(length - 1));
</ins><span class="cx"> return JSValue::encode(result);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -856,20 +924,26 @@
</span><span class="cx"> VM& vm = exec->vm();
</span><span class="cx"> auto scope = DECLARE_THROW_SCOPE(vm);
</span><span class="cx"> JSObject* thisObj = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
</span><del>- if (!thisObj)
- return JSValue::encode(JSValue());
</del><ins>+ ASSERT(!!scope.exception() == !thisObj);
+ if (UNLIKELY(!thisObj))
+ return encodedJSValue();
</ins><span class="cx"> unsigned length = getLength(exec, thisObj);
</span><span class="cx"> RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><span class="cx">
</span><span class="cx"> unsigned begin = argumentClampedIndexFromStartOrEnd(exec, 0, length);
</span><ins>+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
</ins><span class="cx"> unsigned end = argumentClampedIndexFromStartOrEnd(exec, 1, length, length);
</span><ins>+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
</ins><span class="cx">
</span><span class="cx"> std::pair<SpeciesConstructResult, JSObject*> speciesResult = speciesConstructArray(exec, thisObj, end - begin);
</span><span class="cx"> // We can only get an exception if we call some user function.
</span><ins>+ ASSERT(!!scope.exception() == (speciesResult.first == SpeciesConstructResult::Exception));
</ins><span class="cx"> if (UNLIKELY(speciesResult.first == SpeciesConstructResult::Exception))
</span><del>- return JSValue::encode(jsUndefined());
</del><ins>+ return encodedJSValue();
</ins><span class="cx">
</span><del>- if (LIKELY(speciesResult.first == SpeciesConstructResult::FastPath && isJSArray(thisObj) && length == getLength(exec, thisObj))) {
</del><ins>+ bool okToDoFastPath = speciesResult.first == SpeciesConstructResult::FastPath && isJSArray(thisObj) && length == getLength(exec, thisObj);
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
+ if (LIKELY(okToDoFastPath)) {
</ins><span class="cx"> if (JSArray* result = asArray(thisObj)->fastSlice(*exec, begin, end - begin))
</span><span class="cx"> return JSValue::encode(result);
</span><span class="cx"> }
</span><span class="lines">@@ -886,8 +960,10 @@
</span><span class="cx"> for (unsigned k = begin; k < end; k++, n++) {
</span><span class="cx"> JSValue v = getProperty(exec, thisObj, k);
</span><span class="cx"> RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><del>- if (v)
</del><ins>+ if (v) {
</ins><span class="cx"> result->putDirectIndex(exec, n, v, 0, PutDirectIndexShouldThrow);
</span><ins>+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
+ }
</ins><span class="cx"> }
</span><span class="cx"> scope.release();
</span><span class="cx"> setLength(exec, vm, result, n);
</span><span class="lines">@@ -902,15 +978,17 @@
</span><span class="cx"> auto scope = DECLARE_THROW_SCOPE(vm);
</span><span class="cx">
</span><span class="cx"> JSObject* thisObj = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
</span><del>- if (!thisObj)
- return JSValue::encode(JSValue());
</del><ins>+ ASSERT(!!scope.exception() == !thisObj);
+ if (UNLIKELY(!thisObj))
+ return encodedJSValue();
</ins><span class="cx"> unsigned length = getLength(exec, thisObj);
</span><span class="cx"> RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><span class="cx">
</span><span class="cx"> if (!exec->argumentCount()) {
</span><span class="cx"> std::pair<SpeciesConstructResult, JSObject*> speciesResult = speciesConstructArray(exec, thisObj, 0);
</span><del>- if (speciesResult.first == SpeciesConstructResult::Exception)
- return JSValue::encode(jsUndefined());
</del><ins>+ ASSERT(!!scope.exception() == (speciesResult.first == SpeciesConstructResult::Exception));
+ if (UNLIKELY(speciesResult.first == SpeciesConstructResult::Exception))
+ return encodedJSValue();
</ins><span class="cx">
</span><span class="cx"> JSObject* result;
</span><span class="cx"> if (speciesResult.first == SpeciesConstructResult::CreatedObject)
</span><span class="lines">@@ -928,10 +1006,12 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> unsigned actualStart = argumentClampedIndexFromStartOrEnd(exec, 0, length);
</span><ins>+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
</ins><span class="cx">
</span><span class="cx"> unsigned actualDeleteCount = length - actualStart;
</span><span class="cx"> if (exec->argumentCount() > 1) {
</span><span class="cx"> double deleteCount = exec->uncheckedArgument(1).toInteger(exec);
</span><ins>+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
</ins><span class="cx"> if (deleteCount < 0)
</span><span class="cx"> actualDeleteCount = 0;
</span><span class="cx"> else if (deleteCount > length - actualStart)
</span><span class="lines">@@ -941,11 +1021,14 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> std::pair<SpeciesConstructResult, JSObject*> speciesResult = speciesConstructArray(exec, thisObj, actualDeleteCount);
</span><ins>+ ASSERT(!!scope.exception() == (speciesResult.first == SpeciesConstructResult::Exception));
</ins><span class="cx"> if (speciesResult.first == SpeciesConstructResult::Exception)
</span><span class="cx"> return JSValue::encode(jsUndefined());
</span><span class="cx">
</span><span class="cx"> JSObject* result = nullptr;
</span><del>- if (speciesResult.first == SpeciesConstructResult::FastPath && isJSArray(thisObj) && length == getLength(exec, thisObj))
</del><ins>+ bool okToDoFastPath = speciesResult.first == SpeciesConstructResult::FastPath && isJSArray(thisObj) && length == getLength(exec, thisObj);
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
+ if (LIKELY(okToDoFastPath))
</ins><span class="cx"> result = asArray(thisObj)->fastSlice(*exec, actualStart, actualDeleteCount);
</span><span class="cx">
</span><span class="cx"> if (!result) {
</span><span class="lines">@@ -1000,8 +1083,9 @@
</span><span class="cx"> // 15.4.4.13
</span><span class="cx">
</span><span class="cx"> JSObject* thisObj = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
</span><del>- if (!thisObj)
- return JSValue::encode(JSValue());
</del><ins>+ ASSERT(!!scope.exception() == !thisObj);
+ if (UNLIKELY(!thisObj))
+ return encodedJSValue();
</ins><span class="cx"> unsigned length = getLength(exec, thisObj);
</span><span class="cx"> RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><span class="cx">
</span><span class="lines">@@ -1015,6 +1099,7 @@
</span><span class="cx"> RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><span class="cx"> }
</span><span class="cx"> JSValue result = jsNumber(length + nrArgs);
</span><ins>+ scope.release();
</ins><span class="cx"> putLength(exec, vm, thisObj, result);
</span><span class="cx"> return JSValue::encode(result);
</span><span class="cx"> }
</span><span class="lines">@@ -1026,8 +1111,9 @@
</span><span class="cx">
</span><span class="cx"> // 15.4.4.14
</span><span class="cx"> JSObject* thisObj = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
</span><del>- if (!thisObj)
- return JSValue::encode(JSValue());
</del><ins>+ ASSERT(!!scope.exception() == !thisObj);
+ if (UNLIKELY(!thisObj))
+ return encodedJSValue();
</ins><span class="cx"> unsigned length = getLength(exec, thisObj);
</span><span class="cx"> RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><span class="cx">
</span><span class="lines">@@ -1053,10 +1139,11 @@
</span><span class="cx">
</span><span class="cx"> // 15.4.4.15
</span><span class="cx"> JSObject* thisObj = exec->thisValue().toThis(exec, StrictMode).toObject(exec);
</span><del>- if (!thisObj)
- return JSValue::encode(JSValue());
</del><ins>+ ASSERT(!!scope.exception() == !thisObj);
+ if (UNLIKELY(!thisObj))
+ return encodedJSValue();
</ins><span class="cx"> unsigned length = getLength(exec, thisObj);
</span><del>- if (!length)
</del><ins>+ if (UNLIKELY(scope.exception()) || !length)
</ins><span class="cx"> return JSValue::encode(jsNumber(-1));
</span><span class="cx">
</span><span class="cx"> unsigned index = length - 1;
</span><span class="lines">@@ -1131,13 +1218,16 @@
</span><span class="cx"> if (!result)
</span><span class="cx"> return JSValue::encode(throwOutOfMemoryError(exec, scope));
</span><span class="cx">
</span><del>- if (!result->appendMemcpy(exec, vm, 0, first)) {
- if (!moveElements(exec, vm, result, 0, first, firstArraySize)) {
- ASSERT(scope.exception());
- return JSValue::encode(JSValue());
- }
</del><ins>+ bool success = result->appendMemcpy(exec, vm, 0, first);
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
+ if (!success) {
+ bool success = moveElements(exec, vm, result, 0, first, firstArraySize);
+ ASSERT(!scope.exception() == success);
+ if (UNLIKELY(!success))
+ return encodedJSValue();
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+ scope.release();
</ins><span class="cx"> result->putDirectIndex(exec, firstArraySize, second);
</span><span class="cx"> return JSValue::encode(result);
</span><span class="cx">
</span><span class="lines">@@ -1159,12 +1249,16 @@
</span><span class="cx"> return JSValue::encode(jsNull());
</span><span class="cx">
</span><span class="cx"> // We need to check the species constructor here since checking it in the JS wrapper is too expensive for the non-optimizing tiers.
</span><del>- if (UNLIKELY(!speciesWatchpointsValid(exec, firstArray)))
</del><ins>+ bool isValid = speciesWatchpointsValid(exec, firstArray);
+ ASSERT(!scope.exception() || !isValid);
+ if (UNLIKELY(!isValid))
</ins><span class="cx"> return JSValue::encode(jsNull());
</span><span class="cx">
</span><span class="cx"> JSValue second = exec->uncheckedArgument(1);
</span><del>- if (!isJSArray(second))
</del><ins>+ if (!isJSArray(second)) {
+ scope.release();
</ins><span class="cx"> return concatAppendOne(exec, vm, firstArray, second);
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> JSArray* secondArray = jsCast<JSArray*>(second);
</span><span class="cx">
</span><span class="lines">@@ -1180,11 +1274,14 @@
</span><span class="cx"> JSArray* result = constructEmptyArray(exec, nullptr, firstArraySize + secondArraySize);
</span><span class="cx"> RETURN_IF_EXCEPTION(scope, encodedJSValue());
</span><span class="cx">
</span><del>- if (!moveElements(exec, vm, result, 0, firstArray, firstArraySize)
- || !moveElements(exec, vm, result, firstArraySize, secondArray, secondArraySize)) {
- ASSERT(scope.exception());
- return JSValue::encode(JSValue());
- }
</del><ins>+ bool success = moveElements(exec, vm, result, 0, firstArray, firstArraySize);
+ ASSERT(!scope.exception() == success);
+ if (UNLIKELY(!success))
+ return encodedJSValue();
+ success = moveElements(exec, vm, result, firstArraySize, secondArray, secondArraySize);
+ ASSERT(!scope.exception() == success);
+ if (UNLIKELY(!success))
+ return encodedJSValue();
</ins><span class="cx">
</span><span class="cx"> return JSValue::encode(result);
</span><span class="cx"> }
</span><span class="lines">@@ -1250,6 +1347,7 @@
</span><span class="cx"> ASSERT(m_speciesWatchpointStatus == SpeciesWatchpointStatus::Uninitialized);
</span><span class="cx">
</span><span class="cx"> VM& vm = exec->vm();
</span><ins>+ auto scope = DECLARE_THROW_SCOPE(vm);
</ins><span class="cx">
</span><span class="cx"> if (verbose)
</span><span class="cx"> dataLog("Attempting to initialize Array species watchpoints for Array.prototype: ", pointerDump(this), " with structure: ", pointerDump(this->structure()), "\nand Array: ", pointerDump(this->globalObject()->arrayConstructor()), " with structure: ", pointerDump(this->globalObject()->arrayConstructor()->structure()), "\n");
</span><span class="lines">@@ -1267,7 +1365,8 @@
</span><span class="cx">
</span><span class="cx"> PropertySlot constructorSlot(this, PropertySlot::InternalMethodType::VMInquiry);
</span><span class="cx"> JSValue(this).get(exec, vm.propertyNames->constructor, constructorSlot);
</span><del>- if (constructorSlot.slotBase() != this
</del><ins>+ if (UNLIKELY(scope.exception())
+ || constructorSlot.slotBase() != this
</ins><span class="cx"> || !constructorSlot.isCacheableValue()
</span><span class="cx"> || constructorSlot.getValue(exec, vm.propertyNames->constructor) != arrayConstructor)
</span><span class="cx"> return m_speciesWatchpointStatus = SpeciesWatchpointStatus::Fired;
</span><span class="lines">@@ -1278,7 +1377,8 @@
</span><span class="cx">
</span><span class="cx"> PropertySlot speciesSlot(arrayConstructor, PropertySlot::InternalMethodType::VMInquiry);
</span><span class="cx"> JSValue(arrayConstructor).get(exec, vm.propertyNames->speciesSymbol, speciesSlot);
</span><del>- if (speciesSlot.slotBase() != arrayConstructor
</del><ins>+ if (UNLIKELY(scope.exception())
+ || speciesSlot.slotBase() != arrayConstructor
</ins><span class="cx"> || !speciesSlot.isCacheableGetter()
</span><span class="cx"> || speciesSlot.getterSetter() != globalObject->speciesGetterSetter())
</span><span class="cx"> return m_speciesWatchpointStatus = SpeciesWatchpointStatus::Fired;
</span></span></pre>
</div>
</div>
</body>
</html>