|
Lines 18-23
Link Here
|
| 18 |
import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding; |
18 |
import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding; |
| 19 |
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; |
19 |
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; |
| 20 |
import org.eclipse.jdt.internal.compiler.lookup.TagBits; |
20 |
import org.eclipse.jdt.internal.compiler.lookup.TagBits; |
|
|
21 |
import org.eclipse.jdt.internal.compiler.lookup.VariableBinding; |
| 21 |
|
22 |
|
| 22 |
/** |
23 |
/** |
| 23 |
* Record initialization status during definite assignment analysis |
24 |
* Record initialization status during definite assignment analysis |
|
Lines 515-527
Link Here
|
| 515 |
return this; |
516 |
return this; |
| 516 |
} |
517 |
} |
| 517 |
|
518 |
|
| 518 |
final public boolean cannotBeDefinitelyNullOrNonNull(LocalVariableBinding local) { |
519 |
final public boolean cannotBeDefinitelyNullOrNonNull(VariableBinding local) { |
| 519 |
if ((this.tagBits & NULL_FLAG_MASK) == 0 || |
520 |
if ((this.tagBits & NULL_FLAG_MASK) == 0 || |
| 520 |
(local.type.tagBits & TagBits.IsBaseType) != 0) { |
521 |
(local.type.tagBits & TagBits.IsBaseType) != 0) { |
| 521 |
return false; |
522 |
return false; |
| 522 |
} |
523 |
} |
| 523 |
int position; |
524 |
int position; |
| 524 |
if ((position = local.id + this.maxFieldCount) < BitCacheSize) { |
525 |
if (local instanceof FieldBinding) { |
|
|
526 |
position = local.id; |
| 527 |
} else { |
| 528 |
position = local.id + this.maxFieldCount; |
| 529 |
} |
| 530 |
if (position < BitCacheSize) { |
| 525 |
// use bits |
531 |
// use bits |
| 526 |
return ( |
532 |
return ( |
| 527 |
(~this.nullBit1 |
533 |
(~this.nullBit1 |
|
Lines 546-558
Link Here
|
| 546 |
& (1L << (position % BitCacheSize))) != 0; |
552 |
& (1L << (position % BitCacheSize))) != 0; |
| 547 |
} |
553 |
} |
| 548 |
|
554 |
|
| 549 |
final public boolean cannotBeNull(LocalVariableBinding local) { |
555 |
final public boolean cannotBeNull(VariableBinding local) { |
| 550 |
if ((this.tagBits & NULL_FLAG_MASK) == 0 || |
556 |
if ((this.tagBits & NULL_FLAG_MASK) == 0 || |
| 551 |
(local.type.tagBits & TagBits.IsBaseType) != 0) { |
557 |
(local.type.tagBits & TagBits.IsBaseType) != 0) { |
| 552 |
return false; |
558 |
return false; |
| 553 |
} |
559 |
} |
| 554 |
int position; |
560 |
int position; |
| 555 |
if ((position = local.id + this.maxFieldCount) < BitCacheSize) { |
561 |
if (local instanceof FieldBinding) { |
|
|
562 |
position = local.id; |
| 563 |
} else { |
| 564 |
position = local.id + this.maxFieldCount; |
| 565 |
} |
| 566 |
if (position < BitCacheSize) { |
| 556 |
// use bits |
567 |
// use bits |
| 557 |
return (this.nullBit1 & this.nullBit3 |
568 |
return (this.nullBit1 & this.nullBit3 |
| 558 |
& ((this.nullBit2 & this.nullBit4) | ~this.nullBit2) |
569 |
& ((this.nullBit2 & this.nullBit4) | ~this.nullBit2) |
|
Lines 573-585
Link Here
|
| 573 |
& (1L << (position % BitCacheSize))) != 0; |
584 |
& (1L << (position % BitCacheSize))) != 0; |
| 574 |
} |
585 |
} |
| 575 |
|
586 |
|
| 576 |
final public boolean canOnlyBeNull(LocalVariableBinding local) { |
587 |
final public boolean canOnlyBeNull(VariableBinding local) { |
| 577 |
if ((this.tagBits & NULL_FLAG_MASK) == 0 || |
588 |
if ((this.tagBits & NULL_FLAG_MASK) == 0 || |
| 578 |
(local.type.tagBits & TagBits.IsBaseType) != 0) { |
589 |
(local.type.tagBits & TagBits.IsBaseType) != 0) { |
| 579 |
return false; |
590 |
return false; |
| 580 |
} |
591 |
} |
| 581 |
int position; |
592 |
int position; |
| 582 |
if ((position = local.id + this.maxFieldCount) < BitCacheSize) { |
593 |
if (local instanceof FieldBinding) { |
|
|
594 |
position = local.id; |
| 595 |
} else { |
| 596 |
position = local.id + this.maxFieldCount; |
| 597 |
} |
| 598 |
if (position < BitCacheSize) { |
| 583 |
// use bits |
599 |
// use bits |
| 584 |
return (this.nullBit1 & this.nullBit2 |
600 |
return (this.nullBit1 & this.nullBit2 |
| 585 |
& (~this.nullBit3 | ~this.nullBit4) |
601 |
& (~this.nullBit3 | ~this.nullBit4) |
|
Lines 664-673
Link Here
|
| 664 |
* Remove local variables information from this flow info and return this. |
680 |
* Remove local variables information from this flow info and return this. |
| 665 |
* @return this, deprived from any local variable information |
681 |
* @return this, deprived from any local variable information |
| 666 |
*/ |
682 |
*/ |
| 667 |
public UnconditionalFlowInfo discardNonFieldInitializations() { |
683 |
public UnconditionalFlowInfo discardNonFieldInitializations(int fieldStart) { |
| 668 |
int limit = this.maxFieldCount; |
684 |
int limit = this.maxFieldCount; |
| 669 |
if (limit < BitCacheSize) { |
685 |
if (limit < BitCacheSize) { |
| 670 |
long mask = (1L << limit)-1; |
686 |
long mask = (1L << limit)-1; |
|
|
687 |
//mask = mask & (-1L << fieldStart); |
| 671 |
this.definiteInits &= mask; |
688 |
this.definiteInits &= mask; |
| 672 |
this.potentialInits &= mask; |
689 |
this.potentialInits &= mask; |
| 673 |
this.nullBit1 &= mask; |
690 |
this.nullBit1 &= mask; |
|
Lines 745-751
Link Here
|
| 745 |
return isDefinitelyAssigned(local.id + this.maxFieldCount); |
762 |
return isDefinitelyAssigned(local.id + this.maxFieldCount); |
| 746 |
} |
763 |
} |
| 747 |
|
764 |
|
| 748 |
final public boolean isDefinitelyNonNull(LocalVariableBinding local) { |
765 |
final public boolean isDefinitelyNonNull(VariableBinding local) { |
|
|
766 |
if (local instanceof FieldBinding && (this.tagBits & NULL_FLAG_MASK) == 0) { |
| 767 |
// no local yet in scope. Came here because of a field being queried for non null |
| 768 |
// will only happen for final fields, since they are assigned in a constructor or static block |
| 769 |
// and we may currently be in some other method |
| 770 |
this.tagBits |= NULL_FLAG_MASK; |
| 771 |
} |
| 749 |
// do not want to complain in unreachable code |
772 |
// do not want to complain in unreachable code |
| 750 |
if ((this.tagBits & UNREACHABLE) != 0 || |
773 |
if ((this.tagBits & UNREACHABLE) != 0 || |
| 751 |
(this.tagBits & NULL_FLAG_MASK) == 0) { |
774 |
(this.tagBits & NULL_FLAG_MASK) == 0) { |
|
Lines 755-761
Link Here
|
| 755 |
local.constant() != Constant.NotAConstant) { // String instances |
778 |
local.constant() != Constant.NotAConstant) { // String instances |
| 756 |
return true; |
779 |
return true; |
| 757 |
} |
780 |
} |
| 758 |
int position = local.id + this.maxFieldCount; |
781 |
int position; |
|
|
782 |
if (local instanceof FieldBinding) { |
| 783 |
if (local.isFinal() && ((FieldBinding)local).isStatic()) { |
| 784 |
// static final field's null status may not be in the flow info |
| 785 |
return (((FieldBinding) local).getNullStatusForStaticFinalField() == FlowInfo.NON_NULL); |
| 786 |
} |
| 787 |
position = local.id; |
| 788 |
} else { |
| 789 |
position = local.id + this.maxFieldCount; |
| 790 |
} |
| 759 |
if (position < BitCacheSize) { // use bits |
791 |
if (position < BitCacheSize) { // use bits |
| 760 |
return ((this.nullBit1 & this.nullBit3 & (~this.nullBit2 | this.nullBit4)) |
792 |
return ((this.nullBit1 & this.nullBit3 & (~this.nullBit2 | this.nullBit4)) |
| 761 |
& (1L << position)) != 0; |
793 |
& (1L << position)) != 0; |
|
Lines 774-787
Link Here
|
| 774 |
& (1L << (position % BitCacheSize))) != 0; |
806 |
& (1L << (position % BitCacheSize))) != 0; |
| 775 |
} |
807 |
} |
| 776 |
|
808 |
|
| 777 |
final public boolean isDefinitelyNull(LocalVariableBinding local) { |
809 |
final public boolean isDefinitelyNull(VariableBinding local) { |
|
|
810 |
if (local instanceof FieldBinding && (this.tagBits & NULL_FLAG_MASK) == 0) { |
| 811 |
// no local yet in scope. Came here because of a field being queried for non null |
| 812 |
// will only happen for final fields, since they are assigned in a constructor or static block |
| 813 |
// and we may currently be in some other method |
| 814 |
this.tagBits |= NULL_FLAG_MASK; |
| 815 |
} |
| 778 |
// do not want to complain in unreachable code |
816 |
// do not want to complain in unreachable code |
| 779 |
if ((this.tagBits & UNREACHABLE) != 0 || |
817 |
if ((this.tagBits & UNREACHABLE) != 0 || |
| 780 |
(this.tagBits & NULL_FLAG_MASK) == 0 || |
818 |
(this.tagBits & NULL_FLAG_MASK) == 0 || |
| 781 |
(local.type.tagBits & TagBits.IsBaseType) != 0) { |
819 |
(local.type.tagBits & TagBits.IsBaseType) != 0) { |
| 782 |
return false; |
820 |
return false; |
| 783 |
} |
821 |
} |
| 784 |
int position = local.id + this.maxFieldCount; |
822 |
int position; |
|
|
823 |
if (local instanceof FieldBinding) { |
| 824 |
if (local.isFinal() && ((FieldBinding)local).isStatic()) { |
| 825 |
// static final field's null status may not be in the flow info |
| 826 |
return (((FieldBinding) local).getNullStatusForStaticFinalField() == FlowInfo.NULL); |
| 827 |
} |
| 828 |
position = local.id; |
| 829 |
} else { |
| 830 |
position = local.id + this.maxFieldCount; |
| 831 |
} |
| 785 |
if (position < BitCacheSize) { // use bits |
832 |
if (position < BitCacheSize) { // use bits |
| 786 |
return ((this.nullBit1 & this.nullBit2 |
833 |
return ((this.nullBit1 & this.nullBit2 |
| 787 |
& (~this.nullBit3 | ~this.nullBit4)) |
834 |
& (~this.nullBit3 | ~this.nullBit4)) |
|
Lines 801-813
Link Here
|
| 801 |
& (1L << (position % BitCacheSize))) != 0; |
848 |
& (1L << (position % BitCacheSize))) != 0; |
| 802 |
} |
849 |
} |
| 803 |
|
850 |
|
| 804 |
final public boolean isDefinitelyUnknown(LocalVariableBinding local) { |
851 |
final public boolean isDefinitelyUnknown(VariableBinding local) { |
| 805 |
// do not want to complain in unreachable code |
852 |
// do not want to complain in unreachable code |
| 806 |
if ((this.tagBits & UNREACHABLE) != 0 || |
853 |
if ((this.tagBits & UNREACHABLE) != 0 || |
| 807 |
(this.tagBits & NULL_FLAG_MASK) == 0) { |
854 |
(this.tagBits & NULL_FLAG_MASK) == 0) { |
| 808 |
return false; |
855 |
return false; |
| 809 |
} |
856 |
} |
| 810 |
int position = local.id + this.maxFieldCount; |
857 |
int position; |
|
|
858 |
if (local instanceof FieldBinding) { |
| 859 |
position = local.id; |
| 860 |
} else { |
| 861 |
position = local.id + this.maxFieldCount; |
| 862 |
} |
| 811 |
if (position < BitCacheSize) { // use bits |
863 |
if (position < BitCacheSize) { // use bits |
| 812 |
return ((this.nullBit1 & this.nullBit4 |
864 |
return ((this.nullBit1 & this.nullBit4 |
| 813 |
& ~this.nullBit2 & ~this.nullBit3) & (1L << position)) != 0; |
865 |
& ~this.nullBit2 & ~this.nullBit3) & (1L << position)) != 0; |
|
Lines 860-872
Link Here
|
| 860 |
return isPotentiallyAssigned(local.id + this.maxFieldCount); |
912 |
return isPotentiallyAssigned(local.id + this.maxFieldCount); |
| 861 |
} |
913 |
} |
| 862 |
|
914 |
|
| 863 |
final public boolean isPotentiallyNonNull(LocalVariableBinding local) { |
915 |
final public boolean isPotentiallyNonNull(VariableBinding local) { |
| 864 |
if ((this.tagBits & NULL_FLAG_MASK) == 0 || |
916 |
if ((this.tagBits & NULL_FLAG_MASK) == 0 || |
| 865 |
(local.type.tagBits & TagBits.IsBaseType) != 0) { |
917 |
(local.type.tagBits & TagBits.IsBaseType) != 0) { |
| 866 |
return false; |
918 |
return false; |
| 867 |
} |
919 |
} |
| 868 |
int position; |
920 |
int position; |
| 869 |
if ((position = local.id + this.maxFieldCount) < BitCacheSize) { |
921 |
if (local instanceof FieldBinding) { |
|
|
922 |
position = local.id; |
| 923 |
} else { |
| 924 |
position = local.id + this.maxFieldCount; |
| 925 |
} |
| 926 |
if (position < BitCacheSize) { // use bits |
| 870 |
// use bits |
927 |
// use bits |
| 871 |
return ((this.nullBit3 & (~this.nullBit1 | ~this.nullBit2)) |
928 |
return ((this.nullBit3 & (~this.nullBit1 | ~this.nullBit2)) |
| 872 |
& (1L << position)) != 0; |
929 |
& (1L << position)) != 0; |
|
Lines 885-897
Link Here
|
| 885 |
& (1L << (position % BitCacheSize))) != 0; |
942 |
& (1L << (position % BitCacheSize))) != 0; |
| 886 |
} |
943 |
} |
| 887 |
|
944 |
|
| 888 |
final public boolean isPotentiallyNull(LocalVariableBinding local) { |
945 |
final public boolean isPotentiallyNull(VariableBinding local) { |
| 889 |
if ((this.tagBits & NULL_FLAG_MASK) == 0 || |
946 |
if ((this.tagBits & NULL_FLAG_MASK) == 0 || |
| 890 |
(local.type.tagBits & TagBits.IsBaseType) != 0) { |
947 |
(local.type.tagBits & TagBits.IsBaseType) != 0) { |
| 891 |
return false; |
948 |
return false; |
| 892 |
} |
949 |
} |
| 893 |
int position; |
950 |
int position; |
| 894 |
if ((position = local.id + this.maxFieldCount) < BitCacheSize) { |
951 |
if (local instanceof FieldBinding) { |
|
|
952 |
if (local.isFinal() && ((FieldBinding)local).isStatic()) { |
| 953 |
// static final field's null status may not be in the flow info |
| 954 |
return (((FieldBinding) local).getNullStatusForStaticFinalField() == FlowInfo.POTENTIALLY_NULL); |
| 955 |
} |
| 956 |
position = local.id; |
| 957 |
} else { |
| 958 |
position = local.id + this.maxFieldCount; |
| 959 |
} |
| 960 |
if (position < BitCacheSize) { |
| 895 |
// use bits |
961 |
// use bits |
| 896 |
return ((this.nullBit2 & (~this.nullBit1 | ~this.nullBit3)) |
962 |
return ((this.nullBit2 & (~this.nullBit1 | ~this.nullBit3)) |
| 897 |
& (1L << position)) != 0; |
963 |
& (1L << position)) != 0; |
|
Lines 910-922
Link Here
|
| 910 |
& (1L << (position % BitCacheSize))) != 0; |
976 |
& (1L << (position % BitCacheSize))) != 0; |
| 911 |
} |
977 |
} |
| 912 |
|
978 |
|
| 913 |
final public boolean isPotentiallyUnknown(LocalVariableBinding local) { |
979 |
final public boolean isPotentiallyUnknown(VariableBinding local) { |
| 914 |
// do not want to complain in unreachable code |
980 |
// do not want to complain in unreachable code |
| 915 |
if ((this.tagBits & UNREACHABLE) != 0 || |
981 |
if ((this.tagBits & UNREACHABLE) != 0 || |
| 916 |
(this.tagBits & NULL_FLAG_MASK) == 0) { |
982 |
(this.tagBits & NULL_FLAG_MASK) == 0) { |
| 917 |
return false; |
983 |
return false; |
| 918 |
} |
984 |
} |
| 919 |
int position = local.id + this.maxFieldCount; |
985 |
int position; |
|
|
986 |
if (local instanceof FieldBinding) { |
| 987 |
position = local.id; |
| 988 |
} else { |
| 989 |
position = local.id + this.maxFieldCount; |
| 990 |
} |
| 920 |
if (position < BitCacheSize) { // use bits |
991 |
if (position < BitCacheSize) { // use bits |
| 921 |
return (this.nullBit4 |
992 |
return (this.nullBit4 |
| 922 |
& (~this.nullBit1 | ~this.nullBit2 & ~this.nullBit3) |
993 |
& (~this.nullBit1 | ~this.nullBit2 & ~this.nullBit3) |
|
Lines 937-950
Link Here
|
| 937 |
& (1L << (position % BitCacheSize))) != 0; |
1008 |
& (1L << (position % BitCacheSize))) != 0; |
| 938 |
} |
1009 |
} |
| 939 |
|
1010 |
|
| 940 |
final public boolean isProtectedNonNull(LocalVariableBinding local) { |
1011 |
final public boolean isProtectedNonNull(VariableBinding local) { |
| 941 |
if ((this.tagBits & NULL_FLAG_MASK) == 0 || |
1012 |
if ((this.tagBits & NULL_FLAG_MASK) == 0 || |
| 942 |
(local.type.tagBits & TagBits.IsBaseType) != 0) { |
1013 |
(local.type.tagBits & TagBits.IsBaseType) != 0) { |
| 943 |
return false; |
1014 |
return false; |
| 944 |
} |
1015 |
} |
| 945 |
int position; |
1016 |
int position; |
| 946 |
if ((position = local.id + this.maxFieldCount) < BitCacheSize) { |
1017 |
if (local instanceof FieldBinding) { |
| 947 |
// use bits |
1018 |
position = local.id; |
|
|
1019 |
} else { |
| 1020 |
position = local.id + this.maxFieldCount; |
| 1021 |
} |
| 1022 |
if (position < BitCacheSize) { // use bits |
| 948 |
return (this.nullBit1 & this.nullBit3 & this.nullBit4 & (1L << position)) != 0; |
1023 |
return (this.nullBit1 & this.nullBit3 & this.nullBit4 & (1L << position)) != 0; |
| 949 |
} |
1024 |
} |
| 950 |
// use extra vector |
1025 |
// use extra vector |
|
Lines 962-974
Link Here
|
| 962 |
& (1L << (position % BitCacheSize))) != 0; |
1037 |
& (1L << (position % BitCacheSize))) != 0; |
| 963 |
} |
1038 |
} |
| 964 |
|
1039 |
|
| 965 |
final public boolean isProtectedNull(LocalVariableBinding local) { |
1040 |
final public boolean isProtectedNull(VariableBinding local) { |
| 966 |
if ((this.tagBits & NULL_FLAG_MASK) == 0 || |
1041 |
if ((this.tagBits & NULL_FLAG_MASK) == 0 || |
| 967 |
(local.type.tagBits & TagBits.IsBaseType) != 0) { |
1042 |
(local.type.tagBits & TagBits.IsBaseType) != 0) { |
| 968 |
return false; |
1043 |
return false; |
| 969 |
} |
1044 |
} |
| 970 |
int position; |
1045 |
int position; |
| 971 |
if ((position = local.id + this.maxFieldCount) < BitCacheSize) { |
1046 |
if (local instanceof FieldBinding) { |
|
|
1047 |
position = local.id; |
| 1048 |
} else { |
| 1049 |
position = local.id + this.maxFieldCount; |
| 1050 |
} |
| 1051 |
if (position < BitCacheSize) { |
| 972 |
// use bits |
1052 |
// use bits |
| 973 |
return (this.nullBit1 & this.nullBit2 |
1053 |
return (this.nullBit1 & this.nullBit2 |
| 974 |
& (this.nullBit3 ^ this.nullBit4) |
1054 |
& (this.nullBit3 ^ this.nullBit4) |
|
Lines 1001-1015
Link Here
|
| 1001 |
throw new AssertionFailedException("assertion failed: " + message); //$NON-NLS-1$ |
1081 |
throw new AssertionFailedException("assertion failed: " + message); //$NON-NLS-1$ |
| 1002 |
return expression; |
1082 |
return expression; |
| 1003 |
} |
1083 |
} |
| 1004 |
public void markAsComparedEqualToNonNull(LocalVariableBinding local) { |
1084 |
public void markAsComparedEqualToNonNull(VariableBinding local) { |
| 1005 |
// protected from non-object locals in calling methods |
1085 |
// protected from non-object locals in calling methods |
| 1006 |
if (this != DEAD_END) { |
1086 |
if (this != DEAD_END) { |
| 1007 |
this.tagBits |= NULL_FLAG_MASK; |
1087 |
this.tagBits |= NULL_FLAG_MASK; |
| 1008 |
int position; |
1088 |
int position; |
|
|
1089 |
if (local instanceof FieldBinding) { |
| 1090 |
this.markNullStatus(local, FlowInfo.POTENTIALLY_NON_NULL); |
| 1091 |
return; |
| 1092 |
} else { |
| 1093 |
position = local.id + this.maxFieldCount; |
| 1094 |
} |
| 1009 |
long mask; |
1095 |
long mask; |
| 1010 |
long a1, a2, a3, a4, na2; |
1096 |
long a1, a2, a3, a4, na2; |
| 1011 |
// position is zero-based |
1097 |
// position is zero-based |
| 1012 |
if ((position = local.id + this.maxFieldCount) < BitCacheSize) { |
1098 |
if (position < BitCacheSize) { |
| 1013 |
// use bits |
1099 |
// use bits |
| 1014 |
if (((mask = 1L << position) |
1100 |
if (((mask = 1L << position) |
| 1015 |
& (a1 = this.nullBit1) |
1101 |
& (a1 = this.nullBit1) |
|
Lines 1098-1111
Link Here
|
| 1098 |
} |
1184 |
} |
| 1099 |
} |
1185 |
} |
| 1100 |
|
1186 |
|
| 1101 |
public void markAsComparedEqualToNull(LocalVariableBinding local) { |
1187 |
public void markAsComparedEqualToNull(VariableBinding local) { |
| 1102 |
// protected from non-object locals in calling methods |
1188 |
// protected from non-object locals in calling methods |
| 1103 |
if (this != DEAD_END) { |
1189 |
if (this != DEAD_END) { |
| 1104 |
this.tagBits |= NULL_FLAG_MASK; |
1190 |
this.tagBits |= NULL_FLAG_MASK; |
| 1105 |
int position; |
1191 |
int position; |
| 1106 |
long mask; |
1192 |
long mask; |
| 1107 |
// position is zero-based |
1193 |
// position is zero-based |
| 1108 |
if ((position = local.id + this.maxFieldCount) < BitCacheSize) { |
1194 |
if (local instanceof FieldBinding) { |
|
|
1195 |
this.markNullStatus(local, FlowInfo.POTENTIALLY_NULL); |
| 1196 |
return; |
| 1197 |
} else { |
| 1198 |
position = local.id + this.maxFieldCount; |
| 1199 |
} |
| 1200 |
if (position < BitCacheSize) { |
| 1109 |
// use bits |
1201 |
// use bits |
| 1110 |
if (((mask = 1L << position) & this.nullBit1) != 0) { |
1202 |
if (((mask = 1L << position) & this.nullBit1) != 0) { |
| 1111 |
if ((mask |
1203 |
if ((mask |
|
Lines 1236-1249
Link Here
|
| 1236 |
markAsDefinitelyAssigned(local.id + this.maxFieldCount); |
1328 |
markAsDefinitelyAssigned(local.id + this.maxFieldCount); |
| 1237 |
} |
1329 |
} |
| 1238 |
|
1330 |
|
| 1239 |
public void markAsDefinitelyNonNull(LocalVariableBinding local) { |
1331 |
public void markAsDefinitelyNonNull(VariableBinding local) { |
| 1240 |
// protected from non-object locals in calling methods |
1332 |
// protected from non-object locals in calling methods |
| 1241 |
if (this != DEAD_END) { |
1333 |
if (this != DEAD_END) { |
| 1242 |
this.tagBits |= NULL_FLAG_MASK; |
1334 |
this.tagBits |= NULL_FLAG_MASK; |
| 1243 |
long mask; |
1335 |
long mask; |
| 1244 |
int position; |
1336 |
int position; |
|
|
1337 |
if (local instanceof FieldBinding) { |
| 1338 |
this.markNullStatus(local, FlowInfo.POTENTIALLY_NON_NULL); |
| 1339 |
return; |
| 1340 |
} else { |
| 1341 |
position = local.id + this.maxFieldCount; |
| 1342 |
} |
| 1245 |
// position is zero-based |
1343 |
// position is zero-based |
| 1246 |
if ((position = local.id + this.maxFieldCount) < BitCacheSize) { // use bits |
1344 |
if (position < BitCacheSize) { // use bits |
| 1247 |
// set assigned non null |
1345 |
// set assigned non null |
| 1248 |
this.nullBit1 |= (mask = 1L << position); |
1346 |
this.nullBit1 |= (mask = 1L << position); |
| 1249 |
this.nullBit3 |= mask; |
1347 |
this.nullBit3 |= mask; |
|
Lines 1258-1265
Link Here
|
| 1258 |
} |
1356 |
} |
| 1259 |
else { |
1357 |
else { |
| 1260 |
// use extra vector |
1358 |
// use extra vector |
| 1261 |
int vectorIndex ; |
1359 |
int vectorIndex = (position / BitCacheSize) - 1; |
| 1262 |
this.extra[2][vectorIndex = (position / BitCacheSize) - 1] |
1360 |
if (this.extra == null) { |
|
|
1361 |
int length = vectorIndex + 1; |
| 1362 |
this.extra = new long[extraLength][]; |
| 1363 |
for (int j = 0; j < extraLength; j++) { |
| 1364 |
this.extra[j] = new long[length]; |
| 1365 |
} |
| 1366 |
} |
| 1367 |
else { |
| 1368 |
int oldLength; // might need to grow the arrays |
| 1369 |
if (vectorIndex >= (oldLength = this.extra[0].length)) { |
| 1370 |
for (int j = 0; j < extraLength; j++) { |
| 1371 |
System.arraycopy(this.extra[j], 0, |
| 1372 |
(this.extra[j] = new long[vectorIndex + 1]), 0, |
| 1373 |
oldLength); |
| 1374 |
} |
| 1375 |
} |
| 1376 |
} |
| 1377 |
this.extra[2][vectorIndex] |
| 1263 |
|= (mask = 1L << (position % BitCacheSize)); |
1378 |
|= (mask = 1L << (position % BitCacheSize)); |
| 1264 |
this.extra[4][vectorIndex] |= mask; |
1379 |
this.extra[4][vectorIndex] |= mask; |
| 1265 |
this.extra[3][vectorIndex] &= (mask = ~mask); |
1380 |
this.extra[3][vectorIndex] &= (mask = ~mask); |
|
Lines 1273-1286
Link Here
|
| 1273 |
} |
1388 |
} |
| 1274 |
} |
1389 |
} |
| 1275 |
|
1390 |
|
| 1276 |
public void markAsDefinitelyNull(LocalVariableBinding local) { |
1391 |
public void markAsDefinitelyNull(VariableBinding local) { |
| 1277 |
// protected from non-object locals in calling methods |
1392 |
// protected from non-object locals in calling methods |
| 1278 |
if (this != DEAD_END) { |
1393 |
if (this != DEAD_END) { |
| 1279 |
this.tagBits |= NULL_FLAG_MASK; |
1394 |
this.tagBits |= NULL_FLAG_MASK; |
| 1280 |
long mask; |
1395 |
long mask; |
| 1281 |
int position; |
1396 |
int position; |
|
|
1397 |
if (local instanceof FieldBinding) { |
| 1398 |
this.markNullStatus(local, FlowInfo.POTENTIALLY_NULL); |
| 1399 |
return; |
| 1400 |
} else { |
| 1401 |
position = local.id + this.maxFieldCount; |
| 1402 |
} |
| 1282 |
// position is zero-based |
1403 |
// position is zero-based |
| 1283 |
if ((position = local.id + this.maxFieldCount) < BitCacheSize) { // use bits |
1404 |
if (position < BitCacheSize) { // use bits |
| 1284 |
// mark assigned null |
1405 |
// mark assigned null |
| 1285 |
this.nullBit1 |= (mask = 1L << position); |
1406 |
this.nullBit1 |= (mask = 1L << position); |
| 1286 |
this.nullBit2 |= mask; |
1407 |
this.nullBit2 |= mask; |
|
Lines 1295-1302
Link Here
|
| 1295 |
} |
1416 |
} |
| 1296 |
else { |
1417 |
else { |
| 1297 |
// use extra vector |
1418 |
// use extra vector |
| 1298 |
int vectorIndex ; |
1419 |
int vectorIndex = (position / BitCacheSize) - 1; |
| 1299 |
this.extra[2][vectorIndex = (position / BitCacheSize) - 1] |
1420 |
if (this.extra == null) { |
|
|
1421 |
int length = vectorIndex + 1; |
| 1422 |
this.extra = new long[extraLength][]; |
| 1423 |
for (int j = 0; j < extraLength; j++) { |
| 1424 |
this.extra[j] = new long[length]; |
| 1425 |
} |
| 1426 |
} |
| 1427 |
else { |
| 1428 |
int oldLength; // might need to grow the arrays |
| 1429 |
if (vectorIndex >= (oldLength = this.extra[0].length)) { |
| 1430 |
for (int j = 0; j < extraLength; j++) { |
| 1431 |
System.arraycopy(this.extra[j], 0, |
| 1432 |
(this.extra[j] = new long[vectorIndex + 1]), 0, |
| 1433 |
oldLength); |
| 1434 |
} |
| 1435 |
} |
| 1436 |
} |
| 1437 |
this.extra[2][vectorIndex] |
| 1300 |
|= (mask = 1L << (position % BitCacheSize)); |
1438 |
|= (mask = 1L << (position % BitCacheSize)); |
| 1301 |
this.extra[3][vectorIndex] |= mask; |
1439 |
this.extra[3][vectorIndex] |= mask; |
| 1302 |
this.extra[4][vectorIndex] &= (mask = ~mask); |
1440 |
this.extra[4][vectorIndex] &= (mask = ~mask); |
|
Lines 1316-1329
Link Here
|
| 1316 |
*/ |
1454 |
*/ |
| 1317 |
// PREMATURE may try to get closer to markAsDefinitelyAssigned, but not |
1455 |
// PREMATURE may try to get closer to markAsDefinitelyAssigned, but not |
| 1318 |
// obvious |
1456 |
// obvious |
| 1319 |
public void markAsDefinitelyUnknown(LocalVariableBinding local) { |
1457 |
public void markAsDefinitelyUnknown(VariableBinding local) { |
| 1320 |
// protected from non-object locals in calling methods |
1458 |
// protected from non-object locals in calling methods |
| 1321 |
if (this != DEAD_END) { |
1459 |
if (this != DEAD_END) { |
| 1322 |
this.tagBits |= NULL_FLAG_MASK; |
1460 |
this.tagBits |= NULL_FLAG_MASK; |
| 1323 |
long mask; |
1461 |
long mask; |
| 1324 |
int position; |
1462 |
int position; |
|
|
1463 |
if (local instanceof FieldBinding) { |
| 1464 |
position = local.id; |
| 1465 |
} else { |
| 1466 |
position = local.id + this.maxFieldCount; |
| 1467 |
} |
| 1325 |
// position is zero-based |
1468 |
// position is zero-based |
| 1326 |
if ((position = local.id + this.maxFieldCount) < BitCacheSize) { |
1469 |
if (position < BitCacheSize) { |
| 1327 |
// use bits |
1470 |
// use bits |
| 1328 |
// mark assigned null |
1471 |
// mark assigned null |
| 1329 |
this.nullBit1 |= (mask = 1L << position); |
1472 |
this.nullBit1 |= (mask = 1L << position); |
|
Lines 1339-1346
Link Here
|
| 1339 |
} |
1482 |
} |
| 1340 |
else { |
1483 |
else { |
| 1341 |
// use extra vector |
1484 |
// use extra vector |
| 1342 |
int vectorIndex ; |
1485 |
int vectorIndex = (position / BitCacheSize) - 1; |
| 1343 |
this.extra[2][vectorIndex = (position / BitCacheSize) - 1] |
1486 |
if (this.extra == null) { |
|
|
1487 |
int length = vectorIndex + 1; |
| 1488 |
this.extra = new long[extraLength][]; |
| 1489 |
for (int j = 0; j < extraLength; j++) { |
| 1490 |
this.extra[j] = new long[length]; |
| 1491 |
} |
| 1492 |
} |
| 1493 |
else { |
| 1494 |
int oldLength; // might need to grow the arrays |
| 1495 |
if (vectorIndex >= (oldLength = this.extra[0].length)) { |
| 1496 |
for (int j = 0; j < extraLength; j++) { |
| 1497 |
System.arraycopy(this.extra[j], 0, |
| 1498 |
(this.extra[j] = new long[vectorIndex + 1]), 0, |
| 1499 |
oldLength); |
| 1500 |
} |
| 1501 |
} |
| 1502 |
} |
| 1503 |
this.extra[2][vectorIndex] |
| 1344 |
|= (mask = 1L << (position % BitCacheSize)); |
1504 |
|= (mask = 1L << (position % BitCacheSize)); |
| 1345 |
this.extra[5][vectorIndex] |= mask; |
1505 |
this.extra[5][vectorIndex] |= mask; |
| 1346 |
this.extra[3][vectorIndex] &= (mask = ~mask); |
1506 |
this.extra[3][vectorIndex] &= (mask = ~mask); |
|
Lines 1354-1365
Link Here
|
| 1354 |
} |
1514 |
} |
| 1355 |
} |
1515 |
} |
| 1356 |
|
1516 |
|
| 1357 |
public void resetNullInfo(LocalVariableBinding local) { |
1517 |
public void resetNullInfo(VariableBinding local) { |
| 1358 |
if (this != DEAD_END) { |
1518 |
if (this != DEAD_END) { |
| 1359 |
this.tagBits |= NULL_FLAG_MASK; |
1519 |
this.tagBits |= NULL_FLAG_MASK; |
| 1360 |
int position; |
1520 |
int position; |
| 1361 |
long mask; |
1521 |
long mask; |
| 1362 |
if ((position = local.id + this.maxFieldCount) < BitCacheSize) { |
1522 |
if (local instanceof FieldBinding) { |
|
|
1523 |
position = local.id; |
| 1524 |
} else { |
| 1525 |
position = local.id + this.maxFieldCount; |
| 1526 |
} |
| 1527 |
if (position < BitCacheSize) { |
| 1363 |
// use bits |
1528 |
// use bits |
| 1364 |
this.nullBit1 &= (mask = ~(1L << position)); |
1529 |
this.nullBit1 &= (mask = ~(1L << position)); |
| 1365 |
this.nullBit2 &= mask; |
1530 |
this.nullBit2 &= mask; |
|
Lines 1381-1398
Link Here
|
| 1381 |
} |
1546 |
} |
| 1382 |
} |
1547 |
} |
| 1383 |
} |
1548 |
} |
|
|
1549 |
public void resetNullInfoForFields() { |
| 1550 |
if (this != DEAD_END) { |
| 1551 |
long mask; |
| 1552 |
if (this.maxFieldCount < BitCacheSize) { |
| 1553 |
// use bits |
| 1554 |
this.nullBit1 &= (mask = -1L << this.maxFieldCount); |
| 1555 |
this.nullBit2 &= mask; |
| 1556 |
this.nullBit3 &= mask; |
| 1557 |
this.nullBit4 &= mask; |
| 1558 |
} |
| 1559 |
else { |
| 1560 |
this.nullBit1 &= (mask = 0L); |
| 1561 |
this.nullBit2 &= mask; |
| 1562 |
this.nullBit3 &= mask; |
| 1563 |
this.nullBit4 &= mask; |
| 1564 |
if (this.extra != null){ |
| 1565 |
for (int position = BitCacheSize; position < this.maxFieldCount; position++) { |
| 1566 |
// use extra vector |
| 1567 |
int vectorIndex = (position / BitCacheSize) - 1; |
| 1568 |
if (vectorIndex >= this.extra[2].length) |
| 1569 |
break; // No null info about fields beyond this point in the extra vector |
| 1570 |
this.extra[2][vectorIndex] |
| 1571 |
&= (mask = ~(1L << (position % BitCacheSize))); |
| 1572 |
this.extra[3][vectorIndex] &= mask; |
| 1573 |
this.extra[4][vectorIndex] &= mask; |
| 1574 |
this.extra[5][vectorIndex] &= mask; |
| 1575 |
} |
| 1576 |
} |
| 1577 |
} |
| 1578 |
} |
| 1579 |
} |
| 1384 |
|
1580 |
|
| 1385 |
/** |
1581 |
/** |
| 1386 |
* Mark a local as potentially having been assigned to an unknown value. |
1582 |
* Mark a local as potentially having been assigned to an unknown value. |
| 1387 |
* @param local the local to mark |
1583 |
* @param local the local to mark |
| 1388 |
*/ |
1584 |
*/ |
| 1389 |
public void markPotentiallyUnknownBit(LocalVariableBinding local) { |
1585 |
public void markPotentiallyUnknownBit(VariableBinding local) { |
| 1390 |
// protected from non-object locals in calling methods |
1586 |
// protected from non-object locals in calling methods |
| 1391 |
if (this != DEAD_END) { |
1587 |
if (this != DEAD_END) { |
| 1392 |
this.tagBits |= NULL_FLAG_MASK; |
1588 |
this.tagBits |= NULL_FLAG_MASK; |
| 1393 |
int position; |
1589 |
int position; |
| 1394 |
long mask; |
1590 |
long mask; |
| 1395 |
if ((position = local.id + this.maxFieldCount) < BitCacheSize) { |
1591 |
if (local instanceof FieldBinding) { |
|
|
1592 |
position = local.id; |
| 1593 |
} else { |
| 1594 |
position = local.id + this.maxFieldCount; |
| 1595 |
} |
| 1596 |
if (position < BitCacheSize) { |
| 1396 |
// use bits |
1597 |
// use bits |
| 1397 |
mask = 1L << position; |
1598 |
mask = 1L << position; |
| 1398 |
isTrue((this.nullBit1 & mask) == 0, "Adding 'unknown' mark in unexpected state"); //$NON-NLS-1$ |
1599 |
isTrue((this.nullBit1 & mask) == 0, "Adding 'unknown' mark in unexpected state"); //$NON-NLS-1$ |
|
Lines 1434-1445
Link Here
|
| 1434 |
} |
1635 |
} |
| 1435 |
} |
1636 |
} |
| 1436 |
|
1637 |
|
| 1437 |
public void markPotentiallyNullBit(LocalVariableBinding local) { |
1638 |
public void markPotentiallyNullBit(VariableBinding local) { |
| 1438 |
if (this != DEAD_END) { |
1639 |
if (this != DEAD_END) { |
| 1439 |
this.tagBits |= NULL_FLAG_MASK; |
1640 |
this.tagBits |= NULL_FLAG_MASK; |
| 1440 |
int position; |
1641 |
int position; |
| 1441 |
long mask; |
1642 |
long mask; |
| 1442 |
if ((position = local.id + this.maxFieldCount) < BitCacheSize) { |
1643 |
if (local instanceof FieldBinding) { |
|
|
1644 |
position = local.id; |
| 1645 |
} else { |
| 1646 |
position = local.id + this.maxFieldCount; |
| 1647 |
} |
| 1648 |
if (position < BitCacheSize) { |
| 1443 |
// use bits |
1649 |
// use bits |
| 1444 |
mask = 1L << position; |
1650 |
mask = 1L << position; |
| 1445 |
isTrue((this.nullBit1 & mask) == 0, "Adding 'potentially null' mark in unexpected state"); //$NON-NLS-1$ |
1651 |
isTrue((this.nullBit1 & mask) == 0, "Adding 'potentially null' mark in unexpected state"); //$NON-NLS-1$ |
|
Lines 1481-1492
Link Here
|
| 1481 |
} |
1687 |
} |
| 1482 |
} |
1688 |
} |
| 1483 |
|
1689 |
|
| 1484 |
public void markPotentiallyNonNullBit(LocalVariableBinding local) { |
1690 |
public void markPotentiallyNonNullBit(VariableBinding local) { |
| 1485 |
if (this != DEAD_END) { |
1691 |
if (this != DEAD_END) { |
| 1486 |
this.tagBits |= NULL_FLAG_MASK; |
1692 |
this.tagBits |= NULL_FLAG_MASK; |
| 1487 |
int position; |
1693 |
int position; |
| 1488 |
long mask; |
1694 |
long mask; |
| 1489 |
if ((position = local.id + this.maxFieldCount) < BitCacheSize) { |
1695 |
if (local instanceof FieldBinding) { |
|
|
1696 |
position = local.id; |
| 1697 |
} else { |
| 1698 |
position = local.id + this.maxFieldCount; |
| 1699 |
} |
| 1700 |
if (position < BitCacheSize) { |
| 1490 |
// use bits |
1701 |
// use bits |
| 1491 |
mask = 1L << position; |
1702 |
mask = 1L << position; |
| 1492 |
isTrue((this.nullBit1 & mask) == 0, "Adding 'potentially non-null' mark in unexpected state"); //$NON-NLS-1$ |
1703 |
isTrue((this.nullBit1 & mask) == 0, "Adding 'potentially non-null' mark in unexpected state"); //$NON-NLS-1$ |
|
Lines 2007-2014
Link Here
|
| 2007 |
return this; |
2218 |
return this; |
| 2008 |
} |
2219 |
} |
| 2009 |
|
2220 |
|
| 2010 |
public void markedAsNullOrNonNullInAssertExpression(LocalVariableBinding local) { |
2221 |
public void markedAsNullOrNonNullInAssertExpression(VariableBinding binding) { |
| 2011 |
int position = local.id + this.maxFieldCount; |
2222 |
int position; |
|
|
2223 |
if (binding instanceof FieldBinding) { |
| 2224 |
position = binding.id; |
| 2225 |
} else { |
| 2226 |
position = binding.id + this.maxFieldCount; |
| 2227 |
} |
| 2012 |
int oldLength; |
2228 |
int oldLength; |
| 2013 |
if (this.nullStatusChangedInAssert == null) { |
2229 |
if (this.nullStatusChangedInAssert == null) { |
| 2014 |
this.nullStatusChangedInAssert = new int[position + 1]; |
2230 |
this.nullStatusChangedInAssert = new int[position + 1]; |
|
Lines 2021-2028
Link Here
|
| 2021 |
this.nullStatusChangedInAssert[position] = 1; |
2237 |
this.nullStatusChangedInAssert[position] = 1; |
| 2022 |
} |
2238 |
} |
| 2023 |
|
2239 |
|
| 2024 |
public boolean isMarkedAsNullOrNonNullInAssertExpression(LocalVariableBinding local) { |
2240 |
public boolean isMarkedAsNullOrNonNullInAssertExpression(VariableBinding binding) { |
| 2025 |
int position = local.id + this.maxFieldCount; |
2241 |
int position; |
|
|
2242 |
if (binding instanceof FieldBinding) { |
| 2243 |
position = binding.id; |
| 2244 |
} else { |
| 2245 |
position = binding.id + this.maxFieldCount; |
| 2246 |
} |
| 2026 |
if(this.nullStatusChangedInAssert == null || position >= this.nullStatusChangedInAssert.length) { |
2247 |
if(this.nullStatusChangedInAssert == null || position >= this.nullStatusChangedInAssert.length) { |
| 2027 |
return false; |
2248 |
return false; |
| 2028 |
} |
2249 |
} |