[m-rev.] diff: fix bug with MLDS `base' optimization
Fergus Henderson
fjh at cs.mu.OZ.AU
Wed Nov 12 17:59:57 AEDT 2003
Branches: main
Estimated hours taken: 0.5
Fix a bug that broke the MLDS back-end in the case when either heap profiling
or accurate GC was enabled.
compiler/mlds_to_c.m:
Fix a bug in Zoltan's recent change to declare a local variable
"base" for initializing terms allocated on the heap:
change the order in which code is output so that the
declaration of "base" comes immediately after the "{",
without any intervening code. Otherwise, it is not legal C89.
Workspace: /home/ceres/fjh/mercury
Index: compiler/mlds_to_c.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_c.m,v
retrieving revision 1.154
diff -u -d -r1.154 mlds_to_c.m
--- compiler/mlds_to_c.m 11 Nov 2003 03:19:46 -0000 1.154
+++ compiler/mlds_to_c.m 12 Nov 2003 06:52:17 -0000
@@ -2808,6 +2808,28 @@
mlds_indent(Indent),
io__write_string("{\n"),
+ % When filling in the fields of a newly allocated cell, use a fresh
+ % local variable as the base address for the field references in
+ % preference to an lval that is more expensive to access. This yields
+ % a speedup of about 0.3%.
+
+ ( { Target = var(_, _) } ->
+ { Base = lval(Target) }
+ ;
+ % It doesn't matter what string we pick for BaseVarName,
+ % as long as its declaration doesn't hide any of the variables
+ % inside Args. This is not hard to ensure, since the printed
+ % forms of the variables inside Args all include "__".
+ { BaseVarName = "base" },
+ { Base = string(BaseVarName) },
+ mlds_indent(Context, Indent + 1),
+ mlds_output_type_prefix(Type),
+ io__write_string(" "),
+ io__write_string(BaseVarName),
+ mlds_output_type_suffix(Type),
+ io__write_string(";\n")
+ ),
+
% for --gc accurate, we need to insert a call to GC_check()
% before every allocation
globals__io_get_gc_method(GC_Method),
@@ -2838,27 +2860,6 @@
mlds_maybe_output_heap_profile_instr(Context, Indent + 1, Args,
FuncName, MaybeCtorName),
- % When filling in the fields of a newly allocated cell, use a fresh
- % local variable as the base address for the field references in
- % preference to an lval that is more expensive to access. This yields
- % a speedup of about 0.3%.
-
- ( { Target = var(_, _) } ->
- { Base = lval(Target) }
- ;
- % It doesn't matter what string we pick for BaseVarName,
- % as long as its declaration doesn't hide any of the variables
- % inside Args. This is not hard to ensure, since the printed
- % forms of the variables inside Args all include "__".
- { BaseVarName = "base" },
- { Base = string(BaseVarName) },
- mlds_indent(Context, Indent + 1),
- mlds_output_type_prefix(Type),
- io__write_string(" "),
- io__write_string(BaseVarName),
- mlds_output_type_suffix(Type),
- io__write_string(";\n")
- ),
mlds_indent(Context, Indent + 1),
write_lval_or_string(Base),
io__write_string(" = "),
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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