Changeset 279053 in webkit


Ignore:
Timestamp:
Jun 20, 2021 2:48:03 AM (13 months ago)
Author:
ysuzuki@apple.com
Message:

[JSC] Add ValueOf fast path in toPrimitive
https://bugs.webkit.org/show_bug.cgi?id=226948

Reviewed by Ross Kirsling.

JSTests:

  • microbenchmarks/valueof-via-toprimitive.js: Added.

Source/JavaScriptCore:

Add fast path for Object.prototype.valueOf function call since we
sometimes encounter this case in Speedometer2/EmberJS-Debug-TodoMVC.

ToT Patched

value-of-call 65.7169+-0.6192 45.0986+-0.0830 definitely 1.4572x faster

  • runtime/JSCJSValue.cpp:

(JSC::JSValue::toStringSlowCase const):

  • runtime/JSObject.cpp:

(JSC::callToPrimitiveFunction):

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r279013 r279053  
     12021-06-20  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Add ValueOf fast path in toPrimitive
     4        https://bugs.webkit.org/show_bug.cgi?id=226948
     5
     6        Reviewed by Ross Kirsling.
     7
     8        * microbenchmarks/valueof-via-toprimitive.js: Added.
     9
    1102021-06-17  Saam Barati  <sbarati@apple.com>
    211
  • trunk/Source/JavaScriptCore/ChangeLog

    r279052 r279053  
     12021-06-20  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Add ValueOf fast path in toPrimitive
     4        https://bugs.webkit.org/show_bug.cgi?id=226948
     5
     6        Reviewed by Ross Kirsling.
     7
     8        Add fast path for Object.prototype.valueOf function call since we
     9        sometimes encounter this case in Speedometer2/EmberJS-Debug-TodoMVC.
     10
     11                                       ToT                     Patched
     12
     13            value-of-call        65.7169+-0.6192     ^     45.0986+-0.0830        ^ definitely 1.4572x faster
     14
     15        * runtime/JSCJSValue.cpp:
     16        (JSC::JSValue::toStringSlowCase const):
     17        * runtime/JSObject.cpp:
     18        (JSC::callToPrimitiveFunction):
     19
    1202021-06-20  Robin Morisset  <rmorisset@apple.com>
    221
  • trunk/Source/JavaScriptCore/runtime/JSCJSValue.cpp

    r278589 r279053  
    435435    }
    436436
    437     ASSERT(isCell());
    438     JSValue value = asCell()->toPrimitive(globalObject, PreferString);
     437    ASSERT(isObject()); // String, Symbol, and HeapBigInt are already handled.
     438    JSValue value = asObject(asCell())->toPrimitive(globalObject, PreferString);
    439439    RETURN_IF_EXCEPTION(scope, errorValue());
    440440    ASSERT(!value.isObject());
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r278589 r279053  
    22352235    }
    22362236
     2237    if constexpr (key == CachedSpecialPropertyKey::ValueOf) {
     2238        if (function == globalObject->objectProtoValueOfFunction())
     2239            return JSValue();
     2240    }
     2241
    22372242    auto callData = getCallData(vm, function);
    22382243    if (callData.type == CallData::Type::None) {
Note: See TracChangeset for help on using the changeset viewer.