SharedICHelpers-riscv64-inl.h (2649B)
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_riscv64_SharedICHelpers_riscv64_inl_h 8 #define jit_riscv64_SharedICHelpers_riscv64_inl_h 9 10 #include "jit/BaselineFrame.h" 11 #include "jit/SharedICHelpers.h" 12 13 namespace js { 14 namespace jit { 15 16 inline void EmitBaselineTailCallVM(TrampolinePtr target, MacroAssembler& masm, 17 uint32_t argSize) { 18 #ifdef DEBUG 19 Register scratch = R2.scratchReg(); 20 21 // Compute frame size. 22 masm.movePtr(FramePointer, scratch); 23 masm.subPtr(StackPointer, scratch); 24 25 // Store frame size without VMFunction arguments for debug assertions. 26 masm.subPtr(Imm32(argSize), scratch); 27 Address frameSizeAddr(FramePointer, 28 BaselineFrame::reverseOffsetOfDebugFrameSize()); 29 masm.store32(scratch, frameSizeAddr); 30 masm.addPtr(Imm32(argSize), scratch); 31 #endif 32 33 // Push frame descriptor and perform the tail call. 34 masm.push(FrameDescriptor(FrameType::BaselineJS)); 35 36 MOZ_ASSERT(ICTailCallReg == ra); 37 // The return address will be pushed by the VM wrapper, for compatibility 38 // with direct calls. Refer to the top of generateVMWrapper(). 39 // ICTailCallReg (ra) already contains the return address (as we keep 40 // it there through the stub calls). 41 42 masm.jump(target); 43 } 44 45 inline void EmitBaselineCallVM(TrampolinePtr target, MacroAssembler& masm) { 46 masm.push(FrameDescriptor(FrameType::BaselineStub)); 47 masm.call(target); 48 } 49 50 inline void EmitBaselineEnterStubFrame(MacroAssembler& masm, Register scratch) { 51 MOZ_ASSERT(scratch != ICTailCallReg); 52 53 #ifdef DEBUG 54 // Compute frame size. 55 masm.movePtr(FramePointer, scratch); 56 masm.subPtr(StackPointer, scratch); 57 58 Address frameSizeAddr(FramePointer, 59 BaselineFrame::reverseOffsetOfDebugFrameSize()); 60 masm.store32(scratch, frameSizeAddr); 61 #endif 62 63 // Note: when making changes here, don't forget to update 64 // BaselineStubFrame if needed. 65 66 // Push frame descriptor and return address. 67 masm.Push(FrameDescriptor(FrameType::BaselineJS)); 68 masm.Push(ICTailCallReg); 69 70 // Save old frame pointer, stack pointer and stub reg. 71 masm.Push(FramePointer); 72 masm.movePtr(StackPointer, FramePointer); 73 masm.Push(ICStubReg); 74 75 // Stack should remain aligned. 76 masm.assertStackAlignment(sizeof(Value), 0); 77 } 78 79 } // namespace jit 80 } // namespace js 81 82 #endif /* jit_riscv64_SharedICHelpers_riscv64_inl_h */