Sat, 01 Sep 2012 13:25:18 -0400
6964458: Reimplement class meta-data storage to use native memory
Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
duke@435 | 1 | /* |
coleenp@4037 | 2 | * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #include "precompiled.hpp" |
coleenp@4037 | 26 | #include "ci/ciEnv.hpp" |
stefank@2314 | 27 | #include "ci/ciType.hpp" |
stefank@2314 | 28 | #include "ci/ciUtilities.hpp" |
stefank@2314 | 29 | #include "classfile/systemDictionary.hpp" |
stefank@2314 | 30 | #include "oops/oop.inline.hpp" |
duke@435 | 31 | |
duke@435 | 32 | ciType* ciType::_basic_types[T_CONFLICT+1]; |
duke@435 | 33 | |
duke@435 | 34 | // ciType |
duke@435 | 35 | // |
duke@435 | 36 | // This class represents either a class (T_OBJECT), array (T_ARRAY), |
duke@435 | 37 | // or one of the primitive types such as T_INT. |
duke@435 | 38 | |
duke@435 | 39 | // ------------------------------------------------------------------ |
duke@435 | 40 | // ciType::ciType |
duke@435 | 41 | // |
coleenp@4037 | 42 | ciType::ciType(BasicType basic_type) : ciMetadata() { |
duke@435 | 43 | assert(basic_type >= T_BOOLEAN && basic_type <= T_CONFLICT, "range check"); |
duke@435 | 44 | _basic_type = basic_type; |
duke@435 | 45 | } |
duke@435 | 46 | |
coleenp@4037 | 47 | ciType::ciType(KlassHandle k) : ciMetadata(k()) { |
duke@435 | 48 | _basic_type = Klass::cast(k())->oop_is_array() ? T_ARRAY : T_OBJECT; |
duke@435 | 49 | } |
duke@435 | 50 | |
duke@435 | 51 | |
duke@435 | 52 | // ------------------------------------------------------------------ |
duke@435 | 53 | // ciType::is_subtype_of |
duke@435 | 54 | // |
duke@435 | 55 | bool ciType::is_subtype_of(ciType* type) { |
duke@435 | 56 | if (this == type) return true; |
duke@435 | 57 | if (is_klass() && type->is_klass()) |
duke@435 | 58 | return this->as_klass()->is_subtype_of(type->as_klass()); |
duke@435 | 59 | return false; |
duke@435 | 60 | } |
duke@435 | 61 | |
duke@435 | 62 | // ------------------------------------------------------------------ |
duke@435 | 63 | // ciType::print_impl |
duke@435 | 64 | // |
duke@435 | 65 | // Implementation of the print method. |
duke@435 | 66 | void ciType::print_impl(outputStream* st) { |
duke@435 | 67 | st->print(" type="); |
duke@435 | 68 | print_name_on(st); |
duke@435 | 69 | } |
duke@435 | 70 | |
duke@435 | 71 | // ------------------------------------------------------------------ |
duke@435 | 72 | // ciType::print_name |
duke@435 | 73 | // |
duke@435 | 74 | // Print the name of this type |
duke@435 | 75 | void ciType::print_name_on(outputStream* st) { |
duke@435 | 76 | st->print(type2name(basic_type())); |
duke@435 | 77 | } |
duke@435 | 78 | |
duke@435 | 79 | |
duke@435 | 80 | |
duke@435 | 81 | // ------------------------------------------------------------------ |
duke@435 | 82 | // ciType::java_mirror |
duke@435 | 83 | // |
duke@435 | 84 | ciInstance* ciType::java_mirror() { |
duke@435 | 85 | VM_ENTRY_MARK; |
coleenp@4037 | 86 | return CURRENT_THREAD_ENV->get_instance(Universe::java_mirror(basic_type())); |
duke@435 | 87 | } |
duke@435 | 88 | |
duke@435 | 89 | // ------------------------------------------------------------------ |
duke@435 | 90 | // ciType::box_klass |
duke@435 | 91 | // |
duke@435 | 92 | ciKlass* ciType::box_klass() { |
duke@435 | 93 | if (!is_primitive_type()) return this->as_klass(); // reference types are "self boxing" |
duke@435 | 94 | |
duke@435 | 95 | // Void is "boxed" with a null. |
duke@435 | 96 | if (basic_type() == T_VOID) return NULL; |
duke@435 | 97 | |
duke@435 | 98 | VM_ENTRY_MARK; |
coleenp@4037 | 99 | return CURRENT_THREAD_ENV->get_instance_klass(SystemDictionary::box_klass(basic_type())); |
duke@435 | 100 | } |
duke@435 | 101 | |
duke@435 | 102 | |
duke@435 | 103 | // ------------------------------------------------------------------ |
duke@435 | 104 | // ciType::make |
duke@435 | 105 | // |
duke@435 | 106 | // Produce the ciType for a given primitive BasicType. |
duke@435 | 107 | // As a bonus, produce the right reference type for T_OBJECT. |
duke@435 | 108 | // Does not work on T_ARRAY. |
duke@435 | 109 | ciType* ciType::make(BasicType t) { |
duke@435 | 110 | // short, etc. |
duke@435 | 111 | // Note: Bare T_ADDRESS means a raw pointer type, not a return_address. |
duke@435 | 112 | assert((uint)t < T_CONFLICT+1, "range check"); |
never@1577 | 113 | if (t == T_OBJECT) return ciEnv::_Object_klass; // java/lang/Object |
duke@435 | 114 | assert(_basic_types[t] != NULL, "domain check"); |
duke@435 | 115 | return _basic_types[t]; |
duke@435 | 116 | } |
duke@435 | 117 | |
duke@435 | 118 | // ciReturnAddress |
duke@435 | 119 | // |
duke@435 | 120 | // This class represents the type of a specific return address in the |
duke@435 | 121 | // bytecodes. |
duke@435 | 122 | |
duke@435 | 123 | // ------------------------------------------------------------------ |
duke@435 | 124 | // ciReturnAddress::ciReturnAddress |
duke@435 | 125 | // |
duke@435 | 126 | ciReturnAddress::ciReturnAddress(int bci) : ciType(T_ADDRESS) { |
duke@435 | 127 | assert(0 <= bci, "bci cannot be negative"); |
duke@435 | 128 | _bci = bci; |
duke@435 | 129 | } |
duke@435 | 130 | |
duke@435 | 131 | // ------------------------------------------------------------------ |
duke@435 | 132 | // ciReturnAddress::print_impl |
duke@435 | 133 | // |
duke@435 | 134 | // Implementation of the print method. |
duke@435 | 135 | void ciReturnAddress::print_impl(outputStream* st) { |
duke@435 | 136 | st->print(" bci=%d", _bci); |
duke@435 | 137 | } |
duke@435 | 138 | |
duke@435 | 139 | // ------------------------------------------------------------------ |
duke@435 | 140 | // ciReturnAddress::make |
duke@435 | 141 | ciReturnAddress* ciReturnAddress::make(int bci) { |
duke@435 | 142 | GUARDED_VM_ENTRY(return CURRENT_ENV->get_return_address(bci);) |
duke@435 | 143 | } |