comparison agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPool.java @ 2011:dad31fc330cd

7001379: bootstrap method data needs to be moved from constant pool to a classfile attribute Reviewed-by: twisti
author jrose
date Fri, 03 Dec 2010 15:53:57 -0800
parents 3b2dea75431e
children 3582bf76420e
comparison
equal deleted inserted replaced
2010:7601ab0e1e33 2011:dad31fc330cd
58 poolHolder = new OopField(type.getOopField("_pool_holder"), 0); 58 poolHolder = new OopField(type.getOopField("_pool_holder"), 0);
59 length = new CIntField(type.getCIntegerField("_length"), 0); 59 length = new CIntField(type.getCIntegerField("_length"), 0);
60 headerSize = type.getSize(); 60 headerSize = type.getSize();
61 elementSize = 0; 61 elementSize = 0;
62 // fetch constants: 62 // fetch constants:
63 MULTI_OPERAND_COUNT_OFFSET = db.lookupIntConstant("constantPoolOopDesc::_multi_operand_count_offset").intValue();
64 MULTI_OPERAND_BASE_OFFSET = db.lookupIntConstant("constantPoolOopDesc::_multi_operand_base_offset").intValue();
65 INDY_BSM_OFFSET = db.lookupIntConstant("constantPoolOopDesc::_indy_bsm_offset").intValue(); 63 INDY_BSM_OFFSET = db.lookupIntConstant("constantPoolOopDesc::_indy_bsm_offset").intValue();
66 INDY_NT_OFFSET = db.lookupIntConstant("constantPoolOopDesc::_indy_nt_offset").intValue();
67 INDY_ARGC_OFFSET = db.lookupIntConstant("constantPoolOopDesc::_indy_argc_offset").intValue(); 64 INDY_ARGC_OFFSET = db.lookupIntConstant("constantPoolOopDesc::_indy_argc_offset").intValue();
68 INDY_ARGV_OFFSET = db.lookupIntConstant("constantPoolOopDesc::_indy_argv_offset").intValue(); 65 INDY_ARGV_OFFSET = db.lookupIntConstant("constantPoolOopDesc::_indy_argv_offset").intValue();
69 } 66 }
70 67
71 ConstantPool(OopHandle handle, ObjectHeap heap) { 68 ConstantPool(OopHandle handle, ObjectHeap heap) {
81 private static CIntField length; // number of elements in oop 78 private static CIntField length; // number of elements in oop
82 79
83 private static long headerSize; 80 private static long headerSize;
84 private static long elementSize; 81 private static long elementSize;
85 82
86 private static int MULTI_OPERAND_COUNT_OFFSET;
87 private static int MULTI_OPERAND_BASE_OFFSET;
88 private static int INDY_BSM_OFFSET; 83 private static int INDY_BSM_OFFSET;
89 private static int INDY_NT_OFFSET;
90 private static int INDY_ARGC_OFFSET; 84 private static int INDY_ARGC_OFFSET;
91 private static int INDY_ARGV_OFFSET; 85 private static int INDY_ARGV_OFFSET;
92 86
93 public TypeArray getTags() { return (TypeArray) tags.getValue(this); } 87 public TypeArray getTags() { return (TypeArray) tags.getValue(this); }
94 public TypeArray getOperands() { return (TypeArray) operands.getValue(this); } 88 public TypeArray getOperands() { return (TypeArray) operands.getValue(this); }
294 } 288 }
295 return res; 289 return res;
296 } 290 }
297 291
298 /** Lookup for multi-operand (InvokeDynamic) entries. */ 292 /** Lookup for multi-operand (InvokeDynamic) entries. */
299 public int[] getMultiOperandsAt(int i) { 293 public short[] getBootstrapSpecifierAt(int i) {
300 if (Assert.ASSERTS_ENABLED) { 294 if (Assert.ASSERTS_ENABLED) {
301 Assert.that(getTagAt(i).isInvokeDynamic(), "Corrupted constant pool"); 295 Assert.that(getTagAt(i).isInvokeDynamic(), "Corrupted constant pool");
302 } 296 }
303 int pos = this.getIntAt(i); 297 if (getTagAt(i).value() == JVM_CONSTANT_InvokeDynamicTrans)
304 int countPos = pos + MULTI_OPERAND_COUNT_OFFSET; // == pos-1 298 return null;
305 int basePos = pos + MULTI_OPERAND_BASE_OFFSET; // == pos 299 int bsmSpec = extractLowShortFromInt(this.getIntAt(i));
306 if (countPos < 0) return null; // safety first
307 TypeArray operands = getOperands(); 300 TypeArray operands = getOperands();
308 if (operands == null) return null; // safety first 301 if (operands == null) return null; // safety first
309 int length = operands.getIntAt(countPos); 302 int basePos = VM.getVM().buildIntFromShorts(operands.getShortAt(bsmSpec * 2 + 0),
310 int[] values = new int[length]; 303 operands.getShortAt(bsmSpec * 2 + 1));
311 for (int j = 0; j < length; j++) { 304 int argv = basePos + INDY_ARGV_OFFSET;
312 values[j] = operands.getIntAt(basePos+j); 305 int argc = operands.getShortAt(basePos + INDY_ARGC_OFFSET);
306 int endPos = argv + argc;
307 short[] values = new short[endPos - basePos];
308 for (int j = 0; j < values.length; j++) {
309 values[j] = operands.getShortAt(basePos+j);
313 } 310 }
314 return values; 311 return values;
315 } 312 }
316 313
317 final private static String[] nameForTag = new String[] { 314 final private static String[] nameForTag = new String[] {
332 case JVM_CONSTANT_InterfaceMethodref: return "JVM_CONSTANT_InterfaceMethodref"; 329 case JVM_CONSTANT_InterfaceMethodref: return "JVM_CONSTANT_InterfaceMethodref";
333 case JVM_CONSTANT_NameAndType: return "JVM_CONSTANT_NameAndType"; 330 case JVM_CONSTANT_NameAndType: return "JVM_CONSTANT_NameAndType";
334 case JVM_CONSTANT_MethodHandle: return "JVM_CONSTANT_MethodHandle"; 331 case JVM_CONSTANT_MethodHandle: return "JVM_CONSTANT_MethodHandle";
335 case JVM_CONSTANT_MethodType: return "JVM_CONSTANT_MethodType"; 332 case JVM_CONSTANT_MethodType: return "JVM_CONSTANT_MethodType";
336 case JVM_CONSTANT_InvokeDynamic: return "JVM_CONSTANT_InvokeDynamic"; 333 case JVM_CONSTANT_InvokeDynamic: return "JVM_CONSTANT_InvokeDynamic";
334 case JVM_CONSTANT_InvokeDynamicTrans: return "JVM_CONSTANT_InvokeDynamic/transitional";
337 case JVM_CONSTANT_Invalid: return "JVM_CONSTANT_Invalid"; 335 case JVM_CONSTANT_Invalid: return "JVM_CONSTANT_Invalid";
338 case JVM_CONSTANT_UnresolvedClass: return "JVM_CONSTANT_UnresolvedClass"; 336 case JVM_CONSTANT_UnresolvedClass: return "JVM_CONSTANT_UnresolvedClass";
339 case JVM_CONSTANT_UnresolvedClassInError: return "JVM_CONSTANT_UnresolvedClassInError"; 337 case JVM_CONSTANT_UnresolvedClassInError: return "JVM_CONSTANT_UnresolvedClassInError";
340 case JVM_CONSTANT_ClassIndex: return "JVM_CONSTANT_ClassIndex"; 338 case JVM_CONSTANT_ClassIndex: return "JVM_CONSTANT_ClassIndex";
341 case JVM_CONSTANT_UnresolvedString: return "JVM_CONSTANT_UnresolvedString"; 339 case JVM_CONSTANT_UnresolvedString: return "JVM_CONSTANT_UnresolvedString";
391 case JVM_CONSTANT_InterfaceMethodref: 389 case JVM_CONSTANT_InterfaceMethodref:
392 case JVM_CONSTANT_NameAndType: 390 case JVM_CONSTANT_NameAndType:
393 case JVM_CONSTANT_MethodHandle: 391 case JVM_CONSTANT_MethodHandle:
394 case JVM_CONSTANT_MethodType: 392 case JVM_CONSTANT_MethodType:
395 case JVM_CONSTANT_InvokeDynamic: 393 case JVM_CONSTANT_InvokeDynamic:
394 case JVM_CONSTANT_InvokeDynamicTrans:
396 visitor.doInt(new IntField(new NamedFieldIdentifier(nameForTag(ctag)), indexOffset(index), true), true); 395 visitor.doInt(new IntField(new NamedFieldIdentifier(nameForTag(ctag)), indexOffset(index), true), true);
397 break; 396 break;
398 } 397 }
399 } 398 }
400 } 399 }
554 if (DEBUG) debugMessage("CP[" + ci + "] = N&T name = " + nameIndex 553 if (DEBUG) debugMessage("CP[" + ci + "] = N&T name = " + nameIndex
555 + ", type = " + signatureIndex); 554 + ", type = " + signatureIndex);
556 break; 555 break;
557 } 556 }
558 557
558 case JVM_CONSTANT_InvokeDynamicTrans:
559 case JVM_CONSTANT_InvokeDynamic: { 559 case JVM_CONSTANT_InvokeDynamic: {
560 dos.writeByte(cpConstType); 560 dos.writeByte(cpConstType);
561 int[] values = getMultiOperandsAt(ci); 561 int value = getIntAt(ci);
562 for (int vn = 0; vn < values.length; vn++) { 562 short bsmIndex = (short) extractLowShortFromInt(value);
563 dos.writeShort(values[vn]); 563 short nameAndTypeIndex = (short) extractHighShortFromInt(value);
564 } 564 dos.writeShort(bsmIndex);
565 int bootstrapMethodIndex = values[INDY_BSM_OFFSET]; 565 dos.writeShort(nameAndTypeIndex);
566 int nameAndTypeIndex = values[INDY_NT_OFFSET]; 566 if (DEBUG) debugMessage("CP[" + ci + "] = indy BSM = " + bsmIndex
567 int argumentCount = values[INDY_ARGC_OFFSET]; 567 + ", N&T = " + nameAndTypeIndex);
568 assert(INDY_ARGV_OFFSET + argumentCount == values.length);
569 if (DEBUG) debugMessage("CP[" + ci + "] = indy BSM = " + bootstrapMethodIndex
570 + ", N&T = " + nameAndTypeIndex
571 + ", argc = " + argumentCount);
572 break; 568 break;
573 } 569 }
574 570
575 default: 571 default:
576 throw new InternalError("unknown tag: " + cpConstType); 572 throw new InternalError("unknown tag: " + cpConstType);