[m-rev.] for review: RTTI/unify/compare for builtin types in the runtime

Zoltan Somogyi zs at cs.mu.OZ.AU
Thu Aug 8 12:55:28 AEST 2002


On 07-Aug-2002, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> To start with: those XXXs in the log message should be fixed.

Sorry, I fixed those on my laptop just before sending the mail, but sent
an old version from ender instead. Here is updated log.

Zoltan.

Harmonize the treatment of the builtin types by the runtime system across
the MLDS and LLDS C backends. (Their treatment by the .NET and Java backends
is unchanged, at least for now.)

Previously, the RTTI data structures and unify and compare predicates for the
builtin types were defined in runtime/mercury.c for the MLDS backend but in
library/{builtin,private_builtin,type_desc}.m for the LLDS backend. This
make several kinds of maintenance difficult, and more likely to be forgotten.
The two backends also had their generic unify/compare code in different modules
(mercury.c and mercuy_ho_call.c) and used distinct macros for defining RTTI
data structures. This change fixes those problems by defining a consistent
set of macros (with backend-specific implementations but backend-independent
semantics), concentrating the definitions of all the RTTI structures and of all
the unify and compare predicates for builtin types in a new module in the
runtime, mercury_builtin_types.[ch], and concentrating all the generic
unify/compare predicates in mercury_ho_call.[ch].

This change also makes the runtime use consistently module qualified names
for the RTTI data structures for the builtin types. Since they are not module
qualified by the Mercury compiler, we module qualify them by macros that map
the mmc-generated names to the ones expected by the runtime system. This makes
it easier to use the same macros in LLDS and MLDS grades.

runtime/mercury_builtin_types.[ch]:
	New module to contain all the C code for the implementation of
	unify and compare predicates for the builtin types. Its contents
	comes from mercury.c in the runtime (for the MLDS C backend) and
	builtin.m, private_builtin.m and type_desc.m in the library (for the
	LLDS C backend).

	The unify/compare predicates for tuples now report errors. This is
	necessary because the tuple is a variable arity constructor. Their
	previous implementations for the MLDS backend relied on only being
	called from the generic unify/compare routines with a nonstandard
	interface, being passed a typeinfo for the tuple type, rather than
	the typeinfos for the arguments of the type constructor. This worked
	because we don't currently specialize unifies/compares of tuple types,
	but was a potential problem if we ever started to do such
	specialization. The fix is to handle tuples in the generic
	unify/compare routines, just as in the LLDS backend.

runtime/mercury_ho_call.c:
	Move the generic unify/compare routines for the MLDS backend here
	from mercury.c.

	Conform to the coding standard wrt indentation.

runtime/mercury_ho_call.h:
	Declare the generic unify/compare routines for both backends.

	Delete a typedef that now needs to be in mercury_types.h to avoid
	circular dependencies.

runtime/mercury_type_info.h:
	Use the same macros for defining type_ctor_info structures for the MLDS
	and LLDS backends.

	This required moving the definitions of MR_UnifyFunc_N and
	MR_CompareFunc_N here from mercury.c.

runtime/mercury_hlc_types.h:
	A new file containing definitions of types needed by the MLDS C
	backend. These definitions used to be in mercury.h, but now they are
	needed in mercury_type_info.h, a header file that doesn't and shouldn't
	include mercury.h. They can't easily be put in mercury_types.h because
	they depend on mercury_std.h, and we are not allowed to include
	mercury_std.h in mercury_types.h.

runtime/mercury.h:
	Delete the definitions of the C types representing type_info and
	pseudo_type_infos, since these are now in mercury_type_info.h.
	#include mercury_type_info.h.

	Delete the definitions now in mercury_hlc_types.h.

runtime/mercury.c:
	Delete the definitions of the C types representing unify and compare
	predicates, since these are now in mercury_type_info.h.

runtime/mercury_bootstrap.h:
	Module qualify the RTTI data structures of the builtin types, since
	it makes it easier to use the same macros to define RTTI structures
	in the LLDS and MLDS backend. (Previously, mercury_bootstrap.h had
	macros to delete such module qualification for the variable arity
	types.)

runtime/mercury_types.h:
	Move some type definitions from mercury_ho_call.h and
	mercury_deep_profiling.h to mercury_types.h to prevent problems
	with circular dependencies between header files.

runtime/mercury_debug.h:
	Delete a #include to prevent a circular dependency.

runtime/mercury_profiling_builtin.[ch]:
	A new module containing the {call,exit,redo,fail} port predicates
	for deep profiling, moved here from library/profiling_builtin.m.
	They are referred to by the implementations of the unify and compare
	predicates of builtin types, and thus they need to be in the runtime
	directory to avoid references from the runtime to the library.

runtime/Mmakefile:
	Add the new files.

tools/make_port_code:
	A script to generate runtime/mercury_profiling_builtin.[ch] fully
	automatically.

library/array.m:
	Use the new backend-independent macros to reduce the amount of code
	that was duplicated for the two backends.

library/builtin.m:
library/private_builtin.m:
library/type_desc.m:
	Delete RTTI structures and unify and compare predicates
	that are now in runtime/mercury_builtin_types.c.

library/profiling_builtin.m:
	Replace the definitions of the predicates implementing the
	{call,exit,redo,fail} port predicates with external declarations.

trace/mercury_trace_vars.c:
	Use a now backend-independent macro to refer to a type_ctor_info.

trace/Mmakefile:
	Do not define MERCURY_BOOTSTRAP_H, since mercury_bootstrap.h now
	contains some definitions needed by code in the trace directory.

util/mkinit.c:
	Module qualify the references to the RTTI structures of builtin types,
	since the generated _init.c files don't include mercury_bootstrap.h.
	Note that after this change has bootstrapped, we should be able to
	delete those references, since they were only needed to give the
	runtime access to the addresses of RTTI structures that used to be
	defined in the library, but are now defined in the runtime.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list