changeset 46319:a587da3329a5

8165674: G1CMMarkStack::out_of_memory possibly redundant Summary: Remove the redundant G1CMMarkStack::_out_of_memory member. Reviewed-by: kbarrett, tschatzl
author aharlap
date Thu, 09 Mar 2017 10:48:44 +0100
parents 7f0d7841839f
children a38f07dfcf47
files hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp hotspot/src/share/vm/gc/g1/g1ConcurrentMark.hpp
diffstat 2 files changed, 12 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp	Thu Mar 09 01:07:28 2017 +0000
+++ b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp	Thu Mar 09 10:48:44 2017 +0100
@@ -136,7 +136,6 @@
   _max_chunk_capacity(0),
   _base(NULL),
   _chunk_capacity(0),
-  _out_of_memory(false),
   _should_expand(false) {
   set_empty();
 }
@@ -278,11 +277,10 @@
   if (new_chunk == NULL) {
     // Did not get a chunk from the free list. Allocate from backing memory.
     new_chunk = allocate_new_chunk();
-  }
-
-  if (new_chunk == NULL) {
-    _out_of_memory = true;
-    return false;
+
+    if (new_chunk == NULL) {
+      return false;
+    }
   }
 
   Copy::conjoint_memory_atomic(ptr_arr, new_chunk->data, OopsPerChunk * sizeof(oop));
@@ -308,7 +306,6 @@
 void G1CMMarkStack::set_empty() {
   _chunks_in_chunk_list = 0;
   _hwm = 0;
-  clear_out_of_memory();
   _chunk_list = NULL;
   _free_list = NULL;
 }
@@ -592,14 +589,10 @@
 }
 
 
-void G1ConcurrentMark::reset_marking_state(bool clear_overflow) {
+void G1ConcurrentMark::reset_marking_state() {
   _global_mark_stack.set_should_expand(has_overflown());
-  _global_mark_stack.set_empty();        // Also clears the overflow stack's overflow flag
-  if (clear_overflow) {
-    clear_has_overflown();
-  } else {
-    assert(has_overflown(), "pre-condition");
-  }
+  _global_mark_stack.set_empty();
+  clear_has_overflown();
   _finger = _heap_start;
 
   for (uint i = 0; i < _max_worker_id; ++i) {
@@ -883,7 +876,7 @@
       // not clear the overflow flag since we rely on it being true when
       // we exit this method to abort the pause and restart concurrent
       // marking.
-      reset_marking_state(true /* clear_overflow */);
+      reset_marking_state();
 
       log_info(gc, marking)("Concurrent Mark reset for overflow");
     }
@@ -1749,14 +1742,8 @@
     // oop closures will set the has_overflown flag if we overflow the
     // global marking stack.
 
-    assert(_global_mark_stack.is_out_of_memory() || _global_mark_stack.is_empty(),
-            "Mark stack should be empty (unless it is out of memory)");
-
-    if (_global_mark_stack.is_out_of_memory()) {
-      // This should have been done already when we tried to push an
-      // entry on to the global mark stack. But let's do it again.
-      set_has_overflown();
-    }
+    assert(has_overflown() || _global_mark_stack.is_empty(),
+            "Mark stack should be empty (unless it has overflown)");
 
     assert(rp->num_q() == active_workers, "why not");
 
@@ -2931,7 +2918,6 @@
       guarantee(_cm->mark_stack_empty(), "only way to reach here");
       guarantee(_task_queue->size() == 0, "only way to reach here");
       guarantee(!_cm->has_overflown(), "only way to reach here");
-      guarantee(!_cm->mark_stack_overflow(), "only way to reach here");
     } else {
       // Apparently there's more work to do. Let's abort this task. It
       // will restart it and we can hopefully find more things to do.
--- a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.hpp	Thu Mar 09 01:07:28 2017 +0000
+++ b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.hpp	Thu Mar 09 10:48:44 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, 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
@@ -192,8 +192,6 @@
   // NULL if out of memory.
   OopChunk* allocate_new_chunk();
 
-  volatile bool _out_of_memory;
-
   // Atomically add the given chunk to the list.
   void add_chunk_to_list(OopChunk* volatile* list, OopChunk* elem);
   // Atomically remove and return a chunk from the given list. Returns NULL if the
@@ -240,9 +238,6 @@
 
   size_t capacity() const  { return _chunk_capacity; }
 
-  bool is_out_of_memory() const { return _out_of_memory; }
-  void clear_out_of_memory() { _out_of_memory = false; }
-
   bool should_expand() const { return _should_expand; }
   void set_should_expand(bool value) { _should_expand = value; }
 
@@ -432,7 +427,7 @@
 
   // Resets all the marking data structures. Called when we have to restart
   // marking or when marking completes (via set_non_marking_state below).
-  void reset_marking_state(bool clear_overflow = true);
+  void reset_marking_state();
 
   // We do this after we're done with marking so that the marking data
   // structures are initialized to a sensible and predictable state.
@@ -543,7 +538,6 @@
   }
   size_t mark_stack_size()                { return _global_mark_stack.size(); }
   size_t partial_mark_stack_size_target() { return _global_mark_stack.capacity()/3; }
-  bool mark_stack_overflow()              { return _global_mark_stack.is_out_of_memory(); }
   bool mark_stack_empty()                 { return _global_mark_stack.is_empty(); }
 
   G1CMRootRegions* root_regions() { return &_root_regions; }