Bug 1763592 part 2 - Use setupAlignedABICall for some ABI calls. r=iain

Also ensure framePushed is set correctly because we rely on that to compute the
static alignment.

Note that callWithABIPre checks correctness by asserting the stack is aligned
to ABIStackAlignment before the call.

Depends on D143152

Differential Revision: https://phabricator.services.mozilla.com/D143153
This commit is contained in:
Jan de Mooij 2022-04-09 11:35:51 +00:00
Родитель 23bbb257ed
Коммит f2f731cebd
1 изменённых файлов: 23 добавлений и 19 удалений

Просмотреть файл

@ -4138,12 +4138,12 @@ void CodeGenerator::visitMegamorphicLoadSlot(LMegamorphicLoadSlot* lir) {
Label bail; Label bail;
masm.branchIfNonNativeObj(obj, temp0, &bail); masm.branchIfNonNativeObj(obj, temp0, &bail);
masm.pushValue(UndefinedValue()); masm.Push(UndefinedValue());
masm.moveStackPtrTo(temp2); masm.moveStackPtrTo(temp2);
using Fn = using Fn =
bool (*)(JSContext * cx, JSObject * obj, PropertyName * name, Value * vp); bool (*)(JSContext * cx, JSObject * obj, PropertyName * name, Value * vp);
masm.setupUnalignedABICall(temp0); masm.setupAlignedABICall();
masm.loadJSContext(temp0); masm.loadJSContext(temp0);
masm.passABIArg(temp0); masm.passABIArg(temp0);
masm.passABIArg(obj); masm.passABIArg(obj);
@ -4154,7 +4154,7 @@ void CodeGenerator::visitMegamorphicLoadSlot(LMegamorphicLoadSlot* lir) {
masm.callWithABI<Fn, GetNativeDataPropertyPure>(); masm.callWithABI<Fn, GetNativeDataPropertyPure>();
MOZ_ASSERT(!output.aliases(ReturnReg)); MOZ_ASSERT(!output.aliases(ReturnReg));
masm.popValue(output); masm.Pop(output);
masm.branchIfFalseBool(ReturnReg, &bail); masm.branchIfFalseBool(ReturnReg, &bail);
@ -4173,12 +4173,12 @@ void CodeGenerator::visitMegamorphicLoadSlotByValue(
masm.branchIfNonNativeObj(obj, temp0, &bail); masm.branchIfNonNativeObj(obj, temp0, &bail);
// idVal will be in vp[0], result will be stored in vp[1]. // idVal will be in vp[0], result will be stored in vp[1].
masm.subFromStackPtr(Imm32(sizeof(Value))); masm.reserveStack(sizeof(Value));
masm.pushValue(idVal); masm.Push(idVal);
masm.moveStackPtrTo(temp0); masm.moveStackPtrTo(temp0);
using Fn = bool (*)(JSContext * cx, JSObject * obj, Value * vp); using Fn = bool (*)(JSContext * cx, JSObject * obj, Value * vp);
masm.setupUnalignedABICall(temp1); masm.setupAlignedABICall();
masm.loadJSContext(temp1); masm.loadJSContext(temp1);
masm.passABIArg(temp1); masm.passABIArg(temp1);
masm.passABIArg(obj); masm.passABIArg(obj);
@ -4187,15 +4187,17 @@ void CodeGenerator::visitMegamorphicLoadSlotByValue(
MOZ_ASSERT(!idVal.aliases(temp0)); MOZ_ASSERT(!idVal.aliases(temp0));
masm.mov(ReturnReg, temp0); masm.mov(ReturnReg, temp0);
masm.popValue(idVal); masm.Pop(idVal);
uint32_t framePushed = masm.framePushed();
Label ok; Label ok;
masm.branchIfTrueBool(temp0, &ok); masm.branchIfTrueBool(temp0, &ok);
masm.addToStackPtr(Imm32(sizeof(Value))); // Discard result Value. masm.freeStack(sizeof(Value)); // Discard result Value.
masm.jump(&bail); masm.jump(&bail);
masm.bind(&ok); masm.bind(&ok);
masm.popValue(output); masm.setFramePushed(framePushed);
masm.Pop(output);
bailoutFrom(&bail, lir->snapshot()); bailoutFrom(&bail, lir->snapshot());
} }
@ -4207,12 +4209,12 @@ void CodeGenerator::visitMegamorphicStoreSlot(LMegamorphicStoreSlot* lir) {
Register temp1 = ToRegister(lir->temp1()); Register temp1 = ToRegister(lir->temp1());
Register temp2 = ToRegister(lir->temp2()); Register temp2 = ToRegister(lir->temp2());
masm.pushValue(rhs); masm.Push(rhs);
masm.moveStackPtrTo(temp0); masm.moveStackPtrTo(temp0);
using Fn = bool (*)(JSContext * cx, JSObject * obj, PropertyName * name, using Fn = bool (*)(JSContext * cx, JSObject * obj, PropertyName * name,
Value * val); Value * val);
masm.setupUnalignedABICall(temp1); masm.setupAlignedABICall();
masm.loadJSContext(temp1); masm.loadJSContext(temp1);
masm.passABIArg(temp1); masm.passABIArg(temp1);
masm.passABIArg(obj); masm.passABIArg(obj);
@ -4223,7 +4225,7 @@ void CodeGenerator::visitMegamorphicStoreSlot(LMegamorphicStoreSlot* lir) {
MOZ_ASSERT(!rhs.aliases(temp0)); MOZ_ASSERT(!rhs.aliases(temp0));
masm.mov(ReturnReg, temp0); masm.mov(ReturnReg, temp0);
masm.popValue(rhs); masm.Pop(rhs);
Label bail; Label bail;
masm.branchIfFalseBool(temp0, &bail); masm.branchIfFalseBool(temp0, &bail);
@ -4238,12 +4240,12 @@ void CodeGenerator::visitMegamorphicHasProp(LMegamorphicHasProp* lir) {
Register output = ToRegister(lir->output()); Register output = ToRegister(lir->output());
// idVal will be in vp[0], result will be stored in vp[1]. // idVal will be in vp[0], result will be stored in vp[1].
masm.subFromStackPtr(Imm32(sizeof(Value))); masm.reserveStack(sizeof(Value));
masm.pushValue(idVal); masm.Push(idVal);
masm.moveStackPtrTo(temp0); masm.moveStackPtrTo(temp0);
using Fn = bool (*)(JSContext * cx, JSObject * obj, Value * vp); using Fn = bool (*)(JSContext * cx, JSObject * obj, Value * vp);
masm.setupUnalignedABICall(temp1); masm.setupAlignedABICall();
masm.loadJSContext(temp1); masm.loadJSContext(temp1);
masm.passABIArg(temp1); masm.passABIArg(temp1);
masm.passABIArg(obj); masm.passABIArg(obj);
@ -4256,16 +4258,18 @@ void CodeGenerator::visitMegamorphicHasProp(LMegamorphicHasProp* lir) {
MOZ_ASSERT(!idVal.aliases(temp0)); MOZ_ASSERT(!idVal.aliases(temp0));
masm.mov(ReturnReg, temp0); masm.mov(ReturnReg, temp0);
masm.popValue(idVal); masm.Pop(idVal);
uint32_t framePushed = masm.framePushed();
Label bail, ok; Label bail, ok;
masm.branchIfTrueBool(temp0, &ok); masm.branchIfTrueBool(temp0, &ok);
masm.addToStackPtr(Imm32(sizeof(Value))); // Discard result Value. masm.freeStack(sizeof(Value)); // Discard result Value.
masm.jump(&bail); masm.jump(&bail);
masm.bind(&ok); masm.bind(&ok);
masm.setFramePushed(framePushed);
masm.unboxBoolean(Address(masm.getStackPointer(), 0), output); masm.unboxBoolean(Address(masm.getStackPointer(), 0), output);
masm.addToStackPtr(Imm32(sizeof(Value))); masm.freeStack(sizeof(Value));
bailoutFrom(&bail, lir->snapshot()); bailoutFrom(&bail, lir->snapshot());
} }
@ -5039,7 +5043,7 @@ void CodeGenerator::visitCallNative(LCallNative* call) {
} }
// Construct and execute call. // Construct and execute call.
masm.setupUnalignedABICall(tempReg); masm.setupAlignedABICall();
masm.passABIArg(argContextReg); masm.passABIArg(argContextReg);
masm.passABIArg(argUintNReg); masm.passABIArg(argUintNReg);
masm.passABIArg(argVpReg); masm.passABIArg(argVpReg);