B3 should have load elimination
https://bugs.webkit.org/show_bug.cgi?id=153288
Reviewed by Geoffrey Garen.
Source/JavaScriptCore:
This adds a complete GCSE pass that includes load elimination. It would have been super hard
to make this work as part of the reduceStrength() fixpoint, since GCSE needs to analyze
control flow and reduceStrength() is messing with control flow. So, I did a compromise: I
factored out the pure CSE that reduceStrength() was already doing, and now we have:
- reduceStrength() still does pure CSE using the new PureCSE helper.
- eliminateCommonSubexpressions() is a separate phase that does general CSE. It uses the
PureCSE helper for pure values and does its own special thing for memory values.
Unfortunately, this doesn't help any benchmark right now. It doesn't hurt anything, either,
and it's likely to become a bigger pay-off once we implement other features, like mapping
FTL's abstract heaps onto B3's heap ranges.
* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
* b3/B3EliminateCommonSubexpressions.cpp: Added.
(JSC::B3::eliminateCommonSubexpressions):
* b3/B3EliminateCommonSubexpressions.h: Added.
* b3/B3Generate.cpp:
(JSC::B3::generateToAir):
* b3/B3HeapRange.h:
(JSC::B3::HeapRange::HeapRange):
* b3/B3InsertionSet.h:
(JSC::B3::InsertionSet::InsertionSet):
(JSC::B3::InsertionSet::isEmpty):
(JSC::B3::InsertionSet::code):
(JSC::B3::InsertionSet::appendInsertion):
* b3/B3MemoryValue.h:
* b3/B3PureCSE.cpp: Added.
(JSC::B3::PureCSE::PureCSE):
(JSC::B3::PureCSE::~PureCSE):
(JSC::B3::PureCSE::clear):
(JSC::B3::PureCSE::process):
* b3/B3PureCSE.h: Added.
* b3/B3ReduceStrength.cpp:
* b3/B3ReduceStrength.h:
* b3/B3Validate.cpp:
Source/WTF:
I needed a way to track sets of ranges, where there is a high likelihood that all of the
ranges overlap. So I created RangeSet. It's a usually-sorted list of coalesced ranges.
Practically this means that right now, FTL B3 will end up with two kinds of range sets: a set
that just contains top and a set that contains nothing. In the future, most sets will either
be top of empty but some of them will contain a handful of other things.
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/MathExtras.h:
(WTF::leftShiftWithSaturation):
(WTF::nonEmptyRangesOverlap):
(WTF::rangesOverlap):
* wtf/RangeSet.h: Added.
(WTF::RangeSet::RangeSet):
(WTF::RangeSet::~RangeSet):
(WTF::RangeSet::add):
(WTF::RangeSet::contains):
(WTF::RangeSet::overlaps):
(WTF::RangeSet::clear):
(WTF::RangeSet::dump):
(WTF::RangeSet::dumpRaw):
(WTF::RangeSet::compact):
(WTF::RangeSet::overlapsNonEmpty):
(WTF::RangeSet::subsumesNonEmpty):
(WTF::RangeSet::findRange):
* wtf/StdLibExtras.h:
(WTF::binarySearchImpl):
(WTF::binarySearch):
(WTF::tryBinarySearch):
(WTF::approximateBinarySearch):
Canonical link: https://commits.webkit.org/171387@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195417 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-21 19:54:51 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2016 Apple Inc. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
|
|
|
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
|
|
|
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
|
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
|
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
|
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2018-10-15 14:24:49 +00:00
|
|
|
#pragma once
|
B3 should have load elimination
https://bugs.webkit.org/show_bug.cgi?id=153288
Reviewed by Geoffrey Garen.
Source/JavaScriptCore:
This adds a complete GCSE pass that includes load elimination. It would have been super hard
to make this work as part of the reduceStrength() fixpoint, since GCSE needs to analyze
control flow and reduceStrength() is messing with control flow. So, I did a compromise: I
factored out the pure CSE that reduceStrength() was already doing, and now we have:
- reduceStrength() still does pure CSE using the new PureCSE helper.
- eliminateCommonSubexpressions() is a separate phase that does general CSE. It uses the
PureCSE helper for pure values and does its own special thing for memory values.
Unfortunately, this doesn't help any benchmark right now. It doesn't hurt anything, either,
and it's likely to become a bigger pay-off once we implement other features, like mapping
FTL's abstract heaps onto B3's heap ranges.
* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
* b3/B3EliminateCommonSubexpressions.cpp: Added.
(JSC::B3::eliminateCommonSubexpressions):
* b3/B3EliminateCommonSubexpressions.h: Added.
* b3/B3Generate.cpp:
(JSC::B3::generateToAir):
* b3/B3HeapRange.h:
(JSC::B3::HeapRange::HeapRange):
* b3/B3InsertionSet.h:
(JSC::B3::InsertionSet::InsertionSet):
(JSC::B3::InsertionSet::isEmpty):
(JSC::B3::InsertionSet::code):
(JSC::B3::InsertionSet::appendInsertion):
* b3/B3MemoryValue.h:
* b3/B3PureCSE.cpp: Added.
(JSC::B3::PureCSE::PureCSE):
(JSC::B3::PureCSE::~PureCSE):
(JSC::B3::PureCSE::clear):
(JSC::B3::PureCSE::process):
* b3/B3PureCSE.h: Added.
* b3/B3ReduceStrength.cpp:
* b3/B3ReduceStrength.h:
* b3/B3Validate.cpp:
Source/WTF:
I needed a way to track sets of ranges, where there is a high likelihood that all of the
ranges overlap. So I created RangeSet. It's a usually-sorted list of coalesced ranges.
Practically this means that right now, FTL B3 will end up with two kinds of range sets: a set
that just contains top and a set that contains nothing. In the future, most sets will either
be top of empty but some of them will contain a handful of other things.
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/MathExtras.h:
(WTF::leftShiftWithSaturation):
(WTF::nonEmptyRangesOverlap):
(WTF::rangesOverlap):
* wtf/RangeSet.h: Added.
(WTF::RangeSet::RangeSet):
(WTF::RangeSet::~RangeSet):
(WTF::RangeSet::add):
(WTF::RangeSet::contains):
(WTF::RangeSet::overlaps):
(WTF::RangeSet::clear):
(WTF::RangeSet::dump):
(WTF::RangeSet::dumpRaw):
(WTF::RangeSet::compact):
(WTF::RangeSet::overlapsNonEmpty):
(WTF::RangeSet::subsumesNonEmpty):
(WTF::RangeSet::findRange):
* wtf/StdLibExtras.h:
(WTF::binarySearchImpl):
(WTF::binarySearch):
(WTF::tryBinarySearch):
(WTF::approximateBinarySearch):
Canonical link: https://commits.webkit.org/171387@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195417 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-21 19:54:51 +00:00
|
|
|
|
|
|
|
#include <wtf/ListDump.h>
|
|
|
|
#include <wtf/MathExtras.h>
|
|
|
|
#include <wtf/StdLibExtras.h>
|
|
|
|
#include <wtf/Vector.h>
|
|
|
|
|
|
|
|
namespace WTF {
|
|
|
|
|
|
|
|
// A RangeSet is a set of numerical ranges. A value belongs to the set if it is within any of the
|
|
|
|
// ranges. A range belongs to the set if every value in the range belongs to the set. A range overlaps
|
|
|
|
// the set if any value in the range belongs to the set. You can add ranges and query range
|
|
|
|
// membership. The internal representation is a list of ranges that gets periodically compacted. This
|
|
|
|
// representation is optimal so long as the number of distinct ranges tends to be small, and the
|
|
|
|
// number of range sets tends to be small as well. This works reasonably well in a bunch of compiler
|
|
|
|
// algorithms, where the top range ends up being used a lot.
|
|
|
|
//
|
|
|
|
// The initial user of this is JSC::B3::HeapRange, which is used to perform alias analysis. You can
|
|
|
|
// model new users on that class. Basically, you need to define:
|
|
|
|
//
|
|
|
|
// T::Type - the type of the members of the range. HeapRange uses unsigned.
|
|
|
|
// T(T::Type begin, T::Type end) - construct a new range.
|
|
|
|
// T::Type T::begin() const - instance method giving the inclusive beginning of the range.
|
|
|
|
// T::Type T::end() const - instance method giving the exclusive end of the range.
|
|
|
|
// void T::dump(PrintStream&) const - some kind of dumping.
|
|
|
|
|
|
|
|
template<typename RangeType>
|
2019-08-12 20:57:15 +00:00
|
|
|
class RangeSet final {
|
|
|
|
WTF_MAKE_FAST_ALLOCATED;
|
B3 should have load elimination
https://bugs.webkit.org/show_bug.cgi?id=153288
Reviewed by Geoffrey Garen.
Source/JavaScriptCore:
This adds a complete GCSE pass that includes load elimination. It would have been super hard
to make this work as part of the reduceStrength() fixpoint, since GCSE needs to analyze
control flow and reduceStrength() is messing with control flow. So, I did a compromise: I
factored out the pure CSE that reduceStrength() was already doing, and now we have:
- reduceStrength() still does pure CSE using the new PureCSE helper.
- eliminateCommonSubexpressions() is a separate phase that does general CSE. It uses the
PureCSE helper for pure values and does its own special thing for memory values.
Unfortunately, this doesn't help any benchmark right now. It doesn't hurt anything, either,
and it's likely to become a bigger pay-off once we implement other features, like mapping
FTL's abstract heaps onto B3's heap ranges.
* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
* b3/B3EliminateCommonSubexpressions.cpp: Added.
(JSC::B3::eliminateCommonSubexpressions):
* b3/B3EliminateCommonSubexpressions.h: Added.
* b3/B3Generate.cpp:
(JSC::B3::generateToAir):
* b3/B3HeapRange.h:
(JSC::B3::HeapRange::HeapRange):
* b3/B3InsertionSet.h:
(JSC::B3::InsertionSet::InsertionSet):
(JSC::B3::InsertionSet::isEmpty):
(JSC::B3::InsertionSet::code):
(JSC::B3::InsertionSet::appendInsertion):
* b3/B3MemoryValue.h:
* b3/B3PureCSE.cpp: Added.
(JSC::B3::PureCSE::PureCSE):
(JSC::B3::PureCSE::~PureCSE):
(JSC::B3::PureCSE::clear):
(JSC::B3::PureCSE::process):
* b3/B3PureCSE.h: Added.
* b3/B3ReduceStrength.cpp:
* b3/B3ReduceStrength.h:
* b3/B3Validate.cpp:
Source/WTF:
I needed a way to track sets of ranges, where there is a high likelihood that all of the
ranges overlap. So I created RangeSet. It's a usually-sorted list of coalesced ranges.
Practically this means that right now, FTL B3 will end up with two kinds of range sets: a set
that just contains top and a set that contains nothing. In the future, most sets will either
be top of empty but some of them will contain a handful of other things.
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/MathExtras.h:
(WTF::leftShiftWithSaturation):
(WTF::nonEmptyRangesOverlap):
(WTF::rangesOverlap):
* wtf/RangeSet.h: Added.
(WTF::RangeSet::RangeSet):
(WTF::RangeSet::~RangeSet):
(WTF::RangeSet::add):
(WTF::RangeSet::contains):
(WTF::RangeSet::overlaps):
(WTF::RangeSet::clear):
(WTF::RangeSet::dump):
(WTF::RangeSet::dumpRaw):
(WTF::RangeSet::compact):
(WTF::RangeSet::overlapsNonEmpty):
(WTF::RangeSet::subsumesNonEmpty):
(WTF::RangeSet::findRange):
* wtf/StdLibExtras.h:
(WTF::binarySearchImpl):
(WTF::binarySearch):
(WTF::tryBinarySearch):
(WTF::approximateBinarySearch):
Canonical link: https://commits.webkit.org/171387@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195417 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-21 19:54:51 +00:00
|
|
|
public:
|
|
|
|
typedef RangeType Range;
|
|
|
|
typedef typename Range::Type Type;
|
|
|
|
|
2017-07-26 01:58:36 +00:00
|
|
|
typedef Vector<Range, 8> VectorType;
|
|
|
|
|
B3 should have load elimination
https://bugs.webkit.org/show_bug.cgi?id=153288
Reviewed by Geoffrey Garen.
Source/JavaScriptCore:
This adds a complete GCSE pass that includes load elimination. It would have been super hard
to make this work as part of the reduceStrength() fixpoint, since GCSE needs to analyze
control flow and reduceStrength() is messing with control flow. So, I did a compromise: I
factored out the pure CSE that reduceStrength() was already doing, and now we have:
- reduceStrength() still does pure CSE using the new PureCSE helper.
- eliminateCommonSubexpressions() is a separate phase that does general CSE. It uses the
PureCSE helper for pure values and does its own special thing for memory values.
Unfortunately, this doesn't help any benchmark right now. It doesn't hurt anything, either,
and it's likely to become a bigger pay-off once we implement other features, like mapping
FTL's abstract heaps onto B3's heap ranges.
* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
* b3/B3EliminateCommonSubexpressions.cpp: Added.
(JSC::B3::eliminateCommonSubexpressions):
* b3/B3EliminateCommonSubexpressions.h: Added.
* b3/B3Generate.cpp:
(JSC::B3::generateToAir):
* b3/B3HeapRange.h:
(JSC::B3::HeapRange::HeapRange):
* b3/B3InsertionSet.h:
(JSC::B3::InsertionSet::InsertionSet):
(JSC::B3::InsertionSet::isEmpty):
(JSC::B3::InsertionSet::code):
(JSC::B3::InsertionSet::appendInsertion):
* b3/B3MemoryValue.h:
* b3/B3PureCSE.cpp: Added.
(JSC::B3::PureCSE::PureCSE):
(JSC::B3::PureCSE::~PureCSE):
(JSC::B3::PureCSE::clear):
(JSC::B3::PureCSE::process):
* b3/B3PureCSE.h: Added.
* b3/B3ReduceStrength.cpp:
* b3/B3ReduceStrength.h:
* b3/B3Validate.cpp:
Source/WTF:
I needed a way to track sets of ranges, where there is a high likelihood that all of the
ranges overlap. So I created RangeSet. It's a usually-sorted list of coalesced ranges.
Practically this means that right now, FTL B3 will end up with two kinds of range sets: a set
that just contains top and a set that contains nothing. In the future, most sets will either
be top of empty but some of them will contain a handful of other things.
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/MathExtras.h:
(WTF::leftShiftWithSaturation):
(WTF::nonEmptyRangesOverlap):
(WTF::rangesOverlap):
* wtf/RangeSet.h: Added.
(WTF::RangeSet::RangeSet):
(WTF::RangeSet::~RangeSet):
(WTF::RangeSet::add):
(WTF::RangeSet::contains):
(WTF::RangeSet::overlaps):
(WTF::RangeSet::clear):
(WTF::RangeSet::dump):
(WTF::RangeSet::dumpRaw):
(WTF::RangeSet::compact):
(WTF::RangeSet::overlapsNonEmpty):
(WTF::RangeSet::subsumesNonEmpty):
(WTF::RangeSet::findRange):
* wtf/StdLibExtras.h:
(WTF::binarySearchImpl):
(WTF::binarySearch):
(WTF::tryBinarySearch):
(WTF::approximateBinarySearch):
Canonical link: https://commits.webkit.org/171387@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195417 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-21 19:54:51 +00:00
|
|
|
RangeSet()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~RangeSet()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void add(const Range& range)
|
|
|
|
{
|
|
|
|
if (range.begin() == range.end())
|
|
|
|
return;
|
|
|
|
|
|
|
|
// We expect the range set to become top in a lot of cases. We also expect the same range to
|
|
|
|
// be added repeatedly. That's why this is here.
|
|
|
|
if (!m_ranges.isEmpty() && subsumesNonEmpty(m_ranges.last(), range))
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_isCompact = false;
|
|
|
|
|
|
|
|
// We append without compacting only if doing so is guaranteed not to resize the vector.
|
2017-03-30 22:55:44 +00:00
|
|
|
// FIXME: This heuristic is almost certainly wrong, because we don't control the capacity. I
|
|
|
|
// think that this means that we will sometimes be rage-compacting when we are just shy of the
|
|
|
|
// capacity.
|
|
|
|
// https://bugs.webkit.org/show_bug.cgi?id=170308
|
B3 should have load elimination
https://bugs.webkit.org/show_bug.cgi?id=153288
Reviewed by Geoffrey Garen.
Source/JavaScriptCore:
This adds a complete GCSE pass that includes load elimination. It would have been super hard
to make this work as part of the reduceStrength() fixpoint, since GCSE needs to analyze
control flow and reduceStrength() is messing with control flow. So, I did a compromise: I
factored out the pure CSE that reduceStrength() was already doing, and now we have:
- reduceStrength() still does pure CSE using the new PureCSE helper.
- eliminateCommonSubexpressions() is a separate phase that does general CSE. It uses the
PureCSE helper for pure values and does its own special thing for memory values.
Unfortunately, this doesn't help any benchmark right now. It doesn't hurt anything, either,
and it's likely to become a bigger pay-off once we implement other features, like mapping
FTL's abstract heaps onto B3's heap ranges.
* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
* b3/B3EliminateCommonSubexpressions.cpp: Added.
(JSC::B3::eliminateCommonSubexpressions):
* b3/B3EliminateCommonSubexpressions.h: Added.
* b3/B3Generate.cpp:
(JSC::B3::generateToAir):
* b3/B3HeapRange.h:
(JSC::B3::HeapRange::HeapRange):
* b3/B3InsertionSet.h:
(JSC::B3::InsertionSet::InsertionSet):
(JSC::B3::InsertionSet::isEmpty):
(JSC::B3::InsertionSet::code):
(JSC::B3::InsertionSet::appendInsertion):
* b3/B3MemoryValue.h:
* b3/B3PureCSE.cpp: Added.
(JSC::B3::PureCSE::PureCSE):
(JSC::B3::PureCSE::~PureCSE):
(JSC::B3::PureCSE::clear):
(JSC::B3::PureCSE::process):
* b3/B3PureCSE.h: Added.
* b3/B3ReduceStrength.cpp:
* b3/B3ReduceStrength.h:
* b3/B3Validate.cpp:
Source/WTF:
I needed a way to track sets of ranges, where there is a high likelihood that all of the
ranges overlap. So I created RangeSet. It's a usually-sorted list of coalesced ranges.
Practically this means that right now, FTL B3 will end up with two kinds of range sets: a set
that just contains top and a set that contains nothing. In the future, most sets will either
be top of empty but some of them will contain a handful of other things.
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/MathExtras.h:
(WTF::leftShiftWithSaturation):
(WTF::nonEmptyRangesOverlap):
(WTF::rangesOverlap):
* wtf/RangeSet.h: Added.
(WTF::RangeSet::RangeSet):
(WTF::RangeSet::~RangeSet):
(WTF::RangeSet::add):
(WTF::RangeSet::contains):
(WTF::RangeSet::overlaps):
(WTF::RangeSet::clear):
(WTF::RangeSet::dump):
(WTF::RangeSet::dumpRaw):
(WTF::RangeSet::compact):
(WTF::RangeSet::overlapsNonEmpty):
(WTF::RangeSet::subsumesNonEmpty):
(WTF::RangeSet::findRange):
* wtf/StdLibExtras.h:
(WTF::binarySearchImpl):
(WTF::binarySearch):
(WTF::tryBinarySearch):
(WTF::approximateBinarySearch):
Canonical link: https://commits.webkit.org/171387@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195417 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-21 19:54:51 +00:00
|
|
|
if (m_ranges.size() + 1 < m_ranges.capacity()) {
|
|
|
|
m_ranges.append(range);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_ranges.append(range);
|
|
|
|
compact();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool contains(const Range& range) const
|
|
|
|
{
|
|
|
|
if (range.begin() == range.end())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
unsigned index = findRange(range);
|
2016-01-21 21:37:56 +00:00
|
|
|
if (index != UINT_MAX)
|
|
|
|
return subsumesNonEmpty(m_ranges[index], range);
|
B3 should have load elimination
https://bugs.webkit.org/show_bug.cgi?id=153288
Reviewed by Geoffrey Garen.
Source/JavaScriptCore:
This adds a complete GCSE pass that includes load elimination. It would have been super hard
to make this work as part of the reduceStrength() fixpoint, since GCSE needs to analyze
control flow and reduceStrength() is messing with control flow. So, I did a compromise: I
factored out the pure CSE that reduceStrength() was already doing, and now we have:
- reduceStrength() still does pure CSE using the new PureCSE helper.
- eliminateCommonSubexpressions() is a separate phase that does general CSE. It uses the
PureCSE helper for pure values and does its own special thing for memory values.
Unfortunately, this doesn't help any benchmark right now. It doesn't hurt anything, either,
and it's likely to become a bigger pay-off once we implement other features, like mapping
FTL's abstract heaps onto B3's heap ranges.
* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
* b3/B3EliminateCommonSubexpressions.cpp: Added.
(JSC::B3::eliminateCommonSubexpressions):
* b3/B3EliminateCommonSubexpressions.h: Added.
* b3/B3Generate.cpp:
(JSC::B3::generateToAir):
* b3/B3HeapRange.h:
(JSC::B3::HeapRange::HeapRange):
* b3/B3InsertionSet.h:
(JSC::B3::InsertionSet::InsertionSet):
(JSC::B3::InsertionSet::isEmpty):
(JSC::B3::InsertionSet::code):
(JSC::B3::InsertionSet::appendInsertion):
* b3/B3MemoryValue.h:
* b3/B3PureCSE.cpp: Added.
(JSC::B3::PureCSE::PureCSE):
(JSC::B3::PureCSE::~PureCSE):
(JSC::B3::PureCSE::clear):
(JSC::B3::PureCSE::process):
* b3/B3PureCSE.h: Added.
* b3/B3ReduceStrength.cpp:
* b3/B3ReduceStrength.h:
* b3/B3Validate.cpp:
Source/WTF:
I needed a way to track sets of ranges, where there is a high likelihood that all of the
ranges overlap. So I created RangeSet. It's a usually-sorted list of coalesced ranges.
Practically this means that right now, FTL B3 will end up with two kinds of range sets: a set
that just contains top and a set that contains nothing. In the future, most sets will either
be top of empty but some of them will contain a handful of other things.
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/MathExtras.h:
(WTF::leftShiftWithSaturation):
(WTF::nonEmptyRangesOverlap):
(WTF::rangesOverlap):
* wtf/RangeSet.h: Added.
(WTF::RangeSet::RangeSet):
(WTF::RangeSet::~RangeSet):
(WTF::RangeSet::add):
(WTF::RangeSet::contains):
(WTF::RangeSet::overlaps):
(WTF::RangeSet::clear):
(WTF::RangeSet::dump):
(WTF::RangeSet::dumpRaw):
(WTF::RangeSet::compact):
(WTF::RangeSet::overlapsNonEmpty):
(WTF::RangeSet::subsumesNonEmpty):
(WTF::RangeSet::findRange):
* wtf/StdLibExtras.h:
(WTF::binarySearchImpl):
(WTF::binarySearch):
(WTF::tryBinarySearch):
(WTF::approximateBinarySearch):
Canonical link: https://commits.webkit.org/171387@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195417 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-21 19:54:51 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool overlaps(const Range& range) const
|
|
|
|
{
|
|
|
|
if (range.begin() == range.end())
|
|
|
|
return false;
|
|
|
|
|
2016-01-21 21:37:56 +00:00
|
|
|
return findRange(range) != UINT_MAX;
|
B3 should have load elimination
https://bugs.webkit.org/show_bug.cgi?id=153288
Reviewed by Geoffrey Garen.
Source/JavaScriptCore:
This adds a complete GCSE pass that includes load elimination. It would have been super hard
to make this work as part of the reduceStrength() fixpoint, since GCSE needs to analyze
control flow and reduceStrength() is messing with control flow. So, I did a compromise: I
factored out the pure CSE that reduceStrength() was already doing, and now we have:
- reduceStrength() still does pure CSE using the new PureCSE helper.
- eliminateCommonSubexpressions() is a separate phase that does general CSE. It uses the
PureCSE helper for pure values and does its own special thing for memory values.
Unfortunately, this doesn't help any benchmark right now. It doesn't hurt anything, either,
and it's likely to become a bigger pay-off once we implement other features, like mapping
FTL's abstract heaps onto B3's heap ranges.
* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
* b3/B3EliminateCommonSubexpressions.cpp: Added.
(JSC::B3::eliminateCommonSubexpressions):
* b3/B3EliminateCommonSubexpressions.h: Added.
* b3/B3Generate.cpp:
(JSC::B3::generateToAir):
* b3/B3HeapRange.h:
(JSC::B3::HeapRange::HeapRange):
* b3/B3InsertionSet.h:
(JSC::B3::InsertionSet::InsertionSet):
(JSC::B3::InsertionSet::isEmpty):
(JSC::B3::InsertionSet::code):
(JSC::B3::InsertionSet::appendInsertion):
* b3/B3MemoryValue.h:
* b3/B3PureCSE.cpp: Added.
(JSC::B3::PureCSE::PureCSE):
(JSC::B3::PureCSE::~PureCSE):
(JSC::B3::PureCSE::clear):
(JSC::B3::PureCSE::process):
* b3/B3PureCSE.h: Added.
* b3/B3ReduceStrength.cpp:
* b3/B3ReduceStrength.h:
* b3/B3Validate.cpp:
Source/WTF:
I needed a way to track sets of ranges, where there is a high likelihood that all of the
ranges overlap. So I created RangeSet. It's a usually-sorted list of coalesced ranges.
Practically this means that right now, FTL B3 will end up with two kinds of range sets: a set
that just contains top and a set that contains nothing. In the future, most sets will either
be top of empty but some of them will contain a handful of other things.
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/MathExtras.h:
(WTF::leftShiftWithSaturation):
(WTF::nonEmptyRangesOverlap):
(WTF::rangesOverlap):
* wtf/RangeSet.h: Added.
(WTF::RangeSet::RangeSet):
(WTF::RangeSet::~RangeSet):
(WTF::RangeSet::add):
(WTF::RangeSet::contains):
(WTF::RangeSet::overlaps):
(WTF::RangeSet::clear):
(WTF::RangeSet::dump):
(WTF::RangeSet::dumpRaw):
(WTF::RangeSet::compact):
(WTF::RangeSet::overlapsNonEmpty):
(WTF::RangeSet::subsumesNonEmpty):
(WTF::RangeSet::findRange):
* wtf/StdLibExtras.h:
(WTF::binarySearchImpl):
(WTF::binarySearch):
(WTF::tryBinarySearch):
(WTF::approximateBinarySearch):
Canonical link: https://commits.webkit.org/171387@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195417 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-21 19:54:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void clear()
|
|
|
|
{
|
|
|
|
m_ranges.clear();
|
|
|
|
m_isCompact = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void dump(PrintStream& out) const
|
|
|
|
{
|
|
|
|
const_cast<RangeSet*>(this)->compact();
|
|
|
|
out.print(listDump(m_ranges));
|
|
|
|
}
|
|
|
|
|
|
|
|
void dumpRaw(PrintStream& out) const
|
|
|
|
{
|
|
|
|
out.print("{", listDump(m_ranges), ", isCompact = ", m_isCompact, "}");
|
|
|
|
}
|
2017-07-26 01:58:36 +00:00
|
|
|
|
|
|
|
typename VectorType::const_iterator begin() const
|
|
|
|
{
|
|
|
|
return m_ranges.begin();
|
|
|
|
}
|
|
|
|
|
|
|
|
typename VectorType::const_iterator end() const
|
|
|
|
{
|
|
|
|
return m_ranges.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
void addAll(const RangeSet& other)
|
|
|
|
{
|
|
|
|
for (Range range : other)
|
|
|
|
add(range);
|
|
|
|
}
|
B3 should have load elimination
https://bugs.webkit.org/show_bug.cgi?id=153288
Reviewed by Geoffrey Garen.
Source/JavaScriptCore:
This adds a complete GCSE pass that includes load elimination. It would have been super hard
to make this work as part of the reduceStrength() fixpoint, since GCSE needs to analyze
control flow and reduceStrength() is messing with control flow. So, I did a compromise: I
factored out the pure CSE that reduceStrength() was already doing, and now we have:
- reduceStrength() still does pure CSE using the new PureCSE helper.
- eliminateCommonSubexpressions() is a separate phase that does general CSE. It uses the
PureCSE helper for pure values and does its own special thing for memory values.
Unfortunately, this doesn't help any benchmark right now. It doesn't hurt anything, either,
and it's likely to become a bigger pay-off once we implement other features, like mapping
FTL's abstract heaps onto B3's heap ranges.
* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
* b3/B3EliminateCommonSubexpressions.cpp: Added.
(JSC::B3::eliminateCommonSubexpressions):
* b3/B3EliminateCommonSubexpressions.h: Added.
* b3/B3Generate.cpp:
(JSC::B3::generateToAir):
* b3/B3HeapRange.h:
(JSC::B3::HeapRange::HeapRange):
* b3/B3InsertionSet.h:
(JSC::B3::InsertionSet::InsertionSet):
(JSC::B3::InsertionSet::isEmpty):
(JSC::B3::InsertionSet::code):
(JSC::B3::InsertionSet::appendInsertion):
* b3/B3MemoryValue.h:
* b3/B3PureCSE.cpp: Added.
(JSC::B3::PureCSE::PureCSE):
(JSC::B3::PureCSE::~PureCSE):
(JSC::B3::PureCSE::clear):
(JSC::B3::PureCSE::process):
* b3/B3PureCSE.h: Added.
* b3/B3ReduceStrength.cpp:
* b3/B3ReduceStrength.h:
* b3/B3Validate.cpp:
Source/WTF:
I needed a way to track sets of ranges, where there is a high likelihood that all of the
ranges overlap. So I created RangeSet. It's a usually-sorted list of coalesced ranges.
Practically this means that right now, FTL B3 will end up with two kinds of range sets: a set
that just contains top and a set that contains nothing. In the future, most sets will either
be top of empty but some of them will contain a handful of other things.
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/MathExtras.h:
(WTF::leftShiftWithSaturation):
(WTF::nonEmptyRangesOverlap):
(WTF::rangesOverlap):
* wtf/RangeSet.h: Added.
(WTF::RangeSet::RangeSet):
(WTF::RangeSet::~RangeSet):
(WTF::RangeSet::add):
(WTF::RangeSet::contains):
(WTF::RangeSet::overlaps):
(WTF::RangeSet::clear):
(WTF::RangeSet::dump):
(WTF::RangeSet::dumpRaw):
(WTF::RangeSet::compact):
(WTF::RangeSet::overlapsNonEmpty):
(WTF::RangeSet::subsumesNonEmpty):
(WTF::RangeSet::findRange):
* wtf/StdLibExtras.h:
(WTF::binarySearchImpl):
(WTF::binarySearch):
(WTF::tryBinarySearch):
(WTF::approximateBinarySearch):
Canonical link: https://commits.webkit.org/171387@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195417 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-21 19:54:51 +00:00
|
|
|
|
|
|
|
void compact()
|
|
|
|
{
|
|
|
|
if (m_isCompact)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (m_ranges.isEmpty()) {
|
|
|
|
m_isCompact = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::sort(
|
|
|
|
m_ranges.begin(), m_ranges.end(),
|
|
|
|
[&] (const Range& a, const Range& b) -> bool {
|
|
|
|
return a.begin() < b.begin();
|
|
|
|
});
|
|
|
|
|
|
|
|
unsigned srcIndex = 1;
|
|
|
|
unsigned dstIndex = 1;
|
|
|
|
Range* lastRange = &m_ranges[0];
|
|
|
|
while (srcIndex < m_ranges.size()) {
|
|
|
|
Range range = m_ranges[srcIndex++];
|
|
|
|
ASSERT(range.begin() >= lastRange->begin());
|
|
|
|
if (range.end() <= lastRange->end())
|
|
|
|
continue;
|
|
|
|
if (range.begin() <= lastRange->end()) {
|
|
|
|
*lastRange = Range(lastRange->begin(), range.end());
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ASSERT(!overlapsNonEmpty(*lastRange, range));
|
|
|
|
lastRange = &m_ranges[dstIndex++];
|
|
|
|
*lastRange = range;
|
|
|
|
}
|
2017-07-20 21:06:12 +00:00
|
|
|
m_ranges.shrink(dstIndex);
|
B3 should have load elimination
https://bugs.webkit.org/show_bug.cgi?id=153288
Reviewed by Geoffrey Garen.
Source/JavaScriptCore:
This adds a complete GCSE pass that includes load elimination. It would have been super hard
to make this work as part of the reduceStrength() fixpoint, since GCSE needs to analyze
control flow and reduceStrength() is messing with control flow. So, I did a compromise: I
factored out the pure CSE that reduceStrength() was already doing, and now we have:
- reduceStrength() still does pure CSE using the new PureCSE helper.
- eliminateCommonSubexpressions() is a separate phase that does general CSE. It uses the
PureCSE helper for pure values and does its own special thing for memory values.
Unfortunately, this doesn't help any benchmark right now. It doesn't hurt anything, either,
and it's likely to become a bigger pay-off once we implement other features, like mapping
FTL's abstract heaps onto B3's heap ranges.
* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
* b3/B3EliminateCommonSubexpressions.cpp: Added.
(JSC::B3::eliminateCommonSubexpressions):
* b3/B3EliminateCommonSubexpressions.h: Added.
* b3/B3Generate.cpp:
(JSC::B3::generateToAir):
* b3/B3HeapRange.h:
(JSC::B3::HeapRange::HeapRange):
* b3/B3InsertionSet.h:
(JSC::B3::InsertionSet::InsertionSet):
(JSC::B3::InsertionSet::isEmpty):
(JSC::B3::InsertionSet::code):
(JSC::B3::InsertionSet::appendInsertion):
* b3/B3MemoryValue.h:
* b3/B3PureCSE.cpp: Added.
(JSC::B3::PureCSE::PureCSE):
(JSC::B3::PureCSE::~PureCSE):
(JSC::B3::PureCSE::clear):
(JSC::B3::PureCSE::process):
* b3/B3PureCSE.h: Added.
* b3/B3ReduceStrength.cpp:
* b3/B3ReduceStrength.h:
* b3/B3Validate.cpp:
Source/WTF:
I needed a way to track sets of ranges, where there is a high likelihood that all of the
ranges overlap. So I created RangeSet. It's a usually-sorted list of coalesced ranges.
Practically this means that right now, FTL B3 will end up with two kinds of range sets: a set
that just contains top and a set that contains nothing. In the future, most sets will either
be top of empty but some of them will contain a handful of other things.
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/MathExtras.h:
(WTF::leftShiftWithSaturation):
(WTF::nonEmptyRangesOverlap):
(WTF::rangesOverlap):
* wtf/RangeSet.h: Added.
(WTF::RangeSet::RangeSet):
(WTF::RangeSet::~RangeSet):
(WTF::RangeSet::add):
(WTF::RangeSet::contains):
(WTF::RangeSet::overlaps):
(WTF::RangeSet::clear):
(WTF::RangeSet::dump):
(WTF::RangeSet::dumpRaw):
(WTF::RangeSet::compact):
(WTF::RangeSet::overlapsNonEmpty):
(WTF::RangeSet::subsumesNonEmpty):
(WTF::RangeSet::findRange):
* wtf/StdLibExtras.h:
(WTF::binarySearchImpl):
(WTF::binarySearch):
(WTF::tryBinarySearch):
(WTF::approximateBinarySearch):
Canonical link: https://commits.webkit.org/171387@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195417 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-21 19:54:51 +00:00
|
|
|
|
|
|
|
m_isCompact = true;
|
|
|
|
}
|
|
|
|
|
2017-07-26 01:58:36 +00:00
|
|
|
private:
|
B3 should have load elimination
https://bugs.webkit.org/show_bug.cgi?id=153288
Reviewed by Geoffrey Garen.
Source/JavaScriptCore:
This adds a complete GCSE pass that includes load elimination. It would have been super hard
to make this work as part of the reduceStrength() fixpoint, since GCSE needs to analyze
control flow and reduceStrength() is messing with control flow. So, I did a compromise: I
factored out the pure CSE that reduceStrength() was already doing, and now we have:
- reduceStrength() still does pure CSE using the new PureCSE helper.
- eliminateCommonSubexpressions() is a separate phase that does general CSE. It uses the
PureCSE helper for pure values and does its own special thing for memory values.
Unfortunately, this doesn't help any benchmark right now. It doesn't hurt anything, either,
and it's likely to become a bigger pay-off once we implement other features, like mapping
FTL's abstract heaps onto B3's heap ranges.
* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
* b3/B3EliminateCommonSubexpressions.cpp: Added.
(JSC::B3::eliminateCommonSubexpressions):
* b3/B3EliminateCommonSubexpressions.h: Added.
* b3/B3Generate.cpp:
(JSC::B3::generateToAir):
* b3/B3HeapRange.h:
(JSC::B3::HeapRange::HeapRange):
* b3/B3InsertionSet.h:
(JSC::B3::InsertionSet::InsertionSet):
(JSC::B3::InsertionSet::isEmpty):
(JSC::B3::InsertionSet::code):
(JSC::B3::InsertionSet::appendInsertion):
* b3/B3MemoryValue.h:
* b3/B3PureCSE.cpp: Added.
(JSC::B3::PureCSE::PureCSE):
(JSC::B3::PureCSE::~PureCSE):
(JSC::B3::PureCSE::clear):
(JSC::B3::PureCSE::process):
* b3/B3PureCSE.h: Added.
* b3/B3ReduceStrength.cpp:
* b3/B3ReduceStrength.h:
* b3/B3Validate.cpp:
Source/WTF:
I needed a way to track sets of ranges, where there is a high likelihood that all of the
ranges overlap. So I created RangeSet. It's a usually-sorted list of coalesced ranges.
Practically this means that right now, FTL B3 will end up with two kinds of range sets: a set
that just contains top and a set that contains nothing. In the future, most sets will either
be top of empty but some of them will contain a handful of other things.
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/MathExtras.h:
(WTF::leftShiftWithSaturation):
(WTF::nonEmptyRangesOverlap):
(WTF::rangesOverlap):
* wtf/RangeSet.h: Added.
(WTF::RangeSet::RangeSet):
(WTF::RangeSet::~RangeSet):
(WTF::RangeSet::add):
(WTF::RangeSet::contains):
(WTF::RangeSet::overlaps):
(WTF::RangeSet::clear):
(WTF::RangeSet::dump):
(WTF::RangeSet::dumpRaw):
(WTF::RangeSet::compact):
(WTF::RangeSet::overlapsNonEmpty):
(WTF::RangeSet::subsumesNonEmpty):
(WTF::RangeSet::findRange):
* wtf/StdLibExtras.h:
(WTF::binarySearchImpl):
(WTF::binarySearch):
(WTF::tryBinarySearch):
(WTF::approximateBinarySearch):
Canonical link: https://commits.webkit.org/171387@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195417 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-21 19:54:51 +00:00
|
|
|
static bool overlapsNonEmpty(const Range& a, const Range& b)
|
|
|
|
{
|
|
|
|
return nonEmptyRangesOverlap(a.begin(), a.end(), b.begin(), b.end());
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool subsumesNonEmpty(const Range& a, const Range& b)
|
|
|
|
{
|
|
|
|
return a.begin() <= b.begin() && a.end() >= b.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned findRange(const Range& range) const
|
|
|
|
{
|
|
|
|
const_cast<RangeSet*>(this)->compact();
|
|
|
|
|
2016-01-21 21:37:56 +00:00
|
|
|
// FIXME: Once we start using this in anger, we will want this to be a binary search.
|
|
|
|
for (unsigned i = 0; i < m_ranges.size(); ++i) {
|
|
|
|
if (overlapsNonEmpty(m_ranges[i], range))
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return UINT_MAX;
|
B3 should have load elimination
https://bugs.webkit.org/show_bug.cgi?id=153288
Reviewed by Geoffrey Garen.
Source/JavaScriptCore:
This adds a complete GCSE pass that includes load elimination. It would have been super hard
to make this work as part of the reduceStrength() fixpoint, since GCSE needs to analyze
control flow and reduceStrength() is messing with control flow. So, I did a compromise: I
factored out the pure CSE that reduceStrength() was already doing, and now we have:
- reduceStrength() still does pure CSE using the new PureCSE helper.
- eliminateCommonSubexpressions() is a separate phase that does general CSE. It uses the
PureCSE helper for pure values and does its own special thing for memory values.
Unfortunately, this doesn't help any benchmark right now. It doesn't hurt anything, either,
and it's likely to become a bigger pay-off once we implement other features, like mapping
FTL's abstract heaps onto B3's heap ranges.
* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
* b3/B3EliminateCommonSubexpressions.cpp: Added.
(JSC::B3::eliminateCommonSubexpressions):
* b3/B3EliminateCommonSubexpressions.h: Added.
* b3/B3Generate.cpp:
(JSC::B3::generateToAir):
* b3/B3HeapRange.h:
(JSC::B3::HeapRange::HeapRange):
* b3/B3InsertionSet.h:
(JSC::B3::InsertionSet::InsertionSet):
(JSC::B3::InsertionSet::isEmpty):
(JSC::B3::InsertionSet::code):
(JSC::B3::InsertionSet::appendInsertion):
* b3/B3MemoryValue.h:
* b3/B3PureCSE.cpp: Added.
(JSC::B3::PureCSE::PureCSE):
(JSC::B3::PureCSE::~PureCSE):
(JSC::B3::PureCSE::clear):
(JSC::B3::PureCSE::process):
* b3/B3PureCSE.h: Added.
* b3/B3ReduceStrength.cpp:
* b3/B3ReduceStrength.h:
* b3/B3Validate.cpp:
Source/WTF:
I needed a way to track sets of ranges, where there is a high likelihood that all of the
ranges overlap. So I created RangeSet. It's a usually-sorted list of coalesced ranges.
Practically this means that right now, FTL B3 will end up with two kinds of range sets: a set
that just contains top and a set that contains nothing. In the future, most sets will either
be top of empty but some of them will contain a handful of other things.
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/MathExtras.h:
(WTF::leftShiftWithSaturation):
(WTF::nonEmptyRangesOverlap):
(WTF::rangesOverlap):
* wtf/RangeSet.h: Added.
(WTF::RangeSet::RangeSet):
(WTF::RangeSet::~RangeSet):
(WTF::RangeSet::add):
(WTF::RangeSet::contains):
(WTF::RangeSet::overlaps):
(WTF::RangeSet::clear):
(WTF::RangeSet::dump):
(WTF::RangeSet::dumpRaw):
(WTF::RangeSet::compact):
(WTF::RangeSet::overlapsNonEmpty):
(WTF::RangeSet::subsumesNonEmpty):
(WTF::RangeSet::findRange):
* wtf/StdLibExtras.h:
(WTF::binarySearchImpl):
(WTF::binarySearch):
(WTF::tryBinarySearch):
(WTF::approximateBinarySearch):
Canonical link: https://commits.webkit.org/171387@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195417 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-21 19:54:51 +00:00
|
|
|
}
|
|
|
|
|
2017-07-26 01:58:36 +00:00
|
|
|
VectorType m_ranges;
|
B3 should have load elimination
https://bugs.webkit.org/show_bug.cgi?id=153288
Reviewed by Geoffrey Garen.
Source/JavaScriptCore:
This adds a complete GCSE pass that includes load elimination. It would have been super hard
to make this work as part of the reduceStrength() fixpoint, since GCSE needs to analyze
control flow and reduceStrength() is messing with control flow. So, I did a compromise: I
factored out the pure CSE that reduceStrength() was already doing, and now we have:
- reduceStrength() still does pure CSE using the new PureCSE helper.
- eliminateCommonSubexpressions() is a separate phase that does general CSE. It uses the
PureCSE helper for pure values and does its own special thing for memory values.
Unfortunately, this doesn't help any benchmark right now. It doesn't hurt anything, either,
and it's likely to become a bigger pay-off once we implement other features, like mapping
FTL's abstract heaps onto B3's heap ranges.
* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
* b3/B3EliminateCommonSubexpressions.cpp: Added.
(JSC::B3::eliminateCommonSubexpressions):
* b3/B3EliminateCommonSubexpressions.h: Added.
* b3/B3Generate.cpp:
(JSC::B3::generateToAir):
* b3/B3HeapRange.h:
(JSC::B3::HeapRange::HeapRange):
* b3/B3InsertionSet.h:
(JSC::B3::InsertionSet::InsertionSet):
(JSC::B3::InsertionSet::isEmpty):
(JSC::B3::InsertionSet::code):
(JSC::B3::InsertionSet::appendInsertion):
* b3/B3MemoryValue.h:
* b3/B3PureCSE.cpp: Added.
(JSC::B3::PureCSE::PureCSE):
(JSC::B3::PureCSE::~PureCSE):
(JSC::B3::PureCSE::clear):
(JSC::B3::PureCSE::process):
* b3/B3PureCSE.h: Added.
* b3/B3ReduceStrength.cpp:
* b3/B3ReduceStrength.h:
* b3/B3Validate.cpp:
Source/WTF:
I needed a way to track sets of ranges, where there is a high likelihood that all of the
ranges overlap. So I created RangeSet. It's a usually-sorted list of coalesced ranges.
Practically this means that right now, FTL B3 will end up with two kinds of range sets: a set
that just contains top and a set that contains nothing. In the future, most sets will either
be top of empty but some of them will contain a handful of other things.
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/MathExtras.h:
(WTF::leftShiftWithSaturation):
(WTF::nonEmptyRangesOverlap):
(WTF::rangesOverlap):
* wtf/RangeSet.h: Added.
(WTF::RangeSet::RangeSet):
(WTF::RangeSet::~RangeSet):
(WTF::RangeSet::add):
(WTF::RangeSet::contains):
(WTF::RangeSet::overlaps):
(WTF::RangeSet::clear):
(WTF::RangeSet::dump):
(WTF::RangeSet::dumpRaw):
(WTF::RangeSet::compact):
(WTF::RangeSet::overlapsNonEmpty):
(WTF::RangeSet::subsumesNonEmpty):
(WTF::RangeSet::findRange):
* wtf/StdLibExtras.h:
(WTF::binarySearchImpl):
(WTF::binarySearch):
(WTF::tryBinarySearch):
(WTF::approximateBinarySearch):
Canonical link: https://commits.webkit.org/171387@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195417 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-21 19:54:51 +00:00
|
|
|
bool m_isCompact { true };
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace WTF
|
|
|
|
|
|
|
|
using WTF::RangeSet;
|