View | Details | Raw Unified | Return to bug 114855 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/codegen/Label.java (-9 / +33 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.compiler.codegen;
11
package org.eclipse.jdt.internal.compiler.codegen;
12
12
13
import java.util.Arrays;
14
13
import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
15
import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
14
import org.eclipse.jdt.internal.compiler.problem.AbortMethod;
16
import org.eclipse.jdt.internal.compiler.problem.AbortMethod;
15
17
Lines 48-69 Link Here
48
	if (forwardReferenceCount >= (length = forwardReferences.length))
50
	if (forwardReferenceCount >= (length = forwardReferences.length))
49
		System.arraycopy(forwardReferences, 0, (forwardReferences = new int[2*length]), 0, length);
51
		System.arraycopy(forwardReferences, 0, (forwardReferences = new int[2*length]), 0, length);
50
	forwardReferences[forwardReferenceCount++] = iPos;
52
	forwardReferences[forwardReferenceCount++] = iPos;
53
	Arrays.sort(this.forwardReferences, 0, this.forwardReferenceCount);
51
}
54
}
52
55
53
/**
56
/**
54
 * Add a forward refrence for the array.
57
 * Add a forward reference for the array.
55
 */
58
 */
56
public void appendForwardReferencesFrom(Label otherLabel) {
59
public void appendForwardReferencesFrom(Label otherLabel) {
57
	int otherCount = otherLabel.forwardReferenceCount;
60
	int otherCount = otherLabel.forwardReferenceCount;
58
	if (otherCount == 0) return;
61
	if (otherCount == 0) return;
59
	int length = forwardReferences.length;
62
	// need to merge the two sorted arrays of forward references
60
	int neededSpace = otherCount + forwardReferenceCount;
63
	int[] mergedForwardReferences = new int[this.forwardReferenceCount + otherCount];
61
	if (neededSpace >= length){
64
	int indexInMerge = 0;
62
		System.arraycopy(forwardReferences, 0, (forwardReferences = new int[neededSpace]), 0, forwardReferenceCount);
65
	int j = 0;
66
	int i = 0;
67
	int max = this.forwardReferenceCount;
68
	int max2 = otherLabel.forwardReferenceCount;
69
	loop1 : for (; i < max; i++) {
70
		int value1 = this.forwardReferences[i];
71
		loop2: for (; j < max2; j++) {
72
			int value2 = otherLabel.forwardReferences[j];
73
			if (value1 < value2) {
74
				mergedForwardReferences[indexInMerge++] = value1;
75
				continue loop1;
76
			} else if (value1 == value2) {
77
				mergedForwardReferences[indexInMerge++] = value1;
78
				j++;
79
				continue loop1;
80
			} else {
81
				mergedForwardReferences[indexInMerge++] = value2;
82
			}
83
		}
84
	}
85
	for (; j < max2; j++) {
86
		int value2 = otherLabel.forwardReferences[j];
87
		mergedForwardReferences[indexInMerge++] = value2;
63
	}
88
	}
64
	// append other forward references at the end, so they will get updated as well
89
	this.forwardReferences = mergedForwardReferences;
65
	System.arraycopy(otherLabel.forwardReferences, 0, forwardReferences, forwardReferenceCount, otherCount);
90
	this.forwardReferenceCount = indexInMerge;
66
	forwardReferenceCount = neededSpace;
67
}
91
}
68
92
69
/*
93
/*
Lines 172-178 Link Here
172
				codeStream.classFileOffset -= 3;
196
				codeStream.classFileOffset -= 3;
173
				forwardReferenceCount--;
197
				forwardReferenceCount--;
174
				// also update the PCs in the related debug attributes
198
				// also update the PCs in the related debug attributes
175
				/** OLD CODE
199
				/* OLD CODE
176
					int index = codeStream.pcToSourceMapSize - 1;
200
					int index = codeStream.pcToSourceMapSize - 1;
177
						while ((index >= 0) && (codeStream.pcToSourceMap[index][1] == oldPosition)) {
201
						while ((index >= 0) && (codeStream.pcToSourceMap[index][1] == oldPosition)) {
178
							codeStream.pcToSourceMap[index--][1] = position;
202
							codeStream.pcToSourceMap[index--][1] = position;

Return to bug 114855