[m-dev.] for review: --shape-includes-inst

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Apr 19 15:20:24 AEST 1999


For review by Tyson.

Estimated hours taken: 1

Reduce the size of executables compiled with tracing by not including
space for instantiation information in label layout structures by default,
but only when asked for. Previously, we allocated the space in all cases,
even though there is no code yet for filling it in with real info.

This saves 0.1% for the compiler on hydra. That's not much, but it's something.

compiler/options.m:
	Add a new option, --shape-includes-inst, that causes the compiler
	to reserve space for insts in shapes. Only Tyson and whoever else
	works on adding inst info to the RTTI need ever use this option.

compiler/stack_layout.m:
	Only reserve space for insts if this option is set.

compiler/mercury_compile.m:
	If this option is set, pass -DMR_SHAPE_INCLUDES_INST to the C
	compiler.

runtime/mercury_stack_layout.h:
	Only include inst info in MR_Var_Shape_Info structs if
	MR_SHAPE_INCLUDES_INST is defined.

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 compiler
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.123
diff -u -b -u -r1.123 mercury_compile.m
--- mercury_compile.m	1999/04/15 07:35:28	1.123
+++ mercury_compile.m	1999/04/16 02:55:55
@@ -2310,6 +2310,12 @@
 	;
 		StackTraceOpt = ""
 	},
+	globals__io_lookup_bool_option(shape_includes_inst, ShapeInclInst),
+	{ ShapeInclInst = yes ->
+		ShapeInstOpt = "-DMR_SHAPE_INCLUDES_INST "
+	;
+		ShapeInstOpt = ""
+	},
 	globals__io_lookup_bool_option(c_debug, C_Debug),
 	{ C_Debug = yes ->
 		C_DebugOpt = "-g "
@@ -2389,7 +2395,7 @@
 		GC_Opt, ProfileCallsOpt, ProfileTimeOpt, ProfileMemoryOpt,
 		PIC_Reg_Opt, TagsOpt, NumTagBitsOpt,
 		C_DebugOpt, LL_DebugOpt,
-		StackTraceOpt, RequireTracingOpt,
+		StackTraceOpt, ShapeInstOpt, RequireTracingOpt,
 		UseTrailOpt, ArgsOpt, TypeLayoutOpt,
 		InlineAllocOpt, WarningOpt, CFLAGS,
 		" -c ", C_File, " -o ", O_File], Command) },
Index: compiler/options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.257
diff -u -b -u -r1.257 options.m
--- options.m	1999/04/16 04:34:20	1.257
+++ options.m	1999/04/16 06:37:57
@@ -98,6 +98,7 @@
 		;	trace_redo
 		;	trace_optimized
 		;	trace_decl
+		;	shape_includes_inst
 		;	stack_trace_higher_order
 		;	generate_bytecode
 		;	generate_prolog
@@ -162,7 +163,7 @@
 		;	sync_term_size % in words
 		;	type_layout
 		;	max_jump_table_size
-	% Options for internal use only
+	% Options for internal compiler use only
 	% (the values of these options are implied by the
 	% settings of other options)
 				% Stack layout information required to do
@@ -405,6 +406,7 @@
 	trace_redo		-	bool(yes),
 	trace_optimized		-	bool(no),
 	trace_decl		-	bool(no),
+	shape_includes_inst	-	bool(no),
 	stack_trace_higher_order -	bool(no),
 	generate_bytecode	-	bool(no),
 	generate_prolog		-	bool(no),
@@ -758,6 +760,8 @@
 long_option("trace-optimised",		trace_optimized).
 long_option("trace-optimized",		trace_optimized).
 long_option("trace-decl",		trace_decl).
+long_option("shape-includes-inst",	shape_includes_inst).
+long_option("shape-incl-inst",		shape_includes_inst).
 long_option("stack-trace-higher-order",	stack_trace_higher_order).
 long_option("generate-bytecode",	generate_bytecode).
 long_option("generate-prolog",		generate_prolog).
@@ -1484,6 +1488,12 @@
 %		"--trace-decl",
 %		"\tMake the generated tracing code include support for an",
 %		"\texperimental declarative debugger.",
+% --shape-includes-inst is intended only for developers who will work on the
+% addition of inst info to label layouts. Until that work is complete,
+% nobody else has reason to use this option.
+%		"--shape-includes-inst",
+%		"\tInclude instantiation state information in the shape info",
+%		"\generated for variables in label layout structures.",
 		"--stack-trace-higher-order",
 		"\tEnable stack traces through predicates and functions with",
 		"\thigher-order arguments, even if stack tracing is not",
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/16 06:38:00
@@ -115,8 +115,9 @@
 %				a NULL pointer means no type parameters
 %
 % 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 entry will give the location of the variable and its type.
+% (There is also provision in the design for including the instantiation
+% state along with the type, but we don't use this provision yet.)
 %
 % The live data name vector pointer will be NULL. If it is not, the vector
 % will have an entry for each live variable, with each entry giving the name
@@ -191,6 +192,9 @@
 :- import_module hlds_data, hlds_pred, base_type_layout, prog_data, prog_out.
 :- import_module (inst), code_util.
 :- import_module assoc_list, bool, string, int, require.
+<<<<<<< stack_layout.m
+:- import_module map, std_util, term, set.
+=======
 :- import_module map, term, set.
 
 :- type stack_layout_info 	--->
@@ -206,6 +210,7 @@
 		set_bbbtree(label)
 				% the set of labels with layouts
 	).
+>>>>>>> 1.27
 
 %---------------------------------------------------------------------------%
 
@@ -224,16 +229,18 @@
 	globals__lookup_bool_option(Globals, trace_stack_layout, TraceLayout),
 	globals__lookup_bool_option(Globals, procid_stack_layout,
 		ProcInfoLayout),
+	globals__lookup_bool_option(Globals, shape_includes_inst,
+		ShapeInclInst),
 	globals__have_static_code_addresses(Globals, StaticCodeAddr),
 	set_bbbtree__init(LayoutLabels0),
 
 	LayoutInfo0 = stack_layout_info(ModuleName, CellCount, AgcLayout,
-		TraceLayout, ProcInfoLayout, StaticCodeAddr,
+		TraceLayout, ProcInfoLayout, StaticCodeAddr, ShapeInclInst,
 		[], [], LayoutLabels0),
 	list__foldl(stack_layout__construct_layouts, ProcLayoutList,
 		LayoutInfo0, LayoutInfo),
 
-	LayoutInfo  = stack_layout_info(_, FinalCellCount, _,
+	LayoutInfo  = stack_layout_info(_, FinalCellCount, _, _,
 		_, _, _, ProcLayouts, InternalLayouts, LayoutLabels),
 	module_info_set_cell_count(ModuleInfo0, FinalCellCount, ModuleInfo).
 
@@ -789,10 +796,29 @@
 	{ Rval = const(int_const(6)) }.
 stack_layout__represent_live_value_type(var(_, _, Type, Inst), Rval) -->
 	stack_layout__get_cell_number(CNum0),
+<<<<<<< stack_layout.m
+	{ base_type_layout__construct_pseudo_type_info(Type, PseudoRval,
+=======
 	{ stack_layout__represent_var_shape(Type, Inst, VarShape,
+>>>>>>> 1.27
 		CNum0, CNum1) },
 	stack_layout__set_cell_number(CNum1),
+<<<<<<< stack_layout.m
+	stack_layout__get_shape_includes_inst(ShapeInclInst),
+=======
+>>>>>>> 1.27
 	stack_layout__get_next_cell_number(CNum2),
+<<<<<<< stack_layout.m
+	{ ShapeInclInst = yes ->
+			% XXX hack - don't yet write out insts
+		InstRval = const(int_const(-1)),
+		Rval = create(0, [yes(PseudoRval), yes(InstRval)], no, CNum2,
+			"shape_pti_and_inst")
+	;
+		Rval = create(0, [yes(PseudoRval)], no, CNum2,
+			"shape_pti")
+	}.
+=======
 	{ Rval = create(0, VarShape, no, CNum2, "variable_shape") }.
 
 :- pred stack_layout__represent_var_shape((type)::in, (inst)::in,
@@ -804,6 +830,7 @@
 	% XXX hack - don't yet write out insts
 	InstRval = const(int_const(-1)),
 	VarShape = [yes(TypeRval), yes(InstRval)].
+>>>>>>> 1.27
 
 	% Construct a representation of a variable location.
 	%
@@ -978,6 +1005,21 @@
 
 	% 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?
+		bool,		% do shapes include inst info?
+		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.
 
@@ -996,6 +1038,9 @@
 :- pred stack_layout__get_static_code_addresses(bool::out,
 	stack_layout_info::in, stack_layout_info::out) is det.
 
+:- pred stack_layout__get_shape_includes_inst(bool::out,
+	stack_layout_info::in, stack_layout_info::out) is det.
+
 :- pred stack_layout__get_proc_layout_data(list(comp_gen_c_data)::out,
 	stack_layout_info::in, stack_layout_info::out) is det.
 
@@ -1006,61 +1051,69 @@
 	stack_layout_info::in, stack_layout_info::out) is det.
 
 stack_layout__get_module_name(A, LayoutInfo, LayoutInfo) :-
-	LayoutInfo = stack_layout_info(A, _, _, _, _, _, _, _, _).
+	LayoutInfo = stack_layout_info(A, _, _, _, _, _, _, _, _, _).
 
 stack_layout__get_cell_number(B, LayoutInfo, LayoutInfo) :-
-	LayoutInfo = stack_layout_info(_, B, _, _, _, _, _, _, _).
+	LayoutInfo = stack_layout_info(_, B, _, _, _, _, _, _, _, _).
 
 stack_layout__get_agc_stack_layout(C, LayoutInfo, LayoutInfo) :-
-	LayoutInfo = stack_layout_info(_, _, C, _, _, _, _, _, _).
+	LayoutInfo = stack_layout_info(_, _, C, _, _, _, _, _, _, _).
 
 stack_layout__get_trace_stack_layout(D, LayoutInfo, LayoutInfo) :-
-	LayoutInfo = stack_layout_info(_, _, _, D, _, _, _, _, _).
+	LayoutInfo = stack_layout_info(_, _, _, D, _, _, _, _, _, _).
 
 stack_layout__get_procid_stack_layout(E, LayoutInfo, LayoutInfo) :-
-	LayoutInfo = stack_layout_info(_, _, _, _, E, _, _, _, _).
+	LayoutInfo = stack_layout_info(_, _, _, _, E, _, _, _, _, _).
 
 stack_layout__get_static_code_addresses(F, LayoutInfo, LayoutInfo) :-
-	LayoutInfo = stack_layout_info(_, _, _, _, _, F, _, _, _).
+	LayoutInfo = stack_layout_info(_, _, _, _, _, F, _, _, _, _).
+
+stack_layout__get_shape_includes_inst(G, LayoutInfo, LayoutInfo) :-
+	LayoutInfo = stack_layout_info(_, _, _, _, _, _, G, _, _, _).
 
-stack_layout__get_proc_layout_data(G, LayoutInfo, LayoutInfo) :-
-	LayoutInfo = stack_layout_info(_, _, _, _, _, _, G, _, _).
+stack_layout__get_proc_layout_data(H, LayoutInfo, LayoutInfo) :-
+	LayoutInfo = stack_layout_info(_, _, _, _, _, _, _, H, _, _).
 
-stack_layout__get_internal_layout_data(H, LayoutInfo, LayoutInfo) :-
-	LayoutInfo = stack_layout_info(_, _, _, _, _, _, _, H, _).
+stack_layout__get_internal_layout_data(I, LayoutInfo, LayoutInfo) :-
+	LayoutInfo = stack_layout_info(_, _, _, _, _, _, _, _, I, _).
 
-stack_layout__get_label_set(I, LayoutInfo, LayoutInfo) :-
-	LayoutInfo = stack_layout_info(_, _, _, _, _, _, _, _, I).
+stack_layout__get_label_set(J, LayoutInfo, LayoutInfo) :-
+	LayoutInfo = stack_layout_info(_, _, _, _, _, _, _, _, _, J).
 
 :- pred stack_layout__add_proc_layout_data(comp_gen_c_data::in, label::in,
 	stack_layout_info::in, stack_layout_info::out) is det.
 
-stack_layout__add_proc_layout_data(NewG, NewI, LayoutInfo0, LayoutInfo) :-
-	LayoutInfo0 = stack_layout_info(A, B, C, D, E, F, G0, H, I0),
-	G = [NewG | G0],
-	set_bbbtree__insert(I0, NewI, I),
-	LayoutInfo  = stack_layout_info(A, B, C, D, E, F, G , H, I).
+stack_layout__add_proc_layout_data(NewH, NewJ, LayoutInfo0, LayoutInfo) :-
+	LayoutInfo0 = stack_layout_info(A, B, C, D, E, F, G, H0, I, J0),
+	H = [NewH | H0],
+	set_bbbtree__insert(J0, NewJ, J),
+	LayoutInfo  = stack_layout_info(A, B, C, D, E, F, G, H , I, J).
 
 :- pred stack_layout__add_internal_layout_data(comp_gen_c_data::in, label::in,
 	stack_layout_info::in, stack_layout_info::out) is det.
 
-stack_layout__add_internal_layout_data(NewH, NewI, LayoutInfo0, LayoutInfo) :-
-	LayoutInfo0 = stack_layout_info(A, B, C, D, E, F, G, H0, I0),
-	H = [NewH | H0],
-	set_bbbtree__insert(I0, NewI, I),
-	LayoutInfo  = stack_layout_info(A, B, C, D, E, F, G, H , I ).
+stack_layout__add_internal_layout_data(NewI, NewJ, LayoutInfo0, LayoutInfo) :-
+	LayoutInfo0 = stack_layout_info(A, B, C, D, E, F, G, H, I0, J0),
+	I = [NewI | I0],
+	set_bbbtree__insert(J0, NewJ, J),
+	LayoutInfo  = stack_layout_info(A, B, C, D, E, F, G, H, I , J).
 
 :- pred stack_layout__get_next_cell_number(int::out,
 	stack_layout_info::in, stack_layout_info::out) is det.
 
+<<<<<<< stack_layout.m
+stack_layout__get_next_cell_number(B0, LayoutInfo0, LayoutInfo) :-
+	LayoutInfo0 = stack_layout_info(A, B0, C, D, E, F, G, H, I, J),
+=======
 stack_layout__get_next_cell_number(B, LayoutInfo0, LayoutInfo) :-
 	LayoutInfo0 = stack_layout_info(A, B0, C, D, E, F, G, H, I),
+>>>>>>> 1.27
 	B is B0 + 1,
-	LayoutInfo  = stack_layout_info(A, B,  C, D, E, F, G, H, I).
+	LayoutInfo  = stack_layout_info(A, B,  C, D, E, F, G, H, I, J).
 
 :- pred stack_layout__set_cell_number(int::in,
 	stack_layout_info::in, stack_layout_info::out) is det.
 
 stack_layout__set_cell_number(B, LayoutInfo0, LayoutInfo) :-
-	LayoutInfo0 = stack_layout_info(A, _, C, D, E, F, G, H, I),
-	LayoutInfo  = stack_layout_info(A, B, C, D, E, F, G, H, I).
+	LayoutInfo0 = stack_layout_info(A, _, C, D, E, F, G, H, I, J),
+	LayoutInfo  = stack_layout_info(A, B, C, D, E, F, G, H, I, J).
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
cvs diff: Diffing lp_solve
cvs diff: Diffing profiler
cvs diff: Diffing runtime
Index: runtime/mercury_stack_layout.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stack_layout.h,v
retrieving revision 1.20
diff -u -b -u -r1.20 mercury_stack_layout.h
--- mercury_stack_layout.h	1999/04/16 06:05:36	1.20
+++ mercury_stack_layout.h	1999/04/16 06:38:31
@@ -156,9 +156,11 @@
 ** 	  mercury data values (vars).
 **
 ** The data is encoded such that low values (less than
-** TYPE_CTOR_LAYOUT_MAX_VARINT) represent succip, hp, etc.  Higher values
-** represent data variables, and are pointers to a 2 word cell,
-** containing a pseudo type_info and an instantiation represention.
+** TYPE_CTOR_LAYOUT_MAX_VARINT) represent succip, hp, etc.
+** Higher values represent data variables. They are pointers to a memory cell,
+** which contains either a pseudo typeinfo, or a pseudo type_info and an
+** instantiation represention, depending on whether MR_SHAPE_INCLUDES_INST
+** is defined.
 **
 ** This data is generated in compiler/stack_layout.m, which must be kept
 ** in sync with the constants defined here.
@@ -177,7 +179,9 @@
 
 typedef struct {
 	Word	*pseudo_type_info;
+#ifdef	MR_SHAPE_INCLUDES_INST
 	Word	inst;	/* not yet used; currently always -1 */
+#endif
 } MR_Var_Shape_Info;
 
 #define MR_LIVE_TYPE_IS_VAR(T)         ((Word) T > TYPE_CTOR_LAYOUT_MAX_VARINT)
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
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