866
867 // Standard indexes can never conflict with flag bits. Assert it.
868 for (int i = 0; i < ATTR_CONTEXT_LIMIT; i++) {
869 assert((attrFlagMask[i] & maxFlags[i]) == 0);
870 }
871 // Collect counts for both predefs. and custom defs.
872 // Decide on custom, local attribute definitions.
873 backCountTable = new HashMap<>();
874 attrCounts = new int[ATTR_CONTEXT_LIMIT][];
875 for (int i = 0; i < ATTR_CONTEXT_LIMIT; i++) {
876 // Now the remaining defs in allLayouts[i] need attr. indexes.
877 // Fill up unused flag bits with new defs.
878 // Unused bits are those which are not used by predefined attrs,
879 // and which are always clear in the classfiles.
880 long avHiBits = ~(maxFlags[i] | attrFlagMask[i]);
881 assert(attrIndexLimit[i] > 0);
882 assert(attrIndexLimit[i] < 64); // all bits fit into a Java long
883 avHiBits &= (1L<<attrIndexLimit[i])-1;
884 int nextLoBit = 0;
885 Map<Attribute.Layout, int[]> defMap = allLayouts.get(i);
886 @SuppressWarnings({ "unchecked", "rawtypes" })
887 Map.Entry<Attribute.Layout, int[]>[] layoutsAndCounts =
888 new Map.Entry[defMap.size()];
889 defMap.entrySet().toArray(layoutsAndCounts);
890 // Sort by count, most frequent first.
891 // Predefs. participate in this sort, though it does not matter.
892 Arrays.sort(layoutsAndCounts,
893 new Comparator<Map.Entry<Attribute.Layout, int[]>>() {
894 public int compare(Map.Entry<Attribute.Layout, int[]> e0,
895 Map.Entry<Attribute.Layout, int[]> e1) {
896 // Primary sort key is count, reversed.
897 int r = -(e0.getValue()[0] - e1.getValue()[0]);
898 if (r != 0) return r;
899 return e0.getKey().compareTo(e1.getKey());
900 }
901 });
902 attrCounts[i] = new int[attrIndexLimit[i]+layoutsAndCounts.length];
903 for (int j = 0; j < layoutsAndCounts.length; j++) {
904 Map.Entry<Attribute.Layout, int[]> e = layoutsAndCounts[j];
905 Attribute.Layout def = e.getKey();
906 int count = e.getValue()[0];
|
866
867 // Standard indexes can never conflict with flag bits. Assert it.
868 for (int i = 0; i < ATTR_CONTEXT_LIMIT; i++) {
869 assert((attrFlagMask[i] & maxFlags[i]) == 0);
870 }
871 // Collect counts for both predefs. and custom defs.
872 // Decide on custom, local attribute definitions.
873 backCountTable = new HashMap<>();
874 attrCounts = new int[ATTR_CONTEXT_LIMIT][];
875 for (int i = 0; i < ATTR_CONTEXT_LIMIT; i++) {
876 // Now the remaining defs in allLayouts[i] need attr. indexes.
877 // Fill up unused flag bits with new defs.
878 // Unused bits are those which are not used by predefined attrs,
879 // and which are always clear in the classfiles.
880 long avHiBits = ~(maxFlags[i] | attrFlagMask[i]);
881 assert(attrIndexLimit[i] > 0);
882 assert(attrIndexLimit[i] < 64); // all bits fit into a Java long
883 avHiBits &= (1L<<attrIndexLimit[i])-1;
884 int nextLoBit = 0;
885 Map<Attribute.Layout, int[]> defMap = allLayouts.get(i);
886 @SuppressWarnings({"unchecked", "rawtypes"})
887 Map.Entry<Attribute.Layout, int[]>[] layoutsAndCounts =
888 new Map.Entry[defMap.size()];
889 defMap.entrySet().toArray(layoutsAndCounts);
890 // Sort by count, most frequent first.
891 // Predefs. participate in this sort, though it does not matter.
892 Arrays.sort(layoutsAndCounts,
893 new Comparator<Map.Entry<Attribute.Layout, int[]>>() {
894 public int compare(Map.Entry<Attribute.Layout, int[]> e0,
895 Map.Entry<Attribute.Layout, int[]> e1) {
896 // Primary sort key is count, reversed.
897 int r = -(e0.getValue()[0] - e1.getValue()[0]);
898 if (r != 0) return r;
899 return e0.getKey().compareTo(e1.getKey());
900 }
901 });
902 attrCounts[i] = new int[attrIndexLimit[i]+layoutsAndCounts.length];
903 for (int j = 0; j < layoutsAndCounts.length; j++) {
904 Map.Entry<Attribute.Layout, int[]> e = layoutsAndCounts[j];
905 Attribute.Layout def = e.getKey();
906 int count = e.getValue()[0];
|