8313554: Fix -Wconversion warnings for ResolvedFieldEntry

Reviewed-by: coleenp, dlong
This commit is contained in:
Matias Saavedra Silva 2023-08-04 20:24:50 +00:00
parent b463c6d3b0
commit ad6e9e75bf
3 changed files with 12 additions and 8 deletions

View File

@ -716,7 +716,9 @@ void InterpreterRuntime::resolve_get_put(JavaThread* current, Bytecodes::Code by
ResolvedFieldEntry* entry = pool->resolved_field_entry_at(field_index);
entry->set_flags(info.access_flags().is_final(), info.access_flags().is_volatile());
entry->fill_in(info.field_holder(), info.offset(), (u2)info.index(), (u1)state, (u1)get_code, (u1)put_code);
entry->fill_in(info.field_holder(), info.offset(),
checked_cast<u2>(info.index()), checked_cast<u1>(state),
static_cast<u1>(get_code), static_cast<u1>(put_code));
}

View File

@ -185,11 +185,11 @@ void Rewriter::rewrite_field_reference(address bcp, int offset, bool reverse) {
if (!reverse) {
int cp_index = Bytes::get_Java_u2(p);
int field_entry_index = _cp_map.at(cp_index);
Bytes::put_native_u2(p, field_entry_index);
Bytes::put_native_u2(p, checked_cast<u2>(field_entry_index));
} else {
int field_entry_index = Bytes::get_native_u2(p);
int pool_index = _initialized_field_entries.at(field_entry_index).constant_pool_index();
Bytes::put_Java_u2(p, pool_index);
Bytes::put_Java_u2(p, checked_cast<u2>(pool_index));
}
}

View File

@ -50,7 +50,7 @@ class ResolvedFieldEntry {
int _field_offset; // Field offset in bytes
u2 _field_index; // Index into field information in holder InstanceKlass
u2 _cpool_index; // Constant pool index
u1 _tos_state; // TOS state
u1 _tos_state; // TOS state
u1 _flags; // Flags: [0000|00|is_final|is_volatile]
u1 _get_code, _put_code; // Get and Put bytecodes of the field
@ -101,9 +101,11 @@ public:
// Printing
void print_on(outputStream* st) const;
void set_flags(bool is_final, bool is_volatile) {
u1 new_flags = (static_cast<u1>(is_final) << static_cast<u1>(is_final_shift)) | static_cast<u1>(is_volatile);
_flags = new_flags;
void set_flags(bool is_final_flag, bool is_volatile_flag) {
int new_flags = (is_final_flag << is_final_shift) | static_cast<int>(is_volatile_flag);
_flags = checked_cast<u1>(new_flags);
assert(is_final() == is_final_flag, "Must be");
assert(is_volatile() == is_volatile_flag, "Must be");
}
inline void set_bytecode(u1* code, u1 new_code) {
@ -116,7 +118,7 @@ public:
}
// Populate the strucutre with resolution information
void fill_in(InstanceKlass* klass, intx offset, int index, int tos_state, u1 b1, u1 b2) {
void fill_in(InstanceKlass* klass, int offset, u2 index, u1 tos_state, u1 b1, u1 b2) {
_field_holder = klass;
_field_offset = offset;
_field_index = index;