tor-browser

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

CodeGenerator-mips-shared.h (4445B)


      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_CodeGenerator_mips_shared_h
      8 #define jit_mips_shared_CodeGenerator_mips_shared_h
      9 
     10 #include "jit/shared/CodeGenerator-shared.h"
     11 
     12 namespace js {
     13 namespace jit {
     14 
     15 class CodeGeneratorMIPSShared;
     16 class OutOfLineTableSwitch;
     17 
     18 using OutOfLineWasmTruncateCheck =
     19    OutOfLineWasmTruncateCheckBase<CodeGeneratorMIPSShared>;
     20 
     21 class CodeGeneratorMIPSShared : public CodeGeneratorShared {
     22  friend class MoveResolverMIPS;
     23 
     24 protected:
     25  CodeGeneratorMIPSShared(MIRGenerator* gen, LIRGraph* graph,
     26                          MacroAssembler* masm,
     27                          const wasm::CodeMetadata* wasmCodeMeta);
     28 
     29  NonAssertingLabel deoptLabel_;
     30 
     31  Operand ToOperand(const LAllocation& a);
     32  Operand ToOperand(const LAllocation* a);
     33  Operand ToOperand(const LDefinition* def);
     34 
     35  MoveOperand toMoveOperand(LAllocation a) const;
     36 
     37  template <typename T1, typename T2>
     38  void bailoutCmp32(Assembler::Condition c, T1 lhs, T2 rhs,
     39                    LSnapshot* snapshot) {
     40    Label bail;
     41    masm.branch32(c, lhs, rhs, &bail);
     42    bailoutFrom(&bail, snapshot);
     43  }
     44  template <typename T1, typename T2>
     45  void bailoutTest32(Assembler::Condition c, T1 lhs, T2 rhs,
     46                     LSnapshot* snapshot) {
     47    Label bail;
     48    masm.branchTest32(c, lhs, rhs, &bail);
     49    bailoutFrom(&bail, snapshot);
     50  }
     51  template <typename T1, typename T2>
     52  void bailoutCmpPtr(Assembler::Condition c, T1 lhs, T2 rhs,
     53                     LSnapshot* snapshot) {
     54    Label bail;
     55    masm.branchPtr(c, lhs, rhs, &bail);
     56    bailoutFrom(&bail, snapshot);
     57  }
     58  template <typename T>
     59  void bailoutIfFalseBool(T reg, LSnapshot* snapshot) {
     60    Label bail;
     61    masm.branchTest32(Assembler::Zero, reg, Imm32(0xFF), &bail);
     62    bailoutFrom(&bail, snapshot);
     63  }
     64 
     65  void bailoutFrom(Label* label, LSnapshot* snapshot);
     66  void bailout(LSnapshot* snapshot);
     67 
     68  bool generateOutOfLineCode();
     69 
     70  template <typename T>
     71  void branchToBlock(Register lhs, T rhs, MBasicBlock* mir,
     72                     Assembler::Condition cond) {
     73    masm.ma_b(lhs, rhs, skipTrivialBlocks(mir)->lir()->label(), cond);
     74  }
     75  void branchToBlock(Assembler::FloatFormat fmt, FloatRegister lhs,
     76                     FloatRegister rhs, MBasicBlock* mir,
     77                     Assembler::DoubleCondition cond);
     78 
     79  // Emits a branch that directs control flow to the true block if |cond| is
     80  // true, and the false block if |cond| is false.
     81  template <typename T>
     82  void emitBranch(Register lhs, T rhs, Assembler::Condition cond,
     83                  MBasicBlock* mirTrue, MBasicBlock* mirFalse) {
     84    if (isNextBlock(mirFalse->lir())) {
     85      branchToBlock(lhs, rhs, mirTrue, cond);
     86    } else {
     87      branchToBlock(lhs, rhs, mirFalse, Assembler::InvertCondition(cond));
     88      jumpToBlock(mirTrue);
     89    }
     90  }
     91 
     92  void emitTableSwitchDispatch(MTableSwitch* mir, Register index,
     93                               Register base);
     94 
     95  template <typename T>
     96  void emitWasmLoad(T* ins);
     97  template <typename T>
     98  void emitWasmStore(T* ins);
     99 
    100  void generateInvalidateEpilogue();
    101 
    102  // Generating a result.
    103  template <typename S, typename T>
    104  void atomicBinopToTypedIntArray(AtomicOp op, Scalar::Type arrayType,
    105                                  const S& value, const T& mem,
    106                                  Register flagTemp, Register outTemp,
    107                                  Register valueTemp, Register offsetTemp,
    108                                  Register maskTemp, AnyRegister output);
    109 
    110  // Generating no result.
    111  template <typename S, typename T>
    112  void atomicBinopToTypedIntArray(AtomicOp op, Scalar::Type arrayType,
    113                                  const S& value, const T& mem,
    114                                  Register flagTemp, Register valueTemp,
    115                                  Register offsetTemp, Register maskTemp);
    116 
    117  void emitMulI64(Register lhs, int64_t rhs, Register dest);
    118 
    119 public:
    120  // Out of line visitors.
    121  void visitOutOfLineTableSwitch(OutOfLineTableSwitch* ool);
    122  void visitOutOfLineWasmTruncateCheck(OutOfLineWasmTruncateCheck* ool);
    123 };
    124 
    125 }  // namespace jit
    126 }  // namespace js
    127 
    128 #endif /* jit_mips_shared_CodeGenerator_mips_shared_h */