[m-rev.] for review: work towards building the compiler in the java grade

Julien Fischer juliensf at csse.unimelb.edu.au
Wed Jan 19 02:25:01 AEDT 2011


For review by Peter Wang.

Note that there other problems with compiler/Mmakefile that prevent the
compiler from building in the java grade -- I commented out the problems
when I tested this, but since that would break the C grades, it isn't a 
fix -- I will address them separately.

The other problem I encountered in the compiler directory is that
when building the .class files, the runtime classes cannot be found;
presumably this is just a matter of passing --java-classpath to mmc
and pointing it back at the library directory?

Branches: main, 11.01

A step towards getting the compiler to build in the java (and other non-C)
grade(s).

library/Mmakefile:
 	Don't make lib_std depend on Native.so (which is currently
 	unused) in the java grade.

 	The lib_std target for the java grade *does* need to be
 	defined if mmake --use-mmc-make is being used; not the
 	other way round.

browser/Mmakefile:
 	There is no "jars" target (and in any case the standard
 	top-level in this directory works.)

compiler/Mmakefile:
 	Bump the heap size for javac since the default is not
 	sufficient.

compiler/make.util.m:
compiler/md4.m:
compiler/pickle.m:
compiler/process_util.m:
compiler/prog_events.m:
 	Provide definitions of some predicates for the non-C backends.

Julien.

Index: browser/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/browser/Mmakefile,v
retrieving revision 1.61
diff -u -r1.61 Mmakefile
--- browser/Mmakefile	26 Oct 2010 04:59:10 -0000	1.61
+++ browser/Mmakefile	18 Jan 2011 15:12:24 -0000
@@ -135,11 +135,7 @@

  .PHONY: library

-ifeq ("$(findstring java,$(GRADE))","java")
-library: jars
-else
  library: $(LIBS)
-endif

  .PHONY: depend
  depend:	MDB_FLAGS $(DEPENDS)
Index: compiler/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/Mmakefile,v
retrieving revision 1.107
diff -u -r1.107 Mmakefile
--- compiler/Mmakefile	30 Sep 2010 07:23:31 -0000	1.107
+++ compiler/Mmakefile	18 Jan 2011 15:12:24 -0000
@@ -88,6 +88,14 @@
  MCFLAGS += --linkage static
  endif

+# -Xmx256m doesn't always seem to be enough memory to build the complier.
+# This bumps up the memory when building the standard library
+# if the javac executable accepts the -J-Xmx flag, without bumping up
+# the memory requirements in general.
+ifneq ("$(findstring -J-Xmx,$(JAVACFLAGS))","")
+JAVACFLAGS   += -J-Xmx2048m
+endif
+
  #-----------------------------------------------------------------------------#

  # Rules for preprocessing `.pp' files.
Index: compiler/make.util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make.util.m,v
retrieving revision 1.83
diff -u -r1.83 make.util.m
--- compiler/make.util.m	30 Dec 2010 11:17:56 -0000	1.83
+++ compiler/make.util.m	18 Jan 2011 15:12:24 -0000
@@ -771,6 +771,9 @@
      IO = IO0;
  ").

+create_job_ctl(_, _, _, _) :-
+    unexpected($file, $pred, "non-C backend").
+
  :- pred destroy_job_ctl(job_ctl::in, io::di, io::uo) is det.

  :- pragma foreign_proc("C",
@@ -790,6 +793,9 @@
      IO = IO0;
  ").

+destroy_job_ctl(_, _, _) :-
+    unexpected($file, $pred, "non-C backend").
+
  :- pred accept_task(job_ctl::in, int::out, io::di, io::uo) is det.

  :- pragma foreign_proc("C",
@@ -820,6 +826,9 @@
      IO = IO0;
  ").

+accept_task(_, _, _, _) :-
+    unexpected($file, $pred, "non-C backend").
+
  :- pred mark_task_done(job_ctl::in, int::in, io::di, io::uo) is det.

  :- pragma foreign_proc("C",
@@ -835,6 +844,9 @@
      IO = IO0;
  ").

+mark_task_done(_, _, _, _) :-
+    unexpected($file, $pred, "non-C backend").
+
  :- pred mark_task_error(job_ctl::in, int::in, bool::in, io::di, io::uo) is det.

  :- pragma foreign_proc("C",
@@ -856,6 +868,9 @@
      IO = IO0;
  ").

+mark_task_error(_, _, _, _, _) :-
+    unexpected($file, $pred, "non-C backend").
+
  :- pred mark_abort(job_ctl::in, io::di, io::uo) is det.

  :- pragma foreign_proc("C",
@@ -871,6 +886,9 @@
      IO = IO0;
  ").

+mark_abort(_, _, _) :-
+    unexpected($file, $pred, "non-C backend").
+
  :- func make_yes_job_ctl(job_ctl) = maybe(job_ctl).
  :- pragma foreign_export("C", make_yes_job_ctl(in) = out,
      "MC_make_yes_job_ctl").
Index: compiler/md4.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/md4.m,v
retrieving revision 1.3
diff -u -r1.3 md4.m
--- compiler/md4.m	2 Jan 2011 14:37:54 -0000	1.3
+++ compiler/md4.m	18 Jan 2011 15:12:24 -0000
@@ -41,6 +41,8 @@

  :- implementation.

+:- import_module require.
+
  %-----------------------------------------------------------------------------%

  :- pragma foreign_decl("C", "local", "
Index: compiler/pickle.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/pickle.m,v
retrieving revision 1.3
diff -u -r1.3 pickle.m
--- compiler/pickle.m	15 Dec 2010 06:29:54 -0000	1.3
+++ compiler/pickle.m	18 Jan 2011 15:12:24 -0000
@@ -191,6 +191,13 @@
      B = A;
  ").

+:- pragma foreign_proc("Java",
+    pickler_inst_cast(A::in, B::out(pickler_pred)),
+    [will_not_call_mercury, thread_safe, promise_pure],
+"
+    B = A;
+").
+
  %-----------------------------------------------------------------------------%
  %
  % Unpickling
@@ -310,6 +317,13 @@
      B = A;
  ").

+:- pragma foreign_proc("Java",
+    unpickler_inst_cast(A::in, B::out(unpickler_pred)),
+    [will_not_call_mercury, thread_safe, promise_pure],
+"
+    B = A;
+").
+
  %-----------------------------------------------------------------------------%
  %
  % Basic types picklers/unpicklers
@@ -398,6 +412,9 @@
      Str[Length] = '\\0';
  ").

+allocate_string(_, _) :-
+    sorry($file, $pred).
+
      % string.unsafe_set_char is disabled in the standard library so we need our
      % own copy.
  :- pred local_unsafe_set_char(char::in, int::in, string::di, string::uo)
@@ -411,6 +428,9 @@
      Str = Str0;
  ").

+local_unsafe_set_char(_, _, _, _) :-
+    sorry($file, $pred).
+
  :- pred pickle_float(float::in, io::di, io::uo) is det.

  pickle_float(Float, !IO) :-
@@ -442,6 +462,9 @@
      }
  ").

+reinterpret_float_as_ints(_, _, _) :-
+    sorry($file, $pred).
+
  :- pred unpickle_float(unpickle_handle::in, float::out,
      unpickle_state::di, unpickle_state::uo) is det.

@@ -473,6 +496,9 @@
      }
  ").

+reinterpret_ints_as_float(_, _, _) :-
+    sorry($file, $pred).
+
  :- pred get_byte(unpickle_handle::in, int::out,
      unpickle_state::di, unpickle_state::uo) is det.

Index: compiler/process_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/process_util.m,v
retrieving revision 1.33
diff -u -r1.33 process_util.m
--- compiler/process_util.m	2 Jan 2011 14:37:57 -0000	1.33
+++ compiler/process_util.m	18 Jan 2011 15:12:24 -0000
@@ -123,6 +123,8 @@

  :- implementation.

+:- import_module require.
+
  %-----------------------------------------------------------------------------%

  build_with_check_for_interrupt(VeryVerbose, Build, Cleanup, Succeeded,
@@ -312,6 +314,9 @@
  #endif
  ").

+send_signal(_, _, _, _) :-
+    sorry($file, $pred).
+
  :- pragma foreign_proc("C",
      sigint = (Sigint::out),
      [will_not_call_mercury, promise_pure, thread_safe],
@@ -319,6 +324,9 @@
      Sigint = SIGINT;
  ").

+sigint = _ :-
+    sorry($file, $pred).
+
  %-----------------------------------------------------------------------------%

  call_in_forked_process(P, Success, !IO) :-
@@ -500,6 +508,9 @@
  #endif /* ! MC_CAN_FORK */
  ").

+do_wait(_, _, _, _, _) :-
+    sorry($file, $pred).
+
  wait_pid(Pid, Status, !IO) :-
      do_wait(Pid, _Pid, Status0, !IO),
      Status = io.handle_system_command_exit_status(Status0).
Index: compiler/prog_event.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_event.m,v
retrieving revision 1.18
diff -u -r1.18 prog_event.m
--- compiler/prog_event.m	2 Jan 2011 14:37:58 -0000	1.18
+++ compiler/prog_event.m	18 Jan 2011 15:12:24 -0000
@@ -176,6 +176,9 @@
      MR_restore_transient_hp();
  ").

+read_specs_file(_, _, _, _, _) :-
+    unexpected($file, $pred, "non-C backend").
+
  :- pragma foreign_code("C", "

  MR_String
Index: library/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/Mmakefile,v
retrieving revision 1.174
diff -u -r1.174 Mmakefile
--- library/Mmakefile	13 Dec 2010 04:40:39 -0000	1.174
+++ library/Mmakefile	18 Jan 2011 15:12:24 -0000
@@ -237,7 +237,7 @@
  # rule chain rather than the .m -> .pic_s_date -> .pic_s -> .pic_o chain.
  # So don't remove the pic_ss target here.

-.PHONY: os cs ss pic_ss ils
+.PHONY: os cs ss pic_ss ils javas
  ifneq ($(MMAKE_USE_MMC_MAKE),yes)
  os: $($(STD_LIB_NAME).os)
  cs: $($(STD_LIB_NAME).cs)
@@ -378,9 +378,9 @@

  #-----------------------------------------------------------------------------#

-ifneq ($(MMAKE_USE_MMC_MAKE),yes)
+ifeq ($(MMAKE_USE_MMC_MAKE),yes)
  ifeq ("$(findstring java,$(GRADE))","java")
-lib_std: $(STD_LIB_NAME).jar $(RT_LIB_NAME).jar $(NATIVE_SO)
+lib_std: $(STD_LIB_NAME).jar $(RT_LIB_NAME).jar
  endif
  endif

@@ -409,7 +409,7 @@

  endif

-endif	# GRADE != il && GRADE != java && GRADE != erlang
+endif	# GRADE != il && GRADE != csharp && GRADE != java && GRADE != erlang

  #-----------------------------------------------------------------------------#


--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list