Modified: releases/WebKitGTK/webkit-2.16/Source/_javascript_Core/ChangeLog (214813 => 214814)
--- releases/WebKitGTK/webkit-2.16/Source/_javascript_Core/ChangeLog 2017-04-03 17:23:43 UTC (rev 214813)
+++ releases/WebKitGTK/webkit-2.16/Source/_javascript_Core/ChangeLog 2017-04-03 17:24:23 UTC (rev 214814)
@@ -1,3 +1,19 @@
+2017-03-31 Mark Lam <mark....@apple.com>
+
+ Array.prototype.splice() should not be using JSArray::tryCreateForInitializationPrivate().
+ https://bugs.webkit.org/show_bug.cgi?id=170303
+ <rdar://problem/31358281>
+
+ Reviewed by Filip Pizlo.
+
+ This is because it needs to call getProperty() later to get the values for
+ initializing the array. getProperty() can execute arbitrary code and potentially
+ trigger the GC. This is not allowed for clients of JSArray::tryCreateForInitializationPrivate().
+
+ * runtime/ArrayPrototype.cpp:
+ (JSC::arrayProtoFuncSplice):
+ (JSC::copySplicedArrayElements): Deleted.
+
2017-03-30 Mark Lam <mark....@apple.com>
IntlObject should not be using JSArray::initializeIndex().
Modified: releases/WebKitGTK/webkit-2.16/Source/_javascript_Core/runtime/ArrayPrototype.cpp (214813 => 214814)
--- releases/WebKitGTK/webkit-2.16/Source/_javascript_Core/runtime/ArrayPrototype.cpp 2017-04-03 17:23:43 UTC (rev 214813)
+++ releases/WebKitGTK/webkit-2.16/Source/_javascript_Core/runtime/ArrayPrototype.cpp 2017-04-03 17:24:23 UTC (rev 214814)
@@ -967,20 +967,6 @@
return JSValue::encode(result);
}
-template<bool needToFillHolesManually>
-inline bool copySplicedArrayElements(ExecState* exec, ThrowScope& scope, JSObject* result, JSObject* thisObj, unsigned actualStart, unsigned actualDeleteCount)
-{
- VM& vm = scope.vm();
- for (unsigned k = 0; k < actualDeleteCount; ++k) {
- JSValue v = getProperty(exec, thisObj, k + actualStart);
- RETURN_IF_EXCEPTION(scope, false);
- if (UNLIKELY(!v && !needToFillHolesManually))
- continue;
- result->initializeIndex(vm, k, v);
- }
- return true;
-}
-
EncodedJSValue JSC_HOST_CALL arrayProtoFuncSplice(ExecState* exec)
{
// 15.4.4.12
@@ -1055,27 +1041,20 @@
RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
} else {
- result = JSArray::tryCreateForInitializationPrivate(vm, exec->lexicalGlobalObject()->arrayStructureForIndexingTypeDuringAllocation(ArrayWithUndecided), actualDeleteCount);
+ result = JSArray::tryCreate(vm, exec->lexicalGlobalObject()->arrayStructureForIndexingTypeDuringAllocation(ArrayWithUndecided), actualDeleteCount);
if (UNLIKELY(!result)) {
throwOutOfMemoryError(exec, scope);
return encodedJSValue();
}
- // The result can have an ArrayStorage indexing type if we're having a bad time.
- bool isArrayStorage = hasAnyArrayStorage(result->indexingType());
- bool success = false;
- if (UNLIKELY(isArrayStorage)) {
- static const bool needToFillHolesManually = true;
- success = copySplicedArrayElements<needToFillHolesManually>(exec, scope, result, thisObj, actualStart, actualDeleteCount);
- } else {
- ASSERT(hasUndecided(result->indexingType()));
- static const bool needToFillHolesManually = false;
- success = copySplicedArrayElements<needToFillHolesManually>(exec, scope, result, thisObj, actualStart, actualDeleteCount);
+ for (unsigned k = 0; k < actualDeleteCount; ++k) {
+ JSValue v = getProperty(exec, thisObj, k + actualStart);
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
+ if (UNLIKELY(!v))
+ continue;
+ result->putDirectIndex(exec, k, v);
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
}
- if (UNLIKELY(!success)) {
- ASSERT(scope.exception());
- return encodedJSValue();
- }
}
}