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

Side by Side Diff: src/IceTranslator.cpp

Issue 876083007: Subzero: Emit functions and global initializers in a separate thread. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: More code review changes Created 5 years, 10 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/IceTranslator.h ('k') | src/IceUtils.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/IceTranslator.cpp - ICE to machine code ------*- C++ -*-===// 1 //===- subzero/src/IceTranslator.cpp - ICE to machine code ------*- C++ -*-===//
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 // This file defines the general driver class for translating ICE to 10 // This file defines the general driver class for translating ICE to
11 // machine code. 11 // machine code.
12 // 12 //
13 //===----------------------------------------------------------------------===// 13 //===----------------------------------------------------------------------===//
14 14
15 #include "IceCfg.h" 15 #include "IceCfg.h"
16 #include "IceClFlags.h" 16 #include "IceClFlags.h"
17 #include "IceDefs.h" 17 #include "IceDefs.h"
18 #include "IceGlobalInits.h" 18 #include "IceGlobalInits.h"
19 #include "IceTargetLowering.h" 19 #include "IceTargetLowering.h"
20 #include "IceTranslator.h" 20 #include "IceTranslator.h"
21 21
22 using namespace Ice; 22 using namespace Ice;
23 23
24 Translator::Translator(GlobalContext *Ctx, const ClFlags &Flags) 24 Translator::Translator(GlobalContext *Ctx)
25 : Ctx(Ctx), Flags(Flags), 25 : Ctx(Ctx), NextSequenceNumber(GlobalContext::getFirstSequenceNumber()),
26 DataLowering(TargetDataLowering::createLowering(Ctx)), ErrorStatus() {} 26 ErrorStatus() {}
27 27
28 Translator::~Translator() {} 28 Translator::~Translator() {}
29 29
30 IceString Translator::createUnnamedName(const IceString &Prefix, SizeT Index) { 30 IceString Translator::createUnnamedName(const IceString &Prefix, SizeT Index) {
31 if (Index == 0) 31 if (Index == 0)
32 return Prefix; 32 return Prefix;
33 std::string Buffer; 33 std::string Buffer;
34 llvm::raw_string_ostream StrBuf(Buffer); 34 llvm::raw_string_ostream StrBuf(Buffer);
35 StrBuf << Prefix << Index; 35 StrBuf << Prefix << Index;
36 return StrBuf.str(); 36 return StrBuf.str();
(...skipping 10 matching lines...) Expand all
47 OstreamLocker L(Ctx); 47 OstreamLocker L(Ctx);
48 Ostream &Stream = Ctx->getStrDump(); 48 Ostream &Stream = Ctx->getStrDump();
49 Stream << "Warning : Default " << Kind << " prefix '" << Prefix 49 Stream << "Warning : Default " << Kind << " prefix '" << Prefix
50 << "' potentially conflicts with name '" << Name << "'.\n"; 50 << "' potentially conflicts with name '" << Name << "'.\n";
51 return true; 51 return true;
52 } 52 }
53 return false; 53 return false;
54 } 54 }
55 55
56 void Translator::translateFcn(std::unique_ptr<Cfg> Func) { 56 void Translator::translateFcn(std::unique_ptr<Cfg> Func) {
57 Ctx->cfgQueueBlockingPush(std::move(Func)); 57 Ctx->optQueueBlockingPush(std::move(Func));
58 if (Ctx->getFlags().NumTranslationThreads == 0) {
59 Ctx->translateFunctions();
60 }
61 } 58 }
62 59
63 void Translator::emitConstants() { 60 void Translator::emitConstants() {
64 if (!getErrorStatus()) 61 if (getErrorStatus())
65 DataLowering->lowerConstants(Ctx); 62 return;
63 TargetDataLowering::createLowering(Ctx)->lowerConstants();
66 } 64 }
67 65
68 void Translator::transferErrorCode() const { 66 void Translator::transferErrorCode() const {
69 if (getErrorStatus()) 67 if (getErrorStatus())
70 Ctx->getErrorStatus()->assign(getErrorStatus().value()); 68 Ctx->getErrorStatus()->assign(getErrorStatus().value());
71 } 69 }
72 70
73 void 71 // TODO(kschimpf,stichnot): Change VariableDeclarations to be a
74 Translator::lowerGlobals(const VariableDeclarationList &VariableDeclarations) { 72 // unique_ptr so that the work can be transferred to the emitter
75 TimerMarker T(TimerStack::TT_emitGlobalInitializers, Ctx); 73 // thread without a risk of sharing / race conditions.
76 bool DisableTranslation = Ctx->getFlags().DisableTranslation; 74 void Translator::lowerGlobals(VariableDeclarationList *VariableDeclarations) {
77 const bool DumpGlobalVariables = 75 EmitterWorkItem *Item =
78 ALLOW_DUMP && Ctx->getVerbose() && Ctx->getFlags().VerboseFocusOn.empty(); 76 new EmitterWorkItem(getNextSequenceNumber(), VariableDeclarations);
79 if (Ctx->getFlags().UseELFWriter) { 77 Ctx->emitQueueBlockingPush(Item);
80 // Dump all globals if requested, but don't interleave w/ emission.
81 if (DumpGlobalVariables) {
82 OstreamLocker L(Ctx);
83 Ostream &Stream = Ctx->getStrDump();
84 for (const Ice::VariableDeclaration *Global : VariableDeclarations) {
85 Global->dump(getContext(), Stream);
86 }
87 }
88 DataLowering->lowerGlobalsELF(VariableDeclarations);
89 } else {
90 const IceString &TranslateOnly = Ctx->getFlags().TranslateOnly;
91 OstreamLocker L(Ctx);
92 Ostream &Stream = Ctx->getStrDump();
93 for (const Ice::VariableDeclaration *Global : VariableDeclarations) {
94 // Interleave dump output w/ emit output.
95 if (DumpGlobalVariables)
96 Global->dump(getContext(), Stream);
97 if (!DisableTranslation &&
98 GlobalContext::matchSymbolName(Global->getName(), TranslateOnly))
99 DataLowering->lowerGlobal(*Global);
100 }
101 }
102 } 78 }
OLDNEW
« no previous file with comments | « src/IceTranslator.h ('k') | src/IceUtils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698