stage2 大量优化代码使其自举编译时间大幅缩短

This commit is contained in:
zzy committed 2026-09-20 09:33:20 +08:00
1 parent e02b0c633a
commit 846f441e3a
38 files changed
+2418 -835

No files matched your search

+11
View File
@@ -33,6 +33,7 @@ typedef struct {
int profile;
int profile_interval;
const char *profile_out;
int stats;
const char *entry;
const char *path; /* file.sir */
const char **args; /* spl 程序参数(file.sir 之后) */
@@ -48,6 +49,7 @@ static void usage(void) {
" --trace print every instruction\n"
" --profile[=N] native sampling profiler (every N insns, default 10000)\n"
" --profile-out <p> profile output prefix (default build/profile)\n"
" --stats print executed instructions / call count at exit\n"
" -h, --help show help\n");
}
@@ -72,6 +74,8 @@ static int parse_args(int argc, const char **argv, cli_opts_t *o) {
o->trace = 1;
} else if (strcmp(a, "--disasm") == 0) {
o->disasm = 1;
} else if (strcmp(a, "--stats") == 0) {
o->stats = 1;
} else if (strcmp(a, "--profile") == 0) {
o->profile = 1;
} else if (strncmp(a, "--profile=", 10) == 0) {
@@ -656,6 +660,8 @@ int main(int argc, const char **argv) {
if (o.debug) {
fprintf(stderr, "spl_cli: debug mode on\n");
spl_vm_set_debug(&vm, 1);
} else {
spl_vm_set_debug(&vm, 0);
}
if (o.trace) {
fprintf(stderr, "spl_cli: trace mode on\n");
@@ -710,6 +716,11 @@ int main(int argc, const char **argv) {
fprintf(stderr, "spl_cli: hit breakpoint (run with -g to debug)\n");
}
if (o.stats) {
fprintf(stderr, "spl_cli: stats steps=%llu calls=%llu\n", (unsigned long long)vm.steps,
(unsigned long long)vm.ncalls);
}
if (o.profile) {
const char *prefix = o.profile_out ? o.profile_out : "build/profile";
char folded[1024];