[m-rev.] for review: TYPE_CTOR_REP_REFERENCE
Fergus Henderson
fjh at cs.mu.OZ.AU
Tue Feb 11 04:11:33 AEDT 2003
On 10-Feb-2003, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
>
> Implement deep_copy for reference types.
> This is needed for accurate GC.
I missed a couple of files in my original post.
Here's a relative diff for the log message,
and full diffs for the files that I omitted.
I have gone ahead and committed this change now.
--- CHANGES.old1 Tue Feb 11 04:08:46 2003
+++ CHANGES Tue Feb 11 04:07:19 2003
@@ -8,11 +8,13 @@
library/private_builtin.m:
compiler/mlds_to_gcc.m:
runtime/mercury_builtin_types.h:
+runtime/mercury_builtin_types.c:
runtime/mercury_construct.c:
runtime/mercury_hlc_types.h:
runtime/mercury_mcpp.h:
runtime/mercury_ml_expand_body.h:
-runtime/mercury_tabling.h:
+runtime/mercury_tabling.c:
+runtime/mercury_deep_copy_body.h:
runtime/mercury_type_info.h:
runtime/mercury_unify_compare_body.h:
Add a new built-in type `private_builtin.ref(T)' and a
corresponding new type_ctor_rep `TYPE_CTOR_REP_REFERENCE'.
Workspace: /home/ceres/fjh/mercury
Index: runtime/mercury_builtin_types.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_builtin_types.c,v
retrieving revision 1.4
diff -u -d -r1.4 mercury_builtin_types.c
--- runtime/mercury_builtin_types.c 28 Oct 2002 13:44:51 -0000 1.4
+++ runtime/mercury_builtin_types.c 9 Feb 2003 09:34:21 -0000
@@ -49,6 +49,7 @@
MR_DEFINE_PROC_STATICS(builtin, trailptr, 0);
MR_DEFINE_PROC_STATICS(builtin, ticket, 0);
MR_DEFINE_PROC_STATICS(private_builtin, heap_pointer, 0);
+MR_DEFINE_PROC_STATICS(private_builtin, ref, 1);
MR_DEFINE_PROC_STATICS(private_builtin, type_ctor_info, 1);
MR_DEFINE_PROC_STATICS(private_builtin, type_info, 1);
MR_DEFINE_PROC_STATICS(private_builtin, base_typeclass_info, 1);
@@ -85,6 +86,7 @@
#endif
MR_DEFINE_TYPE_CTOR_INFO(private_builtin, heap_pointer, 0, HP);
+MR_DEFINE_TYPE_CTOR_INFO(private_builtin, ref, 1, REFERENCE);
MR_DEFINE_TYPE_CTOR_INFO(private_builtin, type_ctor_info, 1, TYPECTORINFO);
MR_DEFINE_TYPE_CTOR_INFO(private_builtin, type_info, 1, TYPEINFO);
MR_DEFINE_TYPE_CTOR_INFO(private_builtin, base_typeclass_info, 1,
@@ -161,12 +163,19 @@
MR_Heap_Pointer y)
{
MR_fatal_error(
- "called unify/2 for `private_builtin:heap_pointer' type");
+ "called unify/2 for `private_builtin.heap_pointer' type");
return MR_TRUE;
}
MR_bool MR_CALL
+mercury__private_builtin____Unify____ref_1_0(MR_Reference x,
+ MR_Reference y)
+{
+ return x == y;
+}
+
+MR_bool MR_CALL
mercury__builtin____Unify____func_0_0(MR_Func x, MR_Func y)
{
MR_fatal_error("called unify/2 for `func' type");
@@ -310,7 +319,15 @@
MR_Comparison_Result *result, MR_Heap_Pointer x, MR_Heap_Pointer y)
{
MR_fatal_error(
- "called compare/3 for `private_builtin:heap_pointer' type");
+ "called compare/3 for `private_builtin.heap_pointer' type");
+}
+
+void MR_CALL
+mercury__private_builtin____Compare____ref_1_0(
+ MR_Comparison_Result *result, MR_Reference x, MR_Reference y)
+{
+ MR_fatal_error(
+ "called compare/3 for `private_builtin.ref' type");
}
void MR_CALL
@@ -440,6 +457,13 @@
}
MR_bool MR_CALL
+mercury__private_builtin__do_unify__ref_1_0(MR_Box x, MR_Box y)
+{
+ return mercury__private_builtin____Unify____ref_1_0(
+ (MR_Reference) x, (MR_Reference) y);
+}
+
+MR_bool MR_CALL
mercury__builtin__do_unify__func_0_0(MR_Box x, MR_Box y)
{
MR_fatal_error("called unify/2 for `func' type");
@@ -569,7 +593,15 @@
MR_Comparison_Result *result, MR_Box x, MR_Box y)
{
MR_fatal_error(
- "called compare/3 for `private_builtin:heap_pointer' type");
+ "called compare/3 for `private_builtin.heap_pointer' type");
+}
+
+void MR_CALL
+mercury__private_builtin__do_compare__ref_1_0(
+ MR_Comparison_Result *result, MR_Box x, MR_Box y)
+{
+ MR_fatal_error(
+ "called compare/3 for `private_builtin.ref' type");
}
void MR_CALL
@@ -672,6 +704,7 @@
MR_UNIFY_COMPARE_DEFNS(builtin, trailptr, 0)
MR_UNIFY_COMPARE_DEFNS(builtin, ticket, 0)
MR_UNIFY_COMPARE_DEFNS(private_builtin, heap_pointer, 0)
+MR_UNIFY_COMPARE_DEFNS(private_builtin, ref, 1)
MR_UNIFY_COMPARE_DEFNS(private_builtin, type_ctor_info, 1)
MR_UNIFY_COMPARE_DEFNS(private_builtin, type_info, 1)
MR_UNIFY_COMPARE_DEFNS(private_builtin, base_typeclass_info, 1)
@@ -697,6 +730,7 @@
MR_UNIFY_COMPARE_LABELS(builtin, trailptr, 0)
MR_UNIFY_COMPARE_LABELS(builtin, ticket, 0)
MR_UNIFY_COMPARE_LABELS(private_builtin, heap_pointer, 0)
+ MR_UNIFY_COMPARE_LABELS(private_builtin, ref, 1)
MR_UNIFY_COMPARE_LABELS(private_builtin, type_ctor_info, 1)
MR_UNIFY_COMPARE_LABELS(private_builtin, type_info, 1)
MR_UNIFY_COMPARE_LABELS(private_builtin, base_typeclass_info, 1)
@@ -1073,6 +1107,28 @@
/*****************************************************************************/
/*
+** Unify and compare of references are usually handled by the generic unify/2
+** and compare/3 predicates.
+*/
+
+#define module private_builtin
+#define type ref
+#define arity 1
+#define unify_code MR_r1 = (MR_r1 == MR_r2);
+#define compare_code MR_fatal_error("called compare/3 for `ref' type");
+
+#include "mercury_hand_unify_compare_body.h"
+
+#undef module
+#undef type
+#undef arity
+#undef unify_code
+#undef compare_code
+
+
+/*****************************************************************************/
+
+/*
** Unify and compare of type_ctor_infos are usually handled by the generic
** unify/2 and compare/3 predicates.
*/
@@ -1333,6 +1389,7 @@
MR_INIT_TYPE_CTOR_INFO_MNA(builtin, ticket, 0);
#endif
MR_INIT_TYPE_CTOR_INFO_MNA(private_builtin, heap_pointer, 0);
+ MR_INIT_TYPE_CTOR_INFO_MNA(private_builtin, ref, 1);
MR_INIT_TYPE_CTOR_INFO_MNA(private_builtin, type_ctor_info, 1);
MR_INIT_TYPE_CTOR_INFO_MNA(private_builtin, type_info, 1);
MR_INIT_TYPE_CTOR_INFO_MNA(private_builtin, base_typeclass_info, 1);
@@ -1364,6 +1421,7 @@
MR_REGISTER_TYPE_CTOR_INFO(builtin, ticket, 0);
#endif
MR_REGISTER_TYPE_CTOR_INFO(private_builtin, heap_pointer, 0);
+ MR_REGISTER_TYPE_CTOR_INFO(private_builtin, ref, 1);
MR_REGISTER_TYPE_CTOR_INFO(private_builtin, type_ctor_info, 1);
MR_REGISTER_TYPE_CTOR_INFO(private_builtin, type_info, 1);
MR_REGISTER_TYPE_CTOR_INFO(private_builtin, base_typeclass_info, 1);
@@ -1394,6 +1452,7 @@
MR_WRITE_OUT_PROC_STATICS(fp, builtin, trailptr, 0);
MR_WRITE_OUT_PROC_STATICS(fp, builtin, ticket, 0);
MR_WRITE_OUT_PROC_STATICS(fp, private_builtin, heap_pointer, 0);
+ MR_WRITE_OUT_PROC_STATICS(fp, private_builtin, ref, 1);
MR_WRITE_OUT_PROC_STATICS(fp, private_builtin, type_ctor_info, 1);
MR_WRITE_OUT_PROC_STATICS(fp, private_builtin, type_info, 1);
MR_WRITE_OUT_PROC_STATICS(fp, private_builtin, base_typeclass_info, 1);
Index: runtime/mercury_deep_copy_body.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_deep_copy_body.h,v
retrieving revision 1.57
diff -u -d -r1.57 mercury_deep_copy_body.h
--- runtime/mercury_deep_copy_body.h 1 Aug 2002 11:52:26 -0000 1.57
+++ runtime/mercury_deep_copy_body.h 9 Feb 2003 08:39:57 -0000
@@ -614,6 +614,27 @@
new_data = data;
break;
+ case MR_TYPECTOR_REP_REFERENCE:
+ {
+ MR_Word *ref;
+ MR_Word *new_ref;
+ int i;
+
+ assert(MR_tag(data) == 0);
+ ref = (MR_Word *) MR_body(data, MR_mktag(0));
+
+ RETURN_IF_OUT_OF_RANGE(data, ref, 0, MR_Word);
+
+ MR_incr_saved_hp(new_data, 1);
+ new_ref = (MR_Word *) new_data;
+ *new_ref = copy_arg(NULL, *ref, NULL,
+ MR_TYPEINFO_GET_FIXED_ARITY_ARG_VECTOR(type_info),
+ (const MR_PseudoTypeInfo) 1, lower_limit, upper_limit);
+ leave_forwarding_pointer(data, 0, new_data);
+ }
+ break;
+
+ case MR_TYPECTOR_REP_FOREIGN: /* fallthru */
case MR_TYPECTOR_REP_UNKNOWN: /* fallthru */
default:
MR_fatal_error("Unknown layout type in deep copy");
Index: runtime/mercury_tabling.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_tabling.c,v
retrieving revision 1.54
diff -u -d -r1.54 mercury_tabling.c
--- runtime/mercury_tabling.c 15 Nov 2002 04:50:40 -0000 1.54
+++ runtime/mercury_tabling.c 9 Feb 2003 08:38:43 -0000
@@ -1205,6 +1205,10 @@
MR_fatal_error("Attempt to table a value of a foreign type");
break;
+ case MR_TYPECTOR_REP_REFERENCE:
+ MR_fatal_error("Attempt to table a value of a reference type");
+ break;
+
case MR_TYPECTOR_REP_UNKNOWN: /* fallthru */
default:
MR_fatal_error("Unknown layout tag in table_any");
--
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