tor-browser

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

SharedICHelpers-arm64.h (2737B)


      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_arm64_SharedICHelpers_arm64_h
      8 #define jit_arm64_SharedICHelpers_arm64_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 the
     19 // stack on ARM).
     20 static const size_t ICStackValueOffset = 0;
     21 
     22 inline void EmitRestoreTailCallReg(MacroAssembler& masm) {
     23  // No-op on ARM because link register is always holding the return address.
     24 }
     25 
     26 inline void EmitRepushTailCallReg(MacroAssembler& masm) {
     27  // No-op on ARM because link register is always holding the return address.
     28 }
     29 
     30 inline void EmitCallIC(MacroAssembler& masm, CodeOffset* callOffset) {
     31  // The stub pointer must already be in ICStubReg.
     32  // Load stubcode pointer from the ICStub.
     33  // R2 won't be active when we call ICs, so we can use r0.
     34  static_assert(R2 == ValueOperand(r0));
     35  masm.loadPtr(Address(ICStubReg, ICStub::offsetOfStubCode()), r0);
     36 
     37  // Call the stubcode via a direct branch-and-link.
     38  masm.Blr(x0);
     39  *callOffset = CodeOffset(masm.currentOffset());
     40 }
     41 
     42 inline void EmitReturnFromIC(MacroAssembler& masm) {
     43  masm.abiret();  // Defaults to lr.
     44 }
     45 
     46 inline void EmitBaselineLeaveStubFrame(MacroAssembler& masm) {
     47  vixl::UseScratchRegisterScope temps(&masm.asVIXL());
     48  const ARMRegister scratch64 = temps.AcquireX();
     49 
     50  Address stubAddr(FramePointer, BaselineStubFrameLayout::ICStubOffsetFromFP);
     51  masm.loadPtr(stubAddr, ICStubReg);
     52 
     53  masm.moveToStackPtr(FramePointer);
     54 
     55  // Pop values, discarding the frame descriptor.
     56  masm.pop(FramePointer, ICTailCallReg, scratch64.asUnsized());
     57 
     58  // Stack should remain 16-byte aligned.
     59  masm.checkStackAlignment();
     60 }
     61 
     62 template <typename AddrType>
     63 inline void EmitPreBarrier(MacroAssembler& masm, const AddrType& addr,
     64                           MIRType type) {
     65  // On AArch64, lr is clobbered by guardedCallPreBarrier. Save it first.
     66  masm.push(lr);
     67  masm.guardedCallPreBarrier(addr, type);
     68  masm.pop(lr);
     69 }
     70 
     71 inline void EmitStubGuardFailure(MacroAssembler& masm) {
     72  // Load next stub into ICStubReg.
     73  masm.loadPtr(Address(ICStubReg, ICCacheIRStub::offsetOfNext()), ICStubReg);
     74 
     75  // Return address is already loaded, just jump to the next stubcode.
     76  masm.jump(Address(ICStubReg, ICStub::offsetOfStubCode()));
     77 }
     78 
     79 }  // namespace jit
     80 }  // namespace js
     81 
     82 #endif  // jit_arm64_SharedICHelpers_arm64_h