Changeset 194382 in webkit


Ignore:
Timestamp:
Dec 22, 2015, 5:50:19 PM (10 years ago)
Author:
fpizlo@apple.com
Message:

FTL B3 should be able to run richards
https://bugs.webkit.org/show_bug.cgi?id=152514

Reviewed by Michael Saboff.

Source/JavaScriptCore:

This came down to a liveness bug and a register allocation bug.

The liveness bug was that the code that determined whether we should go around the fixpoint
assumed that BitVector::quickSet() would return true if the bit changed state from false to
true. That's not how it works. It returns the old value of the bit, so it will return false
if the bit changed from false to true. Since there is already a lot of code that relies on
this behavior, I fixed Liveness instead of changing BitVector.

The register allocation bug was that we weren't guarding some checks of tmp()'s with checks
that the Arg isTmp().

The liveness took a long time to track down, and I needed to add a lot of dumping to do it.
It's now possible to dump more of the liveness states, including liveAtHead. I found this
extremely helpful, so I removed the code that cleared liveAtHead.

  • b3/air/AirIteratedRegisterCoalescing.cpp:
  • b3/air/AirLiveness.h:

(JSC::B3::Air::AbstractLiveness::AbstractLiveness):
(JSC::B3::Air::AbstractLiveness::Iterable::Iterable):
(JSC::B3::Air::AbstractLiveness::Iterable::iterator::iterator):
(JSC::B3::Air::AbstractLiveness::Iterable::iterator::operator*):
(JSC::B3::Air::AbstractLiveness::Iterable::iterator::operator++):
(JSC::B3::Air::AbstractLiveness::Iterable::iterator::operator==):
(JSC::B3::Air::AbstractLiveness::Iterable::iterator::operator!=):
(JSC::B3::Air::AbstractLiveness::Iterable::begin):
(JSC::B3::Air::AbstractLiveness::Iterable::end):
(JSC::B3::Air::AbstractLiveness::liveAtHead):
(JSC::B3::Air::AbstractLiveness::liveAtTail):

  • b3/air/AirStackSlot.h:

(WTF::printInternal):

  • ftl/FTLOSRExitCompiler.cpp:

(JSC::FTL::compileFTLOSRExit):

Source/WTF:

Change the list dumping helpers to work with a broader set of list kinds.

  • wtf/ListDump.h:

(WTF::ListDump::dump):
(WTF::MapDump::dump):
(WTF::sortedMapDump):
(WTF::ListDumpInContext::dump):

Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r194376 r194382  
     12015-12-22  Filip Pizlo  <fpizlo@apple.com>
     2
     3        FTL B3 should be able to run richards
     4        https://bugs.webkit.org/show_bug.cgi?id=152514
     5
     6        Reviewed by Michael Saboff.
     7
     8        This came down to a liveness bug and a register allocation bug.
     9
     10        The liveness bug was that the code that determined whether we should go around the fixpoint
     11        assumed that BitVector::quickSet() would return true if the bit changed state from false to
     12        true. That's not how it works. It returns the old value of the bit, so it will return false
     13        if the bit changed from false to true. Since there is already a lot of code that relies on
     14        this behavior, I fixed Liveness instead of changing BitVector.
     15
     16        The register allocation bug was that we weren't guarding some checks of tmp()'s with checks
     17        that the Arg isTmp().
     18
     19        The liveness took a long time to track down, and I needed to add a lot of dumping to do it.
     20        It's now possible to dump more of the liveness states, including liveAtHead. I found this
     21        extremely helpful, so I removed the code that cleared liveAtHead.
     22
     23        * b3/air/AirIteratedRegisterCoalescing.cpp:
     24        * b3/air/AirLiveness.h:
     25        (JSC::B3::Air::AbstractLiveness::AbstractLiveness):
     26        (JSC::B3::Air::AbstractLiveness::Iterable::Iterable):
     27        (JSC::B3::Air::AbstractLiveness::Iterable::iterator::iterator):
     28        (JSC::B3::Air::AbstractLiveness::Iterable::iterator::operator*):
     29        (JSC::B3::Air::AbstractLiveness::Iterable::iterator::operator++):
     30        (JSC::B3::Air::AbstractLiveness::Iterable::iterator::operator==):
     31        (JSC::B3::Air::AbstractLiveness::Iterable::iterator::operator!=):
     32        (JSC::B3::Air::AbstractLiveness::Iterable::begin):
     33        (JSC::B3::Air::AbstractLiveness::Iterable::end):
     34        (JSC::B3::Air::AbstractLiveness::liveAtHead):
     35        (JSC::B3::Air::AbstractLiveness::liveAtTail):
     36        * b3/air/AirStackSlot.h:
     37        (WTF::printInternal):
     38        * ftl/FTLOSRExitCompiler.cpp:
     39        (JSC::FTL::compileFTLOSRExit):
     40
    1412015-12-22  Saam barati  <sbarati@apple.com>
    242
  • trunk/Source/JavaScriptCore/b3/air/AirIteratedRegisterCoalescing.cpp

    r194331 r194382  
    11911191                bool forceMove32IfDidSpill = false;
    11921192                bool didSpill = false;
    1193                 if (type == Arg::GP && inst.opcode == Move) {
     1193                if (type == Arg::GP && inst.opcode == Move
     1194                    && inst.args[0].isTmp() && inst.args[1].isTmp()) {
    11941195                    if (m_tmpWidth.defWidth(inst.args[0].tmp()) <= Arg::Width32
    11951196                        || m_tmpWidth.useWidth(inst.args[1].tmp()) <= Arg::Width32)
  • trunk/Source/JavaScriptCore/b3/air/AirLiveness.h

    r194331 r194382  
    3535#include "B3IndexSet.h"
    3636#include <wtf/IndexSparseSet.h>
     37#include <wtf/ListDump.h>
    3738
    3839namespace JSC { namespace B3 { namespace Air {
     
    142143                    for (unsigned newValue : m_workset) {
    143144                        if (liveAtTail.add(newValue)) {
    144                             if (dirtyBlocks.quickSet(predecessor->index()))
     145                            if (!dirtyBlocks.quickSet(predecessor->index()))
    145146                                changed = true;
    146147                        }
     
    149150            }
    150151        } while (changed);
    151 
    152         m_liveAtHead.clear();
    153152    }
    154153
     
    245244    };
    246245
     246    template<typename UnderlyingIterable>
     247    class Iterable {
     248    public:
     249        Iterable(AbstractLiveness& liveness, const UnderlyingIterable& iterable)
     250            : m_liveness(liveness)
     251            , m_iterable(iterable)
     252        {
     253        }
     254
     255        class iterator {
     256        public:
     257            iterator()
     258                : m_liveness(nullptr)
     259                , m_iter()
     260            {
     261            }
     262           
     263            iterator(AbstractLiveness& liveness, typename UnderlyingIterable::const_iterator iter)
     264                : m_liveness(&liveness)
     265                , m_iter(iter)
     266            {
     267            }
     268
     269            typename Adapter::Thing operator*()
     270            {
     271                return m_liveness->indexToValue(*m_iter);
     272            }
     273
     274            iterator& operator++()
     275            {
     276                ++m_iter;
     277                return *this;
     278            }
     279
     280            bool operator==(const iterator& other) const
     281            {
     282                ASSERT(m_liveness == other.m_liveness);
     283                return m_iter == other.m_iter;
     284            }
     285
     286            bool operator!=(const iterator& other) const
     287            {
     288                return !(*this == other);
     289            }
     290
     291        private:
     292            AbstractLiveness* m_liveness;
     293            typename UnderlyingIterable::const_iterator m_iter;
     294        };
     295
     296        iterator begin() const { return iterator(m_liveness, m_iterable.begin()); }
     297        iterator end() const { return iterator(m_liveness, m_iterable.end()); }
     298
     299    private:
     300        AbstractLiveness& m_liveness;
     301        const UnderlyingIterable& m_iterable;
     302    };
     303
     304    Iterable<Vector<unsigned>> liveAtHead(BasicBlock* block)
     305    {
     306        return Iterable<Vector<unsigned>>(*this, m_liveAtHead[block]);
     307    }
     308
     309    Iterable<typename Adapter::IndexSet> liveAtTail(BasicBlock* block)
     310    {
     311        return Iterable<typename Adapter::IndexSet>(*this, m_liveAtTail[block]);
     312    }
     313
    247314private:
    248315    friend class LocalCalc;
  • trunk/Source/JavaScriptCore/b3/air/AirStackSlot.h

    r191745 r194382  
    110110} } } // namespace JSC::B3::Air
    111111
     112namespace WTF {
     113
     114inline void printInternal(PrintStream& out, JSC::B3::Air::StackSlot* stackSlot)
     115{
     116    out.print(*stackSlot);
     117}
     118
     119} // namespace WTF
     120
    112121#endif // ENABLE(B3_JIT)
    113122
  • trunk/Source/JavaScriptCore/ftl/FTLOSRExitCompiler.cpp

    r193640 r194382  
    627627#endif // FTL_USES_B3
    628628        dataLog("    Exit values: ", exit.m_descriptor->m_values, "\n");
     629#if FTL_USES_B3
     630        dataLog("    Value reps: ", listDump(exit.m_valueReps), "\n");
     631#endif // FTL_USES_B3
    629632        if (!exit.m_descriptor->m_materializations.isEmpty()) {
    630633            dataLog("    Materializations:\n");
  • trunk/Source/WTF/ChangeLog

    r194372 r194382  
     12015-12-22  Filip Pizlo  <fpizlo@apple.com>
     2
     3        FTL B3 should be able to run richards
     4        https://bugs.webkit.org/show_bug.cgi?id=152514
     5
     6        Reviewed by Michael Saboff.
     7
     8        Change the list dumping helpers to work with a broader set of list kinds.
     9
     10        * wtf/ListDump.h:
     11        (WTF::ListDump::dump):
     12        (WTF::MapDump::dump):
     13        (WTF::sortedMapDump):
     14        (WTF::ListDumpInContext::dump):
     15
    1162015-12-22  Filip Pizlo  <fpizlo@apple.com>
    217
  • trunk/Source/WTF/wtf/ListDump.h

    r191705 r194382  
    4444    void dump(PrintStream& out) const
    4545    {
    46         for (typename T::const_iterator iter = m_list.begin(); iter != m_list.end(); ++iter)
     46        for (auto iter = m_list.begin(); iter != m_list.end(); ++iter)
    4747            out.print(m_comma, *iter);
    4848    }
     
    8585    void dump(PrintStream& out) const
    8686    {
    87         for (typename T::const_iterator iter = m_map.begin(); iter != m_map.end(); ++iter)
     87        for (auto iter = m_map.begin(); iter != m_map.end(); ++iter)
    8888            out.print(m_comma, iter->key, m_arrow, iter->value);
    8989    }
     
    136136{
    137137    Vector<typename T::KeyType> keys;
    138     for (typename T::const_iterator iter = map.begin(); iter != map.end(); ++iter)
     138    for (auto iter = map.begin(); iter != map.end(); ++iter)
    139139        keys.append(iter->key);
    140140    std::sort(keys.begin(), keys.end(), comparator);
     
    158158    void dump(PrintStream& out) const
    159159    {
    160         for (typename T::const_iterator iter = m_list.begin(); iter != m_list.end(); ++iter)
     160        for (auto iter = m_list.begin(); iter != m_list.end(); ++iter)
    161161            out.print(m_comma, inContext(*iter, m_context));
    162162    }
Note: See TracChangeset for help on using the changeset viewer.