author | iklam |
Tue, 14 Aug 2018 09:59:37 -0700 | |
changeset 51491 | 187c84a5efe1 |
parent 50882 | 80abf702eed8 |
child 51516 | 7c3891b9f1e0 |
permissions | -rw-r--r-- |
8725
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
1 |
/* |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
50882
diff
changeset
|
2 |
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. |
8725
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
4 |
* |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
8 |
* |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
13 |
* accompanied this code). |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
14 |
* |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
18 |
* |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
21 |
* questions. |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
22 |
* |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
23 |
*/ |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
24 |
|
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
25 |
#include "precompiled.hpp" |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
26 |
#include "classfile/javaClasses.hpp" |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
27 |
#include "classfile/systemDictionary.hpp" |
30764 | 28 |
#include "gc/shared/collectedHeap.inline.hpp" |
25356
4a4a482298a6
8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
23872
diff
changeset
|
29 |
#include "memory/iterator.inline.hpp" |
8725
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
30 |
#include "memory/oopFactory.hpp" |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
31 |
#include "oops/instanceKlass.hpp" |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
32 |
#include "oops/instanceMirrorKlass.hpp" |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
33 |
#include "oops/instanceOop.hpp" |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
34 |
#include "oops/oop.inline.hpp" |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
35 |
#include "oops/symbol.hpp" |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
36 |
#include "runtime/handles.inline.hpp" |
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
13738
diff
changeset
|
37 |
#include "utilities/macros.hpp" |
8725
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
38 |
|
13738
d67be49a5beb
7195833: NPG: Rename instanceClassLoaderKlass, instanceRefKlass and instanceMirrorKlass
coleenp
parents:
13728
diff
changeset
|
39 |
int InstanceMirrorKlass::_offset_of_static_fields = 0; |
8725
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
40 |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39695
diff
changeset
|
41 |
int InstanceMirrorKlass::instance_size(Klass* k) { |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39695
diff
changeset
|
42 |
if (k != NULL && k->is_instance_klass()) { |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39695
diff
changeset
|
43 |
return align_object_size(size_helper() + InstanceKlass::cast(k)->static_field_size()); |
8725
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
44 |
} |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
45 |
return size_helper(); |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
46 |
} |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
47 |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
39695
diff
changeset
|
48 |
instanceOop InstanceMirrorKlass::allocate_instance(Klass* k, TRAPS) { |
8725
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
49 |
// Query before forming handle. |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
50 |
int size = instance_size(k); |
39695
946f1321c075
8158946: btree009 fails with assert(s > 0) failed: Bad size calculated
drwhite
parents:
33611
diff
changeset
|
51 |
assert(size > 0, "total object size must be positive: %d", size); |
23872
536c66fc43d3
8028497: SIGSEGV at ClassLoaderData::oops_do(OopClosure*, KlassClosure*, bool)
coleenp
parents:
22234
diff
changeset
|
52 |
|
536c66fc43d3
8028497: SIGSEGV at ClassLoaderData::oops_do(OopClosure*, KlassClosure*, bool)
coleenp
parents:
22234
diff
changeset
|
53 |
// Since mirrors can be variable sized because of the static fields, store |
536c66fc43d3
8028497: SIGSEGV at ClassLoaderData::oops_do(OopClosure*, KlassClosure*, bool)
coleenp
parents:
22234
diff
changeset
|
54 |
// the size in the mirror itself. |
50882
80abf702eed8
8205683: Refactor heap allocation to separate concerns
eosterlund
parents:
50752
diff
changeset
|
55 |
return (instanceOop)Universe::heap()->class_allocate(this, size, CHECK_NULL); |
8725
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
56 |
} |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
57 |
|
13738
d67be49a5beb
7195833: NPG: Rename instanceClassLoaderKlass, instanceRefKlass and instanceMirrorKlass
coleenp
parents:
13728
diff
changeset
|
58 |
int InstanceMirrorKlass::oop_size(oop obj) const { |
8725
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
59 |
return java_lang_Class::oop_size(obj); |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
60 |
} |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
61 |
|
13738
d67be49a5beb
7195833: NPG: Rename instanceClassLoaderKlass, instanceRefKlass and instanceMirrorKlass
coleenp
parents:
13728
diff
changeset
|
62 |
int InstanceMirrorKlass::compute_static_oop_field_count(oop obj) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10742
diff
changeset
|
63 |
Klass* k = java_lang_Class::as_Klass(obj); |
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
30764
diff
changeset
|
64 |
if (k != NULL && k->is_instance_klass()) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10742
diff
changeset
|
65 |
return InstanceKlass::cast(k)->static_oop_field_count(); |
8725
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
66 |
} |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
67 |
return 0; |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff
changeset
|
68 |
} |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
50882
diff
changeset
|
69 |
|
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
50882
diff
changeset
|
70 |
#if INCLUDE_CDS |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
50882
diff
changeset
|
71 |
void InstanceMirrorKlass::serialize_offsets(SerializeClosure* f) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
50882
diff
changeset
|
72 |
f->do_u4((u4*)&_offset_of_static_fields); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
50882
diff
changeset
|
73 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
50882
diff
changeset
|
74 |
#endif |