Skip to content

Commit

Permalink
8314651: G1: Fix -Wconversion warnings in static fields of HeapRegion
Browse files Browse the repository at this point in the history
Reviewed-by: tschatzl, iwalulya
  • Loading branch information
albertnetymk committed Aug 30, 2023
1 parent 876a725 commit cb3f968
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/hotspot/share/gc/g1/c1/g1BarrierSetC1.cpp
Expand Up @@ -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());
}
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/c2/g1BarrierSetC2.cpp
Expand Up @@ -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); {
Expand Down
9 changes: 6 additions & 3 deletions src/hotspot/share/gc/g1/g1Arguments.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/g1CardTable.inline.hpp
Expand Up @@ -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) {
Expand Down
11 changes: 4 additions & 7 deletions src/hotspot/share/gc/g1/heapRegion.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down
7 changes: 3 additions & 4 deletions src/hotspot/share/gc/g1/heapRegion.hpp
Expand Up @@ -289,16 +289,15 @@ class HeapRegion : public CHeapObj<mtGC> {
// 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.
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/vmStructs_g1.hpp
Expand Up @@ -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) \
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/jvmci/vmStructs_jvmci.cpp
Expand Up @@ -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()) \
Expand Down

3 comments on commit cb3f968

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JesperIRL
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/tag jdk-22+13

@openjdk
Copy link

@openjdk openjdk bot commented on cb3f968 Aug 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JesperIRL The tag jdk-22+13 was successfully created.

Please sign in to comment.