Commit 843142fe by Jim Stichnoth

Subzero: Tweaks to reduce malloc use.

1. Subzero constructs many strings based in part on function name. When function names are not present (as in properly finalized pexes), they are synthesized as something like "Function12345". We can shorten these strings to e.g. "F12345" by using --default-function-prefix=F . Similar for global variable names. Using short strings makes it much less likely to have to use malloc. As such, we force that to be the default in the browser translator build. For perf-testing the command-line version, the user can just add the option manually for now. Ultimately, we should avoid use of strings in this way. 2. The register allocator uses a few instances of llvm::SmallVector that are sized too small and therefore end up using malloc. This can be fixed in a clean way, and there is a TODO for it, but in the meantime we just bump the size. BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4360 R=jpp@chromium.org Review URL: https://codereview.chromium.org/1776343004 .
parent 8a4675ce
......@@ -172,6 +172,13 @@ void BrowserCompileServer::getParsedFlags(uint32_t NumThreads, int argc,
Flags->setUseSandboxing(true);
Flags->setOutFileType(FT_Elf);
Flags->setTargetArch(getTargetArch());
// Make the prefixes short to reduce the chance that string construction will
// have to resort to malloc(). Note that this won't change anything if the
// pexe was finalize with "--no-strip-syms". TODO(stichnot): This will be
// unnecessary when we stop directly constructing strings that are used for
// names and lookup keys.
Flags->setDefaultFunctionPrefix("F");
Flags->setDefaultGlobalPrefix("G");
ExtraFlags->setBuildOnRead(true);
ExtraFlags->setInputFileFormat(llvm::PNaClFormat);
}
......
......@@ -43,8 +43,10 @@ public:
void dump(Cfg *Func) const;
// TODO(stichnot): Statically choose the size based on the target being
// compiled.
static constexpr size_t REGS_SIZE = 32;
// compiled. For now, choose a value large enough to fit into the
// SmallVector's fixed portion, which is 32 for x86-32, 84 for x86-64, and 102
// for ARM32.
static constexpr size_t REGS_SIZE = 128;
private:
using OrderedRanges = CfgVector<Variable *>;
......
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