Skip to content

Commit dfc14e3

Browse files
author
Mark Lam
committed
Add predecessor info to dumps from JSC_dumpBytecodeLivenessResults=true.
https://bugs.webkit.org/show_bug.cgi?id=165958 Reviewed by Saam Barati. Also: 1. refactored the code to use a common lambda function to dump FastBitVectors. 2. list successors by their block index instead of pointers. * bytecode/BytecodeLivenessAnalysis.cpp: (JSC::BytecodeLivenessAnalysis::dumpResults): Canonical link: https://commits.webkit.org/183561@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209929 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent fe931a8 commit dfc14e3

2 files changed

Lines changed: 49 additions & 12 deletions

File tree

‎Source/JavaScriptCore/ChangeLog‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
2016-12-16 Mark Lam <mark.lam@apple.com>
2+
3+
Add predecessor info to dumps from JSC_dumpBytecodeLivenessResults=true.
4+
https://bugs.webkit.org/show_bug.cgi?id=165958
5+
6+
Reviewed by Saam Barati.
7+
8+
Also:
9+
1. refactored the code to use a common lambda function to dump FastBitVectors.
10+
2. list successors by their block index instead of pointers.
11+
12+
* bytecode/BytecodeLivenessAnalysis.cpp:
13+
(JSC::BytecodeLivenessAnalysis::dumpResults):
14+
115
2016-12-16 Saam Barati <sbarati@apple.com>
216

317
WebAssembly: WasmB3IRGenerator should throw exceptions instead of crash

‎Source/JavaScriptCore/bytecode/BytecodeLivenessAnalysis.cpp‎

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,43 @@ void BytecodeLivenessAnalysis::dumpResults()
142142
Interpreter* interpreter = codeBlock->vm()->interpreter;
143143
Instruction* instructionsBegin = codeBlock->instructions().begin();
144144
unsigned i = 0;
145+
146+
unsigned numberOfBlocks = m_graph.size();
147+
Vector<FastBitVector> predecessors(numberOfBlocks);
148+
for (BytecodeBasicBlock* block : m_graph)
149+
predecessors[block->index()].resize(numberOfBlocks);
150+
for (BytecodeBasicBlock* block : m_graph) {
151+
for (unsigned j = 0; j < block->successors().size(); j++) {
152+
unsigned blockIndex = block->index();
153+
unsigned successorIndex = block->successors()[j]->index();
154+
predecessors[successorIndex][blockIndex] = true;
155+
}
156+
}
157+
158+
auto dumpBitVector = [] (FastBitVector& bits) {
159+
for (unsigned j = 0; j < bits.numBits(); j++) {
160+
if (bits[j])
161+
dataLogF(" %u", j);
162+
}
163+
};
164+
145165
for (BytecodeBasicBlock* block : m_graph) {
146166
dataLogF("\nBytecode basic block %u: %p (offset: %u, length: %u)\n", i++, block, block->leaderOffset(), block->totalLength());
147-
dataLogF("Successors: ");
167+
168+
dataLogF("Predecessors:");
169+
dumpBitVector(predecessors[block->index()]);
170+
dataLogF("\n");
171+
172+
dataLogF("Successors:");
173+
FastBitVector successors;
174+
successors.resize(numberOfBlocks);
148175
for (unsigned j = 0; j < block->successors().size(); j++) {
149176
BytecodeBasicBlock* successor = block->successors()[j];
150-
dataLogF("%p ", successor);
177+
successors[successor->index()] = true;
151178
}
179+
dumpBitVector(successors); // Dump in sorted order.
152180
dataLogF("\n");
181+
153182
if (block->isEntryBlock()) {
154183
dataLogF("Entry block %p\n", block);
155184
continue;
@@ -161,12 +190,9 @@ void BytecodeLivenessAnalysis::dumpResults()
161190
for (unsigned bytecodeOffset = block->leaderOffset(); bytecodeOffset < block->leaderOffset() + block->totalLength();) {
162191
const Instruction* currentInstruction = &instructionsBegin[bytecodeOffset];
163192

164-
dataLogF("Live variables: ");
193+
dataLogF("Live variables:");
165194
FastBitVector liveBefore = getLivenessInfoAtBytecodeOffset(bytecodeOffset);
166-
for (unsigned j = 0; j < liveBefore.numBits(); j++) {
167-
if (liveBefore[j])
168-
dataLogF("%u ", j);
169-
}
195+
dumpBitVector(liveBefore);
170196
dataLogF("\n");
171197
codeBlock->dumpBytecode(WTF::dataFile(), codeBlock->globalObject()->globalExec(), instructionsBegin, currentInstruction);
172198

@@ -175,12 +201,9 @@ void BytecodeLivenessAnalysis::dumpResults()
175201
bytecodeOffset += opcodeLength;
176202
}
177203

178-
dataLogF("Live variables: ");
204+
dataLogF("Live variables:");
179205
FastBitVector liveAfter = block->out();
180-
for (unsigned j = 0; j < liveAfter.numBits(); j++) {
181-
if (liveAfter[j])
182-
dataLogF("%u ", j);
183-
}
206+
dumpBitVector(liveAfter);
184207
dataLogF("\n");
185208
}
186209
}

0 commit comments

Comments
 (0)