[m-rev.] for review: --support-ms-clr

Peter Ross peter.ross at miscrit.be
Tue Mar 12 01:17:02 AEDT 2002


Hi,


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


Estimated hours taken: 1
Branches: main

Add the --support-ms-clr option.  This helps to make clear which parts
of the IL code generator are there to work around the MS CLR bugs and
which are there to generate correct IL.

compiler/options.m:
	Add the --support-ms-clr option.

doc/user_guide.texi:
	Document the --support-ms-clr option.

compiler/mlds_to_il.m:
	Use the new option to work around a bug in the MS CLR
	implementation where for non-verifiable code the tail call
	return type must be compatible with the caller return type.

Index: compiler/mlds_to_il.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_il.m,v
retrieving revision 1.108
diff -u -r1.108 mlds_to_il.m
--- compiler/mlds_to_il.m	7 Mar 2002 08:30:05 -0000	1.108
+++ compiler/mlds_to_il.m	11 Mar 2002 14:09:46 -0000
@@ -164,6 +164,7 @@
 	debug_il_asm	:: bool,		% --debug-il-asm
 	verifiable_code	:: bool,		% --verifiable-code
 	il_byref_tailcalls :: bool,		% --il-byref-tailcalls
+	support_ms_clr	:: bool,		% --support-ms-clr
 		% class-wide attributes (all accumulate)
 	alloc_instrs	:: instr_tree,		% .cctor allocation instructions
 	init_instrs	:: instr_tree,		% .cctor init instructions
@@ -250,10 +251,13 @@
 	globals__io_lookup_bool_option(sign_assembly, SignAssembly,
 			IO4, IO5),
 	globals__io_lookup_bool_option(separate_assemblies, SeparateAssemblies,
-			IO5, IO),
+			IO5, IO6),
+	globals__io_lookup_bool_option(support_ms_clr, MsCLR,
+			IO6, IO),
 
 	IlInfo0 = il_info_init(ModuleName, AssemblyName, Imports,
-			ILDataRep, DebugIlAsm, VerifiableCode, ByRefTailCalls),
+			ILDataRep, DebugIlAsm, VerifiableCode, ByRefTailCalls,
+			MsCLR),
 
 		% Generate code for all the methods.
 	list__map_foldl(mlds_defn_to_ilasm_decl, Defns, ILDecls,
@@ -1558,6 +1562,7 @@
 		Context), Instrs) -->
 	VerifiableCode =^ verifiable_code,
 	ByRefTailCalls =^ il_byref_tailcalls,
+	MsCLR =^ support_ms_clr,
 	DataRep =^ il_data_rep,
 	{ TypeParams = mlds_signature_to_ilds_type_params(DataRep, Sig) },
 	{ ReturnParam = mlds_signature_to_il_return_param(DataRep, Sig) },
@@ -1580,10 +1585,20 @@
 			),
 			{ ByRefTailCalls = no }
 		),
-		% We must not output the "tail." prefix unless the
-		% callee return type is compatible with the caller
-		% return type
-		{ ReturnParam = CallerReturnParam }
+		% if --verifiable-code is enabled, then we must not output
+		% the "tail." prefix unless the callee return type is
+		% compatible with the caller return type
+		\+ (
+			{ VerifiableCode = yes },
+			{ ReturnParam \= CallerReturnParam }
+		),
+		% Work around a bug in the MS CLR implementation where the
+		% return type of a tail call must be compatible with the
+		% caller return type.
+		\+ (
+			{ MsCLR = yes },
+			{ ReturnParam \= CallerReturnParam }
+		)
 	->
 		{ TailCallInstrs = [tailcall] },
 		% For calls marked with "tail.", we need a `ret'
@@ -4138,12 +4153,12 @@
 %
 
 :- func il_info_init(mlds_module_name, ilds__id, mlds__imports,
-		il_data_rep, bool, bool, bool) = il_info.
+		il_data_rep, bool, bool, bool, bool) = il_info.
 
 il_info_init(ModuleName, AssemblyName, Imports, ILDataRep,
-		DebugIlAsm, VerifiableCode, ByRefTailCalls) =
+		DebugIlAsm, VerifiableCode, ByRefTailCalls, MsCLR) =
 	il_info(ModuleName, AssemblyName, Imports, set__init, ILDataRep,
-		DebugIlAsm, VerifiableCode, ByRefTailCalls,
+		DebugIlAsm, VerifiableCode, ByRefTailCalls, MsCLR,
 		empty, empty, [], no, set__init, set__init,
 		map__init, empty, counter__init(1), counter__init(1), no,
 		Args, MethodName, DefaultSignature) :-
Index: compiler/options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.360
diff -u -r1.360 options.m
--- compiler/options.m	8 Mar 2002 04:03:26 -0000	1.360
+++ compiler/options.m	11 Mar 2002 14:09:48 -0000
@@ -475,6 +475,7 @@
 			
 			% IL
 		;	dotnet_library_version
+		;	support_ms_clr
 
 	% Link options
 		;	output_file_name
@@ -948,7 +949,8 @@
 % IL
 		% We default to the version of the library that came
 		% with Beta2.
-	dotnet_library_version	-	string("1.0.3300.0")
+	dotnet_library_version	-	string("1.0.3300.0"),
+	support_ms_clr		-	bool(yes)
 ]).
 option_defaults_2(link_option, [
 		% Link Options
@@ -1478,6 +1480,7 @@
 long_option("java-object-file-extension", java_object_file_extension).
 
 long_option("dotnet-library-version",	dotnet_library_version).
+long_option("support-ms-clr",		support_ms_clr).
 
 % link options
 long_option("output-file",		output_file_name).
@@ -3093,7 +3096,10 @@
 
 		"--dotnet-library-version <version-number>",
 		"\tThe version number for the mscorlib assembly distributed",
-		"\twith the Microsoft .NET SDK."
+		"\twith the Microsoft .NET SDK.",
+
+		"--no-support-ms-clr",
+		"\tDon't use MS CLR specific workarounds in the generated code."
 	]).
 
 :- pred options_help_link(io__state::di, io__state::uo) is det.
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.299
diff -u -r1.299 user_guide.texi
--- doc/user_guide.texi	8 Mar 2002 04:03:41 -0000	1.299
+++ doc/user_guide.texi	11 Mar 2002 14:09:51 -0000
@@ -5638,6 +5638,11 @@
 The version number for the mscorlib assembly distributed with the
 Microsoft .NET SDK.
 
+ at sp 1
+ at item --no-support-ms-clr
+ at findex --no-support-ms-clr
+Don't use MS CLR specific workarounds in the generated code.
+
 @end table
 
 @node Link options

--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list