diff: tabling bug fixes

Fergus Henderson fjh at cs.mu.OZ.AU
Sun May 17 01:29:46 AEST 1998


Estimated hours taken: 1

Various bug fixes and other cleanups of the new tabling code.

library/mercury_builtin.m:
	Fix a couple of bugs in the new tabling code that broke in
	grades other than asm_fast.gc.

runtime/mercury_tabling.h:
	Fix a couple of type errors that caused things to break in
	grades other than asm_fast.gc.
	Change the layout to match our coding guidelines.

runtime/mercury_table_any.c:
	Fix the layout to match our coding guidelines.

runtime/mercury_table_any.h:
runtime/mercury_table_enum.h:
runtime/mercury_table_int_float_string.h:
runtime/mercury_table_type_info.h:
	Add copyright notice.
	
runtime/mercury_table.h:
	Add a comment pointing out that this is hash tables,
	not tabling.

cvs diff  library/mercury_builtin.m runtime/mercury_table.h runtime/mercury_table_any.c runtime/mercury_table_any.h runtime/mercury_table_enum.h runtime/mercury_table_int_float_string.h runtime/mercury_table_type_info.h runtime/mercury_tabling.h
Index: library/mercury_builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/mercury_builtin.m,v
retrieving revision 1.95
diff -u -r1.95 mercury_builtin.m
--- mercury_builtin.m	1998/05/15 07:08:41	1.95
+++ mercury_builtin.m	1998/05/16 15:19:57
@@ -1286,7 +1286,7 @@
 :- pragma c_code(table_save_char_ans(T::in, Offset::in, C::in), 
 		will_not_call_mercury, "
 	MR_TABLE_SAVE_ANSWER(Offset, T, C,
-		mercury_data___base_type_info_char_0);
+		mercury_data___base_type_info_character_0);
 ").
 
 :- pragma c_code(table_save_string_ans(T::in, Offset::in, S::in), 
@@ -1623,7 +1623,8 @@
 Declare_label(mercury__table_resume_1_0_ChangeLoopDone);
 Declare_label(mercury__table_resume_1_0_SolutionsListLoop);
 Declare_label(mercury__table_resume_1_0_AnsListLoop);
-Declare_label(mercury__table_resume_1_0_AnsListLoopDone);
+Declare_label(mercury__table_resume_1_0_AnsListLoopDone1);
+Declare_label(mercury__table_resume_1_0_AnsListLoopDone2);
 Declare_label(mercury__table_resume_1_0_SkipAns);
 Declare_label(mercury__table_resume_1_0_RedoPoint);
 
@@ -1635,7 +1636,8 @@
 	init_label_sl(mercury__table_resume_1_0_ChangeLoopDone);
 	init_label_sl(mercury__table_resume_1_0_SolutionsListLoop);
 	init_label_sl(mercury__table_resume_1_0_AnsListLoop);
-	init_label_sl(mercury__table_resume_1_0_AnsListLoopDone);
+	init_label_sl(mercury__table_resume_1_0_AnsListLoopDone1);
+	init_label_sl(mercury__table_resume_1_0_AnsListLoopDone2);
 	init_label_sl(mercury__table_resume_1_0_SkipAns);
 	init_label_sl(mercury__table_resume_1_0_RedoPoint);
 BEGIN_CODE
Index: runtime/mercury_table.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_table.h,v
retrieving revision 1.2
diff -u -r1.2 mercury_table.h
--- mercury_table.h	1997/11/23 07:21:37	1.2
+++ mercury_table.h	1998/05/16 14:50:23
@@ -1,11 +1,16 @@
 /*
-** Copyright (C) 1993-1995, 1997 The University of Melbourne.
+** Copyright (C) 1993-1995, 1997-1998 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.
 */
 
 /*
 ** mercury_table.h - defines the interface to the hash table module.
+**
+** Note that this module has nothing to do with the implementating
+** of the "tabling" pragmas such as `pragma memo' -- the implementation
+** of those features uses Tries, not hash tables, and is defined
+** in mercury_tabling.h.
 */
 
 #ifndef	MERCURY_TABLE_H
Index: runtime/mercury_table_any.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_table_any.c,v
retrieving revision 1.1
diff -u -r1.1 mercury_table_any.c
--- mercury_table_any.c	1998/05/15 07:09:20	1.1
+++ mercury_table_any.c	1998/05/16 14:56:49
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 1997 The University of Melbourne.
+** Copyright (C) 1997-1998 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.
 */
@@ -85,17 +85,16 @@
                         break;
 
                     case TYPELAYOUT_UNIV_VALUE:
-                    {
                         table = (Word**) MR_TABLE_TYPE_INFO(table,
                             data_value[UNIV_OFFSET_FOR_TYPEINFO]);
                         table = (Word**) MR_TABLE_ANY(table,
                             data_value[UNIV_OFFSET_FOR_TYPEINFO],
                             data_value[UNIV_OFFSET_FOR_DATA]);
                         break;
-                    }
+
                     case TYPELAYOUT_PREDICATE_VALUE:
                     {
-                           Word args = data_value[0];
+                        Word args = data_value[0];
 
                         table = (Word **) MR_TABLE_WORD(table, args);
                         table = (Word **) MR_TABLE_WORD(table, data_value[1]);
@@ -113,8 +112,8 @@
 
                     case TYPELAYOUT_ARRAY_VALUE:
                     {
-                           MR_ArrayType *array;
-                            Integer array_size;        
+                        MR_ArrayType *array;
+                        Integer array_size;        
         
                         array = (MR_ArrayType *) data_value;
                         array_size = array->size;
Index: runtime/mercury_table_any.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_table_any.h,v
retrieving revision 1.1
diff -u -r1.1 mercury_table_any.h
--- mercury_table_any.h	1998/05/15 07:09:21	1.1
+++ mercury_table_any.h	1998/05/16 14:50:49
@@ -1,3 +1,9 @@
+/*
+** Copyright (C) 1997-1998 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.
+*/
+
 #ifndef MERCURY_TABLE_ANY_H
 #define MERCURY_TABLE_ANY_H
 
Index: runtime/mercury_table_enum.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_table_enum.h,v
retrieving revision 1.1
diff -u -r1.1 mercury_table_enum.h
--- mercury_table_enum.h	1998/05/15 07:09:22	1.1
+++ mercury_table_enum.h	1998/05/16 14:51:14
@@ -1,3 +1,9 @@
+/*
+** Copyright (C) 1997-1998 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.
+*/
+
 #ifndef MERCURY_TABLE_ENUM_H
 #define MERCURY_TABLE_ENUM_H
 
Index: runtime/mercury_table_int_float_string.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_table_int_float_string.h,v
retrieving revision 1.1
diff -u -r1.1 mercury_table_int_float_string.h
--- mercury_table_int_float_string.h	1998/05/15 07:09:24	1.1
+++ mercury_table_int_float_string.h	1998/05/16 14:46:32
@@ -1,5 +1,11 @@
-#ifndef MERCURY_INT_FLOAT_STRING_H
-#define MERCURY_INT_FLOAT_STRING_H
+/*
+** Copyright (C) 1997-1998 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.
+*/
+
+#ifndef MERCURY_TABLE_INT_FLOAT_STRING_H
+#define MERCURY_TABLE_INT_FLOAT_STRING_H
 
 
 /* 
@@ -26,4 +32,4 @@
 **/
 TrieNode MR_string_hash_lookup_or_add(TrieNode Table, String Key);
 
-#endif /* not MERCURY_INT_FLOAT_STRING_H */
+#endif /* not MERCURY_TABLE_INT_FLOAT_STRING_H */
Index: runtime/mercury_table_type_info.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_table_type_info.h,v
retrieving revision 1.1
diff -u -r1.1 mercury_table_type_info.h
--- mercury_table_type_info.h	1998/05/15 07:09:25	1.1
+++ mercury_table_type_info.h	1998/05/16 14:51:42
@@ -1,3 +1,9 @@
+/*
+** Copyright (C) 1997-1998 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.
+*/
+
 #ifndef MERCURY_TABLE_TYPE_INFO
 #define MERCURY_TABLE_TYPE_INFO
 
Index: runtime/mercury_tabling.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_tabling.h,v
retrieving revision 1.1
diff -u -r1.1 mercury_tabling.h
--- mercury_tabling.h	1998/05/15 07:09:26	1.1
+++ mercury_tabling.h	1998/05/16 15:15:38
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 1995-1997 The University of Melbourne.
+** Copyright (C) 1997-1998 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.
 */
@@ -63,18 +63,19 @@
 
 #ifdef CONSERVATIVE_GC
 
-#define MR_TABLE_SAVE_ANSWER(Offset, ABlock, Value, TypeInfo)		\
+  #define MR_TABLE_SAVE_ANSWER(Offset, ABlock, Value, TypeInfo)		\
 	do {								\
 		(*((AnswerBlock)ABlock))[Offset] = Value;		\
 	} while(0)
 
 #else /* not CONSERVATIVE_GC */
 
-#define MR_TABLE_SAVE_ANSWER(Offset, ABlock, Value, TypeInfo)		\
+  #define MR_TABLE_SAVE_ANSWER(Offset, ABlock, Value, TypeInfo)		\
 	do {								\
 	   	save_transient_registers();				\
 		(*((AnswerBlock)ABlock))[Offset] = 			\
-			deep_copy(Value, &TypeInfo, NULL, NULL);	\
+			deep_copy(Value, (Word *) (Word) &TypeInfo,	\
+				NULL, NULL);				\
 		restore_transient_registers();		  		\
 	} while(0)
 
@@ -83,28 +84,29 @@
 
 #ifdef CONSERVATIVE_GC
 
-#define table_allocate(Size)						\
+  #define table_allocate(Size)						\
 	GC_malloc(Size);
 
-#define table_reallocate(Pointer, Size)					\
+  #define table_reallocate(Pointer, Size)				\
 	GC_realloc(Pointer, Size);
 
-#define table_free(Pointer)						\
+  #define table_free(Pointer)						\
 	GC_free(Pointer);
 
-#define MR_table_list_cons(h, t) list_cons((h),(t))
+  #define MR_table_list_cons(h, t) list_cons((h),(t))
 
 #else /* not CONSERVATIVE_GC */
 
-#define table_allocate(Size)                                            \
+  #define table_allocate(Size)						\
 	(fatal_error("Sorry, not implemented: tabling in non-GC grades"), NULL)
-#define table_reallocate(Pointer, Size)					\
+  #define table_reallocate(Pointer, Size)				\
 	(fatal_error("Sorry, not implemented: tabling in non-GC grades"), NULL)
-#define table_free(Pointer)						\
+  #define table_free(Pointer)						\
 	fatal_error("Sorry, not implemented: tabling in non-GC grades")
 
-#define MR_table_list_cons(h, t)					\
-	(fatal_error("Sorry, not implemented: tabling in non-GC grades"), NULL)
+  #define MR_table_list_cons(h, t)					\
+	(fatal_error("Sorry, not implemented: tabling in non-GC grades"), \
+	(Word)0)
 
 #endif /* CONSERVATIVE_GC */
 
-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.



More information about the developers mailing list