Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: runtime/vm/disassembler.h

Issue 2481873005: clang-format runtime/vm (Closed)
Patch Set: Merge Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/deopt_instructions.cc ('k') | runtime/vm/disassembler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef RUNTIME_VM_DISASSEMBLER_H_ 5 #ifndef RUNTIME_VM_DISASSEMBLER_H_
6 #define RUNTIME_VM_DISASSEMBLER_H_ 6 #define RUNTIME_VM_DISASSEMBLER_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/globals.h" 10 #include "vm/globals.h"
11 #include "vm/log.h" 11 #include "vm/log.h"
12 12
13 namespace dart { 13 namespace dart {
14 14
15 // Froward declaration. 15 // Froward declaration.
16 class MemoryRegion; 16 class MemoryRegion;
17 class JSONArray; 17 class JSONArray;
18 18
19 // Disassembly formatter interface, which consumes the 19 // Disassembly formatter interface, which consumes the
20 // disassembled instructions in any desired form. 20 // disassembled instructions in any desired form.
21 class DisassemblyFormatter { 21 class DisassemblyFormatter {
22 public: 22 public:
23 DisassemblyFormatter() { } 23 DisassemblyFormatter() {}
24 virtual ~DisassemblyFormatter() { } 24 virtual ~DisassemblyFormatter() {}
25 25
26 // Consume the decoded instruction at the given pc. 26 // Consume the decoded instruction at the given pc.
27 virtual void ConsumeInstruction(const Code& code, 27 virtual void ConsumeInstruction(const Code& code,
28 char* hex_buffer, 28 char* hex_buffer,
29 intptr_t hex_size, 29 intptr_t hex_size,
30 char* human_buffer, 30 char* human_buffer,
31 intptr_t human_size, 31 intptr_t human_size,
32 Object* object, 32 Object* object,
33 uword pc) = 0; 33 uword pc) = 0;
34 34
35 // Print a formatted message. 35 // Print a formatted message.
36 virtual void Print(const char* format, ...) = 0; 36 virtual void Print(const char* format, ...) = 0;
37 }; 37 };
38 38
39 39
40 // Basic disassembly formatter that outputs the disassembled instruction 40 // Basic disassembly formatter that outputs the disassembled instruction
41 // to stdout. 41 // to stdout.
42 class DisassembleToStdout : public DisassemblyFormatter { 42 class DisassembleToStdout : public DisassemblyFormatter {
43 public: 43 public:
44 DisassembleToStdout() : DisassemblyFormatter() { } 44 DisassembleToStdout() : DisassemblyFormatter() {}
45 ~DisassembleToStdout() { } 45 ~DisassembleToStdout() {}
46 46
47 virtual void ConsumeInstruction(const Code& code, 47 virtual void ConsumeInstruction(const Code& code,
48 char* hex_buffer, 48 char* hex_buffer,
49 intptr_t hex_size, 49 intptr_t hex_size,
50 char* human_buffer, 50 char* human_buffer,
51 intptr_t human_size, 51 intptr_t human_size,
52 Object* object, 52 Object* object,
53 uword pc); 53 uword pc);
54 54
55 virtual void Print(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); 55 virtual void Print(const char* format, ...) PRINTF_ATTRIBUTE(2, 3);
56 56
57 private: 57 private:
58 DISALLOW_ALLOCATION() 58 DISALLOW_ALLOCATION()
59 DISALLOW_COPY_AND_ASSIGN(DisassembleToStdout); 59 DISALLOW_COPY_AND_ASSIGN(DisassembleToStdout);
60 }; 60 };
61 61
62 62
63 // Disassemble into a JSONStream. 63 // Disassemble into a JSONStream.
64 class DisassembleToJSONStream : public DisassemblyFormatter { 64 class DisassembleToJSONStream : public DisassemblyFormatter {
65 public: 65 public:
66 explicit DisassembleToJSONStream(const JSONArray& jsarr) 66 explicit DisassembleToJSONStream(const JSONArray& jsarr)
67 : DisassemblyFormatter(), jsarr_(jsarr) { } 67 : DisassemblyFormatter(), jsarr_(jsarr) {}
68 ~DisassembleToJSONStream() { } 68 ~DisassembleToJSONStream() {}
69 69
70 virtual void ConsumeInstruction(const Code& code, 70 virtual void ConsumeInstruction(const Code& code,
71 char* hex_buffer, 71 char* hex_buffer,
72 intptr_t hex_size, 72 intptr_t hex_size,
73 char* human_buffer, 73 char* human_buffer,
74 intptr_t human_size, 74 intptr_t human_size,
75 Object* object, 75 Object* object,
76 uword pc); 76 uword pc);
77 77
78 virtual void Print(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); 78 virtual void Print(const char* format, ...) PRINTF_ATTRIBUTE(2, 3);
(...skipping 15 matching lines...) Expand all
94 uword end, 94 uword end,
95 DisassemblyFormatter* formatter, 95 DisassemblyFormatter* formatter,
96 const Code& code); 96 const Code& code);
97 97
98 static void Disassemble(uword start, 98 static void Disassemble(uword start,
99 uword end, 99 uword end,
100 DisassemblyFormatter* formatter) { 100 DisassemblyFormatter* formatter) {
101 Disassemble(start, end, formatter, Code::Handle()); 101 Disassemble(start, end, formatter, Code::Handle());
102 } 102 }
103 103
104 static void Disassemble(uword start, 104 static void Disassemble(uword start, uword end, const Code& code) {
105 uword end,
106 const Code& code) {
107 DisassembleToStdout stdout_formatter; 105 DisassembleToStdout stdout_formatter;
108 LogBlock lb; 106 LogBlock lb;
109 Disassemble(start, end, &stdout_formatter, code); 107 Disassemble(start, end, &stdout_formatter, code);
110 } 108 }
111 109
112 static void Disassemble(uword start, uword end) { 110 static void Disassemble(uword start, uword end) {
113 DisassembleToStdout stdout_formatter; 111 DisassembleToStdout stdout_formatter;
114 LogBlock lb; 112 LogBlock lb;
115 Disassemble(start, end, &stdout_formatter); 113 Disassemble(start, end, &stdout_formatter);
116 } 114 }
117 115
118 // Decodes one instruction. 116 // Decodes one instruction.
119 // Writes a hexadecimal representation into the hex_buffer and a 117 // Writes a hexadecimal representation into the hex_buffer and a
120 // human-readable representation into the human_buffer. 118 // human-readable representation into the human_buffer.
121 // Writes the length of the decoded instruction in bytes in out_instr_len. 119 // Writes the length of the decoded instruction in bytes in out_instr_len.
122 static void DecodeInstruction(char* hex_buffer, intptr_t hex_size, 120 static void DecodeInstruction(char* hex_buffer,
123 char* human_buffer, intptr_t human_size, 121 intptr_t hex_size,
124 int* out_instr_len, const Code& code, 122 char* human_buffer,
125 Object** object, uword pc); 123 intptr_t human_size,
124 int* out_instr_len,
125 const Code& code,
126 Object** object,
127 uword pc);
126 128
127 static void DisassembleCode(const Function& function, bool optimized); 129 static void DisassembleCode(const Function& function, bool optimized);
128 static void DisassembleCodeUnoptimized( 130 static void DisassembleCodeUnoptimized(const Function& function,
129 const Function& function, bool optimized); 131 bool optimized);
130 132
131 private: 133 private:
132 static void DisassembleCodeHelper( 134 static void DisassembleCodeHelper(const char* function_fullname,
133 const char* function_fullname, const Code& code, bool optimized); 135 const Code& code,
136 bool optimized);
134 137
135 static const int kHexadecimalBufferSize = 32; 138 static const int kHexadecimalBufferSize = 32;
136 static const int kUserReadableBufferSize = 256; 139 static const int kUserReadableBufferSize = 256;
137 }; 140 };
138 141
139 } // namespace dart 142 } // namespace dart
140 143
141 #endif // RUNTIME_VM_DISASSEMBLER_H_ 144 #endif // RUNTIME_VM_DISASSEMBLER_H_
OLDNEW
« no previous file with comments | « runtime/vm/deopt_instructions.cc ('k') | runtime/vm/disassembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698