annotate src/share/vm/oops/oop.cpp @ 7745:6dc8db7164d2

Added tag jdk9-b49 for changeset 360cd1fc42f1
author katleman
date Thu, 05 Feb 2015 11:43:29 -0800
parents cd6b3f1a94ff
children 6a5be7f00868
rev   line source
duke@0 1 /*
minqi@5895 2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
duke@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 *
duke@0 5 * This code is free software; you can redistribute it and/or modify it
duke@0 6 * under the terms of the GNU General Public License version 2 only, as
duke@0 7 * published by the Free Software Foundation.
duke@0 8 *
duke@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@0 13 * accompanied this code).
duke@0 14 *
duke@0 15 * You should have received a copy of the GNU General Public License version
duke@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 18 *
trims@1472 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1472 20 * or visit www.oracle.com if you need additional information or have any
trims@1472 21 * questions.
duke@0 22 *
duke@0 23 */
duke@0 24
stefank@1879 25 #include "precompiled.hpp"
coleenp@3602 26 #include "classfile/altHashing.hpp"
stefank@1879 27 #include "classfile/javaClasses.hpp"
stefank@1879 28 #include "oops/oop.inline.hpp"
stefank@1879 29 #include "runtime/handles.inline.hpp"
stefank@3864 30 #include "runtime/thread.inline.hpp"
stefank@1879 31 #include "utilities/copy.hpp"
duke@0 32
drchase@6412 33 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
drchase@6412 34
duke@0 35 bool always_do_update_barrier = false;
duke@0 36
duke@0 37 BarrierSet* oopDesc::_bs = NULL;
duke@0 38
duke@0 39 void oopDesc::print_on(outputStream* st) const {
duke@0 40 if (this == NULL) {
duke@0 41 st->print_cr("NULL");
duke@0 42 } else {
coleenp@3602 43 klass()->oop_print_on(oop(this), st);
duke@0 44 }
duke@0 45 }
duke@0 46
duke@0 47 void oopDesc::print_address_on(outputStream* st) const {
duke@0 48 if (PrintOopAddress) {
jrose@665 49 st->print("{"INTPTR_FORMAT"}", this);
duke@0 50 }
duke@0 51 }
duke@0 52
duke@0 53 void oopDesc::print() { print_on(tty); }
duke@0 54
duke@0 55 void oopDesc::print_address() { print_address_on(tty); }
duke@0 56
duke@0 57 char* oopDesc::print_string() {
jrose@1155 58 stringStream st;
jrose@1155 59 print_on(&st);
jrose@1155 60 return st.as_string();
jrose@1155 61 }
jrose@1155 62
jrose@1155 63 void oopDesc::print_value() {
jrose@1155 64 print_value_on(tty);
duke@0 65 }
duke@0 66
duke@0 67 char* oopDesc::print_value_string() {
jrose@1155 68 char buf[100];
jrose@1155 69 stringStream st(buf, sizeof(buf));
jrose@1155 70 print_value_on(&st);
jrose@1155 71 return st.as_string();
duke@0 72 }
duke@0 73
jrose@1155 74 void oopDesc::print_value_on(outputStream* st) const {
jrose@1155 75 oop obj = oop(this);
jrose@1155 76 if (this == NULL) {
jrose@1155 77 st->print("NULL");
jrose@1155 78 } else if (java_lang_String::is_instance(obj)) {
jrose@1155 79 java_lang_String::print(obj, st);
jrose@1155 80 if (PrintOopAddress) print_address_on(st);
jrose@1155 81 } else {
coleenp@3602 82 klass()->oop_print_value_on(obj, st);
jrose@1155 83 }
jrose@1155 84 }
jrose@1155 85
duke@0 86
duke@0 87 void oopDesc::verify_on(outputStream* st) {
duke@0 88 if (this != NULL) {
coleenp@3602 89 klass()->oop_verify_on(this, st);
duke@0 90 }
duke@0 91 }
duke@0 92
duke@0 93
duke@0 94 void oopDesc::verify() {
duke@0 95 verify_on(tty);
duke@0 96 }
duke@0 97
duke@0 98 intptr_t oopDesc::slow_identity_hash() {
duke@0 99 // slow case; we have to acquire the micro lock in order to locate the header
duke@0 100 ResetNoHandleMark rnm; // Might be called from LEAF/QUICK ENTRY
duke@0 101 HandleMark hm;
coleenp@3602 102 Handle object(this);
duke@0 103 return ObjectSynchronizer::identity_hash_value_for(object);
duke@0 104 }
duke@0 105
coleenp@3602 106 // When String table needs to rehash
minqi@5895 107 unsigned int oopDesc::new_hash(juint seed) {
hseigel@4552 108 EXCEPTION_MARK;
coleenp@3602 109 ResourceMark rm;
coleenp@3602 110 int length;
hseigel@4552 111 jchar* chars = java_lang_String::as_unicode_string(this, length, THREAD);
hseigel@4552 112 if (chars != NULL) {
hseigel@4552 113 // Use alternate hashing algorithm on the string
hseigel@4552 114 return AltHashing::murmur3_32(seed, chars, length);
hseigel@4552 115 } else {
ccheung@4558 116 vm_exit_out_of_memory(length, OOM_MALLOC_ERROR, "unable to create Unicode strings for String table rehash");
hseigel@4552 117 return 0;
hseigel@4552 118 }
coleenp@3602 119 }
coleenp@3602 120
duke@0 121 VerifyOopClosure VerifyOopClosure::verify_oop;
coleenp@113 122
coleenp@113 123 void VerifyOopClosure::do_oop(oop* p) { VerifyOopClosure::do_oop_work(p); }
coleenp@113 124 void VerifyOopClosure::do_oop(narrowOop* p) { VerifyOopClosure::do_oop_work(p); }