Skip to content

Commit

Permalink
8313554: Fix -Wconversion warnings for ResolvedFieldEntry
Browse files Browse the repository at this point in the history
Reviewed-by: coleenp, dlong
  • Loading branch information
Matias Saavedra Silva committed Aug 4, 2023
1 parent b463c6d commit ad6e9e7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/hotspot/share/interpreter/interpreterRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}


Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/interpreter/rewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down
12 changes: 7 additions & 5 deletions src/hotspot/share/oops/resolvedFieldEntry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -101,9 +101,11 @@ class ResolvedFieldEntry {
// 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) {
Expand All @@ -116,7 +118,7 @@ class ResolvedFieldEntry {
}

// 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;
Expand Down

1 comment on commit ad6e9e7

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.