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

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

Issue 2995423002: Allow the VM to read Kernel files with external libraries (Closed)
Patch Set: 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_flowgraph.h ('k') | runtime/vm/kernel_reader.h » ('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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 #include "vm/kernel_binary_flowgraph.h" 5 #include "vm/kernel_binary_flowgraph.h"
6 #include "vm/compiler.h" 6 #include "vm/compiler.h"
7 #include "vm/longjump.h" 7 #include "vm/longjump.h"
8 #include "vm/object_store.h" 8 #include "vm/object_store.h"
9 9
10 #if !defined(DART_PRECOMPILED_RUNTIME) 10 #if !defined(DART_PRECOMPILED_RUNTIME)
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 // Ordered with fall-through. 81 // Ordered with fall-through.
82 switch (next_read_) { 82 switch (next_read_) {
83 case kPosition: 83 case kPosition:
84 position_ = builder_->ReadPosition(); // read position. 84 position_ = builder_->ReadPosition(); // read position.
85 if (++next_read_ == field) return; 85 if (++next_read_ == field) return;
86 case kEqualPosition: 86 case kEqualPosition:
87 equals_position_ = builder_->ReadPosition(); // read equals position. 87 equals_position_ = builder_->ReadPosition(); // read equals position.
88 if (++next_read_ == field) return; 88 if (++next_read_ == field) return;
89 case kFlags: 89 case kFlags:
90 flags_ = builder_->ReadFlags(); // read flags. 90 flags_ = builder_->ReadFlags();
91 if (++next_read_ == field) return; 91 if (++next_read_ == field) return;
92 case kNameIndex: 92 case kNameIndex:
93 name_index_ = builder_->ReadStringReference(); // read name index. 93 name_index_ = builder_->ReadStringReference(); // read name index.
94 if (++next_read_ == field) return; 94 if (++next_read_ == field) return;
95 case kType: 95 case kType:
96 builder_->SkipDartType(); // read type. 96 builder_->SkipDartType(); // read type.
97 if (++next_read_ == field) return; 97 if (++next_read_ == field) return;
98 case kInitializer: 98 case kInitializer:
99 if (builder_->ReadTag() == kSomething) 99 if (builder_->ReadTag() == kSomething)
100 builder_->SkipExpression(); // read initializer. 100 builder_->SkipExpression(); // read initializer.
(...skipping 25 matching lines...) Expand all
126 canonical_name_ = 126 canonical_name_ =
127 builder_->ReadCanonicalNameReference(); // read canonical_name. 127 builder_->ReadCanonicalNameReference(); // read canonical_name.
128 if (++next_read_ == field) return; 128 if (++next_read_ == field) return;
129 case kPosition: 129 case kPosition:
130 position_ = builder_->ReadPosition(false); // read position. 130 position_ = builder_->ReadPosition(false); // read position.
131 if (++next_read_ == field) return; 131 if (++next_read_ == field) return;
132 case kEndPosition: 132 case kEndPosition:
133 end_position_ = builder_->ReadPosition(false); // read end position. 133 end_position_ = builder_->ReadPosition(false); // read end position.
134 if (++next_read_ == field) return; 134 if (++next_read_ == field) return;
135 case kFlags: 135 case kFlags:
136 flags_ = builder_->ReadFlags(); // read flags. 136 flags_ = builder_->ReadFlags();
137 if (++next_read_ == field) return; 137 if (++next_read_ == field) return;
138 case kName: 138 case kName:
139 builder_->SkipName(); // read name. 139 builder_->SkipName(); // read name.
140 if (++next_read_ == field) return; 140 if (++next_read_ == field) return;
141 case kSourceUriIndex: 141 case kSourceUriIndex:
142 source_uri_index_ = builder_->ReadUInt(); // read source_uri_index. 142 source_uri_index_ = builder_->ReadUInt(); // read source_uri_index.
143 builder_->current_script_id_ = source_uri_index_; 143 builder_->current_script_id_ = source_uri_index_;
144 builder_->record_token_position(position_); 144 builder_->record_token_position(position_);
145 builder_->record_token_position(end_position_); 145 builder_->record_token_position(end_position_);
146 if (++next_read_ == field) return; 146 if (++next_read_ == field) return;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 case kPosition: 198 case kPosition:
199 position_ = builder_->ReadPosition(false); // read position. 199 position_ = builder_->ReadPosition(false); // read position.
200 if (++next_read_ == field) return; 200 if (++next_read_ == field) return;
201 case kEndPosition: 201 case kEndPosition:
202 end_position_ = builder_->ReadPosition(false); // read end position. 202 end_position_ = builder_->ReadPosition(false); // read end position.
203 if (++next_read_ == field) return; 203 if (++next_read_ == field) return;
204 case kKind: 204 case kKind:
205 kind_ = static_cast<Kind>(builder_->ReadByte()); 205 kind_ = static_cast<Kind>(builder_->ReadByte());
206 if (++next_read_ == field) return; 206 if (++next_read_ == field) return;
207 case kFlags: 207 case kFlags:
208 flags_ = builder_->ReadFlags(); // read flags. 208 flags_ = builder_->ReadFlags();
209 if (++next_read_ == field) return; 209 if (++next_read_ == field) return;
210 case kName: 210 case kName:
211 builder_->SkipName(); // read name. 211 builder_->SkipName(); // read name.
212 if (++next_read_ == field) return; 212 if (++next_read_ == field) return;
213 case kSourceUriIndex: 213 case kSourceUriIndex:
214 source_uri_index_ = builder_->ReadUInt(); // read source_uri_index. 214 source_uri_index_ = builder_->ReadUInt(); // read source_uri_index.
215 builder_->current_script_id_ = source_uri_index_; 215 builder_->current_script_id_ = source_uri_index_;
216 builder_->record_token_position(position_); 216 builder_->record_token_position(position_);
217 builder_->record_token_position(end_position_); 217 builder_->record_token_position(end_position_);
218 if (++next_read_ == field) return; 218 if (++next_read_ == field) return;
(...skipping 30 matching lines...) Expand all
249 canonical_name_ = 249 canonical_name_ =
250 builder_->ReadCanonicalNameReference(); // read canonical_name. 250 builder_->ReadCanonicalNameReference(); // read canonical_name.
251 if (++next_read_ == field) return; 251 if (++next_read_ == field) return;
252 case kPosition: 252 case kPosition:
253 position_ = builder_->ReadPosition(); // read position. 253 position_ = builder_->ReadPosition(); // read position.
254 if (++next_read_ == field) return; 254 if (++next_read_ == field) return;
255 case kEndPosition: 255 case kEndPosition:
256 end_position_ = builder_->ReadPosition(); // read end position. 256 end_position_ = builder_->ReadPosition(); // read end position.
257 if (++next_read_ == field) return; 257 if (++next_read_ == field) return;
258 case kFlags: 258 case kFlags:
259 flags_ = builder_->ReadFlags(); // read flags. 259 flags_ = builder_->ReadFlags();
260 if (++next_read_ == field) return; 260 if (++next_read_ == field) return;
261 case kName: 261 case kName:
262 builder_->SkipName(); // read name. 262 builder_->SkipName(); // read name.
263 if (++next_read_ == field) return; 263 if (++next_read_ == field) return;
264 case kDocumentationCommentIndex: 264 case kDocumentationCommentIndex:
265 builder_->ReadStringReference(); 265 builder_->ReadStringReference();
266 if (++next_read_ == field) return; 266 if (++next_read_ == field) return;
267 case kAnnotations: { 267 case kAnnotations: {
268 annotation_count_ = builder_->ReadListLength(); // read list length. 268 annotation_count_ = builder_->ReadListLength(); // read list length.
269 for (intptr_t i = 0; i < annotation_count_; ++i) { 269 for (intptr_t i = 0; i < annotation_count_; ++i) {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 return; 403 return;
404 } 404 }
405 } 405 }
406 406
407 void LibraryHelper::ReadUntilExcluding(Field field) { 407 void LibraryHelper::ReadUntilExcluding(Field field) {
408 if (field <= next_read_) return; 408 if (field <= next_read_) return;
409 409
410 // Ordered with fall-through. 410 // Ordered with fall-through.
411 switch (next_read_) { 411 switch (next_read_) {
412 case kFlags: { 412 case kFlags: {
413 word flags = builder_->ReadFlags(); // read flags. 413 flags_ = builder_->ReadFlags();
414 ASSERT(flags == 0); // external libraries not supported
415 if (++next_read_ == field) return; 414 if (++next_read_ == field) return;
416 } 415 }
417 case kCanonicalName: 416 case kCanonicalName:
418 canonical_name_ = 417 canonical_name_ =
419 builder_->ReadCanonicalNameReference(); // read canonical_name. 418 builder_->ReadCanonicalNameReference(); // read canonical_name.
420 if (++next_read_ == field) return; 419 if (++next_read_ == field) return;
421 case kName: 420 case kName:
422 name_index_ = builder_->ReadStringReference(); // read name index. 421 name_index_ = builder_->ReadStringReference(); // read name index.
423 if (++next_read_ == field) return; 422 if (++next_read_ == field) return;
424 case kSourceUriIndex: 423 case kSourceUriIndex:
(...skipping 4228 matching lines...) Expand 10 before | Expand all | Expand 10 after
4653 4652
4654 void StreamingFlowGraphBuilder::SkipLibraryCombinator() { 4653 void StreamingFlowGraphBuilder::SkipLibraryCombinator() {
4655 ReadBool(); // read is_show. 4654 ReadBool(); // read is_show.
4656 intptr_t name_count = ReadUInt(); // read list length. 4655 intptr_t name_count = ReadUInt(); // read list length.
4657 for (intptr_t j = 0; j < name_count; ++j) { 4656 for (intptr_t j = 0; j < name_count; ++j) {
4658 ReadUInt(); // read ith entry of name_indices. 4657 ReadUInt(); // read ith entry of name_indices.
4659 } 4658 }
4660 } 4659 }
4661 4660
4662 void StreamingFlowGraphBuilder::SkipLibraryDependency() { 4661 void StreamingFlowGraphBuilder::SkipLibraryDependency() {
4663 ReadFlags(); // read flags. 4662 ReadFlags();
4664 SkipListOfExpressions(); // Read annotations. 4663 SkipListOfExpressions(); // Annotations.
4665 ReadCanonicalNameReference(); // read target_reference. 4664 ReadCanonicalNameReference();
4666 ReadStringReference(); // read name_index. 4665 ReadStringReference(); // Name.
4667 intptr_t combinator_count = ReadListLength(); // read list length. 4666 intptr_t combinator_count = ReadListLength();
4668 for (intptr_t i = 0; i < combinator_count; ++i) { 4667 for (intptr_t i = 0; i < combinator_count; ++i) {
4669 SkipLibraryCombinator(); 4668 SkipLibraryCombinator();
4670 } 4669 }
4671 } 4670 }
4672 4671
4673 void StreamingFlowGraphBuilder::SkipLibraryPart() { 4672 void StreamingFlowGraphBuilder::SkipLibraryPart() {
4674 SkipListOfExpressions(); // Read annotations. 4673 SkipListOfExpressions(); // Read annotations.
4675 ReadStringReference(); // read uri_index. 4674 ReadStringReference(); // read uri_index.
4676 } 4675 }
4677 4676
(...skipping 29 matching lines...) Expand all
4707 } 4706 }
4708 4707
4709 Tag StreamingFlowGraphBuilder::ReadTag(uint8_t* payload) { 4708 Tag StreamingFlowGraphBuilder::ReadTag(uint8_t* payload) {
4710 return reader_->ReadTag(payload); 4709 return reader_->ReadTag(payload);
4711 } 4710 }
4712 4711
4713 Tag StreamingFlowGraphBuilder::PeekTag(uint8_t* payload) { 4712 Tag StreamingFlowGraphBuilder::PeekTag(uint8_t* payload) {
4714 return reader_->PeekTag(payload); 4713 return reader_->PeekTag(payload);
4715 } 4714 }
4716 4715
4717 word StreamingFlowGraphBuilder::ReadFlags() {
4718 return reader_->ReadFlags();
4719 }
4720
4721 void StreamingFlowGraphBuilder::loop_depth_inc() { 4716 void StreamingFlowGraphBuilder::loop_depth_inc() {
4722 ++flow_graph_builder_->loop_depth_; 4717 ++flow_graph_builder_->loop_depth_;
4723 } 4718 }
4724 4719
4725 void StreamingFlowGraphBuilder::loop_depth_dec() { 4720 void StreamingFlowGraphBuilder::loop_depth_dec() {
4726 --flow_graph_builder_->loop_depth_; 4721 --flow_graph_builder_->loop_depth_;
4727 } 4722 }
4728 4723
4729 intptr_t StreamingFlowGraphBuilder::for_in_depth() { 4724 intptr_t StreamingFlowGraphBuilder::for_in_depth() {
4730 return flow_graph_builder_->for_in_depth_; 4725 return flow_graph_builder_->for_in_depth_;
(...skipping 3067 matching lines...) Expand 10 before | Expand all | Expand 10 after
7798 } 7793 }
7799 } 7794 }
7800 7795
7801 return Array::Handle(Array::null()); 7796 return Array::Handle(Array::null());
7802 } 7797 }
7803 7798
7804 } // namespace kernel 7799 } // namespace kernel
7805 } // namespace dart 7800 } // namespace dart
7806 7801
7807 #endif // !defined(DART_PRECOMPILED_RUNTIME) 7802 #endif // !defined(DART_PRECOMPILED_RUNTIME)
OLDNEW
« no previous file with comments | « runtime/vm/kernel_binary_flowgraph.h ('k') | runtime/vm/kernel_reader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698