Title: [204488] trunk/Source/_javascript_Core
- Revision
- 204488
- Author
- sbar...@apple.com
- Date
- 2016-08-15 16:31:39 -0700 (Mon, 15 Aug 2016)
Log Message
Array.prototype.map builtin should go on the fast path when constructor===@Array
https://bugs.webkit.org/show_bug.cgi?id=160836
Reviewed by Keith Miller.
In the FTL, we were not compiling the result array in Array.prototype.map
efficiently when the result array should use the Array constructor
(which is the common case). We used to compile it as:
x: JSConstant(Array)
y: Construct(@x, ...)
instead of
y: NewArrayWithSize(...)
This patch changes the builtin to go down the fast path when certain
conditions are met. Often, the check to go down the fast path will
be constant folded because we always create a normal array from the
Array constructor.
This is around a 5% speedup on ES6 Sample Bench.
I also made similar changes for Array.prototype.filter
and Array.prototype.concat on its slow path.
* builtins/ArrayPrototype.js:
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (204487 => 204488)
--- trunk/Source/_javascript_Core/ChangeLog 2016-08-15 22:43:11 UTC (rev 204487)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-08-15 23:31:39 UTC (rev 204488)
@@ -1,3 +1,30 @@
+2016-08-15 Saam Barati <sbar...@apple.com>
+
+ Array.prototype.map builtin should go on the fast path when constructor===@Array
+ https://bugs.webkit.org/show_bug.cgi?id=160836
+
+ Reviewed by Keith Miller.
+
+ In the FTL, we were not compiling the result array in Array.prototype.map
+ efficiently when the result array should use the Array constructor
+ (which is the common case). We used to compile it as:
+ x: JSConstant(Array)
+ y: Construct(@x, ...)
+ instead of
+ y: NewArrayWithSize(...)
+
+ This patch changes the builtin to go down the fast path when certain
+ conditions are met. Often, the check to go down the fast path will
+ be constant folded because we always create a normal array from the
+ Array constructor.
+
+ This is around a 5% speedup on ES6 Sample Bench.
+
+ I also made similar changes for Array.prototype.filter
+ and Array.prototype.concat on its slow path.
+
+ * builtins/ArrayPrototype.js:
+
2016-08-15 Mark Lam <mark....@apple.com>
Make JSValue::strictEqual() handle failures to resolve JSRopeStrings.
Modified: trunk/Source/_javascript_Core/builtins/ArrayPrototype.js (204487 => 204488)
--- trunk/Source/_javascript_Core/builtins/ArrayPrototype.js 2016-08-15 22:43:11 UTC (rev 204487)
+++ trunk/Source/_javascript_Core/builtins/ArrayPrototype.js 2016-08-15 23:31:39 UTC (rev 204488)
@@ -212,9 +212,9 @@
constructor = @undefined;
}
}
- if (constructor === @undefined) {
+ if (constructor === @Array || constructor === @undefined)
result = [];
- } else
+ else
result = new constructor(0);
var nextIndex = 0;
@@ -261,9 +261,9 @@
constructor = @undefined;
}
}
- if (constructor === @undefined) {
+ if (constructor === @Array || constructor === @undefined)
result = @Array(length);
- } else
+ else
result = new constructor(length);
var nextIndex = 0;
@@ -676,11 +676,13 @@
constructor = @Array;
}
}
- if (constructor === @undefined)
- constructor = @Array;
var argCount = arguments.length;
- var result = new constructor(0);
+ var result;
+ if (constructor === @Array || constructor === @undefined)
+ result = [];
+ else
+ result = new constructor(0);
var resultIsArray = @isJSArray(result);
var resultIndex = 0;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes