This reduces the size of io.m a bit. The other reason for moving the
code is to allow modules that occur in a dependency cycle with io.m
to read results from io.error_util.trans_opt, whereas they may have
been prevented from reading io.trans_opt.
library/io.m:
library/io.error_util.m:
Move is_error, throw_on_error and other similar predicates to a
new undocumented submodule of io.m.
Also move the support functions/predicates used by those predicates.
Make io.make_io_error_from_system_error and
io.make_io_error_from_windows_error call the implementations in
io.error_util.m.
library/MODULES_UNDOC:
library/library.m:
List the new submodule as undocumented.
library/benchmarking.m:
library/bitmap.m:
library/dir.m:
library/io.call_system.m:
library/io.file.m:
Import the new submodule.
Also, move foreign code pieces still in io.m that belong in
previously-carved-out modules to those modules.
library/io.m:
library/io.stream_ops.m:
As above. The new private submodule contains the implementations
(helper predicates) of the operations that
- open and close streams,
- get and set offsets in those streams,
- get and set line numbers on streams,
- return the standard streams, and
- set streams as the current streams.
library/io.m:
Make some previously private includes public, to allow modules outside
of io.m to refer to the C# and Java symbols they define. These includes
are in the second, undocumented interface section of io.m.
Delete the foreign code moved to io.primitives_{read,write}.m,
as well as the foreign code moved to io.stream_ops.m.
Change {get,set}_{line_number,output_line_number}/3, which used
to be implemented directly using foreign_procs, to implement them
in terms of their arity-4 counterparts which take an explicit stream
argument, which now are in io.stream_ops.m. This can yield a slowdown,
but it should be so small as to be unmeasurable on all non-microbenchmark
workloads.
Move related code together.
Update module qualifications in C# and Java code.
Delete the second #include of mercury_library_types.h.
Delete the MR_{initial,final}_io_state macros.
library/MODULES_UNDOC:
library/library.m:
List the new submodule as undocumented.
library/io.primitives_read.m:
library/io.primitives_write.m:
Move the C, C# and Java code related to reading and writing values
of primitive types here from io.m. Put them into one foreign_decl
and one foreign_code per language.
Update module qualifications in C# and Java code.
library/benchmarking.m:
library/bitmap.m:
library/io.call_system.m:
Update module qualifications in C# and Java code.
library/stm_builtin.m:
Replace uses of the MR_{initial,final}_io_state macros with their bodies.
library/benchmarking.m:
Move the code of the predicates that print execution statistics
here from io.m.
Now that their pure replacements are here, mark the impure predicates
report_stats and report_full_memory_stats as obsolete.
library/io.m:
Replace the bodies of the predicates moved to benchmarking.m with
forwarding calls to benchmarking.m, and mark the predicates themselves
obsolete in favor of their moved versions.
NEWS:
Mention the changes above.
compiler/file_util.m:
compiler/mercury_compile_main.m:
Conform to the changes above.
In the Mercury standard library, every exported predicate or function
has (or at least *should* have) a comment that documents it, including
the meanings of its arguments. About 35-40% of these modules put `'s
(left and right quotes) around the names of the variable representing
those arguments. Some tried to do it consistently (though there were spots
with unquoted or half quoted names), while some did it only a few places.
This is inconsistent: we should either do it everywhere, or nowhere.
This diff makes it nowhere, because
- this is what the majority of the standard library modules do;
- this is what virtually all of the modules in the compiler, profiler,
deep_profiler etc directories do;
- typing all those quotes when adding new predicates in modules that
follow this convention is a pain in the ass; and because
- on many modern terminals, `' looks non-symmetrical and weird.
Likewise, the comment explaining a predicate often started with
% `predname(arguments)' returns ...
This diff deletes these quotes as well, since they add nothing useful.
This diff does leave in place quotes around code fragments, both terms
and goals, where this helps delineate the boundaries of that fragment.
Detect I/O errors that occur when reporting statistics and handle them them by
throwing io.error exceptions.
runtime/mercury_report_stats.[ch]:
Make MR_report_{standard,full_memory}_stats return zero on success
or errno if an I/O error occurs.
library/io.m:
Return a system_error indication from the report statistics predicates
and throw an io.error exception on an error.
library/benchmarking.m:
Implement report_stats/0 and report_full_memory_stats/0 by calling the
report statistics predicates from the io module rather then by using
foreign_procs. This ensures we get identical error handling behaviour
between the two modules.
Simplify the C# and Java statistics reporting methods.
Stream line number counters were not being consistently updated by the
predicates used to report statistics. This change fixes the places where these
line number counters are not being updated.
runtime/mercury_report_stats.{h,c}:
Pass the stream line number counter to the functions used to write statistics.
Update stream line number counts as statistics are printed.
library/io.m:
library/benchmarking.m:
Pass the stream line number counters to the C versions of the statistics
reporting functions. (The C# and Java versions already update the counter
correctly.)
library/benchmarking.m:
Generalise the C# implementations of report_stats so that they
can write a specified text output stream, not just standard error.
library/io.m:
Implement report_{standard,full_memory}_stats_2 for C#.
Delete some XXX predicates.
library/benchmarking.m:
Generalise the Java implementations of report_stats so that they
can write a specified text output stream, not just standard error.
library/io.m:
Implement report_{standard,full_memory}_stats_2 for Java.
Until now, all the predicates that reported statistics wrote their output
to stderr; users could not choose another stream. This diff adds ways
to report those same statistics to a stream chosen by the user, though
for now, only when targeting C.
The code for reporting statistics used to be in benchmarking.m, in the
form of a foreign_decl/foreign_code pair that declared and defined the
needed data structures and functions, and foreign_procs that called them.
All this code had stderr hard-coded as the destination stream.
As long as the output is done by C code (as opposed to the C code
constructing a big string containing all the stuff to be output),
directing the output to a user-supplied io.text_output_stream requires
converting that text_output_stream to a value of the C "FILE *" type.
This requires access to the actual definition of the io.text_output_stream
type, which is private to io.m. We could export it to benchmarking.m,
but that is undesirable. Instead, this diff moves the code that used
to be in benchmarking.m's foreign_decl/foreign_code pair to a new
module in the runtime, mercury_report_stats.[ch], which allows
foreign_procs in both benchmarking.m and io.m to use it.
We used to have
impure report_stats/0 in benchmarking.m
report_stats/2 in io.m
report_stats/3 in io.m
The difference between the two versions in io.m is a "selector" argument
that specifies which kind of stats to print. Adding a text_output_stream
argument to report_stats/2 would create report_stats/3, which clashes
with this existing name/arity pair. This diff therefore renames
io.report_stats/2 as io.report_standard_stats.
library/benchmarking.m:
Delete the code moved to mercury_report_stats.[ch]. Call
ML_report_full_memory_stats even if MR_MPROF_PROFILE_MEMORY is not defined
(see next entry).
runtime/mercury_report_stats.[ch]:
New module containing the code moved from benchmarking.m, with
ML_report_stats renamed to ML_report_standard_stats, and then
all ML_ prefixes replaced with MR_ prefixes.
There is one substantive change. In benchmarking.m, the
ML_report_full_memory_stats function was always declared, but it was
defined, and used, only inside "#ifdef MR_MPROF_PROFILE_MEMORY".
Change this so that it is always defined and used, but prints
a message about memory profiling not being available if
MR_MPROF_PROFILE_MEMORY is not defined. This is preferable to the empty
output that calls to report_full_memory_stats used to generate in such
situations.
runtime/Mmakefile:
Add the new header and source files to the lists of header and source
files respectively.
library/io.m:
Make the changes described above.
Provide specific predicates for the full_memory and tabling stats,
as well as for the standard stats. For now, these are implemented
only for C.
Fix inconsistent indentation.
NEWS:
Announce the rename of io.report_stats/2 to io.report_standard_stats/2,
but do not announce the other new predicates in io.m yet. That should
happen when they work for C# and Java as well.
compiler/file_util.m:
Conform to the change from report_stats to report_standard_stats.
runtime/.r1
library/*.m:
Delete Erlang foreign code and foreign types.
Delete documentation specific to Erlang targets.
library/deconstruct.m:
Add pragma no_determinism_warning to allow functor_number_cc/3
to compile for now.
library/Mercury.options:
Delete workaround only needed when targetting Erlang.
browser/listing.m:
mdbcomp/rtti_access.m:
Delete Erlang foreign code and foreign types.
library/LIB_FLAGS.in:
mfilterjavac/MFILTERJAVAC_FLAGS.in:
profiler/PROF_FLAGS.in:
slice/SLICE_FLAGS.in:
ssdb/SSDB_FLAGS.in:
Specify --warn-inconsistent-pred-order-clauses as a default flag
in these directories as well.
library/string.m:
Reorder code to make this module compile cleanly with
--warn-inconsistent-pred-order-clauses.
Don't export base_string_to_int_underscore to lexer.m, since
lexer.m does not use it anymore, and neither does anything else.
(The export was not publicly documented.)
library/benchmarking.m:
library/bitmap.m:
library/builtin.m:
library/map.m:
library/profiling_builtin.m:
library/rbtree.m:
library/table_builtin.m:
library/uint.m:
profiler/globals.m:
profiler/options.m:
profiler/prof_info.m:
slice/mdice.m:
slice/mslice.m:
slice/mtc_diff.m:
slice/mtc_union.m:
ssdb/ssdb.m:
Reorder code to make these modules compile cleanly with
--warn-inconsistent-pred-order-clauses.
library/Mercury.options:
Specify --no-warn-inconsistent-pred-order-clauses for the modules
that would still get warnings without this option.
browser/collect_lib.m:
browser/declarative_execution.m:
browser/dl.m:
browser/io_action.m:
compiler/make.util.m:
compiler/pickle.m:
compiler/process_util.m:
compiler/prog_event.m:
library/array.m:
library/benchmarking.m:
library/bit_buffer.m:
library/builtin.m:
library/char.m:
library/deconstruct.m:
library/dir.m:
library/erlang_rtti_implementation.m:
library/int.m:
library/int16.m:
library/int32.m:
library/int64.m:
library/int8.m:
library/io.m:
library/math.m:
library/mutvar.m:
library/private_builtin.m:
library/profiling_builtin.m:
library/rtti_implementation.m:
library/store.m:
library/string.format.m:
library/string.m:
library/table_builtin.m:
library/term_size_prof_builtin.m:
library/thread.m:
library/time.m:
library/type_desc.m:
library/uint16.m:
library/uint32.m:
library/uint64.m:
library/uint8.m:
ssdb/ssdb.m:
As above. This mostly involved two things.
The first was grouping foreign_procs by predicate instead of by language.
In a few cases, this revealed that some predicates *had* no foreign_proc
for a language, while related predicates did have one that just aborted
if called. This diff adds similar aborting foreign_procs to predicate/
language combinations that were missing them, when this seemed obviously
the right thing to do.
The second was moving pragmas about a predicate from the middle of the
block of clauses of that predicate to the start of that block.
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.
The bodies of the pure report_memory_attribution predicates were
optimised away due to a misused `promise_pure'.
library/benchmarking.m:
Swap pure and impure report_memory_attribution predicates.
Make the impure predicates be a wrapper that calls the pure
predicate in a trace goal.
One option, --warn-non-contiguous-decls, generates warnings if the
mode declarations of a predicate or function aren't in a contiguous block
immediately following the pred or func declaration. Since this is a rare
kind of "style error", this option is enabled by default.
Two options, --warn-inconsistent-pred-order-clauses and
--warn-inconsistent-pred-order-foreign-procs, warn about inconsistencies
between (a) the order in which predicates (and functions) are declared,
and (b) the order in which they are defined. The two options differ in
their scope. The latter applies to all predicates and functions defined
in the module, while the former applies only to those whose definitions
include Mercury clauses.
Since an exported predicate or function may need nonexported auxiliary
predicates and/or functions, imposing a single order the declarations and
definitions of *all* the predicates and functions in a module is not a good
idea. Instead, both options divide the predicates and functions defined
in a module two groups, the exported and the nonexported, and expect
a consistent order only within each group.
The result is output that looks like this:
time.m:021: Warning: the order of the declarations and definitions of the
time.m:021: exported predicates is inconsistent, as shown by this diff:
time.m:021:
time.m:021: --- declaration order
time.m:021: +++ definition order
time.m:021: @@ -1,7 +1,7 @@
time.m:021: predicate `clock'/3
time.m:021: -predicate `time'/3
time.m:021: predicate `times'/4
time.m:021: function `clk_tck'/0
time.m:021: +predicate `time'/3
time.m:021: function `difftime'/2
time.m:021: predicate `localtime'/4
time.m:021: function `localtime'/1
compiler/options.m:
doc/user_guide.texi:
Add the new options.
compiler/style_checks.m:
A new module that generates the new warnings if warranted.
compiler/check_hlds.m:
compiler/notes/compiler_design.html:
Include and document the new module.
compiler/mercury_compile_front_end.m:
Invoke the new module if any of the three new options is set.
compiler/hlds_pred.m:
Record the item number of every predicate, function, and mode declaration
in the module being compiled. We need this for information for the
new warnings.
compiler/hlds_module.m:
Record the context of the module declaration. We use this context
for warnings about inconsistent order, since there isn't a better one.
compiler/hlds_clauses.m:
Add a mechanism to retrieve the item numbers of a set of clauses
even if they are contiguous.
Document some old data types.
compiler/error_util.m:
Add a new phase for style checks.
compiler/accumulator.m:
compiler/add_class.m:
compiler/add_mutable_aux_preds.m:
compiler/add_pragma_tabling.m:
compiler/add_pred.m:
compiler/add_solver.m:
compiler/add_special_pred.m:
compiler/check_typeclass.m:
compiler/clause_to_proc.m:
compiler/from_ground_term_util.m:
compiler/lambda.m:
compiler/make_hlds.m:
compiler/make_hlds_passes.m:
compiler/mercury_compile.m:
compiler/par_loop_control.m:
compiler/polymorphism.m:
compiler/stm_expand.m:
compiler/table_gen.m:
compiler/unify_proc.m:
Conform the changes to the HLDS above.
compiler/typecheck_errors.m:
Fix style of error messages.
library/array2d.m:
library/assoc_list.m:
library/benchmarking.m:
library/bit_buffer.write.m:
library/bool.m:
library/builtin.m:
library/construct.m:
library/cord.m:
library/counter.m:
library/float.m:
library/injection.m:
library/lazy.m:
library/lexer.m:
library/ops.m:
library/private_builtin.m:
library/profiling_builtin.m:
library/prolog.m:
library/queue.m:
library/rational.m:
library/require.m:
library/stack.m:
library/std_util.m:
library/store.m:
library/thread.semaphore.m:
library/tree234.m:
library/univ.m:
library/version_store.m:
Move declarations or definitions around to avoid some of the warnings
that we can now generate. (There are many more left.)
Make some minor style improvements in the process.
tests/warnings/inconsistent_pred_order.{m,exp}:
tests/warnings/non_contiguous_decls.{m,exp}:
New test cases to test the new options. They are both copies of
tests/benchmarks/queens.m, with intentionally-screwed-up style.
tests/warnings/Mmakefile:
Enable the new test cases.
tests/warnings/Mercury.options:
Specify the options being tested for the new test cases.
tests/benchmarks/queens.m:
Bring the style of this module up to date (before copying it).
tests/invalid/mode_decl_in_wrong_section.err_exp:
Expect the warnings we now generate.
As I upgraded the collector last week I noticed that we no-longer need to
run a garbage collection event in order to calculate memory attribution.
This patch makes running a collection optional.
library/benchmarking.m:
runtime/mercury_heap_profile.c:
runtime/mercury_heap_profile.h:
Add an extra parameter to the Mercury predicates and C procedures to say
whether a collection should occur. The Mercury predicates were
duplicated to preserve the old behaviour / compatibility.
GC_stackbottom, GC_gc_no and GC_dont_gc are now deprecated. These changes
use new options in the API where possible.
Update scripts to copy the boehm_gc and libatomic_ops directories correctly.
Pass Boehm GC the correct flags for thread support
Update documentation regarding the version of Boehm GC.
runtime/mercury_wrapper.c:
Don't use the deprecated GC_dont_gc variable.
library/benchmarking.m:
Use GC_get_stackbottom() to get the bottom of stack and GC_get_gc_no()
to get the number of collections so far.
util/mkinit.c:
Do not explicitly set GC_stackbottom anymore, except on AIX where it
cannot be found automatically.
scripts/prepare_install_dir.in:
tools/bootcheck:
tools/build_srcdist:
Add some missing files present in Boehm GC 7.4.2 that wern't present
earlier and remove some old ones.
Coby and link the libatomic_ops directory correctly.
.README.in:
bindist/bindist.README:
Update documentation regarding the version of Boehm GC.
configure.ac:
Something in Boehm GC's build system has changed and we must now pass
-DGC_THREADS whenever building threadsafe versions of BOehm GC. This is now
done using the BOEHM_MISC_CFLAGS_FOR_THREADS autoconf variable, which has
been renamed to BOEHM_CFLAGS_FOR_THREADS now that it is more generally used.
Boehm GC no longer (or perhaps never did) require developers to specify the
type of threading to use, eg -DGC_LINUX_THREADS rather than -DGC_THREADS.
With the exception of win32-pthreads. We now pass -DGC_THREADS whereever
possible.
Mmake.common.in:
Rename BOEHM_MISC_CFLAGS_FOR_THREADS.
As Tomas By's recent emails suggest, this support is doing more harm than good,
by falsely implying to people that MPS is a viable alternative to the Boehm
collector. The MPS collector was only ever experimental, and never performed
as well as Boehm. MPS isn't even in the git repository on git hub. It was
stored in a separate CVS repository on mundula, and (as far as I know)
wasn't carried over to github. The code of MPS was last touched a long time
ago; I would be surprised if it worked on today's systems without changes.
Mmake.common.in:
Mmake.workspace:
RESERVED_MACRO_NAMES:
boehm_gc/Mmakefile:
compiler/add_pragma.m:
compiler/compile_target_code.m:
compiler/globals.m:
compiler/handle_options.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/mlds_to_c.m:
compiler/options.m:
compiler/peephole.m:
doc/user_guide.texi:
library/benchmarking.m:
runtime/Mmakefile.m:
runtime/mercury.h:
runtime/mercury_conf_param.h:
runtime/mercury_grade.h:
runtime/mercury_heap.h:
runtime/mercury_init.h:
runtime/mercury_memory.h:
runtime/mercury_wrapper.[ch]:
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/mgnuc.in:
scripts/ml.in:
scripts/parse_grade_options.sh-subr:
util/mkinit.c:
Remove all references to MPS.
library/benchmarking.m:
library/bit_buffer.m:
library/exception.m:
library/gc.m:
library/io.m:
library/library.m:
library/thread.m:
library/time.m:
Add `thread_safe' or `not_thread_safe' to foreign procs
where it is clear which is correct.
Branches: main, 11.07 (maybe)
Avoid warnings from MSVC concerning assignments from uninitialized variables.
These assignments arise due to the assignment of the initial I/O state to the
final I/O state in foreign_proc bodies. In low-level C grades this leads to
code like the following:
{
MR_Word IO0;
MR_Word IO;
...
IO = IO0;
}
Even though IO is itself unused, MSVC still emits a warning about the
assignment (many hundreds of warnings when the io module is opt-imported).
To avoid this, use don't-care variables for the I/O state in foreign procs
and don't include references to the I/O state in their bodies at all.
(We already did this in some places but not others.)
library/benchmarking.m:
library/dir.m:
library/io.m:
library/par_builtin.m:
library/stm_builtin.m:
library/thread.semaphore.m:
library/time.m:
compiler/make.util.m:
compiler/process_util.m:
Make the above change.
Delete the MR_update_io macro that is defined in a couple of spots.
library/io.m:
Unrelated change: s/MR_CONSERVATIVE_GC/MR_BOEHM_GC/ in a spot
since the former does not imply the later and the code that is
protecting is Boehm GC specific.
tests/debugger/poly_io_retry2.m:
Conform the the above change.
Branches: main
Update the handling of purity in some standard library code.
library/type_desc.m:
For the predicate make_type/2.:
- use a promise_equivalent_clauses/1 pragma in place of a
promise_pure pragma.
- attach the purity information using foreign_proc attributes.
- group all the clauses for the (in, in) = out mode together.
library/benchmarking.m:
library/io.m:
Use promise_semipure foreign_proc attributes in place of
promise_semipure pragmas.
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.
Branches: main
library/io.m:
Always use UTF-8 encoding without byte-order marks, for text streams.
Do not use `System.Encoding.Default', which could be an 8-bit character
encoding or UTF-8 with BOM.
Rename `ML_file_encoding_kind' to `ML_line_ending_kind'.
Delete unused predicate `io.write_bytes_2'.
library/rtti_implementation.m:
library/type_desc.m:
Implement comparison of pseudo_type_infos.
Implement deconstruction of foreign enums.
library/benchmarking.m:
Partially implement `report_stats' in C#, and make
`report_full_memory_stats' not abort.
library/string.m:
Make `c_pointer_to_string' handle null pointers in C#.
Implement C# version of `semidet_from_rev_char_list'.
library/thread.m:
Add C# implementations of `can_spawn' and `yield'.
library/dir.m:
Delete unneeded foreign_exports.
log_threadscope_message/3 allows programmers to post message events to
threadsope. This can be used to help them identify parts of their program
when looking at the events generated by threadscope.
library/benchmarking.m:
Create new log_threadscope_message/3 predicate.
runtime/mercury_threadscope.c:
runtime/mercury_threadscope.h:
Create MR_threadscope_post_log_msg() to support the logging of arbitrary
messages.
This change set creates a new value 'hgc' for the garbage collector grade
component. This enables a new garbage collector included with the runtime
system. Note that this garbage collector is experimental and this grade does
not work yet.
This change set represents work done by both myself and Ralph Becket.
runtime/mercury_hgc.c:
runtime/mercury_hgc.h:
Include the new garbage collector.
runtime/mercury_expanding_array.h:
This new header file provides a template for a type safe expanding array,
it is used by HGC.
runtime/Mmakefile:
Include the new modules in the runtime directory mercury_hgc.[ch] and
mercury_expanding_array.h.
Sort the lists of source files and header files.
compiler/globals.m:
Include 'hgc' in the options for which garbage collector to use.
compiler/handle_options.m:
Handle the new 'hgc' value for the garbage collector type.
compiler/options.m:
Print out information about the new 'hgc' option in the --help text of the
compiler.
compiler/compile_target_code.m:
Pass the -DMR_HGC option to the C compiler for hgc grades.
compiler/add_pragma.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/mlds_to_c.m:
compiler/peephole.m:
Conform to changes in globals.m.
library/benchmarking.m:
Fix a use of MR_CONSERVATIVE_GC that should have been MR_BOEHM_GC.
robdd/bryant.h:
Include the mercury_hgc.h header file when MR_HGC is defined.
runtime/mercury_init.h:
runtime/mercury_heap.h:
Include mercury_hgc.h when MR_HGC is defined.
runtime/mercury_memory_zones.c:
Use mercury_hgc_add_roots_range when appropriate.
runtime/mercury_wrapper.c:
Include initialisation code for HGC.
util/mkinit.c:
Include a call to mercury_hgc_set_stack_bot in init files in the HGC grade.
runtime/mercury_conf_param.h:
runtime/mercury_grade.h:
scripts/canonical_grade.sh-subr
scripts/init_grade_options.sh-subr
scripts/mgnuc.in
scripts/ml.in
scripts/parse_grade_options.sh-subr
Add the new hgc value for the garbage collector grade component.
Branches: main
Make the Java backend not use native code to implement any standard library
procedures. The only such procedures were related to benchmarking and timing,
which aren't very important so I just make a best effort using methods that
the Java standard library provides.
library/benchmarking.m:
Implement `benchmarking.report_stats' for Java as closely as possible
without native code. Add real time output.
Add `benchmarking.ML_initialise' to remember the time when the
program starts up.
compiler/mlds_to_java.m:
Make the main wrapper call `benchmarking.ML_initialise' at startup.
library/time.m:
Implement `time.clock', `time.times', `time.clocks_per_sec',
`time.clk_tck' as closely as possible without native code.
library/Mmakefile:
Comment out commands to build and install Native.so.
java/runtime/Native.c:
Even though this is not used any more, update the function names for
the "jmercury" package prefix.
README.Java:
Update section on unimplemented procedures.
Branches: main
Put all Mercury-generated Java classes into the package `jmercury' and
runtime classes into `jmercury.runtime'. The Mercury module hierarchy is
not reflected in the package name. We name sub-module classes using
their fully-qualified module names with `__' between components, e.g.
`bit_buffer.read' produces `class bit_buffer__read'.
As all generated Java code is in the same package we don't need to package
qualify identifiers, and we don't need the hack to avoid clashing package
and class names. It also makes it easier to write Java foreign code because
generated Java class names are easier to predict from Mercury module names.
The package names are not `mercury' and `mercury.runtime' because on
case-insensitive file systems we may end up with a `mercury' directory
that could be confused with the `Mercury' directory.
compiler/java_names.m:
Delete code related to mangling package names.
Remove the extra `mercury' prefix added to standard library module
names, as it is redundant with `jmercury'.
Change runtime package name.
compiler/mlds_to_java.m:
Make generated code follow the new packaging scheme.
Don't automatically import all runtime classes. It doesn't seem
necessary.
Update for new packaging scheme.
compiler/file_names.m:
Fix Java file paths for the new packaging scheme.
compiler/module_cmds.m:
compiler/rtti.m:
library/array.m:
library/backjump.m:
library/benchmarking.m:
library/bitmap.m:
library/builtin.m:
library/exception.m:
library/io.m:
library/library.m:
library/mutvar.m:
library/private_builtin.m:
library/rtti_implementation.m:
library/store.m:
library/string.m:
library/time.m:
library/type_desc.m:
java/runtime/*.java:
Rename package names.
Delete unnecessary package qualification.
compiler/mlds.m:
Add some XXXs to be fixed later.
library/Mmakefile:
Update for new packaging scheme.
Let mmake --use-mmc-make work in this directory.
Estimated hours taken: 3
Branches: main
Add a new MERCURY_OPTIONS option, --boehm-gc-calc-time. If given, we record
the time taken by garbage collections so far, and make report_stats in
library/benchmarking.m report this information.
boehm_gc/alloc.c:
Gather this information.
boehm_gc/include/gc.h:
Declare the variable that contains this information as well the
variable that controls whether this information is gathered at all.
doc/user_guide.texi:
Document the new option.
Document the renaming of another option, --munmap, that also applies
only when using the Boehm collector.
library/benchmarking.m:
Print the time taken by gc so far if we gather that information.
runtime/mercury_wrapper.c:
Enable the facility in boehm_gc/alloc.c if --boehm-gc-calc-time is
given. Rename --munmap.
Estimated hours taken: 0.5
Branches: main
library/benchmarking.m:
Implement `report_stats' and do_nothing for Erlang backend.
Add a comment that the benchmark_* procedures have a side effect on
`report_stats' in Erlang (fixing this raises its own issues).
README.Erlang:
Remove `benchmarking' and `dir' from the completely unimplemented
library modules list.
Estimated hours taken: 14
Branches: main
Add support for thread local trailing in grades that support parallel
execution. Previously the trail state for each context was copied into the
global variables defined in mercury_trail.[ch] when the context was loaded,
i.e. we had thread-local trailing in grades that did not support parallel
execution.
This change extends the runtime to support thread local trailing in the
presence of parallel execution. We do this by adding the relevant fields to
the MercuryEngine structure and redefining the abstract registers related to
trailing to make accesses to the trail state go via the relevant engine.
This also works for parallel trailing grades with the high-level C backend
because in those grades the trail state is stored in a thread-local dummy
engine and context. (The context, and its attached trail state, are created
when the thread is spawned.)
XXX the coupling between the high-level and low-level versions of the runtimes
w.r.t trailing is not good. I intend to fix it as a separate change.
(It also affects thread local mutables.)
runtime/mercury_context.h:
Fix a comment: a context's trail_zone field should be accessed
via MR_eng_context, not via the an abstract machine register.
runtime/mercury_engine.h:
Extend engines so that in parallel trailing grades they contain the
information necessary to keep track of the state of the trail.
runtime/mercury_regs.h:
In parallel grades MR_trail_ptr, MR_ticket_counter and
MR_ticket_high_water need to be accessed w.r.t the engine that the
context is being executed on.
Modify the definition of MR_restore_trail_registers() so that it
accesses the trail state via abstract registers rather than
manipulating the global variables defined in mercury_trail.[ch]
directly.
runtime/mercury_trail.[ch]:
Only define global variables to hold the trail state in non-parallel
grades.
Document the difference between parallel and non-parallel trailing
grades.
library/benchmarking.m:
In .par.tr grades, ML_report_stats should print the size of the trail
for the current context.
NEWS:
Announce support for thread local trailing in parallel grades.
Estimated hours taken: 1
Branches: main
library/benchmarking.m:
Add a mechanism for dumping out trace counts at selected stages.
compiler/options.m:
doc/user_guide.texi:
Add an option, --dump-trace-counts, to dump out trace counts at
selected stages. The selection is indicated the same way as with
the --dump-hlds option.
compiler/handle_options.m:
Make --dump-trace-counts, as well as --dump-hlds, imply compilation by
phases. Without this, stage numbers referring to the code generator
would be ineffective (since the selected stage of the HLDS would
never exist for all procedures at once).
compiler/mercury_compile.m:
Dump the trace counts file when the option calls for it.
Estimated hours taken: 1
Branches: main
Let benchmark.report_stats/0 report real times on POSIX platforms.
configure.in:
Check for time.h and gettimeofday().
runtime/mercury_conf.h.in:
Add MR_HAVE_TIME_H, MR_HAVE_GETTIMEOFDAY.
Unrelated change: add MR_HAVE_PTHREAD_H.
runtime/mercury_timing.c:
runtime/mercury_timing.h:
Add `MR_get_real_milliseconds'.
runtime/mercury_wrapper.c:
runtime/mercury_wrapper.h:
Rename MR_time_* globals to MR_user_time_*.
Add and initialise MR_real_time_* globals.
library/benchmarking.m:
Output real times in ML_report_stats().
Correct spelling of milliseconds.
java/runtime/Native.c:
java/runtime/Native.java.in:
trace/mercury_trace_declarative.c:
Correct spelling of milliseconds.