Changeset 215310 in webkit for trunk/Source/JavaScriptCore
- Timestamp:
- Apr 12, 2017, 7:26:53 PM (8 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/CMakeLists.txt
r215292 r215310 110 110 b3/air/AirSimplifyCFG.cpp 111 111 b3/air/AirSpecial.cpp 112 b3/air/AirStackAllocation.cpp 112 113 b3/air/AirStackSlot.cpp 113 114 b3/air/AirStackSlotKind.cpp -
trunk/Source/JavaScriptCore/ChangeLog
r215292 r215310 1 2017-04-12 Filip Pizlo <[email protected]> 2 3 Move common stack allocation utilities out of AirAllocateStackByGraphColoring.cpp 4 https://bugs.webkit.org/show_bug.cgi?id=170799 5 6 Reviewed by Michael Saboff and Keith Miller. 7 8 When I added stack allocation to allocateRegistersByLinearScan, I reused a handful of 9 utility functions from AirAllocateStackByGraphColoring.cpp. I accomplished this by 10 putting their declarations in AirAllocateStackByGraphColoring.h. 11 12 That was pretty weird. 13 14 This patch moves a family of stack allocation helper functions out of 15 AirAllocateStackByGraphColoring.cpp and into the new AirStackAllocation.h|cpp. The 16 linear scan stack allocator no longer has to include the other stack allocator's 17 header, which addresses my OCD. 18 19 I moved the functions transitively reachable from the two functions that the linear 20 scan allocator needed. This forced me to give them better names (i.e. no "fooBarImpl") 21 and short descriptive comments. I think that such comments are useful in code that is 22 doing a convoluted version of some theoretical concept. 23 24 No behavior change. 25 26 * CMakeLists.txt: 27 * JavaScriptCore.xcodeproj/project.pbxproj: 28 * b3/air/AirAllocateRegistersAndStackByLinearScan.cpp: 29 * b3/air/AirAllocateStackByGraphColoring.cpp: 30 (JSC::B3::Air::allocateStackByGraphColoring): 31 (JSC::B3::Air::allocateEscapedStackSlots): Deleted. 32 (JSC::B3::Air::updateFrameSizeBasedOnStackSlots): Deleted. 33 * b3/air/AirAllocateStackByGraphColoring.h: 34 * b3/air/AirStackAllocation.cpp: Added. 35 (JSC::B3::Air::attemptAssignment): 36 (JSC::B3::Air::assign): 37 (JSC::B3::Air::allocateAndGetEscapedStackSlotsWithoutChangingFrameSize): 38 (JSC::B3::Air::allocateEscapedStackSlots): 39 (JSC::B3::Air::updateFrameSizeBasedOnStackSlots): 40 * b3/air/AirStackAllocation.h: Added. 41 1 42 2017-04-12 Filip Pizlo <[email protected]> 2 43 -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r215292 r215310 458 458 0F5CF9841E9D537700C18692 /* AirLowerStackArgs.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F5CF9831E9D537500C18692 /* AirLowerStackArgs.h */; }; 459 459 0F5CF9851E9D537A00C18692 /* AirLowerStackArgs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F5CF9821E9D537500C18692 /* AirLowerStackArgs.cpp */; }; 460 0F5CF9881E9ED65000C18692 /* AirStackAllocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F5CF9861E9ED64E00C18692 /* AirStackAllocation.cpp */; }; 461 0F5CF9891E9ED65200C18692 /* AirStackAllocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F5CF9871E9ED64E00C18692 /* AirStackAllocation.h */; }; 460 462 0F5D085D1B8CF99D001143B4 /* DFGNodeOrigin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F5D085C1B8CF99D001143B4 /* DFGNodeOrigin.cpp */; }; 461 463 0F5EF91E16878F7A003E5C25 /* JITThunks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F5EF91B16878F78003E5C25 /* JITThunks.cpp */; }; … … 2997 2999 0F5CF9821E9D537500C18692 /* AirLowerStackArgs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AirLowerStackArgs.cpp; path = b3/air/AirLowerStackArgs.cpp; sourceTree = "<group>"; }; 2998 3000 0F5CF9831E9D537500C18692 /* AirLowerStackArgs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AirLowerStackArgs.h; path = b3/air/AirLowerStackArgs.h; sourceTree = "<group>"; }; 3001 0F5CF9861E9ED64E00C18692 /* AirStackAllocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AirStackAllocation.cpp; path = b3/air/AirStackAllocation.cpp; sourceTree = "<group>"; }; 3002 0F5CF9871E9ED64E00C18692 /* AirStackAllocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AirStackAllocation.h; path = b3/air/AirStackAllocation.h; sourceTree = "<group>"; }; 2999 3003 0F5D085C1B8CF99D001143B4 /* DFGNodeOrigin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGNodeOrigin.cpp; path = dfg/DFGNodeOrigin.cpp; sourceTree = "<group>"; }; 3000 3004 0F5EF91B16878F78003E5C25 /* JITThunks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JITThunks.cpp; sourceTree = "<group>"; }; … … 5657 5661 0FEC85621BDACDC70080FF74 /* AirSpecial.cpp */, 5658 5662 0FEC85631BDACDC70080FF74 /* AirSpecial.h */, 5663 0F5CF9861E9ED64E00C18692 /* AirStackAllocation.cpp */, 5664 0F5CF9871E9ED64E00C18692 /* AirStackAllocation.h */, 5659 5665 0FEC85661BDACDC70080FF74 /* AirStackSlot.cpp */, 5660 5666 0FEC85671BDACDC70080FF74 /* AirStackSlot.h */, … … 8614 8620 E3FF75331D9CEA1800C7E16D /* DOMJITGetterSetter.h in Headers */, 8615 8621 E35CA1541DBC3A5C00F83516 /* DOMJITHeapRange.h in Headers */, 8622 0F5CF9891E9ED65200C18692 /* AirStackAllocation.h in Headers */, 8616 8623 E3C08E3C1DA41B810039478F /* DOMJITPatchpoint.h in Headers */, 8617 8624 534638711E70CF3D00F12AC1 /* JSRunLoopTimer.h in Headers */, … … 10907 10914 AD2FCBF61DB58DAD00B3E736 /* WebAssemblyMemoryPrototype.cpp in Sources */, 10908 10915 AD2FCC001DB58DAD00B3E736 /* WebAssemblyModuleConstructor.cpp in Sources */, 10916 0F5CF9881E9ED65000C18692 /* AirStackAllocation.cpp in Sources */, 10909 10917 AD2FCC021DB58DAD00B3E736 /* WebAssemblyModulePrototype.cpp in Sources */, 10910 10918 AD4937C71DDD0AAE0077C807 /* WebAssemblyModuleRecord.cpp in Sources */, -
trunk/Source/JavaScriptCore/b3/air/AirAllocateRegistersAndStackByLinearScan.cpp
r215292 r215310 29 29 #if ENABLE(B3_JIT) 30 30 31 #include "AirAllocateStackByGraphColoring.h"32 31 #include "AirArgInlines.h" 33 32 #include "AirCode.h" … … 40 39 #include "AirPhaseScope.h" 41 40 #include "AirRegLiveness.h" 41 #include "AirStackAllocation.h" 42 42 #include "AirTmpInlines.h" 43 43 #include "AirTmpMap.h" -
trunk/Source/JavaScriptCore/b3/air/AirAllocateStackByGraphColoring.cpp
r215292 r215310 35 35 #include "AirLiveness.h" 36 36 #include "AirPhaseScope.h" 37 #include "AirStackAllocation.h" 37 38 #include "StackAlignment.h" 38 39 #include <wtf/ListDump.h> … … 43 44 44 45 const bool verbose = false; 45 46 bool attemptAssignment(47 StackSlot* slot, intptr_t offsetFromFP, const Vector<StackSlot*>& otherSlots)48 {49 if (verbose)50 dataLog("Attempting to assign ", pointerDump(slot), " to ", offsetFromFP, " with interference ", pointerListDump(otherSlots), "\n");51 52 // Need to align it to the slot's desired alignment.53 offsetFromFP = -WTF::roundUpToMultipleOf(slot->alignment(), -offsetFromFP);54 55 for (StackSlot* otherSlot : otherSlots) {56 if (!otherSlot->offsetFromFP())57 continue;58 bool overlap = WTF::rangesOverlap(59 offsetFromFP,60 offsetFromFP + static_cast<intptr_t>(slot->byteSize()),61 otherSlot->offsetFromFP(),62 otherSlot->offsetFromFP() + static_cast<intptr_t>(otherSlot->byteSize()));63 if (overlap)64 return false;65 }66 67 if (verbose)68 dataLog("Assigned ", pointerDump(slot), " to ", offsetFromFP, "\n");69 slot->setOffsetFromFP(offsetFromFP);70 return true;71 }72 73 void assign(StackSlot* slot, const Vector<StackSlot*>& otherSlots)74 {75 if (verbose)76 dataLog("Attempting to assign ", pointerDump(slot), " with interference ", pointerListDump(otherSlots), "\n");77 78 if (attemptAssignment(slot, -static_cast<intptr_t>(slot->byteSize()), otherSlots))79 return;80 81 for (StackSlot* otherSlot : otherSlots) {82 if (!otherSlot->offsetFromFP())83 continue;84 bool didAssign = attemptAssignment(85 slot, otherSlot->offsetFromFP() - static_cast<intptr_t>(slot->byteSize()), otherSlots);86 if (didAssign)87 return;88 }89 90 RELEASE_ASSERT_NOT_REACHED();91 }92 46 93 47 struct CoalescableMove { … … 130 84 }; 131 85 132 Vector<StackSlot*> allocateEscapedStackSlotsImpl(Code& code)133 {134 // Allocate all of the escaped slots in order. This is kind of a crazy algorithm to allow for135 // the possibility of stack slots being assigned frame offsets before we even get here.136 RELEASE_ASSERT(!code.frameSize());137 Vector<StackSlot*> assignedEscapedStackSlots;138 Vector<StackSlot*> escapedStackSlotsWorklist;139 for (StackSlot* slot : code.stackSlots()) {140 if (slot->isLocked()) {141 if (slot->offsetFromFP())142 assignedEscapedStackSlots.append(slot);143 else144 escapedStackSlotsWorklist.append(slot);145 } else {146 // It would be super strange to have an unlocked stack slot that has an offset already.147 ASSERT(!slot->offsetFromFP());148 }149 }150 // This is a fairly expensive loop, but it's OK because we'll usually only have a handful of151 // escaped stack slots.152 while (!escapedStackSlotsWorklist.isEmpty()) {153 StackSlot* slot = escapedStackSlotsWorklist.takeLast();154 assign(slot, assignedEscapedStackSlots);155 assignedEscapedStackSlots.append(slot);156 }157 return assignedEscapedStackSlots;158 }159 160 template<typename Collection>161 void updateFrameSizeBasedOnStackSlotsImpl(Code& code, const Collection& collection)162 {163 unsigned frameSize = 0;164 for (StackSlot* slot : collection)165 frameSize = std::max(frameSize, static_cast<unsigned>(-slot->offsetFromFP()));166 code.setFrameSize(WTF::roundUpToMultipleOf(stackAlignmentBytes(), frameSize));167 }168 169 86 } // anonymous namespace 170 171 void allocateEscapedStackSlots(Code& code)172 {173 updateFrameSizeBasedOnStackSlotsImpl(code, allocateEscapedStackSlotsImpl(code));174 }175 176 void updateFrameSizeBasedOnStackSlots(Code& code)177 {178 updateFrameSizeBasedOnStackSlotsImpl(code, code.stackSlots());179 }180 87 181 88 void allocateStackByGraphColoring(Code& code) … … 185 92 handleCalleeSaves(code); 186 93 187 Vector<StackSlot*> assignedEscapedStackSlots = allocateEscapedStackSlotsImpl(code); 94 Vector<StackSlot*> assignedEscapedStackSlots = 95 allocateAndGetEscapedStackSlotsWithoutChangingFrameSize(code); 188 96 189 97 // Now we handle the spill slots. -
trunk/Source/JavaScriptCore/b3/air/AirAllocateStackByGraphColoring.h
r215292 r215310 42 42 void allocateStackByGraphColoring(Code&); 43 43 44 // These are utilities shared by this phase and allocateRegistersAndStackByLinearScan().45 void allocateEscapedStackSlots(Code&);46 void updateFrameSizeBasedOnStackSlots(Code&);47 48 44 } } } // namespace JSC::B3::Air 49 45
Note:
See TracChangeset
for help on using the changeset viewer.