src/share/vm/runtime/objectMonitor.inline.hpp

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

author
thartmann
date
Tue, 29 Jul 2014 13:56:29 +0200
changeset 7002
a073be2ce5c2
parent 4471
22ba8c8ce6a6
child 6876
710a3c8b516e
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 /*
dcubed@4471 2 * Copyright (c) 1998, 2013, 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 #ifndef SHARE_VM_RUNTIME_OBJECTMONITOR_INLINE_HPP
stefank@2314 26 #define SHARE_VM_RUNTIME_OBJECTMONITOR_INLINE_HPP
stefank@2314 27
duke@435 28 inline intptr_t ObjectMonitor::is_entered(TRAPS) const {
duke@435 29 if (THREAD == _owner || THREAD->is_lock_owned((address) _owner)) {
duke@435 30 return 1;
duke@435 31 }
duke@435 32 return 0;
duke@435 33 }
duke@435 34
duke@435 35 inline markOop ObjectMonitor::header() const {
duke@435 36 return _header;
duke@435 37 }
duke@435 38
duke@435 39 inline void ObjectMonitor::set_header(markOop hdr) {
duke@435 40 _header = hdr;
duke@435 41 }
duke@435 42
duke@435 43 inline intptr_t ObjectMonitor::count() const {
duke@435 44 return _count;
duke@435 45 }
duke@435 46
duke@435 47 inline void ObjectMonitor::set_count(intptr_t count) {
duke@435 48 _count= count;
duke@435 49 }
duke@435 50
duke@435 51 inline intptr_t ObjectMonitor::waiters() const {
duke@435 52 return _waiters;
duke@435 53 }
duke@435 54
duke@435 55 inline void* ObjectMonitor::owner() const {
duke@435 56 return _owner;
duke@435 57 }
duke@435 58
duke@435 59 inline void ObjectMonitor::clear() {
duke@435 60 assert(_header, "Fatal logic error in ObjectMonitor header!");
duke@435 61 assert(_count == 0, "Fatal logic error in ObjectMonitor count!");
duke@435 62 assert(_waiters == 0, "Fatal logic error in ObjectMonitor waiters!");
duke@435 63 assert(_recursions == 0, "Fatal logic error in ObjectMonitor recursions!");
duke@435 64 assert(_object, "Fatal logic error in ObjectMonitor object!");
duke@435 65 assert(_owner == 0, "Fatal logic error in ObjectMonitor owner!");
duke@435 66
duke@435 67 _header = NULL;
duke@435 68 _object = NULL;
duke@435 69 }
duke@435 70
duke@435 71
duke@435 72 inline void* ObjectMonitor::object() const {
duke@435 73 return _object;
duke@435 74 }
duke@435 75
duke@435 76 inline void* ObjectMonitor::object_addr() {
duke@435 77 return (void *)(&_object);
duke@435 78 }
duke@435 79
duke@435 80 inline void ObjectMonitor::set_object(void* obj) {
duke@435 81 _object = obj;
duke@435 82 }
duke@435 83
duke@435 84 inline bool ObjectMonitor::check(TRAPS) {
duke@435 85 if (THREAD != _owner) {
duke@435 86 if (THREAD->is_lock_owned((address) _owner)) {
duke@435 87 _owner = THREAD; // regain ownership of inflated monitor
duke@435 88 OwnerIsThread = 1 ;
duke@435 89 assert (_recursions == 0, "invariant") ;
duke@435 90 } else {
duke@435 91 check_slow(THREAD);
duke@435 92 return false;
duke@435 93 }
duke@435 94 }
duke@435 95 return true;
duke@435 96 }
duke@435 97
duke@435 98
duke@435 99 // return number of threads contending for this monitor
duke@435 100 inline intptr_t ObjectMonitor::contentions() const {
duke@435 101 return _count;
duke@435 102 }
duke@435 103
dcubed@4471 104 // Do NOT set _count = 0. There is a race such that _count could
dcubed@4471 105 // be set while inflating prior to setting _owner
dcubed@4471 106 // Just use Atomic::inc/dec and assert 0 when monitor put on free list
duke@435 107 inline void ObjectMonitor::set_owner(void* owner) {
duke@435 108 _owner = owner;
duke@435 109 _recursions = 0;
duke@435 110 }
duke@435 111
stefank@2314 112
stefank@2314 113 #endif // SHARE_VM_RUNTIME_OBJECTMONITOR_INLINE_HPP

mercurial