comparison agent/src/share/classes/sun/jvm/hotspot/oops/ConstMethod.java @ 12939:d2db09f281ca

8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data Summary: Hotspot was updated to store method parameter reflection and generic type signature data at runtime. Serviceability agent support was updated for this data Reviewed-by: coleenp, minqi, sla Contributed-by: eric.mccorkle@oracle.com
author dsamersoff
date Thu, 17 Oct 2013 16:45:08 +0400
parents 927a311d00f9
children
comparison
equal deleted inserted replaced
12935:9e0ef3f02648 12939:d2db09f281ca
49 private static int HAS_LOCALVARIABLE_TABLE; 49 private static int HAS_LOCALVARIABLE_TABLE;
50 private static int HAS_EXCEPTION_TABLE; 50 private static int HAS_EXCEPTION_TABLE;
51 private static int HAS_GENERIC_SIGNATURE; 51 private static int HAS_GENERIC_SIGNATURE;
52 private static int HAS_METHOD_ANNOTATIONS; 52 private static int HAS_METHOD_ANNOTATIONS;
53 private static int HAS_PARAMETER_ANNOTATIONS; 53 private static int HAS_PARAMETER_ANNOTATIONS;
54 private static int HAS_METHOD_PARAMETERS;
54 private static int HAS_DEFAULT_ANNOTATIONS; 55 private static int HAS_DEFAULT_ANNOTATIONS;
55 private static int HAS_TYPE_ANNOTATIONS; 56 private static int HAS_TYPE_ANNOTATIONS;
56 57
57 private static final int sizeofShort = 2; 58 private static final int sizeofShort = 2;
58 59
68 HAS_LOCALVARIABLE_TABLE = db.lookupIntConstant("ConstMethod::_has_localvariable_table").intValue(); 69 HAS_LOCALVARIABLE_TABLE = db.lookupIntConstant("ConstMethod::_has_localvariable_table").intValue();
69 HAS_EXCEPTION_TABLE = db.lookupIntConstant("ConstMethod::_has_exception_table").intValue(); 70 HAS_EXCEPTION_TABLE = db.lookupIntConstant("ConstMethod::_has_exception_table").intValue();
70 HAS_GENERIC_SIGNATURE = db.lookupIntConstant("ConstMethod::_has_generic_signature").intValue(); 71 HAS_GENERIC_SIGNATURE = db.lookupIntConstant("ConstMethod::_has_generic_signature").intValue();
71 HAS_METHOD_ANNOTATIONS = db.lookupIntConstant("ConstMethod::_has_method_annotations").intValue(); 72 HAS_METHOD_ANNOTATIONS = db.lookupIntConstant("ConstMethod::_has_method_annotations").intValue();
72 HAS_PARAMETER_ANNOTATIONS = db.lookupIntConstant("ConstMethod::_has_parameter_annotations").intValue(); 73 HAS_PARAMETER_ANNOTATIONS = db.lookupIntConstant("ConstMethod::_has_parameter_annotations").intValue();
74 HAS_METHOD_PARAMETERS = db.lookupIntConstant("ConstMethod::_has_method_parameters").intValue();
73 HAS_DEFAULT_ANNOTATIONS = db.lookupIntConstant("ConstMethod::_has_default_annotations").intValue(); 75 HAS_DEFAULT_ANNOTATIONS = db.lookupIntConstant("ConstMethod::_has_default_annotations").intValue();
74 HAS_TYPE_ANNOTATIONS = db.lookupIntConstant("ConstMethod::_has_type_annotations").intValue(); 76 HAS_TYPE_ANNOTATIONS = db.lookupIntConstant("ConstMethod::_has_type_annotations").intValue();
75 77
76 // Size of Java bytecodes allocated immediately after ConstMethod*. 78 // Size of Java bytecodes allocated immediately after ConstMethod*.
77 codeSize = new CIntField(type.getCIntegerField("_code_size"), 0); 79 codeSize = new CIntField(type.getCIntegerField("_code_size"), 0);
82 maxLocals = new CIntField(type.getCIntegerField("_max_locals"), 0); 84 maxLocals = new CIntField(type.getCIntegerField("_max_locals"), 0);
83 sizeOfParameters = new CIntField(type.getCIntegerField("_size_of_parameters"), 0); 85 sizeOfParameters = new CIntField(type.getCIntegerField("_size_of_parameters"), 0);
84 86
85 // start of byte code 87 // start of byte code
86 bytecodeOffset = type.getSize(); 88 bytecodeOffset = type.getSize();
89
90 type = db.lookupType("MethodParametersElement");
91 methodParametersElementSize = type.getSize();
87 92
88 type = db.lookupType("CheckedExceptionElement"); 93 type = db.lookupType("CheckedExceptionElement");
89 checkedExceptionElementSize = type.getSize(); 94 checkedExceptionElementSize = type.getSize();
90 95
91 type = db.lookupType("LocalVariableTableElement"); 96 type = db.lookupType("LocalVariableTableElement");
111 private static CIntField maxLocals; 116 private static CIntField maxLocals;
112 private static CIntField sizeOfParameters; 117 private static CIntField sizeOfParameters;
113 118
114 // start of bytecode 119 // start of bytecode
115 private static long bytecodeOffset; 120 private static long bytecodeOffset;
116 121 private static long methodParametersElementSize;
117 private static long checkedExceptionElementSize; 122 private static long checkedExceptionElementSize;
118 private static long localVariableTableElementSize; 123 private static long localVariableTableElementSize;
119 private static long exceptionTableElementSize; 124 private static long exceptionTableElementSize;
120 125
121 public Method getMethod() { 126 public Method getMethod() {
385 offset += checkedExceptionElementSize; 390 offset += checkedExceptionElementSize;
386 } 391 }
387 return ret; 392 return ret;
388 } 393 }
389 394
395 private boolean hasMethodParameters() {
396 return (getFlags() & HAS_METHOD_PARAMETERS) != 0;
397 }
398
390 private boolean hasGenericSignature() { 399 private boolean hasGenericSignature() {
391 return (getFlags() & HAS_GENERIC_SIGNATURE) != 0; 400 return (getFlags() & HAS_GENERIC_SIGNATURE) != 0;
392 } 401 }
393 402
394 private boolean hasMethodAnnotations() { 403 private boolean hasMethodAnnotations() {
440 // Offset of the generic signature index 449 // Offset of the generic signature index
441 private long offsetOfGenericSignatureIndex() { 450 private long offsetOfGenericSignatureIndex() {
442 return offsetOfLastU2Element(); 451 return offsetOfLastU2Element();
443 } 452 }
444 453
445 private long offsetOfCheckedExceptionsLength() { 454 private long offsetOfMethodParametersLength() {
455 if (Assert.ASSERTS_ENABLED) {
456 Assert.that(hasMethodParameters(), "should only be called if table is present");
457 }
446 return hasGenericSignature() ? offsetOfLastU2Element() - sizeofShort : 458 return hasGenericSignature() ? offsetOfLastU2Element() - sizeofShort :
447 offsetOfLastU2Element(); 459 offsetOfLastU2Element();
460 }
461
462 private int getMethodParametersLength() {
463 if (hasMethodParameters())
464 return (int) getAddress().getCIntegerAt(offsetOfMethodParametersLength(), 2, true);
465 else
466 return 0;
467 }
468
469 // Offset of start of checked exceptions
470 private long offsetOfMethodParameters() {
471 long offset = offsetOfMethodParametersLength();
472 long length = getMethodParametersLength();
473 if (Assert.ASSERTS_ENABLED) {
474 Assert.that(length > 0, "should only be called if method parameter information is present");
475 }
476 offset -= length * methodParametersElementSize;
477 return offset;
478 }
479
480 private long offsetOfCheckedExceptionsLength() {
481 if (hasMethodParameters())
482 return offsetOfMethodParameters() - sizeofShort;
483 else {
484 return hasGenericSignature() ? offsetOfLastU2Element() - sizeofShort :
485 offsetOfLastU2Element();
486 }
448 } 487 }
449 488
450 private int getCheckedExceptionsLength() { 489 private int getCheckedExceptionsLength() {
451 if (hasCheckedExceptions()) { 490 if (hasCheckedExceptions()) {
452 return (int) getAddress().getCIntegerAt(offsetOfCheckedExceptionsLength(), 2, true); 491 return (int) getAddress().getCIntegerAt(offsetOfCheckedExceptionsLength(), 2, true);
494 533
495 if (hasExceptionTable()) { 534 if (hasExceptionTable()) {
496 return offsetOfExceptionTable() - sizeofShort; 535 return offsetOfExceptionTable() - sizeofShort;
497 } else if (hasCheckedExceptions()) { 536 } else if (hasCheckedExceptions()) {
498 return offsetOfCheckedExceptions() - sizeofShort; 537 return offsetOfCheckedExceptions() - sizeofShort;
538 } else if (hasMethodParameters()) {
539 return offsetOfMethodParameters() - sizeofShort;
499 } else { 540 } else {
500 return hasGenericSignature() ? offsetOfLastU2Element() - sizeofShort : 541 return hasGenericSignature() ? offsetOfLastU2Element() - sizeofShort :
501 offsetOfLastU2Element(); 542 offsetOfLastU2Element();
502 } 543 }
503 } 544 }
524 if (Assert.ASSERTS_ENABLED) { 565 if (Assert.ASSERTS_ENABLED) {
525 Assert.that(hasExceptionTable(), "should only be called if table is present"); 566 Assert.that(hasExceptionTable(), "should only be called if table is present");
526 } 567 }
527 if (hasCheckedExceptions()) { 568 if (hasCheckedExceptions()) {
528 return offsetOfCheckedExceptions() - sizeofShort; 569 return offsetOfCheckedExceptions() - sizeofShort;
570 } else if (hasMethodParameters()) {
571 return offsetOfMethodParameters() - sizeofShort;
529 } else { 572 } else {
530 return hasGenericSignature() ? offsetOfLastU2Element() - sizeofShort : 573 return hasGenericSignature() ? offsetOfLastU2Element() - sizeofShort :
531 offsetOfLastU2Element(); 574 offsetOfLastU2Element();
532 } 575 }
533 } 576 }