comparison agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java @ 6972:bd7a7ce2e264

6830717: replay of compilations would help with debugging Summary: When java process crashed in compiler thread, repeat the compilation process will help finding root cause. This is done with using SA dump application class data and replay data from core dump, then use debug version of jvm to recompile the problematic java method. Reviewed-by: kvn, twisti, sspitsyn Contributed-by: yumin.qi@oracle.com
author minqi
date Mon, 12 Nov 2012 14:03:53 -0800
parents da91efe96a93
children 4a916f2ce331
comparison
equal deleted inserted replaced
6965:3be318ecfae5 6972:bd7a7ce2e264
276 return vmSymbols.symbolAt(signatureIndex); 276 return vmSymbols.symbolAt(signatureIndex);
277 } 277 }
278 } 278 }
279 279
280 public short getFieldGenericSignatureIndex(int index) { 280 public short getFieldGenericSignatureIndex(int index) {
281 int len = getFields().length(); 281 // int len = getFields().length();
282 int allFieldsCount = getAllFieldsCount(); 282 int allFieldsCount = getAllFieldsCount();
283 int generic_signature_slot = allFieldsCount * FIELD_SLOTS; 283 int generic_signature_slot = allFieldsCount * FIELD_SLOTS;
284 for (int i = 0; i < allFieldsCount; i++) { 284 for (int i = 0; i < allFieldsCount; i++) {
285 short flags = getFieldAccessFlags(i); 285 short flags = getFieldAccessFlags(i);
286 AccessFlags access = new AccessFlags(flags); 286 AccessFlags access = new AccessFlags(flags);
323 public MethodArray getMethods() { return new MethodArray(methods.getValue(getAddress())); } 323 public MethodArray getMethods() { return new MethodArray(methods.getValue(getAddress())); }
324 public KlassArray getLocalInterfaces() { return new KlassArray(localInterfaces.getValue(getAddress())); } 324 public KlassArray getLocalInterfaces() { return new KlassArray(localInterfaces.getValue(getAddress())); }
325 public KlassArray getTransitiveInterfaces() { return new KlassArray(transitiveInterfaces.getValue(getAddress())); } 325 public KlassArray getTransitiveInterfaces() { return new KlassArray(transitiveInterfaces.getValue(getAddress())); }
326 public int getJavaFieldsCount() { return (int) javaFieldsCount.getValue(this); } 326 public int getJavaFieldsCount() { return (int) javaFieldsCount.getValue(this); }
327 public int getAllFieldsCount() { 327 public int getAllFieldsCount() {
328 int len = getFields().length(); 328 int len = getFields().length();
329 int allFieldsCount = 0; 329 int allFieldsCount = 0;
330 for (; allFieldsCount*FIELD_SLOTS < len; allFieldsCount++) { 330 for (; allFieldsCount*FIELD_SLOTS < len; allFieldsCount++) {
331 short flags = getFieldAccessFlags(allFieldsCount); 331 short flags = getFieldAccessFlags(allFieldsCount);
332 AccessFlags access = new AccessFlags(flags); 332 AccessFlags access = new AccessFlags(flags);
333 if (access.fieldHasGenericSignature()) { 333 if (access.fieldHasGenericSignature()) {
579 this.field = field; 579 this.field = field;
580 this.flags = flags; 580 this.flags = flags;
581 } 581 }
582 } 582 }
583 583
584 public Field[] getStaticFields() {
585 U2Array fields = getFields();
586 int length = getJavaFieldsCount();
587 ArrayList result = new ArrayList();
588 for (int index = 0; index < length; index++) {
589 Field f = newField(index);
590 if (f.isStatic()) {
591 result.add(f);
592 }
593 }
594 return (Field[])result.toArray(new Field[result.size()]);
595 }
596
584 public void iterateNonStaticFields(OopVisitor visitor, Oop obj) { 597 public void iterateNonStaticFields(OopVisitor visitor, Oop obj) {
585 if (getSuper() != null) { 598 if (getSuper() != null) {
586 ((InstanceKlass) getSuper()).iterateNonStaticFields(visitor, obj); 599 ((InstanceKlass) getSuper()).iterateNonStaticFields(visitor, obj);
587 } 600 }
588 int length = getJavaFieldsCount(); 601 int length = getJavaFieldsCount();
977 return index; 990 return index;
978 } 991 }
979 } 992 }
980 return -1; 993 return -1;
981 } 994 }
995
996 public void dumpReplayData(PrintStream out) {
997 ConstantPool cp = getConstants();
998
999 // Try to record related loaded classes
1000 Klass sub = getSubklassKlass();
1001 while (sub != null) {
1002 if (sub instanceof InstanceKlass) {
1003 out.println("instanceKlass " + sub.getName().asString());
1004 }
1005 sub = sub.getNextSiblingKlass();
1006 }
1007
1008 final int length = (int) cp.getLength();
1009 out.print("ciInstanceKlass " + getName().asString() + " " + (isLinked() ? 1 : 0) + " " + (isInitialized() ? 1 : 0) + " " + length);
1010 for (int index = 1; index < length; index++) {
1011 out.print(" " + cp.getTags().at(index));
1012 }
1013 out.println();
1014 if (isInitialized()) {
1015 Field[] staticFields = getStaticFields();
1016 for (int i = 0; i < staticFields.length; i++) {
1017 Field f = staticFields[i];
1018 Oop mirror = getJavaMirror();
1019 if (f.isFinal() && !f.hasInitialValue()) {
1020 out.print("staticfield " + getName().asString() + " " +
1021 OopUtilities.escapeString(f.getID().getName()) + " " +
1022 f.getFieldType().getSignature().asString() + " ");
1023 if (f instanceof ByteField) {
1024 ByteField bf = (ByteField)f;
1025 out.println(bf.getValue(mirror));
1026 } else if (f instanceof BooleanField) {
1027 BooleanField bf = (BooleanField)f;
1028 out.println(bf.getValue(mirror) ? 1 : 0);
1029 } else if (f instanceof ShortField) {
1030 ShortField bf = (ShortField)f;
1031 out.println(bf.getValue(mirror));
1032 } else if (f instanceof CharField) {
1033 CharField bf = (CharField)f;
1034 out.println(bf.getValue(mirror) & 0xffff);
1035 } else if (f instanceof IntField) {
1036 IntField bf = (IntField)f;
1037 out.println(bf.getValue(mirror));
1038 } else if (f instanceof LongField) {
1039 LongField bf = (LongField)f;
1040 out.println(bf.getValue(mirror));
1041 } else if (f instanceof FloatField) {
1042 FloatField bf = (FloatField)f;
1043 out.println(Float.floatToRawIntBits(bf.getValue(mirror)));
1044 } else if (f instanceof DoubleField) {
1045 DoubleField bf = (DoubleField)f;
1046 out.println(Double.doubleToRawLongBits(bf.getValue(mirror)));
1047 } else if (f instanceof OopField) {
1048 OopField bf = (OopField)f;
1049
1050 Oop value = bf.getValue(mirror);
1051 if (value == null) {
1052 out.println("null");
1053 } else if (value.isInstance()) {
1054 Instance inst = (Instance)value;
1055 if (inst.isA(SystemDictionary.getStringKlass())) {
1056 out.println("\"" + OopUtilities.stringOopToEscapedString(inst) + "\"");
1057 } else {
1058 out.println(inst.getKlass().getName().asString());
1059 }
1060 } else if (value.isObjArray()) {
1061 ObjArray oa = (ObjArray)value;
1062 Klass ek = (ObjArrayKlass)oa.getKlass();
1063 out.println(oa.getLength() + " " + ek.getName().asString());
1064 } else if (value.isTypeArray()) {
1065 TypeArray ta = (TypeArray)value;
1066 out.println(ta.getLength());
1067 } else {
1068 out.println(value);
1069 }
1070 }
1071 }
1072 }
1073 }
1074 }
982 } 1075 }