Mercurial > hg > truffle
annotate test/compiler/7047069/Test7047069.java @ 10988:cd54c7e92908
8015660: Test8009761.java "Failed: init recursive calls: 24. After deopt 25"
Summary: Windows reserves and only partially commits thread stack. For detecting more thread stack space for execution, Windows installs one-shot page as guard page just before the current commited edge. It will trigger STACK_OVERFLOW_EXCEPTION when lands on last 4 pages of thread stack space. StackYellowPages default value is 2 on Windows (plus 1 page of StackRedPages, 3 pages guarded by hotspot) so the exception happens one page before Yellow pages. Same route executed second time will have one more page brought in, this leads same execution with different stack depth(interpreter mode). We need match Windows settings so the stack overflow exception will not happen before Yellow pages.
Reviewed-by: dholmes
Contributed-by: andreas.schoesser@sap.com
author | minqi |
---|---|
date | Tue, 18 Jun 2013 09:08:35 -0700 |
parents | b2cb497dec28 |
children |
rev | line source |
---|---|
3742
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
1 /* |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
4 * |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
8 * |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
13 * accompanied this code). |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
14 * |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
18 * |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
21 * questions. |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
22 * |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
23 */ |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
24 |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
25 /** |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
26 * @test |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
27 * @bug 7047069 |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
28 * @summary Array can dynamically change size when assigned to an object field |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
29 * |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
30 * @run main/othervm -Xbatch Test7047069 |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
31 */ |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
32 |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
33 import java.util.*; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
34 import java.awt.geom.*; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
35 |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
36 public class Test7047069 { |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
37 static boolean verbose; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
38 |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
39 static final int GROW_SIZE = 24; // Multiple of cubic & quad curve size |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
40 |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
41 float squareflat; // Square of the flatness parameter |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
42 // for testing against squared lengths |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
43 |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
44 int limit; // Maximum number of recursion levels |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
45 |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
46 float hold[] = new float[14]; // The cache of interpolated coords |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
47 // Note that this must be long enough |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
48 // to store a full cubic segment and |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
49 // a relative cubic segment to avoid |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
50 // aliasing when copying the coords |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
51 // of a curve to the end of the array. |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
52 // This is also serendipitously equal |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
53 // to the size of a full quad segment |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
54 // and 2 relative quad segments. |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
55 |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
56 int holdEnd; // The index of the last curve segment |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
57 // being held for interpolation |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
58 |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
59 int holdIndex; // The index of the curve segment |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
60 // that was last interpolated. This |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
61 // is the curve segment ready to be |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
62 // returned in the next call to |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
63 // currentSegment(). |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
64 |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
65 int levels[]; // The recursion level at which |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
66 // each curve being held in storage |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
67 // was generated. |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
68 |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
69 int levelIndex; // The index of the entry in the |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
70 // levels array of the curve segment |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
71 // at the holdIndex |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
72 |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
73 public static void subdivide(float src[], int srcoff, |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
74 float left[], int leftoff, |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
75 float right[], int rightoff) |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
76 { |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
77 float x1 = src[srcoff + 0]; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
78 float y1 = src[srcoff + 1]; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
79 float ctrlx = src[srcoff + 2]; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
80 float ctrly = src[srcoff + 3]; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
81 float x2 = src[srcoff + 4]; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
82 float y2 = src[srcoff + 5]; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
83 if (left != null) { |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
84 left[leftoff + 0] = x1; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
85 left[leftoff + 1] = y1; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
86 } |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
87 if (right != null) { |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
88 right[rightoff + 4] = x2; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
89 right[rightoff + 5] = y2; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
90 } |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
91 x1 = (x1 + ctrlx) / 2f; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
92 y1 = (y1 + ctrly) / 2f; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
93 x2 = (x2 + ctrlx) / 2f; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
94 y2 = (y2 + ctrly) / 2f; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
95 ctrlx = (x1 + x2) / 2f; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
96 ctrly = (y1 + y2) / 2f; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
97 if (left != null) { |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
98 left[leftoff + 2] = x1; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
99 left[leftoff + 3] = y1; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
100 left[leftoff + 4] = ctrlx; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
101 left[leftoff + 5] = ctrly; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
102 } |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
103 if (right != null) { |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
104 right[rightoff + 0] = ctrlx; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
105 right[rightoff + 1] = ctrly; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
106 right[rightoff + 2] = x2; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
107 right[rightoff + 3] = y2; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
108 } |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
109 } |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
110 |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
111 public static double getFlatnessSq(float coords[], int offset) { |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
112 return Line2D.ptSegDistSq(coords[offset + 0], coords[offset + 1], |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
113 coords[offset + 4], coords[offset + 5], |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
114 coords[offset + 2], coords[offset + 3]); |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
115 } |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
116 |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
117 public Test7047069() { |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
118 this.squareflat = .0001f * .0001f; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
119 holdIndex = hold.length - 6; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
120 holdEnd = hold.length - 2; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
121 hold[holdIndex + 0] = (float) (Math.random() * 100); |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
122 hold[holdIndex + 1] = (float) (Math.random() * 100); |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
123 hold[holdIndex + 2] = (float) (Math.random() * 100); |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
124 hold[holdIndex + 3] = (float) (Math.random() * 100); |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
125 hold[holdIndex + 4] = (float) (Math.random() * 100); |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
126 hold[holdIndex + 5] = (float) (Math.random() * 100); |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
127 levelIndex = 0; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
128 this.limit = 10; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
129 this.levels = new int[limit + 1]; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
130 } |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
131 |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
132 /* |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
133 * Ensures that the hold array can hold up to (want) more values. |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
134 * It is currently holding (hold.length - holdIndex) values. |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
135 */ |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
136 void ensureHoldCapacity(int want) { |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
137 if (holdIndex - want < 0) { |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
138 int have = hold.length - holdIndex; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
139 int newsize = hold.length + GROW_SIZE; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
140 float newhold[] = new float[newsize]; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
141 System.arraycopy(hold, holdIndex, |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
142 newhold, holdIndex + GROW_SIZE, |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
143 have); |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
144 if (verbose) System.err.println("old hold = "+hold+"["+hold.length+"]"); |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
145 if (verbose) System.err.println("replacement hold = "+newhold+"["+newhold.length+"]"); |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
146 hold = newhold; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
147 if (verbose) System.err.println("new hold = "+hold+"["+hold.length+"]"); |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
148 if (verbose) System.err.println("replacement hold still = "+newhold+"["+newhold.length+"]"); |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
149 holdIndex += GROW_SIZE; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
150 holdEnd += GROW_SIZE; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
151 } |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
152 } |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
153 |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
154 private boolean next() { |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
155 if (holdIndex >= holdEnd) { |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
156 return false; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
157 } |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
158 |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
159 int level = levels[levelIndex]; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
160 while (level < limit) { |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
161 if (getFlatnessSq(hold, holdIndex) < squareflat) { |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
162 break; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
163 } |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
164 |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
165 ensureHoldCapacity(4); |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
166 subdivide(hold, holdIndex, |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
167 hold, holdIndex - 4, |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
168 hold, holdIndex); |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
169 holdIndex -= 4; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
170 |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
171 // Now that we have subdivided, we have constructed |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
172 // two curves of one depth lower than the original |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
173 // curve. One of those curves is in the place of |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
174 // the former curve and one of them is in the next |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
175 // set of held coordinate slots. We now set both |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
176 // curves level values to the next higher level. |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
177 level++; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
178 levels[levelIndex] = level; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
179 levelIndex++; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
180 levels[levelIndex] = level; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
181 } |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
182 |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
183 // This curve segment is flat enough, or it is too deep |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
184 // in recursion levels to try to flatten any more. The |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
185 // two coordinates at holdIndex+4 and holdIndex+5 now |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
186 // contain the endpoint of the curve which can be the |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
187 // endpoint of an approximating line segment. |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
188 holdIndex += 4; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
189 levelIndex--; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
190 return true; |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
191 } |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
192 |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
193 public static void main(String argv[]) { |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
194 verbose = (argv.length > 0); |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
195 for (int i = 0; i < 100000; i++) { |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
196 Test7047069 st = new Test7047069(); |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
197 while (st.next()) {} |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
198 } |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
199 } |
b2cb497dec28
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
200 } |