Skip to content

Commit be213cf

Browse files
Stephan HerhutCommit Bot
authored andcommitted
[codegen] Use target architecture specific branch alignment
The Assembler class (or some of them at least) have a CodeTargetAlign method that aligns the code to a target specific value (16 byte on x86, 8 byte on arm). However, these were not used. Instead we always aligned to 16 byte boundaries, hence wasting up to 8 bytes on arm. Change-Id: Iee7d24ebc13a9a58002a9d7d0ce53955bee7d628 Reviewed-on: https://chromium-review.googlesource.com/c/1426125 Commit-Queue: Stephan Herhut <[email protected]> Reviewed-by: Michael Starzinger <[email protected]> Cr-Commit-Position: refs/heads/master@{#59024}
1 parent b766299 commit be213cf

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/arm64/assembler-arm64.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,10 @@ void Assembler::Align(int m) {
621621
}
622622
}
623623

624+
void Assembler::CodeTargetAlign() {
625+
// Preferred alignment of jump targets on some ARM chips.
626+
Align(8);
627+
}
624628

625629
void Assembler::CheckLabelLinkChain(Label const * label) {
626630
#ifdef DEBUG

src/arm64/assembler-arm64.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
287287
// Insert the smallest number of zero bytes possible to align the pc offset
288288
// to a mulitple of m. m must be a power of 2 (>= 2).
289289
void DataAlign(int m);
290+
// Aligns code to something that's optimal for a jump target for the platform.
291+
void CodeTargetAlign();
290292

291293
inline void Unreachable();
292294

src/compiler/backend/code-generator.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ void CodeGenerator::AssembleCode() {
191191

192192
// Assemble instructions in assembly order.
193193
for (const InstructionBlock* block : code()->ao_blocks()) {
194-
// Align loop headers on 16-byte boundaries.
194+
// Align loop headers on vendor recommended boundaries.
195195
if (block->ShouldAlign() && !tasm()->jump_optimization_info()) {
196-
tasm()->Align(16);
196+
tasm()->CodeTargetAlign();
197197
}
198198
if (info->trace_turbo_json_enabled()) {
199199
block_starts_[block->rpo_number().ToInt()] = tasm()->pc_offset();

0 commit comments

Comments
 (0)