src/share/vm/utilities/chunkedList.hpp

Tue, 24 Jul 2018 13:22:11 +0800

author
aoqi
date
Tue, 24 Jul 2018 13:22:11 +0800
changeset 9137
dc1769738300
parent 7333
b12a2a9b05ca
permissions
-rw-r--r--

#7048 added Loongson release info to hs_err crash files

     1 /*
     2  * Copyright (c) 2014, 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  *
    23  */
    25 #ifndef SHARE_VM_UTILITIES_CHUNKED_LIST_HPP
    26 #define SHARE_VM_UTILITIES_CHUNKED_LIST_HPP
    28 #include "memory/allocation.hpp"
    29 #include "utilities/debug.hpp"
    31 template <class T, MEMFLAGS F> class ChunkedList : public CHeapObj<F> {
    32   template <class U> friend class TestChunkedList;
    34   static const size_t BufferSize = 64;
    36   T  _values[BufferSize];
    37   T* _top;
    39   ChunkedList<T, F>* _next_used;
    40   ChunkedList<T, F>* _next_free;
    42   T const * end() const {
    43     return &_values[BufferSize];
    44   }
    46  public:
    47   ChunkedList<T, F>() : _top(_values), _next_used(NULL), _next_free(NULL) {}
    49   bool is_full() const {
    50     return _top == end();
    51   }
    53   void clear() {
    54     _top = _values;
    55     // Don't clear the next pointers since that would interfere
    56     // with other threads trying to iterate through the lists.
    57   }
    59   void push(T m) {
    60     assert(!is_full(), "Buffer is full");
    61     *_top = m;
    62     _top++;
    63   }
    65   void set_next_used(ChunkedList<T, F>* buffer) { _next_used = buffer; }
    66   void set_next_free(ChunkedList<T, F>* buffer) { _next_free = buffer; }
    68   ChunkedList<T, F>* next_used() const          { return _next_used; }
    69   ChunkedList<T, F>* next_free() const          { return _next_free; }
    71   size_t size() const {
    72     return pointer_delta(_top, _values, sizeof(T));
    73   }
    75   T at(size_t i) {
    76     assert(i < size(), err_msg("IOOBE i: " SIZE_FORMAT " size(): " SIZE_FORMAT, i, size()));
    77     return _values[i];
    78   }
    79 };
    81 #endif // SHARE_VM_UTILITIES_CHUNKED_LIST_HPP

mercurial