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

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

Issue 2972343002: [kernel] Insert kernel bodies into VM heap (Closed)
Patch Set: Review comments Created 3 years, 4 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/kernel_binary.h ('k') | runtime/vm/kernel_binary_flowgraph.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) 2017, the Dart project authors. Please see the AUTHORS file 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 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_KERNEL_BINARY_FLOWGRAPH_H_ 5 #ifndef RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_
6 #define RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_ 6 #define RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_
7 7
8 #if !defined(DART_PRECOMPILED_RUNTIME) 8 #if !defined(DART_PRECOMPILED_RUNTIME)
9 9
10 #include <map> 10 #include <map>
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 private: 44 private:
45 // Can build a malformed type. 45 // Can build a malformed type.
46 void BuildTypeInternal(); 46 void BuildTypeInternal();
47 void BuildInterfaceType(bool simple); 47 void BuildInterfaceType(bool simple);
48 void BuildFunctionType(bool simple); 48 void BuildFunctionType(bool simple);
49 void BuildTypeParameterType(); 49 void BuildTypeParameterType();
50 50
51 class TypeParameterScope { 51 class TypeParameterScope {
52 public: 52 public:
53 TypeParameterScope(StreamingDartTypeTranslator* translator, 53 TypeParameterScope(StreamingDartTypeTranslator* translator,
54 intptr_t parameters_offset, 54 intptr_t parameter_count)
55 intptr_t parameters_count) 55 : parameter_count_(parameter_count),
56 : parameters_offset_(parameters_offset),
57 parameters_count_(parameters_count),
58 outer_(translator->type_parameter_scope_), 56 outer_(translator->type_parameter_scope_),
59 translator_(translator) { 57 translator_(translator) {
60 outer_parameter_count_ = 0; 58 outer_parameter_count_ = 0;
61 if (outer_ != NULL) { 59 if (outer_ != NULL) {
62 outer_parameter_count_ = 60 outer_parameter_count_ =
63 outer_->outer_parameter_count_ + outer_->parameters_count_; 61 outer_->outer_parameter_count_ + outer_->parameter_count_;
64 } 62 }
65 translator_->type_parameter_scope_ = this; 63 translator_->type_parameter_scope_ = this;
66 } 64 }
67 ~TypeParameterScope() { translator_->type_parameter_scope_ = outer_; } 65 ~TypeParameterScope() { translator_->type_parameter_scope_ = outer_; }
68 66
69 TypeParameterScope* outer() const { return outer_; } 67 TypeParameterScope* outer() const { return outer_; }
70 intptr_t parameters_offset() const { return parameters_offset_; } 68 intptr_t parameter_count() const { return parameter_count_; }
71 intptr_t parameters_count() const { return parameters_count_; }
72 intptr_t outer_parameter_count() const { return outer_parameter_count_; } 69 intptr_t outer_parameter_count() const { return outer_parameter_count_; }
73 70
74 private: 71 private:
75 intptr_t parameters_offset_; 72 intptr_t parameter_count_;
76 intptr_t parameters_count_;
77 intptr_t outer_parameter_count_; 73 intptr_t outer_parameter_count_;
78 TypeParameterScope* outer_; 74 TypeParameterScope* outer_;
79 StreamingDartTypeTranslator* translator_; 75 StreamingDartTypeTranslator* translator_;
80 }; 76 };
81 77
82 intptr_t FindTypeParameterIndex(intptr_t parameters_offset,
83 intptr_t parameters_count,
84 intptr_t look_for);
85
86 StreamingFlowGraphBuilder* builder_; 78 StreamingFlowGraphBuilder* builder_;
87 TranslationHelper& translation_helper_; 79 TranslationHelper& translation_helper_;
88 ActiveClass* active_class_; 80 ActiveClass* active_class_;
89 TypeParameterScope* type_parameter_scope_; 81 TypeParameterScope* type_parameter_scope_;
90 Zone* zone_; 82 Zone* zone_;
91 AbstractType& result_; 83 AbstractType& result_;
92 bool finalize_; 84 bool finalize_;
93 85
94 friend class StreamingScopeBuilder; 86 friend class StreamingScopeBuilder;
95 friend class KernelReader; 87 friend class KernelReader;
96 }; 88 };
97 89
98 class StreamingScopeBuilder { 90 class StreamingScopeBuilder {
99 public: 91 public:
100 StreamingScopeBuilder(ParsedFunction* parsed_function, 92 StreamingScopeBuilder(ParsedFunction* parsed_function,
101 intptr_t kernel_offset, 93 intptr_t relative_kernel_offset,
102 const uint8_t* buffer, 94 const TypedData& data);
103 intptr_t buffer_length);
104 95
105 virtual ~StreamingScopeBuilder(); 96 virtual ~StreamingScopeBuilder();
106 97
107 ScopeBuildingResult* BuildScopes(); 98 ScopeBuildingResult* BuildScopes();
108 99
109 private: 100 private:
110 void VisitField(); 101 void VisitField();
111 102
112 void VisitProcedure(); 103 void VisitProcedure();
113 104
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 intptr_t nesting_depth); 142 intptr_t nesting_depth);
152 143
153 void AddTryVariables(); 144 void AddTryVariables();
154 void AddCatchVariables(); 145 void AddCatchVariables();
155 void AddIteratorVariable(); 146 void AddIteratorVariable();
156 void AddSwitchVariable(); 147 void AddSwitchVariable();
157 148
158 // Record an assignment or reference to a variable. If the occurrence is 149 // Record an assignment or reference to a variable. If the occurrence is
159 // in a nested function, ensure that the variable is handled properly as a 150 // in a nested function, ensure that the variable is handled properly as a
160 // captured variable. 151 // captured variable.
161 void LookupVariable(intptr_t declaration_binary_offest); 152 void LookupVariable(intptr_t declaration_binary_offset);
162 153
163 const dart::String& GenerateName(const char* prefix, intptr_t suffix); 154 const dart::String& GenerateName(const char* prefix, intptr_t suffix);
164 155
165 void HandleSpecialLoad(LocalVariable** variable, const dart::String& symbol); 156 void HandleSpecialLoad(LocalVariable** variable, const dart::String& symbol);
166 void LookupCapturedVariableByName(LocalVariable** variable, 157 void LookupCapturedVariableByName(LocalVariable** variable,
167 const dart::String& name); 158 const dart::String& name);
168 159
169 struct DepthState { 160 struct DepthState {
170 explicit DepthState(intptr_t function) 161 explicit DepthState(intptr_t function)
171 : loop_(0), 162 : loop_(0),
172 function_(function), 163 function_(function),
173 try_(0), 164 try_(0),
174 catch_(0), 165 catch_(0),
175 finally_(0), 166 finally_(0),
176 for_in_(0) {} 167 for_in_(0) {}
177 168
178 intptr_t loop_; 169 intptr_t loop_;
179 intptr_t function_; 170 intptr_t function_;
180 intptr_t try_; 171 intptr_t try_;
181 intptr_t catch_; 172 intptr_t catch_;
182 intptr_t finally_; 173 intptr_t finally_;
183 intptr_t for_in_; 174 intptr_t for_in_;
184 }; 175 };
185 176
186 ScopeBuildingResult* result_; 177 ScopeBuildingResult* result_;
187 ParsedFunction* parsed_function_; 178 ParsedFunction* parsed_function_;
188 intptr_t kernel_offset_; 179 intptr_t relative_kernel_offset_;
189 180
190 ActiveClass active_class_; 181 ActiveClass active_class_;
191 182
192 TranslationHelper translation_helper_; 183 TranslationHelper translation_helper_;
193 Zone* zone_; 184 Zone* zone_;
194 185
195 FunctionNode::AsyncMarker current_function_async_marker_; 186 FunctionNode::AsyncMarker current_function_async_marker_;
196 LocalScope* current_function_scope_; 187 LocalScope* current_function_scope_;
197 LocalScope* scope_; 188 LocalScope* scope_;
198 DepthState depth_; 189 DepthState depth_;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 290
300 Script& script_; 291 Script& script_;
301 Instance& result_; 292 Instance& result_;
302 }; 293 };
303 294
304 class FunctionNodeHelper; 295 class FunctionNodeHelper;
305 296
306 class StreamingFlowGraphBuilder { 297 class StreamingFlowGraphBuilder {
307 public: 298 public:
308 StreamingFlowGraphBuilder(FlowGraphBuilder* flow_graph_builder, 299 StreamingFlowGraphBuilder(FlowGraphBuilder* flow_graph_builder,
309 const uint8_t* buffer, 300 intptr_t relative_kernel_offset,
310 intptr_t buffer_length) 301 const TypedData& data)
311 : flow_graph_builder_(flow_graph_builder), 302 : flow_graph_builder_(flow_graph_builder),
312 translation_helper_(flow_graph_builder->translation_helper_), 303 translation_helper_(flow_graph_builder->translation_helper_),
313 zone_(flow_graph_builder->zone_), 304 zone_(flow_graph_builder->zone_),
314 reader_(new Reader(buffer, buffer_length)), 305 reader_(new Reader(data)),
315 constant_evaluator_(this), 306 constant_evaluator_(this),
316 type_translator_(this, /* finalize= */ true), 307 type_translator_(this, /* finalize= */ true),
308 relative_kernel_offset_(relative_kernel_offset),
317 current_script_id_(-1), 309 current_script_id_(-1),
318 record_for_script_id_(-1), 310 record_for_script_id_(-1),
319 record_token_positions_into_(NULL), 311 record_token_positions_into_(NULL),
320 record_yield_positions_into_(NULL) {} 312 record_yield_positions_into_(NULL) {}
321 313
322 StreamingFlowGraphBuilder(TranslationHelper* translation_helper, 314 StreamingFlowGraphBuilder(TranslationHelper* translation_helper,
323 Zone* zone, 315 Zone* zone,
324 const uint8_t* buffer, 316 const uint8_t* buffer,
325 intptr_t buffer_length) 317 intptr_t buffer_length)
326 : flow_graph_builder_(NULL), 318 : flow_graph_builder_(NULL),
327 translation_helper_(*translation_helper), 319 translation_helper_(*translation_helper),
328 zone_(zone), 320 zone_(zone),
329 reader_(new Reader(buffer, buffer_length)), 321 reader_(new Reader(buffer, buffer_length)),
330 constant_evaluator_(this), 322 constant_evaluator_(this),
331 type_translator_(this, /* finalize= */ true), 323 type_translator_(this, /* finalize= */ true),
324 relative_kernel_offset_(0),
332 current_script_id_(-1), 325 current_script_id_(-1),
333 record_for_script_id_(-1), 326 record_for_script_id_(-1),
334 record_token_positions_into_(NULL), 327 record_token_positions_into_(NULL),
328 record_yield_positions_into_(NULL) {}
329
330 StreamingFlowGraphBuilder(TranslationHelper* translation_helper,
331 Zone* zone,
332 intptr_t relative_kernel_offset,
333 const TypedData& data)
334 : flow_graph_builder_(NULL),
335 translation_helper_(*translation_helper),
336 zone_(zone),
337 reader_(new Reader(data)),
338 constant_evaluator_(this),
339 type_translator_(this, /* finalize= */ true),
340 relative_kernel_offset_(relative_kernel_offset),
341 current_script_id_(-1),
342 record_for_script_id_(-1),
343 record_token_positions_into_(NULL),
335 record_yield_positions_into_(NULL) {} 344 record_yield_positions_into_(NULL) {}
336 345
337 ~StreamingFlowGraphBuilder() { delete reader_; } 346 ~StreamingFlowGraphBuilder() { delete reader_; }
338 347
339 FlowGraph* BuildGraph(intptr_t kernel_offset); 348 FlowGraph* BuildGraph(intptr_t kernel_offset);
340 349
341 Fragment BuildStatementAt(intptr_t kernel_offset); 350 Fragment BuildStatementAt(intptr_t kernel_offset);
342 RawObject* BuildParameterDescriptor(intptr_t kernel_offset); 351 RawObject* BuildParameterDescriptor(intptr_t kernel_offset);
343 RawObject* EvaluateMetadata(intptr_t kernel_offset); 352 RawObject* EvaluateMetadata(intptr_t kernel_offset);
344 void CollectTokenPositionsFor( 353 void CollectTokenPositionsFor(
345 intptr_t script_index, 354 intptr_t script_index,
355 intptr_t initial_script_index,
346 GrowableArray<intptr_t>* record_token_positions_in, 356 GrowableArray<intptr_t>* record_token_positions_in,
347 GrowableArray<intptr_t>* record_yield_positions_in); 357 GrowableArray<intptr_t>* record_yield_positions_in);
348 intptr_t SourceTableSize(); 358 intptr_t SourceTableSize();
349 String& SourceTableUriFor(intptr_t index); 359 String& SourceTableUriFor(intptr_t index);
350 String& GetSourceFor(intptr_t index); 360 String& GetSourceFor(intptr_t index);
351 Array& GetLineStartsFor(intptr_t index); 361 Array& GetLineStartsFor(intptr_t index);
352 362
353 private: 363 private:
354 void DiscoverEnclosingElements(Zone* zone, 364 void DiscoverEnclosingElements(Zone* zone,
355 const Function& function, 365 const Function& function,
356 Function* outermost_function); 366 Function* outermost_function);
357 367
358 /** 368 void ReadUntilFunctionNode();
359 * Will return kernel offset for parent class if reading a constructor. 369 StringIndex GetNameFromVariableDeclaration(intptr_t kernel_offset,
360 * Will otherwise return -1. 370 const Function& function);
361 */
362 intptr_t ReadUntilFunctionNode();
363 StringIndex GetNameFromVariableDeclaration(intptr_t kernel_offset);
364 371
365 FlowGraph* BuildGraphOfStaticFieldInitializer(); 372 FlowGraph* BuildGraphOfStaticFieldInitializer();
366 FlowGraph* BuildGraphOfFieldAccessor(LocalVariable* setter_value); 373 FlowGraph* BuildGraphOfFieldAccessor(LocalVariable* setter_value);
367 void SetupDefaultParameterValues(); 374 void SetupDefaultParameterValues();
368 Fragment BuildFieldInitializer(NameIndex canonical_name); 375 Fragment BuildFieldInitializer(NameIndex canonical_name);
369 Fragment BuildInitializers(intptr_t constructor_class_parent_offset); 376 Fragment BuildInitializers(const Class& parent_class);
370 FlowGraph* BuildGraphOfImplicitClosureFunction(const Function& function); 377 FlowGraph* BuildGraphOfImplicitClosureFunction(const Function& function);
371 FlowGraph* BuildGraphOfConvertedClosureFunction(const Function& function); 378 FlowGraph* BuildGraphOfConvertedClosureFunction(const Function& function);
372 FlowGraph* BuildGraphOfFunction( 379 FlowGraph* BuildGraphOfFunction(bool constructor);
373 intptr_t constructor_class_parent_offset = -1);
374 380
375 Fragment BuildExpression(TokenPosition* position = NULL); 381 Fragment BuildExpression(TokenPosition* position = NULL);
376 Fragment BuildStatement(); 382 Fragment BuildStatement();
377 383
378 intptr_t ReaderOffset(); 384 intptr_t ReaderOffset();
379 void SetOffset(intptr_t offset); 385 void SetOffset(intptr_t offset);
380 void SkipBytes(intptr_t skip); 386 void SkipBytes(intptr_t skip);
381 bool ReadBool(); 387 bool ReadBool();
382 uint8_t ReadByte(); 388 uint8_t ReadByte();
383 uint32_t ReadUInt(); 389 uint32_t ReadUInt();
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 Fragment BuildForInStatement(bool async); 616 Fragment BuildForInStatement(bool async);
611 Fragment BuildSwitchStatement(); 617 Fragment BuildSwitchStatement();
612 Fragment BuildContinueSwitchStatement(); 618 Fragment BuildContinueSwitchStatement();
613 Fragment BuildIfStatement(); 619 Fragment BuildIfStatement();
614 Fragment BuildReturnStatement(); 620 Fragment BuildReturnStatement();
615 Fragment BuildTryCatch(); 621 Fragment BuildTryCatch();
616 Fragment BuildTryFinally(); 622 Fragment BuildTryFinally();
617 Fragment BuildYieldStatement(); 623 Fragment BuildYieldStatement();
618 Fragment BuildVariableDeclaration(); 624 Fragment BuildVariableDeclaration();
619 Fragment BuildFunctionDeclaration(); 625 Fragment BuildFunctionDeclaration();
620 Fragment BuildFunctionNode(intptr_t parent_kernel_offset, 626 Fragment BuildFunctionNode(TokenPosition parent_position,
621 TokenPosition parent_position, 627 StringIndex name_index);
622 bool declaration,
623 intptr_t variable_offeset);
624 void SetupFunctionParameters(const dart::Class& klass, 628 void SetupFunctionParameters(const dart::Class& klass,
625 const dart::Function& function, 629 const dart::Function& function,
626 bool is_method, 630 bool is_method,
627 bool is_closure, 631 bool is_closure,
628 FunctionNodeHelper* function_node_helper); 632 FunctionNodeHelper* function_node_helper);
629 633
630 FlowGraphBuilder* flow_graph_builder_; 634 FlowGraphBuilder* flow_graph_builder_;
631 TranslationHelper& translation_helper_; 635 TranslationHelper& translation_helper_;
632 Zone* zone_; 636 Zone* zone_;
633 Reader* reader_; 637 Reader* reader_;
634 StreamingConstantEvaluator constant_evaluator_; 638 StreamingConstantEvaluator constant_evaluator_;
635 StreamingDartTypeTranslator type_translator_; 639 StreamingDartTypeTranslator type_translator_;
640 intptr_t relative_kernel_offset_;
636 intptr_t current_script_id_; 641 intptr_t current_script_id_;
637 intptr_t record_for_script_id_; 642 intptr_t record_for_script_id_;
638 GrowableArray<intptr_t>* record_token_positions_into_; 643 GrowableArray<intptr_t>* record_token_positions_into_;
639 GrowableArray<intptr_t>* record_yield_positions_into_; 644 GrowableArray<intptr_t>* record_yield_positions_into_;
640 645
641 friend class StreamingConstantEvaluator; 646 friend class StreamingConstantEvaluator;
642 friend class StreamingDartTypeTranslator; 647 friend class StreamingDartTypeTranslator;
643 friend class StreamingScopeBuilder; 648 friend class StreamingScopeBuilder;
644 friend class FunctionNodeHelper; 649 friend class FunctionNodeHelper;
645 friend class VariableDeclarationHelper; 650 friend class VariableDeclarationHelper;
646 friend class FieldHelper; 651 friend class FieldHelper;
647 friend class ProcedureHelper; 652 friend class ProcedureHelper;
648 friend class ClassHelper; 653 friend class ClassHelper;
649 friend class LibraryHelper; 654 friend class LibraryHelper;
650 friend class ConstructorHelper; 655 friend class ConstructorHelper;
651 friend class SimpleExpressionConverter; 656 friend class SimpleExpressionConverter;
652 friend class KernelReader; 657 friend class KernelReader;
653 }; 658 };
654 659
655 // A helper class that saves the current reader position, goes to another reader 660 // A helper class that saves the current reader position, goes to another reader
656 // position, and upon destruction, resets to the original reader position. 661 // position, and upon destruction, resets to the original reader position.
657 class AlternativeReadingScope { 662 class AlternativeReadingScope {
658 public: 663 public:
659 AlternativeReadingScope(Reader* reader, intptr_t new_position) 664 AlternativeReadingScope(Reader* reader, intptr_t new_position)
660 : reader_(reader), saved_offset_(reader_->offset()) { 665 : reader_(reader),
666 saved_size_(reader_->size()),
667 saved_raw_buffer_(reader_->raw_buffer()),
668 saved_typed_data_(reader_->typed_data()),
669 saved_offset_(reader_->offset()) {
670 reader_->set_offset(new_position);
671 }
672
673 AlternativeReadingScope(Reader* reader,
674 const TypedData* new_typed_data,
675 intptr_t new_position)
676 : reader_(reader),
677 saved_size_(reader_->size()),
678 saved_raw_buffer_(reader_->raw_buffer()),
679 saved_typed_data_(reader_->typed_data()),
680 saved_offset_(reader_->offset()) {
681 reader_->set_raw_buffer(NULL);
682 reader_->set_typed_data(new_typed_data);
683 reader_->set_size(new_typed_data->Length());
661 reader_->set_offset(new_position); 684 reader_->set_offset(new_position);
662 } 685 }
663 686
664 explicit AlternativeReadingScope(Reader* reader) 687 explicit AlternativeReadingScope(Reader* reader)
665 : reader_(reader), saved_offset_(reader_->offset()) {} 688 : reader_(reader),
689 saved_size_(reader_->size()),
690 saved_raw_buffer_(reader_->raw_buffer()),
691 saved_typed_data_(reader_->typed_data()),
692 saved_offset_(reader_->offset()) {}
666 693
667 ~AlternativeReadingScope() { reader_->set_offset(saved_offset_); } 694 ~AlternativeReadingScope() {
695 reader_->set_raw_buffer(saved_raw_buffer_);
696 reader_->set_typed_data(saved_typed_data_);
697 reader_->set_size(saved_size_);
698 reader_->set_offset(saved_offset_);
699 }
668 700
669 intptr_t saved_offset() { return saved_offset_; } 701 intptr_t saved_offset() { return saved_offset_; }
670 702
671 private: 703 private:
672 Reader* reader_; 704 Reader* reader_;
705 intptr_t saved_size_;
706 const uint8_t* saved_raw_buffer_;
707 const TypedData* saved_typed_data_;
673 intptr_t saved_offset_; 708 intptr_t saved_offset_;
674 }; 709 };
675 710
676 // Helper class that reads a kernel FunctionNode from binary. 711 // Helper class that reads a kernel FunctionNode from binary.
677 // 712 //
678 // Use ReadUntilExcluding to read up to but not including a field. 713 // Use ReadUntilExcluding to read up to but not including a field.
679 // One can then for instance read the field from the call-site (and remember to 714 // One can then for instance read the field from the call-site (and remember to
680 // call SetAt to inform this helper class), and then use this to read more. 715 // call SetAt to inform this helper class), and then use this to read more.
681 // "Dumb" fields are stored (e.g. integers) and can be fetched from this class. 716 // "Dumb" fields are stored (e.g. integers) and can be fetched from this class.
682 // If asked to read a "non-dumb" field (e.g. an expression) it will be skipped. 717 // If asked to read a "non-dumb" field (e.g. an expression) it will be skipped.
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 // "Dumb" fields are stored (e.g. integers) and can be fetched from this class. 903 // "Dumb" fields are stored (e.g. integers) and can be fetched from this class.
869 // If asked to read a "non-dumb" field (e.g. an expression) it will be skipped. 904 // If asked to read a "non-dumb" field (e.g. an expression) it will be skipped.
870 class FieldHelper { 905 class FieldHelper {
871 public: 906 public:
872 enum Fields { 907 enum Fields {
873 kStart, // tag. 908 kStart, // tag.
874 kCanonicalName, 909 kCanonicalName,
875 kPosition, 910 kPosition,
876 kEndPosition, 911 kEndPosition,
877 kFlags, 912 kFlags,
878 kParentClassBinaryOffset,
879 kName, 913 kName,
880 kSourceUriIndex, 914 kSourceUriIndex,
881 kDocumentationCommentIndex, 915 kDocumentationCommentIndex,
882 kAnnotations, 916 kAnnotations,
883 kType, 917 kType,
884 kInitializer, 918 kInitializer,
885 kEnd 919 kEnd
886 }; 920 };
887 921
888 explicit FieldHelper(StreamingFlowGraphBuilder* builder) 922 explicit FieldHelper(StreamingFlowGraphBuilder* builder)
(...skipping 29 matching lines...) Expand all
918 if (++next_read_ == field) return; 952 if (++next_read_ == field) return;
919 case kPosition: 953 case kPosition:
920 position_ = builder_->ReadPosition(false); // read position. 954 position_ = builder_->ReadPosition(false); // read position.
921 if (++next_read_ == field) return; 955 if (++next_read_ == field) return;
922 case kEndPosition: 956 case kEndPosition:
923 end_position_ = builder_->ReadPosition(false); // read end position. 957 end_position_ = builder_->ReadPosition(false); // read end position.
924 if (++next_read_ == field) return; 958 if (++next_read_ == field) return;
925 case kFlags: 959 case kFlags:
926 flags_ = builder_->ReadFlags(); // read flags. 960 flags_ = builder_->ReadFlags(); // read flags.
927 if (++next_read_ == field) return; 961 if (++next_read_ == field) return;
928 case kParentClassBinaryOffset:
929 parent_class_binary_offset_ =
930 builder_->ReadUInt(); // read parent class binary offset.
931 if (++next_read_ == field) return;
932 case kName: 962 case kName:
933 builder_->SkipName(); // read name. 963 builder_->SkipName(); // read name.
934 if (++next_read_ == field) return; 964 if (++next_read_ == field) return;
935 case kSourceUriIndex: 965 case kSourceUriIndex:
936 source_uri_index_ = builder_->ReadUInt(); // read source_uri_index. 966 source_uri_index_ = builder_->ReadUInt(); // read source_uri_index.
937 builder_->current_script_id_ = source_uri_index_; 967 builder_->current_script_id_ = source_uri_index_;
938 builder_->record_token_position(position_); 968 builder_->record_token_position(position_);
939 builder_->record_token_position(end_position_); 969 builder_->record_token_position(end_position_);
940 if (++next_read_ == field) return; 970 if (++next_read_ == field) return;
941 case kDocumentationCommentIndex: 971 case kDocumentationCommentIndex:
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 *start = function_literal_start_; 1022 *start = function_literal_start_;
993 *end = function_literal_end_; 1023 *end = function_literal_end_;
994 } 1024 }
995 return has_function_literal_initializer_; 1025 return has_function_literal_initializer_;
996 } 1026 }
997 1027
998 NameIndex canonical_name_; 1028 NameIndex canonical_name_;
999 TokenPosition position_; 1029 TokenPosition position_;
1000 TokenPosition end_position_; 1030 TokenPosition end_position_;
1001 word flags_; 1031 word flags_;
1002 intptr_t parent_class_binary_offset_;
1003 intptr_t source_uri_index_; 1032 intptr_t source_uri_index_;
1004 intptr_t annotation_count_; 1033 intptr_t annotation_count_;
1005 1034
1006 private: 1035 private:
1007 StreamingFlowGraphBuilder* builder_; 1036 StreamingFlowGraphBuilder* builder_;
1008 intptr_t next_read_; 1037 intptr_t next_read_;
1009 1038
1010 bool has_function_literal_initializer_; 1039 bool has_function_literal_initializer_;
1011 TokenPosition function_literal_start_; 1040 TokenPosition function_literal_start_;
1012 TokenPosition function_literal_end_; 1041 TokenPosition function_literal_end_;
1013 }; 1042 };
1014 1043
1015 // Helper class that reads a kernel Procedure from binary. 1044 // Helper class that reads a kernel Procedure from binary.
1016 // 1045 //
1017 // Use ReadUntilExcluding to read up to but not including a field. 1046 // Use ReadUntilExcluding to read up to but not including a field.
1018 // One can then for instance read the field from the call-site (and remember to 1047 // One can then for instance read the field from the call-site (and remember to
1019 // call SetAt to inform this helper class), and then use this to read more. 1048 // call SetAt to inform this helper class), and then use this to read more.
1020 // "Dumb" fields are stored (e.g. integers) and can be fetched from this class. 1049 // "Dumb" fields are stored (e.g. integers) and can be fetched from this class.
1021 // If asked to read a "non-dumb" field (e.g. an expression) it will be skipped. 1050 // If asked to read a "non-dumb" field (e.g. an expression) it will be skipped.
1022 class ProcedureHelper { 1051 class ProcedureHelper {
1023 public: 1052 public:
1024 enum Fields { 1053 enum Fields {
1025 kStart, // tag. 1054 kStart, // tag.
1026 kCanonicalName, 1055 kCanonicalName,
1027 kPosition, 1056 kPosition,
1028 kEndPosition, 1057 kEndPosition,
1029 kKind, 1058 kKind,
1030 kFlags, 1059 kFlags,
1031 kParentClassBinaryOffset,
1032 kName, 1060 kName,
1033 kSourceUriIndex, 1061 kSourceUriIndex,
1034 kDocumentationCommentIndex, 1062 kDocumentationCommentIndex,
1035 kAnnotations, 1063 kAnnotations,
1036 kFunction, 1064 kFunction,
1037 kEnd 1065 kEnd
1038 }; 1066 };
1039 1067
1040 explicit ProcedureHelper(StreamingFlowGraphBuilder* builder) { 1068 explicit ProcedureHelper(StreamingFlowGraphBuilder* builder) {
1041 builder_ = builder; 1069 builder_ = builder;
(...skipping 24 matching lines...) Expand all
1066 case kEndPosition: 1094 case kEndPosition:
1067 end_position_ = builder_->ReadPosition(false); // read end position. 1095 end_position_ = builder_->ReadPosition(false); // read end position.
1068 if (++next_read_ == field) return; 1096 if (++next_read_ == field) return;
1069 case kKind: 1097 case kKind:
1070 kind_ = static_cast<Procedure::ProcedureKind>( 1098 kind_ = static_cast<Procedure::ProcedureKind>(
1071 builder_->ReadByte()); // read kind. 1099 builder_->ReadByte()); // read kind.
1072 if (++next_read_ == field) return; 1100 if (++next_read_ == field) return;
1073 case kFlags: 1101 case kFlags:
1074 flags_ = builder_->ReadFlags(); // read flags. 1102 flags_ = builder_->ReadFlags(); // read flags.
1075 if (++next_read_ == field) return; 1103 if (++next_read_ == field) return;
1076 case kParentClassBinaryOffset:
1077 parent_class_binary_offset_ =
1078 builder_->ReadUInt(); // read parent class binary offset.
1079 if (++next_read_ == field) return;
1080 case kName: 1104 case kName:
1081 builder_->SkipName(); // read name. 1105 builder_->SkipName(); // read name.
1082 if (++next_read_ == field) return; 1106 if (++next_read_ == field) return;
1083 case kSourceUriIndex: 1107 case kSourceUriIndex:
1084 source_uri_index_ = builder_->ReadUInt(); // read source_uri_index. 1108 source_uri_index_ = builder_->ReadUInt(); // read source_uri_index.
1085 builder_->current_script_id_ = source_uri_index_; 1109 builder_->current_script_id_ = source_uri_index_;
1086 builder_->record_token_position(position_); 1110 builder_->record_token_position(position_);
1087 builder_->record_token_position(end_position_); 1111 builder_->record_token_position(end_position_);
1088 if (++next_read_ == field) return; 1112 if (++next_read_ == field) return;
1089 case kDocumentationCommentIndex: 1113 case kDocumentationCommentIndex:
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 } 1146 }
1123 bool IsConst() { 1147 bool IsConst() {
1124 return (flags_ & Procedure::kFlagConst) == Procedure::kFlagConst; 1148 return (flags_ & Procedure::kFlagConst) == Procedure::kFlagConst;
1125 } 1149 }
1126 1150
1127 NameIndex canonical_name_; 1151 NameIndex canonical_name_;
1128 TokenPosition position_; 1152 TokenPosition position_;
1129 TokenPosition end_position_; 1153 TokenPosition end_position_;
1130 Procedure::ProcedureKind kind_; 1154 Procedure::ProcedureKind kind_;
1131 word flags_; 1155 word flags_;
1132 intptr_t parent_class_binary_offset_;
1133 intptr_t source_uri_index_; 1156 intptr_t source_uri_index_;
1134 intptr_t annotation_count_; 1157 intptr_t annotation_count_;
1135 1158
1136 private: 1159 private:
1137 StreamingFlowGraphBuilder* builder_; 1160 StreamingFlowGraphBuilder* builder_;
1138 intptr_t next_read_; 1161 intptr_t next_read_;
1139 }; 1162 };
1140 1163
1141 // Helper class that reads a kernel Constructor from binary. 1164 // Helper class that reads a kernel Constructor from binary.
1142 // 1165 //
1143 // Use ReadUntilExcluding to read up to but not including a field. 1166 // Use ReadUntilExcluding to read up to but not including a field.
1144 // One can then for instance read the field from the call-site (and remember to 1167 // One can then for instance read the field from the call-site (and remember to
1145 // call SetAt to inform this helper class), and then use this to read more. 1168 // call SetAt to inform this helper class), and then use this to read more.
1146 // "Dumb" fields are stored (e.g. integers) and can be fetched from this class. 1169 // "Dumb" fields are stored (e.g. integers) and can be fetched from this class.
1147 // If asked to read a "non-dumb" field (e.g. an expression) it will be skipped. 1170 // If asked to read a "non-dumb" field (e.g. an expression) it will be skipped.
1148 class ConstructorHelper { 1171 class ConstructorHelper {
1149 public: 1172 public:
1150 enum Fields { 1173 enum Fields {
1151 kStart, // tag. 1174 kStart, // tag.
1152 kCanonicalName, 1175 kCanonicalName,
1153 kPosition, 1176 kPosition,
1154 kEndPosition, 1177 kEndPosition,
1155 kFlags, 1178 kFlags,
1156 kParentClassBinaryOffset,
1157 kName, 1179 kName,
1158 kDocumentationCommentIndex, 1180 kDocumentationCommentIndex,
1159 kAnnotations, 1181 kAnnotations,
1160 kFunction, 1182 kFunction,
1161 kInitializers, 1183 kInitializers,
1162 kEnd 1184 kEnd
1163 }; 1185 };
1164 1186
1165 explicit ConstructorHelper(StreamingFlowGraphBuilder* builder) { 1187 explicit ConstructorHelper(StreamingFlowGraphBuilder* builder) {
1166 builder_ = builder; 1188 builder_ = builder;
(...skipping 20 matching lines...) Expand all
1187 if (++next_read_ == field) return; 1209 if (++next_read_ == field) return;
1188 case kPosition: 1210 case kPosition:
1189 position_ = builder_->ReadPosition(); // read position. 1211 position_ = builder_->ReadPosition(); // read position.
1190 if (++next_read_ == field) return; 1212 if (++next_read_ == field) return;
1191 case kEndPosition: 1213 case kEndPosition:
1192 end_position_ = builder_->ReadPosition(); // read end position. 1214 end_position_ = builder_->ReadPosition(); // read end position.
1193 if (++next_read_ == field) return; 1215 if (++next_read_ == field) return;
1194 case kFlags: 1216 case kFlags:
1195 flags_ = builder_->ReadFlags(); // read flags. 1217 flags_ = builder_->ReadFlags(); // read flags.
1196 if (++next_read_ == field) return; 1218 if (++next_read_ == field) return;
1197 case kParentClassBinaryOffset:
1198 parent_class_binary_offset_ =
1199 builder_->ReadUInt(); // read parent class binary offset.
1200 if (++next_read_ == field) return;
1201 case kName: 1219 case kName:
1202 builder_->SkipName(); // read name. 1220 builder_->SkipName(); // read name.
1203 if (++next_read_ == field) return; 1221 if (++next_read_ == field) return;
1204 case kDocumentationCommentIndex: 1222 case kDocumentationCommentIndex:
1205 builder_->ReadStringReference(); 1223 builder_->ReadStringReference();
1206 if (++next_read_ == field) return; 1224 if (++next_read_ == field) return;
1207 case kAnnotations: { 1225 case kAnnotations: {
1208 annotation_count_ = builder_->ReadListLength(); // read list length. 1226 annotation_count_ = builder_->ReadListLength(); // read list length.
1209 for (intptr_t i = 0; i < annotation_count_; ++i) { 1227 for (intptr_t i = 0; i < annotation_count_; ++i) {
1210 builder_->SkipExpression(); // read ith expression. 1228 builder_->SkipExpression(); // read ith expression.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 return (flags_ & Constructor::kFlagExternal) == Constructor::kFlagExternal; 1277 return (flags_ & Constructor::kFlagExternal) == Constructor::kFlagExternal;
1260 } 1278 }
1261 bool IsConst() { 1279 bool IsConst() {
1262 return (flags_ & Constructor::kFlagConst) == Constructor::kFlagConst; 1280 return (flags_ & Constructor::kFlagConst) == Constructor::kFlagConst;
1263 } 1281 }
1264 1282
1265 NameIndex canonical_name_; 1283 NameIndex canonical_name_;
1266 TokenPosition position_; 1284 TokenPosition position_;
1267 TokenPosition end_position_; 1285 TokenPosition end_position_;
1268 word flags_; 1286 word flags_;
1269 intptr_t parent_class_binary_offset_;
1270 intptr_t annotation_count_; 1287 intptr_t annotation_count_;
1271 1288
1272 private: 1289 private:
1273 StreamingFlowGraphBuilder* builder_; 1290 StreamingFlowGraphBuilder* builder_;
1274 intptr_t next_read_; 1291 intptr_t next_read_;
1275 }; 1292 };
1276 1293
1277 // Helper class that reads a kernel Class from binary. 1294 // Helper class that reads a kernel Class from binary.
1278 // 1295 //
1279 // Use ReadUntilExcluding to read up to but not including a field. 1296 // Use ReadUntilExcluding to read up to but not including a field.
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 private: 1565 private:
1549 StreamingFlowGraphBuilder* builder_; 1566 StreamingFlowGraphBuilder* builder_;
1550 intptr_t next_read_; 1567 intptr_t next_read_;
1551 }; 1568 };
1552 1569
1553 } // namespace kernel 1570 } // namespace kernel
1554 } // namespace dart 1571 } // namespace dart
1555 1572
1556 #endif // !defined(DART_PRECOMPILED_RUNTIME) 1573 #endif // !defined(DART_PRECOMPILED_RUNTIME)
1557 #endif // RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_ 1574 #endif // RUNTIME_VM_KERNEL_BINARY_FLOWGRAPH_H_
OLDNEW
« no previous file with comments | « runtime/vm/kernel_binary.h ('k') | runtime/vm/kernel_binary_flowgraph.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698