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

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

Issue 2670843006: Encode inlining information in CodeSourceMap and remove inlining interval arrays. (Closed)
Patch Set: . Created 3 years, 10 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
« no previous file with comments | « runtime/vm/clustered_snapshot.cc ('k') | runtime/vm/code_descriptors.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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_CODE_DESCRIPTORS_H_ 5 #ifndef RUNTIME_VM_CODE_DESCRIPTORS_H_
6 #define RUNTIME_VM_CODE_DESCRIPTORS_H_ 6 #define RUNTIME_VM_CODE_DESCRIPTORS_H_
7 7
8 #include "vm/ast.h" 8 #include "vm/ast.h"
9 #include "vm/code_generator.h" 9 #include "vm/code_generator.h"
10 #include "vm/globals.h" 10 #include "vm/globals.h"
(...skipping 24 matching lines...) Expand all
35 GrowableArray<uint8_t> encoded_data_; 35 GrowableArray<uint8_t> encoded_data_;
36 36
37 intptr_t prev_pc_offset; 37 intptr_t prev_pc_offset;
38 intptr_t prev_deopt_id; 38 intptr_t prev_deopt_id;
39 intptr_t prev_token_pos; 39 intptr_t prev_token_pos;
40 40
41 DISALLOW_COPY_AND_ASSIGN(DescriptorList); 41 DISALLOW_COPY_AND_ASSIGN(DescriptorList);
42 }; 42 };
43 43
44 44
45 class CodeSourceMapBuilder : public ZoneAllocated {
46 public:
47 explicit CodeSourceMapBuilder(intptr_t initial_capacity = 64)
48 : encoded_data_(initial_capacity), prev_pc_offset(0), prev_token_pos(0) {}
49
50 ~CodeSourceMapBuilder() {}
51
52 void AddEntry(intptr_t pc_offset, TokenPosition token_pos);
53
54 RawCodeSourceMap* Finalize();
55
56 private:
57 GrowableArray<uint8_t> encoded_data_;
58
59 intptr_t prev_pc_offset;
60 intptr_t prev_token_pos;
61
62 DISALLOW_COPY_AND_ASSIGN(CodeSourceMapBuilder);
63 };
64
65
66 class StackMapTableBuilder : public ZoneAllocated { 45 class StackMapTableBuilder : public ZoneAllocated {
67 public: 46 public:
68 StackMapTableBuilder() 47 StackMapTableBuilder()
69 : stack_map_(StackMap::ZoneHandle()), 48 : stack_map_(StackMap::ZoneHandle()),
70 list_(GrowableObjectArray::ZoneHandle( 49 list_(GrowableObjectArray::ZoneHandle(
71 GrowableObjectArray::New(Heap::kOld))) {} 50 GrowableObjectArray::New(Heap::kOld))) {}
72 ~StackMapTableBuilder() {} 51 ~StackMapTableBuilder() {}
73 52
74 void AddEntry(intptr_t pc_offset, 53 void AddEntry(intptr_t pc_offset,
75 BitmapBuilder* bitmap, 54 BitmapBuilder* bitmap,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 return false; 131 return false;
153 } 132 }
154 133
155 RawExceptionHandlers* FinalizeExceptionHandlers(uword entry_point) const; 134 RawExceptionHandlers* FinalizeExceptionHandlers(uword entry_point) const;
156 135
157 private: 136 private:
158 GrowableArray<struct HandlerDesc> list_; 137 GrowableArray<struct HandlerDesc> list_;
159 DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerList); 138 DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerList);
160 }; 139 };
161 140
141
142 class CodeSourceMapBuilder : public ZoneAllocated {
143 public:
144 CodeSourceMapBuilder(
145 const GrowableArray<intptr_t>& caller_inline_id,
146 const GrowableArray<TokenPosition>& inline_id_to_token_pos,
147 const GrowableArray<const Function*>& inline_id_to_function);
148
149 static const TokenPosition kInitialPosition;
Cutch 2017/02/07 18:27:04 Maybe comment that this is the seed token position
rmacnak 2017/02/07 20:50:45 Done.
150 static const uint8_t kChangePosition = 0;
151 static const uint8_t kAdvancePC = 1;
152 static const uint8_t kPushFunction = 2;
153 static const uint8_t kPopFunction = 3;
154
155 void StartInliningInterval(int32_t pc_offset, intptr_t inline_id);
156 void BeginCodeSourceRange(int32_t pc_offset);
157 void EndCodeSourceRange(int32_t pc_offset, TokenPosition pos);
158
159 RawArray* InliningIdToFunction();
160 RawCodeSourceMap* Finalize();
161
162 private:
163 void EmitPosition(TokenPosition pos) {
164 FlushPeephole();
165 stream_.Write<uint8_t>(kChangePosition);
166 stream_.Write<int32_t>(static_cast<int32_t>(pos.value()));
167 }
168 void EmitAdvancePC(int32_t distance) { advance_pc_peephole_ += distance; }
169 void FlushPeephole() {
170 if (advance_pc_peephole_ != 0) {
171 stream_.Write<uint8_t>(kAdvancePC);
172 stream_.Write<int32_t>(advance_pc_peephole_);
173 advance_pc_peephole_ = 0;
174 }
175 }
176 void EmitPush(intptr_t inline_id) {
177 FlushPeephole();
178 stream_.Write<uint8_t>(kPushFunction);
179 stream_.Write<int32_t>(inline_id);
180 }
181 void EmitPop() {
182 FlushPeephole();
183 stream_.Write<uint8_t>(kPopFunction);
184 }
185
186 bool IsOnStack(intptr_t inline_id) {
187 for (intptr_t i = 0; i < inline_id_stack_.length(); i++) {
188 if (inline_id_stack_[i] == inline_id) {
189 return true;
190 }
191 }
192 return false;
193 }
194
195 intptr_t pc_offset_;
196 intptr_t advance_pc_peephole_;
197 GrowableArray<intptr_t> inline_id_stack_;
198 GrowableArray<TokenPosition> token_pos_stack_;
199
200 const GrowableArray<intptr_t>& caller_inline_id_;
201 const GrowableArray<TokenPosition>& inline_id_to_token_pos_;
202 const GrowableArray<const Function*>& inline_id_to_function_;
203
204 uint8_t* buffer_;
205 WriteStream stream_;
206
207 DISALLOW_COPY_AND_ASSIGN(CodeSourceMapBuilder);
208 };
209
210
211 class CodeSourceMapReader : public ValueObject {
212 public:
213 CodeSourceMapReader(const CodeSourceMap& map,
214 const Array& functions,
215 const Function& root)
216 : map_(map), functions_(functions), root_(root) {}
217
218 void GetInlinedFunctionsAt(int32_t pc_offset,
219 GrowableArray<const Function*>* function_stack,
220 GrowableArray<TokenPosition>* token_positions);
221 NOT_IN_PRODUCT(void PrintJSONInlineIntervals(JSONObject* jsobj));
222 void DumpInlineIntervals(uword start);
223 void DumpSourcePositions(uword start);
224
225 private:
226 const CodeSourceMap& map_;
227 const Array& functions_;
228 const Function& root_;
229
230 DISALLOW_COPY_AND_ASSIGN(CodeSourceMapReader);
231 };
232
162 } // namespace dart 233 } // namespace dart
163 234
164 #endif // RUNTIME_VM_CODE_DESCRIPTORS_H_ 235 #endif // RUNTIME_VM_CODE_DESCRIPTORS_H_
OLDNEW
« no previous file with comments | « runtime/vm/clustered_snapshot.cc ('k') | runtime/vm/code_descriptors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698