comparison agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPoolCache.java @ 1602:136b78722a08

6939203: JSR 292 needs method handle constants Summary: Add new CP types CONSTANT_MethodHandle, CONSTANT_MethodType; extend 'ldc' bytecode. Reviewed-by: twisti, never
author jrose
date Wed, 09 Jun 2010 18:50:45 -0700
parents c18cbe5936b8
children 0a8e0d4345b3
comparison
equal deleted inserted replaced
1585:49fac4acd688 1602:136b78722a08
76 Assert.that(0 <= i && i < getLength(), "index out of bounds"); 76 Assert.that(0 <= i && i < getLength(), "index out of bounds");
77 } 77 }
78 return new ConstantPoolCacheEntry(this, i); 78 return new ConstantPoolCacheEntry(this, i);
79 } 79 }
80 80
81 public static boolean isSecondaryIndex(int i) { return (i < 0); }
82 public static int decodeSecondaryIndex(int i) { return isSecondaryIndex(i) ? ~i : i; }
83 public static int encodeSecondaryIndex(int i) { return !isSecondaryIndex(i) ? ~i : i; }
84
85 // secondary entries hold invokedynamic call site bindings
86 public ConstantPoolCacheEntry getSecondaryEntryAt(int i) {
87 ConstantPoolCacheEntry e = new ConstantPoolCacheEntry(this, decodeSecondaryIndex(i));
88 if (Assert.ASSERTS_ENABLED) {
89 Assert.that(e.isSecondaryEntry(), "must be a secondary entry");
90 }
91 return e;
92 }
93
94 public ConstantPoolCacheEntry getMainEntryAt(int i) {
95 if (isSecondaryIndex(i)) {
96 // run through an extra level of indirection:
97 i = getSecondaryEntryAt(i).getMainEntryIndex();
98 }
99 ConstantPoolCacheEntry e = new ConstantPoolCacheEntry(this, i);
100 if (Assert.ASSERTS_ENABLED) {
101 Assert.that(!e.isSecondaryEntry(), "must not be a secondary entry");
102 }
103 return e;
104 }
105
81 public int getIntAt(int entry, int fld) { 106 public int getIntAt(int entry, int fld) {
82 //alignObjectSize ? 107 //alignObjectSize ?
83 long offset = baseOffset + /*alignObjectSize*/entry * elementSize + fld* getHeap().getIntSize(); 108 long offset = baseOffset + /*alignObjectSize*/entry * elementSize + fld* getHeap().getIntSize();
84 return (int) getHandle().getCIntegerAt(offset, getHeap().getIntSize(), true ); 109 return (int) getHandle().getCIntegerAt(offset, getHeap().getIntSize(), true );
85 } 110 }