Diff
Modified: trunk/LayoutTests/ChangeLog (203032 => 203033)
--- trunk/LayoutTests/ChangeLog 2016-07-09 16:23:27 UTC (rev 203032)
+++ trunk/LayoutTests/ChangeLog 2016-07-09 20:50:51 UTC (rev 203033)
@@ -1,3 +1,19 @@
+2016-07-09 Keith Miller <[email protected]>
+
+ appendMemcpy might fail in concatAppendOne
+ https://bugs.webkit.org/show_bug.cgi?id=159601
+
+ Reviewed by Mark Lam.
+
+ Add new microbenchmark testing the performance of concat
+ when appending one new element. This patch appears to be
+ about a 13% progression on this test.
+
+ * js/regress/concat-append-one-expected.txt: Added.
+ * js/regress/concat-append-one.html: Added.
+ * js/regress/script-tests/concat-append-one.js: Added.
+ (test):
+
2016-07-09 Youenn Fablet <[email protected]>
Make use of PrivateIdentifier to simplify Fetch Headers built-in checks
Added: trunk/LayoutTests/js/regress/concat-append-one-expected.txt (0 => 203033)
--- trunk/LayoutTests/js/regress/concat-append-one-expected.txt (rev 0)
+++ trunk/LayoutTests/js/regress/concat-append-one-expected.txt 2016-07-09 20:50:51 UTC (rev 203033)
@@ -0,0 +1,10 @@
+JSRegress/concat-append-one
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/js/regress/concat-append-one.html (0 => 203033)
--- trunk/LayoutTests/js/regress/concat-append-one.html (rev 0)
+++ trunk/LayoutTests/js/regress/concat-append-one.html 2016-07-09 20:50:51 UTC (rev 203033)
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/js/regress/script-tests/concat-append-one.js (0 => 203033)
--- trunk/LayoutTests/js/regress/script-tests/concat-append-one.js (rev 0)
+++ trunk/LayoutTests/js/regress/script-tests/concat-append-one.js 2016-07-09 20:50:51 UTC (rev 203033)
@@ -0,0 +1,15 @@
+function test() {
+ let obj = {};
+ [1,2,3].concat(4);
+ [1,2,3].concat(1.34);
+ [1.35,2,3].concat(1.34);
+ [1.35,2,3].concat(obj);
+ [1,2,3].concat(obj);
+ [].concat(obj);
+ [].concat(1);
+ [].concat(1.224);
+}
+noInline(test);
+
+for (let i = 0; i < 10000; i++)
+ test();
Modified: trunk/Source/_javascript_Core/ChangeLog (203032 => 203033)
--- trunk/Source/_javascript_Core/ChangeLog 2016-07-09 16:23:27 UTC (rev 203032)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-07-09 20:50:51 UTC (rev 203033)
@@ -1,3 +1,23 @@
+2016-07-09 Keith Miller <[email protected]>
+
+ appendMemcpy might fail in concatAppendOne
+ https://bugs.webkit.org/show_bug.cgi?id=159601
+ <rdar://problem/27211300>
+
+ Reviewed by Mark Lam.
+
+ There are multiple reasons why we might fail appendMemcpy. One
+ reason, which I suspect was the source of the crashes, is that one
+ of the Array prototypes has an indexed property. This patch
+ consolidates the two old cases by just creating an array then
+ attempting to memcpy append. If that fails, we fall back to
+ moveElements.
+
+ * runtime/ArrayPrototype.cpp:
+ (JSC::concatAppendOne):
+ * tests/stress/concat-with-holesMustForwardToPrototype.js: Added.
+ (arrayEq):
+
2016-07-09 Benjamin Poulain <[email protected]>
[JSC] Fix the Template Raw Value of \ (escape) + LineTerminatorSequence
Modified: trunk/Source/_javascript_Core/runtime/ArrayPrototype.cpp (203032 => 203033)
--- trunk/Source/_javascript_Core/runtime/ArrayPrototype.cpp 2016-07-09 16:23:27 UTC (rev 203032)
+++ trunk/Source/_javascript_Core/runtime/ArrayPrototype.cpp 2016-07-09 20:50:51 UTC (rev 203033)
@@ -1047,25 +1047,19 @@
unsigned firstArraySize = firstButterfly->publicLength();
IndexingType type = first->mergeIndexingTypeForCopying(indexingTypeForValue(second) | IsArray);
- JSArray* result;
- if (type == NonArray) {
- result = constructEmptyArray(exec, nullptr, firstArraySize + 1);
- if (vm.exception())
- return JSValue::encode(JSValue());
+ if (type == NonArray)
+ type = ArrayWithUndecided;
+ Structure* resultStructure = exec->lexicalGlobalObject()->arrayStructureForIndexingTypeDuringAllocation(type);
+ JSArray* result = JSArray::create(vm, resultStructure, firstArraySize + 1);
+ if (!result)
+ return JSValue::encode(throwOutOfMemoryError(exec));
+
+ if (!result->appendMemcpy(exec, vm, 0, first)) {
if (!moveElements(exec, vm, result, 0, first, firstArraySize)) {
ASSERT(vm.exception());
return JSValue::encode(JSValue());
}
-
- } else {
- Structure* resultStructure = exec->lexicalGlobalObject()->arrayStructureForIndexingTypeDuringAllocation(type);
- result = JSArray::tryCreateUninitialized(vm, resultStructure, firstArraySize + 1);
- if (!result)
- return JSValue::encode(throwOutOfMemoryError(exec));
-
- bool memcpyResult = result->appendMemcpy(exec, vm, 0, first);
- RELEASE_ASSERT(memcpyResult);
}
result->putDirectIndex(exec, firstArraySize, second);
Added: trunk/Source/_javascript_Core/tests/stress/concat-with-holesMustForwardToPrototype.js (0 => 203033)
--- trunk/Source/_javascript_Core/tests/stress/concat-with-holesMustForwardToPrototype.js (rev 0)
+++ trunk/Source/_javascript_Core/tests/stress/concat-with-holesMustForwardToPrototype.js 2016-07-09 20:50:51 UTC (rev 203033)
@@ -0,0 +1,19 @@
+Array.prototype[1] = 5;
+
+function arrayEq(a, b) {
+ if (a.length !== b.length)
+ throw new Error([a, "\n\n", b]);
+
+ for (let i = 0; i < a.length; i++) {
+ if (a[i] !== b[i])
+ throw new Error([a, "\n\n", b]);
+ }
+}
+
+
+let obj = {};
+arrayEq([1,2,3].concat(4), [1,2,3,4]);
+arrayEq([1,2,3].concat(1.34), [1,2,3,1.34]);
+arrayEq([1.35,2,3].concat(1.34), [1.35,2,3,1.34]);
+arrayEq([1.35,2,3].concat(obj), [1.35,2,3,obj]);
+arrayEq([1,2,3].concat(obj), [1,2,3,obj]);