News for hackers. Stuff that matters.
Re:JEP draft: 64 bit object headers by kichik on Monday October 10, 2022 @08:42PM (#33158133)
How come a whole pointer is required for class pointer? Can't it be a small offset into a class table? Do many Java applications often require millions of classes?
Re:JEP draft: 64 bit object headers by dexwiz on Monday October 10, 2022 @09:01PM (#33158249)
Definitely have seen a few enterprise stacks that reach this size. It’s not common, but it happens.
Re:JEP draft: 64 bit object headers by paulirwin on Tuesday October 11, 2022 @09:31AM (#33163140)
I think I'm understanding correctly, but please correct me if I'm wrong... the class pointer is a pointer to the type (class) the object implements. So that would mean to exceed even an unsigned 32-bit pointer size, there would need to be more than 4 billion types in the program to exceed that, not objects. I can't imagine there are (m)any programs that hit that. And it definitely doesn't need to be a native 64-bit pointer. As pointed out in the proposal: "It may be possible to compress class pointers to less than 32 bits, at the expense of smaller addressable class space."
Re:JEP draft: 64 bit object headers by maxfurman on Tuesday October 11, 2022 @09:45AM (#33163285)
As other comments have mentioned, in the JVM every lambda creates a new type. So there are way, way more "types" created in Java than in a comparable program in another language.
Re:JEP draft: 64 bit object headers by remram on Monday October 10, 2022 @09:00PM (#33158242)
You mean add a level of indirection to every class access?

Also there is already compression for that pointer, making it 32 instead of 64 bits.

Re:JEP draft: 64 bit object headers by saagarjha on Monday October 10, 2022 @09:38PM (#33158474)
Turning a pointer loading into an addition and then a pointer load is not that much overhead.
Re:JEP draft: 64 bit object headers by remram on Monday October 10, 2022 @10:02PM (#33158642)
That's how the current compression works, I guess I don't understand what you propose.
Re:JEP draft: 64 bit object headers by saagarjha on Tuesday October 11, 2022 @02:00AM (#33159975)
I guess I am confused as to what the extra indirection is.
Re:JEP draft: 64 bit object headers by chrisseaton on Tuesday October 11, 2022 @03:30AM (#33160399)
The current compression scheme doesn’t involve reading any memory. Indirection through a lookup table would.

But who cares? 99% of the time you just need class identity, not values from it.

Re:JEP draft: 64 bit object headers by saagarjha on Tuesday October 11, 2022 @04:57AM (#33160947)
If you need identity you can just compare indices instead of pointers, no?
Re:JEP draft: 64 bit object headers by chrisseaton on Tuesday October 11, 2022 @05:02AM (#33160988)
What's what I just said?

> 99% of the time you just need class identity, not values from it.

So no need to deference the class pointer, or the table index.

Re:JEP draft: 64 bit object headers by saagarjha on Tuesday October 11, 2022 @05:24AM (#33161137)
Ok taking a step back I just realized you aren't 'remram :P But anyways my point was that in the old scheme if you wanted to know where the class was you would do some arithmetic on the compressed pointer to get a full pointer and now you can do a comparison, or if you want to read something do a dereference. Assuming the new layout is an array of classes you have a similar scheme where you have an index and you can compare those directly, and if you want data in the class you deref.
Re:JEP draft: 64 bit object headers by chrisseaton on Tuesday October 11, 2022 @05:26AM (#33161152)
> in the old scheme if you wanted to know where the class was you would do some arithmetic on the compressed pointer to get a full pointer and now you can do a comparison

Well also you didn't actually need to decompress the pointer first - compressed pointers are unique as well of course.

Re:JEP draft: 64 bit object headers by saagarjha on Tuesday October 11, 2022 @05:29AM (#33161183)
Ah, yes, true.
Re:JEP draft: 64 bit object headers by twic on Tuesday October 11, 2022 @09:49AM (#33163339)
Also, i believe that 'classes' aren't fixed size, because they contain the class's vtable [1]. As such, you couldn't keep them in an indexable array anyway.

[1] in HotSpot they are instances of InstanceKlass: https://github.com/openjdk/jdk/blob/master/src/hotspot/share...

Re:JEP draft: 64 bit object headers by chrisseaton on Tuesday October 11, 2022 @10:10AM (#33163576)
I think they mean keep references to them in an indexable array.
Re:JEP draft: 64 bit object headers by remram on Tuesday October 11, 2022 @11:18AM (#33164374)
That is the extra indirection I was talking about.
Re:JEP draft: 64 bit object headers by exabrial on Monday October 10, 2022 @08:53PM (#33158201)
It’s uncommon for millions in an average program unless you’ve got a special use case. Typical usage would be a couple thousand.
Re:JEP draft: 64 bit object headers by symaxian on Monday October 10, 2022 @11:18PM (#33159130)
It does seem like some additional compression could be performed, if they wanted to keep it a pointer to avoid a table lookup I wonder if they could do something like ensure that all class definitions must exist in the certain contiguous chunk of memory that has a fixed size of 1-4 gigabytes which would let them shrink the pointer size down.
Re:JEP draft: 64 bit object headers by layer8 on Tuesday October 11, 2022 @09:31AM (#33163132)
Application servers can run an arbitrary number of applications in parallel within the same JVM. Also, every lambda expression currently creates a new class. The interface-proxy mechanism also creates new classes at runtime. Classes are not expected to be a limited resource in JVM-land.