From beebce044db97e50a7aea3f83d70e134b2128d0a Mon Sep 17 00:00:00 2001 From: Martin Doerr Date: Thu, 2 May 2024 10:21:21 +0000 Subject: [PATCH] 8331421: ubsan: vmreg.cpp checking error member call on misaligned address Reviewed-by: mbaesken, lucy --- src/hotspot/share/code/vmreg.cpp | 2 +- src/hotspot/share/code/vmreg.hpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/hotspot/share/code/vmreg.cpp b/src/hotspot/share/code/vmreg.cpp index 37c3137a102..ba30c114c6c 100644 --- a/src/hotspot/share/code/vmreg.cpp +++ b/src/hotspot/share/code/vmreg.cpp @@ -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)(intptr_t)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; diff --git a/src/hotspot/share/code/vmreg.hpp b/src/hotspot/share/code/vmreg.hpp index 78f52b8d57a..41e40e9a017 100644 --- a/src/hotspot/share/code/vmreg.hpp +++ b/src/hotspot/share/code/vmreg.hpp @@ -54,7 +54,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 @@ -71,7 +72,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) {