annotate src/share/vm/utilities/chunkedList.hpp @ 21559:be896a1983c0

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