Commit be213cfc authored by Stephan Herhut's avatar Stephan Herhut Committed by Commit Bot

[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 <herhut@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59024}
parent b766299d
......@@ -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
......
......@@ -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();
......
......@@ -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();
......
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