src/share/vm/gc_implementation/parallelScavenge/psPromotionLAB.hpp

Sun, 13 Apr 2008 17:43:42 -0400

author
coleenp
date
Sun, 13 Apr 2008 17:43:42 -0400
changeset 548
ba764ed4b6f2
parent 435
a61af66fc99e
child 631
d1605aabd0a1
permissions
-rw-r--r--

6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Summary: Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold

duke@435 1 /*
duke@435 2 * Copyright 2002 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 //
duke@435 26 // PSPromotionLAB is a parallel scavenge promotion lab. This class acts very
duke@435 27 // much like a MutableSpace. We couldn't embed a MutableSpace, though, as
duke@435 28 // it has a considerable number of asserts and invariants that are violated.
duke@435 29 //
duke@435 30
duke@435 31 class ObjectStartArray;
duke@435 32
duke@435 33 class PSPromotionLAB : public CHeapObj {
duke@435 34 protected:
coleenp@548 35 static size_t filler_header_size;
duke@435 36
duke@435 37 enum LabState {
duke@435 38 needs_flush,
duke@435 39 flushed,
duke@435 40 zero_size
duke@435 41 };
duke@435 42
duke@435 43 HeapWord* _top;
duke@435 44 HeapWord* _bottom;
duke@435 45 HeapWord* _end;
duke@435 46 LabState _state;
duke@435 47
duke@435 48 void set_top(HeapWord* value) { _top = value; }
duke@435 49 void set_bottom(HeapWord* value) { _bottom = value; }
duke@435 50 void set_end(HeapWord* value) { _end = value; }
duke@435 51
duke@435 52 // The shared initialize code invokes this.
duke@435 53 debug_only(virtual bool lab_is_valid(MemRegion lab) { return false; });
duke@435 54
duke@435 55 PSPromotionLAB() : _top(NULL), _bottom(NULL), _end(NULL) { }
duke@435 56
duke@435 57 public:
duke@435 58 // Filling and flushing.
duke@435 59 void initialize(MemRegion lab);
duke@435 60
duke@435 61 virtual void flush();
duke@435 62
duke@435 63 // Accessors
duke@435 64 HeapWord* bottom() const { return _bottom; }
duke@435 65 HeapWord* end() const { return _end; }
duke@435 66 HeapWord* top() const { return _top; }
duke@435 67
duke@435 68 bool is_flushed() { return _state == flushed; }
duke@435 69
duke@435 70 bool unallocate_object(oop obj);
duke@435 71
duke@435 72 // Returns a subregion containing all objects in this space.
duke@435 73 MemRegion used_region() { return MemRegion(bottom(), top()); }
duke@435 74
duke@435 75 // Boolean querries.
duke@435 76 bool is_empty() const { return used() == 0; }
duke@435 77 bool not_empty() const { return used() > 0; }
duke@435 78 bool contains(const void* p) const { return _bottom <= p && p < _end; }
duke@435 79
duke@435 80 // Size computations. Sizes are in bytes.
duke@435 81 size_t capacity() const { return byte_size(bottom(), end()); }
duke@435 82 size_t used() const { return byte_size(bottom(), top()); }
duke@435 83 size_t free() const { return byte_size(top(), end()); }
duke@435 84 };
duke@435 85
duke@435 86 class PSYoungPromotionLAB : public PSPromotionLAB {
duke@435 87 public:
duke@435 88 PSYoungPromotionLAB() { }
duke@435 89
duke@435 90 // Not MT safe
duke@435 91 HeapWord* allocate(size_t size) {
duke@435 92 // Can't assert this, when young fills, we keep the LAB around, but flushed.
duke@435 93 // assert(_state != flushed, "Sanity");
duke@435 94 HeapWord* obj = top();
duke@435 95 HeapWord* new_top = obj + size;
duke@435 96 // The 'new_top>obj' check is needed to detect overflow of obj+size.
duke@435 97 if (new_top > obj && new_top <= end()) {
duke@435 98 set_top(new_top);
duke@435 99 assert(is_object_aligned((intptr_t)obj) && is_object_aligned((intptr_t)new_top),
duke@435 100 "checking alignment");
duke@435 101 return obj;
duke@435 102 }
duke@435 103
duke@435 104 return NULL;
duke@435 105 }
duke@435 106
duke@435 107 debug_only(virtual bool lab_is_valid(MemRegion lab));
duke@435 108 };
duke@435 109
duke@435 110 class PSOldPromotionLAB : public PSPromotionLAB {
duke@435 111 private:
duke@435 112 ObjectStartArray* _start_array;
duke@435 113
duke@435 114 public:
duke@435 115 PSOldPromotionLAB() : _start_array(NULL) { }
duke@435 116 PSOldPromotionLAB(ObjectStartArray* start_array) : _start_array(start_array) { }
duke@435 117
duke@435 118 void set_start_array(ObjectStartArray* start_array) { _start_array = start_array; }
duke@435 119
duke@435 120 void flush();
duke@435 121
duke@435 122 // Not MT safe
duke@435 123 HeapWord* allocate(size_t size) {
duke@435 124 // Cannot test for this now that we're doing promotion failures
duke@435 125 // assert(_state != flushed, "Sanity");
duke@435 126 assert(_start_array != NULL, "Sanity");
duke@435 127 HeapWord* obj = top();
duke@435 128 HeapWord* new_top = obj + size;
duke@435 129 // The 'new_top>obj' check is needed to detect overflow of obj+size.
duke@435 130 if (new_top > obj && new_top <= end()) {
duke@435 131 set_top(new_top);
duke@435 132 assert(is_object_aligned((intptr_t)obj) && is_object_aligned((intptr_t)new_top),
duke@435 133 "checking alignment");
duke@435 134 _start_array->allocate_block(obj);
duke@435 135 return obj;
duke@435 136 }
duke@435 137
duke@435 138 return NULL;
duke@435 139 }
duke@435 140
duke@435 141 debug_only(virtual bool lab_is_valid(MemRegion lab));
duke@435 142 };

mercurial