src/share/vm/runtime/unhandledOops.cpp

Tue, 29 Jul 2014 13:56:29 +0200

author
thartmann
date
Tue, 29 Jul 2014 13:56:29 +0200
changeset 7002
a073be2ce5c2
parent 6680
78bbf4d43a14
child 6876
710a3c8b516e
child 9327
f96fcd9e1e1b
permissions
-rw-r--r--

8049043: Load variable through a pointer of an incompatible type in hotspot/src/share/vm/runtime/sharedRuntimeMath.hpp
Summary: Fixed parfait warnings caused by __HI and __LO macros in sharedRuntimeMath.hpp by using a union.
Reviewed-by: kvn

duke@435 1 /*
drchase@6680 2 * Copyright (c) 2005, 2014, 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"
stefank@2314 26 #include "gc_interface/collectedHeap.hpp"
stefank@2314 27 #include "memory/gcLocker.inline.hpp"
stefank@2314 28 #include "memory/universe.hpp"
stefank@2314 29 #include "oops/oop.inline.hpp"
stefank@2314 30 #include "runtime/thread.hpp"
stefank@2314 31 #include "runtime/unhandledOops.hpp"
stefank@2314 32 #include "utilities/globalDefinitions.hpp"
duke@435 33
drchase@6680 34 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
drchase@6680 35
duke@435 36 #ifdef CHECK_UNHANDLED_OOPS
duke@435 37 const int free_list_size = 256;
duke@435 38
duke@435 39
duke@435 40 UnhandledOops::UnhandledOops(Thread* thread) {
duke@435 41 _thread = thread;
zgu@3900 42 _oop_list = new (ResourceObj::C_HEAP, mtInternal)
duke@435 43 GrowableArray<UnhandledOopEntry>(free_list_size, true);
duke@435 44 _level = 0;
duke@435 45 }
duke@435 46
duke@435 47 UnhandledOops::~UnhandledOops() {
duke@435 48 delete _oop_list;
duke@435 49 }
duke@435 50
duke@435 51
duke@435 52 void UnhandledOops::dump_oops(UnhandledOops *list) {
duke@435 53 for (int k = 0; k < list->_oop_list->length(); k++) {
duke@435 54 UnhandledOopEntry entry = list->_oop_list->at(k);
duke@435 55 tty->print(" " INTPTR_FORMAT, entry._oop_ptr);
duke@435 56 }
duke@435 57 tty->cr();
duke@435 58 }
duke@435 59
duke@435 60 // For debugging unhandled oop detector _in the debugger_
duke@435 61 // You don't want to turn it on in compiled code here.
duke@435 62 static bool unhandled_oop_print=0;
duke@435 63
duke@435 64 void UnhandledOops::register_unhandled_oop(oop* op, address pc) {
duke@435 65 if (!_thread->is_in_stack((address)op))
duke@435 66 return;
duke@435 67
duke@435 68 _level ++;
duke@435 69 if (unhandled_oop_print) {
duke@435 70 for (int i=0; i<_level; i++) tty->print(" ");
duke@435 71 tty->print_cr("r " INTPTR_FORMAT, op);
duke@435 72 }
duke@435 73 UnhandledOopEntry entry(op, pc);
duke@435 74 _oop_list->push(entry);
duke@435 75 }
duke@435 76
duke@435 77
duke@435 78 bool match_oop_entry(void *op, UnhandledOopEntry e) {
duke@435 79 return (e.oop_ptr() == op);
duke@435 80 }
duke@435 81
duke@435 82 // Mark unhandled oop as okay for GC - the containing struct has an oops_do and
duke@435 83 // for some reason the oop has to be on the stack.
duke@435 84 // May not be called for the current thread, as in the case of
duke@435 85 // VM_GetOrSetLocal in jvmti.
duke@435 86 void UnhandledOops::allow_unhandled_oop(oop* op) {
duke@435 87 assert (CheckUnhandledOops, "should only be called with checking option");
duke@435 88
coleenp@4037 89 int i = _oop_list->find_from_end(op, match_oop_entry);
duke@435 90 assert(i!=-1, "safe for gc oop not in unhandled_oop_list");
duke@435 91
duke@435 92 UnhandledOopEntry entry = _oop_list->at(i);
duke@435 93 assert(!entry._ok_for_gc, "duplicate entry");
duke@435 94 entry._ok_for_gc = true;
duke@435 95 _oop_list->at_put(i, entry);
duke@435 96 }
duke@435 97
duke@435 98
duke@435 99 // Called by the oop destructor to remove unhandled oop from the thread's
duke@435 100 // oop list. All oops given are assumed to be on the list. If not,
duke@435 101 // there's a bug in the unhandled oop detector.
duke@435 102 void UnhandledOops::unregister_unhandled_oop(oop* op) {
duke@435 103 if (!_thread->is_in_stack((address)op)) return;
duke@435 104
duke@435 105 _level --;
duke@435 106 if (unhandled_oop_print) {
duke@435 107 for (int i=0; i<_level; i++) tty->print(" ");
duke@435 108 tty->print_cr("u "INTPTR_FORMAT, op);
duke@435 109 }
duke@435 110
coleenp@4037 111 int i = _oop_list->find_from_end(op, match_oop_entry);
duke@435 112 assert(i!=-1, "oop not in unhandled_oop_list");
duke@435 113 _oop_list->remove_at(i);
duke@435 114 }
duke@435 115
duke@435 116 void UnhandledOops::clear_unhandled_oops() {
duke@435 117 assert (CheckUnhandledOops, "should only be called with checking option");
sjohanss@6619 118
duke@435 119 for (int k = 0; k < _oop_list->length(); k++) {
duke@435 120 UnhandledOopEntry entry = _oop_list->at(k);
duke@435 121 // If an entry is on the unhandled oop list but isn't on the stack
duke@435 122 // anymore, it must not have gotten unregistered properly and it's a bug
duke@435 123 // in the unhandled oop generator.
duke@435 124 if(!_thread->is_in_stack((address)entry._oop_ptr)) {
duke@435 125 tty->print_cr("oop_ptr is " INTPTR_FORMAT, (address)entry._oop_ptr);
duke@435 126 tty->print_cr("thread is " INTPTR_FORMAT " from pc " INTPTR_FORMAT,
duke@435 127 (address)_thread, (address)entry._pc);
duke@435 128 assert(false, "heap is corrupted by the unhandled oop detector");
duke@435 129 }
duke@435 130 // Set unhandled oops to a pattern that will crash distinctively
duke@435 131 if (!entry._ok_for_gc) *(intptr_t*)(entry._oop_ptr) = BAD_OOP_ADDR;
duke@435 132 }
duke@435 133 }
duke@435 134 #endif // CHECK_UNHANDLED_OOPS

mercurial