[m-rev.] diff: minimal model improvements

Zoltan Somogyi zs at cs.mu.OZ.AU
Fri Jun 10 17:12:11 AEST 2005


A bunch of improvements for minimal model tabling.

compiler/code_info.m:
	Improve the code we generate for model_non disjunctions with
	--no-allow-hijacks, which is implied by the usual (stack copy)
	version of minimal model tabling. When the top stack frame is the
	current procedure's ordinary frame, and its redoip is still do_fail,
	then use that redoip. Its use is not hijacking, because we are not
	hiding any choice from the code in runtime/mercury_minimal_model.c
	that looks for right branches in the SLD tree to prune; do_fail
	represents the ABSENCE of such a right branch.

compiler/table_gen.m:
	Instead of lying about the type of the one fixed argument of
	table_mm_answer_is_not_duplicate when hanging a foreign_proc that
	does several other things as well on that predicate, use a variant
	of that predicate with the right argument type specialized for this
	task.

library/table_builtin.m:
	Provide table_mm_answer_is_not_duplicate_shortcut.

library/table_builtin.m:
runtime/mercury_tabling.h:
	Make the implementation of table_mm_answer_is_not_duplicate be a
	foreign_proc, not hand-written code, for simpler maintenance.
	We gain no speedup from keeping it handwritten; the implementation
	isn't even used with --tabling-via-extra-args, which is now the
	default.

runtime/mercury_minimal_model.[ch]:
	Add some missing arguments on code inside a #ifdef, to make the code
	compile in dmm (debugging minimal model) grades.

runtime/mercury_tabling.[ch]:
	Fix the name of a C function in its definition, and delete Julien's
	attempt at a fix of its declaration.

Zoltan.

cvs diff: Diffing .
cvs diff: Diffing analysis
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/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/code_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/code_info.m,v
retrieving revision 1.299
diff -u -b -r1.299 code_info.m
--- compiler/code_info.m	10 Jun 2005 06:48:13 -0000	1.299
+++ compiler/code_info.m	10 Jun 2005 06:48:38 -0000
@@ -1436,7 +1436,8 @@
 
 code_info__prepare_for_disj_hijack(CodeModel, HijackInfo, Code, !CI) :-
     code_info__get_fail_info(!.CI, FailInfo),
-    FailInfo = fail_info(_, ResumeKnown, CurfrMaxfr, CondEnv, Allow),
+    FailInfo = fail_info(ResumePoints, ResumeKnown, CurfrMaxfr, CondEnv,
+        Allow),
     (
         CodeModel \= model_non
     ->
@@ -1445,11 +1446,30 @@
             comment("disj no hijack") - ""
         ])
     ;
-        ( Allow = not_allowed ; CondEnv = inside_non_condition )
+        CondEnv = inside_non_condition
     ->
         HijackInfo = disj_temp_frame,
         code_info__create_temp_frame(do_fail, "prepare for disjunction",
             Code, !CI)
+    ;
+        Allow = not_allowed
+    ->
+        (
+            CurfrMaxfr = must_be_equal,
+            ResumeKnown = resume_point_known(has_been_done),
+            stack__pop(ResumePoints, TopResumePoint, RestResumePoints),
+            stack__is_empty(RestResumePoints),
+            TopResumePoint = stack_only(_, do_fail)
+        ->
+            HijackInfo = disj_quarter_hijack,
+            Code = node([
+                comment("disj quarter hijack of do_fail") - ""
+            ])
+        ;
+            HijackInfo = disj_temp_frame,
+            code_info__create_temp_frame(do_fail, "prepare for disjunction",
+                Code, !CI)
+        )
     ;
         CurfrMaxfr = must_be_equal,
         ResumeKnown = resume_point_known(has_been_done)
Index: compiler/table_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/table_gen.m,v
retrieving revision 1.85
diff -u -b -r1.85 table_gen.m
--- compiler/table_gen.m	7 Jun 2005 13:06:41 -0000	1.85
+++ compiler/table_gen.m	9 Jun 2005 08:10:01 -0000
@@ -2358,6 +2358,7 @@
         SaveDeclCode, CreateSaveCode),
 
     DuplCheckPredName = "table_mm_answer_is_not_duplicate",
+    DuplCheckPredNameShortCut = DuplCheckPredName ++ "_shortcut",
     (
         TablingViaExtraArgs = yes,
         SubgoalName = subgoal_name,
@@ -2381,7 +2382,7 @@
         PostStr = "\tif (" ++ SuccName ++ ") {\n" ++
             CreateSaveCode ++ "\t}\n" ++
             AssignSuccessCodeStr,
-        table_generate_foreign_proc(DuplCheckPredName, semidet,
+        table_generate_foreign_proc(DuplCheckPredNameShortCut, semidet,
             tabling_c_attributes, Args, LookupForeignArgs,
             PreStr, DuplCheckCodeStr, PostStr, impure_code, [],
             ModuleInfo, Context, DuplicateCheckSaveGoal),
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
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/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_glut
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/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
Index: library/table_builtin.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/table_builtin.m,v
retrieving revision 1.45
diff -u -b -r1.45 table_builtin.m
--- library/table_builtin.m	8 Jun 2005 04:13:06 -0000	1.45
+++ library/table_builtin.m	8 Jun 2005 07:58:35 -0000
@@ -833,6 +833,8 @@
 	% If the answer has been generated before, fail.
 	%
 :- impure pred table_mm_answer_is_not_duplicate(ml_trie_node::in) is semidet.
+:- impure pred table_mm_answer_is_not_duplicate_shortcut(ml_subgoal::in)
+	is semidet.
 
 	% Create a new slot in the answer list of the subgoal, create a new
 	% answer block of the given size, and put the answer block in the new
@@ -881,7 +883,6 @@
 	%
 :- external(table_mm_suspend_consumer/2).
 :- external(table_mm_completion/1).
-:- external(table_mm_answer_is_not_duplicate/1).
 :- external(table_mm_return_all_nondet/2).
 :- external(table_mm_return_all_multi/2).
 
@@ -900,6 +901,26 @@
 ").
 
 :- pragma foreign_proc("C",
+	table_mm_answer_is_not_duplicate(TrieNode::in),
+	[will_not_call_mercury],
+"
+	MR_table_mm_answer_is_not_duplicate(TrieNode, SUCCESS_INDICATOR);
+").
+
+:- pragma foreign_proc("C",
+	table_mm_answer_is_not_duplicate_shortcut(Subgoal::in),
+	[will_not_call_mercury],
+"
+	/*
+	** The body of this predicate doesn't matter, because it will never be
+	** referred to. When the compiler creates references to this predicate,
+	** it always overrides the predicate body.
+	*/
+	/* mention Subgoal to shut up the warning */
+	MR_fatal_error(""table_mm_answer_is_not_duplicate_shortcut: direct call"");
+").
+
+:- pragma foreign_proc("C",
 	table_mm_create_answer_block(Subgoal::in, Size::in, AnswerBlock::out),
 	[will_not_call_mercury],
 "
@@ -924,6 +945,18 @@
 	% matching foreign_proc version.
 	semipure private_builtin__semip,
 	private_builtin__sorry("table_mm_get_answer_table").
+
+table_mm_answer_is_not_duplicate(_) :-
+	% This version is only used for back-ends for which there is no
+	% matching foreign_proc version.
+	impure private_builtin__imp,
+	private_builtin__sorry("table_mm_answer_is_not_duplicate").
+
+table_mm_answer_is_not_duplicate_shortcut(_) :-
+	% This version is only used for back-ends for which there is no
+	% matching foreign_proc version.
+	impure private_builtin__imp,
+	private_builtin__sorry("table_mm_answer_is_not_duplicate_shortcut").
 
 table_mm_create_answer_block(_, _, _) :-
 	% This version is only used for back-ends for which there is no
cvs diff: Diffing mdbcomp
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
Index: runtime/mercury_minimal_model.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_minimal_model.c,v
retrieving revision 1.17
diff -u -b -r1.17 mercury_minimal_model.c
--- runtime/mercury_minimal_model.c	2 Aug 2004 03:08:25 -0000	1.17
+++ runtime/mercury_minimal_model.c	10 Jun 2005 07:09:28 -0000
@@ -2,7 +2,7 @@
 ** vim: ts=4 sw=4 expandtab
 */
 /*
-** Copyright (C) 2003-2004 The University of Melbourne.
+** Copyright (C) 2003-2005 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.
 */
@@ -1012,7 +1012,7 @@
     }
 
     if (MR_tablestackdebug) {
-        MR_dump_nondet_stack_from_layout(stdout, start_non, 0, MR_maxfr,
+        MR_dump_nondet_stack_from_layout(stdout, start_non, 0, 0, MR_maxfr,
             top_layout, MR_sp, MR_curfr);
     }
   #endif /* MR_TABLE_DEBUG */
@@ -1101,7 +1101,7 @@
   #ifdef MR_MINIMAL_MODEL_DEBUG
     if (MR_tablestackdebug) {
         MR_dump_nondet_stack_from_layout(stdout,
-            saved_state->MR_ss_non_stack_real_start, 0, MR_maxfr,
+            saved_state->MR_ss_non_stack_real_start, 0, 0, MR_maxfr,
             saved_state->MR_ss_top_layout, MR_sp, MR_curfr);
     }
   #endif /* MR_MINIMAL_MODEL_DEBUG */
@@ -1703,21 +1703,12 @@
         "minimal model tabling with --high-level-code");
 }
 
-void MR_CALL
-mercury__table_builtin__table_mm_answer_is_not_duplicate_1_p_0(
-    MR_C_Pointer subgoal_table_node)
-{
-    MR_fatal_error("sorry, not implemented: "
-        "minimal model tabling with --high-level-code");
-}
-
 #else   /* ! MR_HIGHLEVEL_CODE */
 
 MR_define_extern_entry(MR_MMSC_SUSPEND_ENTRY);
 MR_define_extern_entry(MR_MMSC_COMPLETION_ENTRY);
 MR_define_extern_entry(MR_MMSC_RET_ALL_NONDET_ENTRY);
 MR_define_extern_entry(MR_MMSC_RET_ALL_MULTI_ENTRY);
-MR_define_extern_entry(MR_MMSC_IS_NOT_DUPL_ENTRY);
 
 MR_EXTERN_USER_PROC_ID_PROC_LAYOUT(MR_DETISM_NON, 0, -1,
     MR_PREDICATE, table_builtin, table_mm_suspend_consumer, 2, 0);
@@ -1727,8 +1718,6 @@
     MR_PREDICATE, table_builtin, table_mm_return_all_nondet, 2, 0);
 MR_EXTERN_USER_PROC_ID_PROC_LAYOUT(MR_DETISM_NON, 0, -1,
     MR_PREDICATE, table_builtin, table_mm_return_all_multi, 2, 0);
-MR_EXTERN_USER_PROC_ID_PROC_LAYOUT(MR_DETISM_NON, 0, -1,
-    MR_PREDICATE, table_builtin, table_mm_answer_is_not_duplicate, 1, 0);
 
 #ifndef  MR_USE_MINIMAL_MODEL_STACK_COPY
 
@@ -1737,12 +1726,10 @@
     MR_init_entry_sl(MR_MMSC_COMPLETION_ENTRY);
     MR_init_entry_sl(MR_MMSC_RET_ALL_NONDET_ENTRY);
     MR_init_entry_sl(MR_MMSC_RET_ALL_MULTI_ENTRY);
-    MR_init_entry_sl(MR_MMSC_IS_NOT_DUPL_ENTRY);
     MR_INIT_PROC_LAYOUT_ADDR(MR_MMSC_SUSPEND_ENTRY);
     MR_INIT_PROC_LAYOUT_ADDR(MR_MMSC_COMPLETION_ENTRY);
     MR_INIT_PROC_LAYOUT_ADDR(MR_MMSC_RET_ALL_NONDET_ENTRY);
     MR_INIT_PROC_LAYOUT_ADDR(MR_MMSC_RET_ALL_MULTI_ENTRY);
-    MR_INIT_PROC_LAYOUT_ADDR(MR_MMSC_IS_NOT_DUPL_ENTRY);
 MR_BEGIN_CODE
 
 MR_define_entry(MR_MMSC_SUSPEND_ENTRY);
@@ -1757,9 +1744,6 @@
 MR_define_entry(MR_MMSC_RET_ALL_MULTI_ENTRY);
     MR_fatal_error("call to table_mm_return_all_multi/2 in a grade "
         "without stack copy minimal model tabling");
-MR_define_entry(MR_MMSC_IS_NOT_DUPL_ENTRY);
-    MR_fatal_error("call to table_mm_answer_is_not_duplicate/1 in a grade "
-        "without stack copy minimal model tabling");
 MR_END_MODULE
 
 #else   /* MR_USE_MINIMAL_MODEL_STACK_COPY */
@@ -1831,8 +1815,6 @@
     MR_init_entry_sl(MR_MMSC_RET_ALL_MULTI_ENTRY);
     MR_INIT_PROC_LAYOUT_ADDR(MR_MMSC_RET_ALL_MULTI_ENTRY);
     MR_init_label_sl(RET_ALL_MULTI_LABEL(Next));
-
-    MR_init_entry_sl(MR_MMSC_IS_NOT_DUPL_ENTRY);
 MR_BEGIN_CODE
 
 MR_define_entry(MR_MMSC_SUSPEND_ENTRY);
@@ -2512,15 +2494,6 @@
     MR_r1 = (MR_Word) AnswerBlock;
 }
     MR_succeed();
-
-MR_define_entry(MR_MMSC_IS_NOT_DUPL_ENTRY);
-{
-    MR_TrieNode T;
-
-    T = (MR_TrieNode) MR_r1;
-    MR_table_mm_answer_is_not_duplicate(T, MR_r1);
-}
-    MR_proceed();
 
 MR_END_MODULE
 
Index: runtime/mercury_minimal_model.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_minimal_model.h,v
retrieving revision 1.12
diff -u -b -r1.12 mercury_minimal_model.h
--- runtime/mercury_minimal_model.h	2 Aug 2004 03:08:25 -0000	1.12
+++ runtime/mercury_minimal_model.h	8 Jun 2005 06:05:09 -0000
@@ -249,9 +249,6 @@
   extern void MR_CALL
   	mercury__table_builtin__table_mm_return_all_multi_2_p_0(
 		MR_C_Pointer answer_list, MR_C_Pointer answer_block);
-  extern void MR_CALL
-  	mercury__table_builtin__table_mm_answer_is_not_duplicate_1_p_0(
-		MR_C_Pointer subgoal_table_node);
 
 #else	/* ! MR_HIGHLEVEL_CODE */
 
@@ -267,15 +264,11 @@
   #define MR_MMSC_RET_ALL_MULTI_ENTRY					\
 	MR_proc_entry_user_name(table_builtin,				\
 		table_mm_return_all_multi, 2, 0)
-  #define MR_MMSC_IS_NOT_DUPL_ENTRY					\
-	MR_proc_entry_user_name(table_builtin,				\
-		table_mm_answer_is_not_duplicate, 1, 0)
 
   MR_declare_entry(MR_MMSC_SUSPEND_ENTRY);
   MR_declare_entry(MR_MMSC_COMPLETION_ENTRY);
   MR_declare_entry(MR_MMSC_RET_ALL_NONDET_ENTRY);
   MR_declare_entry(MR_MMSC_RET_ALL_MULTI_ENTRY);
-  MR_declare_entry(MR_MMSC_IS_NOT_DUPL_ENTRY);
 
 #endif	/* !MR_HIGHLEVEL_CODE */
 
Index: runtime/mercury_tabling.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_tabling.c,v
retrieving revision 1.67
diff -u -b -r1.67 mercury_tabling.c
--- runtime/mercury_tabling.c	7 Jun 2005 03:00:03 -0000	1.67
+++ runtime/mercury_tabling.c	8 Jun 2005 07:28:36 -0000
@@ -484,7 +484,7 @@
 }
 
 MR_TrieNode
-MR_ptr_hash_lookup(MR_TrieNode t, MR_Word key)
+MR_word_hash_lookup(MR_TrieNode t, MR_Word key)
 {
 #define key_format              "%p"
 #define key_cast                (MR_Word)
Index: runtime/mercury_tabling.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_tabling.h,v
retrieving revision 1.39
diff -u -b -r1.39 mercury_tabling.h
--- runtime/mercury_tabling.h	9 Jun 2005 10:50:25 -0000	1.39
+++ runtime/mercury_tabling.h	10 Jun 2005 07:08:10 -0000
@@ -193,8 +193,6 @@
 				MR_ConstString key);
 extern	MR_TrieNode	MR_word_hash_lookup_or_add(MR_TrieNode table,
 				MR_Word key);
-extern	MR_TrieNode	MR_ptr_hash_lookup(MR_TrieNode table,
-				MR_Word key);
 
 /*
 ** This function assumes that the table is a statically sized array,
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 samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing slice
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
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