RVM

Baseline compiler emits RegDisp instructions when the Disp is 0

Details

  • Number of attachments :
    0

Description

In some situations we generate a displacement of 0 in the baseline compiler. For example, if we have 1 local then iload0 becomes "push [ESP+0]" when the operand stack is empty. Encoding this is RegDisp form creates an instruction of
opcode = 0xFF
modrm = 01b || 110b || 100b
(include /6 of the extended part of the opcode)
sib = 00100100b
imm8 = 0
ie. 4 bytes long. If this were RegInd form then the instruction could be:
opcode = 0xFF
modrm = 00b || 110b || 100b
sib = 00100100b
ie. 3 bytes long. We probably don't want to clutter up the assembler with "if (disp == 0) ..." so we should fix the baseline compiler.

Activity

Hide
David Grove added a comment -

off the top of my head (don't have the IA32 instruction manual handy) I think it's pretty likely we do this because the RegInd mode can't be used with ESP as a base register. There are a bunch of funny exceptions about addressing modes using ESP as the base that forced us to do weird things in the assembler.

Show
David Grove added a comment - off the top of my head (don't have the IA32 instruction manual handy) I think it's pretty likely we do this because the RegInd mode can't be used with ESP as a base register. There are a bunch of funny exceptions about addressing modes using ESP as the base that forced us to do weird things in the assembler.
Hide
Ian Rogers added a comment -

I think it is sane (Intel manual in hand) but there's a problem that we don't handle ESP with an SIB byte for RegInd instructions. That should probably be put in as a bug

Show
Ian Rogers added a comment - I think it is sane (Intel manual in hand) but there's a problem that we don't handle ESP with an SIB byte for RegInd instructions. That should probably be put in as a bug
Hide
Ian Rogers added a comment -

I'm wrong, we do handle the SIB byte for ESP properly for indirects.

Show
Ian Rogers added a comment - I'm wrong, we do handle the SIB byte for ESP properly for indirects.
Hide
Ian Rogers added a comment -

Patch in r14002.

Show
Ian Rogers added a comment - Patch in r14002.
Hide
Ian Rogers added a comment -

Performance looks unchanged but code size should be fractionally better. Closing issue.

Show
Ian Rogers added a comment - Performance looks unchanged but code size should be fractionally better. Closing issue.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: