Commit Graph

253 Commits

Author SHA1 Message Date
Peter Wang
fcb8ffe9db Delete mkinit_erl program.
util/.gitignore:
util/Mmakefile:
    Don't build or install the mkinit_erl program.

util/mkinit.c:
util/mkinit_common.c:
    Remove references to mkinit_erl.c.

    Delete handling of -m option (only used by mkinit_erl).

util/mkinit_erl.c:
    Delete source file.
2020-10-27 11:10:11 +11:00
Zoltan Somogyi
f7c911ab36 Bring the style of mkinit.c up to date.
Replace /* */ with //.

Generate C code with four space indentation. The existing code intended
to do this by aligning the code on four-space boundaries in mkinit.c,
but the " at the start of each string ate one position, so the generated
code lines started in columns 4, 8, 12 etc, instead of 5, 9, 13 etc.
2020-08-15 02:57:17 +10:00
Zoltan Somogyi
a06ae2c6ef Simplify the code of the mdb help system.
browser/help.m:
    Simplify the data types representing the nested structure
    of help information. Simplify the code of the predicates
    that work on that structure.

    Simplify some of the predicates, e.g. by having a search predicate
    do *just* search.

    Give types and predicates more meaningful names. Make argument order
    more suitable for state-variables. Move a predicate next to its
    only call site.

browser/declarative_user.m:
    Conform to the change in help.m.

    Replace two bools with values of bespoke types.

browser/declarative_debugger.m:
browser/declarative_oracle.m:
    Conform to the changes in help.m and declarative_user.m.

doc/generate_mdb_doc:
    Fix the vim modeline.

trace/mercury_trace_declarative.c:
trace/mercury_trace_help.c:
    Conform to the changes in the browser directory.

util/info_to_mdb.c:
    Switch from /**/ to // for comments.

    Give a macro a meaningful name.

    Fix indentation.
2020-08-14 11:04:17 +10:00
Zoltan Somogyi
b8b845a568 Fix mmakefile rules for os,cs,css,javas.
The main objective of this change is to get bootchecks in the csharp
and java grades to actually build the slice, profiler, deep_profiler
and mfilterjavac directories, which (due to the bug this diff fixes)
they weren't doing before.

However, since one side effect of this change is to eliminate
one source of annoying warnings from mmake about references to undefined
variables, a subsidiary objective is to eliminate other sources of such
warnings as well, which mostly come from the rules for making tags files.

browser/Mmakefile:
deep_profiler/Mmakefile:
library/Mmakefile:
mdbcomp/Mmakefile:
profiler/Mmakefile:
slice/Mmakefile:
ssdb/Mmakefile:
    When creating stage 3, the bootcheck builds, in each directory,
    only the files that it wants to compare against their stage 2 versions.
    This means that it wants to build all the .c, .cs or .java files,
    which it does via the cs, css and javas mmake targets.

    The correct definitions of the rules of these targets depends on
    whether mmc --make is being used or not, so we need at least two
    sets of definitions: one for mmc --make, and for no mmc --make,
    and conditionally selecting the appropriate one. The latter definition
    has the problem that it refers to mmake variables that are intended
    to be defined in .dv files created by mmc --generate-dependencies,
    but until that has been run, those mmake variables are undefined.

    Until now, the only directories that had both the mmc --make
    and the no mmc --make definitions were the ones needed to build
    the compiler. Bootchecks in the csharp and java grades, which
    always use --make make, got errors when they tried to build
    the directories that bootcheck builds after the compiler:
    the slice, profiler, deep_prof and mfilterjavac directories.

    This diff ensures that all directories we build in bootcheck
    get all both versions of the os, cs, css, and javas targets.
    In fact, they get two subversions of the no mmc --make version:
    one for use in the presence of .dv files, and one for use in their
    absence. The latter just builds the .dv files and invokes mmake
    again. This avoids one source of warnings about undefined mmake
    variables.

    To avoid another source, make the rules for tags files and their
    proxies depends on *.m instead of mmake variables such as $(mcov.ms),
    since this makes sense even before making dependencies. The only price
    is that any untracked Mercury source files in the directory have to
    either be given some other suffix, or moved somewhere else.

    Where relevant, make the mtags invocation prefer the master versions
    of files that are copied from the mdbcomp directory to other directories,
    since this is the only writeable version.

    Make the os and cs rules consistently NOT build the _init.[co] files.
    The way we use those files in bootcheck, we never need them;
    when we need them, the right target to give is the executable anyway.

    In the slice directory, don't put mcov between mtc_union and mtc_diff.

    Eliminate unnecessary duplication, e.g. of sources in rules.

    Eliminate double negatives in conditionals.

    Fix formatting.

Mmake.common.in:
bindist/Mmakefile:
bytecode/Mmakefile:
compiler/Mmakefile:
doc/Mmakefile:
grade_lib/Mmakefile:
robdd/Mmakefile:
samples/Mmakefile:
scripts/Mmakefile:
tools/Mmakefile:
trace/Mmakefile:
util/Mmakefile:
    Add "ft=make" to vim modelines. This is redundant for the files whose
    names is Mmakefile, but it is needed for Mmake.common.
2020-04-11 20:10:38 +10:00
Peter Wang
ac29292e9a Delete util/getopt.h
util/getopt.h:
    Delete this file.

util/Mmakefile:
    Pass -I../getopt to the C compiler.

util/mkinit.c:
util/mkinit_erl.c:
    Include either <unistd.h> or ../getopt/getopt.h for the declaration
    of getopt(). We don't include both in case there may be conflicting
    declarations of getopt() on some system.
2019-06-10 13:30:51 +10:00
Peter Wang
544f3bf095 Use musl getopt implementation.
LICENSE:
    Mention files derived from musl library.

runtime/process_getopt:
    Process files from ../getopt/*.[ch] to produce
    mercury_getopt.h, mercury_getopt.c, mercury_getopt_long.c.

runtime/mercury_getopt.h:
runtime/mercury_getopt.c:
runtime/mercury_getopt_long.c:
    Add files generated by process_getopt.

runtime/Mmakefile:
    Update list of source files.

util/Mmakefile:
    Use musl getopt if the system C library does not have getopt().

tests/debugger/browser_test.exp:
tests/debugger/browser_test.exp2:
tests/debugger/browser_test.exp3:
tests/hard_coded/runtime_opt.exp:
    Update expected error messages to match new getopt() output.

changed exp output
2019-06-10 13:30:49 +10:00
Peter Wang
5116277e5e Delete workaround for old gcc.
util/Mmakefile:
    As above.
2019-06-01 16:15:36 +10:00
Peter Wang
bb52ce0804 Fix unintended fallthrough.
util/mkinit.c:
util/mkinit_erl.c:
    Fix unintended fallthrough in switch (harmless).
2019-06-01 16:15:36 +10:00
Peter Wang
c33f811c37 Check availability of getopt() directly.
configure.ac:
Mmake.common.in:
    Check for availability of getopt() in the C library,
    setting the HAVE_GETOPT variable as appropriate.

    Delete GETOPT_H_AVAILABLE variable.

util/Mmakefile:
    Use getopt() if available. This can be true even without getopt.h
    as getopt() is declared in <unistd.h> according to POSIX.

util/getopt.h:
    Add a comment.
2019-05-31 18:13:54 +10:00
Peter Wang
05e9f4b2b6 Delete old code setting GC_stackbottom on AIX.
util/mkinit.c:
    Delete last reference to GC_stackbottom (which has been deprecated).
    The code to set GC_stackbottom was only left for old AIX, but is not
    required at least with AIX 7.1 on POWER, and likely hasn't been
    relevant for a long time.
2019-05-31 15:54:21 +10:00
Peter Wang
daae03f07f Delete unnecessary foreign_exported procedures.
library/io.m:
    Delete unused foreign_exported procedures.

    Add warning about using `ML_io_print_to_stream'.

runtime/mercury_init.h:
runtime/mercury_wrapper.c:
runtime/mercury_wrapper.h:
util/mkinit.c:
    Delete unused function pointer `MR_io_print_to_cur_stream'.
2016-09-28 11:10:33 +10:00
Julien Fischer
10c210dc16 Fix bug #196: binary compatibility checks in C grades do not work.
These have been broken since 2011 because GCC and clang (at least) began
optimising away the MR_grade variable we emit at the end of each generated .c
file.  The fix is to replace the MR_grade variable with an exported function
that references MR_GRADE_VAR in each generated .c file.

compiler/llds_out_file.m:
compiler/mlds_to_c.m:
util/mkinit.c:
     In each generated .c file, emit an exported function that references
     MR_GRADE_VAR.
2016-07-17 20:48:39 +10:00
Zoltan Somogyi
c6ab550db8 Remove the code for automatic initialization of solver vars.
We haven't supported it in years, and keeping it in the compiler
is just a maintenance burden and a performance problem.

mdbcomp/prim_data.m:
    Delete the spec_pred_init functor, since we don't support special
    "init" predicates anymore.

compiler/prog_data.m:
    Delete the slot in solver type details that record the name of the
    auto-initialization predicate.

compiler/prog_io_type_defn.m:
    Don't allow a type definition to specify an auto-initialization predicate.

compiler/options.m:
compiler/globals.m:
    Delete the option that allowed support for auto-initialization to be
    turned back on.

compiler/inst_match.m:
compiler/inst_util.m:
    Delete comments about auto-initialization.

compiler/mode_info.m:
    Delete the record of whether we have variables that can be
    auto-initialized (we never do anymore) and the flag that controls whether
    auto-initialization is permitted or not.

compiler/modecheck_conj.m:
    Simplify the code that modechecks conjunctions, since it no longer
    has to figure out where to insert auto-initializations of solver vars.

compiler/modecheck_goal.m:
    Delete the code that ensured that if one branch of a branched
    control structure auto-initialized a solver variable, then they
    all did.

compiler/modecheck_unify.m:
    Don't auto-initializate variables before unifications.

compiler/modecheck_util.m:
    Delete the code that auto-initialized solver variables at the ends
    of procedure bodies if this needed to be done and wasn't done before.

compiler/add_special_pred.m:
compiler/equiv_type.m:
compiler/equiv_type_hlds.m:
compiler/get_dependencies.m:
compiler/hlds_module.m:
compiler/hlds_pred.m:
compiler/modecheck_call.m:
compiler/modes.m:
compiler/module_qual.qualify_items.m:
compiler/parse_tree_out.m:
compiler/post_term_analysis.m:
compiler/smm_common.m:
compiler/special_pred.m:
compiler/term_constr_errors.m:
compiler/term_constr_initial.m:
compiler/term_util.m:
compiler/termination.m:
compiler/trace_params.m:
compiler/type_util.m:
compiler/unify_proc.m:
    Delete code that handled stuff related to auto-initialization,
    and now always take the path that would normally be taken in the
    absence of auto-initialization.

deep_profiler/read_profile.m:
runtime/mercury_layout_util.c:
runtime/mercury_stack_trace.c:
util/mdemangle.c:
    Remove code that recognized the compiler-generated name of initialization
    predicates.

tests/debugger/solver_test.m:
tests/hard_coded/solver_construction_init_test.m:
tests/hard_coded/solver_disj_inits.m:
tests/hard_coded/solver_ite_inits.m:
tests/invalid/missing_init_pred.m:
tests/invalid/zinc2mer_lib.m:
tests/valid/fz_conf.m:
tests/valid/solver_type_bug_2.m:
tests/valid/solver_type_mutable_bug.m:
    These tests tested the handling of auto-initialization, which we
    no longer support. Keep them around (and a bit more visible than
    inside the git repo) in case we need them again, but add a comment
    to each saying that the test is disabled.

tests/debugger/Mercury.options:
tests/debugger/Mmakefile:
tests/hard_coded/Mercury.options:
tests/hard_coded/Mmakefile:
tests/invalid/Mercury.options:
tests/invalid/Mmakefile:
tests/valid/Mercury.options:
tests/valid/Mmakefile:
    Disable those tests.

tests/warnings/non_term_user_special.{m,exp}:
    Part of this test tested the handling of auto-initialization;
    delete that part.

tests/warnings/Mercury.options:
    Delete the flag required by the deleted part, since we don't support it
    anymore.
2015-12-03 05:06:28 +11:00
Julien Fischer
94535ec121 Fix spelling and formatting throughout the system.
configure.ac:
browser/*.m:
compiler/*.m:
deep_profiler/*.m:
library/*.m:
ssdb/*.m:
runtime/mercury_conf.h.in:
runtime/*.[ch]:
scripts/Mmake.vars.in:
trace/*.[ch]:
util/*.c:
	Fix spelling and doubled-up words.

	Delete trailing whitespace.

	Convert tabs into spaces (where appropriate).
2015-12-02 18:46:14 +11:00
Paul Bone
eed9cc75bd Make changes required to upgrade to Boehm GC 7.4.2
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.
2015-10-01 10:26:46 +10:00
Julien Fischer
e6b669a933 Fix bug #379: warnings about deprecated feature macros with glibc 2.20.
glibc version 2.20 will emit a warning if the macros _BSD_SOURCE or
_SVID_SOURCE are defined.  (They have been deprecated in favour of the macro
_DEFAULT_SOURCE).  The C files generated by mkinit define _BSD_SOURCE,
consequently causing a warning to be emitted by the preprocessor every time you
build an executable on systems with the affected version of glibc.

Also defining _DEFAULT_SOURCE will disable the warning.

util/mkinit.c:
	Define _DEFAULT_SOURCE in order to suppress the warning described
        above.
2015-02-19 11:39:34 +11:00
Zoltan Somogyi
d33273d033 Tell vim not to expand tabs in Makefiles.
This file-specific setting will override a default setting of expandtabs
in $HOME/.vimrc.

*/Makefile:
*/Mmakefile:
    As above.

tests/hard_coded/.gitignore:
    Don't ignore the purity subdir. This ignore must have been left over
    from when purity.m was a test in hard_coded, not hard_coded/purity,
    and it ignored an executable, not a directory.
2015-01-08 22:07:29 +11:00
Zoltan Somogyi
cd72d000a8 Remove support for the MPS garbage collector.
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.
2014-08-05 15:45:33 +02:00
Peter Wang
06647ff390 Implement unify/compare of tuples in Mercury.
The hand-written C unify and compare predicates for tuples did not preserve
deep profiler invariants correctly across the recursive unify/compare of
tuple arguments.  I tried to do so, and failed.  Instead, implement the
predicates in Mercury so the compiler can perform the deep profiling
transformation on them.  Bug #3.

A micro-benchmark on my machine is about twice as fast in asm_fast.gc
after this patch, and about the same in hlc.gc.  The change to the
high-level C backend is only to reduce code duplication.

library/library.m:
	Add foreign-exported predicates to take the place of `io.init_state'
	and `io.finalize_state' as overall initialization/finalization
	predicates.

library/builtin.m:
	Add `unify_tuple', `compare_tuple', `compare_rep_tuple' predicates.

	Add initializer which sets `MR_special_pred_hooks' to point to those
	predicates.

	Delete unused predicates `call_rtti_generic_unify',
	`call_rtti_generic_compare'.

	Reorder some code.

library/io.m:
	Add `io.finalize_state' to hidden interface.

	Delete foreign exports for `io.init_state' and `io.finalize_state'.

	Reorder some code.

runtime/mercury_ho_call.c:
runtime/mercury_ho_call.h:
	Add a global variable `MR_special_pred_hooks' for the library to
	set up during initialisation.

	Add `tailcall' macros for use by `mercury_unify_compare_body.h'.
	Rename `tailcall_user_pred' to `tailcall_tci_pred'.

	Call the new unify/compare predicates in the high-level C
	backend via `MR_special_pred_hooks'.

	Delete `unify_tuples' and `compare_tuples' for the high-level C
	and call the Mercury predicates set in `MR_special_pred_hooks'.

runtime/mercury_unify_compare_body.h:
	Delete the unify and compare code for tuples in the low-level C
	backend.  Jump to the Mercury predicates set in
	`MR_special_pred_hooks' instead.

	Add some comments.

compiler/elds_to_erlang.m:
runtime/mercury_init.h:
runtime/mercury_wrapper.c:
util/mkinit.c:
	Conform to the library initializer/finalizer change.

tests/hard_coded/Mmakefile:
tests/hard_coded/tuple_test2.exp
tests/hard_coded/tuple_test2.m:
	Add test case.

NEWS:
	Announce the change.
2014-07-10 13:24:05 +10:00
Zoltan Somogyi
f6fafa150d Fix Mantis bug 314 for temp frames created by nondet procedures.
Also fix some bugs in related code, and improve the related debugging
infrastructure.

-------------------

runtime/mercury_stacks.[ch]:
   Fix bug 314 for temp frames created by nondet procedures. The fix will
   probably also work for *det* procedures that create temp frames on the
   nondet stack, but I can't think of a way to test that, because det
   procedures create such frames only in very specific circumstances,
   and I cannot think of a way to nest a recursive call inside those
   circumstances.

   The problem was that when we were creating new temp frames on
   the nondet stack, we did not check whether the current nondet stack segment
   had room for them. We now do.

   The stack trace tracing code needs to know the size of each nondet stack
   frame, since it uses the size to classify frames as temp or ordinary.
   The size is given by the difference in address between the address of the
   frame and the address of the previous frame. This difference would yield
   an incorrect size and hence an incorrect frame classification if a temp
   frame were allowed to have a frame on a different segment as its
   immediate predecessor.

   We prevent this by putting an ordinary (i.e. non-temp) frame at the bottom
   of every new nondet stack segment as a sentinel. We hand-build this frame,
   since it is not an "ordinary" ordinary frame. It is not created by a call,
   so it has no meaningful success continuation, and since it does not make
   any calls, no other frame's success continuation can point to it either.

   If backtracking reaches this sentinel frame, we use this fact to free
   all the segments beyond the one the sentinel frame is in, but keep the
   frame the sentinel frame is in, since we are likely to need it again.

   Document the reason why MR_incr_sp_leaf() does not have to check
   whether a new stack segment is needed. (See the fix to llds_out_instr.m
   below.)

runtime/mercury_stack_trace.[ch]:
   When traversing the nondet stack, treat the sentinel frame specially.
   We have to, since it is an ordinary frame (i.e. it is not a temp frame),
   but it is not an "ordinary" ordinary frame: it does not make calls,
   and hence calls cannot return to it, and it does not return to any
   other frame either. It therefore does not have the layout structures
   (label and proc) that the nondet stack traversal expects to find.

   Fix an old bug: the nondet stack traversal used a simple directional
   pointer comparison to check whether it has reached the bottom of the nondet
   stack. This is NOT guaranteed to work in the presence of stack segments:
   depending on exactly what addresses new stack segments get, a stack frame
   can have an address BELOW the address of the initial stack frame
   even if it is logically ABOVE that stack frame.

   Another old bug was that a difference between two pointers, which could
   be 64 bit, was stored in an int, which could be 32 bit.

   The nondet stack traversal code used a similar directional comparison
   to implement optionally stopping at an arbitrary point on the nondet stack.
   Fixing this facility (the limit_addr parameter of MR_dump_nondet_stack)
   while preserving reasonable efficiency would not be trivial, but it would
   also be pointless, since the facility is not actually used. This diff
   deletes the parameter instead.

   Move some loop invariant code out of its loop.

trace/mercury_trace_cmd_developer.c:
trace/mercury_trace_external.c:
   Don't pass the now-deleted parameter to mercury_stack_trace.c.

runtime/mercury_wrapper.c:
   Record the zone of the initial nondet stack frame, since the fix
   of mercury_stack_trace.c needs that info, and it is much more efficient
   to set it up just once.

tests/hard_coded/bug314.{m,exp}:
   The regression test for this bug.

tests/hard_coded/Mercury.options:
   Compile the new test case with the options it needs.

tests/hard_coded/Mmakefile:
   Enable the new test case.

-------------------

runtime/mercury_wrapper.c:
   The compiler knows the number of words in a stack frame it is creating,
   not necessarily the number of bytes (though it could put bounds on that
   from the number of tag bits). Since this size must sync with the runtime,
   change the runtime's variable holding this size to also be in words.

   Note that similar changes would also be beneficial for other sizes.

compiler/llds_out_instr.m:
   Conform to the change in mercury_wrapper.c, fixing an old bug
   (mercury_wrapper.c reserved 128 BYTES for leaf procedures, but
   llds_out_instr.m was using that space for procedures whose frames
   were up to 128 WORDS in size.)

compiler/mercury_memory.c:
   Conform to the change in mercury_wrapper.c.

-------------------

runtime/mercury_memory_zones.h:
   Instead of starting to use EVERY zone at a different offset, do this
   only for the INITIAL zones in each memory area, since only on these
   is it useful. When the program first starts up, it WILL be using
   the initial parts of the det stack, nondet stack and heap, so it is
   useful to make sure that these do not collide in the cache. However,
   when we allocate e.g. the second zone in e.g. the nondet stack, we are
   no more likely to be beating on the initial part of any segment
   of the det stack than on any other part of such segments.

   If a new debug macro, MR_DEBUG_STACK_SEGMENTS_SET_SIZE is set (to an int),
   use only that many words in each segment. This allows the segment switchover
   code to be exercised and debugged with smaller test cases.

runtime/mercury_conf_param.h:
   Document the MR_DEBUG_STACK_SEGMENTS_SET_SIZE macro.

   Convert this file to four-space indentation with tabs expanded.

-------------------

runtime/mercury_overflow.h:
   Make abort messages from overflows and underflows more useful by including
   more information.

runtime/mercury_overflow.c:
   Add a new function to help with the better abort messages.
   Since this file did not exist before, create it.

runtime/Mmakefile:
   Add the new source file to the list of source files.

-------------------

runtime/mercury_debug.[ch]:
   Fix problems with the formatting of the debugging output from existing
   functions.

   Add new functions for dumping info about memory zones.

   Factor out some common code.

   Convert the header file to four-space indentation.

-------------------

runtime/mercury_grade.c:
   Generate an error if stack segments are specified together with stack
   extension

-------------------

trace/.gitignore:
util/.gitignore:
tests/debugger/.gitignore:
   List some more files.

-------------------

runtime/mercury_context.c:
runtime/mercury_engine.[ch]:
runtime/mercury_misc.h:
compiler/notes/failure.html:
   Fix white space.
2014-04-18 02:02:35 +10:00
Julien Fischer
6851f943ec Avoid C compiler warnings that occur when using clang with -Wall.
Except where noted otherwise below most of these warnings relate to implicit
conversions between 64- and 32-bit integers or the signedness of integers
differing in spots.

library/construct.m:
	Delete an unused local variable in the implementation of get_functor_lex.

library/bitmap.m:
	The function MR_bitmap_cmp returns an MR_Integer not an int.

library/thread.semaphore.m:
	Change the count field of the ML_SEMAPHORE_STRUCT structure into
	an MR_Integer (which is what gets passed in).

trace/mercury_trace_declarative.c:
	Avoid a warning about fprintf being called where its second argument
	is not a string literal.  (In this case it can be replaced by a call
	to fputs.)

library/io.m:
mdbcomp/rtti_access.m:
trace/mercury_trace.c:
trace/mercury_trace_cmd_breakpoint.c:
trace/mercury_trace_cmd_help.c:
trace/mercury_trace_completion.m:
trace/mercury_trace_declarative.[ch]:
trace/mercury_trace_external.c:
trace/mercury_trace_internal.c:
trace/mercury_trace_source.c:
trace/mercury_trace_tables.c:
trace/mercury_trace_vars.c:
util/info_to_mdb.c:
util/mfiltercc.c:
util/mdemangle.c:
util/mkinit.c:
util/mkinit_erl.c:
util/mkinit_common.h:
util/mkinit_common.c:
	As above.
2014-03-31 00:31:36 +11:00
Julien Fischer
e9d90b2891 Avoid warnings from clang in the runtime and util directories.
runtime/mercury_stack_trace.c:
	In the function MR_dump_stack_from_layout_clique initialise the variable
	lines_dumped_so_far.  (This appears to be an actual bug.)

runtime/mercury_prof.c:
	Only define the static global in_profiling_code if either of call count
	profiling or time profiling is enabled.

runtime/mercury_context.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_profiling.c:
	Only define some local variables in grades that require them.

runtime/mercury_float.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_construct.c:
runtime/mercury_memory_zones.c:
runtime/mercury_stm.c:
runtime/mercury_trace_base.c:
runtime/mercury_type_info.c:
	Delete unused local variables.

util/mdemangle.c:
	Delete an unused static global variable.

	Use fputs in place of fprintf in a couple of places in order
	to avoid warnings about format strings that are not string literals.

	Delete an unused function.

util/mkinit.c:
util/mkinit_erl.c:
	Delete unused local variables.
2014-03-20 17:01:15 +11:00
Zoltan Somogyi
7e1cdb70aa Fix a problem that truncated mdb_doc files.
util/info_to_doc.c:
    Fix a problem that caused the generation of truncated mdb_doc files,
    and from that truncated test/debugger/mdb_command_test.inp files.
    The problem was that this program expected the info program to quote
    the initial line of each mdb command like this:

        `cmdname options ...'

    but on some machines, including mine, it quotes them like this:

        'cmdname options ...'

    i.e. with the initial as well as the final quote being a forward quote.
    This program now accepts either.

util/Mmakefile:
    Fix white space.

doc/generate_mdb_doc:
    Fix inconsistent indentation. Protect shell variable references.

doc/Mmakefile:
    Generate an error message if a similar problem occurs again
    when creating mdb_doc.

    Fix indentation.

tools/bootcheck:
    Generate an error message if a similar problem occurs again
    when copying tests/debugger/mdb_command_test.inp.
2014-01-22 09:31:37 +11:00
Julien Fischer
4e6828214d Fix bug #288.
Components of the Mercury system that were implemented directly in C were not
respecting the mmake LDFLAGS and EXTRA_LDFLAGS variables (or LD_LIBFLAGS,
EXTRA_LDLIBFLAGS for libraries).

The following patch was contributed by Keri Harris -- I have extended it
slightly to fix some omissions in the handling of .dylib files (i.e.  Mac OS X
style shared libraries).

NEWS:
    Announce the resolution of bug #288.

boehm_gc/Makefile.direct:
runtime/Mmakefile
trace/Mmakefile:
util/Mmakefile:
	Pass options set via LD_FLAGS or EXTRA_LDFLAGS (or the library
	versions) to the linker when building executables (or shared
	libraries) in these directories.
2013-06-20 18:13:41 +10:00
Julien Fischer
fc29b6c0b6 Update the list of reserved macro names.
browser/RESERVED_MACRO_NAMES:
library/RESERVED_MACRO_NAMES:
mdbcomp/RESERVED_MACRO_NAMES:
runtime/RESERVED_MACRO_NAMES:
ssdb/RESERVED_MACRO_NAMES:
trace/RESERVED_MACRO_NAMES:
	Ignore the __USE_MINGW_ANSI_STDIO macro which we
	need to define on MinGW64.

	Ignore the __GCC_HAVE_DWARF2_CFI_ASM macro which
	some versions of GCC define if -g is enabled.

compiler/.gitignore:
deep_profiler/.gitignore:
profiler/.gitignore:
slice/.gitignore:
util/.gitignore:
	Have git ignore .exe files in these directories.
2013-04-03 15:21:22 +11:00
Julien Fischer
1eda59e3da Convert .cvsignore files into .gitignore files.
Delete the empty lazy_evaluation directory from extras.

*/.cvsignore:
     Make this into .gitignore files.
     (Update them where necessary.)

extra/lazy_evalution:
    Delete this directory; its former contents were moved
    elsewhere some time ago.
2013-01-03 13:12:22 +11:00
Paul Bone
428d5a1cc2 Move the sbrk profiling code into the mercury_main() function.
The mercury_main() function is used in both standalone and library builds of
Mercury code.  However the main function where the code was was only used in
standalone programs.  The Mercury compiler is built as a library and
usually liked with main.c in the root directory, this is done so that it can
be used with GCC for the GCC backend.  I have moved the sbrk profiling code
into mercury_main so that it will be executed by the compiler.  I used this
to generate memory usage information in my thesis.

util/mkinit.c:
    As above.
2012-11-11 01:42:00 +00:00
Zoltan Somogyi
b902f5cf60 Minor style cleanups.
Estimated hours taken: 0.5
Branches: main

util/*.c:
	Minor style cleanups.
2012-06-05 16:16:47 +00:00
Peter Wang
a7bac78bf9 Suppress spurious "used but never defined" warnings from gcc 4.6+.
Branches: main, 11.07

Suppress spurious "used but never defined" warnings from gcc 4.6+.
Fixes bug #250.

util/mfiltercc.c:
	Update `drop_line' to match the error message from newer versions of
	gcc, which add a suffix to the message.

	Allow the same message for non-Mercury-generated functions to pass
	through.
2012-05-10 00:12:08 +00:00
Julien Fischer
f6dd75cc54 Make it possible to initialise the Mercury runtime using an external interface
Branches: main

Make it possible to initialise the Mercury runtime using an external interface
without providing the address of the base of the stack.
This should work on most systems and can be useful when the top-level of a
program is not written in C or C++.
(In principle, this probably always worked, so the main change here is to
document it.)

util/mkinit.c:
	If mercury_init's stackbottom argument is NULL then don't
	set GC_stackbottom.

doc/user_guide.texi:
	Extend the description of the mercury_init function in the
	standalone-interfaces section to include the above.
2012-01-11 04:58:12 +00:00
Peter Wang
6b1f89831e Let Mercury be built with a MinGW cross-compiler.
Branches: main

Let Mercury be built with a MinGW cross-compiler.

tools/configure_mingw_cross:
	Add shell script to prepare for cross-compilation.

README.MinGW-cross:
	Document how to use the shell script.

configure.in:
Mmake.common.in:
	Set a new variable CROSS_COMPILING.

	Set FULLARCH and BUILD_C_PROGS_FOR_BUILD_SYSTEM variables
	to be passed to the Boehm GC build system.

	Use $host-ar for AR when cross-compiling.

m4/mercury.m4:
	Determine gcc version with gcc -dumpversion instead of building
	a program and running it.

	Don't run test for mercury_cv_cc_type if set explicitly.

Mmake.workspace:
	Use the default c2init and mkinit when cross-compiling.
	The copies in the util directory would not be usable then.

boehm_gc/Mmakefile:
	Pass configured values of AR, RANLIB down to sub-make.

boehm_gc/Makefile.direct:
boehm_gc/build_atomic_ops.sh:
	Use configured value from Mmake.common for HOSTCC.

	Pass --host when configuring libatomic_ops.

util/Mmakefile:
	Make tools with .exe suffixes on Windows.

Mmakefile:
	Use the bootstrap compiler to build libgrades when cross-compiling.

	Conform to changed target names in the util directory.

compiler/Mmakefile:
deep_profiler/Mmakefile:
profiler/Mmakefile:
slice/Mmakefile:
	Conform to changed target names in the util directory.

Makefile:
	Clean .exe files on Windows.
2012-01-09 00:35:41 +00:00
Julien Fischer
c8b3fd0d02 Don't call the GC before it has been initialised.
Branches: main, 11.07

util/mkinit.c:
	Don't call the GC before it has been initialised.
2011-12-17 04:11:04 +00:00
Julien Fischer
608df4f718 Fix handling of Unicode command-line arguments on Windows with either MinGW or
Branches: main, 11.07

Fix handling of Unicode command-line arguments on Windows with either MinGW or
MSVC.  (For other compilers on Windows, Unicode command-line arguments are not
currently supported.)

The existing approach using GetCommandLineW and CommandLineToArgW caused the
command-line to be parsed in a weird way, e.g. for

   c:\> "C:\ws"\foo.exe

argv[0] was split in two:

   ["c:\ws", "\foo.exe"]


util/mkinit.c:
	Use wmain instead of main with MSVC; this gives us direct access
	to the wide version of the argument vector.

	Use __wgetmainargs to get the wide version of the command-line
	arguments with MinGW.  MinGW doesn't support wmain so we can't
	use that.

	Don't include shellapi.h on Windows, it's no longer required.


compiler/compile_target_code.m:
	Use the wide entry point to the C runtime with MSVC so that
	wmain is invoke isntead of main.
2011-12-16 03:38:20 +00:00
Peter Wang
f205ce9425 Support Unicode characters in command line arguments on Windows.
Branches: main, 11.07

Support Unicode characters in command line arguments on Windows.

util/mkinit.c:
	Retrieve the array of wide-character command-line argument
	strings with GetCommandLineW and CommandLineToArgvW.

	Convert the strings to UTF-8.

	Pass the array of UTF-8 argument strings to mercury_main as usual.
2011-12-14 05:12:42 +00:00
Paul Bone
a885ef1910 Add support for tracking the number, and amount of memory consumed by memory
zones.  The current and maximum values are tracked.  This support is only
compiled in if the MR_PROFILE_ZONES C macro is defined when building the
runtime system.

runtime/mercury_memory_zones.[ch]:
    As above.

runtime/mercury_wrapper.c:
    Print out the zone profiling data as the runtime is exiting.

util/mkinit.c:
    Add support for measuring the top of heap before and after executing
    mercury_main and writing out this difference.  This support is only enabled
    if the MR_PROFILE_SBRK macro is defined when compiling an application.
2011-11-23 10:53:01 +00:00
Julien Fischer
bb457814ba Don't use -O0 with Visual C.
Branches: main, 11.07

util/Mmakefile:
	Don't use -O0 with Visual C.

	Use -Fe instead of -o with Visual C.
2011-07-15 07:34:23 +00:00
Julien Fischer
6a8844236b Protect a reference to GC_stackbottom with #ifdef MR_BOEHM_GC.
Branches: main

util/mkinit.c:
	Protect a reference to GC_stackbottom with #ifdef MR_BOEHM_GC.

library/bag.m:
	Fix some inconsistent indentation.
2011-06-08 04:19:58 +00:00
Paul Bone
322feaf217 Add more threadscope instrumentation.
This change introduces instrumentation that tracks sparks as well as parallel
conjunctions and their conjuncts.  This should hopefully give us more
information to diagnose runtime performance issues.

As of this date the ThreadScope program hasn't been updated to read or
understand these new events.

runtime/mercury_threadscope.[ch]:
    Added a function and types to register all the threadscope strings from an
    array.

    Add functions to post the new events (see below).

runtime/mercury_threadscope.c:
    Added support for 5 new threadscope events.
        Registering a string so that other messages may refer to a constant
        string.

        Marking the beginning and ends of parallel conjunctions.

        Creating a spark for a parallel conjunct.

        Finishing a parallel conjunct.

    Re-arranged event IDs, I've started allocating IDs from 38 onwards for
    general purposes and 100 onwards for mercury specific events after talking
    with Duncan Coutts.

    Trimmed excess whitespace from the end of lines.

runtime/mercury_context.h:
    Post a beginning parallel conjunction message when the sync term for the
    parallel conjunction is initialized.

    Post an event when creating a spark for a parallel conjunction.

    Add a MR_spark_id field to the MR_Spark structure, these identify sparks to
    threadscope.

runtime/mercury_context.c:
    Post threadscope messages when a spark is about to be executed.

    Post a threadscope event when a parallel conjunct is completed.

    Add a missing memory barrier.

runtime/mercury_wrapper.[ch]:
    Create a global function pointer for the code that registers strings in the
    threadscope string table, this is filled in by mkinit.

    Call this function pointer immediatly after setting up threadscope.

runtime/mercury_wsdeque.[ch]:
    Modify MR_wsdeque_pop_bottom to return the spark pointer (which points onto
    the queue) rather then returning a result through a pointer and bool if the
    operation was successful.  This pointer is safe to dereference until
    MR_wsdeque_push_bottom is used.

runtime/mercury_wsdeque.c:
    Corrected a code comment.

runtime/mercury_engine.h:
    Documented some of the fields of the engine structure that hadn't been
    documented.

    Add a next spark ID field to the engine structure.

    Change the type of the engine ID field to MR_uint_least16_t

compiler/llds.m:
    Add a third field to the init_sync_term instruction that stores the index
    into the threadscope string table of the static conjunction ID.

    Add a field to the c_file structure containing the threadscope string
    table.

compiler/layout.m:
    Added a new layout array name for the threadscope string table.

compiler/layout_out.m:
    Implement code to write out the threadscope string table.

compiler/llds_out_file.m:
    Write out the threadscope string table when writing out the c_file.

compiler/par_conj_gen.m:
    Create strings that statically identify parallel conjunctions for each
    init_sync_term LLDS instruction.  These strings are added to a table in the
    !CodeInfo and the index of the string is added to the init_sync_term
    instruction.

    Add an extra instruction after a parallel conjunction to post the message
    that the parallel conjunction has completed.

compiler/global_data.m:
    Add fields to the global data structure to represent the threadscope string
    table and its current size.

    Add predicates to update and retrieve the table.

    Handle merging of threadscope string tables in global data by allowing the
    references to the strings to be remapped.

    Refactored remapping code so that a caller such as proc_gen only needs to
    call one remapping predicate after merging global data..

compiler/code_info.m:
    Add a table of strings for use with threadscope to the code_info_persistent
    type.

    Modify the code_info_init to initialise the threadscope string table fields.

    Add a predicate to get the string table and another to update it.

compiler/proc_gen.m:
    Build the containing goal map before code generation for procedures with
    parallel conjunctions in a parallel grade.  par_conj_gen.m depends on this.

    Conform to changes in code_info.m and global_data.m

compiler/llds_out_instr.m:
    Write out the extra parameter in the init_sync_term instruction.

compiler/dupelim.m:
compiler/dupproc.m:
compiler/exprn_aux.m:
compiler/global_data.m:
compiler/jumpopt.m:
compiler/livemap.m:
compiler/llds_to_x86_64.m:
compiler/mercury_compile_llds_back_end.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 changes in llds.m

compiler/opt_debug.m:
    Conform to changes in layout.m

compiler/mercury_compile_llds_back_end.m:
    Fix some trailing whitespace.

util/mkinit.c:
    Build an initialisation function that registers all the strings in
    threadscope string tables.

    Correct the layout of a comment.
2011-03-25 03:13:42 +00:00
Julien Fischer
4f159fb14d Avoid a C compiler warning on Cygwin regarding a character
Branches: main, 11.01

util/mkinit_erl.c:
	Avoid a C compiler warning on Cygwin regarding a character
	being used as an array subscript.
2011-01-04 07:43:25 +00:00
Julien Fischer
99d591f126 Avoid warnings from the mgnuc script on MinGW, Cygwin and Solaris when
Branches: main, 10.04

Avoid warnings from the mgnuc script on MinGW, Cygwin and Solaris when
compiling the source distribution.  The warnings are from the "which" command,
which is used in the mgnuc script when checking for the presence of the
mfiltercc utility program.  (If the command named in the argument to which
cannot be found on the above systems it fails rather noisily rather than just
setting a non-zero exist status as on Linux and Mac OS X.)

The solution is to ensure that mfiltercc is built before anything that requires
it.

Mmakefile:
	Add a new top-level target util_no_rt that builds those programs in the
	util directory that do not depend on anything in the runtime directory.

scripts/mgnuc.in:
scripts/mgnuc_file_opt.sh-subr:
	Add a new option, --no-filter-cc, that tells mgnuc not to bother
	filtering the warning output of the C compiler.

util/Makefile:
	Compile mfiltercc with --no-filter-cc since for the source distribution
	it obviously won't exist until we do compile it.

util/mfiltercc.c:
	Add a note at the top of this file mentioning the requirement that it
	not depend on anything in the runtime directory.
2010-12-07 07:50:29 +00:00
Julien Fischer
fedfc5c248 Final preparations for the 10.04 release.
Branches: main, 10.04

Final preparations for the 10.04 release.

NEWS:
	10.04 is no longer beta.

tools/test_mercury:
	Switch over to using the release tag.

util/.cvsignore:
	Ignore mfiltercc.
2010-07-18 08:13:53 +00:00
Julien Fischer
237dc9e5de Increase the maximum line length handled by this program since
Branches: main, 10.04

util/mfiltercc.c:
	Increase the maximum line length handled by this program since
	the current value is exceeded by the length of some warnings
	generated at -O5 --intermod-opt.
2010-07-11 14:17:57 +00:00
Peter Wang
6ad6d12260 Filter out warning message from gcc 4.x which are emitted when compiling
Branches: main, 10.04

Filter out warning message from gcc 4.x which are emitted when compiling
low-level C code using assembler labels, at least until a better fix is
available.

util/Mmakefile:
util/mfiltercc.c:
        Add a new program, mfiltercc.

compiler/options.m:
        Add `--filtercc-command' option (undocumented).

compiler/compile_target_code.m:
        Filter compiler output with mfiltercc if using assembler labels.

scripts/mgnuc.in:
        Filter compiler output with mfiltercc if using assembler labels, but
        only if mfiltercc can be found on the $PATH.  The bootstrap compiler
        may not have mfiltercc.

.mercury-compiler.spec.in:
Makefile:
README.MinGW:
bindist/Mmakefile:
bindist/bindist.Makefile.in:
scripts/mercury_config.in:
        Mention mfiltercc in various places.
2010-07-09 07:10:16 +00:00
Paul Bone
e0e251ccbf Correct the prefixes on the symbol and macro names provided by HGC.
runtime/mercury_expanding_array.h:
runtime/mercury_hgc.c:
runtime/mercury_hgc.h:
    As above.

runtime/mercury_init.h:
runtime/mercury_memory_zones.c:
runtime/mercury_wrapper.c:
util/mkinit.c:
    Conform to changes in mercury_hgc.h
2010-02-13 07:29:10 +00:00
Paul Bone
df2349838f Introduce Ralph's History based Garbage Collector (HGC).
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.
2010-02-11 04:36:11 +00:00
Zoltan Somogyi
658934fdb8 Convert this file to four-space indentation, and fix code style.
Estimated hours taken: 0.2
Branches: main

util/mdemangle.c:
	Convert this file to four-space indentation, and fix code style.
2008-11-27 02:51:27 +00:00
Zoltan Somogyi
4083906e33 MERCURY_OPTIONS is a crude way to give options to Mercury programs, since it
Estimated hours taken: 1
Branches: main

MERCURY_OPTIONS is a crude way to give options to Mercury programs, since it
applies to all Mercury programs, even though we often want to give options to
only one specific Mercury program. (For example, we may want to give it only
to a test program's executable, and not to the invocation of the compiler
that generates it.) This diff makes the runtime system, when executing a
program named "progname", look for and process the environment variable
whose name is "MERCURY_OPTIONS-progname". This allows options to be given
at runtime to only one specific program.

runtime/mercury_wrapper.c:
	Make the change described above.

runtime/mercury_wrapper.h:
	Fix some obsolete documentation, and add some up-to-date documentation.

doc/user_guide.texi:
	Document the change.

util/mkinit.c:
	Fix indentation.
2008-05-21 02:48:59 +00:00
Zoltan Somogyi
2dc982cfe4 Make a representation of the program available to the deep profiler.
Estimated hours taken: 50
Branches: main

Make a representation of the program available to the deep profiler. We do
this by letting the user request, via the option "--deep-procrep-file"
in MERCURY_OPTIONS, that when the Deep.data file is written, a Deep.procrep
file should be written alongside it.

The intended use of this information is the discovery of profitable
parallelism. When a conjunction contains two expensive calls, e.g. p(...) and
q(...) connected by some shared variables, the potential gain from executing
them in parallel is limited by how early p produces those variables and how
late q consumes them, and knowing this requires access to the code of p and q.

Since the debugger and the deep profiler both need access to program
representations, put the relevant data structures and the operations on them
in mdbcomp. The data structures are significantly expanded, since the deep
profiler deals with the whole program, while the debugger was interested only
in one procedure at a time.

The layout structures have to change as well. In a previous change, I changed
proc layout structures to make room for the procedure representation even in
non-debugging grades, but this isn't enough, since the procedure representation
refers to the module's string table. This diff therefore makes some parts of
the module layout structure, including of course the string table, also
available in non-debugging grades.

configure.in:
	Check whether the installed compiler can process switches on foreign
	enums correctly, since this diff depends on that.

runtime/mercury_stack_layout.[ch]:
runtime/mercury_types.h:
	Add a new structure, MR_ModuleCommonLayout, that holds the part of
	the module layout that is common to deep profiling and debugging.

runtime/mercury_deep_profiling.[ch]:
	The old "deep profiling token" enum type was error prone, since at
	each point in the data file, only a subset was applicable. This diff
	breaks up the this enum into several enums, each consisting of the
	choice applicable at a given point.

	This also allows some of the resulting enums to be used in procrep
	files.

	Rename some enums and functions to avoid ambiguities, and in one case
	to conform to our naming scheme.

	Make write_out_proc_statics take a second argument. This is a FILE *
	that (if not NULL) asks write_out_proc_statics to write the
	representation of the current module to specified stream.

	These module representations go into the middle part of the program
	representation file. Add functions to write out the prologue and
	epilogue of this file.

	Write out procedure representations if this is requested.

	Factor out some code that is now used in more than one place.

runtime/mercury_deep_profiling_hand.h:
	Conform to the changes to mercury_deep_profiling.h.

runtime/mercury_builtin_types.c:
	Pass the extra argument in the argument lists of invocations of
	write_out_proc_statics.

runtime/mercury_trace_base.[ch]:
	Conform to the name change from proc_rep to proc_defn_rep in mdbcomp.

runtime/mercury_grade.h:
	Due to the change to layout structures, increment the binary
	compatibility version numbers for both debug and deep profiling grades.

runtime/mercury_wrapper.[ch]:
	Provide two new MERCURY_OPTION options. The first --deep-procrep-file,
	allows the user to ask for the program representation to be generated.
	The second, --deep-random-write, allows tools/bootcheck to request that
	only a fraction of all program invocations should generate any deep
	profiling output.

	The first option will be documented once it is tested much more fully.
	The second option is deliberately not documented.

	Update the type of the variable that holds the address of the
	(mkinit-generated) write_out_proc_statics function to accept the second
	argument.

util/mkinit.c:
	Pass the extra argument in the argument list of write_out_proc_statics.

mdbcomp/program_representation.m:
	Extend the existing data structures for representing a procedure body
	to represent a procedure (complete with name), a module and a program.
	The name is implemented as string_proc_label, a form of proc_label that
	can be written out to files. This replaces the old proc_id type the
	deep profiler.

	Extend the representation of switches to record the identity of the
	variable being switched on, and the cons_ids of the arms. Without the
	former, we cannot be sure when a variable is first used, and the latter
	is needed for meaningful prettyprinting of procedure bodies.

	Add code for reading in files of bytecodes, and for making sense of the
	bytecodes themselves. (It is this code that uses foreign enums.)

mdbcomp/prim_data.m:
	Note the relationship of proc_label with string_proc_label.

mdbcomp/rtti_access.m:
	Add the access operations needed to find module string tables with the
	new organization of layout structures.

	Provide operations on bytecodes and string tables generally.

trace/mercury_trace_cmd_browsing.c:
	Conform to the change to mdbcomp/program_representation.m.

compiler/layout.m:
	Add support for a MR_ModuleCommonLayout.

	Rename some function symbols to avoid ambiguities.

compiler/layout_out.m:
	Handle the new structure.

compiler/stack_layout.m:
	Generate the new structure and the procedure representation bytecode
	in deep profiling grades.

compiler/llds_out.m:
	Generate the code required to write out the prologue and epilogue
	of program representation files.

	Pass the extra argument in the argument lists of invocations of
	write_out_proc_statics that tells those invocations to write out
	the module representations between the prologue and the epilogue.

compiler/prog_rep.m:
	When generating bytecodes, include the new information for switches.

compiler/continuation_info.m:
	Replace a bool with a more expressive type.

compiler/proc_rep.m:
	Conform to the change to continuation_info.m.

compiler/opt_debug.m:
	Conform to the change to layout.m.

deep_profiler/mdprof_procrep.m:
	A new test program to test the reading of program representations.

deep_profiler/DEEP_FLAGS.in:
deep_profiler/Mmakefile:
	Copy the contents of the mdbcomp module to this directory on demand,
	instead of linking to it. This is necessary now that the deep profiler
	depends directly on mdbcomp even if it is compiled in a non-debugging
	grade.

	The arrangements for doing this were copied from the slice directory,
	which has long done the same.

	Avoid a duplicate include of Mmake.deep.params.

	Add the new test program to the list of programs in this directory.

Mmakefile:
	Go through deep_profiler/Mmakefile when deciding whether to do "mmake
	depend" in the deep_profiler directory. The old actions won't work
	correctly now that we need to copy some files from mdbcomp before we
	can run "mmake depend".

deep_profiler/profile.m:
	Remove the code that was moved (in cleaned-up form) to mdbcomp.

deep_profiler/dump.m:
deep_profiler/profile.m:
	Conform to the changes above.

browser/declarative_execution.m:
browser/declarative_tree.m:
	Conform to the changes in mdbcomp.

doc/user_guide.texi:
	Add commented out documentation of the two new options.

slice/Mmakefile:
	Fix formatting, and a bug.

library/exception.m:
library/par_builtin.m:
library/thread.m:
library/thread.semaphore.m:
	Update all the handwritten modules to pass the extra argument now
	required by write_out_proc_statics.

tests/debugger/declarative/dependency.exp:
	Conform to the change from proc_rep to proc_defn_rep.

tools/bootcheck:
	Write out deep profiling data only from every 25th invocation, since
	otherwise the time for a bootcheck takes six times as long in deep
	profiling grades than in asm_fast.gc.

	However, do test the ability to write out program representations.

	Use the mkinit from the workspace, not the installed one.

	Don't disable line wrapping.
2007-09-12 06:21:20 +00:00
Peter Wang
75512d9cb9 Change the representation of Mercury strings in the Erlang backend to use
Estimated hours taken: 30
Branches: main

Change the representation of Mercury strings in the Erlang backend to use
binaries instead of the conventional list of integers representation.
Binaries require much less space and provide O(1) indexing (among other
things), although some operations are faster with lists of integers.  I did
not notice much speed difference with the Mercury compiler either way, though.

The HiPE compiler seems not to treat binaries in static data structures
efficiently as it does for lists, so we stick to the list representation
for strings in RTTI data to avoid a big performance drop.

compiler/elds.m:
	Modify the ELDS to allow two string representations, elds_binary and
	elds_list_of_ints.

compiler/elds_to_erlang.m:
compiler/erl_call_gen.m:
compiler/erl_code_gen.m:
compiler/erl_code_util.m:
compiler/erl_rtti.m:
compiler/erl_unify_gen.m:
	Conform to the change in the ELDS.

library/dir.m:
library/erlang_builtin.m:
library/erlang_rtti_implementation.m:
library/io.m:
library/library.m:
library/string.m:
	Update foreign code to account for the new string representation.

	Make the io module use `raw' streams, i.e. don't spawn a separate
	process to handle the file as we have our own process as well.

	Also set read_ahead and delayed_write options to enable caching and
	reduce the number of system calls.

util/mkinit_erl.c:
	Add a comment about the string representation in _init.erl files
	for initialising environment variable values.

doc/reference_manual.texi:
	Update the documentation.
2007-08-17 02:08:40 +00:00
Peter Ross
16f040e706 Allow mkinit_erl accept the -f flag as well.
Estimated hours taken: 1
Branches: main

Allow mkinit_erl accept the -f flag as well.

util/mkinit_erl.c:
	Accept the -f flag.

util/mkinit.c:
util/mkinit_common.c:
util/mkinit_common.h:
	Move the process_file_list_file into mkinit_common.c.
2007-06-18 05:41:31 +00:00