gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gm2] latest fixes to gm2


From: Gaius Mulley
Subject: Re: [Gm2] latest fixes to gm2
Date: 07 May 2004 16:52:14 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Izo writes:

> Gaius Mulley wrote:
> 
> >   *  the -Wunbounded-by-reference and -Wverbose-unbounded.
> >      Here is the extract from gm2.texi
> >----
> >enable optimization of unbounded parameters by attempting to pass non
> >@code{VAR} unbounded parameters by reference.  This optimization
> >avoids the implicit copy inside the callee procedure. GNU Modula-2
> >will only allow unbounded parameters to be passed by reference if,
> >inside the callee procedure, they are not written to, no address is
> >calculated on the array and it is not passed as a @code{VAR}
> >parameter.  Note that it is possible to write code to break this
> >optimization, therefore this option should be used carefully.
> >For example it would be possible to take the address of an array, pass
> >the address and the array to a procedure, read from the array in
> >the procedure and write to the location using the address parameter.
> >
> >Due to the dangerous nature of this option it is not enabled
> >when the -O option is specified.
> >
> Gaius, I do not understand really the reason for the use of this
> option. What situation can it be useful in ?

Hi Iztok,

this option serves to improve the performance of code which makes
heavy use of ARRAY OF foo parameters. Ie consider

StrIO.mod

PROCEDURE WriteString (a: ARRAY OF CHAR) ;
BEGIN

END WriteString ;

and also the StrLib procedures. If a user creates a large string and
keeps passing it to WriteString - or worse StrEqual(a, b) then many
Modula-2 implementations will make a copy of the unbounded arrays
during the prologue of the procedure - even though we know that the
array contents will not be altered - just compared and written out in
these respective cases. So normally gm2 treats WriteString like this:

PROCEDURE WriteString (addr: ADDRESS; high: CARDINAL) ;
(* move into C syntax for a while .. *)
   char *a;

   a = alloca (high+1) ;
   a = memcpy(addr, a, high+1) ;
(* back to M2.. *)
BEGIN
   HIGH(a) maps onto high and a[i] refers to our copy of addr
END WriteString ;

The -Wunbounded-by-reference option tells gm2 to check to see whether
the array contents inside the procedure (WriteString and StrEqual in
our example) is modified - if not then it omits to make a copy of the
incoming data and instead accesses it via a pointer. In the above it
throws away the C code - and replaces the prototype with

PROCEDURE WriteString (char *a, int high)

This could (depending upon how code is written) improve performance
significantly.

> 
> >----
> >
> >   *  nearly finished ISO SYSTEM
> Glad to see this. I've not been around for a while since my project is
> in one of its peaks, but I am certainly going to return to GM2 and use
> it in case it supports various gcc versions not only the single one as
> it is the case now (or I am wrong?), and of course, if it is
> prepared

true at present the current CVS snapshot matches gcc-3.3.3 - I plan to
keep patches for 3.3.3 and use the #if defined mechanism to support
3.3.3 as I migrate to gcc-3.4. The configure tests currently check for
supported 3.3.x and all the hooks are there to install the patches and
it sets the -DGCC_VERSION etc

> to be built to cross-compile to various targets.

yes I've successfully built gm2 as a cross compiler for MinGW and
strong-arm.

> Right now I am using the XDS-C and it is pain to debug. From the
> point I am now at I have two options - complete C++ rewrite of the
> existing M2 code or GM2.
> 
> 
> And I've got two questions:
> 
> 1. What about the .so support ? Is there provided the main body for
> _fini and _init ?

still to do.. I can push this as a high priority fix if need be..

> 2. Debugging formats - does the GM2 emit the dwarf-2 and stabs+ or it
> just depends on the gcc version used ?

gcc-3.3.3 + gm2 supports both. I use -gstabs+ on the 32 bit x86 systems
and -gdwarf-2 on the LP64 opteron system.

> Iztok

hope this helps,
Gaius



reply via email to

[Prev in Thread] Current Thread [Next in Thread]