Changeset 192539 in webkit
- Timestamp:
- Nov 17, 2015, 2:29:54 PM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 3 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r192536 r192539 1 2015-11-17 Filip Pizlo <fpizlo@apple.com> 2 3 Air should lay out code optimally 4 https://bugs.webkit.org/show_bug.cgi?id=150478 5 6 Reviewed by Geoffrey Garen. 7 8 This adds a phase that optimizes code layout using something that's worked well for me in the past. 9 Basically, it just forces pre-ordering on the CFG, except that: 10 11 - Blocks that are only reachable by Rare control flow are scheduled separately, all the way at the 12 end. 13 14 - Successors of the same frequency class are pushed in ascending order of frequency, so that the most 15 frequent successor is scheduled immediately after. 16 17 This also adds the requisite branch flipping, so that a branch's taken successor is not the 18 fall-through block. We want the fall-through to be the not-taken successor if at all possible. 19 20 * JavaScriptCore.xcodeproj/project.pbxproj: 21 * b3/B3BlockWorklist.h: 22 * b3/B3GenericFrequentedBlock.h: 23 (JSC::B3::GenericFrequentedBlock::frequency): 24 (JSC::B3::GenericFrequentedBlock::isRare): 25 (JSC::B3::GenericFrequentedBlock::dump): 26 * b3/B3Procedure.h: 27 * b3/air/AirArg.h: 28 (JSC::B3::Air::Arg::isDoubleCond): 29 (JSC::B3::Air::Arg::isCondition): 30 (JSC::B3::Air::Arg::isSpecial): 31 (JSC::B3::Air::Arg::asDoubleCondition): 32 (JSC::B3::Air::Arg::isInvertible): 33 (JSC::B3::Air::Arg::inverted): 34 * b3/air/AirBasicBlock.h: 35 (JSC::B3::Air::BasicBlock::index): 36 (JSC::B3::Air::BasicBlock::setIndex): 37 (JSC::B3::Air::BasicBlock::size): 38 (JSC::B3::Air::BasicBlock::begin): 39 (JSC::B3::Air::BasicBlock::containsPredecessor): 40 (JSC::B3::Air::BasicBlock::frequency): 41 * b3/air/AirBlockWorklist.h: Added. 42 * b3/air/AirCode.cpp: 43 (JSC::B3::Air::Code::findNextBlock): 44 * b3/air/AirCode.h: 45 (JSC::B3::Air::Code::proc): 46 (JSC::B3::Air::Code::at): 47 (JSC::B3::Air::Code::operator[]): 48 (JSC::B3::Air::Code::blockList): 49 * b3/air/AirGenerate.cpp: 50 (JSC::B3::Air::generate): 51 * b3/air/AirOpcode.opcodes: 52 * b3/air/AirOptimizeBlockOrder.cpp: Added. 53 (JSC::B3::Air::optimizeBlockOrder): 54 * b3/air/AirOptimizeBlockOrder.h: Added. 55 1 56 2015-11-17 Andreas Kling <akling@apple.com> 2 57 -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r192321 r192539 287 287 0F338DF91BE96AA80013C88F /* B3CCallValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F338DF71BE96AA80013C88F /* B3CCallValue.cpp */; }; 288 288 0F338DFA1BE96AA80013C88F /* B3CCallValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F338DF81BE96AA80013C88F /* B3CCallValue.h */; }; 289 289 0F338DFD1BED51270013C88F /* AirSimplifyCFG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F338DFB1BED51270013C88F /* AirSimplifyCFG.cpp */; }; 290 290 0F338DFE1BED51270013C88F /* AirSimplifyCFG.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F338DFC1BED51270013C88F /* AirSimplifyCFG.h */; }; 291 291 0F338E0B1BF0276C0013C88F /* B3Compilation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F338DFF1BF0276C0013C88F /* B3Compilation.cpp */; }; … … 301 301 0F338E151BF0276C0013C88F /* B3ValueKey.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F338E091BF0276C0013C88F /* B3ValueKey.h */; }; 302 302 0F338E161BF0276C0013C88F /* B3ValueKeyInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F338E0A1BF0276C0013C88F /* B3ValueKeyInlines.h */; }; 303 303 0F338E1B1BF286EA0013C88F /* B3BlockInsertionSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F338E171BF286EA0013C88F /* B3BlockInsertionSet.cpp */; }; 304 304 0F338E1C1BF286EA0013C88F /* B3BlockInsertionSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F338E181BF286EA0013C88F /* B3BlockInsertionSet.h */; }; 305 305 0F338E1D1BF286EA0013C88F /* B3LowerMacros.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F338E191BF286EA0013C88F /* B3LowerMacros.cpp */; }; 306 306 0F338E1E1BF286EA0013C88F /* B3LowerMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F338E1A1BF286EA0013C88F /* B3LowerMacros.h */; }; 307 307 0F34B14916D42010001CDA5A /* DFGUseKind.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F34B14716D4200E001CDA5A /* DFGUseKind.cpp */; }; 308 308 0F34B14A16D42013001CDA5A /* DFGUseKind.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F34B14816D4200E001CDA5A /* DFGUseKind.h */; }; 309 309 0F38B01117CF078000B144D3 /* LLIntEntrypoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F38B00F17CF077F00B144D3 /* LLIntEntrypoint.cpp */; }; 310 310 0F38B01217CF078300B144D3 /* LLIntEntrypoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F38B01017CF077F00B144D3 /* LLIntEntrypoint.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 528 528 0FB17662196B8F9E0091052A /* DFGPureValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FB1765E196B8F9E0091052A /* DFGPureValue.cpp */; }; 529 529 0FB17663196B8F9E0091052A /* DFGPureValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FB1765F196B8F9E0091052A /* DFGPureValue.h */; }; 530 0FB3878E1BFBC44D00E3AB1E /* AirBlockWorklist.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FB3878B1BFBC44D00E3AB1E /* AirBlockWorklist.h */; }; 531 0FB3878F1BFBC44D00E3AB1E /* AirOptimizeBlockOrder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FB3878C1BFBC44D00E3AB1E /* AirOptimizeBlockOrder.cpp */; }; 532 0FB387901BFBC44D00E3AB1E /* AirOptimizeBlockOrder.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FB3878D1BFBC44D00E3AB1E /* AirOptimizeBlockOrder.h */; }; 530 533 0FB438A319270B1D00E1FBC9 /* StructureSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FB438A219270B1D00E1FBC9 /* StructureSet.cpp */; }; 531 534 0FB4FB731BC843140025CA5A /* FTLLazySlowPath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FB4FB701BC843140025CA5A /* FTLLazySlowPath.cpp */; }; … … 2336 2339 0F338DF71BE96AA80013C88F /* B3CCallValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = B3CCallValue.cpp; path = b3/B3CCallValue.cpp; sourceTree = "<group>"; }; 2337 2340 0F338DF81BE96AA80013C88F /* B3CCallValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = B3CCallValue.h; path = b3/B3CCallValue.h; sourceTree = "<group>"; }; 2338 2341 0F338DFB1BED51270013C88F /* AirSimplifyCFG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AirSimplifyCFG.cpp; path = b3/air/AirSimplifyCFG.cpp; sourceTree = "<group>"; }; 2339 2342 0F338DFC1BED51270013C88F /* AirSimplifyCFG.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AirSimplifyCFG.h; path = b3/air/AirSimplifyCFG.h; sourceTree = "<group>"; }; 2340 2343 0F338DFF1BF0276C0013C88F /* B3Compilation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = B3Compilation.cpp; path = b3/B3Compilation.cpp; sourceTree = "<group>"; }; … … 2350 2353 0F338E091BF0276C0013C88F /* B3ValueKey.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = B3ValueKey.h; path = b3/B3ValueKey.h; sourceTree = "<group>"; }; 2351 2354 0F338E0A1BF0276C0013C88F /* B3ValueKeyInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = B3ValueKeyInlines.h; path = b3/B3ValueKeyInlines.h; sourceTree = "<group>"; }; 2352 2355 0F338E171BF286EA0013C88F /* B3BlockInsertionSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = B3BlockInsertionSet.cpp; path = b3/B3BlockInsertionSet.cpp; sourceTree = "<group>"; }; 2353 2356 0F338E181BF286EA0013C88F /* B3BlockInsertionSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = B3BlockInsertionSet.h; path = b3/B3BlockInsertionSet.h; sourceTree = "<group>"; }; 2354 2357 0F338E191BF286EA0013C88F /* B3LowerMacros.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = B3LowerMacros.cpp; path = b3/B3LowerMacros.cpp; sourceTree = "<group>"; }; 2355 2358 0F338E1A1BF286EA0013C88F /* B3LowerMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = B3LowerMacros.h; path = b3/B3LowerMacros.h; sourceTree = "<group>"; }; 2356 2359 0F34B14716D4200E001CDA5A /* DFGUseKind.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGUseKind.cpp; path = dfg/DFGUseKind.cpp; sourceTree = "<group>"; }; 2357 2360 0F34B14816D4200E001CDA5A /* DFGUseKind.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGUseKind.h; path = dfg/DFGUseKind.h; sourceTree = "<group>"; }; 2358 2361 0F38B00F17CF077F00B144D3 /* LLIntEntrypoint.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = LLIntEntrypoint.cpp; path = llint/LLIntEntrypoint.cpp; sourceTree = "<group>"; }; 2359 2362 0F38B01017CF077F00B144D3 /* LLIntEntrypoint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = LLIntEntrypoint.h; path = llint/LLIntEntrypoint.h; sourceTree = "<group>"; }; … … 2576 2579 0FB1765E196B8F9E0091052A /* DFGPureValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGPureValue.cpp; path = dfg/DFGPureValue.cpp; sourceTree = "<group>"; }; 2577 2580 0FB1765F196B8F9E0091052A /* DFGPureValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGPureValue.h; path = dfg/DFGPureValue.h; sourceTree = "<group>"; }; 2581 0FB3878B1BFBC44D00E3AB1E /* AirBlockWorklist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AirBlockWorklist.h; path = b3/air/AirBlockWorklist.h; sourceTree = "<group>"; }; 2582 0FB3878C1BFBC44D00E3AB1E /* AirOptimizeBlockOrder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AirOptimizeBlockOrder.cpp; path = b3/air/AirOptimizeBlockOrder.cpp; sourceTree = "<group>"; }; 2583 0FB3878D1BFBC44D00E3AB1E /* AirOptimizeBlockOrder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AirOptimizeBlockOrder.h; path = b3/air/AirOptimizeBlockOrder.h; sourceTree = "<group>"; }; 2578 2584 0FB438A219270B1D00E1FBC9 /* StructureSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StructureSet.cpp; sourceTree = "<group>"; }; 2579 2585 0FB4B51016B3A964003F696B /* DFGMinifiedID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGMinifiedID.h; path = dfg/DFGMinifiedID.h; sourceTree = "<group>"; }; … … 4569 4575 0FEC854C1BDACDC70080FF74 /* AirBasicBlock.cpp */, 4570 4576 0FEC854D1BDACDC70080FF74 /* AirBasicBlock.h */, 4577 0FB3878B1BFBC44D00E3AB1E /* AirBlockWorklist.h */, 4571 4578 0FEC854E1BDACDC70080FF74 /* AirCCallSpecial.cpp */, 4572 4579 0FEC854F1BDACDC70080FF74 /* AirCCallSpecial.h */, … … 4591 4598 0FEC855D1BDACDC70080FF74 /* AirLiveness.h */, 4592 4599 264091FA1BE2FD4100684DB2 /* AirOpcode.opcodes */, 4600 0FB3878C1BFBC44D00E3AB1E /* AirOptimizeBlockOrder.cpp */, 4601 0FB3878D1BFBC44D00E3AB1E /* AirOptimizeBlockOrder.h */, 4593 4602 0FEC855E1BDACDC70080FF74 /* AirPhaseScope.cpp */, 4594 4603 0FEC855F1BDACDC70080FF74 /* AirPhaseScope.h */, … … 7502 7511 0FF729B9166AD360000F5BA3 /* ProfilerBytecodes.h in Headers */, 7503 7512 0F13912A16771C36009CCB07 /* ProfilerBytecodeSequence.h in Headers */, 7513 0FB387901BFBC44D00E3AB1E /* AirOptimizeBlockOrder.h in Headers */, 7504 7514 0FF729BA166AD360000F5BA3 /* ProfilerCompilation.h in Headers */, 7505 7515 0FF729BB166AD360000F5BA3 /* ProfilerCompilationKind.h in Headers */, … … 7603 7613 BC18C4680E16F5CD00B34460 /* StringObject.h in Headers */, 7604 7614 BC18C46A0E16F5CD00B34460 /* StringPrototype.h in Headers */, 7615 0FB3878E1BFBC44D00E3AB1E /* AirBlockWorklist.h in Headers */, 7605 7616 142E313B134FF0A600AFADB5 /* Strong.h in Headers */, 7606 7617 145722861437E140005FDE26 /* StrongInlines.h in Headers */, … … 8433 8444 A737810D1799EA2E00817533 /* DFGNaturalLoops.cpp in Sources */, 8434 8445 0FF0F19C16B72A03005DF95B /* DFGNode.cpp in Sources */, 8446 0FB3878F1BFBC44D00E3AB1E /* AirOptimizeBlockOrder.cpp in Sources */, 8435 8447 0FA581BA150E952C00B9A2D9 /* DFGNodeFlags.cpp in Sources */, 8436 8448 0F5D085D1B8CF99D001143B4 /* DFGNodeOrigin.cpp in Sources */, -
trunk/Source/JavaScriptCore/b3/B3BlockWorklist.h
r191705 r192539 36 36 namespace JSC { namespace B3 { 37 37 38 class BasicBlock;39 40 38 typedef GraphNodeWorklist<BasicBlock*, IndexSet<BasicBlock>> BlockWorklist; 41 39 -
trunk/Source/JavaScriptCore/b3/B3GenericFrequentedBlock.h
r192295 r192539 68 68 FrequencyClass& frequency() { return m_frequency; } 69 69 70 bool isRare() const { return frequency() == FrequencyClass::Rare; } 71 70 72 void dump(PrintStream& out) const 71 73 { -
trunk/Source/JavaScriptCore/b3/B3Procedure.h
r192295 r192539 54 54 JS_EXPORT_PRIVATE ~Procedure(); 55 55 56 JS_EXPORT_PRIVATE BasicBlock* addBlock(double frequency = PNaN);56 JS_EXPORT_PRIVATE BasicBlock* addBlock(double frequency = 1); 57 57 58 58 template<typename ValueType, typename... Arguments> -
trunk/Source/JavaScriptCore/b3/air/AirArg.h
r192072 r192539 381 381 } 382 382 383 bool isCondition() const 384 { 385 switch (kind()) { 386 case RelCond: 387 case ResCond: 388 case DoubleCond: 389 return true; 390 default: 391 return false; 392 } 393 } 394 383 395 bool isSpecial() const 384 396 { … … 725 737 } 726 738 739 // Tells you if the Arg is invertible. Only condition arguments are invertible, and even for those, there 740 // are a few exceptions - notably Overflow and Signed. 741 bool isInvertible() const 742 { 743 switch (kind()) { 744 case RelCond: 745 case DoubleCond: 746 return true; 747 case ResCond: 748 return MacroAssembler::isInvertible(asResultCondition()); 749 default: 750 return false; 751 } 752 } 753 727 754 // This is valid for condition arguments. It will invert them. 728 755 Arg inverted(bool inverted = true) const -
trunk/Source/JavaScriptCore/b3/air/AirBasicBlock.h
r192121 r192539 51 51 52 52 unsigned index() const { return m_index; } 53 54 // This method is exposed for phases that mess with the layout of basic blocks. Currently that means just 55 // optimizeBlockOrder(). 56 void setIndex(unsigned index) { m_index = index; } 53 57 54 58 unsigned size() const { return m_insts.size(); } … … 111 115 bool containsPredecessor(BasicBlock* predecessor) const { return m_predecessors.contains(predecessor); } 112 116 117 double frequency() const { return m_frequency; } 118 113 119 void dump(PrintStream&) const; 114 120 void deepDump(PrintStream&) const; -
trunk/Source/JavaScriptCore/b3/air/AirCode.cpp
r192345 r192539 129 129 BasicBlock* Code::findNextBlock(BasicBlock* block) const 130 130 { 131 return at(findNextBlockIndex(block->index())); 131 unsigned index = findNextBlockIndex(block->index()); 132 if (index < size()) 133 return at(index); 134 return nullptr; 132 135 } 133 136 -
trunk/Source/JavaScriptCore/b3/air/AirCode.h
r192183 r192539 56 56 Procedure& proc() { return m_proc; } 57 57 58 BasicBlock* addBlock(double frequency = PNaN);58 BasicBlock* addBlock(double frequency = 1); 59 59 60 60 StackSlot* addStackSlot(unsigned byteSize, StackSlotKind, StackSlotValue* = nullptr); … … 115 115 BasicBlock* at(unsigned index) const { return m_blocks[index].get(); } 116 116 BasicBlock* operator[](unsigned index) const { return at(index); } 117 118 // This is used by phases that optimize the block list. You shouldn't use this unless you really know 119 // what you're doing. 120 Vector<std::unique_ptr<BasicBlock>>& blockList() { return m_blocks; } 117 121 118 122 // Finds the smallest index' such that at(index') != null and index' >= index. -
trunk/Source/JavaScriptCore/b3/air/AirGenerate.cpp
r192497 r192539 35 35 #include "AirHandleCalleeSaves.h" 36 36 #include "AirIteratedRegisterCoalescing.h" 37 #include "AirOptimizeBlockOrder.h" 37 38 #include "AirReportUsedRegisters.h" 38 39 #include "AirSimplifyCFG.h" … … 87 88 simplifyCFG(code); 88 89 89 // FIXME: We should really have a code layout optimization here. 90 // https://bugs.webkit.org/show_bug.cgi?id=150478 90 // This sorts the basic blocks in Code to achieve an ordering that maximizes the likelihood that a high 91 // frequency successor is also the fall-through target. 92 optimizeBlockOrder(code); 91 93 94 // This is needed to satisfy a requirement of B3::StackmapValue. 92 95 reportUsedRegisters(code); 93 96 -
trunk/Source/JavaScriptCore/b3/air/AirOpcode.opcodes
r192524 r192539 274 274 ResCond, Tmp, Tmp, Tmp 275 275 276 # Note that branches have some logic in AirOptimizeBlockOrder.cpp. If you add new branches, please make sure 277 # you opt them into the block order optimizations. 278 276 279 Branch8 U:G, U:G, U:G /branch 277 280 RelCond, Addr, Imm -
trunk/Source/WTF/ChangeLog
r192376 r192539 1 2015-11-17 Filip Pizlo <fpizlo@apple.com> 2 3 Air should lay out code optimally 4 https://bugs.webkit.org/show_bug.cgi?id=150478 5 6 Reviewed by Geoffrey Garen. 7 8 * wtf/GraphNodeWorklist.h: 9 (WTF::GraphNodeWorklist::push): 10 (WTF::GraphNodeWorklist::isEmpty): 11 (WTF::GraphNodeWorklist::notEmpty): 12 (WTF::GraphNodeWorklist::pop): 13 1 14 2015-11-11 Anders Carlsson <andersca@apple.com> 2 15 -
trunk/Source/WTF/wtf/GraphNodeWorklist.h
r191865 r192539 46 46 } 47 47 48 bool isEmpty() const { return m_stack.isEmpty(); } 48 49 bool notEmpty() const { return !m_stack.isEmpty(); } 49 50
Note:
See TracChangeset
for help on using the changeset viewer.