mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-22 04:43:53 +00:00
083d376e6598628362ee91c2da170febd83590f4
51 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
896e504580 |
Add missing out-of-line definitions for MR_box_{int64,uint64}.
runtime/mercury.c:
Provide out-of-line definitions for MR_box_{int64,uint64} when using
boxed 64-bit integers and *not* using GCC.
|
||
|
|
d465fa53cb |
Update the COPYING.LIB file and references to it.
Discussion of these changes can be found on the Mercury developers
mailing list archives from June 2018.
COPYING.LIB:
Add a special linking exception to the LGPL.
*:
Update references to COPYING.LIB.
Clean up some minor errors that have accumulated in copyright
messages.
|
||
|
|
53b573692a |
Convert C code to use // style comments.
runtime/*.[ch]:
trace/*.[chyl]:
As above. In some places, improve comments, e.g. by expanding contractions
such as "we've". Add #ifndef guards against double inclusion around
the trace/*.h files that did not already have them.
tools/*:
Make the corresponding changes in shell scripts that generate .[ch] files
in the runtime.
tests/*:
Conform to a slight change in the text of a message.
|
||
|
|
67326f16e4 |
Fix style issues in the runtime.
Move all .h and .c files to four-space indentation without tabs, if they weren't there already. Use the same vim line for all .h and .c files. Align all backslashes at the ends of lines in macro definitions. Align close comment signs. In some places, fix inconsistent indentation. Fix a bunch of comments. Add XXXs to a few of them. |
||
|
|
573e6f2f00 |
Support unboxed float fields in high-level C grades.
Branches: main Support unboxed float fields in high-level C grades. When the representation of `float' is no wider than a machine word, d.u. functor arguments of type `float' (or equivalent) will be stored directly within cells constructed for that functor, instead of a pointer to the box containing the value. This was already so for low-level C grades. compiler/mlds.m: Add an option to mlds_type, equivalent to `mlds_array_type(mlds_generic_type)' except that some elements are known to be floats. Update some comments. compiler/ml_global_data.m: Remember the `--unboxed-float' option in `ml_global_data'. Special case generic arrays in `ml_gen_static_scalar_const_addr' and `ml_gen_static_scalar_const_value'. Float literals cannot be used to initialize an element of a generic array in C. If any appear, replace the generic array type by an instance of `mlds_mostly_generic_array_type' with float fields in the positions which have float initializers. compiler/ml_code_util.m: Make `ml_must_box_field_type' and `ml_gen_box_const_rval' depend on the `--unboxed-float' option. Delete some now-misleading comments. Delete an unused predicate. compiler/mlds_to_c.m: Update code that writes out scalar static data to handle `mlds_mostly_generic_array_type'. In one case, for `--high-level-data' only, output float constants by their integer representation, so that they may be cast to pointer types. compiler/ml_unify_gen.m: Rename some predicates for clarity. compiler/ml_accurate_gc.m: compiler/ml_lookup_switch.m: compiler/ml_proc_gen.m: compiler/ml_simplify_switch.m: compiler/mlds_to_cs.m: compiler/mlds_to_gcc.m: compiler/mlds_to_il.m: compiler/mlds_to_java.m: Conform to changes. library/float.m: Add hidden functions to return the integer representation of the bit layout of floating point values. library/exception.m: Delete mention of MR_AVOID_MACROS. runtime/mercury.c: runtime/mercury.h: Make MR_box_float/MR_unbox_float act like "casts" when MR_BOXED_FLOAT is undefined, and only define them in high-level grades. I think they should be replaced by MR_float_to_word/MR_word_to_float (which have less confusing names when there is no boxing) but that would require some header file reshuffling which I don't want to undertake yet. Delete references to MR_AVOID_MACROS. Apparently it existed to support the defunct gcc back-end but I cannot see it ever being defined. runtime/mercury_conf_param.h: MR_HIGHLEVEL_CODE no longer implies MR_BOXED_FLOAT. Delete mention of MR_AVOID_MACROS. runtime/mercury_float.h: Fix a comment. tests/hard_coded/Mmakefile: tests/hard_coded/float_ground_term.exp: tests/hard_coded/float_ground_term.m: Add a test case. |
||
|
|
8af00f7a2a |
Avoid using the __GNUC__ macro in the runtime as a test for the presence of
Branches: main, 11.07 Avoid using the __GNUC__ macro in the runtime as a test for the presence of gcc, since clang also defines that macro. Since clang doesn't support all of the GNU C extensions, we can't actually use __GNUC__ without also checking whether we are actually using clang. runtime/mercury_conf_param.h: Add three new macros, MR_CLANG, MR_GNUC and MR_MSVC that are defined only when the C compiler is clang, gcc, or Visual C respectively. (In particular, MR_GNUC will _not_ be defined when the C compiler is clang.) runtime/mercury.c: runtime/mercury.h: runtime/mercury_atomic_ops.c: runtime/mercury_atomic_ops.h runtime/mercury_bitmap.h: runtime/mercury_float.h: runtime/mercury_getopt.c: runtime/mercury_goto.h: runtime/mercury_heap.h: runtime/mercury_std.h: Replace uses of the __GNUC__ and __clang__ macros with the above. runtime/mercury_regs.h: As above, also #include mercury_conf_param.h directly since this file is #included by some of the tests in the configure script. |
||
|
|
7e26b55e74 |
Implement a new form of memory profiling, which tells the user what memory
Branches: main
Implement a new form of memory profiling, which tells the user what memory
is being retained during a program run. This is done by allocating an extra
word before each cell, which is used to "attribute" the cell to an
allocation site. The attribution, or "allocation id", is an address to an
MR_AllocSiteInfo structure generated by the Mercury compiler, giving the
procedure, filename and line number of the allocation, and the type
constructor and arity of the cell that it allocates.
The user must manually instrument the program with calls to
`benchmarking.report_memory_attribution', which forces a GC and summarises
the live objects on the heap using the attributions. The mprof tool is
extended with a new mode to parse and present that data.
Objects which are unattributed (e.g. by hand-written C code which hasn't
been updated) are still accounted for, but show up in profiles as "unknown".
Currently this profiling mode only works in conjunction with the Boehm
garbage collector, though in principle it can work with any memory allocator
for which we can access a list of the live objects. Since term size
profiling relies on the same technique of using an extra word per memory
cell, the two profiling modes are incompatible.
The output from `mprof -s' looks like this:
------ [1] some label ------
cells words cumul procedure / type (location)
14150 38872 total
* 1949/ 13.8% 4872/ 12.5% 12.5% <predicate `parser.parse_rest/7' mode 0>
975/ 6.9% 1950/ 5.0% list.list/1 (parser.m:502)
487/ 3.4% 1948/ 5.0% term.term/1 (parser.m:501)
487/ 3.4% 974/ 2.5% term.const/0 (parser.m:501)
* 1424/ 10.1% 4272/ 11.0% 23.5% <predicate `parser.parse_simple_term_2/6' mode 0>
708/ 5.0% 2832/ 7.3% term.term/1 (parser.m:643)
708/ 5.0% 1416/ 3.6% term.const/0 (parser.m:643)
...
boehm_gc/alloc.c:
boehm_gc/include/gc.h:
boehm_gc/misc.c:
boehm_gc/reclaim.c:
Add a callback function to be called for every live object after a GC.
Add a function to write out the GC_size_map array.
compiler/layout.m:
Define the alloc_site_info type which is equivalent to the
MR_AllocSiteInfo C structure.
Add alloc_site_array as a kind of "layout" array.
compiler/llds.m:
Add allocation sites to `cfile' structure.
Replace TypeMsg argument (which was also for profiling) on `incr_hp'
instructions by an allocation site identifier.
Add a new foreign_proc_component for allocation site ids.
compiler/code_info.m:
compiler/global_data.m:
compiler/proc_gen.m:
Keep the set of allocation sites in the code_info and global_data
structures.
compiler/unify_gen.m:
Add allocation sites to LLDS allocation instructions.
compiler/layout_out.m:
compiler/llds_out_file.m:
compiler/llds_out_instr.m:
Output MR_AllocSiteInfo arrays in generated C files.
Output code to register the MR_AllocSiteInfo array with the Mercury
runtime.
Output allocation site ids for memory allocation instructions.
compiler/llds_out_util.m:
Add allocation sites to llds_out_info.
compiler/pragma_c_gen.m:
compiler/ml_foreign_proc_gen.m:
Generate a macro MR_ALLOC_ID which resolves to an allocation site
structure, for every foreign_proc whose C code contains the string
"MR_ALLOC_ID". This is to be used by hand-written C code which
allocates memory.
MR_PROC_LABELs are retained for backwards compatibility. Though
they were introduced for profiling, they seem to have been co-opted
for printf-debugging since then.
compiler/ml_global_data.m:
Add allocation site structures to the MLDS global data.
compiler/mlds.m:
compiler/ml_unify_gen.m:
Add allocation site id to `new_object' instruction.
compiler/mlds_to_c.m:
Output allocation site arrays and allocation ids in high-level C code.
Output a call to register the allocation site array with the Mercury
runtime.
Delete an unused predicate.
compiler/exprn_aux.m:
compiler/jumpopt.m:
compiler/livemap.m:
compiler/mercury_compile_llds_back_end.m:
compiler/middle_rec.m:
compiler/ml_accurate_gc.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_util.m:
compiler/mlds_to_cs.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/use_local_vars.m:
compiler/var_locn.m:
Conform to changes.
compiler/pickle.m:
compiler/prog_event.m:
compiler/timestamp.m:
Conform to changes in memory allocation macros.
library/benchmarking.m:
Add the `report_memory_attribution' instrumentation predicates.
Conform to changes to MR_memprof_record.
library/array.m:
library/bit_buffer.m:
library/bitmap.m:
library/construct.m:
library/deconstruct.m:
library/dir.m:
library/io.m:
library/mutvar.m:
library/store.m:
library/string.m:
library/thread.semaphore.m:
library/version_array.m:
Use attributed memory allocation throughout the standard library so
that objects don't show up in the memory profile as "unknown".
Replace MR_PROC_LABEL by MR_ALLOC_ID.
mdbcomp/program_representation.m:
mdbcomp/rtti_access.m:
Replace MR_PROC_LABEL by MR_ALLOC_ID.
profiler/Mercury.options:
profiler/globals.m:
profiler/mercury_profile.m:
profiler/options.m:
profiler/output.m:
profiler/snapshots.m:
Add a new mode to `mprof' to parse and present the data from
`Prof.Snapshots' files.
Add options for the new profiling mode.
profiler/process_file.m:
Fix a typo.
runtime/mercury_conf_param.h:
#define MR_MPROF_PROFILE_MEMORY_ATTRIBUTION if memory profiling
is enabled and we are using Boehm GC.
runtime/mercury.h:
Make MR_new_object take an allocation id argument.
Conform to changes in memory allocation macros.
runtime/mercury_memory.c:
runtime/mercury_memory.h:
runtime/mercury_types.h:
Define MR_AllocSiteInfo.
Add memory allocation functions and macros which take into the
account the additional word necessary for the new profiling mode.
These should be used in preferences to the raw memory allocation
functions wherever possible so that objects do not show up in the
profile as "unknown".
Add analogues of realloc/free which take into account the offset
introduced by the attribution word.
Add function versions of the MR_new_object macros, which can't be
written in standard C. They are only used when necessary.
Add built-in allocation site ids, to be used in the runtime and
other hand-written code when context-specific ids are unavailable.
runtime/mercury_heap.h:
Make MR_tag_offset_incr_hp_msg and MR_tag_offset_incr_hp_atomic_msg
allocate an extra word when memory attribution is desired, and store
the allocation id there.
Similarly for MR_create{1,2,3}_msg.
Replace proclabel arguments in allocation macros by alloc_id
arguments.
Replace MR_hp_alloc_atomic by MR_hp_alloc_atomic_msg. It was only
used for boxing floats.
Conform to change to MR_new_object macro.
runtime/mercury_bootstrap.h:
Delete obsolete macro hp_alloc_atomic.
runtime/mercury_heap_profile.c:
runtime/mercury_heap_profile.h:
Add the code to summarise the live objects on the Boehm GC heap and
writes out the data to `Prof.Snapshots', for display by mprof.
Don't store the procedure name in MR_memprof_record: the procedure
address is enough and faster to compare.
runtime/mercury_prof.c:
Finish and close the `Prof.Snapshots' file when the program
terminates.
Conform to changes in MR_memprof_record.
runtime/mercury_misc.h:
Add a macro to expand to the name of the allocation sites array
in LLDS grades.
runtime/mercury_bitmap.c:
runtime/mercury_bitmap.h:
Pass allocation id through bitmap allocation functions.
Delete unused function MR_string_to_bitmap.
runtime/mercury_string.h:
Add MR_make_aligned_string_copy_msg.
Make string allocation macros take allocation id arguments.
runtime/mercury.c:
runtime/mercury_array_macros.h:
runtime/mercury_context.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deconstruct_macros.h:
runtime/mercury_dlist.c:
runtime/mercury_engine.c:
runtime/mercury_float.h:
runtime/mercury_hash_table.c:
runtime/mercury_ho_call.c:
runtime/mercury_label.c:
runtime/mercury_prof_mem.c:
runtime/mercury_stacks.c:
runtime/mercury_stm.c:
runtime/mercury_string.c:
runtime/mercury_thread.c:
runtime/mercury_trace_base.c:
runtime/mercury_trail.c:
runtime/mercury_type_desc.c:
runtime/mercury_type_info.c:
runtime/mercury_wsdeque.c:
Use attributed memory allocation throughout the runtime so that
objects don't show up in the profile as "unknown".
runtime/mercury_memory_zones.c:
Attribute memory zones to the Mercury runtime.
runtime/mercury_tabling.c:
runtime/mercury_tabling.h:
Use attributed memory allocation macros for tabling structures.
Delete unused MR_table_realloc_* and MR_table_copy_bytes macros.
runtime/mercury_deep_copy_body.h:
Try to retain the original attribution word when copying values.
runtime/mercury_ml_expand_body.h:
Conform to changes in memory allocation macros.
runtime/mercury_tags.h:
Replace proclabel arguments by alloc_id arguments in allocation macros.
runtime/mercury_wrapper.c:
If memory attribution is enabled, tell Boehm GC that pointers may be
displaced by an extra word.
trace/mercury_trace.c:
trace/mercury_trace_tables.c:
Conform to changes in memory allocation macros.
extras/net/tcp.m:
extras/solver_types/library/any_array.m:
extras/trailed_update/tr_array.m:
Conform to changes in memory allocation macros.
doc/user_guide.texi:
Document the new profiling mode.
doc/reference_manual.texi:
Update a commented out example.
|
||
|
|
c959a1657f |
Convert all remaining C source files to four-space indentation.
Estimated hours taken: 0.5 Branches: main runtime/*.c: Convert all remaining C source files to four-space indentation. Fix some deviations from our style guide. |
||
|
|
f007b45df8 |
Implement the infrastructure for term size profiling.
Estimated hours taken: 400
Branches: main
Implement the infrastructure for term size profiling. This means adding two
new grade components, tsw and tsc, and implementing them in the LLDS code
generator. In grades including tsw (term size words), each term is augmented
with an extra word giving the number of heap words it contains; in grades
including tsc (term size cells), each term is augmented with an extra word
giving the number of heap cells it contains. The extra word is at the start,
at offset -1, to leave almost all of the machinery for accessing the heap
unchanged.
For now, the only way to access term sizes is with a new mdb command,
"term_size <varspec>". Later, we will use term sizes in conjunction with
deep profiling to do experimental complexity analysis, but that requires
a lot more research. This diff is a necessary first step.
The implementation of term size profiling consists of three main parts:
- a source-to-source transform that computes the size of each heap cell
when it is constructed (and increments it in the rare cases when a free
argument of an existing heap cell is bound),
- a relatively small change to the code generator that reserves the extra
slot in new heap cells, and
- extensions to the facilities for creating cells from C code to record
the extra information we now need.
The diff overhauls polymorphism.m to make the source-to-source transform
possible. This overhaul includes separating type_ctor_infos and type_infos
as strictly as possible from each other, converting type_ctor_infos into
type_infos only as necessary. It also includes separating type_ctor_infos,
type_infos, base_typeclass_infos and typeclass_infos (as well as voids,
for clarity) from plain user-defined type constructors in type categorizations.
This change needs this separation because values of those four types do not
have size slots, but they ought to be treated specially in other situations
as well (e.g. by tabling).
The diff adds a new mdb command, term_size. It also replaces the proc_body
mdb command with new ways of using the existing print and browse commands
("print proc_body" and "browse proc_body") in order to make looking at
procedure bodies more controllable. This was useful in debugging the effect
of term size profiling on some test case outputs. It is not strictly tied
to term size profiling, but turns out to be difficult to disentangle.
compiler/size_prof.m:
A new module implementing the source-to-source transform.
compiler/notes/compiler_design.html:
Mention the new module.
compiler/transform_hlds.m:
Include size_prof as a submodule of transform_hlds.
compiler/mercury_compile.m:
If term size profiling is enabled, invoke its source-to-source
transform.
compiler/hlds_goal.m:
Extend construction unifications with an optional slot for recording
the size of the term if the size is a constant, or the identity of the
variable holding the size, if the size is not constant. This is
needed by the source-to-source transform.
compiler/quantification.m:
Treat the variable reference that may be in this slot as a nonlocal
variable of construction unifications, since the code generator needs
this.
compiler/compile_target_code.m:
Handle the new grade components.
compiler/options.m:
Implement the options that control term size profiling.
doc/user_guide.texi:
Document the options and grade components that control term size
profiling, and the term_size mdb command. The documentation is
commented out for now.
Modify the wording of the 'u' HLDS dump flag to include other details
of unifications (e.g. term size info) rather than just unification
categories.
Document the new alternatives of the print and browse commands. Since
they are for developers only, the documentation is commented out.
compiler/handle_options.m:
Handle the implications of term size profiling grades.
Add a -D flag value to print HLDS components relevant to HLDS
transformations.
compiler/modules.m:
Import the new builtin library module that implements the operations
needed by term size profiling automatically in term size profiling
grades.
Switch the predicate involved to use state var syntax.
compiler/prog_util.m:
Add predicates and functions that return the sym_names of the modules
needed by term size profiling.
compiler/code_info.m:
compiler/unify_gen.m:
compiler/var_locn.m:
Reserve an extra slot in heap cells and fill them in in unifications
marked by size_prof.
compiler/builtin_ops.m:
Add term_size_prof_builtin.term_size_plus as a builtin, with the same
implementation as int.+.
compiler/make_hlds.m:
Disable warnings about clauses for builtins while the change to
builtin_ops is bootstrapped.
compiler/polymorphism.m:
Export predicates that generate goals to create type_infos and
type_ctor_infos to add_to_construct.m. Rewrite their documentation
to make it more detailed.
Make orders of arguments amenable to the use of state variable syntax.
Consolidate knowledge of which type categories have builtin unify and
compare predicates in one place.
Add code to leave the types of type_ctor_infos alone: instead of
changing their types to type_info when used as arguments of other
type_infos, create a new variable of type type_info instead, and
use an unsafe_cast. This would make the HLDS closer to being type
correct, but this new code is currently commented out, for two
reasons. First, common.m is currently not smart enough to figure out
that if X and Y are equal, then similar unsafe_casts of X and Y
are also equal, and this causes the compiler do not detect some
duplicate calls it used to detect. Second, the code generators
are also not smart enough to know that if Z is an unsafe_cast of X,
then X and Z do not need separate stack slots, but can use the same
slot.
compiler/type_util.m:
Add utility predicates for returning the types of type_infos and
type_ctor_infos, for use by new code in polymorphism.m.
Move some utility predicates here from other modules, since they
are now used by more than one module.
Rename the type `builtin_type' as `type_category', to better reflect
what it does. Extend it to put the type_info, type_ctor_info,
typeclass_info, base_typeclass_info and void types into categories
of their own: treating these types as if they were a user-defined
type (which is how they used to be classified) is not always correct.
Rename the functor polymorphic_type to variable_type, since types
such as list(T) are polymorphic, but they fall into the user-defined
category. Rename user_type as user_ctor_type, since list(int) is not
wholly user-defined but falls into this category. Rename pred_type
as higher_order_type, since it also encompasses functions.
Replace code that used to check for a few of the alternatives
of this type with code that does a full switch on the type,
to ensure that they are updated if the type definition ever
changes again.
compiler/pseudo_type_info.m:
Delete a predicate whose updated implementation is now in type_util.m.
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
Still treat type_infos, type_ctor_infos, typeclass_infos and
base_typeclass_infos as user-defined types, but prepare for when
they won't be.
compiler/hlds_pred.m:
Require interface typeinfo liveness when term size profiling is
enabled.
Add term_size_profiling_builtin.increase_size as a
no_type_info_builtin.
compiler/hlds_out.m:
Print the size annotations on unifications if HLDS dump flags call
for unification details. (The flag test is in the caller of the
modified predicate.)
compiler/llds.m:
Extend incr_hp instructions and data_addr_consts with optional fields
that allow the code generator to refer to N words past the start of
a static or dynamic cell. Term size profiling uses this with N=1.
compiler/llds_out.m:
When allocating memory on the heap, use the macro variants that
specify an optional offset, and specify the offset when required.
compiler/bytecode_gen.m:
compiler/dense_switch.m:
compiler/dupelim.m:
compiler/exprn_aux.m:
compiler/goal_form.m:
compiler/goal_util.m:
compiler/higher_order.m:
compiler/inst_match.m:
compiler/intermod.m:
compiler/jumpopt.m:
compiler/lambda.m:
compiler/livemap.m:
compiler/ll_pseudo_type_info.m:
compiler/lookup_switch.m:
compiler/magic_util.m:
compiler/middle_rec.m:
compiler/ml_code_util.m:
compiler/ml_switch_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/modecheck_unify.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/par_conj_gen.m:
compiler/post_typecheck.m:
compiler/reassign.m:
compiler/rl.m:
compiler/rl_key.m:
compiler/special_pred.m:
compiler/stack_layout.m:
compiler/static_term.m:
compiler/string_switch.m:
compiler/switch_gen.m:
compiler/switch_util.m:
compiler/table_gen.m:
compiler/term_util.m:
compiler/type_ctor_info.m:
compiler/unused_args.m:
compiler/use_local_vars.m:
Minor updates to conform to the changes above.
library/term_size_prof_builtin.m:
New module containing helper predicates for term size profiling.
size_prof.m generates call to these predicates.
library/library.m:
Include the new module in the library.
doc/Mmakefile:
Do not include the term_size_prof_builtin module in the library
documentation.
library/array.m:
library/benchmarking.m:
library/construct.m:
library/deconstruct.m:
library/io.m:
library/sparse_bitset.m:
library/store.m:
library/string.m:
Replace all uses of MR_incr_hp with MR_offset_incr_hp, to ensure
that we haven't overlooked any places where offsets may need to be
specified.
Fix formatting of foreign_procs.
Use new macros defined by the runtime system when constructing
terms (which all happen to be lists) in C code. These new macros
specify the types of the cell arguments, allowing the implementation
to figure out the size of the new cell based on the sizes of its
fields.
library/private_builtin.m:
Define some constant type_info structures for use by these macros.
They cannot be defined in the runtime, since they refer to types
defined in the library (list.list and std_util.univ).
util/mkinit.c:
Make the addresses of these type_info structures available to the
runtime.
runtime/mercury_init.h:
Declare these type_info structures, for use in mkinit-generated
*_init.c files.
runtime/mercury_wrapper.[ch]:
Declare and define the variables that hold these addresses, for use
in the new macros for constructing typed lists.
Since term size profiling can refer to a memory cell by a pointer
that is offset by one word, register the extra offsets with the Boehm
collector if is being used.
Document the incompatibility of MR_HIGHTAGS and the Boehm collector.
runtime/mercury_tags.h:
Define new macros for constructing typed lists.
Provide macros for preserving the old interface presented by this file
to the extent possible. Uses of the old MR_list_cons macro will
continue to work in grades without term size profiling. In term
size profiling grades, their use will get a C compiler error.
Fix a bug caused by a missing backslash.
runtime/mercury_heap.h:
Change the basic macros for allocating new heap cells to take
an optional offset argument. If this is nonzero, the macros
increment the returned address by the given number of words.
Term size profiling specifies offset=1, reserving the extra
word at the start (which is ignored by all components of the
system except term size profiling) for holding the size of the term.
Provide macros for preserving the old interface presented by this file
to the extent possible. Since the old MR_create[123] and MR_list_cons
macros did not specify type information, they had to be changed
to take additional arguments. This affects only hand-written C code.
Call new diagnostic macros that can help debug heap allocations.
Document why the macros in this files must expand to expressions
instead of statements, evn though the latter would be preferable
(e.g. by allowing them to declare and use local variables without
depending on gcc extensions).
runtime/mercury_debug.[ch]:
Add diagnostic macros to debug heap allocations, and the functions
behind them if MR_DEBUG_HEAP_ALLOC is defined.
Update the debugging routines for hand-allocated cells to print the
values of the term size slot as well as the other slots in the relevant
grades.
runtime/mercury_string.h:
Provide some needed variants of the macro for copying strings.
runtime/mercury_deconstruct_macros.h:
runtime/mercury_type_info.c:
Supply type information when constructing terms.
runtime/mercury_deep_copy_body.h:
Preserve the term size slot when copying terms.
runtime/mercury_deep_copy_body.h:
runtime/mercury_ho_call.c:
runtime/mercury_ml_expand_body.h:
Use MR_offset_incr_hp instead of MR_incr_hp to ensure that all places
that allocate cells also allocate space for the term size slot if
necessary.
Reduce code duplication by using a now standard macro for copying
strings.
runtime/mercury_grade.h:
Handle the two new grade components.
runtime/mercury_conf_param.h:
Document the C macros used to control the two new grade components,
as well as MR_DEBUG_HEAP_ALLOC.
Detect incompatibilities between high level code and profiling.
runtime/mercury_term_size.[ch]:
A new module to house a function to find and return term sizes
stored in heap cells.
runtime/mercury_proc_id.h:
runtime/mercury_univ.h:
New header files. mercury_proc_id.h contains the (unchanged)
definition of MR_Proc_Id, while mercury_univ.h contains the
definitions of the macros for manipulating univs that used to be
in mercury_type_info.h, updated to use the new macros for allocating
memory.
In the absence of these header files, the following circularity
would ensue:
mercury_deep_profiling.h includes mercury_stack_layout.h
- needs definition of MR_Proc_Id
mercury_stack_layout.h needs mercury_type_info.h
- needs definition of MR_PseudoTypeInfo
mercury_type_info.h needs mercury_heap.h
- needs heap allocation macros for MR_new_univ_on_hp
mercury_heap.h includes mercury_deep_profiling.h
- needs MR_current_call_site_dynamic for recording allocations
Breaking the circular dependency in two places, not just one, is to
minimize similar problems in the future.
runtime/mercury_stack_layout.h:
Delete the definition of MR_Proc_Id, which is now in mercury_proc_id.h.
runtime/mercury_type_info.h:
Delete the macros for manipulating univs, which are now in
mercury_univ.h.
runtime/Mmakefile:
Mention the new files.
runtime/mercury_imp.h:
runtime/mercury.h:
runtime/mercury_construct.c:
runtime/mercury_deep_profiling.h:
Include the new files at appropriate points.
runtime/mercury.c:
Change the names of the functions that create heap cells for
hand-written code, since the interface to hand-written code has
changed to include type information.
runtime/mercury_tabling.h:
Delete some unused macros.
runtime/mercury_trace_base.c:
runtime/mercury_type_info.c:
Use the new macros supplying type information when constructing lists.
scripts/canonical_grade_options.sh-subr:
Fix an undefined sh variable bug that could cause error messages
to come out without identifying the program they were from.
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/canonical_grade_options.sh-subr:
scripts/mgnuc.in:
Handle the new grade components and the options controlling them.
trace/mercury_trace_internal.c:
Implement the mdb command "term_size <varspec>", which is like
"print <varspec>", but prints the size of a term instead of its value.
In non-term-size-profiling grades, it prints an error message.
Replace the "proc_body" command with optional arguments to the "print"
and "browse" commands.
doc/user_guide.tex:
Add documentation of the term_size mdb command. Since the command is
for implementors only, and works only in grades that are not yet ready
for public consumption, the documentation is commented out.
Add documentation of the new arguments of the print and browse mdb
commands. Since they are for implementors only, the documentation
is commented out.
trace/mercury_trace_vars.[ch]:
Add the functions needed to implement the term_size command, and
factor out the code common to the "size" and "print"/"browse" commands.
Decide whether to print the name of a variable before invoking the
supplied print or browse predicate on it based on a flag design for
this purpose, instead of overloading the meaning of the output FILE *
variable. This arrangement is much clearer.
trace/mercury_trace_browse.c:
trace/mercury_trace_external.c:
trace/mercury_trace_help.c:
Supply type information when constructing terms.
browser/program_representation.m:
Since the new library module term_size_prof_builtin never generates
any events, mark it as such, so that the declarative debugger doesn't
expect it to generate any.
Do the same for the deep profiling builtin module.
tests/debugger/term_size_words.{m,inp,exp}:
tests/debugger/term_size_cells.{m,inp,exp}:
Two new test cases, each testing one of the new grades.
tests/debugger/Mmakefile:
Enable the two new test cases in their grades.
Disable the tests sensitive to stack frame sizes in term size profiling
grades.
tests/debugger/completion.exp:
Add the new "term_size" mdb command to the list of command completions,
and delete "proc_body".
tests/debugger/declarative/dependency.{inp,exp}:
Use "print proc_body" instead of "proc_body".
tests/hard_coded/nondet_c.m:
tests/hard_coded/pragma_inline.m:
Use MR_offset_incr_hp instead of MR_incr_hp to ensure that all places
that allocate cells also allocate space for the term size slot if
necessary.
tests/valid/Mmakefile:
Disable the IL tests in term size profiling grades, since the term size
profiling primitives haven't been (and probably won't be) implemented
for the MLDS backends, and handle_options causes a compiler abort
for grades that combine term size profiling and any one of IL, Java
and high level C.
|
||
|
|
bac4b47f2a |
Harmonize the treatment of the builtin types by the runtime system across
Estimated hours taken: 36
Branches: main
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.
Replace it with MR_NO_BACKWARDS_COMPAT.
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.
|
||
|
|
56e818af67 |
Implement compare_representation/3, which is like compare except that it
Estimated hours taken: 5.5 Branches: main Implement compare_representation/3, which is like compare except that it is cc_multi, and it doesn't abort on non-canonical types. The implementation only works for the LLDS backend; in other cases, the runtime aborts with a "sorry" message. For this reason, it is not officially part of the standard library yet. library/std_util.m: Add the new predicate, which is implemented via "external". runtime/mercury_ho_call.c: Implement compare_representation/3, and also a C version. runtime/mercury_unify_compare_body.h: Implement the body of compare_representation/3. When the macro include_compare_rep_code is defined comparison of preds and funcs doesn't abort, the code that is used for MR_COMPARE_BY_RTTI is enabled, and usereq types are treated as normal types. runtime/mercury_conf_param.h: Document the fact that calls to compare_representation are counted as calls to compare for the purposes of MR_TYPE_CTOR_STATS. runtime/Mmakefile: Bug fix: add missing pic_o versions of the explicit dependencies. Use variables for the suffixes in these dependencies. runtime/mercury.c: runtime/mercury.h: Supply a HIGHLEVEL_CODE version of the new predicate. This just gives a "Sorry, not implemented" message and aborts. tests/hard_coded/Mmakefile: tests/hard_coded/compare_rep_usereq.exp: tests/hard_coded/compare_rep_usereq.m: tests/hard_coded/compare_representation.exp: tests/hard_coded/compare_representation.m: Test cases. tests/hard_coded/compare_rep_array.m: A test case which doesn't work yet. |
||
|
|
43fbf4b956 |
A step towards RTTI in Mercury.
Estimated hours taken: 40 Branches: main A step towards RTTI in Mercury. This step redefines the representation of pseudo-typeinfos inside the compiler to be identical to the representation we will need for efficient interpretation of RTTI data structures in Mercury. Later steps will do likewise for typectorinfos. In the end, we will have two implementations of RTTI: the current low-level, very efficient one written in C, which will be used by the C backends (both LLDS and MLDS), and a new, higher-level one which will use Mercury data structures and Mercury predicates for interpretation (along the lines of library/rtti_implementation.m) for the Java and IL backends. A large part of this change concerns the fact that pseudo-typeinfos can now contain typeinfos as well as other pseudo-typeinfos, and they do in the frequent case that the type of an argument is ground. Given that typeinfos are just special cases of pseudo-typeinfos, the code for handling the two types is usually similar, with common code factored out when relevant. In the process of redesigning the data structures concerning (pseudo-) typeinfos, I also fixed an old naming scheme that has become misleading. The representation of a (pseudo-) typeinfo depends on whether the principal type constructor is fixed arity or not. We used to denote this distinction with the phrases first-order vs higher-order, since at first the only variable arity type constructors were pred and func. However, this hasn't been true since we added tuples. I have changed the naming scheme to be fixed-arity vs variable-arity. compiler/rtti.m: Add new, purely Mercury data structures for representing typeinfos and pseudo-typeinfos, designed both for efficient interpretation and as a source for the generation of static data structures in C. compiler/pseudo_type_info.m: Delete the type definitions here, since they are superseded by the new definitions in rtti.m. Add predicates for constructing typeinfos as well as pseudo-typeinfos, since now we need those too. Conform to the changed data structures for (pseudo-) typeinfos. compiler/ll_pseudo_type_info.m: compiler/ml_closure_gen.m: compiler/rtti_out.m: compiler/rtti_to_mlds.m: compiler/opt_debug.m: compiler/type_ctor_info.m: Conform to the changed data structures for (pseudo-) typeinfos. compiler/mlds.m: Since the MLDS now refers to type_infos, add their type (mlds__type_info_type) to the list of types the MLDS knows about. compiler/ml_code_util.m: compiler/mlds_to_c.m: compiler/mlds_to_il.m: compiler/mlds_to_java.m: Handle mlds__type_info_type. compiler/mlds_to_gcc.m: Conform to the changed data structures for (pseudo-) typeinfos, and handle mlds__type_info_type. runtime/mercury_bootstrap.h: Override the compiler-generated names of the type_ctor_infos of the variable arity type constructors. The MLDS backend requires these to be module qualified; the LLDS backend requires them to be unqualified. This is a problem because the same code now generates the compiler's internal representation of pseudo-typeinfos for both backends. The temporary solution is to have the compiler generate these names module qualified, and have these macros convert them to the unqualified form. (The long term solution should be to always module qualify everything, but doing that is for another change.) runtime/mercury_type_info.h: Change the naming scheme from first order vs higher order to fixed arity vs variable arity. library/construct.m: library/deconstruct.m: runtime/mercury.c: runtime/mercury_construct.c: runtime/mercury_deconstruct.c: runtime/mercury_deep_copy_body.h: runtime/mercury_make_type_info_body.h: runtime/mercury_ml_expand_body.h: runtime/mercury_tabling.c: runtime/mercury_type_desc.c: runtime/mercury_type_info.c: runtime/mercury_unify_compare_body.h: Conform to the new naming scheme. runtime/mercury.h: Conform to the new naming scheme. Declare fixed and variable arity types for typeinfos as well as pseudo-typeinfos, since pseudo-typeinfos can now refer to typeinfos. |
||
|
|
62c3375f5d |
Fix the RTTI of type_descs and type_ctor_descs.
Estimated hours taken: 40
Branches: main
Fix the RTTI of type_descs and type_ctor_descs. Make comparisons between
type_ctor_descs and type_ctor_infos (and therefore between type_descs and
type_infos) more predictable and consistent across backends by basing them
on programmer-visible attributes instead of accident of location in the
executable.
runtime/mercury_type_desc.[ch]:
Implement unification and comparison functions for type_ctor_descs.
(The unification and comparison functions for type_infos also double
as the unification and comparison functions for type_descs.)
Make the comparison function work on the module name, type name and
arity instead of the address of the type_ctor_info structure. This
ensures consistency across back ends.
Add some useful macros.
runtime/mercury_type_info.[ch]:
Make the comparison function on type_ctor_infos also work on module
name, type name and arity. Since this makes comparison slower, add
specialized unification functions for type_infos and type_ctor_infos.
runtime/mercury_type_info.h:
runtime/mercury_mcpp.{h,cpp}:
runtime/mercury.h:
library/private_builtin.m:
library/rtti_implementation.m:
java/runtime/TypeCtorRep.java:
compiler/mlds_to_gcc.m:
Add type_ctor_reps for type_descs and type_ctor_descs. Type_ctor_descs
definitely need it, since their representation is very low level and
not shared with anything else. Type_descs could use the type_ctor_rep
of type_infos, since type_descs and type_infos share the same
representation at the moment. However, we add a new one because
profiling cares about the conceptual distinction between type_infos
and type_descs.
library/type_desc.m:
Delete the Mercury "definition" of type_desc, because it is misleading.
Implement it as a builtin type.
runtime/mercury.[ch]:
Implement type_ctor_desc as a builtin type.
Add missing implementations of unify/compare on type_ctor_infos.
runtime/mercury_deconstruct.c:
runtime/mercury_ml_expand_body.h:
Implement deconstruction for type_descs and type_ctor_descs.
runtime/mercury_ho_call.c:
runtime/mercury_unify_compare_body.h:
Implement unify and compare for type_descs and type_ctor_descs.
Implement unify for type_infos, type_ctor_infos, type_descs and
type_ctor_descs by calling the relevant unification function,
not the relevant comparison function, since the unification
function will be faster.
runtime/mercury_deep_copy_body.h:
runtime/mercury_construct.c:
runtime/mercury_tabling.c:
Minor changes to handle type_descs and type_ctor_descs.
trace/mercury_trace_vars.c:
Enable the printing of type_descs and type_ctor_descs.
tests/debugger/type_desc_test.{m,inp,exp,exp2}:
New test case to check the printing of type_descs and type_ctor_descs.
tests/debugger/Mmakefile:
Enable the new test case.
tests/hard_coded/type_ctor_desc_manip.{m,exp}:
New test case to check the deconstruction and comparison of type_descs
and (especially) type_ctor_descs. Before this change, we got different
results for comparisons of type_ctor_descs, results that were
inconsistent with the results of comparisons of the type_descs
that the type_ctor_descs were derived from.
tests/hard_coded/Mmakefile:
Enable the new test case.
|
||
|
|
ff9a6657d3 |
Fix a bug: the type_ctor_reps for private_builtin:typeclass_info/1
Estimated hours taken: 0.1 Branches: main runtime/mercury.c: Fix a bug: the type_ctor_reps for private_builtin:typeclass_info/1 and private_builtin:base_typeclass_info/1 were swapped. |
||
|
|
b7c4a317e9 |
Add MR_ prefixes to the remaining non-prefixed symbols.
Estimated hours taken: 4 Branches: main Add MR_ prefixes to the remaining non-prefixed symbols. This change will require all workspaces to be updated The compiler will start generating references to MR_TRUE, MR_bool, etc., which are not defined in the old runtime header files. runtime/mercury_std.h: Add MR_ prefixes to bool, TRUE, FALSE, max, min, streq, strdiff, strtest, strntest, strneq, strndiff, strntest, NO_RETURN. Delete a commented out definition of `reg'. runtime/mercury_tags.h: Add an MR_ prefix to TAGBITS. configure.in: runtime/mercury_goto.h: runtime/machdeps/i386_regs.h/mercury_goto.h: Add an MR_ prefix to PIC. runtime/mercury_conf_param.h: Allow non-prefixed PIC and HIGHTAGS to be defined on the command line. runtime/mercury_bootstrap.h: Add backwards compatibility definitions. RESERVED_MACRO_NAMES: Remove the renamed macros. compiler/export.m: compiler/ml_code_gen.m: Use MR_bool rather than MR_Bool (MR_Bool is meant to be for references to the Mercury type bool__bool). runtime/mercury_types.h: Add a comment the MR_Bool is for references to bool__bool. */*.c: */*.h: */*.m: Add MR_ prefixes. |
||
|
|
c66cea0665 |
Add MR_ prefixes to uses of configuration macros.
Estimated hours taken: 2.5 Branches: main Add MR_ prefixes to uses of configuration macros. Bootcheck now succeeds with MR_NO_CONF_BACKWARDS_COMPAT. Mmake.common.in: Define MR_NO_CONF_BACKWARDS_COMPAT when checking for namespace cleanliness. RESERVED_MACRO_NAMES: Remove the configuration macros. runtime/mercury_conf_bootstrap.h: Remove a duplicate definition of BOXED_FLOAT. configure.in: */*.c: */*.h: */*.m: Add MR_ prefixes. |
||
|
|
7622e889e0 |
Define the `heap_pointer' type in private_builtin.m as a new builtin
Estimated hours taken: 2 Branches: main Define the `heap_pointer' type in private_builtin.m as a new builtin type with representation MR_TYPECTOR_REP_HP, rather than as equivalent to `c_pointer'. This is needed so that the accurate garbage collector can tell saved heap pointer values apart from other c_pointer values, which it needs to do in order to handle saved heap pointer values. library/private_builtin.m: runtime/mercury.h: runtime/mercury.c: Define the type_ctor_info etc. for the heap_pointer type. compiler/type_util.m: Add a new function `heap_pointer_type'. compiler/add_heap_ops.m: Use `heap_pointer_type' from type_util.m. |
||
|
|
3e8cc77012 |
Various bug fixes for accurate GC with the MLDS->C back-end.
Estimated hours taken: 16 Branches: main Various bug fixes for accurate GC with the MLDS->C back-end. runtime/mercury.c: Fix a typo in the definition of the `stack_chain' global. compiler/ml_code_util.m: compiler/ml_call_gen.m: Fix several bugs: - generate appropriate GC tracing code for tracing type_infos and typeclass_infos. These need to be handled specially because of the parameters of private_builtin:type_info/1 etc. don't affect the representation of the type, and need to be ignored (to avoid infinite recursion). - don't generate GC tracing code for no_type_info_builtin procedures, because the generated GC tracing code would refer to type_info arguments that don't get passed. - in ml_call_gen.m, we were generating incorrect GC tracing code for the `conv_*' variables introduced to hold output arguments of polymorphically typed procedures. compiler/type_util.m: library/private_builtin.m: Add types `sample_type_info' and `sample_typeclass_info', so that ml_code_util.m can use them when tracing type_infos and typeclass_infos (respectively). library/private_builtin.m: Fix some software rot in gc_trace/1: add `MR_eng_' prefixes. library/io.m: runtime/mercury_library_types.h: runtime/mercury_file.c: Implement stream ids for NATIVE_GC. |
||
|
|
2b559ad054 |
Move the RTTI-related parts of std_util.m to three new modules in the standard
Estimated hours taken: 8
Branches: main
Move the RTTI-related parts of std_util.m to three new modules in the standard
library, and (in the case of embedded C code) to new modules in the runtime.
The main reason for this is to allow a reorganization of some of the
RTTi-related functionality without breaking backward compatibility. However,
the new arrangement should also be easier to maintain.
Use a separate type_ctor_rep for functions, to distinguish them from predicates
for RTTI code. (At one point, I thought this could avoid the need for the
change to the initialization files mentioned below. It can't, but it is a good
idea in any case.)
library/std_util.m:
Remove the functionality moved to the new modules, and replace them
with type equivalences and forwarding code. There are no changes in
the meanings of the user-visible predicates, with two exceptions.
- First, the true, equivalence-expanded names of what used to be
std_util:type_desc and std_util:type_ctor_desc are now
type_desc:type_desc and type_desc: type_ctor_desc.
- Second, deconstructing a function term now yields
"<<function>>" instead of "<<predicate>>".
The intention is that the RTTI predicates in std_util.m will continue
to work in a backwards-compatible manner for the near future, i.e. as
the new modules are updated, the code in std_util will be updated to
maintain the same functionality, modulo improvements such as avoiding
unwanted exceptions. When the RTTI functionality in the other modules
has stabilised, the RTTI predicates in std_util.m should be marked
obsolete.
The exported but non-documented functionality of std_util has been
moved to one of the new modules without forwarding code, with one
of the moved predicates being turned into the function it should have
been in the first place.
library/construct.m:
library/deconstruct.m:
library/type_desc.m:
Three new modules for the code moved from std_util.m.
library/library.m:
compiler/modules.m:
Record the names of the three new library modules.
runtime/mercury.[ch]:
compiler/mlds_to_il.m:
Record that type_desc is now in type_desc.m, not std_util.m.
compiler/static_term.m:
Import the deconstruct module, since we are using its undocumented
facilities.
runtime/Mmakefile:
Mention the two new modules.
runtime/mercury_construct.[ch]:
runtime/mercury_type_desc.[ch]:
Two new modules holding the C functions that used to be in foreign_code
in std_util, now using MR_ instead of ML_ prefixes, and being more
consistent about indentation.
runtime/mercury_type_info.h:
Add a new type_ctor_rep for functions, separate from predicates.
(It reuses the EQUIV_VAR type_ctor_rep, which hasn't been used
in ages.)
Use type_ctor_reps to distinguish between the type_ctor_infos of
pred/0 and func/0. However, to create higher order typeinfos, we
still need to know the addresses of the type_ctor_infos for
pred/0 and func/0, and we still need to know the address of the
type_ctor_info for tuples to create typeinfos for tuples. Since
these three type_ctor_infos are defined in the library,
we cannot access them directly from the runtime. We therefore need
to access them indirectly in the usual manner, via address_of
variables initialized by mkinit-generated code.
library/builtin.m:
library/private_builtin.m:
library/rtti_implementation.m:
runtime/mercury.c:
runtime/mercury_mcpp.{h,cpp}:
java/TypeCtorRep.java:
Updates to accommondate the new function type_ctor_rep.
runtime/mercury_type_info.[ch]:
Add some functions from foreign_code in std_util that fit in best here.
runtime/mercury_ml_expand_body.h:
runtime/mercury_tabling.h:
runtime/mercury_unify_compare_body.h:
Delete the code for handling EQUIV_VAR, and add code for handling
functions.
runtime/mercury_init.h:
runtime/mercury_wrapper.[ch]:
Add three variables holding the address of the type_ctor_infos
representing functions, predicates and tuples.
util/mkinit.c:
Fill in these three variables.
tests/general/accumulator/construct.{m,exp}:
tests/general/accumulator/deconstruct.{m,exp}:
tests/hard_coded/construct.{m,exp}:
Rename these tests by adding a _test at the ends of their names,
in order to avoid collisions with the names of the new standard library
modules. The test cases have not changed, with the exception of the :-
module declaration of course.
tests/general/accumulator/Mmakefile:
tests/general/accumulator/INTRODUCED:
tests/hard_coded/Mmakefile:
Record the name changes.
tests/hard_coded/existential_float.exp:
Updated the expected output to reflect that deconstructions now print
"<<function>>" instead of "<<predicate>>" when appropriate.
tests/hard_coded/higher_order_type_manip.exp:
Updated the expected output to reflect the new name of what used to be
std_util:type_desc.
trace/mercury_trace_browse.c:
trace/mercury_trace_external.c:
trace/mercury_trace_help.c:
#include type_desc.h instead of std_util.h, since the C functions
we want to call are now defined there.
trace/mercury_trace_vars.c:
Update to account for the movement of type_desc from std_util to
type_desc, and ensure that we don't refer to any type_ctor_infos
in MLDS grades.
|
||
|
|
228ddfdd0b |
Fix a bug by distinguishing the type_ctor_reps of type_infos and
Estimated hours taken: 12 Branches: main Fix a bug by distinguishing the type_ctor_reps of type_infos and type_ctor_infos. The type_ctor_infos of types with nonzero arity cannot be printed, copied etc like type_infos; any attempt to do so causes a core dump. For similar reasons, add a separate type_ctor_rep for base_typeclass_infos separate from typeclass_infos. runtime/mercury_type_info.h: runtime/mercury_mcpp.h: compiler/mlds_to_gcc.m: library/rtti_implementation.m: java/TypeCtorRep.java: Add new type_ctor_reps for type_ctor_infos and base_typeclass_infos. library/private_builtin.m: runtime/mercury.c: Use the new type_ctor_reps in the type_ctor_infos of the builtin types type_ctor_info and base_typeclass_info. runtime/mercury_type_info.[ch]: Add a function for comparing type_ctor_infos. Move some interface documentation from the source file to the header file. runtime/mercury_deep_copy_body.h: Add code to handle the new type_ctor_reps. Simplify some code. Make the whole file use 4-space indentation. library/std_util.m: runtime/mercury_ml_expand_body.h: runtime/mercury_unify_compare_body.h: runtime/mercury_ho_call.c: runtime/mercury_tabling.c: Add code to handle the new type_ctor_reps. |
||
|
|
b5c571c500 |
This is the first half of a change that removes redundant fields from
Estimated hours taken: 12 Branches: main This is the first half of a change that removes redundant fields from type_ctor_info structures. configure.in: Do not require an exact match on the RTTI version number. runtime/mercury_type_info.h: Update the RTTI version number. Add the new definition of type_ctor_infos. Add prefixes to the fields in type_ctor_infos that did not already have them. Provide macros to access the fields in the changed part of type_ctor_infos in a way that works with both the old and new type_ctor_info structures. Move some stuff so that macros that logically belong together are next to each other. runtime/mercury_mcpp.h: Update the RTTI version number and the macros for defining type_ctor_infos. library/rtti_implementation.m: Update the mechanism for access to type_ctor_info fields. Add prefixes to field names and use RTTI-version-independent macros as necessary. compiler/hlds_module.m: compiler/rtti.m: Delete obsolete fields from the terms from which type_ctor_info structures are derived. compiler/dead_proc_elim.m: Minor changes to conform to this change in data structure. compiler/type_ctor_info.m: Minor changes to conform to this change in data structure. Update the RTTI version number. compiler/rtti_out.m: compiler/rtti_to_mlds.m: Output the new type_ctor_info structure. compiler/llds_out.m: compiler/mlds_to_c.m: Emit a #define to select the new type_ctor_info structure. library/std_util.m: runtime/mercury.c: runtime/mercury_deconstruct.c: runtime/mercury_deep_copy_body.h: runtime/mercury_ho_call.c: runtime/mercury_ml_expand_body.h: runtime/mercury_tabling.c: runtime/mercury_type_info.c: runtime/mercury_type_tables.c: runtime/mercury_unify_compare_body.h: tests/hard_coded/type_tables.m: trace/mercury_trace.c: Add prefixes to field names and use RTTI-version-independent macros as necessary. |
||
|
|
dd27a33ac3 |
Fix a bug where the definition of MR_unbox_float()
Estimated hours taken: 0.5 Branches: main runtime/mercury.c: Fix a bug where the definition of MR_unbox_float() was inside `#if defined(MR_AVOID_MACROS) || !defined(__GNUC__)' when it ought to be inside just `#if defined(MR_AVOID_MACROS)'; this caused problems when compiling with C compilers other than GNU C, because the macro definition conflicts with the function definition, leading to a syntax error in the function definition. |
||
|
|
f4b75c1535 |
Estimated hours taken: _____
Branches: <which CVS branches ("main", "release", etc.) this change
|
||
|
|
b5b81c7af7 |
Fix a bug reported by Michael Cameron <Michael.Cameron@general.monash.edu.au>,
Estimated hours taken: 2 Branches: main Fix a bug reported by Michael Cameron <Michael.Cameron@general.monash.edu.au>, where we were not handling inline functions correctly for C99. runtime/mercury_std.h: - Document the MR_INLINE and MR_EXTERN_INLINE macros. - Fix a bug where MR_EXTERN_INLINE was defined wrongly for C99. - Add MR_OUTLINE_DEFN(), for providing out-of-line definitions of inline functions declared with MR_EXTERN_INLINE; previously this was done in a non-portable way that worked with GCC but didn't work with C99. - Add MR_STATIC_INLINE, for inline functions used only within a single translation unit -- currently not used, but should be there for completeness. runtime/mercury.c: Use MR_OUTLINE_DEFN() rather than #ifdef __GNUC__. |
||
|
|
af15e1f5d1 |
Preliminary steps towards support for accurate GC
Branches: main Estimated hours taken: 20 Preliminary steps towards support for accurate GC in the MLDS->C back-end. compiler/ml_elim_nested.m: Add support for a new pass that puts local variables that might contain pointers into a struct, and chains these structs together. compiler/mercury_compile.m: Invoke the new pass (if `--gc accurate'). runtime/mercury.h: runtime/mercury.c: Declare the `stack_chain' global variable that points to the head of the chain. |
||
|
|
0cb4a26ee0 |
Fix an omission in my previous change to add support for `--gc none'
Estimated hours taken: 0.5 Branches: main Fix an omission in my previous change to add support for `--gc none' to the MLDS->C back-end. runtime/mercury.c: Call MR_make_hp_float_aligned() in MR_box_float and MR_asm_box_float(), to ensure that the memory allocated in `--gc none' grades will be properly aligned for a float. |
||
|
|
04e614485d |
Implement deep profiling; merge the changes on the deep2 branch back
Estimated hours taken: 500 Branches: main Implement deep profiling; merge the changes on the deep2 branch back onto the trunk. The main documentation on the general architecture of the deep profiler is the deep profiling paper. doc/user_guide.texi: Document how to use the deep profiler. deep_profiler: deep_profiler/Mmakefile: A new directory holding the deep profiler and its mmakefile. Mmakefile: Add targets for the new directory. Add support for removing inappropriate files from directories. deep_profiler/interface.m: The deep profiler consists of two programs: mdprof_cgi.m, which acts as a CGI "script", and mdprof_server.m, which implements the server process that the CGI script talks to. Interface.m defines the interface between them. script/mdprof.in: A shell script template. ../configure uses it to generate mdprof, which is a wrapper around mdprof_cgi that tells it how to find mdprof_server. deep_profiler/mdprof_cgi.m: The CGI "script" program. deep_profiler/mdprof_server.m: The top level predicates of the server. deep_profiler/profile.m: The main data structures of the server and their operations. deep_profiler/read_profile.m: Code for reading in profiling data files. deep_profiler/startup.m: Code for post-processing the information in profiling data files, propagating costs from procedures to their ancestors and performing various kinds of summaries. deep_profiler/server.m: Code for responding to requests from the CGI script. deep_profiler/cliques.m: Code to find cliques in graphs. deep_profiler/array_util.m: deep_profiler/util.m: Utility predicates. deep_profiler/dense_bitset.m: An implementation of (part of) the set ADT with dense bit vectors. deep_profiler/measurements.m: Operations on profiling measurements. deep_profiler/timeout.m: An implementation of a timeout facility. deep_profiler/conf.m: Functions that depend on autoconfigured settings. configure.in: Find out what command to use to find the name of the local host. Install deep profiling versions of the standard library along with the other profiling versions. runtime/mercury_conf.h.in: Add some macros for deep_profiler/conf.m to use. library/profiling_builtin.m: runtime/mercury_deep_call_port_body.h: runtime/mercury_deep_leave_port_body.h: runtime/mercury_deep_redo_port_body.h: A new library module that implements deep profiling primitives. Some of these primitives have many versions, whose common code is factor is factored out in three new include files in the runtime. compiler/deep_profiling.m: New module to perform the program transformations described in the paper. compiler/notes/compiler_design.html: Document the new compiler module. compiler/mercury_compiler.m: Invoke the new module in deep profiling grades. Allow global static data to be generated by deep_profiling.m. compiler/options.m: Add options to turn on deep profiling and (for benchmarking purposes) control its implementation. Add an optiooption disable tailcall optimization in the LLDS backend, to help benchmarking deep profiling. compiler/jumpopt.m: compiler/optimize.m: Obey the option to disable tailcalls. compiler/handle_options.m: Handle the implications of deep profiling. compiler/modules.m: In deep profiling grades, automatically import profiling_builtin.m. compiler/prog_util.m: doc/Makefile: library/library.m: Handle the new builtin module. compiler/export.m: In deep profiling grades, wrap deep profiling code around exported procedures to handle the "unscheduled call" aspects of callbacks to Mercury from the foreign language. compiler/higher_order.m: profiler/demangle.m: util/demangle.c: When creating a name for a higher-order-specialized predicate, include the mode number in the name. compiler/add_trail_ops.m: compiler/type_util.m: Move c_pointer_type from add_trail_ops to type_util, so it can also be used by deep_profiling.m. compiler/hlds_goal.m: Add a new goal feature that marks a tail call, for use by deep_profiling.m. compiler/hlds_pred.m: Add a new field to proc_info structures for use by deep_profiling.m. Add a mechanism for getting proc_ids for procedure clones. Remove next_proc_id, an obsolete and unused predicate. compiler/hlds_data.m: Add a new cons_id to refer to the proc_static structure of a procedure. compiler/bytecode_gen.m: compiler/code_util.m: compiler/dependency_graph.m: compiler/hlds_out.m: compiler/mercury_to_mercury.m: compiler/ml_unify_gen.m: compiler/opt_debug.m: compiler/prog_rep.m: compiler/rl_exprn.m: compiler/switch_util.m: compiler/unify_gen.m: Trivial changes to handle the new cons_id, goal feature and/or proc_info argument. compiler/rtti.m: Add a utility predicate for extracting pred_id and proc_id from an rtti_proc_label, for use by hlds_out.m compiler/layout.m: compiler/layout_out.m: compiler/llds.m: compiler/llds_common.m: Add support for proc_static and call_site_static structures. compiler/layout_out.m: compiler/llds_out.m: Add code for the output of proc_static structures. compiler/code_util.m: Make code_util__make_proc_label_from_rtti a function, and export it. util/mkinit.c: compiler/llds_out.m: compiler/layout.m: compiler/modules.m: Add support for a fourth per-module C function, for writing out proc_static structures (and the call_site_static structures they contains). Since proc_static structures can be referred to from LLDS code (and not just from other static structures and compiler-generated C code), reorganize the declarations of static structures slightly. Change the schema for the name of the first per-module C function slightly, to make it the addition of the fourth function easier. The scheme now is: mercury__<modulename>__init mercury__<modulename>__init_type_tables mercury__<modulename>__init_debugger mercury__<modulename>__write_out_proc_statics Improve formatting of the generated C code. library/*.m: runtime/mercury.c: runtime/mercury_context.c: runtime/mercury_engine.c: runtime/mercury_ho_call.c: runtime/mercury_tabling.c: runtime/mercury_trace_base.c: runtime/mercury_wrapper.c: trace/mercrury_trace.[ch]: trace/mercrury_trace_declarative.c: trace/mercrury_trace_external.c: trace/mercrury_trace_internal.c: Conform to the new scheme for initialization functions for hand-written modules. compiler/mercury_compile.m: library/benchmarking.m: runtime/mercury_conf_param.h: runtime/mercury.h: runtime/mercury_engine.c: runtime/mercury_goto.c: runtime/mercury_grade.h: runtime/mercury_ho_call.c: runtime/mercury_label.[ch]: runtime/mercury_prof.[ch]: Add an MR_MPROF_ prefix in front of the C macros used to control the old profiler. compiler/handle_options.m: runtime/mercury_grade.h: scripts/canonical_grade.sh-subr: scripts/init_grade_options.sh-subr: scripts/parse_grade_options.sh-subr: Make deep profiling completely separate from the old profiling system, by making the deep profiling grade independent of MR_MPROF_PROFILE_TIME and the compiler option --profile-time. library/array.m: library/builtin.m: library/std_util.m: runtime/mercury_hand_unify_body.h: runtime/mercury_hand_compare_body.h: In deep profiling grades, wrap the deep profiling call, exit, fail and redo codes around the bodies of hand-written unification and comparison procedures. Make the reporting of array bounds violations switchable between making them fatal errors, as we currently, and reporting them by throwing an exception. Throwing an exception makes debugging code using arrays easier, but since exceptions aren't (yet) propagated across engine boundaries, we keep the old behaviour as the default; the new behaviour is for implementors. runtime/mercury_deep_profiling_hand.h: New file that defines macros for use in Mercury predicates whose definition is in hand-written C code. library/exception.m: runtime/mercury_exception_catch_body.h: runtime/mercury_stacks.h: In deep profiling grades, wrap the deep profiling call, exit, fail and redo codes around the bodies of the various modes of builtin_catch. Provide a function that C code can use to throw exceptions. library/benchmarking.m: library/exception.m: library/gc.m: library/std_util.m: runtime/mercury_context.[ch]: runtime/mercury_engine.[ch]: runtime/mercury_debug.c: runtime/mercury_deep_copy.c: runtime/mercury_overflow.h: runtime/mercury_regs.h: runtime/mercury_stacks.h: runtime/mercury_thread.c: runtime/mercury_wrapper.c: Add prefixes to the names of the fields in the engine and context structures, to make code using them easier to understand and modify. runtime/mercury_deep_profiling.[ch]: New module containing support functions for deep profiling and functions for writing out a deep profiling data file at the end of execution. runtime/mercury_debug.[ch]: Add support for debugging deep profiling. Add support for watching the value at a given address. Make the buffered/unbuffered nature of debugging output controllable via the -du option. Print register contents only if -dr is specified. runtime/mercury_goto.h: runtime/mercury_std.h: Use the macros in mercury_std.h instead of defining local variants. runtime/mercury_goto.h: runtime/mercury_stack_layout.h: runtime/mercury_stack_trace.c: runtime/mercury_tabling.c: trace/mercury_trace.c: trace/mercury_trace_declarative.c: trace/mercury_trace_external.c: trace/mercury_trace_vars.c: Standardize some of the macro names with those used in the debugger paper. runtime/mercury_heap.h: Add support for memory profiling with the deep profiler. runtime/mercury_prof.[ch]: runtime/mercury_prof_time.[ch]: Move the functionality that both the old profiler and the deep profiler need into the new module mercury_prof_time. Leave mercury_prof containing stuff that is only relevant to the old profiler. runtime/mercury_prof.[ch]: runtime/mercury_strerror.[ch]: Move the definition of strerror from mercury_prof to its own file. runtime/mercury_wrapper.[ch]: Add support for deep profiling. Add suppory for controlling whether debugging output is buffered or not. Add support for watching the value at a given address. runtime/Mmakefile: Mention all the added files. scripts/mgnuc.in: Add an option for turning on deep profiling. Add options for controlling the details of deep profiling. These are not documented because they are intended only for benchmarking the deep profiler itself, for the paper; they are not for general use. tools/bootcheck: Compile the deep_profiler directory as well as the other directories containing Mercury code. Turn off the creation of deep profiling data files during bootcheck, since all but one of these in each directory will be overwritten anyway. Add support for turning on --keep-objs by default in a workspace. tools/speedtest: Preserve any deep profiling data files created by the tests. trace/mercury_trace.c: Trap attempts to perform retries in deep profiling grades, since they would lead to core dumps otherwise. util/Mmakefile: Avoid compile-time warnings when compiling getopt. tests/*/Mmakefile: tests/*/*/Mmakefile: In deep profiling grades, switch off the tests that test features that don't work with deep profiling, either by design or because the combination hasn't been implemented yet. |
||
|
|
717e4904a8 |
Fix a bug that broke profiling in MLDS grades.
Estimated hours taken: 2.5 Fix a bug that broke profiling in MLDS grades. (Note that profiling is still broken in MLDS grades, due to some other bug(s) that still remain.) library/array.m: library/builtin.m: runtime/mercury.c: Delete some unnecessary and harmful calls to MR_init_entry() for procedures for which we were already automatically generating calls to MR_init_entry(). The duplicate calls broke profiling, since the profiler aborts if it detects duplicate entries in the Prof.Decl file. library/array.m: library/builtin.m: library/private_builtin.m: library/std_util.m: library/exception.m: runtime/mercury.c: Document empty initialization functions better. |
||
|
|
6199787a07 |
Fix a bug with the GCC back-end interface where it was generating
Estimated hours taken: 1.5 Fix a bug with the GCC back-end interface where it was generating calls to `MR_box_float', but `MR_box_float' was not defined in the runtime library. mercury/runtime/mercury.h: mercury/runtime/mercury.c: Add a new function `MR_asm_box_float'. This is the same as `MR_box_float' except that it is always defined as an external function, never as a macro or inline function. Also fix a bug where the return type of `MR_box_float' was declared as `MR_Float *' rather than `MR_Box'. gcc/mercury/mercury-gcc.c: mercury/compiler/gcc.m: Generate calls to `MR_asm_box_float' rather than to `MR_box_float'. |
||
|
|
28dfba60cb |
Avoid a dependency where the runtime depends on the library.
Estimated hours taken: 5
Avoid a dependency where the runtime depends on the library.
library/array.m:
runtime/mercury.c:
runtime/mercury.h:
runtime/mercury_type_info.h:
Move code for doing array comparisons and unifications into the std
library.
|
||
|
|
94a3247593 |
Fix a bug where the compiler failed to bootcheck in the hlc grades as
Estimated hours taken: 0.5
Fix a bug where the compiler failed to bootcheck in the hlc grades as
univ is no longer a builtin type.
runtime/mercury.c:
Remove all references to the univ type.
|
||
|
|
499ffadbc3 |
Connect the Mercury compiler to the GCC back-end.
Estimated hours taken: 120
Connect the Mercury compiler to the GCC back-end.
These changes give us a version of the Mercury compiler which
compiles to assembler without going via any intermediate files.
This version generates GCC's `tree' data type, and then calls functions
in the GCC middle-end to convert that to GCC's RTL (Register Transfer
Language) and to invoke the rest of the GCC middle-end and back-end
to compile it to assembler.
RATIONALE
The main advantage is improved compilation speed.
(The improvement is not huge, since the current front-end is so slow,
but improving the speed of the back-end increases the incentive to
improve the speed of the front-end, since it means that any increases
in the speed of the front-end will get bigger overall speedups.)
Another advantage is that it gives us more opportunity to give the GCC
back-end information about how to optimize the code that we generate.
For example:
- We can tell GCC when it is safe to treat function calls
as tail calls. (The gcc back-end already has some support
for doing tail calls. But its check to determine when
it is safe to do them is much too conservative for Mercury.
I've been working on extending the gcc back-end infrastructure
so that front ends can tell the gcc back-end when it is safe.)
- We can use `__builtin_{set,long}jmp' rather than ordinary
`{set,long}jmp'. (We can also do this for the C back-end,
as it happens, since those are supported in GNU C too, but
I wouldn't have found out about it if not for doing this
back-end.) Or we can use gcc's exception handling;
the gcc developers have told me that using exception
handling may be more efficient on some platforms.
- We can mark GC_malloc as an allocation function,
so that GCC knows that stuff allocated with it won't
alias other pointers.
- In general we could give GCC more information about aliasing.
I haven't investigated this much yet, but I think the GCC
back-end has support for keeping track of alias sets and
recording which set each pointer points to and which sets
may be subsets of which other sets.
Another advantage is that it provides a demonstration of how to
compile logic languages or functional languages using the GNU C
back-end. This may be useful to researchers or open-source developers
who are working on other languages.
It is also good public relations, because it removes one more
barrier towards acceptance of Mercury. Some people want a language
implementation that has a "native code compiler", and don't want one
that compiles via C. These people may be more willing to consider
Mercury now.
gcc/mercury:
New directory.
This contains the C side of the Mercury <-> GCC interface.
gcc/mercury/Make-lang.in:
gcc/mercury/config-lang.in:
gcc/mercury/lang-specs.h:
Makefile/configure/specs fragments (respectively)
that are required by GCC.
gcc/mercury/lang-options.h:
Documents the Mercury-specific gcc options,
in particular the `--mmc-flag=' option.
gcc/mercury/mercury-gcc.c:
gcc/mercury/mercury-gcc.h:
This is the "meat" on the C side of the Mercury <-> GCC interface.
These files provide the C code that GCC requires of each
language front-end. They also define some routines for
building parts of the GCC `tree' data structure that are
used by the Mercury compiler.
gcc/mercury/Makefile:
A Makefile which just runs `make mercury' in the parent directory.
Just for convenience.
gcc/mercury/README:
gcc/mercury/ChangeLog:
Some (very basic) documentation.
gcc/mercury/test.m:
A sample Mercury module, to serve as a simple test case.
gcc/mercury/testmercury.c:
C driver program for the test Mercury module.
mercury/compiler/gcc.m:
New file. This is an interface to the tree data structure defined
in gcc/tree.h, and to functions for manipulating that data structure
which are defined in gcc/mercury/mercury-gcc.c and in other parts
of the GCC back-end. It's almost entirely composed of simple
pragma c_code routines that each just call a single C function.
mercury/compiler/mlds_to_gcc.m:
New file. This converts the MLDS into the gcc tree representation
whose interface is in gcc.m, using the routines defined in gcc.m.
This is the "meat" on the Mercury side of the Mercury <=> GCC interface.
mercury/compiler/globals.m:
Define new target `asm', for compiling directly to assembler
(without any intermediate files), via the gcc back-end.
mercury/compiler/handle_options.m:
`--target asm' implies `--high-level-code'.
mercury/compiler/mercury_compile.m:
Handle `--target asm' by invoking mlds_to_gcc.m.
mercury/main.c:
New file, containing main() that calls mercury_main().
mercury/compiler/Mmakefile:
Add C2INITFLAGS=--library, so that we can link `libmercury_compile.a'
as a library without main(). For the mercury_compile executable,
get main by linking in ../main.o.
Add `libmmc' target, for building libmercury_compile.a and
mercury_compile_init.a.
Add the appropriate `-D' and `-I' options to CFLAGS-gcc so that we
can compile gcc.m.
mercury/runtime/mercury.c:
Define out-of-line copies of MR_box_float() and MR_unbox_float(),
so that the new `--target asm' back-end can generate calls to them.
mercury/runtime/mercury.h:
mercury/runtime/mercury_heap.h:
Add comments warning about code duplication between
the inline and out-of-line versions of various functions.
mercury/Makefile:
mercury/Mmakefile:
Add `libmmc' target, for use by gcc/mercury/Make-lang.in.
mercury/runtime/mercury_std.h:
When IN_GCC is defined, use safe_ctype.h rather than
ctype.h, since the latter conflicts with the GCC headers.
Comment out the definition of the `reg' macro, since
that too conflicts with the GCC headers.
mercury/runtime/mercury_dlist.c:
mercury/runtime/mercury_hash_table.c:
mercury/runtime/mercury_stacks.h:
Delete unnecessary uses of the `reg' macro.
|
||
|
|
de80683489 |
This change makes univ a user-defined type (in std_util.m) rather than
Estimated hours taken: 10 This change makes univ a user-defined type (in std_util.m) rather than a builtin type. The rationale for this is that the code for builtin types needs to be maintained by hand when the execution model is changed (eg introducing a new backend), but code for user defined types is modified implicitly. Note that the semantics of deconstruct/4 have changed. See the NEWS file for details. NEWS: Document the changed semantics of deconstruct/4. browser/browse.m: Fix the calls to deconstruct/4 to reflect the changed semantics of deconstruct. library/io.m: Remove the special handling of univ for io__write. Fix the calls to deconstruct/4 to reflect the changed semantics of deconstruct. library/private_builtin.m: Implement typed_unify and typed_compare in terms of type_of and unsafe_type_cast instead of univ, so that preds/funcs operating on univs can be implemented in terms of typed_unify. Add a new impure predicate var/1 which succeeds/fails depending on the instantiation of its argument. This is used to implement bidirectional predicates that require different code for different modes (cf type_to_univ/2). This is *not* mentioned in the NEWS file because it should only be used by implementors. (Well, actually, anyone who wants to do bidirectional code involving existential types may need it, but we don't exactly want to encourage its use ;-). library/std_util.m: Implement univ/0 as a user-defined type rather than a hand coded builtin type. Removed the foreign language code to implement the operations on univs (include unify/2 and compare/3). The implementations of deconstruct, et al, now call back to Mercury to construct/deconstruct univs, so the code of these has changed. Note that there has been an implicit change in the semantics of deconstruct/4, which had non-orthogonal handling of univ inputs. It now handles them orthogonally: deconstruct of a univ yields the functor "univ_cons" and its one argument which will be the wrapped value. The non-orthogonal behaviour wasn't documented before, so deconstruct/4 now behaves as its documentation describes it. library/term.m: Fix the call to deconstruct/4 to reflect the changed semantics of deconstruct. runtime/mercury.c: runtime/mercury_deep_copy_body.h: runtime/mercury_mcpp.h: runtime/mercury_tabling.c: runtime/mercury_type_info.h: runtime/mercury_unify_compare_body.h: Remove declarations and definitions for univ since it is now a user level type rather than a builtin type. trace/mercury_trace_declarative.h: trace/mercury_trace_external.h: trace/mercury_trace_internal.h: Replace the hand-coded constructions of univs with call backs to ML_construct_univ. |
||
|
|
e05f2a4780 |
Add support for using a different C calling convention for the
Estimated hours taken: 16 Add support for using a different C calling convention for the C functions generated by the MLDS back-end, if you're on x86 and you define MR_USE_REGPARM. The code do to this uses GNU C's function attributes extension; it will only work if you have the latest snapshot versions of gcc. So MR_USE_REGPARM is not enabled by default. compiler/ml_call_gen.m: For higher-order calls and class method calls, assign the function pointer to a local variable. This is needed for current versions of gcc, since gcc doesn't support function attributes on function types in function pointer type casts. compiler/mlds_to_c.m: Output "MR_CALL" in function declarations. Also output a reference to MR_GRADE_VAR, like we do for the LLDS back-end. runtime/mercury_std.h: Define MR_CALL. This is a macro that can expand to some implementation-specific C extension to specify the calling convention used for the MLDS back-end. E.g. for gcc, on x86, if MR_USE_REGPARM is defined it expands to `__attribute__((__regparm__(3), __stdcall__))'. runtime/mercury_conf_param.h: Document MR_USE_REGPARM. runtime/mercury_grade.h: Encode the setting of MR_USE_REGPARM in the mangled grade name. runtime/mercury_types.h: runtime/mercury.h: runtime/mercury.c: runtime/mercury_wrapper.h: runtime/mercury_wrapper.c: util/mkinit.c: library/array.m: library/builtin.m: library/exception.m: Use MR_CALL for functions that should have the Mercury calling convention. runtime/mercury_types.h: runtime/mercury.h: Move the definition of MR_Cont and MR_NestedCont from mercury_types.h to mercury.h. This was needed to avoid a cyclic header dependency problem and is also a good idea anyway, since MR_Cont and MR_NestedCont are specific to the MLDS back-end. |
||
|
|
c74a7e5be4 |
Various changes to get things to work with the DEC Alpha OSF1 C
Estimated hours taken: 8
Various changes to get things to work with the DEC Alpha OSF1 C
compiler in grade hlc.gc.
compiler/equiv_type.m:
Change the code for equiv_type__replace_item_in_item_list
so that it is tail recursive, by using an accumulator and
calling list__reverse at the end. This is needed to avoid
a stack overflow (with the default 2M stack limit) when
bootstrapping with the DEC Alpha OSF1 C compiler in grade hlc.gc.
The dec-alpha-osf3.2 `cc' was generating code that used
280 bytes of space per stack frame for this procedure.
compiler/fact_table.m:
Ensure that there is a statement after every label, since
ANSI/ISO C doesn't allow labels at the end of a block without
an empty statement following them.
library/exception.m:
Use a different name for the local typedef in different functions.
This allows the code to work with the DEC Alpha OSF1 C in
`-std' ("ANSI C with popular extensions") mode, rather than
the `-std1' (strict ANSI/ISO C). The supposedly popular
extension here is treating local typedefs as if they were
global. It's probably not worth expending much effort to
cater for non-ANSI modes of compilers, but in this case the
effort is small and arguably the different names are more
descriptive anyway.
runtime/mercury.c:
Avoid the use of a GNU C extension (returning void values).
runtime/mercury_deep_copy.c:
Change `#undef FOO(ARGS)' to `#undef FOO', since the former
is not allowed in ANSI/ISO C.
trace/mercury_trace_internal.c:
Change `#endif FOO' to `#endif /* FOO */', since the former
is not allowed in ANSI/ISO C.
tests/hard_coded/pragma_c_code.m:
tests/hard_coded/type_tables.m:
Use `\\n' rather than `\n' for newlines in strings inside
`pragma c_code'. This is needed because the first level of
slashes gets processed when converting from Mercury to C, and
ANSI/ISO C doesn't allow literal newlines in strings.
|
||
|
|
090552c993 |
Make everything in the runtime use MR_ prefixes, and make the compiler
Estimated hours taken: 10 Make everything in the runtime use MR_ prefixes, and make the compiler bootstrap with -DMR_NO_BACKWARDS_COMPAT. runtime/mercury_*.[ch] Add MR_ prefixes to all functions, global variables and almost all macros that could pollute the namespace. The (intentional) exceptions are 1. some function, variable, type and label names that already start with MR_, mercury_, Mercury or _entry; 2. some standard C macros in mercury_std.h; 3. the macros used in autoconfiguration (since they are used in scripts as well as the runtime, the MR_ prefix may not be appropriate for those). In some cases, I deleted things instead of adding prefixes if the "things" were obsolete and not user visible. runtime/mercury_bootstrap.h: Provide MR_-less forms of the macros for bootstrapping and for backward compatibility for user code. runtime/mercury_debug.[ch]: Add a FILE * parameter to a function that needs it. compiler/code_info.m: compiler/export.m: compiler/fact_table.m: compiler/llds.m: compiler/llds_out.m: compiler/pragma_c_gen.m: compiler/trace.m: Add MR_ prefixes to the C code generated by the compiler. library/*.m: Add MR_ prefixes to handwritten code. trace/mercury_trace_*.c: util/mkinit.c: Add MR_ prefixes as necessary. extras/concurrency/semaphore.m: Add MR_ prefixes as necessary. |
||
|
|
b7a1d89e39 |
Implement some NYI in mercury.c
Estimated hours taken: 1
library/array.m:
runtime/mercury.c:
Implement some NYI in mercury.c
|
||
|
|
a5863fc791 |
Implement the compare and unify operations for arrays in the hlc grade.
Estimated hours taken: 1
runtime/mercury.c:
Implement the compare and unify operations for arrays in the hlc grade.
|
||
|
|
6828f396a8 |
Rename MR_Type_Info as MR_Mercury_Type_Info,
Estimated hours taken: 1
runtime/mercury.h:
Rename MR_Type_Info as MR_Mercury_Type_Info,
to avoid confusing it with MR_TypeInfo.
Likewise for MR_Type_Ctor_Info, etc.
Add some comments explaining this.
runtime/mercury.c:
library/builtin.m:
library/exception.m:
Trivial modifications to reflect the above renaming.
|
||
|
|
5f32e738e1 |
Implement compare and unify for the univ type in the hlc grades.
Estimated hours taken: 1
mercury.c:
Implement compare and unify for the univ type in the hlc grades.
|
||
|
|
46a8da81cb |
Implement builtin tuple types, similar to those in Haskell.
Estimated hours taken: 30
Implement builtin tuple types, similar to those in Haskell.
Tuples are constructed and deconstructed using
the syntax X = {Arg1, Arg2, ...}.
Tuples have type `{Arg1, Arg2, ...}'.
Unary tuples (X = {Arg}) do work, unlike in Haskell. The rationale
for this is that it is useful to be able to construct unary tuples
to be passed to a polymorphic predicate which uses std_util__deconstruct
to deal with a tuple of any arity. Since this is probably the only
use for unary tuples, it's not really worth the effort of treating
them as no_tag types, so we don't.
The type-infos for tuples have the same structure as for higher-order
types. There is a single type_ctor_info for tuples, and the arity
is placed before the argument type_infos.
library/parser.m:
Change the way '{}/N' terms are parsed, so that the parsed
representation is consistent with the way other functors
are represented (previously the arguments were left as
unparsed ','/2 terms). This avoids special case code
in prog_io__parse_qualified_term, term__term_to_type
and term__type_to_term.
compiler/prog_io_dcg.m:
compiler/prog_io_util.m:
Handle the new structure of '{}/N' terms when parsing DCG escapes
by converting the argument list back into a single ','/2 term.
compiler/module_qual.m:
Treat tuples as a builtin type.
compiler/typecheck.m:
Typecheck tuple constructors.
compiler/mode_util.m:
Propagate types into tuple bound insts.
compiler/type_util.m:
Add type_is_tuple/2 and type_id_is_tuple/1 to identify tuple types.
Add tuples to the list of types which are not atomic types.
Handle tuple types in `type_constructors' and
`get_cons_id_arg_types' and `switch_type_num_functors'.
compiler/tabling.m:
Handle tabling of tuples.
compiler/term_util.m:
Handle tuples in the code to compute functor norms.
compiler/magic_util.m:
compiler/rl.m:
compiler/rl_key.m:
Handle tuple types in the Aditi back end.
compiler/mercury_to_mercury.m:
library/io.m:
library/term_io.m:
Handle output of '{}/N' terms.
compiler/higher_order.m:
compiler/simplify.m:
Don't specialize complicated unifications of tuple
types into calls to a specific unification procedure --
even if the procedure were implemented, it probably
wouldn't be that much more efficient.
compiler/unify_proc.m:
Generate unification procedures for complicated unifications
of tuples (other than in-in unifications). These are generated
lazily as required.
compiler/make_hlds.m:
Export add_special_pred for use by unify_proc.m.
compiler/polymorphism.m:
Export polymorphism__process_pred for use by unify_proc.m.
compiler/bytecode_gen.m:
compiler/code_util.m:
compiler/ml_code_util.m:
Handle unify procedure names and tags for tuple types.
compiler/mlds_to_c.m:
Output tuple types as MR_Tuple.
compiler/ml_unify_gen.m:
Compute the field types for tuples.
compiler/polymorphism.m:
compiler/pseudo_type_info.m:
Treat tuple type_infos in a similar way to higher-order type_infos.
compiler/hlds_data.m:
Document how cons_ids for tuple types are represented.
compiler/switch_gen.m:
compiler/table_gen.m:
Add tuple types to switches on type_util__builtin_type.
compiler/llds_out.m:
util/mdemangle.c:
profiler/demangle.m:
Transform items named "{}" to "f_tuple" when mangling symbols.
library/builtin.m:
Define the type_ctor_info used for tuples.
library/private_builtin.m:
Add `builtin_unify_tuple/2' and `builtin_compare_tuple/3',
both of which abort. All comparisons and in-in unifications
of tuples are performed by the generic unification functions
in runtime/mercury_ho_call.c and runtime/mercury.c.
library/std_util.m:
Implement the various RTTI functions for tuples.
Encode tuple `TypeCtorDesc's in a similar way to that
used for higher-order types. This has the consequence that the limit
on the arity of higher-order types is now MAX_VIRTUAL_REG,
rather than 2*MAX_VIRTUAL_REG.
Avoid calling MR_GC_free for the type-info vector returned
from ML_expand() for tuples because unlike the vectors
for du types, it is not copied.
runtime/mercury_type_info.h:
Add macros for extracting fields from tuple type-infos.
These just call the macros for extracting fields from higher-order
type-infos.
Add a macro MR_type_ctor_rep_is_variable_arity(), which
returns TRUE for tuples and higher-order types.
The distinction between higher-order and first-order types
is now misnamed -- the distinction is really between fixed arity
types and builtin variable arity types. I'm not sure whether
it's worth renaming everything.
runtime/mercury.h:
runtime/mercury.c:
Define unification and comparison of tuples in
high-level code grades.
runtime/mercury_deep_copy_body.h:
runtime/mercury_make_type_info_body.h:
runtime/mercury_tabling.c:
runtime/mercury_unify_compare_body.h:
Handle tuple types in code which traverses data using RTTI.
tests/hard_coded/construct.{m,exp}:
tests/hard_coded/expand.{m,exp}:
Test RTTI functions from std_util.m applied to tuples.
tests/hard_coded/tuple_test.{m,exp}:
Test unification, comparison, term_to_type etc. applied to tuples.
tests/hard_coded/deep_copy.{m,exp}:
Test deep copy of tuples.
tests/hard_coded/typeclasses/tuple_instance.{m,exp}:
Test instance declarations for tuples.
tests/tabling/expand_tuple.{m,exp}:
Test tabling of tuples.
tests/hard_coded/write.m:
Add some module qualifications for code which uses
`{}/1' constructors which are not tuples.
tests/invalid/errors2.{m,err_exp,err_exp2}:
Test handling of tuples in type errors messages.
NEWS:
doc/reference_manual.texi:
w3/news/newsdb.inc:
Document tuples.
doc/transition_guide.texi:
Document the change to the parsing of '{}/N' terms.
|
||
|
|
db64a3588d |
Add MR_ prefixes to the types used when generating C code.
Estimated hours taken: 4 Add MR_ prefixes to the types used when generating C code. This means types such as Word, String, Bool, Float become MR_Word, MR_String, MR_Bool, MR_Float. Also define MR_Box for both the LLDS and MLDS backends so we can use it uniformly. This is very important in environments where String or Bool have already been used as system types (for example, managed C++). And besides, we should do it anyway as part of the grand namespace cleanup. I have fixed all of the uses of the non-prefixed types in the runtime and trace directories. I haven't done it for the library and compiler directories yet (no promises that I will do it in future either). But if you see a non-prefixed type in code from now on, please consider it a bug and fix it. mercury_bootstrap.h contains #defines to map the non-prefixed types into the prefixed ones. Like many of the other namespace cleaning backwards compatibility macros, this can be turned off with MR_NO_BACKWARDS_COMPAT. This shouldn't break any code, but this kind of change affects so many things that of course there could be problems lurking in there somewhere. If you start getting errors from the C compiler after this change is installed, you will want to make sure you at least have the runtime system updated so that you are getting the backwards compatibility definitions in mercury_bootstrap.h. Then if you continue to have problems you can bug me about it. compiler/export.m: compiler/llds_out.m: compiler/mlds_to_c.m: Use MR_Word, MR_Float, MR_Bool, etc when generating C. doc/reference_manual.texi: Update the reference manual to talk about MR_Word, MR_String, MR_Char, etc. runtime/mercury_bootstrap.h: Add bootstrapping typedefs. runtime/*: trace/*: Change Word, Float, Bool, Code, String, etc to MR_Word, MR_Float, MR_Bool, MR_Code, MR_String. |
||
|
|
113dca2cad |
Bootstrap in the grade hlc.gc.memprof.
Estimated hours taken: 24
Bootstrap in the grade hlc.gc.memprof.
To analyse the generated Prof.* files you need to supply the option
--no-demangle to the profiler.
compiler/ml_code_gen.m:
Define MR_PROC_LABEL in pragma c_code.
compiler/mlds.m:
Add a new alternative to the type target_code_component which
records a mlds_entity_name. This information is needed when
outputing the MR_PROC_LABEL #define.
compiler/ml_elim_nested.m:
Changes due to the change to the type target_code_component.
compiler/mlds_to_c.m:
Define a new predicate mlds_maybe_output_init_fn which outputs an
initialisation function, if necessary. This body of the
initialisation function consists of calls to init_entry for each
function in the src module.
If profiling is turned on at each function call: call
MR_prof_call_profile(callee, caller) to record the arc in the call
graph.
If profiling is turned on each heap allocation call
MR_maybe_record_allocation().
Changes due to the change to the type target_code_component.
library/array.m:
library/builtin.m:
library/exception.m:
library/private_builtin.m:
library/std_util.m:
As c2init doesn't understand preprocessor directives we need to
define some empty initialisation functions.
trace/mercury_trace_vars.c:
Avoid a linking problem with MR_trace_ignored_type_ctors.
Add a dummy member to MR_trace_ignored_type_ctors so that the array
is never empty.
runtime/mercury.c:
Call MR_init_entry for each hand defined procedure.
runtime/mercury.h:
If profiling is turned on include the relevant header files.
runtime/mercury_goto.h:
Define MR_init_entry.
runtime/mercury_prof.c:
runtime/mercury_prof.h:
Make decl_fptr an extern global pointer so that mercury_wrapper.c
can call fclose on it.
runtime/mercury_wrapper.c:
Call fclose on decl_fptr.
|
||
|
|
d38a833145 |
Implement `pragma export' for the MLDS backend.
Estimated hours taken: 30
Implement `pragma export' for the MLDS backend.
compiler/mlds.m:
Add a new type mlds__pragma_export. It records the exported name,
the MLDS name of the exported procedure, the function parameters
of the MLDS entity and the context of the export declaration.
Add a new mlds_entity_name type export, for names which come from
pragma export.
compiler/ml_code_gen.m:
For every pragma export declaration, we associate the information
used to generate the function prototype for the MLDS entity. We
also record whether or not the procedure is a det function in the
forward mode.
compiler/mlds_to_c.m:
Output a declaration for the exported procedure to the header file.
Output a definition for the exported procedure to the source file.
Providing that the procedure is not a det func in the forward mode
the declaration is constructed by outputing the function prototype
for the MLDS function, but using the exported name instead and
the definition is constructed by defining a function which directly
calls the MLDS function.
If the procedure is a det func in the forward mode then the output
argument is returned by the function instead of being passed in call
by reference. The signature of the exported function is changed to
this new convention. This change is required so the an exported
procedure can by re-imported.
Define in each header file MR_BOOTSTRAPPED_PRAGMA_EXPORT, this code
should be removed once the compiler has bootstrapped.
Move output_c_defns so that it comes after all the declarations.
Modify mlds_output_params so that it takes a module name, not an
entity name as all it needs is the module name.
When outputing an mlds_entity_name of type export, don't module
qualify the name and just output the string.
compiler/hlds_module.m:
Add a prog_context field to the type pragma_exported_proc.
compiler/make_hlds.m:
Record the context of the pragma export.
compiler/dead_proc_elim.m:
compiler/export.m:
Ignore extra field added to pragma_exported_proc.
compiler/ml_elim_nested.m:
In ml_env_name report error for export mlds__entity_name's.
library/io.m:
runtime/mercury.c:
runtime/mercury.h:
runtime/mercury_init.h:
Check to see if MR_BOOTSTRAPPED_PRAGMA_EXPORT is defined when
deciding whether hacks to get around the lack of pragma export need
to turned on. This code should be removed once the compiler has
bootstrapped.
This also required some definitions to be moved from mercury.c to
io.m so that MR_BOOTSTRAPPED_PRAGMA_EXPORT is defined when the
definition is reached.
|
||
|
|
4a78eff73d |
Mork work on implementing the `--high-level-data' option.
Estimated hours taken: 6 Mork work on implementing the `--high-level-data' option. This change adds support for it to the runtime and standard library code. runtime/mercury.h: Wrap `#ifndef MR_HIGHLEVEL_DATA' around out the #defines that work around the lack of support for `pragma export', since that work-around doesn't work with --high-level-data. runtime/mercury.h: Define typedefs for C names corresponding to the various Mercury builtin / standard library types: from builtin.m: comparison_result, void, c_pointer, pred, func; from array.m: array; from std_util.m: univ, type_desc; from private_builtin.m: type_info, type_ctor_info, typeclass_info, base_typeclass_info. For `--no-high-level-code', these typedefs are defined as `MR_Word'. But for `--high-level-code', they are mostly defined as pointers to struct types. runtime/mercury.h: runtime/mercury.c: library/builtin.m: library/exception.m: Use the typedefs mentioned above, rather than hard-coding `MR_Word'. runtime/mercury.c: #include "mercury_heap.h", to fix a gcc warning about the definitions of create[1-3](). compiler/ml_unify_gen.m: Add some extra casts that are needed when you use --high-level-data but not `--tags none'. In particular, for `shared_local_tag' constants of user-defined types, where we generate a `mkword' rval, we need to cast the result of `mkword' to the right type. compiler/mlds_to_c.m: - Declare each function parameter on a separate line. For --high-level-data, this makes the generated code much more readable. Even for --no-high-level-data, it is probably an improvement. - Avoid some redundant forward struct declarations. |
||
|
|
555ca1cb95 |
Fix a portability problem: avoid using the gcc extension
Estimated hours taken: 0.25 runtime/mercury.c: Fix a portability problem: avoid using the gcc extension which allows `return' in a void-valued function. |
||
|
|
7fa70967e4 |
Fix several bugs in the MLDS back-end:
Estimated hours taken: 12
Fix several bugs in the MLDS back-end:
- a bug in tail recursion optimization
- a bug that lead to duplicate field names in environment structs
- a few miscellaneous fixes for runtime/mercury.{h,c}.
compiler/mlds_to_c.m:
Fix a bug with tail recursion optimization:
for the tail recursive call `p(H1, H2) :- ... p(H2, H1) ...',
it was generating code of the form
void p(MR_Word H1, MR_Word H2) {
for(;;) {
...
{
H1 = H2;
H2 = H1;
continue;
}
...
}
}
which clobbered the value of H1. The fix was to change
it to generate code which assigns the new arguments to
temporary local variables before assigning them to the
headvars:
void p(MR_Word H1, MR_Word H2) {
for(;;) {
...
{
MR_Word H1__tmp_copy = H2;
MR_Word H2__tmp_copy = H1;
H1 = H1__tmp_copy;
H2 = H2__tmp_copy;
continue;
...
}
}
compiler/ml_code_util.m:
Add a new function ml_gen_mlds_var_decl/4, for use by
mlds_to_c.m for the tempoaries it now generates when handling
tail recursion.
compiler/ml_call_gen.m:
Ensure that the temporary conversion variables generated by
ml_gen_box_or_unbox_lval all have distinct names, by including
a sequence number in the name. This is needed because
ml_elim_nested.m assumes that all variables defined in a
function have different names; if two variables are defined in
different scopes with the same name, then when ml_elim_nested
hoists them out, this leads to a duplicate field name in the
environment struct.
compiler/ml_code_util.m:
Add a new counter field to the ml_gen_info and a new predicate
ml_gen_info_new_conv_var for accessing it, for use by
ml_gen_box_or_unbox_lval in ml_call_gen.m.
runtime/mercury.c:
Add definitions for some functions declared `extern inline'
in runtime/mercury_heap.h.
runtime/mercury.h:
- Delete some unnecessary `#ifdef ... #define ... #endif' guards;
everything in this file is already protected by the
`#ifndef MERCURY_H' guard at the top of the file.
- Increase the fixed limit here on the arity of types from 5 to 10,
since some files in the compiler directory use higher-order
types with arities greater than 5.
- Add a macro version of MR_box_float(), using gcc's `({...})'
extension.
|
||
|
|
aa3f54f73f |
More work on the MLDS back-end.
Estimated hours taken: 6
More work on the MLDS back-end.
runtime/mercury.c:
Fix a cut-and-paste bug in the code for compare/3:
I forgot to add `break' after each case of a `switch' statement.
library/builtin.m:
library/private_builtin.m:
Replace the hand-coded definition of builtin_{compare,unify}_pred
in builtin.m with ordinary Mercury clauses in private_builtin.m.
This ensures that it works with the MLDS back-end.
(It also means that these procedures call error/1 rather than
MR_fatal_error(), so you get an exception rather than a
program abort.)
runtime/mercury.h:
runtime/mercury.c:
Add declarations and definitions of the compare and unify
procedures for the builtin types. (For some types,
the definitions here are still just stubs.)
runtime/mercury.h:
runtime/mercury.c:
runtime/mercury_init.h:
Add some hacks to work-around the current lack of support
for `pragma export'.
runtime/mercury_type_info.c:
If MR_HIGHLEVEL_CODE is defined, don't #include "mercury_imp.h",
since it is not needed.
runtime/mercury_wrapper.c:
runtime/mercury_wrapper.h:
runtime/mercury_init.h:
util/mkinit.c:
scripts/c2init.in:
Add support for the MLDS back-end to the program start-up
code.
|
||
|
|
6ba459bdaa |
Add some `MR_' prefixes.
Estimated hours taken: 0.75 Add some `MR_' prefixes. runtime/mercury_string.h: runtime/mercury_misc.h: runtime/mercury_misc.c: runtime/mercury_make_type_info_body.h: runtime/mercury_type_info.c: runtime/mercury.c: extras/*/*.m: extras/*/*/*.m: library/*.m: trace/*.c: compiler/fact_table.m: compiler/ml_code_gen.m: compiler/stack_layout.m: Add `MR_' prefixes to fatal_error(), hash_string(), do_hash_string, and HASH_STRING_FUNC_BODY. runtime/mercury_bootstrap.h: Add backwards compatibility macros for fatal_error() and hash_string(). |
||
|
|
a1b02cfc47 |
More fixes for the MLDS back-end.
Estimated hours taken: 8
More fixes for the MLDS back-end.
compiler/ml_code_gen.m:
library/private_builtin.m:
runtime/mercury.h:
Don't treat unsafe_type_cast as an inline builtin, since the
code generated for it as an inline builtin is not type-correct.
Instead, declare `unsafe_type_cast/2' as external in
library/private_builtin.m, so that the generated code
for this module does not try to declare or define it.
And in runtime/mercury.h, define unsafe_type_cast/2 as a
macro / inline function.
library/private_builtin.m:
Fix a bug in my previous change: add a missing cast.
runtime/mercury_type_info.h:
Declare the constants mercury_data___type_ctor_info_{pred,func}_0;
used by the MR_TYPE_CTOR_INFO_HO_{FUNC,PRED} macros.
Add some conditional code so that those macros do the right
thing for the MLDS back-end.
runtime/mercury_deep_copy.c:
runtime/mercury_tabling.c:
library/std_util.m:
Delete the now unnecessary declarations of
mercury_data___type_ctor_info_{pred,func}_0;
these are now declared in runtime/mercury_type_info.h.
library/std_util.m:
Delete the redundant definitions of the MR_TYPE_CTOR_INFO_*()
macros; these were defined identically in runtime/mercury_type_info.h.
Also use MR_TYPE_CTOR_INFO_HO_{FUNC,PRED} rather than hard-coding
their definitions.
runtime/mercury.h:
runtime/mercury.c:
Update to reflect recent RTTI changes.
In particular, use MR_TypeCtorInfo rather than MR_BaseTypeInfo,
and delete the code for the index/2 predicate.
runtime/mercury_std.h:
runtime/mercury.h:
Move the definition of MR_INLINE and MR_EXTERN_INLINE
from mercury.h to mercury_std.h, since they're used in
mercury_heap.h.
runtime/mercury.c:
Wrap `#ifdef MR_HIGHLEVEL_CODE' around the whole of this file,
so that it does the right thing in LLDS-based grades.
runtime/mercury_heap.h:
runtime/mercury_imp.h:
runtime/mercury_deep_copy.h:
runtime/mercury_layout_util.h:
Add some missing `#include' directives.
runtime/Mmakefile:
Add mercury.c and mercury.h to the respective file lists.
Split the HDRS variable into HDRS and BODY_HDRS, so that
`mmake check_headers' does not assume that *_body.h
will be syntactically correct.
|