Ignore:
Timestamp:
Mar 7, 2015, 2:20:54 PM (10 years ago)
Author:
[email protected]
Message:

Unreviewed, rolling out r181010.
https://bugs.webkit.org/show_bug.cgi?id=142442

Broke media/video-src-invalid-poster.html (Requested by kling
on #webkit).

Reverted changeset:

"Stale entries in WeakGCMaps are keeping tons of WeakBlocks
alive unnecessarily."
https://bugs.webkit.org/show_bug.cgi?id=142115
http://trac.webkit.org/changeset/181010

File:
1 edited

Legend:

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

    r181010 r181214  
    11/*
    2  * Copyright (C) 2009, 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2009 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4848    typedef typename HashMapType::const_iterator const_iterator;
    4949
    50     explicit WeakGCMap(VM&);
    51     ~WeakGCMap();
     50    WeakGCMap()
     51        : m_gcThreshold(minGCThreshold)
     52    {
     53    }
    5254
    5355    ValueArg* get(const KeyType& key) const
     
    5860    AddResult set(const KeyType& key, ValueType value)
    5961    {
     62        gcMapIfNeeded();
    6063        return m_map.set(key, WTF::move(value));
    6164    }
     
    6366    ALWAYS_INLINE AddResult add(const KeyType& key, ValueType value)
    6467    {
     68        gcMapIfNeeded();
    6569        AddResult addResult = m_map.fastAdd(key, nullptr);
    6670        if (!addResult.iterator->value) { // New value or found a zombie value.
     
    100104    }
    101105
    102     void pruneStaleEntries();
     106private:
     107    static const int minGCThreshold = 3;
    103108
    104 private:
     109    NEVER_INLINE void gcMap()
     110    {
     111        Vector<KeyType, 4> zombies;
     112
     113        for (iterator it = m_map.begin(), end = m_map.end(); it != end; ++it) {
     114            if (!it->value)
     115                zombies.append(it->key);
     116        }
     117
     118        for (size_t i = 0; i < zombies.size(); ++i)
     119            m_map.remove(zombies[i]);
     120    }
     121
     122    void gcMapIfNeeded()
     123    {
     124        if (m_map.size() < m_gcThreshold)
     125            return;
     126
     127        gcMap();
     128        m_gcThreshold = std::max(minGCThreshold, m_map.size() * 2 - 1);
     129    }
     130
    105131    HashMapType m_map;
    106     VM& m_vm;
     132    int m_gcThreshold;
    107133};
     134
     135template<typename KeyArg, typename RawMappedArg, typename HashArg, typename KeyTraitsArg>
     136const int WeakGCMap<KeyArg, RawMappedArg, HashArg, KeyTraitsArg>::minGCThreshold;
    108137
    109138} // namespace JSC
Note: See TracChangeset for help on using the changeset viewer.