Skip to content

Commit e9822a7

Browse files
Garbage collect unused bit-flag org.eclipse.jdt.internal.compiler.codegen.BranchLabel.USED (eclipse-jdt#3408)
* Fixes eclipse-jdt#3407
1 parent 954ce51 commit e9822a7

File tree

10 files changed

+4
-27
lines changed

10 files changed

+4
-27
lines changed

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,6 @@ public void generateCode(
290290

291291
// Generate code for the condition
292292
falseLabel = new BranchLabel(codeStream);
293-
falseLabel.tagBits |= BranchLabel.USED;
294293
this.condition.generateOptimizedBoolean(
295294
currentScope,
296295
codeStream,

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/DoStatement.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream) {
172172

173173
// labels management
174174
BranchLabel actionLabel = new BranchLabel(codeStream);
175-
if (this.action != null) actionLabel.tagBits |= BranchLabel.USED;
176175
actionLabel.place();
177176
this.breakLabel.initialize(codeStream);
178177
boolean hasContinueLabel = this.continueLabel != null;

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ForStatement.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,6 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream) {
288288

289289
// label management
290290
BranchLabel actionLabel = new BranchLabel(codeStream);
291-
actionLabel.tagBits |= BranchLabel.USED;
292291
BranchLabel conditionLabel = new BranchLabel(codeStream);
293292
this.breakLabel.initialize(codeStream);
294293
if (this.continueLabel == null || conditionInjectsBindings) {
@@ -305,7 +304,6 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream) {
305304
if ((this.condition != null)
306305
&& (this.condition.constant == Constant.NotAConstant)
307306
&& !((this.action == null || this.action.isEmptyBlock()) && (this.increments == null))) {
308-
conditionLabel.tagBits |= BranchLabel.USED;
309307
int jumpPC = codeStream.position;
310308
codeStream.goto_(conditionLabel);
311309
codeStream.recordPositionsFrom(jumpPC, this.condition.sourceStart);

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,7 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream) {
265265
}
266266
// label management
267267
BranchLabel actionLabel = new BranchLabel(codeStream);
268-
actionLabel.tagBits |= BranchLabel.USED;
269268
BranchLabel conditionLabel = new BranchLabel(codeStream);
270-
conditionLabel.tagBits |= BranchLabel.USED;
271269
this.breakLabel.initialize(codeStream);
272270
if (this.continueLabel == null) {
273271
// generate the condition (swapped for optimizing)
@@ -290,7 +288,6 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream) {
290288
codeStream.recordPositionsFrom(conditionPC, this.elementVariable.sourceStart);
291289
} else {
292290
this.continueLabel.initialize(codeStream);
293-
this.continueLabel.tagBits |= BranchLabel.USED;
294291
// jump over the actionBlock
295292
codeStream.goto_(conditionLabel);
296293
}

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,6 @@ public String toString() {
540540
String literal = this.labelExpressions[i].constant.stringValue();
541541
stringCases[i] = new StringSwitchCase(literal.hashCode(), literal, sourceCaseLabels[i]);
542542
hashCodeCaseLabels[i] = new CaseLabel(codeStream);
543-
hashCodeCaseLabels[i].tagBits |= BranchLabel.USED;
544543
}
545544
Arrays.sort(stringCases);
546545

@@ -563,13 +562,11 @@ public String toString() {
563562
}
564563

565564
CaseLabel defaultCaseLabel = new CaseLabel(codeStream);
566-
defaultCaseLabel.tagBits |= BranchLabel.USED;
567565

568566
// prepare the labels and constants
569567
this.breakLabel.initialize(codeStream);
570568

571569
BranchLabel defaultBranchLabel = new BranchLabel(codeStream);
572-
if (hasCases) defaultBranchLabel.tagBits |= BranchLabel.USED;
573570
if (this.defaultCase != null) {
574571
this.defaultCase.targetLabel = defaultBranchLabel;
575572
}
@@ -649,10 +646,9 @@ private <T extends BranchLabel>T[] gatherLabels(CodeStream codeStream, T[] caseL
649646
for (int k = 0; k < length; ++k) {
650647
Expression e = peeledLabelExpressions[k];
651648
if (e instanceof FakeDefaultLiteral) continue;
652-
targetLabels[count++] = (caseLabels[j] = newLabel.apply(codeStream));
649+
targetLabels[count++] = (caseLabels[j++] = newLabel.apply(codeStream));
653650
if (e == this.totalPattern)
654651
this.defaultCase = stmt;
655-
caseLabels[j++].tagBits |= BranchLabel.USED;
656652
}
657653
System.arraycopy(targetLabels, 0, stmt.targetLabels = new BranchLabel[count], 0, count);
658654
}
@@ -682,7 +678,6 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream) {
682678

683679
CaseLabel defaultLabel = new CaseLabel(codeStream);
684680
final boolean hasCases = this.caseCount > 1 || (this.caseCount == 1 && this.defaultCase == null);
685-
if (hasCases) defaultLabel.tagBits |= BranchLabel.USED;
686681
if (this.defaultCase != null) {
687682
this.defaultCase.targetLabel = defaultLabel;
688683
}

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream) {
242242
// generate the action
243243
BranchLabel actionLabel = new BranchLabel(codeStream);
244244
if (this.action != null) {
245-
actionLabel.tagBits |= BranchLabel.USED;
246245
// Required to fix 1PR0XVS: LFRE:WINNT - Compiler: variable table for method appears incorrect
247246
if (this.condIfTrueInitStateIndex != -1) {
248247
// insert all locals initialized inside the condition into the action generated prior to the condition

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/BranchLabel.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ public class BranchLabel extends Label {
3030
public int tagBits;
3131
protected int targetStackDepth = -1;
3232
public final static int WIDE = 1;
33-
public final static int USED = 2;
34-
public final static int VALIDATE = 4;
33+
public final static int VALIDATE = 2;
3534
private OperandStack operandStack;
3635

3736

@@ -194,7 +193,6 @@ protected void trackStackDepth(boolean branch) {
194193
* Put down a reference to the array at the location in the codestream.
195194
*/
196195
void branch() {
197-
this.tagBits |= BranchLabel.USED;
198196
if (this.delegate != null) {
199197
this.delegate.branch();
200198
return;
@@ -217,7 +215,6 @@ void branch() {
217215
* No support for wide branches yet
218216
*/
219217
void branchWide() {
220-
this.tagBits |= BranchLabel.USED;
221218
if (this.delegate != null) {
222219
this.delegate.branchWide();
223220
return;

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/CaseLabel.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,7 @@ public boolean isStandardLabel(){
6666
*/
6767
@Override
6868
public void place() {
69-
if ((this.tagBits & USED) != 0) {
70-
this.position = this.codeStream.getPosition();
71-
} else {
72-
this.position = this.codeStream.position;
73-
}
69+
this.position = this.codeStream.position;
7470
if (this.instructionPosition != POS_NOT_SET) {
7571
int offset = this.position - this.instructionPosition;
7672
int[] forwardRefs = forwardReferences();

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3690,9 +3690,6 @@ public static TypeBinding getConstantPoolDeclaringClass(Scope currentScope, Meth
36903690
}
36913691
return constantPoolDeclaringClass;
36923692
}
3693-
protected int getPosition() {
3694-
return this.position;
3695-
}
36963693

36973694
public void getClass(TypeBinding baseType) {
36983695
this.countLabels = 0;

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/codegen/ExceptionLabel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public int getCount() {
4646
public void place() {
4747
// register the handler inside the codeStream then normal place
4848
this.codeStream.registerExceptionHandler(this);
49-
this.position = this.codeStream.getPosition();
49+
this.position = this.codeStream.position;
5050
this.codeStream.stackDepth = 1;
5151
}
5252

0 commit comments

Comments
 (0)