Mercurial > hg > graal-jvmci-8
comparison jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodData.java @ 23700:9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Sat, 18 Jun 2016 13:19:01 +0200 |
parents | 4b58c92e939b |
children | 41fa89f93355 |
comparison
equal
deleted
inserted
replaced
23699:8f9709f61cd4 | 23700:9e1235406b59 |
---|---|
44 /** | 44 /** |
45 * Access to a HotSpot MethodData structure (defined in methodData.hpp). | 45 * Access to a HotSpot MethodData structure (defined in methodData.hpp). |
46 */ | 46 */ |
47 public final class HotSpotMethodData { | 47 public final class HotSpotMethodData { |
48 | 48 |
49 private static final HotSpotVMConfig config = config(); | 49 static final HotSpotVMConfig config = config(); |
50 private static final HotSpotMethodDataAccessor NO_DATA_NO_EXCEPTION_ACCESSOR = new NoMethodData(TriState.FALSE); | 50 static final HotSpotMethodDataAccessor NO_DATA_NO_EXCEPTION_ACCESSOR = new NoMethodData(TriState.FALSE); |
51 private static final HotSpotMethodDataAccessor NO_DATA_EXCEPTION_POSSIBLY_NOT_RECORDED_ACCESSOR = new NoMethodData(TriState.UNKNOWN); | 51 static final HotSpotMethodDataAccessor NO_DATA_EXCEPTION_POSSIBLY_NOT_RECORDED_ACCESSOR = new NoMethodData(TriState.UNKNOWN); |
52 | |
53 static final int BIT_DATA_SIZE = cellIndexToOffset(0); | |
54 static final int BIT_DATA_NULL_SEEN_FLAG = 1 << config.bitDataNullSeenFlag; | |
55 | |
56 static final int BRANCH_DATA_SIZE = cellIndexToOffset(3); | |
57 static final int NOT_TAKEN_COUNT_OFFSET = cellIndexToOffset(config.branchDataNotTakenOffset); | |
58 | |
59 static final int ARG_INFO_DATA_SIZE = cellIndexToOffset(1); | |
60 | |
61 static final int COUNTER_DATA_SIZE = cellIndexToOffset(1); | |
62 static final int COUNTER_DATA_COUNT_OFFSET = cellIndexToOffset(config.methodDataCountOffset); | |
63 static final int JUMP_DATA_SIZE = cellIndexToOffset(2); | |
64 static final int TAKEN_COUNT_OFFSET = cellIndexToOffset(config.jumpDataTakenOffset); | |
65 static final int TAKEN_DISPLACEMENT_OFFSET = cellIndexToOffset(config.jumpDataDisplacementOffset); | |
66 static final int TYPE_DATA_ROW_SIZE = cellsToBytes(config.receiverTypeDataReceiverTypeRowCellCount); | |
67 | |
68 static final int NONPROFILED_COUNT_OFFSET = cellIndexToOffset(config.receiverTypeDataNonprofiledCountOffset); | |
69 static final int TYPE_DATA_FIRST_TYPE_OFFSET = cellIndexToOffset(config.receiverTypeDataReceiver0Offset); | |
70 static final int TYPE_DATA_FIRST_TYPE_COUNT_OFFSET = cellIndexToOffset(config.receiverTypeDataCount0Offset); | |
71 static final int VIRTUAL_CALL_DATA_SIZE = cellIndexToOffset(2) + TYPE_DATA_ROW_SIZE * (config.typeProfileWidth + config.methodProfileWidth); | |
72 static final int VIRTUAL_CALL_DATA_FIRST_METHOD_OFFSET = TYPE_DATA_FIRST_TYPE_OFFSET + TYPE_DATA_ROW_SIZE * config.typeProfileWidth; | |
73 static final int VIRTUAL_CALL_DATA_FIRST_METHOD_COUNT_OFFSET = TYPE_DATA_FIRST_TYPE_COUNT_OFFSET + TYPE_DATA_ROW_SIZE * config.typeProfileWidth; | |
74 | |
75 static final int ARRAY_DATA_LENGTH_OFFSET = cellIndexToOffset(config.arrayDataArrayLenOffset); | |
76 static final int ARRAY_DATA_START_OFFSET = cellIndexToOffset(config.arrayDataArrayStartOffset); | |
77 | |
78 static final int TYPE_CHECK_DATA_SIZE = cellIndexToOffset(2) + TYPE_DATA_ROW_SIZE * config.typeProfileWidth; | |
79 | |
80 static final int RET_DATA_ROW_SIZE = cellsToBytes(3); | |
81 static final int RET_DATA_SIZE = cellIndexToOffset(1) + RET_DATA_ROW_SIZE * config.bciProfileWidth; | |
82 | |
83 static final int MULTI_BRANCH_DATA_SIZE = cellIndexToOffset(1); | |
84 static final int MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS = config.multiBranchDataPerCaseCellCount; | |
85 static final int MULTI_BRANCH_DATA_ROW_SIZE = cellsToBytes(MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS); | |
86 static final int MULTI_BRANCH_DATA_FIRST_COUNT_OFFSET = ARRAY_DATA_START_OFFSET + cellsToBytes(0); | |
87 static final int MULTI_BRANCH_DATA_FIRST_DISPLACEMENT_OFFSET = ARRAY_DATA_START_OFFSET + cellsToBytes(1); | |
52 | 88 |
53 // sorted by tag | 89 // sorted by tag |
54 // @formatter:off | 90 // @formatter:off |
55 private static final HotSpotMethodDataAccessor[] PROFILE_DATA_ACCESSORS = { | 91 static final HotSpotMethodDataAccessor[] PROFILE_DATA_ACCESSORS = { |
56 null, | 92 null, |
57 new BitData(), | 93 new BitData(), |
58 new CounterData(), | 94 new CounterData(), |
59 new JumpData(), | 95 new JumpData(), |
60 new ReceiverTypeData(), | 96 new ReceiverTypeData(), |
267 | 303 |
268 } | 304 } |
269 return sb.toString(); | 305 return sb.toString(); |
270 } | 306 } |
271 | 307 |
308 /** | |
309 * Corresponds to {@code exception_seen_flag}. | |
310 */ | |
311 static final int EXCEPTIONS_MASK = 1 << config.bitDataExceptionSeenFlag; | |
312 static final int NO_DATA_SIZE = cellIndexToOffset(0); | |
313 | |
272 private abstract static class AbstractMethodData implements HotSpotMethodDataAccessor { | 314 private abstract static class AbstractMethodData implements HotSpotMethodDataAccessor { |
273 | |
274 /** | |
275 * Corresponds to {@code exception_seen_flag}. | |
276 */ | |
277 private static final int EXCEPTIONS_MASK = 1 << config.bitDataExceptionSeenFlag; | |
278 | 315 |
279 private final Tag tag; | 316 private final Tag tag; |
280 protected final int staticSize; | 317 protected final int staticSize; |
281 | 318 |
282 protected AbstractMethodData(Tag tag, int staticSize) { | 319 protected AbstractMethodData(Tag tag, int staticSize) { |
355 } | 392 } |
356 | 393 |
357 public abstract StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos); | 394 public abstract StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos); |
358 } | 395 } |
359 | 396 |
360 private static class NoMethodData extends AbstractMethodData { | 397 static class NoMethodData extends AbstractMethodData { |
361 | |
362 private static final int NO_DATA_SIZE = cellIndexToOffset(0); | |
363 | 398 |
364 private final TriState exceptionSeen; | 399 private final TriState exceptionSeen; |
365 | 400 |
366 protected NoMethodData(TriState exceptionSeen) { | 401 protected NoMethodData(TriState exceptionSeen) { |
367 super(Tag.No, NO_DATA_SIZE); | 402 super(Tag.No, NO_DATA_SIZE); |
382 public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { | 417 public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { |
383 return sb; | 418 return sb; |
384 } | 419 } |
385 } | 420 } |
386 | 421 |
387 private static class BitData extends AbstractMethodData { | 422 static class BitData extends AbstractMethodData { |
388 | |
389 private static final int BIT_DATA_SIZE = cellIndexToOffset(0); | |
390 private static final int BIT_DATA_NULL_SEEN_FLAG = 1 << config.bitDataNullSeenFlag; | |
391 | 423 |
392 private BitData() { | 424 private BitData() { |
393 super(Tag.BitData, BIT_DATA_SIZE); | 425 super(Tag.BitData, BIT_DATA_SIZE); |
394 } | 426 } |
395 | 427 |
406 public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { | 438 public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { |
407 return sb.append(format("exception_seen(%s)", getExceptionSeen(data, pos))); | 439 return sb.append(format("exception_seen(%s)", getExceptionSeen(data, pos))); |
408 } | 440 } |
409 } | 441 } |
410 | 442 |
411 private static class CounterData extends BitData { | 443 static class CounterData extends BitData { |
412 | |
413 private static final int COUNTER_DATA_SIZE = cellIndexToOffset(1); | |
414 private static final int COUNTER_DATA_COUNT_OFFSET = cellIndexToOffset(config.methodDataCountOffset); | |
415 | 444 |
416 CounterData() { | 445 CounterData() { |
417 super(Tag.CounterData, COUNTER_DATA_SIZE); | 446 super(Tag.CounterData, COUNTER_DATA_SIZE); |
418 } | 447 } |
419 | 448 |
434 public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { | 463 public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { |
435 return sb.append(format("count(%d) null_seen(%s) exception_seen(%s)", getCounterValue(data, pos), getNullSeen(data, pos), getExceptionSeen(data, pos))); | 464 return sb.append(format("count(%d) null_seen(%s) exception_seen(%s)", getCounterValue(data, pos), getNullSeen(data, pos), getExceptionSeen(data, pos))); |
436 } | 465 } |
437 } | 466 } |
438 | 467 |
439 private static class JumpData extends AbstractMethodData { | 468 static class JumpData extends AbstractMethodData { |
440 | |
441 private static final int JUMP_DATA_SIZE = cellIndexToOffset(2); | |
442 protected static final int TAKEN_COUNT_OFFSET = cellIndexToOffset(config.jumpDataTakenOffset); | |
443 protected static final int TAKEN_DISPLACEMENT_OFFSET = cellIndexToOffset(config.jumpDataDisplacementOffset); | |
444 | 469 |
445 JumpData() { | 470 JumpData() { |
446 super(Tag.JumpData, JUMP_DATA_SIZE); | 471 super(Tag.JumpData, JUMP_DATA_SIZE); |
447 } | 472 } |
448 | 473 |
482 this.counts = counts; | 507 this.counts = counts; |
483 this.totalCount = totalCount; | 508 this.totalCount = totalCount; |
484 } | 509 } |
485 } | 510 } |
486 | 511 |
487 private abstract static class AbstractTypeData extends CounterData { | 512 abstract static class AbstractTypeData extends CounterData { |
488 | |
489 protected static final int TYPE_DATA_ROW_SIZE = cellsToBytes(config.receiverTypeDataReceiverTypeRowCellCount); | |
490 | |
491 protected static final int NONPROFILED_COUNT_OFFSET = cellIndexToOffset(config.receiverTypeDataNonprofiledCountOffset); | |
492 protected static final int TYPE_DATA_FIRST_TYPE_OFFSET = cellIndexToOffset(config.receiverTypeDataReceiver0Offset); | |
493 protected static final int TYPE_DATA_FIRST_TYPE_COUNT_OFFSET = cellIndexToOffset(config.receiverTypeDataCount0Offset); | |
494 | 513 |
495 protected AbstractTypeData(Tag tag, int staticSize) { | 514 protected AbstractTypeData(Tag tag, int staticSize) { |
496 super(tag, staticSize); | 515 super(tag, staticSize); |
497 } | 516 } |
498 | 517 |
581 } | 600 } |
582 return sb; | 601 return sb; |
583 } | 602 } |
584 } | 603 } |
585 | 604 |
586 private static class ReceiverTypeData extends AbstractTypeData { | 605 static class ReceiverTypeData extends AbstractTypeData { |
587 | |
588 private static final int TYPE_CHECK_DATA_SIZE = cellIndexToOffset(2) + TYPE_DATA_ROW_SIZE * config.typeProfileWidth; | |
589 | 606 |
590 ReceiverTypeData() { | 607 ReceiverTypeData() { |
591 super(Tag.ReceiverTypeData, TYPE_CHECK_DATA_SIZE); | 608 super(Tag.ReceiverTypeData, TYPE_CHECK_DATA_SIZE); |
592 } | 609 } |
593 | 610 |
604 protected long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position) { | 621 protected long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position) { |
605 return data.readUnsignedIntAsSignedInt(position, NONPROFILED_COUNT_OFFSET); | 622 return data.readUnsignedIntAsSignedInt(position, NONPROFILED_COUNT_OFFSET); |
606 } | 623 } |
607 } | 624 } |
608 | 625 |
609 private static class VirtualCallData extends ReceiverTypeData { | 626 static class VirtualCallData extends ReceiverTypeData { |
610 | |
611 private static final int VIRTUAL_CALL_DATA_SIZE = cellIndexToOffset(2) + TYPE_DATA_ROW_SIZE * (config.typeProfileWidth + config.methodProfileWidth); | |
612 private static final int VIRTUAL_CALL_DATA_FIRST_METHOD_OFFSET = TYPE_DATA_FIRST_TYPE_OFFSET + TYPE_DATA_ROW_SIZE * config.typeProfileWidth; | |
613 private static final int VIRTUAL_CALL_DATA_FIRST_METHOD_COUNT_OFFSET = TYPE_DATA_FIRST_TYPE_COUNT_OFFSET + TYPE_DATA_ROW_SIZE * config.typeProfileWidth; | |
614 | 627 |
615 VirtualCallData() { | 628 VirtualCallData() { |
616 super(Tag.VirtualCallData, VIRTUAL_CALL_DATA_SIZE); | 629 super(Tag.VirtualCallData, VIRTUAL_CALL_DATA_SIZE); |
617 } | 630 } |
618 | 631 |
710 } | 723 } |
711 return sb; | 724 return sb; |
712 } | 725 } |
713 } | 726 } |
714 | 727 |
715 private static class VirtualCallTypeData extends VirtualCallData { | 728 static class VirtualCallTypeData extends VirtualCallData { |
716 | 729 |
717 VirtualCallTypeData() { | 730 VirtualCallTypeData() { |
718 super(Tag.VirtualCallTypeData, 0); | 731 super(Tag.VirtualCallTypeData, 0); |
719 } | 732 } |
720 | 733 |
723 assert staticSize == 0; | 736 assert staticSize == 0; |
724 return HotSpotJVMCIRuntime.runtime().compilerToVm.methodDataProfileDataSize(data.metaspaceMethodData, position); | 737 return HotSpotJVMCIRuntime.runtime().compilerToVm.methodDataProfileDataSize(data.metaspaceMethodData, position); |
725 } | 738 } |
726 } | 739 } |
727 | 740 |
728 private static class RetData extends CounterData { | 741 static class RetData extends CounterData { |
729 | |
730 private static final int RET_DATA_ROW_SIZE = cellsToBytes(3); | |
731 private static final int RET_DATA_SIZE = cellIndexToOffset(1) + RET_DATA_ROW_SIZE * config.bciProfileWidth; | |
732 | 742 |
733 RetData() { | 743 RetData() { |
734 super(Tag.RetData, RET_DATA_SIZE); | 744 super(Tag.RetData, RET_DATA_SIZE); |
735 } | 745 } |
736 } | 746 } |
737 | 747 |
738 private static class BranchData extends JumpData { | 748 static class BranchData extends JumpData { |
739 | |
740 private static final int BRANCH_DATA_SIZE = cellIndexToOffset(3); | |
741 private static final int NOT_TAKEN_COUNT_OFFSET = cellIndexToOffset(config.branchDataNotTakenOffset); | |
742 | 749 |
743 BranchData() { | 750 BranchData() { |
744 super(Tag.BranchData, BRANCH_DATA_SIZE); | 751 super(Tag.BranchData, BRANCH_DATA_SIZE); |
745 } | 752 } |
746 | 753 |
766 double takenProbability = getBranchTakenProbability(data, pos); | 773 double takenProbability = getBranchTakenProbability(data, pos); |
767 return sb.append(format("taken(%d, %4.2f) not_taken(%d, %4.2f) displacement(%d)", taken, takenProbability, notTaken, 1.0D - takenProbability, getTakenDisplacement(data, pos))); | 774 return sb.append(format("taken(%d, %4.2f) not_taken(%d, %4.2f) displacement(%d)", taken, takenProbability, notTaken, 1.0D - takenProbability, getTakenDisplacement(data, pos))); |
768 } | 775 } |
769 } | 776 } |
770 | 777 |
771 private static class ArrayData extends AbstractMethodData { | 778 static class ArrayData extends AbstractMethodData { |
772 | |
773 private static final int ARRAY_DATA_LENGTH_OFFSET = cellIndexToOffset(config.arrayDataArrayLenOffset); | |
774 protected static final int ARRAY_DATA_START_OFFSET = cellIndexToOffset(config.arrayDataArrayStartOffset); | |
775 | 779 |
776 ArrayData(Tag tag, int staticSize) { | 780 ArrayData(Tag tag, int staticSize) { |
777 super(tag, staticSize); | 781 super(tag, staticSize); |
778 } | 782 } |
779 | 783 |
790 public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { | 794 public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { |
791 return sb.append(format("length(%d)", getLength(data, pos))); | 795 return sb.append(format("length(%d)", getLength(data, pos))); |
792 } | 796 } |
793 } | 797 } |
794 | 798 |
795 private static class MultiBranchData extends ArrayData { | 799 static class MultiBranchData extends ArrayData { |
796 | |
797 private static final int MULTI_BRANCH_DATA_SIZE = cellIndexToOffset(1); | |
798 private static final int MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS = config.multiBranchDataPerCaseCellCount; | |
799 private static final int MULTI_BRANCH_DATA_ROW_SIZE = cellsToBytes(MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS); | |
800 private static final int MULTI_BRANCH_DATA_FIRST_COUNT_OFFSET = ARRAY_DATA_START_OFFSET + cellsToBytes(0); | |
801 private static final int MULTI_BRANCH_DATA_FIRST_DISPLACEMENT_OFFSET = ARRAY_DATA_START_OFFSET + cellsToBytes(1); | |
802 | 800 |
803 MultiBranchData() { | 801 MultiBranchData() { |
804 super(Tag.MultiBranchData, MULTI_BRANCH_DATA_SIZE); | 802 super(Tag.MultiBranchData, MULTI_BRANCH_DATA_SIZE); |
805 } | 803 } |
806 | 804 |
876 } | 874 } |
877 return sb; | 875 return sb; |
878 } | 876 } |
879 } | 877 } |
880 | 878 |
881 private static class ArgInfoData extends ArrayData { | 879 static class ArgInfoData extends ArrayData { |
882 | |
883 private static final int ARG_INFO_DATA_SIZE = cellIndexToOffset(1); | |
884 | 880 |
885 ArgInfoData() { | 881 ArgInfoData() { |
886 super(Tag.ArgInfoData, ARG_INFO_DATA_SIZE); | 882 super(Tag.ArgInfoData, ARG_INFO_DATA_SIZE); |
887 } | 883 } |
888 } | 884 } |
889 | 885 |
890 private static class UnknownProfileData extends AbstractMethodData { | 886 static class UnknownProfileData extends AbstractMethodData { |
891 UnknownProfileData(Tag tag) { | 887 UnknownProfileData(Tag tag) { |
892 super(tag, 0); | 888 super(tag, 0); |
893 } | 889 } |
894 | 890 |
895 @Override | 891 @Override |