src/hotspot/share/gc/z/zList.inline.hpp
author eosterlund
Tue, 12 Nov 2019 20:01:23 +0000
changeset 59038 b9a42ca342db
parent 58708 f74ec3cbfcc0
permissions -rw-r--r--
8233061: ZGC: Enforce memory ordering in segmented bit maps Reviewed-by: pliden, stefank
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     1
/*
58708
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
     2
 * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     4
 *
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     7
 * published by the Free Software Foundation.
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     8
 *
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    13
 * accompanied this code).
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    14
 *
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    18
 *
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    21
 * questions.
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    22
 */
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    23
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    24
#ifndef SHARE_GC_Z_ZLIST_INLINE_HPP
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    25
#define SHARE_GC_Z_ZLIST_INLINE_HPP
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    26
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    27
#include "gc/z/zList.hpp"
58708
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    28
#include "utilities/debug.hpp"
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    29
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    30
template <typename T>
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    31
inline ZListNode<T>::ZListNode(ZListNode* next, ZListNode* prev) :
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    32
    _next(next),
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    33
    _prev(prev) {}
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    34
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    35
template <typename T>
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    36
inline void ZListNode<T>::set_unused() {
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    37
  _next = NULL;
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    38
  _prev = NULL;
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    39
}
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    40
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    41
template <typename T>
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    42
inline ZListNode<T>::ZListNode() {
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    43
  set_unused();
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    44
}
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    45
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    46
template <typename T>
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    47
inline ZListNode<T>::~ZListNode() {
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    48
  set_unused();
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    49
}
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    50
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    51
template <typename T>
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    52
inline bool ZListNode<T>::is_unused() const {
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    53
  return _next == NULL && _prev == NULL;
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    54
}
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    55
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    56
template <typename T>
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    57
inline void ZList<T>::verify() const {
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    58
  assert(_head._next->_prev == &_head, "List corrupt");
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    59
  assert(_head._prev->_next == &_head, "List corrupt");
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    60
}
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    61
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    62
template <typename T>
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    63
inline void ZList<T>::insert(ZListNode<T>* before, ZListNode<T>* node) {
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    64
  verify();
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    65
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    66
  assert(node->is_unused(), "Already in a list");
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    67
  node->_prev = before;
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    68
  node->_next = before->_next;
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    69
  before->_next = node;
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    70
  node->_next->_prev = node;
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    71
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    72
  _size++;
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    73
}
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    74
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    75
template <typename T>
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    76
inline ZListNode<T>* ZList<T>::cast_to_inner(T* elem) const {
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    77
  return &elem->_node;
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    78
}
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    79
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    80
template <typename T>
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    81
inline T* ZList<T>::cast_to_outer(ZListNode<T>* node) const {
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    82
  return (T*)((uintptr_t)node - offset_of(T, _node));
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    83
}
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    84
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    85
template <typename T>
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    86
inline ZList<T>::ZList() :
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    87
    _head(&_head, &_head),
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    88
    _size(0) {
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    89
  verify();
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    90
}
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    91
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    92
template <typename T>
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    93
inline size_t ZList<T>::size() const {
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    94
  verify();
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    95
  return _size;
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    96
}
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    97
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    98
template <typename T>
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
    99
inline bool ZList<T>::is_empty() const {
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   100
  return _size == 0;
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   101
}
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   102
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   103
template <typename T>
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   104
inline T* ZList<T>::first() const {
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   105
  return is_empty() ? NULL : cast_to_outer(_head._next);
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   106
}
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   107
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   108
template <typename T>
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   109
inline T* ZList<T>::last() const {
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   110
  return is_empty() ? NULL : cast_to_outer(_head._prev);
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   111
}
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   112
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   113
template <typename T>
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   114
inline T* ZList<T>::next(T* elem) const {
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   115
  verify();
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   116
  ZListNode<T>* next = cast_to_inner(elem)->_next;
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   117
  return (next == &_head) ? NULL : cast_to_outer(next);
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   118
}
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   119
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   120
template <typename T>
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   121
inline T* ZList<T>::prev(T* elem) const {
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   122
  verify();
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   123
  ZListNode<T>* prev = cast_to_inner(elem)->_prev;
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   124
  return (prev == &_head) ? NULL : cast_to_outer(prev);
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   125
}
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   126
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   127
template <typename T>
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   128
inline void ZList<T>::insert_first(T* elem) {
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   129
  insert(&_head, cast_to_inner(elem));
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   130
}
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   131
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   132
template <typename T>
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   133
inline void ZList<T>::insert_last(T* elem) {
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   134
  insert(_head._prev, cast_to_inner(elem));
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   135
}
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   136
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   137
template <typename T>
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   138
inline void ZList<T>::insert_before(T* before, T* elem) {
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   139
  insert(cast_to_inner(before)->_prev, cast_to_inner(elem));
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   140
}
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   141
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   142
template <typename T>
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   143
inline void ZList<T>::insert_after(T* after, T* elem) {
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   144
  insert(cast_to_inner(after), cast_to_inner(elem));
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   145
}
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   146
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   147
template <typename T>
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   148
inline void ZList<T>::remove(T* elem) {
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   149
  verify();
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   150
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   151
  ZListNode<T>* const node = cast_to_inner(elem);
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   152
  assert(!node->is_unused(), "Not in a list");
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   153
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   154
  ZListNode<T>* const next = node->_next;
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   155
  ZListNode<T>* const prev = node->_prev;
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   156
  assert(next->_prev == node, "List corrupt");
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   157
  assert(prev->_next == node, "List corrupt");
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   158
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   159
  prev->_next = next;
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   160
  next->_prev = prev;
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   161
  node->set_unused();
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   162
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   163
  _size--;
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   164
}
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   165
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   166
template <typename T>
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   167
inline T* ZList<T>::remove_first() {
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   168
  T* elem = first();
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   169
  if (elem != NULL) {
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   170
    remove(elem);
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   171
  }
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   172
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   173
  return elem;
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   174
}
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   175
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   176
template <typename T>
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   177
inline T* ZList<T>::remove_last() {
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   178
  T* elem = last();
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   179
  if (elem != NULL) {
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   180
    remove(elem);
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   181
  }
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   182
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   183
  return elem;
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   184
}
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   185
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   186
template <typename T>
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   187
inline void ZList<T>::transfer(ZList<T>* list) {
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   188
  verify();
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   189
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   190
  if (!list->is_empty()) {
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   191
    list->_head._next->_prev = _head._prev;
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   192
    list->_head._prev->_next = _head._prev->_next;
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   193
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   194
    _head._prev->_next = list->_head._next;
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   195
    _head._prev = list->_head._prev;
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   196
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   197
    list->_head._next = &list->_head;
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   198
    list->_head._prev = &list->_head;
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   199
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   200
    _size += list->_size;
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   201
    list->_size = 0;
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   202
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   203
    list->verify();
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   204
    verify();
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   205
  }
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   206
}
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   207
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   208
template <typename T, bool forward>
58708
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   209
inline ZListIteratorImpl<T, forward>::ZListIteratorImpl(const ZList<T>* list) :
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   210
    _list(list),
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   211
    _next(forward ? list->first() : list->last()) {}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   212
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   213
template <typename T, bool forward>
58708
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   214
inline bool ZListIteratorImpl<T, forward>::next(T** elem) {
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   215
  if (_next != NULL) {
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   216
    *elem = _next;
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   217
    _next = forward ? _list->next(_next) : _list->prev(_next);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   218
    return true;
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   219
  }
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   220
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   221
  // No more elements
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   222
  return false;
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   223
}
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   224
58708
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   225
template <typename T>
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   226
inline ZListIterator<T>::ZListIterator(const ZList<T>* list) :
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   227
    ZListIteratorImpl<T, ZLIST_FORWARD>(list) {}
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   228
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   229
template <typename T>
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   230
inline ZListReverseIterator<T>::ZListReverseIterator(const ZList<T>* list) :
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   231
    ZListIteratorImpl<T, ZLIST_REVERSE>(list) {}
f74ec3cbfcc0 8232238: ZGC: Move ZList inline funtions to zList.inline.hpp
pliden
parents: 54834
diff changeset
   232
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
   233
#endif // SHARE_GC_Z_ZLIST_INLINE_HPP