8331421: ubsan: vmreg.cpp checking error member call on misaligned address

Reviewed-by: mbaesken
Backport-of: beebce044d
This commit is contained in:
Martin Doerr
2024-06-12 19:38:24 +00:00
committed by Vitaly Provodin
parent 85249f35a0
commit e3df281f37
2 changed files with 4 additions and 3 deletions

View File

@@ -30,7 +30,7 @@
// used by SA and jvmti, but it's a leaky abstraction: SA and jvmti
// "know" that stack0 is an integer masquerading as a pointer. For the
// sake of those clients, we preserve this interface.
VMReg VMRegImpl::stack0 = (VMReg)VMRegImpl::stack_0()->value();
VMReg VMRegImpl::stack0 = (VMReg)(intptr_t)FIRST_STACK;
// VMRegs are 4 bytes wide on all platforms
const int VMRegImpl::stack_slot_size = 4;

View File

@@ -53,7 +53,8 @@ friend class OptoReg;
// friend class Location;
private:
enum {
BAD_REG = -1
BAD_REG = -1,
FIRST_STACK = (ConcreteRegisterImpl::number_of_registers + 7) & ~7
};
// Despite being private, this field is exported to the
@@ -70,7 +71,7 @@ private:
public:
static constexpr VMReg stack_0() {
return first() + ((ConcreteRegisterImpl::number_of_registers + 7) & ~7);
return first() + FIRST_STACK;
}
static VMReg as_VMReg(int val, bool bad_ok = false) {