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 | /* |
brutisso@3711 | 2 | * Copyright (c) 1997, 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 "classfile/altHashing.hpp" |
stefank@2314 | 27 | #include "classfile/javaClasses.hpp" |
stefank@2314 | 28 | #include "oops/oop.inline.hpp" |
stefank@2314 | 29 | #include "runtime/handles.inline.hpp" |
stefank@2314 | 30 | #include "utilities/copy.hpp" |
stefank@2314 | 31 | #ifdef TARGET_OS_FAMILY_linux |
stefank@2314 | 32 | # include "thread_linux.inline.hpp" |
stefank@2314 | 33 | #endif |
stefank@2314 | 34 | #ifdef TARGET_OS_FAMILY_solaris |
stefank@2314 | 35 | # include "thread_solaris.inline.hpp" |
stefank@2314 | 36 | #endif |
stefank@2314 | 37 | #ifdef TARGET_OS_FAMILY_windows |
stefank@2314 | 38 | # include "thread_windows.inline.hpp" |
stefank@2314 | 39 | #endif |
never@3156 | 40 | #ifdef TARGET_OS_FAMILY_bsd |
never@3156 | 41 | # include "thread_bsd.inline.hpp" |
never@3156 | 42 | #endif |
duke@435 | 43 | |
duke@435 | 44 | bool always_do_update_barrier = false; |
duke@435 | 45 | |
duke@435 | 46 | BarrierSet* oopDesc::_bs = NULL; |
duke@435 | 47 | |
duke@435 | 48 | void oopDesc::print_on(outputStream* st) const { |
duke@435 | 49 | if (this == NULL) { |
duke@435 | 50 | st->print_cr("NULL"); |
duke@435 | 51 | } else { |
coleenp@4037 | 52 | klass()->oop_print_on(oop(this), st); |
duke@435 | 53 | } |
duke@435 | 54 | } |
duke@435 | 55 | |
duke@435 | 56 | void oopDesc::print_address_on(outputStream* st) const { |
duke@435 | 57 | if (PrintOopAddress) { |
jrose@1100 | 58 | st->print("{"INTPTR_FORMAT"}", this); |
duke@435 | 59 | } |
duke@435 | 60 | } |
duke@435 | 61 | |
duke@435 | 62 | void oopDesc::print() { print_on(tty); } |
duke@435 | 63 | |
duke@435 | 64 | void oopDesc::print_address() { print_address_on(tty); } |
duke@435 | 65 | |
duke@435 | 66 | char* oopDesc::print_string() { |
jrose@1590 | 67 | stringStream st; |
jrose@1590 | 68 | print_on(&st); |
jrose@1590 | 69 | return st.as_string(); |
jrose@1590 | 70 | } |
jrose@1590 | 71 | |
jrose@1590 | 72 | void oopDesc::print_value() { |
jrose@1590 | 73 | print_value_on(tty); |
duke@435 | 74 | } |
duke@435 | 75 | |
duke@435 | 76 | char* oopDesc::print_value_string() { |
jrose@1590 | 77 | char buf[100]; |
jrose@1590 | 78 | stringStream st(buf, sizeof(buf)); |
jrose@1590 | 79 | print_value_on(&st); |
jrose@1590 | 80 | return st.as_string(); |
duke@435 | 81 | } |
duke@435 | 82 | |
jrose@1590 | 83 | void oopDesc::print_value_on(outputStream* st) const { |
jrose@1590 | 84 | oop obj = oop(this); |
jrose@1590 | 85 | if (this == NULL) { |
jrose@1590 | 86 | st->print("NULL"); |
jrose@1590 | 87 | } else if (java_lang_String::is_instance(obj)) { |
jrose@1590 | 88 | java_lang_String::print(obj, st); |
jrose@1590 | 89 | if (PrintOopAddress) print_address_on(st); |
jrose@1590 | 90 | } else { |
coleenp@4037 | 91 | klass()->oop_print_value_on(obj, st); |
jrose@1590 | 92 | } |
jrose@1590 | 93 | } |
jrose@1590 | 94 | |
duke@435 | 95 | |
duke@435 | 96 | void oopDesc::verify_on(outputStream* st) { |
duke@435 | 97 | if (this != NULL) { |
coleenp@4037 | 98 | klass()->oop_verify_on(this, st); |
duke@435 | 99 | } |
duke@435 | 100 | } |
duke@435 | 101 | |
duke@435 | 102 | |
duke@435 | 103 | void oopDesc::verify() { |
duke@435 | 104 | verify_on(tty); |
duke@435 | 105 | } |
duke@435 | 106 | |
duke@435 | 107 | intptr_t oopDesc::slow_identity_hash() { |
duke@435 | 108 | // slow case; we have to acquire the micro lock in order to locate the header |
duke@435 | 109 | ResetNoHandleMark rnm; // Might be called from LEAF/QUICK ENTRY |
duke@435 | 110 | HandleMark hm; |
coleenp@4037 | 111 | Handle object(this); |
duke@435 | 112 | return ObjectSynchronizer::identity_hash_value_for(object); |
duke@435 | 113 | } |
duke@435 | 114 | |
coleenp@4037 | 115 | // When String table needs to rehash |
coleenp@4037 | 116 | unsigned int oopDesc::new_hash(jint seed) { |
coleenp@4037 | 117 | ResourceMark rm; |
coleenp@4037 | 118 | int length; |
coleenp@4037 | 119 | jchar* chars = java_lang_String::as_unicode_string(this, length); |
coleenp@4037 | 120 | // Use alternate hashing algorithm on the string |
coleenp@4037 | 121 | return AltHashing::murmur3_32(seed, chars, length); |
coleenp@4037 | 122 | } |
coleenp@4037 | 123 | |
duke@435 | 124 | VerifyOopClosure VerifyOopClosure::verify_oop; |
coleenp@548 | 125 | |
coleenp@548 | 126 | void VerifyOopClosure::do_oop(oop* p) { VerifyOopClosure::do_oop_work(p); } |
coleenp@548 | 127 | void VerifyOopClosure::do_oop(narrowOop* p) { VerifyOopClosure::do_oop_work(p); } |