Misc assembler optimizations

RESOLVED FIXED in mozilla37

Status

()

--
enhancement
RESOLVED FIXED
4 years ago
4 years ago

People

(Reporter: sunfish, Assigned: sunfish)

Tracking

unspecified
mozilla37
x86_64
All
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(4 attachments)

(Assignee)

Description

4 years ago
Created attachment 8541752 [details] [diff] [review]
eax-encodings.patch

The following patches implement a variety of low-level x86 encoding optimizations.

First is a patch implementing optimized %eax encodings.
Attachment #8541752 - Flags: review?(jdemooij)
(Assignee)

Comment 1

4 years ago
Created attachment 8541771 [details] [diff] [review]
vex-shrink-moves.patch

This patch optimizes movaps/movapd/movdqa to use 2-byte VEX prefixes instead of 3-byte ones in more cases.
Attachment #8541771 - Flags: review?(jdemooij)
(Assignee)

Comment 2

4 years ago
Created attachment 8541776 [details] [diff] [review]
eax-mov-encodings.patch

This implements the %eax encoding optimizations for mov instructions.
Attachment #8541776 - Flags: review?(jdemooij)
(Assignee)

Comment 3

4 years ago
Created attachment 8541780 [details] [diff] [review]
jump-shrink.patch

This patch enables the use of 8-bit jump displacements for jumps where the destination is known (e.g. loop backedges).
Attachment #8541780 - Flags: review?(jdemooij)
(Assignee)

Updated

4 years ago
OS: Linux → All
Attachment #8541752 - Flags: review?(jdemooij) → review+
Comment on attachment 8541771 [details] [diff] [review]
vex-shrink-moves.patch

Review of attachment 8541771 [details] [diff] [review]:
-----------------------------------------------------------------

Clever.
Attachment #8541771 - Flags: review?(jdemooij) → review+
Attachment #8541776 - Flags: review?(jdemooij) → review+
Comment on attachment 8541780 [details] [diff] [review]
jump-shrink.patch

Review of attachment 8541780 [details] [diff] [review]:
-----------------------------------------------------------------

Great, also nice cleanup.

::: js/src/jit/shared/BaseAssembler-x86-shared.h
@@ +2884,5 @@
> +        int32_t diff = dst.offset() - m_formatter.size();
> +        spew("jmp        .Llabel%d", dst.offset());
> +
> +        // The jump immediate is an offset from the end of the jump instruction.
> +        // An jump instrution is either 1 byte opcode and 1 byte offset, or 1

Nit: A jump instruction

@@ +2944,5 @@
> +        int32_t diff = dst.offset() - m_formatter.size();
> +        spew("j%s        .Llabel%d", nameCC(cond), dst.offset());
> +
> +        // The jump immediate is an offset from the end of the jump instruction.
> +        // A conditional jump instrution is either 1 byte opcode and 1 byte

Nit: instruction (typo)
Attachment #8541780 - Flags: review?(jdemooij) → review+
Comment on attachment 8541780 [details] [diff] [review]
jump-shrink.patch

Review of attachment 8541780 [details] [diff] [review]:
-----------------------------------------------------------------

We should have a way to enforce an absolute address for jumpWithPatch, or a way to ensure that we will SEGV if we ever try to insert a larger address than what is acceptable by the jump size.
Note that loop backedges are patchable in order to handle interuption callbacks.
You need to log in before you can comment on or make changes to this bug.