tor-browser

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

Disasm-riscv64.h (2264B)


      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 */
      4 // Copyright 2007-2008 the V8 project authors. All rights reserved.
      5 // Use of this source code is governed by a BSD-style license that can be
      6 // found in the LICENSE file.
      7 
      8 #ifndef jit_riscv64_disasm_Disasm_riscv64_h
      9 #define jit_riscv64_disasm_Disasm_riscv64_h
     10 
     11 #include <stdio.h>
     12 
     13 #include "jit/riscv64/constant/Constant-riscv64.h"
     14 #include "jit/riscv64/constant/util-riscv64.h"
     15 namespace js {
     16 namespace jit {
     17 namespace disasm {
     18 
     19 typedef unsigned char byte;
     20 
     21 // Interface and default implementation for converting addresses and
     22 // register-numbers to text.  The default implementation is machine
     23 // specific.
     24 class NameConverter {
     25 public:
     26  virtual ~NameConverter() {}
     27  virtual const char* NameOfCPURegister(int reg) const;
     28  virtual const char* NameOfByteCPURegister(int reg) const;
     29  virtual const char* NameOfXMMRegister(int reg) const;
     30  virtual const char* NameOfAddress(byte* addr) const;
     31  virtual const char* NameOfConstant(byte* addr) const;
     32  virtual const char* NameInCode(byte* addr) const;
     33 
     34 protected:
     35  EmbeddedVector<char, 128> tmp_buffer_;
     36 };
     37 
     38 // A generic Disassembler interface
     39 class Disassembler {
     40 public:
     41  // Caller deallocates converter.
     42  explicit Disassembler(const NameConverter& converter);
     43 
     44  virtual ~Disassembler();
     45 
     46  // Writes one disassembled instruction into 'buffer' (0-terminated).
     47  // Returns the length of the disassembled machine instruction in bytes.
     48  int InstructionDecode(V8Vector<char> buffer, uint8_t* instruction);
     49 
     50  // Returns -1 if instruction does not mark the beginning of a constant pool,
     51  // or the number of entries in the constant pool beginning here.
     52  int ConstantPoolSizeAt(byte* instruction);
     53 
     54  // Write disassembly into specified file 'f' using specified NameConverter
     55  // (see constructor).
     56  static void Disassemble(FILE* f, uint8_t* begin, uint8_t* end);
     57 
     58 private:
     59  const NameConverter& converter_;
     60 
     61  // Disallow implicit constructors.
     62  Disassembler() = delete;
     63  Disassembler(const Disassembler&) = delete;
     64  void operator=(const Disassembler&) = delete;
     65 };
     66 
     67 }  // namespace disasm
     68 }  // namespace jit
     69 }  // namespace js
     70 
     71 #endif  // jit_riscv64_disasm_Disasm_riscv64_h