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
|
|
|
/*
|
2020-01-09 17:38:41 -05:00
|
|
|
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
|
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
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "precompiled.hpp"
|
|
|
|
#include "classfile/classLoaderData.hpp"
|
2017-08-02 18:06:38 -07:00
|
|
|
#include "logging/log.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"
|
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/oopFactory.hpp"
|
|
|
|
#include "oops/annotations.hpp"
|
|
|
|
#include "oops/instanceKlass.hpp"
|
2018-02-15 23:45:15 +01:00
|
|
|
#include "oops/typeArrayOop.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 "utilities/ostream.hpp"
|
|
|
|
|
|
|
|
// Allocate annotations in metadata area
|
|
|
|
Annotations* Annotations::allocate(ClassLoaderData* loader_data, TRAPS) {
|
2017-08-02 18:06:38 -07:00
|
|
|
return new (loader_data, size(), MetaspaceObj::AnnotationsType, THREAD) Annotations();
|
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
|
|
|
}
|
|
|
|
|
|
|
|
// helper
|
2013-02-11 14:06:22 -05:00
|
|
|
void Annotations::free_contents(ClassLoaderData* loader_data, Array<AnnotationArray*>* p) {
|
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 (p != NULL) {
|
|
|
|
for (int i = 0; i < p->length(); i++) {
|
|
|
|
MetadataFactory::free_array<u1>(loader_data, p->at(i));
|
|
|
|
}
|
|
|
|
MetadataFactory::free_array<AnnotationArray*>(loader_data, p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Annotations::deallocate_contents(ClassLoaderData* loader_data) {
|
|
|
|
if (class_annotations() != NULL) {
|
|
|
|
MetadataFactory::free_array<u1>(loader_data, class_annotations());
|
|
|
|
}
|
|
|
|
free_contents(loader_data, fields_annotations());
|
2012-12-20 10:22:19 +01:00
|
|
|
|
2013-02-11 14:06:22 -05:00
|
|
|
if (class_type_annotations() != NULL) {
|
|
|
|
MetadataFactory::free_array<u1>(loader_data, class_type_annotations());
|
|
|
|
}
|
|
|
|
free_contents(loader_data, fields_type_annotations());
|
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
|
|
|
}
|
|
|
|
|
|
|
|
// Copy annotations to JVM call or reflection to the java heap.
|
2013-02-11 14:06:22 -05:00
|
|
|
// The alternative to creating this array and adding to Java heap pressure
|
|
|
|
// is to have a hashtable of the already created typeArrayOops
|
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
|
|
|
typeArrayOop Annotations::make_java_array(AnnotationArray* annotations, TRAPS) {
|
|
|
|
if (annotations != NULL) {
|
|
|
|
int length = annotations->length();
|
|
|
|
typeArrayOop copy = oopFactory::new_byteArray(length, CHECK_NULL);
|
|
|
|
for (int i = 0; i< length; i++) {
|
|
|
|
copy->byte_at_put(i, annotations->at(i));
|
|
|
|
}
|
|
|
|
return copy;
|
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-02 18:06:38 -07:00
|
|
|
void Annotations::metaspace_pointers_do(MetaspaceClosure* it) {
|
|
|
|
log_trace(cds)("Iter(Annotations): %p", this);
|
|
|
|
it->push(&_class_annotations);
|
|
|
|
it->push(&_fields_annotations);
|
|
|
|
it->push(&_class_type_annotations);
|
|
|
|
it->push(&_fields_type_annotations); // FIXME: need a test case where _fields_type_annotations != 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
|
|
|
|
|
|
|
void Annotations::print_value_on(outputStream* st) const {
|
2019-08-21 11:29:40 -04:00
|
|
|
st->print("Annotations(" INTPTR_FORMAT ")", p2i(this));
|
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
|
|
|
}
|
|
|
|
|
|
|
|
#define BULLET " - "
|
|
|
|
|
|
|
|
#ifndef PRODUCT
|
|
|
|
void Annotations::print_on(outputStream* st) const {
|
|
|
|
st->print(BULLET"class_annotations "); class_annotations()->print_value_on(st);
|
|
|
|
st->print(BULLET"fields_annotations "); fields_annotations()->print_value_on(st);
|
2013-02-11 14:06:22 -05:00
|
|
|
st->print(BULLET"class_type_annotations "); class_type_annotations()->print_value_on(st);
|
|
|
|
st->print(BULLET"fields_type_annotations "); fields_type_annotations()->print_value_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
|
|
|
}
|
|
|
|
#endif // PRODUCT
|