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