[m-rev.] diff: fix profiling and high-level C grades

Julien Fischer juliensf at cs.mu.OZ.AU
Fri May 5 17:41:29 AEST 2006


Estimated hours taken: 1
Branches: main, release

Fix a bug with profiling and the high-level C grades.  The problem was that we
were only emitting an INIT comment whenever there was a user initialisation or
finalisation predicate.  This is not noticeable in most of the hl* grades
since mercury__<modulename>__init is empty anyway.  However in the profiling
grades the init function is responsible for calling MR_init_entry for each
procedure.  Failing to do this causes unknown functions to show up in the
profile.  (This problem appears to have been introduced with r1.101 of
util/mkinit.c - prior to that, in the 0.12 release for example, init functions
in the hl* grades were handled differently.)

compiler/mlds_to_c.m:
	Always output the INIT comment for a module.

Julien.

Index: compiler/mlds_to_c.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_c.m,v
retrieving revision 1.187
diff -u -r1.187 mlds_to_c.m
--- compiler/mlds_to_c.m	20 Apr 2006 05:36:56 -0000	1.187
+++ compiler/mlds_to_c.m	5 May 2006 07:19:36 -0000
@@ -5,10 +5,12 @@
 % This file may only be copied under the terms of the GNU General
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
-
-% mlds_to_c - Convert MLDS to C/C++ code.
+%
+% File: mlds_to_c.m.
 % Main author: fjh.
-
+%
+% Convert MLDS to C/C++ code.
+%
 % TODO:
 %   - RTTI for debugging (module_layout, proc_layout, internal_layout)
 %   - trail ops
@@ -19,7 +21,8 @@
 %     is to change some calls to sorry/2 to unexpected/2).
 %   - packages, classes and inheritance
 %     (currently we just generate all classes as structs)
-
+%
+%-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%

 :- module ml_backend.mlds_to_c.
@@ -386,6 +389,13 @@
 mlds_output_init_and_final_comments(ModuleName,
         UserInitPredCNames, UserFinalPredCNames, !IO) :-
     io.write_string("/*\n", !IO),
+    % In profiling grades the module mercury__<modulename>__init predicate
+    % is responsible for calling MR_init_entry, so the INIT comment must be
+    % present.
+    % XXX we could probably omit it in non-profiling grades.
+    io.write_string("INIT ", !IO),
+    output_init_name(ModuleName, !IO),
+    io.write_string("init\n", !IO),
     (
         UserInitPredCNames = [],
         UserFinalPredCNames = []
@@ -394,9 +404,6 @@
         % any module init or final preds.
         true
     ;
-        io.write_string("INIT ", !IO),
-        output_init_name(ModuleName, !IO),
-        io.write_string("init\n", !IO),
         list.foldl(mlds_output_required_user_init_comment,
             UserInitPredCNames, !IO),
         list.foldl(mlds_output_required_user_final_comment,

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