Ignore:
Timestamp:
Apr 14, 2014, 1:46:27 AM (11 years ago)
Author:
[email protected]
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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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   
Note: See TracChangeset for help on using the changeset viewer.