Tue, 07 Oct 2008 11:01:35 -0700
Merge
duke@435 | 1 | /* |
xdono@631 | 2 | * Copyright 2002-2008 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 | inline PSPromotionManager* PSPromotionManager::manager_array(int index) { |
duke@435 | 26 | assert(_manager_array != NULL, "access of NULL manager_array"); |
duke@435 | 27 | assert(index >= 0 && index <= (int)ParallelGCThreads, "out of range manager_array access"); |
duke@435 | 28 | return _manager_array[index]; |
duke@435 | 29 | } |
duke@435 | 30 | |
coleenp@548 | 31 | template <class T> |
coleenp@548 | 32 | inline void PSPromotionManager::claim_or_forward_internal_depth(T* p) { |
coleenp@548 | 33 | if (p != NULL) { // XXX: error if p != NULL here |
coleenp@548 | 34 | oop o = oopDesc::load_decode_heap_oop_not_null(p); |
duke@435 | 35 | if (o->is_forwarded()) { |
duke@435 | 36 | o = o->forwardee(); |
duke@435 | 37 | // Card mark |
duke@435 | 38 | if (PSScavenge::is_obj_in_young((HeapWord*) o)) { |
duke@435 | 39 | PSScavenge::card_table()->inline_write_ref_field_gc(p, o); |
duke@435 | 40 | } |
coleenp@548 | 41 | oopDesc::encode_store_heap_oop_not_null(p, o); |
duke@435 | 42 | } else { |
duke@435 | 43 | push_depth(p); |
duke@435 | 44 | } |
duke@435 | 45 | } |
duke@435 | 46 | } |
duke@435 | 47 | |
coleenp@548 | 48 | template <class T> |
coleenp@548 | 49 | inline void PSPromotionManager::claim_or_forward_internal_breadth(T* p) { |
coleenp@548 | 50 | if (p != NULL) { // XXX: error if p != NULL here |
coleenp@548 | 51 | oop o = oopDesc::load_decode_heap_oop_not_null(p); |
duke@435 | 52 | if (o->is_forwarded()) { |
duke@435 | 53 | o = o->forwardee(); |
duke@435 | 54 | } else { |
duke@435 | 55 | o = copy_to_survivor_space(o, false); |
duke@435 | 56 | } |
duke@435 | 57 | // Card mark |
duke@435 | 58 | if (PSScavenge::is_obj_in_young((HeapWord*) o)) { |
duke@435 | 59 | PSScavenge::card_table()->inline_write_ref_field_gc(p, o); |
duke@435 | 60 | } |
coleenp@548 | 61 | oopDesc::encode_store_heap_oop_not_null(p, o); |
duke@435 | 62 | } |
duke@435 | 63 | } |
duke@435 | 64 | |
duke@435 | 65 | inline void PSPromotionManager::flush_prefetch_queue() { |
duke@435 | 66 | assert(!depth_first(), "invariant"); |
coleenp@548 | 67 | for (int i = 0; i < _prefetch_queue.length(); i++) { |
coleenp@548 | 68 | claim_or_forward_internal_breadth((oop*)_prefetch_queue.pop()); |
duke@435 | 69 | } |
duke@435 | 70 | } |
duke@435 | 71 | |
coleenp@548 | 72 | template <class T> |
coleenp@548 | 73 | inline void PSPromotionManager::claim_or_forward_depth(T* p) { |
duke@435 | 74 | assert(depth_first(), "invariant"); |
coleenp@548 | 75 | assert(PSScavenge::should_scavenge(p, true), "revisiting object?"); |
coleenp@548 | 76 | assert(Universe::heap()->kind() == CollectedHeap::ParallelScavengeHeap, |
coleenp@548 | 77 | "Sanity"); |
duke@435 | 78 | assert(Universe::heap()->is_in(p), "pointer outside heap"); |
duke@435 | 79 | |
duke@435 | 80 | claim_or_forward_internal_depth(p); |
duke@435 | 81 | } |
duke@435 | 82 | |
coleenp@548 | 83 | template <class T> |
coleenp@548 | 84 | inline void PSPromotionManager::claim_or_forward_breadth(T* p) { |
duke@435 | 85 | assert(!depth_first(), "invariant"); |
coleenp@548 | 86 | assert(PSScavenge::should_scavenge(p, true), "revisiting object?"); |
coleenp@548 | 87 | assert(Universe::heap()->kind() == CollectedHeap::ParallelScavengeHeap, |
coleenp@548 | 88 | "Sanity"); |
duke@435 | 89 | assert(Universe::heap()->is_in(p), "pointer outside heap"); |
duke@435 | 90 | |
duke@435 | 91 | if (UsePrefetchQueue) { |
coleenp@548 | 92 | claim_or_forward_internal_breadth((T*)_prefetch_queue.push_and_pop(p)); |
duke@435 | 93 | } else { |
duke@435 | 94 | // This option is used for testing. The use of the prefetch |
duke@435 | 95 | // queue can delay the processing of the objects and thus |
duke@435 | 96 | // change the order of object scans. For example, remembered |
duke@435 | 97 | // set updates are typically the clearing of the remembered |
duke@435 | 98 | // set (the cards) followed by updates of the remembered set |
duke@435 | 99 | // for young-to-old pointers. In a situation where there |
duke@435 | 100 | // is an error in the sequence of clearing and updating |
duke@435 | 101 | // (e.g. clear card A, update card A, erroneously clear |
duke@435 | 102 | // card A again) the error can be obscured by a delay |
duke@435 | 103 | // in the update due to the use of the prefetch queue |
duke@435 | 104 | // (e.g., clear card A, erroneously clear card A again, |
duke@435 | 105 | // update card A that was pushed into the prefetch queue |
duke@435 | 106 | // and thus delayed until after the erronous clear). The |
duke@435 | 107 | // length of the delay is random depending on the objects |
duke@435 | 108 | // in the queue and the delay can be zero. |
duke@435 | 109 | claim_or_forward_internal_breadth(p); |
duke@435 | 110 | } |
duke@435 | 111 | } |
duke@435 | 112 | |
coleenp@548 | 113 | inline void PSPromotionManager::process_popped_location_depth(StarTask p) { |
duke@435 | 114 | if (is_oop_masked(p)) { |
duke@435 | 115 | assert(PSChunkLargeArrays, "invariant"); |
duke@435 | 116 | oop const old = unmask_chunked_array_oop(p); |
duke@435 | 117 | process_array_chunk(old); |
duke@435 | 118 | } else { |
coleenp@548 | 119 | if (p.is_narrow()) { |
coleenp@548 | 120 | PSScavenge::copy_and_push_safe_barrier(this, (narrowOop*)p); |
coleenp@548 | 121 | } else { |
coleenp@548 | 122 | PSScavenge::copy_and_push_safe_barrier(this, (oop*)p); |
coleenp@548 | 123 | } |
duke@435 | 124 | } |
duke@435 | 125 | } |