Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(393)

Side by Side Diff: src/IceELFObjectWriter.cpp

Issue 1784243006: Subzero: Improve the use of timers. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceConverter.cpp ('k') | src/IceGlobalContext.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceELFObjectWriter.cpp - ELF object file writer --------===// 1 //===- subzero/src/IceELFObjectWriter.cpp - ELF object file writer --------===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 /// 9 ///
10 /// \file 10 /// \file
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 if (AlignDiff == 0) 212 if (AlignDiff == 0)
213 return OffsetInFile; 213 return OffsetInFile;
214 Str.writeZeroPadding(AlignDiff); 214 Str.writeZeroPadding(AlignDiff);
215 OffsetInFile += AlignDiff; 215 OffsetInFile += AlignDiff;
216 return OffsetInFile; 216 return OffsetInFile;
217 } 217 }
218 218
219 void ELFObjectWriter::writeFunctionCode(const IceString &FuncName, 219 void ELFObjectWriter::writeFunctionCode(const IceString &FuncName,
220 bool IsInternal, Assembler *Asm) { 220 bool IsInternal, Assembler *Asm) {
221 assert(!SectionNumbersAssigned); 221 assert(!SectionNumbersAssigned);
222 TimerMarker T_func(&Ctx, FuncName);
222 TimerMarker Timer(TimerStack::TT_writeELF, &Ctx); 223 TimerMarker Timer(TimerStack::TT_writeELF, &Ctx);
223 constexpr TimerStackIdT StackID = GlobalContext::TSK_Funcs;
224 TimerIdT TimerID = 0;
225 bool TimeThisFunction = Ctx.getFlags().getTimeEachFunction();
226 if (TimeThisFunction) {
227 TimerID = Ctx.getTimerID(StackID, FuncName);
228 Ctx.pushTimer(TimerID, StackID);
229 }
230 ELFTextSection *Section = nullptr; 224 ELFTextSection *Section = nullptr;
231 ELFRelocationSection *RelSection = nullptr; 225 ELFRelocationSection *RelSection = nullptr;
232 const bool FunctionSections = Ctx.getFlags().getFunctionSections(); 226 const bool FunctionSections = Ctx.getFlags().getFunctionSections();
233 if (TextSections.empty() || FunctionSections) { 227 if (TextSections.empty() || FunctionSections) {
234 IceString SectionName = ".text"; 228 IceString SectionName = ".text";
235 if (FunctionSections) 229 if (FunctionSections)
236 SectionName += "." + FuncName; 230 SectionName += "." + FuncName;
237 constexpr Elf64_Xword ShFlags = SHF_ALLOC | SHF_EXECINSTR; 231 constexpr Elf64_Xword ShFlags = SHF_ALLOC | SHF_EXECINSTR;
238 const Elf64_Xword ShAlign = 1 << Asm->getBundleAlignLog2Bytes(); 232 const Elf64_Xword ShAlign = 1 << Asm->getBundleAlignLog2Bytes();
239 Section = createSection<ELFTextSection>(SectionName, SHT_PROGBITS, ShFlags, 233 Section = createSection<ELFTextSection>(SectionName, SHT_PROGBITS, ShFlags,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 if (!RelSection->isRela()) { 265 if (!RelSection->isRela()) {
272 // This is a non-rela section, so we need to update the instruction stream 266 // This is a non-rela section, so we need to update the instruction stream
273 // with the relocation addends. 267 // with the relocation addends.
274 for (const auto *Fixup : Fixups) { 268 for (const auto *Fixup : Fixups) {
275 Fixup->emitOffset(Asm); 269 Fixup->emitOffset(Asm);
276 } 270 }
277 } 271 }
278 RelSection->addRelocations(OffsetInSection, Asm->fixups(), SymTab); 272 RelSection->addRelocations(OffsetInSection, Asm->fixups(), SymTab);
279 } 273 }
280 Section->appendData(Str, Asm->getBufferView()); 274 Section->appendData(Str, Asm->getBufferView());
281 if (TimeThisFunction)
282 Ctx.popTimer(TimerID, StackID);
283 } 275 }
284 276
285 namespace { 277 namespace {
286 278
287 ELFObjectWriter::SectionType 279 ELFObjectWriter::SectionType
288 classifyGlobalSection(const VariableDeclaration *Var) { 280 classifyGlobalSection(const VariableDeclaration *Var) {
289 if (Var->getIsConstant()) 281 if (Var->getIsConstant())
290 return ELFObjectWriter::ROData; 282 return ELFObjectWriter::ROData;
291 if (Var->hasNonzeroInitializer()) 283 if (Var->hasNonzeroInitializer())
292 return ELFObjectWriter::Data; 284 return ELFObjectWriter::Data;
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 if (ELF64) { 693 if (ELF64) {
702 writeELFHeaderInternal<true>(ShOffset, ShStrTab->getNumber(), 694 writeELFHeaderInternal<true>(ShOffset, ShStrTab->getNumber(),
703 AllSections.size()); 695 AllSections.size());
704 } else { 696 } else {
705 writeELFHeaderInternal<false>(ShOffset, ShStrTab->getNumber(), 697 writeELFHeaderInternal<false>(ShOffset, ShStrTab->getNumber(),
706 AllSections.size()); 698 AllSections.size());
707 } 699 }
708 } 700 }
709 701
710 } // end of namespace Ice 702 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceConverter.cpp ('k') | src/IceGlobalContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698