[m-dev.] for review: compressing RTTI using non-word creates (part 2)

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Apr 26 17:38:46 AEST 1999


Index: compiler/stack_layout.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/stack_layout.m,v
retrieving revision 1.27
diff -u -b -u -r1.27 stack_layout.m
--- stack_layout.m	1999/04/16 06:04:54	1.27
+++ stack_layout.m	1999/04/26 05:23:13
@@ -14,8 +14,7 @@
 % We can create several types of stack layouts. Which kind we generate
 % depends on the values of several options.
 %
-% Main author: trd.
-% Modifications by zs.
+% Main authors: trd, zs.
 %
 % NOTE: If you make changes in this file, you may also need to modify
 % runtime/mercury_stack_layout.h.
@@ -30,11 +29,11 @@
 % This structure will always contain the following information:
 %
 %	code address		(Code *) - address of entry
-% 	determinism		(Integer) actually, type MR_Determinism
-% 	number of stack slots	(Integer)
-% 	succip stack location	(Integer) actually, type MR_Live_Lval
+% 	succip stack location	(uint_least32_t) actually, type MR_Live_Lval
 % 					(the location will be set to -1
 % 					if there is no succip available).
+% 	number of stack slots	(uint_least16_t)
+% 	determinism		(uint_least16_t) actually, type MR_Determinism
 %
 % If the option procid_stack_layout is set, i.e. if we are doing stack
 % tracing, execution tracing or profiling, the structure will also include
@@ -70,10 +69,10 @@
 % tracing, the structure will also include three extra fields:
 %
 %	call trace info		(Word *) - pointer to label stack layout
-%	maybe from full		(Integer) - number of the stack slot of
+%	maybe from full		(int_least16_t) - number of the stack slot of
 %				the from_full flag, if the procedure is
 %				shallow traced
-%	maybe decl debug	(Integer) - number of the first of two
+%	maybe decl debug	(int_least16_t) - number of the first of two
 %				stack slots used by the declarative debugger,
 %				if --trace-decl is set
 %
@@ -105,20 +104,53 @@
 % This table has the following format:
 %
 %	procedure info		(Word *) - pointer to procedure stack layout
-% 	# of live vars		(Integer)
-% 	live data pairs 	(Word *) - pointer to vector of pairs
-%				containing MR_Live_Lval and MR_Live_Type
-% 	live data names	 	(Word *) - pointer to vector of String
-%	type parameters		(Word *) - pointer to vector of MR_Live_Lval
-%				in which the first word is an Integer
-%				giving the number of entries in the vector;
-%				a NULL pointer means no type parameters
+% 	# of live data item	(void *) - an encoded representation of
+%				the number of live data items at the label
+% 	live data types locns 	(void *) - pointer to an area of memory
+%				containing information about where the live
+%				data items are and what their types are
+% 	live data names	 	(String *) - pointer to vector of String
+%				giving the names of the data items, if any
+%	type parameters		(MR_Long_Lval *) - pointer to vector of
+%			 	MR_Long_Lval giving the locations of the
+%				typeinfos for the type parameters that may
+%				be referred to by the types of the live data
+%				items; the first word of the vector is an
+%				integer giving the number of entries in the
+%				vector; a NULL pointer means no type parameters
+%
+% The layout of the memory area containing information about the locations
+% and types of live data items is somewhat complicated, due to our desire
+% to make this information compact. We can represent a location in one of
+% two ways, as an 8-bit MR_Short_Lval or as a 32-bit MR_Long_Lval.
+% We prefer representing a location as an MR_Short_Lval, but of course
+% not all locations can be represented in this way, so those other locations
+% are represented as MR_Long_Lvals.
+%
+% The field containing the number of live data items is encoded by the
+% formula (#Long << 8 + #Short), where #Short is the number data items whose
+% descriptions fit into an MR_Short_Lval and #Long is the number of data
+% items whose descriptions do not. (The field is not an integer so that
+% people who attempt to use it without going through the decoding macros
+% in runtime/mercury_stack_layout.h get an error from the C compiler).
+%
+% The memory area contains three vectors back to back. The first vector
+% has #Long + #Short word-sized elements, each of which is a pointer to a
+% MR_PseudoTypeInfo giving the type of a live data item, with a small
+% integer instead of a pointer representing a special kind of live data item
+% (e.g. a saved succip or hp). The second vector is an array of #Long
+% MR_Long_Lvals, and the third is an array of #Short MR_Short_Lvals,
+% each of which describes a location. The pseudotypeinfo pointed to by
+% the slot at subscript i in the first vector describes the type of
+% the data stored in slot i in the second vector if i < #Long, and
+% the type of the data stored in slot i - #Long in the third vector
+% otherwise.
 %
 % The live data pair vector will have an entry for each live variable.
 % The entry will give the location of the variable and its type. (It also
 % has room for its instantiation state, but this is not filled in yet.)
 %
-% The live data name vector pointer will be NULL. If it is not, the vector
+% The live data name vector pointer may be NULL. If it is not, the vector
 % will have an entry for each live variable, with each entry giving the name
 % of the variable (it is either a pointer to a string, or a NULL pointer,
 % which means that the variable has no name).
@@ -183,7 +215,7 @@
 
 :- pred stack_layout__construct_closure_layout(proc_label::in,
 	maybe(closure_layout_info)::in, list(maybe(rval))::out,
-	int::in, int::out) is det.
+	create_arg_types::out, int::in, int::out) is det.
 
 :- implementation.
 
@@ -193,20 +225,6 @@
 :- import_module assoc_list, bool, string, int, require.
 :- import_module map, term, set.
 
-:- type stack_layout_info 	--->
-	stack_layout_info(
-		module_name,	% module name
-		int,		% next available cell number
-		bool,		% generate agc layout info?
-		bool,		% generate tracing layout info?
-		bool,		% generate procedure id layout info?
-		bool,		% have static code addresses?
-		list(comp_gen_c_data),	% generated proc layouts
-		list(comp_gen_c_data),	% generated label layouts
-		set_bbbtree(label)
-				% the set of labels with layouts
-	).
-
 %---------------------------------------------------------------------------%
 
 	% Process all the continuation information stored in the HLDS,
@@ -301,13 +319,6 @@
 			% similar constraints.
 		Location = -1
 	},
-	{ determinism_components(Detism, _, at_most_many) ->
-		SuccipLval = framevar(Location)
-	;
-		SuccipLval = stackvar(Location)
-	},
-	{ stack_layout__represent_locn(direct(SuccipLval), SuccipRval) },
-	{ StackSlotsRval = const(int_const(StackSlots)) },
 	stack_layout__get_static_code_addresses(StaticCodeAddr),
 	{ StaticCodeAddr = yes ->
 		CodeAddrRval = const(code_addr_const(label(EntryLabel)))
@@ -316,38 +327,67 @@
 		% at initialization time.
 		CodeAddrRval = const(int_const(0))
 	},
-
+	{ determinism_components(Detism, _, at_most_many) ->
+		SuccipLval = framevar(Location)
+	;
+		SuccipLval = stackvar(Location)
+	},
+	{ stack_layout__represent_locn_as_int(direct(SuccipLval), SuccipRval) },
+	{ StackSlotsRval = const(int_const(StackSlots)) },
 	{ stack_layout__represent_determinism(Detism, DetismRval) },
-	{ MaybeRvals0 = [yes(CodeAddrRval), yes(DetismRval),
-		yes(StackSlotsRval), yes(SuccipRval)] },
+	{ TraversalRvals = [yes(CodeAddrRval), yes(SuccipRval),
+		yes(StackSlotsRval), yes(DetismRval)] },
+	{ TraversalArgTypes = [1 - yes(code_ptr), 1 - yes(uint32), 
+		2 - yes(uint16)] },
 
 	stack_layout__get_procid_stack_layout(ProcIdLayout0),
 	{ bool__or(ProcIdLayout0, ForceProcIdLayout, ProcIdLayout) },
-	{
-		ProcIdLayout = yes
+	(
+		{ ProcIdLayout = yes }
 	->
-		code_util__extract_proc_label_from_label(EntryLabel, ProcLabel),
-		stack_layout__construct_procid_rvals(ProcLabel, IdRvals),
-		list__append(MaybeRvals0, IdRvals, MaybeRvals1)
-	;
-		% Indicate the absence of the procedure id fields.
-		NoIdRvals = yes(const(int_const(-1))),
-		list__append(MaybeRvals0, [NoIdRvals], MaybeRvals1)
-	},
+		{ code_util__extract_proc_label_from_label(EntryLabel,
+			ProcLabel) },
+		{ stack_layout__construct_procid_rvals(ProcLabel, IdRvals,
+			IdArgTypes) },
+		stack_layout__construct_trace_layout(MaybeCallLabel,
+			TraceSlotInfo, TraceRvals, TraceArgTypes),
+		{ list__append(IdRvals, TraceRvals, IdTraceRvals) },
+		{ IdTraceArgTypes = initial(IdArgTypes, TraceArgTypes) }
+	;
+		% Indicate the absence of the proc id and exec trace fields.
+		{ IdTraceRvals = [yes(const(int_const(-1)))] },
+		{ IdTraceArgTypes = initial([1 - yes(word)], none) }
+	),
 
+	{ Exported = no },	% XXX With the new profiler, we will need to
+				% set this to `yes' if the profiling option
+				% is given and if the procedure is exported.
+				% Beware however that linkage/2 in llds_out.m
+				% assumes that this is `no'.
+	{ list__append(TraversalRvals, IdTraceRvals, Rvals) },
+	{ ArgTypes = initial(TraversalArgTypes, IdTraceArgTypes) },
+	stack_layout__get_module_name(ModuleName),
+	{ CData = comp_gen_c_data(ModuleName, proc_layout(EntryLabel),
+		Exported, Rvals, ArgTypes, []) },
+	stack_layout__add_proc_layout_data(CData, EntryLabel).
+
+:- pred stack_layout__construct_trace_layout(maybe(label)::in,
+	trace_slot_info::in, list(maybe(rval))::out, create_arg_types::out,
+	stack_layout_info::in, stack_layout_info::out) is det.
+
+stack_layout__construct_trace_layout(MaybeCallLabel, TraceSlotInfo,
+		Rvals, ArgTypes) -->
 	stack_layout__get_module_name(ModuleName),
 	stack_layout__get_trace_stack_layout(TraceLayout),
 	{
 		TraceLayout = yes
 	->
-		require(unify(ProcIdLayout, yes),
-			"trace_layout is set but proc_id_layout is not"),
 		( MaybeCallLabel = yes(CallLabel) ->
 			CallRval = yes(const(data_addr_const(
 					data_addr(ModuleName,
 						internal_layout(CallLabel)))))
 		;
-			error("stack_layout__construct_proc_layout: call label not present")
+			error("stack_layout__construct_trace_layout: call label not present")
 		),
 		TraceSlotInfo = trace_slot_info(MaybeFromFullSlot,
 			MaybeDeclSlots),
@@ -361,35 +401,21 @@
 		;
 			DeclRval = yes(const(int_const(-1)))
 		),
-		list__append(MaybeRvals1, [CallRval, FromFullRval, DeclRval],
-			MaybeRvals)
+		Rvals = [CallRval, FromFullRval, DeclRval],
+		ArgTypes = initial([1 - yes(data_ptr), 2 - yes(int16)],
+			none)
 	;
-		ProcIdLayout = yes
-	->
 		% Indicate the absence of the trace layout fields.
-		NoCallRval = yes(const(int_const(0))),
-		list__append(MaybeRvals1, [NoCallRval], MaybeRvals)
-	;
-		% The absence of the procedure id fields implies
-		% the absence of the trace layout fields as well.
-		MaybeRvals = MaybeRvals1
-	},
-
-	{ Exported = no },	% XXX With the new profiler, we will need to
-				% set this to `yes' if the profiling option
-				% is given and if the procedure is exported.
-				% Beware however that linkage/2 in llds_out.m
-				% assumes that this is `no'.
-	{ CData = comp_gen_c_data(ModuleName, proc_layout(EntryLabel),
-		Exported, MaybeRvals, []) },
-	stack_layout__add_proc_layout_data(CData, EntryLabel).
+		Rvals = [yes(const(int_const(0)))],
+		ArgTypes = initial([1 - yes(integer)], none)
+	}.
 
 %---------------------------------------------------------------------------%
 
 :- pred stack_layout__construct_procid_rvals(proc_label::in,
-	list(maybe(rval))::out) is det.
+	list(maybe(rval))::out, initial_arg_types::out) is det.
 
-stack_layout__construct_procid_rvals(ProcLabel, Rvals) :-
+stack_layout__construct_procid_rvals(ProcLabel, Rvals, ArgTypes) :-
 	(
 		ProcLabel = proc(DefModule, PredFunc, DeclModule,
 			PredName, Arity, ProcId),
@@ -404,7 +430,8 @@
 				yes(const(string_const(PredName))),
 				yes(const(int_const(Arity))),
 				yes(const(int_const(Mode)))
-			]
+			],
+		ArgTypes = [6 - no]
 	;
 		ProcLabel = special_proc(DefModule, PredName, TypeModule,
 			TypeName, Arity, ProcId),
@@ -418,7 +445,8 @@
 				yes(const(string_const(PredName))),
 				yes(const(int_const(Arity))),
 				yes(const(int_const(Mode)))
-			]
+			],
+		ArgTypes = [6 - no]
 	).
 
 :- pred stack_layout__represent_pred_or_func(pred_or_func::in, int::out) is det.
@@ -439,7 +467,8 @@
 	stack_layout__get_module_name(ModuleName),
 	{ EntryAddrRval = const(data_addr_const(data_addr(ModuleName,
 		proc_layout(EntryLabel)))) },
-	stack_layout__construct_internal_rvals(Internal, VarInfoRvals),
+	stack_layout__construct_internal_rvals(Internal, VarInfoRvals,
+		VarInfoRvalTypes),
 	% Reenable this code if you want label numbers in label layouts.
 	% { Label = local(_, LabelNum0) ->
 	% 	LabelNum = LabelNum0
@@ -447,20 +476,21 @@
 	% 	LabelNum = 0
 	% },
 	% { LabelNumRval = const(int_const(LabelNum)) },
-	% { LayoutRvals = [yes(EntryAddrRval), yes(LabelNumRval
+	% { LayoutRvals = [yes(EntryAddrRval), yes(LabelNumRval)
 	% 	| VarInfoRvals] }
 	{ LayoutRvals = [yes(EntryAddrRval) | VarInfoRvals] },
+	{ ArgTypes = initial([1 - no], VarInfoRvalTypes) },
 	{ CData = comp_gen_c_data(ModuleName, internal_layout(Label),
-		no, LayoutRvals, []) },
+		no, LayoutRvals, ArgTypes, []) },
 	stack_layout__add_internal_layout_data(CData, Label).
 
 	% Construct the rvals required for accurate GC or for tracing.
 
 :- pred stack_layout__construct_internal_rvals(internal_layout_info::in,
-	list(maybe(rval))::out,
+	list(maybe(rval))::out, create_arg_types::out,
 	stack_layout_info::in, stack_layout_info::out) is det.
 
-stack_layout__construct_internal_rvals(Internal, RvalList) -->
+stack_layout__construct_internal_rvals(Internal, RvalList, ArgTypes) -->
 	{ Internal = internal_layout_info(Port, Return) },
 	{
 		Port = no,
@@ -502,56 +532,63 @@
 			% about variables at this label. (Zero would say
 			% that there are no variables live at this label,
 			% which may not be true.)
-		{ RvalList = [yes(const(int_const(-1)))] }
+		{ RvalList = [yes(const(int_const(-1)))] },
+		{ ArgTypes = initial([1 - yes(integer)], none) }
 	;
 			% XXX ignore differences in insts inside var_infos
 		{ set__union(PortLiveVarSet, ReturnLiveVarSet, LiveVarSet) },
 		{ map__union(set__intersect, PortTypeVarMap, ReturnTypeVarMap,
 			TypeVarMap) },
 		stack_layout__construct_livelval_rvals(LiveVarSet,
-			TypeVarMap, RvalList)
+			TypeVarMap, RvalList, ArgTypes)
 	).
 
 %---------------------------------------------------------------------------%
 
 :- pred stack_layout__construct_livelval_rvals(set(var_info)::in,
 	map(tvar, set(layout_locn))::in, list(maybe(rval))::out,
-	stack_layout_info::in, stack_layout_info::out) is det.
+	create_arg_types::out, stack_layout_info::in, stack_layout_info::out)
+	is det.
 
-stack_layout__construct_livelval_rvals(LiveLvalSet, TVarLocnMap, RvalList) -->
+stack_layout__construct_livelval_rvals(LiveLvalSet, TVarLocnMap,
+		RvalList, ArgTypes) -->
 	{ set__to_sorted_list(LiveLvalSet, LiveLvals) },
 	{ list__length(LiveLvals, Length) },
-	{ VarLengthRval = const(int_const(Length)) },
 	( { Length > 0 } ->
 		{ stack_layout__sort_livevals(LiveLvals, SortedLiveLvals) },
-		stack_layout__construct_liveval_pairs(SortedLiveLvals,
-			LiveValRval, NamesRval),
+		stack_layout__construct_liveval_arrays(SortedLiveLvals,
+			VarLengthRval, LiveValRval, NamesRval),
 
 		( { map__is_empty(TVarLocnMap) } ->
 			{ TypeParamRval = const(int_const(0)) }
 		;
 			{ stack_layout__construct_tvar_rvals(TVarLocnMap,
-				Vector) },
+				Vector, VectorTypes) },
 			stack_layout__get_next_cell_number(CNum1),
-			{ TypeParamRval = create(0, Vector, no, CNum1,
+			{ TypeParamRval = create(0, Vector, VectorTypes,
+				must_be_static, CNum1,
 				"stack_layout_type_param_locn_vector") }
 		),
 		{ RvalList = [yes(VarLengthRval), yes(LiveValRval),
-			yes(NamesRval), yes(TypeParamRval)] }
+			yes(NamesRval), yes(TypeParamRval)] },
+		{ ArgTypes = initial([1 - yes(integer), 3 - yes(data_ptr)],
+			none) }
 	;
-		{ RvalList = [yes(VarLengthRval)] }
+		{ RvalList = [yes(const(int_const(0)))] },
+		{ ArgTypes = initial([1 - yes(integer)], none) }
 	).
 
 :- pred stack_layout__construct_tvar_rvals(map(tvar, set(layout_locn))::in,
-	list(maybe(rval))::out) is det.
+	list(maybe(rval))::out, create_arg_types::out) is det.
 
-stack_layout__construct_tvar_rvals(TVarLocnMap, Vector) :-
+stack_layout__construct_tvar_rvals(TVarLocnMap, Vector, VectorTypes) :-
 	map__to_assoc_list(TVarLocnMap, TVarLocns),
 	stack_layout__construct_type_param_locn_vector(TVarLocns, 1,
 		TypeParamLocs),
 	list__length(TypeParamLocs, TypeParamsLength),
 	LengthRval = const(int_const(TypeParamsLength)),
-	Vector = [yes(LengthRval) | TypeParamLocs].
+	Vector = [yes(LengthRval) | TypeParamLocs],
+	VectorTypes = uniform(yes(uint32)).
 
 %---------------------------------------------------------------------------%
 
@@ -644,7 +681,7 @@
 		;
 			error("tvar has empty set of locations")
 		),
-		stack_layout__represent_locn(Locn, Rval),
+		stack_layout__represent_locn_as_int(Locn, Rval),
 		stack_layout__construct_type_param_locn_vector(TVarLocns,
 			NextSlot, VectorTail),
 		Vector = [yes(Rval) | VectorTail]
@@ -658,44 +695,93 @@
 		error("unsorted tvars in construct_type_param_locn_vector")
 	).
 
+%---------------------------------------------------------------------------%
+
+:- type liveval_array_info
+	--->	live_array_info(rval, rval, rval).
+		% Rvals describing the location, type (eventually: shape)
+		% and name of a live value.
+
 	% Construct a vector of (locn, live_value_type) pairs,
 	% and a corresponding vector of variable names.
 
-:- pred stack_layout__construct_liveval_pairs(list(var_info)::in,
-	rval::out, rval::out, stack_layout_info::in, stack_layout_info::out)
-	is det.
+:- pred stack_layout__construct_liveval_arrays(list(var_info)::in,
+	rval::out, rval::out, rval::out,
+	stack_layout_info::in, stack_layout_info::out) is det.
 
-stack_layout__construct_liveval_pairs(LiveLvals, LocnVector, NameVector) -->
-	list__map_foldl(stack_layout__construct_liveval_pair, LiveLvals,
-		LocnTypePairs),
-	{ list__condense(LocnTypePairs, LocnTypeVectorArgs) },
+stack_layout__construct_liveval_arrays(VarInfos, LengthRval,
+		TypeLocnVector, NameVector) -->
+	stack_layout__construct_liveval_array_infos(VarInfos,
+		IntArrayInfo, ByteArrayInfo),
+
+	{ list__length(IntArrayInfo, IntArrayLength) },
+	{ list__length(ByteArrayInfo, ByteArrayLength) },
+	{ list__append(IntArrayInfo, ByteArrayInfo, AllArrayInfo) },
+	{ AllArrayLength is IntArrayLength + ByteArrayLength },
+
+	{ stack_layout__byte_bits(ByteBits) },
+	{ EncodedLength is IntArrayLength << ByteBits + ByteArrayLength },
+	{ LengthRval = const(int_const(EncodedLength)) },
+
+	{ SelectLocns = lambda([ArrayInfo::in, MaybeLocnRval::out] is det, (
+		ArrayInfo = live_array_info(LocnRval, _, _),
+		MaybeLocnRval = yes(LocnRval)
+	)) },
+	{ SelectTypes = lambda([ArrayInfo::in, MaybeTypeRval::out] is det, (
+		ArrayInfo = live_array_info(_, TypeRval, _),
+		MaybeTypeRval = yes(TypeRval)
+	)) },
+	{ SelectNames = lambda([ArrayInfo::in, MaybeNameRval::out] is det, (
+		ArrayInfo = live_array_info(_, _, NameRval),
+		MaybeNameRval = yes(NameRval)
+	)) },
+
+	{ list__map(SelectTypes, AllArrayInfo, AllTypes) },
+	{ list__map(SelectLocns, IntArrayInfo, IntLocns) },
+	{ list__map(SelectLocns, ByteArrayInfo, ByteLocns) },
+	{ list__append(IntLocns, ByteLocns, AllLocns) },
+	{ list__append(AllTypes, AllLocns, TypeLocnVectorRvals) },
+	{ ArgTypes = initial([AllArrayLength - yes(word),
+			IntArrayLength - yes(uint32),
+			ByteArrayLength - yes(uint8)], none) },
 	stack_layout__get_next_cell_number(CNum1),
-	{ LocnVector = create(0, LocnTypeVectorArgs, no, CNum1,
-		"stack_layout_locn_vector") },
+	{ TypeLocnVector = create(0, TypeLocnVectorRvals, ArgTypes,
+		must_be_static, CNum1, "stack_layout_locn_vector") },
 
-	{ list__map(stack_layout__construct_liveval_name, LiveLvals, Names) },
+	{ list__map(SelectNames, AllArrayInfo, AllNames) },
 	stack_layout__get_next_cell_number(CNum2),
-	{ NameVector = create(0, Names, no, CNum2,
-		"stack_layout_name_vector") }.
-
-	% Construct a pair of (locn, live_value_type) representations.
+	{ NameVector = create(0, AllNames, uniform(yes(string)),
+		must_be_static, CNum2, "stack_layout_name_vector") }.
 
-:- pred stack_layout__construct_liveval_pair(var_info::in,
-	list(maybe(rval))::out, stack_layout_info::in, stack_layout_info::out)
-	is det.
+:- pred stack_layout__construct_liveval_array_infos(list(var_info)::in,
+	list(liveval_array_info)::out, list(liveval_array_info)::out,
+	stack_layout_info::in, stack_layout_info::out) is det.
 
-stack_layout__construct_liveval_pair(var_info(Locn, LiveValueType),
-		MaybeRvals) -->
-	{ stack_layout__represent_locn(Locn, Rval0) },
-	stack_layout__represent_live_value_type(LiveValueType, Rval1),
-	{ MaybeRvals = [yes(Rval0), yes(Rval1)] }.
+stack_layout__construct_liveval_array_infos([], [], []) --> [].
+stack_layout__construct_liveval_array_infos([VarInfo | VarInfos],
+		IntVars, ByteVars) -->
+	stack_layout__construct_liveval_array_infos(VarInfos,
+		IntVars0, ByteVars0),
+	{ VarInfo = var_info(Locn, LiveValueType) },
+	stack_layout__represent_live_value_type(LiveValueType, TypeRval),
+	{ stack_layout__construct_liveval_name(VarInfo, NameRval) },
+	{ stack_layout__represent_locn_as_byte(Locn, LocnByteRval) ->
+		Var = live_array_info(LocnByteRval, TypeRval, NameRval),
+		IntVars = IntVars0,
+		ByteVars = [Var | ByteVars0]
+	;
+		stack_layout__represent_locn_as_int(Locn, LocnRval),
+		Var = live_array_info(LocnRval, TypeRval, NameRval),
+		IntVars = [Var | IntVars0],
+		ByteVars = ByteVars0
+	}.
 
-:- pred stack_layout__construct_liveval_name(var_info::in, maybe(rval)::out)
+:- pred stack_layout__construct_liveval_name(var_info::in, rval::out)
 	is det.
 
-stack_layout__construct_liveval_name(var_info(_, VarInfo), MaybeRval) :-
+stack_layout__construct_liveval_name(var_info(_, LiveValueType), Rval) :-
 	(
-		VarInfo = var(Var, Name, _, _),
+		LiveValueType = var(Var, Name, _, _),
 		Name \= ""
 	->
 		% We include a representation of the variable number at the
@@ -713,8 +799,7 @@
 		% We prefer a null pointer to a pointer to an empty string,
 		% since this way we don't need many copies of the empty string.
 		Rval = const(int_const(0))
-	),
-	MaybeRval = yes(Rval).
+	).
 
 %---------------------------------------------------------------------------%
 
@@ -723,30 +808,38 @@
 	% the data structures we build here.
 
 stack_layout__construct_closure_layout(ProcLabel, MaybeClosureLayoutInfo,
-		Rvals, CNum0, CNum) :-
-	stack_layout__construct_procid_rvals(ProcLabel, ProcIdRvals),
+		Rvals, ArgTypes, CNum0, CNum) :-
+	stack_layout__construct_procid_rvals(ProcLabel, ProcIdRvals,
+		ProcIdTypes),
 	( MaybeClosureLayoutInfo = yes(ClosureLayoutInfo) ->
 		ClosureLayoutInfo = closure_layout_info(ClosureArgs,
 			TVarLocnMap),
 		stack_layout__construct_closure_arg_rvals(ClosureArgs,
-			ClosureArgRvals, CNum0, CNum),
-		stack_layout__construct_tvar_rvals(TVarLocnMap, TVarRvals),
-		list__append(ClosureArgRvals, TVarRvals, LayoutRvals)
+			ClosureArgRvals, ClosureArgTypes, CNum0, CNum),
+		stack_layout__construct_tvar_rvals(TVarLocnMap, TVarRvals,
+			TvarRvalTypes),
+		list__append(ClosureArgRvals, TVarRvals, LayoutRvals),
+		LayoutTypes = initial(ClosureArgTypes, TvarRvalTypes)
 	;
 		LayoutRvals = [yes(const(int_const(-1)))],
+		LayoutTypes = initial([1 - yes(integer)], none),
 		CNum = CNum0
 	),
-	list__append(ProcIdRvals, LayoutRvals, Rvals).
+	list__append(ProcIdRvals, LayoutRvals, Rvals),
+	ArgTypes = initial(ProcIdTypes, LayoutTypes).
 
 :- pred stack_layout__construct_closure_arg_rvals(list(closure_arg_info)::in,
-	list(maybe(rval))::out, int::in, int::out) is det.
+	list(maybe(rval))::out, initial_arg_types::out, int::in, int::out)
+	is det.
 
 stack_layout__construct_closure_arg_rvals(ClosureArgs, ClosureArgRvals,
-		CNum0, CNum) :-
+		ClosureArgTypes, CNum0, CNum) :-
 	list__map_foldl(stack_layout__construct_closure_arg_rval,
 		ClosureArgs, MaybeArgRvals, CNum0, CNum),
 	list__length(MaybeArgRvals, Length),
-	ClosureArgRvals = [yes(const(int_const(Length))) | MaybeArgRvals].
+	ClosureArgRvals = [yes(const(int_const(Length))) | MaybeArgRvals],
+	NumberOfWords is 1 + Length,	% the length itself takes a word
+	ClosureArgTypes = [NumberOfWords - yes(word)].
 
 :- pred stack_layout__construct_closure_arg_rval(closure_arg_info::in,
 	maybe(rval)::out, int::in, int::out) is det.
@@ -793,7 +886,8 @@
 		CNum0, CNum1) },
 	stack_layout__set_cell_number(CNum1),
 	stack_layout__get_next_cell_number(CNum2),
-	{ Rval = create(0, VarShape, no, CNum2, "variable_shape") }.
+	{ Rval = create(0, VarShape, uniform(no), must_be_static,
+		CNum2, "variable_shape") }.
 
 :- pred stack_layout__represent_var_shape((type)::in, (inst)::in,
 	list(maybe(rval))::out, int::in, int::out) is det.
@@ -805,7 +899,10 @@
 	InstRval = const(int_const(-1)),
 	VarShape = [yes(TypeRval), yes(InstRval)].
 
-	% Construct a representation of a variable location.
+%---------------------------------------------------------------------------%
+
+	% Construct a representation of a variable location as a 32-bit
+	% integer.
 	%
 	% Most of the time, a layout specifies a location as an lval.
 	% However, a type_info variable may be hidden inside a typeclass_info,
@@ -819,13 +916,13 @@
 	% A more general representation that would allow more indirection
 	% would be much harder to fit into one machine word.
 
-:- pred stack_layout__represent_locn(layout_locn, rval).
-:- mode stack_layout__represent_locn(in, out) is det.
+:- pred stack_layout__represent_locn_as_int(layout_locn, rval).
+:- mode stack_layout__represent_locn_as_int(in, out) is det.
 
-stack_layout__represent_locn(direct(Lval), Rval) :-
+stack_layout__represent_locn_as_int(direct(Lval), Rval) :-
 	stack_layout__represent_lval(Lval, Word),
 	Rval = const(int_const(Word)).
-stack_layout__represent_locn(indirect(Lval, Offset), Rval) :-
+stack_layout__represent_locn_as_int(indirect(Lval, Offset), Rval) :-
 	stack_layout__represent_lval(Lval, BaseWord),
 	stack_layout__offset_bits(OffsetBits),
 	require((1 << OffsetBits) > Offset,
@@ -834,7 +931,7 @@
 	stack_layout__make_tagged_word(lval_indirect, BaseAndOffset, Word),
 	Rval = const(int_const(Word)).
 
-	% Construct a representation of an lval.
+	% Construct a four byte representation of an lval.
 
 :- pred stack_layout__represent_lval(lval, int).
 :- mode stack_layout__represent_lval(in, out) is det.
@@ -936,6 +1033,59 @@
 
 %---------------------------------------------------------------------------%
 
+	% Construct a representation of a variable location as a byte,
+	% if this is possible.
+
+:- pred stack_layout__represent_locn_as_byte(layout_locn::in, rval::out)
+	is semidet.
+
+stack_layout__represent_locn_as_byte(LayoutLocn, Rval) :-
+	LayoutLocn = direct(Lval), 
+	stack_layout__represent_lval_as_byte(Lval, Byte),
+	Rval = const(int_const(Byte)).
+
+	% Construct a representation of an lval in a byte, if possible.
+
+:- pred stack_layout__represent_lval_as_byte(lval::in, int::out) is semidet.
+
+stack_layout__represent_lval_as_byte(reg(r, Num), Byte) :-
+	stack_layout__make_tagged_byte(0, Num, Byte).
+
+stack_layout__represent_lval_as_byte(stackvar(Num), Byte) :-
+	stack_layout__make_tagged_byte(1, Num, Byte).
+stack_layout__represent_lval_as_byte(framevar(Num), Byte) :-
+	stack_layout__make_tagged_byte(2, Num, Byte).
+
+stack_layout__represent_lval_as_byte(succip, Byte) :-
+	stack_layout__locn_type_code(lval_succip, Val),
+	stack_layout__make_tagged_byte(3, Val, Byte).
+stack_layout__represent_lval_as_byte(maxfr, Byte) :-
+	stack_layout__locn_type_code(lval_maxfr, Val),
+	stack_layout__make_tagged_byte(3, Val, Byte).
+stack_layout__represent_lval_as_byte(curfr, Byte) :-
+	stack_layout__locn_type_code(lval_curfr, Val),
+	stack_layout__make_tagged_byte(3, Val, Byte).
+stack_layout__represent_lval_as_byte(hp, Byte) :-
+	stack_layout__locn_type_code(lval_hp, Val),
+	stack_layout__make_tagged_byte(3, Val, Byte).
+stack_layout__represent_lval_as_byte(sp, Byte) :-
+	stack_layout__locn_type_code(lval_succip, Val),
+	stack_layout__make_tagged_byte(3, Val, Byte).
+
+:- pred stack_layout__make_tagged_byte(int::in, int::in, int::out) is semidet.
+
+stack_layout__make_tagged_byte(Tag, Value, TaggedValue) :-
+	stack_layout__byte_bits(ByteBits),
+	int__pow(2, ByteBits - 2, Limit),
+	Value < Limit,
+	TaggedValue is unchecked_left_shift(Value, 2) + Tag.
+
+:- pred stack_layout__byte_bits(int::out) is det.
+
+stack_layout__byte_bits(8).
+
+%---------------------------------------------------------------------------%
+
 	% Construct a representation of the interface determinism of a
 	% procedure. The code we have chosen is not sequential; instead
 	% it encodes the various properties of each determinism.
@@ -977,6 +1127,20 @@
 %---------------------------------------------------------------------------%
 
 	% Access to the stack_layout data structure.
+
+:- type stack_layout_info 	--->
+	stack_layout_info(
+		module_name,	% module name
+		int,		% next available cell number
+		bool,		% generate agc layout info?
+		bool,		% generate tracing layout info?
+		bool,		% generate procedure id layout info?
+		bool,		% have static code addresses?
+		list(comp_gen_c_data),	% generated proc layouts
+		list(comp_gen_c_data),	% generated label layouts
+		set_bbbtree(label)
+				% the set of labels with layouts
+	).
 
 :- pred stack_layout__get_module_name(module_name::out,
 	stack_layout_info::in, stack_layout_info::out) is det.
Index: compiler/string_switch.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/string_switch.m,v
retrieving revision 1.31
diff -u -b -u -r1.31 string_switch.m
--- string_switch.m	1998/11/20 04:09:15	1.31
+++ string_switch.m	1999/04/23 07:34:44
@@ -1,5 +1,5 @@
 %-----------------------------------------------------------------------------%
-% Copyright (C) 1994-1998 The University of Melbourne.
+% Copyright (C) 1994-1999 The University of Melbourne.
 % This file may only be copied under the terms of the GNU General
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
@@ -85,9 +85,11 @@
 
 		% Generate code which does the hash table lookup
 	{
-		NextSlotsTable = create(0, NextSlots, no, NextSlotsTableNo,
+		NextSlotsTable = create(0, NextSlots, uniform(no),
+			must_be_static, NextSlotsTableNo,
 			"string_switch_next_slots_table"),
-		StringTable = create(0, Strings, no, StringTableNo,
+		StringTable = create(0, Strings, uniform(no),
+			must_be_static, StringTableNo,
 			"string_switch_string_table"),
 		HashLookupCode = node([
 			comment("hashed string switch") -
Index: compiler/unify_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/unify_gen.m,v
retrieving revision 1.96
diff -u -b -u -r1.96 unify_gen.m
--- unify_gen.m	1999/04/22 01:04:14	1.96
+++ unify_gen.m	1999/04/23 08:00:03
@@ -305,7 +305,8 @@
 	{ unify_gen__var_type_msg(VarType, VarTypeMsg) },
 	% XXX Later we will need to worry about
 	% whether the cell must be unique or not.
-	{ Expr = create(UnsharedTag, RVals, no, CellNo, VarTypeMsg) },
+	{ Expr = create(UnsharedTag, RVals, uniform(no), can_be_either,
+		CellNo, VarTypeMsg) },
 	code_info__cache_expression(Var, Expr).
 unify_gen__generate_construction_2(shared_remote_tag(Bits0, Num0),
 		Var, Args, Modes, Code) -->
@@ -321,7 +322,8 @@
 	{ unify_gen__var_type_msg(VarType, VarTypeMsg) },
 	% XXX Later we will need to worry about
 	% whether the cell must be unique or not.
-	{ Expr = create(Bits0, RVals, no, CellNo, VarTypeMsg) },
+	{ Expr = create(Bits0, RVals, uniform(no), can_be_either,
+		CellNo, VarTypeMsg) },
 	code_info__cache_expression(Var, Expr).
 unify_gen__generate_construction_2(shared_local_tag(Bits1, Num1),
 		Var, _Args, _Modes, Code) -->
@@ -534,10 +536,11 @@
 		code_info__get_cell_count(CNum0),
 		{ stack_layout__construct_closure_layout(ProcLabel,
 			MaybeClosureInfo, ClosureLayoutMaybeRvals,
-			CNum0, CNum) },
+			ClosureLayoutArgTypes, CNum0, CNum) },
 		code_info__set_cell_count(CNum),
 		code_info__get_next_cell_number(ClosureLayoutCellNo),
-		{ ClosureLayout = create(0, ClosureLayoutMaybeRvals, no,
+		{ ClosureLayout = create(0, ClosureLayoutMaybeRvals,
+			ClosureLayoutArgTypes, must_be_static,
 			ClosureLayoutCellNo, "closure_layout") },
 		{ list__length(Args, NumArgs) },
 		{ proc_info_arg_info(ProcInfo, ArgInfo) },
@@ -549,7 +552,8 @@
 			| PredArgs
 		] },
 		code_info__get_next_cell_number(ClosureCellNo),
-		{ Value = create(0, Vector, no, ClosureCellNo, "closure") }
+		{ Value = create(0, Vector, uniform(no), can_be_either,
+			ClosureCellNo, "closure") }
 	),
 	code_info__cache_expression(Var, Value).
 
Index: compiler/vn_cost.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/vn_cost.m,v
retrieving revision 1.35
diff -u -b -u -r1.35 vn_cost.m
--- vn_cost.m	1998/07/29 08:53:51	1.35
+++ vn_cost.m	1999/04/20 08:20:59
@@ -1,5 +1,5 @@
 %-----------------------------------------------------------------------------%
-% Copyright (C) 1995-1998 The University of Melbourne.
+% Copyright (C) 1995-1999 The University of Melbourne.
 % This file may only be copied under the terms of the GNU General
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
@@ -306,7 +306,7 @@
 		Rval = var(_),
 		error("var found in rval_cost")
 	;
-		Rval = create(_, _, _, _, _),
+		Rval = create(_, _, _, _, _, _),
 		Cost = 0
 	;
 		Rval = mkword(_, Rval1),
Index: compiler/vn_filter.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/vn_filter.m,v
retrieving revision 1.20
diff -u -b -u -r1.20 vn_filter.m
--- vn_filter.m	1998/07/29 08:53:52	1.20
+++ vn_filter.m	1999/04/20 08:21:20
@@ -1,5 +1,5 @@
 %-----------------------------------------------------------------------------%
-% Copyright (C) 1996-1998 The University of Melbourne.
+% Copyright (C) 1996-1999 The University of Melbourne.
 % This file may only be copied under the terms of the GNU General
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
@@ -388,8 +388,8 @@
 	).
 vn_filter__replace_in_rval(var(_), _, _, _) :-
 	error("found var in vn_filter__replace_in_rval").
-vn_filter__replace_in_rval(create(Tag, Args, Unique, Label, Msg), _, _,
-		create(Tag, Args, Unique, Label, Msg)).
+vn_filter__replace_in_rval(create(Tag, Args, AT, StatDyn, Label, Msg), _, _,
+		create(Tag, Args, AT, StatDyn, Label, Msg)).
 vn_filter__replace_in_rval(mkword(Tag, Rval0), Temp, Defn, mkword(Tag, Rval)) :-
 	vn_filter__replace_in_rval(Rval0, Temp, Defn, Rval).
 vn_filter__replace_in_rval(const(Const), _, _, const(Const)).
Index: compiler/vn_flush.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/vn_flush.m,v
retrieving revision 1.47
diff -u -b -u -r1.47 vn_flush.m
--- vn_flush.m	1998/07/20 10:01:45	1.47
+++ vn_flush.m	1999/04/20 10:59:24
@@ -1,5 +1,5 @@
 %-----------------------------------------------------------------------------%
-% Copyright (C) 1995-1998 The University of Melbourne.
+% Copyright (C) 1995-1999 The University of Melbourne.
 % This file may only be copied under the terms of the GNU General
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
@@ -689,8 +689,9 @@
 		Templocs = Templocs0,
 		Instrs = []
 	;
-		Vnrval = vn_create(Tag, MaybeRvals, Unique, Label, Msg),
-		Rval = create(Tag, MaybeRvals, Unique, Label, Msg),
+		Vnrval = vn_create(Tag, MaybeRvals, ArgTypes, StatDyn,
+			Label, Msg),
+		Rval = create(Tag, MaybeRvals, ArgTypes, StatDyn, Label, Msg),
 		VnTables = VnTables0,
 		Templocs = Templocs0,
 		Instrs = []
@@ -893,7 +894,7 @@
 			Templocs = Templocs0,
 			Instrs = []
 		;
-			Vnrval = vn_create(_, _, _, _, _),
+			Vnrval = vn_create(_, _, _, _, _, _),
 			error("create in calculation of new hp")
 		;
 			Vnrval = vn_unop(_, _),
Index: compiler/vn_order.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/vn_order.m,v
retrieving revision 1.47
diff -u -b -u -r1.47 vn_order.m
--- vn_order.m	1998/07/20 10:01:47	1.47
+++ vn_order.m	1999/04/20 10:59:40
@@ -635,7 +635,7 @@
 			Predmap = Predmap0,
 			VnTables = VnTables0
 		;
-			Vnrval = vn_create(_, _, _, _, _),
+			Vnrval = vn_create(_, _, _, _, _, _),
 			Succmap = Succmap0,
 			Predmap = Predmap0,
 			VnTables = VnTables0
Index: compiler/vn_type.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/vn_type.m,v
retrieving revision 1.39
diff -u -b -u -r1.39 vn_type.m
--- vn_type.m	1998/07/20 10:01:49	1.39
+++ vn_type.m	1999/04/20 11:00:05
@@ -14,7 +14,7 @@
 
 :- interface.
 :- import_module llds, livemap, options.
-:- import_module bool, getopt, map, set, list, std_util.
+:- import_module getopt, map, set, list, std_util.
 
 :- type vn == int.
 
@@ -42,7 +42,8 @@
 			;	vn_mkword(tag, vn)
 			;	vn_const(rval_const)
 			;	vn_create(tag, list(maybe(rval)),
-					bool, int, string)
+					create_arg_types, static_or_dynamic,
+					int, string)
 			;	vn_unop(unary_op, vn)
 			;	vn_binop(binary_op, vn, vn)
 			;	vn_stackvar_addr(int)
@@ -177,7 +178,7 @@
 
 vn_type__vnrval_type(vn_origlval(Lval), Type) :-
 	vn_type__vnlval_type(Lval, Type).
-vn_type__vnrval_type(vn_create(_, _, _, _, _), data_ptr).
+vn_type__vnrval_type(vn_create(_, _, _, _, _, _), data_ptr).
 vn_type__vnrval_type(vn_mkword(_, _), data_ptr). % see comment in llds.m
 vn_type__vnrval_type(vn_const(Const), Type) :-
 	llds__const_type(Const, Type).
Index: compiler/vn_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/vn_util.m,v
retrieving revision 1.64
diff -u -b -u -r1.64 vn_util.m
--- vn_util.m	1999/04/01 02:51:25	1.64
+++ vn_util.m	1999/04/20 11:16:02
@@ -1,5 +1,5 @@
 %-----------------------------------------------------------------------------%
-% Copyright (C) 1995-1998 The University of Melbourne.
+% Copyright (C) 1995-1999 The University of Melbourne.
 % This file may only be copied under the terms of the GNU General
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
@@ -148,9 +148,9 @@
 		Rval = var(_),
 		error("value_number should never get rval: var")
 	;
-		Rval = create(Tag, Args, Unique, Label, Msg),
-		vn_util__vnrval_to_vn(vn_create(Tag, Args, Unique, Label, Msg),
-			Vn, VnTables0, VnTables)
+		Rval = create(Tag, Args, ArgTypes, StatDyn, Label, Msg),
+		vn_util__vnrval_to_vn(vn_create(Tag, Args, ArgTypes,
+			StatDyn, Label, Msg), Vn, VnTables0, VnTables)
 	;
 		Rval = mkword(Tag, Rval1),
 		vn_util__rval_to_vn(Rval1, SubVn, VnTables0, VnTables1),
@@ -1026,7 +1026,7 @@
 	vn_util__vnlval_access_vns(Vnlval, SubVns).
 vn_util__find_sub_vns(vn_mkword(_, SubVn), [SubVn]).
 vn_util__find_sub_vns(vn_const(_), []).
-vn_util__find_sub_vns(vn_create(_, _, _, _, _), []).
+vn_util__find_sub_vns(vn_create(_, _, _, _, _, _), []).
 vn_util__find_sub_vns(vn_unop(_, SubVn), [SubVn]).
 vn_util__find_sub_vns(vn_binop(_, SubVn1, SubVn2), [SubVn1, SubVn2]).
 vn_util__find_sub_vns(vn_stackvar_addr(_), []).
@@ -1045,7 +1045,7 @@
 		Vnrval = vn_const(_),
 		IsConst = yes
 	;
-		Vnrval = vn_create(_, _, _, _, _),
+		Vnrval = vn_create(_, _, _, _, _, _),
 		IsConst = yes
 	;
 		Vnrval = vn_unop(_, Vn1),
@@ -1076,7 +1076,7 @@
 		Rval = var(_),
 		error("var found in vn_util__find_lvals_in_rval")
 	;
-		Rval = create(_, _, _, _, _),
+		Rval = create(_, _, _, _, _, _),
 		Lvals = []
 	;
 		Rval = mkword(_, Rval1),
@@ -1343,7 +1343,7 @@
 			Vnrval = vn_const(_),
 			VnTables = VnTables1
 		;
-			Vnrval = vn_create(_, _, _, _, _),
+			Vnrval = vn_create(_, _, _, _, _, _),
 			VnTables = VnTables1
 		;
 			Vnrval = vn_unop(_, SubVn),
Index: compiler/vn_verify.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/vn_verify.m,v
retrieving revision 1.19
diff -u -b -u -r1.19 vn_verify.m
--- vn_verify.m	1998/07/29 08:53:54	1.19
+++ vn_verify.m	1999/04/20 08:22:13
@@ -1,5 +1,5 @@
 %-----------------------------------------------------------------------------%
-% Copyright (C) 1996-1998 The University of Melbourne.
+% Copyright (C) 1996-1999 The University of Melbourne.
 % This file may only be copied under the terms of the GNU General
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
@@ -228,7 +228,7 @@
 	vn_verify__lval(Vnlval, VnTables, Lval).
 vn_verify__subst_sub_vns(vn_mkword(Tag, _), [R], _, mkword(Tag, R)).
 vn_verify__subst_sub_vns(vn_const(Const), [], _, const(Const)).
-vn_verify__subst_sub_vns(vn_create(T,A,U,L,M), [], _, create(T,A,U,L,M)).
+vn_verify__subst_sub_vns(vn_create(T,A,AT,U,L,M), [], _, create(T,A,AT,U,L,M)).
 vn_verify__subst_sub_vns(vn_unop(Op, _), [R], _, unop(Op, R)).
 vn_verify__subst_sub_vns(vn_binop(Op, _, _), [R1, R2], _, binop(Op, R1, R2)).
 
@@ -410,7 +410,7 @@
 	vn_verify__tags_lval(Lval, NoDeref).
 vn_verify__tags_rval(var(_), _) :-
 	error("found var in vn_verify__tags_rval").
-vn_verify__tags_rval(create(_, _, _, _, _), _).
+vn_verify__tags_rval(create(_, _, _, _, _, _), _).
 vn_verify__tags_rval(mkword(_, Rval), NoDeref) :-
 	vn_verify__tags_rval(Rval, NoDeref).
 vn_verify__tags_rval(const(_), _).
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
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/dynamic_linking
cvs diff: Diffing extras/exceptions
cvs diff: Diffing extras/graphics
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/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
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/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/library/Mmakefile,v
retrieving revision 1.37
diff -u -b -u -r1.37 Mmakefile
--- Mmakefile	1999/04/08 12:58:02	1.37
+++ Mmakefile	1999/04/26 01:16:09
@@ -194,6 +194,17 @@
 $(os_subdir)library.pic_o \
 	: $(RUNTIME_DIR)/mercury_conf.h
 
+# The object files in this directory depend on many of the header files
+# in the runtime. However, changes to many of these header files require
+# a global make clean. Here we list only the header files from the runtime
+# whose changes don't usually require a make clean but which nevertheless
+# require some files in the library to be recompiled.
+$(os_subdir)benchmarking.o \
+$(os_subdir)benchmarking.pic_o \
+$(os_subdir)std_util.o \
+$(os_subdir)std_util.pic_o \
+	: ../runtime/mercury_stack_layout.h
+
 #-----------------------------------------------------------------------------#
 
 realclean:
Index: library/benchmarking.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/benchmarking.m,v
retrieving revision 1.21
diff -u -b -u -r1.21 benchmarking.m
--- benchmarking.m	1999/04/16 06:05:13	1.21
+++ benchmarking.m	1999/04/21 10:45:14
@@ -576,7 +576,7 @@
 Declare_label(mercury__benchmarking__benchmark_nondet_5_0_i2);
 
 MR_MAKE_PROC_LAYOUT(mercury__benchmarking__benchmark_nondet_5_0,
-	MR_DETISM_NON, BENCHMARK_NONDET_STACK_SLOTS, MR_LVAL_TYPE_UNKNOWN,
+	MR_DETISM_NON, BENCHMARK_NONDET_STACK_SLOTS, MR_LONG_LVAL_TYPE_UNKNOWN,
 	MR_PREDICATE, ""benchmarking"", ""benchmark_nondet"", 5, 0);
 MR_MAKE_INTERNAL_LAYOUT(mercury__benchmarking__benchmark_nondet_5_0, 1);
 MR_MAKE_INTERNAL_LAYOUT(mercury__benchmarking__benchmark_nondet_5_0, 2);
@@ -689,7 +689,7 @@
 Define_extern_entry(mercury__benchmarking__benchmark_det_5_0);
 Declare_label(mercury__benchmarking__benchmark_det_5_0_i1);
 MR_MAKE_PROC_LAYOUT(mercury__benchmarking__benchmark_det_5_0,
-	MR_DETISM_NON, BENCHMARK_DET_STACK_SLOTS, MR_LIVE_LVAL_STACKVAR(6),
+	MR_DETISM_NON, BENCHMARK_DET_STACK_SLOTS, MR_LONG_LVAL_STACKVAR(6),
 	MR_PREDICATE, ""benchmarking"", ""benchmark_nondet"", 5, 0);
 MR_MAKE_INTERNAL_LAYOUT(mercury__benchmarking__benchmark_det_5_0, 1);
 
Index: library/std_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/std_util.m,v
retrieving revision 1.145
diff -u -b -u -r1.145 std_util.m
--- std_util.m	1999/04/22 01:04:23	1.145
+++ std_util.m	1999/04/22 01:56:14
@@ -511,7 +511,7 @@
 Declare_label(mercury__std_util__builtin_aggregate_4_0_i3);
 
 MR_MAKE_PROC_LAYOUT(mercury__std_util__builtin_aggregate_4_0,
-	MR_DETISM_MULTI, MR_ENTRY_NO_SLOT_COUNT, MR_LVAL_TYPE_UNKNOWN,
+	MR_DETISM_MULTI, MR_ENTRY_NO_SLOT_COUNT, MR_LONG_LVAL_TYPE_UNKNOWN,
 	MR_PREDICATE, ""std_util"", ""builtin_aggregate"", 4, 0);
 
 MR_MAKE_INTERNAL_LAYOUT(mercury__std_util__builtin_aggregate_4_0, 1);
@@ -1107,7 +1107,7 @@
 Declare_label(mercury____Compare___std_util__univ_0_0_i1);
 
 MR_MAKE_PROC_LAYOUT(mercury____Compare___std_util__univ_0_0,
-	MR_DETISM_DET, 1, MR_LIVE_LVAL_STACKVAR(1),
+	MR_DETISM_DET, 1, MR_LONG_LVAL_STACKVAR(1),
 	MR_PREDICATE, ""std_util"", ""compare_univ"", 3, 0);
 MR_MAKE_INTERNAL_LAYOUT(mercury____Compare___std_util__univ_0_0, 1);
 
cvs diff: Diffing profiler
cvs diff: Diffing runtime
Index: runtime/mercury_accurate_gc.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_accurate_gc.c,v
retrieving revision 1.5
diff -u -b -u -r1.5 mercury_accurate_gc.c
--- mercury_accurate_gc.c	1999/04/26 03:34:28	1.5
+++ mercury_accurate_gc.c	1999/04/26 05:35:48
@@ -66,7 +66,8 @@
 	MR_Live_Lval		location;
 	const char		*reason;
 	MR_Entry		*entry_label = NULL;
-	int			determinism, number;
+	int				number;
+	MR_Determinism			determinism;
 
 	if (gc_running) {
 		/*
@@ -229,7 +230,6 @@
 {
     MR_Internal                     *label, *first_label;
     int                             i, var_count, count;
-    MR_Determinism                  determinism;
     const MR_Stack_Layout_Label     *internal_layout;
     const MR_Stack_Layout_Vars      *vars;
     MemoryZone                      *old_heap, *new_heap;
Index: runtime/mercury_conf.h.in
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_conf.h.in,v
retrieving revision 1.17
diff -u -b -u -r1.17 mercury_conf.h.in
--- mercury_conf.h.in	1999/04/22 06:13:58	1.17
+++ mercury_conf.h.in	1999/04/22 07:38:12
@@ -45,6 +45,24 @@
 #undef	WORD_TYPE
 
 /*
+** INT16_TYPE:
+** This must be a C integral type (e.g. short, int)
+** without any explicit signedness.
+** It ought to be at least 16 bits in size.
+** It may be bigger, but any bits beyond 16 are not used.
+*/
+#undef	INT16_TYPE
+
+/*
+** INT32_TYPE:
+** This must be a C integral type (e.g. short, int, long)
+** without any explicit signedness.
+** It ought to be at least 32 bits in size.
+** It may be bigger, but any bits beyond 32 are not used.
+*/
+#undef	INT32_TYPE
+
+/*
 ** LOW_TAG_BITS: an integer, specifying the number of low-order tag bits
 ** we can use.  Normally this is the base-2 log of the word size in bytes.
 */
Index: runtime/mercury_layout_util.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_layout_util.c,v
retrieving revision 1.6
diff -u -b -u -r1.6 mercury_layout_util.c
--- mercury_layout_util.c	1999/04/16 06:05:34	1.6
+++ mercury_layout_util.c	1999/04/23 07:36:50
@@ -90,7 +90,7 @@
 		*/
 		for (i = 0; i < count; i++) {
 			if (vars->MR_slvs_tvars->MR_tp_param_locns[i] != 0) {
-				type_params[i + 1] = MR_lookup_live_lval_base(
+				type_params[i + 1] = MR_lookup_long_lval_base(
 					vars->MR_slvs_tvars->
 						MR_tp_param_locns[i],
 					saved_regs, base_sp, base_curfr,
@@ -110,22 +110,25 @@
 Word
 MR_make_var_list(const MR_Stack_Layout_Label *layout, Word *saved_regs)
 {
-	int 				var_count;
 	const MR_Stack_Layout_Vars 	*vars;
-	int				i;
+	int 				var_count;
+	int 				long_count;
 	const char			*name;
 
 	Word				univ_list;
-	MR_Stack_Layout_Var*		var;
-	Word				univ, value;
+	Word				univ;
+	Word				value;
 	MR_Live_Type			live_type;
 	Word				type_info;
 	Word				*base_sp;
 	Word				*base_curfr;
 	Word				*type_params;
 
-	var_count = layout->MR_sll_var_count;
+	int				i;
+
 	vars = &layout->MR_sll_var_info;
+	var_count = MR_all_desc_var_count(vars);
+	long_count = MR_long_desc_var_count(vars);
 	base_sp = MR_saved_sp(saved_regs);
 	base_curfr = MR_saved_curfr(saved_regs);
 
@@ -136,9 +139,9 @@
 
 	/* 
 	** If no information on live variables is available, return the 
-	** empty list 
+	** empty list.
 	*/
-	if (layout->MR_sll_var_count <= 0) {
+	if (var_count <= 0) {
 		return univ_list;
 	} 
 		
@@ -153,9 +156,7 @@
 		*/
 
 		name = MR_name_if_present(vars, i);
-		var = &vars->MR_slvs_pairs[i];
-
-		if (! MR_get_type_and_value_filtered(var, saved_regs,
+		if (! MR_get_type_and_value_filtered(vars, i, saved_regs,
 			name, type_params, &type_info, &value))
 		{
 			/*
@@ -190,10 +191,20 @@
 }
 
 int
-MR_get_register_number(MR_Live_Lval locn)
+MR_get_register_number_long(MR_Long_Lval locn)
 {
-	if (MR_LIVE_LVAL_TYPE(locn) == MR_LVAL_TYPE_R) {
-		return MR_LIVE_LVAL_NUMBER(locn);
+	if (MR_LONG_LVAL_TYPE(locn) == MR_LONG_LVAL_TYPE_R) {
+		return MR_LONG_LVAL_NUMBER(locn);
+	} else {
+		return -1;
+	}
+}
+
+int
+MR_get_register_number_short(MR_Short_Lval locn)
+{
+	if ((locn & 03) == MR_SHORT_LVAL_TYPE_R) {
+		return locn >> 2;
 	} else {
 		return -1;
 	}
@@ -203,15 +214,15 @@
 static	bool	MR_print_locn = FALSE;
 
 Word
-MR_lookup_live_lval(MR_Live_Lval locn, Word *saved_regs, bool *succeeded)
+MR_lookup_long_lval(MR_Long_Lval locn, Word *saved_regs, bool *succeeded)
 {
-	return MR_lookup_live_lval_base(locn, saved_regs,
+	return MR_lookup_long_lval_base(locn, saved_regs,
 		MR_saved_sp(saved_regs), MR_saved_curfr(saved_regs),
 		succeeded);
 }
 
 Word
-MR_lookup_live_lval_base(MR_Live_Lval locn, Word *saved_regs,
+MR_lookup_long_lval_base(MR_Long_Lval locn, Word *saved_regs,
 	Word *base_sp, Word *base_curfr, bool *succeeded)
 {
 	int	locn_num;
@@ -223,9 +234,9 @@
 	*succeeded = FALSE;
 	value = 0;
 
-	locn_num = (int) MR_LIVE_LVAL_NUMBER(locn);
-	switch (MR_LIVE_LVAL_TYPE(locn)) {
-		case MR_LVAL_TYPE_R:
+	locn_num = (int) MR_LONG_LVAL_NUMBER(locn);
+	switch (MR_LONG_LVAL_TYPE(locn)) {
+		case MR_LONG_LVAL_TYPE_R:
 			if (MR_print_locn) {
 				printf("r%d", locn_num);
 			}
@@ -235,13 +246,13 @@
 			}
 			break;
 
-		case MR_LVAL_TYPE_F:
+		case MR_LONG_LVAL_TYPE_F:
 			if (MR_print_locn) {
 				printf("f%d", locn_num);
 			}
 			break;
 
-		case MR_LVAL_TYPE_STACKVAR:
+		case MR_LONG_LVAL_TYPE_STACKVAR:
 			if (MR_print_locn) {
 				printf("stackvar%d", locn_num);
 			}
@@ -249,7 +260,7 @@
 			*succeeded = TRUE;
 			break;
 
-		case MR_LVAL_TYPE_FRAMEVAR:
+		case MR_LONG_LVAL_TYPE_FRAMEVAR:
 			if (MR_print_locn) {
 				printf("framevar%d", locn_num);
 			}
@@ -257,43 +268,43 @@
 			*succeeded = TRUE;
 			break;
 
-		case MR_LVAL_TYPE_SUCCIP:
+		case MR_LONG_LVAL_TYPE_SUCCIP:
 			if (MR_print_locn) {
 				printf("succip");
 			}
 			break;
 
-		case MR_LVAL_TYPE_MAXFR:
+		case MR_LONG_LVAL_TYPE_MAXFR:
 			if (MR_print_locn) {
 				printf("maxfr");
 			}
 			break;
 
-		case MR_LVAL_TYPE_CURFR:
+		case MR_LONG_LVAL_TYPE_CURFR:
 			if (MR_print_locn) {
 				printf("curfr");
 			}
 			break;
 
-		case MR_LVAL_TYPE_HP:
+		case MR_LONG_LVAL_TYPE_HP:
 			if (MR_print_locn) {
 				printf("hp");
 			}
 			break;
 
-		case MR_LVAL_TYPE_SP:
+		case MR_LONG_LVAL_TYPE_SP:
 			if (MR_print_locn) {
 				printf("sp");
 			}
 			break;
 
-		case MR_LVAL_TYPE_INDIRECT:
-			offset = MR_LIVE_LVAL_INDIRECT_OFFSET(locn_num);
-			sublocn = MR_LIVE_LVAL_INDIRECT_BASE_LVAL(locn_num);
+		case MR_LONG_LVAL_TYPE_INDIRECT:
+			offset = MR_LONG_LVAL_INDIRECT_OFFSET(locn_num);
+			sublocn = MR_LONG_LVAL_INDIRECT_BASE_LVAL(locn_num);
 			if (MR_print_locn) {
 				printf("offset %d from ", offset);
 			}
-			baseaddr = MR_lookup_live_lval_base(sublocn,
+			baseaddr = MR_lookup_long_lval_base(sublocn,
 					saved_regs, base_sp, base_curfr,
 					succeeded);
 			if (! *succeeded) {
@@ -304,7 +315,7 @@
 			*succeeded = TRUE;
 			break;
 
-		case MR_LVAL_TYPE_UNKNOWN:
+		case MR_LONG_LVAL_TYPE_UNKNOWN:
 			if (MR_print_locn) {
 				printf("unknown");
 			}
@@ -320,58 +331,159 @@
 	return value;
 }
 
+Word
+MR_lookup_short_lval(MR_Short_Lval locn, Word *saved_regs, bool *succeeded)
+{
+	return MR_lookup_short_lval_base(locn, saved_regs,
+		MR_saved_sp(saved_regs), MR_saved_curfr(saved_regs),
+		succeeded);
+}
+
+Word
+MR_lookup_short_lval_base(MR_Short_Lval locn, Word *saved_regs,
+	Word *base_sp, Word *base_curfr, bool *succeeded)
+{
+	int	locn_num;
+	Word	value;
+
+	*succeeded = FALSE;
+	value = 0;
+
+	locn_num = (int) locn >> 2;
+	switch (locn & 03) {
+		case MR_SHORT_LVAL_TYPE_R:
+			if (MR_print_locn) {
+				printf("r%d", locn_num);
+			}
+			if (saved_regs != NULL) {
+				value = saved_reg(saved_regs, locn_num);
+				*succeeded = TRUE;
+			}
+			break;
+
+		case MR_SHORT_LVAL_TYPE_STACKVAR:
+			if (MR_print_locn) {
+				printf("stackvar%d", locn_num);
+			}
+			value = MR_based_stackvar(base_sp, locn_num);
+			*succeeded = TRUE;
+			break;
+
+		case MR_SHORT_LVAL_TYPE_FRAMEVAR:
+			if (MR_print_locn) {
+				printf("framevar%d", locn_num);
+			}
+			value = MR_based_framevar(base_curfr, locn_num);
+			*succeeded = TRUE;
+			break;
+
+		case MR_SHORT_LVAL_TYPE_SPECIAL:
+			switch (locn_num) {
+				case MR_LONG_LVAL_TYPE_SUCCIP:
+					if (MR_print_locn) {
+						printf("succip");
+					}
+					break;
+
+				case MR_LONG_LVAL_TYPE_MAXFR:
+					if (MR_print_locn) {
+						printf("maxfr");
+					}
+					break;
+
+				case MR_LONG_LVAL_TYPE_CURFR:
+					if (MR_print_locn) {
+						printf("curfr");
+					}
+					break;
+
+				case MR_LONG_LVAL_TYPE_HP:
+					if (MR_print_locn) {
+						printf("hp");
+					}
+					break;
+
+				case MR_LONG_LVAL_TYPE_SP:
+					if (MR_print_locn) {
+						printf("sp");
+					}
+					break;
+
+				default:
+					if (MR_print_locn) {
+						printf("DEFAULT");
+					}
+			}
+
+		default:
+			if (MR_print_locn) {
+				printf("DEFAULT");
+			}
+			break;
+	}
+
+	return value;
+}
+
 bool
-MR_get_type_and_value(const MR_Stack_Layout_Var *var,
+MR_get_type_and_value(const MR_Stack_Layout_Vars *vars, int i,
 	Word *saved_regs, Word *type_params, Word *type_info, Word *value)
 {
-	return MR_get_type_and_value_base(var, saved_regs,
+	return MR_get_type_and_value_base(vars, i, saved_regs,
 		MR_saved_sp(saved_regs), MR_saved_curfr(saved_regs),
 		type_params, type_info, value);
 }
 
 bool
-MR_get_type_and_value_base(const MR_Stack_Layout_Var *var,
+MR_get_type_and_value_base(const MR_Stack_Layout_Vars *vars, int i,
 	Word *saved_regs, Word *base_sp, Word *base_curfr,
 	Word *type_params, Word *type_info, Word *value)
 {
 	bool	succeeded;
 	Word	*pseudo_type_info;
-	int	i;
 
-	if (!MR_LIVE_TYPE_IS_VAR(var->MR_slv_live_type)) {
+	if (!MR_LIVE_TYPE_IS_VAR(MR_var_pti(vars, i))) {
 		return FALSE;
 	}
 
-	pseudo_type_info = MR_LIVE_TYPE_GET_VAR_TYPE(var->MR_slv_live_type);
+	pseudo_type_info = MR_LIVE_TYPE_GET_VAR_TYPE(MR_var_pti(vars, i));
 	*type_info = (Word) MR_create_type_info(type_params, pseudo_type_info);
-	*value = MR_lookup_live_lval_base(var->MR_slv_locn,
+
+	if (i < MR_long_desc_var_count(vars)) {
+		*value = MR_lookup_long_lval_base(
+			MR_long_desc_var_locn(vars, i),
+			saved_regs, base_sp, base_curfr, &succeeded);
+	} else {
+		*value = MR_lookup_short_lval_base(
+			MR_short_desc_var_locn(vars, i),
 		saved_regs, base_sp, base_curfr, &succeeded);
+	}
+
 	return succeeded;
 }
 
 bool
-MR_get_type(const MR_Stack_Layout_Var *var, Word *saved_regs,
+MR_get_type(const MR_Stack_Layout_Vars *vars, int i, Word *saved_regs,
 	Word *type_params, Word *type_info)
 {
-	return MR_get_type_base(var, saved_regs,
+	return MR_get_type_base(vars, i, saved_regs,
 		MR_saved_sp(saved_regs), MR_saved_curfr(saved_regs),
 		type_params, type_info);
 }
 
 bool
-MR_get_type_base(const MR_Stack_Layout_Var *var,
+MR_get_type_base(const MR_Stack_Layout_Vars *vars, int i,
 	Word *saved_regs, Word *base_sp, Word *base_curfr,
 	Word *type_params, Word *type_info)
 {
 	bool	succeeded;
 	Word	*pseudo_type_info;
-	int	i;
 
-	if (!MR_LIVE_TYPE_IS_VAR(var->MR_slv_live_type)) {
+	if (!MR_LIVE_TYPE_IS_VAR(MR_var_pti(vars, i))) {
 		return FALSE;
 	}
 
-	pseudo_type_info = MR_LIVE_TYPE_GET_VAR_TYPE(var->MR_slv_live_type);
+	pseudo_type_info = MR_LIVE_TYPE_GET_VAR_TYPE(MR_var_pti(vars, i));
 	*type_info = (Word) MR_create_type_info(type_params, pseudo_type_info);
 	
 	return TRUE;
@@ -386,24 +498,24 @@
 */
 
 bool
-MR_get_type_and_value_filtered(const MR_Stack_Layout_Var *var, 
+MR_get_type_and_value_filtered(const MR_Stack_Layout_Vars *vars, int i,
 	Word *saved_regs, const char *name, Word *type_params, 
 	Word *type_info, Word *value)
 {
 	return ((strncmp(name, "TypeInfo", 8) != 0)
 	       && (strncmp(name, "TypeClassInfo", 13) != 0)
-	       && MR_get_type_and_value(var, saved_regs, type_params,
+	       && MR_get_type_and_value(vars, i, saved_regs, type_params,
 			type_info, value));
 }
 
 
 bool
-MR_get_type_filtered(const MR_Stack_Layout_Var *var, Word *saved_regs,
-	const char *name, Word *type_params, Word *type_info)
+MR_get_type_filtered(const MR_Stack_Layout_Vars *vars, int i,
+	Word *saved_regs, const char *name, Word *type_params, Word *type_info)
 {
 	return ((strncmp(name, "TypeInfo", 8) != 0)
 	       && (strncmp(name, "TypeClassInfo", 13) != 0)
-	       && MR_get_type(var, saved_regs, type_params, type_info));
+	       && MR_get_type(vars, i, saved_regs, type_params, type_info));
 }
 
 void
Index: runtime/mercury_layout_util.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_layout_util.h,v
retrieving revision 1.4
diff -u -b -u -r1.4 mercury_layout_util.h
--- mercury_layout_util.h	1999/02/19 16:11:45	1.4
+++ mercury_layout_util.h	1999/04/21 09:41:09
@@ -66,22 +66,30 @@
 ** If it does not, return -1.
 */
 
-extern	int	MR_get_register_number(MR_Live_Lval locn);
+extern	int	MR_get_register_number_long(MR_Long_Lval locn);
+extern	int	MR_get_register_number_short(MR_Short_Lval locn);
 
 /*
-** Given an encoded location, return the value at that location if possible.
-** *succeeded will say whether the attempt was successful.
+** Given an location either in a long or short form, return the value
+** at that location if possible. *succeeded will say whether the attempt
+** was successful.
 **
-** MR_lookup_live_lval looks up locations in the current environment,
+** MR_lookup_{long,short}_lval looks up locations in the current environment,
 ** as indicated by the set of saved registers (including MR_sp and MR_curfr).
-** MR_lookup_live_lval_base does the same job but assumes the environment
-** is given by the given values of MR_sp and MR_curfr, and does not assume
-** that the registers have valid contents unless saved_regs is non-null.
+** MR_lookup_{long,short}_lval_base does the same job but assumes the
+** environment is given by the given values of MR_sp and MR_curfr, and does
+** not assume that the registers have valid contents unless saved_regs is
+** non-null.
 */ 
 
-extern	Word	MR_lookup_live_lval(MR_Live_Lval locn,
+extern	Word	MR_lookup_long_lval(MR_Long_Lval locn,
+			Word *saved_regs, bool *succeeded);
+extern	Word	MR_lookup_long_lval_base(MR_Long_Lval locn,
+			Word *saved_regs, Word *base_sp, Word *base_curfr,
+			bool *succeeded);
+extern	Word	MR_lookup_short_lval(MR_Short_Lval locn,
 			Word *saved_regs, bool *succeeded);
-extern	Word	MR_lookup_live_lval_base(MR_Live_Lval locn,
+extern	Word	MR_lookup_short_lval_base(MR_Short_Lval locn,
 			Word *saved_regs, Word *base_sp, Word *base_curfr,
 			bool *succeeded);
 
@@ -113,22 +121,23 @@
 ** be allocated on the Mercury heap.
 */
 
-extern	bool	MR_get_type_and_value(const MR_Stack_Layout_Var *var,
-			Word *saved_regs, Word *type_params, Word *type_info,
-			Word *value);
-extern	bool	MR_get_type_and_value_base(const MR_Stack_Layout_Var *var,
-			Word *saved_regs, Word *base_sp, Word *base_curfr,
+extern	bool	MR_get_type_and_value(const MR_Stack_Layout_Vars *vars,
+			int var, Word *saved_regs,
 			Word *type_params, Word *type_info, Word *value);
-extern	bool	MR_get_type(const MR_Stack_Layout_Var *var,
+extern	bool	MR_get_type_and_value_base(const MR_Stack_Layout_Vars *vars,
+			int var, Word *saved_regs,
+			Word *base_sp, Word *base_curfr,
+			Word *type_params, Word *type_info, Word *value);
+extern	bool	MR_get_type(const MR_Stack_Layout_Vars *vars, int var,
 			Word *saved_regs, Word *type_params, Word *type_info);
-extern	bool	MR_get_type_base(const MR_Stack_Layout_Var *var,
+extern	bool	MR_get_type_base(const MR_Stack_Layout_Vars *vars, int var,
 			Word *saved_regs, Word *base_sp, Word *base_curfr,
 			Word *type_params, Word *type_info);
 extern	bool	MR_get_type_and_value_filtered(
-			const MR_Stack_Layout_Var *var, Word *saved_regs,
-			const char *name, Word *type_params, Word *type_info, 
-			Word *value);
-extern	bool	MR_get_type_filtered(const MR_Stack_Layout_Var *var, 
+			const MR_Stack_Layout_Vars *vars, int var,
+			Word *saved_regs, const char *name,
+			Word *type_params, Word *type_info, Word *value);
+extern	bool	MR_get_type_filtered(const MR_Stack_Layout_Vars *vars, int var, 
 			Word *saved_regs, const char *name, Word *type_params, 
 			Word *type_info);
 
Index: runtime/mercury_stack_layout.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stack_layout.h,v
retrieving revision 1.22
diff -u -b -u -r1.22 mercury_stack_layout.h
--- mercury_stack_layout.h	1999/04/22 06:13:59	1.22
+++ mercury_stack_layout.h	1999/04/26 01:01:39
@@ -42,7 +42,7 @@
 ** that we do not set the 1 bit unless we also set the 2 bit.
 */
 
-typedef	Word MR_Determinism;
+typedef	int_least16_t	 MR_Determinism;
 
 #define	MR_DETISM_DET		6
 #define	MR_DETISM_SEMI		2
@@ -66,17 +66,17 @@
 
 /*-------------------------------------------------------------------------*/
 /*
-** Definitions for MR_Live_Lval
+** Definitions for MR_Long_Lval and MR_Short_Lval
 */
 
 /*
-** MR_Live_Lval is a Word which describes an location. This includes
+** MR_Long_Lval is a uint_least32_t which describes an location. This includes
 ** lvals such as stack slots, general registers, and special registers
 ** such as succip, hp, etc, as well as locations whose address is given
-** as a particular word offset from the memory address found in an lval.
+** as a typeinfo inside the type class info structure pointed to by an lval.
 **
-** What kind of of location an MR_Live_Lval refers to is encoded using
-** a low tag with MR_LIVE_LVAL_TAGBITS bits; the type MR_Lval_Type describes
+** What kind of location an MR_Long_Lval refers to is encoded using
+** a low tag with MR_LONG_LVAL_TAGBITS bits; the type MR_Lval_Type describes
 ** the different tag values. The interpretation of the rest of the word
 ** depends on the location type:
 **
@@ -94,56 +94,94 @@
 **  unknown		10	(The location is not known)
 **
 ** For indirect references, the word exclusive of the tag consists of
-** (a) an integer with MR_LIVE_LVAL_OFFSETBITS bits giving the number of
-** words to offset and (b) a MR_Live_Lval value giving the location of
-** the base address. This MR_Live_Lval valud will *not* have an indirect tag.
+** (a) an integer with MR_LONG_LVAL_OFFSETBITS bits giving the index
+** of the typeinfo inside a type class info (to be interpreted by
+** private_builtin:type_info_from_typeclass_info), and (b) a MR_Long_Lval
+** value giving the location of the pointer to the type class info.
+** This MR_Long_Lval valud will *not* have an indirect tag.
 **
 ** This data is generated in compiler/stack_layout.m, which must be kept
 ** in sync with the constants defined here.
 */
 
-typedef Word MR_Live_Lval;
+typedef uint_least32_t	MR_Long_Lval;
 
 typedef enum {
-	MR_LVAL_TYPE_R,
-	MR_LVAL_TYPE_F,
-	MR_LVAL_TYPE_STACKVAR,
-	MR_LVAL_TYPE_FRAMEVAR,
-	MR_LVAL_TYPE_SUCCIP,
-	MR_LVAL_TYPE_MAXFR,
-	MR_LVAL_TYPE_CURFR,
-	MR_LVAL_TYPE_HP,
-	MR_LVAL_TYPE_SP,
-	MR_LVAL_TYPE_INDIRECT,
-	MR_LVAL_TYPE_UNKNOWN 
-} MR_Lval_Type;
+	MR_LONG_LVAL_TYPE_R,
+	MR_LONG_LVAL_TYPE_F,
+	MR_LONG_LVAL_TYPE_STACKVAR,
+	MR_LONG_LVAL_TYPE_FRAMEVAR,
+	MR_LONG_LVAL_TYPE_SUCCIP,
+	MR_LONG_LVAL_TYPE_MAXFR,
+	MR_LONG_LVAL_TYPE_CURFR,
+	MR_LONG_LVAL_TYPE_HP,
+	MR_LONG_LVAL_TYPE_SP,
+	MR_LONG_LVAL_TYPE_INDIRECT,
+	MR_LONG_LVAL_TYPE_UNKNOWN 
+} MR_Long_Lval_Type;
 
 /* This must be in sync with stack_layout__tag_bits */
-#define MR_LIVE_LVAL_TAGBITS	4
+#define MR_LONG_LVAL_TAGBITS	4
 
-#define MR_LIVE_LVAL_TYPE(Locn) 				\
-	((MR_Lval_Type) (((Word) Locn) & ((1 << MR_LIVE_LVAL_TAGBITS) - 1)))
+#define MR_LONG_LVAL_TYPE(Locn) 					\
+	((MR_Long_Lval_Type)						\
+		(((Word) Locn) & ((1 << MR_LONG_LVAL_TAGBITS) - 1)))
 
-#define MR_LIVE_LVAL_NUMBER(Locn) 				\
-	((int) ((Word) Locn) >> MR_LIVE_LVAL_TAGBITS)
+#define MR_LONG_LVAL_NUMBER(Locn) 					\
+	((int) ((Word) Locn) >> MR_LONG_LVAL_TAGBITS)
 
 /* This must be in sync with stack_layout__offset_bits */
-#define MR_LIVE_LVAL_OFFSETBITS	6
+#define MR_LONG_LVAL_OFFSETBITS	6
 
-#define MR_LIVE_LVAL_INDIRECT_OFFSET(LocnNumber) 		\
-	((int) ((LocnNumber) & ((1 << MR_LIVE_LVAL_OFFSETBITS) - 1)))
+#define MR_LONG_LVAL_INDIRECT_OFFSET(LocnNumber) 			\
+	((int) ((LocnNumber) & ((1 << MR_LONG_LVAL_OFFSETBITS) - 1)))
 
-#define MR_LIVE_LVAL_INDIRECT_BASE_LVAL(LocnNumber)		\
-	(((Word) (LocnNumber)) >> MR_LIVE_LVAL_OFFSETBITS)
+#define MR_LONG_LVAL_INDIRECT_BASE_LVAL(LocnNumber)			\
+	(((Word) (LocnNumber)) >> MR_LONG_LVAL_OFFSETBITS)
 
-#define	MR_LIVE_LVAL_STACKVAR(n)				\
-	((Word) ((n) << MR_LIVE_LVAL_TAGBITS) + MR_LVAL_TYPE_STACKVAR)
+#define	MR_LONG_LVAL_STACKVAR(n)					\
+	((Word) ((n) << MR_LONG_LVAL_TAGBITS) + MR_LONG_LVAL_TYPE_STACKVAR)
 
-#define	MR_LIVE_LVAL_FRAMEVAR(n)				\
-	((Word) ((n) << MR_LIVE_LVAL_TAGBITS) + MR_LVAL_TYPE_FRAMEVAR)
+#define	MR_LONG_LVAL_FRAMEVAR(n)					\
+	((Word) ((n) << MR_LONG_LVAL_TAGBITS) + MR_LONG_LVAL_TYPE_FRAMEVAR)
 
-#define	MR_LIVE_LVAL_R_REG(n)					\
-	((Word) ((n) << MR_LIVE_LVAL_TAGBITS) + MR_LVAL_TYPE_R)
+#define	MR_LONG_LVAL_R_REG(n)						\
+	((Word) ((n) << MR_LONG_LVAL_TAGBITS) + MR_LONG_LVAL_TYPE_R)
+
+/*
+** MR_Short_Lval is a uint_least8_t which describes an location. This includes
+** lvals such as stack slots and general registers that have small numbers,
+** and special registers such as succip, hp, etc.
+**
+** What kind of location an MR_Long_Lval refers to is encoded using
+** a low tag with 2 bits; the type MR_Short_Lval_Type describes
+** the different tag values. The interpretation of the rest of the word
+** depends on the location type:
+**
+**  Locn		Tag	Rest
+**  r(Num)		 0	Num (register number)
+**  stackvar(Num)	 1	Num (stack slot number)
+**  framevar(Num)	 2	Num (stack slot number)
+**  special reg		 3	MR_Long_Lval_Type
+*/
+
+typedef uint_least8_t	MR_Short_Lval;
+
+typedef enum {
+	MR_SHORT_LVAL_TYPE_R,
+	MR_SHORT_LVAL_TYPE_STACKVAR,
+	MR_SHORT_LVAL_TYPE_FRAMEVAR,
+	MR_SHORT_LVAL_TYPE_SPECIAL
+} MR_Short_Lval_Type;
+
+#define	MR_SHORT_LVAL_STACKVAR(n)					\
+	((MR_Short_Lval) (((n) << 2) + MR_SHORT_LVAL_TYPE_STACKVAR))
+
+#define	MR_SHORT_LVAL_FRAMEVAR(n)					\
+	((MR_Short_Lval) (((n) << 2) + MR_SHORT_LVAL_TYPE_FRAMEVAR))
+
+#define	MR_SHORT_LVAL_R_REG(n)						\
+	((MR_Short_Lval) (((n) << 2) + MR_SHORT_LVAL_TYPE_R))
 
 /*-------------------------------------------------------------------------*/
 /*
@@ -191,13 +229,6 @@
 #define MR_LIVE_TYPE_GET_VAR_INST(T)   			\
 		(((MR_Var_Shape_Info *) T)->inst)
 
-/* MR_Stack_Layout_Var --------------------------------------------------- */
-
-typedef	struct MR_Stack_Layout_Var_Struct {
-	MR_Live_Lval		MR_slv_locn;
-	MR_Live_Type		MR_slv_live_type;
-} MR_Stack_Layout_Var;
-
 /*-------------------------------------------------------------------------*/
 /*
 ** Definitions for MR_Stack_Layout_Vars
@@ -205,26 +236,57 @@
 
 /*
 ** If MR_slvs_tvars == NULL, there are no type parameters.
-** If it is != NULL, then (Integer) MR_slvs_tvars[0] is the index
-** of the highest numbered type parameter, and MR_slvs_tvars[i]
-** for values of i between 1 and (Integer) MR_slvs_tvars[0] (both inclusive)
-** describe the location of the typeinfo structure for the type variable
-** of the corresponding number. If one of these type variables
+** If it is != NULL, then MR_slvs_tvars->MR_tp_param_count is the number
+** of type parameters, and the element at index i in the array
+** MR_slvs_tvars->MR_tp_param_locns describes the location of the typeinfo
+** structure for type variable i+1 (since array offsets start at zero
+** but type variable numbers start at one). If one of these type variables
 ** is not referred to by the variables described in MR_slvs_pairs,
 ** the corresponding entry will be zero.
 */
 
 typedef	struct MR_Type_Param_Locns_Struct {
-	Integer			MR_tp_param_count;
-	MR_Live_Lval		MR_tp_param_locns[MR_VARIABLE_SIZED];
+	uint_least32_t		MR_tp_param_count;
+	MR_Long_Lval		MR_tp_param_locns[MR_VARIABLE_SIZED];
 } MR_Type_Param_Locns;
 
+/*
+** The MR_slvs_var_count field should be set to a negative number
+** if there is no information about the variables live at the label.
+*/
+
 typedef	struct MR_Stack_Layout_Vars_Struct {
-	MR_Stack_Layout_Var	*MR_slvs_pairs;
+	void			*MR_slvs_var_count;
+	/* the remaining fields are present only if MR_sll_var_count > 0 */
+	void			*MR_slvs_locns_types;
 	String			*MR_slvs_names;
 	MR_Type_Param_Locns	*MR_slvs_tvars;
 } MR_Stack_Layout_Vars;
 
+#define	MR_BYTE_BITS	8
+#define	MR_BYTE_MAX	((1 << MR_BYTE_BITS) - 1)
+
+#define	MR_has_valid_var_count(slvs)					    \
+		(((Integer) ((slvs)->MR_slvs_var_count)) >= 0)
+#define	MR_has_valid_var_info(slvs)					    \
+		(((Integer) ((slvs)->MR_slvs_var_count)) > 0)
+#define	MR_long_desc_var_count(slvs)					    \
+		(((Integer) ((slvs)->MR_slvs_var_count)) >> MR_BYTE_BITS)
+#define	MR_short_desc_var_count(slvs)					    \
+		(((Integer) ((slvs)->MR_slvs_var_count)) & MR_BYTE_MAX)
+#define	MR_all_desc_var_count(slvs)					    \
+		(MR_long_desc_var_count(slvs) + MR_short_desc_var_count(slvs))
+#define	MR_var_pti(slvs, i)						    \
+		(((MR_PseudoTypeInfo **) ((slvs)->MR_slvs_locns_types))[(i)])
+#define	MR_end_of_var_ptis(slvs)					    \
+		(&MR_var_pti((slvs), MR_all_desc_var_count(slvs)))
+#define	MR_long_desc_var_locn(slvs, i)					    \
+		(((uint_least32_t *) MR_end_of_var_ptis(slvs))[(i)])
+#define	MR_end_of_long_desc_var_locns(slvs)				    \
+		(&MR_long_desc_var_locn((slvs), MR_long_desc_var_count(slvs)))
+#define	MR_short_desc_var_locn(slvs, i)					    \
+		(((uint_least8_t *) MR_end_of_long_desc_var_locns(slvs))[(i)])
+
 #define	MR_name_if_present(vars, i)					    \
 				((vars->MR_slvs_names != NULL		    \
 				&& vars->MR_slvs_names[(i)] != NULL)	    \
@@ -305,9 +367,9 @@
 typedef	struct MR_Stack_Layout_Entry_Struct {
 	/* stack traversal group */
 	Code			*MR_sle_code_addr;
+	MR_Long_Lval		MR_sle_succip_locn;
+	int_least16_t		MR_sle_stack_slots;
 	MR_Determinism		MR_sle_detism;
-	Integer			MR_sle_stack_slots;
-	MR_Live_Lval		MR_sle_succip_locn;
 
 	/* proc id group */
 	MR_Stack_Layout_Proc_Id	MR_sle_proc_id;
@@ -315,8 +377,8 @@
 	/* exec trace group */
 	struct MR_Stack_Layout_Label_Struct
 				*MR_sle_call_label;
-	Integer			MR_sle_maybe_from_full;
-	Integer			MR_sle_maybe_decl_debug;
+	int_least16_t		MR_sle_maybe_from_full;
+	int_least16_t		MR_sle_maybe_decl_debug;
 } MR_Stack_Layout_Entry;
 
 #define	MR_sle_user	MR_sle_proc_id.MR_proc_user
@@ -343,7 +405,7 @@
 ** and the location of the succip is fixed.
 **
 ** An unknown slot count should be signalled by MR_ENTRY_NO_SLOT_COUNT.
-** An unknown succip location should be signalled by MR_LVAL_TYPE_UNKNOWN.
+** An unknown succip location should be signalled by MR_LONG_LVAL_TYPE_UNKNOWN.
 **
 ** For the procedure identification, we always use the same module name
 ** for the defining and declaring modules, since procedures whose code
@@ -376,9 +438,9 @@
 		pf, module, name, arity, mode) 				\
 	MR_Stack_Layout_Entry mercury_data__layout__##entry = {		\
 		MR_MAKE_PROC_LAYOUT_ADDR(entry),			\
-		detism,							\
-		slots,							\
 		succip_locn,						\
+		slots,							\
+		detism,							\
 		{{							\
 			pf,						\
 			module,						\
@@ -440,18 +502,11 @@
 ** Definitions for MR_Stack_Layout_Label
 */
 
-/*
-** The MR_sll_var_count field should be set to a negative number
-** if there is no information about the variables live at the label.
-*/
-
 typedef	struct MR_Stack_Layout_Label_Struct {
 	MR_Stack_Layout_Entry	*MR_sll_entry;
 #ifdef	MR_LABEL_STRUCTS_INCLUDE_NUMBER
 	Integer			MR_sll_label_num;
 #endif
-	Integer			MR_sll_var_count;
-	/* the last field is present only if MR_sll_var_count > 0 */
 	MR_Stack_Layout_Vars	MR_sll_var_info;
 } MR_Stack_Layout_Label;
 
@@ -488,7 +543,12 @@
 	MR_Stack_Layout_Label mercury_data__layout__##l = {		\
 		&mercury_data__layout__##e,				\
 		UNKNOWN_INTERNAL_LABEL_NUMBER				\
-		(Integer) -1	/* No information about live values */	\
+		{							\
+			(void *) -1,	/* No info about live values */	\
+			NULL,						\
+			NULL,						\
+			NULL						\
+		}							\
 	}
 
 #define MR_MAKE_INTERNAL_LAYOUT(e, n)					\
Index: runtime/mercury_stack_trace.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stack_trace.c,v
retrieving revision 1.30
diff -u -b -u -r1.30 mercury_stack_trace.c
--- mercury_stack_trace.c	1999/03/17 00:35:08	1.30
+++ mercury_stack_trace.c	1999/04/21 02:59:01
@@ -160,8 +160,8 @@
 	const char **problem_ptr)
 {
 	MR_Internal		*label;
-	MR_Live_Lval		location;
-	MR_Lval_Type		type;
+	MR_Long_Lval		location;
+	MR_Long_Lval_Type	type;
 	int			number;
 	int			determinism;
 	Code			*success;
@@ -181,10 +181,10 @@
 
 	if (MR_DETISM_DET_STACK(determinism)) {
 		location = entry_layout->MR_sle_succip_locn;
-		type = MR_LIVE_LVAL_TYPE(location);
-		number = MR_LIVE_LVAL_NUMBER(location);
+		type = MR_LONG_LVAL_TYPE(location);
+		number = MR_LONG_LVAL_NUMBER(location);
 
-		if (type != MR_LVAL_TYPE_STACKVAR) {
+		if (type != MR_LONG_LVAL_TYPE_STACKVAR) {
 			*problem_ptr = "can only handle stackvars";
 			return STEP_ERROR_AFTER;
 		}
Index: runtime/mercury_types.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_types.h,v
retrieving revision 1.14
diff -u -b -u -r1.14 mercury_types.h
--- mercury_types.h	1998/12/15 00:22:29	1.14
+++ mercury_types.h	1999/04/26 01:10:38
@@ -26,10 +26,23 @@
 ** this is ensured by the autoconfiguration script.
 */
 
-typedef	unsigned WORD_TYPE	Word;
-typedef WORD_TYPE		Integer;
-typedef unsigned WORD_TYPE	Unsigned;
-typedef WORD_TYPE		Bool;
+#ifdef	HAVE_STDINT
+#include <stdint.h>
+#else
+typedef	unsigned WORD_TYPE	uintptr_t;
+typedef	WORD_TYPE		intptr_t;
+typedef	unsigned INT32_TYPE	uint_least32_t;
+typedef	INT32_TYPE		int_least32_t;
+typedef	unsigned INT16_TYPE	uint_least16_t;
+typedef	INT16_TYPE		int_least16_t;
+typedef	unsigned char		uint_least8_t;
+typedef	signed char		int_least8_t;
+#endif
+
+typedef	uintptr_t		Word;
+typedef	intptr_t		Integer;
+typedef	uintptr_t		Unsigned;
+typedef	intptr_t		Bool;
 
 /*
 ** `Code *' is used as a generic pointer-to-label type that can point
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 scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/misc_tests
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
Index: trace/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/Mmakefile,v
retrieving revision 1.8
diff -u -b -u -r1.8 Mmakefile
--- Mmakefile	1999/04/08 12:58:17	1.8
+++ Mmakefile	1999/04/26 01:13:48
@@ -61,6 +61,14 @@
 			mercury_trace_spy.c		\
 			mercury_trace_tables.c
 
+# The object files in this directory depend on many of the header files
+# in the runtime. However, changes to many of these header files require
+# a global make clean. Here we list only the header files from the runtime
+# whose changes don't usually require a make clean but which nevertheless
+# require the trace library to be recompiled.
+RUNTIME_HDRS	=	\
+			../runtime/mercury_stack_layout.h
+
 OBJS		= $(CFILES:.c=.o)
 PIC_OBJS	= $(CFILES:.c=.$(EXT_FOR_PIC_OBJECTS))
 
@@ -103,7 +111,7 @@
 
 #-----------------------------------------------------------------------------#
 
-$(OBJS) $(PIC_OBJS): $(HDRS)
+$(OBJS) $(PIC_OBJS): $(HDRS) $(RUNTIME_HDRS)
 
 #-----------------------------------------------------------------------------#
 
Index: trace/mercury_trace.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace.c,v
retrieving revision 1.8
diff -u -b -u -r1.8 mercury_trace.c
--- mercury_trace.c	1999/02/23 08:06:54	1.8
+++ mercury_trace.c	1999/04/21 09:51:31
@@ -302,15 +302,14 @@
 	saved_regs = event_info->MR_saved_regs;
 	entry = event_info->MR_event_sll->MR_sll_entry;
 	call_label = entry->MR_sle_call_label;
+	input_args = &call_label->MR_sll_var_info;
 
-	if (call_label->MR_sll_var_count < 0) {
+	if (input_args->MR_slvs_var_count < 0) {
 		message = "Cannot perform retry because information about "
 		          "the input arguments is not available.";
 		return message;
 	}
 
-	input_args = &call_label->MR_sll_var_info;
-
 	/*
 	** With the Boehm collector, args need not be considered a root, 
 	** since its contents are just copies of values from elsewhere,
@@ -322,7 +321,7 @@
 	args = NULL;
 	arg_max = 0;
 
-	for (i = 0; i < call_label->MR_sll_var_count; i++) {
+	for (i = 0; i < MR_all_desc_var_count(input_args); i++) {
 		arg_value = MR_trace_find_input_arg(event_info->MR_event_sll,
 				saved_regs, input_args->MR_slvs_names[i],
 				&succeeded);
@@ -333,8 +332,14 @@
 			return message;
 		}
 
-		arg_num = MR_get_register_number(
-			input_args->MR_slvs_pairs[i].MR_slv_locn);
+		if (i < MR_long_desc_var_count(input_args)) {
+			arg_num = MR_get_register_number_long(
+				MR_long_desc_var_locn(input_args, i));
+		} else {
+			arg_num = MR_get_register_number_short(
+				MR_short_desc_var_locn(input_args, i));
+		}
+
 		if (arg_num > 0) {
 			MR_ensure_big_enough(arg_num, arg, Word,
 				MR_INIT_ARG_COUNT);
@@ -348,7 +353,7 @@
 	MR_trace_call_depth = event_info->MR_call_depth - 1;
 
 	if (MR_DETISM_DET_STACK(entry->MR_sle_detism)) {
-		MR_Live_Lval	location;
+		MR_Long_Lval	location;
 		Word		*this_frame;
 
 		/*
@@ -359,14 +364,15 @@
 		*/
 
 		location = entry->MR_sle_succip_locn;
-		if (MR_LIVE_LVAL_TYPE(location) != MR_LVAL_TYPE_STACKVAR) {
+		if (MR_LONG_LVAL_TYPE(location) != MR_LONG_LVAL_TYPE_STACKVAR)
+		{
 			fatal_error("illegal location for stored succip");
 		}
 
 		this_frame = MR_saved_sp(saved_regs);
 		MR_saved_succip(saved_regs) = (Word *)
 				MR_based_stackvar(this_frame,
-				MR_LIVE_LVAL_NUMBER(location));
+				MR_LONG_LVAL_NUMBER(location));
 		MR_saved_sp(saved_regs) -= entry->MR_sle_stack_slots;
 		MR_trace_event_number = MR_event_num_stackvar(this_frame);
 	} else {
@@ -425,12 +431,19 @@
 		return 0;
 	}
 
-	for (i = 0; i < label->MR_sll_var_count; i++) {
+	for (i = 0; i < MR_all_desc_var_count(vars); i++) {
 		if (streq(vars->MR_slvs_names[i], name)) {
-			return MR_lookup_live_lval_base(
-				vars->MR_slvs_pairs[i].MR_slv_locn, saved_regs,
-				MR_saved_sp(saved_regs),
+			if (i < MR_long_desc_var_count(vars)) {
+				return MR_lookup_long_lval_base(
+					MR_long_desc_var_locn(vars, i),
+					saved_regs, MR_saved_sp(saved_regs),
+					MR_saved_curfr(saved_regs), succeeded);
+			} else {
+				return MR_lookup_short_lval_base(
+					MR_short_desc_var_locn(vars, i),
+					saved_regs, MR_saved_sp(saved_regs),
 				MR_saved_curfr(saved_regs), succeeded);
+			}
 		}
 	}
 
Index: trace/mercury_trace_external.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_external.c,v
retrieving revision 1.15
diff -u -b -u -r1.15 mercury_trace_external.c
--- mercury_trace_external.c	1999/04/22 06:58:50	1.15
+++ mercury_trace_external.c	1999/04/22 07:40:18
@@ -819,8 +819,8 @@
 
 	Word				var_names_list;
 
-	var_count = layout->MR_sll_var_count;
 	vars = &layout->MR_sll_var_info;
+	var_count = MR_all_desc_var_count(vars);
 
     MR_TRACE_USE_HP(
 	var_names_list = list_empty();
@@ -831,8 +831,7 @@
 		** due to the fake arity of the type private_builtin:typeinfo/1.
 		*/
 		if ((strncmp(name, "TypeInfo", 8) == 0)
-		    || (strncmp(name, "TypeClassInfo", 13) == 0)
-		    ) {
+		|| (strncmp(name, "TypeClassInfo", 13) == 0)) {
 		  continue;
 		}
 
@@ -856,7 +855,6 @@
 	const MR_Stack_Layout_Vars 	*vars;
 	int				i;
 	const char			*name;
-	MR_Stack_Layout_Var*		var;
 	Word				type_info;
 	String		      		type_info_string;
 	Word				*base_sp;
@@ -865,8 +863,8 @@
 
 	Word				type_list;
 
-	var_count = layout->MR_sll_var_count;
 	vars = &layout->MR_sll_var_info;
+	var_count = MR_all_desc_var_count(vars);
 
 	base_sp = MR_saved_sp(saved_regs);
 	base_curfr = MR_saved_curfr(saved_regs);
@@ -876,10 +874,10 @@
         );
 
 	/* 
-	** If no information on live variables is available, return the 
-	** empty list 
+	** If no information on live variables is available, or if there
+	** are no live variables, return the empty list.
 	*/
-	if (layout->MR_sll_var_count <= 0) {
+	if (! MR_has_valid_var_info(vars)) {
 		return type_list;
 	}
 
@@ -889,10 +887,8 @@
 	for (i = var_count - 1; i >= 0; i--) {
 
 		name = MR_name_if_present(vars, i);
-		var = &vars->MR_slvs_pairs[i];
-
-		if (! MR_get_type_filtered(var, saved_regs, name, type_params, 
-			&type_info))
+		if (! MR_get_type_filtered(vars, i, saved_regs,
+			name, type_params, &type_info))
 		{
 			continue;
 		}
@@ -921,8 +917,6 @@
 	int 				var_number;
 	const MR_Stack_Layout_Vars 	*vars;
 	const char			*name;
-	MR_Stack_Layout_Var*		var;
-	int				i;
 	Word				value;
 	Word				type_info;
 	Word				*base_sp;
@@ -936,7 +930,6 @@
 		   current_nth_var(var_number) */
 	vars = &layout->MR_sll_var_info;
 	name = MR_name_if_present(vars, var_number);
-	var = &vars->MR_slvs_pairs[var_number];
 	base_sp = MR_saved_sp(saved_regs);
 	base_curfr = MR_saved_curfr(saved_regs);
 	
@@ -944,7 +937,7 @@
 	** Should never occur since we check in the external debugger
 	** process if a variable is live before retrieving it.
 	*/
-	if (layout->MR_sll_var_count <= 0) {
+	if (! MR_has_valid_var_info(vars)) {
 		fatal_error("try to retrieve a non-live variable");
 	}
 
@@ -955,7 +948,7 @@
 		incr_hp(univ, 2);
 	);
 
-	if (MR_get_type_and_value_filtered(var, saved_regs, name,
+	if (MR_get_type_and_value_filtered(vars, var_number, saved_regs, name,
 			type_params, &type_info, &value))
 	{
 		field(mktag(0), univ, UNIV_OFFSET_FOR_TYPEINFO) = type_info;
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.39
diff -u -b -u -r1.39 mercury_trace_internal.c
--- mercury_trace_internal.c	1999/04/20 11:48:56	1.39
+++ mercury_trace_internal.c	1999/04/21 10:21:00
@@ -183,7 +183,7 @@
 static	void	MR_trace_browse_all(const MR_Stack_Layout_Label *top_layout,
 			Word *saved_regs, int ancestor_level);
 static	void	MR_trace_browse_var(const char *name,
-			const MR_Stack_Layout_Var *var,
+			const MR_Stack_Layout_Vars *vars, int i,
 			Word *saved_regs, Word *base_sp, Word *base_curfr,
 			Word *type_params, bool browse);
 static	const char *MR_trace_validate_var_count(const MR_Stack_Layout_Label
@@ -1768,7 +1768,7 @@
 	type_params = MR_materialize_typeinfos_base(vars,
 				valid_saved_regs, base_sp, base_curfr);
 	MR_trace_browse_var(MR_name_if_present(vars, which_var),
-		&vars->MR_slvs_pairs[which_var], valid_saved_regs,
+		vars, which_var, valid_saved_regs,
 		base_sp, base_curfr, type_params, browse);
 	free(type_params);
 }
@@ -1817,7 +1817,7 @@
 
 	for (i = 0; i < var_count; i++) {
 		MR_trace_browse_var(MR_name_if_present(vars, i),
-			&vars->MR_slvs_pairs[i], valid_saved_regs,
+			vars, i, valid_saved_regs,
 			base_sp, base_curfr, type_params, FALSE);
 	}
 
@@ -1825,14 +1825,13 @@
 }
 
 static void
-MR_trace_browse_var(const char *name, const MR_Stack_Layout_Var *var,
+MR_trace_browse_var(const char *name, const MR_Stack_Layout_Vars *vars, int i,
 	Word *saved_regs, Word *base_sp, Word *base_curfr, Word *type_params,
 	bool browse)
 {
 	Word	value;
 	Word	type_info;
 	bool	print_value;
-	int	i;
 
 	/*
 	** XXX The printing of type_infos is buggy at the moment
@@ -1864,7 +1863,7 @@
 	** are not of interest to the user.
 	*/
 
-	print_value = MR_get_type_and_value_base(var, saved_regs,
+	print_value = MR_get_type_and_value_base(vars, i, saved_regs,
 			base_sp, base_curfr, type_params, &type_info, &value);
 	if (print_value) {
 		if (browse) {
@@ -1883,12 +1882,13 @@
 MR_trace_validate_var_count(const MR_Stack_Layout_Label *layout,
 	int *var_count_ptr)
 {
-	*var_count_ptr = (int) layout->MR_sll_var_count;
-	if (*var_count_ptr < 0) {
+	if (! MR_has_valid_var_count(&layout->MR_sll_var_info)) {
 		return "there is no information about live variables";
-	} else if (*var_count_ptr == 0) {
+	} else if (! MR_has_valid_var_info(&layout->MR_sll_var_info)) {
 		return "there are no live variables";
 	} else {
+		*var_count_ptr =
+			MR_all_desc_var_count(&layout->MR_sll_var_info);
 		return NULL;
 	}
 }
cvs diff: Diffing trial
cvs diff: Diffing util
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list