[m-rev.] diff: tag on cell to be reused is unknown

Peter Ross peter.ross at miscrit.be
Tue Mar 13 23:37:57 AEDT 2001


Hi,



===================================================================


Estimated hours taken: 0.25
Branches: main

Merge changes from the reuse branch back onto the main branch.

compiler/ml_unify_gen.m:
    Handle the case where the tag on the cell to be reused is unknown.
    
compiler/hlds_goal.m:
    Add a field which records what possible cons_ids the cell to be
    reused can be tagged with.

compiler/builtin_ops.m:
    Add the unary builtin operator strip_tag.

compiler/bytecode.m:
compiler/c_util.m:
compiler/java_util.m:
compiler/llds.m:
compiler/mlds_to_il.m:
compiler/opt_debug.m:
bytecode/mb_disasm.c:
bytecode/mb_exec.c:
    Handle the strip_tag operator.


Index: bytecode/mb_disasm.c
===================================================================
RCS file: /home/mercury1/repository/mercury/bytecode/mb_disasm.c,v
retrieving revision 1.3
diff -u -r1.3 mb_disasm.c
--- bytecode/mb_disasm.c	2001/02/19 02:05:46	1.3
+++ bytecode/mb_disasm.c	2001/03/13 12:21:57
@@ -920,7 +920,7 @@
 	"unmktag",
 	"mkbody",
 	"unmkbody",
-	"cast_to_unsigned",
+	"strip_tag",
 	"hash_string",
 	"bitwise_complement",
 	"not"
Index: bytecode/mb_exec.c
===================================================================
RCS file: /home/mercury1/repository/mercury/bytecode/mb_exec.c,v
retrieving revision 1.1
diff -u -r1.1 mb_exec.c
--- bytecode/mb_exec.c	2001/02/19 02:05:46	1.1
+++ bytecode/mb_exec.c	2001/03/13 12:21:57
@@ -1300,7 +1300,7 @@
 	unop_bad, 		/* unmktag */
 	unop_bad, 		/* mkbody */
 	unop_bad, 		/* unmkbody */
-	unop_bad,		/* cast_to_unsigned */
+	unop_bad,		/* strip_tag  */
 	unop_bad,		/* hash_string */
 	unop_bitwise_complement,
 	unop_not
Index: compiler/builtin_ops.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/builtin_ops.m,v
retrieving revision 1.5
diff -u -r1.5 builtin_ops.m
--- compiler/builtin_ops.m	2001/01/20 15:42:41	1.5
+++ compiler/builtin_ops.m	2001/03/13 12:21:58
@@ -24,6 +24,7 @@
 	--->	mktag
 	;	tag
 	;	unmktag
+	;	strip_tag
 	;	mkbody
 	;	unmkbody
 	;	hash_string
Index: compiler/bytecode.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/bytecode.m,v
retrieving revision 1.46
diff -u -r1.46 bytecode.m
--- compiler/bytecode.m	2001/02/19 02:05:56	1.46
+++ compiler/bytecode.m	2001/03/13 12:21:58
@@ -1126,8 +1126,7 @@
 unop_code(unmktag,		 2).
 unop_code(mkbody,		 3).
 unop_code(unmkbody,		 4).
-% We used to use value `5' for cast_to_unsigned.
-% This is now no longer used.
+unop_code(strip_tag,		 5).
 unop_code(hash_string,		 6).
 unop_code(bitwise_complement,	 7).
 unop_code((not),		 8).
@@ -1140,6 +1139,7 @@
 unop_debug(unmktag,		"unmktag").
 unop_debug(mkbody,		"mkbody").
 unop_debug(unmkbody,		"unmkbody").
+unop_debug(strip_tag,		"strip_tag").
 unop_debug(hash_string,		"has_string").
 unop_debug(bitwise_complement,	"bitwise_complement").
 unop_debug((not),		"not").
Index: compiler/c_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/c_util.m,v
retrieving revision 1.8
diff -u -r1.8 c_util.m
--- compiler/c_util.m	2001/03/01 15:52:35	1.8
+++ compiler/c_util.m	2001/03/13 12:21:58
@@ -212,6 +212,7 @@
 c_util__unary_prefix_op(unmktag,		"MR_unmktag").
 c_util__unary_prefix_op(mkbody,			"MR_mkbody").
 c_util__unary_prefix_op(unmkbody,		"MR_unmkbody").
+c_util__unary_prefix_op(strip_tag,		"MR_strip_tag").
 c_util__unary_prefix_op(hash_string,		"MR_hash_string").
 c_util__unary_prefix_op(bitwise_complement,	"~").
 c_util__unary_prefix_op(not,			"!").
Index: compiler/hlds_goal.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_goal.m,v
retrieving revision 1.84
diff -u -r1.84 hlds_goal.m
--- compiler/hlds_goal.m	2001/02/05 00:46:41	1.84
+++ compiler/hlds_goal.m	2001/03/13 12:22:05
@@ -523,7 +523,8 @@
 :- type cell_to_reuse
 	---> cell_to_reuse(
 		prog_var,
-		cons_id,
+		list(cons_id),	% The cell to be reused may be tagged
+				% with one of these cons_ids.
 		list(bool)      % A `no' entry means that the corresponding
 				% argument already has the correct value
 				% and does not need to be filled in.
Index: compiler/java_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/java_util.m,v
retrieving revision 1.1
diff -u -r1.1 java_util.m
--- compiler/java_util.m	2001/03/01 15:52:35	1.1
+++ compiler/java_util.m	2001/03/13 12:22:07
@@ -76,13 +76,15 @@
 
 %-----------------------------------------------------------------------------%
 
-% XXX I'm not sure what the first six of these should be
+% XXX I'm not sure what the first seven of these should be
 %     for the Java backend.
 java_util__unary_prefix_op(mktag, _) :-
 	unexpected(this_file, "Java backend does not support tags").
 java_util__unary_prefix_op(tag,	_) :-
 	unexpected(this_file, "Java backend does not support tags").
 java_util__unary_prefix_op(unmktag, _) :-
+	unexpected(this_file, "Java backend does not support tags").
+java_util__unary_prefix_op(strip_tag, _) :-
 	unexpected(this_file, "Java backend does not support tags").
 java_util__unary_prefix_op(mkbody, _) :-
 	unexpected(this_file, "Java backend does not support tags").
Index: compiler/llds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds.m,v
retrieving revision 1.273
diff -u -r1.273 llds.m
--- compiler/llds.m	2001/01/20 15:42:42	1.273
+++ compiler/llds.m	2001/03/13 12:22:08
@@ -1157,6 +1157,7 @@
 llds__unop_return_type(mktag, word).
 llds__unop_return_type(tag, word).
 llds__unop_return_type(unmktag, word).
+llds__unop_return_type(strip_tag, word).
 llds__unop_return_type(mkbody, word).
 llds__unop_return_type(unmkbody, word).
 llds__unop_return_type(hash_string, integer).
@@ -1166,6 +1167,7 @@
 llds__unop_arg_type(mktag, word).
 llds__unop_arg_type(tag, word).
 llds__unop_arg_type(unmktag, word).
+llds__unop_arg_type(strip_tag, word).
 llds__unop_arg_type(mkbody, word).
 llds__unop_arg_type(unmkbody, word).
 llds__unop_arg_type(hash_string, word).
Index: compiler/ml_unify_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_unify_gen.m,v
retrieving revision 1.31
diff -u -r1.31 ml_unify_gen.m
--- compiler/ml_unify_gen.m	2001/03/09 14:35:27	1.31
+++ compiler/ml_unify_gen.m	2001/03/13 12:22:13
@@ -1041,7 +1041,7 @@
 		{ MLDS_Statements = [AssignStatement] }
 	;
 		{ HowToConstruct = reuse_cell(CellToReuse) },
-		{ CellToReuse = cell_to_reuse(ReuseVar, ReuseConsId, _) },
+		{ CellToReuse = cell_to_reuse(ReuseVar, ReuseConsIds, _) },
 
 		{ MaybeConsId = yes(ConsId0) ->
 			ConsId = ConsId0
@@ -1049,10 +1049,17 @@
 			error("ml_gen_new_object: unknown cons id")
 		},
 
-		ml_variable_type(ReuseVar, ReuseType),
-		ml_cons_id_to_tag(ReuseConsId, ReuseType, ReuseConsIdTag),
-		{ ml_tag_offset_and_argnum(ReuseConsIdTag,
-				ReusePrimaryTag, _ReuseOffSet, _ReuseArgNum) },
+		list__map_foldl(
+			(pred(ReuseConsId::in, ReusePrimTag::out,
+					in, out) is det -->
+				ml_variable_type(ReuseVar, ReuseType),
+				ml_cons_id_to_tag(ReuseConsId, ReuseType,
+						ReuseConsIdTag),
+				{ ml_tag_offset_and_argnum(ReuseConsIdTag,
+						ReusePrimTag,
+						_ReuseOffSet, _ReuseArgNum) }
+			), ReuseConsIds, ReusePrimaryTags0),
+		{ list__remove_dups(ReusePrimaryTags0, ReusePrimaryTags) },
 
 		ml_cons_id_to_tag(ConsId, Type, ConsIdTag),
 		ml_field_names_and_types(Type, ConsId, ArgTypes, Fields),
@@ -1061,12 +1068,23 @@
 
 		ml_gen_var(Var, Var1Lval),
 		ml_gen_var(ReuseVar, Var2Lval),
-		{ ReusePrimaryTag = PrimaryTag ->
+
+		{ list__filter((pred(ReuseTag::in) is semidet :-
+				ReuseTag \= PrimaryTag
+			), ReusePrimaryTags, DifferentTags) },
+		{ DifferentTags = [] ->
 			Var2Rval = lval(Var2Lval)
-		;
+		; DifferentTags = [ReusePrimaryTag] ->
+				% The body operator is slightly more
+				% efficient than the strip_tag operator so
+				% we use it when the old tag is known.
 			Var2Rval = mkword(PrimaryTag,
 					binop(body, lval(Var2Lval),
 					ml_gen_mktag(ReusePrimaryTag)))
+		;
+			Var2Rval = mkword(PrimaryTag,
+					unop(std_unop(strip_tag),
+					lval(Var2Lval)))
 		},
 
 		{ MLDS_Statement = ml_gen_assign(Var1Lval, Var2Rval, Context) },
Index: compiler/mlds_to_il.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_il.m,v
retrieving revision 1.13
diff -u -r1.13 mlds_to_il.m
--- compiler/mlds_to_il.m	2001/02/20 07:52:18	1.13
+++ compiler/mlds_to_il.m	2001/03/13 12:22:15
@@ -1299,6 +1299,7 @@
 unaryop_to_il(std_unop(tag), _, Instrs) --> 
 	load(const(int_const(0)), Instrs).
 unaryop_to_il(std_unop(unmktag), _, comment_node("unmktag (a no-op)")) --> [].
+unaryop_to_il(std_unop(strip_tag),_,comment_node("strip_tag (a no-op)")) --> [].
 unaryop_to_il(std_unop(mkbody),	_, comment_node("mkbody (a no-op)")) --> [].
 unaryop_to_il(std_unop(unmkbody), _, comment_node("unmkbody (a no-op)")) --> [].
 
Index: compiler/opt_debug.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/opt_debug.m,v
retrieving revision 1.112
diff -u -r1.112 opt_debug.m
--- compiler/opt_debug.m	2001/01/20 15:42:47	1.112
+++ compiler/opt_debug.m	2001/03/13 12:22:17
@@ -861,6 +861,7 @@
 opt_debug__dump_unop(mktag, "mktag").
 opt_debug__dump_unop(tag, "tag").
 opt_debug__dump_unop(unmktag, "unmktag").
+opt_debug__dump_unop(strip_tag, "strip_tag").
 opt_debug__dump_unop(mkbody, "mkbody").
 opt_debug__dump_unop(unmkbody, "unmkbody").
 opt_debug__dump_unop(not, "not").

--------------------------------------------------------------------------
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