__WhereVal/__WhereRef on fields
Ali Ebrahimi
ali.ebrahimi1781 at gmail.com
Wed Dec 16 20:30:44 UTC 2015
Hi,
On Wed, Dec 16, 2015 at 9:19 PM, Brian Goetz <brian.goetz at oracle.com> wrote:
> To put this in perspective, you can do anything with refs that you can do
> with values, and more (assign to null, synchronize on them, etc.) So
> rather than thinking in terms of "here's the value version, and here's the
> ref version", its more effective to think in terms of "here's the any
> version (that works for values and refs)" and "here's the
> optimized/specialized version for refs". (In other words, __WhereVal is not
> needed and is probably going away as part of the model.)
>
I was thinking about some form of C's union types.
Think of this as:
class ArrayList<any E> ...{
private __WhereVal(T){Type1}|__WhereRef(T){T[]} elementData;
Or even more customized storage:
private __Where(T is boolean){BitVector}|__ELSE(T){Type2} elementData;
Or if would need only val version:
private __WhereVal(T){Type1} elementData;
This should not allocated for reffs.
In other word, one field of same name but with different type.
I think for supporting this level of customization we would need an
additional Template class file for Val specific bytecode.
Test.class
Class Test{
}
Test.vtemplate
Class Test.vtemplate
... // val type members
}
--
Best Regards,
Ali Ebrahimi
More information about the valhalla-dev
mailing list