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
|
|
|
* Copyright (c) 1999, 2012, 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"
|
|
|
|
#include "ci/ciInstanceKlass.hpp"
|
|
|
|
#include "ci/ciObjArrayKlass.hpp"
|
|
|
|
#include "ci/ciSymbol.hpp"
|
|
|
|
#include "ci/ciUtilities.hpp"
|
|
|
|
#include "oops/objArrayKlass.hpp"
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// ciObjArrayKlass
|
|
|
|
//
|
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 class represents a Klass* in the HotSpot virtual machine
|
2012-09-29 06:40:00 -04:00
|
|
|
// whose Klass part is an ObjArrayKlass.
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciObjArrayKlass::ciObjArrayKlass
|
|
|
|
//
|
|
|
|
// Constructor for loaded object array klasses.
|
|
|
|
ciObjArrayKlass::ciObjArrayKlass(KlassHandle h_k) : ciArrayKlass(h_k) {
|
|
|
|
assert(get_Klass()->oop_is_objArray(), "wrong type");
|
2012-09-29 06:40:00 -04:00
|
|
|
Klass* element_Klass = get_ObjArrayKlass()->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
|
|
|
_base_element_klass = CURRENT_ENV->get_klass(element_Klass);
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(_base_element_klass->is_instance_klass() ||
|
|
|
|
_base_element_klass->is_type_array_klass(), "bad base klass");
|
|
|
|
if (dimension() == 1) {
|
|
|
|
_element_klass = _base_element_klass;
|
|
|
|
} else {
|
|
|
|
_element_klass = NULL;
|
|
|
|
}
|
|
|
|
if (!ciObjectFactory::is_initialized()) {
|
|
|
|
assert(_element_klass->is_java_lang_Object(), "only arrays of object are shared");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciObjArrayKlass::ciObjArrayKlass
|
|
|
|
//
|
|
|
|
// Constructor for unloaded object array klasses.
|
|
|
|
ciObjArrayKlass::ciObjArrayKlass(ciSymbol* array_name,
|
|
|
|
ciKlass* base_element_klass,
|
|
|
|
int dimension)
|
|
|
|
: ciArrayKlass(array_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
|
|
|
dimension, T_OBJECT) {
|
2007-12-01 00:00:00 +00:00
|
|
|
_base_element_klass = base_element_klass;
|
|
|
|
assert(_base_element_klass->is_instance_klass() ||
|
|
|
|
_base_element_klass->is_type_array_klass(), "bad base klass");
|
|
|
|
if (dimension == 1) {
|
|
|
|
_element_klass = base_element_klass;
|
|
|
|
} else {
|
|
|
|
_element_klass = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciObjArrayKlass::element_klass
|
|
|
|
//
|
|
|
|
// What is the one-level element type of this array?
|
|
|
|
ciKlass* ciObjArrayKlass::element_klass() {
|
|
|
|
if (_element_klass == NULL) {
|
|
|
|
assert(dimension() > 1, "_element_klass should not be NULL");
|
|
|
|
// Produce the element klass.
|
|
|
|
if (is_loaded()) {
|
|
|
|
VM_ENTRY_MARK;
|
2012-09-29 06:40:00 -04:00
|
|
|
Klass* element_Klass = get_ObjArrayKlass()->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
|
|
|
_element_klass = CURRENT_THREAD_ENV->get_klass(element_Klass);
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
|
|
|
VM_ENTRY_MARK;
|
|
|
|
// We are an unloaded array klass. Attempt to fetch our
|
|
|
|
// element klass by name.
|
|
|
|
_element_klass = CURRENT_THREAD_ENV->get_klass_by_name_impl(
|
|
|
|
this,
|
2011-06-23 17:14:06 -07:00
|
|
|
constantPoolHandle(),
|
2007-12-01 00:00:00 +00:00
|
|
|
construct_array_name(base_element_klass()->name(),
|
|
|
|
dimension() - 1),
|
|
|
|
false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return _element_klass;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciObjArrayKlass::construct_array_name
|
|
|
|
//
|
|
|
|
// Build an array name from an element name and a dimension.
|
|
|
|
ciSymbol* ciObjArrayKlass::construct_array_name(ciSymbol* element_name,
|
|
|
|
int dimension) {
|
|
|
|
EXCEPTION_CONTEXT;
|
|
|
|
int element_len = element_name->utf8_length();
|
|
|
|
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* base_name_sym = element_name->get_symbol();
|
2007-12-01 00:00:00 +00:00
|
|
|
char* name;
|
|
|
|
|
|
|
|
if (base_name_sym->byte_at(0) == '[' ||
|
|
|
|
(base_name_sym->byte_at(0) == 'L' && // watch package name 'Lxx'
|
|
|
|
base_name_sym->byte_at(element_len-1) == ';')) {
|
|
|
|
|
|
|
|
int new_len = element_len + dimension + 1; // for the ['s and '\0'
|
|
|
|
name = CURRENT_THREAD_ENV->name_buffer(new_len);
|
|
|
|
|
|
|
|
int pos = 0;
|
|
|
|
for ( ; pos < dimension; pos++) {
|
|
|
|
name[pos] = '[';
|
|
|
|
}
|
|
|
|
strncpy(name+pos, (char*)element_name->base(), element_len);
|
|
|
|
name[new_len-1] = '\0';
|
|
|
|
} else {
|
|
|
|
int new_len = 3 // for L, ;, and '\0'
|
|
|
|
+ dimension // for ['s
|
|
|
|
+ element_len;
|
|
|
|
|
|
|
|
name = CURRENT_THREAD_ENV->name_buffer(new_len);
|
|
|
|
int pos = 0;
|
|
|
|
for ( ; pos < dimension; pos++) {
|
|
|
|
name[pos] = '[';
|
|
|
|
}
|
|
|
|
name[pos++] = 'L';
|
|
|
|
strncpy(name+pos, (char*)element_name->base(), element_len);
|
|
|
|
name[new_len-2] = ';';
|
|
|
|
name[new_len-1] = '\0';
|
|
|
|
}
|
|
|
|
return ciSymbol::make(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciObjArrayKlass::make_impl
|
|
|
|
//
|
|
|
|
// Implementation of make.
|
|
|
|
ciObjArrayKlass* ciObjArrayKlass::make_impl(ciKlass* element_klass) {
|
|
|
|
|
|
|
|
if (element_klass->is_loaded()) {
|
|
|
|
EXCEPTION_CONTEXT;
|
|
|
|
// The element klass is loaded
|
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 = element_klass->get_Klass()->array_klass(THREAD);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (HAS_PENDING_EXCEPTION) {
|
|
|
|
CLEAR_PENDING_EXCEPTION;
|
|
|
|
CURRENT_THREAD_ENV->record_out_of_memory_failure();
|
|
|
|
return ciEnv::unloaded_ciobjarrayklass();
|
|
|
|
}
|
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 CURRENT_THREAD_ENV->get_obj_array_klass(array);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// The array klass was unable to be made or the element klass was
|
|
|
|
// not loaded.
|
|
|
|
ciSymbol* array_name = construct_array_name(element_klass->name(), 1);
|
|
|
|
if (array_name == ciEnv::unloaded_cisymbol()) {
|
|
|
|
return ciEnv::unloaded_ciobjarrayklass();
|
|
|
|
}
|
|
|
|
return
|
|
|
|
CURRENT_ENV->get_unloaded_klass(element_klass, array_name)
|
|
|
|
->as_obj_array_klass();
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// ciObjArrayKlass::make
|
|
|
|
//
|
|
|
|
// Make an array klass corresponding to the specified primitive type.
|
|
|
|
ciObjArrayKlass* ciObjArrayKlass::make(ciKlass* element_klass) {
|
|
|
|
GUARDED_VM_ENTRY(return make_impl(element_klass);)
|
|
|
|
}
|