tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

SharedICHelpers-mips-shared.h (2847B)


      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    UseScratchRegisterScope temps(masm);
     63    Register scratch2 = temps.Acquire();
     64    masm.Pop(scratch2);
     65  }
     66 }
     67 
     68 template <typename AddrType>
     69 inline void EmitPreBarrier(MacroAssembler& masm, const AddrType& addr,
     70                           MIRType type) {
     71  // On MIPS, $ra is clobbered by guardedCallPreBarrier. Save it first.
     72  masm.push(ra);
     73  masm.guardedCallPreBarrier(addr, type);
     74  masm.pop(ra);
     75 }
     76 
     77 inline void EmitStubGuardFailure(MacroAssembler& masm) {
     78  // Load next stub into ICStubReg
     79  masm.loadPtr(Address(ICStubReg, ICCacheIRStub::offsetOfNext()), ICStubReg);
     80 
     81  // Return address is already loaded, just jump to the next stubcode.
     82  MOZ_ASSERT(ICTailCallReg == ra);
     83  masm.jump(Address(ICStubReg, ICStub::offsetOfStubCode()));
     84 }
     85 
     86 }  // namespace jit
     87 }  // namespace js
     88 
     89 #endif /* jit_mips_shared_SharedICHelpers_mips_shared_h */