1 /* |
1 /* |
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
62 // between a call to init() and a call to release(). The count |
62 // between a call to init() and a call to release(). The count |
63 // mostly includes regions that are freshly allocated, as well as |
63 // mostly includes regions that are freshly allocated, as well as |
64 // the region that is re-used using the set() method. This count can |
64 // the region that is re-used using the set() method. This count can |
65 // be used in any heuristics that might want to bound how many |
65 // be used in any heuristics that might want to bound how many |
66 // distinct regions this object can used during an active interval. |
66 // distinct regions this object can used during an active interval. |
67 size_t _count; |
67 uint _count; |
68 |
68 |
69 // When we set up a new active region we save its used bytes in this |
69 // When we set up a new active region we save its used bytes in this |
70 // field so that, when we retire it, we can calculate how much space |
70 // field so that, when we retire it, we can calculate how much space |
71 // we allocated in it. |
71 // we allocated in it. |
72 size_t _used_bytes_before; |
72 size_t _used_bytes_before; |
134 HeapRegion* get() const { |
134 HeapRegion* get() const { |
135 // Make sure that the dummy region does not escape this class. |
135 // Make sure that the dummy region does not escape this class. |
136 return (_alloc_region == _dummy_region) ? NULL : _alloc_region; |
136 return (_alloc_region == _dummy_region) ? NULL : _alloc_region; |
137 } |
137 } |
138 |
138 |
139 size_t count() { return _count; } |
139 uint count() { return _count; } |
140 |
140 |
141 // The following two are the building blocks for the allocation method. |
141 // The following two are the building blocks for the allocation method. |
142 |
142 |
143 // First-level allocation: Should be called without holding a |
143 // First-level allocation: Should be called without holding a |
144 // lock. It will try to allocate lock-free out of the active region, |
144 // lock. It will try to allocate lock-free out of the active region, |