hotspot/src/share/vm/runtime/objectMonitor.inline.hpp
changeset 27165 785a8d56024c
parent 15234 ff1f01be5fbd
equal deleted inserted replaced
27164:6523fa019ffa 27165:785a8d56024c
     1 /*
     1 /*
     2  * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    38 
    38 
    39 inline void ObjectMonitor::set_header(markOop hdr) {
    39 inline void ObjectMonitor::set_header(markOop hdr) {
    40   _header = hdr;
    40   _header = hdr;
    41 }
    41 }
    42 
    42 
    43 inline intptr_t ObjectMonitor::count() const {
    43 inline jint ObjectMonitor::count() const {
    44   return _count;
    44   return _count;
    45 }
    45 }
    46 
    46 
    47 inline void ObjectMonitor::set_count(intptr_t count) {
    47 inline jint ObjectMonitor::waiters() const {
    48   _count= count;
       
    49 }
       
    50 
       
    51 inline intptr_t ObjectMonitor::waiters() const {
       
    52   return _waiters;
    48   return _waiters;
    53 }
    49 }
    54 
    50 
    55 inline void* ObjectMonitor::owner() const {
    51 inline void* ObjectMonitor::owner() const {
    56   return _owner;
    52   return _owner;
    59 inline void ObjectMonitor::clear() {
    55 inline void ObjectMonitor::clear() {
    60   assert(_header, "Fatal logic error in ObjectMonitor header!");
    56   assert(_header, "Fatal logic error in ObjectMonitor header!");
    61   assert(_count == 0, "Fatal logic error in ObjectMonitor count!");
    57   assert(_count == 0, "Fatal logic error in ObjectMonitor count!");
    62   assert(_waiters == 0, "Fatal logic error in ObjectMonitor waiters!");
    58   assert(_waiters == 0, "Fatal logic error in ObjectMonitor waiters!");
    63   assert(_recursions == 0, "Fatal logic error in ObjectMonitor recursions!");
    59   assert(_recursions == 0, "Fatal logic error in ObjectMonitor recursions!");
    64   assert(_object, "Fatal logic error in ObjectMonitor object!");
    60   assert(_object != NULL, "Fatal logic error in ObjectMonitor object!");
    65   assert(_owner == 0, "Fatal logic error in ObjectMonitor owner!");
    61   assert(_owner == 0, "Fatal logic error in ObjectMonitor owner!");
    66 
    62 
    67   _header = NULL;
    63   _header = NULL;
    68   _object = NULL;
    64   _object = NULL;
    69 }
    65 }
    83 
    79 
    84 inline bool ObjectMonitor::check(TRAPS) {
    80 inline bool ObjectMonitor::check(TRAPS) {
    85   if (THREAD != _owner) {
    81   if (THREAD != _owner) {
    86     if (THREAD->is_lock_owned((address) _owner)) {
    82     if (THREAD->is_lock_owned((address) _owner)) {
    87       _owner = THREAD;  // regain ownership of inflated monitor
    83       _owner = THREAD;  // regain ownership of inflated monitor
    88       OwnerIsThread = 1 ;
       
    89       assert (_recursions == 0, "invariant") ;
    84       assert (_recursions == 0, "invariant") ;
    90     } else {
    85     } else {
    91       check_slow(THREAD);
    86       check_slow(THREAD);
    92       return false;
    87       return false;
    93     }
    88     }
    95   return true;
    90   return true;
    96 }
    91 }
    97 
    92 
    98 
    93 
    99 // return number of threads contending for this monitor
    94 // return number of threads contending for this monitor
   100 inline intptr_t ObjectMonitor::contentions() const {
    95 inline jint ObjectMonitor::contentions() const {
   101   return _count;
    96   return _count;
   102 }
    97 }
   103 
    98 
   104 // Do NOT set _count = 0. There is a race such that _count could
    99 // Do NOT set _count = 0. There is a race such that _count could
   105 // be set while inflating prior to setting _owner
   100 // be set while inflating prior to setting _owner