[ia32] Add a root-relative addressing mode

.. and use it for generating faster loads of external references. This
changes the stack check instruction sequence from

mov ecx,0x567651dc  // The address of the stack limit.
cmp esp,[ecx]

to

cmp esp,[ebx+0x3c]

This addressing mode was likely forgotten when we recently added root
register support on ia32.

Bug: chromium:998751,v8:9534
Change-Id: I3521519da1e9d373dfcd83831b3e399e0e9c895b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1781056
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63508}
This commit is contained in:
Jakob Gruber 2019-09-02 15:11:57 +02:00 committed by Commit Bot
parent 6039d7baa2
commit f6fc9d6e3e
3 changed files with 22 additions and 1 deletions

View File

@ -165,6 +165,11 @@ class IA32OperandConverter : public InstructionOperandConverter {
Constant ctant = ToConstant(instr_->InputAt(NextOffset(offset)));
return Operand(ctant.ToInt32(), ctant.rmode());
}
case kMode_Root: {
Register base = kRootRegister;
int32_t disp = InputInt32(NextOffset(offset));
return Operand(base, disp);
}
case kMode_None:
UNREACHABLE();
}

View File

@ -393,7 +393,8 @@ namespace compiler {
V(M2I) /* [ %r2*2 + K] */ \
V(M4I) /* [ %r2*4 + K] */ \
V(M8I) /* [ %r2*8 + K] */ \
V(MI) /* [ K] */
V(MI) /* [ K] */ \
V(Root) /* [%root + K] */
} // namespace compiler
} // namespace internal

View File

@ -152,6 +152,21 @@ class IA32OperandGenerator final : public OperandGenerator {
AddressingMode GetEffectiveAddressMemoryOperand(Node* node,
InstructionOperand inputs[],
size_t* input_count) {
{
LoadMatcher<ExternalReferenceMatcher> m(node);
if (m.index().HasValue() && m.object().HasValue() &&
selector()->CanAddressRelativeToRootsRegister(m.object().Value())) {
ptrdiff_t const delta =
m.index().Value() +
TurboAssemblerBase::RootRegisterOffsetForExternalReference(
selector()->isolate(), m.object().Value());
if (is_int32(delta)) {
inputs[(*input_count)++] = TempImmediate(static_cast<int32_t>(delta));
return kMode_Root;
}
}
}
BaseWithIndexAndDisplacement32Matcher m(node, AddressOption::kAllowAll);
DCHECK(m.matches());
if ((m.displacement() == nullptr || CanBeImmediate(m.displacement()))) {