changeset 49828:ee3555b4a130

8201647: Make initial clearing of CHeapBitMap optional Reviewed-by: stefank, kbarrett, tschatzl, smonteith
author pliden
date Thu, 19 Apr 2018 07:54:50 +0200
parents a4672513d6e3
children 19b137cb2d42
files src/hotspot/share/utilities/bitMap.cpp src/hotspot/share/utilities/bitMap.hpp
diffstat 2 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/utilities/bitMap.cpp	Thu Apr 19 07:54:50 2018 +0200
+++ b/src/hotspot/share/utilities/bitMap.cpp	Thu Apr 19 07:54:50 2018 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, 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
@@ -72,7 +72,7 @@
 };
 
 template <class Allocator>
-BitMap::bm_word_t* BitMap::reallocate(const Allocator& allocator, bm_word_t* old_map, idx_t old_size_in_bits, idx_t new_size_in_bits) {
+BitMap::bm_word_t* BitMap::reallocate(const Allocator& allocator, bm_word_t* old_map, idx_t old_size_in_bits, idx_t new_size_in_bits, bool clear) {
   size_t old_size_in_words = calc_size_in_words(old_size_in_bits);
   size_t new_size_in_words = calc_size_in_words(new_size_in_bits);
 
@@ -86,7 +86,7 @@
                            MIN2(old_size_in_words, new_size_in_words));
     }
 
-    if (new_size_in_words > old_size_in_words) {
+    if (clear && new_size_in_words > old_size_in_words) {
       clear_range_of_words(map, old_size_in_words, new_size_in_words);
     }
   }
@@ -99,9 +99,9 @@
 }
 
 template <class Allocator>
-bm_word_t* BitMap::allocate(const Allocator& allocator, idx_t size_in_bits) {
+bm_word_t* BitMap::allocate(const Allocator& allocator, idx_t size_in_bits, bool clear) {
   // Reuse reallocate to ensure that the new memory is cleared.
-  return reallocate(allocator, NULL, 0, size_in_bits);
+  return reallocate(allocator, NULL, 0, size_in_bits, clear);
 }
 
 template <class Allocator>
@@ -153,8 +153,8 @@
     : BitMap(allocate(ArenaBitMapAllocator(arena), size_in_bits), size_in_bits) {
 }
 
-CHeapBitMap::CHeapBitMap(idx_t size_in_bits, MEMFLAGS flags)
-    : BitMap(allocate(CHeapBitMapAllocator(flags), size_in_bits), size_in_bits), _flags(flags) {
+CHeapBitMap::CHeapBitMap(idx_t size_in_bits, MEMFLAGS flags, bool clear)
+    : BitMap(allocate(CHeapBitMapAllocator(flags), size_in_bits, clear), size_in_bits), _flags(flags) {
 }
 
 CHeapBitMap::~CHeapBitMap() {
--- a/src/hotspot/share/utilities/bitMap.hpp	Thu Apr 19 07:54:50 2018 +0200
+++ b/src/hotspot/share/utilities/bitMap.hpp	Thu Apr 19 07:54:50 2018 +0200
@@ -123,11 +123,11 @@
 
   // Allocates and clears the bitmap memory.
   template <class Allocator>
-  static bm_word_t* allocate(const Allocator&, idx_t size_in_bits);
+  static bm_word_t* allocate(const Allocator&, idx_t size_in_bits, bool clear = true);
 
   // Reallocates and clears the new bitmap memory.
   template <class Allocator>
-  static bm_word_t* reallocate(const Allocator&, bm_word_t* map, idx_t old_size_in_bits, idx_t new_size_in_bits);
+  static bm_word_t* reallocate(const Allocator&, bm_word_t* map, idx_t old_size_in_bits, idx_t new_size_in_bits, bool clear = true);
 
   // Free the bitmap memory.
   template <class Allocator>
@@ -359,7 +359,7 @@
  public:
   CHeapBitMap(MEMFLAGS flags = mtInternal) : BitMap(NULL, 0), _flags(flags) {}
   // Clears the bitmap memory.
-  CHeapBitMap(idx_t size_in_bits, MEMFLAGS flags = mtInternal);
+  CHeapBitMap(idx_t size_in_bits, MEMFLAGS flags = mtInternal, bool clear = true);
   ~CHeapBitMap();
 
   // Resize the backing bitmap memory.