2011-03-18 16:00:34 -07:00
|
|
|
/*
|
2015-03-26 11:28:19 +01:00
|
|
|
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
2011-03-18 16:00:34 -07: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/javaClasses.hpp"
|
|
|
|
#include "classfile/systemDictionary.hpp"
|
|
|
|
#include "gc_interface/collectedHeap.inline.hpp"
|
2014-06-24 16:20:15 +02:00
|
|
|
#include "memory/iterator.inline.hpp"
|
2011-03-18 16:00:34 -07:00
|
|
|
#include "memory/oopFactory.hpp"
|
2015-03-17 14:18:52 +01:00
|
|
|
#include "memory/specialized_oop_closures.hpp"
|
2011-03-18 16:00:34 -07:00
|
|
|
#include "oops/instanceKlass.hpp"
|
|
|
|
#include "oops/instanceMirrorKlass.hpp"
|
|
|
|
#include "oops/instanceOop.hpp"
|
|
|
|
#include "oops/oop.inline.hpp"
|
|
|
|
#include "oops/symbol.hpp"
|
|
|
|
#include "runtime/handles.inline.hpp"
|
2013-01-23 13:02:39 -05:00
|
|
|
#include "utilities/macros.hpp"
|
2011-03-18 16:00:34 -07:00
|
|
|
|
2012-09-07 12:04:16 -04:00
|
|
|
int InstanceMirrorKlass::_offset_of_static_fields = 0;
|
2011-03-18 16:00:34 -07:00
|
|
|
|
2012-09-07 12:04:16 -04:00
|
|
|
int InstanceMirrorKlass::instance_size(KlassHandle k) {
|
2011-03-18 16:00:34 -07:00
|
|
|
if (k() != NULL && k->oop_is_instance()) {
|
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 align_object_size(size_helper() + InstanceKlass::cast(k())->static_field_size());
|
2011-03-18 16:00:34 -07:00
|
|
|
}
|
|
|
|
return size_helper();
|
|
|
|
}
|
|
|
|
|
2012-09-07 12:04:16 -04:00
|
|
|
instanceOop InstanceMirrorKlass::allocate_instance(KlassHandle k, TRAPS) {
|
2011-03-18 16:00:34 -07:00
|
|
|
// Query before forming handle.
|
|
|
|
int size = instance_size(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
|
|
|
KlassHandle h_k(THREAD, this);
|
2014-04-08 13:58:38 -04:00
|
|
|
instanceOop i = (instanceOop)CollectedHeap::obj_allocate(h_k, size, CHECK_NULL);
|
|
|
|
|
|
|
|
// Since mirrors can be variable sized because of the static fields, store
|
|
|
|
// the size in the mirror itself.
|
|
|
|
java_lang_Class::set_oop_size(i, size);
|
|
|
|
|
2011-03-18 16:00:34 -07:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2012-09-07 12:04:16 -04:00
|
|
|
int InstanceMirrorKlass::oop_size(oop obj) const {
|
2011-03-18 16:00:34 -07:00
|
|
|
return java_lang_Class::oop_size(obj);
|
|
|
|
}
|
|
|
|
|
2012-09-07 12:04:16 -04:00
|
|
|
int InstanceMirrorKlass::compute_static_oop_field_count(oop obj) {
|
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 = java_lang_Class::as_Klass(obj);
|
|
|
|
if (k != NULL && k->oop_is_instance()) {
|
|
|
|
return InstanceKlass::cast(k)->static_oop_field_count();
|
2011-03-18 16:00:34 -07:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|