v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
disasm.h
Go to the documentation of this file.
1// Copyright 2007-2008 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_DIAGNOSTICS_DISASM_H_
6#define V8_DIAGNOSTICS_DISASM_H_
7
8#include "src/base/vector.h"
9
10namespace disasm {
11
12// Interface and default implementation for converting addresses and
13// register-numbers to text. The default implementation is machine
14// specific.
16 public:
17 virtual ~NameConverter() = default;
18 virtual const char* NameOfCPURegister(int reg) const;
19 virtual const char* NameOfByteCPURegister(int reg) const;
20 virtual const char* NameOfXMMRegister(int reg) const;
21 virtual const char* NameOfAddress(uint8_t* addr) const;
22 virtual const char* NameOfConstant(uint8_t* addr) const;
23 virtual const char* NameInCode(uint8_t* addr) const;
24
25 // Given a root-register-relative offset, returns either a name or nullptr if
26 // none is found.
27 // TODO(jgruber,v8:7989): This is a temporary solution until we can preserve
28 // code comments through snapshotting.
29 virtual const char* RootRelativeName(int offset) const { UNREACHABLE(); }
30
31 protected:
33};
34
35// A generic Disassembler interface
37 public:
42
43 // Caller deallocates converter.
49
53
54 // Writes one disassembled instruction into 'buffer' (0-terminated).
55 // Returns the length of the disassembled machine instruction in bytes.
57 uint8_t* instruction);
58
59 // Returns -1 if instruction does not mark the beginning of a constant pool,
60 // or the number of entries in the constant pool beginning here.
61 int ConstantPoolSizeAt(uint8_t* instruction);
62
63 // Write disassembly into specified file 'f' using specified NameConverter
64 // (see constructor).
66 FILE* f, uint8_t* begin, uint8_t* end,
67 UnimplementedOpcodeAction unimplemented_action =
69
70 private:
73
75};
76
77} // namespace disasm
78
79#endif // V8_DIAGNOSTICS_DISASM_H_
static V8_EXPORT_PRIVATE void Disassemble(FILE *f, uint8_t *begin, uint8_t *end, UnimplementedOpcodeAction unimplemented_action=kAbortOnUnimplementedOpcode)
V8_EXPORT_PRIVATE int InstructionDecode(v8::base::Vector< char > buffer, uint8_t *instruction)
int ConstantPoolSizeAt(uint8_t *instruction)
@ kContinueOnUnimplementedOpcode
Definition disasm.h:39
@ kAbortOnUnimplementedOpcode
Definition disasm.h:40
const UnimplementedOpcodeAction unimplemented_opcode_action_
Definition disasm.h:72
DISALLOW_IMPLICIT_CONSTRUCTORS(Disassembler)
Disassembler(const NameConverter &converter, UnimplementedOpcodeAction unimplemented_opcode_action=kAbortOnUnimplementedOpcode)
Definition disasm.h:44
UnimplementedOpcodeAction unimplemented_opcode_action() const
Definition disasm.h:50
const NameConverter & converter_
Definition disasm.h:71
v8::base::EmbeddedVector< char, 128 > tmp_buffer_
Definition disasm.h:32
virtual const char * RootRelativeName(int offset) const
Definition disasm.h:29
virtual ~NameConverter()=default
int end
int32_t offset
LiftoffRegister reg
#define UNREACHABLE()
Definition logging.h:67
#define V8_EXPORT_PRIVATE
Definition macros.h:460