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

Unified Diff: src/PNaClTranslator.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/PNaClTranslator.h ('k') | src/assembler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/PNaClTranslator.cpp
diff --git a/src/PNaClTranslator.cpp b/src/PNaClTranslator.cpp
index 552ee6009622d22f676c174af3c6f3f33d6bbf7b..f5820141a41c1051e6154d723ac5bb5202eb6ea5 100644
--- a/src/PNaClTranslator.cpp
+++ b/src/PNaClTranslator.cpp
@@ -163,6 +163,7 @@ public:
NaClBitstreamCursor &Cursor, Ice::ErrorCode &ErrorStatus)
: NaClBitcodeParser(Cursor), Translator(Translator), Header(Header),
ErrorStatus(ErrorStatus), NumErrors(0), NextDefiningFunctionID(0),
+ VariableDeclarations(new Ice::VariableDeclarationList),
BlockParser(nullptr), StubbedConstCallValue(nullptr) {}
~TopLevelParser() override {}
@@ -265,7 +266,7 @@ public:
if (ID >= ValueIDConstants.size()) {
C = nullptr;
unsigned ExpectedSize =
- FunctionDeclarationList.size() + VariableDeclarations.size();
+ FunctionDeclarationList.size() + VariableDeclarations->size();
if (ID >= ExpectedSize)
ExpectedSize = ID;
ValueIDConstants.resize(ExpectedSize);
@@ -289,8 +290,8 @@ public:
Decl = FunctionDeclarationList[ID];
const auto Func = llvm::cast<Ice::FunctionDeclaration>(Decl);
IsUndefined = Func->isProto();
- } else if ((ID - FcnIDSize) < VariableDeclarations.size()) {
- Decl = VariableDeclarations[ID - FcnIDSize];
+ } else if ((ID - FcnIDSize) < VariableDeclarations->size()) {
+ Decl = VariableDeclarations->at(ID - FcnIDSize);
const auto Var = llvm::cast<Ice::VariableDeclaration>(Decl);
IsUndefined = !Var->hasInitializer();
}
@@ -343,27 +344,27 @@ public:
/// Returns the number of global declarations (i.e. IDs) defined in
/// the bitcode file.
unsigned getNumGlobalIDs() const {
- return FunctionDeclarationList.size() + VariableDeclarations.size();
+ return FunctionDeclarationList.size() + VariableDeclarations->size();
}
/// Creates Count global variable declarations.
void CreateGlobalVariables(size_t Count) {
- assert(VariableDeclarations.empty());
+ assert(VariableDeclarations->empty());
for (size_t i = 0; i < Count; ++i) {
- VariableDeclarations.push_back(Ice::VariableDeclaration::create());
+ VariableDeclarations->push_back(Ice::VariableDeclaration::create());
}
}
/// Returns the number of global variable declarations in the
/// bitcode file.
Ice::SizeT getNumGlobalVariables() const {
- return VariableDeclarations.size();
+ return VariableDeclarations->size();
}
/// Returns the global variable declaration with the given index.
Ice::VariableDeclaration *getGlobalVariableByID(unsigned Index) {
- if (Index < VariableDeclarations.size())
- return VariableDeclarations[Index];
+ if (Index < VariableDeclarations->size())
+ return VariableDeclarations->at(Index);
return reportGetGlobalVariableByIDError(Index);
}
@@ -378,7 +379,7 @@ public:
}
/// Returns the list of parsed global variable declarations.
- const Ice::VariableDeclarationList &getGlobalVariables() {
+ Ice::VariableDeclarationList *getGlobalVariables() {
return VariableDeclarations;
}
@@ -403,7 +404,7 @@ private:
// actually-defined function.
size_t NextDefiningFunctionID;
// The set of global variables.
- Ice::VariableDeclarationList VariableDeclarations;
+ Ice::VariableDeclarationList *VariableDeclarations;
// Relocatable constants associated with global declarations.
std::vector<Ice::Constant *> ValueIDConstants;
// Error recovery value to use when getFuncSigTypeByID fails.
@@ -495,11 +496,11 @@ TopLevelParser::reportGetGlobalVariableByIDError(unsigned Index) {
raw_string_ostream StrBuf(Buffer);
StrBuf << "Global index " << Index
<< " not allowed. Out of range. Must be less than "
- << VariableDeclarations.size();
+ << VariableDeclarations->size();
BlockError(StrBuf.str());
// TODO(kschimpf) Remove error recovery once implementation complete.
- if (!VariableDeclarations.empty())
- return VariableDeclarations[0];
+ if (!VariableDeclarations->empty())
+ return VariableDeclarations->at(0);
report_fatal_error("Unable to continue");
}
@@ -1099,7 +1100,8 @@ public:
}
if (!isIRGenerationDisabled())
- Func = Ice::Cfg::create(getTranslator().getContext());
+ Func = Ice::Cfg::create(getTranslator().getContext(),
+ getTranslator().getNextSequenceNumber());
Ice::Cfg::setCurrentCfg(Func.get());
// TODO(kschimpf) Clean up API to add a function signature to
@@ -1134,7 +1136,7 @@ public:
// translation of all remaining functions. This allows successive
// parsing errors to be reported, without adding extra checks to
// the translator for such parsing errors.
- if (Context->getNumErrors() == 0) {
+ if (Context->getNumErrors() == 0 && Func) {
getTranslator().translateFcn(std::move(Func));
// The translator now has ownership of Func.
} else {
@@ -2810,11 +2812,13 @@ private:
// the first call will do the installation.
void InstallGlobalNamesAndGlobalVarInitializers() {
if (!GlobalDeclarationNamesAndInitializersInstalled) {
+ Ice::VariableDeclarationList *VariableDeclarations =
+ Context->getGlobalVariables();
Ice::Translator &Trans = getTranslator();
const Ice::IceString &GlobalPrefix = getFlags().DefaultGlobalPrefix;
if (!GlobalPrefix.empty()) {
uint32_t NameIndex = 0;
- for (Ice::VariableDeclaration *Var : Context->getGlobalVariables()) {
+ for (Ice::VariableDeclaration *Var : *VariableDeclarations) {
installDeclarationName(Trans, Var, GlobalPrefix, "global", NameIndex);
}
}
@@ -2827,7 +2831,7 @@ private:
NameIndex);
}
}
- getTranslator().lowerGlobals(Context->getGlobalVariables());
+ getTranslator().lowerGlobals(VariableDeclarations);
GlobalDeclarationNamesAndInitializersInstalled = true;
}
}
« no previous file with comments | « src/PNaClTranslator.h ('k') | src/assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698