tor-browser

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

SharedICHelpers-loong64-inl.h (2686B)


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