Title: [264397] trunk
Revision
264397
Author
[email protected]
Date
2020-07-15 07:47:44 -0700 (Wed, 15 Jul 2020)

Log Message

Emit HasOwnPropertyFunctionCallDotNode for "Reflect" identifiers
https://bugs.webkit.org/show_bug.cgi?id=214325

Reviewed by Darin Adler and Saam Barati.

JSTests:

* microbenchmarks/has-own-property-for-in-loop-reflect-name.js: Added.
* stress/reflect-has.js:
* stress/reflect.js:

Source/_javascript_Core:

Currently, HasOwnPropertyFunctionCallDotNode is emitted for all ResolveNodes
except ones with "Reflect" identifier. This exception doesn't seem necessary
as ReflectObject inherits ordinary `Object.prototype.hasOwnProperty` method.

This patch removes the exception, advancing provided "Reflect" microbenchmark
by 20%. No behavior change.

* parser/ASTBuilder.h:
(JSC::ASTBuilder::makeFunctionCallNode):

Modified Paths

Added Paths

Diff

Modified: trunk/JSTests/ChangeLog (264396 => 264397)


--- trunk/JSTests/ChangeLog	2020-07-15 14:00:53 UTC (rev 264396)
+++ trunk/JSTests/ChangeLog	2020-07-15 14:47:44 UTC (rev 264397)
@@ -1,3 +1,14 @@
+2020-07-15  Alexey Shvayka  <[email protected]>
+
+        Emit HasOwnPropertyFunctionCallDotNode for "Reflect" identifiers
+        https://bugs.webkit.org/show_bug.cgi?id=214325
+
+        Reviewed by Darin Adler and Saam Barati.
+
+        * microbenchmarks/has-own-property-for-in-loop-reflect-name.js: Added.
+        * stress/reflect-has.js:
+        * stress/reflect.js:
+
 2020-07-14  Saam Barati  <[email protected]>
 
         We must hold the CodeBlock lock when calling StructureStubInfo::reset

Added: trunk/JSTests/microbenchmarks/has-own-property-for-in-loop-reflect-name.js (0 => 264397)


--- trunk/JSTests/microbenchmarks/has-own-property-for-in-loop-reflect-name.js	                        (rev 0)
+++ trunk/JSTests/microbenchmarks/has-own-property-for-in-loop-reflect-name.js	2020-07-15 14:47:44 UTC (rev 264397)
@@ -0,0 +1,28 @@
+function assert(b) {
+    if (!b)
+        throw new Error;
+}
+
+function test1() {
+    function count(Reflect) {
+        let c = 0;
+        for (let p in Reflect) {
+            if (Reflect.hasOwnProperty(p))
+                ++c;
+        }
+        return c;
+    }
+    noInline(count);
+
+    let o = {
+        a:20,
+        b:30,
+        c:40,
+        d:50
+    };
+
+    for (let i = 0; i < 600000; ++i) {
+        assert(count(o) === 4);
+    }
+}
+test1();

Modified: trunk/JSTests/stress/reflect-has.js (264396 => 264397)


--- trunk/JSTests/stress/reflect-has.js	2020-07-15 14:00:53 UTC (rev 264396)
+++ trunk/JSTests/stress/reflect-has.js	2020-07-15 14:47:44 UTC (rev 264397)
@@ -16,6 +16,7 @@
         throw new Error("bad error: " + String(error));
 }
 
+shouldBe(Reflect.hasOwnProperty("has"), true);
 shouldBe(Reflect.has.length, 2);
 
 shouldThrow(() => {

Modified: trunk/JSTests/stress/reflect.js (264396 => 264397)


--- trunk/JSTests/stress/reflect.js	2020-07-15 14:00:53 UTC (rev 264396)
+++ trunk/JSTests/stress/reflect.js	2020-07-15 14:47:44 UTC (rev 264397)
@@ -7,3 +7,4 @@
 shouldBe(Reflect, Reflect);
 shouldBe(Object.getPrototypeOf(Reflect), Object.getPrototypeOf({}));
 shouldBe(Reflect.toString(), "[object Object]");
+shouldBe(Reflect.hasOwnProperty, Object.prototype.hasOwnProperty);

Modified: trunk/Source/_javascript_Core/ChangeLog (264396 => 264397)


--- trunk/Source/_javascript_Core/ChangeLog	2020-07-15 14:00:53 UTC (rev 264396)
+++ trunk/Source/_javascript_Core/ChangeLog	2020-07-15 14:47:44 UTC (rev 264397)
@@ -1,3 +1,20 @@
+2020-07-15  Alexey Shvayka  <[email protected]>
+
+        Emit HasOwnPropertyFunctionCallDotNode for "Reflect" identifiers
+        https://bugs.webkit.org/show_bug.cgi?id=214325
+
+        Reviewed by Darin Adler and Saam Barati.
+
+        Currently, HasOwnPropertyFunctionCallDotNode is emitted for all ResolveNodes
+        except ones with "Reflect" identifier. This exception doesn't seem necessary
+        as ReflectObject inherits ordinary `Object.prototype.hasOwnProperty` method.
+
+        This patch removes the exception, advancing provided "Reflect" microbenchmark
+        by 20%. No behavior change.
+
+        * parser/ASTBuilder.h:
+        (JSC::ASTBuilder::makeFunctionCallNode):
+
 2020-07-15  Yusuke Suzuki  <[email protected]>
 
         [JSC] Introduce JSCTEST_hardTimeout

Modified: trunk/Source/_javascript_Core/parser/ASTBuilder.h (264396 => 264397)


--- trunk/Source/_javascript_Core/parser/ASTBuilder.h	2020-07-15 14:00:53 UTC (rev 264396)
+++ trunk/Source/_javascript_Core/parser/ASTBuilder.h	2020-07-15 14:47:44 UTC (rev 264397)
@@ -1455,7 +1455,7 @@
         && args->m_listNode->m_expr
         && args->m_listNode->m_expr->isResolveNode()
         && !args->m_listNode->m_next
-        && ((dot->base()->isResolveNode() && static_cast<ResolveNode*>(dot->base())->identifier() != m_vm.propertyNames->Reflect) || dot->base()->isThisNode())) {
+        && (dot->base()->isResolveNode() || dot->base()->isThisNode())) {
         // We match the AST pattern:
         // <resolveNode|thisNode>.hasOwnProperty(<resolveNode>)
         // i.e:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to