Skip to content

Commit fd1163d

Browse files
committed
8310332: Fix -Wconversion warnings in MethodData
Reviewed-by: aph, fparain
1 parent 72501cf commit fd1163d

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

src/hotspot/share/oops/methodData.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ address RetData::fixup_ret(int return_bci, MethodData* h_mdo) {
480480
// Now check to see if any of the cache slots are open.
481481
for (uint row = 0; row < row_limit(); row++) {
482482
if (bci(row) == no_bci) {
483-
set_bci_displacement(row, mdp - dp());
483+
set_bci_displacement(row, checked_cast<int>(mdp - dp()));
484484
set_bci_count(row, DataLayout::counter_increment);
485485
// Barrier to ensure displacement is written before the bci; allows
486486
// the interpreter to read displacement without fear of race condition.
@@ -987,7 +987,7 @@ int MethodData::initialize_data(BytecodeStream* stream,
987987
return 0;
988988
}
989989
int cell_count = -1;
990-
int tag = DataLayout::no_tag;
990+
u1 tag = DataLayout::no_tag;
991991
DataLayout* data_layout = data_layout_at(data_index);
992992
Bytecodes::Code c = stream->code();
993993
switch (c) {
@@ -1098,7 +1098,7 @@ int MethodData::initialize_data(BytecodeStream* stream,
10981098
if (cell_count >= 0) {
10991099
assert(tag != DataLayout::no_tag, "bad tag");
11001100
assert(bytecode_has_profile(c), "agree w/ BHP");
1101-
data_layout->initialize(tag, stream->bci(), cell_count);
1101+
data_layout->initialize(tag, checked_cast<u2>(stream->bci()), cell_count);
11021102
return DataLayout::compute_size_in_bytes(cell_count);
11031103
} else {
11041104
assert(!bytecode_has_profile(c), "agree w/ !BHP");
@@ -1310,8 +1310,8 @@ void MethodData::init() {
13101310
double scale = 1.0;
13111311
methodHandle mh(Thread::current(), _method);
13121312
CompilerOracle::has_option_value(mh, CompileCommand::CompileThresholdScaling, scale);
1313-
_invoke_mask = right_n_bits(CompilerConfig::scaled_freq_log(Tier0InvokeNotifyFreqLog, scale)) << InvocationCounter::count_shift;
1314-
_backedge_mask = right_n_bits(CompilerConfig::scaled_freq_log(Tier0BackedgeNotifyFreqLog, scale)) << InvocationCounter::count_shift;
1313+
_invoke_mask = (int)right_n_bits(CompilerConfig::scaled_freq_log(Tier0InvokeNotifyFreqLog, scale)) << InvocationCounter::count_shift;
1314+
_backedge_mask = (int)right_n_bits(CompilerConfig::scaled_freq_log(Tier0BackedgeNotifyFreqLog, scale)) << InvocationCounter::count_shift;
13151315

13161316
_tenure_traps = 0;
13171317
_num_loops = 0;
@@ -1479,7 +1479,7 @@ ProfileData* MethodData::bci_to_extra_data(int bci, Method* m, bool create_if_mi
14791479
return nullptr;
14801480
}
14811481
DataLayout temp;
1482-
temp.initialize(tag, bci, 0);
1482+
temp.initialize(tag, checked_cast<u2>(bci), 0);
14831483

14841484
dp->set_header(temp.header());
14851485
assert(dp->tag() == tag, "sane");

src/hotspot/share/oops/methodData.hpp

+15-15
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class DataLayout {
114114
};
115115

116116
// Tag values
117-
enum {
117+
enum : u1 {
118118
no_tag,
119119
bit_data_tag,
120120
counter_data_tag,
@@ -204,7 +204,7 @@ class DataLayout {
204204
}
205205

206206
void set_flag_at(u1 flag_number) {
207-
_header._struct._flags |= (0x1 << flag_number);
207+
_header._struct._flags |= (u1)(0x1 << flag_number);
208208
}
209209
bool flag_at(u1 flag_number) const {
210210
return (_header._struct._flags & (0x1 << flag_number)) != 0;
@@ -233,7 +233,7 @@ class DataLayout {
233233
return temp._header._struct._flags;
234234
}
235235
// Return a value which, when or-ed as a word into _header, sets the flag.
236-
static u8 flag_mask_to_header_mask(uint byte_constant) {
236+
static u8 flag_mask_to_header_mask(u1 byte_constant) {
237237
DataLayout temp; temp.set_header(0);
238238
temp._header._struct._flags = byte_constant;
239239
return temp._header._bits;
@@ -344,18 +344,18 @@ class ProfileData : public ResourceObj {
344344
return cast_to_oop(intptr_at(index));
345345
}
346346

347-
void set_flag_at(int flag_number) {
347+
void set_flag_at(u1 flag_number) {
348348
data()->set_flag_at(flag_number);
349349
}
350-
bool flag_at(int flag_number) const {
350+
bool flag_at(u1 flag_number) const {
351351
return data()->flag_at(flag_number);
352352
}
353353

354354
// two convenient imports for use by subclasses:
355355
static ByteSize cell_offset(int index) {
356356
return DataLayout::cell_offset(index);
357357
}
358-
static int flag_number_to_constant(int flag_number) {
358+
static u1 flag_number_to_constant(u1 flag_number) {
359359
return DataLayout::flag_number_to_constant(flag_number);
360360
}
361361

@@ -487,7 +487,7 @@ class BitData : public ProfileData {
487487
friend class VMStructs;
488488
friend class JVMCIVMStructs;
489489
protected:
490-
enum {
490+
enum : u1 {
491491
// null_seen:
492492
// saw a null operand (cast/aastore/instanceof)
493493
null_seen_flag = DataLayout::first_flag + 0
@@ -525,7 +525,7 @@ class BitData : public ProfileData {
525525
#endif
526526

527527
// Code generation support
528-
static int null_seen_byte_constant() {
528+
static u1 null_seen_byte_constant() {
529529
return flag_number_to_constant(null_seen_flag);
530530
}
531531

@@ -1126,7 +1126,7 @@ class ReceiverTypeData : public CounterData {
11261126

11271127
// Direct accessors
11281128
static uint row_limit() {
1129-
return TypeProfileWidth;
1129+
return (uint) TypeProfileWidth;
11301130
}
11311131
static int receiver_cell_index(uint row) {
11321132
return receiver0_offset + row * receiver_type_row_cell_count;
@@ -1430,7 +1430,7 @@ class RetData : public CounterData {
14301430
}
14311431

14321432
static uint row_limit() {
1433-
return BciProfileWidth;
1433+
return (uint) BciProfileWidth;
14341434
}
14351435
static int bci_cell_index(uint row) {
14361436
return bci0_offset + row * ret_row_cell_count;
@@ -2010,7 +2010,7 @@ class MethodData : public Metadata {
20102010
assert((uint)reason < ARRAY_SIZE(_trap_hist._array), "oob");
20112011
uint cnt1 = 1 + _trap_hist._array[reason];
20122012
if ((cnt1 & _trap_hist_mask) != 0) { // if no counter overflow...
2013-
_trap_hist._array[reason] = cnt1;
2013+
_trap_hist._array[reason] = (u1)cnt1;
20142014
return cnt1;
20152015
} else {
20162016
return _trap_hist_mask + (++_nof_overflow_traps);
@@ -2262,9 +2262,9 @@ class MethodData : public Metadata {
22622262
bool would_profile() const { return _would_profile != no_profile; }
22632263

22642264
int num_loops() const { return _num_loops; }
2265-
void set_num_loops(int n) { _num_loops = n; }
2265+
void set_num_loops(short n) { _num_loops = n; }
22662266
int num_blocks() const { return _num_blocks; }
2267-
void set_num_blocks(int n) { _num_blocks = n; }
2267+
void set_num_blocks(short n) { _num_blocks = n; }
22682268

22692269
bool is_mature() const; // consult mileage and ProfileMaturityPercentage
22702270
static int mileage_of(Method* m);
@@ -2326,7 +2326,7 @@ class MethodData : public Metadata {
23262326

23272327
// Convert a dp (data pointer) to a di (data index).
23282328
int dp_to_di(address dp) const {
2329-
return dp - ((address)_data);
2329+
return (int)(dp - ((address)_data));
23302330
}
23312331

23322332
// bci to di/dp conversion.
@@ -2366,7 +2366,7 @@ class MethodData : public Metadata {
23662366
DataLayout* extra_data_limit() const { return (DataLayout*)((address)this + size_in_bytes()); }
23672367
DataLayout* args_data_limit() const { return (DataLayout*)((address)this + size_in_bytes() -
23682368
parameters_size_in_bytes()); }
2369-
int extra_data_size() const { return (address)extra_data_limit() - (address)extra_data_base(); }
2369+
int extra_data_size() const { return (int)((address)extra_data_limit() - (address)extra_data_base()); }
23702370
static DataLayout* next_extra(DataLayout* dp);
23712371

23722372
// Return (uint)-1 for overflow.

src/hotspot/share/runtime/globals.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1110,11 +1110,11 @@ const int ObjectAlignmentInBytes = 8;
11101110
"X, Y and Z in 0=off ; 1=jsr292 only; 2=all methods") \
11111111
constraint(TypeProfileLevelConstraintFunc, AfterErgo) \
11121112
\
1113-
product(intx, TypeProfileArgsLimit, 2, \
1113+
product(int, TypeProfileArgsLimit, 2, \
11141114
"max number of call arguments to consider for type profiling") \
11151115
range(0, 16) \
11161116
\
1117-
product(intx, TypeProfileParmsLimit, 2, \
1117+
product(int, TypeProfileParmsLimit, 2, \
11181118
"max number of incoming parameters to consider for type profiling"\
11191119
", -1 for all") \
11201120
range(-1, 64) \
@@ -1377,7 +1377,7 @@ const int ObjectAlignmentInBytes = 8;
13771377
"Limit on traps (of one kind) at a particular BCI") \
13781378
range(0, max_jint) \
13791379
\
1380-
product(intx, SpecTrapLimitExtraEntries, 3, EXPERIMENTAL, \
1380+
product(int, SpecTrapLimitExtraEntries, 3, EXPERIMENTAL, \
13811381
"Extra method data trap entries for speculation") \
13821382
\
13831383
product(double, InlineFrequencyRatio, 0.25, DIAGNOSTIC, \

0 commit comments

Comments
 (0)