Closed Bug 1070985 Opened 10 years ago Closed 10 years ago

IonMonkey x64: add some move instructions with a constant address operand, and fix the formatters to emit REX prefixes.

Categories

(Core :: JavaScript Engine: JIT, defect)

x86_64
All
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla35

People

(Reporter: dougc, Assigned: dougc)

Details

Attachments

(1 file, 1 obsolete file)

The x64 supports an immediate 32 bit constant in the addressing mode. There is already some support for move instructions with 32 bit constant operand addresses but these are only enabled on the x86 and the formatters for these did not set the REX prefix.

I would at least like to see the formatters fixed as I use these instructions in some experimental code and don't want other developers to waste time tracking down the subtle bugs that occur when the REX prefixes are not emitted - bugs show up under register pressure.
Comment on attachment 8493071 [details] [diff] [review]
Add some move instructions with a constant address operand, and fix the formatters to emit REX prefixes.

This patch enables a number of instruction for the x64 that were only compiled for the x86. These are all supported on the x64, but perhaps were disabled because they had not immediate use. When enabled for the x64 there were problems in the formatters due to missing REX prefixes.

I would at least like to get the REX prefixes fixed, but am open to not enabling the unused instructions for the x64 in which case I'll split the patch?

I use the enabled instruction in some experimental code.
Attachment #8493071 - Flags: review?(nicolas.b.pierron)
Comment on attachment 8493071 [details] [diff] [review]
Add some move instructions with a constant address operand, and fix the formatters to emit REX prefixes.

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

::: js/src/jit/shared/BaseAssembler-x86-shared.h
@@ +4388,5 @@
> +#ifdef JS_CODEGEN_X86
> +            MOZ_ASSERT(!byteRegRequiresRex(reg));
> +#endif
> +            m_buffer.ensureSpace(maxInstructionSize);
> +            emitRexIf(byteRegRequiresRex(reg), reg, 0, 0);

nit: Use emitRexIfNeeded, and move the above assertion into emitRexIfNeeded, as well as doing it for all registers.
Attachment #8493071 - Flags: review?(nicolas.b.pierron) → review+
(In reply to Nicolas B. Pierron [:nbp] from comment #3)
> Comment on attachment 8493071 [details] [diff] [review]
> Add some move instructions with a constant address operand, and fix the
> formatters to emit REX prefixes.
> 
> Review of attachment 8493071 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: js/src/jit/shared/BaseAssembler-x86-shared.h
> @@ +4388,5 @@
> > +#ifdef JS_CODEGEN_X86
> > +            MOZ_ASSERT(!byteRegRequiresRex(reg));
> > +#endif
> > +            m_buffer.ensureSpace(maxInstructionSize);
> > +            emitRexIf(byteRegRequiresRex(reg), reg, 0, 0);
> 
> nit: Use emitRexIfNeeded, and move the above assertion into emitRexIfNeeded,
> as well as doing it for all registers.

Thank you for the quick review. emitRexIfNeeded is used for word sized operands. In this case the 'reg' is a byte sized operand so it needs to use byteRegRequiresRex, see the comments for emitRexIf. It's because there are ah, and al, etc for byte sized operands, but only eax or rax for large sized operands. Thus the above code looks correct as-is, and can it be left as-is?
Flags: needinfo?(nicolas.b.pierron)
(In reply to Douglas Crosher [:dougc] from comment #4)
> (In reply to Nicolas B. Pierron [:nbp] from comment #3)
> > Comment on attachment 8493071 [details] [diff] [review]
> > Add some move instructions with a constant address operand, and fix the
> > formatters to emit REX prefixes.
> > 
> > Review of attachment 8493071 [details] [diff] [review]:
> > -----------------------------------------------------------------
> > 
> > ::: js/src/jit/shared/BaseAssembler-x86-shared.h
> > @@ +4388,5 @@
> > > +#ifdef JS_CODEGEN_X86
> > > +            MOZ_ASSERT(!byteRegRequiresRex(reg));
> > > +#endif
> > > +            m_buffer.ensureSpace(maxInstructionSize);
> > > +            emitRexIf(byteRegRequiresRex(reg), reg, 0, 0);
> > 
> > nit: Use emitRexIfNeeded, and move the above assertion into emitRexIfNeeded,
> > as well as doing it for all registers.
> 
> Thank you for the quick review. emitRexIfNeeded is used for word sized
> operands. In this case the 'reg' is a byte sized operand so it needs to use
> byteRegRequiresRex, see the comments for emitRexIf. It's because there are
> ah, and al, etc for byte sized operands, but only eax or rax for large sized
> operands. Thus the above code looks correct as-is, and can it be left as-is?

Indeed, I guess I confused byteRegRequiresRex with regRequiresRex.  So, yes
.
Flags: needinfo?(nicolas.b.pierron)
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/6f6b6ba01341
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla35
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: