[m-rev.] diff: disable intermod optimizatin of C# and MC++

Peter Ross pro at missioncriticalit.com
Wed Dec 3 07:52:51 AEDT 2003


Hi,

I thought this change would fix a compilation error on the il backend,
where we are generating code to access mer_std__csharp_code assembly,
but not including it in the list of referenced assemblies.  It doesn't
but I think it may fix similar problems in the future, so I am
committing anyway.

I am guessing the compilation error is also something to do with stayls
recent changes, I am looking into it further.

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


Estimated hours taken: 2
Branches: main

Don't place predicates whose definition is a foreign_proc into the
.opt file, if the foreign_proc can't be embedded directly in the
generated code as the gain is minimal for the extra complexity
in the generated code.

compiler/intermod.m:
	For the il backend, don't export MC++ or C# foreign_procs.

Index: compiler/intermod.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/intermod.m,v
retrieving revision 1.152
diff -u -r1.152 intermod.m
--- compiler/intermod.m	1 Dec 2003 15:55:39 -0000	1.152
+++ compiler/intermod.m	2 Dec 2003 20:43:49 -0000
@@ -373,6 +373,11 @@
 		% These will be recreated in the importing module.
 		\+ set__member(PredId, TypeSpecForcePreds),
 
+		% No point exporting code which isn't very inlinable.
+		module_info_globals(ModuleInfo, Globals),
+		globals__get_target(Globals, Target),
+		\+ clauses_contain_noninlinable_foreign_code(Target, Clauses),
+
 		(
 			inlining__is_simple_clause_list(Clauses,
 				InlineThreshold + Arity),
@@ -403,6 +408,22 @@
 		% included in the .opt file.
 		pred_info_get_goal_type(PredInfo, promise(_))
 	).
+
+	% If the clauses contains foreign code which requires an external
+	% definition, there is not much point in exporting it.
+:- pred clauses_contain_noninlinable_foreign_code(compilation_target::in,
+		list(clause)::in) is semidet.
+
+clauses_contain_noninlinable_foreign_code(Target, [C | _Cs]) :-
+	Target = il,
+	Lang = C ^ clause_lang,
+	Lang = foreign_language(ForeignLang),
+	( ForeignLang = csharp
+	; ForeignLang = managed_cplusplus
+	).
+clauses_contain_noninlinable_foreign_code(Target, [_ | Cs]) :-
+	clauses_contain_noninlinable_foreign_code(Target, Cs).
+
 
 :- pred intermod__traverse_clauses(list(clause)::in, list(clause)::out,
 		bool::out, intermod_info::in, intermod_info::out) is det.


-- 
Peter Ross		
Software Engineer                                (Work)   +32 2 757 10 15
Mission Critical                                 (Mobile) +32 485 482 559
--------------------------------------------------------------------------
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