src/share/vm/oops/oop.cpp

Thu, 04 Apr 2019 17:56:29 +0800

author
aoqi
date
Thu, 04 Apr 2019 17:56:29 +0800
changeset 9572
624a0741915c
parent 9448
73d689add964
child 10015
eb7ce841ccec
permissions
-rw-r--r--

Merge

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

mercurial