8314651: G1: Fix -Wconversion warnings in static fields of HeapRegion

Reviewed-by: tschatzl, iwalulya
This commit is contained in:
Albert Mingkun Yang 2023-08-30 09:36:34 +00:00
parent 876a725af9
commit cb3f9680d3
9 changed files with 20 additions and 20 deletions

View File

@ -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<jint>(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<jint>(HeapRegion::LogOfHRGrainBytes)),
xor_shift_res,
LIR_Opr::illegalOpr());
}

View File

@ -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<jint>(HeapRegion::LogOfHRGrainBytes)));
// if (xor_res == 0) same region so skip
__ if_then(xor_res, BoolTest::ne, zeroX, likely); {

View File

@ -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));
}

View File

@ -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) {

View File

@ -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);

View File

@ -289,16 +289,15 @@ public:
// 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.

View File

@ -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) \

View File

@ -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");

View File

@ -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()) \