Tue, 05 May 2009 22:15:35 -0700
6833576: G1: assert illegal index, growableArray.hpp:186
Summary: The code that calculates the heap region index for an object address incorrectly used signed arithmetic.
Reviewed-by: jcoomes, ysr
ysr@777 | 1 | /* |
ysr@777 | 2 | * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved. |
ysr@777 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ysr@777 | 4 | * |
ysr@777 | 5 | * This code is free software; you can redistribute it and/or modify it |
ysr@777 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ysr@777 | 7 | * published by the Free Software Foundation. |
ysr@777 | 8 | * |
ysr@777 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
ysr@777 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ysr@777 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ysr@777 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
ysr@777 | 13 | * accompanied this code). |
ysr@777 | 14 | * |
ysr@777 | 15 | * You should have received a copy of the GNU General Public License version |
ysr@777 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
ysr@777 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ysr@777 | 18 | * |
ysr@777 | 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
ysr@777 | 20 | * CA 95054 USA or visit www.sun.com if you need additional information or |
ysr@777 | 21 | * have any questions. |
ysr@777 | 22 | * |
ysr@777 | 23 | */ |
ysr@777 | 24 | |
ysr@777 | 25 | #ifndef SERIALGC |
ysr@777 | 26 | |
ysr@777 | 27 | class DirtyCardQueueSet; |
ysr@777 | 28 | |
ysr@777 | 29 | // This barrier is specialized to use a logging barrier to support |
ysr@777 | 30 | // snapshot-at-the-beginning marking. |
ysr@777 | 31 | |
ysr@777 | 32 | class G1SATBCardTableModRefBS: public CardTableModRefBSForCTRS { |
ysr@777 | 33 | private: |
ysr@777 | 34 | // Add "pre_val" to a set of objects that may have been disconnected from the |
ysr@777 | 35 | // pre-marking object graph. |
ysr@777 | 36 | static void enqueue(oop pre_val); |
ysr@777 | 37 | |
ysr@777 | 38 | public: |
ysr@777 | 39 | G1SATBCardTableModRefBS(MemRegion whole_heap, |
ysr@777 | 40 | int max_covered_regions); |
ysr@777 | 41 | |
ysr@777 | 42 | bool is_a(BarrierSet::Name bsn) { |
ysr@777 | 43 | return bsn == BarrierSet::G1SATBCT || CardTableModRefBS::is_a(bsn); |
ysr@777 | 44 | } |
ysr@777 | 45 | |
ysr@777 | 46 | virtual bool has_write_ref_pre_barrier() { return true; } |
ysr@777 | 47 | |
ysr@777 | 48 | // This notes that we don't need to access any BarrierSet data |
ysr@777 | 49 | // structures, so this can be called from a static context. |
ysr@777 | 50 | static void write_ref_field_pre_static(void* field, oop newVal) { |
ysr@777 | 51 | assert(!UseCompressedOops, "Else needs to be templatized"); |
ysr@777 | 52 | oop preVal = *((oop*)field); |
ysr@777 | 53 | if (preVal != NULL) { |
ysr@777 | 54 | enqueue(preVal); |
ysr@777 | 55 | } |
ysr@777 | 56 | } |
ysr@777 | 57 | |
ysr@777 | 58 | // When we know the current java thread: |
ysr@777 | 59 | static void write_ref_field_pre_static(void* field, oop newVal, |
ysr@777 | 60 | JavaThread* jt); |
ysr@777 | 61 | |
ysr@777 | 62 | // We export this to make it available in cases where the static |
ysr@777 | 63 | // type of the barrier set is known. Note that it is non-virtual. |
ysr@777 | 64 | inline void inline_write_ref_field_pre(void* field, oop newVal) { |
ysr@777 | 65 | write_ref_field_pre_static(field, newVal); |
ysr@777 | 66 | } |
ysr@777 | 67 | |
ysr@777 | 68 | // This is the more general virtual version. |
ysr@777 | 69 | void write_ref_field_pre_work(void* field, oop new_val) { |
ysr@777 | 70 | inline_write_ref_field_pre(field, new_val); |
ysr@777 | 71 | } |
ysr@777 | 72 | |
ysr@777 | 73 | virtual void write_ref_array_pre(MemRegion mr); |
ysr@777 | 74 | |
ysr@777 | 75 | }; |
ysr@777 | 76 | |
ysr@777 | 77 | // Adds card-table logging to the post-barrier. |
ysr@777 | 78 | // Usual invariant: all dirty cards are logged in the DirtyCardQueueSet. |
ysr@777 | 79 | class G1SATBCardTableLoggingModRefBS: public G1SATBCardTableModRefBS { |
ysr@777 | 80 | private: |
ysr@777 | 81 | DirtyCardQueueSet& _dcqs; |
ysr@777 | 82 | public: |
ysr@777 | 83 | G1SATBCardTableLoggingModRefBS(MemRegion whole_heap, |
ysr@777 | 84 | int max_covered_regions); |
ysr@777 | 85 | |
ysr@777 | 86 | bool is_a(BarrierSet::Name bsn) { |
ysr@777 | 87 | return bsn == BarrierSet::G1SATBCTLogging || |
ysr@777 | 88 | G1SATBCardTableModRefBS::is_a(bsn); |
ysr@777 | 89 | } |
ysr@777 | 90 | |
ysr@777 | 91 | void write_ref_field_work(void* field, oop new_val); |
ysr@777 | 92 | |
ysr@777 | 93 | // Can be called from static contexts. |
ysr@777 | 94 | static void write_ref_field_static(void* field, oop new_val); |
ysr@777 | 95 | |
ysr@777 | 96 | // NB: if you do a whole-heap invalidation, the "usual invariant" defined |
ysr@777 | 97 | // above no longer applies. |
ysr@777 | 98 | void invalidate(MemRegion mr, bool whole_heap = false); |
ysr@777 | 99 | |
ysr@777 | 100 | void write_region_work(MemRegion mr) { invalidate(mr); } |
ysr@777 | 101 | void write_ref_array_work(MemRegion mr) { invalidate(mr); } |
ysr@777 | 102 | |
ysr@777 | 103 | |
ysr@777 | 104 | }; |
ysr@777 | 105 | |
ysr@777 | 106 | |
ysr@777 | 107 | #endif // SERIALGC |