Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/misc/HashedGarbageProducer.java
42165 views
1
/*
2
* Copyright (c) 2007, 2018, 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 nsk.share.gc.gp.misc;
25
26
import nsk.share.gc.gp.DerivedProducer;
27
import nsk.share.gc.gp.GarbageProducer;
28
29
/*
30
* Garbage producer that also calls {@link java.lang.System#identityHashCode(java.lang.Object)} on produced object.
31
*/
32
33
/*
34
The description is misleading. I looked at some old email, and the
35
goal is to stress the code that deals with displaced mark words, so
36
the description should be more like "Stress tests for displaced mark
37
words." In hotspot, each object has a mark word that stores several
38
things about the object including its hash code (if it has one) and
39
lock state. Most objects never have a hash code and are never locked,
40
so the mark word is empty.
41
42
Most of our garbage collectors use the mark word temporarily during GC
43
to store a 'forwarding pointer.' It's not important what that is, but
44
it means that objects that have a hash code or that are locked have to
45
have the mark word saved during GC and then restored at the end of GC.
46
We want to exercise this saving/restoring code. So a test case should
47
have a large percentage (40-50%) of objects that either have a hash
48
code or are locked.
49
50
*/
51
public class HashedGarbageProducer<T> extends DerivedProducer<T, T> {
52
public HashedGarbageProducer(GarbageProducer<T> parent) {
53
super(parent);
54
}
55
56
public T create(long memory) {
57
T obj = createParent(memory);
58
System.identityHashCode(obj);
59
return obj;
60
}
61
62
public void validate(T obj) {
63
validateParent(obj);
64
}
65
}
66
67