Ignore:
Timestamp:
Jan 31, 2011, 12:07:21 PM (14 years ago)
Author:
[email protected]
Message:

2011-01-31 Oliver Hunt <[email protected]>

Convert markstack to a slot visitor API
https://bugs.webkit.org/show_bug.cgi?id=53219

rolling r77098, r77099, r77100, r77109, and
r77111 back in, along with a few more Qt fix attempts.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/WeakGCMap.h

    r77125 r77151  
    4747
    4848public:
    49     typedef typename HashMap<KeyType, MappedType>::iterator iterator;
    50     typedef typename HashMap<KeyType, MappedType>::const_iterator const_iterator;
     49    typedef typename HashMap<KeyType, DeprecatedPtr<MappedType> >::iterator iterator;
     50    typedef typename HashMap<KeyType, DeprecatedPtr<MappedType> >::const_iterator const_iterator;
    5151   
    5252    bool isEmpty() { return m_map.isEmpty(); }
    5353    void clear() { m_map.clear(); }
    5454
    55     MappedType get(const KeyType& key) const;
    56     pair<iterator, bool> set(const KeyType&, const MappedType&);
    57     MappedType take(const KeyType& key);
     55    MappedType* get(const KeyType&) const;
     56    pair<iterator, bool> set(const KeyType&, MappedType*);
     57    MappedType* take(const KeyType&);
    5858
    5959    // These unchecked functions provide access to a value even if the value's
     
    6161    // during the GC mark phase, which begins by clearing all mark bits.
    6262
    63     MappedType uncheckedGet(const KeyType& key) const { return m_map.get(key); }
    64     bool uncheckedRemove(const KeyType&, const MappedType&);
     63    MappedType* uncheckedGet(const KeyType& key) const { return m_map.get(key).get(); }
     64    DeprecatedPtr<MappedType>* uncheckedGetSlot(const KeyType& key)
     65    {
     66        iterator iter = m_map.find(key);
     67        if (iter == m_map.end())
     68            return 0;
     69        return &iter->second;
     70    }
     71    bool uncheckedRemove(const KeyType&, MappedType*);
    6572
    6673    iterator uncheckedBegin() { return m_map.begin(); }
     
    7178
    7279private:
    73     HashMap<KeyType, MappedType> m_map;
     80    HashMap<KeyType, DeprecatedPtr<MappedType> > m_map;
    7481};
    7582
    7683template<typename KeyType, typename MappedType>
    77 inline MappedType WeakGCMap<KeyType, MappedType>::get(const KeyType& key) const
     84inline MappedType* WeakGCMap<KeyType, MappedType>::get(const KeyType& key) const
    7885{
    79     MappedType result = m_map.get(key);
    80     if (result == HashTraits<MappedType>::emptyValue())
     86    MappedType* result = m_map.get(key).get();
     87    if (result == HashTraits<MappedType*>::emptyValue())
    8188        return result;
    8289    if (!Heap::isCellMarked(result))
    83         return HashTraits<MappedType>::emptyValue();
     90        return HashTraits<MappedType*>::emptyValue();
    8491    return result;
    8592}
    8693
    8794template<typename KeyType, typename MappedType>
    88 MappedType WeakGCMap<KeyType, MappedType>::take(const KeyType& key)
     95MappedType* WeakGCMap<KeyType, MappedType>::take(const KeyType& key)
    8996{
    90     MappedType result = m_map.take(key);
    91     if (result == HashTraits<MappedType>::emptyValue())
     97    MappedType* result = m_map.take(key).get();
     98    if (result == HashTraits<MappedType*>::emptyValue())
    9299        return result;
    93100    if (!Heap::isCellMarked(result))
    94         return HashTraits<MappedType>::emptyValue();
     101        return HashTraits<MappedType*>::emptyValue();
    95102    return result;
    96103}
    97104
    98105template<typename KeyType, typename MappedType>
    99 pair<typename HashMap<KeyType, MappedType>::iterator, bool> WeakGCMap<KeyType, MappedType>::set(const KeyType& key, const MappedType& value)
     106pair<typename WeakGCMap<KeyType, MappedType>::iterator, bool> WeakGCMap<KeyType, MappedType>::set(const KeyType& key, MappedType* value)
    100107{
    101108    Heap::markCell(value); // If value is newly allocated, it's not marked, so mark it now.
    102109    pair<iterator, bool> result = m_map.add(key, value);
    103110    if (!result.second) { // pre-existing entry
    104         result.second = !Heap::isCellMarked(result.first->second);
     111        result.second = !Heap::isCellMarked(result.first->second.get());
    105112        result.first->second = value;
    106113    }
     
    109116
    110117template<typename KeyType, typename MappedType>
    111 bool WeakGCMap<KeyType, MappedType>::uncheckedRemove(const KeyType& key, const MappedType& value)
     118bool WeakGCMap<KeyType, MappedType>::uncheckedRemove(const KeyType& key, MappedType* value)
    112119{
    113120    iterator it = m_map.find(key);
    114121    if (it == m_map.end())
    115122        return false;
    116     if (it->second != value)
     123    if (it->second.get() != value)
    117124        return false;
    118125    m_map.remove(it);
Note: See TracChangeset for help on using the changeset viewer.