Commit a0af1c2b authored by Victor Gomes's avatar Victor Gomes Committed by Commit Bot

[test] Fix StackAlignment test

Change-Id: Icd094eaa12b957bc7a658807aaa565665a184c81
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2470561
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Auto-Submit: Victor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70499}
parent 0b48da8b
...@@ -12,33 +12,45 @@ namespace internal { ...@@ -12,33 +12,45 @@ namespace internal {
#ifdef V8_CC_GNU #ifdef V8_CC_GNU
DISABLE_ASAN inline uintptr_t GetStackPointer() {
// MSAN doesn't seem to treat initializing stores in inline assembly as such,
// so we initialize this value here.
uintptr_t sp_addr = 0;
#if V8_HOST_ARCH_X64 #if V8_HOST_ARCH_X64
__asm__ __volatile__("mov %%rsp, %0" : "=g"(sp_addr)); #define GET_STACK_POINTER_TO(sp_addr) \
__asm__ __volatile__("mov %%rsp, %0" : "=g"(sp_addr))
#elif V8_HOST_ARCH_IA32 #elif V8_HOST_ARCH_IA32
__asm__ __volatile__("mov %%esp, %0" : "=g"(sp_addr)); #define GET_STACK_POINTER_TO(sp_addr) \
__asm__ __volatile__("mov %%esp, %0" : "=g"(sp_addr))
#elif V8_HOST_ARCH_ARM #elif V8_HOST_ARCH_ARM
__asm__ __volatile__("str sp, %0" : "=g"(sp_addr)); #define GET_STACK_POINTER_TO(sp_addr) \
__asm__ __volatile__("str sp, %0" : "=g"(sp_addr))
#elif V8_HOST_ARCH_ARM64 #elif V8_HOST_ARCH_ARM64
__asm__ __volatile__("mov x16, sp; str x16, %0" : "=g"(sp_addr)); #define GET_STACK_POINTER_TO(sp_addr) \
__asm__ __volatile__("mov x16, sp; str x16, %0" : "=g"(sp_addr))
#elif V8_HOST_ARCH_MIPS #elif V8_HOST_ARCH_MIPS
__asm__ __volatile__("sw $sp, %0" : "=g"(sp_addr)); #define GET_STACK_POINTER_TO(sp_addr) \
__asm__ __volatile__("sw $sp, %0" : "=g"(sp_addr))
#elif V8_HOST_ARCH_MIPS64 #elif V8_HOST_ARCH_MIPS64
__asm__ __volatile__("sd $sp, %0" : "=g"(sp_addr)); #define GET_STACK_POINTER_TO(sp_addr) \
__asm__ __volatile__("sd $sp, %0" : "=g"(sp_addr))
#elif defined(__s390x__) || defined(_ARCH_S390X) #elif defined(__s390x__) || defined(_ARCH_S390X)
__asm__ __volatile__("stg %%r15, %0" : "=m"(sp_addr)); #define GET_STACK_POINTER_TO(sp_addr) \
__asm__ __volatile__("stg %%r15, %0" : "=m"(sp_addr))
#elif defined(__s390__) || defined(_ARCH_S390) #elif defined(__s390__) || defined(_ARCH_S390)
__asm__ __volatile__("st 15, %0" : "=m"(sp_addr)); #define GET_STACK_POINTER_TO(sp_addr) \
__asm__ __volatile__("st 15, %0" : "=m"(sp_addr))
#elif defined(__PPC64__) || defined(_ARCH_PPC64) #elif defined(__PPC64__) || defined(_ARCH_PPC64)
__asm__ __volatile__("std 1, %0" : "=g"(sp_addr)); #define GET_STACK_POINTER_TO(sp_addr) \
__asm__ __volatile__("std 1, %0" : "=g"(sp_addr))
#elif defined(__PPC__) || defined(_ARCH_PPC) #elif defined(__PPC__) || defined(_ARCH_PPC)
__asm__ __volatile__("stw 1, %0" : "=g"(sp_addr)); #define GET_STACK_POINTER_TO(sp_addr) \
__asm__ __volatile__("stw 1, %0" : "=g"(sp_addr))
#else #else
#error Host architecture was not detected as supported by v8 #error Host architecture was not detected as supported by v8
#endif #endif
DISABLE_ASAN inline uintptr_t GetStackPointer() {
// MSAN doesn't seem to treat initializing stores in inline assembly as such,
// so we initialize this value here.
uintptr_t sp_addr = 0;
GET_STACK_POINTER_TO(sp_addr);
return sp_addr; return sp_addr;
} }
......
...@@ -16,9 +16,10 @@ namespace internal { ...@@ -16,9 +16,10 @@ namespace internal {
#ifdef V8_CC_GNU #ifdef V8_CC_GNU
void GetStackPointerCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { static uintptr_t sp_addr = 0;
uintptr_t sp_addr = GetStackPointer();
void GetStackPointerCallback(const v8::FunctionCallbackInfo<v8::Value>& args) {
GET_STACK_POINTER_TO(sp_addr);
args.GetReturnValue().Set(v8::Integer::NewFromUnsigned( args.GetReturnValue().Set(v8::Integer::NewFromUnsigned(
args.GetIsolate(), static_cast<uint32_t>(sp_addr))); args.GetIsolate(), static_cast<uint32_t>(sp_addr)));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment