Skip to content

Commit 9b94cc7

Browse files
committed
[JSC] Add index() / setIndex() to DFG::BasicBlock
https://bugs.webkit.org/show_bug.cgi?id=317621 rdar://180352661 Reviewed by Dan Hecht. Add DFG::BasicBlock::index() getter / setter and making index member to m_index and make it private member field. This makes DFG::BasicBlock more similar to B3::BasicBlock, which allows sharing code easily. We would like to unify DFG::SSACalculator and B3::SSACalculator as they are almost the same. By doing so, now we can use IndexMap for both DFG and B3. Use IndexMap and remove BlockMap. * Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj: * Source/JavaScriptCore/dfg/DFGArgumentsEliminationPhase.cpp: * Source/JavaScriptCore/dfg/DFGAtTailAbstractState.cpp: (JSC::DFG::AtTailAbstractState::AtTailAbstractState): * Source/JavaScriptCore/dfg/DFGAtTailAbstractState.h: * Source/JavaScriptCore/dfg/DFGBackwardsPropagationPhase.cpp: (JSC::DFG::BackwardsPropagationPhase::BackwardsPropagationPhase): * Source/JavaScriptCore/dfg/DFGBasicBlock.cpp: (JSC::DFG::BasicBlock::BasicBlock): (JSC::DFG::BasicBlock::dump const): * Source/JavaScriptCore/dfg/DFGBasicBlock.h: (JSC::DFG::BasicBlock::index const): (JSC::DFG::BasicBlock::setIndex): * Source/JavaScriptCore/dfg/DFGBlockInsertionSet.cpp: (JSC::DFG::BlockInsertionSet::insertBefore): (JSC::DFG::BlockInsertionSet::execute): * Source/JavaScriptCore/dfg/DFGBlockMap.h: Removed. * Source/JavaScriptCore/dfg/DFGBlockMapInlines.h: Removed. * Source/JavaScriptCore/dfg/DFGBlockSet.h: (JSC::DFG::BlockSet::add): (JSC::DFG::BlockSet::remove): (JSC::DFG::BlockSet::contains const): * Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::allocateUntargetableBlock): * Source/JavaScriptCore/dfg/DFGCFG.h: (JSC::DFG::CFG::newMap): (JSC::DFG::CFG::index const): * Source/JavaScriptCore/dfg/DFGCSEPhase.cpp: * Source/JavaScriptCore/dfg/DFGCombinedLiveness.cpp: (JSC::DFG::CombinedLiveness::CombinedLiveness): * Source/JavaScriptCore/dfg/DFGCombinedLiveness.h: * Source/JavaScriptCore/dfg/DFGGraph.cpp: (JSC::DFG::Graph::dumpBlockHeader): (JSC::DFG::Graph::dump): (JSC::DFG::Graph::appendIonGraphPass): * Source/JavaScriptCore/dfg/DFGGraph.h: * Source/JavaScriptCore/dfg/DFGIntegerRangeOptimizationPhase.cpp: * Source/JavaScriptCore/dfg/DFGJITCompiler.cpp: (JSC::DFG::JITCompiler::link): * Source/JavaScriptCore/dfg/DFGLivenessAnalysisPhase.cpp: * Source/JavaScriptCore/dfg/DFGMovHintRemovalPhase.cpp: * Source/JavaScriptCore/dfg/DFGOSRAvailabilityAnalysisPhase.cpp: (JSC::DFG::OSRAvailabilityAnalysisPhase::run): (JSC::DFG::OSRAvailabilityAnalysisPhase::validateNode): (JSC::DFG::validateOSRExitAvailability): * Source/JavaScriptCore/dfg/DFGObjectAllocationSinkingPhase.cpp: * Source/JavaScriptCore/dfg/DFGPutStackSinkingPhase.cpp: * Source/JavaScriptCore/dfg/DFGSSACalculator.cpp: (JSC::DFG::SSACalculator::SSACalculator): (JSC::DFG::SSACalculator::ensureDominanceFrontiers): * Source/JavaScriptCore/dfg/DFGSSACalculator.h: (JSC::DFG::SSACalculator::computePhis): * Source/JavaScriptCore/dfg/DFGSSAConversionPhase.cpp: * Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileCurrentBlock): * Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h: (JSC::DFG::SpeculativeJIT::nextBlock): * Source/JavaScriptCore/dfg/DFGStoreBarrierInsertionPhase.cpp: * Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileBlock): (JSC::FTL::DFG::LowerDFGToB3::compileCompareStrictEq): Canonical link: https://commits.webkit.org/315651@main
1 parent ea32ddc commit 9b94cc7

32 files changed

Lines changed: 109 additions & 276 deletions

‎Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,6 @@
512512
0FC20CB61852E2C600C9E954 /* DFGStrengthReductionPhase.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FC20CB41852E2C600C9E954 /* DFGStrengthReductionPhase.h */; };
513513
0FC20CBA18556A3500C9E954 /* DFGSSALoweringPhase.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FC20CB818556A3500C9E954 /* DFGSSALoweringPhase.h */; };
514514
0FC314121814559100033232 /* RegisterSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FC314101814559100033232 /* RegisterSet.h */; settings = {ATTRIBUTES = (Private, ); }; };
515-
0FC3CCFC19ADA410006AC72A /* DFGBlockMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FC3CCF519ADA410006AC72A /* DFGBlockMap.h */; };
516-
0FC3CCFD19ADA410006AC72A /* DFGBlockMapInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FC3CCF619ADA410006AC72A /* DFGBlockMapInlines.h */; };
517515
0FC3CCFE19ADA410006AC72A /* DFGBlockSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FC3CCF719ADA410006AC72A /* DFGBlockSet.h */; };
518516
0FC3CD0019ADA410006AC72A /* DFGBlockWorklist.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FC3CCF919ADA410006AC72A /* DFGBlockWorklist.h */; };
519517
0FC712DF17CD877C008CC93C /* DeferredCompilationCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FC712DD17CD8778008CC93C /* DeferredCompilationCallback.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -3550,8 +3548,6 @@
35503548
0FC20CB818556A3500C9E954 /* DFGSSALoweringPhase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGSSALoweringPhase.h; path = dfg/DFGSSALoweringPhase.h; sourceTree = "<group>"; };
35513549
0FC314101814559100033232 /* RegisterSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegisterSet.h; sourceTree = "<group>"; };
35523550
0FC3141418146D7000033232 /* RegisterSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegisterSet.cpp; sourceTree = "<group>"; };
3553-
0FC3CCF519ADA410006AC72A /* DFGBlockMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGBlockMap.h; path = dfg/DFGBlockMap.h; sourceTree = "<group>"; };
3554-
0FC3CCF619ADA410006AC72A /* DFGBlockMapInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGBlockMapInlines.h; path = dfg/DFGBlockMapInlines.h; sourceTree = "<group>"; };
35553551
0FC3CCF719ADA410006AC72A /* DFGBlockSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGBlockSet.h; path = dfg/DFGBlockSet.h; sourceTree = "<group>"; };
35563552
0FC3CCF919ADA410006AC72A /* DFGBlockWorklist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGBlockWorklist.h; path = dfg/DFGBlockWorklist.h; sourceTree = "<group>"; };
35573553
0FC712DC17CD8778008CC93C /* DeferredCompilationCallback.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DeferredCompilationCallback.cpp; sourceTree = "<group>"; };
@@ -9847,8 +9843,6 @@
98479843
0FD5652216AB780A00197653 /* DFGBasicBlockInlines.h */,
98489844
A7D89CE417A0B8CC00773AD8 /* DFGBlockInsertionSet.cpp */,
98499845
A7D89CE517A0B8CC00773AD8 /* DFGBlockInsertionSet.h */,
9850-
0FC3CCF519ADA410006AC72A /* DFGBlockMap.h */,
9851-
0FC3CCF619ADA410006AC72A /* DFGBlockMapInlines.h */,
98529846
0FBF158A19B7A53100695DD0 /* DFGBlockSet.cpp */,
98539847
0FC3CCF719ADA410006AC72A /* DFGBlockSet.h */,
98549848
0FBF158B19B7A53100695DD0 /* DFGBlockSetInlines.h */,
@@ -11558,8 +11552,6 @@
1155811552
0F620176143FCD3B0068B77C /* DFGBasicBlock.h in Headers */,
1155911553
0FFB921A16D02EC50055A5DB /* DFGBasicBlockInlines.h in Headers */,
1156011554
A7D89CF417A0B8CC00773AD8 /* DFGBlockInsertionSet.h in Headers */,
11561-
0FC3CCFC19ADA410006AC72A /* DFGBlockMap.h in Headers */,
11562-
0FC3CCFD19ADA410006AC72A /* DFGBlockMapInlines.h in Headers */,
1156311555
0FC3CCFE19ADA410006AC72A /* DFGBlockSet.h in Headers */,
1156411556
0FBF158D19B7A53100695DD0 /* DFGBlockSetInlines.h in Headers */,
1156511557
0FC3CD0019ADA410006AC72A /* DFGBlockWorklist.h in Headers */,

‎Source/JavaScriptCore/dfg/DFGArgumentsEliminationPhase.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "ArrayPrototype.h"
3232
#include "ClonedArguments.h"
3333
#include "DFGArgumentsUtilities.h"
34-
#include "DFGBlockMapInlines.h"
34+
#include <wtf/IndexMap.h>
3535
#include "DFGClobberize.h"
3636
#include "DFGForAllKills.h"
3737
#include "DFGGraph.h"
@@ -503,7 +503,7 @@ class ArgumentsEliminationPhase : public Phase {
503503
m_graph.initializeNodeOwners();
504504
CombinedLiveness combinedLiveness(m_graph);
505505

506-
BlockMap<Operands<bool>> clobberedByBlock(m_graph);
506+
IndexMap<BasicBlock*, Operands<bool>> clobberedByBlock(m_graph.numBlocks());
507507
for (BasicBlock* block : m_graph.blocksInNaturalOrder()) {
508508
Operands<bool>& clobberedByThisBlock = clobberedByBlock[block];
509509
clobberedByThisBlock = Operands<bool>(OperandsLike, m_graph.block(0)->variablesAtHead);

‎Source/JavaScriptCore/dfg/DFGAtTailAbstractState.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
#include "config.h"
2727
#include "DFGAtTailAbstractState.h"
28-
#include "DFGBlockMapInlines.h"
28+
#include <wtf/IndexMap.h>
2929

3030
#if ENABLE(DFG_JIT)
3131

@@ -35,8 +35,8 @@ namespace JSC { namespace DFG {
3535

3636
AtTailAbstractState::AtTailAbstractState(Graph& graph)
3737
: m_graph(graph)
38-
, m_valuesAtTailMap(m_graph)
39-
, m_tupleAbstractValues(m_graph)
38+
, m_valuesAtTailMap(m_graph.numBlocks())
39+
, m_tupleAbstractValues(m_graph.numBlocks())
4040
{
4141
for (BasicBlock* block : graph.blocksInNaturalOrder()) {
4242
auto& valuesAtTail = m_valuesAtTailMap.at(block);

‎Source/JavaScriptCore/dfg/DFGAtTailAbstractState.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include "DFGAbstractInterpreterClobberState.h"
3131
#include "DFGAbstractValue.h"
3232
#include "DFGBasicBlock.h"
33-
#include "DFGBlockMap.h"
33+
#include <wtf/IndexMap.h>
3434
#include "DFGGraph.h"
3535
#include "DFGNodeFlowProjection.h"
3636

@@ -268,8 +268,8 @@ class AtTailAbstractState {
268268

269269
private:
270270
Graph& m_graph;
271-
BlockMap<UncheckedKeyHashMap<NodeFlowProjection, AbstractValue>> m_valuesAtTailMap;
272-
BlockMap<Vector<AbstractValue>> m_tupleAbstractValues;
271+
IndexMap<BasicBlock*, UncheckedKeyHashMap<NodeFlowProjection, AbstractValue>> m_valuesAtTailMap;
272+
IndexMap<BasicBlock*, Vector<AbstractValue>> m_tupleAbstractValues;
273273
BasicBlock* m_block { nullptr };
274274
bool m_trustEdgeProofs { false };
275275
};

‎Source/JavaScriptCore/dfg/DFGBackwardsPropagationPhase.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
#if ENABLE(DFG_JIT)
3030

31-
#include "DFGBlockMapInlines.h"
31+
#include <wtf/IndexMap.h>
3232
#include "DFGGraph.h"
3333
#include "DFGPhase.h"
3434
#include "JSCJSValueInlines.h"
@@ -46,7 +46,7 @@ class BackwardsPropagationPhase : public Phase {
4646
public:
4747
BackwardsPropagationPhase(Graph& graph)
4848
: Phase(graph, "backwards propagation"_s, !graph.afterFixup())
49-
, m_flagsAtHead(graph)
49+
, m_flagsAtHead(graph.numBlocks())
5050
{
5151
}
5252

@@ -720,7 +720,7 @@ class BackwardsPropagationPhase : public Phase {
720720

721721
bool m_allowNestedOverflowingAdditions;
722722

723-
BlockMap<Operands<NodeFlags>> m_flagsAtHead;
723+
IndexMap<BasicBlock*, Operands<NodeFlags>> m_flagsAtHead;
724724
Operands<NodeFlags> m_currentFlags;
725725
};
726726

‎Source/JavaScriptCore/dfg/DFGBasicBlock.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ DEFINE_ALLOCATOR_WITH_HEAP_IDENTIFIER(BasicBlock);
4141

4242
BasicBlock::BasicBlock(BytecodeIndex bytecodeBegin, unsigned numArguments, unsigned numLocals, unsigned numTmps, float executionCount)
4343
: bytecodeBegin(bytecodeBegin)
44-
, index(NoBlock)
44+
, m_index(NoBlock)
4545
, cfaStructureClobberStateAtHead(StructuresAreWatched)
4646
, cfaStructureClobberStateAtTail(StructuresAreWatched)
4747
, cfaBranchDirection(InvalidBranchDirection)
@@ -140,7 +140,7 @@ void BasicBlock::replacePredecessor(BasicBlock* from, BasicBlock* to)
140140

141141
void BasicBlock::dump(PrintStream& out) const
142142
{
143-
out.print("#", index);
143+
out.print("#", m_index);
144144
}
145145

146146
BasicBlock::SSAData::SSAData(BasicBlock* block)

‎Source/JavaScriptCore/dfg/DFGBasicBlock.h‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,10 @@ class BasicBlock {
165165
}
166166

167167
bool isJumpPad() { return m_nodes.size() == 1 && m_nodes[0]->isJump(); }
168-
168+
169+
BlockIndex index() const { return m_index; }
170+
void setIndex(BlockIndex index) { m_index = index; }
171+
169172
void NODELETE removePredecessor(BasicBlock* block);
170173
void NODELETE replacePredecessor(BasicBlock* from, BasicBlock* to);
171174

@@ -192,9 +195,9 @@ class BasicBlock {
192195
// This value is used internally for block linking and OSR entry. It is mostly meaningless
193196
// for other purposes due to inlining.
194197
BytecodeIndex bytecodeBegin;
195-
196-
BlockIndex index;
197-
198+
private:
199+
BlockIndex m_index;
200+
public:
198201
StructureClobberState cfaStructureClobberStateAtHead;
199202
StructureClobberState cfaStructureClobberStateAtTail;
200203
BranchDirection cfaBranchDirection;

‎Source/JavaScriptCore/dfg/DFGBlockInsertionSet.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ BasicBlock* BlockInsertionSet::insert(size_t index, float executionCount)
6060

6161
BasicBlock* BlockInsertionSet::insertBefore(BasicBlock* before, float executionCount)
6262
{
63-
return insert(before->index, executionCount);
63+
return insert(before->index(), executionCount);
6464
}
6565

6666
bool BlockInsertionSet::execute()
@@ -88,7 +88,7 @@ bool BlockInsertionSet::execute()
8888

8989
// Make sure that the blocks know their new indices.
9090
for (unsigned i = 0; i < m_graph.m_blocks.size(); ++i)
91-
m_graph.m_blocks[i]->index = i;
91+
m_graph.m_blocks[i]->setIndex(i);
9292

9393
// And finally, invalidate all analyses that rely on the CFG.
9494
m_graph.invalidateCFG();

‎Source/JavaScriptCore/dfg/DFGBlockMap.h‎

Lines changed: 0 additions & 115 deletions
This file was deleted.

‎Source/JavaScriptCore/dfg/DFGBlockMapInlines.h‎

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)