< 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,7 +1,7 @@
 /*
- * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -193,12 +193,12 @@
   // In either case, each scanned reference must be scanned precisely
   // once so as to avoid cloning of a young referent. For efficiency,
   // our closures depend on this property and do not protect against
   // double scans.
 
-  uintptr_t cur_chunk_index = addr_to_chunk_index(chunk_mr.start());
-  cur_chunk_index           = cur_chunk_index - lowest_non_clean_base_chunk_index;
+  uintptr_t start_chunk_index = addr_to_chunk_index(chunk_mr.start());
+  uintptr_t cur_chunk_index   = start_chunk_index - lowest_non_clean_base_chunk_index;
 
   NOISY(tty->print_cr("===========================================================================");)
   NOISY(tty->print_cr(" process_chunk_boundary: Called with [" PTR_FORMAT "," PTR_FORMAT ")",
                       chunk_mr.start(), chunk_mr.end());)
 

@@ -240,11 +240,12 @@
       }
     }
     if (first_dirty_card != NULL) {
       NOISY(tty->print_cr(" LNC: Found a dirty card at " PTR_FORMAT " in current chunk",
                     first_dirty_card);)
-      assert(0 <= cur_chunk_index && cur_chunk_index < lowest_non_clean_chunk_size,
+      assert(start_chunk_index >= lowest_non_clean_base_chunk_index && // Check underflow.
+             cur_chunk_index   <  lowest_non_clean_chunk_size,
              "Bounds error.");
       assert(lowest_non_clean[cur_chunk_index] == NULL,
              "Write exactly once : value should be stable hereafter for this round");
       lowest_non_clean[cur_chunk_index] = first_dirty_card;
     } NOISY(else {
< prev index next >