Struct/value types + stack allocations

David Holmes david.holmes at oracle.com
Wed Jan 18 22:52:51 PST 2012


I think it is time to take this off hotspot-runtime-dev ...

On 19/01/2012 4:23 PM, Kirk Pepperdine wrote:
> Hi Vitaly,
>
> Sorry, but I'm still not seeing a use case for this. What is it that
> you're trying to do that you can't accomplish with a class?

The "struct" has different assignment semantics to allow it to be stack 
allocated but not allow it to escape from a scope where it is valid. If 
you used a Class, and perhaps an annotation to indicate stack 
allocation, you'd then need additional things in place to ensure it 
didn't escape. The RTSJ uses runtime assignment checks which are both a 
performance hit and introduce a whole new range of unexpected failure 
modes (assignment can now throw exceptions!). Other possibilities would 
involve some form of escape analysis that perhaps promoted the 
stack-object to being a heap-object if it escaped.

But as has been said this is not really a discussion for this mailing list.

David
-----

> Oracle finally released invokedynamic after a lot of discussion but only
> after a number of people from both in and out side of Sun/Oracle made
> significant efforts to make it happen. it's hard to get changes like
> this into the JVM and IMHO, it should/needs to be because OpenJDK
> shouldn't shouldn't become a grab bag of everything that's cool new and
> shiny. Instead there is a conservative yet responsible path to
> innovation and it is that path that the invokedynamic people took. Same
> story with closures. Not quite the same story with generics and so....
>
> Regards,
> Kirk
>
> On 2012-01-19, at 5:41 AM, Vitaly Davidovich wrote:
>
>> Hi John,
>>
>> Sorry, let me clarify - I'm not saying that this is a priority for me
>> in the sense that it's preventing me from accomplishing something
>> concrete. Rather, it's something that I (and I think a substantial
>> populace of other java developers) would really like to see in java
>> and the VM. I'm not sure how projects are selected for implementation
>> by Oracle (e.g. how did invokedynamic, which is mostly useful for
>> dynamic languages and not java, get Oracle engineers allocated to it?
>> Did someone external contribute a preliminary prototype first?) but I
>> was hoping that I could make a decent case for why something like this
>> would be very welcomed by the java community and why I think it should
>> get *relative* priority to other projects under consideration.
>>
>> Feel free to move this conversation to mlvm (or something else) as
>> it's getting a bit exploratory.
>>
>> Thanks
>>
>> Sent from my phone
>>
>> On Jan 18, 2012 8:59 PM, "John Pampuch" <john.pampuch at oracle.com
>> <mailto:john.pampuch at oracle.com>> wrote:
>>
>>     __
>>     Vitaly-
>>
>>     I think contributing to OpenJDK is the best way to express your
>>     priorities :)
>>
>>     The Java language probably wouldn't have constructs in it that
>>     could leverage a mechanism like this for a long time (if ever).
>>     Would you mind sharing why this is a priority for you?
>>
>>     -John
>>
>>     On 1/18/12 4:39 PM, Vitaly Davidovich wrote:
>>>
>>>     I also see my phone auto-corrected as heal instead of heel ... :)
>>>
>>>     To John, albeit selfishly :), I'd love to see structs prioritized
>>>     over fixnums and maybe some of the other things (reification
>>>     would be great too and would go a long way in reducing bloat due
>>>     to boxed numerics). Is there something akin to public voting on
>>>     prioritization of features that Oracle agrees to dedicate
>>>     resources to? Maybe I'm overestimating demand, but I think
>>>     structs would get a lot of backing.
>>>
>>>     Thanks
>>>
>>>     Sent from my phone
>>>
>>>     On Jan 18, 2012 5:01 PM, "Ismael Juma" <mlists at juma.me.uk
>>>     <mailto:mlists at juma.me.uk>> wrote:
>>>
>>>         Hi all,
>>>
>>>         Vitaly Davidovich <vitalyd at ...> <mailto:vitalyd at ...> writes:
>>>         > The reason I ask is because I think the achilles heal of
>>>         java performance
>>>         > is the memory consumption (this is something you often hear
>>>         in discussions
>>>         > about java performance).
>>>
>>>         Agreed. I've seen and written tons of code to workaround the
>>>         fact that there are
>>>         no structs in the language. Examples of popular open-source
>>>         projects that use
>>>         parallel arrays (with much worse cache locality) to avoid
>>>         objects and their
>>>         memory overhead are many (Lucene, Mahout, fastutil, Trove,
>>>         JGit, etc.).
>>>
>>>         Best,
>>>         Ismael
>>>
>


More information about the hotspot-runtime-dev mailing list