A question about bytecodes

Joseph D. Darcy Joe.Darcy at Sun.COM
Fri Jan 9 13:43:38 PST 2009


Tom Rodriguez wrote:
>>> The if?? bytecodes operates on the 3 way result from that so you 
>>> don't _have_ to add unsigned variants of them I think.
>>
>> I assume the if?? variants can operate on a regular int aswell? Then
>> we'll need an unsigned ifge and ifgt. iflt and ifle are actually invalid
>> for unsigned numbers.
>
> They can be used with it but they are just a special case encoding of 
> ificmp that's not absolutely necessary for unsigned support.
>
>> I really don't want to go through the VM adding 3 new primitives in just
>> for unsigned integers. From what I've seen this would be an excessive
>> amount of work. (I should point out, I really don't know what I'm doing
>> yet :))
>
> Indeed it would.
>
> One thing I might mention is that there's another approach to adding 
> unsigned which is to do in the form of an API that's expected to be 
> intrinsified by the JVM.  The performance of this would/could be 
> exactly the same as a bytecoded version without requiring a change to 
> the JVM specification for adoption, which I think is a largely 
> insurmountable barrier.  Any way you slice it, javac would have to be 
> updated to emit something different so either implementation would 
> appear the same from the user standpoint.  The only ugly ones from an 
> API perspective are the unsigned byte versions of 
> getstatic/getfield/baload.  Those could simply by fudged by emitting a 
> following & 0xff.  I vaguely remember a proposal like this being 
> mooted about a few years ago but I don't know what happened to it.
>
> If you go the bytecode route with the expectation of JVM spec support 
> then I think you would need to update the type signatures to include 
> unsigned types.  I think a spec change would require more uniformity 
> of implementation.
>
> tom

If unsigned support is going to be added to the platform, I agree the 
most tractable way to do so at this point is through library support 
without explicit language or JVM changes, 4504839 "Java libraries should 
provide support for unsigned integer arithmetic."

To help track (un)signedness in code and make sure any needed 
conversions weren't missing, an annotation processing checker from JSR 
308 could be used.

-Joe




More information about the hotspot-dev mailing list