[m-rev.] for review: --no-inline-builtins
Simon Taylor
stayl at cs.mu.OZ.AU
Thu Jan 30 02:16:04 AEDT 2003
On 30-Jan-2003, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 29-Jan-2003, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> >
> > Add an option `--no-inline-builins', which causes builtins to
> > be generated as calls to out-of-line procedures. This can be
> > useful for debugging, as without this option the execution of
> > builtins is not traced.
> That looks good. I think this option should be enabled by
> default if execution tracing is requested (e.g. for debug
> grades), unless `--trace-optimized' is specified.
>
> Oh, looking at the diff, I think you did that already.
> But the log message, NEWS file entry, and option documentation
> didn't make that clear.
Fixed.
>
> > --- tests/debugger/Mmakefile 15 Nov 2002 04:50:43 -0000 1.92
> > +++ tests/debugger/Mmakefile 29 Jan 2003 02:40:01 -0000
> > @@ -101,8 +101,20 @@
> > +# The no_inline_builtins test only works if the library is
> > +# built with execution tracing enabled. Adding a `.exp2' file
> > +# to allow it to be run in other grades would mean that we
> > +# wouldn't detect a regression which caused builtins not to
> > +# be traced with `--no-inline-builtins'.
> > +ifeq "$(findstring debug,$(GRADE))" "debug"
> > + DEBUG_GRADE_PROGS = no_inline_builtins
> > +else
> > + DEBUG_GRADE_PROGS =
> > +endif
>
> I think it's also worth covering the case when
> `--no-inline-builtins' is specified and debugging isn't.
> This could be done by copying the no_inline_builtins.m
> test cases to another file, no_inline_builtins2.m,
> and changing the `else' case there to use no_inline_builtins2.m.
I've added it to tests/hard_coded so that it is run in high-level
code grades.
> > Index: tests/debugger/queens.exp2
> > ===================================================================
> > @@ -1,45 +1,48 @@
> > - 1: 1 1 CALL pred queens.main/2-0 (cc_multi) queens.m:17
> > + E1: C1 1 CALL pred queens.main/2-0 (cc_multi) queens.m:17
> > mdb> echo on
> > Command echo enabled.
> > +mdb> register --quiet
> > mdb> retry 1
> > not that many ancestors
> > mdb> print *
> > DCG_0 (arg 1) state('<<c_pointer>>')
> > -mdb>
> > - 2: 2 2 CALL pred queens.data/1-0 (det) queens.m:39 (queens.m:15)
> > +mdb> b data
> > + 0: + stop interface pred queens.data/1-0 (det)
> > +mdb> continue
> > + E2: C2 2 CALL pred queens.data/1-0 (det) queens.m:39 (queens.m:15)
>
> Huh? Where did all these differences come from?
queens.exp2 was previously unused -- it wasn't up to date.
> > +++ tests/debugger/declarative/args.exp 29 Jan 2003 03:57:11 -0000
> > @@ -11,7 +11,15 @@
> > mdb> dd
> > p(1, 16, 3, 20, 5)
> > Valid? no
> > -my_succeed
> > ++(1, 3) = 4
> > +Valid? yes
> > +*(3, 5) = 15
> > +Valid? yes
> > ++(1, 15) = 16
> > +Valid? yes
> > +*(4, 5) = 20
> > +Valid? yes
> > +semidet_succeed
>
> You know, I think the declarative debugger really ought to by default
> assume that everything in the standard library is correct.
> Having the declarative debugger ask you if 1 + 3 = 4 is not a
> usability improvement! (Shades of 1984...)
I think you can only assume that everything in the library that
doesn't take a higher-order argument is correct. With abstract
types, it could be difficult to know what can take a higher-order
argument. For example, when processing map__lookup, without
inter-module optimization the compiler couldn't know that the
type `tree234' isn't a higher-order type.
> > --- tests/debugger/declarative/gcf.m 2 Jun 1999 07:28:55 -0000 1.1
> > +++ tests/debugger/declarative/gcf.m 29 Jan 2003 07:13:45 -0000
> > @@ -3,7 +3,7 @@
> > :- import_module io.
> > :- pred main(io__state::di, io__state::uo) is cc_multi.
> > :- implementation.
> > -:- import_module std_util, int.
> > +:- import_module int, std_util.
Fixed.
Simon.
Estimated hours taken: 8
Branches: main
Add an option `--no-inline-builtins', which causes builtins to
be generated as calls to out-of-line procedures. This is done
by default when debugging, as without this option the execution
of builtins is not traced.
On earth, a compiler built in grade asm_fast.gc.tr.debug
takes 36.8s to run `mmc -C -I ../analysis/ hlds.make_hlds'.
When the compiler is built with `--no-inline-builtins',
this is increased to 38.6s.
The size of the compiler built in grade asm_fast.gc.tr.debug
increases from 45.0MB to 46.6MB.
compiler/options.m:
Add the option.
compiler/code_util.m:
Work out whether builtins should be generated inline.
compiler/handle_options.m:
Disable inlining of builtins when debugging.
compiler/simplify.m:
compiler/higher_order.m:
compiler/modes.m:
code_util__builtin_state now needs to know where the
builtin is being called from to know whether a particular
call should be treated as an inline builtin. The "recursive"
calls from the automatically generated procedures for each
builtin should always be generated inline, or else we would
generate an infinite loop.
NEWS:
doc/user_guide.texi:
compiler/notes/todo.html:
Document the change.
tests/debugger/Mmakefile:
tests/debugger/no_inline_builtins.{m,exp,inp}:
Test case.
tests/debugger/*.{inp,exp,exp2}:
tests/debugger/declarative/*.{inp,exp,exp2}:
Update due to changed event numbers.
tests/debugger/lval_desc_array.inp:
Use a less brittle method for stepping to the point in
the program where the test needs to display variables.
tests/debugger/declarative/library_forwarding.m:
tests/debugger/declarative/*.m:
Add forwarding predicates for some library predicates
and functions so that the declarative debugger doesn't
ask different questions depending on whether or not
the library was compiled with debugging enabled.
diff -u NEWS NEWS
--- NEWS
+++ NEWS
@@ -98,7 +98,7 @@
of the Mercury User's Guide for details.
* Inlining of builtins can now be disabled using the `--no-inline-builtins'
- option. This can be useful for debugging, as without this option the
+ option. This is done by default when debugging, as without this option the
execution of builtins is not traced.
* The Mercury compiler now uses `.' and not `:' as the module separator
diff -u compiler/options.m compiler/options.m
--- compiler/options.m
+++ compiler/options.m
@@ -3371,9 +3371,9 @@
"\tDisable the inlining of simple procedures.",
"--no-inline-builtins",
"\tGenerate builtins (e.g. arithmetic operators) as calls to",
- "\tout of line procedures. This can be useful for debugging,",
- "\tas without this option the execution of builtins is not",
- "\ttraced.",
+ "\tout of line procedures. This is done by default when,",
+ "\tdebugging, as without this option the execution of",
+ "\tbuiltins is not traced.",
"--no-inline-single-use",
"\tDisable the inlining of procedures called only once.",
"--inline-compound-threshold <threshold>",
diff -u doc/user_guide.texi doc/user_guide.texi
--- doc/user_guide.texi
+++ doc/user_guide.texi
@@ -5663,9 +5663,8 @@
@item --no-inline-builtins
@findex --no-inline-builtins
Generate builtins (e.g.@: arithmetic operators) as calls to
-out of line procedures. This can be useful for debugging,
-as without this option the execution of builtins is not
-traced.
+out of line procedures. This is done by default when debugging,
+as without this option the execution of builtins is not traced.
@item --no-inline-single-use
@findex --no-inline-single-use
reverted:
--- tests/debugger/declarative/gcf.m 29 Jan 2003 07:13:45 -0000
+++ tests/debugger/declarative/gcf.m 2 Jun 1999 07:28:55 -0000 1.1
@@ -3,7 +3,7 @@
:- import_module io.
:- pred main(io__state::di, io__state::uo) is cc_multi.
:- implementation.
+:- import_module std_util, int.
-:- import_module int, std_util.
main -->
{
Index: tests/hard_coded/Mercury.options
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/Mercury.options,v
retrieving revision 1.3
diff -u -u -r1.3 Mercury.options
--- tests/hard_coded/Mercury.options 27 Nov 2002 16:54:31 -0000 1.3
+++ tests/hard_coded/Mercury.options 29 Jan 2003 14:54:29 -0000
@@ -20,6 +20,7 @@
MCFLAGS-intermod_type_qual2 = --intermodule-optimization
MCFLAGS-intermod_multimode = --intermodule-optimization
MCFLAGS-intermod_multimode_main = --intermodule-optimization
+MCFLAGS-no_inline_builtins = --no-inline-builtins
MCFLAGS-no_warn_singleton = --halt-at-warn
MCFLAGS-nondet_copy_out = --no-inlining --nondet-copy-out
MCFLAGS-redoip_clobber = --no-inlining
Index: tests/hard_coded/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/Mmakefile,v
retrieving revision 1.183
diff -u -u -r1.183 Mmakefile
--- tests/hard_coded/Mmakefile 23 Jan 2003 04:25:47 -0000 1.183
+++ tests/hard_coded/Mmakefile 29 Jan 2003 14:48:30 -0000
@@ -99,6 +99,7 @@
name_mangling \
no_fully_strict \
no_inline \
+ no_inline_builtins \
no_warn_singleton \
nondet_ctrl_vn \
nondet_copy_out \
Index: tests/hard_coded/no_inline_builtins.exp
===================================================================
RCS file: tests/hard_coded/no_inline_builtins.exp
diff -N tests/hard_coded/no_inline_builtins.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/no_inline_builtins.exp 29 Jan 2003 14:48:03 -0000
@@ -0,0 +1 @@
+42
Index: tests/hard_coded/no_inline_builtins.m
===================================================================
RCS file: tests/hard_coded/no_inline_builtins.m
diff -N tests/hard_coded/no_inline_builtins.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/no_inline_builtins.m 29 Jan 2003 14:47:44 -0000
@@ -0,0 +1,13 @@
+:- module no_inline_builtins.
+:- interface.
+:- import_module io.
+
+:- pred main(io__state::di, io__state::uo) is det.
+
+:- implementation.
+
+:- import_module int.
+
+main -->
+ io__write_int(40 + 2),
+ io__nl.
--------------------------------------------------------------------------
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