Title: [204597] trunk/Source/_javascript_Core
- Revision
- 204597
- Author
- [email protected]
- Date
- 2016-08-18 10:17:41 -0700 (Thu, 18 Aug 2016)
Log Message
Make @Array(size) a bytecode intrinsic
https://bugs.webkit.org/show_bug.cgi?id=160867
Reviewed by Mark Lam.
There were a few places in the code where we were emitting `@Array(size)`
or `new @Array(size)`. Since we have a bytecode operation that already
represents this, called new_array_with_size, it's faster to just make a
bytecode intrinsic for the this operation. This patch does that and
the intrinsic is called `@newArrayWithSize`. This might be around a
1% speedup on ES6 sample bench, but it's within the noise. This is just
a good bytecode operation to have because it's common enough to
create arrays and it's good to make that fast in all tiers.
* builtins/ArrayConstructor.js:
(of):
(from):
* builtins/ArrayPrototype.js:
(filter):
(map):
(sort.stringSort):
(sort):
(concatSlowPath):
* bytecode/BytecodeIntrinsicRegistry.h:
* bytecompiler/NodesCodegen.cpp:
(JSC::BytecodeIntrinsicNode::emit_intrinsic_isObject):
(JSC::BytecodeIntrinsicNode::emit_intrinsic_newArrayWithSize):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (204596 => 204597)
--- trunk/Source/_javascript_Core/ChangeLog 2016-08-18 16:10:26 UTC (rev 204596)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-08-18 17:17:41 UTC (rev 204597)
@@ -1,3 +1,33 @@
+2016-08-18 Saam Barati <[email protected]>
+
+ Make @Array(size) a bytecode intrinsic
+ https://bugs.webkit.org/show_bug.cgi?id=160867
+
+ Reviewed by Mark Lam.
+
+ There were a few places in the code where we were emitting `@Array(size)`
+ or `new @Array(size)`. Since we have a bytecode operation that already
+ represents this, called new_array_with_size, it's faster to just make a
+ bytecode intrinsic for the this operation. This patch does that and
+ the intrinsic is called `@newArrayWithSize`. This might be around a
+ 1% speedup on ES6 sample bench, but it's within the noise. This is just
+ a good bytecode operation to have because it's common enough to
+ create arrays and it's good to make that fast in all tiers.
+
+ * builtins/ArrayConstructor.js:
+ (of):
+ (from):
+ * builtins/ArrayPrototype.js:
+ (filter):
+ (map):
+ (sort.stringSort):
+ (sort):
+ (concatSlowPath):
+ * bytecode/BytecodeIntrinsicRegistry.h:
+ * bytecompiler/NodesCodegen.cpp:
+ (JSC::BytecodeIntrinsicNode::emit_intrinsic_isObject):
+ (JSC::BytecodeIntrinsicNode::emit_intrinsic_newArrayWithSize):
+
2016-08-18 Rawinder Singh <[email protected]>
[web-animations] Add Animatable, AnimationEffect, KeyframeEffect and Animation interface
Modified: trunk/Source/_javascript_Core/builtins/ArrayConstructor.js (204596 => 204597)
--- trunk/Source/_javascript_Core/builtins/ArrayConstructor.js 2016-08-18 16:10:26 UTC (rev 204596)
+++ trunk/Source/_javascript_Core/builtins/ArrayConstructor.js 2016-08-18 17:17:41 UTC (rev 204597)
@@ -28,7 +28,7 @@
"use strict";
var length = arguments.length;
- var array = @isConstructor(this) ? new this(length) : new @Array(length);
+ var array = @isConstructor(this) ? new this(length) : @newArrayWithSize(length);
for (var k = 0; k < length; ++k)
@putByValDirect(array, k, arguments[k]);
array.length = length;
@@ -87,7 +87,7 @@
var arrayLike = @Object(items);
var arrayLikeLength = @toLength(arrayLike.length);
- var result = @isConstructor(thisObj) ? new thisObj(arrayLikeLength) : new @Array(arrayLikeLength);
+ var result = @isConstructor(thisObj) ? new thisObj(arrayLikeLength) : @newArrayWithSize(arrayLikeLength);
var k = 0;
while (k < arrayLikeLength) {
Modified: trunk/Source/_javascript_Core/builtins/ArrayPrototype.js (204596 => 204597)
--- trunk/Source/_javascript_Core/builtins/ArrayPrototype.js 2016-08-18 16:10:26 UTC (rev 204596)
+++ trunk/Source/_javascript_Core/builtins/ArrayPrototype.js 2016-08-18 17:17:41 UTC (rev 204597)
@@ -213,7 +213,7 @@
}
}
if (constructor === @Array || constructor === @undefined)
- result = [];
+ result = @newArrayWithSize(0);
else
result = new constructor(0);
@@ -262,7 +262,7 @@
}
}
if (constructor === @Array || constructor === @undefined)
- result = @Array(length);
+ result = @newArrayWithSize(length);
else
result = new constructor(length);
@@ -630,7 +630,7 @@
var valueCount = compact(array, length);
- var strings = new @Array(valueCount);
+ var strings = @newArrayWithSize(valueCount);
for (var i = 0; i < valueCount; ++i)
strings[i] = { string: @toString(array[i]), value: array[i] };
@@ -680,7 +680,7 @@
var argCount = arguments.length;
var result;
if (constructor === @Array || constructor === @undefined)
- result = [];
+ result = @newArrayWithSize(0);
else
result = new constructor(0);
var resultIsArray = @isJSArray(result);
Modified: trunk/Source/_javascript_Core/bytecode/BytecodeIntrinsicRegistry.h (204596 => 204597)
--- trunk/Source/_javascript_Core/bytecode/BytecodeIntrinsicRegistry.h 2016-08-18 16:10:26 UTC (rev 204596)
+++ trunk/Source/_javascript_Core/bytecode/BytecodeIntrinsicRegistry.h 2016-08-18 17:17:41 UTC (rev 204597)
@@ -47,7 +47,8 @@
macro(tryGetById) \
macro(putByValDirect) \
macro(toNumber) \
- macro(toString)
+ macro(toString) \
+ macro(newArrayWithSize) \
#define JSC_COMMON_BYTECODE_INTRINSIC_CONSTANTS_EACH_NAME(macro) \
macro(undefined) \
Modified: trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp (204596 => 204597)
--- trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp 2016-08-18 16:10:26 UTC (rev 204596)
+++ trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp 2016-08-18 17:17:41 UTC (rev 204597)
@@ -953,7 +953,18 @@
return generator.moveToDestinationIfNeeded(dst, generator.emitIsObject(generator.tempDestination(dst), src.get()));
}
+RegisterID* BytecodeIntrinsicNode::emit_intrinsic_newArrayWithSize(JSC::BytecodeGenerator& generator, JSC::RegisterID* dst)
+{
+ ArgumentListNode* node = m_args->m_listNode;
+ RefPtr<RegisterID> size = generator.emitNode(node);
+ ASSERT(!node->m_next);
+ RefPtr<RegisterID> finalDestination = generator.finalDestination(dst);
+ generator.emitNewArrayWithSize(finalDestination.get(), size.get());
+ return finalDestination.get();
+}
+
+
#define JSC_DECLARE_BYTECODE_INTRINSIC_CONSTANT_GENERATORS(name) \
RegisterID* BytecodeIntrinsicNode::emit_intrinsic_##name(BytecodeGenerator& generator, RegisterID* dst) \
{ \
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes