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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceTranslator.h ('k') | src/IceUtils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceTranslator.cpp
diff --git a/src/IceTranslator.cpp b/src/IceTranslator.cpp
index 4753b228dbb82a4965f0b6b0bf744b5934497cfd..4b5129e32157be96441380fef1bede912f363323 100644
--- a/src/IceTranslator.cpp
+++ b/src/IceTranslator.cpp
@@ -21,9 +21,9 @@
using namespace Ice;
-Translator::Translator(GlobalContext *Ctx, const ClFlags &Flags)
- : Ctx(Ctx), Flags(Flags),
- DataLowering(TargetDataLowering::createLowering(Ctx)), ErrorStatus() {}
+Translator::Translator(GlobalContext *Ctx)
+ : Ctx(Ctx), NextSequenceNumber(GlobalContext::getFirstSequenceNumber()),
+ ErrorStatus() {}
Translator::~Translator() {}
@@ -54,15 +54,13 @@ bool Translator::checkIfUnnamedNameSafe(const IceString &Name, const char *Kind,
}
void Translator::translateFcn(std::unique_ptr<Cfg> Func) {
- Ctx->cfgQueueBlockingPush(std::move(Func));
- if (Ctx->getFlags().NumTranslationThreads == 0) {
- Ctx->translateFunctions();
- }
+ Ctx->optQueueBlockingPush(std::move(Func));
}
void Translator::emitConstants() {
- if (!getErrorStatus())
- DataLowering->lowerConstants(Ctx);
+ if (getErrorStatus())
+ return;
+ TargetDataLowering::createLowering(Ctx)->lowerConstants();
}
void Translator::transferErrorCode() const {
@@ -70,33 +68,11 @@ void Translator::transferErrorCode() const {
Ctx->getErrorStatus()->assign(getErrorStatus().value());
}
-void
-Translator::lowerGlobals(const VariableDeclarationList &VariableDeclarations) {
- TimerMarker T(TimerStack::TT_emitGlobalInitializers, Ctx);
- bool DisableTranslation = Ctx->getFlags().DisableTranslation;
- const bool DumpGlobalVariables =
- ALLOW_DUMP && Ctx->getVerbose() && Ctx->getFlags().VerboseFocusOn.empty();
- if (Ctx->getFlags().UseELFWriter) {
- // Dump all globals if requested, but don't interleave w/ emission.
- if (DumpGlobalVariables) {
- OstreamLocker L(Ctx);
- Ostream &Stream = Ctx->getStrDump();
- for (const Ice::VariableDeclaration *Global : VariableDeclarations) {
- Global->dump(getContext(), Stream);
- }
- }
- DataLowering->lowerGlobalsELF(VariableDeclarations);
- } else {
- const IceString &TranslateOnly = Ctx->getFlags().TranslateOnly;
- OstreamLocker L(Ctx);
- Ostream &Stream = Ctx->getStrDump();
- for (const Ice::VariableDeclaration *Global : VariableDeclarations) {
- // Interleave dump output w/ emit output.
- if (DumpGlobalVariables)
- Global->dump(getContext(), Stream);
- if (!DisableTranslation &&
- GlobalContext::matchSymbolName(Global->getName(), TranslateOnly))
- DataLowering->lowerGlobal(*Global);
- }
- }
+// TODO(kschimpf,stichnot): Change VariableDeclarations to be a
+// unique_ptr so that the work can be transferred to the emitter
+// thread without a risk of sharing / race conditions.
+void Translator::lowerGlobals(VariableDeclarationList *VariableDeclarations) {
+ EmitterWorkItem *Item =
+ new EmitterWorkItem(getNextSequenceNumber(), VariableDeclarations);
+ Ctx->emitQueueBlockingPush(Item);
}
« 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