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

Reviewed-by: mbaesken, lucy
This commit is contained in:
Martin Doerr 2024-05-02 10:21:21 +00:00
parent ae82405ff7
commit beebce044d
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 // 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 // "know" that stack0 is an integer masquerading as a pointer. For the
// sake of those clients, we preserve this interface. // sake of those clients, we preserve this interface.
VMReg VMRegImpl::stack0 = (VMReg)(intptr_t)VMRegImpl::stack_0()->value(); VMReg VMRegImpl::stack0 = (VMReg)(intptr_t)FIRST_STACK;
// VMRegs are 4 bytes wide on all platforms // VMRegs are 4 bytes wide on all platforms
const int VMRegImpl::stack_slot_size = 4; const int VMRegImpl::stack_slot_size = 4;

View File

@ -54,7 +54,8 @@ friend class OptoReg;
// friend class Location; // friend class Location;
private: private:
enum { enum {
BAD_REG = -1 BAD_REG = -1,
FIRST_STACK = (ConcreteRegisterImpl::number_of_registers + 7) & ~7
}; };
// Despite being private, this field is exported to the // Despite being private, this field is exported to the
@ -71,7 +72,7 @@ private:
public: public:
static constexpr VMReg stack_0() { 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) { static VMReg as_VMReg(int val, bool bad_ok = false) {