[m-rev.] for review: fix a problem with mutables for non-MR_Word types

Julien Fischer juliensf at cs.mu.OZ.AU
Thu Feb 23 17:01:19 AEDT 2006


On Thu, 23 Feb 2006, Zoltan Somogyi wrote:

> For review by anyone.
>
> Fix a bug reported by Greg Duck. The bug was that the compiler always
> generated a global variable of type MR_Word for each mutable, but could then
> assign variables of other types to and from this global. If this other type
> is float, the assignments discard the fractional part. If this other type is
> something else, the result can be even worse.
>
> There are two ways to fix this discrepancy. One is to change the type of the
> global, and the other is to change the type of the variables it is assigned
> to and from. The former looks cleaner, but it would mean that every call to
> the get predicate would require a boxing operation, and that can be
> relatively slow, since (e.g. for floats) it may require allocating a heap
> cell.
>
> This diff implements both solutions.
>
> We use the second solution on the LLDS backend because of its better
> performance. We have to use the first solution on the MLDS backend,
> because on that backend the type of the mutable variable is reflected
> in the signature of the getter and setter predicates (whereas on the
> LLDS backend all arguments are always MR_Words).

Have you checked that this works correctly when the clauses for the
access predicates are exported in the .opt files?  If so, then that's
fine.

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