2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2019-01-05 20:08:24 +01:00
|
|
|
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
|
2007-12-01 00:00:00 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
2010-05-27 19:08:38 -07:00
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
2007-12-01 00:00:00 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "precompiled.hpp"
|
2016-04-26 09:08:12 -04:00
|
|
|
#include "classfile/moduleEntry.hpp"
|
|
|
|
#include "classfile/packageEntry.hpp"
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
#include "classfile/symbolTable.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "classfile/systemDictionary.hpp"
|
|
|
|
#include "classfile/vmSymbols.hpp"
|
2015-05-13 15:16:06 +02:00
|
|
|
#include "gc/shared/collectedHeap.inline.hpp"
|
2014-06-24 16:20:15 +02:00
|
|
|
#include "memory/iterator.inline.hpp"
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
#include "memory/metadataFactory.hpp"
|
2017-08-02 18:06:38 -07:00
|
|
|
#include "memory/metaspaceClosure.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "memory/resourceArea.hpp"
|
2018-03-07 21:57:36 +01:00
|
|
|
#include "memory/universe.hpp"
|
2016-08-29 20:13:45 -04:00
|
|
|
#include "oops/arrayKlass.inline.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "oops/instanceKlass.hpp"
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
#include "oops/klass.inline.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "oops/objArrayKlass.inline.hpp"
|
2015-02-13 14:37:35 +01:00
|
|
|
#include "oops/objArrayOop.inline.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "oops/oop.inline.hpp"
|
2011-01-27 16:11:27 -08:00
|
|
|
#include "oops/symbol.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "runtime/handles.inline.hpp"
|
|
|
|
#include "runtime/mutexLocker.hpp"
|
2013-01-23 13:02:39 -05:00
|
|
|
#include "utilities/macros.hpp"
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2017-03-15 10:25:37 -04:00
|
|
|
ObjArrayKlass* ObjArrayKlass::allocate(ClassLoaderData* loader_data, int n, Klass* k, Symbol* name, TRAPS) {
|
2012-09-29 06:40:00 -04:00
|
|
|
assert(ObjArrayKlass::header_size() <= InstanceKlass::header_size(),
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
"array klasses must be same size as InstanceKlass");
|
|
|
|
|
2012-09-29 06:40:00 -04:00
|
|
|
int size = ArrayKlass::static_size(ObjArrayKlass::header_size());
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2017-03-15 10:25:37 -04:00
|
|
|
return new (loader_data, size, THREAD) ObjArrayKlass(n, k, name);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2012-09-29 06:40:00 -04:00
|
|
|
Klass* ObjArrayKlass::allocate_objArray_klass(ClassLoaderData* loader_data,
|
2017-03-15 10:25:37 -04:00
|
|
|
int n, Klass* element_klass, TRAPS) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
// Eagerly allocate the direct array supertype.
|
2017-03-15 10:25:37 -04:00
|
|
|
Klass* super_klass = NULL;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (!Universe::is_bootstrapping() || SystemDictionary::Object_klass_loaded()) {
|
2017-03-15 10:25:37 -04:00
|
|
|
Klass* element_super = element_klass->super();
|
|
|
|
if (element_super != NULL) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// The element type has a direct super. E.g., String[] has direct super of Object[].
|
2017-03-15 10:25:37 -04:00
|
|
|
super_klass = element_super->array_klass_or_null();
|
|
|
|
bool supers_exist = super_klass != NULL;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Also, see if the element has secondary supertypes.
|
|
|
|
// We need an array type for each.
|
2018-08-07 15:45:07 -07:00
|
|
|
const Array<Klass*>* element_supers = element_klass->secondary_supers();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
for( int i = element_supers->length()-1; i >= 0; i-- ) {
|
|
|
|
Klass* elem_super = element_supers->at(i);
|
2012-11-12 16:15:05 -05:00
|
|
|
if (elem_super->array_klass_or_null() == NULL) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
supers_exist = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!supers_exist) {
|
|
|
|
// Oops. Not allocated yet. Back out, allocate it, and retry.
|
2017-03-15 10:25:37 -04:00
|
|
|
Klass* ek = NULL;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
{
|
|
|
|
MutexUnlocker mu(MultiArray_lock);
|
2017-03-15 10:25:37 -04:00
|
|
|
super_klass = element_super->array_klass(CHECK_0);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
for( int i = element_supers->length()-1; i >= 0; i-- ) {
|
2017-03-15 10:25:37 -04:00
|
|
|
Klass* elem_super = element_supers->at(i);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
elem_super->array_klass(CHECK_0);
|
|
|
|
}
|
|
|
|
// Now retry from the beginning
|
2017-03-15 10:25:37 -04:00
|
|
|
ek = element_klass->array_klass(n, CHECK_0);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
} // re-lock
|
2017-03-15 10:25:37 -04:00
|
|
|
return ek;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// The element type is already Object. Object[] has direct super of Object.
|
2017-03-15 10:25:37 -04:00
|
|
|
super_klass = SystemDictionary::Object_klass();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create type name for klass.
|
|
|
|
Symbol* name = NULL;
|
2015-10-28 09:47:23 -04:00
|
|
|
if (!element_klass->is_instance_klass() ||
|
2017-03-15 10:25:37 -04:00
|
|
|
(name = InstanceKlass::cast(element_klass)->array_name()) == NULL) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
ResourceMark rm(THREAD);
|
|
|
|
char *name_str = element_klass->name()->as_C_string();
|
|
|
|
int len = element_klass->name()->utf8_length();
|
|
|
|
char *new_str = NEW_RESOURCE_ARRAY(char, len + 4);
|
|
|
|
int idx = 0;
|
|
|
|
new_str[idx++] = '[';
|
2015-10-28 09:47:23 -04:00
|
|
|
if (element_klass->is_instance_klass()) { // it could be an array or simple type
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
new_str[idx++] = 'L';
|
|
|
|
}
|
|
|
|
memcpy(&new_str[idx], name_str, len * sizeof(char));
|
|
|
|
idx += len;
|
2015-10-28 09:47:23 -04:00
|
|
|
if (element_klass->is_instance_klass()) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
new_str[idx++] = ';';
|
|
|
|
}
|
|
|
|
new_str[idx++] = '\0';
|
2019-05-14 11:29:18 -04:00
|
|
|
name = SymbolTable::new_permanent_symbol(new_str);
|
2015-10-28 09:47:23 -04:00
|
|
|
if (element_klass->is_instance_klass()) {
|
2017-03-15 10:25:37 -04:00
|
|
|
InstanceKlass* ik = InstanceKlass::cast(element_klass);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
ik->set_array_name(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialize instance variables
|
2012-09-29 06:40:00 -04:00
|
|
|
ObjArrayKlass* oak = ObjArrayKlass::allocate(loader_data, n, element_klass, name, CHECK_0);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2016-04-26 09:08:12 -04:00
|
|
|
ModuleEntry* module = oak->module();
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
assert(module != NULL, "No module entry for array");
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Call complete_create_array_klass after all instance variables has been initialized.
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
ArrayKlass::complete_create_array_klass(oak, super_klass, module, CHECK_0);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2019-05-08 10:08:11 -04:00
|
|
|
// Add all classes to our internal class loader list here,
|
|
|
|
// including classes in the bootstrap (NULL) class loader.
|
|
|
|
// Do this step after creating the mirror so that if the
|
|
|
|
// mirror creation fails, loaded_classes_do() doesn't find
|
|
|
|
// an array class without a mirror.
|
|
|
|
loader_data->add_class(oak);
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
return oak;
|
|
|
|
}
|
|
|
|
|
2018-05-26 06:59:49 +02:00
|
|
|
ObjArrayKlass::ObjArrayKlass(int n, Klass* element_klass, Symbol* name) : ArrayKlass(name, ID) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
this->set_dimension(n);
|
2017-03-15 10:25:37 -04:00
|
|
|
this->set_element_klass(element_klass);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// decrement refcount because object arrays are not explicitly freed. The
|
|
|
|
// InstanceKlass array_name() keeps the name counted while the klass is
|
|
|
|
// loaded.
|
|
|
|
name->decrement_refcount();
|
|
|
|
|
|
|
|
Klass* bk;
|
2015-10-28 09:47:23 -04:00
|
|
|
if (element_klass->is_objArray_klass()) {
|
2017-03-15 10:25:37 -04:00
|
|
|
bk = ObjArrayKlass::cast(element_klass)->bottom_klass();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
} else {
|
2017-03-15 10:25:37 -04:00
|
|
|
bk = element_klass;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
2015-10-28 09:47:23 -04:00
|
|
|
assert(bk != NULL && (bk->is_instance_klass() || bk->is_typeArray_klass()), "invalid bottom klass");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
this->set_bottom_klass(bk);
|
|
|
|
this->set_class_loader_data(bk->class_loader_data());
|
|
|
|
|
|
|
|
this->set_layout_helper(array_layout_helper(T_OBJECT));
|
2015-10-28 09:47:23 -04:00
|
|
|
assert(this->is_array_klass(), "sanity");
|
|
|
|
assert(this->is_objArray_klass(), "sanity");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2012-09-29 06:40:00 -04:00
|
|
|
int ObjArrayKlass::oop_size(oop obj) const {
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(obj->is_objArray(), "must be object array");
|
|
|
|
return objArrayOop(obj)->object_size();
|
|
|
|
}
|
|
|
|
|
2012-09-29 06:40:00 -04:00
|
|
|
objArrayOop ObjArrayKlass::allocate(int length, TRAPS) {
|
2018-10-05 20:03:14 +02:00
|
|
|
check_array_allocation_length(length, arrayOopDesc::max_array_length(T_OBJECT), CHECK_0);
|
|
|
|
int size = objArrayOopDesc::object_size(length);
|
|
|
|
return (objArrayOop)Universe::heap()->array_allocate(this, size, length,
|
|
|
|
/* do_zero */ true, THREAD);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int multi_alloc_counter = 0;
|
|
|
|
|
2012-09-29 06:40:00 -04:00
|
|
|
oop ObjArrayKlass::multi_allocate(int rank, jint* sizes, TRAPS) {
|
2007-12-01 00:00:00 +00:00
|
|
|
int length = *sizes;
|
|
|
|
// Call to lower_dimension uses this pointer, so most be called before a
|
|
|
|
// possible GC
|
2017-03-15 10:25:37 -04:00
|
|
|
Klass* ld_klass = lower_dimension();
|
2007-12-01 00:00:00 +00:00
|
|
|
// If length < 0 allocate will throw an exception.
|
|
|
|
objArrayOop array = allocate(length, CHECK_NULL);
|
|
|
|
objArrayHandle h_array (THREAD, array);
|
|
|
|
if (rank > 1) {
|
|
|
|
if (length != 0) {
|
|
|
|
for (int index = 0; index < length; index++) {
|
2017-03-15 10:25:37 -04:00
|
|
|
ArrayKlass* ak = ArrayKlass::cast(ld_klass);
|
2007-12-01 00:00:00 +00:00
|
|
|
oop sub_array = ak->multi_allocate(rank-1, &sizes[1], CHECK_NULL);
|
|
|
|
h_array->obj_at_put(index, sub_array);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Since this array dimension has zero length, nothing will be
|
|
|
|
// allocated, however the lower dimension values must be checked
|
|
|
|
// for illegal values.
|
|
|
|
for (int i = 0; i < rank - 1; ++i) {
|
|
|
|
sizes += 1;
|
|
|
|
if (*sizes < 0) {
|
2018-05-30 11:39:26 +02:00
|
|
|
THROW_MSG_0(vmSymbols::java_lang_NegativeArraySizeException(), err_msg("%d", *sizes));
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return h_array();
|
|
|
|
}
|
|
|
|
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
// Either oop or narrowOop depending on UseCompressedOops.
|
2018-06-04 23:01:48 +02:00
|
|
|
void ObjArrayKlass::do_copy(arrayOop s, size_t src_offset,
|
|
|
|
arrayOop d, size_t dst_offset, int length, TRAPS) {
|
2018-04-03 13:15:27 +02:00
|
|
|
if (oopDesc::equals(s, d)) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// since source and destination are equal we do not need conversion checks.
|
|
|
|
assert(length > 0, "sanity check");
|
2018-06-04 23:01:48 +02:00
|
|
|
ArrayAccess<>::oop_arraycopy(s, src_offset, d, dst_offset, length);
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
|
|
|
// We have to make sure all elements conform to the destination array
|
2012-09-29 06:40:00 -04:00
|
|
|
Klass* bound = ObjArrayKlass::cast(d->klass())->element_klass();
|
|
|
|
Klass* stype = ObjArrayKlass::cast(s->klass())->element_klass();
|
2012-11-12 16:15:05 -05:00
|
|
|
if (stype == bound || stype->is_subtype_of(bound)) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// elements are guaranteed to be subtypes, so no check necessary
|
2018-06-04 23:01:48 +02:00
|
|
|
ArrayAccess<ARRAYCOPY_DISJOINT>::oop_arraycopy(s, src_offset, d, dst_offset, length);
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
|
|
|
// slow case: need individual subtype checks
|
|
|
|
// note: don't use obj_at_put below because it includes a redundant store check
|
2018-06-04 23:01:48 +02:00
|
|
|
if (!ArrayAccess<ARRAYCOPY_DISJOINT | ARRAYCOPY_CHECKCAST>::oop_arraycopy(s, src_offset, d, dst_offset, length)) {
|
2018-06-15 12:25:53 +02:00
|
|
|
ResourceMark rm(THREAD);
|
|
|
|
stringStream ss;
|
|
|
|
if (!bound->is_subtype_of(stype)) {
|
|
|
|
ss.print("arraycopy: type mismatch: can not copy %s[] into %s[]",
|
|
|
|
stype->external_name(), bound->external_name());
|
|
|
|
} else {
|
|
|
|
// oop_arraycopy should return the index in the source array that
|
|
|
|
// contains the problematic oop.
|
|
|
|
ss.print("arraycopy: element type mismatch: can not cast one of the elements"
|
|
|
|
" of %s[] to the type of the destination array, %s",
|
|
|
|
stype->external_name(), bound->external_name());
|
|
|
|
}
|
|
|
|
THROW_MSG(vmSymbols::java_lang_ArrayStoreException(), ss.as_string());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-29 06:40:00 -04:00
|
|
|
void ObjArrayKlass::copy_array(arrayOop s, int src_pos, arrayOop d,
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
int dst_pos, int length, TRAPS) {
|
|
|
|
assert(s->is_objArray(), "must be obj array");
|
|
|
|
|
|
|
|
if (!d->is_objArray()) {
|
2018-06-15 12:25:53 +02:00
|
|
|
ResourceMark rm(THREAD);
|
|
|
|
stringStream ss;
|
|
|
|
if (d->is_typeArray()) {
|
|
|
|
ss.print("arraycopy: type mismatch: can not copy object array[] into %s[]",
|
|
|
|
type2name_tab[ArrayKlass::cast(d->klass())->element_type()]);
|
|
|
|
} else {
|
|
|
|
ss.print("arraycopy: destination type %s is not an array", d->klass()->external_name());
|
|
|
|
}
|
|
|
|
THROW_MSG(vmSymbols::java_lang_ArrayStoreException(), ss.as_string());
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check is all offsets and lengths are non negative
|
|
|
|
if (src_pos < 0 || dst_pos < 0 || length < 0) {
|
2018-05-07 09:11:21 +02:00
|
|
|
// Pass specific exception reason.
|
2018-06-15 12:25:53 +02:00
|
|
|
ResourceMark rm(THREAD);
|
2018-05-07 09:11:21 +02:00
|
|
|
stringStream ss;
|
|
|
|
if (src_pos < 0) {
|
|
|
|
ss.print("arraycopy: source index %d out of bounds for object array[%d]",
|
|
|
|
src_pos, s->length());
|
|
|
|
} else if (dst_pos < 0) {
|
|
|
|
ss.print("arraycopy: destination index %d out of bounds for object array[%d]",
|
|
|
|
dst_pos, d->length());
|
|
|
|
} else {
|
|
|
|
ss.print("arraycopy: length %d is negative", length);
|
|
|
|
}
|
|
|
|
THROW_MSG(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), ss.as_string());
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
}
|
|
|
|
// Check if the ranges are valid
|
2018-05-07 09:11:21 +02:00
|
|
|
if ((((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length()) ||
|
|
|
|
(((unsigned int) length + (unsigned int) dst_pos) > (unsigned int) d->length())) {
|
|
|
|
// Pass specific exception reason.
|
2018-06-15 12:25:53 +02:00
|
|
|
ResourceMark rm(THREAD);
|
2018-05-07 09:11:21 +02:00
|
|
|
stringStream ss;
|
|
|
|
if (((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length()) {
|
|
|
|
ss.print("arraycopy: last source index %u out of bounds for object array[%d]",
|
|
|
|
(unsigned int) length + (unsigned int) src_pos, s->length());
|
|
|
|
} else {
|
|
|
|
ss.print("arraycopy: last destination index %u out of bounds for object array[%d]",
|
|
|
|
(unsigned int) length + (unsigned int) dst_pos, d->length());
|
|
|
|
}
|
|
|
|
THROW_MSG(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), ss.as_string());
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Special case. Boundary cases must be checked first
|
|
|
|
// This allows the following call: copy_array(s, s.length(), d.length(), 0).
|
|
|
|
// This is correct, since the position is supposed to be an 'in between point', i.e., s.length(),
|
|
|
|
// points to the right of the last element.
|
|
|
|
if (length==0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (UseCompressedOops) {
|
2018-06-04 23:01:48 +02:00
|
|
|
size_t src_offset = (size_t) objArrayOopDesc::obj_at_offset<narrowOop>(src_pos);
|
|
|
|
size_t dst_offset = (size_t) objArrayOopDesc::obj_at_offset<narrowOop>(dst_pos);
|
|
|
|
assert(arrayOopDesc::obj_offset_to_raw<narrowOop>(s, src_offset, NULL) ==
|
2018-08-09 17:11:11 +02:00
|
|
|
objArrayOop(s)->obj_at_addr_raw<narrowOop>(src_pos), "sanity");
|
2018-06-04 23:01:48 +02:00
|
|
|
assert(arrayOopDesc::obj_offset_to_raw<narrowOop>(d, dst_offset, NULL) ==
|
2018-08-09 17:11:11 +02:00
|
|
|
objArrayOop(d)->obj_at_addr_raw<narrowOop>(dst_pos), "sanity");
|
2018-06-04 23:01:48 +02:00
|
|
|
do_copy(s, src_offset, d, dst_offset, length, CHECK);
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
} else {
|
2018-06-04 23:01:48 +02:00
|
|
|
size_t src_offset = (size_t) objArrayOopDesc::obj_at_offset<oop>(src_pos);
|
|
|
|
size_t dst_offset = (size_t) objArrayOopDesc::obj_at_offset<oop>(dst_pos);
|
|
|
|
assert(arrayOopDesc::obj_offset_to_raw<oop>(s, src_offset, NULL) ==
|
2018-08-09 17:11:11 +02:00
|
|
|
objArrayOop(s)->obj_at_addr_raw<oop>(src_pos), "sanity");
|
2018-06-04 23:01:48 +02:00
|
|
|
assert(arrayOopDesc::obj_offset_to_raw<oop>(d, dst_offset, NULL) ==
|
2018-08-09 17:11:11 +02:00
|
|
|
objArrayOop(d)->obj_at_addr_raw<oop>(dst_pos), "sanity");
|
2018-06-04 23:01:48 +02:00
|
|
|
do_copy(s, src_offset, d, dst_offset, length, CHECK);
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2012-09-29 06:40:00 -04:00
|
|
|
Klass* ObjArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) {
|
2007-12-01 00:00:00 +00:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
assert(dimension() <= n, "check order of chain");
|
|
|
|
int dim = dimension();
|
|
|
|
if (dim == n) return this;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-08-29 20:13:45 -04:00
|
|
|
// lock-free read needs acquire semantics
|
|
|
|
if (higher_dimension_acquire() == NULL) {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (or_null) return NULL;
|
|
|
|
|
|
|
|
ResourceMark rm;
|
|
|
|
JavaThread *jt = (JavaThread *)THREAD;
|
|
|
|
{
|
|
|
|
// Ensure atomic creation of higher dimensions
|
|
|
|
MutexLocker mu(MultiArray_lock, THREAD);
|
|
|
|
|
|
|
|
// Check if another thread beat us
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (higher_dimension() == NULL) {
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Create multi-dim klass object and link them together
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* k =
|
2012-09-29 06:40:00 -04:00
|
|
|
ObjArrayKlass::allocate_objArray_klass(class_loader_data(), dim + 1, this, CHECK_NULL);
|
|
|
|
ObjArrayKlass* ak = ObjArrayKlass::cast(k);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
ak->set_lower_dimension(this);
|
2016-08-29 20:13:45 -04:00
|
|
|
// use 'release' to pair with lock-free load
|
|
|
|
release_set_higher_dimension(ak);
|
2015-10-28 09:47:23 -04:00
|
|
|
assert(ak->is_objArray_klass(), "incorrect initialization of ObjArrayKlass");
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
|
|
|
|
}
|
|
|
|
|
2012-09-29 06:40:00 -04:00
|
|
|
ObjArrayKlass *ak = ObjArrayKlass::cast(higher_dimension());
|
2007-12-01 00:00:00 +00:00
|
|
|
if (or_null) {
|
|
|
|
return ak->array_klass_or_null(n);
|
|
|
|
}
|
2014-11-14 09:47:09 +01:00
|
|
|
return ak->array_klass(n, THREAD);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2012-09-29 06:40:00 -04:00
|
|
|
Klass* ObjArrayKlass::array_klass_impl(bool or_null, TRAPS) {
|
2014-11-14 09:47:09 +01:00
|
|
|
return array_klass_impl(or_null, dimension() + 1, THREAD);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2012-09-29 06:40:00 -04:00
|
|
|
bool ObjArrayKlass::can_be_primary_super_slow() const {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
if (!bottom_klass()->can_be_primary_super())
|
2007-12-01 00:00:00 +00:00
|
|
|
// array of interfaces
|
|
|
|
return false;
|
|
|
|
else
|
|
|
|
return Klass::can_be_primary_super_slow();
|
|
|
|
}
|
|
|
|
|
2018-05-02 09:26:10 -07:00
|
|
|
GrowableArray<Klass*>* ObjArrayKlass::compute_secondary_supers(int num_extra_slots,
|
2018-08-07 15:45:07 -07:00
|
|
|
Array<InstanceKlass*>* transitive_interfaces) {
|
2018-05-02 09:26:10 -07:00
|
|
|
assert(transitive_interfaces == NULL, "sanity");
|
2007-12-01 00:00:00 +00:00
|
|
|
// interfaces = { cloneable_klass, serializable_klass, elemSuper[], ... };
|
2018-08-07 15:45:07 -07:00
|
|
|
const Array<Klass*>* elem_supers = element_klass()->secondary_supers();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
int num_elem_supers = elem_supers == NULL ? 0 : elem_supers->length();
|
2007-12-01 00:00:00 +00:00
|
|
|
int num_secondaries = num_extra_slots + 2 + num_elem_supers;
|
|
|
|
if (num_secondaries == 2) {
|
|
|
|
// Must share this for correct bootstrapping!
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
set_secondary_supers(Universe::the_array_interfaces_array());
|
|
|
|
return NULL;
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
GrowableArray<Klass*>* secondaries = new GrowableArray<Klass*>(num_elem_supers+2);
|
|
|
|
secondaries->push(SystemDictionary::Cloneable_klass());
|
|
|
|
secondaries->push(SystemDictionary::Serializable_klass());
|
2007-12-01 00:00:00 +00:00
|
|
|
for (int i = 0; i < num_elem_supers; i++) {
|
2018-08-07 15:45:07 -07:00
|
|
|
Klass* elem_super = elem_supers->at(i);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* array_super = elem_super->array_klass_or_null();
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(array_super != NULL, "must already have been created");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
secondaries->push(array_super);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
return secondaries;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-29 06:40:00 -04:00
|
|
|
void ObjArrayKlass::initialize(TRAPS) {
|
2012-11-12 16:15:05 -05:00
|
|
|
bottom_klass()->initialize(THREAD); // dispatches to either InstanceKlass or TypeArrayKlass
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2017-08-02 18:06:38 -07:00
|
|
|
void ObjArrayKlass::metaspace_pointers_do(MetaspaceClosure* it) {
|
|
|
|
ArrayKlass::metaspace_pointers_do(it);
|
|
|
|
it->push(&_element_klass);
|
|
|
|
it->push(&_bottom_klass);
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// JVM support
|
|
|
|
|
2012-09-29 06:40:00 -04:00
|
|
|
jint ObjArrayKlass::compute_modifier_flags(TRAPS) const {
|
2007-12-01 00:00:00 +00:00
|
|
|
// The modifier for an objectArray is the same as its element
|
|
|
|
if (element_klass() == NULL) {
|
|
|
|
assert(Universe::is_bootstrapping(), "partial objArray only at startup");
|
|
|
|
return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC;
|
|
|
|
}
|
2008-10-14 10:15:33 -04:00
|
|
|
// Return the flags of the bottom element type.
|
2012-11-12 16:15:05 -05:00
|
|
|
jint element_flags = bottom_klass()->compute_modifier_flags(CHECK_0);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
return (element_flags & (JVM_ACC_PUBLIC | JVM_ACC_PRIVATE | JVM_ACC_PROTECTED))
|
|
|
|
| (JVM_ACC_ABSTRACT | JVM_ACC_FINAL);
|
|
|
|
}
|
|
|
|
|
2016-04-26 09:08:12 -04:00
|
|
|
ModuleEntry* ObjArrayKlass::module() const {
|
|
|
|
assert(bottom_klass() != NULL, "ObjArrayKlass returned unexpected NULL bottom_klass");
|
|
|
|
// The array is defined in the module of its bottom class
|
|
|
|
return bottom_klass()->module();
|
|
|
|
}
|
|
|
|
|
|
|
|
PackageEntry* ObjArrayKlass::package() const {
|
|
|
|
assert(bottom_klass() != NULL, "ObjArrayKlass returned unexpected NULL bottom_klass");
|
|
|
|
return bottom_klass()->package();
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Printing
|
|
|
|
|
2012-09-29 06:40:00 -04:00
|
|
|
void ObjArrayKlass::print_on(outputStream* st) const {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
#ifndef PRODUCT
|
|
|
|
Klass::print_on(st);
|
|
|
|
st->print(" - instance klass: ");
|
|
|
|
element_klass()->print_value_on(st);
|
|
|
|
st->cr();
|
|
|
|
#endif //PRODUCT
|
|
|
|
}
|
|
|
|
|
2012-09-29 06:40:00 -04:00
|
|
|
void ObjArrayKlass::print_value_on(outputStream* st) const {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
assert(is_klass(), "must be klass");
|
|
|
|
|
|
|
|
element_klass()->print_value_on(st);
|
|
|
|
st->print("[]");
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef PRODUCT
|
|
|
|
|
2012-09-29 06:40:00 -04:00
|
|
|
void ObjArrayKlass::oop_print_on(oop obj, outputStream* st) {
|
|
|
|
ArrayKlass::oop_print_on(obj, st);
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(obj->is_objArray(), "must be objArray");
|
|
|
|
objArrayOop oa = objArrayOop(obj);
|
|
|
|
int print_len = MIN2((intx) oa->length(), MaxElementPrintSize);
|
|
|
|
for(int index = 0; index < print_len; index++) {
|
|
|
|
st->print(" - %3d : ", index);
|
2018-07-31 14:24:10 -04:00
|
|
|
if (oa->obj_at(index) != NULL) {
|
|
|
|
oa->obj_at(index)->print_value_on(st);
|
|
|
|
st->cr();
|
|
|
|
} else {
|
|
|
|
st->print_cr("NULL");
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
int remaining = oa->length() - print_len;
|
|
|
|
if (remaining > 0) {
|
2012-10-01 13:29:11 +02:00
|
|
|
st->print_cr(" - <%d more elements, increase MaxElementPrintSize to print>", remaining);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-08 13:47:01 -08:00
|
|
|
#endif //PRODUCT
|
|
|
|
|
2012-09-29 06:40:00 -04:00
|
|
|
void ObjArrayKlass::oop_print_value_on(oop obj, outputStream* st) {
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(obj->is_objArray(), "must be objArray");
|
2009-03-20 23:19:36 -07:00
|
|
|
st->print("a ");
|
2007-12-01 00:00:00 +00:00
|
|
|
element_klass()->print_value_on(st);
|
2009-03-20 23:19:36 -07:00
|
|
|
int len = objArrayOop(obj)->length();
|
|
|
|
st->print("[%d] ", len);
|
2018-07-31 14:24:10 -04:00
|
|
|
if (obj != NULL) {
|
|
|
|
obj->print_address_on(st);
|
|
|
|
} else {
|
|
|
|
st->print_cr("NULL");
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2012-09-29 06:40:00 -04:00
|
|
|
const char* ObjArrayKlass::internal_name() const {
|
2007-12-01 00:00:00 +00:00
|
|
|
return external_name();
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Verification
|
|
|
|
|
2014-02-15 13:03:38 -05:00
|
|
|
void ObjArrayKlass::verify_on(outputStream* st) {
|
|
|
|
ArrayKlass::verify_on(st);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
guarantee(element_klass()->is_klass(), "should be klass");
|
|
|
|
guarantee(bottom_klass()->is_klass(), "should be klass");
|
2012-11-12 16:15:05 -05:00
|
|
|
Klass* bk = bottom_klass();
|
2015-10-28 09:47:23 -04:00
|
|
|
guarantee(bk->is_instance_klass() || bk->is_typeArray_klass(), "invalid bottom klass");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2012-09-29 06:40:00 -04:00
|
|
|
void ObjArrayKlass::oop_verify_on(oop obj, outputStream* st) {
|
|
|
|
ArrayKlass::oop_verify_on(obj, st);
|
2007-12-01 00:00:00 +00:00
|
|
|
guarantee(obj->is_objArray(), "must be objArray");
|
|
|
|
objArrayOop oa = objArrayOop(obj);
|
|
|
|
for(int index = 0; index < oa->length(); index++) {
|
2017-08-23 14:52:55 -04:00
|
|
|
guarantee(oopDesc::is_oop_or_null(oa->obj_at(index)), "should be oop");
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|