Ignore:
Timestamp:
Jan 14, 2010, 10:43:21 PM (15 years ago)
Author:
[email protected]
Message:

JavaScriptCore: Make naming & behaviour of UString[Impl] methods more consistent.
https://bugs.webkit.org/show_bug.cgi?id=33702

Reviewed by Sam Weinig.

UString::create() creates a copy of the UChar* passed, but UStringImpl::create() assumes
that it should assume ownership of the provided buffer (with UString::createNonCopying()
and UStringImpl::createCopying() providing the alternate behaviours). Unify on create()
taking a copy of the provided buffer. For non-copying cases, use the name 'adopt', and
make this method take a Vector<UChar>&. For cases where non-copying construction was being
used, other than from a Vector<UChar>, change the code to allocate the storage along with
the UStringImpl using UStringImpl::createUninitialized(). (The adopt() method also more
closely matches that of WebCore::StringImpl).

Also, UString::createUninitialized() and UStringImpl::createUninitialized() have incompatible
behaviours, in that the UString form sets the provided UChar* to a null or non-null value to
indicate success or failure, but UStringImpl uses the returned PassRefPtr<UStringImpl> to
indicate when allocation has failed (potentially leaving the output Char* uninitialized).
This is also incompatible with WebCore::StringImpl's behaviour, in that
StringImpl::createUninitialized() will CRASH() if unable to allocate. Some uses of
createUninitialized() in JSC are unsafe, since they do not test the result for null.
UStringImpl's indication is preferable, since we may want a successful call to set the result
buffer to 0 (specifically, StringImpl returns 0 for the buffer where createUninitialized()
returns the empty string, which seems reasonable to catch bugs early). UString's method
cannot support UStringImpl's behaviour directly, since it returns an object rather than a
pointer.

  • remove UString::createUninitialized(), replace with calls to UStringImpl::createUninitialized()
  • create a UStringImpl::tryCreateUninitialized() form UStringImpl::createUninitialized(), with current behaviour, make createUninitialized() crash on failure to allocate.
  • make cases in JSC that do not check the result call createUninitialized(), and cases that do check call tryCreateUninitialized().

Rename computedHash() to existingHash(), to bring this in line wih WebCore::StringImpl.

  • API/JSClassRef.cpp:

(OpaqueJSClassContextData::OpaqueJSClassContextData):

(JSC::arrayProtoFuncToString):

  • runtime/Identifier.cpp:

(JSC::CStringTranslator::translate):
(JSC::UCharBufferTranslator::translate):

  • runtime/JSString.cpp:

(JSC::JSString::resolveRope):

  • runtime/Lookup.cpp:

(JSC::HashTable::createTable):

  • runtime/Lookup.h:

(JSC::HashTable::entry):

  • runtime/StringBuilder.h:

(JSC::StringBuilder::release):

  • runtime/StringConstructor.cpp:

(JSC::stringFromCharCodeSlowCase):

  • runtime/StringPrototype.cpp:

(JSC::substituteBackreferencesSlow):
(JSC::stringProtoFuncToLowerCase):
(JSC::stringProtoFuncToUpperCase):
(JSC::stringProtoFuncFontsize):
(JSC::stringProtoFuncLink):

  • runtime/Structure.cpp:

(JSC::Structure::despecifyDictionaryFunction):
(JSC::Structure::get):
(JSC::Structure::despecifyFunction):
(JSC::Structure::put):
(JSC::Structure::remove):
(JSC::Structure::insertIntoPropertyMapHashTable):
(JSC::Structure::checkConsistency):

  • runtime/Structure.h:

(JSC::Structure::get):

  • runtime/StructureTransitionTable.h:

(JSC::StructureTransitionTableHash::hash):

  • runtime/UString.cpp:

(JSC::createRep):
(JSC::UString::UString):
(JSC::UString::spliceSubstringsWithSeparators):
(JSC::UString::replaceRange):
(JSC::UString::operator=):

  • runtime/UString.h:

(JSC::UString::adopt):
(JSC::IdentifierRepHash::hash):
(JSC::makeString):

  • runtime/UStringImpl.h:

(JSC::UStringImpl::adopt):
(JSC::UStringImpl::create):
(JSC::UStringImpl::createUninitialized):
(JSC::UStringImpl::tryCreateUninitialized):
(JSC::UStringImpl::existingHash):

WebCore: Rubber stamped by Sam Weinig.

Make naming & behaviour of UString[Impl] methods more consistent.
https://bugs.webkit.org/show_bug.cgi?id=33702

WebCore change reflecting UString method name change computedHash() -> existingHash().

  • platform/text/AtomicString.cpp:

(WebCore::AtomicString::add):
(WebCore::AtomicString::find):

File:
1 edited

Legend:

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

    r53170 r53320  
    304304    ASSERT(m_propertyTable);
    305305
    306     unsigned i = rep->computedHash();
     306    unsigned i = rep->existingHash();
    307307
    308308#if DUMP_PROPERTYMAP_STATS
     
    322322#endif
    323323
    324     unsigned k = 1 | doubleHash(rep->computedHash());
     324    unsigned k = 1 | doubleHash(rep->existingHash());
    325325
    326326    while (1) {
     
    687687        return notFound;
    688688
    689     unsigned i = rep->computedHash();
     689    unsigned i = rep->existingHash();
    690690
    691691#if DUMP_PROPERTYMAP_STATS
     
    707707#endif
    708708
    709     unsigned k = 1 | doubleHash(rep->computedHash());
     709    unsigned k = 1 | doubleHash(rep->existingHash());
    710710
    711711    while (1) {
     
    738738    UString::Rep* rep = propertyName._ustring.rep();
    739739
    740     unsigned i = rep->computedHash();
     740    unsigned i = rep->existingHash();
    741741
    742742#if DUMP_PROPERTYMAP_STATS
     
    758758#endif
    759759
    760     unsigned k = 1 | doubleHash(rep->computedHash());
     760    unsigned k = 1 | doubleHash(rep->existingHash());
    761761
    762762    while (1) {
     
    807807    // FIXME: Consider a fast case for tables with no deleted sentinels.
    808808
    809     unsigned i = rep->computedHash();
     809    unsigned i = rep->existingHash();
    810810    unsigned k = 0;
    811811    bool foundDeletedElement = false;
     
    830830
    831831        if (k == 0) {
    832             k = 1 | doubleHash(rep->computedHash());
     832            k = 1 | doubleHash(rep->existingHash());
    833833#if DUMP_PROPERTYMAP_STATS
    834834            ++numCollisions;
     
    910910
    911911    // Find the thing to remove.
    912     unsigned i = rep->computedHash();
     912    unsigned i = rep->existingHash();
    913913    unsigned k = 0;
    914914    unsigned entryIndex;
     
    924924
    925925        if (k == 0) {
    926             k = 1 | doubleHash(rep->computedHash());
     926            k = 1 | doubleHash(rep->existingHash());
    927927#if DUMP_PROPERTYMAP_STATS
    928928            ++numCollisions;
     
    968968    ASSERT(m_propertyTable);
    969969
    970     unsigned i = entry.key->computedHash();
     970    unsigned i = entry.key->existingHash();
    971971    unsigned k = 0;
    972972
     
    981981
    982982        if (k == 0) {
    983             k = 1 | doubleHash(entry.key->computedHash());
     983            k = 1 | doubleHash(entry.key->existingHash());
    984984#if DUMP_PROPERTYMAP_STATS
    985985            ++numCollisions;
     
    11791179            continue;
    11801180        ++nonEmptyEntryCount;
    1181         unsigned i = rep->computedHash();
     1181        unsigned i = rep->existingHash();
    11821182        unsigned k = 0;
    11831183        unsigned entryIndex;
     
    11881188                break;
    11891189            if (k == 0)
    1190                 k = 1 | doubleHash(rep->computedHash());
     1190                k = 1 | doubleHash(rep->existingHash());
    11911191            i += k;
    11921192        }
Note: See TracChangeset for help on using the changeset viewer.