Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java')
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java381
1 files changed, 92 insertions, 289 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java
index 5532e4482..30b2bcf7b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -20,13 +20,11 @@
package org.eclipse.jdt.internal.compiler.flow;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.eclipse.jdt.internal.compiler.lookup.TagBits;
-import org.eclipse.jdt.internal.compiler.lookup.VariableBinding;
import org.eclipse.objectteams.otdt.internal.core.compiler.ast.BaseCallTrackingVariable;
/**
@@ -92,20 +90,17 @@ public class UnconditionalFlowInfo extends FlowInfo {
// extra segments
public static final int extraLength = 6;
- // extra bit fields for larger numbers of fields/variables
- // extra[0] holds definiteInits values, extra[1] potentialInits, etc.
- // lifecycle is extra == null or else all extra[]'s are allocated
- // arrays which have the same size
public long extra[][];
-
+ // extra bit fields for larger numbers of fields/variables
+ // extra[0] holds definiteInits values, extra[1] potentialInits, etc.
+ // lifecycle is extra == null or else all extra[]'s are allocated
+ // arrays which have the same size
+
public int maxFieldCount; // limit between fields and locals
// Constants
public static final int BitCacheSize = 64; // 64 bits in a long.
public int[] nullStatusChangedInAssert; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=303448
- public long constantFieldsMask; // record positions of constant fields so that they don't get reset in resetNullInfoForFields()
- public long extraConstantFieldMask[]; // extra mask for larger number of fields
- protected static final int AccConstant = ClassFileConstants.AccStatic|ClassFileConstants.AccFinal;
public FlowInfo addInitializationsFrom(FlowInfo inits) {
return addInfoFrom(inits, true);
@@ -535,13 +530,13 @@ public UnconditionalFlowInfo addPotentialNullInfoFrom(
return this;
}
-final public boolean cannotBeDefinitelyNullOrNonNull(VariableBinding var) {
+final public boolean cannotBeDefinitelyNullOrNonNull(LocalVariableBinding local) {
if ((this.tagBits & NULL_FLAG_MASK) == 0 ||
- (var.type.tagBits & TagBits.IsBaseType) != 0) {
+ (local.type.tagBits & TagBits.IsBaseType) != 0) {
return false;
}
- int position = var.getAnalysisId(this.maxFieldCount);
- if (position < BitCacheSize) {
+ int position;
+ if ((position = local.id + this.maxFieldCount) < BitCacheSize) {
// use bits
return (
(~this.nullBit1
@@ -566,13 +561,13 @@ final public boolean cannotBeDefinitelyNullOrNonNull(VariableBinding var) {
& (1L << (position % BitCacheSize))) != 0;
}
-final public boolean cannotBeNull(VariableBinding var) {
+final public boolean cannotBeNull(LocalVariableBinding local) {
if ((this.tagBits & NULL_FLAG_MASK) == 0 ||
- (var.type.tagBits & TagBits.IsBaseType) != 0) {
+ (local.type.tagBits & TagBits.IsBaseType) != 0) {
return false;
}
- int position = var.getAnalysisId(this.maxFieldCount);
- if (position < BitCacheSize) {
+ int position;
+ if ((position = local.id + this.maxFieldCount) < BitCacheSize) {
// use bits
return (this.nullBit1 & this.nullBit3
& ((this.nullBit2 & this.nullBit4) | ~this.nullBit2)
@@ -593,13 +588,13 @@ final public boolean cannotBeNull(VariableBinding var) {
& (1L << (position % BitCacheSize))) != 0;
}
-final public boolean canOnlyBeNull(VariableBinding var) {
+final public boolean canOnlyBeNull(LocalVariableBinding local) {
if ((this.tagBits & NULL_FLAG_MASK) == 0 ||
- (var.type.tagBits & TagBits.IsBaseType) != 0) {
+ (local.type.tagBits & TagBits.IsBaseType) != 0) {
return false;
}
- int position = var.getAnalysisId(this.maxFieldCount);
- if (position < BitCacheSize) {
+ int position;
+ if ((position = local.id + this.maxFieldCount) < BitCacheSize) {
// use bits
return (this.nullBit1 & this.nullBit2
& (~this.nullBit3 | ~this.nullBit4)
@@ -637,8 +632,6 @@ public FlowInfo copy() {
}
copy.tagBits = this.tagBits;
copy.maxFieldCount = this.maxFieldCount;
- copy.constantFieldsMask = this.constantFieldsMask;
- copy.extraConstantFieldMask = this.extraConstantFieldMask;
if (this.extra != null) {
int length;
copy.extra = new long[extraLength][];
@@ -756,47 +749,32 @@ final public boolean isDefinitelyAssigned(FieldBinding field) {
if ((this.tagBits & UNREACHABLE_OR_DEAD) != 0) {
return true;
}
- //{ObjectTeams: if it is copied don't require definite assignment again
- if (field.copyInheritanceSrc != null)
- return true;
- // SH}
- return isDefinitelyAssigned(field.getAnalysisId(this.maxFieldCount));
+//{ObjectTeams: if it is copied don't require definite assignment again
+ if (field.copyInheritanceSrc != null)
+ return true;
+// SH}
+ return isDefinitelyAssigned(field.id);
}
-final public boolean isDefinitelyAssigned(LocalVariableBinding var) {
+final public boolean isDefinitelyAssigned(LocalVariableBinding local) {
// do not want to complain in unreachable code if local declared in reachable code
- if ((this.tagBits & UNREACHABLE_OR_DEAD) != 0 && (var.declaration.bits & ASTNode.IsLocalDeclarationReachable) != 0) {
+ if ((this.tagBits & UNREACHABLE_OR_DEAD) != 0 && (local.declaration.bits & ASTNode.IsLocalDeclarationReachable) != 0) {
return true;
}
- return isDefinitelyAssigned(var.id + this.maxFieldCount);
-}
-
-final public boolean isDefinitelyAssigned(VariableBinding var) {
- if (var instanceof FieldBinding) {
- return this.isDefinitelyAssigned((FieldBinding)var);
- } else {
- return this.isDefinitelyAssigned((LocalVariableBinding)var);
- }
+ return isDefinitelyAssigned(local.id + this.maxFieldCount);
}
-final public boolean isDefinitelyNonNull(VariableBinding var) {
- boolean isField = var instanceof FieldBinding;
- if (isField && (this.tagBits & NULL_FLAG_MASK) == 0) {
- // no local yet in scope. Came here because of a field being queried for non null
- // will only happen for final fields, since they are assigned in a constructor or static block
- // and we may currently be in some other method
- this.tagBits |= NULL_FLAG_MASK;
- }
+final public boolean isDefinitelyNonNull(LocalVariableBinding local) {
// do not want to complain in unreachable code
if ((this.tagBits & UNREACHABLE) != 0 ||
(this.tagBits & NULL_FLAG_MASK) == 0) {
return false;
}
- if ((var.type.tagBits & TagBits.IsBaseType) != 0 ||
- var.constant() != Constant.NotAConstant) { // String instances
+ if ((local.type.tagBits & TagBits.IsBaseType) != 0 ||
+ local.constant() != Constant.NotAConstant) { // String instances
return true;
}
- int position = var.getAnalysisId(this.maxFieldCount);
+ int position = local.id + this.maxFieldCount;
if (position < BitCacheSize) { // use bits
return ((this.nullBit1 & this.nullBit3 & (~this.nullBit2 | this.nullBit4))
& (1L << position)) != 0;
@@ -815,21 +793,14 @@ final public boolean isDefinitelyNonNull(VariableBinding var) {
& (1L << (position % BitCacheSize))) != 0;
}
-final public boolean isDefinitelyNull(VariableBinding var) {
- boolean isField = var instanceof FieldBinding;
- if (isField && (this.tagBits & NULL_FLAG_MASK) == 0) {
- // no local yet in scope. Came here because of a field being queried for non null
- // will only happen for final fields, since they are assigned in a constructor or static block
- // and we may currently be in some other method
- this.tagBits |= NULL_FLAG_MASK;
- }
+final public boolean isDefinitelyNull(LocalVariableBinding local) {
// do not want to complain in unreachable code
if ((this.tagBits & UNREACHABLE) != 0 ||
(this.tagBits & NULL_FLAG_MASK) == 0 ||
- (var.type.tagBits & TagBits.IsBaseType) != 0) {
+ (local.type.tagBits & TagBits.IsBaseType) != 0) {
return false;
}
- int position = var.getAnalysisId(this.maxFieldCount);
+ int position = local.id + this.maxFieldCount;
if (position < BitCacheSize) { // use bits
return ((this.nullBit1 & this.nullBit2
& (~this.nullBit3 | ~this.nullBit4))
@@ -849,13 +820,13 @@ final public boolean isDefinitelyNull(VariableBinding var) {
& (1L << (position % BitCacheSize))) != 0;
}
-final public boolean isDefinitelyUnknown(VariableBinding var) {
+final public boolean isDefinitelyUnknown(LocalVariableBinding local) {
// do not want to complain in unreachable code
if ((this.tagBits & UNREACHABLE) != 0 ||
(this.tagBits & NULL_FLAG_MASK) == 0) {
return false;
}
- int position = var.getAnalysisId(this.maxFieldCount);
+ int position = local.id + this.maxFieldCount;
if (position < BitCacheSize) { // use bits
return ((this.nullBit1 & this.nullBit4
& ~this.nullBit2 & ~this.nullBit3) & (1L << position)) != 0;
@@ -904,7 +875,7 @@ final private boolean isPotentiallyAssigned(int position) {
}
final public boolean isPotentiallyAssigned(FieldBinding field) {
- return isPotentiallyAssigned(field.getAnalysisId(this.maxFieldCount));
+ return isPotentiallyAssigned(field.id);
}
final public boolean isPotentiallyAssigned(LocalVariableBinding local) {
@@ -915,22 +886,14 @@ final public boolean isPotentiallyAssigned(LocalVariableBinding local) {
return isPotentiallyAssigned(local.id + this.maxFieldCount);
}
-final public boolean isPotentiallyAssigned(VariableBinding var) {
- if (var instanceof FieldBinding) {
- return this.isPotentiallyAssigned((FieldBinding)var);
- } else {
- return this.isPotentiallyAssigned((LocalVariableBinding)var);
- }
-}
-
// TODO (Ayush) Check why this method does not return true for protected non null (1111)
-final public boolean isPotentiallyNonNull(VariableBinding var) {
+final public boolean isPotentiallyNonNull(LocalVariableBinding local) {
if ((this.tagBits & NULL_FLAG_MASK) == 0 ||
- (var.type.tagBits & TagBits.IsBaseType) != 0) {
+ (local.type.tagBits & TagBits.IsBaseType) != 0) {
return false;
}
- int position = var.getAnalysisId(this.maxFieldCount);
- if (position < BitCacheSize) { // use bits
+ int position;
+ if ((position = local.id + this.maxFieldCount) < BitCacheSize) {
// use bits
return ((this.nullBit3 & (~this.nullBit1 | ~this.nullBit2))
& (1L << position)) != 0;
@@ -950,13 +913,13 @@ final public boolean isPotentiallyNonNull(VariableBinding var) {
}
// TODO (Ayush) Check why this method does not return true for protected null
-final public boolean isPotentiallyNull(VariableBinding var) {
+final public boolean isPotentiallyNull(LocalVariableBinding local) {
if ((this.tagBits & NULL_FLAG_MASK) == 0 ||
- (var.type.tagBits & TagBits.IsBaseType) != 0) {
+ (local.type.tagBits & TagBits.IsBaseType) != 0) {
return false;
}
- int position = var.getAnalysisId(this.maxFieldCount);
- if (position < BitCacheSize) {
+ int position;
+ if ((position = local.id + this.maxFieldCount) < BitCacheSize) {
// use bits
return ((this.nullBit2 & (~this.nullBit1 | ~this.nullBit3))
& (1L << position)) != 0;
@@ -975,13 +938,13 @@ final public boolean isPotentiallyNull(VariableBinding var) {
& (1L << (position % BitCacheSize))) != 0;
}
-final public boolean isPotentiallyUnknown(VariableBinding var) {
+final public boolean isPotentiallyUnknown(LocalVariableBinding local) {
// do not want to complain in unreachable code
if ((this.tagBits & UNREACHABLE) != 0 ||
(this.tagBits & NULL_FLAG_MASK) == 0) {
return false;
}
- int position = var.getAnalysisId(this.maxFieldCount);
+ int position = local.id + this.maxFieldCount;
if (position < BitCacheSize) { // use bits
return (this.nullBit4
& (~this.nullBit1 | ~this.nullBit2 & ~this.nullBit3)
@@ -1002,13 +965,14 @@ final public boolean isPotentiallyUnknown(VariableBinding var) {
& (1L << (position % BitCacheSize))) != 0;
}
-final public boolean isProtectedNonNull(VariableBinding var) {
+final public boolean isProtectedNonNull(LocalVariableBinding local) {
if ((this.tagBits & NULL_FLAG_MASK) == 0 ||
- (var.type.tagBits & TagBits.IsBaseType) != 0) {
+ (local.type.tagBits & TagBits.IsBaseType) != 0) {
return false;
}
- int position = var.getAnalysisId(this.maxFieldCount);
- if (position < BitCacheSize) { // use bits
+ int position;
+ if ((position = local.id + this.maxFieldCount) < BitCacheSize) {
+ // use bits
return (this.nullBit1 & this.nullBit3 & this.nullBit4 & (1L << position)) != 0;
}
// use extra vector
@@ -1026,13 +990,13 @@ final public boolean isProtectedNonNull(VariableBinding var) {
& (1L << (position % BitCacheSize))) != 0;
}
-final public boolean isProtectedNull(VariableBinding var) {
+final public boolean isProtectedNull(LocalVariableBinding local) {
if ((this.tagBits & NULL_FLAG_MASK) == 0 ||
- (var.type.tagBits & TagBits.IsBaseType) != 0) {
+ (local.type.tagBits & TagBits.IsBaseType) != 0) {
return false;
}
- int position = var.getAnalysisId(this.maxFieldCount);
- if (position < BitCacheSize) {
+ int position;
+ if ((position = local.id + this.maxFieldCount) < BitCacheSize) {
// use bits
return (this.nullBit1 & this.nullBit2
& (this.nullBit3 ^ this.nullBit4)
@@ -1065,27 +1029,15 @@ protected static boolean isTrue(boolean expression, String message) {
throw new AssertionFailedException("assertion failed: " + message); //$NON-NLS-1$
return expression;
}
-public void markAsComparedEqualToNonNull(VariableBinding var) {
+public void markAsComparedEqualToNonNull(LocalVariableBinding local) {
// protected from non-object locals in calling methods
if (this != DEAD_END) {
this.tagBits |= NULL_FLAG_MASK;
int position;
- if (var instanceof FieldBinding) {
- if ((var.modifiers & AccConstant) == AccConstant) {
- position = var.getAnalysisId(this.maxFieldCount);
- } else {
- // non-final fields may be modified in separate threads and we cannot be sure about their
- // definite nullness. Hence, marking as definitely unknown to avoid deferring null check for these fields
- this.markAsDefinitelyUnknown(var);
- return;
- }
- } else {
- position = var.id + this.maxFieldCount;
- }
long mask;
long a1, a2, a3, a4, na2;
// position is zero-based
- if (position < BitCacheSize) {
+ if ((position = local.id + this.maxFieldCount) < BitCacheSize) {
// use bits
if (((mask = 1L << position)
& (a1 = this.nullBit1)
@@ -1174,26 +1126,14 @@ public void markAsComparedEqualToNonNull(VariableBinding var) {
}
}
-public void markAsComparedEqualToNull(VariableBinding var) {
+public void markAsComparedEqualToNull(LocalVariableBinding local) {
// protected from non-object locals in calling methods
if (this != DEAD_END) {
this.tagBits |= NULL_FLAG_MASK;
int position;
long mask;
// position is zero-based
- if (var instanceof FieldBinding) {
- if ((var.modifiers & AccConstant) == AccConstant) {
- position = var.getAnalysisId(this.maxFieldCount);
- } else {
- // non-final fields may be modified in separate threads and we cannot be sure about their
- // definite nullness. Hence, marking as potential null.
- this.markNullStatus(var, FlowInfo.POTENTIALLY_NULL);
- return;
- }
- } else {
- position = var.id + this.maxFieldCount;
- }
- if (position < BitCacheSize) {
+ if ((position = local.id + this.maxFieldCount) < BitCacheSize) {
// use bits
if (((mask = 1L << position) & this.nullBit1) != 0) {
if ((mask
@@ -1314,31 +1254,24 @@ final private void markAsDefinitelyAssigned(int position) {
}
}
-public void markAsDefinitelyAssigned(VariableBinding var) {
+public void markAsDefinitelyAssigned(FieldBinding field) {
if (this != DEAD_END)
- markAsDefinitelyAssigned(var.getAnalysisId(this.maxFieldCount));
+ markAsDefinitelyAssigned(field.id);
}
-public void markAsDefinitelyNonNull(VariableBinding var) {
+public void markAsDefinitelyAssigned(LocalVariableBinding local) {
+ if (this != DEAD_END)
+ markAsDefinitelyAssigned(local.id + this.maxFieldCount);
+}
+
+public void markAsDefinitelyNonNull(LocalVariableBinding local) {
// protected from non-object locals in calling methods
if (this != DEAD_END) {
this.tagBits |= NULL_FLAG_MASK;
long mask;
int position;
// position is zero-based
- if (var instanceof FieldBinding) {
- if ((var.modifiers & AccConstant) == AccConstant) {
- position = var.getAnalysisId(this.maxFieldCount);
- } else {
- // non-final fields may be modified in separate threads and we cannot be sure about their
- // definite nullness. Hence, marking as definitely unknown to avoid deferring null check for these fields.
- this.markAsDefinitelyUnknown(var);
- return;
- }
- } else {
- position = var.id + this.maxFieldCount;
- }
- if (position < BitCacheSize) { // use bits
+ if ((position = local.id + this.maxFieldCount) < BitCacheSize) { // use bits
// set assigned non null
this.nullBit1 |= (mask = 1L << position);
this.nullBit3 |= mask;
@@ -1385,26 +1318,14 @@ public void markAsDefinitelyNonNull(VariableBinding var) {
}
}
-public void markAsDefinitelyNull(VariableBinding var) {
+public void markAsDefinitelyNull(LocalVariableBinding local) {
// protected from non-object locals in calling methods
if (this != DEAD_END) {
this.tagBits |= NULL_FLAG_MASK;
long mask;
int position;
// position is zero-based
- if (var instanceof FieldBinding) {
- if ((var.modifiers & AccConstant) == AccConstant) {
- position = var.getAnalysisId(this.maxFieldCount);
- } else {
- // non-final fields may be modified in separate threads and we cannot be sure about their
- // definite nullness. Hence, marking as potential null.
- this.markNullStatus(var, FlowInfo.POTENTIALLY_NULL);
- return;
- }
- } else {
- position = var.id + this.maxFieldCount;
- }
- if (position < BitCacheSize) { // use bits
+ if ((position = local.id + this.maxFieldCount) < BitCacheSize) { // use bits
// mark assigned null
this.nullBit1 |= (mask = 1L << position);
this.nullBit2 |= mask;
@@ -1453,17 +1374,18 @@ public void markAsDefinitelyNull(VariableBinding var) {
/**
* Mark a local as having been assigned to an unknown value.
- * @param var the local to mark
+ * @param local the local to mark
*/
// PREMATURE may try to get closer to markAsDefinitelyAssigned, but not
// obvious
-public void markAsDefinitelyUnknown(VariableBinding var) {
+public void markAsDefinitelyUnknown(LocalVariableBinding local) {
// protected from non-object locals in calling methods
if (this != DEAD_END) {
this.tagBits |= NULL_FLAG_MASK;
long mask;
- int position = var.getAnalysisId(this.maxFieldCount);
- if (position < BitCacheSize) {
+ int position;
+ // position is zero-based
+ if ((position = local.id + this.maxFieldCount) < BitCacheSize) {
// use bits
// mark assigned null
this.nullBit1 |= (mask = 1L << position);
@@ -1511,12 +1433,12 @@ public void markAsDefinitelyUnknown(VariableBinding var) {
}
}
-public void resetNullInfo(VariableBinding var) {
+public void resetNullInfo(LocalVariableBinding local) {
if (this != DEAD_END) {
this.tagBits |= NULL_FLAG_MASK;
+ int position;
long mask;
- int position = var.getAnalysisId(this.maxFieldCount);
- if (position < BitCacheSize) {
+ if ((position = local.id + this.maxFieldCount) < BitCacheSize) {
// use bits
this.nullBit1 &= (mask = ~(1L << position));
this.nullBit2 &= mask;
@@ -1539,132 +1461,17 @@ public void resetNullInfo(VariableBinding var) {
}
}
-public void resetNullInfoForFields() {
- if (this != DEAD_END) {
- long mask = this.maxFieldCount < BitCacheSize ? (-1L << this.maxFieldCount) : 0L;
- mask |= this.constantFieldsMask;
- // first reset normal bits:
- this.nullBit1 |= ~mask;
- this.nullBit2 &= mask;
- this.nullBit3 &= mask;
- this.nullBit4 |= ~mask;
- if (this.maxFieldCount >= BitCacheSize && this.extra != null) {
- // use extra vector
- int localsStartIndex = this.maxFieldCount/BitCacheSize - 1;
- int localsStartOffset = this.maxFieldCount % BitCacheSize;
- int len = Math.min(localsStartIndex+1, this.extra[2].length);
- if (this.extraConstantFieldMask != null){
- for (int vectorIndex = 0; vectorIndex < len; vectorIndex++) {
- if (vectorIndex >= this.extraConstantFieldMask.length) {
- // no constant fields after this, just mask all fields
- if (vectorIndex == localsStartIndex) {
- // some locals, some fields at this vectorIndex
- mask = -1L << localsStartOffset;
- } else {
- // all fields here
- mask = 0L;
- }
- } else {
- if (vectorIndex == localsStartIndex) {
- // some locals, some fields at this vectorIndex
- mask = ((-1 << localsStartOffset) | this.extraConstantFieldMask[vectorIndex]);
- } else {
- // all fields here
- mask = 0L | this.extraConstantFieldMask[vectorIndex];
- }
-
- }
- this.extra[2][vectorIndex]
- |= ~mask;
- this.extra[3][vectorIndex] &= mask;
- this.extra[4][vectorIndex] &= mask;
- this.extra[5][vectorIndex] |= ~mask;
- }
- } else {
- // no constant fields
- for (int vectorIndex = 0; vectorIndex < len; vectorIndex++) {
- if (vectorIndex == localsStartIndex) {
- // some locals, some fields at this vectorIndex
- mask = -1L << localsStartOffset;
- } else {
- // all fields here
- mask = 0L;
- }
- this.extra[2][vectorIndex]
- |= ~mask;
- this.extra[3][vectorIndex] &= mask;
- this.extra[4][vectorIndex] &= mask;
- this.extra[5][vectorIndex] |= ~mask;
- }
- }
- }
- }
-}
-
-public void updateConstantFieldsMask(FieldBinding field) {
- int position = field.getAnalysisId(this.maxFieldCount);
- long mask = 1L << (position % BitCacheSize);
- if (position < BitCacheSize) {
- this.constantFieldsMask |= 1L << position; // exclude this field from being reset
- } else {
- // use extra vector
- int vectorIndex = (position / BitCacheSize) - 1;
- if (this.extraConstantFieldMask == null) {
- // extra array not created. Create constant field mask bit streams.
- int length = vectorIndex + 1;
- this.extraConstantFieldMask = new long[length];
- }
- else {
- int oldLength; // might need to grow the arrays
- if (vectorIndex >= (oldLength = this.extraConstantFieldMask.length)) {
- System.arraycopy(this.extraConstantFieldMask, 0, (this.extraConstantFieldMask = new long[vectorIndex + 1]), 0, oldLength);
- }
- }
- this.extraConstantFieldMask[vectorIndex] |= mask; // exclude this field from resetNullInfoForFields
- }
-}
-
-/**
- * All the infos originate in TypeDeclaration.analyseCode(). So making sure that this method is called for every info that is sent into
- * methods/constructors should be sufficient
- */
-public void addConstantFieldsMask(UnconditionalFlowInfo other) {
- this.constantFieldsMask |= other.constantFieldsMask;
- if (other.extraConstantFieldMask != null) {
- int oldLength = 0;
- int otherLen = other.extraConstantFieldMask.length;
- if (this.extraConstantFieldMask != null) {
- oldLength = this.extraConstantFieldMask.length;
- if (otherLen > (oldLength = this.extraConstantFieldMask.length)) {
- System.arraycopy(this.extraConstantFieldMask, 0, (this.extraConstantFieldMask = new long[otherLen]), 0, oldLength);
- for (int i = 0; i < oldLength; i++) {
- this.extraConstantFieldMask[i] |= other.extraConstantFieldMask[i];
- }
- } else {
- for (int i = 0; i < otherLen; i++) {
- this.extraConstantFieldMask[i] |= other.extraConstantFieldMask[i];
- }
- }
- } else {
- this.extraConstantFieldMask = new long[otherLen];
- }
- for (int i = oldLength; i < otherLen; i++) {
- this.extraConstantFieldMask[i] = other.extraConstantFieldMask[i];
- }
- }
-}
-
/**
* Mark a local as potentially having been assigned to an unknown value.
- * @param var the local to mark
+ * @param local the local to mark
*/
-public void markPotentiallyUnknownBit(VariableBinding var) {
+public void markPotentiallyUnknownBit(LocalVariableBinding local) {
// protected from non-object locals in calling methods
if (this != DEAD_END) {
this.tagBits |= NULL_FLAG_MASK;
+ int position;
long mask;
- int position = var.getAnalysisId(this.maxFieldCount);
- if (position < BitCacheSize) {
+ if ((position = local.id + this.maxFieldCount) < BitCacheSize) {
// use bits
mask = 1L << position;
isTrue((this.nullBit1 & mask) == 0, "Adding 'unknown' mark in unexpected state"); //$NON-NLS-1$
@@ -1706,12 +1513,12 @@ public void markPotentiallyUnknownBit(VariableBinding var) {
}
}
-public void markPotentiallyNullBit(VariableBinding var) {
+public void markPotentiallyNullBit(LocalVariableBinding local) {
if (this != DEAD_END) {
this.tagBits |= NULL_FLAG_MASK;
+ int position;
long mask;
- int position = var.getAnalysisId(this.maxFieldCount);
- if (position < BitCacheSize) {
+ if ((position = local.id + this.maxFieldCount) < BitCacheSize) {
// use bits
mask = 1L << position;
isTrue((this.nullBit1 & mask) == 0, "Adding 'potentially null' mark in unexpected state"); //$NON-NLS-1$
@@ -1753,12 +1560,12 @@ public void markPotentiallyNullBit(VariableBinding var) {
}
}
-public void markPotentiallyNonNullBit(VariableBinding var) {
+public void markPotentiallyNonNullBit(LocalVariableBinding local) {
if (this != DEAD_END) {
this.tagBits |= NULL_FLAG_MASK;
+ int position;
long mask;
- int position = var.getAnalysisId(this.maxFieldCount);
- if (position < BitCacheSize) {
+ if ((position = local.id + this.maxFieldCount) < BitCacheSize) {
// use bits
mask = 1L << position;
isTrue((this.nullBit1 & mask) == 0, "Adding 'potentially non-null' mark in unexpected state"); //$NON-NLS-1$
@@ -2115,8 +1922,6 @@ public UnconditionalFlowInfo nullInfoLessUnconditionalCopy() {
copy.tagBits = this.tagBits & ~NULL_FLAG_MASK;
copy.maxFieldCount = this.maxFieldCount;
copy.nullStatusChangedInAssert = this.nullStatusChangedInAssert;
- copy.constantFieldsMask = this.constantFieldsMask;
- copy.extraConstantFieldMask = this.extraConstantFieldMask;
if (this.extra != null) {
int length;
copy.extra = new long[extraLength][];
@@ -2239,8 +2044,6 @@ public UnconditionalFlowInfo unconditionalFieldLessCopy() {
UnconditionalFlowInfo copy = new UnconditionalFlowInfo();
copy.tagBits = this.tagBits;
copy.maxFieldCount = this.maxFieldCount;
- copy.constantFieldsMask = this.constantFieldsMask;
- copy.extraConstantFieldMask = this.extraConstantFieldMask;
int limit = this.maxFieldCount;
if (limit < BitCacheSize) {
long mask;
@@ -2295,8 +2098,8 @@ public UnconditionalFlowInfo unconditionalInitsWithoutSideEffect() {
return this;
}
-public void markedAsNullOrNonNullInAssertExpression(VariableBinding binding) {
- int position = binding.getAnalysisId(this.maxFieldCount);
+public void markedAsNullOrNonNullInAssertExpression(LocalVariableBinding local) {
+ int position = local.id + this.maxFieldCount;
int oldLength;
if (this.nullStatusChangedInAssert == null) {
this.nullStatusChangedInAssert = new int[position + 1];
@@ -2309,8 +2112,8 @@ public void markedAsNullOrNonNullInAssertExpression(VariableBinding binding) {
this.nullStatusChangedInAssert[position] = 1;
}
-public boolean isMarkedAsNullOrNonNullInAssertExpression(VariableBinding binding) {
- int position = binding.getAnalysisId(this.maxFieldCount);
+public boolean isMarkedAsNullOrNonNullInAssertExpression(LocalVariableBinding local) {
+ int position = local.id + this.maxFieldCount;
if(this.nullStatusChangedInAssert == null || position >= this.nullStatusChangedInAssert.length) {
return false;
}

Back to the top