Bug 1885489 - Part 5: Add SnapshotIterator::readInt32(). r=iain
[gecko.git] / js / src / jit / x86 / SharedICHelpers-x86.h
blob07d2ae8a6fe67bc2a5c213119ab45d6d0ed35621
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/. */
7 #ifndef jit_x86_SharedICHelpers_x86_h
8 #define jit_x86_SharedICHelpers_x86_h
10 #include "jit/BaselineIC.h"
11 #include "jit/JitFrames.h"
12 #include "jit/MacroAssembler.h"
13 #include "jit/SharedICRegisters.h"
15 namespace js {
16 namespace jit {
18 // Distance from stack top to the top Value inside an IC stub (this is the
19 // return address).
20 static const size_t ICStackValueOffset = sizeof(void*);
22 inline void EmitRestoreTailCallReg(MacroAssembler& masm) {
23 masm.Pop(ICTailCallReg);
26 inline void EmitRepushTailCallReg(MacroAssembler& masm) {
27 masm.Push(ICTailCallReg);
30 inline void EmitCallIC(MacroAssembler& masm, CodeOffset* callOffset) {
31 // The stub pointer must already be in ICStubReg.
32 // Call the stubcode.
33 masm.call(Address(ICStubReg, ICStub::offsetOfStubCode()));
34 *callOffset = CodeOffset(masm.currentOffset());
37 inline void EmitReturnFromIC(MacroAssembler& masm) { masm.ret(); }
39 inline void EmitBaselineLeaveStubFrame(MacroAssembler& masm) {
40 Address stubAddr(FramePointer, BaselineStubFrameLayout::ICStubOffsetFromFP);
41 masm.loadPtr(stubAddr, ICStubReg);
43 masm.mov(FramePointer, StackPointer);
44 masm.Pop(FramePointer);
46 // The return address is on top of the stack, followed by the frame
47 // descriptor. Use a pop instruction to overwrite the frame descriptor
48 // with the return address. Note that pop increments the stack pointer
49 // before computing the address.
50 masm.Pop(Operand(StackPointer, 0));
53 template <typename AddrType>
54 inline void EmitPreBarrier(MacroAssembler& masm, const AddrType& addr,
55 MIRType type) {
56 masm.guardedCallPreBarrier(addr, type);
59 inline void EmitStubGuardFailure(MacroAssembler& masm) {
60 // Load next stub into ICStubReg
61 masm.loadPtr(Address(ICStubReg, ICCacheIRStub::offsetOfNext()), ICStubReg);
63 // Return address is already loaded, just jump to the next stubcode.
64 masm.jmp(Operand(ICStubReg, ICStub::offsetOfStubCode()));
67 } // namespace jit
68 } // namespace js
70 #endif /* jit_x86_SharedICHelpers_x86_h */