Far classes
John Rose
john.r.rose at oracle.com
Wed Jun 26 22:32:49 UTC 2024
On 26 Jun 2024, at 2:54, Andrew Haley wrote:
> On 6/26/24 09:54, John Rose wrote:
>> You could also use a joint encoding [1] on more than one bit,
>> so as have encode more near classes in the same number of
>> bits.
>
> [1] https://cr.openjdk.org/~jrose/jvm/joint-bit-encodings.html
>
> Joint Bit Encodings is a kind of Arithmetic Code, isn't it? We don't
> have to think in terms of bits in the encoded class at all, just to
> say that if an encoded value is less than N, it's an offset to the
> real Klass*. Otherwise, subtract N from the encoded value and use
> that.
Joint bits are often easier to understand than arithmetic
limits, but yes. The concrete example I gave intentionally
maps not only to joint bits but also to a range check.
And such a range check limit doesn’t need to be a specially
formatted constant; it can be any parameter. Probably the
ISAs we care about don’t care whether it is a bit check
(on a nice mask) or a range check (on a nice limit).
Also, for those keeping score, the code I gave for get_klass
can sometimes be optimized as a flow-free conditional move
to get the array base (this or &NEAR_KLASSES[-1<<10]) and
then a slick uniform index operation that works for both
cases.
More information about the lilliput-dev
mailing list