Changeset 221602 in webkit for trunk/Source/JavaScriptCore/b3
- Timestamp:
- Sep 4, 2017, 8:21:33 PM (8 years ago)
- Location:
- trunk/Source/JavaScriptCore/b3/air
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/b3/air/AirCode.cpp
r216989 r221602 157 157 bool Code::isEntrypoint(BasicBlock* block) const 158 158 { 159 // Note: This function must work both before and after LowerEntrySwitch. 160 159 161 if (m_entrypoints.isEmpty()) 160 162 return !block->index(); … … 165 167 } 166 168 return false; 169 } 170 171 std::optional<unsigned> Code::entrypointIndex(BasicBlock* block) const 172 { 173 RELEASE_ASSERT(m_entrypoints.size()); 174 for (unsigned i = 0; i < m_entrypoints.size(); ++i) { 175 if (m_entrypoints[i].block() == block) 176 return i; 177 } 178 return std::nullopt; 167 179 } 168 180 -
trunk/Source/JavaScriptCore/b3/air/AirCode.h
r216989 r221602 54 54 class CCallSpecial; 55 55 class CFG; 56 class Code; 56 57 class Disassembler; 57 58 58 59 typedef void WasmBoundsCheckGeneratorFunction(CCallHelpers&, GPRReg); 59 60 typedef SharedTask<WasmBoundsCheckGeneratorFunction> WasmBoundsCheckGenerator; 61 62 typedef void PrologueGeneratorFunction(CCallHelpers&, Code&); 63 typedef SharedTask<PrologueGeneratorFunction> PrologueGenerator; 60 64 61 65 // This is an IR that is very close to the bare metal. It requires about 40x more bytes than the … … 166 170 const FrequentedBlock& entrypoint(unsigned index) const { return m_entrypoints[index]; } 167 171 bool isEntrypoint(BasicBlock*) const; 168 172 // Note: It is only valid to call this function after LowerEntrySwitch. 173 std::optional<unsigned> entrypointIndex(BasicBlock*) const; 174 void setPrologueForEntrypoint(unsigned entrypointIndex, RefPtr<PrologueGenerator> generator) 175 { 176 // Note: We allow this to be called even before we set m_entrypoints just for convenience to users of this API. 177 m_entrypointIndexToGenerator.set(entrypointIndex, generator); 178 } 179 RefPtr<PrologueGenerator> prologueGeneratorForEntrypoint(unsigned entrypointIndex) 180 { 181 return m_entrypointIndexToGenerator.get(entrypointIndex); 182 } 183 169 184 // This is used by lowerEntrySwitch(). 170 185 template<typename Vector> … … 354 369 Vector<FrequentedBlock> m_entrypoints; // This is empty until after lowerEntrySwitch(). 355 370 Vector<CCallHelpers::Label> m_entrypointLabels; // This is empty until code generation. 371 HashMap<unsigned, RefPtr<PrologueGenerator>, WTF::IntHash<unsigned>, WTF::UnsignedWithZeroKeyHashTraits<unsigned>> m_entrypointIndexToGenerator; 356 372 RefPtr<WasmBoundsCheckGenerator> m_wasmBoundsCheckGenerator; 357 373 const char* m_lastPhaseName; -
trunk/Source/JavaScriptCore/b3/air/AirGenerate.cpp
r217221 r221602 209 209 disassembler->startBlock(block, jit); 210 210 211 if (code.isEntrypoint(block)) { 211 if (std::optional<unsigned> entrypointIndex = code.entrypointIndex(block)) { 212 ASSERT(code.isEntrypoint(block)); 213 212 214 if (disassembler) 213 215 disassembler->startEntrypoint(jit); 214 216 215 jit.emitFunctionPrologue(); 216 if (code.frameSize()) { 217 AllowMacroScratchRegisterUsageIf allowScratch(jit, isARM64()); 218 jit.addPtr(CCallHelpers::TrustedImm32(-code.frameSize()), MacroAssembler::stackPointerRegister); 217 if (RefPtr<PrologueGenerator> prologueGenerator = code.prologueGeneratorForEntrypoint(*entrypointIndex)) 218 prologueGenerator->run(jit, code); 219 else { 220 jit.emitFunctionPrologue(); 221 if (code.frameSize()) { 222 AllowMacroScratchRegisterUsageIf allowScratch(jit, isARM64()); 223 jit.addPtr(CCallHelpers::TrustedImm32(-code.frameSize()), MacroAssembler::stackPointerRegister); 224 } 225 226 jit.emitSave(code.calleeSaveRegisterAtOffsetList()); 219 227 } 220 221 jit.emitSave(code.calleeSaveRegisterAtOffsetList());222 228 223 229 if (disassembler) 224 230 disassembler->endEntrypoint(jit); 225 } 231 } else 232 ASSERT(!code.isEntrypoint(block)); 226 233 227 234 ASSERT(block->size() >= 1);
Note:
See TracChangeset
for help on using the changeset viewer.