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

stefank@7333 1 /*
stefank@7333 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
stefank@7333 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
stefank@7333 4 *
stefank@7333 5 * This code is free software; you can redistribute it and/or modify it
stefank@7333 6 * under the terms of the GNU General Public License version 2 only, as
stefank@7333 7 * published by the Free Software Foundation.
stefank@7333 8 *
stefank@7333 9 * This code is distributed in the hope that it will be useful, but WITHOUT
stefank@7333 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
stefank@7333 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
stefank@7333 12 * version 2 for more details (a copy is included in the LICENSE file that
stefank@7333 13 * accompanied this code).
stefank@7333 14 *
stefank@7333 15 * You should have received a copy of the GNU General Public License version
stefank@7333 16 * 2 along with this work; if not, write to the Free Software Foundation,
stefank@7333 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
stefank@7333 18 *
stefank@7333 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
stefank@7333 20 * or visit www.oracle.com if you need additional information or have any
stefank@7333 21 * questions.
stefank@7333 22 *
stefank@7333 23 */
stefank@7333 24
stefank@7333 25 #ifndef SHARE_VM_UTILITIES_CHUNKED_LIST_HPP
stefank@7333 26 #define SHARE_VM_UTILITIES_CHUNKED_LIST_HPP
stefank@7333 27
stefank@7333 28 #include "memory/allocation.hpp"
stefank@7333 29 #include "utilities/debug.hpp"
stefank@7333 30
stefank@7333 31 template <class T, MEMFLAGS F> class ChunkedList : public CHeapObj<F> {
stefank@7333 32 template <class U> friend class TestChunkedList;
stefank@7333 33
stefank@7333 34 static const size_t BufferSize = 64;
stefank@7333 35
stefank@7333 36 T _values[BufferSize];
stefank@7333 37 T* _top;
stefank@7333 38
stefank@7333 39 ChunkedList<T, F>* _next_used;
stefank@7333 40 ChunkedList<T, F>* _next_free;
stefank@7333 41
stefank@7333 42 T const * end() const {
stefank@7333 43 return &_values[BufferSize];
stefank@7333 44 }
stefank@7333 45
stefank@7333 46 public:
stefank@7333 47 ChunkedList<T, F>() : _top(_values), _next_used(NULL), _next_free(NULL) {}
stefank@7333 48
stefank@7333 49 bool is_full() const {
stefank@7333 50 return _top == end();
stefank@7333 51 }
stefank@7333 52
stefank@7333 53 void clear() {
stefank@7333 54 _top = _values;
stefank@7333 55 // Don't clear the next pointers since that would interfere
stefank@7333 56 // with other threads trying to iterate through the lists.
stefank@7333 57 }
stefank@7333 58
stefank@7333 59 void push(T m) {
stefank@7333 60 assert(!is_full(), "Buffer is full");
stefank@7333 61 *_top = m;
stefank@7333 62 _top++;
stefank@7333 63 }
stefank@7333 64
stefank@7333 65 void set_next_used(ChunkedList<T, F>* buffer) { _next_used = buffer; }
stefank@7333 66 void set_next_free(ChunkedList<T, F>* buffer) { _next_free = buffer; }
stefank@7333 67
stefank@7333 68 ChunkedList<T, F>* next_used() const { return _next_used; }
stefank@7333 69 ChunkedList<T, F>* next_free() const { return _next_free; }
stefank@7333 70
stefank@7333 71 size_t size() const {
stefank@7333 72 return pointer_delta(_top, _values, sizeof(T));
stefank@7333 73 }
stefank@7333 74
stefank@7333 75 T at(size_t i) {
stefank@7333 76 assert(i < size(), err_msg("IOOBE i: " SIZE_FORMAT " size(): " SIZE_FORMAT, i, size()));
stefank@7333 77 return _values[i];
stefank@7333 78 }
stefank@7333 79 };
stefank@7333 80
stefank@7333 81 #endif // SHARE_VM_UTILITIES_CHUNKED_LIST_HPP

mercurial