src/hotspot/share/oops/instanceMirrorKlass.cpp
author stefank
Thu, 09 May 2019 14:28:30 +0200
changeset 54786 ebf733a324d4
parent 53380 c8208421a860
permissions -rw-r--r--
8223624: Cleanup includes of universe.hpp Reviewed-by: coleenp, lkorinth
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
     1
/*
51491
187c84a5efe1 8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents: 50882
diff changeset
     2
 * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
     4
 *
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
     7
 * published by the Free Software Foundation.
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
     8
 *
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    13
 * accompanied this code).
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    14
 *
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    18
 *
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    21
 * questions.
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    22
 *
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    23
 */
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    24
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    25
#include "precompiled.hpp"
53380
c8208421a860 8217325: Enable inlining of java_lang_Class::oop_size_raw
redestad
parents: 52067
diff changeset
    26
#include "classfile/javaClasses.inline.hpp"
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    27
#include "classfile/systemDictionary.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30150
diff changeset
    28
#include "gc/shared/collectedHeap.inline.hpp"
25356
4a4a482298a6 8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents: 23872
diff changeset
    29
#include "memory/iterator.inline.hpp"
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    30
#include "memory/oopFactory.hpp"
54786
ebf733a324d4 8223624: Cleanup includes of universe.hpp
stefank
parents: 53380
diff changeset
    31
#include "memory/universe.hpp"
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    32
#include "oops/instanceKlass.hpp"
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    33
#include "oops/instanceMirrorKlass.hpp"
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    34
#include "oops/instanceOop.hpp"
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    35
#include "oops/oop.inline.hpp"
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    36
#include "oops/symbol.hpp"
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    37
#include "runtime/handles.inline.hpp"
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13738
diff changeset
    38
#include "utilities/macros.hpp"
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    39
13738
d67be49a5beb 7195833: NPG: Rename instanceClassLoaderKlass, instanceRefKlass and instanceMirrorKlass
coleenp
parents: 13728
diff changeset
    40
int InstanceMirrorKlass::_offset_of_static_fields = 0;
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    41
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 39695
diff changeset
    42
int InstanceMirrorKlass::instance_size(Klass* k) {
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 39695
diff changeset
    43
  if (k != NULL && k->is_instance_klass()) {
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 39695
diff changeset
    44
    return align_object_size(size_helper() + InstanceKlass::cast(k)->static_field_size());
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    45
  }
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    46
  return size_helper();
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    47
}
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    48
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 39695
diff changeset
    49
instanceOop InstanceMirrorKlass::allocate_instance(Klass* k, TRAPS) {
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    50
  // Query before forming handle.
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    51
  int size = instance_size(k);
39695
946f1321c075 8158946: btree009 fails with assert(s > 0) failed: Bad size calculated
drwhite
parents: 33611
diff changeset
    52
  assert(size > 0, "total object size must be positive: %d", size);
23872
536c66fc43d3 8028497: SIGSEGV at ClassLoaderData::oops_do(OopClosure*, KlassClosure*, bool)
coleenp
parents: 22234
diff changeset
    53
536c66fc43d3 8028497: SIGSEGV at ClassLoaderData::oops_do(OopClosure*, KlassClosure*, bool)
coleenp
parents: 22234
diff changeset
    54
  // Since mirrors can be variable sized because of the static fields, store
536c66fc43d3 8028497: SIGSEGV at ClassLoaderData::oops_do(OopClosure*, KlassClosure*, bool)
coleenp
parents: 22234
diff changeset
    55
  // the size in the mirror itself.
52067
2e72562697bf 8211394: CHECK_ must be used in the rhs of an assignment statement within a block
dholmes
parents: 51516
diff changeset
    56
  return (instanceOop)Universe::heap()->class_allocate(this, size, THREAD);
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    57
}
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    58
13738
d67be49a5beb 7195833: NPG: Rename instanceClassLoaderKlass, instanceRefKlass and instanceMirrorKlass
coleenp
parents: 13728
diff changeset
    59
int InstanceMirrorKlass::oop_size(oop obj) const {
51516
7c3891b9f1e0 8206457: Code paths from oop_iterate() must use barrier-free access
rkennke
parents: 51491
diff changeset
    60
  return java_lang_Class::oop_size_raw(obj);
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    61
}
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    62
13738
d67be49a5beb 7195833: NPG: Rename instanceClassLoaderKlass, instanceRefKlass and instanceMirrorKlass
coleenp
parents: 13728
diff changeset
    63
int InstanceMirrorKlass::compute_static_oop_field_count(oop obj) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10742
diff changeset
    64
  Klass* k = java_lang_Class::as_Klass(obj);
33611
9abd65805e19 8139203: Consistent naming for klass type predicates
coleenp
parents: 30764
diff changeset
    65
  if (k != NULL && k->is_instance_klass()) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 10742
diff changeset
    66
    return InstanceKlass::cast(k)->static_oop_field_count();
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    67
  }
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    68
  return 0;
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents:
diff changeset
    69
}
51491
187c84a5efe1 8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents: 50882
diff changeset
    70
187c84a5efe1 8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents: 50882
diff changeset
    71
#if INCLUDE_CDS
187c84a5efe1 8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents: 50882
diff changeset
    72
void InstanceMirrorKlass::serialize_offsets(SerializeClosure* f) {
187c84a5efe1 8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents: 50882
diff changeset
    73
  f->do_u4((u4*)&_offset_of_static_fields);
187c84a5efe1 8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents: 50882
diff changeset
    74
}
187c84a5efe1 8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents: 50882
diff changeset
    75
#endif