[m-rev.] java back-end runtime fixes

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Nov 28 20:18:04 AEDT 2003


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.

Workspace: /home/jupiter/fjh/ws-jupiter/mercury
Index: java/runtime/DuExistLocn.java
===================================================================
RCS file: /home/mercury1/repository/mercury/java/runtime/DuExistLocn.java,v
retrieving revision 1.1
diff -u -d -r1.1 DuExistLocn.java
--- java/runtime/DuExistLocn.java	11 Feb 2002 06:31:32 -0000	1.1
+++ java/runtime/DuExistLocn.java	28 Nov 2003 03:44:22 -0000
@@ -6,9 +6,13 @@
 
 package mercury.runtime;
 
+// Corresponds to MR_DuExistLocn in runtime/mercury_type_info.h
+
 public class DuExistLocn {
-	
 	public int exist_arg_num;
 	public int exist_offset_in_tci;
-
+	public DuExistLocn(int arg_num, int offset_in_tci) {
+		exist_arg_num = arg_num;
+		exist_offset_in_tci = offset_in_tci;
+	}
 }
Index: java/runtime/DuFunctorDesc.java
===================================================================
RCS file: /home/mercury1/repository/mercury/java/runtime/DuFunctorDesc.java,v
retrieving revision 1.1
diff -u -d -r1.1 DuFunctorDesc.java
--- java/runtime/DuFunctorDesc.java	11 Feb 2002 06:31:32 -0000	1.1
+++ java/runtime/DuFunctorDesc.java	28 Nov 2003 07:52:42 -0000
@@ -21,4 +21,27 @@
 	public /*final*/ java.lang.String[] du_functor_arg_names;
 	public /*final*/ mercury.runtime.DuExistInfo[] du_functor_exist_info;
 
+	public DuFunctorDesc(java.lang.String functor_name, int orig_arity,
+		int arg_type_contains_var, int sectag_locn, int primary,
+		int secondary, int ordinal,
+		// XXX why do we need to use Object here?
+		java.lang.Object arg_types,
+		java.lang.Object arg_names,
+		java.lang.Object exist_info)
+	{
+		du_functor_name = functor_name;
+		du_functor_orig_arity = orig_arity;
+		du_functor_ordinal = ordinal;
+		du_functor_arg_type_contains_var = arg_type_contains_var;
+		du_functor_sectag_locn =
+			new mercury.runtime.Sectag_Locn(sectag_locn);
+		du_functor_primary = primary;
+		du_functor_secondary = secondary;
+		du_functor_ordinal = ordinal;
+		du_functor_arg_types = (mercury.runtime.PseudoTypeInfo [])
+			arg_types;
+		du_functor_arg_names = (java.lang.String []) arg_names;
+		du_functor_exist_info =
+			(mercury.runtime.DuExistInfo[]) exist_info;
+	}
 }
Index: java/runtime/DuPtagLayout.java
===================================================================
RCS file: /home/mercury1/repository/mercury/java/runtime/DuPtagLayout.java,v
retrieving revision 1.1
diff -u -d -r1.1 DuPtagLayout.java
--- java/runtime/DuPtagLayout.java	11 Feb 2002 06:31:32 -0000	1.1
+++ java/runtime/DuPtagLayout.java	28 Nov 2003 07:45:15 -0000
@@ -10,6 +10,19 @@
 	
 	public int sectag_sharers;
 	public mercury.runtime.Sectag_Locn sectag_locn;
-	public /* final */ DuFunctorDesc[] sectag_alternatives;
+	public /* final */ mercury.runtime.DuFunctorDesc[] sectag_alternatives;
 
+	public DuPtagLayout(int sharers, mercury.runtime.Sectag_Locn locn,
+			mercury.runtime.DuFunctorDesc[] alts)
+	{
+		sectag_sharers = sharers;
+		sectag_locn = locn;
+		sectag_alternatives = alts;
+	}
+
+	public DuPtagLayout(int sharers, int locn, DuFunctorDesc[] alts) {
+		sectag_sharers = sharers;
+		sectag_locn = new mercury.runtime.Sectag_Locn(locn);
+		sectag_alternatives = alts;
+	}
 }
Index: java/runtime/MaybeResAddrFunctorDesc.java
===================================================================
RCS file: java/runtime/MaybeResAddrFunctorDesc.java
diff -N java/runtime/MaybeResAddrFunctorDesc.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ java/runtime/MaybeResAddrFunctorDesc.java	28 Nov 2003 02:47:01 -0000
@@ -0,0 +1,22 @@
+//
+// Copyright (C) 2003 The University of Melbourne.
+// This file may only be copied under the terms of the GNU Library General
+// Public License - see the file COPYING.LIB in the Mercury distribution.
+//
+
+package mercury.runtime;
+
+public class MaybeResAddrFunctorDesc {
+	public java.lang.String		maybe_res_name;
+	public int			maybe_res_arity;
+	public boolean			maybe_res_is_res;
+	public MaybeResFunctorDesc	maybe_res_ptr;
+	public MaybeResAddrFunctorDesc(java.lang.String name, int arity,
+		boolean is_res, MaybeResFunctorDesc ptr)
+	{
+		maybe_res_name = name;
+		maybe_res_arity = arity;
+		maybe_res_is_res = is_res;
+		maybe_res_ptr = ptr;
+	}
+}
Index: java/runtime/MaybeResFunctorDesc.java
===================================================================
RCS file: java/runtime/MaybeResFunctorDesc.java
diff -N java/runtime/MaybeResFunctorDesc.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ java/runtime/MaybeResFunctorDesc.java	28 Nov 2003 02:42:46 -0000
@@ -0,0 +1,18 @@
+//
+// Copyright (C) 2003 The University of Melbourne.
+// This file may only be copied under the terms of the GNU Library General
+// Public License - see the file COPYING.LIB in the Mercury distribution.
+//
+
+package mercury.runtime;
+
+public class MaybeResFunctorDesc {
+	public DuFunctorDesc		maybe_res_du;
+	public ReservedAddrFunctorDesc	maybe_res_res;
+	public MaybeResFunctorDesc(DuFunctorDesc du, 
+		ReservedAddrFunctorDesc res)
+	{
+		maybe_res_du = du;
+		maybe_res_res = res;
+	}
+}
Index: java/runtime/PseudoTypeInfo.java
===================================================================
RCS file: /home/mercury1/repository/mercury/java/runtime/PseudoTypeInfo.java,v
retrieving revision 1.1
diff -u -d -r1.1 PseudoTypeInfo.java
--- java/runtime/PseudoTypeInfo.java	11 Feb 2002 06:31:32 -0000	1.1
+++ java/runtime/PseudoTypeInfo.java	27 Nov 2003 22:24:05 -0000
@@ -6,8 +6,11 @@
 
 package mercury.runtime;
 
-public abstract class PseudoTypeInfo {
+public class PseudoTypeInfo {
 	// This class is intentionally empty. 
 	// XXX PsuedoTypeInfo's have not been implemented yet.
 	//     They should all extend this class.
+	public int variable_number;
+	public PseudoTypeInfo()      { variable_number = -1; }
+	public PseudoTypeInfo(int n) { variable_number = n; }
 }
Index: java/runtime/TypeCtorInfo_Struct.java
===================================================================
RCS file: /home/mercury1/repository/mercury/java/runtime/TypeCtorInfo_Struct.java,v
retrieving revision 1.3
diff -u -d -r1.3 TypeCtorInfo_Struct.java
--- java/runtime/TypeCtorInfo_Struct.java	8 Jul 2003 10:30:00 -0000	1.3
+++ java/runtime/TypeCtorInfo_Struct.java	28 Nov 2003 07:57:40 -0000
@@ -6,7 +6,7 @@
 
 package mercury.runtime;
 
-public class TypeCtorInfo_Struct {
+public class TypeCtorInfo_Struct extends PseudoTypeInfo {
     
 	public int                              arity;
 	public int                              type_ctor_version;
@@ -25,8 +25,10 @@
 			int type_arity, int version, int num_ptags, int rep,
 			Object unify_proc, Object compare_proc, 
 			String module, String name,
-			Object[] name_ordered_functor_descs,
-			Object[] value_ordered_functor_descs,
+			// mercury.runtime.TypeFunctors
+			java.lang.Object name_ordered_functor_descs,
+			// mercury.runtime.TypeLayout
+			java.lang.Object value_ordered_functor_descs,
 			int num_functors, int flags)
 	{
 		arity = type_arity;
@@ -37,11 +39,10 @@
 		compare_pred = (mercury.runtime.MethodPtr) compare_proc;
 		type_ctor_module_name = module;
 		type_ctor_name = name;
-		// XXX type mismatch
-		//type_functors = (mercury.runtime.TypeFunctors)
-		//	name_ordered_functor_descs;
-		//type_layout = (mercury.runtime.TypeLayout)
-		//	name_ordered_functor_descs;
+		type_functors = (mercury.runtime.TypeFunctors)
+			name_ordered_functor_descs;
+		type_layout = (mercury.runtime.TypeLayout)
+			name_ordered_functor_descs;
 		type_ctor_flags = flags;
 	}
 }
Index: java/runtime/TypeFunctors.java
===================================================================
RCS file: /home/mercury1/repository/mercury/java/runtime/TypeFunctors.java,v
retrieving revision 1.1
diff -u -d -r1.1 TypeFunctors.java
--- java/runtime/TypeFunctors.java	11 Feb 2002 06:31:33 -0000	1.1
+++ java/runtime/TypeFunctors.java	28 Nov 2003 02:59:47 -0000
@@ -7,7 +7,7 @@
 package mercury.runtime;
 
 //   XXX In the C backend this was a union.  
-//   It would (eventually) be better to have derived classes
+//   It might (eventually) be better to have derived classes
 //   for each of the unions constructors and make them all extend
 //   this class (rather like we do with the generated code from the 
 //   mercury compiler.  That way we can just use the `instanceof' operator
@@ -15,7 +15,17 @@
 
 public class TypeFunctors {
 	public java.lang.Object functors_init;
-	public mercury.runtime.DuFunctorDesc[] functors_du;
-	public mercury.runtime.EnumFunctorDesc[] functors_enum;
-	public mercury.runtime.NotagFunctorDesc functors_notag;
+	// the above field should contain one of the following types:
+	public mercury.runtime.DuFunctorDesc[] functors_du() {
+		return (mercury.runtime.DuFunctorDesc[]) functors_init;
+	}
+	public mercury.runtime.EnumFunctorDesc[] functors_enum() {
+		return (mercury.runtime.EnumFunctorDesc[]) functors_init;
+	}
+	public mercury.runtime.NotagFunctorDesc functors_notag() {
+		return (mercury.runtime.NotagFunctorDesc) functors_init;
+	}
+	public TypeFunctors(java.lang.Object init) {
+		functors_init = init;
+	}
 }
Index: java/runtime/TypeLayout.java
===================================================================
RCS file: /home/mercury1/repository/mercury/java/runtime/TypeLayout.java,v
retrieving revision 1.1
diff -u -d -r1.1 TypeLayout.java
--- java/runtime/TypeLayout.java	11 Feb 2002 06:31:33 -0000	1.1
+++ java/runtime/TypeLayout.java	28 Nov 2003 03:02:05 -0000
@@ -7,29 +7,46 @@
 package mercury.runtime;
 
 public class TypeLayout {
+		// This should hold a value of one of the types
+		// accessible by the access functions that follow.
+	public java.lang.Object layout_init;
+
 		//
 		// In runtime/mercury_type_info.h:
 		// typedef MR_DuPtagLayout *MR_DuTypeLayout;
 		// so here we just use DuPtagLayout[]
 		//
-	public mercury.runtime.DuPtagLayout[] layout_du;
+	public mercury.runtime.DuPtagLayout[] layout_du() {
+		return (mercury.runtime.DuPtagLayout[]) layout_init;
+	}
+
 		//
 		// In runtime/mercury_type_info.h:
 		// typedef MR_EnumFunctorDesc **EnumTypeLayout;
 		// so here we just use EnumFunctorDesc[][]
 		//
-	public mercury.runtime.EnumFunctorDesc[] layout_enum;
+	public mercury.runtime.EnumFunctorDesc[] layout_enum() {
+		return (mercury.runtime.EnumFunctorDesc[]) layout_init;
+	}
+
 		//
 		// In runtime/mercury_type_info.h:
 		// typedef MR_NotagFunctorDesc *MR_NotagTypeLayout;
 		// so here we just us NotagFunctorDesc[]
 		//
-	public mercury.runtime.NotagFunctorDesc[] layout_notag;
+	public mercury.runtime.NotagFunctorDesc[] layout_notag() {
+		return (mercury.runtime.NotagFunctorDesc[]) layout_init;
+	}
 		//
 		// In runtime/mercury_type_info.h:
 		// typedef MR_PseudoTypeInfo MR_EquivType;
 		// so here we just use MR_PseudoTypeInfo
 		//
-	public mercury.runtime.PseudoTypeInfo layout_equiv;
+	public mercury.runtime.PseudoTypeInfo layout_equiv() {
+		return (mercury.runtime.PseudoTypeInfo) layout_init;
+	}
+
+	public TypeLayout(java.lang.Object init) {
+		layout_init = init;
+	}
 }
-	
Index: java/runtime/TypeclassInfo.java
===================================================================
RCS file: /home/mercury1/repository/mercury/java/runtime/TypeclassInfo.java,v
retrieving revision 1.1
diff -u -d -r1.1 TypeclassInfo.java
--- java/runtime/TypeclassInfo.java	8 Jul 2003 10:30:00 -0000	1.1
+++ java/runtime/TypeclassInfo.java	28 Nov 2003 09:17:10 -0000
@@ -6,33 +6,6 @@
 
 package mercury.runtime;
 
-public class TypeInfo_Struct extends PseudoTypeInfo {
-
-	public TypeCtorInfo_Struct type_ctor;
-	public PseudoTypeInfo args[];
-    
-	public TypeInfo_Struct(TypeCtorInfo_Struct tc, PseudoTypeInfo[] as)
-	{
-		type_ctor = tc;
-		args = as;
-	}
-
-	public TypeInfo_Struct(TypeCtorInfo_Struct tc)
-	{
-		type_ctor = tc;
-		args = null;
-	}
-
-	public TypeInfo_Struct(TypeCtorInfo_Struct tc, PseudoTypeInfo a1)
-	{
-		type_ctor = tc;
-		args = new PseudoTypeInfo[] { a1 };
-	}
-
-	public TypeInfo_Struct(TypeCtorInfo_Struct tc, PseudoTypeInfo a1,
-				PseudoTypeInfo a2)
-	{
-		type_ctor = tc;
-		args = new PseudoTypeInfo[] { a1, a2 };
-	}
+public class TypeclassInfo extends PseudoTypeInfo {
+	// stub only
 }
Index: java/runtime/VA_PseudoTypeInfo_Struct1.java
===================================================================
RCS file: /home/mercury1/repository/mercury/java/runtime/VA_PseudoTypeInfo_Struct1.java,v
retrieving revision 1.1
diff -u -d -r1.1 VA_PseudoTypeInfo_Struct1.java
--- java/runtime/VA_PseudoTypeInfo_Struct1.java	8 Jul 2003 10:30:00 -0000	1.1
+++ java/runtime/VA_PseudoTypeInfo_Struct1.java	28 Nov 2003 07:58:44 -0000
@@ -8,8 +8,8 @@
 
 public class VA_PseudoTypeInfo_Struct1 extends PseudoTypeInfo {
 	public VA_PseudoTypeInfo_Struct1(
-			int arity,
 			TypeCtorInfo_Struct type_ctor_info,
+			int arity,
 			Object[] args) {
 		// XXX stub only
 	}
Index: java/runtime/VA_PseudoTypeInfo_Struct2.java
===================================================================
RCS file: /home/mercury1/repository/mercury/java/runtime/VA_PseudoTypeInfo_Struct2.java,v
retrieving revision 1.1
diff -u -d -r1.1 VA_PseudoTypeInfo_Struct2.java
--- java/runtime/VA_PseudoTypeInfo_Struct2.java	8 Jul 2003 10:30:00 -0000	1.1
+++ java/runtime/VA_PseudoTypeInfo_Struct2.java	28 Nov 2003 07:58:28 -0000
@@ -8,8 +8,8 @@
 
 public class VA_PseudoTypeInfo_Struct2 extends PseudoTypeInfo {
 	public VA_PseudoTypeInfo_Struct2(
-			int arity,
 			TypeCtorInfo_Struct type_ctor_info,
+			int arity,
 			Object[] args) {
 		// XXX stub only
 	}
Index: java/runtime/VA_PseudoTypeInfo_Struct3.java
===================================================================
RCS file: /home/mercury1/repository/mercury/java/runtime/VA_PseudoTypeInfo_Struct3.java,v
retrieving revision 1.1
diff -u -d -r1.1 VA_PseudoTypeInfo_Struct3.java
--- java/runtime/VA_PseudoTypeInfo_Struct3.java	8 Jul 2003 10:30:00 -0000	1.1
+++ java/runtime/VA_PseudoTypeInfo_Struct3.java	28 Nov 2003 07:58:51 -0000
@@ -8,8 +8,8 @@
 
 public class VA_PseudoTypeInfo_Struct3 extends PseudoTypeInfo {
 	public VA_PseudoTypeInfo_Struct3(
-			int arity,
 			TypeCtorInfo_Struct type_ctor_info,
+			int arity,
 			Object[] args) {
 		// XXX stub only
 	}
Index: java/runtime/VA_PseudoTypeInfo_Struct4.java
===================================================================
RCS file: /home/mercury1/repository/mercury/java/runtime/VA_PseudoTypeInfo_Struct4.java,v
retrieving revision 1.1
diff -u -d -r1.1 VA_PseudoTypeInfo_Struct4.java
--- java/runtime/VA_PseudoTypeInfo_Struct4.java	8 Jul 2003 10:30:00 -0000	1.1
+++ java/runtime/VA_PseudoTypeInfo_Struct4.java	28 Nov 2003 07:58:57 -0000
@@ -8,8 +8,8 @@
 
 public class VA_PseudoTypeInfo_Struct4 extends PseudoTypeInfo {
 	public VA_PseudoTypeInfo_Struct4(
-			int arity,
 			TypeCtorInfo_Struct type_ctor_info,
+			int arity,
 			Object[] args) {
 		// XXX stub only
 	}

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list