diff --git a/src/hotspot/share/gc/g1/c1/g1BarrierSetC1.cpp b/src/hotspot/share/gc/g1/c1/g1BarrierSetC1.cpp index 3668a51a32ef4..ef2f23633b9ad 100644 --- a/src/hotspot/share/gc/g1/c1/g1BarrierSetC1.cpp +++ b/src/hotspot/share/gc/g1/c1/g1BarrierSetC1.cpp @@ -158,13 +158,13 @@ void G1BarrierSetC1::post_barrier(LIRAccess& access, LIR_Opr addr, LIR_Opr new_v __ logical_xor(xor_res, new_val, xor_res); __ move(xor_res, xor_shift_res); __ unsigned_shift_right(xor_shift_res, - LIR_OprFact::intConst(HeapRegion::LogOfHRGrainBytes), + LIR_OprFact::intConst(checked_cast(HeapRegion::LogOfHRGrainBytes)), xor_shift_res, LIR_Opr::illegalOpr()); } else { __ logical_xor(addr, new_val, xor_res); __ unsigned_shift_right(xor_res, - LIR_OprFact::intConst(HeapRegion::LogOfHRGrainBytes), + LIR_OprFact::intConst(checked_cast(HeapRegion::LogOfHRGrainBytes)), xor_shift_res, LIR_Opr::illegalOpr()); } diff --git a/src/hotspot/share/gc/g1/c2/g1BarrierSetC2.cpp b/src/hotspot/share/gc/g1/c2/g1BarrierSetC2.cpp index 5542794624f09..4d45c227f8c07 100644 --- a/src/hotspot/share/gc/g1/c2/g1BarrierSetC2.cpp +++ b/src/hotspot/share/gc/g1/c2/g1BarrierSetC2.cpp @@ -454,7 +454,7 @@ void G1BarrierSetC2::post_barrier(GraphKit* kit, // Should be able to do an unsigned compare of region_size instead of // and extra shift. Do we have an unsigned compare?? // Node* region_size = __ ConI(1 << HeapRegion::LogOfHRGrainBytes); - Node* xor_res = __ URShiftX ( __ XorX( cast, __ CastPX(__ ctrl(), val)), __ ConI(HeapRegion::LogOfHRGrainBytes)); + Node* xor_res = __ URShiftX ( __ XorX( cast, __ CastPX(__ ctrl(), val)), __ ConI(checked_cast(HeapRegion::LogOfHRGrainBytes))); // if (xor_res == 0) same region so skip __ if_then(xor_res, BoolTest::ne, zeroX, likely); { diff --git a/src/hotspot/share/gc/g1/g1Arguments.cpp b/src/hotspot/share/gc/g1/g1Arguments.cpp index a20a62f571218..b76fd7b418f91 100644 --- a/src/hotspot/share/gc/g1/g1Arguments.cpp +++ b/src/hotspot/share/gc/g1/g1Arguments.cpp @@ -30,6 +30,7 @@ #include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1HeapVerifier.hpp" #include "gc/g1/heapRegion.hpp" +#include "gc/g1/heapRegionBounds.inline.hpp" #include "gc/g1/heapRegionRemSet.hpp" #include "gc/shared/cardTable.hpp" #include "gc/shared/gcArguments.hpp" @@ -131,11 +132,13 @@ void G1Arguments::initialize_mark_stack_size() { void G1Arguments::initialize_card_set_configuration() { assert(HeapRegion::LogOfHRGrainBytes != 0, "not initialized"); // Array of Cards card set container globals. - const int LOG_M = 20; - uint region_size_log_mb = (uint)MAX2(HeapRegion::LogOfHRGrainBytes - LOG_M, 0); + const uint LOG_M = 20; + assert(log2i_exact(HeapRegionBounds::min_size()) == LOG_M, "inv"); + assert(HeapRegion::LogOfHRGrainBytes >= LOG_M, "from the above"); + uint region_size_log_mb = HeapRegion::LogOfHRGrainBytes - LOG_M; if (FLAG_IS_DEFAULT(G1RemSetArrayOfCardsEntries)) { - uint max_cards_in_inline_ptr = G1CardSetConfiguration::max_cards_in_inline_ptr(HeapRegion::LogOfHRGrainBytes - CardTable::card_shift()); + uint max_cards_in_inline_ptr = G1CardSetConfiguration::max_cards_in_inline_ptr(HeapRegion::LogCardsPerRegion); FLAG_SET_ERGO(G1RemSetArrayOfCardsEntries, MAX2(max_cards_in_inline_ptr * 2, G1RemSetArrayOfCardsEntriesBase << region_size_log_mb)); } diff --git a/src/hotspot/share/gc/g1/g1CardTable.inline.hpp b/src/hotspot/share/gc/g1/g1CardTable.inline.hpp index 5d9742c629a5b..d48fce6cb9ed1 100644 --- a/src/hotspot/share/gc/g1/g1CardTable.inline.hpp +++ b/src/hotspot/share/gc/g1/g1CardTable.inline.hpp @@ -31,7 +31,7 @@ inline uint G1CardTable::region_idx_for(CardValue* p) { size_t const card_idx = pointer_delta(p, _byte_map, sizeof(CardValue)); - return (uint)(card_idx >> (HeapRegion::LogOfHRGrainBytes - _card_shift)); + return (uint)(card_idx >> HeapRegion::LogCardsPerRegion); } inline bool G1CardTable::mark_clean_as_dirty(CardValue* card) { diff --git a/src/hotspot/share/gc/g1/heapRegion.cpp b/src/hotspot/share/gc/g1/heapRegion.cpp index 025b844bfa775..50b9f25242ec1 100644 --- a/src/hotspot/share/gc/g1/heapRegion.cpp +++ b/src/hotspot/share/gc/g1/heapRegion.cpp @@ -48,8 +48,8 @@ #include "runtime/globals_extension.hpp" #include "utilities/powerOfTwo.hpp" -int HeapRegion::LogOfHRGrainBytes = 0; -int HeapRegion::LogCardsPerRegion = 0; +uint HeapRegion::LogOfHRGrainBytes = 0; +uint HeapRegion::LogCardsPerRegion = 0; size_t HeapRegion::GrainBytes = 0; size_t HeapRegion::GrainWords = 0; size_t HeapRegion::CardsPerRegion = 0; @@ -78,12 +78,9 @@ void HeapRegion::setup_heap_region_size(size_t max_heap_size) { // Now make sure that we don't go over or under our limits. region_size = clamp(region_size, HeapRegionBounds::min_size(), HeapRegionBounds::max_size()); - // Calculate the log for the region size. - int region_size_log = log2i_exact(region_size); - // Now, set up the globals. guarantee(LogOfHRGrainBytes == 0, "we should only set it once"); - LogOfHRGrainBytes = region_size_log; + LogOfHRGrainBytes = log2i_exact(region_size); guarantee(GrainBytes == 0, "we should only set it once"); GrainBytes = region_size; @@ -94,7 +91,7 @@ void HeapRegion::setup_heap_region_size(size_t max_heap_size) { guarantee(CardsPerRegion == 0, "we should only set it once"); CardsPerRegion = GrainBytes >> G1CardTable::card_shift(); - LogCardsPerRegion = log2i(CardsPerRegion); + LogCardsPerRegion = log2i_exact(CardsPerRegion); if (G1HeapRegionSize != GrainBytes) { FLAG_SET_ERGO(G1HeapRegionSize, GrainBytes); diff --git a/src/hotspot/share/gc/g1/heapRegion.hpp b/src/hotspot/share/gc/g1/heapRegion.hpp index 67769c3b607f1..ae4aec7338654 100644 --- a/src/hotspot/share/gc/g1/heapRegion.hpp +++ b/src/hotspot/share/gc/g1/heapRegion.hpp @@ -289,16 +289,15 @@ class HeapRegion : public CHeapObj { // there's clearing to be done ourselves. We also always mangle the space. void initialize(bool clear_space = false, bool mangle_space = SpaceDecorator::Mangle); - static int LogOfHRGrainBytes; - static int LogCardsPerRegion; + static uint LogOfHRGrainBytes; + static uint LogCardsPerRegion; static size_t GrainBytes; static size_t GrainWords; static size_t CardsPerRegion; static size_t align_up_to_region_byte_size(size_t sz) { - return (sz + (size_t) GrainBytes - 1) & - ~((1 << (size_t) LogOfHRGrainBytes) - 1); + return align_up(sz, GrainBytes); } // Returns whether a field is in the same region as the obj it points to. diff --git a/src/hotspot/share/gc/g1/vmStructs_g1.hpp b/src/hotspot/share/gc/g1/vmStructs_g1.hpp index 351c1baf5dfdf..e7df5277e862a 100644 --- a/src/hotspot/share/gc/g1/vmStructs_g1.hpp +++ b/src/hotspot/share/gc/g1/vmStructs_g1.hpp @@ -35,7 +35,7 @@ static_field) \ \ static_field(HeapRegion, GrainBytes, size_t) \ - static_field(HeapRegion, LogOfHRGrainBytes, int) \ + static_field(HeapRegion, LogOfHRGrainBytes, uint) \ \ nonstatic_field(HeapRegion, _type, HeapRegionType) \ nonstatic_field(HeapRegion, _bottom, HeapWord* const) \ diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp b/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp index 881f46e86c72d..608aee7103391 100644 --- a/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp +++ b/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp @@ -399,6 +399,7 @@ jobjectArray readConfiguration0(JNIEnv *env, JVMCI_TRAPS) { assert(box.is_non_null(), "must have a box"); } else if (strcmp(vmField.typeString, "int") == 0 || strcmp(vmField.typeString, "jint") == 0 || + strcmp(vmField.typeString, "uint") == 0 || strcmp(vmField.typeString, "uint32_t") == 0) { BOXED_LONG(box, *(jint*) vmField.address); assert(box.is_non_null(), "must have a box"); diff --git a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp index 6953f5f540969..d160a03d8981e 100644 --- a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp +++ b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp @@ -817,7 +817,7 @@ #if INCLUDE_G1GC #define VM_STRUCTS_JVMCI_G1GC(nonstatic_field, static_field) \ - static_field(HeapRegion, LogOfHRGrainBytes, int) + static_field(HeapRegion, LogOfHRGrainBytes, uint) #define VM_INT_CONSTANTS_JVMCI_G1GC(declare_constant, declare_constant_with_value, declare_preprocessor_constant) \ declare_constant_with_value("G1CardTable::g1_young_gen", G1CardTable::g1_young_card_val()) \