[m-rev.] for review: fix float_to_string so that roundtripping works

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Nov 21 21:15:54 AEDT 2002


On 21-Nov-2002, Peter Ross <pro at missioncriticalit.com> wrote:
> On Thu, Nov 21, 2002 at 02:26:50AM +1100, Fergus Henderson wrote:
> > This should be written in C# rather than IL.  IL is a low-level assembly
> > language, so we don't want to write it by hand unless we have to.
>
> There are some advantages of writing the IL code by hand.  For starters
> it is easy, you just cut and paste the code from the ildasm of the C#
> code that you wrote in the start, you only need to get the stack size
> right ;).

Even that can be cut-and-paste from the .maxstack directive in the
ildasm output.

So yes, if you do it that way I guess it is reasonably easy to get the
IL correct.  But this process is still more complicated than just
writing it in C#, and the resulting code is a little less readable and
thus a little harder to maintain.

Another advantage of using C# is that the C# compiler will issue warnings
for the use of deprecated methods, whereas I doubt that ilasm would do that
(especialy since it doesn't read the meta-data for imported modules).

> Once the code is in IL it has the advantage that it is inlineable by
> the mercury compiler, this of course has performance implications.

True; however, inlining is not so critical in the IL back-end as it is
in the C back-end, since a good JIT will do inlining anyway.  In fact
the JIT may be better able to judge when inlining is likely to pay off,
since it is more likely to have access to accurate profiling information.

> > As proof of this, "ldloca" in the above is incorrect (it should be "ldloc")
> 
> No it isn't.  float64 is a valuetype so you need to load its address.

Sorry, you are correct.

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