Reland "[codegen] Align the code start at 64 byte in x64"
This is a reland of commit 40af03b8c3
The original CL failed one test in Windows, and this CL fix this issue.
Original changes's description:
> [codegen] Align the code start at 64 byte in x64
>
> In order to make loop header aligned at 64 byte (relative to memory address), code start should also be aligned at 64 byte.
>
> Bug: chromium:1231471
> Change-Id: I95390babd9cc78492e0beb0f1b03901eb481d5d5
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3094167
> Reviewed-by: Jakob Gruber <jgruber@chromium.org>
> Commit-Queue: Hao A Xu <hao.a.xu@intel.com>
> Cr-Commit-Position: refs/heads/main@{#76484}
Bug: chromium:1231471
Change-Id: Ia927305c792c7486588bc15e9e87840d6db18478
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3133957
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Commit-Queue: Hao A Xu <hao.a.xu@intel.com>
Cr-Commit-Position: refs/heads/main@{#76617}
This commit is contained in:
parent
6f80c9a619
commit
7e8270dd4e
@ -590,9 +590,14 @@ constexpr intptr_t kPointerAlignmentMask = kPointerAlignment - 1;
|
||||
constexpr intptr_t kDoubleAlignment = 8;
|
||||
constexpr intptr_t kDoubleAlignmentMask = kDoubleAlignment - 1;
|
||||
|
||||
// Desired alignment for generated code is 32 bytes (to improve cache line
|
||||
// utilization).
|
||||
// Desired alignment for generated code is 64 bytes on x64 (to allow 64-bytes
|
||||
// loop header alignment) and 32 bytes (to improve cache line utilization) on
|
||||
// other architectures.
|
||||
#if V8_TARGET_ARCH_X64
|
||||
constexpr int kCodeAlignmentBits = 6;
|
||||
#else
|
||||
constexpr int kCodeAlignmentBits = 5;
|
||||
#endif
|
||||
constexpr intptr_t kCodeAlignment = 1 << kCodeAlignmentBits;
|
||||
constexpr intptr_t kCodeAlignmentMask = kCodeAlignment - 1;
|
||||
|
||||
|
@ -1001,8 +1001,11 @@ void Code::CodeVerify(Isolate* isolate) {
|
||||
CHECK_LE(constant_pool_offset(), code_comments_offset());
|
||||
CHECK_LE(code_comments_offset(), unwinding_info_offset());
|
||||
CHECK_LE(unwinding_info_offset(), MetadataSize());
|
||||
#if !defined(_MSC_VER) || defined(__clang__)
|
||||
// See also: PlatformEmbeddedFileWriterWin::AlignToCodeAlignment.
|
||||
CHECK_IMPLIES(!ReadOnlyHeap::Contains(*this),
|
||||
IsAligned(InstructionStart(), kCodeAlignment));
|
||||
#endif // !defined(_MSC_VER) || defined(__clang__)
|
||||
CHECK_IMPLIES(!ReadOnlyHeap::Contains(*this),
|
||||
IsAligned(raw_instruction_start(), kCodeAlignment));
|
||||
if (V8_EXTERNAL_CODE_SPACE_BOOL) {
|
||||
|
@ -547,7 +547,7 @@ class Code : public HeapObject {
|
||||
#elif V8_TARGET_ARCH_LOONG64
|
||||
static constexpr int kHeaderPaddingSize = 24;
|
||||
#elif V8_TARGET_ARCH_X64
|
||||
static constexpr int kHeaderPaddingSize = COMPRESS_POINTERS_BOOL ? 12 : 24;
|
||||
static constexpr int kHeaderPaddingSize = COMPRESS_POINTERS_BOOL ? 12 : 56;
|
||||
#elif V8_TARGET_ARCH_ARM
|
||||
static constexpr int kHeaderPaddingSize = 12;
|
||||
#elif V8_TARGET_ARCH_IA32
|
||||
|
@ -65,8 +65,14 @@ void PlatformEmbeddedFileWriterAIX::DeclareSymbolGlobal(const char* name) {
|
||||
}
|
||||
|
||||
void PlatformEmbeddedFileWriterAIX::AlignToCodeAlignment() {
|
||||
#if V8_TARGET_ARCH_X64
|
||||
// On x64 use 64-bytes code alignment to allow 64-bytes loop header alignment.
|
||||
STATIC_ASSERT((1 << 6) >= kCodeAlignment);
|
||||
fprintf(fp_, ".align 6\n");
|
||||
#else
|
||||
STATIC_ASSERT((1 << 5) >= kCodeAlignment);
|
||||
fprintf(fp_, ".align 5\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
void PlatformEmbeddedFileWriterAIX::AlignToDataAlignment() {
|
||||
|
@ -74,8 +74,14 @@ void PlatformEmbeddedFileWriterGeneric::DeclareSymbolGlobal(const char* name) {
|
||||
}
|
||||
|
||||
void PlatformEmbeddedFileWriterGeneric::AlignToCodeAlignment() {
|
||||
#if V8_TARGET_ARCH_X64
|
||||
// On x64 use 64-bytes code alignment to allow 64-bytes loop header alignment.
|
||||
STATIC_ASSERT(64 >= kCodeAlignment);
|
||||
fprintf(fp_, ".balign 64\n");
|
||||
#else
|
||||
STATIC_ASSERT(32 >= kCodeAlignment);
|
||||
fprintf(fp_, ".balign 32\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
void PlatformEmbeddedFileWriterGeneric::AlignToDataAlignment() {
|
||||
|
@ -56,12 +56,18 @@ void PlatformEmbeddedFileWriterMac::DeclareSymbolGlobal(const char* name) {
|
||||
// prevents something along the compilation chain from messing with the
|
||||
// embedded blob. Using .global here causes embedded blob hash verification
|
||||
// failures at runtime.
|
||||
STATIC_ASSERT(32 >= kCodeAlignment);
|
||||
fprintf(fp_, ".private_extern _%s\n", name);
|
||||
}
|
||||
|
||||
void PlatformEmbeddedFileWriterMac::AlignToCodeAlignment() {
|
||||
#if V8_TARGET_ARCH_X64
|
||||
// On x64 use 64-bytes code alignment to allow 64-bytes loop header alignment.
|
||||
STATIC_ASSERT(64 >= kCodeAlignment);
|
||||
fprintf(fp_, ".balign 64\n");
|
||||
#else
|
||||
STATIC_ASSERT(32 >= kCodeAlignment);
|
||||
fprintf(fp_, ".balign 32\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
void PlatformEmbeddedFileWriterMac::AlignToDataAlignment() {
|
||||
|
@ -637,7 +637,14 @@ void PlatformEmbeddedFileWriterWin::DeclareSymbolGlobal(const char* name) {
|
||||
}
|
||||
|
||||
void PlatformEmbeddedFileWriterWin::AlignToCodeAlignment() {
|
||||
#if V8_TARGET_ARCH_X64
|
||||
// On x64 use 64-bytes code alignment to allow 64-bytes loop header alignment.
|
||||
STATIC_ASSERT(64 >= kCodeAlignment);
|
||||
fprintf(fp_, ".balign 64\n");
|
||||
#else
|
||||
STATIC_ASSERT(32 >= kCodeAlignment);
|
||||
fprintf(fp_, ".balign 32\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
void PlatformEmbeddedFileWriterWin::AlignToDataAlignment() {
|
||||
|
Loading…
Reference in New Issue
Block a user