< prev index next >

src/share/vm/gc_implementation/parNew/parCardTableModRefBS.cpp

Print this page
rev 7793 : 8073315: Enable gcc -Wtype-limits and fix upcoming issues.
Summary: Relevant fixes in blockOffsetTable.cpp, os_linux.cpp, parCardTableModRefBS.cpp.
   1 /*
   2  * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 178                          DirtyCardToOopClosure* dcto_cl,
 179                          MemRegion chunk_mr,
 180                          MemRegion used,
 181                          jbyte** lowest_non_clean,
 182                          uintptr_t lowest_non_clean_base_chunk_index,
 183                          size_t    lowest_non_clean_chunk_size)
 184 {
 185   // We must worry about non-array objects that cross chunk boundaries,
 186   // because such objects are both precisely and imprecisely marked:
 187   // .. if the head of such an object is dirty, the entire object
 188   //    needs to be scanned, under the interpretation that this
 189   //    was an imprecise mark
 190   // .. if the head of such an object is not dirty, we can assume
 191   //    precise marking and it's efficient to scan just the dirty
 192   //    cards.
 193   // In either case, each scanned reference must be scanned precisely
 194   // once so as to avoid cloning of a young referent. For efficiency,
 195   // our closures depend on this property and do not protect against
 196   // double scans.
 197 
 198   uintptr_t cur_chunk_index = addr_to_chunk_index(chunk_mr.start());
 199   cur_chunk_index           = cur_chunk_index - lowest_non_clean_base_chunk_index;
 200 
 201   NOISY(tty->print_cr("===========================================================================");)
 202   NOISY(tty->print_cr(" process_chunk_boundary: Called with [" PTR_FORMAT "," PTR_FORMAT ")",
 203                       chunk_mr.start(), chunk_mr.end());)
 204 
 205   // First, set "our" lowest_non_clean entry, which would be
 206   // used by the thread scanning an adjoining left chunk with
 207   // a non-array object straddling the mutual boundary.
 208   // Find the object that spans our boundary, if one exists.
 209   // first_block is the block possibly straddling our left boundary.
 210   HeapWord* first_block = sp->block_start(chunk_mr.start());
 211   assert((chunk_mr.start() != used.start()) || (first_block == chunk_mr.start()),
 212          "First chunk should always have a co-initial block");
 213   // Does the block straddle the chunk's left boundary, and is it
 214   // a non-array object?
 215   if (first_block < chunk_mr.start()        // first block straddles left bdry
 216       && sp->block_is_obj(first_block)      // first block is an object
 217       && !(oop(first_block)->is_objArray()  // first block is not an array (arrays are precisely dirtied)
 218            || oop(first_block)->is_typeArray())) {
 219     // Find our least non-clean card, so that a left neighbor


 225         byte_for(first_block + sp->block_size(first_block) - 1);
 226     jbyte* first_card_of_cur_chunk = byte_for(chunk_mr.start());
 227     jbyte* last_card_of_cur_chunk = byte_for(chunk_mr.last());
 228     jbyte* last_card_to_check =
 229       (jbyte*) MIN2((intptr_t) last_card_of_cur_chunk,
 230                     (intptr_t) last_card_of_first_obj);
 231     // Note that this does not need to go beyond our last card
 232     // if our first object completely straddles this chunk.
 233     for (jbyte* cur = first_card_of_cur_chunk;
 234          cur <= last_card_to_check; cur++) {
 235       jbyte val = *cur;
 236       if (card_will_be_scanned(val)) {
 237         first_dirty_card = cur; break;
 238       } else {
 239         assert(!card_may_have_been_dirty(val), "Error");
 240       }
 241     }
 242     if (first_dirty_card != NULL) {
 243       NOISY(tty->print_cr(" LNC: Found a dirty card at " PTR_FORMAT " in current chunk",
 244                     first_dirty_card);)
 245       assert(0 <= cur_chunk_index && cur_chunk_index < lowest_non_clean_chunk_size,

 246              "Bounds error.");
 247       assert(lowest_non_clean[cur_chunk_index] == NULL,
 248              "Write exactly once : value should be stable hereafter for this round");
 249       lowest_non_clean[cur_chunk_index] = first_dirty_card;
 250     } NOISY(else {
 251       tty->print_cr(" LNC: Found no dirty card in current chunk; leaving LNC entry NULL");
 252       // In the future, we could have this thread look for a non-NULL value to copy from its
 253       // right neighbor (up to the end of the first object).
 254       if (last_card_of_cur_chunk < last_card_of_first_obj) {
 255         tty->print_cr(" LNC: BEWARE!!! first obj straddles past right end of chunk:\n"
 256                       "   might be efficient to get value from right neighbor?");
 257       }
 258     })
 259   } else {
 260     // In this case we can help our neighbor by just asking them
 261     // to stop at our first card (even though it may not be dirty).
 262     NOISY(tty->print_cr(" LNC: first block is not a non-array object; setting LNC to first card of current chunk");)
 263     assert(lowest_non_clean[cur_chunk_index] == NULL, "Write once : value should be stable hereafter");
 264     jbyte* first_card_of_cur_chunk = byte_for(chunk_mr.start());
 265     lowest_non_clean[cur_chunk_index] = first_card_of_cur_chunk;


   1 /*
   2  * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 178                          DirtyCardToOopClosure* dcto_cl,
 179                          MemRegion chunk_mr,
 180                          MemRegion used,
 181                          jbyte** lowest_non_clean,
 182                          uintptr_t lowest_non_clean_base_chunk_index,
 183                          size_t    lowest_non_clean_chunk_size)
 184 {
 185   // We must worry about non-array objects that cross chunk boundaries,
 186   // because such objects are both precisely and imprecisely marked:
 187   // .. if the head of such an object is dirty, the entire object
 188   //    needs to be scanned, under the interpretation that this
 189   //    was an imprecise mark
 190   // .. if the head of such an object is not dirty, we can assume
 191   //    precise marking and it's efficient to scan just the dirty
 192   //    cards.
 193   // In either case, each scanned reference must be scanned precisely
 194   // once so as to avoid cloning of a young referent. For efficiency,
 195   // our closures depend on this property and do not protect against
 196   // double scans.
 197 
 198   uintptr_t start_chunk_index = addr_to_chunk_index(chunk_mr.start());
 199   uintptr_t cur_chunk_index   = start_chunk_index - lowest_non_clean_base_chunk_index;
 200 
 201   NOISY(tty->print_cr("===========================================================================");)
 202   NOISY(tty->print_cr(" process_chunk_boundary: Called with [" PTR_FORMAT "," PTR_FORMAT ")",
 203                       chunk_mr.start(), chunk_mr.end());)
 204 
 205   // First, set "our" lowest_non_clean entry, which would be
 206   // used by the thread scanning an adjoining left chunk with
 207   // a non-array object straddling the mutual boundary.
 208   // Find the object that spans our boundary, if one exists.
 209   // first_block is the block possibly straddling our left boundary.
 210   HeapWord* first_block = sp->block_start(chunk_mr.start());
 211   assert((chunk_mr.start() != used.start()) || (first_block == chunk_mr.start()),
 212          "First chunk should always have a co-initial block");
 213   // Does the block straddle the chunk's left boundary, and is it
 214   // a non-array object?
 215   if (first_block < chunk_mr.start()        // first block straddles left bdry
 216       && sp->block_is_obj(first_block)      // first block is an object
 217       && !(oop(first_block)->is_objArray()  // first block is not an array (arrays are precisely dirtied)
 218            || oop(first_block)->is_typeArray())) {
 219     // Find our least non-clean card, so that a left neighbor


 225         byte_for(first_block + sp->block_size(first_block) - 1);
 226     jbyte* first_card_of_cur_chunk = byte_for(chunk_mr.start());
 227     jbyte* last_card_of_cur_chunk = byte_for(chunk_mr.last());
 228     jbyte* last_card_to_check =
 229       (jbyte*) MIN2((intptr_t) last_card_of_cur_chunk,
 230                     (intptr_t) last_card_of_first_obj);
 231     // Note that this does not need to go beyond our last card
 232     // if our first object completely straddles this chunk.
 233     for (jbyte* cur = first_card_of_cur_chunk;
 234          cur <= last_card_to_check; cur++) {
 235       jbyte val = *cur;
 236       if (card_will_be_scanned(val)) {
 237         first_dirty_card = cur; break;
 238       } else {
 239         assert(!card_may_have_been_dirty(val), "Error");
 240       }
 241     }
 242     if (first_dirty_card != NULL) {
 243       NOISY(tty->print_cr(" LNC: Found a dirty card at " PTR_FORMAT " in current chunk",
 244                     first_dirty_card);)
 245       assert(start_chunk_index >= lowest_non_clean_base_chunk_index && // Check underflow.
 246              cur_chunk_index   <  lowest_non_clean_chunk_size,
 247              "Bounds error.");
 248       assert(lowest_non_clean[cur_chunk_index] == NULL,
 249              "Write exactly once : value should be stable hereafter for this round");
 250       lowest_non_clean[cur_chunk_index] = first_dirty_card;
 251     } NOISY(else {
 252       tty->print_cr(" LNC: Found no dirty card in current chunk; leaving LNC entry NULL");
 253       // In the future, we could have this thread look for a non-NULL value to copy from its
 254       // right neighbor (up to the end of the first object).
 255       if (last_card_of_cur_chunk < last_card_of_first_obj) {
 256         tty->print_cr(" LNC: BEWARE!!! first obj straddles past right end of chunk:\n"
 257                       "   might be efficient to get value from right neighbor?");
 258       }
 259     })
 260   } else {
 261     // In this case we can help our neighbor by just asking them
 262     // to stop at our first card (even though it may not be dirty).
 263     NOISY(tty->print_cr(" LNC: first block is not a non-array object; setting LNC to first card of current chunk");)
 264     assert(lowest_non_clean[cur_chunk_index] == NULL, "Write once : value should be stable hereafter");
 265     jbyte* first_card_of_cur_chunk = byte_for(chunk_mr.start());
 266     lowest_non_clean[cur_chunk_index] = first_card_of_cur_chunk;


< prev index next >