Estimated hours taken: 1
Branches: main
compiler/handle_options.m:
scripts/final_grade_options.sh-subr.m:
Remove the implication from .debug to .tr. This implication is no
longer appropriate, since we now have both .tr and .trseg versions
of trailing, and .trseg is the more useful one. However, since .tr
is still used, replacing the implication with one from .debug to
.trseg is not appropriate either.
Removing the implication yields an executable size reduction of 6.8%,
and speedup of 10%.
Estimated hours taken: 10
Branches: main
Provide access to runtime granularity control primitives.
In 2007 Zoltan implemented some runtime granularity control primitives in the
runtime system. This change provides access to them from procedures in the
par_builtin module, this is useful for testing. Recording of parallelization
decisions has also been implemented to help verify and debug this approach.
The variables that the runtime granularity control method depends upon have
been made volatile.
The runtime granularity control method is:
NumCPUs > (executable contexts + sparks on global queue).
I previously thought that this was incorrect but instead my testing code was
broken, having fixed it this works correctly.
library/par_builtin.m:
Define a procedure as above so that it can be called explicits from code,
this is useful for testing.
runtime/mercury_context.c:
runtime/mercury_context.h:
Make the variables used by the granularity control method volatile.
Provide debugging code enabled by a C macro.
Estimated hours taken: 3
Branches: main
Minor cleanups of the mode constraints code.
compiler/abstract_mode_constraints.m:
compiler/build_mode_constraints.m:
compiler/mcsolver.m:
compiler/prop_mode_constraints.m:
Add some optional diagnostic outputs.
Pass around the extra data needed by the diagnostic output.
Change the style of predicate comments to match the rest of the
compiler. Delete the redundant copies of these comments near the start
of the predicate definitions.
Give some predicates, function symbols and types less ambiguous names.
Use !StateVar ^ ... := ... syntax where applicable.
Convert some predicates from using clauses to explicit disjunctions.
Add a missing abort.
compiler/mode_constraints.m:
compiler/ordering_mode_constraints.m:
Conform to the changes above.
compiler/timestamp.m:
Add Java implementation of gmtime_to_timestamp_2.
library/io.m:
library/time.m:
Make Java implementation of io.file_modification_time return the
correct type.
library/string.m:
Make generic version of string.to_char_list avoid bounds checks
per character.
Add Java implementations of string.semidet_from_char_list,
string.append_list.
Branches: main
library/rtti_implementation.m:
Make the dummy definition of pseudo_type_info not be a dummy type,
to work around the Erlang backend to generating invalid code for this
module.
Estimated hours taken: 0.2
Branches: main
library/LIB_FLAGS.in:
library/Mercury.options:
Compile all modules in the library, not just a few, with
--optimize-constructor-last-call. I tried this last year, when
it yielded a slight slowdown on tools/speedtest; but now, it yields
a speedup of about 3.5%. The downside is not that important: a 2.8%
increase in the size of the archive file holding the Mercury standard
library.
Branches: main
The Java 5 compiler warns about a method with an array argument:
m1(Object[] args)
overriding a method declared with varargs:
m1(Object... args)
The Java 6 compiler accepts it, though I don't know if that was intended.
java/runtime/MethodPtr.java:
Don't use varargs syntax for MethodPtr.call___0_0.
library/rtti_implementation.m:
Explicitly create the Object[] arrays in foreign_procs.
Branches: main
library/Mmakefile:
Avoid problems with overlong command lines when making mer_std.jar.
Call `jar i' to add indices for jar files.
scripts/prepare_install_dir.in:
Make a copy of the java/runtime directory for the java grade.
runtime/mercury_stack_trace.c:
Handle values of type MR_Level in format strings correctly.
runtime/mercury_wrapper.c:
Check the return value of a call to system().
Branches: main
For Java backend, use static instances to represent enumeration constants
instead of dynamically allocating them. This is similar to using native Java
enums but leaves the possibility of manually assigning ordinal values, which
might be needed to make `:- pragma foreign_enum' do something sensible.
Support `:- pragma foreign_export_enum' for Java.
compiler/add_pragma.m:
Don't abort on seeing `:- pragma foreign_export_enum' for Java.
compiler/export.m:
Only output exported enums if `:- pragma foreign_export_enum' was
declared for C. Previously it ignored the language.
compiler/mlds.m:
Remember in `mlds_exported_enum' the type constructor of the exported
enumeration. This is needed for mlds_to_java.m.
Delete the `mlds_type' in `mlds_exported_enum' as it was useless.
For each exported constant, keep a `mlds_initializer' of its integer
value, instead of a `mlds_entity_defn'.
compiler/ml_type_gen.m:
compiler/mlds_to_c.m:
Conform to previous changes.
compiler/mlds_to_java.m:
Output static instances of enumeration constants. These are named
`K<n>' where <n> is the integer value of the constant.
Use the `K<n>' instances instead of dynamically allocating objects
for enumeration classes.
Don't output int fields which hold the integer value for each
enumeration constructor as they are now useless.
Output foreign exported enumerations. These are static class members
(at the module level) which point to the `K<n>' instances, giving
them predictable names for foreign code.
library/io.m:
Fix Java implementation of `io.file_type_2' which previously relied
on the representation of enums.
Branches: main
compiler/ml_closure_gen.m:
Fix a bug where `ml_gen_wrapper_arg_lvals' treated unused arguments
like output arguments. This caused the Java code generator to abort
on some code.
tests/valid/Mmakefile:
tests/valid/wrapper_arg_lvals.m:
Add test case.
Branches: main
In the Java grade, an enumeration is represented by a class with a `value'
field, alongside constants named by the user. A constant named `value'
would conflict with that field, so we rename it to `MR_value'.
compiler/ml_type_gen.m:
compiler/mlds_to_java.m:
As above.
tests/hard_coded/Mmakefile:
tests/hard_coded/value_enum.exp:
tests/hard_coded/value_enum.m:
Add test case.
Branches: main
Previously, unqualified Mercury modules would result in Java classes which
were placed in the default (unnamed) package. This is a problem as Java
doesn't allow packaged classes to import types from the unpackaged classes.
This patch gives all Java classes generated from Mercury files the "mercury."
package prefix.
mmake support for Java files is even more broken than before. It expects
Java files to be placed in the same directory but, due to the "mercury."
prefix, even classes for non-nested modules are placed in a subdirectory
called `mercury'. (The standard library can still be built with mmake using
custom rules.)
Fix creation of `.jar' files. It is not enough to package the `.class' files
that we know will be produced for each module. Nested classes generate
separate `.class' files which also need to be included.
Fix creation of the shell script that launches Java programs.
compiler/java_names.m:
Add a function to add an outermost "mercury" qualifier on module names.
Make `java_module_name' add the outermost "mercury" qualifier.
compiler/mlds_to_java.m:
Add the outermost "mercury" qualifier wherever we are writing out
a package name.
compiler/compile_target_code.m:
Fix creation of `.jar' files, as described.
Use a temporary file and @-syntax to pass the list of class files to
`jar'.
Pass `jar -C <dir> <class> -C <dir> <class> ...' as -C only affects
the argument immediately following it.
Run `jar i' to add an index to jar files.
compiler/file_names.m:
Add `get_class_dir_name' to return the directory that contains class
files.
Make `choose_file_name' work for Java files again (with package
directories) when `--use-subdirs' is disabled.
compiler/module_cmds.m:
Make `create_java_shell_script' work correctly when
`--use-grade-subdirs' is enabled, and when the main module is
packaged (as it will be).
Make Java shell scripts get the path to the class directory from $0,
and make the path to the Java interpreter overridable by an environment
variable.
Make `list_class_files_for_jar' scan the directory containing class
files, to include nested classes. Return a list of class files.
Make `list_class_files_for_jar_mmake' use `get_class_dir_name'.
library/Mmakefile:
Update hacks to build the standard library in the java grade.
mdbcomp/prim_data.m:
Delete `insert_module_qualifier' as `add_outermost_qualifier'
is equivalent.
compiler/module_qual.m:
compiler/prog_type.m:
compiler/write_deps_file.m:
Conform to changes.
Branches: main
Avoid a problem with type names and constructor names that are the same.
Java does not allow the name of a nested class to be the same as its
enclosing class. If we would violate that rule (when generating Java) then
add the prefix "mr_" to the constructor name. The user can still trigger the
problem by naming a different constructor with the "mr_" prefix.
compiler/ml_type_gen.m:
Add functions to generate constructor names that avoid the problem.
Use the functions for naming d.u. constructors.
compiler/ml_unify_gen.m:
Use the functions for naming d.u. constructors.
compiler/mlds_to_java.m:
Delete TODO.
Branches: main
Fix problems with `--track-flags' feature.
compiler/file_names.m:
Make `.track_flags' files grade-dependent, otherwise you get
unnecessary rebuilds when changing grades with
"--use-grade-subdirs --track-flags".
compiler/options.m:
doc/user_guide.texi:
Don't track build system options, otherwise you get unnecessary
rebuilds just by changing things like the `--jobs <n>' value.
library/pretty_printer.m:
Add a new doc constructor, hard_nl, which always causes a newline
(and indentation) to be printed.
Change the behaviour of the nl constructor so that a newline is
only started if it increases the amount of space on the line for
output.
tests/hard_coded/test_pretty_printer.exp:
tests/hard_coded/test_pretty_printer.m:
Update the indentation test (the new nl behaviour gives different
output).
Estimated hours taken: 0.2
Branches: main
library/pretty_printer.m:
Fix a bug in the pretty printer for arbitrary terms where it would not
start a new line for a functor that could not fit on the remainder of
the line. This made it impossible to see structure from indentation in
some cases.
tests/hard_coded/test_pretty_printer.exp:
tests/hard_coded/test_pretty_printer.m:
Update the test case.
Branches: main
Support generating Java archives (.jar) with `mmc --make'.
compiler/make.program_target.m:
compiler/compile_target_code.m:
Make `build_linked_target_2' call `compile_target_code.link' instead of
`create_java_shell_script' so that jar targets don't produce shell
scripts.
Make `compile_target_code.link' call `create_java_shell_script' so
that Java executable targets don't try to produce native executables.
compiler/module_cmds.m:
Rename `list_class_files_for_jar' to `list_class_files_for_jar_mmake'.
Add a version of `list_class_files_for_jar' where we are given the
actual list of .class files. The old version was given only a mmake
variable reference so generated a shell expression that relied on `sed'
to strip `Mercury/classs' prefixes off paths.
compiler/write_deps_file.m:
Conform to renaming.
library/string.m:
NEWS:
Add string.remove_prefix_if_present/2.
Branches: main
Make `mmc --make' support submodules when compiling to Java. Java files must
be placed in subdirectories named after the package that each class belongs to.
compiler/java_names.m
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Add a new module in the parse_tree package to contain code related to
name mangling for Java.
compiler/mlds.m:
compiler/java_util.m:
Move predicates to java_names.m.
compiler/mlds_to_java.m:
Move predicates to java_names.m.
Delete an unused predicate.
compiler/file_names.m:
Rename `erlang_module_name' as it is now also used for Java.
Make `module_name_to_file_name_general' return file names for `.java'
and `.class' files that include package subdirectories.
compiler/make.program_target.m:
Clean `.class' files on make clean.
compiler/mlds_to_il.m:
mdbcomp/prim_data.m:
Move `sym_name_to_list' to mdbcomp.prim_data.
compiler/compile_target_code.m:
compiler/elds_to_erlang.m:
Conform to changes.
library/Mmakefile:
Delete hacks that work around Mercury not writing submodule .java files
in subdirectories.
Estimated hours taken: 0.2
Branches: main
extras/lazy_evaluation/lazy.m:
Conform to current layout conventions.
Remove function modes (they're not needed these days).
Update closure cells with value cells, rather than new closures
returning the previously computed result.
Branches: main
Fix I/O problems in Java backend.
library/io.m:
Don't write to System.out directly in io.write_*/3. io.write_*/4
works with a stream layered on top of System.out, and mixing the two
sets of predicates results output coming out in the wrong order.
In MR_MercuryFileStruct.put and MR_MercuryFileStruct.write flush a
text output stream if a newline is written, otherwise the user is
liable to not see any output at all (the buffering is very
aggressive).
tests/hard_coded/csharp_test.m:
tests/hard_coded/java_test.m:
Update some old :- pragma foreign_* syntax.
Branches: main
Fix these problems with string and character literals output by the Java
backend, due to using routines originally designed for C literals:
- string literals cannot be broken into multiple segments
- \a, \v escape characters are not supported
- trigraphs are not supported so don't need to avoid them
compiler/c_util.m:
Add versions of existing predicates which take the output language as
an argument.
Fix the above problems for Java.
compiler/mlds_to_java.m:
Use the new predicates.
Estimated hours taken: 0.1
Make mmc --help generate output that can be turned into a more correct man
page. Namely the NAME section of the man page was not being generated which is
used by apropos to search for man pages. This fixes a lintian warning when
generating a debian package.
compiler/handle_options.m:
As above
Branches: main
With mmc --make, invoke `javac' once only for a linked target, passing it all
the .java files which need compiling. This is how the Java compiler is meant
to be used, and is much quicker.
compiler/make.program_target.m:
As above.
Clear cached timestamps of all `.class' files afterwards.
compiler/compile_target_code.m:
Change `compile_java_file' to accept multiple Java files.
compiler/make.dependencies.m:
Fix a bug. `.class' files should depend on the `.java' file only.
compiler/make.module_target.m:
compiler/mercury_compile.m:
Conform to changes.
runtime/mercury_stm.c
Rephrase a comment to be clearer and more accurate.
runtime/mercury_stm.h
Parenthesize an argument ofa macro in the macro body.
library/stm_builtin.m
Change (!defined MR_HIGHLEVEL_CODE) to !defined(MR_HIGHLEVEL_CODE) in
several places.
grades.
runtime/mercury_stm.h
In low level grades, define the type MR_STM_ConditionVar as an alias
for MR_STM_TransLog*, and prototype the MR_STM_condvar_signal procedure.
runtime/mercury_stm.c
MR_stm_block_thread is now conditional on MR_HIGHLEVEL_CODE.
In low level grades, MR_STM_condvar_signal is defined to allow the
transaction logs saved as "condition variables" to be "signalled".
library/stm_builtin.m
In low level grades, stm_block saves the current context in the waiter
queues of the STM variables mentioned in the context's transaction log,
then calls MR_runnext to look for more work.
calls that are made when thread debugging is not enabled.
runtime/mercury_thread.c
runtime/mercury_thread.h
Update the functions to which the debug versions of MR_LOCK,
MR_UNLOCK, MR_SIGNAL, etc, expand. Make them all return int error
codes, as do the underlying pthread_* functions, make
MR_cond_signal call pthread_cond_signal instead of
pthread_cond_broadcast, and create an analogous MR_cond_broadcast
function.
Branches: main
library/rtti_implementation.m:
Fix Java implementation of `get_subterm' to look up the name of the
field to extract, which is necessary if the field in the Mercury type
was named.
Estimated hours taken: 0.1
Branch: main
Fix two bugs in RBMM.
compiler/rbmm.region_instruction.m:
Add remove instructions for regions reachable from void variables.
runtime/mercury_region.h:
Add a missing variable declaration.
Branches: main
Introduce hacks to make it possible to build the standard library in the Java
grade, even though sub-modules aren't yet supported by the Java backend.
library/Mmakefile:
Copy submodule source files into package directories as expected by
javac, e.g. thread.mvar.java -> thread_/mvar.java
Make `jars' target include source files in package directories.
Branches: main
Make `mmc --make' work for Java grade.
compiler/make.dependencies.m:
compiler/make.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
Make `mmc --make' know to generate `.class' files.
compiler/compile_target_code.m:
Pass "-sourcepath Mercury/javas" to javac when using subdirectories.
compiler/module_cmds.m:
Make the shell script we generate to invoke `java' pass command line
arguments through to the user program. `exec' the java process.
library/Mmakefile:
Use $(ALL_JAVACFLAGS) when compiling standard library modules so
$(EXTRA_JAVACFLAGS) has its effect.
Branches: main
RTTI improvements for Java backend. io.write/3 works for some simple types
(builtin types and non-existential d.u. types).
compiler/mlds_to_java.m:
Fix problem with cyclic RTTI definitions. Initialisers could refer to
other RTTI structures which weren't yet allocated, leading to fields
being null. The fix is to allocate all top-level RTTI objects first
and initialise in a second phase.
java/runtime/DuExistInfo.java:
java/runtime/DuExistLocn.java:
java/runtime/DuFunctorDesc.java:
java/runtime/EnumFunctorDesc.java:
java/runtime/ForeignEnumFunctorDesc.java:
java/runtime/TypeClassConstraint.java:
java/runtime/TypeClassDeclStruct.java:
java/runtime/TypeClassId.java:
java/runtime/TypeCtorInfo_Struct.java:
java/runtime/TypeInfo_Struct.java:
Separate constructors into constructors for the initial allocation,
and an `init' method to fill in the fields.
java/runtime/MethodPtr.java:
Use variadic method support to simplify semidet_call_* and
result_call_* in rtti_implementation.m.
library/builtin.m:
Make Java definitions of builtin.unify/2 and builtin.compare/3 call
rtti_implementation.generic_unify and generic_compare.
library/private_builtin.m:
Add missing MR_TYPECTOR_REP_FOREIGN_ENUM{,_USEREQ} constants
for C# and Java.
library/rtti_implementation.m:
Fix and add missing Java versions of many foreign_procs.
Add more attributes to foreign_procs.
Clean up the code a bit (fewer casts and ^ field access functions).
README.Java:
Bump Java version requirement to J2SE 1.5 or higher.
Branches: main
Fix an abort when compiling private_builtin.m with the Java backend.
`--optimize-constructor-last-call' is incompatible with Java but the
declarations for the builtins that it uses are in private_builtin.m, and the
predicates were being given bodies which aren't handled by the Java backend.
compiler/add_pred.m:
If the target language is Java or Erlang, treat
`private_builtin.store_at_ref_impure' and `store_at_ref' as stubs.
They should never be called.
Set `marker_builtin_stub' on those predicates, as well as
`builtin_compound_eq' and `builtin_compound_lt'.
compiler/hlds_pred.m:
Add a new marker type `marker_builtin_stub'.
compiler/typecheck.m:
Generate stub clauses for predicates with the `marker_builtin_stub'
marker, even if `--allow-stubs' is disabled.
compiler/hlds_out.m:
compiler/intermod.m:
compiler/table_gen.m:
Conform to changes.
Branches: main
library/dir.m:
library/io.m:
Update these modules using `:- pragma foreign_export' in Java grades
to fix undefined reference errors.
library/Mercury.options:
Set `--no-halt-at-warn' on io.m for now as compilers more than a week
old will warn about the foreign_exports, even though they work.
Estimated hours taken: 10
Branch: main
Convert the parts of the runtime support for RBMM that have been implemented
fully using macros to macros that finally are expanded to function calls.
Using pure macros may improve the performance of small programs but not what
we want in general.
The function version is the default while the macros are kept for experimental
purposes. The macros can be turned on by specifying the C flag
MR_RBMM_USE_MACROS when compiling programs.
This change is the completion of Zoltan's unfinished work before.
runtime/mercury_conf_param.h:
Add MR_RBMM_USE_MACROS flag as an experimental option.
runtime/mercury_region.h:
runtime/mercury_region.c:
Implement the functions corresponding to the old macros. There is no
change in terms of algorithm.
Branches: main
compiler/make_hlds_passes.m:
Don't generate lock objects for a constant mutables in Java grade
as they won't be used.
compiler/prog_mutable.m:
Document mutable transformation for Java.
Branches: main
Add support for mutables in the java grade.
`thread_local' mutables are not yet supported.
compiler/make_hlds_passes.m:
Add support for mutables in the java grade.
compiler/mlds_to_java.m:
Make generated Java code call mutable initialisation predicates.
(General module initialisation predicates are not yet working).
compiler/elds_to_erlang.m:
Add an XXX I noticed while making the change.