mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 17:33:38 +00:00
Estimated hours taken: 6 Branches: main Optimize higher order calls by providing variants of the relevant code that are specialized to a given number of explicitly given arguments. runtime/mercury_ho_call.[ch]: Define variants of do_call_closure and do_call_class_method specialized to 0, 1, 2 or 3 explicit input arguments. Apart from not needing to be passed the number of explicit input arguments in a register, these avoid some runtime tests and unroll loops. Harmonize the variable names used in the do_call_closure and do_call_class_method variants. Since they are near-copies of each other, factor out their documentation. (Factoring out the code itself would be possible, but would not make maintenance easier and would make the code harder to read.) Provide a mechanism to gather statistics about the numbers of hidden and explicit arguments if the macro MR_DO_CALL_STATS is set. compiler/options.m: Add options that specify how many of these variants exist. These provide the necessary synchronization between the runtime and the compiler. They are not meant to be set from the command line, even by implementors. runtime/mercury_conf_params.h: Document MR_DO_CALL_STATS. runtime/mercury_wrapper.c: If MR_DO_CALL_STATS is set, print the gathered statistics when execution ends. runtime/mecury_mm_own_stack.c: Fix a typo that prevented the stage2 library from linking in jump.gc grade. compiler/llds.m: Provide a way to represent the labels of the new specialized variants. compiler/llds__out.m: Output the labels of the new specialized variants if required. Convert to four-space indentation. compiler/call_gen.m: Call the specialized variants of do_call_closure or do_call_class_method if they are applicable. code_info/follow_vars.m: code_info/interval.m: code_info/tupling.m: Conform to the change in call_gen.m. code_info/dupproc.m: code_info/exprn_aux.m: code_info/livemap.m: code_info/opt_util.m: Conform to the change in llds.m. compiler/code_info.m: Minor style cleanups. tools/bootcheck: Enable the collection of statistics from the compilation of stage 3 and the test cases, for use when the stage 2 is built with MR_DO_CALL_STATS enabled. tools/ho_call_stats: A new script to analyze the statistics collected. tools/makebatch: Add a new option --save-stage2-on-no-compiler, which is a variant of the existing option --save-stage2-on-error.
43 lines
1.3 KiB
Bash
Executable File
43 lines
1.3 KiB
Bash
Executable File
#!/bin/sh
|
|
# vim: ts=4 sw=4 et
|
|
awk '
|
|
$1 == "closure" && $5 == "explicit" { closure_explicit[$4] += $7; }
|
|
$1 == "closure" && $5 == "hidden" { closure_hidden[$4] += $7; }
|
|
$1 == "method" && $5 == "explicit" { method_explicit[$4] += $7; }
|
|
$1 == "method" && $5 == "hidden" { method_hidden[$4] += $7; }
|
|
{
|
|
if ($4 > max) {
|
|
max = $4;
|
|
}
|
|
}
|
|
END {
|
|
for (i = 0; i <= max; i++) {
|
|
if (closure_explicit[i]) {
|
|
printf "closure invocations with %2d explicit args: %10d\n", \
|
|
i, closure_explicit[i];
|
|
}
|
|
}
|
|
|
|
for (i = 0; i <= max; i++) {
|
|
if (closure_hidden[i]) {
|
|
printf "closure invocations with %2d hidden args: %10d\n", \
|
|
i, closure_hidden[i];
|
|
}
|
|
}
|
|
|
|
for (i = 0; i <= max; i++) {
|
|
if (method_explicit[i]) {
|
|
printf "method invocations with %2d explicit args: %10d\n", \
|
|
i, method_explicit[i];
|
|
}
|
|
}
|
|
|
|
for (i = 0; i <= max; i++) {
|
|
if (method_hidden[i]) {
|
|
printf "method invocations with %2d hidden args: %10d\n", \
|
|
i, method_hidden[i];
|
|
}
|
|
}
|
|
}
|
|
' "$@"
|