author | coleenp |
Wed, 24 Jul 2019 10:22:11 -0400 | |
changeset 57511 | 00ae3b739184 |
parent 50277 | f84ae8aa5d88 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
50277
f84ae8aa5d88
8203028: Simplify reference processing in light of JDK-8175797
kbarrett
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4573
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4573
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4573
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "classfile/javaClasses.hpp" |
|
27 |
#include "classfile/systemDictionary.hpp" |
|
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29792
diff
changeset
|
28 |
#include "oops/instanceRefKlass.inline.hpp" |
7397 | 29 |
#include "oops/oop.inline.hpp" |
1 | 30 |
|
13738
d67be49a5beb
7195833: NPG: Rename instanceClassLoaderKlass, instanceRefKlass and instanceMirrorKlass
coleenp
parents:
13728
diff
changeset
|
31 |
void InstanceRefKlass::update_nonstatic_oop_maps(Klass* k) { |
1 | 32 |
// Clear the nonstatic oop-map entries corresponding to referent |
50277
f84ae8aa5d88
8203028: Simplify reference processing in light of JDK-8175797
kbarrett
parents:
47216
diff
changeset
|
33 |
// and discovered fields. They are treated specially by the |
1 | 34 |
// garbage collector. |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12780
diff
changeset
|
35 |
InstanceKlass* ik = InstanceKlass::cast(k); |
1 | 36 |
|
37 |
// Check that we have the right class |
|
38 |
debug_only(static bool first_time = true); |
|
4571 | 39 |
assert(k == SystemDictionary::Reference_klass() && first_time, |
1 | 40 |
"Invalid update of maps"); |
41 |
debug_only(first_time = false); |
|
3693 | 42 |
assert(ik->nonstatic_oop_map_count() == 1, "just checking"); |
1 | 43 |
|
44 |
OopMapBlock* map = ik->start_of_nonstatic_oop_maps(); |
|
45 |
||
50277
f84ae8aa5d88
8203028: Simplify reference processing in light of JDK-8175797
kbarrett
parents:
47216
diff
changeset
|
46 |
#ifdef ASSERT |
f84ae8aa5d88
8203028: Simplify reference processing in light of JDK-8175797
kbarrett
parents:
47216
diff
changeset
|
47 |
// Verify fields are in the expected places. |
f84ae8aa5d88
8203028: Simplify reference processing in light of JDK-8175797
kbarrett
parents:
47216
diff
changeset
|
48 |
int referent_offset = java_lang_ref_Reference::referent_offset; |
f84ae8aa5d88
8203028: Simplify reference processing in light of JDK-8175797
kbarrett
parents:
47216
diff
changeset
|
49 |
int queue_offset = java_lang_ref_Reference::queue_offset; |
f84ae8aa5d88
8203028: Simplify reference processing in light of JDK-8175797
kbarrett
parents:
47216
diff
changeset
|
50 |
int next_offset = java_lang_ref_Reference::next_offset; |
f84ae8aa5d88
8203028: Simplify reference processing in light of JDK-8175797
kbarrett
parents:
47216
diff
changeset
|
51 |
int discovered_offset = java_lang_ref_Reference::discovered_offset; |
f84ae8aa5d88
8203028: Simplify reference processing in light of JDK-8175797
kbarrett
parents:
47216
diff
changeset
|
52 |
assert(referent_offset < queue_offset, "just checking"); |
f84ae8aa5d88
8203028: Simplify reference processing in light of JDK-8175797
kbarrett
parents:
47216
diff
changeset
|
53 |
assert(queue_offset < next_offset, "just checking"); |
f84ae8aa5d88
8203028: Simplify reference processing in light of JDK-8175797
kbarrett
parents:
47216
diff
changeset
|
54 |
assert(next_offset < discovered_offset, "just checking"); |
f84ae8aa5d88
8203028: Simplify reference processing in light of JDK-8175797
kbarrett
parents:
47216
diff
changeset
|
55 |
const unsigned int count = |
f84ae8aa5d88
8203028: Simplify reference processing in light of JDK-8175797
kbarrett
parents:
47216
diff
changeset
|
56 |
1 + ((discovered_offset - referent_offset) / heapOopSize); |
f84ae8aa5d88
8203028: Simplify reference processing in light of JDK-8175797
kbarrett
parents:
47216
diff
changeset
|
57 |
assert(count == 4, "just checking"); |
f84ae8aa5d88
8203028: Simplify reference processing in light of JDK-8175797
kbarrett
parents:
47216
diff
changeset
|
58 |
#endif // ASSERT |
1 | 59 |
|
50277
f84ae8aa5d88
8203028: Simplify reference processing in light of JDK-8175797
kbarrett
parents:
47216
diff
changeset
|
60 |
// Updated map starts at "queue", covers "queue" and "next". |
f84ae8aa5d88
8203028: Simplify reference processing in light of JDK-8175797
kbarrett
parents:
47216
diff
changeset
|
61 |
const int new_offset = java_lang_ref_Reference::queue_offset; |
f84ae8aa5d88
8203028: Simplify reference processing in light of JDK-8175797
kbarrett
parents:
47216
diff
changeset
|
62 |
const unsigned int new_count = 2; // queue and next |
f84ae8aa5d88
8203028: Simplify reference processing in light of JDK-8175797
kbarrett
parents:
47216
diff
changeset
|
63 |
|
f84ae8aa5d88
8203028: Simplify reference processing in light of JDK-8175797
kbarrett
parents:
47216
diff
changeset
|
64 |
// Verify existing map is as expected, and update if needed. |
1 | 65 |
if (UseSharedSpaces) { |
50277
f84ae8aa5d88
8203028: Simplify reference processing in light of JDK-8175797
kbarrett
parents:
47216
diff
changeset
|
66 |
assert(map->offset() == new_offset, "just checking"); |
f84ae8aa5d88
8203028: Simplify reference processing in light of JDK-8175797
kbarrett
parents:
47216
diff
changeset
|
67 |
assert(map->count() == new_count, "just checking"); |
1 | 68 |
} else { |
50277
f84ae8aa5d88
8203028: Simplify reference processing in light of JDK-8175797
kbarrett
parents:
47216
diff
changeset
|
69 |
assert(map->offset() == referent_offset, "just checking"); |
f84ae8aa5d88
8203028: Simplify reference processing in light of JDK-8175797
kbarrett
parents:
47216
diff
changeset
|
70 |
assert(map->count() == count, "just checking"); |
f84ae8aa5d88
8203028: Simplify reference processing in light of JDK-8175797
kbarrett
parents:
47216
diff
changeset
|
71 |
map->set_offset(new_offset); |
f84ae8aa5d88
8203028: Simplify reference processing in light of JDK-8175797
kbarrett
parents:
47216
diff
changeset
|
72 |
map->set_count(new_count); |
1 | 73 |
} |
74 |
} |
|
75 |
||
76 |
||
77 |
// Verification |
|
78 |
||
13738
d67be49a5beb
7195833: NPG: Rename instanceClassLoaderKlass, instanceRefKlass and instanceMirrorKlass
coleenp
parents:
13728
diff
changeset
|
79 |
void InstanceRefKlass::oop_verify_on(oop obj, outputStream* st) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12780
diff
changeset
|
80 |
InstanceKlass::oop_verify_on(obj, st); |
1 | 81 |
// Verify referent field |
82 |
oop referent = java_lang_ref_Reference::referent(obj); |
|
83 |
if (referent != NULL) { |
|
46968
9119841280f4
8160399: is_oop_or_null involves undefined behavior
coleenp
parents:
37129
diff
changeset
|
84 |
guarantee(oopDesc::is_oop(referent), "referent field heap failed"); |
1 | 85 |
} |
50277
f84ae8aa5d88
8203028: Simplify reference processing in light of JDK-8175797
kbarrett
parents:
47216
diff
changeset
|
86 |
// Additional verification for next field, which must be a Reference or null |
1 | 87 |
oop next = java_lang_ref_Reference::next(obj); |
88 |
if (next != NULL) { |
|
46968
9119841280f4
8160399: is_oop_or_null involves undefined behavior
coleenp
parents:
37129
diff
changeset
|
89 |
guarantee(oopDesc::is_oop(next), "next field should be an oop"); |
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
33148
diff
changeset
|
90 |
guarantee(next->is_instance(), "next field should be an instance"); |
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
33148
diff
changeset
|
91 |
guarantee(InstanceKlass::cast(next->klass())->is_reference_instance_klass(), "next field verify failed"); |
1 | 92 |
} |
93 |
} |