v8  3.11.10(node0.8.26)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
disasm.h
Go to the documentation of this file.
1 // Copyright 2007-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 #ifndef V8_DISASM_H_
29 #define V8_DISASM_H_
30 
31 namespace disasm {
32 
33 typedef unsigned char byte;
34 
35 // Interface and default implementation for converting addresses and
36 // register-numbers to text. The default implementation is machine
37 // specific.
39  public:
40  virtual ~NameConverter() {}
41  virtual const char* NameOfCPURegister(int reg) const;
42  virtual const char* NameOfByteCPURegister(int reg) const;
43  virtual const char* NameOfXMMRegister(int reg) const;
44  virtual const char* NameOfAddress(byte* addr) const;
45  virtual const char* NameOfConstant(byte* addr) const;
46  virtual const char* NameInCode(byte* addr) const;
47 
48  protected:
50 };
51 
52 
53 // A generic Disassembler interface
54 class Disassembler {
55  public:
56  // Caller deallocates converter.
57  explicit Disassembler(const NameConverter& converter);
58 
59  virtual ~Disassembler();
60 
61  // Writes one disassembled instruction into 'buffer' (0-terminated).
62  // Returns the length of the disassembled machine instruction in bytes.
63  int InstructionDecode(v8::internal::Vector<char> buffer, byte* instruction);
64 
65  // Returns -1 if instruction does not mark the beginning of a constant pool,
66  // or the number of entries in the constant pool beginning here.
67  int ConstantPoolSizeAt(byte* instruction);
68 
69  // Write disassembly into specified file 'f' using specified NameConverter
70  // (see constructor).
71  static void Disassemble(FILE* f, byte* begin, byte* end);
72  private:
73  const NameConverter& converter_;
74 
75  DISALLOW_IMPLICIT_CONSTRUCTORS(Disassembler);
76 };
77 
78 } // namespace disasm
79 
80 #endif // V8_DISASM_H_
static void Disassemble(FILE *f, byte *begin, byte *end)
unsigned char byte
Definition: disasm.h:33
Disassembler(const NameConverter &converter)
int ConstantPoolSizeAt(byte *instruction)
virtual const char * NameOfXMMRegister(int reg) const
v8::internal::EmbeddedVector< char, 128 > tmp_buffer_
Definition: disasm.h:49
virtual const char * NameOfConstant(byte *addr) const
virtual const char * NameInCode(byte *addr) const
virtual const char * NameOfByteCPURegister(int reg) const
virtual const char * NameOfCPURegister(int reg) const
int InstructionDecode(v8::internal::Vector< char > buffer, byte *instruction)
virtual const char * NameOfAddress(byte *addr) const
virtual ~NameConverter()
Definition: disasm.h:40