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

Tue, 09 Oct 2012 10:09:34 -0700

author
mikael
date
Tue, 09 Oct 2012 10:09:34 -0700
changeset 4153
b9a9ed0f8eeb
parent 3900
d2a62e0f25eb
child 6876
710a3c8b516e
child 7031
ee019285a52c
permissions
-rw-r--r--

7197424: update copyright year to match last edit in jdk8 hotspot repository
Summary: Update copyright year to 2012 for relevant files
Reviewed-by: dholmes, coleenp

duke@435 1 /*
mikael@4153 2 * Copyright (c) 2002, 2012, Oracle and/or its affiliates. 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 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONLAB_HPP
stefank@2314 26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONLAB_HPP
stefank@2314 27
stefank@2314 28 #include "gc_implementation/parallelScavenge/objectStartArray.hpp"
stefank@2314 29 #include "memory/allocation.hpp"
stefank@2314 30
duke@435 31 //
duke@435 32 // PSPromotionLAB is a parallel scavenge promotion lab. This class acts very
duke@435 33 // much like a MutableSpace. We couldn't embed a MutableSpace, though, as
duke@435 34 // it has a considerable number of asserts and invariants that are violated.
duke@435 35 //
duke@435 36
duke@435 37 class ObjectStartArray;
duke@435 38
zgu@3900 39 class PSPromotionLAB : public CHeapObj<mtGC> {
duke@435 40 protected:
coleenp@548 41 static size_t filler_header_size;
duke@435 42
duke@435 43 enum LabState {
duke@435 44 needs_flush,
duke@435 45 flushed,
duke@435 46 zero_size
duke@435 47 };
duke@435 48
duke@435 49 HeapWord* _top;
duke@435 50 HeapWord* _bottom;
duke@435 51 HeapWord* _end;
duke@435 52 LabState _state;
duke@435 53
duke@435 54 void set_top(HeapWord* value) { _top = value; }
duke@435 55 void set_bottom(HeapWord* value) { _bottom = value; }
duke@435 56 void set_end(HeapWord* value) { _end = value; }
duke@435 57
duke@435 58 // The shared initialize code invokes this.
duke@435 59 debug_only(virtual bool lab_is_valid(MemRegion lab) { return false; });
duke@435 60
duke@435 61 PSPromotionLAB() : _top(NULL), _bottom(NULL), _end(NULL) { }
duke@435 62
duke@435 63 public:
duke@435 64 // Filling and flushing.
duke@435 65 void initialize(MemRegion lab);
duke@435 66
duke@435 67 virtual void flush();
duke@435 68
duke@435 69 // Accessors
duke@435 70 HeapWord* bottom() const { return _bottom; }
duke@435 71 HeapWord* end() const { return _end; }
duke@435 72 HeapWord* top() const { return _top; }
duke@435 73
duke@435 74 bool is_flushed() { return _state == flushed; }
duke@435 75
stefank@3181 76 bool unallocate_object(HeapWord* obj, size_t obj_size);
duke@435 77
duke@435 78 // Returns a subregion containing all objects in this space.
duke@435 79 MemRegion used_region() { return MemRegion(bottom(), top()); }
duke@435 80
duke@435 81 // Boolean querries.
duke@435 82 bool is_empty() const { return used() == 0; }
duke@435 83 bool not_empty() const { return used() > 0; }
duke@435 84 bool contains(const void* p) const { return _bottom <= p && p < _end; }
duke@435 85
duke@435 86 // Size computations. Sizes are in bytes.
duke@435 87 size_t capacity() const { return byte_size(bottom(), end()); }
duke@435 88 size_t used() const { return byte_size(bottom(), top()); }
duke@435 89 size_t free() const { return byte_size(top(), end()); }
duke@435 90 };
duke@435 91
duke@435 92 class PSYoungPromotionLAB : public PSPromotionLAB {
duke@435 93 public:
duke@435 94 PSYoungPromotionLAB() { }
duke@435 95
duke@435 96 // Not MT safe
duke@435 97 HeapWord* allocate(size_t size) {
duke@435 98 // Can't assert this, when young fills, we keep the LAB around, but flushed.
duke@435 99 // assert(_state != flushed, "Sanity");
duke@435 100 HeapWord* obj = top();
duke@435 101 HeapWord* new_top = obj + size;
duke@435 102 // The 'new_top>obj' check is needed to detect overflow of obj+size.
duke@435 103 if (new_top > obj && new_top <= end()) {
duke@435 104 set_top(new_top);
duke@435 105 assert(is_object_aligned((intptr_t)obj) && is_object_aligned((intptr_t)new_top),
duke@435 106 "checking alignment");
duke@435 107 return obj;
duke@435 108 }
duke@435 109
duke@435 110 return NULL;
duke@435 111 }
duke@435 112
duke@435 113 debug_only(virtual bool lab_is_valid(MemRegion lab));
duke@435 114 };
duke@435 115
duke@435 116 class PSOldPromotionLAB : public PSPromotionLAB {
duke@435 117 private:
duke@435 118 ObjectStartArray* _start_array;
duke@435 119
duke@435 120 public:
duke@435 121 PSOldPromotionLAB() : _start_array(NULL) { }
duke@435 122 PSOldPromotionLAB(ObjectStartArray* start_array) : _start_array(start_array) { }
duke@435 123
duke@435 124 void set_start_array(ObjectStartArray* start_array) { _start_array = start_array; }
duke@435 125
duke@435 126 void flush();
duke@435 127
duke@435 128 // Not MT safe
duke@435 129 HeapWord* allocate(size_t size) {
duke@435 130 // Cannot test for this now that we're doing promotion failures
duke@435 131 // assert(_state != flushed, "Sanity");
duke@435 132 assert(_start_array != NULL, "Sanity");
duke@435 133 HeapWord* obj = top();
duke@435 134 HeapWord* new_top = obj + size;
duke@435 135 // The 'new_top>obj' check is needed to detect overflow of obj+size.
duke@435 136 if (new_top > obj && new_top <= end()) {
duke@435 137 set_top(new_top);
duke@435 138 assert(is_object_aligned((intptr_t)obj) && is_object_aligned((intptr_t)new_top),
duke@435 139 "checking alignment");
duke@435 140 _start_array->allocate_block(obj);
duke@435 141 return obj;
duke@435 142 }
duke@435 143
duke@435 144 return NULL;
duke@435 145 }
duke@435 146
duke@435 147 debug_only(virtual bool lab_is_valid(MemRegion lab));
duke@435 148 };
stefank@2314 149
stefank@2314 150 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONLAB_HPP

mercurial