| 1 |
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
| 2 |
* vim: set ts=8 sts=2 et sw=2 tw=80: |
| 3 |
* This Source Code Form is subject to the terms of the Mozilla Public |
| 4 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 6 |
|
| 7 |
#ifndef jit_mips_shared_SharedICHelpers_mips_shared_h |
| 8 |
#define jit_mips_shared_SharedICHelpers_mips_shared_h |
| 9 |
|
| 10 |
#include "jit/BaselineIC.h" |
| 11 |
#include "jit/JitFrames.h" |
| 12 |
#include "jit/MacroAssembler.h" |
| 13 |
#include "jit/SharedICRegisters.h" |
| 14 |
|
| 15 |
namespace js { |
| 16 |
namespace jit { |
| 17 |
|
| 18 |
// Distance from sp to the top Value inside an IC stub (no return address on |
| 19 |
// the stack on MIPS). |
| 20 |
static const size_t ICStackValueOffset = 0; |
| 21 |
|
| 22 |
struct BaselineStubFrame { |
| 23 |
uintptr_t savedFrame; |
| 24 |
uintptr_t savedStub; |
| 25 |
uintptr_t returnAddress; |
| 26 |
uintptr_t descriptor; |
| 27 |
}; |
| 28 |
|
| 29 |
inline void EmitRestoreTailCallReg(MacroAssembler& masm) { |
| 30 |
// No-op on MIPS because ra register is always holding the return address. |
| 31 |
} |
| 32 |
|
| 33 |
inline void EmitRepushTailCallReg(MacroAssembler& masm) { |
| 34 |
// No-op on MIPS because ra register is always holding the return address. |
| 35 |
} |
| 36 |
|
| 37 |
inline void EmitCallIC(MacroAssembler& masm, CodeOffset* callOffset) { |
| 38 |
// The stub pointer must already be in ICStubReg. |
| 39 |
// Load stubcode pointer from the ICStub. |
| 40 |
// R2 won't be active when we call ICs, so we can use it as scratch. |
| 41 |
masm.loadPtr(Address(ICStubReg, ICStub::offsetOfStubCode()), R2.scratchReg()); |
| 42 |
|
| 43 |
// Call the stubcode via a direct jump-and-link |
| 44 |
masm.call(R2.scratchReg()); |
| 45 |
*callOffset = CodeOffset(masm.currentOffset()); |
| 46 |
} |
| 47 |
|
| 48 |
inline void EmitReturnFromIC(MacroAssembler& masm) { masm.branch(ra); } |
| 49 |
|
| 50 |
inline void EmitBaselineLeaveStubFrame(MacroAssembler& masm) { |
| 51 |
masm.loadPtr( |
| 52 |
Address(FramePointer, BaselineStubFrameLayout::ICStubOffsetFromFP), |
| 53 |
ICStubReg); |
| 54 |
masm.movePtr(FramePointer, StackPointer); |
| 55 |
masm.Pop(FramePointer); |
| 56 |
|
| 57 |
// Load the return address. |
| 58 |
masm.Pop(ICTailCallReg); |
| 59 |
|
| 60 |
// Discard the frame descriptor. |
| 61 |
{ |
| 62 |
SecondScratchRegisterScope scratch2(masm); |
| 63 |
masm.Pop(scratch2); |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
template <typename AddrType> |
| 68 |
inline void EmitPreBarrier(MacroAssembler& masm, const AddrType& addr, |
| 69 |
MIRType type) { |
| 70 |
// On MIPS, $ra is clobbered by guardedCallPreBarrier. Save it first. |
| 71 |
masm.push(ra); |
| 72 |
masm.guardedCallPreBarrier(addr, type); |
| 73 |
masm.pop(ra); |
| 74 |
} |
| 75 |
|
| 76 |
inline void EmitStubGuardFailure(MacroAssembler& masm) { |
| 77 |
// Load next stub into ICStubReg |
| 78 |
masm.loadPtr(Address(ICStubReg, ICCacheIRStub::offsetOfNext()), ICStubReg); |
| 79 |
|
| 80 |
// Return address is already loaded, just jump to the next stubcode. |
| 81 |
MOZ_ASSERT(ICTailCallReg == ra); |
| 82 |
masm.jump(Address(ICStubReg, ICStub::offsetOfStubCode())); |
| 83 |
} |
| 84 |
|
| 85 |
} // namespace jit |
| 86 |
} // namespace js |
| 87 |
|
| 88 |
#endif /* jit_mips_shared_SharedICHelpers_mips_shared_h */ |