From 57e10942ba78d7fa064ab9c11e0fd17e983856cf Mon Sep 17 00:00:00 2001 From: Mark Williams Date: Wed, 1 May 2013 08:13:41 -0700 Subject: [PATCH] Undo systemlib change Put systemlib in the repo again, and use it for repo-authoritative builds --- hphp/compiler/analysis/emitter.cpp | 37 ++++++++++++++++++++++++++++++ hphp/hhvm/process_init.cpp | 29 +++++++++++++++-------- hphp/runtime/base/runtime_option.h | 3 ++- 3 files changed, 59 insertions(+), 10 deletions(-) diff --git a/hphp/compiler/analysis/emitter.cpp b/hphp/compiler/analysis/emitter.cpp index 10a698f3d..b9bbb51e6 100644 --- a/hphp/compiler/analysis/emitter.cpp +++ b/hphp/compiler/analysis/emitter.cpp @@ -7331,6 +7331,41 @@ static void batchCommit(std::vector& ues) { ues.clear(); } +static void emitSystemLib() { + if (!Option::WholeProgram) return; + + string slib = get_systemlib(); + if (slib.empty()) return; + + Option::WholeProgram = false; + SystemLib::s_inited = false; + + SCOPE_EXIT { + SystemLib::s_inited = true; + Option::WholeProgram = true; + }; + + AnalysisResultPtr ar(new AnalysisResult()); + Scanner scanner(slib.c_str(), slib.size(), + RuntimeOption::ScannerType, "/:systemlib.php"); + Parser parser(scanner, "/:systemlib.php", ar, slib.size()); + parser.parse(); + FileScopePtr fsp = parser.getFileScope(); + fsp->setOuterScope(ar); + + ar->loadBuiltins(); + ar->setPhase(AnalysisResult::AnalyzeAll); + fsp->analyzeProgram(ar); + + int md5len; + char* md5str = string_md5(slib.c_str(), slib.size(), false, md5len); + MD5 md5(md5str); + free(md5str); + + UnitEmitter* ue = emitHHBCUnitEmitter(ar, fsp, md5); + Repo::get().commitUnit(ue, UnitOriginFile); +} + /** * This is the entry point for offline bytecode generation. */ @@ -7385,6 +7420,8 @@ void emitAllHHBC(AnalysisResultPtr ar) { break; } } + + emitSystemLib(); } else { dispatcher.waitEmpty(); } diff --git a/hphp/hhvm/process_init.cpp b/hphp/hhvm/process_init.cpp index 42cf1577d..2f11cc9e7 100644 --- a/hphp/hhvm/process_init.cpp +++ b/hphp/hhvm/process_init.cpp @@ -110,10 +110,10 @@ void ProcessInit() { // Save the current options, and set things up so that // systemlib.php can be read from and stored in the // normal repo. - bool db = RuntimeOption::EvalDumpBytecode; + int db = RuntimeOption::EvalDumpBytecode; bool rp = RuntimeOption::AlwaysUseRelativePath; bool sf = RuntimeOption::SafeFileAccess; - RuntimeOption::EvalDumpBytecode = false; + RuntimeOption::EvalDumpBytecode &= ~1; RuntimeOption::AlwaysUseRelativePath = false; RuntimeOption::SafeFileAccess = false; @@ -125,16 +125,27 @@ void ProcessInit() { String currentDir = g_vmContext->getCwd(); - string slib = get_systemlib(); + if (RuntimeOption::RepoAuthoritative) { + auto file = g_vmContext->lookupPhpFile(String("/:systemlib.php").get(), + currentDir.data(), nullptr); + if (!file) { + // Die a horrible death. + Logger::Error("Unable to find/load systemlib.php"); + _exit(1); + } + file->incRef(); + SystemLib::s_unit = file->unit(); + } else { + string slib = get_systemlib(); - if (slib.empty()) { - // Die a horrible death. - Logger::Error("Unable to find/load systemlib.php"); - _exit(1); + if (slib.empty()) { + // Die a horrible death. + Logger::Error("Unable to find/load systemlib.php"); + _exit(1); + } + SystemLib::s_unit = compile_string(slib.c_str(), slib.size()); } - SystemLib::s_unit = compile_string(slib.c_str(), slib.size()); - // Restore most settings before merging anything, // because of optimizations that depend on them RuntimeOption::AlwaysUseRelativePath = rp; diff --git a/hphp/runtime/base/runtime_option.h b/hphp/runtime/base/runtime_option.h index dabcccfe5..3c5997f60 100644 --- a/hphp/runtime/base/runtime_option.h +++ b/hphp/runtime/base/runtime_option.h @@ -433,7 +433,8 @@ public: F(bool, HHIRDisableTx64, true) \ F(uint64_t, MaxHHIRTrans, -1) \ F(bool, HHIRDeadCodeElim, true) \ - F(bool, DumpBytecode, false) \ + /* DumpBytecode =1 dumps user php, =2 dumps systemlib & user php */ \ + F(int32_t, DumpBytecode, 0) \ F(bool, DumpTC, false) \ F(bool, DumpAst, false) \ F(bool, MapTCHuge, true) \