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

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

Issue 2931803002: [kernel] Cleanup kernel code after streaming (part 1). (Closed)
Patch Set: Created 3 years, 6 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.cc ('k') | no next file » | 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 #if !defined(DART_PRECOMPILED_RUNTIME) 4 #if !defined(DART_PRECOMPILED_RUNTIME)
5 5
6 #include "vm/kernel_binary.h" 6 #include "vm/kernel_binary.h"
7 #include "platform/globals.h" 7 #include "platform/globals.h"
8 #include "vm/flags.h" 8 #include "vm/flags.h"
9 #include "vm/growable_array.h" 9 #include "vm/growable_array.h"
10 #include "vm/kernel.h" 10 #include "vm/kernel.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 for (intptr_t i = 0; i < num_classes; i++) { 198 for (intptr_t i = 0; i < num_classes; i++) {
199 Tag tag = reader->ReadTag(); 199 Tag tag = reader->ReadTag();
200 ASSERT(tag == kClass); 200 ASSERT(tag == kClass);
201 NormalClass* klass = classes().GetOrCreate<NormalClass>(i, this); 201 NormalClass* klass = classes().GetOrCreate<NormalClass>(i, this);
202 klass->ReadFrom(reader); 202 klass->ReadFrom(reader);
203 } 203 }
204 204
205 fields().ReadFrom<Field>(reader, this); 205 fields().ReadFrom<Field>(reader, this);
206 procedures().ReadFrom<Procedure>(reader, this); 206 procedures().ReadFrom<Procedure>(reader, this);
207 207
208 can_stream_ =
209 classes().CanStream() && fields().CanStream() && procedures().CanStream();
210
211 return this; 208 return this;
212 } 209 }
213 210
214 211
215 Typedef* Typedef::ReadFrom(Reader* reader) { 212 Typedef* Typedef::ReadFrom(Reader* reader) {
216 TRACE_READ_OFFSET(); 213 TRACE_READ_OFFSET();
217 214
218 canonical_name_ = reader->ReadCanonicalNameReference(); 215 canonical_name_ = reader->ReadCanonicalNameReference();
219 position_ = reader->ReadPosition(false); 216 position_ = reader->ReadPosition(false);
220 name_index_ = StringIndex(reader->ReadUInt()); 217 name_index_ = StringIndex(reader->ReadUInt());
(...skipping 11 matching lines...) Expand all
232 kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 229 kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
233 canonical_name_ = reader->ReadCanonicalNameReference(); 230 canonical_name_ = reader->ReadCanonicalNameReference();
234 position_ = reader->ReadPosition(false); 231 position_ = reader->ReadPosition(false);
235 is_abstract_ = reader->ReadBool(); 232 is_abstract_ = reader->ReadBool();
236 name_index_ = StringIndex(reader->ReadUInt()); 233 name_index_ = StringIndex(reader->ReadUInt());
237 source_uri_index_ = reader->ReadUInt(); 234 source_uri_index_ = reader->ReadUInt();
238 reader->set_current_script_id(source_uri_index_); 235 reader->set_current_script_id(source_uri_index_);
239 reader->record_token_position(position_); 236 reader->record_token_position(position_);
240 annotations_.ReadFromStatic<Expression>(reader); 237 annotations_.ReadFromStatic<Expression>(reader);
241 238
242 can_stream_ = annotations_.CanStream();
243
244 return this; 239 return this;
245 } 240 }
246 241
247 242
248 NormalClass* NormalClass::ReadFrom(Reader* reader) { 243 NormalClass* NormalClass::ReadFrom(Reader* reader) {
249 TRACE_READ_OFFSET(); 244 TRACE_READ_OFFSET();
250 Class::ReadFrom(reader); 245 Class::ReadFrom(reader);
251 TypeParameterScope<ReaderHelper> scope(reader->helper()); 246 TypeParameterScope<ReaderHelper> scope(reader->helper());
252 247
253 type_parameters_.ReadFrom(reader); 248 type_parameters_.ReadFrom(reader);
254 DartType* type = reader->ReadOptional<DartType>(); 249 DartType* type = reader->ReadOptional<DartType>();
255 250
256 super_class_ = InterfaceType::Cast(type); 251 super_class_ = InterfaceType::Cast(type);
257 reader->ReadOptional<DartType>(); // Mixed-in type is unused. 252 reader->ReadOptional<DartType>(); // Mixed-in type is unused.
258 implemented_classes_.ReadFromStatic<DowncastReader<DartType, InterfaceType> >( 253 implemented_classes_.ReadFromStatic<DowncastReader<DartType, InterfaceType> >(
259 reader); 254 reader);
260 fields_.ReadFrom<Field>(reader, this); 255 fields_.ReadFrom<Field>(reader, this);
261 constructors_.ReadFrom<Constructor>(reader, this); 256 constructors_.ReadFrom<Constructor>(reader, this);
262 procedures_.ReadFrom<Procedure>(reader, this); 257 procedures_.ReadFrom<Procedure>(reader, this);
263 258
264 can_stream_ = can_stream_ && fields_.CanStream() &&
265 constructors_.CanStream() && procedures_.CanStream();
266
267 return this; 259 return this;
268 } 260 }
269 261
270
271 MixinClass* MixinClass::ReadFrom(Reader* reader) {
272 TRACE_READ_OFFSET();
273 TypeParameterScope<ReaderHelper> scope(reader->helper());
274
275 Class::ReadFrom(reader);
276 type_parameters_.ReadFrom(reader);
277 first_ = InterfaceType::Cast(DartType::ReadFrom(reader));
278 second_ = InterfaceType::Cast(DartType::ReadFrom(reader));
279 implemented_classes_.ReadFromStatic<DowncastReader<DartType, InterfaceType> >(
280 reader);
281 constructors_.ReadFrom<Constructor>(reader, this);
282
283 can_stream_ = constructors_.CanStream();
284
285 return this;
286 }
287
288 262
289 NameIndex Reference::ReadMemberFrom(Reader* reader, bool allow_null) { 263 NameIndex Reference::ReadMemberFrom(Reader* reader, bool allow_null) {
290 TRACE_READ_OFFSET(); 264 TRACE_READ_OFFSET();
291 NameIndex canonical_name = reader->ReadCanonicalNameReference(); 265 NameIndex canonical_name = reader->ReadCanonicalNameReference();
292 if ((canonical_name == -1) && !allow_null) { 266 if ((canonical_name == -1) && !allow_null) {
293 FATAL("Expected a valid member reference, but got `null`"); 267 FATAL("Expected a valid member reference, but got `null`");
294 } 268 }
295 return canonical_name; 269 return canonical_name;
296 } 270 }
297 271
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 reader->ReadUInt(); // parent class binary offset (or 0). 303 reader->ReadUInt(); // parent class binary offset (or 0).
330 name_ = Name::ReadFrom(reader); 304 name_ = Name::ReadFrom(reader);
331 source_uri_index_ = reader->ReadUInt(); 305 source_uri_index_ = reader->ReadUInt();
332 reader->set_current_script_id(source_uri_index_); 306 reader->set_current_script_id(source_uri_index_);
333 reader->record_token_position(position_); 307 reader->record_token_position(position_);
334 reader->record_token_position(end_position_); 308 reader->record_token_position(end_position_);
335 annotations_.ReadFromStatic<Expression>(reader); 309 annotations_.ReadFromStatic<Expression>(reader);
336 type_ = DartType::ReadFrom(reader); 310 type_ = DartType::ReadFrom(reader);
337 initializer_ = reader->ReadOptional<Expression>(); 311 initializer_ = reader->ReadOptional<Expression>();
338 312
339 can_stream_ = (initializer_ == NULL || initializer_->can_stream()) &&
340 annotations_.CanStream();
341
342 return this; 313 return this;
343 } 314 }
344 315
345 316
346 Constructor* Constructor::ReadFrom(Reader* reader) { 317 Constructor* Constructor::ReadFrom(Reader* reader) {
347 TRACE_READ_OFFSET(); 318 TRACE_READ_OFFSET();
348 kernel_offset_ = reader->offset(); // Notice the ReadTag() below. 319 kernel_offset_ = reader->offset(); // Notice the ReadTag() below.
349 Tag tag = reader->ReadTag(); 320 Tag tag = reader->ReadTag();
350 ASSERT(tag == kConstructor); 321 ASSERT(tag == kConstructor);
351 322
352 canonical_name_ = reader->ReadCanonicalNameReference(); 323 canonical_name_ = reader->ReadCanonicalNameReference();
353 VariableScope<ReaderHelper> parameters(reader->helper()); 324 VariableScope<ReaderHelper> parameters(reader->helper());
354 position_ = reader->ReadPosition(); 325 position_ = reader->ReadPosition();
355 end_position_ = reader->ReadPosition(); 326 end_position_ = reader->ReadPosition();
356 flags_ = reader->ReadFlags(); 327 flags_ = reader->ReadFlags();
357 reader->ReadUInt(); // parent class binary offset. 328 reader->ReadUInt(); // parent class binary offset.
358 name_ = Name::ReadFrom(reader); 329 name_ = Name::ReadFrom(reader);
359 annotations_.ReadFromStatic<Expression>(reader); 330 annotations_.ReadFromStatic<Expression>(reader);
360 function_ = FunctionNode::ReadFrom(reader); 331 function_ = FunctionNode::ReadFrom(reader);
361 initializers_.ReadFromStatic<Initializer>(reader); 332 initializers_.ReadFromStatic<Initializer>(reader);
362 333
363 can_stream_ = annotations_.CanStream() && function_->can_stream() &&
364 initializers_.CanStream();
365
366 return this; 334 return this;
367 } 335 }
368 336
369 337
370 Procedure* Procedure::ReadFrom(Reader* reader) { 338 Procedure* Procedure::ReadFrom(Reader* reader) {
371 TRACE_READ_OFFSET(); 339 TRACE_READ_OFFSET();
372 kernel_offset_ = reader->offset(); // Notice the ReadTag() below. 340 kernel_offset_ = reader->offset(); // Notice the ReadTag() below.
373 Tag tag = reader->ReadTag(); 341 Tag tag = reader->ReadTag();
374 ASSERT(tag == kProcedure); 342 ASSERT(tag == kProcedure);
375 343
376 canonical_name_ = reader->ReadCanonicalNameReference(); 344 canonical_name_ = reader->ReadCanonicalNameReference();
377 VariableScope<ReaderHelper> parameters(reader->helper()); 345 VariableScope<ReaderHelper> parameters(reader->helper());
378 position_ = reader->ReadPosition(false); 346 position_ = reader->ReadPosition(false);
379 end_position_ = reader->ReadPosition(false); 347 end_position_ = reader->ReadPosition(false);
380 kind_ = static_cast<ProcedureKind>(reader->ReadByte()); 348 kind_ = static_cast<ProcedureKind>(reader->ReadByte());
381 flags_ = reader->ReadFlags(); 349 flags_ = reader->ReadFlags();
382 reader->ReadUInt(); // parent class binary offset (or 0). 350 reader->ReadUInt(); // parent class binary offset (or 0).
383 name_ = Name::ReadFrom(reader); 351 name_ = Name::ReadFrom(reader);
384 source_uri_index_ = reader->ReadUInt(); 352 source_uri_index_ = reader->ReadUInt();
385 reader->set_current_script_id(source_uri_index_); 353 reader->set_current_script_id(source_uri_index_);
386 reader->record_token_position(position_); 354 reader->record_token_position(position_);
387 reader->record_token_position(end_position_); 355 reader->record_token_position(end_position_);
388 annotations_.ReadFromStatic<Expression>(reader); 356 annotations_.ReadFromStatic<Expression>(reader);
389 function_ = reader->ReadOptional<FunctionNode>(); 357 function_ = reader->ReadOptional<FunctionNode>();
390 358
391 can_stream_ = annotations_.CanStream() &&
392 (function_ == NULL || function_->can_stream());
393
394 return this; 359 return this;
395 } 360 }
396 361
397 362
398 Initializer* Initializer::ReadFrom(Reader* reader) { 363 Initializer* Initializer::ReadFrom(Reader* reader) {
399 TRACE_READ_OFFSET(); 364 TRACE_READ_OFFSET();
400 Tag tag = reader->ReadTag(); 365 Tag tag = reader->ReadTag();
401 switch (tag) { 366 switch (tag) {
402 case kInvalidInitializer: 367 case kInvalidInitializer:
403 return InvalidInitializer::ReadFromImpl(reader); 368 return InvalidInitializer::ReadFromImpl(reader);
(...skipping 17 matching lines...) Expand all
421 return new InvalidInitializer(); 386 return new InvalidInitializer();
422 } 387 }
423 388
424 389
425 FieldInitializer* FieldInitializer::ReadFromImpl(Reader* reader) { 390 FieldInitializer* FieldInitializer::ReadFromImpl(Reader* reader) {
426 TRACE_READ_OFFSET(); 391 TRACE_READ_OFFSET();
427 FieldInitializer* initializer = new FieldInitializer(); 392 FieldInitializer* initializer = new FieldInitializer();
428 initializer->field_reference_ = Reference::ReadMemberFrom(reader); 393 initializer->field_reference_ = Reference::ReadMemberFrom(reader);
429 initializer->value_ = Expression::ReadFrom(reader); 394 initializer->value_ = Expression::ReadFrom(reader);
430 395
431 initializer->can_stream_ = initializer->value_->can_stream();
432
433 return initializer; 396 return initializer;
434 } 397 }
435 398
436 399
437 SuperInitializer* SuperInitializer::ReadFromImpl(Reader* reader) { 400 SuperInitializer* SuperInitializer::ReadFromImpl(Reader* reader) {
438 TRACE_READ_OFFSET(); 401 TRACE_READ_OFFSET();
439 SuperInitializer* init = new SuperInitializer(); 402 SuperInitializer* init = new SuperInitializer();
440 init->target_reference_ = Reference::ReadMemberFrom(reader); 403 init->target_reference_ = Reference::ReadMemberFrom(reader);
441 init->arguments_ = Arguments::ReadFrom(reader); 404 init->arguments_ = Arguments::ReadFrom(reader);
442 405
443 init->can_stream_ = init->arguments_->can_stream();
444
445 return init; 406 return init;
446 } 407 }
447 408
448 409
449 RedirectingInitializer* RedirectingInitializer::ReadFromImpl(Reader* reader) { 410 RedirectingInitializer* RedirectingInitializer::ReadFromImpl(Reader* reader) {
450 TRACE_READ_OFFSET(); 411 TRACE_READ_OFFSET();
451 RedirectingInitializer* init = new RedirectingInitializer(); 412 RedirectingInitializer* init = new RedirectingInitializer();
452 init->target_reference_ = Reference::ReadMemberFrom(reader); 413 init->target_reference_ = Reference::ReadMemberFrom(reader);
453 init->arguments_ = Arguments::ReadFrom(reader); 414 init->arguments_ = Arguments::ReadFrom(reader);
454 415
455 init->can_stream_ = init->arguments_->can_stream();
456
457 return init; 416 return init;
458 } 417 }
459 418
460 419
461 LocalInitializer* LocalInitializer::ReadFromImpl(Reader* reader) { 420 LocalInitializer* LocalInitializer::ReadFromImpl(Reader* reader) {
462 TRACE_READ_OFFSET(); 421 TRACE_READ_OFFSET();
463 LocalInitializer* init = new LocalInitializer(); 422 LocalInitializer* init = new LocalInitializer();
464 init->variable_ = VariableDeclaration::ReadFromImpl(reader, false); 423 init->variable_ = VariableDeclaration::ReadFromImpl(reader, false);
465 424
466 init->can_stream_ = init->variable_->can_stream();
467
468 return init; 425 return init;
469 } 426 }
470 427
471 428
472 Expression* Expression::ReadFrom(Reader* reader) { 429 Expression* Expression::ReadFrom(Reader* reader) {
473 TRACE_READ_OFFSET(); 430 TRACE_READ_OFFSET();
474 uint8_t payload = 0; 431 uint8_t payload = 0;
475 Tag tag = reader->ReadTag(&payload); 432 Tag tag = reader->ReadTag(&payload);
476 switch (tag) { 433 switch (tag) {
477 case kInvalidExpression: 434 case kInvalidExpression:
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 TRACE_READ_OFFSET(); 576 TRACE_READ_OFFSET();
620 VariableSet* set = new VariableSet(); 577 VariableSet* set = new VariableSet();
621 set->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 578 set->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
622 set->position_ = reader->ReadPosition(); 579 set->position_ = reader->ReadPosition();
623 set->variable_kernel_offset_ = reader->ReadUInt(); 580 set->variable_kernel_offset_ = reader->ReadUInt();
624 set->variable_ = reader->helper()->variables().Lookup(reader->ReadUInt()); 581 set->variable_ = reader->helper()->variables().Lookup(reader->ReadUInt());
625 ASSERT(set->variable_->kernel_offset_no_tag() == 582 ASSERT(set->variable_->kernel_offset_no_tag() ==
626 set->variable_kernel_offset_); 583 set->variable_kernel_offset_);
627 set->expression_ = Expression::ReadFrom(reader); 584 set->expression_ = Expression::ReadFrom(reader);
628 585
629 set->can_stream_ = set->expression_->can_stream();
630
631 return set; 586 return set;
632 } 587 }
633 588
634 589
635 VariableSet* VariableSet::ReadFrom(Reader* reader, uint8_t payload) { 590 VariableSet* VariableSet::ReadFrom(Reader* reader, uint8_t payload) {
636 TRACE_READ_OFFSET(); 591 TRACE_READ_OFFSET();
637 VariableSet* set = new VariableSet(); 592 VariableSet* set = new VariableSet();
638 set->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 593 set->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
639 set->variable_ = reader->helper()->variables().Lookup(payload); 594 set->variable_ = reader->helper()->variables().Lookup(payload);
640 set->position_ = reader->ReadPosition(); 595 set->position_ = reader->ReadPosition();
641 set->variable_kernel_offset_ = reader->ReadUInt(); 596 set->variable_kernel_offset_ = reader->ReadUInt();
642 ASSERT(set->variable_->kernel_offset_no_tag() == 597 ASSERT(set->variable_->kernel_offset_no_tag() ==
643 set->variable_kernel_offset_); 598 set->variable_kernel_offset_);
644 set->expression_ = Expression::ReadFrom(reader); 599 set->expression_ = Expression::ReadFrom(reader);
645 600
646 set->can_stream_ = set->expression_->can_stream();
647
648 return set; 601 return set;
649 } 602 }
650 603
651 604
652 PropertyGet* PropertyGet::ReadFrom(Reader* reader) { 605 PropertyGet* PropertyGet::ReadFrom(Reader* reader) {
653 TRACE_READ_OFFSET(); 606 TRACE_READ_OFFSET();
654 PropertyGet* get = new PropertyGet(); 607 PropertyGet* get = new PropertyGet();
655 get->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 608 get->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
656 get->position_ = reader->ReadPosition(); 609 get->position_ = reader->ReadPosition();
657 get->receiver_ = Expression::ReadFrom(reader); 610 get->receiver_ = Expression::ReadFrom(reader);
658 get->name_ = Name::ReadFrom(reader); 611 get->name_ = Name::ReadFrom(reader);
659 get->interface_target_reference_ = Reference::ReadMemberFrom(reader, true); 612 get->interface_target_reference_ = Reference::ReadMemberFrom(reader, true);
660 613
661 get->can_stream_ = get->receiver_->can_stream();
662
663 return get; 614 return get;
664 } 615 }
665 616
666 617
667 PropertySet* PropertySet::ReadFrom(Reader* reader) { 618 PropertySet* PropertySet::ReadFrom(Reader* reader) {
668 TRACE_READ_OFFSET(); 619 TRACE_READ_OFFSET();
669 PropertySet* set = new PropertySet(); 620 PropertySet* set = new PropertySet();
670 set->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 621 set->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
671 set->position_ = reader->ReadPosition(); 622 set->position_ = reader->ReadPosition();
672 set->receiver_ = Expression::ReadFrom(reader); 623 set->receiver_ = Expression::ReadFrom(reader);
673 set->name_ = Name::ReadFrom(reader); 624 set->name_ = Name::ReadFrom(reader);
674 set->value_ = Expression::ReadFrom(reader); 625 set->value_ = Expression::ReadFrom(reader);
675 set->interface_target_reference_ = Reference::ReadMemberFrom(reader, true); 626 set->interface_target_reference_ = Reference::ReadMemberFrom(reader, true);
676 627
677 set->can_stream_ = set->receiver_->can_stream() && set->value_->can_stream();
678
679 return set; 628 return set;
680 } 629 }
681 630
682 631
683 DirectPropertyGet* DirectPropertyGet::ReadFrom(Reader* reader) { 632 DirectPropertyGet* DirectPropertyGet::ReadFrom(Reader* reader) {
684 TRACE_READ_OFFSET(); 633 TRACE_READ_OFFSET();
685 DirectPropertyGet* get = new DirectPropertyGet(); 634 DirectPropertyGet* get = new DirectPropertyGet();
686 get->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 635 get->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
687 get->position_ = reader->ReadPosition(); 636 get->position_ = reader->ReadPosition();
688 get->receiver_ = Expression::ReadFrom(reader); 637 get->receiver_ = Expression::ReadFrom(reader);
689 get->target_reference_ = Reference::ReadMemberFrom(reader); 638 get->target_reference_ = Reference::ReadMemberFrom(reader);
690 639
691 get->can_stream_ = get->receiver_->can_stream();
692
693 return get; 640 return get;
694 } 641 }
695 642
696 643
697 DirectPropertySet* DirectPropertySet::ReadFrom(Reader* reader) { 644 DirectPropertySet* DirectPropertySet::ReadFrom(Reader* reader) {
698 TRACE_READ_OFFSET(); 645 TRACE_READ_OFFSET();
699 DirectPropertySet* set = new DirectPropertySet(); 646 DirectPropertySet* set = new DirectPropertySet();
700 set->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 647 set->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
701 set->position_ = reader->ReadPosition(); 648 set->position_ = reader->ReadPosition();
702 set->receiver_ = Expression::ReadFrom(reader); 649 set->receiver_ = Expression::ReadFrom(reader);
703 set->target_reference_ = Reference::ReadMemberFrom(reader); 650 set->target_reference_ = Reference::ReadMemberFrom(reader);
704 set->value_ = Expression::ReadFrom(reader); 651 set->value_ = Expression::ReadFrom(reader);
705 652
706 set->can_stream_ = set->receiver_->can_stream() && set->value_->can_stream();
707
708 return set; 653 return set;
709 } 654 }
710 655
711 656
712 StaticGet* StaticGet::ReadFrom(Reader* reader) { 657 StaticGet* StaticGet::ReadFrom(Reader* reader) {
713 TRACE_READ_OFFSET(); 658 TRACE_READ_OFFSET();
714 StaticGet* get = new StaticGet(); 659 StaticGet* get = new StaticGet();
715 get->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 660 get->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
716 get->position_ = reader->ReadPosition(); 661 get->position_ = reader->ReadPosition();
717 get->target_reference_ = Reference::ReadMemberFrom(reader); 662 get->target_reference_ = Reference::ReadMemberFrom(reader);
718 return get; 663 return get;
719 } 664 }
720 665
721 666
722 StaticSet* StaticSet::ReadFrom(Reader* reader) { 667 StaticSet* StaticSet::ReadFrom(Reader* reader) {
723 TRACE_READ_OFFSET(); 668 TRACE_READ_OFFSET();
724 StaticSet* set = new StaticSet(); 669 StaticSet* set = new StaticSet();
725 set->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 670 set->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
726 set->position_ = reader->ReadPosition(); 671 set->position_ = reader->ReadPosition();
727 set->target_reference_ = Reference::ReadMemberFrom(reader); 672 set->target_reference_ = Reference::ReadMemberFrom(reader);
728 set->expression_ = Expression::ReadFrom(reader); 673 set->expression_ = Expression::ReadFrom(reader);
729 674
730 set->can_stream_ = set->expression_->can_stream();
731
732 return set; 675 return set;
733 } 676 }
734 677
735 678
736 Arguments* Arguments::ReadFrom(Reader* reader) { 679 Arguments* Arguments::ReadFrom(Reader* reader) {
737 TRACE_READ_OFFSET(); 680 TRACE_READ_OFFSET();
738 Arguments* arguments = new Arguments(); 681 Arguments* arguments = new Arguments();
739 intptr_t num_arguments = reader->ReadUInt(); 682 intptr_t num_arguments = reader->ReadUInt();
740 arguments->types().ReadFromStatic<DartType>(reader); 683 arguments->types().ReadFromStatic<DartType>(reader);
741 arguments->positional().ReadFromStatic<Expression>(reader); 684 arguments->positional().ReadFromStatic<Expression>(reader);
742 arguments->named().ReadFromStatic<NamedExpression>(reader); 685 arguments->named().ReadFromStatic<NamedExpression>(reader);
743 ASSERT(arguments->count() == num_arguments); 686 ASSERT(arguments->count() == num_arguments);
744 687
745 arguments->can_stream_ =
746 arguments->positional().CanStream() && arguments->named().CanStream();
747
748 return arguments; 688 return arguments;
749 } 689 }
750 690
751 691
752 NamedExpression* NamedExpression::ReadFrom(Reader* reader) { 692 NamedExpression* NamedExpression::ReadFrom(Reader* reader) {
753 TRACE_READ_OFFSET(); 693 TRACE_READ_OFFSET();
754 StringIndex name_index(reader->ReadUInt()); 694 StringIndex name_index(reader->ReadUInt());
755 Expression* expression = Expression::ReadFrom(reader); 695 Expression* expression = Expression::ReadFrom(reader);
756 NamedExpression* named = new NamedExpression(name_index, expression); 696 NamedExpression* named = new NamedExpression(name_index, expression);
757 697
758 named->can_stream_ = expression->can_stream();
759
760 return named; 698 return named;
761 } 699 }
762 700
763 701
764 MethodInvocation* MethodInvocation::ReadFrom(Reader* reader) { 702 MethodInvocation* MethodInvocation::ReadFrom(Reader* reader) {
765 TRACE_READ_OFFSET(); 703 TRACE_READ_OFFSET();
766 MethodInvocation* invocation = new MethodInvocation(); 704 MethodInvocation* invocation = new MethodInvocation();
767 invocation->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 705 invocation->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
768 invocation->position_ = reader->ReadPosition(); 706 invocation->position_ = reader->ReadPosition();
769 invocation->receiver_ = Expression::ReadFrom(reader); 707 invocation->receiver_ = Expression::ReadFrom(reader);
770 invocation->name_ = Name::ReadFrom(reader); 708 invocation->name_ = Name::ReadFrom(reader);
771 invocation->arguments_ = Arguments::ReadFrom(reader); 709 invocation->arguments_ = Arguments::ReadFrom(reader);
772 invocation->interface_target_reference_ = 710 invocation->interface_target_reference_ =
773 Reference::ReadMemberFrom(reader, true); 711 Reference::ReadMemberFrom(reader, true);
774 712
775 invocation->can_stream_ = invocation->receiver_->can_stream() &&
776 invocation->arguments_->can_stream();
777
778 return invocation; 713 return invocation;
779 } 714 }
780 715
781 716
782 DirectMethodInvocation* DirectMethodInvocation::ReadFrom(Reader* reader) { 717 DirectMethodInvocation* DirectMethodInvocation::ReadFrom(Reader* reader) {
783 TRACE_READ_OFFSET(); 718 TRACE_READ_OFFSET();
784 DirectMethodInvocation* invocation = new DirectMethodInvocation(); 719 DirectMethodInvocation* invocation = new DirectMethodInvocation();
785 invocation->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 720 invocation->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
786 invocation->receiver_ = Expression::ReadFrom(reader); 721 invocation->receiver_ = Expression::ReadFrom(reader);
787 invocation->target_reference_ = Reference::ReadMemberFrom(reader); 722 invocation->target_reference_ = Reference::ReadMemberFrom(reader);
788 invocation->arguments_ = Arguments::ReadFrom(reader); 723 invocation->arguments_ = Arguments::ReadFrom(reader);
789 724
790 invocation->can_stream_ = invocation->receiver_->can_stream() &&
791 invocation->arguments_->can_stream();
792
793 return invocation; 725 return invocation;
794 } 726 }
795 727
796 728
797 StaticInvocation* StaticInvocation::ReadFrom(Reader* reader, bool is_const) { 729 StaticInvocation* StaticInvocation::ReadFrom(Reader* reader, bool is_const) {
798 TRACE_READ_OFFSET(); 730 TRACE_READ_OFFSET();
799 StaticInvocation* invocation = new StaticInvocation(); 731 StaticInvocation* invocation = new StaticInvocation();
800 invocation->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 732 invocation->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
801 invocation->is_const_ = is_const; 733 invocation->is_const_ = is_const;
802 invocation->position_ = reader->ReadPosition(); 734 invocation->position_ = reader->ReadPosition();
803 invocation->procedure_reference_ = Reference::ReadMemberFrom(reader); 735 invocation->procedure_reference_ = Reference::ReadMemberFrom(reader);
804 invocation->arguments_ = Arguments::ReadFrom(reader); 736 invocation->arguments_ = Arguments::ReadFrom(reader);
805 737
806 invocation->can_stream_ = invocation->arguments_->can_stream();
807
808 return invocation; 738 return invocation;
809 } 739 }
810 740
811 741
812 ConstructorInvocation* ConstructorInvocation::ReadFrom(Reader* reader, 742 ConstructorInvocation* ConstructorInvocation::ReadFrom(Reader* reader,
813 bool is_const) { 743 bool is_const) {
814 TRACE_READ_OFFSET(); 744 TRACE_READ_OFFSET();
815 ConstructorInvocation* invocation = new ConstructorInvocation(); 745 ConstructorInvocation* invocation = new ConstructorInvocation();
816 invocation->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 746 invocation->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
817 invocation->is_const_ = is_const; 747 invocation->is_const_ = is_const;
818 invocation->position_ = reader->ReadPosition(); 748 invocation->position_ = reader->ReadPosition();
819 invocation->target_reference_ = Reference::ReadMemberFrom(reader); 749 invocation->target_reference_ = Reference::ReadMemberFrom(reader);
820 invocation->arguments_ = Arguments::ReadFrom(reader); 750 invocation->arguments_ = Arguments::ReadFrom(reader);
821 751
822 invocation->can_stream_ = invocation->arguments_->can_stream();
823
824 return invocation; 752 return invocation;
825 } 753 }
826 754
827 755
828 Not* Not::ReadFrom(Reader* reader) { 756 Not* Not::ReadFrom(Reader* reader) {
829 TRACE_READ_OFFSET(); 757 TRACE_READ_OFFSET();
830 Not* n = new Not(); 758 Not* n = new Not();
831 n->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 759 n->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
832 n->expression_ = Expression::ReadFrom(reader); 760 n->expression_ = Expression::ReadFrom(reader);
833 761
834 n->can_stream_ = n->expression_->can_stream();
835
836 return n; 762 return n;
837 } 763 }
838 764
839 765
840 LogicalExpression* LogicalExpression::ReadFrom(Reader* reader) { 766 LogicalExpression* LogicalExpression::ReadFrom(Reader* reader) {
841 TRACE_READ_OFFSET(); 767 TRACE_READ_OFFSET();
842 LogicalExpression* expr = new LogicalExpression(); 768 LogicalExpression* expr = new LogicalExpression();
843 expr->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 769 expr->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
844 expr->left_ = Expression::ReadFrom(reader); 770 expr->left_ = Expression::ReadFrom(reader);
845 expr->operator_ = static_cast<Operator>(reader->ReadByte()); 771 expr->operator_ = static_cast<Operator>(reader->ReadByte());
846 expr->right_ = Expression::ReadFrom(reader); 772 expr->right_ = Expression::ReadFrom(reader);
847 773
848 expr->can_stream_ = expr->left_->can_stream() && expr->right_->can_stream();
849
850 return expr; 774 return expr;
851 } 775 }
852 776
853 777
854 ConditionalExpression* ConditionalExpression::ReadFrom(Reader* reader) { 778 ConditionalExpression* ConditionalExpression::ReadFrom(Reader* reader) {
855 TRACE_READ_OFFSET(); 779 TRACE_READ_OFFSET();
856 ConditionalExpression* expr = new ConditionalExpression(); 780 ConditionalExpression* expr = new ConditionalExpression();
857 expr->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 781 expr->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
858 expr->condition_ = Expression::ReadFrom(reader); 782 expr->condition_ = Expression::ReadFrom(reader);
859 expr->then_ = Expression::ReadFrom(reader); 783 expr->then_ = Expression::ReadFrom(reader);
860 expr->otherwise_ = Expression::ReadFrom(reader); 784 expr->otherwise_ = Expression::ReadFrom(reader);
861 reader->ReadOptional<DartType>(); // Unused static type. 785 reader->ReadOptional<DartType>(); // Unused static type.
862 786
863 expr->can_stream_ = expr->condition_->can_stream() &&
864 expr->then_->can_stream() &&
865 expr->otherwise_->can_stream();
866
867 return expr; 787 return expr;
868 } 788 }
869 789
870 790
871 StringConcatenation* StringConcatenation::ReadFrom(Reader* reader) { 791 StringConcatenation* StringConcatenation::ReadFrom(Reader* reader) {
872 TRACE_READ_OFFSET(); 792 TRACE_READ_OFFSET();
873 StringConcatenation* concat = new StringConcatenation(); 793 StringConcatenation* concat = new StringConcatenation();
874 concat->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 794 concat->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
875 concat->position_ = reader->ReadPosition(); 795 concat->position_ = reader->ReadPosition();
876 concat->expressions_.ReadFromStatic<Expression>(reader); 796 concat->expressions_.ReadFromStatic<Expression>(reader);
877 797
878 concat->can_stream_ = concat->expressions_.CanStream();
879
880 return concat; 798 return concat;
881 } 799 }
882 800
883 801
884 IsExpression* IsExpression::ReadFrom(Reader* reader) { 802 IsExpression* IsExpression::ReadFrom(Reader* reader) {
885 TRACE_READ_OFFSET(); 803 TRACE_READ_OFFSET();
886 IsExpression* expr = new IsExpression(); 804 IsExpression* expr = new IsExpression();
887 expr->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 805 expr->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
888 expr->position_ = reader->ReadPosition(); 806 expr->position_ = reader->ReadPosition();
889 expr->operand_ = Expression::ReadFrom(reader); 807 expr->operand_ = Expression::ReadFrom(reader);
890 expr->type_ = DartType::ReadFrom(reader); 808 expr->type_ = DartType::ReadFrom(reader);
891 809
892 expr->can_stream_ = expr->operand_->can_stream();
893
894 return expr; 810 return expr;
895 } 811 }
896 812
897 813
898 AsExpression* AsExpression::ReadFrom(Reader* reader) { 814 AsExpression* AsExpression::ReadFrom(Reader* reader) {
899 TRACE_READ_OFFSET(); 815 TRACE_READ_OFFSET();
900 AsExpression* expr = new AsExpression(); 816 AsExpression* expr = new AsExpression();
901 expr->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 817 expr->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
902 expr->position_ = reader->ReadPosition(); 818 expr->position_ = reader->ReadPosition();
903 expr->operand_ = Expression::ReadFrom(reader); 819 expr->operand_ = Expression::ReadFrom(reader);
904 expr->type_ = DartType::ReadFrom(reader); 820 expr->type_ = DartType::ReadFrom(reader);
905 821
906 expr->can_stream_ = expr->operand_->can_stream();
907
908 return expr; 822 return expr;
909 } 823 }
910 824
911 825
912 StringLiteral* StringLiteral::ReadFrom(Reader* reader) { 826 StringLiteral* StringLiteral::ReadFrom(Reader* reader) {
913 TRACE_READ_OFFSET(); 827 TRACE_READ_OFFSET();
914 intptr_t offset = reader->offset() - 1; // -1 to include tag byte. 828 intptr_t offset = reader->offset() - 1; // -1 to include tag byte.
915 StringLiteral* lit = new StringLiteral(StringIndex(reader->ReadUInt())); 829 StringLiteral* lit = new StringLiteral(StringIndex(reader->ReadUInt()));
916 lit->kernel_offset_ = offset; 830 lit->kernel_offset_ = offset;
917 return lit; 831 return lit;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 } 921 }
1008 922
1009 923
1010 Throw* Throw::ReadFrom(Reader* reader) { 924 Throw* Throw::ReadFrom(Reader* reader) {
1011 TRACE_READ_OFFSET(); 925 TRACE_READ_OFFSET();
1012 Throw* t = new Throw(); 926 Throw* t = new Throw();
1013 t->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 927 t->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1014 t->position_ = reader->ReadPosition(); 928 t->position_ = reader->ReadPosition();
1015 t->expression_ = Expression::ReadFrom(reader); 929 t->expression_ = Expression::ReadFrom(reader);
1016 930
1017 t->can_stream_ = t->expression_->can_stream();
1018
1019 return t; 931 return t;
1020 } 932 }
1021 933
1022 934
1023 ListLiteral* ListLiteral::ReadFrom(Reader* reader, bool is_const) { 935 ListLiteral* ListLiteral::ReadFrom(Reader* reader, bool is_const) {
1024 TRACE_READ_OFFSET(); 936 TRACE_READ_OFFSET();
1025 ListLiteral* literal = new ListLiteral(); 937 ListLiteral* literal = new ListLiteral();
1026 literal->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 938 literal->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1027 literal->is_const_ = is_const; 939 literal->is_const_ = is_const;
1028 literal->position_ = reader->ReadPosition(); 940 literal->position_ = reader->ReadPosition();
1029 literal->type_ = DartType::ReadFrom(reader); 941 literal->type_ = DartType::ReadFrom(reader);
1030 literal->expressions_.ReadFromStatic<Expression>(reader); 942 literal->expressions_.ReadFromStatic<Expression>(reader);
1031 943
1032 literal->can_stream_ = literal->expressions_.CanStream();
1033
1034 return literal; 944 return literal;
1035 } 945 }
1036 946
1037 947
1038 MapLiteral* MapLiteral::ReadFrom(Reader* reader, bool is_const) { 948 MapLiteral* MapLiteral::ReadFrom(Reader* reader, bool is_const) {
1039 TRACE_READ_OFFSET(); 949 TRACE_READ_OFFSET();
1040 MapLiteral* literal = new MapLiteral(); 950 MapLiteral* literal = new MapLiteral();
1041 literal->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 951 literal->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1042 literal->is_const_ = is_const; 952 literal->is_const_ = is_const;
1043 literal->position_ = reader->ReadPosition(); 953 literal->position_ = reader->ReadPosition();
1044 literal->key_type_ = DartType::ReadFrom(reader); 954 literal->key_type_ = DartType::ReadFrom(reader);
1045 literal->value_type_ = DartType::ReadFrom(reader); 955 literal->value_type_ = DartType::ReadFrom(reader);
1046 literal->entries_.ReadFromStatic<MapEntry>(reader); 956 literal->entries_.ReadFromStatic<MapEntry>(reader);
1047 957
1048 literal->can_stream_ = literal->entries_.CanStream();
1049
1050 return literal; 958 return literal;
1051 } 959 }
1052 960
1053 961
1054 MapEntry* MapEntry::ReadFrom(Reader* reader) { 962 MapEntry* MapEntry::ReadFrom(Reader* reader) {
1055 MapEntry* entry = new MapEntry(); 963 MapEntry* entry = new MapEntry();
1056 entry->key_ = Expression::ReadFrom(reader); 964 entry->key_ = Expression::ReadFrom(reader);
1057 entry->value_ = Expression::ReadFrom(reader); 965 entry->value_ = Expression::ReadFrom(reader);
1058 966
1059 entry->can_stream_ = entry->key_->can_stream() && entry->value_->can_stream();
1060
1061 return entry; 967 return entry;
1062 } 968 }
1063 969
1064 970
1065 AwaitExpression* AwaitExpression::ReadFrom(Reader* reader) { 971 AwaitExpression* AwaitExpression::ReadFrom(Reader* reader) {
1066 TRACE_READ_OFFSET(); 972 TRACE_READ_OFFSET();
1067 AwaitExpression* await = new AwaitExpression(); 973 AwaitExpression* await = new AwaitExpression();
1068 await->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 974 await->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1069 await->operand_ = Expression::ReadFrom(reader); 975 await->operand_ = Expression::ReadFrom(reader);
1070 976
1071 await->can_stream_ = await->operand_->can_stream();
1072
1073 return await; 977 return await;
1074 } 978 }
1075 979
1076 980
1077 FunctionExpression* FunctionExpression::ReadFrom(Reader* reader) { 981 FunctionExpression* FunctionExpression::ReadFrom(Reader* reader) {
1078 TRACE_READ_OFFSET(); 982 TRACE_READ_OFFSET();
1079 VariableScope<ReaderHelper> parameters(reader->helper()); 983 VariableScope<ReaderHelper> parameters(reader->helper());
1080 FunctionExpression* expr = new FunctionExpression(); 984 FunctionExpression* expr = new FunctionExpression();
1081 expr->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 985 expr->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1082 expr->function_ = FunctionNode::ReadFrom(reader); 986 expr->function_ = FunctionNode::ReadFrom(reader);
1083 987
1084 expr->can_stream_ = false;
1085
1086 return expr; 988 return expr;
1087 } 989 }
1088 990
1089 991
1090 Let* Let::ReadFrom(Reader* reader) { 992 Let* Let::ReadFrom(Reader* reader) {
1091 TRACE_READ_OFFSET(); 993 TRACE_READ_OFFSET();
1092 VariableScope<ReaderHelper> vars(reader->helper()); 994 VariableScope<ReaderHelper> vars(reader->helper());
1093 PositionScope scope(reader); 995 PositionScope scope(reader);
1094 996
1095 Let* let = new Let(); 997 Let* let = new Let();
1096 let->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 998 let->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1097 let->variable_ = VariableDeclaration::ReadFromImpl(reader, false); 999 let->variable_ = VariableDeclaration::ReadFromImpl(reader, false);
1098 let->body_ = Expression::ReadFrom(reader); 1000 let->body_ = Expression::ReadFrom(reader);
1099 let->position_ = reader->min_position(); 1001 let->position_ = reader->min_position();
1100 let->end_position_ = reader->max_position(); 1002 let->end_position_ = reader->max_position();
1101 1003
1102 let->can_stream_ = let->variable_->can_stream() && let->body_->can_stream();
1103
1104 return let; 1004 return let;
1105 } 1005 }
1106 1006
1107 1007
1108 VectorCreation* VectorCreation::ReadFrom(Reader* reader) { 1008 VectorCreation* VectorCreation::ReadFrom(Reader* reader) {
1109 TRACE_READ_OFFSET(); 1009 TRACE_READ_OFFSET();
1110 1010
1111 VectorCreation* vector_creation = new VectorCreation(); 1011 VectorCreation* vector_creation = new VectorCreation();
1112 vector_creation->kernel_offset_ = 1012 vector_creation->kernel_offset_ =
1113 reader->offset() - 1; // -1 to include tag byte. 1013 reader->offset() - 1; // -1 to include tag byte.
1114 vector_creation->value_ = reader->ReadUInt(); 1014 vector_creation->value_ = reader->ReadUInt();
1115 1015
1116 return vector_creation; 1016 return vector_creation;
1117 } 1017 }
1118 1018
1119 1019
1120 VectorGet* VectorGet::ReadFrom(Reader* reader) { 1020 VectorGet* VectorGet::ReadFrom(Reader* reader) {
1121 TRACE_READ_OFFSET(); 1021 TRACE_READ_OFFSET();
1122 1022
1123 VectorGet* vector_get = new VectorGet(); 1023 VectorGet* vector_get = new VectorGet();
1124 vector_get->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 1024 vector_get->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1125 vector_get->vector_expression_ = Expression::ReadFrom(reader); 1025 vector_get->vector_expression_ = Expression::ReadFrom(reader);
1126 vector_get->index_ = reader->ReadUInt(); 1026 vector_get->index_ = reader->ReadUInt();
1127 1027
1128 vector_get->can_stream_ = false;
1129
1130 return vector_get; 1028 return vector_get;
1131 } 1029 }
1132 1030
1133 1031
1134 VectorSet* VectorSet::ReadFrom(Reader* reader) { 1032 VectorSet* VectorSet::ReadFrom(Reader* reader) {
1135 TRACE_READ_OFFSET(); 1033 TRACE_READ_OFFSET();
1136 1034
1137 VectorSet* vector_set = new VectorSet(); 1035 VectorSet* vector_set = new VectorSet();
1138 vector_set->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 1036 vector_set->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1139 vector_set->vector_expression_ = Expression::ReadFrom(reader); 1037 vector_set->vector_expression_ = Expression::ReadFrom(reader);
1140 vector_set->index_ = reader->ReadUInt(); 1038 vector_set->index_ = reader->ReadUInt();
1141 vector_set->value_ = Expression::ReadFrom(reader); 1039 vector_set->value_ = Expression::ReadFrom(reader);
1142 1040
1143 vector_set->can_stream_ = false;
1144
1145 return vector_set; 1041 return vector_set;
1146 } 1042 }
1147 1043
1148 1044
1149 VectorCopy* VectorCopy::ReadFrom(Reader* reader) { 1045 VectorCopy* VectorCopy::ReadFrom(Reader* reader) {
1150 TRACE_READ_OFFSET(); 1046 TRACE_READ_OFFSET();
1151 1047
1152 VectorCopy* vector_copy = new VectorCopy(); 1048 VectorCopy* vector_copy = new VectorCopy();
1153 vector_copy->kernel_offset_ = 1049 vector_copy->kernel_offset_ =
1154 reader->offset() - 1; // -1 to include tag byte. 1050 reader->offset() - 1; // -1 to include tag byte.
1155 vector_copy->vector_expression_ = Expression::ReadFrom(reader); 1051 vector_copy->vector_expression_ = Expression::ReadFrom(reader);
1156 1052
1157 vector_copy->can_stream_ = false;
1158
1159 return vector_copy; 1053 return vector_copy;
1160 } 1054 }
1161 1055
1162 1056
1163 ClosureCreation* ClosureCreation::ReadFrom(Reader* reader) { 1057 ClosureCreation* ClosureCreation::ReadFrom(Reader* reader) {
1164 TRACE_READ_OFFSET(); 1058 TRACE_READ_OFFSET();
1165 1059
1166 ClosureCreation* closure_creation = new ClosureCreation(); 1060 ClosureCreation* closure_creation = new ClosureCreation();
1167 closure_creation->kernel_offset_ = 1061 closure_creation->kernel_offset_ =
1168 reader->offset() - 1; // to include tag byte. 1062 reader->offset() - 1; // to include tag byte.
1169 closure_creation->top_level_function_reference_ = 1063 closure_creation->top_level_function_reference_ =
1170 Reference::ReadMemberFrom(reader); 1064 Reference::ReadMemberFrom(reader);
1171 closure_creation->context_vector_ = Expression::ReadFrom(reader); 1065 closure_creation->context_vector_ = Expression::ReadFrom(reader);
1172 closure_creation->function_type_ = 1066 closure_creation->function_type_ =
1173 FunctionType::Cast(DartType::ReadFrom(reader)); 1067 FunctionType::Cast(DartType::ReadFrom(reader));
1174 1068
1175 closure_creation->can_stream_ = false;
1176
1177 return closure_creation; 1069 return closure_creation;
1178 } 1070 }
1179 1071
1180 1072
1181 Statement* Statement::ReadFrom(Reader* reader) { 1073 Statement* Statement::ReadFrom(Reader* reader) {
1182 TRACE_READ_OFFSET(); 1074 TRACE_READ_OFFSET();
1183 Tag tag = reader->ReadTag(); 1075 Tag tag = reader->ReadTag();
1184 switch (tag) { 1076 switch (tag) {
1185 case kInvalidStatement: 1077 case kInvalidStatement:
1186 return InvalidStatement::ReadFrom(reader); 1078 return InvalidStatement::ReadFrom(reader);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 } 1131 }
1240 1132
1241 1133
1242 ExpressionStatement* ExpressionStatement::ReadFrom(Reader* reader) { 1134 ExpressionStatement* ExpressionStatement::ReadFrom(Reader* reader) {
1243 TRACE_READ_OFFSET(); 1135 TRACE_READ_OFFSET();
1244 intptr_t offset = reader->offset() - 1; // -1 to include tag byte. 1136 intptr_t offset = reader->offset() - 1; // -1 to include tag byte.
1245 ExpressionStatement* stmt = 1137 ExpressionStatement* stmt =
1246 new ExpressionStatement(Expression::ReadFrom(reader)); 1138 new ExpressionStatement(Expression::ReadFrom(reader));
1247 stmt->kernel_offset_ = offset; 1139 stmt->kernel_offset_ = offset;
1248 1140
1249 stmt->can_stream_ = stmt->expression_->can_stream();
1250
1251 return stmt; 1141 return stmt;
1252 } 1142 }
1253 1143
1254 1144
1255 Block* Block::ReadFromImpl(Reader* reader) { 1145 Block* Block::ReadFromImpl(Reader* reader) {
1256 TRACE_READ_OFFSET(); 1146 TRACE_READ_OFFSET();
1257 PositionScope scope(reader); 1147 PositionScope scope(reader);
1258 1148
1259 VariableScope<ReaderHelper> vars(reader->helper()); 1149 VariableScope<ReaderHelper> vars(reader->helper());
1260 Block* block = new Block(); 1150 Block* block = new Block();
1261 block->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 1151 block->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1262 block->statements().ReadFromStatic<Statement>(reader); 1152 block->statements().ReadFromStatic<Statement>(reader);
1263 block->position_ = reader->min_position(); 1153 block->position_ = reader->min_position();
1264 block->end_position_ = reader->max_position(); 1154 block->end_position_ = reader->max_position();
1265 1155
1266 block->can_stream_ = block->statements().CanStream();
1267
1268 return block; 1156 return block;
1269 } 1157 }
1270 1158
1271 1159
1272 EmptyStatement* EmptyStatement::ReadFrom(Reader* reader) { 1160 EmptyStatement* EmptyStatement::ReadFrom(Reader* reader) {
1273 TRACE_READ_OFFSET(); 1161 TRACE_READ_OFFSET();
1274 EmptyStatement* stmt = new EmptyStatement(); 1162 EmptyStatement* stmt = new EmptyStatement();
1275 stmt->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 1163 stmt->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1276 return stmt; 1164 return stmt;
1277 } 1165 }
1278 1166
1279 1167
1280 AssertStatement* AssertStatement::ReadFrom(Reader* reader) { 1168 AssertStatement* AssertStatement::ReadFrom(Reader* reader) {
1281 TRACE_READ_OFFSET(); 1169 TRACE_READ_OFFSET();
1282 AssertStatement* stmt = new AssertStatement(); 1170 AssertStatement* stmt = new AssertStatement();
1283 stmt->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 1171 stmt->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1284 stmt->condition_ = Expression::ReadFrom(reader); 1172 stmt->condition_ = Expression::ReadFrom(reader);
1285 stmt->message_ = reader->ReadOptional<Expression>(); 1173 stmt->message_ = reader->ReadOptional<Expression>();
1286 1174
1287 stmt->can_stream_ = stmt->condition_->can_stream() &&
1288 (stmt->message_ == NULL || stmt->message_->can_stream());
1289
1290 return stmt; 1175 return stmt;
1291 } 1176 }
1292 1177
1293 1178
1294 LabeledStatement* LabeledStatement::ReadFrom(Reader* reader) { 1179 LabeledStatement* LabeledStatement::ReadFrom(Reader* reader) {
1295 TRACE_READ_OFFSET(); 1180 TRACE_READ_OFFSET();
1296 LabeledStatement* stmt = new LabeledStatement(); 1181 LabeledStatement* stmt = new LabeledStatement();
1297 stmt->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 1182 stmt->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1298 1183
1299 reader->helper()->labels()->Push(stmt); 1184 reader->helper()->labels()->Push(stmt);
1300 stmt->body_ = Statement::ReadFrom(reader); 1185 stmt->body_ = Statement::ReadFrom(reader);
1301 reader->helper()->labels()->Pop(stmt); 1186 reader->helper()->labels()->Pop(stmt);
1302 1187
1303 stmt->can_stream_ = stmt->body_->can_stream();
1304
1305 return stmt; 1188 return stmt;
1306 } 1189 }
1307 1190
1308 1191
1309 BreakStatement* BreakStatement::ReadFrom(Reader* reader) { 1192 BreakStatement* BreakStatement::ReadFrom(Reader* reader) {
1310 TRACE_READ_OFFSET(); 1193 TRACE_READ_OFFSET();
1311 BreakStatement* stmt = new BreakStatement(); 1194 BreakStatement* stmt = new BreakStatement();
1312 stmt->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 1195 stmt->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1313 stmt->position_ = reader->ReadPosition(); 1196 stmt->position_ = reader->ReadPosition();
1314 stmt->target_index_ = reader->ReadUInt(); 1197 stmt->target_index_ = reader->ReadUInt();
1315 return stmt; 1198 return stmt;
1316 } 1199 }
1317 1200
1318 1201
1319 WhileStatement* WhileStatement::ReadFrom(Reader* reader) { 1202 WhileStatement* WhileStatement::ReadFrom(Reader* reader) {
1320 TRACE_READ_OFFSET(); 1203 TRACE_READ_OFFSET();
1321 WhileStatement* stmt = new WhileStatement(); 1204 WhileStatement* stmt = new WhileStatement();
1322 stmt->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 1205 stmt->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1323 stmt->condition_ = Expression::ReadFrom(reader); 1206 stmt->condition_ = Expression::ReadFrom(reader);
1324 stmt->body_ = Statement::ReadFrom(reader); 1207 stmt->body_ = Statement::ReadFrom(reader);
1325 1208
1326 stmt->can_stream_ =
1327 stmt->condition_->can_stream() && stmt->body_->can_stream();
1328
1329 return stmt; 1209 return stmt;
1330 } 1210 }
1331 1211
1332 1212
1333 DoStatement* DoStatement::ReadFrom(Reader* reader) { 1213 DoStatement* DoStatement::ReadFrom(Reader* reader) {
1334 TRACE_READ_OFFSET(); 1214 TRACE_READ_OFFSET();
1335 DoStatement* dostmt = new DoStatement(); 1215 DoStatement* dostmt = new DoStatement();
1336 dostmt->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 1216 dostmt->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1337 dostmt->body_ = Statement::ReadFrom(reader); 1217 dostmt->body_ = Statement::ReadFrom(reader);
1338 dostmt->condition_ = Expression::ReadFrom(reader); 1218 dostmt->condition_ = Expression::ReadFrom(reader);
1339 1219
1340 dostmt->can_stream_ =
1341 dostmt->body_->can_stream() && dostmt->condition_->can_stream();
1342
1343 return dostmt; 1220 return dostmt;
1344 } 1221 }
1345 1222
1346 1223
1347 ForStatement* ForStatement::ReadFrom(Reader* reader) { 1224 ForStatement* ForStatement::ReadFrom(Reader* reader) {
1348 TRACE_READ_OFFSET(); 1225 TRACE_READ_OFFSET();
1349 VariableScope<ReaderHelper> vars(reader->helper()); 1226 VariableScope<ReaderHelper> vars(reader->helper());
1350 PositionScope scope(reader); 1227 PositionScope scope(reader);
1351 1228
1352 ForStatement* forstmt = new ForStatement(); 1229 ForStatement* forstmt = new ForStatement();
1353 forstmt->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 1230 forstmt->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1354 forstmt->variables_.ReadFromStatic<VariableDeclarationImpl>(reader); 1231 forstmt->variables_.ReadFromStatic<VariableDeclarationImpl>(reader);
1355 forstmt->condition_ = reader->ReadOptional<Expression>(); 1232 forstmt->condition_ = reader->ReadOptional<Expression>();
1356 forstmt->updates_.ReadFromStatic<Expression>(reader); 1233 forstmt->updates_.ReadFromStatic<Expression>(reader);
1357 forstmt->body_ = Statement::ReadFrom(reader); 1234 forstmt->body_ = Statement::ReadFrom(reader);
1358 forstmt->end_position_ = reader->max_position(); 1235 forstmt->end_position_ = reader->max_position();
1359 forstmt->position_ = reader->min_position(); 1236 forstmt->position_ = reader->min_position();
1360 1237
1361 forstmt->can_stream_ =
1362 forstmt->body_->can_stream() &&
1363 (forstmt->condition_ == NULL || forstmt->condition_->can_stream()) &&
1364 forstmt->variables_.CanStream() && forstmt->updates_.CanStream();
1365
1366 return forstmt; 1238 return forstmt;
1367 } 1239 }
1368 1240
1369 1241
1370 ForInStatement* ForInStatement::ReadFrom(Reader* reader, bool is_async) { 1242 ForInStatement* ForInStatement::ReadFrom(Reader* reader, bool is_async) {
1371 TRACE_READ_OFFSET(); 1243 TRACE_READ_OFFSET();
1372 VariableScope<ReaderHelper> vars(reader->helper()); 1244 VariableScope<ReaderHelper> vars(reader->helper());
1373 PositionScope scope(reader); 1245 PositionScope scope(reader);
1374 1246
1375 ForInStatement* forinstmt = new ForInStatement(); 1247 ForInStatement* forinstmt = new ForInStatement();
1376 forinstmt->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 1248 forinstmt->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1377 forinstmt->is_async_ = is_async; 1249 forinstmt->is_async_ = is_async;
1378 forinstmt->position_ = reader->ReadPosition(); 1250 forinstmt->position_ = reader->ReadPosition();
1379 forinstmt->variable_ = VariableDeclaration::ReadFromImpl(reader, false); 1251 forinstmt->variable_ = VariableDeclaration::ReadFromImpl(reader, false);
1380 forinstmt->iterable_ = Expression::ReadFrom(reader); 1252 forinstmt->iterable_ = Expression::ReadFrom(reader);
1381 forinstmt->body_ = Statement::ReadFrom(reader); 1253 forinstmt->body_ = Statement::ReadFrom(reader);
1382 forinstmt->end_position_ = reader->max_position(); 1254 forinstmt->end_position_ = reader->max_position();
1383 if (!forinstmt->position_.IsReal()) { 1255 if (!forinstmt->position_.IsReal()) {
1384 forinstmt->position_ = reader->min_position(); 1256 forinstmt->position_ = reader->min_position();
1385 } 1257 }
1386 forinstmt->variable_->set_end_position(forinstmt->position_); 1258 forinstmt->variable_->set_end_position(forinstmt->position_);
1387 1259
1388 forinstmt->can_stream_ = forinstmt->variable_->can_stream() &&
1389 forinstmt->iterable_->can_stream() &&
1390 forinstmt->body_->can_stream();
1391
1392 return forinstmt; 1260 return forinstmt;
1393 } 1261 }
1394 1262
1395 1263
1396 SwitchStatement* SwitchStatement::ReadFrom(Reader* reader) { 1264 SwitchStatement* SwitchStatement::ReadFrom(Reader* reader) {
1397 TRACE_READ_OFFSET(); 1265 TRACE_READ_OFFSET();
1398 SwitchStatement* stmt = new SwitchStatement(); 1266 SwitchStatement* stmt = new SwitchStatement();
1399 stmt->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 1267 stmt->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1400 stmt->condition_ = Expression::ReadFrom(reader); 1268 stmt->condition_ = Expression::ReadFrom(reader);
1401 int count = reader->ReadUInt(); 1269 int count = reader->ReadUInt();
1402 stmt->cases_.EnsureInitialized(count); 1270 stmt->cases_.EnsureInitialized(count);
1403 for (intptr_t i = 0; i < count; i++) { 1271 for (intptr_t i = 0; i < count; i++) {
1404 SwitchCase* sc = stmt->cases_.GetOrCreate<SwitchCase>(i); 1272 SwitchCase* sc = stmt->cases_.GetOrCreate<SwitchCase>(i);
1405 sc->ReadFrom(reader); 1273 sc->ReadFrom(reader);
1406 } 1274 }
1407 1275
1408 stmt->can_stream_ =
1409 stmt->condition_->can_stream() && stmt->cases_.CanStream();
1410
1411 return stmt; 1276 return stmt;
1412 } 1277 }
1413 1278
1414 1279
1415 SwitchCase* SwitchCase::ReadFrom(Reader* reader) { 1280 SwitchCase* SwitchCase::ReadFrom(Reader* reader) {
1416 TRACE_READ_OFFSET(); 1281 TRACE_READ_OFFSET();
1417 int length = reader->ReadListLength(); 1282 int length = reader->ReadListLength();
1418 expressions_.EnsureInitialized(length); 1283 expressions_.EnsureInitialized(length);
1419 1284
1420 for (intptr_t i = 0; i < length; i++) { 1285 for (intptr_t i = 0; i < length; i++) {
1421 ASSERT(expressions_[i] == NULL); 1286 ASSERT(expressions_[i] == NULL);
1422 TokenPosition position = reader->ReadPosition(); 1287 TokenPosition position = reader->ReadPosition();
1423 expressions_[i] = Expression::ReadFrom(reader); 1288 expressions_[i] = Expression::ReadFrom(reader);
1424 expressions_[i]->set_position(position); 1289 expressions_[i]->set_position(position);
1425 } 1290 }
1426 is_default_ = reader->ReadBool(); 1291 is_default_ = reader->ReadBool();
1427 body_ = Statement::ReadFrom(reader); 1292 body_ = Statement::ReadFrom(reader);
1428 1293
1429 can_stream_ = expressions_.CanStream() && body_->can_stream();
1430
1431 return this; 1294 return this;
1432 } 1295 }
1433 1296
1434 1297
1435 ContinueSwitchStatement* ContinueSwitchStatement::ReadFrom(Reader* reader) { 1298 ContinueSwitchStatement* ContinueSwitchStatement::ReadFrom(Reader* reader) {
1436 TRACE_READ_OFFSET(); 1299 TRACE_READ_OFFSET();
1437 ContinueSwitchStatement* stmt = new ContinueSwitchStatement(); 1300 ContinueSwitchStatement* stmt = new ContinueSwitchStatement();
1438 stmt->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 1301 stmt->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1439 stmt->target_index_ = reader->ReadUInt(); 1302 stmt->target_index_ = reader->ReadUInt();
1440 1303
1441 return stmt; 1304 return stmt;
1442 } 1305 }
1443 1306
1444 1307
1445 IfStatement* IfStatement::ReadFrom(Reader* reader) { 1308 IfStatement* IfStatement::ReadFrom(Reader* reader) {
1446 TRACE_READ_OFFSET(); 1309 TRACE_READ_OFFSET();
1447 IfStatement* ifstmt = new IfStatement(); 1310 IfStatement* ifstmt = new IfStatement();
1448 ifstmt->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 1311 ifstmt->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1449 ifstmt->condition_ = Expression::ReadFrom(reader); 1312 ifstmt->condition_ = Expression::ReadFrom(reader);
1450 ifstmt->then_ = Statement::ReadFrom(reader); 1313 ifstmt->then_ = Statement::ReadFrom(reader);
1451 ifstmt->otherwise_ = Statement::ReadFrom(reader); 1314 ifstmt->otherwise_ = Statement::ReadFrom(reader);
1452 1315
1453 ifstmt->can_stream_ = ifstmt->condition_->can_stream() &&
1454 ifstmt->then_->can_stream() &&
1455 ifstmt->otherwise_->can_stream();
1456
1457 return ifstmt; 1316 return ifstmt;
1458 } 1317 }
1459 1318
1460 1319
1461 ReturnStatement* ReturnStatement::ReadFrom(Reader* reader) { 1320 ReturnStatement* ReturnStatement::ReadFrom(Reader* reader) {
1462 TRACE_READ_OFFSET(); 1321 TRACE_READ_OFFSET();
1463 ReturnStatement* ret = new ReturnStatement(); 1322 ReturnStatement* ret = new ReturnStatement();
1464 ret->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 1323 ret->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1465 ret->position_ = reader->ReadPosition(); 1324 ret->position_ = reader->ReadPosition();
1466 ret->expression_ = reader->ReadOptional<Expression>(); 1325 ret->expression_ = reader->ReadOptional<Expression>();
1467 1326
1468 ret->can_stream_ =
1469 (ret->expression_ == NULL || ret->expression_->can_stream());
1470
1471 return ret; 1327 return ret;
1472 } 1328 }
1473 1329
1474 1330
1475 TryCatch* TryCatch::ReadFrom(Reader* reader) { 1331 TryCatch* TryCatch::ReadFrom(Reader* reader) {
1476 TRACE_READ_OFFSET(); 1332 TRACE_READ_OFFSET();
1477 PositionScope scope(reader); 1333 PositionScope scope(reader);
1478 1334
1479 TryCatch* tc = new TryCatch(); 1335 TryCatch* tc = new TryCatch();
1480 tc->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 1336 tc->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1481 tc->body_ = Statement::ReadFrom(reader); 1337 tc->body_ = Statement::ReadFrom(reader);
1482 reader->ReadBool(); // whether any catch needs a stacktrace. 1338 reader->ReadBool(); // whether any catch needs a stacktrace.
1483 tc->catches_.ReadFromStatic<Catch>(reader); 1339 tc->catches_.ReadFromStatic<Catch>(reader);
1484 tc->position_ = reader->min_position(); 1340 tc->position_ = reader->min_position();
1485 1341
1486 tc->can_stream_ = tc->body_->can_stream() && tc->catches_.CanStream();
1487
1488 return tc; 1342 return tc;
1489 } 1343 }
1490 1344
1491 1345
1492 Catch* Catch::ReadFrom(Reader* reader) { 1346 Catch* Catch::ReadFrom(Reader* reader) {
1493 TRACE_READ_OFFSET(); 1347 TRACE_READ_OFFSET();
1494 VariableScope<ReaderHelper> vars(reader->helper()); 1348 VariableScope<ReaderHelper> vars(reader->helper());
1495 PositionScope scope(reader); 1349 PositionScope scope(reader);
1496 1350
1497 Catch* c = new Catch(); 1351 Catch* c = new Catch();
1498 c->kernel_offset_ = reader->offset(); // Catch has no tag. 1352 c->kernel_offset_ = reader->offset(); // Catch has no tag.
1499 c->guard_ = DartType::ReadFrom(reader); 1353 c->guard_ = DartType::ReadFrom(reader);
1500 c->exception_ = 1354 c->exception_ =
1501 reader->ReadOptional<VariableDeclaration, VariableDeclarationImpl>(); 1355 reader->ReadOptional<VariableDeclaration, VariableDeclarationImpl>();
1502 c->stack_trace_ = 1356 c->stack_trace_ =
1503 reader->ReadOptional<VariableDeclaration, VariableDeclarationImpl>(); 1357 reader->ReadOptional<VariableDeclaration, VariableDeclarationImpl>();
1504 c->body_ = Statement::ReadFrom(reader); 1358 c->body_ = Statement::ReadFrom(reader);
1505 c->end_position_ = reader->max_position(); 1359 c->end_position_ = reader->max_position();
1506 c->position_ = reader->min_position(); 1360 c->position_ = reader->min_position();
1507 1361
1508 c->can_stream_ = c->body_->can_stream();
1509
1510 return c; 1362 return c;
1511 } 1363 }
1512 1364
1513 1365
1514 TryFinally* TryFinally::ReadFrom(Reader* reader) { 1366 TryFinally* TryFinally::ReadFrom(Reader* reader) {
1515 TRACE_READ_OFFSET(); 1367 TRACE_READ_OFFSET();
1516 TryFinally* tf = new TryFinally(); 1368 TryFinally* tf = new TryFinally();
1517 tf->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 1369 tf->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1518 tf->body_ = Statement::ReadFrom(reader); 1370 tf->body_ = Statement::ReadFrom(reader);
1519 tf->finalizer_ = Statement::ReadFrom(reader); 1371 tf->finalizer_ = Statement::ReadFrom(reader);
1520 1372
1521 tf->can_stream_ = tf->body_->can_stream() && tf->finalizer_->can_stream();
1522
1523 return tf; 1373 return tf;
1524 } 1374 }
1525 1375
1526 1376
1527 YieldStatement* YieldStatement::ReadFrom(Reader* reader) { 1377 YieldStatement* YieldStatement::ReadFrom(Reader* reader) {
1528 TRACE_READ_OFFSET(); 1378 TRACE_READ_OFFSET();
1529 YieldStatement* stmt = new YieldStatement(); 1379 YieldStatement* stmt = new YieldStatement();
1530 stmt->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 1380 stmt->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1531 stmt->position_ = reader->ReadPosition(); 1381 stmt->position_ = reader->ReadPosition();
1532 reader->record_yield_token_position(stmt->position_); 1382 reader->record_yield_token_position(stmt->position_);
1533 stmt->flags_ = reader->ReadByte(); 1383 stmt->flags_ = reader->ReadByte();
1534 stmt->expression_ = Expression::ReadFrom(reader); 1384 stmt->expression_ = Expression::ReadFrom(reader);
1535 1385
1536 stmt->can_stream_ = stmt->expression_->can_stream();
1537
1538 return stmt; 1386 return stmt;
1539 } 1387 }
1540 1388
1541 1389
1542 VariableDeclaration* VariableDeclaration::ReadFrom(Reader* reader) { 1390 VariableDeclaration* VariableDeclaration::ReadFrom(Reader* reader) {
1543 TRACE_READ_OFFSET(); 1391 TRACE_READ_OFFSET();
1544 Tag tag = reader->ReadTag(); 1392 Tag tag = reader->ReadTag();
1545 ASSERT(tag == kVariableDeclaration); 1393 ASSERT(tag == kVariableDeclaration);
1546 return VariableDeclaration::ReadFromImpl(reader, true); 1394 return VariableDeclaration::ReadFromImpl(reader, true);
1547 } 1395 }
(...skipping 15 matching lines...) Expand all
1563 decl->type_ = DartType::ReadFrom(reader); 1411 decl->type_ = DartType::ReadFrom(reader);
1564 decl->initializer_ = reader->ReadOptional<Expression>(); 1412 decl->initializer_ = reader->ReadOptional<Expression>();
1565 1413
1566 // Go to next token position so it ends *after* the last potentially 1414 // Go to next token position so it ends *after* the last potentially
1567 // debuggable position in the initializer. 1415 // debuggable position in the initializer.
1568 TokenPosition position = reader->max_position(); 1416 TokenPosition position = reader->max_position();
1569 if (position.IsReal()) position.Next(); 1417 if (position.IsReal()) position.Next();
1570 decl->end_position_ = position; 1418 decl->end_position_ = position;
1571 reader->helper()->variables().Push(decl); 1419 reader->helper()->variables().Push(decl);
1572 1420
1573 decl->can_stream_ =
1574 (decl->initializer_ == NULL || decl->initializer_->can_stream());
1575
1576 return decl; 1421 return decl;
1577 } 1422 }
1578 1423
1579 1424
1580 FunctionDeclaration* FunctionDeclaration::ReadFrom(Reader* reader) { 1425 FunctionDeclaration* FunctionDeclaration::ReadFrom(Reader* reader) {
1581 TRACE_READ_OFFSET(); 1426 TRACE_READ_OFFSET();
1582 FunctionDeclaration* decl = new FunctionDeclaration(); 1427 FunctionDeclaration* decl = new FunctionDeclaration();
1583 decl->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 1428 decl->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1584 decl->position_ = reader->ReadPosition(); 1429 decl->position_ = reader->ReadPosition();
1585 decl->variable_ = VariableDeclaration::ReadFromImpl(reader, false); 1430 decl->variable_ = VariableDeclaration::ReadFromImpl(reader, false);
1586 VariableScope<ReaderHelper> parameters(reader->helper()); 1431 VariableScope<ReaderHelper> parameters(reader->helper());
1587 decl->function_ = FunctionNode::ReadFrom(reader); 1432 decl->function_ = FunctionNode::ReadFrom(reader);
1588 1433
1589 decl->can_stream_ = false;
1590
1591 return decl; 1434 return decl;
1592 } 1435 }
1593 1436
1594 1437
1595 Name* Name::ReadFrom(Reader* reader) { 1438 Name* Name::ReadFrom(Reader* reader) {
1596 StringIndex name_index(reader->ReadUInt()); 1439 StringIndex name_index(reader->ReadUInt());
1597 if ((reader->StringLength(name_index) >= 1) && 1440 if ((reader->StringLength(name_index) >= 1) &&
1598 (reader->CharacterAt(name_index, 0) == '_')) { 1441 (reader->CharacterAt(name_index, 0) == '_')) {
1599 intptr_t library_reference = reader->ReadCanonicalNameReference(); 1442 intptr_t library_reference = reader->ReadCanonicalNameReference();
1600 return new Name(name_index, library_reference); 1443 return new Name(name_index, library_reference);
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1777 1620
1778 int libraries = reader->ReadUInt(); 1621 int libraries = reader->ReadUInt();
1779 program->libraries().EnsureInitialized(libraries); 1622 program->libraries().EnsureInitialized(libraries);
1780 for (intptr_t i = 0; i < libraries; i++) { 1623 for (intptr_t i = 0; i < libraries; i++) {
1781 program->libraries().GetOrCreate<Library>(i)->ReadFrom(reader); 1624 program->libraries().GetOrCreate<Library>(i)->ReadFrom(reader);
1782 } 1625 }
1783 1626
1784 program->main_method_reference_ = 1627 program->main_method_reference_ =
1785 Reference::ReadMemberFrom(reader, /*allow_null=*/true); 1628 Reference::ReadMemberFrom(reader, /*allow_null=*/true);
1786 1629
1787 program->can_stream_ = false;
1788
1789 return program; 1630 return program;
1790 } 1631 }
1791 1632
1792 1633
1793 FunctionNode* FunctionNode::ReadFrom(Reader* reader) { 1634 FunctionNode* FunctionNode::ReadFrom(Reader* reader) {
1794 TRACE_READ_OFFSET(); 1635 TRACE_READ_OFFSET();
1795 TypeParameterScope<ReaderHelper> scope(reader->helper()); 1636 TypeParameterScope<ReaderHelper> scope(reader->helper());
1796 1637
1797 FunctionNode* function = new FunctionNode(); 1638 FunctionNode* function = new FunctionNode();
1798 // FunctionNode tag not read yet. 1639 // FunctionNode tag not read yet.
(...skipping 12 matching lines...) Expand all
1811 function->positional_parameters().ReadFromStatic<VariableDeclarationImpl>( 1652 function->positional_parameters().ReadFromStatic<VariableDeclarationImpl>(
1812 reader); 1653 reader);
1813 function->named_parameters().ReadFromStatic<VariableDeclarationImpl>(reader); 1654 function->named_parameters().ReadFromStatic<VariableDeclarationImpl>(reader);
1814 function->return_type_ = DartType::ReadFrom(reader); 1655 function->return_type_ = DartType::ReadFrom(reader);
1815 1656
1816 LabelScope<ReaderHelper, BlockStack<LabeledStatement> > labels( 1657 LabelScope<ReaderHelper, BlockStack<LabeledStatement> > labels(
1817 reader->helper()); 1658 reader->helper());
1818 VariableScope<ReaderHelper> vars(reader->helper()); 1659 VariableScope<ReaderHelper> vars(reader->helper());
1819 function->body_ = reader->ReadOptional<Statement>(); 1660 function->body_ = reader->ReadOptional<Statement>();
1820 1661
1821 function->can_stream_ =
1822 function->positional_parameters_.CanStream() &&
1823 function->named_parameters_.CanStream() &&
1824 (function->body_ == NULL || function->body_->can_stream());
1825
1826 return function; 1662 return function;
1827 } 1663 }
1828 1664
1829 1665
1830 TypeParameter* TypeParameter::ReadFrom(Reader* reader) { 1666 TypeParameter* TypeParameter::ReadFrom(Reader* reader) {
1831 TRACE_READ_OFFSET(); 1667 TRACE_READ_OFFSET();
1832 kernel_offset_ = reader->offset(); 1668 kernel_offset_ = reader->offset();
1833 name_index_ = StringIndex(reader->ReadUInt()); 1669 name_index_ = StringIndex(reader->ReadUInt());
1834 bound_ = DartType::ReadFrom(reader); 1670 bound_ = DartType::ReadFrom(reader);
1835 return this; 1671 return this;
1836 } 1672 }
1837 1673
1838 1674
1839 } // namespace kernel 1675 } // namespace kernel
1840 1676
1841 1677
1842 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer, 1678 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer,
1843 intptr_t buffer_length) { 1679 intptr_t buffer_length) {
1844 kernel::Reader reader(buffer, buffer_length); 1680 kernel::Reader reader(buffer, buffer_length);
1845 return kernel::Program::ReadFrom(&reader); 1681 return kernel::Program::ReadFrom(&reader);
1846 } 1682 }
1847 1683
1848 1684
1849 } // namespace dart 1685 } // namespace dart
1850 #endif // !defined(DART_PRECOMPILED_RUNTIME) 1686 #endif // !defined(DART_PRECOMPILED_RUNTIME)
OLDNEW
« no previous file with comments | « runtime/vm/kernel.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698