Skip to content

Commit

Permalink
[codegen] Use target architecture specific branch alignment
Browse files Browse the repository at this point in the history
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 <herhut@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59024}
  • Loading branch information
Stephan Herhut authored and Commit Bot committed Jan 23, 2019
1 parent b766299 commit be213cf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/arm64/assembler-arm64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,10 @@ void Assembler::Align(int m) {
}
}

void Assembler::CodeTargetAlign() {
// Preferred alignment of jump targets on some ARM chips.
Align(8);
}

void Assembler::CheckLabelLinkChain(Label const * label) {
#ifdef DEBUG
Expand Down
2 changes: 2 additions & 0 deletions src/arm64/assembler-arm64.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
// Insert the smallest number of zero bytes possible to align the pc offset
// to a mulitple of m. m must be a power of 2 (>= 2).
void DataAlign(int m);
// Aligns code to something that's optimal for a jump target for the platform.
void CodeTargetAlign();

inline void Unreachable();

Expand Down
4 changes: 2 additions & 2 deletions src/compiler/backend/code-generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ void CodeGenerator::AssembleCode() {

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

0 comments on commit be213cf

Please sign in to comment.