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

Fri, 27 Feb 2009 13:27:09 -0800

author
twisti
date
Fri, 27 Feb 2009 13:27:09 -0800
changeset 1040
98cb887364d3
parent 435
a61af66fc99e
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6810672: Comment typos
Summary: I have collected some typos I have found while looking at the code.
Reviewed-by: kvn, never

duke@435 1 /*
duke@435 2 * Copyright 2001-2005 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 // This class can be used to locate the beginning of an object in the
duke@435 27 // covered region.
duke@435 28 //
duke@435 29
duke@435 30 class ObjectStartArray : public CHeapObj {
duke@435 31 friend class VerifyObjectStartArrayClosure;
duke@435 32
duke@435 33 private:
duke@435 34 PSVirtualSpace _virtual_space;
duke@435 35 MemRegion _reserved_region;
duke@435 36 MemRegion _covered_region;
duke@435 37 MemRegion _blocks_region;
duke@435 38 jbyte* _raw_base;
duke@435 39 jbyte* _offset_base;
duke@435 40
duke@435 41 public:
duke@435 42
duke@435 43 enum BlockValueConstants {
duke@435 44 clean_block = -1
duke@435 45 };
duke@435 46
duke@435 47 enum BlockSizeConstants {
duke@435 48 block_shift = 9,
duke@435 49 block_size = 1 << block_shift,
duke@435 50 block_size_in_words = block_size / sizeof(HeapWord)
duke@435 51 };
duke@435 52
duke@435 53 protected:
duke@435 54
duke@435 55 // Mapping from address to object start array entry
duke@435 56 jbyte* block_for_addr(void* p) const {
duke@435 57 assert(_covered_region.contains(p),
duke@435 58 "out of bounds access to object start array");
duke@435 59 jbyte* result = &_offset_base[uintptr_t(p) >> block_shift];
duke@435 60 assert(_blocks_region.contains(result),
duke@435 61 "out of bounds result in byte_for");
duke@435 62 return result;
duke@435 63 }
duke@435 64
duke@435 65 // Mapping from object start array entry to address of first word
duke@435 66 HeapWord* addr_for_block(jbyte* p) {
duke@435 67 assert(_blocks_region.contains(p),
duke@435 68 "out of bounds access to object start array");
duke@435 69 size_t delta = pointer_delta(p, _offset_base, sizeof(jbyte));
duke@435 70 HeapWord* result = (HeapWord*) (delta << block_shift);
duke@435 71 assert(_covered_region.contains(result),
duke@435 72 "out of bounds accessor from card marking array");
duke@435 73 return result;
duke@435 74 }
duke@435 75
duke@435 76 // Mapping that includes the derived offset.
duke@435 77 // If the block is clean, returns the last address in the covered region.
duke@435 78 // If the block is < index 0, returns the start of the covered region.
duke@435 79 HeapWord* offset_addr_for_block (jbyte* p) const {
duke@435 80 // We have to do this before the assert
duke@435 81 if (p < _raw_base) {
duke@435 82 return _covered_region.start();
duke@435 83 }
duke@435 84
duke@435 85 assert(_blocks_region.contains(p),
duke@435 86 "out of bounds access to object start array");
duke@435 87
duke@435 88 if (*p == clean_block) {
duke@435 89 return _covered_region.end();
duke@435 90 }
duke@435 91
duke@435 92 size_t delta = pointer_delta(p, _offset_base, sizeof(jbyte));
duke@435 93 HeapWord* result = (HeapWord*) (delta << block_shift);
duke@435 94 result += *p;
duke@435 95
duke@435 96 assert(_covered_region.contains(result),
duke@435 97 "out of bounds accessor from card marking array");
duke@435 98
duke@435 99 return result;
duke@435 100 }
duke@435 101
duke@435 102 public:
duke@435 103
duke@435 104 // This method is in lieu of a constructor, so that this class can be
duke@435 105 // embedded inline in other classes.
duke@435 106 void initialize(MemRegion reserved_region);
duke@435 107
duke@435 108 void set_covered_region(MemRegion mr);
duke@435 109
duke@435 110 void reset();
duke@435 111
duke@435 112 MemRegion covered_region() { return _covered_region; }
duke@435 113
duke@435 114 void allocate_block(HeapWord* p) {
duke@435 115 assert(_covered_region.contains(p), "Must be in covered region");
duke@435 116 jbyte* block = block_for_addr(p);
duke@435 117 HeapWord* block_base = addr_for_block(block);
duke@435 118 size_t offset = pointer_delta(p, block_base, sizeof(HeapWord*));
duke@435 119 assert(offset < 128, "Sanity");
duke@435 120 // When doing MT offsets, we can't assert this.
duke@435 121 //assert(offset > *block, "Found backwards allocation");
duke@435 122 *block = (jbyte)offset;
duke@435 123
duke@435 124 // tty->print_cr("[%p]", p);
duke@435 125 }
duke@435 126
duke@435 127 // Optimized for finding the first object that crosses into
duke@435 128 // a given block. The blocks contain the offset of the last
duke@435 129 // object in that block. Scroll backwards by one, and the first
twisti@1040 130 // object hit should be at the beginning of the block
duke@435 131 HeapWord* object_start(HeapWord* addr) const {
duke@435 132 assert(_covered_region.contains(addr), "Must be in covered region");
duke@435 133 jbyte* block = block_for_addr(addr);
duke@435 134 HeapWord* scroll_forward = offset_addr_for_block(block--);
duke@435 135 while (scroll_forward > addr) {
duke@435 136 scroll_forward = offset_addr_for_block(block--);
duke@435 137 }
duke@435 138
duke@435 139 HeapWord* next = scroll_forward;
duke@435 140 while (next <= addr) {
duke@435 141 scroll_forward = next;
duke@435 142 next += oop(next)->size();
duke@435 143 }
duke@435 144 assert(scroll_forward <= addr, "wrong order for current and arg");
duke@435 145 assert(addr <= next, "wrong order for arg and next");
duke@435 146 return scroll_forward;
duke@435 147 }
duke@435 148
duke@435 149 bool is_block_allocated(HeapWord* addr) {
duke@435 150 assert(_covered_region.contains(addr), "Must be in covered region");
duke@435 151 jbyte* block = block_for_addr(addr);
duke@435 152 if (*block == clean_block)
duke@435 153 return false;
duke@435 154
duke@435 155 return true;
duke@435 156 }
duke@435 157
duke@435 158 // Return true if an object starts in the range of heap addresses.
duke@435 159 // If an object starts at an address corresponding to
duke@435 160 // "start", the method will return true.
duke@435 161 bool object_starts_in_range(HeapWord* start_addr, HeapWord* end_addr) const;
duke@435 162 };

mercurial