on javac flags
B. Blaser
bsrbnd at gmail.com
Sun Sep 30 14:23:43 UTC 2018
Hi,
On Thu, 27 Sep 2018 at 12:00, B. Blaser <bsrbnd at gmail.com> wrote:
>
> On Wed, 26 Sep 2018 at 22:06, Maurizio Cimadamore
> <maurizio.cimadamore at oracle.com> wrote:
> >
> > Hi Bernard,
> > your solution is clever, but now a symbol has an array of N elements -
> > which makes it completely unfeasible from a memory footprint
> > perspective. Although maybe the core of what you are suggesting is -
> > just use a custom data structure, e.g. something like an immutable
> > bitset, so that we can share common combinations, etc.
>
> Yes, a custom BitSet or FlagSet was the idea behind this and I guess
> Brian is of the same opinion.
> I've not verified how primitive boolean arrays are implemented, but do
> we use a 64-bit word for each boolean value?
> If so, maybe something might be improved here... but several long
> values, as Brian/Rémi suggest, would be a good solution.
> And note that EnumSet probably also uses an array of references
> internally (?) or something equivalent.
> But, as Jon said, first specifying the API would probably help
> choosing the right implementation.
>
> Bernard
>
> >
> > Maurizio
I did a quick investigation and comparison between boolean[] vs BitSet
vs EnumSet:
* boolean[] seems to use one byte per boolean which isn't as bad, see [1]
* BitSet uses several long values which is good, see [2]
* EnumSet (RegularEnumSet/JumboEnumSet) uses several long values too
[3] and a shared reference array [4] which seems to be perfect.
So I would lean towards EnumSet as you initially suggested unless you
prefer a custom BitSet for some particular reasons?
Bernard
[1] https://docs.oracle.com/javase/specs/jvms/se11/html/jvms-6.html#jvms-6.5.baload
http://hg.openjdk.java.net/jdk/jdk/file/540c1a848dd8/src/hotspot/cpu/x86/templateTable_x86.cpp#l1182
[2] http://hg.openjdk.java.net/jdk/jdk/file/540c1a848dd8/src/java.base/share/classes/java/util/BitSet.java#l68
[3] http://hg.openjdk.java.net/jdk/jdk/file/540c1a848dd8/src/java.base/share/classes/java/util/JumboEnumSet.java#l40
[4] http://hg.openjdk.java.net/jdk/jdk/file/540c1a848dd8/src/java.base/share/classes/java/util/EnumSet.java#l402
More information about the compiler-dev
mailing list