hotspot/src/share/vm/gc/g1/g1FromCardCache.hpp
changeset 46669 05296a16012a
parent 37228 25ea8814a824
--- a/hotspot/src/share/vm/gc/g1/g1FromCardCache.hpp	Fri Jul 14 14:04:57 2017 +0200
+++ b/hotspot/src/share/vm/gc/g1/g1FromCardCache.hpp	Mon Jul 17 10:32:36 2017 +0200
@@ -40,6 +40,14 @@
   static int** _cache;
   static uint _max_regions;
   static size_t _static_mem_size;
+#ifdef ASSERT
+  static uint _max_workers;
+
+  static void check_bounds(uint worker_id, uint region_idx) {
+    assert(worker_id < _max_workers, "Worker_id %u is larger than maximum %u", worker_id, _max_workers);
+    assert(region_idx < _max_regions, "Region_idx %u is larger than maximum %u", region_idx, _max_regions);
+  }
+#endif
 
  public:
   enum {
@@ -61,10 +69,12 @@
   }
 
   static int at(uint worker_id, uint region_idx) {
+    DEBUG_ONLY(check_bounds(worker_id, region_idx);)
     return _cache[region_idx][worker_id];
   }
 
   static void set(uint worker_id, uint region_idx, int val) {
+    DEBUG_ONLY(check_bounds(worker_id, region_idx);)
     _cache[region_idx][worker_id] = val;
   }