Commit 3dd127e6 by Karl Schimpf

Force sequential parsing when threads=0.

When threads=0, it doesn't pay to run a parallel parse, since each parallel parse slows down parsing by requiring a copy of bits in the function block. BUG=None R=stichnot@chromium.org Review URL: https://codereview.chromium.org/1848873002 .
parent cc89c959
...@@ -130,6 +130,9 @@ private: ...@@ -130,6 +130,9 @@ private:
public: public:
bool isSequential() const { return NumTranslationThreads == 0; } bool isSequential() const { return NumTranslationThreads == 0; }
bool isParseParallel() const {
return getParseParallel() && !isSequential() && getBuildOnRead();
}
std::string getAppName() const { return AppName; } std::string getAppName() const { return AppName; }
void setAppName(const std::string &Value) { AppName = Value; } void setAppName(const std::string &Value) { AppName = Value; }
......
...@@ -287,10 +287,10 @@ GlobalContext::GlobalContext(Ostream *OsDump, Ostream *OsEmit, Ostream *OsError, ...@@ -287,10 +287,10 @@ GlobalContext::GlobalContext(Ostream *OsDump, Ostream *OsEmit, Ostream *OsError,
ELFStreamer *ELFStr) ELFStreamer *ELFStr)
: Strings(new StringPool()), ConstPool(new ConstantPool()), ErrorStatus(), : Strings(new StringPool()), ConstPool(new ConstantPool()), ErrorStatus(),
StrDump(OsDump), StrEmit(OsEmit), StrError(OsError), IntrinsicsInfo(this), StrDump(OsDump), StrEmit(OsEmit), StrError(OsError), IntrinsicsInfo(this),
ObjectWriter(), OptQ(/*Sequential=*/Flags.isSequential(), ObjectWriter(),
OptQ(/*Sequential=*/Flags.isSequential(),
/*MaxSize=*/ /*MaxSize=*/
(Flags.getParseParallel() && Flags.getBuildOnRead()) Flags.isParseParallel() ? MaxOptQSize
? MaxOptQSize
: Flags.getNumTranslationThreads()), : Flags.getNumTranslationThreads()),
// EmitQ is allowed unlimited size. // EmitQ is allowed unlimited size.
EmitQ(/*Sequential=*/Flags.isSequential()), EmitQ(/*Sequential=*/Flags.isSequential()),
......
...@@ -2995,7 +2995,8 @@ public: ...@@ -2995,7 +2995,8 @@ public:
ModuleParser(unsigned BlockID, TopLevelParser *Context) ModuleParser(unsigned BlockID, TopLevelParser *Context)
: BlockParserBaseClass(BlockID, Context), : BlockParserBaseClass(BlockID, Context),
Timer(Ice::TimerStack::TT_parseModule, Timer(Ice::TimerStack::TT_parseModule,
Context->getTranslator().getContext()) {} Context->getTranslator().getContext()),
IsParseParallel(Ice::GlobalContext::Flags.isParseParallel()) {}
~ModuleParser() override = default; ~ModuleParser() override = default;
const char *getBlockName() const override { return "module"; } const char *getBlockName() const override { return "module"; }
NaClBitstreamCursor &getCursor() const { return Record.GetCursor(); } NaClBitstreamCursor &getCursor() const { return Record.GetCursor(); }
...@@ -3007,6 +3008,7 @@ private: ...@@ -3007,6 +3008,7 @@ private:
bool GlobalDeclarationNamesAndInitializersInstalled = false; bool GlobalDeclarationNamesAndInitializersInstalled = false;
// True if we have already processed the symbol table for the module. // True if we have already processed the symbol table for the module.
bool FoundValuesymtab = false; bool FoundValuesymtab = false;
const bool IsParseParallel;
// Generates names for unnamed global addresses (i.e. functions and global // Generates names for unnamed global addresses (i.e. functions and global
// variables). Then lowers global variable declaration initializers to the // variables). Then lowers global variable declaration initializers to the
...@@ -3148,7 +3150,7 @@ bool ModuleParser::ParseBlock(unsigned BlockID) { ...@@ -3148,7 +3150,7 @@ bool ModuleParser::ParseBlock(unsigned BlockID) {
Ice::GlobalContext *Ctx = Context->getTranslator().getContext(); Ice::GlobalContext *Ctx = Context->getTranslator().getContext();
uint32_t SeqNumber = Context->getTranslator().getNextSequenceNumber(); uint32_t SeqNumber = Context->getTranslator().getNextSequenceNumber();
NaClBcIndexSize_t FcnId = Context->getNextFunctionBlockValueID(); NaClBcIndexSize_t FcnId = Context->getNextFunctionBlockValueID();
if (Ctx->getFlags().getParseParallel()) { if (IsParseParallel) {
// Skip the block and copy into a buffer. Note: We copy into a buffer // Skip the block and copy into a buffer. Note: We copy into a buffer
// using the top-level parser to make sure that the underlying // using the top-level parser to make sure that the underlying
// buffer reading from the data streamer is not thread safe. // buffer reading from the data streamer is not thread safe.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment