8336256: memcpy short value to int local is incorrect in VtableStubs::unsafe_hash

Reviewed-by: stuefe, shade, kvn
This commit is contained in:
Richard Reingruber 2024-07-15 07:34:10 +00:00
parent 3f2636d9b7
commit a96de6d8d2

View File

@ -262,7 +262,8 @@ inline uint VtableStubs::unsafe_hash(address entry_point) {
address vtable_type_addr = vtable_stub_addr + offset_of(VtableStub, _type);
address vtable_index_addr = vtable_stub_addr + offset_of(VtableStub, _index);
bool is_vtable_stub = *vtable_type_addr == static_cast<uint8_t>(VtableStub::Type::vtable_stub);
int vtable_index;
short vtable_index;
static_assert(sizeof(VtableStub::_index) == sizeof(vtable_index), "precondition");
memcpy(&vtable_index, vtable_index_addr, sizeof(vtable_index));
return hash(is_vtable_stub, vtable_index);
}