summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/dfg/DFGNaturalLoops.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/JavaScriptCore/dfg/DFGNaturalLoops.h')
-rw-r--r--Source/JavaScriptCore/dfg/DFGNaturalLoops.h34
1 files changed, 16 insertions, 18 deletions
diff --git a/Source/JavaScriptCore/dfg/DFGNaturalLoops.h b/Source/JavaScriptCore/dfg/DFGNaturalLoops.h
index 7ad0b0bdc..3f5e58080 100644
--- a/Source/JavaScriptCore/dfg/DFGNaturalLoops.h
+++ b/Source/JavaScriptCore/dfg/DFGNaturalLoops.h
@@ -23,16 +23,15 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef DFGNaturalLoops_h
-#define DFGNaturalLoops_h
-
-#include <wtf/Platform.h>
+#pragma once
#if ENABLE(DFG_JIT)
-#include "DFGAnalysis.h"
#include "DFGBasicBlock.h"
#include "DFGCommon.h"
+#include "DFGDominators.h"
+#include <wtf/FastMalloc.h>
+#include <wtf/Noncopyable.h>
namespace JSC { namespace DFG {
@@ -90,21 +89,19 @@ private:
unsigned m_index;
};
-class NaturalLoops : public Analysis<NaturalLoops> {
+class NaturalLoops {
+ WTF_MAKE_NONCOPYABLE(NaturalLoops);
+ WTF_MAKE_FAST_ALLOCATED;
public:
- NaturalLoops();
+ NaturalLoops(Graph&);
~NaturalLoops();
- void compute(Graph&);
-
unsigned numLoops() const
{
- ASSERT(isValid());
return m_loops.size();
}
const NaturalLoop& loop(unsigned i) const
{
- ASSERT(isValid());
return m_loops[i];
}
@@ -112,7 +109,6 @@ public:
// loop it belongs to.
const NaturalLoop* headerOf(BasicBlock* block) const
{
- ASSERT(isValid());
const NaturalLoop* loop = innerMostLoopOf(block);
if (!loop)
return 0;
@@ -127,7 +123,6 @@ public:
const NaturalLoop* innerMostLoopOf(BasicBlock* block) const
{
- ASSERT(isValid());
unsigned index = block->innerMostLoopIndices[0];
if (index == UINT_MAX)
return 0;
@@ -136,7 +131,6 @@ public:
const NaturalLoop* innerMostOuterLoop(const NaturalLoop& loop) const
{
- ASSERT(isValid());
if (loop.m_outerLoopIndex == UINT_MAX)
return 0;
return &m_loops[loop.m_outerLoopIndex];
@@ -144,7 +138,6 @@ public:
bool belongsTo(BasicBlock* block, const NaturalLoop& candidateLoop) const
{
- ASSERT(isValid());
// It's faster to do this test using the loop itself, if it's small.
if (candidateLoop.size() < 4)
return candidateLoop.contains(block);
@@ -156,6 +149,14 @@ public:
return false;
}
+ unsigned loopDepth(BasicBlock* block) const
+ {
+ unsigned depth = 0;
+ for (const NaturalLoop* loop = innerMostLoopOf(block); loop; loop = innerMostOuterLoop(*loop))
+ depth++;
+ return depth;
+ }
+
// Return the indices of all loops this belongs to.
Vector<const NaturalLoop*> loopsOf(BasicBlock*) const;
@@ -169,6 +170,3 @@ private:
} } // namespace JSC::DFG
#endif // ENABLE(DFG_JIT)
-
-#endif // DFGNaturalLoops_h
-