for review: fix init_entry_sl(...) generation.

Tyson Dowd trd at cs.mu.OZ.AU
Wed Jul 15 18:53:12 AEST 1998


Hi,

Zoltan might want to take a quick look at this.

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


Estimated hours taken: 2

Fix a bug in the generation of init_entry_sl(...) code.

compiler/code_gen.m:
compiler/continuation_info.m:
compiler/stack_layout.m:
	Previously the code used a proc_label to describe an entry label,
	and stored (incorrectly) as local(proc_label) in a list of labels
	(the list of labels that had stack_layouts).

	Later when deciding whether an "init_entry" or "init_entry_sl"
	should be generated, it looked for the label in the list of
	labels for which stack layouts had been generated, but would
	compare with the actual label for the entry.  In particular,
	the label might be exported(....) instead of local(....), which
	means init_entry was used instead of init_entry_sl.

	Fix this by correctly generating labels rather than assuming
	they are local(...), and using "label" where "proc_label" was
	used before.



Index: compiler/code_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_gen.m,v
retrieving revision 1.52
diff -u -r1.52 code_gen.m
--- code_gen.m	1998/06/18 06:05:48	1.52
+++ code_gen.m	1998/07/14 05:08:52
@@ -211,7 +211,6 @@
 		ModuleInfo, CellCount0, CodeInfo0),
 		% generate code for the procedure
 	globals__get_trace_level(Globals, TraceLevel),
-	code_util__make_proc_label(ModuleInfo, PredId, ProcId, ProcLabel),
 	( trace_level_trace_interface(TraceLevel, yes) ->
 		trace__setup(TraceLevel, CodeInfo0, CodeInfo1)
 	;
@@ -238,8 +237,10 @@
 	),
 	( BasicStackLayout = yes ->
 		code_info__get_layout_info(LayoutInfo, CodeInfo, _CodeInfo2),
+		code_util__make_local_entry_label(ModuleInfo, PredId, ProcId,
+			no, Label),
 		continuation_info__add_proc_info(proc(PredId, ProcId),
-			ProcLabel, TotalSlots, Detism, MaybeSuccipSlot,
+			Label, TotalSlots, Detism, MaybeSuccipSlot,
 			MaybeTraceCallLabel, LayoutInfo, ContInfo0, ContInfo)
 	;
 		ContInfo = ContInfo0
Index: compiler/continuation_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/continuation_info.m,v
retrieving revision 1.13
diff -u -r1.13 continuation_info.m
--- continuation_info.m	1998/06/18 06:06:04	1.13
+++ continuation_info.m	1998/07/14 05:11:30
@@ -63,7 +63,7 @@
 	%
 :- type proc_layout_info
 	--->	proc_layout_info(
-			proc_label,	% the proc label
+			label,		% the entry label
 			determinism,	% determines which stack is used
 			int,		% number of stack slots
 			maybe(int),	% location of succip on stack
@@ -170,11 +170,11 @@
 	%
 	% Add the information for a single proc.
 	%
-	% Takes the pred_proc_id, proc_label, the number of stack slots,
+	% Takes the pred_proc_id, label, the number of stack slots,
 	% the code model for this proc, and the stack slot of the succip
 	% in this proc (if there is one).
 	%
-:- pred continuation_info__add_proc_info(pred_proc_id::in, proc_label::in,
+:- pred continuation_info__add_proc_info(pred_proc_id::in, label::in,
 	int::in, determinism::in, maybe(int)::in, maybe(label)::in,
 	proc_label_layout_info::in, continuation_info::in,
 	continuation_info::out) is det.
@@ -226,13 +226,13 @@
 	% Add the info for this proc (a proc_layout_info) to the
 	% continuation_info. 
 	%
-continuation_info__add_proc_info(PredProcId, ProcLabel, StackSize,
+continuation_info__add_proc_info(PredProcId, Label, StackSize,
 		Detism, SuccipLocation, MaybeTraceCallLabel, InternalMap,
 		ContInfo0, ContInfo) :-
 	( map__contains(ContInfo0, PredProcId) ->
 		error("duplicate continuation_info for proc.")
 	;
-		LayoutInfo = proc_layout_info(ProcLabel, Detism, StackSize,
+		LayoutInfo = proc_layout_info(Label, Detism, StackSize,
 			SuccipLocation, MaybeTraceCallLabel, InternalMap),
 		map__det_insert(ContInfo0, PredProcId, LayoutInfo, ContInfo)
 	).
Index: compiler/stack_layout.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/stack_layout.m,v
retrieving revision 1.15
diff -u -r1.15 stack_layout.m
--- stack_layout.m	1998/07/09 04:38:47	1.15
+++ stack_layout.m	1998/07/14 05:35:55
@@ -221,23 +221,23 @@
 	stack_layout_info::in, stack_layout_info::out) is det.
 
 stack_layout__construct_layouts(ProcLayoutInfo) -->
-	{ ProcLayoutInfo = proc_layout_info(ProcLabel, Detism,
+	{ ProcLayoutInfo = proc_layout_info(Label, Detism,
 		StackSlots, SuccipLoc, CallLabel, InternalMap) },
-	stack_layout__construct_proc_layout(ProcLabel, Detism,
+	stack_layout__construct_proc_layout(Label, Detism,
 		StackSlots, SuccipLoc, CallLabel),
 	{ map__to_assoc_list(InternalMap, Internals) },
-	list__foldl(stack_layout__construct_internal_layout(ProcLabel),
+	list__foldl(stack_layout__construct_internal_layout(Label),
 		Internals).
 
 %---------------------------------------------------------------------------%
 
 	% Construct a procedure-specific layout.
 
-:- pred stack_layout__construct_proc_layout(proc_label::in,
+:- pred stack_layout__construct_proc_layout(label::in,
 	determinism::in, int::in, maybe(int)::in, maybe(label)::in,
 	stack_layout_info::in, stack_layout_info::out) is det.
 
-stack_layout__construct_proc_layout(ProcLabel, Detism, StackSlots,
+stack_layout__construct_proc_layout(Label, Detism, StackSlots,
 		MaybeSuccipLoc, MaybeCallLabel) -->
 	{
 		MaybeSuccipLoc = yes(Location0)
@@ -277,7 +277,6 @@
 	;
 		SuccipLval = stackvar(Location)
 	},
-	{ Label = local(ProcLabel) },
 	{ stack_layout__represent_lval(SuccipLval, SuccipRval) },
 	{ StackSlotsRval = const(int_const(StackSlots)) },
 	{ CodeAddrRval = const(code_addr_const(label(Label))) },
@@ -290,7 +289,7 @@
 	(
 		{ ProcIdLayout = yes }
 	->
-		{ stack_layout__construct_procid_rvals(ProcLabel, IdRvals) },
+		{ stack_layout__construct_procid_rvals(Label, IdRvals) },
 		{ list__append(MaybeRvals0, IdRvals, MaybeRvals1) }
 	;
 		{ NoIdRvals = yes(const(int_const(-1))) },
@@ -324,10 +323,19 @@
 
 %---------------------------------------------------------------------------%
 
-:- pred stack_layout__construct_procid_rvals(proc_label::in,
+:- pred stack_layout__construct_procid_rvals(label::in,
 	list(maybe(rval))::out) is det.
 
-stack_layout__construct_procid_rvals(ProcLabel, Rvals) :-
+stack_layout__construct_procid_rvals(Label, Rvals) :-
+	( 
+		Label = local(ProcLabel, _)
+	;
+		Label = c_local(ProcLabel)
+	;
+		Label = local(ProcLabel)
+	;
+		Label = exported(ProcLabel)
+	),
 	(
 		ProcLabel = proc(DefModule, PredFunc, DeclModule,
 			PredName, Arity, ProcId),
@@ -368,7 +376,7 @@
 
 	% Construct the layout describing a single internal label.
 
-:- pred stack_layout__construct_internal_layout(proc_label::in,
+:- pred stack_layout__construct_internal_layout(label::in,
 	pair(label, internal_layout_info)::in,
 	stack_layout_info::in, stack_layout_info::out) is det.
 
@@ -376,7 +384,7 @@
 		% generate the required rvals
 	stack_layout__get_module_name(ModuleName),
 	{ EntryAddrRval = const(data_addr_const(data_addr(ModuleName,
-		stack_layout(local(ProcLabel))))) },
+		stack_layout(ProcLabel)))) },
 	stack_layout__construct_internal_rvals(Internal, VarInfoRvals),
 	% Reenable this code if you want label numbers in label layouts.
 	% { Label = local(_, LabelNum0) ->


-- 
       Tyson Dowd           # There isn't any reason why Linux can't be
                            # implemented as an enterprise computing solution.
     trd at cs.mu.oz.au        # Find out what you've been missing while you've
http://www.cs.mu.oz.au/~trd # been rebooting Windows NT. -- InfoWorld, 1998.



More information about the developers mailing list