mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-12 12:26:29 +00:00
50daad3ff7bcaa7588c29fc746f04f111af6aa38
45 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
9ac576f657 |
Don't call a function that doesn't exist in grades that don't use conservative
Branches: main, 11.07 Don't call a function that doesn't exist in grades that don't use conservative GC. runtime/mercury_memory.c: In MR_GC_free_attrib, call MR_GC_free not GC_free. (The corresponding allocation is made with MR_GC_malloc.) |
||
|
|
af99b1bd1f |
Avoid problems with the inclusion of windows.h in the runtime and a few
Branches: main, 11.07 Avoid problems with the inclusion of windows.h in the runtime and a few standard library modules. By default, windows.h includes a lot of other header files, some of which conflict with other parts of the Windows API. Such a conflict occurs with G12 tcp module where the inclusion of winsock2.h conflicts with the inclusion of winsock.h by windows.h. We can avoid this by defining the macro WIN32_LEAN_AND_MEAN. It causes winsock.h and some other headers not to be included by windows.h. (Should the other headers actually be required -- the Mercury runtime and standard library do not require them -- then they will need to be included separately.) To make this (and other workarounds for silly things in windows.h) possible this change adds wrapper header for windows.h to the runtime. We now use this wrapper header throughout the rest of the system rather than including windows.h directly. runtime/mercury_windows.h: Add a wrapper around windows.h that allows us to control how windows.h is included in a consistent manner. Define WIN32_LEAN_AND_MEAN in order to avoid problems with code that uses winsock2.h. runtime/Mmakefile: Include the new header. runtime/mercury_memory.c: runtime/mercury_memory_handlers.h runtime/mercury_memory_zones.c: runtime/mercury_timing.c: library/dir.m: library/io.m: library/time.m: Include mercury_windows.h rather than directly including windows.h. |
||
|
|
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.
|
||
|
|
ca7878f01a |
Make improvements to stack segments code.
The main benefits of these changes are:
Stack segments (and other memory zones) are cached when they are released
and can be re-used.
Some thread safety-fixes have been added.
All stack segments on all stacks are now the same size:
Small contexts (which had small stacks) aren't used with stack
segments.
The first segment on any stack is the same size as any other segment.
The first segment on any stack no-longer has a redzone.
Hard zones on all memory zones have been set to the minimum of one page
rather than one MR_unit which is usually two pages.
The caching of stack segments results in the following benchmark results. The
benefit is negligible under normal circumstances, but becomes important when
small segment sizes are used. Small segment sizes are common in
asm_fast.gc.par.stseg configurations as they reduce the memory required for
suspended contexts.
Non-segmented stack (32MB)
asm_fast.gc average of 5 with ignore=1 18.16 (1.00)
With 512KB (normal) segments:
asm_fast.gc.stseg and NO caching average of 5 with ignore=1 19.20 (1.06)
asm_fast.gc.stseg WITH caching average of 5 with ignore=1 19.16 (1.06)
With 4KB segments:
asm_fast.gc.stseg and NO caching average of 5 with ignore=1 20.66 (1.14)
asm_fast.gc.stseg WITH caching average of 5 with ignore=1 19.66 (1.08)
Other changes include corrections in code comments, clearer function names and
a documentation fix.
runtime/mercury_memory_zones.h:
runtime/mercury_memory_zones.c:
Re-write a lot of the code that managed the zone lists. The old code did
not re-use previously allocated but saved zones. The changes ensure that
MR_create_or_reuse_zone (formerly MR_create_zone) checks for a free zone
of at least the required size before allocating a new one. When zones are
released they are put on the free list.
As above MR_create_zone is now MR_create_or_reuse_zone,
MR_unget_zone is now MR_release_zone.
MR_construct_zone has been removed, it was only ever called by
MR_create_or_reuse_zone. MR_create_or_reuse_zone now contains the code for
MR_construct_zone.
To avoid an unnecessary sychronisation in parallel code some zones are not
added to the used list. The only zones put on the used list are those that
are useful to have on the used list because they have a non-default signal
handler or a redzone.
Updates to used_memory_zones now use a pthread mutex so that only one
thread may be updating the list at once. This lock is shared with the
free_memory_zones structure.
Updates to used_memory_zones now use memory barriers to guarantee that
concurrent reads always read a consistent, but possibly incomplete,
data-structure. This is necessary because it is read from a signal handler
which cannot call pthread_mutex().
Rename MR_get_used_memory_zones() to MR_get_used_memory_zones_readonly()
and document that the zone lists may be incomplete.
Make the MR_zone_next field of the MR_MemoryZone_Struct structure volatile.
Remove MAX_ZONES, it wasn't being used anywhere.
Insert some calls to MR_debug_log_message to help with debugging.
Use the correct printf integer length modifier for MR_Unsigned values.
Rename MR_context_id_counter to zone_id_counter, protect it with a lock in
HLC thread safe grades and use atomic operations in LLC thread-safe
grades..
The offset at which we start using a memory zone is allocated in sequence
from a table. This table was protected by Mercury's global lock, this is
now a CAS operation which prevents deadlocks when using trail segment,
parallel grades.
runtime/mercury_stacks.c:
Conform to changes in mercury_memory_zones.c.
Use MR_debug_log_message for printf-style debugging rather than printf.
runtime/mercury_wrapper.h:
runtime/mercury_wrapper.c:
Remove support for the smaller sized stacks in grades with stack segments.
Disable redzones when using stack segments. The MR_(non)detstack_zone_size
variables affect the first segment on every stack. Regardless of the type
of contaxt that owns that stack.
Conform to changes in runtime/mercury_memory_zones.h.
runtime/mercury_context.h:
runtime/mercury_context.c:
Removed an extra declaration for MR_init_context_maybe_generator
Small contexts are problematic since it's unclear to the programmer which
computations will be executed on smaller contexts and therefore whether
their stacks would overflow.
Conform to changes in runtime/mercury_memory_zones.h.
Conform to changes in runtime/mercury_wrapper.h.
runtime/mercury_memory.c:
Adjust the definition of MR_unit. It is now guaranteed to be a multiple of
the page size which is required by its use in mercury_memory_zones.c
Conform to changes in mercury_wrapper.h.
runtime/mercury_engine.c:
runtime/mercury_memory_handlers.c:
runtime/mercury_trail.c:
Conform to changes in runtime/mercury_memory_zones.h.
runtime/mercury_memory_handlers.c:
Use the correct printf integer length modifier for MR_Unsigned values.
runtime/mercury_misc.c:
Print out the meaning of errno if it is nonzero in MR_fatal_error.
Use the correct printf integer length modifier for MR_Unsigned values.
runtime/mercury_atomic_ops.h:
Define MR_THREADSAFE_VOLATILE to expand to volatile when MR_THREADSAFE is
defined. Otherwise it expands to nothing.
Make memory fences macros and atomic operations available in all thread safe
grades, not just low level C grades.
doc/user_guide.texi:
Corrected the default detstack size.
|
||
|
|
8d4afd3780 |
Avoid a C compiler warning due to the system headers on MinGW not including a
Branches: main Avoid a C compiler warning due to the system headers on MinGW not including a declaration for getpagesize(). This, according to the MinGW developers, is deliberate, despite getpagesize() being defined in libgcc on that system it isn't supposed to be used -- this diff redirects calls to getpagesize() on MinGW to the Win32 function GetSystemInfo(). runtime/mercury_memory.c: As above. Rename the definition of getpagesize() we use with MSVC and use that with MinGW as well. Add a macro that maps calls to getpagesize() onto the renamed function. |
||
|
|
3a76fe424f |
When the user asks for the printing of a non-existent part of a term, make
Estimated hours taken: 3 Branches: main When the user asks for the printing of a non-existent part of a term, make mdb print the path up to the nonexistent part as part of the error message. trace/mercury_trace_var.[ch]: Give to the function that generates those error messages a pointer not just to the bad part of the path, but to the full path as well, so it can print the good part. Remove fixed limits on the size of error messages. trace/mercury_trace_spy.c: Conform to the change in mercury_trace_var.h. runtime/mercury_memory.[ch]: Provide a mechanism for dynamically resizing character buffers for use by mercury_trace_vars.c. We use this instead of snprint because snprint isn't available or doesn't work properly on some platforms. Document a previously overlooked function. tests/debugger/browser_test.exp3: tests/debugger/field_names.exp: Update these test cases to expect the new, more informative error messages. |
||
|
|
ecf1ee3117 |
Add a mechanism for growing the stacks on demand by adding new segments
Estimated hours taken: 20 Branches: main Add a mechanism for growing the stacks on demand by adding new segments to them. You can ask for the new mechanism via a new grade component, stseg (short for "stack segments"). The mechanism works by adding a test to each increment of a stack pointer (sp or maxfr). If the test indicates that we are about to run out of stack, we allocate a new stack segment, allocate a placeholder frame on the new segment, and then allocate the frame we wanted in the first place on top of the placeholder. We also override succip to make it point code that will (1) release the new segment when the newly created stack frame returns, and then (2) go to the place indicated by the original, overridden succip. For leaf procedures on the det stack, we optimize away the check of the stack pointer. We can do this because we reserve some space on each stack for the use of such stack frames. My intention is that doc/user_guide.texi and NEWS will be updated once we have used the feature ourselves for a while and it seems to be stable. runtime/mercury_grade.h: Add the new grade component. runtime/mercury_conf_param.h: Document the new grade component, and the option used to debug stack segments. runtime/mercury_context.[ch]: Add new fields to contexts to hold the list of previous segments of the det and nondet stacks. runtime/mercury_memory_zones.[ch]: Include a threshold in all zones, for use in stack segments. Set it when a zone is allocated. Restore the previous #ifdef'd out function MR_unget_zone, for use when freeing stack segments execution has fallen out of. runtime/mercury_debug.[ch]: When printing the offsets of pointers into the det and nondet stacks, print the number of the segment the pointer points into (unless it is the first, in which case we suppress this in the interest of brevity and simplicity). Make all the functions in this module take a FILE * as an input argument; don't print to stdout by default. runtime/mercury_stacks.[ch]: Modify the macros that allocate stack frames to invoke the code for adding new stack segments when we are about to run out of stack. Standardize on "nondet" over "nond" as the abbreviation referring to the nondet stack. Conform to the changes in mercury_debug.c. runtime/mercury_stack_trace.c: When traversing the stack, step over the placeholder stack frames at the bottoms of stack segments. Conform to the changes in mercury_debug.c. runtime/mercury_wrapper.[ch]: Make the default stack size small in grades that support stack segments. Standardize on "nondet" over "nond" as the abbreviation referring to the nondet stack. Conform to the changes in mercury_debug.c. runtime/mercury_memory.c: Standardize on "nondet" over "nond" as the abbreviation referring to the nondet stack. runtime/mercury_engine.[ch]: runtime/mercury_overflow.h: Standardize on "nondet" over "nond" as the abbreviation referring to the nondet stack. Convert these files to four-space indentation. runtime/mercury_minimal_model.c: trace/mercury_trace.c: trace/mercury_trace_util.c: Conform to the changes in mercury_debug.c. compiler/options.m: Add the new grade option for stack segments. compiler/compile_target_code.m: compiler/handle_options.m: Add the new grade component, and handle its exclusions with other grade components and optimizations. compiler/llds.m: Extend the incr_sp instruction to record whether the stack frame is for a leaf procedure. compiler/llds_out.m: Output the extended incr_sp instruction. compiler/proc_gen.m: Fill in the extra slot in incr_sp instructions. compiler/goal_util.m: Provide a predicate for testing whether a procedure body is a leaf. compiler/delay_slot.m: compiler/dupelim.m: compiler/dupproc.m: compiler/exprn_aux.m: compiler/frameopt.m: compiler/global_data.m: compiler/jumpopt.m: compiler/middle_rec.m: compiler/opt_debug.m: compiler/opt_util.m: compiler/peephole.m: compiler/reassign.m: compiler/use_local_vars.m: Conform to the change in llds.m. scripts/canonicate_grade.sh-subr: scripts/init_grade_options.sh-subr: scripts/parse_grade_options.sh-subr: scripts/final_grade_options.sh-subr: scripts/mgnuc.in: Handle the new grade component. Convert parse_grade_options.sh-subr to four-space indentation. Mmake.workspace: Fix an old bug that prevented bootcheck from working in the new grade: when computing the gc grade, use the workspace's version of ml (which in this case understands the new grade components), rather than the installed ml (which does not). (This was a devil to track down, because neither make --debug nor strace on make revealed how the installed ml was being invoked, and there was no explicit invocation in the Makefile either; the error message appeared to come out of thin air just before the completion of the stage 2 library. It turned out the invocation happened implicitly, as a result of expanding a make variable.) |
||
|
|
70a83b2632 |
A common way to use parallel conjunction can cause a lot of Mercury contexts
Estimated hours taken: 7
Branches: main
A common way to use parallel conjunction can cause a lot of Mercury contexts
to be allocated, e.g.
map([], []).
map([H0|T0], [H|T]) :-
( p(H0, H) % contains no parallel conjunctions
& map(T0, T)
).
When the left parallel conjunct completes, the engine that was executing it
must suspend the context in which it was run, waiting for the right conjunct
to finish. The engine is then idle and will attempt to find further work to
execute in a _new_ context. To avoid excessive memory consumption due to
contexts we currently limit the number of contexts we allocate. However,
that severely limits the parallelism we can exploit in this example (and
similar patterns of work distribution). There are a lot of contexts
allocated but most of them are simply suspended.
Assuming that most parallel conjuncts contain small sub-computations, we can
allow many contexts to be allocated without excessive memory consumption by
just giving them smaller stacks. This patch creates a simple variant of a
MR_Context structure which has smaller stacks than the initial MR_Context
structure and executes parallel conjuncts in the smaller contexts if
larger contexts are unavailable.
runtime/mercury_memory.c:
runtime/mercury_wrapper.c:
runtime/mercury_wrapper.h:
doc/user_guide.texi:
Add globals to hold the desired sizes of small det and nondet stacks.
Add `--small-detstack-size' and `--small-nondetstack-size'
options for the MERCURY_OPTIONS environment variable to set the
desired sizes.
runtime/mercury_context.h:
Add a MR_ctxt_size field to MR_Context to indicate whether it has
regular or small sized stacks.
runtime/mercury_context.c:
Add an argument to MR_create_context() specifying whether we want a
regular or small context.
Ask for small stacks when creating new contexts to begin execution
from a spark (i.e. parallel conjuncts).
Create a new free-list to hold unused small contexts.
extras/concurrency/spawn.m:
runtime/mercury_mm_own_stacks.c:
runtime/mercury_thread.c:
Match the interface change to MR_create_context(). We give the
initial context and contexts created due for explicit Mercury threads
regular-sized stacks.
|
||
|
|
c391c78695 |
Remove a workaround which is no longer needed with Boehm GC 7.0.
Estimated hours taken: 0 Branches: main runtime/mercury_memory.c: Remove a workaround which is no longer needed with Boehm GC 7.0. |
||
|
|
6e27cee1f3 |
This patch enables the thread-local memory allocation feature of Boehm GC in
Estimated hours taken: 4 Branches: main This patch enables the thread-local memory allocation feature of Boehm GC in parallel grades on Linux hosts; without it, performance is terrible. It may work on other operating systems using pthreads, but I haven't tested. Mmake.common.in: configure.in: boehm_gc/Makefile: Build Boehm GC with the THREAD_LOCAL_ALLOC preprocessor symbol in parallel grades on Linux. Add -DGC_REDIRECT_TO_LOCAL to CFLAGS_FOR_THREADS to redirect calls to GC_malloc() to GC_local_malloc(). runtime/mercury_memory.c: Work around a bug in the garbage collector when using thread-local allocation. Hans Boehm says, "A size zero GC_local_malloc allocation currently just returns a fixed address outside the real heap." This leads to a crash when we later try to GC_free() the address. |
||
|
|
e854a5f9d9 |
Major improvements to tabling, of two types.
Estimated hours taken: 32
Branches: main
Major improvements to tabling, of two types. The first is the implementation
of the loopcheck and memo forms of tabling for model_non procedures, and the
second is a start on the implementation of a new method of implementing
minimal model tabling, one that has the potential for a proper fix of the
problem that we currently merely detect with the pneg stack (the detection
is followed by a runtime abort). Since this new method relies on giving each
own generator its own stack, the grade component denoting it is "mmos"
(minimal model own stack). The true name of the existing method is changed
from "mm" to "mmsc" (minimal model stack copy). The grade component "mm"
is now a shorthand for "mmsc"; when the new method works, "mm" will be changed
to be a shorthand for "mmos".
configure.in:
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/final_grade_options.sh-subr:
compiler/options.m:
Handle the new way of handling minimal model grades.
scripts/mgnuc.in:
compiler/compile_target_code.m:
Conform to the changes in minimal model grade options.
compiler/table_gen.m:
Implement the transformations required by the loopcheck and memo
tabling of model_non procedures, and the minimal model own stack
transformation.
The new implementation transformations use foreign_procs with extra
args, since there is no point in implementing them both that way and
with separate calls to library predicates. This required making the
choice of which method to use at the top level of each transformation.
Fix an oversight that hasn't caused problems yet but may in the future:
mark goals wrapping the original goals as not impure for determinism
computations.
compiler/handle_options.m:
Handle the new arrangement of the options for minimal model tabling.
Detect simultaneous calls for both forms of minimal model tabling,
and generate an error message. Allow for more than one error message
generated at once; report them all once rather than separately.
compiler/globals.m:
Add a mechanism to allow a fix a problem detected by the changes
to handle_options: the fact that we currently may generate a usage
message more than once for invocations with more than one error.
compiler/mercury_compile.m:
compiler/make.program_target.m:
compiler/make.util.m:
Use the new mechanism in handle_options to avoid generating duplicate
usage messages.
compiler/error_util.m:
Add a utility predicate for use by handle_options.
compiler/hlds_pred.m:
Allow memo tabling for model_non predicates, and handle own stack
tabling.
compiler/hlds_out.m:
Print information about the modes of the arguments of foreign_procs,
since this is useful in debugging transformations such as tabling
that generate them.
compiler/prog_data.m:
compiler/layout_out.m:
compiler/prog_out.m:
runtime/mercury_stack_layout.h:
Mention the new evaluation method.
compiler/goal_util.m:
Change the predicates for creating calls and foreign_procs to allow
more than one goal feature to be attached to the new goal. table_gen.m
now uses this capability.
compiler/add_heap_ops.m:
compiler/add_trail_ops.m:
compiler/polymorphism.m:
compiler/simplify.m:
compiler/size_prof.m:
compiler/typecheck.m:
compiler/unify_proc.m:
Conform to the changes in goal_util.
compiler/code_info.m:
compiler/make_hlds.m:
compiler/modules.m:
compiler/prog_io_pragma.m:
Conform to the new the options controlling minimal model
tabling.
compiler/prog_util.m:
Add a utility predicate for use by table_gen.m.
library/std_util.m:
Conform to the changes in the macros for minimal model tabling grades.
library/table_builtin.m:
Add the types and predicates required by the new transformations.
Delete an obsolete comment.
runtime/mercury_grade.h:
Handle the new minimal model grade component.
runtime/mercury_conf_param.h:
List macros controlling minimal model grades.
runtime/mercury_tabling.[ch]:
Define the types needed by the new transformations,
Implement the performance-critical predicates that need to be
hand-written for memo tabling of model_non predicates.
Add utility predicates for debugging.
runtime/mercury_tabling_preds.h:
Add the implementations of the predicates required by the new
transformations.
runtime/mercury_mm_own_stacks.[ch]:
This new module contains the first draft of the implementation
of the own stack implementation of minimal model tabling.
runtime/mercury_imp.h:
Include the new file if the grade needs it.
runtime/Mmakefile:
Mention the new files, and sort the lists of filenames.
runtime/mercury_tabling_macros.h:
Add a macro for allocating answer blocks without requiring them to be
pointed to directly by trie nodes.
runtime/mercury_minimal_model.[ch]:
The structure type holding answer lists is now in mercury_tabling.h,
since it is now also needed by memo tabling of model_non predicates.
It no longer has a field for an answer num, because while it is ok
to require a separate grade for debugging minimal model tabling,
it is not ok to require a separate grade for debugging memo tabling
of model_non predicates. Instead of printing the answer numbers,
print the answers themselves when we need to identify solutions
for debugging.
Change function names, macro names, error messages etc where this is
useful to distinguish the two kinds of minimal model tabling.
Fix some oversights wrt transient registers.
runtime/mercury_context.[ch]:
runtime/mercury_engine.[ch]:
runtime/mercury_memory.[ch]:
runtime/mercury_wrapper.[ch]:
With own stack tabling, each subgoal has its own context, so record
the identity of the subgoal owning a context in the context itself.
The main computation's context is the exception: it has no owner.
Record not just the main context, but also the contexts of subgoals
in the engine.
Add variables for holding the sizes of the det and nondet stacks
of the contexts of subgoals (which should in general be smaller
than the sizes of the corresponding stacks of the main context),
and initialize them as needed.
Initialize the variables holding the sizes of the gen, cut and pneg
stacks, even in grades where the stacks are not used, for safety.
Fix some out-of-date documentation, and conform to our coding
guidelines.
runtime/mercury_memory_zones.[ch]:
Add a function to test whether a pointer is in a zone, to help
debugging.
runtime/mercury_debug.[ch]:
Add some functions to help debugging in the presence of multiple
contexts, and factor out some common code to help with this.
Delete the obsolete, unused function MR_printdetslot_as_label.
runtime/mercury_context.h:
runtime/mercury_bootstrap.h:
Move a bootstrapping #define from mercury_context.h to
mercury_bootstrap.h.
runtime/mercury_context.h:
runtime/mercury_bootstrap.h:
Move a bootstrapping #define from mercury_context.h to
mercury_bootstrap.h.
runtime/mercury_types.h:
Add some more forward declarations of type names.
runtime/mercury_dlist.[ch]:
Rename a field to avoid assignments that dereference NULL.
runtime/mercury_debug.c:
runtime/mercury_memory.c:
runtime/mercury_ml_expand_body.h:
runtime/mercury_stack_trace.c:
runtime/mercury_stacks.[ch]:
trace/mercury_trace_util.c
Update uses of the macros that control minimal model tabling.
runtime/mercury_stack_trace.c:
Provide a mechanism to allow stack traces to be suppressed entirely.
The intention is that by using this mechanism, by the testing system
won't have to provide separate .exp files for hlc grades, nondebug
LLDS grades and debug LLDS grades, as we do currently. The mechanism
is the environment variable MERCURY_SUPPRESS_STACK_TRACE.
tools/bootcheck:
tools/test_mercury:
Specify MERCURY_SUPPRESS_STACK_TRACE.
trace/mercury_trace.c:
When performing retries across tabled calls, handle memo tabled
model_non predicates, for which the call table tip variable holds
a record with a back pointer to a trie node, instead of the trie node
itself.
trace/mercury_trace_internal.c:
When printing tables, handle memo tabled model_non predicates. Delete
the code now moved to runtime/mercury_tabling.c.
Add functions for printing the data structures for own stack minimal
model tabling.
tests/debugger/print_table.{m,inp,exp}:
Update this test case to also test the printing of tables for
memo tabled model_non predicates.
tests/debugger/retry.{m,inp,exp}:
Update this test case to also test retries across memo tabled
model_non predicates.
tests/tabling/loopcheck_nondet.{m,exp}:
tests/tabling/loopcheck_nondet_non_loop.{m,exp}:
New test cases to test loopcheck tabled model_non predicates.
One test case has a loop to detect, one doesn't.
tests/tabling/memo_non.{m,exp}:
tests/tabling/tc_memo.{m,exp}:
tests/tabling/tc_memo2.{m,exp}:
New test cases to test memo tabled model_non predicates.
One test case has a loop to detect, one has a need for minimal model
tabling to detect, and the third doesn't have either.
tests/tabling/Mmakefile:
Add the new test cases, and reenable the existing tc_loop test case.
Rename some make variables and targets to make them better reflect
their meaning.
tests/tabling/test_mercury:
Conform to the change in the name of the make target.
|
||
|
|
ca36453476 |
Fix a bug in the implementation of the "-dm" (debug memory) runtime option:
Estimated hours taken: 0.75 Branches: main Fix a bug in the implementation of the "-dm" (debug memory) runtime option: it was not printing out the information about the memory zones. runtime/mercury_memory.c: runtime/mercury_wrapper.c: Don't call debug_memory() at the end of init_memory(), because the memory zones haven't been created then. Instead, call it in mercury_runtime_init(), after all the different memory zones have been initialized. (Also, fix an out-of-date comment in mercury_wrapper.c.) |
||
|
|
37e3602c30 |
If MR_heap_margin_size is too big (greater than the heap size),
Estimated hours taken: 1 Branches: main runtime/mercury_memory.c: If MR_heap_margin_size is too big (greater than the heap size), then reset it to be a single page, like we do for MR_heap_zone_size. Otherwise we attempt a collection at every allocation, which takes way too long (and causes tests/hard_coded/rational_test.m to fail due to exceeding the 5 minute ulimit). |
||
|
|
168500343c |
This change adds new facilities for debugging minimal model tabling, and
Estimated hours taken: 160 Branches: main This change adds new facilities for debugging minimal model tabling, and has several bug fixes found with the aid of those facilities. Most of the diff affects the behavior of the system only in minimal model grades and/or when debugging flags are defined. compiler/ite_gen.m: In minimal model grades, surround the conditions of if-then-elses with calls to three functions. These functions detect when a condition fails due to one or more suspensions, and abort the program. (After resumptions, the condition may actually have solutions, but by then the computation has committed to the wrong path.) compiler/table_gen.m: Change the program transformation for model_non predicates to use a switch instead of nested if-then-elses, to avoid the overhead of wrapping the condition. The version with switches is also a bit easier to debug. The transformation for model_det and model_semi predicates stays as before, because for such predicates finding the status (which we want to switch on) requires computation, not just a lookup. Switch to state variable syntax in the affected predicates. Make the error message for an internal error in loopcheck predicates more precise. Mark the code fragments that modify tabling data structures as impure and code fragments that examine tabling data structures as semipure. runtime/mercury_stacks.[ch]: Implement the new stack of possibly negated contexts that we use to detect false failures due to suspensions in negated contexts. Fix a bug: don't refer to MR_cut_stack[-1]. Shorten the name of the generator stack. runtime/mercury_context.[ch]: runtime/mercury_memory.c: runtime/mercury_wrapper.[ch]: Allocate memory for the new stack of possibly negated contexts. Use the shortened name of the generator stack. runtime/mercury_regorder.h: Allocate a pointer for the new stack of possibly negated contexts. runtime/mercury_minimal_model.[ch]: A new module holding the part of mercury_tabling.[ch] that is specific to minimal model tabling. This version contains tools to help debugging of minimal model tabling, as well as some bug fixes found with the aid of those tools. runtime/mercury_tabling.[ch]: Remove the code moved to mercury_minimal_model.[ch], and add the code moved here from trace/mercury_trace_internal.c. Add prefixes to a bunch of structure fields to make it easier to read code accessing those fields. Add mechanisms to allocate and copy tabling structures with type safety. runtime/mercury_imp.h: #include the new header file, if it is needed. runtime/Mmakefile: Mention the new module, and fix sortedness errors. runtime/mercury_stack_trace.c: Fix a bug that sometimes caused stack traces to abort in minimal model grades: they were trying to get layout information from labels that do not have them, such as do_fail. If MR_TABLE_DEBUG is defined, print the locations of stack frames when doing stack dumps. runtime/mercury_trace_base.h: Export to mercury_stack_trace.c the labels that we use to let the debugger get control at redos and fails, since they don't have layout information. runtime/mercury_types.h: Move typedefs here from mercury_tabling.h, and add typedefs for some newly added types. runtime/mercury_engine.[ch]: Add a table mapping debugging flags to their offsets in the MR_debugflag array, for use in the debugger. runtime/mercury_misc.c: Make the formatting of det stack pointers the same as nondet stack pointers in debugging output. runtime/mercury_debug.[ch]: Add conditionally compiled debugging output when creating temp frames on the nondet stack. library/table_builtin.m: Conform to the new names of some fields. Add a predicate to return the status of a subgoal. Add conditionally compiled debugging code. library/Mmakefile: Make table_builtin.m depend on runtime/mercury_minimal_model.h. trace/mercury_trace.c: Conform to the new names of some fields. trace/mercury_trace_internal.c: Add two new mdb commands, to print the cut stack and the new possibly negated context stack. Add two new mdb commands to print a subgoal and a consumer. Move some of the code to print tabling-related data structures to runtime/mercury_tabling.[ch]. Add a new mdb command to report the values of debugging flags and to set and clear them. Previously, one had to turn on these debugging flags with environment variables, which were problematic because they turned on diagnostic printouts even in Mercury programs that *weren't* being debugged, such as the Mercury compiler when being used to generate the program to be debugged. Now the flags can be turned on from a .mdbrc file, which eliminates much setting and unsetting of environment variables. doc/user_guide.tex: Document the new mdb commands. tests/debugger/mdb_command_test.inp: Test the documentation of the new mdb commands. tests/debugger/completion.exp: Expect the new commands in the command completion test. tests/debugger//nondet_stack.exp*: Expect the new format of det stack pointers. tests/debugger/all_solutions.exp3: tests/debugger/exception_value.exp3: tests/debugger/declarative/catch.exp3: tests/debugger/declarative/ho5.exp3: tests/debugger/declarative/throw.exp3: New expected test cases for use in minimal model grades. They differ from existing expected output files only in the precise phrasing of error messages. tests/debugger/declarative/Mmakefile: Disable the untraced_subgoal test case in .mm grades, since we don't pass it yet. tests/tabling/Mmakefile: Enable the mday test case, now that we pass it. |
||
|
|
17d5aa732e |
Add support for interfacing Mercury with the MPS garbage collector.
Estimated hours taken: 20
Branches: main
Add support for interfacing Mercury with the MPS garbage collector.
This change is broken into three parts:
1. Import version 1.100.1 of the MPS kit into the Mercury
CVS repository, in the directory `mps_gc'.
2. Make some changes to the MPS kit for Mercury,
to support fully-conservative collection and tagged pointers,
and to wrap it in an interface that is similar to that of
the Boehm collector.
3. Modify the rest of the Mercury implementation
to support linking with the MPS kit instead
of the Boehm collector. This involved defining
`mps' as a new GC method and a new grade component.
This is part 3 of 3.
Mmake.workspace:
Include the MPS directories in the header file and library search
paths.
tools/bootcheck:
Link the mps_gc directory into the stage2 and stage3 directories.
Mmake.workspace:
runtime/Mmakefile:
scripts/ml.in:
For *.mps grades, link in mps.a.
(XXX ml.in is linking in libmps.a, which is wrong.)
runtime/Mmakefile:
trace/Mmakefile:
In the rule for `check_headers', which checks macro namespace
cleanliness, allow names to start with `MPS_' or `mps_'.
runtime/RESERVED_MACRO_NAMES:
Add `mercury_mps_h', which is used by mps_gc/code/mercury_mps.h
for its header guard. (Normally it would be better to use
uppercase for header guard macro names, but that would be
inconsistent with the coding style used in mps_gc/code.)
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/canonical_grade.sh-subr:
Handle the new `mps' GC method and grade component.
compiler/globals.m:
compiler/options.m:
doc/user_guide.texi:
Replace gc_method `conservative' with two alternatives
`boehm' and `mps'. ("--gc conservative" is still allowed,
and treated as equivalent to "--gc boehm".)
Add new function `gc_is_conservative' to globals.m.
compiler/mercury_compile.m:
compiler/handle_options.m:
Use `gc_is_conservative' rather than `= conservative'.
compiler/handle_options.m:
Handle the "mps" grade component.
(XXX need to document this in options.m and user_guide.texi)
compiler/compile_target_code.m:
Pass the appropriate C defines for the new GC methods.
compiler/mercury_compile.m:
Wrap the work-around for a Boehm GC bug inside `#ifndef MR_MPS_GC'.
library/array.m:
Use GC_FREE() rather than GC_free().
This is needed for two reasons:
- so that it works with MPS, which only defines GC_FREE
- so that it works with then Boehm collector when
GC debugging is enabled
library/benchmarking.m:
Output GC statistics for the MPS collector.
runtime/mercury.h:
runtime/mercury_heap.h:
runtime/mercury_init.h:
runtime/mercury_memory.h:
If MR_MPS_GC is defined, use mercury_mps.h rather than gc.h.
runtime/mercury_conf_param.h:
Add configuration macros MR_BOEHM_GC and MR_MPS_GC.
Set MR_CONSERVATIVE_GC if either of these is set.
Default to MR_BOEHM_GC if only MR_CONSERVATIVE_GC is set.
runtime/mercury_context.h:
runtime/mercury_deep_copy.h:
runtime/mercury_engine.h:
runtime/mercury_float.h:
runtime/mercury_heap.h:
Explictly #include "mercury_conf.h", so that
MR_CONSERVATIVE_GC will be set properly before it is tested.
runtime/mercury_grade.h:
Handle the .mps grade component.
runtime/mercury_memory.c:
runtime/mercury_wrapper.c:
runtime/mercury_memory_handlers.c:
Move the call to MR_setup_signals() earlier in the
initialization sequence, so that the MPS signal handlers
get installed after our signal handlers. This is needed
because our signal handlers assume that any signals that
they can't handle are fatal errors, which interfere's
with MPS's use of signal handlers for memory barriers.
runtime/mercury_wrapper.c:
Add code to initialize the MPS collector.
Put code which is specific to the Boehm collector inside
#ifdef MR_BOEHM_GC rather than #ifdef MR_CONSERVATIVE_GC.
runtime/mercury_wrapper.h:
Update a comment.
|
||
|
|
32051f5467 |
Add support for command line completion to mdb.
Estimated hours taken: 40
Branches: main
Add support for command line completion to mdb.
NEWS:
Document the change.
trace/mercury_trace_completion.{c,h}:
Define the framework for completion.
Examine command lines to determine which completers to use.
trace/mercury_trace_alias.{c,h}:
trace/mercury_trace_help.{c,h}:
trace/mercury_trace_internal.{c,h}:
trace/mercury_trace_tables.{c,h}:
trace/mercury_trace_vars.{c,h}:
Define context-specific completers.
trace/mercury_trace_help.c:
Record all help topics in an array for use by the completer.
trace/mercury_trace_internal.c:
Add completion information to the list of commands.
Add a function MR_trace_command_completion_info to access
that information.
runtime/mercury_wrapper.{c,h}
Add a runtime option `--force-readline', which tells mdb to
use readline even if MR_mdb_in is not a tty. This is needed
for tests/debugger/completion. `--force-readline' is not
documented because I'm not sure that it will work properly
in all situations (it's fine for the test).
Fix capitalisation in references to the Mercury User's Guide
in error messages.
trace/mercury_trace_readline.c:
Tell Readline to use our completer.
Handle `--force-readline'. Disable some Readline terminal
initialisation code which reports spurious warnings if the
input stream is not a tty.
trace/Mmakefile:
Add mercury_trace_completion.{c,h}.
runtime/mercury_array_macros.h:
Define a macro MR_find_first_match, which is like MR_bsearch
except that it finds the first match, not an arbitrary match.
runtime/mercury_memory.c:
Handle NULL pointers in MR_copy_string();
runtime/mercury_memory.h:
Add a macro MR_free_func which returns the address of free().
Used where it is necessary to pass the address of MR_free().
tests/debugger/Mmakefile:
tests/debugger/completion.m:
tests/debugger/completion.exp:
tests/debugger/completion.inp:
tests/debugger/completion.inputrc:
tests/debugger/completion.sub1.m:
tests/debugger/completion.sub2.m:
tests/debugger/completion.sub2.sub3.m:
Test case.
|
||
|
|
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. |
||
|
|
af62036bff |
Two related changes for accurate GC with the MLDS->C back-end:
Estimated hours taken: 2 Branches: main Two related changes for accurate GC with the MLDS->C back-end: - Add a new runtime option --heap-margin-size for the threshold of free heap space before a collection is invoked, rather than the previous hack of reusing --heap-zone-size for that purpose. - A minor optimization to reduce the cost of MR_gc_check(): cache the value of MR_zone_end - MR_heap_margin_size. runtime/mercury_wrapper.h: runtime/mercury_wrapper.c: runtime/mercury_memory.c: Add new variable `MR_heap_margin_size', and add a new runtime option `--heap-margin-size' to set it. runtime/mercury_memory_zones.h: Add new field `gc_threshold' to the MR_MemoryZone struct. runtime/mercury_memory_zones.c: Initialize the new field to point to the zone end minus MR_heap_margin_size. runtime/mercury.h: Change MR_GC_check() to use the `gc_threshold' field. |
||
|
|
e3157727fd |
Add a comment that mercury_signal.h must be included
Estimated hours taken: 0.2 runtime/mercury_signal.h: runtime/mercury_memory.c: runtime/mercury_memory_handlers.c: Add a comment that mercury_signal.h must be included before <signal.h> if `struct_sigcontext' is needed. |
||
|
|
e1c9ac5299 |
Fix a bug in my last change.
Estimated hours taken: 0.2 runtime/mercury_signal.h: Fix a bug in my last change. <signal.h> needs to be included here for `struct sigaction'. runtime/mercury_signal.c: runtime/mercury_memory.c: runtime/mercury_memory_handlers.c: Remove some duplicated code. |
||
|
|
210a596aaf |
Make even things used only in grade none use MR_ prefixes.
Estimated hours taken: 2 Make even things used only in grade none use MR_ prefixes. runtime/mercury_memory.c: Delete some obsolete global variables that were replaced by fields of the engine structure ages ago. Their declaration gets a syntax error in grade none. runtime/mercury_engine.h: Remove some confusing macros for referring to these fields. runtime/mercury_*.[ch] Add MR_ prefixes as necessary. Get rid of references to the confusing macros. library/exception.m: Add MR_ prefixes as necessary. Get rid of references to the confusing macros. library/std_util.m: Add MR_ prefixes as necessary. |
||
|
|
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. |
||
|
|
1c8cb6faf2 |
Get the compiler to bootstrap with -DMR_NO_BACKWARDS_COMPAT.
Estimated hours taken: 2 Get the compiler to bootstrap with -DMR_NO_BACKWARDS_COMPAT. compiler/c_util.m: compiler/rtti_out.m: Add MR_ prefixes to various type names in generated code. compiler/*.m: browser/*.m: library/*.m: Add MR_prefixes to various type and function names in pragma C code. runtime/*.[ch]: trace/*.[ch]: Add MR_prefixes to various type and function names in hand-written code. |
||
|
|
d7f7621434 |
Fix a GC-related bug that broke the asm_fast.gc.par grade on
Estimated hours taken: 20 (roughly -- including time spent by trd and conway) Fix a GC-related bug that broke the asm_fast.gc.par grade on some systems. runtime/mercury_memory.h: runtime/mercury_memory.c: Add MR_GC_NEW_UNCOLLECTABLE() and MR_GC_malloc_uncollectable(), which are like MR_GC_NEW() and MR_GC_malloc() except that they call GC_MALLOC_UNCOLLECTABLE() rather than GC_MALLOC(). runtime/mercury_engine.c: Allocate the engine with MR_GC_NEW_UNCOLLECTABLE() rather than MR_GC_NEW(), so that it is safe to store the only pointer to it in thread-local storage. |
||
|
|
ada9593c53 |
Add a forward declaration of `struct sigcontext' to avoid a
Estimated hours taken: 0.5
runtime/mercury_signal.c:
runtime/mercury_memory.c:
runtime/mercury_memory_handlers.c:
Add a forward declaration of `struct sigcontext' to avoid a
gcc warning inside <signal.h>. This is needed since our
`#define sigcontext_struct sigcontext' hack breaks the Linux
headers a bit -- it means that an earlier forward declaration
of `struct sigcontext_struct' won't prevent this warning.
Also add an XXX comment about the code being duplicated three times.
|
||
|
|
201413d997 |
Use Win32 exceptions to report problems when Win32 structured exceptions
Estimated hours taken: 48
Use Win32 exceptions to report problems when Win32 structured exceptions
are available.
configure.in:
runtime/mercury_conf.h.in:
No longer define MR_WIN32, just because we are using a Microsoft
compiler, instead we use _WIN32 to detect the presence of the Win32
API.
runtime/mercury_conf_param.h:
Define the following symbolic constants:
MR_WIN32 which is true if the Win32 API is available.
MR_WIN32_GETSYSTEMINFO which is true if GetSystemInfo() is
availabe.
MR_WIN32_VIRTUALALLOC which is true if VirtualAlloc() is
availabe.
MR_MSVC_STRUCTURED_EXCEPTIONS if we can use Microsoft Visual C
structured exceptions.
MR_PROTECTPAGE if can provide mprotect like functionality.
All of the above are assumed true if the Win32 API is available.
MR_CHECK_OVERFLOW_VIA_MPROTECT is also true if MR_WIN32, because the
Win32 API provides mprotect like functionality.
runtime/mercury_memory_zones.c:
Define a function MR_protect_pages() which has the same interface as
mprotect. It just calls mprotect when it exists or equivalent code
to emulate it under Win32.
Use MR_PROTECTPAGE in place of HAVE_MPROTECT, and replace all calls
to mprotect() with MR_protect_pages().
Define a Win32 version of memalign.
runtime/mercury_memory_handlers.c:
Use MR_protect_pages() instead of mprotect().
Don't use signal handlers when in a Win32 structured exceptions are
available.
Code to explain Win32 exceptions on stderr.
runtime/mercury_memory_handlers.h:
Export MR_filter_win32_exception for use in mercury_wrapper.c
runtime/mercury_memory_zones.h:
Use MR_PROTECTPAGE in place of HAVE_MPROTECT.
Define PROT_{NONE,READ,WRITE} if we the Win32 API is available and
they are not already defined.
Export the definition of MR_protect_pages().
runtime/mercury_wrapper.c:
Wrap the call to main in a __try __except block if we are using
Win32 structured exceptions, so that any exceptions generated are
caught and debugging info about them printed to stderr.
runtime/mercury_memory.c:
Add a Win32 version of getpagesize().
|
||
|
|
a68df3d95f |
Allow compilation of the mercury compiler *ONLY* in the grade hlc.gc
Estimated hours taken: 40
Allow compilation of the mercury compiler *ONLY* in the grade hlc.gc
using the Microsoft Visual C++ compiler (MSVC). This is still
work-in-progress.
configure.in:
Test to see whether or not we are using the Microsoft compiler.
Don't fail if we can't interpret return values from system.
boehm_gc/Mmakefile:
Use NT_MAKEFILE if we are using MSVC.
boehm_gc/NT_MAKEFILE:
Apply the the changes to boehm_gc/Makefile to this file.
browser/Mmakefile:
library/Mmakefile:
runtime/Mmakefile:
trace/Mmakefile:
Use the correct executable to create libraries.
Use AR_LIBFILE_OPT to name the library.
compiler/llds_out.m:
Export output_c_file_intro_and_grade so that the correct header can
be placed at the start of each C file.
compiler/mlds_to_c.m:
Output the header at the start of each C file, so that configure
doesn't delete the file when checking the compatability with
the configured settings.
When initializing empty arrays place a dummy entry in the array, so
that the MSVC compiler generates a symbol for that array.
compiler/passes_aux.m:
Add invoke_shell_command. This predicate wraps commands with
a bash -c 'command ' when shell scripts aren't supported by the
target system.
compiler/mercury_compile.m:
compiler/modules.m:
Use invoke_shell_command instead of invoke_system_command for shell
scripts.
library/io.m:
Call _unlink in io_rename_file, when compiling with MSVC.
runtime/mercury_wrapper.c:
Initialise MR_runqueue_head so that the segment containing this
variable is registered with the garbage collector. This stops
intermittent failures of the GC_is_visible() test.
runtime/mercury_conf.h.in:
Define MR_WIN32 when we are using MSVC.
runtime/mercury_memory.c:
runtime/mercury_memory_handlers.c:
runtime/mercury_memory_zones.c:
runtime/mercury_prof.c:
runtime/mercury_reg_workarounds.c:
runtime/mercury_reg_workarounds.h:
runtime/mercury_signal.c:
runtime/mercury_timing.c:
runtime/mercury_timing.h:
runtime/mercury_trace_base.c:
util/mkinit.c:
Only include unistd.h and sys/times.h when they exist.
MSVC doesn't have SIGBUS so #ifdef sections which refer to it.
scripts/Mmake.rules:
Use /Fo instead of -o to generate .o files if compiling with MSVC.
scripts/Mmake.vars.in:
Define AR to use the autoconfed executable for linking.
scripts/mgnuc.in:
Only add option -Wno-uninitialized if we are using gcc.
util/Mmakefile:
Explicitly locate the getopt src, and use it in compiling the
utilities.
|
||
|
|
88a513b580 |
Reorganize the routines for allocating and deallocating memory:
Estimated hours taken: 8
Reorganize the routines for allocating and deallocating memory:
runtime/mercury_std.h:
runtime/mercury_misc.c:
runtime/mercury_memory.h:
runtime/mercury_memory.c:
- Put the routines in the proper place.
Previously the declarations and definitions of the memory
allocation/deallocation routines were spread amoungst
all four of these files; I moved the ones in mercury_std.h
and mercury_misc.c so that they are now all defined
in mercury_memory.{h,c}
- Avoid unnecessary duplication
The following routines did exactly the same thing,
modulo bugs(!):
allocate_bytes() and newmem()
deallocate_bytes() and oldmem()
make() and allocate_object()
make_many() and allocate_array()
- Use appropriate names.
I added `MR_' prefixes, and ensured that macros that are not
function-like macros use all uppercase. I also used a more
consistent naming scheme.
Previously the names used were
(1) checked_malloc, checked_realloc
(2a) allocate_bytes, deallocate_bytes, reallocate_bytes,
allocate_object, allocate_array, resize_array
(2b) newmem, oldmem, resizemem,
make, make_many, resize_many
The new names are
(1) MR_malloc, MR_free, MR_realloc,
MR_NEW, MR_NEW_ARRAY, MR_RESIZE_ARRAY
(2) MR_GC_malloc, MR_GC_free, MR_GC_realloc,
MR_GC_NEW, MR_GC_NEW_ARRAY, MR_GC_RESIZE_ARRAY
runtime/*.[ch]:
trace/*.[ch]:
library/array.m:
library/benchmarking.m:
library/io.m:
library/std_util.m:
extras/odbc/odbc.m:
extras/aditi/aditi.m:
Use the new names.
|
||
|
|
dc03496d06 |
Rewrite significant parts of minimal model tabling so that it works
Estimated hours taken: 130
Rewrite significant parts of minimal model tabling so that it works
in a much wider variety of situations, including coups. Also, clean up
the tabling implementation to make it more maintainable, and introduce
a new grade component, .mm, that enables minimal model tabling.
(Minimal model tabling requires distributed fat, and we don't want to
incur such costs unless necessary.)
compiler/options.m:
Add a new option --use-minimal-model, which for now is documented
as "not for general use". This option is a grade option, and is
required if minimal model tabling is to work.
compiler/handle_options.m:
When --use-minimal-model is given, do not allow nondet frame hijacks,
since minimal model tabling cannot cope with hijacks.
Make --use-minimal-model a grade component.
compiler/code_info.m:
When --use-minimal-model is given, insert calls to MR_commit_{mark,cut}
around goals being committed across. This is now necessary, so that we
can detect and handle sitations where a goal being committed across
starts but does not complete a tabled goal.
compiler/table_gen.m:
Rename many of the tabling helper predicates, using a naming scheme
that separates predicates used for model_non procedures from those
used to implement simpler forms of tabling, while bringing out
the parallels between these two sets of predicates.
When calls to two tabling helper predicates always occur
one after the other, merge the two into one.
Generate and use more meaningful variable names; having all of the
several variables inserted by this transformation named TableVar
was quite confusing.
library/private_builtin.m:
Reorganize this file, to separate out the different sections.
The contents of the non-tabling sections were not modified, only
moved around.
Rename the predicates referred to by table_gen.m.
Move most of the type declarations and complex code out of here,
into runtime/mercury_tabling.c. This makes it easier to debug them,
since (a) creating a new executable is quicker, since you don't have
to wait for lots of mercury compiler invocations, and (b) gdb doesn't
get confused by #line directives. It also makes it easier to write
them, since you don't have to !&(*U&( remember to double all your
double quotes and to backslash all your backslashes.
runtime/mercury_grade.h:
Include a grade component reflecting whether MR_USE_MINIMAL_MODEL
is defined.
runtime/mercury_conf_param.h:
Document MR_USE_MINIMAL_MODEL.
runtime/mercury_stacks.[ch]:
The changes to tabling require the addition of two new stacks,
the generator stack and the cut stack. This module defines the
structures of the frames of these stacks and provides the
operations on these stacks.
The header file also contains some additional macros that return
the addresses of fixed nondet stack slots, not their contents,
for use by tabling code.
runtime/mercury_context.[ch]:
runtime/mercury_memory.[ch]:
runtime/mercury_wrapper.[ch]:
Declare and set up the two new stacks, both in saved contexts and in
the active context, if MR_USE_MINIMAL_MODEL is defined.
runtime/mercury_regorder.h:
Add four new global virtual machine registers to hold pointers
to the memory areas of the two new stacks and the current offsets
within them. These are defined whether MR_USE_MINIMAL_MODEL is defined
or not, since the cost is minimal and the potential bugs we avoid
would be hard to track down.
runtime/mercury_engine.h:
runtime/mercury_wrapper.c:
Add support for a new debugging flag, -dS, which prints the contents
of the nondet stack at several points during tabling.
runtime/mercury_tabling.[ch]:
The implementation of the new tabling system. Much of the new code here
is stuff moved from library/private_builtin.m, but in a significantly
rewritten form. There is also substantial new code, e.g. to handle
the extension of saved stack segments, and to manage dependencies
between subgoals in general.
Improve the documentation considerably.
Replace lists stored as Mercury data structures with lists stored
as linked structures in the usual C fashion. This allows us to use
debuggers such as ddd on these data structures, whose complexity
requires this.
Ensure that global names start with MR_.
runtime/mercury_init.h:
Explicitly include mercury_regs.h at the start. Without this,
we get an error, because now mercury_wrappers.h, which mercury_init.h
includes, also includes mercury_regs.h, but not before functions
have been declared.
runtime/Mmakefile:
Refer to the new file mercury_stacks.c (mercury_stacks.h already
existed, but the module consisted entirely of macros.)
Fix a sorting error.
scripts/{init,parse,final}_grade_options.sh-subr:
scripts/mgnuc.in:
Handle the new grade component.
tests/tabling/*
Add several new test cases that we now pass, most of which we couldn't
pass before. Also add some new test cases that we don't pass yet,
due to interactions between tabling and negated contexts.
trace/mercury_trace_internal.c:
If MR_USE_MINIMAL_MODEL is defined, add a new command to print
the generator stack. (The new command is deliberately not documented
in doc/mdb_doc yet, since (a) it is intended for developers only,
and (b) there is no way to test MR_USE_MINIMAL_MODEL in mdb_doc.)
|
||
|
|
8ddce575d4 |
Introduce two new directories, trace and browser, containing libraries
Estimated hours taken: 10
Introduce two new directories, trace and browser, containing libraries
holding the C and Mercury code of the debugger respectively. (Although
the browser directory does not have a browser in it yet, the browser
should soon become its biggest component.) Take the opportunity to
rename the existing libraries, for consistency.
After this change, the linking order becomes:
the object of the auto-generated init file
program object files
trace library (libmer_trace.a)
browser library (libmer_browser.a)
standard library (libmer_std.a)
runtime library (libmer_rt.a)
Boehm collector (libgc.a)
To avoid circularities, libraries cannot contain direct calls to
any routines that are defined in libraries (or object files) that
occur earlier in the above list. Any such calls must be made into
indirect calls via function pointers.
In particular, there was a circularity caused by the library calling
MR_trace() which invokes the tracer which in turn invokes the
library. This circularity was broken by having MR_trace(),
which is defined in the runtime, call the tracer indirectly via
a global variable named MR_trace_func_ptr. This global variable
is initialized by the auto-generated *_init.c file.
To avoid linking in the tracer even when it is not being used,
this global variable is only set to point to MR_trace_real()
if you're using a debugging grade or if c2init was invoked
with the `-t' flag. Otherwise it is set to MR_trace_fake()
which just prints an error message telling the user to
rebuild the executable with debugging enabled.
Makefile.DLLs:
Reserve random locations for the two new libraries. Whether they work
will be decided by testing on Windows.
Mmake.common.in:
Add variables naming the new directories, and create variables
naming the libraries.
Mmakefile:
Add targets for the new directories, and modify existing rules
as appropriate.
browser/Mmakefile:
Mmakefile for the new directory, modelled on library/Mmakefile.
browser/browser_library.m:
Umbrella file for the new directory, modelled on library/library.m.
{browser,library}/debugger_interface.m:
Moved this file from library to browser without change.
browser/help.m:
A new module for the help system of the debugger. Not yet used.
compiler/Mmakefile:
Update to refer to the new directories and libraries where
appropriate.
compiler/mercury_compile.m:
If we are doing tracing, then pass -t instead of -i to c2init.
compiler/modules.m:
When generating the .dep file, get the grade flags passed to c2init.
doc/Mmakefile:
Remove the special treatment of library/debugger_interface.m.
library/Mmakefile:
Update to refer to the new directories and libraries where
appropriate, and to conform to the new name of the library.
library/library.m:
Do not import debugger_interface.
profiler/Mmakefile:
Update to refer to the new directories and libraries where
appropriate.
runtime/Mmakefile:
Update to refer to the new directories and libraries where
appropriate, and to conform to the new name of the library.
Remove references to files being moved to the trace directory.
runtime/mercury_init.h:
Refer to the automatically generated dll header file by its new name
(renamed because the runtime library is renamed).
Add declarations to support the new global variable MR_trace_func_ptr.
runtime/mercury_memory_handlers.c:
runtime/mercury_memory_zones.c:
runtime/mercury_misc.c:
Remove inappropriate #includes of "mercury_trace.h", and substitute
a #include of "mercury_trace_base.h" if necessary.
{runtime,trace}/mercury_trace.[ch]:
{runtime,trace}/mercury_trace_external.[ch]:
{runtime,trace}/mercury_trace_internal.[ch]:
Move these files from the runtime to the trace directory.
The only changes are the removal from mercury_trace.h of declarations
added to runtime/mercury_trace_base.h, and the change from MR_trace
to MR_trace_real.
runtime/mercury_trace_base.[ch]:
Define MR_trace(), which does an indirect call through
MR_trace_func_ptr if the event should be traced.
Define MR_trace_fake, which just prints an error message.
Its address will be assigned to MR_trace_func_ptr if tracing
is not enabled.
Define the types needed by the signature of MR_trace.
Fix an old bug: s/MERCURY_TRACE_PERMANENT_H/MERCURY_TRACE_BASE_H/.
runtime/mercury_wrapper.[ch]:
Add the new global variable MR_trace_func_ptr.
scripts/c2init.in:
Add a new option, -t/--trace, which enables tracing by causing the
address of MR_trace_real to be assigned to MR_trace_func_ptr.
Have this option be implied by the grade. Also have the old option
-i (need initialization code) be implied by the grade, as well as by
-t.
scripts/ml.in:
Include the new libraries in the link command.
tests/debugger/Mmakefile:
Include -t instead of -i in the list of c2init options. (-t implies
-i.)
tools/bootcheck:
Copy and build the new directories as appropriate. The trace directory
is treated like the runtime, the browser directory is treated like the
library.
trace/Mmakefile:
Mmakefile for the new directory, modelled on runtime/Mmakefile.
util/mkinit.c:
Add the new option -t, as discussed above.
Mmakefile for the new directory, modelled on runtime/Mmakefile.
util/Mmakefile:
Specify -O0, since with the default optimization level, gcc on
cyclone ignores the assignment of TRUE to need_tracing when -t is
given (!!!).
|
||
|
|
3b4a652bf3 |
Add a new function MR_copy_string.
Estimated hours taken: 0.2
runtime/mercury_memory.[ch]:
Add a new function MR_copy_string.
|
||
|
|
5d33372f98 |
Fix some bugs in tabling, to enable the boyer test case to work.
Estimated hours taken: 6 Fix some bugs in tabling, to enable the boyer test case to work. runtime/mercury_tabling.h: Add a new set of macros that optionally print debugging info at tabling actions. Debugging recquires compilation with -DMR_TABLE_DEBUG and -dT in MERCURY_OPTIONS. runtime/mercury_table_any.c: Use the debugging macros. Fix two bugs, one found with their help. One is that a tagged pointer to the table giving information about remote secondary tags did not have its tag stripped before use. The other is that the extraction of local secondary tags from words was done by subtracting the tag, and not by shifting out the tag, leaving the secondary tag value too high by a factor of 4 or 8. runtime/mercury_table_any.[ch]: runtime/mercury_table_enum.[ch]: Change the order of some function arguments to be consistent with the orders in the macros that call these functions. runtime/mercury_table_enum.c: Add an optional sanity check that detects the second bug above. runtime/mercury_engine.[ch]: Add a new debug flag, MR_tabledebug. Rename the flags so they always start with MR_. runtime/mercury_wrapper.c: Allow -dT in MERCURY_OPTIONS to set MR_tabledebug. runtime/*.[ch]: Trivial changes for the new names of the debug flags. runtime/Mmakefile: Reimpose alphabetical order on the list of C files. library/private_builtin.m: Use the new debugging macros in the C code that does tabling. Expose the equivalence between ml_table, ml_subgoal_table_node etc and c_pointer. The reason is % These equivalences should be local to private_builtin. However, % at the moment table_gen.m assumes that it can use a single variable % sometimes as an ml_table and other times as an ml_subgoal_table_node % (e.g. by giving the output of table_lookup_insert_int as input to % table_have_all_ans). The proper fix would be for table_gen.m to % use additional variables and insert unsafe casts. However, this % would require significant work for no real gain, so for now % we fix the problem by exposing the equivalences to code generated % by table_gen.m. library/mercury_builtin.m: Delete the contents of this obsolete file, leaving only a pointer to builtin.m and private_builtin.m. tests/tabling/Mmakefile: Enable the boyer benchmark, since we now pass it. |
||
|
|
376f2c69af |
An initial implementation of the accurate garbage collector.
Estimated hours taken: 90 An initial implementation of the accurate garbage collector. WORK_IN_PROGRESS: Add an entry for the accurate garbage collector. library/builtin.m: library/mercury_builtin.m: library/std_util.m: runtime/mercury_tabling.h: Deep copy terms using the address of the value instead of just the value. library/io.m: Initialize the garbage collector's rootset with the globals. runtime/Mmakefile: Add new files to the Mmakefile. runtime/mercury_accurate_gc.h: runtime/mercury_accurate_gc.c: The new garbage collector. runtime/mercury_agc_debug.c: runtime/mercury_agc_debug.h: Debugging utilities for the new garbage collector. runtime/mercury_deep_copy.c: runtime/mercury_deep_copy.h: runtime/mercury_deep_copy_body.h: Put the deep copy code in mercury_deep_copy_body.h, and #include it with appropriate #defines in order to get a variant for deep_copy(), and one for agc_deep_copy(). agc_deep_copy() forwards pointers as it copies. Also, deep_copy (all variants) have been modified to take a pointer to the data to be copied, because some variants need to be able to modify it. runtime/mercury_engine.c: runtime/mercury_engine.h: Add a second heap_zone which is the to-space of the copying collector. Add a debug_heap_zone, which is used as a scratch heap for debugging. runtime/mercury_label.c: Instead of realloc(entry_table, ....) do entry_table = realloc(entry_table, ....) to avoid horrible bugs. Also, make sure the tables get initialized before looking up an entry label. runtime/mercury_imp.h: Include mercury_debug.h before most of the modules. (mercury_engine.h adds a new MemoryZone only if we are debugging accurate GC). runtime/mercury_memory.c: Setup the debug_memory_zone sizes. Remove an unnecessary prototype. runtime/mercury_memory_handlers.c: Add code to get the program counter and the stack pointer from the signal context. Call MR_schedule_agc() from default_handler() if doing accurate gc. runtime/mercury_memory_zones.c: Setup the hardzone regardless of whether redzones are used. Add some more debugging information. runtime/mercury_regorder.h: runtime/machdeps/alpha_regs.h: runtime/machdeps/i386_regs.h: Add definitions to make the real machine registers name/number for MR_sp available. runtime/mercury_trace_internal.c: runtime/mercury_trace_util.c: runtime/mercury_trace_util.h: Add MR_trace_write_variable(), which writes terms given their value and type_info. runtime/mercury_wrapper.c: runtime/mercury_wrapper.h: Change the size of the heap redzone when doing accurate GC. Use a small heap when debugging agc. runtime/mercury_debug.h: runtime/mercury_conf_param.h: Add new debugging macros and document them. runtime/mercury_type_info.c: Add const to the pointer arguments of MR_make_type_info. |
||
|
|
9cbccbd5dc |
This change adds a new extras directory, "references".
Estimated hours taken: 70 (plus whatever pets spent when he wrote the original version of this) This change adds a new extras directory, "references". This directory contains two impure reference type modules and a module that allows scoped non-backtrackable update, along with examples of using them and tests. These modules are intended to be useful when HAL is retargetted to Mercury, for implementing global variables (backtracking and non-backtracking), and may also be useful for the debugger. In order to implement these features, a new memory zone "global heap" was added to the runtime system, for a heap which is not reclaimed on failure, along with a pair of functions for copying terms to this heap. runtime/mercury_deep_copy.c: runtime/mercury_deep_copy.h: Added two functions, MR_make_permanent() and MR_make_partially_permanent(), which essentially do a deep copy of a term to the global heap. (In conservative GC grades, these functions actually do nothing). runtime/mercury_engine.c: runtime/mercury_engine.h: Added fields global_heap_zone and e_global_hp (for the global heap and its heap pointer) to the MR_mercury_engine_struct, along with appropriate initialisation, etc. Defined MR_heap_zone, MR_solutions_heap_zone, and MR_global_heap_zone for convenient access to the corresponding field of the relevant Mercury engine. runtime/mercury_memory.c: Added code for handling the size and zone size of the global heap. runtime/mercury_regorder.h: runtime/mercury_regs.h: Defined MR_global_hp (the global heap pointer for general use), along with corresponding other changes. runtime/mercury_wrapper.c: runtime/mercury_wrapper.h: Added declarations and initialisation of the size and zone_size of the global_heap. Added an entry for MR_GLOBAL_HP_RN to print_register_usage_counts() (plus missing entries for MR_SOL_HP_RN, MR_MIN_HP_REC and MR_MIN_SOL_HP_REC). New files: extras/references/Mmakefile: Mmakefile for building and testing these modules. extras/references/README: Description of contents of this directory. extras/references/global.m: A wrapper module for building a library containing the nb_reference, reference and scoped_update modules. extras/references/nb_reference.m: Implements references which are not backtracked on failure. extras/references/reference.m: Implements references which *are* backtracked on failure. extras/references/scoped_update.m: Allows nested scoping of non-backtracking references. extras/references/samples/Mmakefile: extras/references/samples/max_of.m: extras/references/samples/max_test.exp: extras/references/samples/max_test.m: An example of using a non-backtracking reference (to find the maximum of the solutions generated by a predicate), with tests. extras/references/tests/Mmakefile: extras/references/tests/ref_test.exp: extras/references/tests/ref_test.m: Some tests of references (backtracking and non-backtracking) and scoping. |
||
|
|
b65079017f |
fix a trivial bug in my previous changes.
runtime/mercury_memory.c: fix a trivial bug in my previous changes. |
||
|
|
a70b59e83c |
Add a test to find the number of words needed to represent a
configure.in:
Add a test to find the number of words needed to represent a
synchronization term.
boehm_gc/gc.h:
fix a declaration by replacing the args () with (void).
boehm_gc/solaris_pthreads.c:
add a missing include
check the return values of pthread calls.
compiler/*.m:
Add handling for the new HLDS goal type par_conj.
Add handling for the four new LLDS instructions:
init_sync_term
fork
join_and_terminate
join_and_continue
compiler/code_info.m:
add a new alternative for slot_contents - sync_term.
compiler/handle_options.m:
add .par as part of the grade
compiler/hlds_goal.m:
add the new goal type par_conj.
compiler/instmap.m:
add instmap__unify which takes a list of instmaps
and abstractly unifies them.
add unify_instmap_delta which tajes two instmap deltas
and abstractly unifies them.
compiler/llds.m:
add the new llds instructions.
compiler/mode_info.m:
add par_conj as a lock reason.
library/Makefile:
work around a bug in the solaris version pthread.h
library/benchmarking.m:
reference the stack zones from the engine structure
rather than from global variables.
library/{nc,sp}_builtin.nl:
add an op declaration for &.
library/std_util.m:
change references to global variables to references inside
the engine structure.
runtime/Mmakefile:
add mercury_thread.{c,h}
add THREADLIBS to the libraries
runtime/*.{c,h}
Remove some old junk from the previous processes/shrd-mem
changes that found their way into the repository.
Add MR_ prefixes to lots of names.
runtime/mercury_context.c:
Add init_thread_stuff for creating and initializing a
context structure for the current thread.
runtime/mercury_context.h:
add a field to the mercury context which stores the thread id
of the thread where this context originated.
add various macros for implementing the new llds instructions.
runtime/mercury_engine.c:
initialize the engine structure, rather than a bunch of globals.
runtime/mercury_engine.h:
declare the mercury_engine structure.
runtime/mercury_regorder.h:
if MR_THREAD_SAFE, and there is at least one global register
then use mr0 as a pointer to the mercury engine structure.
scripts/init_grade_options.sh-subr
add thread_safe
scripts/mgnuc.in
add THREAD_OPTS
scripts/ml.in:
add THREAD_LIBS
|
||
|
|
cd3914c609 |
More cleanup of the memory management code.
Estimated hours taken: 5 More cleanup of the memory management code. This time we clean up the signal handler setup code. runtime/Mmakefile: Add new files. runtime/mercury_memory.c: Rename setup_signal() to setup_signals(). runtime/mercury_memory_handlers.c: runtime/mercury_memory_handlers.h: Clean up signal handling. Use MR_setup_signal to setup signal handlers. Define bus_handler and segv_handler signal handlers, the old signal handlers are just one or the other (or both). runtime/mercury_prof.c: Use MR_setup_signal to setup signal handler. runtime/mercury_signal.c: runtime/mercury_signal.h: New files -- a standard interface for setting up signal handlers (a porting base, if you like). |
||
|
|
917c158436 |
Split mercury_memory.{c,h} into several files.
Estimated hours taken: 5
Split mercury_memory.{c,h} into several files. Added a few
comments about functions whose declarations have been moved into
the header files, otherwise the content is unchanged.
runtime/Mmakefile:
Add new files.
runtime/mercury_context.c:
Add a #include "mercury_memory_handlers.h" as this module
creates new zones using default_handler.
runtime/mercury_memory.c:
runtime/mercury_memory.h:
Other code (mostly code to set up the actual memory
zones we use in the Mercury runtime).
runtime/mercury_memory_handlers.c:
runtime/mercury_memory_handlers.h:
Signal handlers for memory access violations.
runtime/mercury_memory_zones.c:
runtime/mercury_memory_zones.h:
The implementation MemoryZone data type.
|
||
|
|
67d8308260 | Same as previous message. | ||
|
|
2b5f65707f |
Include some verbose progress messages in the polymorphism pass.
Estimated hours taken: 0.5 compiler/mercury_compile.m: compiler/polymorphism.m: Include some verbose progress messages in the polymorphism pass. runtime/mercury_memory.h: runtime/mercury_memory.c: runtime/mercury_misc.h: runtime/mercury_misc.c: Move checked_malloc() to mercury_memory.c, add checked_realloc(). |
||
|
|
c315607690 |
Clean up the handling of configuration macros in the runtime.
Estimated hours taken: 4 Clean up the handling of configuration macros in the runtime. runtime/mercury_conf.h.in: runtime/mercury_conf_param.h: Move the code to set configuration parameters based on the values of other configuration parameters from mercury_conf.h.in to a new file mercury_conf_param.h, because otherwise autoconf munges the code in undesirable ways (it replaces all `#undef <foo>' statements with `/* #undef <foo> */'). runtime/mercury_conf.h.in: runtime/mercury_conf_param.h: runtime/*.h: runtime/*.c: Use more meaningful names, starting with the usual `MR_' prefix, for various configuration parameters: - replace the existing configuration macros SPEED with three new macros MR_CHECK_OVERFLOW, MR_LOWLEVEL_DEBUG, and MR_DEBUG_NONDET_STACK; - rename DEBUG_GOTOS as MR_DEBUG_GOTOS, and make it implied by MR_LOWLEVEL_DEBUG; - rename DEBUG_LABELS as MR_CHOOSE_ENTRY_POINT. (But there are still many configuration parameters that don't start with `MR_', I'm afraid.) runtime/CFLAGSFILE: runtime/mercury_conf_param.h: Removed CFLAGSFILE. The documentation there was had rotted badly. I moved most of it to mercury_conf_param.h where hopefully it will stand a better chance of being kept up-to-date. I added documentation for the configuration parameters added in the last year or so. The documentation here now covers every configuration parameter that we use; please keep it that way! runtime/mercury_debug.h: Fix a bug: there was a misplaced "#endif". runtime/mercury_stack_trace.c: Fix yet another misspelling of "deterministic". |
||
|
|
aab560b8c7 |
Fix a couple of bugs where the macro USE_DLLs was referenced
Estimated hours taken: 0.5 runtime/mercury_table.c: runtime/mercury_memory.c: Fix a couple of bugs where the macro USE_DLLs was referenced without having previously done "#include mercury_conf.h". runtime/conf.h.in: Some minor improvements to the comments. |
||
|
|
bd19208eb9 |
Remove old .h files.
Estimated hours taken: 1 runtime/*.h: runtime/*.c: runtime/mercury_conf.h.in: Remove old .h files. Update #includes to refer to mercury_*.h Update #ifdef MODULE_H to be #ifdef MERCURY_MODULE_H |
||
|
|
7ce7d489a2 |
Cleaned up runtime directory.
Estimated hours taken: 2 Cleaned up runtime directory. runtime/*.c: - Renamed all .c files as mercury_*.c Some have been renamed to make their purpose clearer. call.mod -> mercury_ho_call.c runtime/*.h: - Moved contents of .h files to mercury_*.h - *.h now contain #include mercury_*.h. They be removed later. - Updated references to conf.h -> mercury_conf.h runtime/conf.h.in: - Renamed conf.h.in as mercury_conf.h.in. Didn't leave a forwarding header for this one, as conf.h was never part of the repository anyway. runtime/Mmakefile: - Convert lists to one-per-line lists. - Add mercury_accurate_gc.h to HDRS. - Remove all .mod files - Make sure runtime.init uses the ORIG_CS not MOD_CS. - Fix the rules for "clean_o" and "clean_mod_c", which used wildcards like "*.o" to remove files. The one that removed all .c files corresponding with *.mod, instead of using MOD_CS was particularly vicious. - Cope with the file renamings. configure.in: - Cope with the file renamings. |