@@ -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 (" \n Bytecode 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