Commit d82b77e4 authored by Anton Bikineev's avatar Anton Bikineev Committed by Commit Bot

cppgc: Add test for stack alignment

This tests that the stack doesn't get misaligned after asm trampolines.
x86 and x64 psABI requires the stack to be 16 bytes aligned.

Bug: chromium:1056170
Change-Id: I73e7100806c6ecf3f5e884a121a15bcc384d8011
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2128048Reviewed-by: 's avatarAnton Bikineev <bikineev@chromium.org>
Reviewed-by: 's avatarOmer Katz <omerkatz@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66922}
parent fd9e54a9
......@@ -11,6 +11,10 @@
#include "src/base/platform/platform.h"
#include "testing/gtest/include/gtest/gtest.h"
#if V8_OS_LINUX && (V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64)
#include <xmmintrin.h>
#endif
namespace cppgc {
namespace internal {
......@@ -233,6 +237,22 @@ TEST_F(GCStackTest, IteratePointersFindsCalleeSavedRegisters) {
#undef FOR_ALL_CALLEE_SAVED_REGS
}
#if V8_OS_LINUX && (V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64)
class CheckStackAlignmentVisitor final : public StackVisitor {
public:
void VisitPointer(const void*) final {
float f[4] = {0.};
volatile auto xmm = ::_mm_load_ps(f);
USE(xmm);
}
};
TEST_F(GCStackTest, StackAlignment) {
auto checker = std::make_unique<CheckStackAlignmentVisitor>();
GetStack()->IteratePointers(checker.get());
}
#endif // V8_OS_LINUX && (V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64)
#endif // CONSERVATIVE_STACK_SCAN_SUPPORTED
} // namespace internal
......
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