⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 176622 in webkit


Ignore:
Timestamp:
Dec 1, 2014, 6:21:16 PM (12 years ago)
Author:
akling@apple.com
Message:

Optimize constructing JSC::Identifier from AtomicString.
<https://webkit.org/b/139157>

Reviewed by Michael Saboff.

Source/JavaScriptCore:

Add constructors for Identifier taking AtomicString and AtomicStringImpl.
This avoids branching on the string's isAtomic flag, which is obviously
always true for AtomicString & AtomicStringImpl.

Had to add a Identifier(const char*) constructor to resolve implicit
ambiguity between String / AtomicString.

Also made PrivateName::uid() return AtomicStringImpl* to take advantage
of the new constructor in a few places.

  • runtime/Identifier.h:

(JSC::Identifier::Identifier):

  • runtime/IdentifierInlines.h:

(JSC::Identifier::Identifier):

  • runtime/PrivateName.h:

(JSC::PrivateName::uid):

Source/WTF:

Make AtomicString::isInAtomicStringTable() public so it can be used
in some Identifier assertions.

  • wtf/text/AtomicString.h:
Location:
trunk/Source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r176601 r176622  
     12014-12-01  Andreas Kling  <akling@apple.com>
     2
     3        Optimize constructing JSC::Identifier from AtomicString.
     4        <https://webkit.org/b/139157>
     5
     6        Reviewed by Michael Saboff.
     7
     8        Add constructors for Identifier taking AtomicString and AtomicStringImpl.
     9        This avoids branching on the string's isAtomic flag, which is obviously
     10        always true for AtomicString & AtomicStringImpl.
     11
     12        Had to add a Identifier(const char*) constructor to resolve implicit
     13        ambiguity between String / AtomicString.
     14
     15        Also made PrivateName::uid() return AtomicStringImpl* to take advantage
     16        of the new constructor in a few places.
     17
     18        * runtime/Identifier.h:
     19        (JSC::Identifier::Identifier):
     20        * runtime/IdentifierInlines.h:
     21        (JSC::Identifier::Identifier):
     22        * runtime/PrivateName.h:
     23        (JSC::PrivateName::uid):
     24
    1252014-12-01  Alexey Proskuryakov  <ap@apple.com>
    226
  • trunk/Source/JavaScriptCore/runtime/Identifier.h

    r176583 r176622  
    4545    Identifier(VM* vm, const char (&characters)[charactersCount]) : m_string(add(vm, characters)) { ASSERT(m_string.impl()->isAtomic()); }
    4646
     47    Identifier(ExecState*, AtomicStringImpl*);
     48    Identifier(ExecState*, const AtomicString&);
    4749    Identifier(ExecState* exec, StringImpl* rep) : m_string(add(exec, rep)) { ASSERT(m_string.impl()->isAtomic()); }
    4850    Identifier(ExecState* exec, const String& s) : m_string(add(exec, s.impl())) { ASSERT(m_string.impl()->isAtomic()); }
     51    Identifier(ExecState* exec, const char* s) : Identifier(exec, AtomicString(s)) { }
    4952
    5053    Identifier(VM* vm, const LChar* s, int length) : m_string(add(vm, s, length)) { ASSERT(m_string.impl()->isAtomic()); }
  • trunk/Source/JavaScriptCore/runtime/IdentifierInlines.h

    r165999 r176622  
    3232namespace JSC  {
    3333
     34inline Identifier::Identifier(ExecState* exec, AtomicStringImpl* string)
     35    : m_string(string)
     36{
     37#ifndef NDEBUG
     38    checkCurrentAtomicStringTable(exec);
     39    if (string)
     40        ASSERT_WITH_MESSAGE(!string->length() || AtomicString::isInAtomicStringTable(string), "The atomic string comes from an other thread!");
     41#else
     42    UNUSED_PARAM(exec);
     43#endif
     44}
     45
     46inline Identifier::Identifier(ExecState* exec, const AtomicString& string)
     47    : m_string(string.string())
     48{
     49#ifndef NDEBUG
     50    checkCurrentAtomicStringTable(exec);
     51    if (!string.isNull())
     52        ASSERT_WITH_MESSAGE(!string.length() || AtomicString::isInAtomicStringTable(string.impl()), "The atomic string comes from an other thread!");
     53#else
     54    UNUSED_PARAM(exec);
     55#endif
     56}
     57
    3458inline PassRef<StringImpl> Identifier::add(ExecState* exec, StringImpl* r)
    3559{
  • trunk/Source/JavaScriptCore/runtime/PrivateName.h

    r156910 r176622  
    4343    }
    4444
    45     StringImpl* uid() const { return m_impl.get(); }
     45    AtomicStringImpl* uid() const { return static_cast<AtomicStringImpl*>(m_impl.get()); }
    4646
    4747private:
  • trunk/Source/WTF/ChangeLog

    r176616 r176622  
     12014-12-01  Andreas Kling  <akling@apple.com>
     2
     3        Optimize constructing JSC::Identifier from AtomicString.
     4        <https://webkit.org/b/139157>
     5
     6        Reviewed by Michael Saboff.
     7
     8        Make AtomicString::isInAtomicStringTable() public so it can be used
     9        in some Identifier assertions.
     10
     11        * wtf/text/AtomicString.h:
     12
    1132014-12-01  Oliver Hunt  <oliver@apple.com>
    214
  • trunk/Source/WTF/wtf/text/AtomicString.h

    r176275 r176622  
    205205    }
    206206
     207#if !ASSERT_DISABLED
     208    WTF_EXPORT_STRING_API static bool isInAtomicStringTable(StringImpl*);
     209#endif
     210
    207211private:
    208212    // The explicit constructors with AtomicString::ConstructFromLiteral must be used for literals.
     
    216220    WTF_EXPORT_STRING_API static AtomicStringImpl* findSlowCase(StringImpl&);
    217221    WTF_EXPORT_STRING_API static AtomicString fromUTF8Internal(const char*, const char*);
    218 
    219 #if !ASSERT_DISABLED
    220     WTF_EXPORT_STRING_API static bool isInAtomicStringTable(StringImpl*);
    221 #endif
    222222};
    223223
Note: See TracChangeset for help on using the changeset viewer.