[m-dev.] for review: options to switch off RTTI features.

Tyson Dowd trd at cs.mu.OZ.AU
Tue May 25 15:04:13 AEST 1999


Hi,

Zoltan, this one is for you.

These changes add options for controlling RTTI features which we
measured in the RTTI paper.

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


Estimated hours taken: 5

Add options to turn off various RTTI features.  Also switch off the
generation of variable names for accurate GC (this should be the default
unless we are tracing).

These new options are for space measurement only.  There is little
chance the code will link or work if the options are used.

compiler/base_type_layout.m:
	Let --type-ctor-layout and --type-ctor-functors control the
	generation of layout and functors.

compiler/mercury_compile.m:
	Let --type-ctor-info control the generation of type_ctor_info
	structures.

compiler/stack_layout.m:
	Turn off the generation of variable names structures unless
	tracing.

compiler/unify_proc.m:
	Use --special-preds to control the generation of unify and
	compare predicates.

compiler/options.m:
	Add the new options (as internal use only options).


Index: compiler/base_type_layout.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/base_type_layout.m,v
retrieving revision 1.43
diff -u -r1.43 base_type_layout.m
--- base_type_layout.m	1999/04/30 06:19:07	1.43
+++ base_type_layout.m	1999/05/25 02:16:28
@@ -328,7 +328,7 @@
 	module_info_get_cell_count(ModuleInfo0, CellCount),
 	LayoutInfo0 = layout_info(ModuleName, ConsTable, MaxTags, CellCount, 
 		unqualified("") - 0, []),
-	base_type_layout__construct_base_type_data(BaseGenInfos, 
+	base_type_layout__construct_base_type_data(BaseGenInfos, Globals,
 		LayoutInfo0, LayoutInfo),
 	LayoutInfo = layout_info(_, _, _, FinalCellCount, _, CModules),
 	module_info_set_cell_count(ModuleInfo0, FinalCellCount, ModuleInfo).
@@ -342,12 +342,12 @@
 	% functors, one for layout.
 	
 :- pred base_type_layout__construct_base_type_data(list(base_gen_layout),
-	layout_info, layout_info).
-:- mode base_type_layout__construct_base_type_data(in, in, out) is det.
+	globals, layout_info, layout_info).
+:- mode base_type_layout__construct_base_type_data(in, in, in, out) is det.
 
-base_type_layout__construct_base_type_data([], LayoutInfo, LayoutInfo).
+base_type_layout__construct_base_type_data([], _, LayoutInfo, LayoutInfo).
 base_type_layout__construct_base_type_data([BaseGenInfo | BaseGenInfos],
-		LayoutInfo0, LayoutInfo) :-
+		Globals, LayoutInfo0, LayoutInfo) :-
 	BaseGenInfo = base_gen_layout(TypeId, ModuleName, TypeName, TypeArity,
 		_Status, HldsType),
 	base_type_layout__set_type_id(LayoutInfo0, TypeId, LayoutInfo1),
@@ -427,14 +427,26 @@
 		FunctorsDataName = type_ctor(functors, TypeName, TypeArity),
 		FunctorsCData = comp_gen_c_data(ModuleName, FunctorsDataName,
 			Exported, FunctorsTypeData, uniform(no), []),
-		base_type_layout__add_c_data(LayoutInfo3, LayoutCData, 
-			LayoutInfo4),
-		base_type_layout__add_c_data(LayoutInfo4, FunctorsCData, 
-			LayoutInfo5)
-	),
-	base_type_layout__construct_base_type_data(BaseGenInfos, LayoutInfo5,
-		LayoutInfo).
 
+		globals__lookup_bool_option(Globals, type_ctor_layout,
+			LayoutOption),
+		globals__lookup_bool_option(Globals, type_ctor_functors,
+			FunctorsOption),
+		( LayoutOption = yes ->
+			base_type_layout__add_c_data(LayoutInfo3,
+				LayoutCData, LayoutInfo4)
+		;	
+			LayoutInfo4 = LayoutInfo3
+		),
+		( FunctorsOption = yes ->
+			base_type_layout__add_c_data(LayoutInfo4,
+				FunctorsCData, LayoutInfo5)
+		;
+			LayoutInfo5 = LayoutInfo4
+		)
+	),
+	base_type_layout__construct_base_type_data(BaseGenInfos, Globals, 
+		LayoutInfo5, LayoutInfo).
 
 %---------------------------------------------------------------------------%
 
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.125
diff -u -r1.125 mercury_compile.m
--- mercury_compile.m	1999/04/30 08:23:51	1.125
+++ mercury_compile.m	1999/05/24 12:42:51
@@ -1560,12 +1560,19 @@
 :- mode mercury_compile__maybe_type_ctor_infos(in, in, in, out, di, uo) is det.
 
 mercury_compile__maybe_type_ctor_infos(HLDS0, Verbose, Stats, HLDS) -->
-	maybe_write_string(Verbose,
-		"% Generating type_ctor_info structures..."),
-	maybe_flush_output(Verbose),
-	{ base_type_info__generate_hlds(HLDS0, HLDS) },
-	maybe_write_string(Verbose, " done.\n"),
-	maybe_report_stats(Stats).
+	globals__io_lookup_bool_option(type_ctor_info, TypeCtorInfoOption),
+	( 
+		{ TypeCtorInfoOption = yes } 
+	->
+		maybe_write_string(Verbose,
+			"% Generating type_ctor_info structures..."),
+		maybe_flush_output(Verbose),
+		{ base_type_info__generate_hlds(HLDS0, HLDS) },
+		maybe_write_string(Verbose, " done.\n"),
+		maybe_report_stats(Stats)
+	;
+		{ HLDS0 = HLDS }
+	).
 
 	% We only add type_ctor_layouts if shared-one-or-two-cell
 	% type_infos are being used (the layouts refer to the
Index: compiler/options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.263
diff -u -r1.263 options.m
--- options.m	1999/04/30 08:23:52	1.263
+++ options.m	1999/05/25 02:11:04
@@ -181,6 +181,23 @@
 				% where typeinfos are live for any live data
 				% the includes that type variable.
 		;	typeinfo_liveness
+				% Generate unify and compare preds.  For
+				% measurement only. code generated with
+				% this set to `no' is unlikely to
+				% actually work.
+		;	special_preds
+				% Generate type_ctor_info structures.
+				% For measurement only -- turn this off
+				% and you're unlikey to be able to link.
+		;	type_ctor_info
+				% Generate type_ctor_layout structures.
+				% For measurement only -- turn this off
+				% and you're unlikey to be able to link.
+		;	type_ctor_layout
+				% Generate type_ctor_functors structures.
+				% For measurement only -- turn this off
+				% and you're unlikey to be able to link.
+		;	type_ctor_functors
 	% Code generation options
 		;	low_level_debug
 		;	trad_passes
@@ -484,6 +501,10 @@
 	procid_stack_layout	-	bool(no),
 	trace_stack_layout	-	bool(no),
 	typeinfo_liveness	-	bool(no),
+	special_preds		-	bool(yes),
+	type_ctor_info		-	bool(yes),
+	type_ctor_layout	-	bool(yes),
+	type_ctor_functors	-	bool(yes),
 	highlevel_c		-	bool(no),
 	unboxed_float		-	bool(no)
 ]).
@@ -828,6 +849,10 @@
 long_option("procid-stack-layout",	procid_stack_layout).
 long_option("trace-stack-layout",	trace_stack_layout).
 long_option("typeinfo-liveness",	typeinfo_liveness).
+long_option("special-preds",		special_preds).
+long_option("type-ctor-info",		type_ctor_info).
+long_option("type-ctor-layout",		type_ctor_layout).
+long_option("type-ctor-functors",	type_ctor_functors).
 long_option("highlevel-C",		highlevel_c).
 long_option("highlevel-c",		highlevel_c).
 long_option("high-level-C",		highlevel_c).
Index: compiler/stack_layout.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/stack_layout.m,v
retrieving revision 1.29
diff -u -r1.29 stack_layout.m
--- stack_layout.m	1999/05/07 08:08:56	1.29
+++ stack_layout.m	1999/05/25 02:33:54
@@ -768,10 +768,16 @@
 		initial(ArgTypes, none), must_be_static, CNum1,
 		"stack_layout_locn_vector") },
 
-	{ list__map(SelectNames, AllArrayInfo, AllNames) },
-	stack_layout__get_next_cell_number(CNum2),
-	{ NameVector = create(0, AllNames, uniform(yes(string)),
-		must_be_static, CNum2, "stack_layout_name_vector") }.
+	stack_layout__get_agc_stack_layout(AgcStackLayout),
+	( { AgcStackLayout = no } ->
+		{ list__map(SelectNames, AllArrayInfo, AllNames) },
+		stack_layout__get_next_cell_number(CNum2),
+		{ NameVector = create(0, AllNames, uniform(yes(string)),
+			must_be_static, CNum2, "stack_layout_name_vector") }
+	;
+		{ NameVector = const(int_const(0)) }
+	).
+
 
 :- pred stack_layout__construct_liveval_array_infos(list(var_info)::in,
 	int::in, int::in,
Index: compiler/unify_proc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/unify_proc.m,v
retrieving revision 1.73
diff -u -r1.73 unify_proc.m
--- unify_proc.m	1999/05/18 03:09:04	1.73
+++ unify_proc.m	1999/05/24 11:35:57
@@ -450,28 +450,36 @@
 
 unify_proc__generate_clause_info(SpecialPredId, Type, TypeBody, Context,
 		ModuleInfo, ClauseInfo) :-
-	unify_proc__info_init(ModuleInfo, VarTypeInfo0),
+	module_info_globals(ModuleInfo, Globals),
+	globals__lookup_bool_option(Globals, special_preds, SpecialPredsOpt),
 	( TypeBody = eqv_type(EqvType) ->
 		HeadVarType = EqvType
 	;
 		HeadVarType = Type
 	),
 	special_pred_info(SpecialPredId, HeadVarType,
-			_PredName, ArgTypes, _Modes, _Det),
+		_PredName, ArgTypes, _Modes, _Det),
+	unify_proc__info_init(ModuleInfo, VarTypeInfo0),
 	unify_proc__make_fresh_vars_from_types(ArgTypes, Args,
-					VarTypeInfo0, VarTypeInfo1),
-	( SpecialPredId = unify, Args = [H1, H2] ->
-		unify_proc__generate_unify_clauses(TypeBody, H1, H2, Context,
-					Clauses, VarTypeInfo1, VarTypeInfo)
-	; SpecialPredId = index, Args = [X, Index] ->
-		unify_proc__generate_index_clauses(TypeBody, X, Index, Context,
-					Clauses, VarTypeInfo1, VarTypeInfo)
-	; SpecialPredId = compare, Args = [Res, X, Y] ->
-		unify_proc__generate_compare_clauses(TypeBody, Res, X, Y,
-					Context,
-					Clauses, VarTypeInfo1, VarTypeInfo)
+				VarTypeInfo0, VarTypeInfo1),
+	( SpecialPredsOpt = yes ->
+		( SpecialPredId = unify, Args = [H1, H2] ->
+			unify_proc__generate_unify_clauses(TypeBody, H1, H2,
+				Context, Clauses, VarTypeInfo1, VarTypeInfo)
+		; SpecialPredId = index, Args = [X, Index] ->
+			unify_proc__generate_index_clauses(TypeBody,
+				X, Index, Context, Clauses, VarTypeInfo1,
+				VarTypeInfo)
+		; SpecialPredId = compare, Args = [Res, X, Y] ->
+			unify_proc__generate_compare_clauses(TypeBody, Res,
+				X, Y, Context, Clauses, VarTypeInfo1,
+				VarTypeInfo)
+		;
+			error("unknown special pred")
+		)
 	;
-		error("unknown special pred")
+		Clauses = [],
+		VarTypeInfo = VarTypeInfo1
 	),
 	unify_proc__info_extract(VarTypeInfo, VarSet, Types),
 	ClauseInfo = clauses_info(VarSet, Types, Types, Args, Clauses).


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