Commit d0f35b6b authored by fpizlo@apple.com's avatar fpizlo@apple.com

Liveness analysis should take less memory in CodeBlock when it is unused

https://bugs.webkit.org/show_bug.cgi?id=124225

Reviewed by Mark Hahnenberg.
        
Basically, I turned CodeBlock::m_livenessAnalysis into a pointer that is null by
default.

* bytecode/BytecodeLivenessAnalysis.cpp:
(JSC::BytecodeLivenessAnalysis::BytecodeLivenessAnalysis):
(JSC::BytecodeLivenessAnalysis::runLivenessFixpoint):
(JSC::BytecodeLivenessAnalysis::operandIsLiveAtBytecodeOffset):
(JSC::BytecodeLivenessAnalysis::dumpResults):
(JSC::BytecodeLivenessAnalysis::compute):
* bytecode/BytecodeLivenessAnalysis.h:
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::CodeBlock):
* bytecode/CodeBlock.h:
(JSC::CodeBlock::livenessAnalysis):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159141 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ca94cf42
2013-11-12 Filip Pizlo <fpizlo@apple.com>
Liveness analysis should take less memory in CodeBlock when it is unused
https://bugs.webkit.org/show_bug.cgi?id=124225
Reviewed by Mark Hahnenberg.
Basically, I turned CodeBlock::m_livenessAnalysis into a pointer that is null by
default.
* bytecode/BytecodeLivenessAnalysis.cpp:
(JSC::BytecodeLivenessAnalysis::BytecodeLivenessAnalysis):
(JSC::BytecodeLivenessAnalysis::runLivenessFixpoint):
(JSC::BytecodeLivenessAnalysis::operandIsLiveAtBytecodeOffset):
(JSC::BytecodeLivenessAnalysis::dumpResults):
(JSC::BytecodeLivenessAnalysis::compute):
* bytecode/BytecodeLivenessAnalysis.h:
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::CodeBlock):
* bytecode/CodeBlock.h:
(JSC::CodeBlock::livenessAnalysis):
2013-11-11 Oliver Hunt <oliver@apple.com>
Support unprefixed deconstructing assignment
......
......@@ -33,16 +33,9 @@ namespace JSC {
BytecodeLivenessAnalysis::BytecodeLivenessAnalysis(CodeBlock* codeBlock)
: m_codeBlock(codeBlock)
, m_computed(false)
{
ASSERT(m_codeBlock);
}
BytecodeLivenessAnalysis::BytecodeLivenessAnalysis(const BytecodeLivenessAnalysis& other)
: m_codeBlock(other.m_codeBlock)
, m_basicBlocks(other.m_basicBlocks)
, m_computed(other.m_computed)
{
compute();
}
static int numberOfCapturedVariables(CodeBlock* codeBlock)
......@@ -588,7 +581,6 @@ static void computeLocalLivenessForBlock(CodeBlock* codeBlock, BytecodeBasicBloc
void BytecodeLivenessAnalysis::runLivenessFixpoint()
{
ASSERT(!m_computed);
UnlinkedCodeBlock* unlinkedCodeBlock = m_codeBlock->unlinkedCodeBlock();
unsigned numberOfVariables = unlinkedCodeBlock->m_numVars +
unlinkedCodeBlock->m_numCalleeRegisters - numberOfCapturedVariables(m_codeBlock);
......@@ -631,7 +623,6 @@ void BytecodeLivenessAnalysis::getLivenessInfoForNonCapturedVarsAtBytecodeOffset
bool BytecodeLivenessAnalysis::operandIsLiveAtBytecodeOffset(int operand, unsigned bytecodeOffset)
{
int numCapturedVars = numberOfCapturedVariables(m_codeBlock);
ASSERT(m_computed);
if (VirtualRegister(operand).isArgument())
return true;
if (operand <= captureStart(m_codeBlock) && operand > captureEnd(m_codeBlock))
......@@ -678,7 +669,6 @@ FastBitVector BytecodeLivenessAnalysis::getLivenessInfoAtBytecodeOffset(unsigned
void BytecodeLivenessAnalysis::dumpResults()
{
ASSERT(m_computed);
Interpreter* interpreter = m_codeBlock->vm()->interpreter;
Instruction* instructionsBegin = m_codeBlock->instructions().begin();
for (unsigned i = 0; i < m_basicBlocks.size(); i++) {
......@@ -733,13 +723,9 @@ void BytecodeLivenessAnalysis::dumpResults()
void BytecodeLivenessAnalysis::compute()
{
if (m_computed)
return;
computeBytecodeBasicBlocks(m_codeBlock, m_basicBlocks);
ASSERT(m_basicBlocks.size());
runLivenessFixpoint();
m_computed = true;
if (Options::dumpBytecodeLivenessResults())
dumpResults();
......
......@@ -38,21 +38,12 @@ class CodeBlock;
class BytecodeLivenessAnalysis {
public:
BytecodeLivenessAnalysis(CodeBlock*);
BytecodeLivenessAnalysis(const BytecodeLivenessAnalysis&);
bool operandIsLiveAtBytecodeOffset(int operand, unsigned bytecodeOffset);
FastBitVector getLivenessInfoAtBytecodeOffset(unsigned bytecodeOffset);
bool hasBeenComputed() { return m_computed; }
void compute();
void computeIfNecessary()
{
if (m_computed)
return;
compute();
}
private:
void compute();
void runLivenessFixpoint();
void dumpResults();
......@@ -60,8 +51,6 @@ private:
CodeBlock* m_codeBlock;
Vector<RefPtr<BytecodeBasicBlock> > m_basicBlocks;
bool m_computed;
};
} // namespace JSC
......
......@@ -1572,7 +1572,6 @@ CodeBlock::CodeBlock(CopyParsedBlockTag, CodeBlock& other)
, m_optimizationDelayCounter(0)
, m_reoptimizationRetryCounter(0)
, m_hash(other.m_hash)
, m_livenessAnalysis(other.m_livenessAnalysis)
#if ENABLE(JIT)
, m_capabilityLevelState(DFG::CapabilityLevelNotSet)
#endif
......@@ -1618,7 +1617,6 @@ CodeBlock::CodeBlock(ScriptExecutable* ownerExecutable, UnlinkedCodeBlock* unlin
, m_osrExitCounter(0)
, m_optimizationDelayCounter(0)
, m_reoptimizationRetryCounter(0)
, m_livenessAnalysis(this)
#if ENABLE(JIT)
, m_capabilityLevelState(DFG::CapabilityLevelNotSet)
#endif
......
......@@ -679,7 +679,12 @@ public:
JSGlobalObject* globalObjectFor(CodeOrigin);
BytecodeLivenessAnalysis& livenessAnalysis() { return m_livenessAnalysis; }
BytecodeLivenessAnalysis& livenessAnalysis()
{
if (!m_livenessAnalysis)
m_livenessAnalysis = std::make_unique<BytecodeLivenessAnalysis>(this);
return *m_livenessAnalysis;
}
// Jump Tables
......@@ -1077,7 +1082,7 @@ private:
mutable CodeBlockHash m_hash;
BytecodeLivenessAnalysis m_livenessAnalysis;
std::unique_ptr<BytecodeLivenessAnalysis> m_livenessAnalysis;
struct RareData {
WTF_MAKE_FAST_ALLOCATED;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment