mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-17 23:05:21 +00:00
585fca09aeb3dda5b718b534043edf2929da944c
3 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
c2a696d8b6 |
Clean up the runtime system's handling of type_infos and pseudo_type_infos.
Estimated hours taken: 40
Clean up the runtime system's handling of type_infos and pseudo_type_infos.
This cleanup has two major aspects. First, it represents type_infos and
pseudo_type_infos with distinct C types, and reducing the use of casts
to the minimum. These casts are in two kinds of places: in a few macros
defined in runtime/mercury_type_info.h, and at the interfaces between C code
and Mercury code (since Mercury code represents (pseudo-)type_infos, like
everything else, as Words). Part of this aspect is the separation of the
type "MR_TypeInfo" from the type "MR_TypeInfoParams"; a MR_TypeInfo can be
used as a source of type parameters directly only when it is first order.
Second, it removes the confusion between the types named "type_info" and
"type_ctor_info" defined by the modules private_builtin.m and std_util.m,
by renaming the types defined in std_util.m to "type_desc" and
"type_ctor_desc".
To avoid doing this cleanup twice, this diff also removes support for the
old type_ctor_info representation. This in turn makes it feasible to provide
conditionally enabled code to support unification and comparison by RTTI.
runtime/mercury_grade.h:
Increment the binary compatibility version number. This is required
by the dropping of support for old type_ctor_info representations.
runtime/mercury_type_info.h:
Define the types MR_TypeInfo, MR_PseudoTypeInfo and MR_TypeInfoParams,
and macros that operate on them.
Remove the types and macros that were useful only with the old RTTI
representation.
Move the section that deals with initializing code addresses in
type_ctor_info structure for grades without static code addresses
to the logical place.
Add a const qualifier to the MR_sectag_alternatives field in
MR_DuPtagLayout, since this simplifies code manipulating du types.
Convert the whole file to 4 space indentation, since it is a nuisance
if only part of it is so indented.
runtime/mercury_deep_copy.h:
runtime/mercury_deep_copy_body.h:
runtime/mercury_tabling.h:
runtime/mercury_tabling.c:
Clean up the implementation as described above.
runtime/mercury_type_info.c:
runtime/mercury_make_type_info_body.h:
Clean up the implementation as described above.
Eliminate the code duplication between the function MR_make_type_info
and MR_create_type_info, and their helpers, which do the same thing
except for how they allocate memory, by putting the common code into
the new file mercury_make_type_info_body.h, and including it twice
in two different #define contexts.
Move the (updated) documentation of those functions to
mercury_type_info.h, where it belongs.
runtime/mercury_ho_call.c:
runtime/mercury_unify_compare_body.h:
Clean up the implementation as described above.
Eliminate the code duplication between the implementation of unify
and compare, which do very similar jobs, by putting the common code
into the new file mercury_unify_compare_body.h, and including it three
times in two different #define contexts. The third time is for defining
the body of a C function which does the same thing as compare. This
is necessary for unification and comparison by RTTI, since the
unification or comparison of two structured terms requires comparing
their subterms. (There is no need for a separate C function for
unification; the C comparison function is sufficient.)
mercury_unify_compare_body.h has conditional support for unification
and comparison by RTTI. Although this has been tested and is known
to work, it is turned off for the moment. This may change after
benchmarking.
runtime/Mmakefile:
Add the new include files to the list.
library/std_util.m:
Rename type_info to type_desc and type_ctor_info to type_info_desc.
Keep the old names as equivalence types, for the time being.
Document the representations.
Move the macros that refer to type_descs and type_ctor_descs here from
runtime/mercury_type_info.h, since this is the only place where they
are used. Rename them to conform to the new names of the types.
Clean up the implementation of the RTTI predicates and functions
as described above. In the process, fix some bugs where type variables
were expanded twice, with the second expansion's code being incorrect.
Also factor out some common code, and unfactor some uncommon code
(where a function had two uses, but its implementation was inefficient
overkill for one of them).
library/builtin.m:
library/private_builtin.m:
library/io.m:
library/store.m:
runtime/mercury_layout_util.[ch]:
trace/mercury_trace_declarative.c:
trace/mercury_trace_external.c:
trace/mercury_trace_vars.[ch]:
When calling C functions involving type_infos, cast them to the new
types.
runtime/mercury_stack_layout.h:
Fix a bug that was masked by casts in its client code.
compiler/rtti_out.m:
Delete from the output a cast made unnecessary by the new const
qualifier on MR_sectag_alternatives.
browser/browse.m:
browser/help.m:
library/io.m:
library/term.m:
tests/hard_coded/construct.m;
tests/hard_coded/existential_types_test.m:
tests/hard_coded/higher_order_type_manip.{m,exp}:
Refer to the types defined in std_util.m by their new names.
tests/hard_coded/existential_rtti.{m,exp}:
Make the test tougher by printing out not just one deconstructed term,
but deconstructed versions of all the terms created by this test.
|
||
|
|
9ba3b14098 |
Make all the modules in the browser library sub-modules of
Estimated hours taken: 1 Make all the modules in the browser library sub-modules of module `mdb', to avoid link errors when users use module names such as `parse'. browser/Mmakefile: browser/browser_library.m: browser/mdb.m: Rename browser_library.m to mdb.m. Change `:- import_module' declarations to `:- include_module' declarations. browser/Mmakefile: Remove the special case rule for `mer_browser.init' -- it doesn't work when the file names are not the same as the module name. Instead, the default rule for `mdb.init' is used and the output is copied to `mer_browser.init'. browser/.cvsignore: Rename header files, etc. browser/*.m: Add a `mdb__' prefix to the names of modules in the browser library in `:- module' and `:- import_module' declarations. trace/*.c: Rename the header files for the browser library in `#include' statements. tests/hard_coded/Mmakefile: tests/hard_coded/parse.m: tests/hard_coded/parse.exp: Test case. |
||
|
|
8ddce575d4 |
Introduce two new directories, trace and browser, containing libraries
Estimated hours taken: 10
Introduce two new directories, trace and browser, containing libraries
holding the C and Mercury code of the debugger respectively. (Although
the browser directory does not have a browser in it yet, the browser
should soon become its biggest component.) Take the opportunity to
rename the existing libraries, for consistency.
After this change, the linking order becomes:
the object of the auto-generated init file
program object files
trace library (libmer_trace.a)
browser library (libmer_browser.a)
standard library (libmer_std.a)
runtime library (libmer_rt.a)
Boehm collector (libgc.a)
To avoid circularities, libraries cannot contain direct calls to
any routines that are defined in libraries (or object files) that
occur earlier in the above list. Any such calls must be made into
indirect calls via function pointers.
In particular, there was a circularity caused by the library calling
MR_trace() which invokes the tracer which in turn invokes the
library. This circularity was broken by having MR_trace(),
which is defined in the runtime, call the tracer indirectly via
a global variable named MR_trace_func_ptr. This global variable
is initialized by the auto-generated *_init.c file.
To avoid linking in the tracer even when it is not being used,
this global variable is only set to point to MR_trace_real()
if you're using a debugging grade or if c2init was invoked
with the `-t' flag. Otherwise it is set to MR_trace_fake()
which just prints an error message telling the user to
rebuild the executable with debugging enabled.
Makefile.DLLs:
Reserve random locations for the two new libraries. Whether they work
will be decided by testing on Windows.
Mmake.common.in:
Add variables naming the new directories, and create variables
naming the libraries.
Mmakefile:
Add targets for the new directories, and modify existing rules
as appropriate.
browser/Mmakefile:
Mmakefile for the new directory, modelled on library/Mmakefile.
browser/browser_library.m:
Umbrella file for the new directory, modelled on library/library.m.
{browser,library}/debugger_interface.m:
Moved this file from library to browser without change.
browser/help.m:
A new module for the help system of the debugger. Not yet used.
compiler/Mmakefile:
Update to refer to the new directories and libraries where
appropriate.
compiler/mercury_compile.m:
If we are doing tracing, then pass -t instead of -i to c2init.
compiler/modules.m:
When generating the .dep file, get the grade flags passed to c2init.
doc/Mmakefile:
Remove the special treatment of library/debugger_interface.m.
library/Mmakefile:
Update to refer to the new directories and libraries where
appropriate, and to conform to the new name of the library.
library/library.m:
Do not import debugger_interface.
profiler/Mmakefile:
Update to refer to the new directories and libraries where
appropriate.
runtime/Mmakefile:
Update to refer to the new directories and libraries where
appropriate, and to conform to the new name of the library.
Remove references to files being moved to the trace directory.
runtime/mercury_init.h:
Refer to the automatically generated dll header file by its new name
(renamed because the runtime library is renamed).
Add declarations to support the new global variable MR_trace_func_ptr.
runtime/mercury_memory_handlers.c:
runtime/mercury_memory_zones.c:
runtime/mercury_misc.c:
Remove inappropriate #includes of "mercury_trace.h", and substitute
a #include of "mercury_trace_base.h" if necessary.
{runtime,trace}/mercury_trace.[ch]:
{runtime,trace}/mercury_trace_external.[ch]:
{runtime,trace}/mercury_trace_internal.[ch]:
Move these files from the runtime to the trace directory.
The only changes are the removal from mercury_trace.h of declarations
added to runtime/mercury_trace_base.h, and the change from MR_trace
to MR_trace_real.
runtime/mercury_trace_base.[ch]:
Define MR_trace(), which does an indirect call through
MR_trace_func_ptr if the event should be traced.
Define MR_trace_fake, which just prints an error message.
Its address will be assigned to MR_trace_func_ptr if tracing
is not enabled.
Define the types needed by the signature of MR_trace.
Fix an old bug: s/MERCURY_TRACE_PERMANENT_H/MERCURY_TRACE_BASE_H/.
runtime/mercury_wrapper.[ch]:
Add the new global variable MR_trace_func_ptr.
scripts/c2init.in:
Add a new option, -t/--trace, which enables tracing by causing the
address of MR_trace_real to be assigned to MR_trace_func_ptr.
Have this option be implied by the grade. Also have the old option
-i (need initialization code) be implied by the grade, as well as by
-t.
scripts/ml.in:
Include the new libraries in the link command.
tests/debugger/Mmakefile:
Include -t instead of -i in the list of c2init options. (-t implies
-i.)
tools/bootcheck:
Copy and build the new directories as appropriate. The trace directory
is treated like the runtime, the browser directory is treated like the
library.
trace/Mmakefile:
Mmakefile for the new directory, modelled on runtime/Mmakefile.
util/mkinit.c:
Add the new option -t, as discussed above.
Mmakefile for the new directory, modelled on runtime/Mmakefile.
util/Mmakefile:
Specify -O0, since with the default optimization level, gcc on
cyclone ignores the assignment of TRUE to need_tracing when -t is
given (!!!).
|