Estimated hours taken: 13
Branches: main
Implement some library predicates for Java using JNI.
java/runtime/Native.java.in:
A new class which uses JNI to provide any native functionality
required by predicates of the standard library in Java.
So far it only provides methods relating to timing.
java/runtime/Native.c:
Source code, written in C, which implements all the native methods of
mercury.runtime.Native. Note that this implementation makes use of the
existing C implementation of the equivalent functions.
java/runtime/Mmakefile:
Rules for compiling a shared object from Native.c.
library/time.m:
Implement the following predicates for Java using Native interface:
time__c_clock/3
time__clocks_per_sec/1
time__times/7
library/benchmarking.m:
Implement the following predicates for Java using Native interface:
get_user_cpu_miliseconds/1
library/Mmakefile:
Renamed to library/Mmakefile.in, so as to have access to FULLARCH
constant.
library/Mmakefile.in:
Added rules for incorporating the Native shared object.
Estimated hours taken: 2
Branches: main
Implement library version for Java.
library/library.m:
Implement library__version in Java.
java/runtime/Constants.java.in:
File from which Constants.java is to be generated, which is the source
for a class to hold mercury-related constants, such as the library
version.
configure.in:
Added java/runtime/Constants.java to the list of files to generate.
Estimated hours taken: 5
Branches: main
Implement some library procedures for the Java back end.
library/std_util.m:
Defined the type mutvar(T) as an array of java.lang.Objects (which
will always be size 1)
Implemented the following procedures in Java:
get_registers/3
check_for_floundering/1
discard_trail_ticket/0
swap_heap_and_solutions_heap/0
partial_deep_copy/3
reset_solutions_heap/1
new_mutvar/2
get_mutvar/2
set_mutvar/2
java/runtime/VA_PseudoTypeInfo_Struct0.java:
This new file is a workaround which allows std_util.m to successfully
compile in grade Java.
Estimated hours taken: 4
Branches: main
Implement some library procedures for the Java back end.
library/dir.m:
Updated the imports so interface includes string and io, and altered
style to that of one import per line.
Defined the dir__stream foreign_type as an java.util.Iterator.
Implemented the following procedures in Java:
dir__directory_separator/0
can_implement_make_directory/0
dir__make_single_directory_2/5
dir__open_2/4
dir__close_2/5
dir__read_entry_2/6
java/runtime/VA_PseudoTypeInfo_Struct8.java:
This new file is a workaround which allows dir.m to successfully
compile in grade Java.
Estimated hours taken: 3
Branches: main
Added support for progname and exit status in grade Java.
compiler/mlds_to_java.m:
Added code to maybe_write_main_driver/5 to store the main class's name
and exit status in mercury.runtime.JavaInternal's static variables.
Also, main() now calls java.lang.System.exit() instead of returning,
since Java insists that main must have void return type.
java/runtime/JavaInternal.java:
Added static variables "progname" and "exit_status".
Estimated hours taken: 6
Branches: main
More work on the Java back-end. The standard library now compiles
in grade `java', and hello world (the version using io__write_string,
and linked against the standard library in library/*.m, not the
hand-coded one in java/library/*.java) now works!
compiler/make_hlds.m:
Ignore `pragma type_spec' declarations for the Java back-end.
This works around a problem where javac was failing to compile
some of our generated code due to it overflowing limits on
file name length for the names of the .class files for some
nested classes.
compiler/mlds_to_java.m:
Add some comments. Add myself to the "main authors" list.
library/string.m:
Provide Java definitions of string__first_char and
string__unsafe_index. (These are needed for string.append,
which is used by private_builtin.sorry.)
library/io.m:
Provide Java definitions of io__write_{string,int,char,float}/3.
java/runtime/TypeCtorInfo_Struct.java:
Fix a cut-and-paste error.
java/runtime/TypeInfo_Struct.java:
Improve the implementation of the TypeInfo_Struct(Object)
constructor so that it doesn't throw exceptions during
the initialization of the standard library.
java/runtime/FA_TypeInfo_Struct1.java:
Make this type inherit from TypeInfo_Struct.
Estimated hours taken: 10
Branches: main
Bug fixes for the Java back-end.
The standard library now almost compiles in grade java.
compiler/mlds_to_java.m:
Output Java foreign declarations before any other code,
to fix a problem with references to the TYPE_CTOR_REP
constants in library/private_builtin.m.
Fix some bugs where we were not being consistent about mangling
the module name when naming the classes used to simulate taking
procedure addresses. This bug broke Java compilation of library/char.m.
Fix some bugs where the compiler was getting confused about
which types map to array types in Java.
For MLDS casts that cast to type_info or pseudo_type_info,
generate Java constructor calls, not Java casts.
This fixes type errors in the generated Java code.
Simplify the code for hand_defined_type.
compiler/rtti.m:
Fix a bug in tc_rtti_name_java_type: map typeclass_infos to
the Java type "java.lang.Object[]", not "java.lang.Integer[]".
The latter didn't work because the elements which hold the method
addresses do not have type java.lang.Integer.
java/runtime/DuExistInfo.java:
java/runtime/NotagFunctorDesc.java:
Define constructors for these types.
java/runtime/TypeInfo_Struct.java:
Define some additional constructors for this type.
library/builtin.m:
Provide Java stub definitions of
- classes for the types func/0 and c_pointer/0;
- unify/compare preds for func, c_pointer, tuple, and void;
Define Java definitions for the additional modes of compare/3
(they just call the first mode).
library/exception.m:
Define Java versions of make_io_state and consume_io_state,
and Java stubs for throw_impl and catch_impl.
Change try_all so that it calls catch_impl, like try does,
rather than calling builtin_catch directly. This is needed
since the .NET and Java back-ends only define catch_impl,
not builtin_catch.
library/io.m:
Provide Java `pragma foreign_type' declarations for the types
array.array(T) and io.system_error. This is needed to avoid
compilation errors when building in grade `java'.
library/private_builtin.m:
Delete the Java definition of the type_info for type_info/1,
because that is generated automatically now,
after petdr's recent bug fix.
Provide Java stubs definitions of the unify/compare preds
for ref/1, heap_pointer/0, type_ctor_info, type_info,
base_typeclass_info, and typeclass_info.
Provide Java definition of dummy_var.
library/type_desc.m:
Provide Java stub definitions of
- classes for type_desc/0 and type_ctor_desc/0
- unify/compare preds for those types
library/store.m:
Define unification and comparison predicates for the store(S)
type. This is needed because the automatically generated ones
might not have the right semantics, but also because the Java
back-end generates some invalid code for the automatically
generated unification and compare predicates (the generated
code has some invalid references to "dummy_var").
Estimated hours taken: 2
Branches: main
Runtime fixes for the Java back-end.
java/runtime/DuExistLocn.java:
java/runtime/DuFunctorDesc.java:
java/runtime/DuPtagLayout.java:
Define constructors for these types.
java/runtime/MaybeResAddrFunctorDesc.java:
New file (corresponds to MR_MaybeResAddrFunctorDesc type in C).
java/runtime/MaybeResFunctorDesc.java:
New file (corresponds to MR_MaybeResFunctorDesc type in C).
java/runtime/PseudoTypeInfo.java:
Define constructors.
Make non-abstract (XXX temp work-around only).
java/runtime/TypeCtorInfo_Struct.java:
XXX Pass some parameters of the constructor as "Object",
to work around type errors in invocations of those constructors.
java/runtime/TypeFunctors.java:
java/runtime/TypeLayout.java:
Model the C unions better; use a single field, with accessor
functions that convert to each alternative, not several fields.
java/runtime/TypeclassInfo.java:
Implement as stub (previous code was just copy of TypeInfo.java).
java/runtime/VA_PseudoTypeInfo_Struct*.java:
Fix a bug: change the order of the constructor parameters
to match the way we generate code which invokes those constructors.
Estimated hours taken: 18
Branches: main
Some fixes to the Java back-end to make it support RTTI
better. The aim is to at least be able to *compile* code
that makes use of polymorphism (e.g. the Mercury standard
library!), although that aim is not yet achieved with this diff.
Getting code which actually *uses* the RTTI to work is still
a long way off...
compiler/rtti.m:
compiler/mlds_to_java.m:
Fix some bugs in the code to output RTTI type names.
compiler/mlds_to_java.m:
Output the RTTI definitions. This is needed to avoid errors
in code which references them.
Handle initializers better; in particular deal with nested
initializers properly.
Pass the current module name down to output_lval, so that we can
module-qualify data names only if they occur in a different
module. This is needed to ensure that static data defined
in other modules gets module-qualified, but local variables don't.
This also required change some places which were incorrectly
calling output_fully_qualified_name to instead call output_name.
Add comments in the generated output code when generating
"java.lang.Object", so that it is clearer what kind of object
is involved.
Add some special treatment for the types with hand-defined RTTI.
java/runtime/*.java:
Add some definitions of RTTI types, and some new constructors
for the RTTI types that were already defined.
These are currently all just stubs.
Estimated hours taken: 2
Branches: main
Delete the univ type_ctor_rep, since we haven't used it in a long time,
and add two new type_ctor_reps: one for subgoals, so that they won't have
to be treated specially when deconstructed, and one for a future type,
stable_c_pointer, which is the same as c_pointer except that it guarantees
that the entire data structure it points to, directly and indirectly is
read only, which means that its values can be tabled. The intention is
to use stable_c_pointers to represent robdds.
runtime/mercury_type_info.h:
Make the change above.
runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_ml_expand_body.h:
runtime/mercury_tabling.c:
runtime/mercury_unify_compare_body.h:
Handle the two new type_ctor_reps, and delete the code handling univs.
compiler/mlds_to_gcc.m:
java/runtime/TypeCtorRep.java:
library/private_builtin.m:
runtime/mercury_mcpp.h:
runtime/mercury_mcpp.cpp:
Update the list of type_ctor_reps, including fixing some old errors
in some files.
library/rtti_implementation.m:
Update the list of type_ctor_reps, and modify the routines that
interpret the RTTI accordingly.
Estimated hours taken: 6
Branches: main
Fix test case failures involving type_ctor_descs in .rt grades.
The cause of the failures was that the type_ctor_rep for type_ctor_descs (which
happens to be 35) does not fit into a signed 8-bit integer in .rt grades,
since those grade require 2 bits for a primary tag (3 bits on 64-bit machines).
The fix is to make the type_ctor_rep field in type_ctor_infos 16 bits in size.
To maintain alignment, this requires swapping that field with the num_ptags
field.
The second part of this change will remove the bootstrapping code and raise
the binary compatibility version number. That part cannot be committed until
this part has been installed on all our machines.
runtime/mercury_type_info.h:
Define a new version of the type_ctor_info structure with this swap
and size increase. Provide backward compatibility for bootstrapping.
runtime/mercury_mcpp.h:
library/rtti_implementation.m:
java/runtime/TypeCtorInfo_Struct.m:
Make the same change.
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/mlds_to_gcc.m:
Generate the new type_ctor_info structure.
compiler/llds_out.m:
compiler/mlds_to_c.m:
Generate a macro that selects the new version of the type_ctor_info
structure.
compiler/type_ctor_info.m:
Update the type_ctor_info version number.
Estimated hours taken: 40
Branches: main
Fix the RTTI of type_descs and type_ctor_descs. Make comparisons between
type_ctor_descs and type_ctor_infos (and therefore between type_descs and
type_infos) more predictable and consistent across backends by basing them
on programmer-visible attributes instead of accident of location in the
executable.
runtime/mercury_type_desc.[ch]:
Implement unification and comparison functions for type_ctor_descs.
(The unification and comparison functions for type_infos also double
as the unification and comparison functions for type_descs.)
Make the comparison function work on the module name, type name and
arity instead of the address of the type_ctor_info structure. This
ensures consistency across back ends.
Add some useful macros.
runtime/mercury_type_info.[ch]:
Make the comparison function on type_ctor_infos also work on module
name, type name and arity. Since this makes comparison slower, add
specialized unification functions for type_infos and type_ctor_infos.
runtime/mercury_type_info.h:
runtime/mercury_mcpp.{h,cpp}:
runtime/mercury.h:
library/private_builtin.m:
library/rtti_implementation.m:
java/runtime/TypeCtorRep.java:
compiler/mlds_to_gcc.m:
Add type_ctor_reps for type_descs and type_ctor_descs. Type_ctor_descs
definitely need it, since their representation is very low level and
not shared with anything else. Type_descs could use the type_ctor_rep
of type_infos, since type_descs and type_infos share the same
representation at the moment. However, we add a new one because
profiling cares about the conceptual distinction between type_infos
and type_descs.
library/type_desc.m:
Delete the Mercury "definition" of type_desc, because it is misleading.
Implement it as a builtin type.
runtime/mercury.[ch]:
Implement type_ctor_desc as a builtin type.
Add missing implementations of unify/compare on type_ctor_infos.
runtime/mercury_deconstruct.c:
runtime/mercury_ml_expand_body.h:
Implement deconstruction for type_descs and type_ctor_descs.
runtime/mercury_ho_call.c:
runtime/mercury_unify_compare_body.h:
Implement unify and compare for type_descs and type_ctor_descs.
Implement unify for type_infos, type_ctor_infos, type_descs and
type_ctor_descs by calling the relevant unification function,
not the relevant comparison function, since the unification
function will be faster.
runtime/mercury_deep_copy_body.h:
runtime/mercury_construct.c:
runtime/mercury_tabling.c:
Minor changes to handle type_descs and type_ctor_descs.
trace/mercury_trace_vars.c:
Enable the printing of type_descs and type_ctor_descs.
tests/debugger/type_desc_test.{m,inp,exp,exp2}:
New test case to check the printing of type_descs and type_ctor_descs.
tests/debugger/Mmakefile:
Enable the new test case.
tests/hard_coded/type_ctor_desc_manip.{m,exp}:
New test case to check the deconstruction and comparison of type_descs
and (especially) type_ctor_descs. Before this change, we got different
results for comparisons of type_ctor_descs, results that were
inconsistent with the results of comparisons of the type_descs
that the type_ctor_descs were derived from.
tests/hard_coded/Mmakefile:
Enable the new test case.
Estimated hours taken: 3
Branches: main
This change introduces some (partial) Java versions of the mercury library
which are currently needed to compile some .java files generated by the
mercury compiler for the tests/benchmarks test cases.
These additions are required temporarily for testing purposes until the
mercury library can be compiled in grade java.
mercury/java/Commit.java:
mercury/java/DuExistInfo.java:
mercury/java/DuExistLocn.java:
mercury/java/DuFunctorDesc.java:
mercury/java/DuPtagLayout.java:
mercury/java/EnumFunctorDesc.java:
mercury/java/JavaInternal.java:
mercury/java/MethodPtr.java:
mercury/java/NotagFunctorDesc.java:
mercury/java/PseudoTypeInfo.java:
mercury/java/Sectag_Locn.java:
mercury/java/TypeCtorInfo_Struct.java:
mercury/java/TypeCtorRep.java:
mercury/java/TypeFunctors.java:
mercury/java/TypeLayout.java:
mercury/java/UnreachableDefault.java:
All files that were located in the mercury/java directory have been
moved to mercury/java/runtime.
mercury/java/Makefile:
A simple Makefile to set up a couple of symbolic links so we can
just include the mercury/java directory in our CLASSPATH.
mercury/java/library/assoc_list.java:
mercury/java/library/bool.java:
mercury/java/library/builtin.java:
mercury/java/library/deconstruct.java:
mercury/java/library/enum.java:
mercury/java/library/integer.java:
mercury/java/library/io.java:
mercury/java/library/list.java:
mercury/java/library/map.java:
mercury/java/library/mer_int.java:
mercury/java/library/mr_char.java:
mercury/java/library/mr_float.java:
mercury/java/library/mr_int.java:
mercury/java/library/ops.java:
mercury/java/library/private_builtin.java:
mercury/java/library/require.java:
mercury/java/library/set.java:
mercury/java/library/std_util.java:
mercury/java/library/string.java:
mercury/java/library/term.java:
mercury/java/library/time.java:
mercury/java/library/tree234.java:
mercury/java/library/type_desc.java:
These are partial Java versions of mercury library modules. They are
very rough but will currently allow for most of the tests/benchmark
directory to run in Java.