mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 17:33:38 +00:00
Estimated hours taken: 20
Branches: main
Try to work around the Snow Leopard linker's performance problem with
debug grade object files by greatly reducing the number of symbols needed
to represent the debugger's data structures.
Specifically, this diff groups all label layouts in a module, each of which
previously had its own named global variable, into only a few (one to four)
global variables, each of which is an array. References to the old global
variables are replaced by references to slots in these arrays.
This same treatment could also be applied to other layout structures. However,
most layouts are label layouts, so doing just label layouts gets most of the
available benefit.
When the library and compiler are compiled in grade asm_fast.gc.debug,
this diff leads to about a 1.5% increase in the size of their generated C
source files (from 338 to 343 Mb), but a more significant reduction (about 17%)
in the size of the corresponding object files (from 155 to 128 Mb). This leads
to an overall reduction in disk requirements from 493 to 471 Mb (about 4.5%).
Since we generate the same code and data as before, with the data just being
arranged differently, the decrease in object file sizes is coming from the
reduction in relocation information, the information processed by the linker.
This should speed up the linker.
compiler/layout.m:
Make the change described above. We now define up to four arrays:
one each for label layouts with and without information about
variables, one for the layout structures of user events,
and one for the variable number lists of user events.
compiler/layout_out.m:
Generate the new arrays that the module being compiled needs.
Use purpose-specific types instead of booleans.
compiler/trace_gen.m:
Use a new field in foreign_proc_code instructions to record the
identity of any labels whose layout structures we want to refer to,
even though layout structures have not been generated yet. The labels
will be looked up in a map (generated together with the layout
structures) by llds_out.m.
compiler/llds.m:
Add this extra field to foreign_proc_code instructions.
Add the map (which is actually in two parts) to the c_file type,
which is the data structure representing the entire LLDS.
Also add to the c_file type some other data structures that previously
we used to hand around alongside it. Some of these data structures
used to conmingle layout structures that we now separate.
compiler/stack_layout.m:
Generate array slots instead of separate structures for label layouts.
Return the different arrays separately.
compiler/llds_out.m:
Order the output of layout structures to require fewer forward
declarations. The forward declarations of the few arrays holding the
label layout structures replace a lot of the declarations previously
needed.
Include the information needed by layout_out.m in the llds_out_info,
and conform to the changes above.
As a side-effect of all these changes, we now generate proc layout
structures in the same order as the procedures' appearence in the HLDS,
which is the same as their order in the source code, modulo any
procedures added by the compiler itself (for lambdas, unification
predicates, etc).
compiler/code_info.m:
compiler/dupelim.m:
compiler/dup_proc.m:
compiler/exprn_aux.m:
compiler/frameopt.m:
compiler/global_data.m:
compiler/ite_gen.m:
compiler/jumpopt.m:
compiler/livemap.m:
compiler/llds_to_x86_64.m:
compiler/mercury_compile_llds_back_end.m:
compiler/middle_rec.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/pragma_c_gen.m:
compiler/proc_gen.m:
compiler/reassign.m:
compiler/use_local_vars.m:
Conform to the changes above.
runtime/mercury_goto.h:
Add the macros used by the new code in layout_out.m and llds_out.m.
We need new macros because the old ones assumed that the
C preprocessor can construct the address of a label's layout structure
from the name of the label, which is obviously no longer possible.
Make even existing families of macros handle in bulk up to 10 labels,
up from the previous 8.
runtime/mercury_stack_layout.h:
Add macros for use by the new code in layout.m.
tests/debugger/*.{inp,exp}:
tests/debugger/declarative/*.{inp,exp}:
Update these test cases to account for the new (and better) order
of proc layout structures. Where inputs changed, this was to ensure
that we still select the same procedures from lists of procedures,
e.g. to put a breakpoint on.
78 lines
2.1 KiB
Plaintext
78 lines
2.1 KiB
Plaintext
E1: C1 CALL pred polymorphic_output.main/2-0 (det) polymorphic_output.m:29
|
|
mdb> echo on
|
|
Command echo enabled.
|
|
mdb> register --quiet
|
|
mdb> context none
|
|
Contexts will not be printed.
|
|
mdb> b functor_names
|
|
0: + stop interface func polymorphic_output.functor_names/1-0 (det)
|
|
mdb> c
|
|
E2: C2 CALL func polymorphic_output.functor_names/1-0 (det)
|
|
mdb> delete 0
|
|
0: E stop interface func polymorphic_output.functor_names/1-0 (det)
|
|
mdb> p goal
|
|
functor_names(two("three", 3, three("four", 4, "one", 1, empty, empty, empty), two("two", 2, empty, empty))) = _
|
|
mdb> format verbose
|
|
mdb> format_param lines 100
|
|
mdb> p goal
|
|
functor_names
|
|
1-two
|
|
| 1-"three"
|
|
| 2-3
|
|
| 3-three
|
|
| | 1-"four"
|
|
| | 2-4
|
|
| | 3-"one"
|
|
| | 4-1
|
|
| | 5-empty
|
|
| | 6-empty
|
|
| | 7-empty
|
|
| 4-two
|
|
| 1-"two"
|
|
| 2-2
|
|
| 3-empty
|
|
| 4-empty
|
|
2-_
|
|
|
|
mdb> format flat
|
|
mdb> browse goal
|
|
browser> ^1
|
|
browser> p
|
|
two("three", 3, three("four", 4, "one", 1, empty, empty, empty), two("two", 2, empty, empty))
|
|
browser> ^..^2
|
|
browser> p
|
|
'_'
|
|
browser> ^..^3
|
|
error: there is no subterm 3
|
|
browser> p
|
|
'_'
|
|
browser> ^..^r
|
|
browser> p
|
|
'_'
|
|
browser> quit
|
|
mdb> b -A deconstruct.det_arg/4
|
|
0: + stop interface pred deconstruct.det_arg/4-0 (det)
|
|
1: + stop interface pred deconstruct.det_arg/4-1 (det)
|
|
2: + stop interface pred deconstruct.det_arg/4-2 (cc_multi)
|
|
3: + stop interface pred deconstruct.det_arg/4-3 (cc_multi)
|
|
mdb> c
|
|
E3: C3 CALL pred deconstruct.det_arg/4-1 (det)
|
|
mdb> P
|
|
Term (arg 1) two("three", 3, three("four", 4, "one", 1, empty, empty, empty), two/4)
|
|
NonCanon (arg 2) canonicalize
|
|
Index (arg 3) 3
|
|
mdb> f
|
|
E4: C3 EXIT pred deconstruct.det_arg/4-1 (det)
|
|
mdb> P
|
|
Term (arg 1) two("three", 3, three("four", 4, "one", 1, empty, empty, empty), two/4)
|
|
NonCanon (arg 2) canonicalize
|
|
Index (arg 3) 3
|
|
Argument (arg 4) two("two", 2, empty, empty)
|
|
mdb> disable *
|
|
0: - stop interface pred deconstruct.det_arg/4-0 (det)
|
|
1: - stop interface pred deconstruct.det_arg/4-1 (det)
|
|
2: - stop interface pred deconstruct.det_arg/4-2 (cc_multi)
|
|
3: - stop interface pred deconstruct.det_arg/4-3 (cc_multi)
|
|
mdb> c
|
|
two
|