author | goetz |
Fri, 15 Jun 2018 12:25:53 +0200 | |
changeset 50601 | 3fbae7b9ddb5 |
parent 50389 | 7e8c0409a747 |
child 50752 | 9d62da00bf15 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
49359
59f6547e151f
8199264: Remove universe.inline.hpp to simplify include dependencies
stefank
parents:
47998
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:
5076
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5076
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:
5076
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
38094
46977cd73d86
8152844: JVM InstanceKlass Methods For Obtaining Package/Module Should Be Moved to Klass
rprotacio
parents:
37190
diff
changeset
|
26 |
#include "classfile/moduleEntry.hpp" |
46977cd73d86
8152844: JVM InstanceKlass Methods For Obtaining Package/Module Should Be Moved to Klass
rprotacio
parents:
37190
diff
changeset
|
27 |
#include "classfile/packageEntry.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
28 |
#include "classfile/symbolTable.hpp" |
7397 | 29 |
#include "classfile/systemDictionary.hpp" |
30 |
#include "classfile/vmSymbols.hpp" |
|
30764 | 31 |
#include "gc/shared/collectedHeap.inline.hpp" |
32 |
#include "gc/shared/specialized_oop_closures.hpp" |
|
25356
4a4a482298a6
8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
24351
diff
changeset
|
33 |
#include "memory/iterator.inline.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
34 |
#include "memory/metadataFactory.hpp" |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46329
diff
changeset
|
35 |
#include "memory/metaspaceClosure.hpp" |
7397 | 36 |
#include "memory/resourceArea.hpp" |
49359
59f6547e151f
8199264: Remove universe.inline.hpp to simplify include dependencies
stefank
parents:
47998
diff
changeset
|
37 |
#include "memory/universe.hpp" |
40887
8d35e19f5548
8158854: Ensure release_store is paired with load_acquire in lock-free code
dholmes
parents:
38094
diff
changeset
|
38 |
#include "oops/arrayKlass.inline.hpp" |
7397 | 39 |
#include "oops/instanceKlass.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
40 |
#include "oops/klass.inline.hpp" |
7397 | 41 |
#include "oops/objArrayKlass.inline.hpp" |
29081
c61eb4914428
8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
27680
diff
changeset
|
42 |
#include "oops/objArrayOop.inline.hpp" |
7397 | 43 |
#include "oops/oop.inline.hpp" |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7890
diff
changeset
|
44 |
#include "oops/symbol.hpp" |
7397 | 45 |
#include "runtime/handles.inline.hpp" |
46 |
#include "runtime/mutexLocker.hpp" |
|
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
14588
diff
changeset
|
47 |
#include "utilities/macros.hpp" |
1 | 48 |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
40887
diff
changeset
|
49 |
ObjArrayKlass* ObjArrayKlass::allocate(ClassLoaderData* loader_data, int n, Klass* k, Symbol* name, TRAPS) { |
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
50 |
assert(ObjArrayKlass::header_size() <= InstanceKlass::header_size(), |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
51 |
"array klasses must be same size as InstanceKlass"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
52 |
|
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
53 |
int size = ArrayKlass::static_size(ObjArrayKlass::header_size()); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
54 |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
40887
diff
changeset
|
55 |
return new (loader_data, size, THREAD) ObjArrayKlass(n, k, name); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
56 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
57 |
|
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
58 |
Klass* ObjArrayKlass::allocate_objArray_klass(ClassLoaderData* loader_data, |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
40887
diff
changeset
|
59 |
int n, Klass* element_klass, TRAPS) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
60 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
61 |
// Eagerly allocate the direct array supertype. |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
40887
diff
changeset
|
62 |
Klass* super_klass = NULL; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
63 |
if (!Universe::is_bootstrapping() || SystemDictionary::Object_klass_loaded()) { |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
40887
diff
changeset
|
64 |
Klass* element_super = element_klass->super(); |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
40887
diff
changeset
|
65 |
if (element_super != NULL) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
66 |
// The element type has a direct super. E.g., String[] has direct super of Object[]. |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
40887
diff
changeset
|
67 |
super_klass = element_super->array_klass_or_null(); |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
40887
diff
changeset
|
68 |
bool supers_exist = super_klass != NULL; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
69 |
// Also, see if the element has secondary supertypes. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
70 |
// We need an array type for each. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
71 |
Array<Klass*>* element_supers = element_klass->secondary_supers(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
72 |
for( int i = element_supers->length()-1; i >= 0; i-- ) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
73 |
Klass* elem_super = element_supers->at(i); |
14488 | 74 |
if (elem_super->array_klass_or_null() == NULL) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
75 |
supers_exist = false; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
76 |
break; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
77 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
78 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
79 |
if (!supers_exist) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
80 |
// Oops. Not allocated yet. Back out, allocate it, and retry. |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
40887
diff
changeset
|
81 |
Klass* ek = NULL; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
82 |
{ |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
83 |
MutexUnlocker mu(MultiArray_lock); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
84 |
MutexUnlocker mc(Compile_lock); // for vtables |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
40887
diff
changeset
|
85 |
super_klass = element_super->array_klass(CHECK_0); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
86 |
for( int i = element_supers->length()-1; i >= 0; i-- ) { |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
40887
diff
changeset
|
87 |
Klass* elem_super = element_supers->at(i); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
88 |
elem_super->array_klass(CHECK_0); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
89 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
90 |
// Now retry from the beginning |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
40887
diff
changeset
|
91 |
ek = element_klass->array_klass(n, CHECK_0); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
92 |
} // re-lock |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
40887
diff
changeset
|
93 |
return ek; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
94 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
95 |
} else { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
96 |
// The element type is already Object. Object[] has direct super of Object. |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
40887
diff
changeset
|
97 |
super_klass = SystemDictionary::Object_klass(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
98 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
99 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
100 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
101 |
// Create type name for klass. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
102 |
Symbol* name = NULL; |
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
31592
diff
changeset
|
103 |
if (!element_klass->is_instance_klass() || |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
40887
diff
changeset
|
104 |
(name = InstanceKlass::cast(element_klass)->array_name()) == NULL) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
105 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
106 |
ResourceMark rm(THREAD); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
107 |
char *name_str = element_klass->name()->as_C_string(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
108 |
int len = element_klass->name()->utf8_length(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
109 |
char *new_str = NEW_RESOURCE_ARRAY(char, len + 4); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
110 |
int idx = 0; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
111 |
new_str[idx++] = '['; |
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
31592
diff
changeset
|
112 |
if (element_klass->is_instance_klass()) { // it could be an array or simple type |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
113 |
new_str[idx++] = 'L'; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
114 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
115 |
memcpy(&new_str[idx], name_str, len * sizeof(char)); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
116 |
idx += len; |
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
31592
diff
changeset
|
117 |
if (element_klass->is_instance_klass()) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
118 |
new_str[idx++] = ';'; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
119 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
120 |
new_str[idx++] = '\0'; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
121 |
name = SymbolTable::new_permanent_symbol(new_str, CHECK_0); |
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
31592
diff
changeset
|
122 |
if (element_klass->is_instance_klass()) { |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
40887
diff
changeset
|
123 |
InstanceKlass* ik = InstanceKlass::cast(element_klass); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
124 |
ik->set_array_name(name); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
125 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
126 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
127 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
128 |
// Initialize instance variables |
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
129 |
ObjArrayKlass* oak = ObjArrayKlass::allocate(loader_data, n, element_klass, name, CHECK_0); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
130 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
131 |
// Add all classes to our internal class loader list here, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
132 |
// including classes in the bootstrap (NULL) class loader. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
133 |
// GC walks these as strong roots. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
134 |
loader_data->add_class(oak); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
135 |
|
38094
46977cd73d86
8152844: JVM InstanceKlass Methods For Obtaining Package/Module Should Be Moved to Klass
rprotacio
parents:
37190
diff
changeset
|
136 |
ModuleEntry* module = oak->module(); |
36508 | 137 |
assert(module != NULL, "No module entry for array"); |
138 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
139 |
// Call complete_create_array_klass after all instance variables has been initialized. |
36508 | 140 |
ArrayKlass::complete_create_array_klass(oak, super_klass, module, CHECK_0); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
141 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
142 |
return oak; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
143 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
144 |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
40887
diff
changeset
|
145 |
ObjArrayKlass::ObjArrayKlass(int n, Klass* element_klass, Symbol* name) : ArrayKlass(name) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
146 |
this->set_dimension(n); |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
40887
diff
changeset
|
147 |
this->set_element_klass(element_klass); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
148 |
// decrement refcount because object arrays are not explicitly freed. The |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
149 |
// InstanceKlass array_name() keeps the name counted while the klass is |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
150 |
// loaded. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
151 |
name->decrement_refcount(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
152 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
153 |
Klass* bk; |
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
31592
diff
changeset
|
154 |
if (element_klass->is_objArray_klass()) { |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
40887
diff
changeset
|
155 |
bk = ObjArrayKlass::cast(element_klass)->bottom_klass(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
156 |
} else { |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
40887
diff
changeset
|
157 |
bk = element_klass; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
158 |
} |
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
31592
diff
changeset
|
159 |
assert(bk != NULL && (bk->is_instance_klass() || bk->is_typeArray_klass()), "invalid bottom klass"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
160 |
this->set_bottom_klass(bk); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
161 |
this->set_class_loader_data(bk->class_loader_data()); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
162 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
163 |
this->set_layout_helper(array_layout_helper(T_OBJECT)); |
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
31592
diff
changeset
|
164 |
assert(this->is_array_klass(), "sanity"); |
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
31592
diff
changeset
|
165 |
assert(this->is_objArray_klass(), "sanity"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
166 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
167 |
|
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
168 |
int ObjArrayKlass::oop_size(oop obj) const { |
1 | 169 |
assert(obj->is_objArray(), "must be object array"); |
170 |
return objArrayOop(obj)->object_size(); |
|
171 |
} |
|
172 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
173 |
objArrayOop ObjArrayKlass::allocate(int length, TRAPS) { |
1 | 174 |
if (length >= 0) { |
175 |
if (length <= arrayOopDesc::max_array_length(T_OBJECT)) { |
|
176 |
int size = objArrayOopDesc::object_size(length); |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
40887
diff
changeset
|
177 |
return (objArrayOop)CollectedHeap::array_allocate(this, size, length, THREAD); |
1 | 178 |
} else { |
3576
4ceec8fb3e18
6850957: Honor -XX:OnOutOfMemoryError when array size exceeds VM limit
martin
parents:
2332
diff
changeset
|
179 |
report_java_out_of_memory("Requested array size exceeds VM limit"); |
12114
9a825a536095
7123170: JCK vm/jvmti/ResourceExhausted/resexh001/resexh00101/ tests fails since 7u4 b02
sspitsyn
parents:
8297
diff
changeset
|
180 |
JvmtiExport::post_array_size_exhausted(); |
1 | 181 |
THROW_OOP_0(Universe::out_of_memory_error_array_size()); |
182 |
} |
|
183 |
} else { |
|
50304
d5331b94f821
8203881: Print erroneous size in NegativeArraySizeException
goetz
parents:
50094
diff
changeset
|
184 |
THROW_MSG_0(vmSymbols::java_lang_NegativeArraySizeException(), err_msg("%d", length)); |
1 | 185 |
} |
186 |
} |
|
187 |
||
188 |
static int multi_alloc_counter = 0; |
|
189 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
190 |
oop ObjArrayKlass::multi_allocate(int rank, jint* sizes, TRAPS) { |
1 | 191 |
int length = *sizes; |
192 |
// Call to lower_dimension uses this pointer, so most be called before a |
|
193 |
// possible GC |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
40887
diff
changeset
|
194 |
Klass* ld_klass = lower_dimension(); |
1 | 195 |
// If length < 0 allocate will throw an exception. |
196 |
objArrayOop array = allocate(length, CHECK_NULL); |
|
197 |
objArrayHandle h_array (THREAD, array); |
|
198 |
if (rank > 1) { |
|
199 |
if (length != 0) { |
|
200 |
for (int index = 0; index < length; index++) { |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
40887
diff
changeset
|
201 |
ArrayKlass* ak = ArrayKlass::cast(ld_klass); |
1 | 202 |
oop sub_array = ak->multi_allocate(rank-1, &sizes[1], CHECK_NULL); |
203 |
h_array->obj_at_put(index, sub_array); |
|
204 |
} |
|
205 |
} else { |
|
206 |
// Since this array dimension has zero length, nothing will be |
|
207 |
// allocated, however the lower dimension values must be checked |
|
208 |
// for illegal values. |
|
209 |
for (int i = 0; i < rank - 1; ++i) { |
|
210 |
sizes += 1; |
|
211 |
if (*sizes < 0) { |
|
50304
d5331b94f821
8203881: Print erroneous size in NegativeArraySizeException
goetz
parents:
50094
diff
changeset
|
212 |
THROW_MSG_0(vmSymbols::java_lang_NegativeArraySizeException(), err_msg("%d", *sizes)); |
1 | 213 |
} |
214 |
} |
|
215 |
} |
|
216 |
} |
|
217 |
return h_array(); |
|
218 |
} |
|
219 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
220 |
// Either oop or narrowOop depending on UseCompressedOops. |
50389
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
50304
diff
changeset
|
221 |
void ObjArrayKlass::do_copy(arrayOop s, size_t src_offset, |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
50304
diff
changeset
|
222 |
arrayOop d, size_t dst_offset, int length, TRAPS) { |
49658 | 223 |
if (oopDesc::equals(s, d)) { |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
224 |
// since source and destination are equal we do not need conversion checks. |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
225 |
assert(length > 0, "sanity check"); |
50389
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
50304
diff
changeset
|
226 |
ArrayAccess<>::oop_arraycopy(s, src_offset, d, dst_offset, length); |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
227 |
} else { |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
228 |
// We have to make sure all elements conform to the destination array |
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
229 |
Klass* bound = ObjArrayKlass::cast(d->klass())->element_klass(); |
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
230 |
Klass* stype = ObjArrayKlass::cast(s->klass())->element_klass(); |
14488 | 231 |
if (stype == bound || stype->is_subtype_of(bound)) { |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
232 |
// elements are guaranteed to be subtypes, so no check necessary |
50389
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
50304
diff
changeset
|
233 |
ArrayAccess<ARRAYCOPY_DISJOINT>::oop_arraycopy(s, src_offset, d, dst_offset, length); |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
234 |
} else { |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
235 |
// slow case: need individual subtype checks |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
236 |
// note: don't use obj_at_put below because it includes a redundant store check |
50389
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
50304
diff
changeset
|
237 |
if (!ArrayAccess<ARRAYCOPY_DISJOINT | ARRAYCOPY_CHECKCAST>::oop_arraycopy(s, src_offset, d, dst_offset, length)) { |
50601 | 238 |
ResourceMark rm(THREAD); |
239 |
stringStream ss; |
|
240 |
if (!bound->is_subtype_of(stype)) { |
|
241 |
ss.print("arraycopy: type mismatch: can not copy %s[] into %s[]", |
|
242 |
stype->external_name(), bound->external_name()); |
|
243 |
} else { |
|
244 |
// oop_arraycopy should return the index in the source array that |
|
245 |
// contains the problematic oop. |
|
246 |
ss.print("arraycopy: element type mismatch: can not cast one of the elements" |
|
247 |
" of %s[] to the type of the destination array, %s", |
|
248 |
stype->external_name(), bound->external_name()); |
|
249 |
} |
|
250 |
THROW_MSG(vmSymbols::java_lang_ArrayStoreException(), ss.as_string()); |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
251 |
} |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
252 |
} |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
253 |
} |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
254 |
} |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
255 |
|
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
256 |
void ObjArrayKlass::copy_array(arrayOop s, int src_pos, arrayOop d, |
1 | 257 |
int dst_pos, int length, TRAPS) { |
258 |
assert(s->is_objArray(), "must be obj array"); |
|
259 |
||
260 |
if (!d->is_objArray()) { |
|
50601 | 261 |
ResourceMark rm(THREAD); |
262 |
stringStream ss; |
|
263 |
if (d->is_typeArray()) { |
|
264 |
ss.print("arraycopy: type mismatch: can not copy object array[] into %s[]", |
|
265 |
type2name_tab[ArrayKlass::cast(d->klass())->element_type()]); |
|
266 |
} else { |
|
267 |
ss.print("arraycopy: destination type %s is not an array", d->klass()->external_name()); |
|
268 |
} |
|
269 |
THROW_MSG(vmSymbols::java_lang_ArrayStoreException(), ss.as_string()); |
|
1 | 270 |
} |
271 |
||
272 |
// Check is all offsets and lengths are non negative |
|
273 |
if (src_pos < 0 || dst_pos < 0 || length < 0) { |
|
50094
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49948
diff
changeset
|
274 |
// Pass specific exception reason. |
50601 | 275 |
ResourceMark rm(THREAD); |
50094
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49948
diff
changeset
|
276 |
stringStream ss; |
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49948
diff
changeset
|
277 |
if (src_pos < 0) { |
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49948
diff
changeset
|
278 |
ss.print("arraycopy: source index %d out of bounds for object array[%d]", |
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49948
diff
changeset
|
279 |
src_pos, s->length()); |
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49948
diff
changeset
|
280 |
} else if (dst_pos < 0) { |
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49948
diff
changeset
|
281 |
ss.print("arraycopy: destination index %d out of bounds for object array[%d]", |
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49948
diff
changeset
|
282 |
dst_pos, d->length()); |
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49948
diff
changeset
|
283 |
} else { |
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49948
diff
changeset
|
284 |
ss.print("arraycopy: length %d is negative", length); |
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49948
diff
changeset
|
285 |
} |
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49948
diff
changeset
|
286 |
THROW_MSG(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), ss.as_string()); |
1 | 287 |
} |
288 |
// Check if the ranges are valid |
|
50094
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49948
diff
changeset
|
289 |
if ((((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length()) || |
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49948
diff
changeset
|
290 |
(((unsigned int) length + (unsigned int) dst_pos) > (unsigned int) d->length())) { |
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49948
diff
changeset
|
291 |
// Pass specific exception reason. |
50601 | 292 |
ResourceMark rm(THREAD); |
50094
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49948
diff
changeset
|
293 |
stringStream ss; |
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49948
diff
changeset
|
294 |
if (((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length()) { |
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49948
diff
changeset
|
295 |
ss.print("arraycopy: last source index %u out of bounds for object array[%d]", |
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49948
diff
changeset
|
296 |
(unsigned int) length + (unsigned int) src_pos, s->length()); |
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49948
diff
changeset
|
297 |
} else { |
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49948
diff
changeset
|
298 |
ss.print("arraycopy: last destination index %u out of bounds for object array[%d]", |
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49948
diff
changeset
|
299 |
(unsigned int) length + (unsigned int) dst_pos, d->length()); |
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49948
diff
changeset
|
300 |
} |
2f79462aab9b
8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents:
49948
diff
changeset
|
301 |
THROW_MSG(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), ss.as_string()); |
1 | 302 |
} |
303 |
||
304 |
// Special case. Boundary cases must be checked first |
|
305 |
// This allows the following call: copy_array(s, s.length(), d.length(), 0). |
|
306 |
// This is correct, since the position is supposed to be an 'in between point', i.e., s.length(), |
|
307 |
// points to the right of the last element. |
|
308 |
if (length==0) { |
|
309 |
return; |
|
310 |
} |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
311 |
if (UseCompressedOops) { |
50389
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
50304
diff
changeset
|
312 |
size_t src_offset = (size_t) objArrayOopDesc::obj_at_offset<narrowOop>(src_pos); |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
50304
diff
changeset
|
313 |
size_t dst_offset = (size_t) objArrayOopDesc::obj_at_offset<narrowOop>(dst_pos); |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
50304
diff
changeset
|
314 |
assert(arrayOopDesc::obj_offset_to_raw<narrowOop>(s, src_offset, NULL) == |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
50304
diff
changeset
|
315 |
objArrayOop(s)->obj_at_addr<narrowOop>(src_pos), "sanity"); |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
50304
diff
changeset
|
316 |
assert(arrayOopDesc::obj_offset_to_raw<narrowOop>(d, dst_offset, NULL) == |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
50304
diff
changeset
|
317 |
objArrayOop(d)->obj_at_addr<narrowOop>(dst_pos), "sanity"); |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
50304
diff
changeset
|
318 |
do_copy(s, src_offset, d, dst_offset, length, CHECK); |
1 | 319 |
} else { |
50389
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
50304
diff
changeset
|
320 |
size_t src_offset = (size_t) objArrayOopDesc::obj_at_offset<oop>(src_pos); |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
50304
diff
changeset
|
321 |
size_t dst_offset = (size_t) objArrayOopDesc::obj_at_offset<oop>(dst_pos); |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
50304
diff
changeset
|
322 |
assert(arrayOopDesc::obj_offset_to_raw<oop>(s, src_offset, NULL) == |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
50304
diff
changeset
|
323 |
objArrayOop(s)->obj_at_addr<oop>(src_pos), "sanity"); |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
50304
diff
changeset
|
324 |
assert(arrayOopDesc::obj_offset_to_raw<oop>(d, dst_offset, NULL) == |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
50304
diff
changeset
|
325 |
objArrayOop(d)->obj_at_addr<oop>(dst_pos), "sanity"); |
7e8c0409a747
8198285: More consistent Access API for arraycopy
rkennke
parents:
50304
diff
changeset
|
326 |
do_copy(s, src_offset, d, dst_offset, length, CHECK); |
1 | 327 |
} |
328 |
} |
|
329 |
||
330 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
331 |
Klass* ObjArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) { |
1 | 332 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
333 |
assert(dimension() <= n, "check order of chain"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
334 |
int dim = dimension(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
335 |
if (dim == n) return this; |
1 | 336 |
|
40887
8d35e19f5548
8158854: Ensure release_store is paired with load_acquire in lock-free code
dholmes
parents:
38094
diff
changeset
|
337 |
// lock-free read needs acquire semantics |
8d35e19f5548
8158854: Ensure release_store is paired with load_acquire in lock-free code
dholmes
parents:
38094
diff
changeset
|
338 |
if (higher_dimension_acquire() == NULL) { |
1 | 339 |
if (or_null) return NULL; |
340 |
||
341 |
ResourceMark rm; |
|
342 |
JavaThread *jt = (JavaThread *)THREAD; |
|
343 |
{ |
|
344 |
MutexLocker mc(Compile_lock, THREAD); // for vtables |
|
345 |
// Ensure atomic creation of higher dimensions |
|
346 |
MutexLocker mu(MultiArray_lock, THREAD); |
|
347 |
||
348 |
// Check if another thread beat us |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
349 |
if (higher_dimension() == NULL) { |
1 | 350 |
|
351 |
// Create multi-dim klass object and link them together |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
352 |
Klass* k = |
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
353 |
ObjArrayKlass::allocate_objArray_klass(class_loader_data(), dim + 1, this, CHECK_NULL); |
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
354 |
ObjArrayKlass* ak = ObjArrayKlass::cast(k); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
355 |
ak->set_lower_dimension(this); |
40887
8d35e19f5548
8158854: Ensure release_store is paired with load_acquire in lock-free code
dholmes
parents:
38094
diff
changeset
|
356 |
// use 'release' to pair with lock-free load |
8d35e19f5548
8158854: Ensure release_store is paired with load_acquire in lock-free code
dholmes
parents:
38094
diff
changeset
|
357 |
release_set_higher_dimension(ak); |
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
31592
diff
changeset
|
358 |
assert(ak->is_objArray_klass(), "incorrect initialization of ObjArrayKlass"); |
1 | 359 |
} |
360 |
} |
|
361 |
} else { |
|
362 |
CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops()); |
|
363 |
} |
|
364 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
365 |
ObjArrayKlass *ak = ObjArrayKlass::cast(higher_dimension()); |
1 | 366 |
if (or_null) { |
367 |
return ak->array_klass_or_null(n); |
|
368 |
} |
|
27680
8ecc0871c18e
8064811: Use THREAD instead of CHECK_NULL in return statements
stefank
parents:
26316
diff
changeset
|
369 |
return ak->array_klass(n, THREAD); |
1 | 370 |
} |
371 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
372 |
Klass* ObjArrayKlass::array_klass_impl(bool or_null, TRAPS) { |
27680
8ecc0871c18e
8064811: Use THREAD instead of CHECK_NULL in return statements
stefank
parents:
26316
diff
changeset
|
373 |
return array_klass_impl(or_null, dimension() + 1, THREAD); |
1 | 374 |
} |
375 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
376 |
bool ObjArrayKlass::can_be_primary_super_slow() const { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
377 |
if (!bottom_klass()->can_be_primary_super()) |
1 | 378 |
// array of interfaces |
379 |
return false; |
|
380 |
else |
|
381 |
return Klass::can_be_primary_super_slow(); |
|
382 |
} |
|
383 |
||
49948
ff8dbb56740a
8200466: Revisit the setting of _transitive_interfaces in InstanceKlass
ccheung
parents:
49658
diff
changeset
|
384 |
GrowableArray<Klass*>* ObjArrayKlass::compute_secondary_supers(int num_extra_slots, |
ff8dbb56740a
8200466: Revisit the setting of _transitive_interfaces in InstanceKlass
ccheung
parents:
49658
diff
changeset
|
385 |
Array<Klass*>* transitive_interfaces) { |
ff8dbb56740a
8200466: Revisit the setting of _transitive_interfaces in InstanceKlass
ccheung
parents:
49658
diff
changeset
|
386 |
assert(transitive_interfaces == NULL, "sanity"); |
1 | 387 |
// interfaces = { cloneable_klass, serializable_klass, elemSuper[], ... }; |
14488 | 388 |
Array<Klass*>* elem_supers = element_klass()->secondary_supers(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
389 |
int num_elem_supers = elem_supers == NULL ? 0 : elem_supers->length(); |
1 | 390 |
int num_secondaries = num_extra_slots + 2 + num_elem_supers; |
391 |
if (num_secondaries == 2) { |
|
392 |
// Must share this for correct bootstrapping! |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
393 |
set_secondary_supers(Universe::the_array_interfaces_array()); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
394 |
return NULL; |
1 | 395 |
} else { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
396 |
GrowableArray<Klass*>* secondaries = new GrowableArray<Klass*>(num_elem_supers+2); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
397 |
secondaries->push(SystemDictionary::Cloneable_klass()); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
398 |
secondaries->push(SystemDictionary::Serializable_klass()); |
1 | 399 |
for (int i = 0; i < num_elem_supers; i++) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
400 |
Klass* elem_super = (Klass*) elem_supers->at(i); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
401 |
Klass* array_super = elem_super->array_klass_or_null(); |
1 | 402 |
assert(array_super != NULL, "must already have been created"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
403 |
secondaries->push(array_super); |
1 | 404 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
405 |
return secondaries; |
1 | 406 |
} |
407 |
} |
|
408 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
409 |
bool ObjArrayKlass::compute_is_subtype_of(Klass* k) { |
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
31592
diff
changeset
|
410 |
if (!k->is_objArray_klass()) |
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
411 |
return ArrayKlass::compute_is_subtype_of(k); |
1 | 412 |
|
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
413 |
ObjArrayKlass* oak = ObjArrayKlass::cast(k); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
414 |
return element_klass()->is_subtype_of(oak->element_klass()); |
1 | 415 |
} |
416 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
417 |
void ObjArrayKlass::initialize(TRAPS) { |
14488 | 418 |
bottom_klass()->initialize(THREAD); // dispatches to either InstanceKlass or TypeArrayKlass |
1 | 419 |
} |
420 |
||
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46329
diff
changeset
|
421 |
void ObjArrayKlass::metaspace_pointers_do(MetaspaceClosure* it) { |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46329
diff
changeset
|
422 |
ArrayKlass::metaspace_pointers_do(it); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46329
diff
changeset
|
423 |
it->push(&_element_klass); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46329
diff
changeset
|
424 |
it->push(&_bottom_klass); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46329
diff
changeset
|
425 |
} |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46329
diff
changeset
|
426 |
|
1 | 427 |
// JVM support |
428 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
429 |
jint ObjArrayKlass::compute_modifier_flags(TRAPS) const { |
1 | 430 |
// The modifier for an objectArray is the same as its element |
431 |
if (element_klass() == NULL) { |
|
432 |
assert(Universe::is_bootstrapping(), "partial objArray only at startup"); |
|
433 |
return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC; |
|
434 |
} |
|
1430
16aa7ef1ffa1
6700107: java/lang/Class/forName/TooManyDimensions.java crashes with SIGSEGV in c2 compiler with fastdebug
coleenp
parents:
1388
diff
changeset
|
435 |
// Return the flags of the bottom element type. |
14488 | 436 |
jint element_flags = bottom_klass()->compute_modifier_flags(CHECK_0); |
1 | 437 |
|
438 |
return (element_flags & (JVM_ACC_PUBLIC | JVM_ACC_PRIVATE | JVM_ACC_PROTECTED)) |
|
439 |
| (JVM_ACC_ABSTRACT | JVM_ACC_FINAL); |
|
440 |
} |
|
441 |
||
38094
46977cd73d86
8152844: JVM InstanceKlass Methods For Obtaining Package/Module Should Be Moved to Klass
rprotacio
parents:
37190
diff
changeset
|
442 |
ModuleEntry* ObjArrayKlass::module() const { |
46977cd73d86
8152844: JVM InstanceKlass Methods For Obtaining Package/Module Should Be Moved to Klass
rprotacio
parents:
37190
diff
changeset
|
443 |
assert(bottom_klass() != NULL, "ObjArrayKlass returned unexpected NULL bottom_klass"); |
46977cd73d86
8152844: JVM InstanceKlass Methods For Obtaining Package/Module Should Be Moved to Klass
rprotacio
parents:
37190
diff
changeset
|
444 |
// The array is defined in the module of its bottom class |
46977cd73d86
8152844: JVM InstanceKlass Methods For Obtaining Package/Module Should Be Moved to Klass
rprotacio
parents:
37190
diff
changeset
|
445 |
return bottom_klass()->module(); |
46977cd73d86
8152844: JVM InstanceKlass Methods For Obtaining Package/Module Should Be Moved to Klass
rprotacio
parents:
37190
diff
changeset
|
446 |
} |
46977cd73d86
8152844: JVM InstanceKlass Methods For Obtaining Package/Module Should Be Moved to Klass
rprotacio
parents:
37190
diff
changeset
|
447 |
|
46977cd73d86
8152844: JVM InstanceKlass Methods For Obtaining Package/Module Should Be Moved to Klass
rprotacio
parents:
37190
diff
changeset
|
448 |
PackageEntry* ObjArrayKlass::package() const { |
46977cd73d86
8152844: JVM InstanceKlass Methods For Obtaining Package/Module Should Be Moved to Klass
rprotacio
parents:
37190
diff
changeset
|
449 |
assert(bottom_klass() != NULL, "ObjArrayKlass returned unexpected NULL bottom_klass"); |
46977cd73d86
8152844: JVM InstanceKlass Methods For Obtaining Package/Module Should Be Moved to Klass
rprotacio
parents:
37190
diff
changeset
|
450 |
return bottom_klass()->package(); |
46977cd73d86
8152844: JVM InstanceKlass Methods For Obtaining Package/Module Should Be Moved to Klass
rprotacio
parents:
37190
diff
changeset
|
451 |
} |
1 | 452 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
453 |
// Printing |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
454 |
|
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
455 |
void ObjArrayKlass::print_on(outputStream* st) const { |
1 | 456 |
#ifndef PRODUCT |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
457 |
Klass::print_on(st); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
458 |
st->print(" - instance klass: "); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
459 |
element_klass()->print_value_on(st); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
460 |
st->cr(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
461 |
#endif //PRODUCT |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
462 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
463 |
|
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
464 |
void ObjArrayKlass::print_value_on(outputStream* st) const { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
465 |
assert(is_klass(), "must be klass"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
466 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
467 |
element_klass()->print_value_on(st); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
468 |
st->print("[]"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
469 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
470 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
471 |
#ifndef PRODUCT |
1 | 472 |
|
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
473 |
void ObjArrayKlass::oop_print_on(oop obj, outputStream* st) { |
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
474 |
ArrayKlass::oop_print_on(obj, st); |
1 | 475 |
assert(obj->is_objArray(), "must be objArray"); |
476 |
objArrayOop oa = objArrayOop(obj); |
|
477 |
int print_len = MIN2((intx) oa->length(), MaxElementPrintSize); |
|
478 |
for(int index = 0; index < print_len; index++) { |
|
479 |
st->print(" - %3d : ", index); |
|
480 |
oa->obj_at(index)->print_value_on(st); |
|
481 |
st->cr(); |
|
482 |
} |
|
483 |
int remaining = oa->length() - print_len; |
|
484 |
if (remaining > 0) { |
|
13922
ab7d352debe6
8000227: [obj|type]ArrayKlass::oop_print_on prints one line to tty instead of the provided output stream
stefank
parents:
13728
diff
changeset
|
485 |
st->print_cr(" - <%d more elements, increase MaxElementPrintSize to print>", remaining); |
1 | 486 |
} |
487 |
} |
|
488 |
||
4584
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
4571
diff
changeset
|
489 |
#endif //PRODUCT |
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
4571
diff
changeset
|
490 |
|
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
491 |
void ObjArrayKlass::oop_print_value_on(oop obj, outputStream* st) { |
1 | 492 |
assert(obj->is_objArray(), "must be objArray"); |
2332
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1430
diff
changeset
|
493 |
st->print("a "); |
1 | 494 |
element_klass()->print_value_on(st); |
2332
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1430
diff
changeset
|
495 |
int len = objArrayOop(obj)->length(); |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1430
diff
changeset
|
496 |
st->print("[%d] ", len); |
5c7b6f4ce0a1
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
1430
diff
changeset
|
497 |
obj->print_address_on(st); |
1 | 498 |
} |
499 |
||
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
500 |
const char* ObjArrayKlass::internal_name() const { |
1 | 501 |
return external_name(); |
502 |
} |
|
503 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
504 |
|
1 | 505 |
// Verification |
506 |
||
22794
f1c014ad3754
8027146: Class loading verification failure if GC occurs in Universe::flush_dependents_on
coleenp
parents:
22234
diff
changeset
|
507 |
void ObjArrayKlass::verify_on(outputStream* st) { |
f1c014ad3754
8027146: Class loading verification failure if GC occurs in Universe::flush_dependents_on
coleenp
parents:
22234
diff
changeset
|
508 |
ArrayKlass::verify_on(st); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
509 |
guarantee(element_klass()->is_klass(), "should be klass"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
510 |
guarantee(bottom_klass()->is_klass(), "should be klass"); |
14488 | 511 |
Klass* bk = bottom_klass(); |
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
31592
diff
changeset
|
512 |
guarantee(bk->is_instance_klass() || bk->is_typeArray_klass(), "invalid bottom klass"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
513 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12379
diff
changeset
|
514 |
|
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
515 |
void ObjArrayKlass::oop_verify_on(oop obj, outputStream* st) { |
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
516 |
ArrayKlass::oop_verify_on(obj, st); |
1 | 517 |
guarantee(obj->is_objArray(), "must be objArray"); |
518 |
objArrayOop oa = objArrayOop(obj); |
|
519 |
for(int index = 0; index < oa->length(); index++) { |
|
46968
9119841280f4
8160399: is_oop_or_null involves undefined behavior
coleenp
parents:
46746
diff
changeset
|
520 |
guarantee(oopDesc::is_oop_or_null(oa->obj_at(index)), "should be oop"); |
1 | 521 |
} |
522 |
} |