1 #ifdef USE_PRAGMA_IDENT_HDR 2 #pragma ident "@(#)cardTableExtension.hpp 1.20 07/05/05 17:05:26 JVM" 3 #endif 4 /* 5 * Copyright 2001-2003 Sun Microsystems, Inc. All Rights Reserved. 6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7 * 8 * This code is free software; you can redistribute it and/or modify it 9 * under the terms of the GNU General Public License version 2 only, as 10 * published by the Free Software Foundation. 11 * 12 * This code is distributed in the hope that it will be useful, but WITHOUT 13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 * version 2 for more details (a copy is included in the LICENSE file that 16 * accompanied this code). 17 * 18 * You should have received a copy of the GNU General Public License version 19 * 2 along with this work; if not, write to the Free Software Foundation, 20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21 * 22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 23 * CA 95054 USA or visit www.sun.com if you need additional information or 24 * have any questions. 25 * 26 */ 27 28 class MutableSpace; 29 class ObjectStartArray; 30 class PSPromotionManager; 31 class GCTaskQueue; 32 33 class CardTableExtension : public CardTableModRefBS { 34 private: 35 // Support methods for resizing the card table. 36 void resize_commit_uncommit(int changed_region, MemRegion new_region); 37 void resize_update_card_table_entries(int changed_region, 38 MemRegion new_region); 39 void resize_update_committed_table(int changed_region, MemRegion new_region); 40 void resize_update_covered_table(int changed_region, MemRegion new_region); 41 42 protected: 43 44 static void verify_all_young_refs_precise_helper(MemRegion mr); 45 46 public: 47 enum ExtendedCardValue { 48 youngergen_card = CardTableModRefBS::CT_MR_BS_last_reserved + 1, 49 verify_card = CardTableModRefBS::CT_MR_BS_last_reserved + 5 50 }; 51 52 CardTableExtension(MemRegion whole_heap, int max_covered_regions) : 53 CardTableModRefBS(whole_heap, max_covered_regions) { } 54 55 // Too risky for the 4/10/02 putback 56 // BarrierSet::Name kind() { return BarrierSet::CardTableExtension; } 57 58 // Scavenge support 59 void scavenge_contents(ObjectStartArray* start_array, 60 MutableSpace* sp, 61 HeapWord* space_top, 62 PSPromotionManager* pm); 63 64 void scavenge_contents_parallel(ObjectStartArray* start_array, 65 MutableSpace* sp, 66 HeapWord* space_top, 67 PSPromotionManager* pm, 68 uint stripe_number); 69 70 // Verification 71 static void verify_all_young_refs_imprecise(); 72 static void verify_all_young_refs_precise(); 73 74 bool addr_is_marked_imprecise(void *addr); 75 bool addr_is_marked_precise(void *addr); 76 77 void set_card_newgen(void* addr) { jbyte* p = byte_for(addr); *p = verify_card; } 78 79 // Testers for entries 80 static bool card_is_dirty(int value) { return value == dirty_card; } 81 static bool card_is_newgen(int value) { return value == youngergen_card; } 82 static bool card_is_clean(int value) { return value == clean_card; } 83 static bool card_is_verify(int value) { return value == verify_card; } 84 85 // Card marking 86 void inline_write_ref_field_gc(oop* field, oop new_val) { 87 jbyte* byte = byte_for(field); 88 *byte = youngergen_card; 89 } 90 91 // Adaptive size policy support 92 // Allows adjustment of the base and size of the covered regions 93 void resize_covered_region(MemRegion new_region); 94 // Finds the covered region to resize based on the start address 95 // of the covered regions. 96 void resize_covered_region_by_start(MemRegion new_region); 97 // Finds the covered region to resize based on the end address 98 // of the covered regions. 99 void resize_covered_region_by_end(int changed_region, MemRegion new_region); 100 // Finds the lowest start address of a covered region that is 101 // previous (i.e., lower index) to the covered region with index "ind". 102 HeapWord* lowest_prev_committed_start(int ind) const; 103 104 #ifdef ASSERT 105 106 bool is_valid_card_address(jbyte* addr) { 107 return (addr >= _byte_map) && (addr < _byte_map + _byte_map_size); 108 } 109 110 #endif // ASSERT 111 }; 112