Changeset 62367 in webkit for trunk/JavaScriptCore/runtime


Ignore:
Timestamp:
Jul 1, 2010, 11:31:27 PM (15 years ago)
Author:
[email protected]
Message:

2010-07-01 Oliver Hunt <[email protected]>

Reviewed by Maciej Stachowiak.

Add a FixedArray template to encapsulate fixed length arrays
https://bugs.webkit.org/show_bug.cgi?id=41506

This new type is used in place of fixed length C arrays so
that debug builds can guard against attempts to go beyond
the end of the array.

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • bytecode/Opcode.cpp: (JSC::OpcodeStats::~OpcodeStats):
  • pcre/pcre_compile.cpp: (calculateCompiledPatternLength):
  • runtime/Collector.cpp: (JSC::Heap::allocateBlock): (JSC::Heap::allocate):
  • runtime/Collector.h: (JSC::CollectorBitmap::clearAll):
  • runtime/CollectorHeapIterator.h: (JSC::CollectorHeapIterator::operator*):
  • runtime/DateInstanceCache.h:
  • runtime/JSString.cpp: (JSC::JSString::replaceCharacter):
  • runtime/JSString.h: (JSC::RopeBuilder::JSStringFinalizerStruct::):
  • runtime/NumericStrings.h:
  • runtime/RegExpCache.h:
  • runtime/SmallStrings.h: (JSC::SmallStrings::singleCharacterStrings):
  • wtf/AVLTree.h:
  • wtf/FixedArray.h: Added. (WTF::FixedArray::operator[]): (WTF::FixedArray::data):

2010-07-01 Oliver Hunt <[email protected]>

Reviewed by Maciej Stachowiak.

Add a FixedArray template to encapsulate fixed length arrays
https://bugs.webkit.org/show_bug.cgi?id=41506

Add forwarding header.

  • ForwardingHeaders/wtf/FixedArray.h: Added.

2010-07-01 Oliver Hunt <[email protected]>

Reviewed by Maciej Stachowiak.

Add a FixedArray template to encapsulate fixed length arrays
https://bugs.webkit.org/show_bug.cgi?id=41506

Add forwarding header, and replace a few fixed length arrays
with the new FixedArray type.

  • ForwardingHeaders/wtf/FixedArray.h: Added.
  • dom/Document.h:
  • platform/graphics/GlyphMetricsMap.h:
Location:
trunk/JavaScriptCore/runtime
Files:
9 edited

Legend:

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

    r62254 r62367  
    246246    Structure* dummyMarkableCellStructure = m_globalData->dummyMarkableCellStructure.get();
    247247    for (size_t i = 0; i < HeapConstants::cellsPerBlock; ++i)
    248         new (block->cells + i) JSCell(dummyMarkableCellStructure);
     248        new (&block->cells[i]) JSCell(dummyMarkableCellStructure);
    249249   
    250250    // Add block to blocks vector.
     
    385385            ASSERT(m_heap.nextCell < HeapConstants::cellsPerBlock);
    386386            if (!block->marked.get(m_heap.nextCell)) { // Always false for the last cell in the block
    387                 Cell* cell = block->cells + m_heap.nextCell;
     387                Cell* cell = &block->cells[m_heap.nextCell];
    388388
    389389                m_heap.operationInProgress = Allocation;
  • trunk/JavaScriptCore/runtime/Collector.h

    r60323 r62367  
    2525#include <stddef.h>
    2626#include <string.h>
     27#include <wtf/FixedArray.h>
    2728#include <wtf/HashCountedSet.h>
    2829#include <wtf/HashSet.h>
     
    216217
    217218    struct CollectorBitmap {
    218         uint32_t bits[BITMAP_WORDS];
     219        FixedArray<uint32_t, BITMAP_WORDS> bits;
    219220        bool get(size_t n) const { return !!(bits[n >> 5] & (1 << (n & 0x1F))); }
    220221        void set(size_t n) { bits[n >> 5] |= (1 << (n & 0x1F)); }
    221222        void clear(size_t n) { bits[n >> 5] &= ~(1 << (n & 0x1F)); }
    222         void clearAll() { memset(bits, 0, sizeof(bits)); }
     223        void clearAll() { memset(bits.data(), 0, sizeof(bits)); }
    223224        ALWAYS_INLINE void advanceToNextPossibleFreeCell(size_t& startCell)
    224225        {
     
    249250 
    250251    struct CollectorCell {
    251         double memory[CELL_ARRAY_LENGTH];
     252        FixedArray<double, CELL_ARRAY_LENGTH> memory;
    252253    };
    253254
    254255    class CollectorBlock {
    255256    public:
    256         CollectorCell cells[CELLS_PER_BLOCK];
     257        FixedArray<CollectorCell, CELLS_PER_BLOCK> cells;
    257258        CollectorBitmap marked;
    258259        Heap* heap;
  • trunk/JavaScriptCore/runtime/CollectorHeapIterator.h

    r54672 r62367  
    7878    inline JSCell* CollectorHeapIterator::operator*() const
    7979    {
    80         return reinterpret_cast<JSCell*>(m_heap.blocks[m_block]->cells + m_cell);
     80        return reinterpret_cast<JSCell*>(&m_heap.blocks[m_block]->cells[m_cell]);
    8181    }
    8282   
  • trunk/JavaScriptCore/runtime/DateInstanceCache.h

    r50709 r62367  
    8787        CacheEntry& lookup(double d) { return m_cache[WTF::FloatHash<double>::hash(d) & (cacheSize - 1)]; }
    8888
    89         CacheEntry m_cache[cacheSize];
     89        FixedArray<CacheEntry, cacheSize> m_cache;
    9090    };
    9191
  • trunk/JavaScriptCore/runtime/JSString.cpp

    r61750 r62367  
    121121    UStringImpl* matchString = 0;
    122122    int matchPosition = -1;
    123     for (RopeIterator it(m_other.m_fibers, m_fiberCount); it != end; ++it) {
     123    for (RopeIterator it(m_other.m_fibers.data(), m_fiberCount); it != end; ++it) {
    124124        ++fiberCount;
    125125        if (matchString)
     
    140140        return throwOutOfMemoryError(exec);
    141141
    142     for (RopeIterator it(m_other.m_fibers, m_fiberCount); it != end; ++it) {
     142    for (RopeIterator it(m_other.m_fibers.data(), m_fiberCount); it != end; ++it) {
    143143        UStringImpl* string = *it;
    144144        if (string != matchString) {
  • trunk/JavaScriptCore/runtime/JSString.h

    r60392 r62367  
    418418            JSStringFinalizerStruct() : m_finalizerCallback(0) {}
    419419            union {
    420                 mutable RopeImpl::Fiber m_fibers[s_maxInternalRopeLength];
     420                mutable FixedArray<RopeImpl::Fiber, s_maxInternalRopeLength> m_fibers;
    421421                struct {
    422422                    JSStringFinalizerCallback m_finalizerCallback;
  • trunk/JavaScriptCore/runtime/NumericStrings.h

    r55599 r62367  
    2828
    2929#include "UString.h"
     30#include <wtf/FixedArray.h>
    3031#include <wtf/HashFunctions.h>
    3132
     
    8788        }
    8889
    89         CacheEntry<double> doubleCache[cacheSize];
    90         CacheEntry<int> intCache[cacheSize];
    91         CacheEntry<unsigned> unsignedCache[cacheSize];
    92         UString smallIntCache[cacheSize];
     90        FixedArray<CacheEntry<double>, cacheSize> doubleCache;
     91        FixedArray<CacheEntry<int>, cacheSize> intCache;
     92        FixedArray<CacheEntry<unsigned>, cacheSize> unsignedCache;
     93        FixedArray<UString, cacheSize> smallIntCache;
    9394    };
    9495
  • trunk/JavaScriptCore/runtime/RegExpCache.h

    r61927 r62367  
    4646
    4747    typedef HashMap<RegExpKey, RefPtr<RegExp> > RegExpCacheMap;
    48     RegExpKey patternKeyArray[maxCacheableEntries];
     48    FixedArray<RegExpKey, maxCacheableEntries> patternKeyArray;
    4949    RegExpCacheMap m_cacheMap;
    5050    JSGlobalData* m_globalData;
  • trunk/JavaScriptCore/runtime/SmallStrings.h

    r58317 r62367  
    2828
    2929#include "UString.h"
     30#include <wtf/FixedArray.h>
    3031#include <wtf/OwnPtr.h>
    3132
     
    6263        unsigned count() const;
    6364#if ENABLE(JIT)
    64         JSString** singleCharacterStrings() { return m_singleCharacterStrings; }
     65        JSString** singleCharacterStrings() { return m_singleCharacterStrings.data(); }
    6566#endif
    6667    private:
     
    6970
    7071        JSString* m_emptyString;
    71         JSString* m_singleCharacterStrings[0x100];
     72        FixedArray<JSString*, 0x100> m_singleCharacterStrings;
    7273        OwnPtr<SmallStringsStorage> m_storage;
    7374    };
Note: See TracChangeset for help on using the changeset viewer.