for review: layouts without static code addresses

Zoltan Somogyi zs at cs.mu.OZ.AU
Tue Nov 10 22:43:39 AEDT 1998


This is for Fergus.

Estimated hours taken: 16

Make stack layout structures work in grades that do not have static code
addresses.

compiler/llds_out.m:
	If an entry label has a layout structure, then during its
	initialization, output a macro that will, if necessary,
	initialize the code address inside its layout structure.

	Do not output a const before a layout structure if the macro
	will actually initialize a code address inside it.

compiler/llds.m:
	Separate out proc_layouts from internal_layouts in the type
	data_name, since only proc_layouts have code addresses in them.

	Clarify the existing documentation of the label type's alternatives.
	This should help prevent the recurrence of bugs like the one in
	mercury_goto.h.

compiler/stack_layout.m:
	Replace code addresses inside proc layout structures with a dummy
	value if code addresses are not static.

runtime/mercury_goto.h:
	Fix a long-standing bug: init_local should treat its argument
	as an entry label, not as an internal label.

runtime/mercury_stack_layout.h:
	In the macros for creating proc layouts by hand-written C code,
	allow for the absence of static code addresses, and add a new
	macro that fills in the code address slot in proc layouts
	at initialization time if necessary.

library/benchmarking.m:
library/private_builtin.m:
library/std_util.m:
	Add calls to the new initialization macro to accompany hand-written
	proc layout structures.

Zoltan.

cvs diff: Diffing .
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing bytecode/test
cvs diff: Diffing compiler
Index: compiler/llds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds.m,v
retrieving revision 1.230
diff -u -u -r1.230 llds.m
- --- llds.m	1998/10/23 00:40:10	1.230
+++ llds.m	1998/11/10 11:19:12
@@ -648,8 +648,11 @@
 	;	base_typeclass_info(class_id, string)
 			% class name & class arity, names and arities of the
 			% types
- -	;	stack_layout(label).	
- -			% stack_layout for a given label
+	;	proc_layout(label)
+			% layout structure for the procedure of the given entry
+			% label
+	;	internal_layout(label).
+			% layout structure for the given internal label
 
 :- type base_data
 	--->	info
@@ -715,10 +718,10 @@
 	;	f.		% floating point regs
 
 :- type label
- -	--->	local(proc_label, int)	% internal to procedure
- -	;	c_local(proc_label)	% internal to C module
- -	;	local(proc_label)	% internal to Mercury module
- -	;	exported(proc_label).	% exported from Mercury module
+	--->	local(proc_label, int)	% not entry; internal to a procedure
+	;	c_local(proc_label)	% entry; internal to a C module
+	;	local(proc_label)	% entry; internal to a Mercury module
+	;	exported(proc_label).	% entry; exported from a Mercury module
 
 :- type code_addr
 	--->	label(label)		% A label defined in this Mercury
Index: compiler/llds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds_out.m,v
retrieving revision 1.95
diff -u -u -r1.95 llds_out.m
- --- llds_out.m	1998/11/05 03:52:20	1.95
+++ llds_out.m	1998/11/10 11:31:58
@@ -773,43 +773,47 @@
 :- mode output_c_label_init(in, in, di, uo) is det.
 
 output_c_label_init(Label, StackLayoutLabels) -->
- -	(
- -		{ Label = exported(_) },
- -		( { set_bbbtree__member(Label, StackLayoutLabels) } ->
- -			io__write_string("\tinit_entry_sl(")
+	( { set_bbbtree__member(Label, StackLayoutLabels) } ->
+		( { label_is_entry(Label, yes) } ->
+			% Labels whose stack layouts are proc layouts may need
+			% to have the code address in that layout initialized
+			% at run time (if code addresses are not static).
+			io__write_string("\tMR_INIT_PROC_LAYOUT_ADDR("),
+			output_label(Label),
+			io__write_string(");\n")
 		;
- -			io__write_string("\tinit_entry(")
+			% Labels whose stack layouts are internal layouts
+			% do not have code addresses in their layouts.
+			[]
 		),
- -		output_label(Label),
- -		io__write_string(");\n")
+		{ SuffixOpen = "_sl(" }
+	;
+		{ SuffixOpen = "(" }
+	),
+	(
+		{ Label = exported(_) },
+		{ TabInitMacro = "\tinit_entry" }
 	;
 		{ Label = local(_) },
- -		( { set_bbbtree__member(Label, StackLayoutLabels) } ->
- -			io__write_string("\tinit_entry_sl(")
- -		;
- -			io__write_string("\tinit_entry(")
- -		),
- -		output_label(Label),
- -		io__write_string(");\n")
+		{ TabInitMacro = "\tinit_entry" }
 	;
 		{ Label = c_local(_) },
- -		( { set_bbbtree__member(Label, StackLayoutLabels) } ->
- -			io__write_string("\tinit_local_sl(")
- -		;
- -			io__write_string("\tinit_local(")
- -		),
- -		output_label(Label),
- -		io__write_string(");\n")
+		{ TabInitMacro = "\tinit_local" }
 	;
 		{ Label = local(_, _) },
- -		( { set_bbbtree__member(Label, StackLayoutLabels) } ->
- -			io__write_string("\tinit_label_sl(")
- -		;
- -			io__write_string("\tinit_label(")
- -		),
- -		output_label(Label),
- -		io__write_string(");\n")
- -	).
+		{ TabInitMacro = "\tinit_label" }
+	),
+	io__write_string(TabInitMacro),
+	io__write_string(SuffixOpen),
+	output_label(Label),
+	io__write_string(");\n").
+
+:- pred label_is_entry(label::in, bool::out) is det.
+
+label_is_entry(local(_, _), no).
+label_is_entry(c_local(_), yes).
+label_is_entry(local(_), yes).
+label_is_entry(exported(_), yes).
 
 :- pred output_c_procedure_list_decls(list(c_procedure), decl_set, decl_set,
 	io__state, io__state).
@@ -2034,11 +2038,13 @@
 		globals__io_get_globals(Globals),
 		{ globals__have_static_code_addresses(Globals, StaticCode) },
 		(
- -				% Don't make decls of base_type_infos `const' 
- -				% if we don't have static code addresses.
+				% Don't make the structure `const' 
+				% if the structure will eventually include
+				% code addresses but we don't have static code
+				% addresses.
 			{ StaticCode = no },
- -			{ DeclId = data_addr(
- -					data_addr(_, base_type(info, _, _))) }
+			{ DeclId = data_addr(data_addr(_, DataName)) },
+			{ data_name_would_include_code_address(DataName, yes) }
 		->
 			[]
 		;
@@ -2078,6 +2084,23 @@
 		io__write_string(";\n")
 	).
 
+	% Return true if a data structure of the given type will eventually
+	% include code addresses. Note that we can't just test the data
+	% structure itself, since in the absence of code addresses the earlier
+	% passes will have replaced any code addresses with dummy values
+	% that will have to be overridden with the real code address at
+	% initialization time.
+
+:- pred data_name_would_include_code_address(data_name, bool).
+:- mode data_name_would_include_code_address(in, out) is det.
+
+data_name_would_include_code_address(common(_), no).
+data_name_would_include_code_address(base_type(info, _, _), yes).
+data_name_would_include_code_address(base_type(layout, _, _), no).
+data_name_would_include_code_address(base_type(functors, _, _), no).
+data_name_would_include_code_address(base_typeclass_info(_, _), yes).
+data_name_would_include_code_address(proc_layout(_), yes).
+data_name_would_include_code_address(internal_layout(_), no).
 
 :- pred output_decl_id(decl_id, io__state, io__state).
 :- mode output_decl_id(in, di, uo) is det.
@@ -2435,12 +2458,13 @@
 :- type linkage ---> extern ; static.
 
 :- pred linkage(data_name::in, linkage::out) is det.
- -linkage(base_typeclass_info(_, _), extern).
+linkage(common(_),                 static).
 linkage(base_type(info, _, _),     extern).
 linkage(base_type(layout, _, _),   static).
 linkage(base_type(functors, _, _), static).
- -linkage(common(_),                 static).
- -linkage(stack_layout(_),           static).
+linkage(base_typeclass_info(_, _), extern).
+linkage(proc_layout(_),            static).
+linkage(internal_layout(_),        static).
 
 %-----------------------------------------------------------------------------%
 
@@ -2693,7 +2717,12 @@
 		io__write_string(Str)
 	;
 		% Keep this code in sync with make_stack_layout_name/3.
- -		{ VarName = stack_layout(Label) },
+		{ VarName = proc_layout(Label) },
+		io__write_string("_layout__"),
+		output_label(Label)
+	;
+		% Keep this code in sync with make_stack_layout_name/3.
+		{ VarName = internal_layout(Label) },
 		io__write_string("_layout__"),
 		output_label(Label)
 	).
Index: compiler/stack_layout.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/stack_layout.m,v
retrieving revision 1.22
diff -u -u -r1.22 stack_layout.m
- --- stack_layout.m	1998/11/05 03:52:35	1.22
+++ stack_layout.m	1998/11/10 11:23:09
@@ -185,6 +185,7 @@
 		bool,		% generate agc layout info?
 		bool,		% generate tracing layout info?
 		bool,		% generate procedure id layout info?
+		bool,		% have static code addresses?
 		list(c_module),	% generated data
 		set_bbbtree(label)
 				% the set of labels with stack layouts
@@ -208,10 +209,12 @@
 	globals__lookup_bool_option(Globals, trace_stack_layout, TraceLayout),
 	globals__lookup_bool_option(Globals, procid_stack_layout,
 		ProcInfoLayout),
+	globals__have_static_code_addresses(Globals, StaticCodeAddr),
 	set_bbbtree__init(StackLayoutLabels0),
 
 	LayoutInfo0 = stack_layout_info(ModuleName, CellCount, AgcLayout,
- -		TraceLayout, ProcInfoLayout, [], StackLayoutLabels0),
+		TraceLayout, ProcInfoLayout, StaticCodeAddr,
+		[], StackLayoutLabels0),
 	list__foldl(stack_layout__construct_layouts, ProcLayoutList,
 		LayoutInfo0, LayoutInfo),
 
@@ -291,7 +294,14 @@
 	},
 	{ stack_layout__represent_locn(direct(SuccipLval), SuccipRval) },
 	{ StackSlotsRval = const(int_const(StackSlots)) },
- -	{ CodeAddrRval = const(code_addr_const(label(EntryLabel))) },
+	stack_layout__get_static_code_addresses(StaticCodeAddr),
+	{ StaticCodeAddr = yes ->
+		CodeAddrRval = const(code_addr_const(label(EntryLabel)))
+	;
+		% This is a lie; the slot will be filled in for real
+		% at initialization time.
+		CodeAddrRval = const(int_const(0))
+	},
 
 	{ stack_layout__represent_determinism(Detism, DetismRval) },
 	{ MaybeRvals0 = [yes(CodeAddrRval), yes(DetismRval),
@@ -320,7 +330,7 @@
 		( MaybeCallLabel = yes(CallLabel) ->
 			CallRval = yes(const(data_addr_const(
 					data_addr(ModuleName,
- -						stack_layout(CallLabel)))))
+						internal_layout(CallLabel)))))
 		;
 			error("stack_layout__construct_proc_layout: call label not present")
 		),
@@ -348,7 +358,7 @@
 				% is given and if the procedure is exported.
 				% Beware however that linkage/2 in llds_out.m
 				% assumes that this is `no'.
- -	{ CModule = c_data(ModuleName, stack_layout(EntryLabel), Exported,
+	{ CModule = c_data(ModuleName, proc_layout(EntryLabel), Exported,
 		MaybeRvals, []) },
 	stack_layout__add_cmodule(CModule, EntryLabel).
 
@@ -415,7 +425,7 @@
 		% generate the required rvals
 	stack_layout__get_module_name(ModuleName),
 	{ EntryAddrRval = const(data_addr_const(data_addr(ModuleName,
- -		stack_layout(EntryLabel)))) },
+		proc_layout(EntryLabel)))) },
 	stack_layout__construct_internal_rvals(Internal, VarInfoRvals),
 	% Reenable this code if you want label numbers in label layouts.
 	% { Label = local(_, LabelNum0) ->
@@ -427,7 +437,7 @@
 	% { LayoutRvals = [yes(EntryAddrRval), yes(LabelNumRval
 	% 	| VarInfoRvals] }
 	{ LayoutRvals = [yes(EntryAddrRval) | VarInfoRvals] },
- -	{ CModule = c_data(ModuleName, stack_layout(Label), no,
+	{ CModule = c_data(ModuleName, internal_layout(Label), no,
 		LayoutRvals, []) },
 	stack_layout__add_cmodule(CModule, Label).
 
@@ -906,68 +916,75 @@
 	stack_layout_info::in, stack_layout_info::out) is det.
 
 stack_layout__get_module_name(ModuleName, LayoutInfo, LayoutInfo) :-
- -	LayoutInfo = stack_layout_info(ModuleName, _, _, _, _, _, _).
+	LayoutInfo = stack_layout_info(ModuleName, _, _, _, _, _, _, _).
 
 :- pred stack_layout__get_next_cell_number(int::out,
 	stack_layout_info::in, stack_layout_info::out) is det.
 
 stack_layout__get_next_cell_number(CNum0, LayoutInfo0, LayoutInfo) :-
- -	LayoutInfo0 = stack_layout_info(A, CNum0, C, D, E, F, G),
+	LayoutInfo0 = stack_layout_info(A, CNum0, C, D, E, F, G, H),
 	CNum is CNum0 + 1,
- -	LayoutInfo = stack_layout_info(A, CNum, C, D, E, F, G).
+	LayoutInfo = stack_layout_info(A, CNum, C, D, E, F, G, H).
 
 :- pred stack_layout__get_cell_number(int::out,
 	stack_layout_info::in, stack_layout_info::out) is det.
 
 stack_layout__get_cell_number(CNum, LayoutInfo, LayoutInfo) :-
- -	LayoutInfo = stack_layout_info(_, CNum, _, _, _, _, _).
+	LayoutInfo = stack_layout_info(_, CNum, _, _, _, _, _, _).
 
 :- pred stack_layout__get_agc_stack_layout(bool::out,
 	stack_layout_info::in, stack_layout_info::out) is det.
 
 stack_layout__get_agc_stack_layout(AgcStackLayout, LayoutInfo, LayoutInfo) :-
- -	LayoutInfo = stack_layout_info(_, _, AgcStackLayout, _, _, _, _).
+	LayoutInfo = stack_layout_info(_, _, AgcStackLayout, _, _, _, _, _).
 
 :- pred stack_layout__get_trace_stack_layout(bool::out,
 	stack_layout_info::in, stack_layout_info::out) is det.
 
 stack_layout__get_trace_stack_layout(TraceStackLayout, LayoutInfo,
 		LayoutInfo) :-
- -	LayoutInfo = stack_layout_info(_, _, _, TraceStackLayout, _, _, _).
+	LayoutInfo = stack_layout_info(_, _, _, TraceStackLayout, _, _, _, _).
 
 :- pred stack_layout__get_procid_stack_layout(bool::out,
 	stack_layout_info::in, stack_layout_info::out) is det.
 
 stack_layout__get_procid_stack_layout(ProcIdStackLayout, LayoutInfo,
 		LayoutInfo) :-
- -	LayoutInfo = stack_layout_info(_, _, _, _, ProcIdStackLayout, _, _).
+	LayoutInfo = stack_layout_info(_, _, _, _, ProcIdStackLayout, _, _, _).
+
+:- pred stack_layout__get_static_code_addresses(bool::out,
+	stack_layout_info::in, stack_layout_info::out) is det.
+
+stack_layout__get_static_code_addresses(StaticCodeAdddr, LayoutInfo,
+		LayoutInfo) :-
+	LayoutInfo = stack_layout_info(_, _, _, _, _, StaticCodeAdddr, _, _).
 
 :- pred stack_layout__get_cmodules(list(c_module)::out,
 	stack_layout_info::in, stack_layout_info::out) is det.
 
 stack_layout__get_cmodules(CModules, LayoutInfo, LayoutInfo) :-
- -	LayoutInfo = stack_layout_info(_, _, _, _, _, CModules, _).
+	LayoutInfo = stack_layout_info(_, _, _, _, _, _, CModules, _).
 
 :- pred stack_layout__get_label_set(set_bbbtree(label)::out,
 	stack_layout_info::in, stack_layout_info::out) is det.
 
 stack_layout__get_label_set(StackLayoutLabels, LayoutInfo, LayoutInfo) :-
- -	LayoutInfo = stack_layout_info(_, _, _, _, _, _, StackLayoutLabels).
+	LayoutInfo = stack_layout_info(_, _, _, _, _, _, _, StackLayoutLabels).
 
 :- pred stack_layout__add_cmodule(c_module::in, label::in,
 	stack_layout_info::in, stack_layout_info::out) is det.
 
 stack_layout__add_cmodule(CModule, Label, LayoutInfo0, LayoutInfo) :-
- -	LayoutInfo0 = stack_layout_info(A, B, C, D, E, CModules0,
- -		StackLayoutLabels0),
+	LayoutInfo0 = stack_layout_info(A, B, C, D, E, F,
+		CModules0, StackLayoutLabels0),
 	CModules = [CModule | CModules0],
 	set_bbbtree__insert(StackLayoutLabels0, Label, StackLayoutLabels),
- -	LayoutInfo = stack_layout_info(A, B, C, D, E, CModules,
- -		StackLayoutLabels).
+	LayoutInfo = stack_layout_info(A, B, C, D, E, F,
+		CModules, StackLayoutLabels).
 
 :- pred stack_layout__set_cell_number(int::in,
 	stack_layout_info::in, stack_layout_info::out) is det.
 
 stack_layout__set_cell_number(CNum, LayoutInfo0, LayoutInfo) :-
- -	LayoutInfo0 = stack_layout_info(A, _, C, D, E, F, G),
- -	LayoutInfo = stack_layout_info(A, CNum, C, D, E, F, G).
+	LayoutInfo0 = stack_layout_info(A, _, C, D, E, F, G, H),
+	LayoutInfo = stack_layout_info(A, CNum, C, D, E, F, G, H).
cvs diff: Diffing compiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/exceptions
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/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/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/benchmarking.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/benchmarking.m,v
retrieving revision 1.19
diff -u -u -r1.19 benchmarking.m
- --- benchmarking.m	1998/11/05 16:35:22	1.19
+++ benchmarking.m	1998/11/09 05:40:06
@@ -585,6 +585,7 @@
 Declare_entry(do_call_det_closure);
 
 BEGIN_MODULE(benchmark_nondet_module)
+	MR_INIT_PROC_LAYOUT_ADDR(mercury__benchmarking__benchmark_nondet_5_0);
 	init_entry_sl(mercury__benchmarking__benchmark_nondet_5_0);
 	init_label_sl(mercury__benchmarking__benchmark_nondet_5_0_i1);
 	init_label_sl(mercury__benchmarking__benchmark_nondet_5_0_i2);
@@ -694,6 +695,7 @@
 MR_MAKE_INTERNAL_LAYOUT(mercury__benchmarking__benchmark_det_5_0, 1);
 
 BEGIN_MODULE(benchmark_det_module)
+	MR_INIT_PROC_LAYOUT_ADDR(mercury__benchmarking__benchmark_det_5_0);
 	init_entry_sl(mercury__benchmarking__benchmark_det_5_0);
 	init_label_sl(mercury__benchmarking__benchmark_det_5_0_i1);
 BEGIN_CODE
Index: library/private_builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/private_builtin.m,v
retrieving revision 1.13
diff -u -u -r1.13 private_builtin.m
- --- private_builtin.m	1998/11/05 16:35:24	1.13
+++ private_builtin.m	1998/11/09 05:40:13
@@ -857,6 +857,7 @@
 	MR_DETISM_NON, 0, MR_LVAL_TYPE_UNKNOWN,
 	MR_PREDICATE, ""private_builtin"", ""table_suspend"", 2, 0);
 BEGIN_MODULE(table_suspend_module)
+	MR_INIT_PROC_LAYOUT_ADDR(mercury__table_suspend_2_0);
 	init_entry_sl(mercury__table_suspend_2_0);
 BEGIN_CODE
 
@@ -1044,6 +1045,7 @@
 	mercury__table_resume_1_0_RedoPoint, mercury__table_resume_1_0);
 
 BEGIN_MODULE(table_resume_module)
+	MR_INIT_PROC_LAYOUT_ADDR(mercury__table_resume_1_0);
 	init_entry_sl(mercury__table_resume_1_0);
 	init_label_sl(mercury__table_resume_1_0_ChangeLoop);
 	init_label_sl(mercury__table_resume_1_0_ChangeLoopDone);
Index: library/std_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/std_util.m,v
retrieving revision 1.133
diff -u -u -r1.133 std_util.m
- --- std_util.m	1998/11/05 16:35:26	1.133
+++ std_util.m	1998/11/09 05:40:24
@@ -499,6 +499,7 @@
 MR_MAKE_INTERNAL_LAYOUT(mercury__std_util__builtin_aggregate_4_0, 3);
 
 BEGIN_MODULE(builtin_aggregate_module)
+	MR_INIT_PROC_LAYOUT_ADDR(mercury__std_util__builtin_aggregate_4_0);
 	init_entry_sl(mercury__std_util__builtin_aggregate_4_0);
 	init_entry(mercury__std_util__builtin_aggregate_4_1);
 	init_entry(mercury__std_util__builtin_aggregate_4_2);
@@ -1112,6 +1113,7 @@
 #ifdef	COMPACT_ARGS
 	init_entry(mercury____Compare___std_util__univ_0_0);
 #else
+	MR_INIT_PROC_LAYOUT_ADDR.(mercury____Compare___std_util__univ_0_0);
 	init_entry_sl(mercury____Compare___std_util__univ_0_0);
 	init_label_sl(mercury____Compare___std_util__univ_0_0_i1);
 #endif
cvs diff: Diffing lp_solve
cvs diff: Diffing lp_solve/lp_examples
cvs diff: Diffing profiler
cvs diff: Diffing runtime
Index: runtime/mercury_goto.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_goto.h,v
retrieving revision 1.17
diff -u -u -r1.17 mercury_goto.h
- --- mercury_goto.h	1998/11/07 13:12:02	1.17
+++ mercury_goto.h	1998/11/09 07:54:30
@@ -41,9 +41,9 @@
 #define make_label_sl(n, a, l)		MR_insert_internal_label(n, a, \
 						MR_INTERNAL_LAYOUT(l))
 
- -#define make_local_ai(n, a, l)		MR_insert_internal_label(n, a, NULL)
- -#define make_local_sl(n, a, l)		MR_insert_internal_label(n, a, \
- -						MR_INTERNAL_LAYOUT(l))
+#define make_local_ai(n, a, l)		MR_insert_entry_label(n, a, NULL)
+#define make_local_sl(n, a, l)		MR_insert_entry_label(n, a, \
+						MR_ENTRY_LAYOUT(l))
 
 #define make_entry_ai(n, a, l)		MR_insert_entry_label(n, a, NULL)
 #define make_entry_sl(n, a, l)		MR_insert_entry_label(n, a, \
Index: runtime/mercury_stack_layout.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stack_layout.h,v
retrieving revision 1.12
diff -u -u -r1.12 mercury_stack_layout.h
- --- mercury_stack_layout.h	1998/11/05 03:53:42	1.12
+++ mercury_stack_layout.h	1998/11/10 01:01:20
@@ -332,14 +332,34 @@
 ** For the procedure identification, we always use the same module name
 ** for the defining and declaring modules, since procedures whose code
 ** is hand-written as C modules cannot be inlined in other Mercury modules.
+**
+** Due to the possibility that code addresses are not static, any use of
+** the MR_MAKE_PROC_LAYOUT macro has to be accompanied by a call to the
+** MR_INIT_PROC_LAYOUT_ADDR macro in the initialization code of the C module
+** that defines the entry. (The cast in the body of MR_INIT_PROC_LAYOUT_ADDR
+** is needed because compiler-generated layout structures have their own
+** compiler-generated type.)
 */ 
 
 #define	MR_ENTRY_NO_SLOT_COUNT		-1
 
+#ifdef	MR_STATIC_CODE_ADDRESSES
+ #define	MR_MAKE_PROC_LAYOUT_ADDR(entry)		STATIC(entry)
+ #define	MR_INIT_PROC_LAYOUT_ADDR(entry)		do { } while (0)
+#else
+ #define	MR_MAKE_PROC_LAYOUT_ADDR(entry)		((Code *) NULL)
+ #define	MR_INIT_PROC_LAYOUT_ADDR(entry)				\
+		do {							\
+			((MR_Stack_Layout_Entry *) &			\
+			mercury_data__layout__##entry)			\
+				->MR_sle_code_addr = ENTRY(entry);	\
+		} while (0)
+#endif
+
 #define MR_MAKE_PROC_LAYOUT(entry, detism, slots, succip_locn,		\
 		pf, module, name, arity, mode) 				\
 	MR_Stack_Layout_Entry mercury_data__layout__##entry = {		\
- -		STATIC(entry),						\
+		MR_MAKE_PROC_LAYOUT_ADDR(entry),			\
 		detism,							\
 		slots,							\
 		succip_locn,						\
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 scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/general
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/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
cvs diff: Diffing trial
cvs diff: Diffing util



More information about the developers mailing list