duke@435: /* hseigel@4987: * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #include "precompiled.hpp" coleenp@4037: #include "classfile/altHashing.hpp" stefank@2314: #include "classfile/javaClasses.hpp" stefank@2314: #include "oops/oop.inline.hpp" stefank@2314: #include "runtime/handles.inline.hpp" stefank@4299: #include "runtime/thread.inline.hpp" stefank@2314: #include "utilities/copy.hpp" duke@435: duke@435: bool always_do_update_barrier = false; duke@435: duke@435: BarrierSet* oopDesc::_bs = NULL; duke@435: duke@435: void oopDesc::print_on(outputStream* st) const { duke@435: if (this == NULL) { duke@435: st->print_cr("NULL"); duke@435: } else { coleenp@4037: klass()->oop_print_on(oop(this), st); duke@435: } duke@435: } duke@435: duke@435: void oopDesc::print_address_on(outputStream* st) const { duke@435: if (PrintOopAddress) { jrose@1100: st->print("{"INTPTR_FORMAT"}", this); duke@435: } duke@435: } duke@435: duke@435: void oopDesc::print() { print_on(tty); } duke@435: duke@435: void oopDesc::print_address() { print_address_on(tty); } duke@435: duke@435: char* oopDesc::print_string() { jrose@1590: stringStream st; jrose@1590: print_on(&st); jrose@1590: return st.as_string(); jrose@1590: } jrose@1590: jrose@1590: void oopDesc::print_value() { jrose@1590: print_value_on(tty); duke@435: } duke@435: duke@435: char* oopDesc::print_value_string() { jrose@1590: char buf[100]; jrose@1590: stringStream st(buf, sizeof(buf)); jrose@1590: print_value_on(&st); jrose@1590: return st.as_string(); duke@435: } duke@435: jrose@1590: void oopDesc::print_value_on(outputStream* st) const { jrose@1590: oop obj = oop(this); jrose@1590: if (this == NULL) { jrose@1590: st->print("NULL"); jrose@1590: } else if (java_lang_String::is_instance(obj)) { jrose@1590: java_lang_String::print(obj, st); jrose@1590: if (PrintOopAddress) print_address_on(st); jrose@1590: } else { coleenp@4037: klass()->oop_print_value_on(obj, st); jrose@1590: } jrose@1590: } jrose@1590: duke@435: duke@435: void oopDesc::verify_on(outputStream* st) { duke@435: if (this != NULL) { coleenp@4037: klass()->oop_verify_on(this, st); duke@435: } duke@435: } duke@435: duke@435: duke@435: void oopDesc::verify() { duke@435: verify_on(tty); duke@435: } duke@435: duke@435: intptr_t oopDesc::slow_identity_hash() { duke@435: // slow case; we have to acquire the micro lock in order to locate the header duke@435: ResetNoHandleMark rnm; // Might be called from LEAF/QUICK ENTRY duke@435: HandleMark hm; coleenp@4037: Handle object(this); duke@435: return ObjectSynchronizer::identity_hash_value_for(object); duke@435: } duke@435: coleenp@4037: // When String table needs to rehash coleenp@4037: unsigned int oopDesc::new_hash(jint seed) { hseigel@4987: EXCEPTION_MARK; coleenp@4037: ResourceMark rm; coleenp@4037: int length; hseigel@4987: jchar* chars = java_lang_String::as_unicode_string(this, length, THREAD); hseigel@4987: if (chars != NULL) { hseigel@4987: // Use alternate hashing algorithm on the string hseigel@4987: return AltHashing::murmur3_32(seed, chars, length); hseigel@4987: } else { hseigel@4987: vm_exit_out_of_memory(length, "unable to create Unicode strings for String table rehash"); hseigel@4987: return 0; hseigel@4987: } coleenp@4037: } coleenp@4037: duke@435: VerifyOopClosure VerifyOopClosure::verify_oop; coleenp@548: coleenp@548: void VerifyOopClosure::do_oop(oop* p) { VerifyOopClosure::do_oop_work(p); } coleenp@548: void VerifyOopClosure::do_oop(narrowOop* p) { VerifyOopClosure::do_oop_work(p); }