[m-rev.] diff: large integer literals in java backend

Peter Wang novalazy at gmail.com
Tue Jul 21 13:29:24 AEST 2009


2009/7/20 Paul Bone <pbone at csse.unimelb.edu.au>:
> On Thu, Jul 16, 2009 at 03:24:33PM +1000, Peter Wang wrote:
>> Other suggestions welcome.
>>
>>
>> Branches: main
>>
>> When using a 64-bit Mercury compiler, a hexadecimal literal with the 32nd bit
>> set (e.g. 0xffffffff) would be written out to Java source files as a large
>> positive integer, but the Java compiler would complain because the integer is
>> too large to fit in 32-bits.
>>
>> This patch works around the problem by writing such literals in hexadecimal.
>
> Does this mean that the Java backend (for all intents and purposes) is a
> 32bit backend no matter what machine it runs on?

Mercury `int's are Java `ints', which are always 32-bits wide.

> Can/will the compiler bootstrap in Java?

The compiler can be built in the java grade, with some hacking still.
I don't know if it bootstraps but it compiles some modules.

> Does this routine work
> correctly in when the compiler is built using the Java backend?

It should.

> Perhaps
> the more general question here is can a 32bit mercury compiler build a
> 64bit mercury program?

Not sure what a 64-bit Mercury program is, but a 32-bit Mercury compiler
cannot read a 64-bit integer constant.

> I'm not suggesting any changes to the compiler, but perhaps these things
> should be stated explicitly in the documentation if they aren't already.

There are also problems with a 64-bit host compiler evaluating operations at
compile time, which produce different results to that which would be produced
on a 32-bit target.

Peter

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list