One old fixnum solution proposed by Per Bothner many years ago (he is on this mailing list so he might know the PDF he wrote I am referring to?) Whenever I read something,my mind often over paraphrases things (even makes up it's own version!) but I walked away with this
The primitive types that the JVM feels the need to box. Int/float/byte etc All could be put into a "TAGGED" structure. This means (jobject && BYTE_TAG) >> TAG_LSR_BYTE == jbyte value (jobject && INT_TAG) >> TAG_LSR_INT == jint value That basically many jobjects would actually point to places in memory that are never actually valid. One bit is used to tell us that the type is TAGGED_AT_ALL specially that is a valid boxing of a primitive. Some more bits are used to decide how the what type of primitive is boxed. The remainder of the bits is the value. some types are totally subsumed Short/Byte.. some wont fit totally like Long/Float/Long/Double/Int etc.. but very common values for them will still fit. Some like Byte and Short don't need to use their full value range and use their impossible values to help host other primitives types that would have fallen out of the possible value range. Still others like Long that fall outside of available data bit range are stuck using their old legacy impl (the current impl!) This makes boxing and unboxing most primitives "most often" a very tiny operation. The boxed versions still pretend to be jobjects giving compatibility to most part of the code.. however every part that is used to consuming a jobject will take on slight overhead to see if its a boxed value first.. but I think this would be worth it. Is this correct interpretation? -- You received this message because you are subscribed to the Google Groups "JVM Languages" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/jvm-languages?hl=.
