< prev index next >

test/jdk/lib/testlibrary/bytecode/jdk/experimental/bytecode/BytePoolHelper.java

Print this page
rev 47761 : 8186209: Tool support for ConstantDynamic
8186046: Minimal ConstantDynamic support
Reviewed-by: acorn
Contributed-by: lois.foltan@oracle.com, john.r.rose@oracle.com, paul.sandoz@oracle.com
* * *
Minor Hotspot code cleanup changes resulting from condy review
Summary: Addressed missing DynamicInError condition, removed unused TraceDynamicConstants
Reviewed-by: acorn, psandoz
rev 47762 : 8187742: Minimal set of bootstrap methods for constant dynamic
Contributed-by: brian.goetz@oracle.com, john.r.rose@oracle.com, paul.sandoz@oracle.com
Reviewed-by: forax

*** 488,498 **** List<Integer> static_idxs = staticArgsBuilder.indexes; bsmKey.set(bsmClass, bsmName, bsmType, static_idxs); BsmKey poolKey = bootstraps.lookup(bsmKey); if (poolKey == null) { poolKey = bsmKey.dup(); ! int bsm_ref = putHandleInternal(MethodHandleInfo.REF_invokeStatic, bsmClass, bsmName, bsmType); poolKey.at(currentBsmIndex++); bootstraps.enter(poolKey); bsm_attr.writeChar(bsm_ref); bsm_attr.writeChar(static_idxs.size()); for (int i : static_idxs) { --- 488,499 ---- List<Integer> static_idxs = staticArgsBuilder.indexes; bsmKey.set(bsmClass, bsmName, bsmType, static_idxs); BsmKey poolKey = bootstraps.lookup(bsmKey); if (poolKey == null) { poolKey = bsmKey.dup(); ! // TODO the BSM could be a static method on an interface ! int bsm_ref = putHandleInternal(MethodHandleInfo.REF_invokeStatic, bsmClass, bsmName, bsmType, false); poolKey.at(currentBsmIndex++); bootstraps.enter(poolKey); bsm_attr.writeChar(bsm_ref); bsm_attr.writeChar(static_idxs.size()); for (int i : static_idxs) {
*** 560,601 **** return poolKey.index; } @Override public int putHandle(int refKind, S owner, CharSequence name, T type) { ! return putHandleInternal(refKind, symbolToString.apply(owner), name, typeToString.apply(type)); } ! private int putHandleInternal(int refKind, String owner, CharSequence name, String type) { key.setMethodHandle(refKind, owner, name, type); PoolKey poolKey = entries.lookup(key); if (poolKey == null) { poolKey = key.dup(); ! int ref_idx = putMemberRefInternal(fromKind(refKind), owner, name, type); poolKey.at(currentIndex++); entries.enter(poolKey); pool.writeByte(PoolTag.CONSTANT_METHODHANDLE.tag); pool.writeByte(refKind); pool.writeChar(ref_idx); } return poolKey.index; } ! PoolTag fromKind(int bsmKind) { switch (bsmKind) { case 1: // REF_getField case 2: // REF_getStatic case 3: // REF_putField case 4: // REF_putStatic return PoolTag.CONSTANT_FIELDREF; case 5: // REF_invokeVirtual case 6: // REF_invokeStatic case 7: // REF_invokeSpecial case 8: // REF_newInvokeSpecial - return PoolTag.CONSTANT_METHODREF; case 9: // REF_invokeInterface ! return PoolTag.CONSTANT_INTERFACEMETHODREF; default: throw new IllegalStateException(); } } --- 561,606 ---- return poolKey.index; } @Override public int putHandle(int refKind, S owner, CharSequence name, T type) { ! return putHandleInternal(refKind, symbolToString.apply(owner), name, typeToString.apply(type), false); } ! @Override ! public int putHandle(int refKind, S owner, CharSequence name, T type, boolean isInterface) { ! return putHandleInternal(refKind, symbolToString.apply(owner), name, typeToString.apply(type), isInterface); ! } ! ! private int putHandleInternal(int refKind, String owner, CharSequence name, String type, boolean isInterface) { key.setMethodHandle(refKind, owner, name, type); PoolKey poolKey = entries.lookup(key); if (poolKey == null) { poolKey = key.dup(); ! int ref_idx = putMemberRefInternal(fromKind(refKind, isInterface), owner, name, type); poolKey.at(currentIndex++); entries.enter(poolKey); pool.writeByte(PoolTag.CONSTANT_METHODHANDLE.tag); pool.writeByte(refKind); pool.writeChar(ref_idx); } return poolKey.index; } ! PoolTag fromKind(int bsmKind, boolean isInterface) { switch (bsmKind) { case 1: // REF_getField case 2: // REF_getStatic case 3: // REF_putField case 4: // REF_putStatic return PoolTag.CONSTANT_FIELDREF; case 5: // REF_invokeVirtual case 6: // REF_invokeStatic case 7: // REF_invokeSpecial case 8: // REF_newInvokeSpecial case 9: // REF_invokeInterface ! return isInterface ? PoolTag.CONSTANT_INTERFACEMETHODREF : PoolTag.CONSTANT_METHODREF; default: throw new IllegalStateException(); } }
< prev index next >