Ignore:
Timestamp:
Mar 14, 2011, 3:31:29 PM (14 years ago)
Author:
[email protected]
Message:

2011-03-14 Geoffrey Garen <[email protected]>

Reviewed by Oliver Hunt.

Removed more cases of DeprecatedPtr (exception, SmallStrings)
https://bugs.webkit.org/show_bug.cgi?id=56332

  • runtime/Identifier.cpp: (JSC::Identifier::add): (JSC::Identifier::addSlowCase): Use a variable instead of a hard-coded constant, to make this code less brittle.
  • runtime/JSGlobalData.h: Use HeapRoot instead of DeprecatedPtr because this reference is owned and managed directly by the heap.
  • runtime/JSString.cpp: (JSC::JSString::substringFromRope):
  • runtime/JSString.h: (JSC::jsSingleCharacterString): (JSC::jsSingleCharacterSubstring): (JSC::jsString): (JSC::jsStringWithFinalizer): (JSC::jsSubstring): (JSC::jsOwnedString): Use a variable instead of a hard-coded constant, to make this code less brittle.
  • runtime/SmallStrings.cpp: (JSC::SmallStringsStorage::rep): (JSC::SmallStringsStorage::SmallStringsStorage): (JSC::SmallStrings::SmallStrings): (JSC::SmallStrings::markChildren): (JSC::SmallStrings::clear): (JSC::SmallStrings::count): Use a variable instead of a hard-coded constant, to make this code less brittle.
  • runtime/SmallStrings.h: (JSC::SmallStrings::singleCharacterString): Use HeapRoot instead of DeprecatedPtr because these references are owned and managed directly by the heap.


Stop using FixedArray because we only want a very limited set
of classes to be able to use HeapRoot. (Replaced with manual ASSERTs.)

  • runtime/WriteBarrier.h: (JSC::operator==): (JSC::WriteBarrier::WriteBarrier): (JSC::HeapRoot::HeapRoot): (JSC::HeapRoot::operator=): Added HeapRoot, which is allowed to set without write barrier because we assume all HeapRoots are scanned during all GC passes.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/SmallStrings.cpp

    r77391 r81071  
    3434namespace JSC {
    3535
    36 static const unsigned numCharactersToStore = 0x100;
    37 
    3836static inline bool isMarked(JSCell* string)
    3937{
     
    4644    SmallStringsStorage();
    4745
    48     StringImpl* rep(unsigned char character) { return m_reps[character].get(); }
     46    StringImpl* rep(unsigned char character)
     47    {
     48        return m_reps[character].get();
     49    }
    4950
    5051private:
    51     RefPtr<StringImpl> m_reps[numCharactersToStore];
     52    static const unsigned singleCharacterStringCount = maxSingleCharacterString + 1;
     53
     54    RefPtr<StringImpl> m_reps[singleCharacterStringCount];
    5255};
    5356
     
    5558{
    5659    UChar* characterBuffer = 0;
    57     RefPtr<StringImpl> baseString = StringImpl::createUninitialized(numCharactersToStore, characterBuffer);
    58     for (unsigned i = 0; i < numCharactersToStore; ++i) {
     60    RefPtr<StringImpl> baseString = StringImpl::createUninitialized(singleCharacterStringCount, characterBuffer);
     61    for (unsigned i = 0; i < singleCharacterStringCount; ++i) {
    5962        characterBuffer[i] = i;
    6063        m_reps[i] = StringImpl::create(baseString, i, 1);
     
    6467SmallStrings::SmallStrings()
    6568{
    66     COMPILE_ASSERT(numCharactersToStore == sizeof(m_singleCharacterStrings) / sizeof(m_singleCharacterStrings[0]), IsNumCharactersConstInSyncWithClassUsage);
     69    COMPILE_ASSERT(singleCharacterStringCount == sizeof(m_singleCharacterStrings) / sizeof(m_singleCharacterStrings[0]), IsNumCharactersConstInSyncWithClassUsage);
    6770    clear();
    6871}
     
    8588
    8689    bool isAnyStringMarked = isMarked(m_emptyString.get());
    87     for (unsigned i = 0; i < numCharactersToStore && !isAnyStringMarked; ++i)
     90    for (unsigned i = 0; i < singleCharacterStringCount && !isAnyStringMarked; ++i)
    8891        isAnyStringMarked = isMarked(m_singleCharacterStrings[i].get());
    8992   
     
    9598    if (m_emptyString)
    9699        markStack.append(&m_emptyString);
    97     for (unsigned i = 0; i < numCharactersToStore; ++i) {
     100    for (unsigned i = 0; i < singleCharacterStringCount; ++i) {
    98101        if (m_singleCharacterStrings[i])
    99102            markStack.append(&m_singleCharacterStrings[i]);
     
    104107{
    105108    m_emptyString = 0;
    106     for (unsigned i = 0; i < numCharactersToStore; ++i)
     109    for (unsigned i = 0; i < singleCharacterStringCount; ++i)
    107110        m_singleCharacterStrings[i] = 0;
    108111}
     
    113116    if (m_emptyString)
    114117        ++count;
    115     for (unsigned i = 0; i < numCharactersToStore; ++i) {
     118    for (unsigned i = 0; i < singleCharacterStringCount; ++i) {
    116119        if (m_singleCharacterStrings[i])
    117120            ++count;
Note: See TracChangeset for help on using the changeset viewer.