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

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

Issue 2723213002: DWARF and unwind support for AOT assembly output. (Closed)
Patch Set: . Created 3 years, 9 months 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
OLDNEW
(Empty)
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
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.
4
5 #ifndef RUNTIME_VM_DWARF_H_
6 #define RUNTIME_VM_DWARF_H_
7
8 #include "vm/allocation.h"
9 #include "vm/hash_map.h"
10 #include "vm/object.h"
11 #include "vm/zone.h"
12
13 namespace dart {
14
15 #ifdef DART_PRECOMPILER
16
17 class InliningNode;
18
19 struct ScriptIndexPair {
20 // Typedefs needed for the DirectChainedHashMap template.
21 typedef const Script* Key;
22 typedef intptr_t Value;
23 typedef ScriptIndexPair Pair;
24
25 static Key KeyOf(Pair kv) { return kv.script_; }
26
27 static Value ValueOf(Pair kv) { return kv.index_; }
28
29 static inline intptr_t Hashcode(Key key) {
30 return String::Handle(key->url()).Hash();
31 }
32
33 static inline bool IsKeyEqual(Pair pair, Key key) {
34 return pair.script_->raw() == key->raw();
35 }
36
37 ScriptIndexPair(const Script* s, intptr_t index)
38 : script_(s), index_(index) {}
39
40 ScriptIndexPair() : script_(NULL), index_(-1) {}
41
42 void Print() const;
43
44 const Script* script_;
45 intptr_t index_;
46 };
47
48 typedef DirectChainedHashMap<ScriptIndexPair> ScriptIndexMap;
49
50 struct FunctionIndexPair {
51 // Typedefs needed for the DirectChainedHashMap template.
52 typedef const Function* Key;
53 typedef intptr_t Value;
54 typedef FunctionIndexPair Pair;
55
56 static Key KeyOf(Pair kv) { return kv.function_; }
57
58 static Value ValueOf(Pair kv) { return kv.index_; }
59
60 static inline intptr_t Hashcode(Key key) { return key->token_pos().value(); }
Cutch 2017/03/15 14:54:13 maybe use a better hash code?
61
62 static inline bool IsKeyEqual(Pair pair, Key key) {
63 return pair.function_->raw() == key->raw();
64 }
65
66 FunctionIndexPair(const Function* f, intptr_t index)
67 : function_(f), index_(index) {}
68
69 FunctionIndexPair() : function_(NULL), index_(-1) {}
70
71 void Print() const;
72
73 const Function* function_;
74 intptr_t index_;
75 };
76
77 typedef DirectChainedHashMap<FunctionIndexPair> FunctionIndexMap;
78
79 struct CodeIndexPair {
80 // Typedefs needed for the DirectChainedHashMap template.
81 typedef const Code* Key;
82 typedef intptr_t Value;
83 typedef CodeIndexPair Pair;
84
85 static Key KeyOf(Pair kv) { return kv.code_; }
86
87 static Value ValueOf(Pair kv) { return kv.index_; }
88
89 static inline intptr_t Hashcode(Key key) { return key->PayloadStart(); }
Florian Schneider 2017/03/15 18:15:06 Maybe add a comment that code object don't move.
rmacnak 2017/03/16 17:50:11 Done.
90
91 static inline bool IsKeyEqual(Pair pair, Key key) {
92 return pair.code_->raw() == key->raw();
93 }
94
95 CodeIndexPair(const Code* f, intptr_t index) : code_(f), index_(index) {}
Florian Schneider 2017/03/15 18:15:06 Code* c
rmacnak 2017/03/16 17:50:11 Done.
96
97 CodeIndexPair() : code_(NULL), index_(-1) {}
98
99 void Print() const;
100
101 const Code* code_;
102 intptr_t index_;
103 };
104
105 typedef DirectChainedHashMap<CodeIndexPair> CodeIndexMap;
106
107 class Dwarf : public ZoneAllocated {
108 public:
109 Dwarf(Zone* zone, WriteStream* stream);
110
111 intptr_t AddCode(const Code& code);
112 intptr_t AddFunction(const Function& function);
113 intptr_t AddScript(const Script& script);
114 intptr_t LookupFunction(const Function& function);
115 intptr_t LookupScript(const Script& script);
116
117 void Write() {
118 WriteAbbreviations();
119 WriteCompilationUnit();
120 WriteLines();
121 }
122
123 private:
124 static const intptr_t DW_TAG_compile_unit = 0x11;
125 static const intptr_t DW_TAG_inlined_subroutine = 0x1d;
126 static const intptr_t DW_TAG_subprogram = 0x2e;
127
128 static const intptr_t DW_CHILDREN_no = 0x0;
129 static const intptr_t DW_CHILDREN_yes = 0x1;
130
131 static const intptr_t DW_AT_sibling = 0x1;
132 static const intptr_t DW_AT_name = 0x3;
133 static const intptr_t DW_AT_stmt_list = 0x10;
134 static const intptr_t DW_AT_low_pc = 0x11;
135 static const intptr_t DW_AT_high_pc = 0x12;
136 static const intptr_t DW_AT_comp_dir = 0x1b;
137 static const intptr_t DW_AT_inline = 0x20;
138 static const intptr_t DW_AT_producer = 0x25;
139 static const intptr_t DW_AT_abstract_origin = 0x31;
140 static const intptr_t DW_AT_decl_column = 0x39;
141 static const intptr_t DW_AT_decl_file = 0x3a;
142 static const intptr_t DW_AT_decl_line = 0x3b;
143 static const intptr_t DW_AT_call_column = 0x57;
144 static const intptr_t DW_AT_call_file = 0x58;
145 static const intptr_t DW_AT_call_line = 0x59;
146
147 static const intptr_t DW_FORM_addr = 0x01;
148 static const intptr_t DW_FORM_string = 0x08;
149 static const intptr_t DW_FORM_udata = 0x0f;
150 static const intptr_t DW_FORM_ref4 = 0x13;
151 static const intptr_t DW_FORM_ref_udata = 0x15;
152 static const intptr_t DW_FORM_sec_offset = 0x17;
153
154 static const intptr_t DW_INL_not_inlined = 0x0;
155 static const intptr_t DW_INL_inlined = 0x1;
156
157 static const intptr_t DW_LNS_copy = 0x1;
158 static const intptr_t DW_LNS_advance_pc = 0x2;
159 static const intptr_t DW_LNS_advance_line = 0x3;
160 static const intptr_t DW_LNS_set_file = 0x4;
161
162 static const intptr_t DW_LNE_end_sequence = 0x01;
163 static const intptr_t DW_LNE_set_address = 0x02;
164
165 enum {
166 kCompilationUnit = 1,
167 kAbstractFunction,
168 kConcreteFunction,
169 kInlinedFunction,
170 };
171
172 void Print(const char* format, ...);
173
174 void WriteAbbreviations();
175 void WriteCompilationUnit();
176 void WriteAbstractFunctions();
177 void WriteConcreteFunctions();
178 InliningNode* ExpandInliningTree(const Code& code);
179 void WriteInliningNode(InliningNode* node,
180 intptr_t root_code_index,
181 const Script& parent_script);
182 void WriteLines();
183
184 Zone* const zone_;
185 WriteStream* stream_;
186 ZoneGrowableArray<const Code*> codes_;
187 CodeIndexMap code_to_index_;
188 ZoneGrowableArray<const Function*> functions_;
189 FunctionIndexMap function_to_index_;
190 ZoneGrowableArray<const Script*> scripts_;
191 ScriptIndexMap script_to_index_;
192 intptr_t temp_;
193 };
194
195 #endif // DART_PRECOMPILER
196
197 } // namespace dart
198
199 #endif // RUNTIME_VM_DWARF_H_
OLDNEW
« no previous file with comments | « runtime/vm/datastream.h ('k') | runtime/vm/dwarf.cc » ('j') | runtime/vm/dwarf.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698