Changeset 205753 in webkit


Ignore:
Timestamp:
Sep 9, 2016 11:04:19 AM (8 years ago)
Author:
sbarati@apple.com
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):

Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r205746 r205753  
     12016-09-09  Saam Barati  <sbarati@apple.com>
     2
     3        Make hasOwnProperty ALWAYS_INLINE
     4        https://bugs.webkit.org/show_bug.cgi?id=161775
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Speedometer spends around 2.5% of its time in hasOwnProperty.
     9        Let's reduce the overhead of calling that function by marking
     10        it as inline. Also, it's likely that the function will call into
     11        JSObject::getOwnPropertySlot. I added a check to see if that's
     12        the function we're calling, if it is, we do a direct call instead
     13        of an indirect call.
     14
     15        * runtime/JSObject.cpp:
     16        (JSC::JSObject::hasOwnProperty): Deleted.
     17        * runtime/JSObjectInlines.h:
     18        (JSC::JSObject::hasOwnProperty):
     19
    1202016-09-09  Filip Pizlo  <fpizlo@apple.com>
    221
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r205670 r205753  
    14661466
    14671467    return true;
    1468 }
    1469 
    1470 // HasOwnProperty(O, P) from section 7.3.11 in the spec.
    1471 // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-hasownproperty
    1472 bool JSObject::hasOwnProperty(ExecState* exec, PropertyName propertyName) const
    1473 {
    1474     PropertySlot slot(this, PropertySlot::InternalMethodType::GetOwnProperty);
    1475     return const_cast<JSObject*>(this)->methodTable(exec->vm())->getOwnPropertySlot(const_cast<JSObject*>(this), exec, propertyName, slot);
    1476 }
    1477 
    1478 bool JSObject::hasOwnProperty(ExecState* exec, unsigned propertyName) const
    1479 {
    1480     PropertySlot slot(this, PropertySlot::InternalMethodType::GetOwnProperty);
    1481     return const_cast<JSObject*>(this)->methodTable(exec->vm())->getOwnPropertySlotByIndex(const_cast<JSObject*>(this), exec, propertyName, slot);
    14821468}
    14831469
  • trunk/Source/JavaScriptCore/runtime/JSObjectInlines.h

    r205569 r205753  
    198198}
    199199
     200// HasOwnProperty(O, P) from section 7.3.11 in the spec.
     201// http://www.ecma-international.org/ecma-262/6.0/index.html#sec-hasownproperty
     202ALWAYS_INLINE bool JSObject::hasOwnProperty(ExecState* exec, PropertyName propertyName) const
     203{
     204    PropertySlot slot(this, PropertySlot::InternalMethodType::GetOwnProperty);
     205    if (LIKELY(const_cast<JSObject*>(this)->methodTable(exec->vm())->getOwnPropertySlot == JSObject::getOwnPropertySlot))
     206        return JSObject::getOwnPropertySlot(const_cast<JSObject*>(this), exec, propertyName, slot);
     207    return const_cast<JSObject*>(this)->methodTable(exec->vm())->getOwnPropertySlot(const_cast<JSObject*>(this), exec, propertyName, slot);
     208}
     209
     210ALWAYS_INLINE bool JSObject::hasOwnProperty(ExecState* exec, unsigned propertyName) const
     211{
     212    PropertySlot slot(this, PropertySlot::InternalMethodType::GetOwnProperty);
     213    return const_cast<JSObject*>(this)->methodTable(exec->vm())->getOwnPropertySlotByIndex(const_cast<JSObject*>(this), exec, propertyName, slot);
     214}
     215
    200216} // namespace JSC
    201217
Note: See TracChangeset for help on using the changeset viewer.