8133805: Remove the bot_updates parameter from G1Allocator's allocation methods
authorlkorinth
Wed, 06 Dec 2017 11:11:16 +0100
changeset 48402 945332d45710
parent 48401 be065f758154
child 48403 6d4e1efac80a
8133805: Remove the bot_updates parameter from G1Allocator's allocation methods Reviewed-by: tschatzl, sjohanss
src/hotspot/share/gc/g1/g1AllocRegion.cpp
src/hotspot/share/gc/g1/g1AllocRegion.hpp
src/hotspot/share/gc/g1/g1AllocRegion.inline.hpp
src/hotspot/share/gc/g1/g1Allocator.cpp
src/hotspot/share/gc/g1/g1Allocator.inline.hpp
--- a/src/hotspot/share/gc/g1/g1AllocRegion.cpp	Thu Dec 14 12:49:47 2017 +0530
+++ b/src/hotspot/share/gc/g1/g1AllocRegion.cpp	Wed Dec 06 11:11:16 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -42,17 +42,17 @@
 
   // Make sure that any allocation attempt on this region will fail
   // and will not trigger any asserts.
-  assert(allocate(dummy_region, 1, false) == NULL, "should fail");
-  assert(par_allocate(dummy_region, 1, false) == NULL, "should fail");
-  assert(allocate(dummy_region, 1, true) == NULL, "should fail");
-  assert(par_allocate(dummy_region, 1, true) == NULL, "should fail");
+  assert(dummy_region->allocate_no_bot_updates(1) == NULL, "should fail");
+  assert(dummy_region->allocate(1) == NULL, "should fail");
+  DEBUG_ONLY(size_t assert_tmp);
+  assert(dummy_region->par_allocate_no_bot_updates(1, 1, &assert_tmp) == NULL, "should fail");
+  assert(dummy_region->par_allocate(1, 1, &assert_tmp) == NULL, "should fail");
 
   _g1h = g1h;
   _dummy_region = dummy_region;
 }
 
-size_t G1AllocRegion::fill_up_remaining_space(HeapRegion* alloc_region,
-                                              bool bot_updates) {
+size_t G1AllocRegion::fill_up_remaining_space(HeapRegion* alloc_region) {
   assert(alloc_region != NULL && alloc_region != _dummy_region,
          "pre-condition");
   size_t result = 0;
@@ -74,7 +74,7 @@
   size_t min_word_size_to_fill = CollectedHeap::min_fill_size();
 
   while (free_word_size >= min_word_size_to_fill) {
-    HeapWord* dummy = par_allocate(alloc_region, free_word_size, bot_updates);
+    HeapWord* dummy = par_allocate(alloc_region, free_word_size);
     if (dummy != NULL) {
       // If the allocation was successful we should fill in the space.
       CollectedHeap::fill_with_object(dummy, free_word_size);
@@ -110,7 +110,7 @@
                            "the alloc region should never be empty");
 
     if (fill_up) {
-      result = fill_up_remaining_space(alloc_region, _bot_updates);
+      result = fill_up_remaining_space(alloc_region);
     }
 
     assert_alloc_region(alloc_region->used() >= _used_bytes_before, "invariant");
@@ -135,7 +135,7 @@
     new_alloc_region->reset_pre_dummy_top();
     // Need to do this before the allocation
     _used_bytes_before = new_alloc_region->used();
-    HeapWord* result = allocate(new_alloc_region, word_size, _bot_updates);
+    HeapWord* result = allocate(new_alloc_region, word_size);
     assert_alloc_region(result != NULL, "the allocation should succeeded");
 
     OrderAccess::storestore();
@@ -301,7 +301,7 @@
       // possible object. In this case this region will not be retained, so the
       // original problem cannot occur.
       if (to_allocate_words >= G1CollectedHeap::min_fill_size()) {
-        HeapWord* dummy = attempt_allocation(to_allocate_words, true /* bot_updates */);
+        HeapWord* dummy = attempt_allocation(to_allocate_words);
         CollectedHeap::fill_with_object(dummy, to_allocate_words);
       }
     }
--- a/src/hotspot/share/gc/g1/g1AllocRegion.hpp	Thu Dec 14 12:49:47 2017 +0530
+++ b/src/hotspot/share/gc/g1/g1AllocRegion.hpp	Wed Dec 06 11:11:16 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -83,37 +83,27 @@
   // whether the _alloc_region is NULL or not.
   static HeapRegion* _dummy_region;
 
-  // Some of the methods below take a bot_updates parameter. Its value
-  // should be the same as the _bot_updates field. The idea is that
-  // the parameter will be a constant for a particular alloc region
-  // and, given that these methods will be hopefully inlined, the
-  // compiler should compile out the test.
-
   // Perform a non-MT-safe allocation out of the given region.
-  static inline HeapWord* allocate(HeapRegion* alloc_region,
-                                   size_t word_size,
-                                   bool bot_updates);
+  inline HeapWord* allocate(HeapRegion* alloc_region,
+                            size_t word_size);
 
   // Perform a MT-safe allocation out of the given region.
-  static inline HeapWord* par_allocate(HeapRegion* alloc_region,
-                                       size_t word_size,
-                                       bool bot_updates);
+  inline HeapWord* par_allocate(HeapRegion* alloc_region,
+                                size_t word_size);
   // Perform a MT-safe allocation out of the given region, with the given
   // minimum and desired size. Returns the actual size allocated (between
   // minimum and desired size) in actual_word_size if the allocation has been
   // successful.
-  static inline HeapWord* par_allocate(HeapRegion* alloc_region,
-                                       size_t min_word_size,
-                                       size_t desired_word_size,
-                                       size_t* actual_word_size,
-                                       bool bot_updates);
+  inline HeapWord* par_allocate(HeapRegion* alloc_region,
+                                size_t min_word_size,
+                                size_t desired_word_size,
+                                size_t* actual_word_size);
 
   // Ensure that the region passed as a parameter has been filled up
   // so that noone else can allocate out of it any more.
   // Returns the number of bytes that have been wasted by filled up
   // the space.
-  static size_t fill_up_remaining_space(HeapRegion* alloc_region,
-                                        bool bot_updates);
+  size_t fill_up_remaining_space(HeapRegion* alloc_region);
 
   // After a region is allocated by alloc_new_region, this
   // method is used to set it as the active alloc_region
@@ -160,8 +150,7 @@
   // First-level allocation: Should be called without holding a
   // lock. It will try to allocate lock-free out of the active region,
   // or return NULL if it was unable to.
-  inline HeapWord* attempt_allocation(size_t word_size,
-                                      bool bot_updates);
+  inline HeapWord* attempt_allocation(size_t word_size);
   // Perform an allocation out of the current allocation region, with the given
   // minimum and desired size. Returns the actual size allocated (between
   // minimum and desired size) in actual_word_size if the allocation has been
@@ -170,8 +159,7 @@
   // out of the active region, or return NULL if it was unable to.
   inline HeapWord* attempt_allocation(size_t min_word_size,
                                       size_t desired_word_size,
-                                      size_t* actual_word_size,
-                                      bool bot_updates);
+                                      size_t* actual_word_size);
 
   // Second-level allocation: Should be called while holding a
   // lock. It will try to first allocate lock-free out of the active
@@ -179,23 +167,20 @@
   // alloc region with a new one. We require that the caller takes the
   // appropriate lock before calling this so that it is easier to make
   // it conform to its locking protocol.
-  inline HeapWord* attempt_allocation_locked(size_t word_size,
-                                             bool bot_updates);
+  inline HeapWord* attempt_allocation_locked(size_t word_size);
   // Same as attempt_allocation_locked(size_t, bool), but allowing specification
   // of minimum word size of the block in min_word_size, and the maximum word
   // size of the allocation in desired_word_size. The actual size of the block is
   // returned in actual_word_size.
   inline HeapWord* attempt_allocation_locked(size_t min_word_size,
                                              size_t desired_word_size,
-                                             size_t* actual_word_size,
-                                             bool bot_updates);
+                                             size_t* actual_word_size);
 
   // Should be called to allocate a new region even if the max of this
   // type of regions has been reached. Should only be called if other
   // allocation attempts have failed and we are not holding a valid
   // active region.
-  inline HeapWord* attempt_allocation_force(size_t word_size,
-                                            bool bot_updates);
+  inline HeapWord* attempt_allocation_force(size_t word_size);
 
   // Should be called before we start using this object.
   void init();
@@ -236,7 +221,7 @@
   virtual void retire_region(HeapRegion* alloc_region, size_t allocated_bytes);
 
   virtual size_t retire(bool fill_up);
-public:
+
   G1GCAllocRegion(const char* name, bool bot_updates, G1EvacStats* stats, InCSetState::in_cset_state_t purpose)
   : G1AllocRegion(name, bot_updates), _stats(stats), _purpose(purpose) {
     assert(stats != NULL, "Must pass non-NULL PLAB statistics");
--- a/src/hotspot/share/gc/g1/g1AllocRegion.inline.hpp	Thu Dec 14 12:49:47 2017 +0530
+++ b/src/hotspot/share/gc/g1/g1AllocRegion.inline.hpp	Wed Dec 06 11:11:16 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -37,52 +37,47 @@
 
 
 inline HeapWord* G1AllocRegion::allocate(HeapRegion* alloc_region,
-                                         size_t word_size,
-                                         bool bot_updates) {
+                                         size_t word_size) {
   assert(alloc_region != NULL, "pre-condition");
 
-  if (!bot_updates) {
+  if (!_bot_updates) {
     return alloc_region->allocate_no_bot_updates(word_size);
   } else {
     return alloc_region->allocate(word_size);
   }
 }
 
-inline HeapWord* G1AllocRegion::par_allocate(HeapRegion* alloc_region, size_t word_size, bool bot_updates) {
+inline HeapWord* G1AllocRegion::par_allocate(HeapRegion* alloc_region, size_t word_size) {
   size_t temp;
-  return par_allocate(alloc_region, word_size, word_size, &temp, bot_updates);
+  return par_allocate(alloc_region, word_size, word_size, &temp);
 }
 
 inline HeapWord* G1AllocRegion::par_allocate(HeapRegion* alloc_region,
                                              size_t min_word_size,
                                              size_t desired_word_size,
-                                             size_t* actual_word_size,
-                                             bool bot_updates) {
+                                             size_t* actual_word_size) {
   assert(alloc_region != NULL, "pre-condition");
   assert(!alloc_region->is_empty(), "pre-condition");
 
-  if (!bot_updates) {
+  if (!_bot_updates) {
     return alloc_region->par_allocate_no_bot_updates(min_word_size, desired_word_size, actual_word_size);
   } else {
     return alloc_region->par_allocate(min_word_size, desired_word_size, actual_word_size);
   }
 }
 
-inline HeapWord* G1AllocRegion::attempt_allocation(size_t word_size, bool bot_updates) {
+inline HeapWord* G1AllocRegion::attempt_allocation(size_t word_size) {
   size_t temp;
-  return attempt_allocation(word_size, word_size, &temp, bot_updates);
+  return attempt_allocation(word_size, word_size, &temp);
 }
 
 inline HeapWord* G1AllocRegion::attempt_allocation(size_t min_word_size,
                                                    size_t desired_word_size,
-                                                   size_t* actual_word_size,
-                                                   bool bot_updates) {
-  assert_alloc_region(bot_updates == _bot_updates, "pre-condition");
-
+                                                   size_t* actual_word_size) {
   HeapRegion* alloc_region = _alloc_region;
   assert_alloc_region(alloc_region != NULL, "not initialized properly");
 
-  HeapWord* result = par_allocate(alloc_region, min_word_size, desired_word_size, actual_word_size, bot_updates);
+  HeapWord* result = par_allocate(alloc_region, min_word_size, desired_word_size, actual_word_size);
   if (result != NULL) {
     trace("alloc", min_word_size, desired_word_size, *actual_word_size, result);
     return result;
@@ -91,19 +86,18 @@
   return NULL;
 }
 
-inline HeapWord* G1AllocRegion::attempt_allocation_locked(size_t word_size, bool bot_updates) {
+inline HeapWord* G1AllocRegion::attempt_allocation_locked(size_t word_size) {
   size_t temp;
-  return attempt_allocation_locked(word_size, word_size, &temp, bot_updates);
+  return attempt_allocation_locked(word_size, word_size, &temp);
 }
 
 inline HeapWord* G1AllocRegion::attempt_allocation_locked(size_t min_word_size,
                                                           size_t desired_word_size,
-                                                          size_t* actual_word_size,
-                                                          bool bot_updates) {
+                                                          size_t* actual_word_size) {
   // First we have to redo the allocation, assuming we're holding the
   // appropriate lock, in case another thread changed the region while
   // we were waiting to get the lock.
-  HeapWord* result = attempt_allocation(min_word_size, desired_word_size, actual_word_size, bot_updates);
+  HeapWord* result = attempt_allocation(min_word_size, desired_word_size, actual_word_size);
   if (result != NULL) {
     return result;
   }
@@ -119,9 +113,7 @@
   return NULL;
 }
 
-inline HeapWord* G1AllocRegion::attempt_allocation_force(size_t word_size,
-                                                         bool bot_updates) {
-  assert_alloc_region(bot_updates == _bot_updates, "pre-condition");
+inline HeapWord* G1AllocRegion::attempt_allocation_force(size_t word_size) {
   assert_alloc_region(_alloc_region != NULL, "not initialized properly");
 
   trace("forcing alloc", word_size, word_size);
--- a/src/hotspot/share/gc/g1/g1Allocator.cpp	Thu Dec 14 12:49:47 2017 +0530
+++ b/src/hotspot/share/gc/g1/g1Allocator.cpp	Wed Dec 06 11:11:16 2017 +0100
@@ -190,14 +190,12 @@
 
   HeapWord* result = survivor_gc_alloc_region(context)->attempt_allocation(min_word_size,
                                                                            desired_word_size,
-                                                                           actual_word_size,
-                                                                           false /* bot_updates */);
+                                                                           actual_word_size);
   if (result == NULL && !survivor_is_full(context)) {
     MutexLockerEx x(FreeList_lock, Mutex::_no_safepoint_check_flag);
     result = survivor_gc_alloc_region(context)->attempt_allocation_locked(min_word_size,
                                                                           desired_word_size,
-                                                                          actual_word_size,
-                                                                          false /* bot_updates */);
+                                                                          actual_word_size);
     if (result == NULL) {
       set_survivor_full(context);
     }
@@ -217,14 +215,12 @@
 
   HeapWord* result = old_gc_alloc_region(context)->attempt_allocation(min_word_size,
                                                                       desired_word_size,
-                                                                      actual_word_size,
-                                                                      true /* bot_updates */);
+                                                                      actual_word_size);
   if (result == NULL && !old_is_full(context)) {
     MutexLockerEx x(FreeList_lock, Mutex::_no_safepoint_check_flag);
     result = old_gc_alloc_region(context)->attempt_allocation_locked(min_word_size,
                                                                      desired_word_size,
-                                                                     actual_word_size,
-                                                                     true /* bot_updates */);
+                                                                     actual_word_size);
     if (result == NULL) {
       set_old_full(context);
     }
--- a/src/hotspot/share/gc/g1/g1Allocator.inline.hpp	Thu Dec 14 12:49:47 2017 +0530
+++ b/src/hotspot/share/gc/g1/g1Allocator.inline.hpp	Wed Dec 06 11:11:16 2017 +0100
@@ -30,18 +30,18 @@
 #include "gc/shared/plab.inline.hpp"
 
 HeapWord* G1Allocator::attempt_allocation(size_t word_size, AllocationContext_t context) {
-  return mutator_alloc_region(context)->attempt_allocation(word_size, false /* bot_updates */);
+  return mutator_alloc_region(context)->attempt_allocation(word_size);
 }
 
 HeapWord* G1Allocator::attempt_allocation_locked(size_t word_size, AllocationContext_t context) {
-  HeapWord* result = mutator_alloc_region(context)->attempt_allocation_locked(word_size, false /* bot_updates */);
+  HeapWord* result = mutator_alloc_region(context)->attempt_allocation_locked(word_size);
   assert(result != NULL || mutator_alloc_region(context)->get() == NULL,
          "Must not have a mutator alloc region if there is no memory, but is " PTR_FORMAT, p2i(mutator_alloc_region(context)->get()));
   return result;
 }
 
 HeapWord* G1Allocator::attempt_allocation_force(size_t word_size, AllocationContext_t context) {
-  return mutator_alloc_region(context)->attempt_allocation_force(word_size, false /* bot_updates */);
+  return mutator_alloc_region(context)->attempt_allocation_force(word_size);
 }
 
 inline HeapWord* G1PLABAllocator::plab_allocate(InCSetState dest,