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 void PSScavenge::save_to_space_top_before_gc() { |
duke@435 | 26 | ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); |
duke@435 | 27 | _to_space_top_before_gc = heap->young_gen()->to_space()->top(); |
duke@435 | 28 | } |
duke@435 | 29 | |
coleenp@548 | 30 | template <class T> inline bool PSScavenge::should_scavenge(T* p) { |
coleenp@548 | 31 | T heap_oop = oopDesc::load_heap_oop(p); |
coleenp@548 | 32 | if (oopDesc::is_null(heap_oop)) return false; |
coleenp@548 | 33 | oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); |
coleenp@548 | 34 | return PSScavenge::is_obj_in_young((HeapWord*)obj); |
duke@435 | 35 | } |
duke@435 | 36 | |
coleenp@548 | 37 | template <class T> |
coleenp@548 | 38 | inline bool PSScavenge::should_scavenge(T* p, MutableSpace* to_space) { |
duke@435 | 39 | if (should_scavenge(p)) { |
coleenp@548 | 40 | oop obj = oopDesc::load_decode_heap_oop_not_null(p); |
duke@435 | 41 | // Skip objects copied to to_space since the scavenge started. |
coleenp@548 | 42 | HeapWord* const addr = (HeapWord*)obj; |
duke@435 | 43 | return addr < to_space_top_before_gc() || addr >= to_space->end(); |
duke@435 | 44 | } |
duke@435 | 45 | return false; |
duke@435 | 46 | } |
duke@435 | 47 | |
coleenp@548 | 48 | template <class T> |
coleenp@548 | 49 | inline bool PSScavenge::should_scavenge(T* p, bool check_to_space) { |
duke@435 | 50 | if (check_to_space) { |
coleenp@548 | 51 | ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); |
duke@435 | 52 | return should_scavenge(p, heap->young_gen()->to_space()); |
duke@435 | 53 | } |
duke@435 | 54 | return should_scavenge(p); |
duke@435 | 55 | } |
duke@435 | 56 | |
duke@435 | 57 | // Attempt to "claim" oop at p via CAS, push the new obj if successful |
duke@435 | 58 | // This version tests the oop* to make sure it is within the heap before |
duke@435 | 59 | // attempting marking. |
coleenp@548 | 60 | template <class T> |
duke@435 | 61 | inline void PSScavenge::copy_and_push_safe_barrier(PSPromotionManager* pm, |
coleenp@548 | 62 | T* p) { |
coleenp@548 | 63 | assert(should_scavenge(p, true), "revisiting object?"); |
duke@435 | 64 | |
coleenp@548 | 65 | oop o = oopDesc::load_decode_heap_oop_not_null(p); |
coleenp@548 | 66 | oop new_obj = o->is_forwarded() |
coleenp@548 | 67 | ? o->forwardee() |
coleenp@548 | 68 | : pm->copy_to_survivor_space(o, pm->depth_first()); |
coleenp@548 | 69 | oopDesc::encode_store_heap_oop_not_null(p, new_obj); |
duke@435 | 70 | |
duke@435 | 71 | // We cannot mark without test, as some code passes us pointers |
duke@435 | 72 | // that are outside the heap. |
coleenp@548 | 73 | if ((!PSScavenge::is_obj_in_young((HeapWord*)p)) && |
duke@435 | 74 | Universe::heap()->is_in_reserved(p)) { |
coleenp@548 | 75 | if (PSScavenge::is_obj_in_young((HeapWord*)new_obj)) { |
coleenp@548 | 76 | card_table()->inline_write_ref_field_gc(p, new_obj); |
duke@435 | 77 | } |
duke@435 | 78 | } |
duke@435 | 79 | } |