The hand-written C unify and compare predicates for tuples did not preserve
deep profiler invariants correctly across the recursive unify/compare of
tuple arguments. I tried to do so, and failed. Instead, implement the
predicates in Mercury so the compiler can perform the deep profiling
transformation on them. Bug #3.
A micro-benchmark on my machine is about twice as fast in asm_fast.gc
after this patch, and about the same in hlc.gc. The change to the
high-level C backend is only to reduce code duplication.
library/library.m:
Add foreign-exported predicates to take the place of `io.init_state'
and `io.finalize_state' as overall initialization/finalization
predicates.
library/builtin.m:
Add `unify_tuple', `compare_tuple', `compare_rep_tuple' predicates.
Add initializer which sets `MR_special_pred_hooks' to point to those
predicates.
Delete unused predicates `call_rtti_generic_unify',
`call_rtti_generic_compare'.
Reorder some code.
library/io.m:
Add `io.finalize_state' to hidden interface.
Delete foreign exports for `io.init_state' and `io.finalize_state'.
Reorder some code.
runtime/mercury_ho_call.c:
runtime/mercury_ho_call.h:
Add a global variable `MR_special_pred_hooks' for the library to
set up during initialisation.
Add `tailcall' macros for use by `mercury_unify_compare_body.h'.
Rename `tailcall_user_pred' to `tailcall_tci_pred'.
Call the new unify/compare predicates in the high-level C
backend via `MR_special_pred_hooks'.
Delete `unify_tuples' and `compare_tuples' for the high-level C
and call the Mercury predicates set in `MR_special_pred_hooks'.
runtime/mercury_unify_compare_body.h:
Delete the unify and compare code for tuples in the low-level C
backend. Jump to the Mercury predicates set in
`MR_special_pred_hooks' instead.
Add some comments.
compiler/elds_to_erlang.m:
runtime/mercury_init.h:
runtime/mercury_wrapper.c:
util/mkinit.c:
Conform to the library initializer/finalizer change.
tests/hard_coded/Mmakefile:
tests/hard_coded/tuple_test2.exp
tests/hard_coded/tuple_test2.m:
Add test case.
NEWS:
Announce the change.