for review: a fix for tests/tabling/boyer.m
Zoltan Somogyi
zs at cs.mu.OZ.AU
Fri Aug 21 11:21:22 AEST 1998
This is for Tyson.
runtime/mercury_tabling.h:
Add a new set of macros that optionally print debugging info at
tabling actions. Debugging recquires compilation with -DMR_TABLE_DEBUG
and -dT in MERCURY_OPTIONS.
runtime/mercury_table_any.c:
Use the debugging macros. Fix two bugs, one found with their help.
One is that a tagged pointer to the table giving information about
remote secondary tags did not have its tag stripped before use.
The other is that the extraction of local secondary tags from words
was done by subtracting the tag, and not by shifting out the tag,
leaving the secondary tag value too high by a factor of 4 or 8.
runtime/mercury_table_any.[ch]:
runtime/mercury_table_enum.[ch]:
Change the order of some function arguments to be consistent with
the orders in the macros that call these functions.
runtime/mercury_table_enum.c:
Add an optional sanity check that detects the second bug above.
runtime/mercury_engine.[ch]:
Add a new debug flag, MR_tabledebug. Rename the flags so they always
start with MR_.
runtime/mercury_wrapper.c:
Allow -dT in MERCURY_OPTIONS to set MR_tabledebug.
runtime/*.[ch]:
Trivial changes for the new names of the debug flags.
runtime/Mmakefile:
Reimpose alphabetical order on the list of C files.
library/private_builtin.m:
Use the new debugging macros in the C code that does tabling.
Expose the equivalence between ml_table, ml_subgoal_table_node etc
and c_pointer. The reason is
% These equivalences should be local to private_builtin. However,
% at the moment table_gen.m assumes that it can use a single variable
% sometimes as an ml_table and other times as an ml_subgoal_table_node
% (e.g. by giving the output of table_lookup_insert_int as input to
% table_have_all_ans). The proper fix would be for table_gen.m to
% use additional variables and insert unsafe casts. However, this
% would require significant work for no real gain, so for now
% we fix the problem by exposing the equivalences to code generated
% by table_gen.m.
library/mercury_builtin.m:
Delete the contents of this obsolete file, leaving only a pointer
to builtin.m and private_builtin.m.
tests/tabling/Mmakefile:
Enable the boyer benchmark, since we now pass it.
Zoltan.
cvs diff: Diffing .
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing bytecode/test
cvs diff: Diffing compiler
cvs diff: Diffing compiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/exceptions
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/Togl-1.2
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing library
Index: library/mercury_builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/mercury_builtin.m,v
retrieving revision 1.99
diff -u -u -r1.99 mercury_builtin.m
--- mercury_builtin.m 1998/07/22 07:41:49 1.99
+++ mercury_builtin.m 1998/08/20 09:40:00
@@ -4,1854 +4,5 @@
% Public License - see the file COPYING.LIB in the Mercury distribution.
%---------------------------------------------------------------------------%
-% File: mercury_builtin.m.
-% Main author: fjh.
-% Stability: low.
-
% IMPORTANT NOTE! This file is no longer used.
% Its contents have been moved to builtin.m and private_builtin.m.
<rest of file deleted>
Index: library/private_builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/private_builtin.m,v
retrieving revision 1.6
diff -u -u -r1.6 private_builtin.m
--- private_builtin.m 1998/08/04 05:39:17 1.6
+++ private_builtin.m 1998/08/20 10:50:40
@@ -126,6 +126,7 @@
%
% The following predicates are used in code transformed by the table_gen pass
% of the compiler. The predicates fall into three categories :
+%
% 1) Predicates to do lookups or insertions into the tables. This group
% also contains function to create and initialise tables. There are
% currently two types of table used by the tabling system. 1) A subgoal
@@ -150,12 +151,12 @@
% structures. Because the tables are persistent through backtracking, this
% causes the predicates to become impure. The predicates with the semipure
% directive only examine the trees but do not have any side effects.
-%
+%
% This type is used as a generic table: it can in fact represent two
% types, either a subgoal_table or an answer_table. The subgoal_table
% and answer_table types are differentiated by what they have at the
- % table nodes but not by the actual underling trie structure.
+ % table nodes but not by the actual underlying trie structure.
:- type ml_table.
% This type is used in contexts where a node of a subgoal table is
@@ -172,8 +173,6 @@
% This type is used in contexts where an answer block is expected.
:- type ml_answer_block.
-
-
% This is a dummy predicate: its pred_proc_id, but not its code,
% is used. See the comment in compiler/table_gen.m for more
% information.
@@ -185,14 +184,10 @@
:- impure pred table_setup(ml_subgoal_table_node, ml_subgoal_table_node).
:- mode table_setup(in, out) is det.
-
-
% Return all of the answer blocks stored in the given table.
:- semipure pred table_return_all_ans(ml_subgoal_table_node, ml_answer_block).
:- mode table_return_all_ans(in, out) is nondet.
-
-
% Returns true if the given nondet table has returned some of its
% answers.
:- semipure pred table_have_some_ans(ml_subgoal_table_node).
@@ -203,7 +198,6 @@
:- semipure pred table_have_all_ans(ml_subgoal_table_node).
:- mode table_have_all_ans(in) is semidet.
-
% Mark a table as having some answers.
:- impure pred table_mark_have_some_ans(ml_subgoal_table_node).
:- mode table_mark_have_some_ans(in) is det.
@@ -212,7 +206,6 @@
:- impure pred table_mark_have_all_ans(ml_subgoal_table_node).
:- mode table_mark_have_all_ans(in) is det.
-
% currently being evaluated (working on an answer).
:- semipure pred table_working_on_ans(ml_subgoal_table_node).
:- mode table_working_on_ans(in) is semidet.
@@ -222,7 +215,6 @@
:- semipure pred table_not_working_on_ans(ml_subgoal_table_node).
:- mode table_not_working_on_ans(in) is semidet.
-
% Mark the subgoal represented by the given table as currently
% being evaluated (working on an answer).
:- impure pred table_mark_as_working(ml_subgoal_table_node).
@@ -233,14 +225,10 @@
:- impure pred table_mark_done_working(ml_subgoal_table_node).
:- mode table_mark_done_working(in) is det.
-
-
% Report an error message about the current subgoal looping.
:- pred table_loopcheck_error(string).
:- mode table_loopcheck_error(in) is erroneous.
-
-
%
% The following table_lookup_insert... predicates lookup or insert the second
% argument into the trie pointed to by the first argument. The value returned
@@ -275,13 +263,11 @@
:- impure pred table_lookup_insert_poly(ml_table, T, ml_table).
:- mode table_lookup_insert_poly(in, in, out) is det.
-
% Return true if the subgoal represented by the given table has an
% answer. NOTE : this is only used for det and semidet procedures.
:- semipure pred table_have_ans(ml_subgoal_table_node).
:- mode table_have_ans(in) is semidet.
-
% Save the fact the the subgoal has succeeded in the given table.
:- impure pred table_mark_as_succeeded(ml_subgoal_table_node).
:- mode table_mark_as_succeeded(in) is det.
@@ -290,7 +276,6 @@
:- impure pred table_mark_as_failed(ml_subgoal_table_node).
:- mode table_mark_as_failed(in) is det.
-
% Return true if the subgoal represented by the given table has a
% true answer. NOTE : this is only used for det and semidet
% procedures.
@@ -302,7 +287,6 @@
:- semipure pred table_has_failed(ml_subgoal_table_node).
:- mode table_has_failed(in) is semidet.
-
% Create an answer block with the given number of slots and add it
% to the given table.
:- impure pred table_create_ans_block(ml_subgoal_table_node, int,
@@ -338,7 +322,6 @@
:- impure pred table_save_any_ans(ml_answer_block, int, T).
:- mode table_save_any_ans(in, in, in) is det.
-
% Restore an integer answer from the given answer block at the
% given offset.
:- semipure pred table_restore_int_ans(ml_answer_block, int, int).
@@ -364,7 +347,6 @@
:- semipure pred table_restore_any_ans(ml_answer_block, int, T).
:- mode table_restore_any_ans(in, in, out) is det.
-
% Return the table of answers already return to the given nondet
% table.
:- impure pred table_get_ans_table(ml_subgoal_table_node, ml_table).
@@ -394,6 +376,21 @@
:- impure pred table_resume(ml_subgoal_table_node).
:- mode table_resume(in) is det.
+ % These equivalences should be local to private_builtin. However,
+ % at the moment table_gen.m assumes that it can use a single variable
+ % sometimes as an ml_table and other times as an ml_subgoal_table_node
+ % (e.g. by giving the output of table_lookup_insert_int as input to
+ % table_have_all_ans). The proper fix would be for table_gen.m to
+ % use additional variables and insert unsafe casts. However, this
+ % would require significant work for no real gain, so for now
+ % we fix the problem by exposing the equivalences to code generated
+ % by table_gen.m.
+:- type ml_table == c_pointer.
+:- type ml_subgoal_table_node == c_pointer.
+:- type ml_answer_table_node == c_pointer.
+:- type ml_answer_slot == c_pointer.
+:- type ml_answer_block == c_pointer.
+
%-----------------------------------------------------------------------------%
:- implementation.
@@ -515,12 +512,6 @@
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
-:- type ml_table == c_pointer.
-:- type ml_subgoal_table_node == c_pointer.
-:- type ml_answer_table_node == c_pointer.
-:- type ml_answer_slot == c_pointer.
-:- type ml_answer_block == c_pointer.
-
:- pragma c_header_code("
#include ""mercury_deep_copy.h""
@@ -557,45 +548,44 @@
*((Word*) T) = ML_UNINITIALIZED;
").
-
table_loopcheck_error(Message) :-
error(Message).
-
:- pragma c_code(table_lookup_insert_int(T0::in, I::in, T::out),
will_not_call_mercury, "
- T = (Word) MR_TABLE_INT((Word**)T0, I);
+ MR_DEBUG_NEW_TABLE_INT(T, T0, I);
").
:- pragma c_code(table_lookup_insert_char(T0::in, C::in, T::out),
will_not_call_mercury, "
- T = (Word) MR_TABLE_CHAR((Word **) T0, C);
+ MR_DEBUG_NEW_TABLE_CHAR(T, T0, C);
").
:- pragma c_code(table_lookup_insert_string(T0::in, S::in, T::out),
will_not_call_mercury, "
- T = (Word) MR_TABLE_STRING((Word **) T0, S);
+ MR_DEBUG_NEW_TABLE_STRING(T, T0, S);
").
:- pragma c_code(table_lookup_insert_float(T0::in, F::in, T::out),
will_not_call_mercury, "
- T = (Word) MR_TABLE_FLOAT((Word **) T0, F);
+ MR_DEBUG_NEW_TABLE_FLOAT(T, T0, F);
").
:- pragma c_code(table_lookup_insert_enum(T0::in, R::in, V::in, T::out),
will_not_call_mercury, "
- T = (Word) MR_TABLE_ENUM((Word **) T0, R, V);
+ MR_DEBUG_NEW_TABLE_ENUM(T, T0, R, V);
").
:- pragma c_code(table_lookup_insert_user(T0::in, V::in, T::out),
will_not_call_mercury, "
- T = (Word) MR_TABLE_ANY((Word **) T0, TypeInfo_for_T, V);
+ MR_DEBUG_NEW_TABLE_ANY(T, T0, TypeInfo_for_T, V);
").
:- pragma c_code(table_lookup_insert_poly(T0::in, V::in, T::out),
will_not_call_mercury, "
- Word T1 = (Word) MR_TABLE_TYPE_INFO((Word **) T0, TypeInfo_for_T);
- T = (Word) MR_TABLE_ANY((Word **) T1, TypeInfo_for_T, V);
+ Word T1;
+ MR_DEBUG_NEW_TABLE_TYPEINFO(T1, T0, TypeInfo_for_T);
+ MR_DEBUG_NEW_TABLE_ANY(T, T1, TypeInfo_for_T, V);
").
:- pragma c_code(table_have_ans(T::in), will_not_call_mercury, "
@@ -673,7 +663,6 @@
*((Word*) T) = ML_FAILED;
").
-
:- pragma c_code(table_restore_int_ans(T::in, Offset::in, I::out),
will_not_call_mercury, "
I = (Integer) MR_TABLE_GET_ANSWER(Offset, T);
@@ -699,7 +688,6 @@
V = (Word) MR_TABLE_GET_ANSWER(Offset, T);
").
-
:- pragma c_header_code("
/*
@@ -767,7 +755,6 @@
#define NON_TABLE(T) (*(NondetTable **)T)
").
-
:- pragma c_code(table_setup(T0::in, T::out), will_not_call_mercury, "
/* Init the table if this is the first time me see it */
if (NON_TABLE(T0) == NULL) {
@@ -788,7 +775,6 @@
T = T0;
").
-
table_return_all_ans(T, A) :-
semipure table_return_all_ans_list(T, AnsList),
list__member(Node, AnsList),
@@ -827,8 +813,6 @@
SUCCESS_INDICATOR = (*((Word*) T) == ML_ANS_NOT_RET);
").
-
-
:- pragma c_code(table_mark_have_all_ans(T::in), will_not_call_mercury, "
NON_TABLE(T)->status = have_all_ans;
").
@@ -841,7 +825,6 @@
*((Word *) T) = ML_ANS_RET;
").
-
:- external(table_suspend/2).
:- external(table_resume/1).
@@ -930,7 +913,6 @@
AnswerListNode *ansNode;
} ResumeStackNode;
-
Integer ML_resumption_sp = -1;
Word ML_resumption_stack_size = 4; /* Half the initial size of
the stack in ResumeStackNode's */
@@ -1024,7 +1006,6 @@
list_is_empty(NON_TABLE(r1)->suspend_list))
proceed();
-
/* Save the current state. */
ML_RESUME_PUSH();
ML_RESUME_VAR->table = NON_TABLE(r1);
@@ -1087,14 +1068,12 @@
ML_RESUME_VAR->ansNode = (AnswerListNode *)list_head(
ML_RESUME_VAR->ans_list);
-
/*
** Restore the state of the suspended node and return the answer
** through the redoip we saved when the node was originally
** suspended
*/
-
table_copy_mem(ML_RESUME_VAR->table->non_stack_bottom,
ML_RESUME_VAR->suspend_node->non_stack_block,
ML_RESUME_VAR->suspend_node->non_stack_block_size);
@@ -1146,7 +1125,6 @@
else
ML_RESUME_VAR->changed = 1;
-
ML_RESUME_VAR->suspend_node->last_ret_ans =
&ML_RESUME_VAR->ans_list;
@@ -1217,7 +1195,6 @@
Slot = (Word) &n->ans;
").
-
:- end_module private_builtin.
cvs diff: Diffing lp_solve
cvs diff: Diffing lp_solve/lp_examples
cvs diff: Diffing profiler
cvs diff: Diffing runtime
Index: runtime/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/Mmakefile,v
retrieving revision 1.36
diff -u -u -r1.36 Mmakefile
--- Mmakefile 1998/08/10 07:17:34 1.36
+++ Mmakefile 1998/08/20 10:49:02
@@ -121,11 +121,11 @@
mercury_signal.c \
mercury_stack_trace.c \
mercury_table.c \
- mercury_thread.c \
mercury_table_any.c \
mercury_table_enum.c \
mercury_table_builtins.c \
mercury_table_type_info.c \
+ mercury_thread.c \
mercury_timing.c \
mercury_trace.c \
mercury_trace_base.c \
Index: runtime/mercury_context.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_context.c,v
retrieving revision 1.10
diff -u -u -r1.10 mercury_context.c
--- mercury_context.c 1998/08/07 00:50:15 1.10
+++ mercury_context.c 1998/08/21 02:41:58
@@ -20,7 +20,7 @@
#include "mercury_memory_handlers.h"
#include "mercury_context.h"
-#include "mercury_engine.h" /* for `memdebug' */
+#include "mercury_engine.h" /* for `MR_memdebug' */
MR_Context *MR_runqueue;
#ifdef MR_THREAD_SAFE
Index: runtime/mercury_debug.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_debug.h,v
retrieving revision 1.5
diff -u -u -r1.5 mercury_debug.h
--- mercury_debug.h 1998/07/29 08:55:53 1.5
+++ mercury_debug.h 1998/08/21 02:41:58
@@ -24,10 +24,10 @@
#define debuggoto(label) \
(MR_assert(label), \
- IF (gotodebug, (save_transient_registers(), goto_msg(label))))
+ IF (MR_gotodebug, (save_transient_registers(), goto_msg(label))))
#define debugsreg() \
- IF (sregdebug, (save_transient_registers(), reg_msg()))
+ IF (MR_sregdebug, (save_transient_registers(), reg_msg()))
#endif
@@ -65,68 +65,68 @@
#define dump_pop_msg() (--dumpindex)
#define debugcr1(val0, hp) \
- IF (heapdebug, (save_transient_registers(), cr1_msg(val0, hp)))
+ IF (MR_heapdebug, (save_transient_registers(), cr1_msg(val0, hp)))
#define debugcr2(val0, val1, hp) \
- IF (heapdebug, (save_transient_registers(), cr2_msg(val0, val1, hp)))
+ IF (MR_heapdebug, (save_transient_registers(), cr2_msg(val0, val1, hp)))
#define debugincrhp(val, hp) \
- IF (heapdebug, \
+ IF (MR_heapdebug, \
(save_transient_registers(), incr_hp_debug_msg((val), (hp))))
#define debugincrsp(val, sp) \
- IF (detstackdebug, (save_transient_registers(), incr_sp_msg((val), (sp))))
+ IF (MR_detstackdebug, (save_transient_registers(), incr_sp_msg((val), (sp))))
#define debugdecrsp(val, sp) \
- IF (detstackdebug, (save_transient_registers(), decr_sp_msg((val), (sp))))
+ IF (MR_detstackdebug, (save_transient_registers(), decr_sp_msg((val), (sp))))
#define debugpush(val, sp) \
- IF (detstackdebug, (save_transient_registers(), push_msg((val), (sp))))
+ IF (MR_detstackdebug, (save_transient_registers(), push_msg((val), (sp))))
#define debugpop(val, sp) \
- IF (detstackdebug, (save_transient_registers(), pop_msg(val, sp)))
+ IF (MR_detstackdebug, (save_transient_registers(), pop_msg(val, sp)))
#define debugregs(msg) \
- IF (progdebug, (save_transient_registers(), printregs(msg)))
+ IF (MR_progdebug, (save_transient_registers(), printregs(msg)))
#define debugmkframe() \
- IF (nondstackdebug, (save_transient_registers(), mkframe_msg()))
+ IF (MR_nondstackdebug, (save_transient_registers(), mkframe_msg()))
#define debugframe(msg) \
- IF (progdebug, (save_transient_registers(), printframe(msg)))
+ IF (MR_progdebug, (save_transient_registers(), printframe(msg)))
#define debugsucceed() \
- IF (nondstackdebug, (save_transient_registers(), succeed_msg()))
+ IF (MR_nondstackdebug, (save_transient_registers(), succeed_msg()))
#define debugsucceeddiscard() \
- IF (nondstackdebug, (save_transient_registers(), succeeddiscard_msg()))
+ IF (MR_nondstackdebug, (save_transient_registers(), succeeddiscard_msg()))
#define debugfail() \
- IF (nondstackdebug, (save_transient_registers(), fail_msg()))
+ IF (MR_nondstackdebug, (save_transient_registers(), fail_msg()))
#define debugredo() \
- IF (nondstackdebug, (save_transient_registers(), redo_msg()))
+ IF (MR_nondstackdebug, (save_transient_registers(), redo_msg()))
#define debugcall(proc, succ_cont) \
- IF (calldebug, (save_transient_registers(), call_msg(proc, succ_cont)))
+ IF (MR_calldebug, (save_transient_registers(), call_msg(proc, succ_cont)))
#define debugtailcall(proc) \
- IF (calldebug, (save_transient_registers(), tailcall_msg(proc)))
+ IF (MR_calldebug, (save_transient_registers(), tailcall_msg(proc)))
#define debugproceed() \
- IF (calldebug, (save_transient_registers(), proceed_msg()))
+ IF (MR_calldebug, (save_transient_registers(), proceed_msg()))
#define debugmsg0(msg) \
- IF (progdebug, (printf(msg)))
+ IF (MR_progdebug, (printf(msg)))
#define debugmsg1(msg, arg1) \
- IF (progdebug, (printf(msg, arg1)))
+ IF (MR_progdebug, (printf(msg, arg1)))
#define debugmsg2(msg, arg1, arg2) \
- IF (progdebug, (printf(msg, arg1, arg2)))
+ IF (MR_progdebug, (printf(msg, arg1, arg2)))
#define debugmsg3(msg, arg1, arg2, arg3) \
- IF (progdebug, (printf(msg, arg1, arg2, arg3)))
+ IF (MR_progdebug, (printf(msg, arg1, arg2, arg3)))
#endif /* MR_LOWLEVEL_DEBUG */
Index: runtime/mercury_engine.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_engine.c,v
retrieving revision 1.13
diff -u -u -r1.13 mercury_engine.c
--- mercury_engine.c 1998/08/07 00:50:17 1.13
+++ mercury_engine.c 1998/08/21 02:53:13
@@ -37,7 +37,7 @@
MR_MAKE_STACK_LAYOUT_ENTRY(engine_done)
#endif
-bool debugflag[MAXFLAG];
+bool MR_debugflag[MR_MAXFLAG];
#ifndef MR_THREAD_SAFE
MercuryEngine MR_engine_base;
@@ -459,7 +459,7 @@
int i, pos;
#if !defined(MR_DEBUG_GOTOS)
- if (tracedebug)
+ if (MR_tracedebug)
#endif
{
printf("previous %d locations:\n", NUM_PREV_FPS);
@@ -485,7 +485,7 @@
fp = (Func *) entry_point;
#if !defined(MR_DEBUG_GOTOS)
-if (!tracedebug) {
+if (!MR_tracedebug) {
for (;;)
{
fp = (Func *) (*fp)();
Index: runtime/mercury_engine.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_engine.h,v
retrieving revision 1.9
diff -u -u -r1.9 mercury_engine.h
--- mercury_engine.h 1998/08/07 00:50:19 1.9
+++ mercury_engine.h 1998/08/21 02:48:03
@@ -34,33 +34,35 @@
** Global flags that control the behaviour of the Mercury engine(s)
*/
-extern bool debugflag[];
+extern bool MR_debugflag[];
-#define PROGFLAG 0
-#define GOTOFLAG 1
-#define CALLFLAG 2
-#define HEAPFLAG 3
-#define DETSTACKFLAG 4
-#define NONDSTACKFLAG 5
-#define FINALFLAG 6
-#define MEMFLAG 7
-#define SREGFLAG 8
-#define TRACEFLAG 9
-#define DETAILFLAG 10
-#define MAXFLAG 11
-/* DETAILFLAG should be the last real flag */
+#define MR_PROGFLAG 0
+#define MR_GOTOFLAG 1
+#define MR_CALLFLAG 2
+#define MR_HEAPFLAG 3
+#define MR_DETSTACKFLAG 4
+#define MR_NONDSTACKFLAG 5
+#define MR_FINALFLAG 6
+#define MR_MEMFLAG 7
+#define MR_SREGFLAG 8
+#define MR_TRACEFLAG 9
+#define MR_TABLEFLAG 10
+#define MR_DETAILFLAG 11
+#define MR_MAXFLAG 12
+/* MR_DETAILFLAG should be the last real flag */
-#define progdebug debugflag[PROGFLAG]
-#define gotodebug debugflag[GOTOFLAG]
-#define calldebug debugflag[CALLFLAG]
-#define heapdebug debugflag[HEAPFLAG]
-#define detstackdebug debugflag[DETSTACKFLAG]
-#define nondstackdebug debugflag[NONDSTACKFLAG]
-#define finaldebug debugflag[FINALFLAG]
-#define memdebug debugflag[MEMFLAG]
-#define sregdebug debugflag[SREGFLAG]
-#define tracedebug debugflag[TRACEFLAG]
-#define detaildebug debugflag[DETAILFLAG]
+#define MR_progdebug MR_debugflag[MR_PROGFLAG]
+#define MR_gotodebug MR_debugflag[MR_GOTOFLAG]
+#define MR_calldebug MR_debugflag[MR_CALLFLAG]
+#define MR_heapdebug MR_debugflag[MR_HEAPFLAG]
+#define MR_detstackdebug MR_debugflag[MR_DETSTACKFLAG]
+#define MR_nondstackdebug MR_debugflag[MR_NONDSTACKFLAG]
+#define MR_finaldebug MR_debugflag[MR_FINALFLAG]
+#define MR_memdebug MR_debugflag[MR_MEMFLAG]
+#define MR_sregdebug MR_debugflag[MR_SREGFLAG]
+#define MR_tracedebug MR_debugflag[MR_TRACEFLAG]
+#define MR_tabledebug MR_debugflag[MR_TABLEFLAG]
+#define MR_detaildebug MR_debugflag[MR_DETAILFLAG]
/*
** MR_setjmp and MR_longjmp are wrappers around setjmp and longjmp
Index: runtime/mercury_label.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_label.c,v
retrieving revision 1.8
diff -u -u -r1.8 mercury_label.c
--- mercury_label.c 1998/07/22 07:52:47 1.8
+++ mercury_label.c 1998/08/21 02:41:59
@@ -20,7 +20,7 @@
#include "mercury_table.h" /* for `Table' */
#include "mercury_prof.h" /* for prof_output_addr_decl() */
-#include "mercury_engine.h" /* for `progdebug' */
+#include "mercury_engine.h" /* for `MR_progdebug' */
#include "mercury_wrapper.h" /* for do_init_modules() */
/*
@@ -100,7 +100,7 @@
#endif
#ifdef MR_LOWLEVEL_DEBUG
- if (progdebug) {
+ if (MR_progdebug) {
printf("recording entry label %s at %p\n", name, addr);
}
#endif
@@ -201,7 +201,7 @@
internal->i_name = name;
#ifdef MR_LOWLEVEL_DEBUG
- if (progdebug) {
+ if (MR_progdebug) {
printf("inserting internal label %s at %p\n", name, addr);
}
#endif
@@ -219,7 +219,7 @@
do_init_modules();
#ifdef MR_LOWLEVEL_DEBUG
- if (progdebug) {
+ if (MR_progdebug) {
printf("looking for internal label at %p\n", addr);
}
#endif
Index: runtime/mercury_memory.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_memory.c,v
retrieving revision 1.12
diff -u -u -r1.12 mercury_memory.c
--- mercury_memory.c 1998/07/22 07:52:51 1.12
+++ mercury_memory.c 1998/08/21 02:41:59
@@ -202,7 +202,7 @@
init_zones();
setup_signals();
- if (memdebug) debug_memory();
+ if (MR_memdebug) debug_memory();
} /* end init_memory() */
#ifdef CONSERVATIVE_GC
Index: runtime/mercury_memory_handlers.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_memory_handlers.c,v
retrieving revision 1.6
diff -u -u -r1.6 mercury_memory_handlers.c
--- mercury_memory_handlers.c 1998/07/26 11:32:04 1.6
+++ mercury_memory_handlers.c 1998/08/21 02:41:59
@@ -129,12 +129,12 @@
zone = get_used_memory_zones();
- if (memdebug) {
+ if (MR_memdebug) {
fprintf(stderr, "caught fault at %p\n", (void *)addr);
}
while(zone != NULL) {
- if (memdebug) {
+ if (MR_memdebug) {
fprintf(stderr, "checking %s#%d: %p - %p\n",
zone->name, zone->id, (void *) zone->redzone,
(void *) zone->top);
@@ -142,7 +142,7 @@
if (zone->redzone <= fault_addr && fault_addr <= zone->top) {
- if (memdebug) {
+ if (MR_memdebug) {
fprintf(stderr, "address is in %s#%d redzone\n",
zone->name, zone->id);
}
@@ -152,7 +152,7 @@
zone = zone->next;
}
- if (memdebug) {
+ if (MR_memdebug) {
fprintf(stderr, "address not in any redzone.\n");
}
@@ -203,7 +203,7 @@
if (new_zone <= zone->hardmax) {
zone_size = (char *)new_zone - (char *)zone->redzone;
- if (memdebug) {
+ if (MR_memdebug) {
fprintf(stderr, "trying to unprotect %s#%d from %p to %p (%x)\n",
zone->name, zone->id, (void *) zone->redzone, (void *) new_zone,
(int)zone_size);
@@ -220,7 +220,7 @@
zone->redzone = new_zone;
- if (memdebug) {
+ if (MR_memdebug) {
fprintf(stderr, "successful: %s#%d redzone now %p to %p\n",
zone->name, zone->id, (void *) zone->redzone,
(void *) zone->top);
@@ -232,7 +232,7 @@
return TRUE;
} else {
char buf[2560];
- if (memdebug) {
+ if (MR_memdebug) {
fprintf(stderr, "can't unprotect last page of %s#%d\n",
zone->name, zone->id);
fflush(stdout);
@@ -323,19 +323,19 @@
** we're not debugging, only print them if
** try_munprotect fails.
*/
- if (memdebug) {
+ if (MR_memdebug) {
fflush(stdout);
fprintf(stderr, "\n*** Mercury runtime: "
"caught segmentation violation ***\n");
}
if (try_munprotect(address, &sigcontext)) {
- if (memdebug) {
+ if (MR_memdebug) {
fprintf(stderr, "returning from "
"signal handler\n\n");
}
return;
}
- if (!memdebug) {
+ if (!MR_memdebug) {
fflush(stdout);
fprintf(stderr, "\n*** Mercury runtime: "
"caught segmentation violation ***\n");
@@ -470,19 +470,19 @@
** only print them if try_munprotect fails.
*/
- if (memdebug) {
+ if (MR_memdebug) {
explain_segv(info, context);
}
if (try_munprotect(info->si_addr, context)) {
- if (memdebug) {
+ if (MR_memdebug) {
fprintf(stderr, "returning from signal handler\n\n");
}
return;
}
- if (!memdebug) {
+ if (!MR_memdebug) {
explain_segv(info, context);
}
Index: runtime/mercury_misc.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_misc.c,v
retrieving revision 1.10
diff -u -u -r1.10 mercury_misc.c
--- mercury_misc.c 1998/07/29 08:55:59 1.10
+++ mercury_misc.c 1998/08/21 02:42:00
@@ -33,7 +33,7 @@
printf("succ ip: "); printlabel(cursuccip);
printf("redo ip: "); printlabel(curredoip);
- if (detaildebug) {
+ if (MR_detaildebug) {
dumpnondstack();
}
@@ -50,7 +50,7 @@
printf("succ fr: "); printnondstack(cursuccfr);
printf("succ ip: "); printlabel(cursuccip);
- if (detaildebug) {
+ if (MR_detaildebug) {
printregs("registers at success");
}
@@ -67,7 +67,7 @@
printf("succ fr: "); printnondstack(cursuccfr);
printf("succ ip: "); printlabel(cursuccip);
- if (detaildebug) {
+ if (MR_detaildebug) {
printregs("registers at success");
}
Index: runtime/mercury_table_any.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_table_any.c,v
retrieving revision 1.3
diff -u -u -r1.3 mercury_table_any.c
--- mercury_table_any.c 1998/06/10 06:56:13 1.3
+++ mercury_table_any.c 1998/08/21 02:55:03
@@ -14,25 +14,23 @@
#include "mercury_type_info.h"
#include <stdio.h>
-
MR_DECLARE_STRUCT(mercury_data___base_type_info_pred_0);
MR_DECLARE_STRUCT(mercury_data___base_type_info_func_0);
-
/*
** Due to the depth of the control here, we'll use 4 space indentation.
**
-** NOTE : changes to this function will probably also have to be reflected
+** NOTE : changes to this function will probably also have to be reflected
** in mercury_deep_copy.c and std_util::ML_expand().
*/
+
TrieNode
-MR_table_type(Word *type_info, Word data, TrieNode table)
+MR_table_type(TrieNode table, Word *type_info, Word data)
{
Word *base_type_info, *base_type_layout, *base_type_functors;
- Word functors_indicator;
- Word layout_entry, *entry_value, *data_value;
+ Word layout_for_tag, *layout_vector_for_tag, *data_value;
enum MR_DataRepresentation data_rep;
- int data_tag, entry_tag;
+ int data_tag, entry_tag;
MR_MemoryList allocated_memory_cells = NULL;
@@ -41,48 +39,52 @@
base_type_info = MR_TYPEINFO_GET_BASE_TYPEINFO(type_info);
base_type_layout = MR_BASE_TYPEINFO_GET_TYPELAYOUT(base_type_info);
- layout_entry = base_type_layout[data_tag];
-
base_type_functors = MR_BASE_TYPEINFO_GET_TYPEFUNCTORS(base_type_info);
- functors_indicator = MR_TYPEFUNCTORS_INDICATOR(base_type_functors);
- entry_value = (Word *) strip_tag(layout_entry);
+ layout_for_tag = base_type_layout[data_tag];
+ layout_vector_for_tag = (Word *) strip_tag(layout_for_tag);
- data_rep = MR_categorize_data(functors_indicator, layout_entry);
+ data_rep = MR_categorize_data(MR_TYPEFUNCTORS_INDICATOR(base_type_functors),
+ layout_for_tag);
+#ifdef MR_TABLE_DEBUG
+ if (MR_tabledebug) {
+ printf("ENTRY %p %x, data rep: %d\n", table, data, data_rep);
+ }
+#endif /* MR_TABLE_DEBUG */
switch (data_rep) {
case MR_DATAREP_ENUM: {
- Word functors =
- MR_TYPELAYOUT_ENUM_VECTOR_NUM_FUNCTORS(entry_value);
- table = (Word**) MR_TABLE_ENUM(table, functors, data);
+ int functors = MR_TYPELAYOUT_ENUM_VECTOR_NUM_FUNCTORS(
+ layout_vector_for_tag);
+ MR_DEBUG_TABLE_ENUM(table, functors, data);
break;
}
case MR_DATAREP_COMPLICATED_CONST: {
- Word functors =
- MR_TYPELAYOUT_ENUM_VECTOR_NUM_FUNCTORS(entry_value);
- table = (Word**) MR_TABLE_TAG(table, data_tag);
- table = (Word**) MR_TABLE_ENUM(table, functors, (Word) data_value);
+ int functors = MR_TYPELAYOUT_ENUM_VECTOR_NUM_FUNCTORS(
+ layout_vector_for_tag);
+ MR_DEBUG_TABLE_TAG(table, data_tag);
+ MR_DEBUG_TABLE_ENUM(table, functors, unmkbody(data));
break;
}
case MR_DATAREP_SIMPLE: {
int arity, i;
Word *argument_vector, *type_info_vector, *new_type_info;
-
+
argument_vector = data_value;
- arity = entry_value[TYPELAYOUT_SIMPLE_ARITY_OFFSET];
- type_info_vector = entry_value + TYPELAYOUT_SIMPLE_ARGS_OFFSET;
+ arity = layout_vector_for_tag[TYPELAYOUT_SIMPLE_ARITY_OFFSET];
+ type_info_vector = &layout_vector_for_tag[
+ TYPELAYOUT_SIMPLE_ARGS_OFFSET];
- table = (Word**) MR_TABLE_TAG(table, data_tag);
+ MR_DEBUG_TABLE_TAG(table, data_tag);
/* copy arguments */
for (i = 0; i < arity; i++) {
new_type_info = MR_make_type_info(type_info,
(Word *) type_info_vector[i], &allocated_memory_cells);
-
- table = (Word**) MR_TABLE_ANY(table, new_type_info,
- argument_vector[i]);
+
+ MR_DEBUG_TABLE_ANY(table, new_type_info, argument_vector[i]);
}
break;
}
@@ -93,82 +95,83 @@
secondary_tag = *data_value;
argument_vector = data_value + 1;
- new_entry = (Word *) entry_value[secondary_tag +1];
- arity = new_entry[TYPELAYOUT_SIMPLE_ARITY_OFFSET];
- type_info_vector = new_entry +
- TYPELAYOUT_SIMPLE_ARGS_OFFSET;
- table = (Word**) MR_TABLE_TAG(table, data_tag);
-
num_sharers = MR_TYPELAYOUT_COMPLICATED_VECTOR_NUM_SHARERS(
- entry_value);
- table = (Word**) MR_TABLE_ENUM(table, num_sharers, secondary_tag);
-
+ layout_vector_for_tag);
+ /* XXX trd: this operation should have a macro */
+ new_entry = (Word *) strip_tag(
+ layout_vector_for_tag[secondary_tag + 1]);
+ arity = new_entry[TYPELAYOUT_SIMPLE_ARITY_OFFSET];
+ type_info_vector = &new_entry[TYPELAYOUT_SIMPLE_ARGS_OFFSET];
+
+ MR_DEBUG_TABLE_TAG(table, data_tag);
+ MR_DEBUG_TABLE_ENUM(table, num_sharers, secondary_tag);
+
for (i = 0; i < arity; i++) {
new_type_info = MR_make_type_info(type_info,
(Word *) type_info_vector[i], &allocated_memory_cells);
-
- table = (Word**) MR_TABLE_ANY(table, new_type_info,
- argument_vector[i]);
+
+ MR_DEBUG_TABLE_ANY(table, new_type_info, argument_vector[i]);
}
break;
}
case MR_DATAREP_NOTAG: {
Word *new_type_info;
new_type_info = MR_make_type_info(type_info,
- (Word *) *MR_TYPELAYOUT_NO_TAG_VECTOR_ARGS(entry_value),
+ (Word *) *MR_TYPELAYOUT_NO_TAG_VECTOR_ARGS(
+ layout_vector_for_tag),
&allocated_memory_cells);
- table = (Word**) MR_TABLE_ANY(table, new_type_info, data);
+ MR_DEBUG_TABLE_ANY(table, new_type_info, data);
break;
}
case MR_DATAREP_EQUIV: {
Word *new_type_info;
new_type_info = MR_make_type_info(type_info,
- (Word *) MR_TYPELAYOUT_EQUIV_TYPE(entry_value),
+ (Word *) MR_TYPELAYOUT_EQUIV_TYPE(layout_vector_for_tag),
&allocated_memory_cells);
- table = (Word**) MR_TABLE_ANY(table, new_type_info, data);
+ MR_DEBUG_TABLE_ANY(table, new_type_info, data);
break;
}
case MR_DATAREP_EQUIV_VAR:
- table = (Word**) MR_TABLE_ANY(table,
- (Word *) type_info[(Word) entry_value], data);
+ MR_DEBUG_TABLE_ANY(table,
+ (Word *) type_info[(Word) layout_vector_for_tag], data);
break;
case MR_DATAREP_INT:
- table = (Word**) MR_TABLE_INT(table, data);
+ MR_DEBUG_TABLE_INT(table, data);
break;
case MR_DATAREP_CHAR:
- table = (Word**) MR_TABLE_CHAR(table, data);
+ MR_DEBUG_TABLE_CHAR(table, data);
break;
case MR_DATAREP_FLOAT:
- table = (Word**) MR_TABLE_FLOAT(table, data);
+ MR_DEBUG_TABLE_FLOAT(table, data);
break;
case MR_DATAREP_STRING:
- table = (Word**) MR_TABLE_STRING(table, data);
+ MR_DEBUG_TABLE_STRING(table, data);
break;
case MR_DATAREP_PRED: {
int i;
Word args = data_value[0];
- table = (Word **) MR_TABLE_WORD(table, args);
- table = (Word **) MR_TABLE_WORD(table, data_value[1]);
-
+ MR_DEBUG_TABLE_STRING(table, args);
+ MR_DEBUG_TABLE_STRING(table, data_value[1]);
+
for (i = 0; i < args; i++) {
- table = (Word **) MR_TABLE_ANY(table,
+ MR_DEBUG_TABLE_ANY(table,
(Word *) type_info[i + TYPEINFO_OFFSET_FOR_PRED_ARGS],
data_value[i+2]);
}
break;
}
case MR_DATAREP_UNIV:
- 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],
+ MR_DEBUG_TABLE_TYPEINFO(table,
+ (Word *) data_value[UNIV_OFFSET_FOR_TYPEINFO]);
+ MR_DEBUG_TABLE_ANY(table,
+ (Word *) data_value[UNIV_OFFSET_FOR_TYPEINFO],
data_value[UNIV_OFFSET_FOR_DATA]);
break;
@@ -180,22 +183,21 @@
int i;
MR_ArrayType *array;
Word *new_type_info;
- Integer array_size;
-
+ Integer array_size;
+
array = (MR_ArrayType *) data_value;
array_size = array->size;
-
+
new_type_info = MR_make_type_info(type_info, (Word *) 1,
&allocated_memory_cells);
-
+
for (i = 0; i < array_size; i++) {
- table = (Word**) MR_TABLE_ANY(table, new_type_info,
- array->elements[i]);
+ MR_DEBUG_TABLE_ANY(table, new_type_info, array->elements[i]);
}
break;
}
case MR_DATAREP_TYPEINFO:
- table = (Word**) MR_TABLE_TYPE_INFO(table, data_value);
+ MR_DEBUG_TABLE_TYPEINFO(table, (Word *) data_value);
break;
case MR_DATAREP_C_POINTER:
@@ -208,8 +210,7 @@
break;
}
- MR_deallocate(allocated_memory_cells);
-
+ MR_deallocate(allocated_memory_cells);
+
return table;
} /* end table_any() */
-
Index: runtime/mercury_table_any.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_table_any.h,v
retrieving revision 1.2
diff -u -u -r1.2 mercury_table_any.h
--- mercury_table_any.h 1998/05/16 15:30:55 1.2
+++ mercury_table_any.h 1998/08/21 02:42:01
@@ -13,6 +13,7 @@
** info to do this. It returns a pointer to the node found by the
** insertion/lookup.
*/
-TrieNode MR_table_type(Word *type_info, Word data_value, TrieNode Table);
+
+TrieNode MR_table_type(TrieNode Table, Word *type_info, Word data_value);
#endif /* not MERCURY_TABLE_ANY_H */
Index: runtime/mercury_table_enum.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_table_enum.c,v
retrieving revision 1.1
diff -u -u -r1.1 mercury_table_enum.c
--- mercury_table_enum.c 1998/05/15 07:09:21 1.1
+++ mercury_table_enum.c 1998/08/21 02:42:01
@@ -13,14 +13,21 @@
#define ELEMENT(Table, Key) ((Word**)&((Table)[Key]))
/*
-** MR_int_index_lookup_or_add() : This function maintains a simple indexed
-** table of size Range.
+** MR_int_index_lookup_or_add() : This function maintains a simple indexed
+** table of size Range.
*/
-TrieNode
-MR_int_index_lookup_or_add(TrieNode t, Integer key, Integer range)
+
+TrieNode
+MR_int_index_lookup_or_add(TrieNode t, Integer range, Integer key)
{
Word *table = *t; /* Deref table */
-
+
+#ifdef MR_TABLE_DEBUG
+ if (key >= range) {
+ fatal_error("MR_int_index_lookup_or_add: key out of range");
+ }
+#endif
+
if (table == NULL) {
*t = table = table_allocate(sizeof(Word *) * range);
memset(table, 0, sizeof(Word *) * range);
@@ -28,4 +35,3 @@
return ELEMENT(table, key);
}
-
Index: runtime/mercury_table_enum.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_table_enum.h,v
retrieving revision 1.2
diff -u -u -r1.2 mercury_table_enum.h
--- mercury_table_enum.h 1998/05/16 15:30:57 1.2
+++ mercury_table_enum.h 1998/08/21 02:42:01
@@ -12,6 +12,7 @@
** table of size Range. The return value is a pointer to the table
** node found by the lookup/insert.
*/
-TrieNode MR_int_index_lookup_or_add(TrieNode, Integer, Integer);
+
+TrieNode MR_int_index_lookup_or_add(TrieNode table, Integer range, Integer key);
#endif /* not MERCURY_TABLE_ENUM_H */
Index: runtime/mercury_tabling.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_tabling.h,v
retrieving revision 1.7
diff -u -u -r1.7 mercury_tabling.h
--- mercury_tabling.h 1998/08/04 00:33:20 1.7
+++ mercury_tabling.h 1998/08/21 02:46:54
@@ -9,48 +9,329 @@
** code generated by the Mercury compiler and by the Mercury runtime.
*/
-#ifndef MERCURY_TABLING_H
-#define MERCURY_TABLING_H
+#ifndef MERCURY_TABLING_H
+#define MERCURY_TABLING_H
-#undef MR_TABLE_DEBUG
+typedef Word **TrieNode;
+typedef Word **AnswerBlock;
-typedef Word ** TrieNode;
-typedef Word ** AnswerBlock;
-
-
#include "mercury_table_enum.h"
#include "mercury_table_any.h"
#include "mercury_table_type_info.h"
#include "mercury_table_builtins.h"
+#define MR_RAW_TABLE_ANY(Table, TypeInfo, Value) \
+ MR_table_type(Table, (Word *) TypeInfo, Value)
+
+#define MR_RAW_TABLE_TAG(Table, Tag) \
+ MR_int_index_lookup_or_add(Table, 1 << TAGBITS, Tag)
-#define MR_TABLE_WORD(Table, Value) \
- MR_int_hash_lookup_or_add(Table, (Integer)Value);
+#define MR_RAW_TABLE_ENUM(Table, Range, Value) \
+ MR_int_index_lookup_or_add(Table, Range, Value)
-#define MR_TABLE_INT(Table, Value) \
+#define MR_RAW_TABLE_WORD(Table, Value) \
+ MR_int_hash_lookup_or_add(Table, (Integer) Value);
+
+#define MR_RAW_TABLE_INT(Table, Value) \
MR_int_hash_lookup_or_add(Table, Value);
+
+#define MR_RAW_TABLE_CHAR(Table, Value) \
+ MR_int_hash_lookup_or_add(Table, (Integer) Value);
-#define MR_TABLE_FLOAT(Table, Value) \
+#define MR_RAW_TABLE_FLOAT(Table, Value) \
MR_float_hash_lookup_or_add(Table, Value);
+
+#define MR_RAW_TABLE_STRING(Table, Value) \
+ MR_string_hash_lookup_or_add(Table, (String) Value);
+
+#define MR_RAW_TABLE_TYPE_INFO(Table, Type) \
+ MR_type_info_lookup_or_add(Table, (Word *) Type)
+
+#ifdef MR_TABLE_DEBUG
+
+#define MR_DEBUG_NEW_TABLE_ANY(table, table0, type_info, value) \
+ do { \
+ (table) = (Word) MR_RAW_TABLE_ANY((Word **) (table0), \
+ (type_info), (value)); \
+ if (MR_tabledebug) { \
+ printf("TABLE %p: any %x type %p => %p\n", \
+ (Word **) (table0), (value), \
+ (Word **) (type_info), (Word **) (table));\
+ } \
+ } while (0)
+#define MR_DEBUG_TABLE_ANY(table, type_info, value) \
+ do { \
+ TrieNode prev_table = (table); \
+ (table) = (Word **) MR_RAW_TABLE_ANY((table), \
+ (type_info), (value)); \
+ if (MR_tabledebug) { \
+ printf("TABLE %p: any %x type %p => %p\n", \
+ (table), (value), (type_info), \
+ prev_table); \
+ } \
+ } while (0)
+
+#define MR_DEBUG_NEW_TABLE_TAG(table, table0, value) \
+ do { \
+ (table) = (Word) MR_RAW_TABLE_TAG((Word **) (table0), \
+ (value)); \
+ if (MR_tabledebug) { \
+ printf("TABLE %p: tag %d => %p\n", \
+ (Word **) (table0), (value), \
+ (Word **) (table)) \
+ } \
+ } while (0)
+#define MR_DEBUG_TABLE_TAG(table, value) \
+ do { \
+ TrieNode prev_table = (table); \
+ (table) = (Word **) MR_RAW_TABLE_TAG((table), (value)); \
+ if (MR_tabledebug) { \
+ printf("TABLE %p: tag %d => %p\n", (table), \
+ (value), prev_table); \
+ } \
+ } while (0)
+
+#define MR_DEBUG_NEW_TABLE_ENUM(table, table0, count, value) \
+ do { \
+ (table) = (Word) MR_RAW_TABLE_ENUM((Word **) (table0), \
+ (count), (value)); \
+ if (MR_tabledebug) { \
+ printf("TABLE %p: enum %d of %d => %p\n", \
+ (Word **) (table0), (value), (count), \
+ (Word **) (table)); \
+ } \
+ } while (0)
+#define MR_DEBUG_TABLE_ENUM(table, count, value) \
+ do { \
+ TrieNode prev_table = (table); \
+ (table) = (Word **) MR_RAW_TABLE_ENUM((table), (count), \
+ (value)); \
+ if (MR_tabledebug) { \
+ printf("TABLE %p: enum %d of %d => %p\n", \
+ (table), (value), (count), prev_table); \
+ } \
+ } while (0)
-#define MR_TABLE_CHAR(Table, Value) \
- MR_int_hash_lookup_or_add(Table, (Integer)Value);
+#define MR_DEBUG_NEW_TABLE_WORD(table, table0, value) \
+ do { \
+ (table) = (Word) MR_RAW_TABLE_WORD((Word **) (table0), \
+ (value)); \
+ if (MR_tabledebug) { \
+ printf("TABLE %p: word %d => %p\n", \
+ (Word **) (table0), (value), \
+ (Word **) (table)); \
+ } \
+ } while (0)
+#define MR_DEBUG_TABLE_WORD(table, value) \
+ do { \
+ TrieNode prev_table = (table); \
+ (table) = (Word **) MR_RAW_TABLE_WORD((table), (value));\
+ if (MR_tabledebug) { \
+ printf("TABLE %p: word %d => %p\n", \
+ (table), (value), prev_table); \
+ } \
+ } while (0)
-#define MR_TABLE_STRING(Table, Value) \
- MR_string_hash_lookup_or_add(Table, (String)Value);
-
-#define MR_TABLE_ENUM(Table, Range, Value) \
- MR_int_index_lookup_or_add(Table, Value, Range)
-
-#define MR_TABLE_TAG(Table, Tag) \
- MR_int_index_lookup_or_add(Table, Tag, 1 << TAGBITS)
-
-#define MR_TABLE_TYPE_INFO(Table, Type) \
- MR_type_info_lookup_or_add(Table, (Word*) Type)
-
-#define MR_TABLE_ANY(Table, TypeInfo, Value) \
- MR_table_type((Word*)TypeInfo, Value, Table)
+#define MR_DEBUG_NEW_TABLE_INT(table, table0, value) \
+ do { \
+ (table) = (Word) MR_RAW_TABLE_INT((Word **) (table0), \
+ (value)); \
+ if (MR_tabledebug) { \
+ printf("TABLE %p: int %d => %p\n", \
+ (Word **) (table0), (value), \
+ (Word **) (table)); \
+ } \
+ } while (0)
+#define MR_DEBUG_TABLE_INT(table, value) \
+ do { \
+ TrieNode prev_table = (table); \
+ (table) = (Word **) MR_RAW_TABLE_INT((table), (value)); \
+ if (MR_tabledebug) { \
+ printf("TABLE %p: int %d => %p\n", \
+ (table), (value), prev_table); \
+ } \
+ } while (0)
+#define MR_DEBUG_NEW_TABLE_CHAR(table, table0, value) \
+ do { \
+ (table) = (Word) MR_RAW_TABLE_CHAR((Word **) (table0), \
+ (value)); \
+ if (MR_tabledebug) { \
+ printf("TABLE %p: char `%c'/%d => %p\n", \
+ (Word **) (table0), (int) (value), \
+ (int) (value), (Word **) (table)); \
+ } \
+ } while (0)
+#define MR_DEBUG_TABLE_CHAR(table, value) \
+ do { \
+ TrieNode prev_table = (table); \
+ (table) = (Word **) MR_RAW_TABLE_CHAR((table), (value));\
+ if (MR_tabledebug) { \
+ printf("TABLE %p: char `%c'/%d => %p\n", \
+ (table), (int) (value), (int) (value), \
+ prev_table); \
+ } \
+ } while (0)
+
+#define MR_DEBUG_NEW_TABLE_FLOAT(table, table0, value) \
+ do { \
+ (table) = (Word) MR_RAW_TABLE_FLOAT((Word **) (table0), \
+ (value)); \
+ if (MR_tabledebug) { \
+ printf("TABLE %p: float %f => %p\n", \
+ (Word **) (table0), value, \
+ (Word **) (table)); \
+ } \
+ } while (0)
+#define MR_DEBUG_TABLE_FLOAT(table, value) \
+ do { \
+ TrieNode prev_table = (table); \
+ (table) = (Word **) MR_RAW_TABLE_FLOAT((table), (value));\
+ if (MR_tabledebug) { \
+ printf("TABLE %p: float %f => %p\n", \
+ (table), (double) word_to_float(value), \
+ prev_table); \
+ } \
+ } while (0)
+
+#define MR_DEBUG_NEW_TABLE_STRING(table, table0, value) \
+ do { \
+ (table) = (Word) MR_RAW_TABLE_STRING((Word **) (table0),\
+ (value)); \
+ if (MR_tabledebug) { \
+ printf("TABLE %p: string `%s' => %p\n", \
+ (Word **) (table), (char *) (value), \
+ (Word **) (table)); \
+ } \
+ } while (0)
+#define MR_DEBUG_TABLE_STRING(table, value) \
+ do { \
+ TrieNode prev_table = (table); \
+ (table) = (Word **) MR_RAW_TABLE_STRING((table), (value));\
+ if (MR_tabledebug) { \
+ printf("TABLE %p: string `%s' => %p\n", \
+ (table), (char *) (value), prev_table); \
+ } \
+ } while (0)
+
+#define MR_DEBUG_NEW_TABLE_TYPEINFO(table, table0, value) \
+ do { \
+ (table) = (Word) MR_RAW_TABLE_TYPE_INFO((Word **) (table0),\
+ (value)); \
+ if (MR_tabledebug) { \
+ printf("TABLE %p: typeinfo %p => %p\n", \
+ (Word **) (table), (Word **) (value), \
+ (Word **) (table)); \
+ } \
+ } while (0)
+#define MR_DEBUG_TABLE_TYPEINFO(table, value) \
+ do { \
+ TrieNode prev_table = (table); \
+ (table) = (Word **) MR_RAW_TABLE_TYPE_INFO((table), (value));\
+ if (MR_tabledebug) { \
+ printf("TABLE %p: typeinfo %p => %p\n", \
+ (table), (value), prev_table); \
+ } \
+ } while (0)
+
+#else /* not MR_TABLE_DEBUG */
+
+#define MR_DEBUG_NEW_TABLE_ANY(table, table0, type_info, value) \
+ do { \
+ (table) = (Word) MR_RAW_TABLE_ANY((Word **) (table0), \
+ (type_info), (value)); \
+ } while (0)
+#define MR_DEBUG_TABLE_ANY(table, type_info, value) \
+ do { \
+ (table) = (Word **) MR_RAW_TABLE_ANY((table), \
+ (type_info), (value)); \
+ } while (0)
+
+#define MR_DEBUG_NEW_TABLE_TAG(table, table0, value) \
+ do { \
+ (table) = (Word) MR_RAW_TABLE_TAG((Word **) (table0), \
+ (value)); \
+ } while (0)
+#define MR_DEBUG_TABLE_TAG(table, value) \
+ do { \
+ (table) = (Word **) MR_RAW_TABLE_TAG((table), (value)); \
+ } while (0)
+
+#define MR_DEBUG_NEW_TABLE_ENUM(table, table0, count, value) \
+ do { \
+ (table) = (Word) MR_RAW_TABLE_ENUM((Word **) (table0), \
+ (count), (value)); \
+ } while (0)
+#define MR_DEBUG_TABLE_ENUM(table, count, value) \
+ do { \
+ (table) = (Word **) MR_RAW_TABLE_ENUM((table), (count), \
+ (value)); \
+ } while (0)
+
+#define MR_DEBUG_NEW_TABLE_WORD(table, table0, value) \
+ do { \
+ (table) = (Word) MR_RAW_TABLE_WORD((Word **) (table0), \
+ (value)); \
+ } while (0)
+#define MR_DEBUG_TABLE_WORD(table, value) \
+ do { \
+ (table) = (Word **) MR_RAW_TABLE_WORD((table), (value));\
+ } while (0)
+
+#define MR_DEBUG_NEW_TABLE_INT(table, table0, value) \
+ do { \
+ (table) = (Word) MR_RAW_TABLE_INT((Word **) (table0), \
+ (value)); \
+ } while (0)
+#define MR_DEBUG_TABLE_INT(table, value) \
+ do { \
+ (table) = (Word **) MR_RAW_TABLE_INT((table), (value)); \
+ } while (0)
+
+#define MR_DEBUG_NEW_TABLE_CHAR(table, table0, value) \
+ do { \
+ (table) = (Word) MR_RAW_TABLE_CHAR((Word **) (table0), \
+ (value)); \
+ } while (0)
+#define MR_DEBUG_TABLE_CHAR(table, value) \
+ do { \
+ (table) = (Word **) MR_RAW_TABLE_CHAR((table), (value));\
+ } while (0)
+
+#define MR_DEBUG_NEW_TABLE_FLOAT(table, table0, value) \
+ do { \
+ (table) = (Word) MR_RAW_TABLE_FLOAT((Word **) (table0), \
+ (value)); \
+ } while (0)
+#define MR_DEBUG_TABLE_FLOAT(table, value) \
+ do { \
+ (table) = (Word **) MR_RAW_TABLE_FLOAT((table), (value));\
+ } while (0)
+
+#define MR_DEBUG_NEW_TABLE_STRING(table, table0, value) \
+ do { \
+ (table) = (Word) MR_RAW_TABLE_STRING((Word **) (table0),\
+ (value)); \
+ } while (0)
+#define MR_DEBUG_TABLE_STRING(table, value) \
+ do { \
+ (table) = (Word **) MR_RAW_TABLE_STRING((table), (value));\
+ } while (0)
+
+#define MR_DEBUG_NEW_TABLE_TYPEINFO(table, table0, value) \
+ do { \
+ (table) = (Word) MR_RAW_TABLE_TYPE_INFO((Word **) (table0),\
+ (value)); \
+ } while (0)
+#define MR_DEBUG_TABLE_TYPEINFO(table, value) \
+ do { \
+ (table) = (Word **) MR_RAW_TABLE_TYPE_INFO((table), (value));\
+ } while (0)
+
+#endif /* MR_TABLE_DEBUG */
+
+/***********************************************************************/
+
#define MR_TABLE_CREATE_ANSWER_BLOCK(ABlock, Elements) \
do { \
*((AnswerBlock) ABlock) = \
@@ -58,32 +339,30 @@
} while(0)
#define MR_TABLE_GET_ANSWER(Offset, ABlock) \
- (*((AnswerBlock)ABlock))[Offset]
+ (* ((AnswerBlock) ABlock))[Offset]
-
#ifdef CONSERVATIVE_GC
#define MR_TABLE_SAVE_ANSWER(Offset, ABlock, Value, TypeInfo) \
do { \
- (*((AnswerBlock)ABlock))[Offset] = Value; \
+ (* ((AnswerBlock) ABlock))[Offset] = Value; \
} while(0)
#else /* not CONSERVATIVE_GC */
#define MR_TABLE_SAVE_ANSWER(Offset, ABlock, Value, TypeInfo) \
do { \
- save_transient_registers(); \
+ save_transient_registers(); \
{ Word local_val = Value; \
- (*((AnswerBlock)ABlock))[Offset] = \
+ (* ((AnswerBlock) ABlock))[Offset] = \
deep_copy(&local_val, (Word *) (Word) &TypeInfo,\
NULL, NULL); \
} \
- restore_transient_registers(); \
+ restore_transient_registers(); \
} while(0)
#endif /* CONSERVATIVE_GC */
-
#ifdef CONSERVATIVE_GC
#define table_allocate(size) \
@@ -95,7 +374,7 @@
#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 */
@@ -110,7 +389,7 @@
#define MR_table_list_cons(h, t) \
(fatal_error("Sorry, not implemented: tabling in non-GC grades"), \
- (Word)0)
+ (Word) 0)
#endif /* CONSERVATIVE_GC */
Index: runtime/mercury_wrapper.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_wrapper.c,v
retrieving revision 1.22
diff -u -u -r1.22 mercury_wrapper.c
--- mercury_wrapper.c 1998/08/10 07:17:54 1.22
+++ mercury_wrapper.c 1998/08/21 02:46:48
@@ -595,13 +595,13 @@
case 'd':
if (streq(MR_optarg, "b"))
- nondstackdebug = TRUE;
+ MR_nondstackdebug = TRUE;
else if (streq(MR_optarg, "c"))
- calldebug = TRUE;
+ MR_calldebug = TRUE;
else if (streq(MR_optarg, "d"))
- detaildebug = TRUE;
+ MR_detaildebug = TRUE;
else if (streq(MR_optarg, "g"))
- gotodebug = TRUE;
+ MR_gotodebug = TRUE;
else if (streq(MR_optarg, "G"))
#ifdef CONSERVATIVE_GC
GC_quiet = FALSE;
@@ -609,28 +609,30 @@
; /* ignore inapplicable option */
#endif
else if (streq(MR_optarg, "s"))
- detstackdebug = TRUE;
+ MR_detstackdebug = TRUE;
else if (streq(MR_optarg, "h"))
- heapdebug = TRUE;
+ MR_heapdebug = TRUE;
else if (streq(MR_optarg, "f"))
- finaldebug = TRUE;
+ MR_finaldebug = TRUE;
else if (streq(MR_optarg, "p"))
- progdebug = TRUE;
+ MR_progdebug = TRUE;
else if (streq(MR_optarg, "m"))
- memdebug = TRUE;
+ MR_memdebug = TRUE;
else if (streq(MR_optarg, "r"))
- sregdebug = TRUE;
+ MR_sregdebug = TRUE;
else if (streq(MR_optarg, "t"))
- tracedebug = TRUE;
+ MR_tracedebug = TRUE;
+ else if (streq(MR_optarg, "T"))
+ MR_tabledebug = TRUE;
else if (streq(MR_optarg, "a")) {
- calldebug = TRUE;
- nondstackdebug = TRUE;
- detstackdebug = TRUE;
- heapdebug = TRUE;
- gotodebug = TRUE;
- sregdebug = TRUE;
- finaldebug = TRUE;
- tracedebug = TRUE;
+ MR_calldebug = TRUE;
+ MR_nondstackdebug = TRUE;
+ MR_detstackdebug = TRUE;
+ MR_heapdebug = TRUE;
+ MR_gotodebug = TRUE;
+ MR_sregdebug = TRUE;
+ MR_finaldebug = TRUE;
+ MR_tracedebug = TRUE;
#ifdef CONSERVATIVE_GC
GC_quiet = FALSE;
#endif
@@ -680,13 +682,13 @@
case 't':
use_own_timer = TRUE;
- calldebug = FALSE;
- nondstackdebug = FALSE;
- detstackdebug = FALSE;
- heapdebug = FALSE;
- gotodebug = FALSE;
- sregdebug = FALSE;
- finaldebug = FALSE;
+ MR_calldebug = FALSE;
+ MR_nondstackdebug = FALSE;
+ MR_detstackdebug = FALSE;
+ MR_heapdebug = FALSE;
+ MR_gotodebug = FALSE;
+ MR_sregdebug = FALSE;
+ MR_finaldebug = FALSE;
break;
case 'T':
@@ -802,12 +804,12 @@
}
#endif
- if (detaildebug) {
+ if (MR_detaildebug) {
debugregs("after final call");
}
#ifdef MR_LOWLEVEL_DEBUG
- if (memdebug) {
+ if (MR_memdebug) {
printf("\n");
#ifndef CONSERVATIVE_GC
printf("max heap used: %6ld words\n",
@@ -938,10 +940,10 @@
Define_label(global_success);
#ifdef MR_LOWLEVEL_DEBUG
- if (finaldebug) {
+ if (MR_finaldebug) {
save_transient_registers();
printregs("global succeeded");
- if (detaildebug)
+ if (MR_detaildebug)
dumpnondstack();
}
#endif
@@ -953,11 +955,11 @@
Define_label(global_fail);
#ifdef MR_LOWLEVEL_DEBUG
- if (finaldebug) {
+ if (MR_finaldebug) {
save_transient_registers();
printregs("global failed");
- if (detaildebug)
+ if (MR_detaildebug)
dumpnondstack();
}
#endif
@@ -973,7 +975,7 @@
MR_hp = (Word *) pop();
#ifdef MR_LOWLEVEL_DEBUG
- if (finaldebug && detaildebug) {
+ if (MR_finaldebug && MR_detaildebug) {
save_transient_registers();
printregs("after popping...");
}
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/general
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/tabling
Index: tests/tabling/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/tabling/Mmakefile,v
retrieving revision 1.1
diff -u -u -r1.1 Mmakefile
--- Mmakefile 1998/08/14 06:27:05 1.1
+++ Mmakefile 1998/08/21 02:57:24
@@ -7,11 +7,11 @@
#-----------------------------------------------------------------------------#
PROGS= \
+# boyer \
fib \
tc_loop
# We don't yet pass the following tests:
-# boyer \
# tc_minimal
#-----------------------------------------------------------------------------#
@@ -19,7 +19,7 @@
# at the moment tabling only works with conservative gc
GRADEFLAGS = --gc conservative
-# tc_loop is expected to fail, so we need to ignore the exit status
+# tc_loop is expected to abort, so we need to ignore the exit status
# (hence the leading `-')
tc_loop.out: tc_loop
-./tc_loop > tc_loop.out 2>&1;
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trial
cvs diff: Diffing util
More information about the developers
mailing list