Hi,
Good find! Filed a bug: https://bugs.openjdk.java.net/browse/JDK-8117883
Thanks,
-Sundar
On Wednesday 17 June 2015 07:16 PM, Ahmed Ashour wrote:
Hi all,
During digging a little into the bytecode generated by Nasgen, there is a pattern of
"new ArrayList(memberCount)", but that member count is 1 more that what is
needed, this is not always the case, as it depends on the members.
This doesn't have functional impact, but every single byte counts;)
The root cause for Prototype, is that Constructor are included in the total
count, but it is not added.
To give example:
NativeArrayBuffer$Prototype:
{ ArrayList list = new ArrayList(2);
list.add(AccessorProperty.create("slice", 2, "G$slice", "S$slice"));
$nasgenmap$ = PropertyMap.newMap(list); }
although the list will contain a single entry, ArrayList was initialized by 2.
This also happens in the ScriptClass, e.g.:
NativeArray: { ArrayList list = new ArrayList(2);
list.add(AccessorProperty.create("length", 6, "length", "length"));
$nasgenmap$ = PropertyMap.newMap(list); }
But it is fine in, e.g.:
ArrayBufferView: { ArrayList list = new ArrayList(4); list.add(AccessorProperty.create("buffer", 7, "buffer",
(MethodHandle)null)); list.add(AccessorProperty.create("byteOffset", 7, "byteOffset", (MethodHandle)null));
list.add(AccessorProperty.create("byteLength", 7, "byteLength", (MethodHandle)null));
list.add(AccessorProperty.create("length", 7, "length", (MethodHandle)null)); $nasgenmap$ = PropertyMap.newMap(list); }
Thanks,Ahmed