mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-23 06:10:02 +08:00
Program builds that import runtime bitcode parsed and merged every unit's whole module, although the import can only ever take small bodies that need no second copy of unit-local state. The helper now reduces a unit's bitcode to exactly that set when the runtime pack is built: the importable bodies within the size limit at their call distance from any public function, and the constants they copy. Every other definition becomes a declaration, as the import would treat it. A program's selection starts from public functions, so it is always a subset of the pruned set, and programs import the same bodies as before. `runtime-unit` writes the pruned bitcode for speed units; the new `prune-import` command prunes a unit's bitcode as compiled, for units whose objects the runtime compiler emits itself. Linux x64 speed bitcode shrinks from 17.0 MB to 8.6 MB. Runtime objects are byte-identical, and import lists match the unpruned bitcode exactly. Interleaved cold builds of 53 programs in a Linux Vercel Sandbox: speed went from +21.4% to +12.1% over release.
16 lines
583 B
C++
16 lines
583 B
C++
#pragma once
|
|
|
|
namespace scriptc {
|
|
|
|
// `scriptc-llvm-codegen runtime-unit`: emit a runtime-pack unit's object and
|
|
// its import bitcode from one optimized module with promoted locals.
|
|
int runtimeUnit(int Argc, char **Argv);
|
|
|
|
// `scriptc-llvm-codegen prune-import --input <bc> --output <bc>`: reduce a
|
|
// unit's bitcode, as compiled, to what a program build can import from it.
|
|
// Its unit-local symbols stay local, so bodies that need them are never
|
|
// imported and the unit's object can come from the runtime compiler.
|
|
int pruneImport(int Argc, char **Argv);
|
|
|
|
} // namespace scriptc
|