Changeset 167220 in webkit


Ignore:
Timestamp:
Apr 14, 2014 1:46:27 AM (10 years ago)
Author:
benjamin@webkit.org
Message:

[JSC] Improve the call site of string comparison in some hot path
https://bugs.webkit.org/show_bug.cgi?id=131605

Reviewed by Darin Adler.

Source/JavaScriptCore:

When resolved, the String of a JSString is never null. It can be empty but not null.
The null value is reserved for ropes but those would be resolved when getting the value.

Consequently, we should use the equal() operation that do not handle null values.
Using the StringImpl directly is already common in StringPrototype but it was not used here for some reason.

  • jit/JITOperations.cpp:
  • runtime/JSCJSValueInlines.h:

(JSC::JSValue::equalSlowCaseInline):
(JSC::JSValue::strictEqualSlowCaseInline):
(JSC::JSValue::pureStrictEqual):

Source/WebCore:

  • dom/NodeRareData.h:

(WebCore::NodeListsNodeData::NodeListCacheMapEntryHash::equal):
We should use the right comparison operation depending on the Hash Traits.

Source/WTF:

  • wtf/text/StringImpl.cpp:

(WTF::stringImplContentEqual):
Inline that function to reduce the call overhead for JSC.
This is only inlined twice, it is not catastrophic for our binary.

Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r167199 r167220  
     12014-04-14  Benjamin Poulain  <benjamin@webkit.org>
     2
     3        [JSC] Improve the call site of string comparison in some hot path
     4        https://bugs.webkit.org/show_bug.cgi?id=131605
     5
     6        Reviewed by Darin Adler.
     7
     8        When resolved, the String of a JSString is never null. It can be empty but not null.
     9        The null value is reserved for ropes but those would be resolved when getting the value.
     10
     11        Consequently, we should use the equal() operation that do not handle null values.
     12        Using the StringImpl directly is already common in StringPrototype but it was not used here for some reason.
     13
     14        * jit/JITOperations.cpp:
     15        * runtime/JSCJSValueInlines.h:
     16        (JSC::JSValue::equalSlowCaseInline):
     17        (JSC::JSValue::strictEqualSlowCaseInline):
     18        (JSC::JSValue::pureStrictEqual):
     19
    1202014-04-08  Oliver Hunt  <oliver@apple.com>
    221
  • trunk/Source/JavaScriptCore/jit/JITOperations.cpp

    r167036 r167220  
    913913    NativeCallFrameTracer tracer(vm, exec);
    914914
    915     bool result = asString(left)->value(exec) == asString(right)->value(exec);
     915    bool result = WTF::equal(*asString(left)->value(exec).impl(), *asString(right)->value(exec).impl());
    916916#if USE(JSVALUE64)
    917917    return JSValue::encode(jsBoolean(result));
  • trunk/Source/JavaScriptCore/runtime/JSCJSValueInlines.h

    r164764 r167220  
    3131#include "JSCellInlines.h"
    3232#include "JSFunction.h"
     33#include <wtf/text/StringImpl.h>
    3334
    3435namespace JSC {
     
    739740        bool s2 = v2.isString();
    740741        if (s1 && s2)
    741             return asString(v1)->value(exec) == asString(v2)->value(exec);
     742            return WTF::equal(*asString(v1)->value(exec).impl(), *asString(v2)->value(exec).impl());
    742743
    743744        if (v1.isUndefinedOrNull()) {
     
    801802
    802803    if (v1.asCell()->isString() && v2.asCell()->isString())
    803         return asString(v1)->value(exec) == asString(v2)->value(exec);
     804        return WTF::equal(*asString(v1)->value(exec).impl(), *asString(v2)->value(exec).impl());
    804805
    805806    return v1 == v2;
     
    836837        if (!v1String || !v2String)
    837838            return MixedTriState;
    838         return triState(WTF::equal(v1String, v2String));
     839        return triState(WTF::equal(*v1String, *v2String));
    839840    }
    840841   
  • trunk/Source/WTF/ChangeLog

    r167206 r167220  
     12014-04-14  Benjamin Poulain  <benjamin@webkit.org>
     2
     3        [JSC] Improve the call site of string comparison in some hot path
     4        https://bugs.webkit.org/show_bug.cgi?id=131605
     5
     6        Reviewed by Darin Adler.
     7
     8        * wtf/text/StringImpl.cpp:
     9        (WTF::stringImplContentEqual):
     10        Inline that function to reduce the call overhead for JSC.
     11        This is only inlined twice, it is not catastrophic for our binary.
     12
    1132014-04-13  Andy Estes  <aestes@apple.com>
    214
  • trunk/Source/WTF/wtf/text/StringImpl.cpp

    r166120 r167220  
    17651765}
    17661766
    1767 static inline bool stringImplContentEqual(const StringImpl& a, const StringImpl& b)
     1767static ALWAYS_INLINE bool stringImplContentEqual(const StringImpl& a, const StringImpl& b)
    17681768{
    17691769    unsigned aLength = a.length();
  • trunk/Source/WebCore/ChangeLog

    r167219 r167220  
     12014-04-14  Benjamin Poulain  <benjamin@webkit.org>
     2
     3        [JSC] Improve the call site of string comparison in some hot path
     4        https://bugs.webkit.org/show_bug.cgi?id=131605
     5
     6        Reviewed by Darin Adler.
     7
     8        * dom/NodeRareData.h:
     9        (WebCore::NodeListsNodeData::NodeListCacheMapEntryHash::equal):
     10        We should use the right comparison operation depending on the Hash Traits.
     11
    1122014-04-14  Andreas Kling  <akling@apple.com>
    213
  • trunk/Source/WebCore/dom/NodeRareData.h

    r166461 r167220  
    109109            return DefaultHash<StringType>::Hash::hash(entry.second) + entry.first;
    110110        }
    111         static bool equal(const std::pair<unsigned char, StringType>& a, const std::pair<unsigned char, StringType>& b) { return a == b; }
     111        static bool equal(const std::pair<unsigned char, StringType>& a, const std::pair<unsigned char, StringType>& b) { return a.first == b.first && DefaultHash<StringType>::Hash::equal(a.second, b.second); }
    112112        static const bool safeToCompareToEmptyOrDeleted = DefaultHash<StringType>::Hash::safeToCompareToEmptyOrDeleted;
    113113    };
Note: See TracChangeset for help on using the changeset viewer.