< prev index next >

src/share/vm/runtime/objectMonitor.cpp

Print this page


   1 /*
   2  * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


1656 
1657     if (policy == 0) {       // prepend to EntryList
1658       if (list == NULL) {
1659         iterator->_next = iterator->_prev = NULL;
1660         _EntryList = iterator;
1661       } else {
1662         list->_prev = iterator;
1663         iterator->_next = list;
1664         iterator->_prev = NULL;
1665         _EntryList = iterator;
1666       }
1667     } else if (policy == 1) {      // append to EntryList
1668       if (list == NULL) {
1669         iterator->_next = iterator->_prev = NULL;
1670         _EntryList = iterator;
1671       } else {
1672         // CONSIDER:  finding the tail currently requires a linear-time walk of
1673         // the EntryList.  We can make tail access constant-time by converting to
1674         // a CDLL instead of using our current DLL.
1675         ObjectWaiter * tail;
1676         for (tail = list; tail->_next != NULL; tail = tail->_next) /* empty */;
1677         assert(tail != NULL && tail->_next == NULL, "invariant");
1678         tail->_next = iterator;
1679         iterator->_prev = tail;
1680         iterator->_next = NULL;
1681       }
1682     } else if (policy == 2) {      // prepend to cxq
1683       if (list == NULL) {
1684         iterator->_next = iterator->_prev = NULL;
1685         _EntryList = iterator;
1686       } else {
1687         iterator->TState = ObjectWaiter::TS_CXQ;
1688         for (;;) {
1689           ObjectWaiter * front = _cxq;
1690           iterator->_next = front;
1691           if (Atomic::cmpxchg_ptr(iterator, &_cxq, front) == front) {
1692             break;
1693           }
1694         }
1695       }
1696     } else if (policy == 3) {      // append to cxq


   1 /*
   2  * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


1656 
1657     if (policy == 0) {       // prepend to EntryList
1658       if (list == NULL) {
1659         iterator->_next = iterator->_prev = NULL;
1660         _EntryList = iterator;
1661       } else {
1662         list->_prev = iterator;
1663         iterator->_next = list;
1664         iterator->_prev = NULL;
1665         _EntryList = iterator;
1666       }
1667     } else if (policy == 1) {      // append to EntryList
1668       if (list == NULL) {
1669         iterator->_next = iterator->_prev = NULL;
1670         _EntryList = iterator;
1671       } else {
1672         // CONSIDER:  finding the tail currently requires a linear-time walk of
1673         // the EntryList.  We can make tail access constant-time by converting to
1674         // a CDLL instead of using our current DLL.
1675         ObjectWaiter * tail;
1676         for (tail = list; tail->_next != NULL; tail = tail->_next) {}
1677         assert(tail != NULL && tail->_next == NULL, "invariant");
1678         tail->_next = iterator;
1679         iterator->_prev = tail;
1680         iterator->_next = NULL;
1681       }
1682     } else if (policy == 2) {      // prepend to cxq
1683       if (list == NULL) {
1684         iterator->_next = iterator->_prev = NULL;
1685         _EntryList = iterator;
1686       } else {
1687         iterator->TState = ObjectWaiter::TS_CXQ;
1688         for (;;) {
1689           ObjectWaiter * front = _cxq;
1690           iterator->_next = front;
1691           if (Atomic::cmpxchg_ptr(iterator, &_cxq, front) == front) {
1692             break;
1693           }
1694         }
1695       }
1696     } else if (policy == 3) {      // append to cxq


< prev index next >