1 /*
  2  * Copyright (c) 2019, Red Hat, Inc. All rights reserved.
  3  * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
  4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  5  *
  6  * This code is free software; you can redistribute it and/or modify it
  7  * under the terms of the GNU General Public License version 2 only, as
  8  * published by the Free Software Foundation.
  9  *
 10  * This code is distributed in the hope that it will be useful, but WITHOUT
 11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 13  * version 2 for more details (a copy is included in the LICENSE file that
 14  * accompanied this code).
 15  *
 16  * You should have received a copy of the GNU General Public License version
 17  * 2 along with this work; if not, write to the Free Software Foundation,
 18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 19  *
 20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 21  * or visit www.oracle.com if you need additional information or have any
 22  * questions.
 23  */
 24 
 25 /*
 26  * @test id=default
 27  * @summary Test clone barriers work correctly
 28  * @requires vm.gc.Shenandoah
 29  *
 30  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
 31  *                   -XX:+UseShenandoahGC
 32  *                   TestClone
 33  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
 34  *                   -XX:+UseShenandoahGC
 35  *                   -Xint
 36  *                   TestClone
 37  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
 38  *                   -XX:+UseShenandoahGC
 39  *                   -XX:-TieredCompilation
 40  *                   TestClone
 41  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
 42  *                   -XX:+UseShenandoahGC
 43  *                   -XX:TieredStopAtLevel=1
 44  *                   TestClone
 45  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
 46  *                   -XX:+UseShenandoahGC
 47  *                   -XX:TieredStopAtLevel=4
 48  *                   TestClone
 49  */
 50 
 51 /*
 52  * @test id=default-verify
 53  * @summary Test clone barriers work correctly
 54  * @requires vm.gc.Shenandoah
 55  *
 56  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
 57  *                   -XX:+UseShenandoahGC
 58  *                   -XX:+ShenandoahVerify
 59  *                   TestClone
 60  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
 61  *                   -XX:+UseShenandoahGC
 62  *                   -XX:+ShenandoahVerify
 63  *                   -Xint
 64  *                   TestClone
 65  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
 66  *                   -XX:+UseShenandoahGC
 67  *                   -XX:+ShenandoahVerify
 68  *                   -XX:-TieredCompilation
 69  *                   TestClone
 70  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
 71  *                   -XX:+UseShenandoahGC
 72  *                   -XX:+ShenandoahVerify
 73  *                   -XX:TieredStopAtLevel=1
 74  *                   TestClone
 75  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
 76  *                   -XX:+UseShenandoahGC
 77  *                   -XX:+ShenandoahVerify
 78  *                   -XX:TieredStopAtLevel=4
 79  *                   TestClone
 80  */
 81 
 82 
 83 /*
 84  * @test id=passive
 85  * @summary Test clone barriers work correctly
 86  * @requires vm.gc.Shenandoah
 87  *
 88  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
 89  *                   -XX:+UseShenandoahGC
 90  *                   -XX:ShenandoahGCMode=passive -XX:+ShenandoahCloneBarrier
 91  *                   TestClone
 92  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
 93  *                   -XX:+UseShenandoahGC
 94  *                   -XX:ShenandoahGCMode=passive -XX:+ShenandoahCloneBarrier
 95  *                   -Xint
 96  *                   TestClone
 97  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
 98  *                   -XX:+UseShenandoahGC
 99  *                   -XX:ShenandoahGCMode=passive -XX:+ShenandoahCloneBarrier
100  *                   -XX:-TieredCompilation
101  *                   TestClone
102  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
103  *                   -XX:+UseShenandoahGC
104  *                   -XX:ShenandoahGCMode=passive -XX:+ShenandoahCloneBarrier
105  *                   -XX:TieredStopAtLevel=1
106  *                   TestClone
107  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
108  *                   -XX:+UseShenandoahGC
109  *                   -XX:ShenandoahGCMode=passive -XX:+ShenandoahCloneBarrier
110  *                   -XX:TieredStopAtLevel=4
111  *                   TestClone
112  */
113 
114 /*
115  * @test id=passive-verify
116  * @summary Test clone barriers work correctly
117  * @requires vm.gc.Shenandoah
118  *
119  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
120  *                   -XX:+UseShenandoahGC
121  *                   -XX:ShenandoahGCMode=passive -XX:+ShenandoahCloneBarrier
122  *                   -XX:+ShenandoahVerify
123  *                   TestClone
124  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
125  *                   -XX:+UseShenandoahGC
126  *                   -XX:ShenandoahGCMode=passive -XX:+ShenandoahCloneBarrier
127  *                   -XX:+ShenandoahVerify
128  *                   -Xint
129  *                   TestClone
130  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
131  *                   -XX:+UseShenandoahGC
132  *                   -XX:ShenandoahGCMode=passive -XX:+ShenandoahCloneBarrier
133  *                   -XX:+ShenandoahVerify
134  *                   -XX:-TieredCompilation
135  *                   TestClone
136  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
137  *                   -XX:+UseShenandoahGC
138  *                   -XX:ShenandoahGCMode=passive -XX:+ShenandoahCloneBarrier
139  *                   -XX:+ShenandoahVerify
140  *                   -XX:TieredStopAtLevel=1
141  *                   TestClone
142  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
143  *                   -XX:+UseShenandoahGC
144  *                   -XX:ShenandoahGCMode=passive -XX:+ShenandoahCloneBarrier
145  *                   -XX:+ShenandoahVerify
146  *                   -XX:TieredStopAtLevel=4
147  *                   TestClone
148  */
149 
150 /*
151  * @test id=aggressive
152  * @summary Test clone barriers work correctly
153  * @requires vm.gc.Shenandoah
154  *
155  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
156  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
157  *                   TestClone
158  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
159  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
160  *                   -Xint
161  *                   TestClone
162  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
163  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
164  *                   -XX:-TieredCompilation
165  *                   TestClone
166  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
167  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
168  *                   -XX:TieredStopAtLevel=1
169  *                   TestClone
170  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
171  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
172  *                   -XX:TieredStopAtLevel=4
173  *                   TestClone
174  */
175 
176 /*
177  * @test id=no-coops
178  * @summary Test clone barriers work correctly
179  * @requires vm.gc.Shenandoah
180  * @requires vm.bits == "64"
181  *
182  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
183  *                   -XX:-UseCompressedOops
184  *                   -XX:+UseShenandoahGC
185  *                   TestClone
186  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
187  *                   -XX:-UseCompressedOops
188  *                   -XX:+UseShenandoahGC
189  *                   -Xint
190  *                   TestClone
191  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
192  *                   -XX:-UseCompressedOops
193  *                   -XX:+UseShenandoahGC
194  *                   -XX:-TieredCompilation
195  *                   TestClone
196  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
197  *                   -XX:-UseCompressedOops
198  *                   -XX:+UseShenandoahGC
199  *                   -XX:TieredStopAtLevel=1
200  *                   TestClone
201  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
202  *                   -XX:-UseCompressedOops
203  *                   -XX:+UseShenandoahGC
204  *                   -XX:TieredStopAtLevel=4
205  *                   TestClone
206  */
207 
208 /*
209  * @test id=no-coops-verify
210  * @summary Test clone barriers work correctly
211  * @requires vm.gc.Shenandoah
212  * @requires vm.bits == "64"
213  *
214  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
215  *                   -XX:-UseCompressedOops
216  *                   -XX:+UseShenandoahGC
217  *                   -XX:+ShenandoahVerify
218  *                   TestClone
219  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
220  *                   -XX:-UseCompressedOops
221  *                   -XX:+UseShenandoahGC
222  *                   -XX:+ShenandoahVerify
223  *                   -Xint
224  *                   TestClone
225  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
226  *                   -XX:-UseCompressedOops
227  *                   -XX:+UseShenandoahGC
228  *                   -XX:+ShenandoahVerify
229  *                   -XX:-TieredCompilation
230  *                   TestClone
231  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
232  *                   -XX:-UseCompressedOops
233  *                   -XX:+UseShenandoahGC
234  *                   -XX:+ShenandoahVerify
235  *                   -XX:TieredStopAtLevel=1
236  *                   TestClone
237  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
238  *                   -XX:-UseCompressedOops
239  *                   -XX:+UseShenandoahGC
240  *                   -XX:+ShenandoahVerify
241  *                   -XX:TieredStopAtLevel=4
242  *                   TestClone
243  */
244 
245 /*
246  * @test id=no-coops-aggressive
247  * @summary Test clone barriers work correctly
248  * @requires vm.gc.Shenandoah
249  * @requires vm.bits == "64"
250  *
251  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
252  *                   -XX:-UseCompressedOops
253  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
254  *                   TestClone
255  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
256  *                   -XX:-UseCompressedOops
257  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
258  *                   -Xint
259  *                   TestClone
260  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
261  *                   -XX:-UseCompressedOops
262  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
263  *                   -XX:-TieredCompilation
264  *                   TestClone
265  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
266  *                   -XX:-UseCompressedOops
267  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
268  *                   -XX:TieredStopAtLevel=1
269  *                   TestClone
270  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
271  *                   -XX:-UseCompressedOops
272  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
273  *                   -XX:TieredStopAtLevel=4
274  *                   TestClone
275  */
276 
277 /*
278  * @test id=generational
279  * @summary Test clone barriers work correctly
280  * @requires vm.gc.Shenandoah
281  *
282  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
283  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
284  *                   TestClone
285  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
286  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
287  *                   -Xint
288  *                   TestClone
289  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
290  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
291  *                   -XX:-TieredCompilation
292  *                   TestClone
293  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
294  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
295  *                   -XX:TieredStopAtLevel=1
296  *                   TestClone
297  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
298  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
299  *                   -XX:TieredStopAtLevel=4
300  *                   TestClone
301  */
302 
303 /*
304  * @test id=generational-small-card-size
305  * @summary Test clone barriers work correctly
306  * @requires vm.gc.Shenandoah
307  *
308  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
309  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational -XX:GCCardSizeInBytes=128
310  *                   TestClone
311  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
312  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational -XX:GCCardSizeInBytes=128
313  *                   -Xint
314  *                   TestClone
315  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
316  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational -XX:GCCardSizeInBytes=128
317  *                   -XX:-TieredCompilation
318  *                   TestClone
319  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
320  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational -XX:GCCardSizeInBytes=128
321  *                   -XX:TieredStopAtLevel=1
322  *                   TestClone
323  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
324  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational -XX:GCCardSizeInBytes=128
325  *                   -XX:TieredStopAtLevel=4
326  *                   TestClone
327  */
328 
329 /*
330  * @test id=generational-verify
331  * @summary Test clone barriers work correctly
332  * @requires vm.gc.Shenandoah
333  *
334  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
335  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
336  *                   -XX:+ShenandoahVerify
337  *                   TestClone
338  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
339  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
340  *                   -XX:+ShenandoahVerify
341  *                   -Xint
342  *                   TestClone
343  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
344  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
345  *                   -XX:+ShenandoahVerify
346  *                   -XX:-TieredCompilation
347  *                   TestClone
348  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
349  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
350  *                   -XX:+ShenandoahVerify
351  *                   -XX:TieredStopAtLevel=1
352  *                   TestClone
353  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
354  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
355  *                   -XX:+ShenandoahVerify
356  *                   -XX:TieredStopAtLevel=4
357  *                   TestClone
358  */
359 
360  /*
361   * @test id=generational-no-coops
362   * @summary Test clone barriers work correctly
363   * @requires vm.gc.Shenandoah
364   * @requires vm.bits == "64"
365   *
366   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
367   *                   -XX:-UseCompressedOops
368   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
369   *                   TestClone
370   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
371   *                   -XX:-UseCompressedOops
372   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
373   *                   -Xint
374   *                   TestClone
375   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
376   *                   -XX:-UseCompressedOops
377   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
378   *                   -XX:-TieredCompilation
379   *                   TestClone
380   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
381   *                   -XX:-UseCompressedOops
382   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
383   *                   -XX:TieredStopAtLevel=1
384   *                   TestClone
385   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
386   *                   -XX:-UseCompressedOops
387   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
388   *                   -XX:TieredStopAtLevel=4
389   *                   TestClone
390   */
391 
392  /*
393   * @test id=generational-no-coops-verify
394   * @summary Test clone barriers work correctly
395   * @requires vm.gc.Shenandoah
396   * @requires vm.bits == "64"
397   *
398   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
399   *                   -XX:-UseCompressedOops
400   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
401   *                   -XX:+ShenandoahVerify
402   *                   TestClone
403   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
404   *                   -XX:-UseCompressedOops
405   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
406   *                   -XX:+ShenandoahVerify
407   *                   -Xint
408   *                   TestClone
409   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
410   *                   -XX:-UseCompressedOops
411   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
412   *                   -XX:+ShenandoahVerify
413   *                   -XX:-TieredCompilation
414   *                   TestClone
415   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
416   *                   -XX:-UseCompressedOops
417   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
418   *                   -XX:+ShenandoahVerify
419   *                   -XX:TieredStopAtLevel=1
420   *                   TestClone
421   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
422   *                   -XX:-UseCompressedOops
423   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
424   *                   -XX:+ShenandoahVerify
425   *                   -XX:TieredStopAtLevel=4
426   *                   TestClone
427   */
428 
429 public class TestClone {
430 
431     public static void main(String[] args) throws Exception {
432         for (int i = 0; i < 10000; i++) {
433             Object[] src = new Object[i];
434             for (int c = 0; c < src.length; c++) {
435                 src[c] = new Object();
436             }
437             testWith(src);
438 
439             testWithObject(new SmallObject());
440             testWithObject(new LargeObject());
441         }
442     }
443 
444     static void testWith(Object[] src) {
445         Object[] dst = src.clone();
446         int srcLen = src.length;
447         int dstLen = dst.length;
448         if (srcLen != dstLen) {
449             throw new IllegalStateException("Lengths do not match: " + srcLen + " vs " + dstLen);
450         }
451         for (int c = 0; c < src.length; c++) {
452             Object s = src[c];
453             Object d = dst[c];
454             if (s != d) {
455                 throw new IllegalStateException("Elements do not match at " + c + ": " + s + " vs " + d + ", len = " + srcLen);
456             }
457         }
458     }
459 
460     static void testWithObject(SmallObject src) {
461         SmallObject dst = src.clone();
462         if (dst.x1 != src.x1 ||
463             dst.x2 != src.x2 ||
464             dst.x3 != src.x3 ||
465             dst.x4 != src.x4) {
466             throw new IllegalStateException("Contents do not match");
467         }
468     }
469 
470     static void testWithObject(LargeObject src) {
471         LargeObject dst = src.clone();
472         if (dst.x01 != src.x01 ||
473             dst.x02 != src.x02 ||
474             dst.x03 != src.x03 ||
475             dst.x04 != src.x04 ||
476             dst.x05 != src.x05 ||
477             dst.x06 != src.x06 ||
478             dst.x07 != src.x07 ||
479             dst.x08 != src.x08 ||
480             dst.x09 != src.x09 ||
481             dst.x10 != src.x10 ||
482             dst.x11 != src.x11 ||
483             dst.x12 != src.x12 ||
484             dst.x13 != src.x13 ||
485             dst.x14 != src.x14 ||
486             dst.x15 != src.x15 ||
487             dst.x16 != src.x16) {
488             throw new IllegalStateException("Contents do not match");
489         }
490     }
491 
492     static class SmallObject implements Cloneable {
493         Object x1 = new Object();
494         Object x2 = new Object();
495         Object x3 = new Object();
496         Object x4 = new Object();
497 
498         @Override
499         public SmallObject clone() {
500             try {
501                 return (SmallObject) super.clone();
502             } catch (CloneNotSupportedException e) {
503                 throw new AssertionError();
504             }
505         }
506     }
507 
508     static class LargeObject implements Cloneable {
509         Object x01 = new Object();
510         Object x02 = new Object();
511         Object x03 = new Object();
512         Object x04 = new Object();
513         Object x05 = new Object();
514         Object x06 = new Object();
515         Object x07 = new Object();
516         Object x08 = new Object();
517         Object x09 = new Object();
518         Object x10 = new Object();
519         Object x11 = new Object();
520         Object x12 = new Object();
521         Object x13 = new Object();
522         Object x14 = new Object();
523         Object x15 = new Object();
524         Object x16 = new Object();
525 
526         @Override
527         public LargeObject clone() {
528             try {
529                 return (LargeObject) super.clone();
530             } catch (CloneNotSupportedException e) {
531                 throw new AssertionError();
532             }
533         }
534     }
535 }
536