Title: [206147] trunk
- Revision
- 206147
- Author
- utatane....@gmail.com
- Date
- 2016-09-20 08:45:43 -0700 (Tue, 20 Sep 2016)
Log Message
[JSC] Add `typeof value === "symbol"` handling to bytecode compiler
https://bugs.webkit.org/show_bug.cgi?id=162253
Reviewed by Sam Weinig.
JSTests:
* microbenchmarks/is-symbol-mixed.js: Added.
(isSymbol):
(i.let.pair.of.list.String):
* microbenchmarks/is-symbol.js: Added.
(isSymbol):
Source/_javascript_Core:
Add `typeof value === "symbol"` handling to the bytecode compiler.
The effect is tiny, but it keeps consistency since the bytecode compiler
already has the similar optimization for "string" case.
* bytecode/SpeculatedType.cpp:
(JSC::speculationFromJSType):
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::emitEqualityOp):
Modified Paths
Added Paths
Diff
Modified: trunk/JSTests/ChangeLog (206146 => 206147)
--- trunk/JSTests/ChangeLog 2016-09-20 15:26:19 UTC (rev 206146)
+++ trunk/JSTests/ChangeLog 2016-09-20 15:45:43 UTC (rev 206147)
@@ -1,3 +1,16 @@
+2016-09-20 Yusuke Suzuki <utatane....@gmail.com>
+
+ [JSC] Add `typeof value === "symbol"` handling to bytecode compiler
+ https://bugs.webkit.org/show_bug.cgi?id=162253
+
+ Reviewed by Sam Weinig.
+
+ * microbenchmarks/is-symbol-mixed.js: Added.
+ (isSymbol):
+ (i.let.pair.of.list.String):
+ * microbenchmarks/is-symbol.js: Added.
+ (isSymbol):
+
2016-09-19 Saam Barati <sbar...@apple.com>
Make HasOwnProperty faster
Added: trunk/JSTests/microbenchmarks/is-symbol-mixed.js (0 => 206147)
--- trunk/JSTests/microbenchmarks/is-symbol-mixed.js (rev 0)
+++ trunk/JSTests/microbenchmarks/is-symbol-mixed.js 2016-09-20 15:45:43 UTC (rev 206147)
@@ -0,0 +1,22 @@
+function isSymbol(value)
+{
+ return typeof value === 'symbol';
+}
+noInline(isSymbol);
+
+var list = [
+ [ {}, false ],
+ [ [] , false ],
+ [ "Cappuccino", false ],
+ [ Symbol('Cocoa'), true ],
+ [ null, false ],
+ [ undefined, false ],
+ [ 42, false ],
+]
+
+for (var i = 0; i < 1e4; ++i) {
+ for (let pair of list) {
+ if (isSymbol(pair[0]) != pair[1])
+ throw new Error(`bad value:${String(pair[0])}, ${pair[1]}`);
+ }
+}
Added: trunk/JSTests/microbenchmarks/is-symbol.js (0 => 206147)
--- trunk/JSTests/microbenchmarks/is-symbol.js (rev 0)
+++ trunk/JSTests/microbenchmarks/is-symbol.js 2016-09-20 15:45:43 UTC (rev 206147)
@@ -0,0 +1,10 @@
+function isSymbol(value)
+{
+ return typeof value === 'symbol';
+}
+noInline(isSymbol);
+
+for (var i = 0; i < 1e4; ++i) {
+ if (!isSymbol(Symbol('Cocoa')))
+ throw new Error("out");
+}
Modified: trunk/Source/_javascript_Core/ChangeLog (206146 => 206147)
--- trunk/Source/_javascript_Core/ChangeLog 2016-09-20 15:26:19 UTC (rev 206146)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-09-20 15:45:43 UTC (rev 206147)
@@ -1,3 +1,19 @@
+2016-09-20 Yusuke Suzuki <utatane....@gmail.com>
+
+ [JSC] Add `typeof value === "symbol"` handling to bytecode compiler
+ https://bugs.webkit.org/show_bug.cgi?id=162253
+
+ Reviewed by Sam Weinig.
+
+ Add `typeof value === "symbol"` handling to the bytecode compiler.
+ The effect is tiny, but it keeps consistency since the bytecode compiler
+ already has the similar optimization for "string" case.
+
+ * bytecode/SpeculatedType.cpp:
+ (JSC::speculationFromJSType):
+ * bytecompiler/BytecodeGenerator.cpp:
+ (JSC::BytecodeGenerator::emitEqualityOp):
+
2016-09-19 Saam Barati <sbar...@apple.com>
Make HasOwnProperty faster
Modified: trunk/Source/_javascript_Core/bytecode/SpeculatedType.cpp (206146 => 206147)
--- trunk/Source/_javascript_Core/bytecode/SpeculatedType.cpp 2016-09-20 15:26:19 UTC (rev 206146)
+++ trunk/Source/_javascript_Core/bytecode/SpeculatedType.cpp 2016-09-20 15:45:43 UTC (rev 206147)
@@ -476,6 +476,8 @@
switch (type) {
case StringType:
return SpecString;
+ case SymbolType:
+ return SpecSymbol;
case ArrayType:
return SpecArray;
case DerivedArrayType:
Modified: trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp (206146 => 206147)
--- trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp 2016-09-20 15:26:19 UTC (rev 206146)
+++ trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp 2016-09-20 15:45:43 UTC (rev 206147)
@@ -1665,6 +1665,14 @@
instructions().append(StringType);
return dst;
}
+ if (value == "symbol") {
+ rewindUnaryOp();
+ emitOpcode(op_is_cell_with_type);
+ instructions().append(dst->index());
+ instructions().append(srcIndex);
+ instructions().append(SymbolType);
+ return dst;
+ }
if (value == "object") {
rewindUnaryOp();
emitOpcode(op_is_object_or_null);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes