Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/gc/g1/TestInvalidateArrayCopy.java
40942 views
1
/*
2
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
package gc.g1;
25
26
/*
27
* @test TestInvalidateArrayCopy
28
* @bug 8182050
29
* @summary Check that benign (0-sized) out of heap bounds card table invalidations do not assert.
30
* @requires vm.gc.G1
31
* @requires vm.debug
32
* @run main/othervm -XX:NewSize=1M -Xlog:gc -XX:MaxNewSize=1m -XX:-UseTLAB -XX:OldSize=63M -XX:MaxHeapSize=64M gc.g1.TestInvalidateArrayCopy
33
*/
34
35
// The test allocates zero-sized arrays of j.l.O and tries to arraycopy random data into it so
36
// that the asserting post barrier calls are executed. It assumes that G1 allocates eden regions
37
// at the top of the heap for this problem to occur.
38
public class TestInvalidateArrayCopy {
39
40
static final int NumIterations = 1000000;
41
42
// "Random" source data to "copy" into the target.
43
static Object[] sourceArray = new Object[10];
44
45
public static void main(String[] args) {
46
for (int i = 0; i < NumIterations; i++) {
47
Object[] x = new Object[0];
48
// Make sure that the compiler can't optimize out the above allocations.
49
if (i % (NumIterations / 10) == 0) {
50
System.out.println(x);
51
}
52
System.arraycopy(sourceArray, 0, x, 0, Math.min(x.length, sourceArray.length));
53
}
54
}
55
}
56
57