summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/bytecode/BytecodeBasicBlock.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/bytecode/BytecodeBasicBlock.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/JavaScriptCore/bytecode/BytecodeBasicBlock.h')
-rw-r--r--Source/JavaScriptCore/bytecode/BytecodeBasicBlock.h69
1 files changed, 36 insertions, 33 deletions
diff --git a/Source/JavaScriptCore/bytecode/BytecodeBasicBlock.h b/Source/JavaScriptCore/bytecode/BytecodeBasicBlock.h
index 736ba8540..fb81650ca 100644
--- a/Source/JavaScriptCore/bytecode/BytecodeBasicBlock.h
+++ b/Source/JavaScriptCore/bytecode/BytecodeBasicBlock.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,77 +23,80 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef BytecodeBasicBlock_h
-#define BytecodeBasicBlock_h
+#pragma once
#include <limits.h>
#include <wtf/FastBitVector.h>
-#include <wtf/HashMap.h>
-#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
namespace JSC {
class CodeBlock;
+class UnlinkedCodeBlock;
+struct Instruction;
+struct UnlinkedInstruction;
-class BytecodeBasicBlock : public RefCounted<BytecodeBasicBlock> {
+class BytecodeBasicBlock {
+ WTF_MAKE_FAST_ALLOCATED;
public:
enum SpecialBlockType { EntryBlock, ExitBlock };
BytecodeBasicBlock(unsigned start, unsigned length);
BytecodeBasicBlock(SpecialBlockType);
+ void shrinkToFit();
- bool isEntryBlock() { return !m_leaderBytecodeOffset && !m_totalBytecodeLength; }
- bool isExitBlock() { return m_leaderBytecodeOffset == UINT_MAX && m_totalBytecodeLength == UINT_MAX; }
+ bool isEntryBlock() { return !m_leaderOffset && !m_totalLength; }
+ bool isExitBlock() { return m_leaderOffset == UINT_MAX && m_totalLength == UINT_MAX; }
- unsigned leaderBytecodeOffset() { return m_leaderBytecodeOffset; }
- unsigned totalBytecodeLength() { return m_totalBytecodeLength; }
+ unsigned leaderOffset() { return m_leaderOffset; }
+ unsigned totalLength() { return m_totalLength; }
- Vector<unsigned>& bytecodeOffsets() { return m_bytecodeOffsets; }
- void addBytecodeLength(unsigned);
+ const Vector<unsigned>& offsets() const { return m_offsets; }
- void addPredecessor(BytecodeBasicBlock* block) { m_predecessors.append(block); }
- void addSuccessor(BytecodeBasicBlock* block) { m_successors.append(block); }
-
- Vector<BytecodeBasicBlock*>& predecessors() { return m_predecessors; }
- Vector<BytecodeBasicBlock*>& successors() { return m_successors; }
+ const Vector<BytecodeBasicBlock*>& successors() const { return m_successors; }
FastBitVector& in() { return m_in; }
FastBitVector& out() { return m_out; }
+ unsigned index() const { return m_index; }
+
+ static void compute(CodeBlock*, Instruction* instructionsBegin, unsigned instructionCount, Vector<std::unique_ptr<BytecodeBasicBlock>>&);
+ static void compute(UnlinkedCodeBlock*, UnlinkedInstruction* instructionsBegin, unsigned instructionCount, Vector<std::unique_ptr<BytecodeBasicBlock>>&);
+
private:
- unsigned m_leaderBytecodeOffset;
- unsigned m_totalBytecodeLength;
+ template<typename Block, typename Instruction> static void computeImpl(Block* codeBlock, Instruction* instructionsBegin, unsigned instructionCount, Vector<std::unique_ptr<BytecodeBasicBlock>>& basicBlocks);
- Vector<unsigned> m_bytecodeOffsets;
+ void addSuccessor(BytecodeBasicBlock* block) { m_successors.append(block); }
- Vector<BytecodeBasicBlock*> m_predecessors;
+ void addLength(unsigned);
+
+ unsigned m_leaderOffset;
+ unsigned m_totalLength;
+ unsigned m_index;
+
+ Vector<unsigned> m_offsets;
Vector<BytecodeBasicBlock*> m_successors;
FastBitVector m_in;
FastBitVector m_out;
};
-void computeBytecodeBasicBlocks(CodeBlock*, Vector<RefPtr<BytecodeBasicBlock> >&);
-
inline BytecodeBasicBlock::BytecodeBasicBlock(unsigned start, unsigned length)
- : m_leaderBytecodeOffset(start)
- , m_totalBytecodeLength(length)
+ : m_leaderOffset(start)
+ , m_totalLength(length)
{
- m_bytecodeOffsets.append(m_leaderBytecodeOffset);
+ m_offsets.append(m_leaderOffset);
}
inline BytecodeBasicBlock::BytecodeBasicBlock(BytecodeBasicBlock::SpecialBlockType blockType)
- : m_leaderBytecodeOffset(blockType == BytecodeBasicBlock::EntryBlock ? 0 : UINT_MAX)
- , m_totalBytecodeLength(blockType == BytecodeBasicBlock::EntryBlock ? 0 : UINT_MAX)
+ : m_leaderOffset(blockType == BytecodeBasicBlock::EntryBlock ? 0 : UINT_MAX)
+ , m_totalLength(blockType == BytecodeBasicBlock::EntryBlock ? 0 : UINT_MAX)
{
}
-inline void BytecodeBasicBlock::addBytecodeLength(unsigned bytecodeLength)
+inline void BytecodeBasicBlock::addLength(unsigned bytecodeLength)
{
- m_bytecodeOffsets.append(m_leaderBytecodeOffset + m_totalBytecodeLength);
- m_totalBytecodeLength += bytecodeLength;
+ m_offsets.append(m_leaderOffset + m_totalLength);
+ m_totalLength += bytecodeLength;
}
} // namespace JSC
-
-#endif // BytecodeBasicBlock_h