8073315: Enable gcc -Wtype-limits and fix upcoming issues.
authorgoetz
Mon, 16 Feb 2015 14:07:36 +0100
changeset 29580 a67a581cfe11
parent 29477 82f545c6572b
child 29581 b8d83fef0c8e
8073315: Enable gcc -Wtype-limits and fix upcoming issues. Summary: Relevant fixes in blockOffsetTable.cpp, os_linux.cpp, parCardTableModRefBS.cpp. Reviewed-by: jwilhelm, kbarrett, simonis
hotspot/make/linux/makefiles/gcc.make
hotspot/src/os/linux/vm/os_linux.cpp
hotspot/src/share/vm/asm/codeBuffer.cpp
hotspot/src/share/vm/classfile/systemDictionary.cpp
hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp
hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp
hotspot/src/share/vm/gc_implementation/g1/g1CardCounts.hpp
hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp
hotspot/src/share/vm/gc_implementation/g1/heapRegionManager.cpp
hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp
hotspot/src/share/vm/gc_implementation/g1/heapRegionSet.cpp
hotspot/src/share/vm/gc_implementation/g1/ptrQueue.cpp
hotspot/src/share/vm/gc_implementation/parNew/parCardTableModRefBS.cpp
hotspot/src/share/vm/gc_implementation/shared/gcUtil.hpp
hotspot/src/share/vm/gc_implementation/shared/liveRange.hpp
hotspot/src/share/vm/gc_implementation/shared/mutableSpace.cpp
hotspot/src/share/vm/memory/allocation.cpp
hotspot/src/share/vm/memory/blockOffsetTable.cpp
hotspot/src/share/vm/memory/heap.cpp
hotspot/src/share/vm/memory/referenceProcessor.cpp
hotspot/src/share/vm/opto/chaitin.cpp
hotspot/src/share/vm/opto/graphKit.cpp
hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp
hotspot/src/share/vm/runtime/virtualspace.cpp
hotspot/src/share/vm/utilities/bitMap.cpp
hotspot/src/share/vm/utilities/workgroup.cpp
hotspot/src/share/vm/utilities/yieldingWorkgroup.cpp
--- a/hotspot/make/linux/makefiles/gcc.make	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/make/linux/makefiles/gcc.make	Mon Feb 16 14:07:36 2015 +0100
@@ -214,6 +214,11 @@
   # conversions which might affect the values. Only enable it in earlier versions.
   ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
     WARNING_FLAGS += -Wconversion
+  endif  
+  ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 8 \) \))" "1"
+    # This flag is only known since GCC 4.3. Gcc 4.8 contains a fix so that with templates no
+    # warnings are issued: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=11856
+    WARNING_FLAGS += -Wtype-limits
   endif
 endif
 
--- a/hotspot/src/os/linux/vm/os_linux.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/os/linux/vm/os_linux.cpp	Mon Feb 16 14:07:36 2015 +0100
@@ -3732,14 +3732,14 @@
       // Does this overlap the block we wanted? Give back the overlapped
       // parts and try again.
 
-      size_t top_overlap = requested_addr + (bytes + gap) - base[i];
-      if (top_overlap >= 0 && top_overlap < bytes) {
+      ptrdiff_t top_overlap = requested_addr + (bytes + gap) - base[i];
+      if (top_overlap >= 0 && (size_t)top_overlap < bytes) {
         unmap_memory(base[i], top_overlap);
         base[i] += top_overlap;
         size[i] = bytes - top_overlap;
       } else {
-        size_t bottom_overlap = base[i] + bytes - requested_addr;
-        if (bottom_overlap >= 0 && bottom_overlap < bytes) {
+        ptrdiff_t bottom_overlap = base[i] + bytes - requested_addr;
+        if (bottom_overlap >= 0 && (size_t)bottom_overlap < bytes) {
           unmap_memory(requested_addr, bottom_overlap);
           size[i] = bytes - bottom_overlap;
         } else {
@@ -6003,11 +6003,11 @@
   }
 
   if (strlen(core_pattern) == 0) {
-    return 0;
+    return -1;
   }
 
   char *pid_pos = strstr(core_pattern, "%p");
-  size_t written;
+  int written;
 
   if (core_pattern[0] == '/') {
     written = jio_snprintf(buffer, bufferSize, core_pattern);
@@ -6016,8 +6016,7 @@
 
     const char* p = get_current_directory(cwd, PATH_MAX);
     if (p == NULL) {
-      assert(p != NULL, "failed to get current directory");
-      return 0;
+      return -1;
     }
 
     if (core_pattern[0] == '|') {
@@ -6029,8 +6028,11 @@
     }
   }
 
-  if ((written >= 0) && (written < bufferSize)
-            && (pid_pos == NULL) && (core_pattern[0] != '|')) {
+  if (written < 0) {
+    return -1;
+  }
+
+  if (((size_t)written < bufferSize) && (pid_pos == NULL) && (core_pattern[0] != '|')) {
     int core_uses_pid_file = ::open("/proc/sys/kernel/core_uses_pid", O_RDONLY);
 
     if (core_uses_pid_file != -1) {
@@ -6038,7 +6040,7 @@
       ssize_t ret = ::read(core_uses_pid_file, &core_uses_pid, 1);
       ::close(core_uses_pid_file);
 
-      if (core_uses_pid == '1'){
+      if (core_uses_pid == '1') {
         jio_snprintf(buffer + written, bufferSize - written,
                                           ".%d", current_process_id());
       }
--- a/hotspot/src/share/vm/asm/codeBuffer.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/asm/codeBuffer.cpp	Mon Feb 16 14:07:36 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -926,9 +926,6 @@
 void CodeBuffer::take_over_code_from(CodeBuffer* cb) {
   // Must already have disposed of the old blob somehow.
   assert(blob() == NULL, "must be empty");
-#ifdef ASSERT
-
-#endif
   // Take the new blob away from cb.
   set_blob(cb->blob());
   // Take over all the section pointers.
--- a/hotspot/src/share/vm/classfile/systemDictionary.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp	Mon Feb 16 14:07:36 2015 +0100
@@ -1368,8 +1368,6 @@
   ClassLoaderData* loader_data = k->class_loader_data();
   Handle class_loader_h(THREAD, loader_data->class_loader());
 
-  for (uintx it = 0; it < GCExpandToAllocateDelayMillis; it++){}
-
  // for bootstrap and other parallel classloaders don't acquire lock,
  // use placeholder token
  // If a parallelCapable class loader calls define_instance_class instead of
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Mon Feb 16 14:07:36 2015 +0100
@@ -2170,12 +2170,13 @@
         g1h->secondary_free_list_add(&tmp_free_list);
         SecondaryFreeList_lock->notify_all();
       }
-
+#ifndef PRODUCT
       if (G1StressConcRegionFreeing) {
         for (uintx i = 0; i < G1StressConcRegionFreeingDelayMillis; ++i) {
           os::sleep(Thread::current(), (jlong) 1, false);
         }
       }
+#endif
     }
   }
   assert(tmp_free_list.is_empty(), "post-condition");
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp	Mon Feb 16 14:07:36 2015 +0100
@@ -853,7 +853,7 @@
 
   // Returns the card bitmap for a given task or worker id.
   BitMap* count_card_bitmap_for(uint worker_id) {
-    assert(0 <= worker_id && worker_id < _max_worker_id, "oob");
+    assert(worker_id < _max_worker_id, "oob");
     assert(_count_card_bitmaps != NULL, "uninitialized");
     BitMap* task_card_bm = &_count_card_bitmaps[worker_id];
     assert(task_card_bm->size() == _card_bm.size(), "size mismatch");
@@ -863,7 +863,7 @@
   // Returns the array containing the marked bytes for each region,
   // for the given worker or task id.
   size_t* count_marked_bytes_array_for(uint worker_id) {
-    assert(0 <= worker_id && worker_id < _max_worker_id, "oob");
+    assert(worker_id < _max_worker_id, "oob");
     assert(_count_marked_bytes != NULL, "uninitialized");
     size_t* marked_bytes_array = _count_marked_bytes[worker_id];
     assert(marked_bytes_array != NULL, "uninitialized");
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CardCounts.hpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CardCounts.hpp	Mon Feb 16 14:07:36 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -84,13 +84,13 @@
                    "_ct_bot: " PTR_FORMAT,
                    p2i(card_ptr), p2i(_ct_bot)));
     size_t card_num = pointer_delta(card_ptr, _ct_bot, sizeof(jbyte));
-    assert(card_num >= 0 && card_num < _reserved_max_card_num,
+    assert(card_num < _reserved_max_card_num,
            err_msg("card pointer out of range: " PTR_FORMAT, p2i(card_ptr)));
     return card_num;
   }
 
   jbyte* card_num_2_ptr(size_t card_num) {
-    assert(card_num >= 0 && card_num < _reserved_max_card_num,
+    assert(card_num < _reserved_max_card_num,
            err_msg("card num out of range: "SIZE_FORMAT, card_num));
     return (jbyte*) (_ct_bot + card_num);
   }
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Mon Feb 16 14:07:36 2015 +0100
@@ -5425,7 +5425,7 @@
     // limit is set using max_num_q() - which was set using ParallelGCThreads.
     // So this must be true - but assert just in case someone decides to
     // change the worker ids.
-    assert(0 <= worker_id && worker_id < limit, "sanity");
+    assert(worker_id < limit, "sanity");
     assert(!rp->discovery_is_atomic(), "check this code");
 
     // Select discovered lists [i, i+stride, i+2*stride,...,limit)
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp	Mon Feb 16 14:07:36 2015 +0100
@@ -324,9 +324,8 @@
 void HeapRegion::note_self_forwarding_removal_end(bool during_initial_mark,
                                                   bool during_conc_mark,
                                                   size_t marked_bytes) {
-  assert(0 <= marked_bytes && marked_bytes <= used(),
-         err_msg("marked: "SIZE_FORMAT" used: "SIZE_FORMAT,
-                 marked_bytes, used()));
+  assert(marked_bytes <= used(),
+         err_msg("marked: "SIZE_FORMAT" used: "SIZE_FORMAT, marked_bytes, used()));
   _prev_top_at_mark_start = top();
   _prev_marked_bytes = marked_bytes;
 }
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionManager.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionManager.cpp	Mon Feb 16 14:07:36 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -270,7 +270,7 @@
   const uint n_regions = hrclaimer->n_regions();
   for (uint count = 0; count < n_regions; count++) {
     const uint index = (start_index + count) % n_regions;
-    assert(0 <= index && index < n_regions, "sanity");
+    assert(index < n_regions, "sanity");
     // Skip over unavailable regions
     if (!is_available(index)) {
       continue;
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp	Mon Feb 16 14:07:36 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -541,7 +541,7 @@
 
 PerRegionTable*
 OtherRegionsTable::find_region_table(size_t ind, HeapRegion* hr) const {
-  assert(0 <= ind && ind < _max_fine_entries, "Preconditions.");
+  assert(ind < _max_fine_entries, "Preconditions.");
   PerRegionTable* prt = _fine_grain_regions[ind];
   while (prt != NULL && prt->hr() != hr) {
     prt = prt->collision_list_next();
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSet.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSet.cpp	Mon Feb 16 14:07:36 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -57,7 +57,7 @@
   check_mt_safety();
 
   guarantee(( is_empty() && length() == 0 && total_capacity_bytes() == 0) ||
-            (!is_empty() && length() >= 0 && total_capacity_bytes() >= 0),
+            (!is_empty() && length() > 0  && total_capacity_bytes() > 0) ,
             hrs_ext_msg(this, "invariant"));
 }
 
--- a/hotspot/src/share/vm/gc_implementation/g1/ptrQueue.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/ptrQueue.cpp	Mon Feb 16 14:07:36 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -58,7 +58,7 @@
 
 
 void PtrQueue::enqueue_known_active(void* ptr) {
-  assert(0 <= _index && _index <= _sz, "Invariant.");
+  assert(_index <= _sz, "Invariant.");
   assert(_index == 0 || _buf != NULL, "invariant");
 
   while (_index == 0) {
@@ -68,7 +68,7 @@
   assert(_index > 0, "postcondition");
   _index -= oopSize;
   _buf[byte_index_to_index((int)_index)] = ptr;
-  assert(0 <= _index && _index <= _sz, "Invariant.");
+  assert(_index <= _sz, "Invariant.");
 }
 
 void PtrQueue::locking_enqueue_completed_buffer(void** buf) {
@@ -194,7 +194,6 @@
   _buf = qset()->allocate_buffer();
   _sz = qset()->buffer_size();
   _index = _sz;
-  assert(0 <= _index && _index <= _sz, "Invariant.");
 }
 
 bool PtrQueueSet::process_or_enqueue_complete_buffer(void** buf) {
--- a/hotspot/src/share/vm/gc_implementation/parNew/parCardTableModRefBS.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parNew/parCardTableModRefBS.cpp	Mon Feb 16 14:07:36 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -195,8 +195,9 @@
   // 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());
+  assert(start_chunk_index >= lowest_non_clean_base_chunk_index, "Bounds error.");
+  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 ")",
@@ -242,8 +243,7 @@
     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,
-             "Bounds error.");
+      assert(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;
--- a/hotspot/src/share/vm/gc_implementation/shared/gcUtil.hpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/shared/gcUtil.hpp	Mon Feb 16 14:07:36 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -103,7 +103,7 @@
 
   static inline float exp_avg(float avg, float sample,
                                unsigned int weight) {
-    assert(0 <= weight && weight <= 100, "weight must be a percent");
+    assert(weight <= 100, "weight must be a percent");
     return (100.0F - weight) * avg / 100.0F + weight * sample / 100.0F;
   }
   static inline size_t exp_avg(size_t avg, size_t sample,
--- a/hotspot/src/share/vm/gc_implementation/shared/liveRange.hpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/shared/liveRange.hpp	Mon Feb 16 14:07:36 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -42,7 +42,6 @@
     MemRegion::set_end(e);
   }
   void set_word_size(size_t ws) {
-    assert(ws >= 0, "should be a non-zero range");
     MemRegion::set_word_size(ws);
   }
 
--- a/hotspot/src/share/vm/gc_implementation/shared/mutableSpace.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/shared/mutableSpace.cpp	Mon Feb 16 14:07:36 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -36,8 +36,7 @@
 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
 
 MutableSpace::MutableSpace(size_t alignment): ImmutableSpace(), _top(NULL), _alignment(alignment) {
-  assert(MutableSpace::alignment() >= 0 &&
-         MutableSpace::alignment() % os::vm_page_size() == 0,
+  assert(MutableSpace::alignment() % os::vm_page_size() == 0,
          "Space should be aligned");
   _mangler = new MutableSpaceMangler(this);
 }
--- a/hotspot/src/share/vm/memory/allocation.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/memory/allocation.cpp	Mon Feb 16 14:07:36 2015 +0100
@@ -562,7 +562,6 @@
 
 // Reallocate storage in Arena.
 void *Arena::Arealloc(void* old_ptr, size_t old_size, size_t new_size, AllocFailType alloc_failmode) {
-  assert(new_size >= 0, "bad size");
   if (new_size == 0) return NULL;
 #ifdef ASSERT
   if (UseMallocOnly) {
--- a/hotspot/src/share/vm/memory/blockOffsetTable.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/memory/blockOffsetTable.cpp	Mon Feb 16 14:07:36 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -792,6 +792,5 @@
 }
 
 size_t BlockOffsetArrayContigSpace::last_active_index() const {
-  size_t result = _next_offset_index - 1;
-  return result >= 0 ? result : 0;
+  return _next_offset_index == 0 ? 0 : _next_offset_index - 1;
 }
--- a/hotspot/src/share/vm/memory/heap.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/memory/heap.cpp	Mon Feb 16 14:07:36 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -52,7 +52,7 @@
 
 
 void CodeHeap::mark_segmap_as_free(size_t beg, size_t end) {
-  assert(0   <= beg && beg <  _number_of_committed_segments, "interval begin out of bounds");
+  assert(              beg <  _number_of_committed_segments, "interval begin out of bounds");
   assert(beg <  end && end <= _number_of_committed_segments, "interval end   out of bounds");
   // setup _segmap pointers for faster indexing
   address p = (address)_segmap.low() + beg;
@@ -63,7 +63,7 @@
 
 
 void CodeHeap::mark_segmap_as_used(size_t beg, size_t end) {
-  assert(0   <= beg && beg <  _number_of_committed_segments, "interval begin out of bounds");
+  assert(              beg <  _number_of_committed_segments, "interval begin out of bounds");
   assert(beg <  end && end <= _number_of_committed_segments, "interval end   out of bounds");
   // setup _segmap pointers for faster indexing
   address p = (address)_segmap.low() + beg;
--- a/hotspot/src/share/vm/memory/referenceProcessor.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/memory/referenceProcessor.cpp	Mon Feb 16 14:07:36 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -987,7 +987,7 @@
       id = next_id();
     }
   }
-  assert(0 <= id && id < _max_num_q, "Id is out-of-bounds (call Freud?)");
+  assert(id < _max_num_q, "Id is out-of-bounds (call Freud?)");
 
   // Get the discovered queue to which we will add
   DiscoveredList* list = NULL;
@@ -1345,7 +1345,7 @@
 }
 
 const char* ReferenceProcessor::list_name(uint i) {
-   assert(i >= 0 && i <= _max_num_q * number_of_subclasses_of_ref(),
+   assert(i <= _max_num_q * number_of_subclasses_of_ref(),
           "Out of bounds index");
 
    int j = i / _max_num_q;
--- a/hotspot/src/share/vm/opto/chaitin.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/opto/chaitin.cpp	Mon Feb 16 14:07:36 2015 +0100
@@ -602,7 +602,7 @@
 
   // This frame must preserve the required fp alignment
   _framesize = round_to(_framesize, Matcher::stack_alignment_in_slots());
-  assert( _framesize >= 0 && _framesize <= 1000000, "sanity check" );
+  assert(_framesize <= 1000000, "sanity check");
 #ifndef PRODUCT
   _total_framesize += _framesize;
   if ((int)_framesize > _max_framesize) {
--- a/hotspot/src/share/vm/opto/graphKit.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/opto/graphKit.cpp	Mon Feb 16 14:07:36 2015 +0100
@@ -3027,12 +3027,7 @@
     // We may not have profiling here or it may not help us. If we have
     // a speculative type use it to perform an exact cast.
     ciKlass* spec_obj_type = obj_type->speculative_type();
-    if (spec_obj_type != NULL ||
-        (data != NULL &&
-         // Counter has never been decremented (due to cast failure).
-         // ...This is a reasonable thing to expect.  It is true of
-         // all casts inserted by javac to implement generic types.
-         data->as_CounterData()->count() >= 0)) {
+    if (spec_obj_type != NULL || data != NULL) {
       cast_obj = maybe_cast_profiled_receiver(not_null_obj, tk->klass(), spec_obj_type, safe_for_replace);
       if (cast_obj != NULL) {
         if (failure_control != NULL) // failure is now impossible
--- a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp	Mon Feb 16 14:07:36 2015 +0100
@@ -2902,18 +2902,13 @@
     // }
 
     assert(stackmap_p + 1 <= stackmap_end, "no room for frame_type");
-    // The Linux compiler does not like frame_type to be u1 or u2. It
-    // issues the following warning for the first if-statement below:
-    //
-    // "warning: comparison is always true due to limited range of data type"
-    //
-    u4 frame_type = *stackmap_p;
+    u1 frame_type = *stackmap_p;
     stackmap_p++;
 
     // same_frame {
     //   u1 frame_type = SAME; /* 0-63 */
     // }
-    if (frame_type >= 0 && frame_type <= 63) {
+    if (frame_type <= 63) {
       // nothing more to do for same_frame
     }
 
--- a/hotspot/src/share/vm/runtime/virtualspace.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/runtime/virtualspace.cpp	Mon Feb 16 14:07:36 2015 +0100
@@ -519,12 +519,13 @@
 
       // Calc address range within we try to attach (range of possible start addresses).
       char *const highest_start = (char *)align_ptr_down(zerobased_max - size, attach_point_alignment);
-      // SS10 and SS12u1 cannot compile "(char *)UnscaledOopHeapMax - size" on solaris sparc 32-bit:
-      // "Cannot use int to initialize char*." Introduce aux variable.
-      char *unscaled_end = (char *)UnscaledOopHeapMax;
-      unscaled_end -= size;
-      char *lowest_start = (size < UnscaledOopHeapMax) ?
-        MAX2(unscaled_end, aligned_heap_base_min_address) : aligned_heap_base_min_address;
+      // Need to be careful about size being guaranteed to be less
+      // than UnscaledOopHeapMax due to type constraints.
+      char *lowest_start = aligned_heap_base_min_address;
+      uint64_t unscaled_end = UnscaledOopHeapMax - size;
+      if (unscaled_end < UnscaledOopHeapMax) { // unscaled_end wrapped if size is large
+        lowest_start = MAX2(lowest_start, (char*)unscaled_end);
+      }
       lowest_start  = (char *)align_ptr_up(lowest_start, attach_point_alignment);
       try_reserve_range(highest_start, lowest_start, attach_point_alignment,
                         aligned_heap_base_min_address, zerobased_max, size, alignment, large);
--- a/hotspot/src/share/vm/utilities/bitMap.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/utilities/bitMap.cpp	Mon Feb 16 14:07:36 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -33,7 +33,6 @@
   _map(map), _size(size_in_bits), _map_allocator(false)
 {
   assert(sizeof(bm_word_t) == BytesPerWord, "Implementation assumption.");
-  assert(size_in_bits >= 0, "just checking");
 }
 
 
@@ -45,7 +44,6 @@
 }
 
 void BitMap::resize(idx_t size_in_bits, bool in_resource_area) {
-  assert(size_in_bits >= 0, "just checking");
   idx_t old_size_in_words = size_in_words();
   bm_word_t* old_map = map();
 
--- a/hotspot/src/share/vm/utilities/workgroup.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/utilities/workgroup.cpp	Mon Feb 16 14:07:36 2015 +0100
@@ -124,7 +124,7 @@
   // Array index bounds checking.
   GangWorker* result = NULL;
   assert(gang_workers() != NULL, "No workers for indexing");
-  assert(((i >= 0) && (i < total_workers())), "Worker index out of bounds");
+  assert(i < total_workers(), "Worker index out of bounds");
   result = _gang_workers[i];
   assert(result != NULL, "Indexing to null worker");
   return result;
@@ -463,7 +463,7 @@
 }
 
 bool SubTasksDone::is_task_claimed(uint t) {
-  assert(0 <= t && t < _n_tasks, "bad task id.");
+  assert(t < _n_tasks, "bad task id.");
   uint old = _tasks[t];
   if (old == 0) {
     old = Atomic::cmpxchg(1, &_tasks[t], 0);
--- a/hotspot/src/share/vm/utilities/yieldingWorkgroup.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/utilities/yieldingWorkgroup.cpp	Mon Feb 16 14:07:36 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -120,7 +120,6 @@
   _sequence_number++;
 
   uint requested_size = new_task->requested_size();
-  assert(requested_size >= 0, "Should be non-negative");
   if (requested_size != 0) {
     _active_workers = MIN2(requested_size, total_workers());
   } else {