Skip to content

Commit 218e583

Browse files
committed
Add a --profile-stage option to profile only one compilation stage.
1 parent 547d61f commit 218e583

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/HLL/Compiler.nqp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class HLL::Compiler does HLL::Backend::Default {
2323
@!stages := nqp::split(' ', 'start parse ast ' ~ $!backend.stages());
2424

2525
# Command options and usage.
26-
@!cmdoptions := nqp::split(' ', 'e=s help|h target=s trace|t=s encoding=s output|o=s source-name=s combine version|v show-config verbose-config|V stagestats=s? ll-exception rxtrace nqpevent=s profile=s? profile-compile=s? profile-filename=s');
26+
@!cmdoptions := nqp::split(' ', 'e=s help|h target=s trace|t=s encoding=s output|o=s source-name=s combine version|v show-config verbose-config|V stagestats=s? ll-exception rxtrace nqpevent=s profile=s? profile-compile=s? profile-filename=s profile-stage=s');
2727
%!config := nqp::hash();
2828
}
2929

@@ -426,15 +426,23 @@ class HLL::Compiler does HLL::Backend::Default {
426426
}
427427
nqp::printfh($stderr, nqp::sprintf("Stage %-11s: ", [$_])) if nqp::defined($stagestats);
428428
my $timestamp := nqp::time_n();
429-
if nqp::can(self, $_) {
430-
$result := self."$_"($result, |%adverbs);
431-
}
432-
elsif nqp::can($!backend, $_) {
433-
$result := $!backend."$_"($result, |%adverbs);
434-
}
435-
else {
436-
nqp::die("Unknown compilation stage '$_'");
429+
430+
my sub run() {
431+
if nqp::can(self, $_) {
432+
self."$_"($result, |%adverbs);
433+
}
434+
elsif nqp::can($!backend, $_) {
435+
$!backend."$_"($result, |%adverbs);
436+
}
437+
else {
438+
nqp::die("Unknown compilation stage '$_'");
439+
}
437440
}
441+
442+
$result := %adverbs<profile-stage> eq $_
443+
?? $!backend.run_profiled(&run, '', %adverbs<profile-filename>)
444+
!! run();
445+
438446
my $diff := nqp::time_n() - $timestamp;
439447
if nqp::defined($stagestats) {
440448
nqp::printfh($stderr, nqp::sprintf("%7.3f", [$diff]));

0 commit comments

Comments
 (0)