Title: [205753] trunk/Source/_javascript_Core
Revision
205753
Author
[email protected]
Date
2016-09-09 11:04:19 -0700 (Fri, 09 Sep 2016)

Log Message

Make hasOwnProperty ALWAYS_INLINE
https://bugs.webkit.org/show_bug.cgi?id=161775

Reviewed by Ryosuke Niwa.

Speedometer spends around 2.5% of its time in hasOwnProperty.
Let's reduce the overhead of calling that function by marking
it as inline. Also, it's likely that the function will call into
JSObject::getOwnPropertySlot. I added a check to see if that's
the function we're calling, if it is, we do a direct call instead
of an indirect call.

* runtime/JSObject.cpp:
(JSC::JSObject::hasOwnProperty): Deleted.
* runtime/JSObjectInlines.h:
(JSC::JSObject::hasOwnProperty):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (205752 => 205753)


--- trunk/Source/_javascript_Core/ChangeLog	2016-09-09 17:56:10 UTC (rev 205752)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-09-09 18:04:19 UTC (rev 205753)
@@ -1,3 +1,22 @@
+2016-09-09  Saam Barati  <[email protected]>
+
+        Make hasOwnProperty ALWAYS_INLINE
+        https://bugs.webkit.org/show_bug.cgi?id=161775
+
+        Reviewed by Ryosuke Niwa.
+
+        Speedometer spends around 2.5% of its time in hasOwnProperty.
+        Let's reduce the overhead of calling that function by marking
+        it as inline. Also, it's likely that the function will call into
+        JSObject::getOwnPropertySlot. I added a check to see if that's
+        the function we're calling, if it is, we do a direct call instead
+        of an indirect call.
+
+        * runtime/JSObject.cpp:
+        (JSC::JSObject::hasOwnProperty): Deleted.
+        * runtime/JSObjectInlines.h:
+        (JSC::JSObject::hasOwnProperty):
+
 2016-09-09  Filip Pizlo  <[email protected]>
 
         HashMapImpl needs to m_buffer.clear() in its constructor

Modified: trunk/Source/_javascript_Core/runtime/JSObject.cpp (205752 => 205753)


--- trunk/Source/_javascript_Core/runtime/JSObject.cpp	2016-09-09 17:56:10 UTC (rev 205752)
+++ trunk/Source/_javascript_Core/runtime/JSObject.cpp	2016-09-09 18:04:19 UTC (rev 205753)
@@ -1467,20 +1467,6 @@
     return true;
 }
 
-// HasOwnProperty(O, P) from section 7.3.11 in the spec.
-// http://www.ecma-international.org/ecma-262/6.0/index.html#sec-hasownproperty
-bool JSObject::hasOwnProperty(ExecState* exec, PropertyName propertyName) const
-{
-    PropertySlot slot(this, PropertySlot::InternalMethodType::GetOwnProperty);
-    return const_cast<JSObject*>(this)->methodTable(exec->vm())->getOwnPropertySlot(const_cast<JSObject*>(this), exec, propertyName, slot);
-}
-
-bool JSObject::hasOwnProperty(ExecState* exec, unsigned propertyName) const
-{
-    PropertySlot slot(this, PropertySlot::InternalMethodType::GetOwnProperty);
-    return const_cast<JSObject*>(this)->methodTable(exec->vm())->getOwnPropertySlotByIndex(const_cast<JSObject*>(this), exec, propertyName, slot);
-}
-
 bool JSObject::deletePropertyByIndex(JSCell* cell, ExecState* exec, unsigned i)
 {
     JSObject* thisObject = jsCast<JSObject*>(cell);

Modified: trunk/Source/_javascript_Core/runtime/JSObjectInlines.h (205752 => 205753)


--- trunk/Source/_javascript_Core/runtime/JSObjectInlines.h	2016-09-09 17:56:10 UTC (rev 205752)
+++ trunk/Source/_javascript_Core/runtime/JSObjectInlines.h	2016-09-09 18:04:19 UTC (rev 205753)
@@ -197,6 +197,22 @@
     return thisObject->putInlineSlow(exec, propertyName, value, slot);
 }
 
+// HasOwnProperty(O, P) from section 7.3.11 in the spec.
+// http://www.ecma-international.org/ecma-262/6.0/index.html#sec-hasownproperty
+ALWAYS_INLINE bool JSObject::hasOwnProperty(ExecState* exec, PropertyName propertyName) const
+{
+    PropertySlot slot(this, PropertySlot::InternalMethodType::GetOwnProperty);
+    if (LIKELY(const_cast<JSObject*>(this)->methodTable(exec->vm())->getOwnPropertySlot == JSObject::getOwnPropertySlot))
+        return JSObject::getOwnPropertySlot(const_cast<JSObject*>(this), exec, propertyName, slot);
+    return const_cast<JSObject*>(this)->methodTable(exec->vm())->getOwnPropertySlot(const_cast<JSObject*>(this), exec, propertyName, slot);
+}
+
+ALWAYS_INLINE bool JSObject::hasOwnProperty(ExecState* exec, unsigned propertyName) const
+{
+    PropertySlot slot(this, PropertySlot::InternalMethodType::GetOwnProperty);
+    return const_cast<JSObject*>(this)->methodTable(exec->vm())->getOwnPropertySlotByIndex(const_cast<JSObject*>(this), exec, propertyName, slot);
+}
+
 } // namespace JSC
 
 #endif // JSObjectInlines_h
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to