Ignore:
Timestamp:
Mar 12, 2010, 3:49:05 PM (15 years ago)
Author:
[email protected]
Message:

Bug 36075 - Clean up screwyness re static string impls & Identifiers.

Reviewed by Oliver Hunt.

JavaScriptCore:

  • API/JSClassRef.cpp:

(OpaqueJSClass::~OpaqueJSClass): Classname may be null/empty, and these are an identifer. This is okay, since the null/empty strings are shared across all threads.

(JSC::Identifier::add): No need to explicitly hash null reps, this is done in the ststic UStringImpl constructor.
(JSC::Identifier::addSlowCase): UStringImpl::empty() handled & checkCurrentIdentifierTable now called in the header.
(JSC::Identifier::checkCurrentIdentifierTable): Replaces checkSameIdentifierTable (this no longer checked the rep since the identifierTable pointer was removed from UString::Rep long ago).

  • runtime/Identifier.h:

(JSC::Identifier::add): Replace call to checkSameIdentifierTable with call to checkCurrentIdentifierTable at head of function.

  • runtime/UStringImpl.cpp:

(JSC::UStringImpl::~UStringImpl): Remove call to checkConsistency - this function no longer checks anything interesting.

  • runtime/UStringImpl.h:

(JSC::UStringOrRopeImpl::UStringOrRopeImpl): Set s_refCountFlagIsIdentifier in static constructor.
(JSC::UStringImpl::UStringImpl): remove calls to checkConsistency (see above), add new ASSERT to substring constructor.
(JSC::UStringImpl::setHash): ASSERT not static (static strings set the hash in their constructor, should not reach this code path).
(JSC::UStringImpl::create): Add missing ASSERT.
(JSC::UStringImpl::setIsIdentifier): ASSERT !isStatic() (static strings hash set in constructor).

WebCore:

  • platform/text/StringImpl.cpp:

(WebCore::StringImpl::~StringImpl): Add ASSERT
(WebCore::StringImpl::sharedBuffer): Add ASSERT

  • platform/text/StringImpl.h:

(WebCore::StringImpl::setHash): Add ASSERT
(WebCore::StringImpl::isStatic): added.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/Identifier.cpp

    r55878 r55943  
    125125PassRefPtr<UString::Rep> Identifier::add(JSGlobalData* globalData, const char* c)
    126126{
    127     if (!c) {
    128         UString::Rep* rep = UString::null().rep();
    129         rep->hash();
    130         return rep;
    131     }
     127    if (!c)
     128        return UString::null().rep();
    132129    if (!c[0])
    133130        return UString::Rep::empty();
     
    210207{
    211208    ASSERT(!r->isIdentifier());
     209    // The empty & null strings are static singletons, and static strings are handled
     210    // in ::add() in the header, so we should never get here with a zero length string.
     211    ASSERT(r->length());
     212
    212213    if (r->length() == 1) {
    213214        UChar c = r->characters()[0];
    214215        if (c <= 0xFF)
    215216            r = globalData->smallStrings.singleCharacterStringRep(c);
    216             if (r->isIdentifier()) {
    217 #ifndef NDEBUG
    218                 checkSameIdentifierTable(globalData, r);
    219 #endif
     217            if (r->isIdentifier())
    220218                return r;
    221             }
    222     }
    223     if (!r->length())
    224         return UString::Rep::empty();
     219    }
     220
    225221    return *globalData->identifierTable->add(r).first;
    226222}
     
    253249#ifndef NDEBUG
    254250
    255 void Identifier::checkSameIdentifierTable(ExecState* exec, UString::Rep*)
    256 {
    257     ASSERT_UNUSED(exec, exec->globalData().identifierTable == currentIdentifierTable());
    258 }
    259 
    260 void Identifier::checkSameIdentifierTable(JSGlobalData* globalData, UString::Rep*)
    261 {
     251void Identifier::checkCurrentIdentifierTable(JSGlobalData* globalData)
     252{
     253    // Check the identifier table accessible through the threadspecific matches the
     254    // globalData's identifier table.
    262255    ASSERT_UNUSED(globalData, globalData->identifierTable == currentIdentifierTable());
    263256}
    264257
     258void Identifier::checkCurrentIdentifierTable(ExecState* exec)
     259{
     260    checkCurrentIdentifierTable(&exec->globalData());
     261}
     262
    265263#else
    266264
    267 void Identifier::checkSameIdentifierTable(ExecState*, UString::Rep*)
    268 {
    269 }
    270 
    271 void Identifier::checkSameIdentifierTable(JSGlobalData*, UString::Rep*)
    272 {
    273 }
     265// These only exists so that our exports are the same for debug and release builds.
     266// This would be an ASSERT_NOT_REACHED(), but we're in NDEBUG only code here!
     267void Identifier::checkCurrentIdentifierTable(JSGlobalData*) { CRASH(); }
     268void Identifier::checkCurrentIdentifierTable(ExecState*) { CRASH(); }
    274269
    275270#endif
Note: See TracChangeset for help on using the changeset viewer.