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

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

Issue 3001103002: Do not qualify with dart:: except where necessary (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)
11 11
12 namespace dart { 12 namespace dart {
13 namespace kernel { 13 namespace kernel {
14 14
15 #define Z (zone_) 15 #define Z (zone_)
16 #define H (translation_helper_) 16 #define H (translation_helper_)
17 #define T (type_translator_) 17 #define T (type_translator_)
18 #define I Isolate::Current() 18 #define I Isolate::Current()
19 19
20 static bool IsStaticInitializer(const Function& function, Zone* zone) { 20 static bool IsStaticInitializer(const Function& function, Zone* zone) {
21 return (function.kind() == RawFunction::kImplicitStaticFinalGetter) && 21 return (function.kind() == RawFunction::kImplicitStaticFinalGetter) &&
22 dart::String::Handle(zone, function.name()) 22 String::Handle(zone, function.name())
23 .StartsWith(Symbols::InitPrefix()); 23 .StartsWith(Symbols::InitPrefix());
24 } 24 }
25 25
26 void FunctionNodeHelper::ReadUntilExcluding(Field field) { 26 void FunctionNodeHelper::ReadUntilExcluding(Field field) {
27 if (field <= next_read_) return; 27 if (field <= next_read_) return;
28 28
29 // Ordered with fall-through. 29 // Ordered with fall-through.
30 switch (next_read_) { 30 switch (next_read_) {
31 case kStart: { 31 case kStart: {
32 Tag tag = builder_->ReadTag(); // read tag. 32 Tag tag = builder_->ReadTag(); // read tag.
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 ScopeBuildingResult* StreamingScopeBuilder::BuildScopes() { 511 ScopeBuildingResult* StreamingScopeBuilder::BuildScopes() {
512 if (result_ != NULL) return result_; 512 if (result_ != NULL) return result_;
513 513
514 ASSERT(scope_ == NULL && depth_.loop_ == 0 && depth_.function_ == 0); 514 ASSERT(scope_ == NULL && depth_.loop_ == 0 && depth_.function_ == 0);
515 result_ = new (Z) ScopeBuildingResult(); 515 result_ = new (Z) ScopeBuildingResult();
516 516
517 const Function& function = parsed_function_->function(); 517 const Function& function = parsed_function_->function();
518 518
519 // Setup a [ActiveClassScope] and a [ActiveMemberScope] which will be used 519 // Setup a [ActiveClassScope] and a [ActiveMemberScope] which will be used
520 // e.g. for type translation. 520 // e.g. for type translation.
521 const dart::Class& klass = 521 const Class& klass =
522 dart::Class::Handle(zone_, parsed_function_->function().Owner()); 522 Class::Handle(zone_, parsed_function_->function().Owner());
523 523
524 Function& outermost_function = Function::Handle(Z); 524 Function& outermost_function = Function::Handle(Z);
525 builder_->DiscoverEnclosingElements(Z, function, &outermost_function); 525 builder_->DiscoverEnclosingElements(Z, function, &outermost_function);
526 526
527 ActiveClassScope active_class_scope(&active_class_, &klass); 527 ActiveClassScope active_class_scope(&active_class_, &klass);
528 ActiveMemberScope active_member(&active_class_, &outermost_function); 528 ActiveMemberScope active_member(&active_class_, &outermost_function);
529 529
530 LocalScope* enclosing_scope = NULL; 530 LocalScope* enclosing_scope = NULL;
531 if (function.IsLocalFunction()) { 531 if (function.IsLocalFunction()) {
532 enclosing_scope = LocalScope::RestoreOuterScope( 532 enclosing_scope = LocalScope::RestoreOuterScope(
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 intptr_t pos = 0; 574 intptr_t pos = 0;
575 if (function.IsClosureFunction()) { 575 if (function.IsClosureFunction()) {
576 LocalVariable* variable = MakeVariable( 576 LocalVariable* variable = MakeVariable(
577 TokenPosition::kNoSource, TokenPosition::kNoSource, 577 TokenPosition::kNoSource, TokenPosition::kNoSource,
578 Symbols::ClosureParameter(), AbstractType::dynamic_type()); 578 Symbols::ClosureParameter(), AbstractType::dynamic_type());
579 variable->set_is_forced_stack(); 579 variable->set_is_forced_stack();
580 scope_->InsertParameterAt(pos++, variable); 580 scope_->InsertParameterAt(pos++, variable);
581 } else if (!function.is_static()) { 581 } else if (!function.is_static()) {
582 // We use [is_static] instead of [IsStaticFunction] because the latter 582 // We use [is_static] instead of [IsStaticFunction] because the latter
583 // returns `false` for constructors. 583 // returns `false` for constructors.
584 dart::Class& klass = dart::Class::Handle(Z, function.Owner()); 584 Class& klass = Class::Handle(Z, function.Owner());
585 Type& klass_type = H.GetCanonicalType(klass); 585 Type& klass_type = H.GetCanonicalType(klass);
586 LocalVariable* variable = 586 LocalVariable* variable =
587 MakeVariable(TokenPosition::kNoSource, TokenPosition::kNoSource, 587 MakeVariable(TokenPosition::kNoSource, TokenPosition::kNoSource,
588 Symbols::This(), klass_type); 588 Symbols::This(), klass_type);
589 scope_->InsertParameterAt(pos++, variable); 589 scope_->InsertParameterAt(pos++, variable);
590 result_->this_variable = variable; 590 result_->this_variable = variable;
591 591
592 // We visit instance field initializers because they might contain 592 // We visit instance field initializers because they might contain
593 // [Let] expressions and we need to have a mapping. 593 // [Let] expressions and we need to have a mapping.
594 if (tag == kConstructor) { 594 if (tag == kConstructor) {
595 Class& parent_class = Class::Handle(Z, function.Owner()); 595 Class& parent_class = Class::Handle(Z, function.Owner());
596 Array& class_fields = Array::Handle(Z, parent_class.fields()); 596 Array& class_fields = Array::Handle(Z, parent_class.fields());
597 dart::Field& class_field = dart::Field::Handle(Z); 597 Field& class_field = Field::Handle(Z);
598 for (intptr_t i = 0; i < class_fields.Length(); ++i) { 598 for (intptr_t i = 0; i < class_fields.Length(); ++i) {
599 class_field ^= class_fields.At(i); 599 class_field ^= class_fields.At(i);
600 if (!class_field.is_static()) { 600 if (!class_field.is_static()) {
601 TypedData& kernel_data = 601 TypedData& kernel_data =
602 TypedData::Handle(Z, class_field.kernel_data()); 602 TypedData::Handle(Z, class_field.kernel_data());
603 ASSERT(!kernel_data.IsNull()); 603 ASSERT(!kernel_data.IsNull());
604 AlternativeReadingScope alt(builder_->reader_, &kernel_data, 0); 604 AlternativeReadingScope alt(builder_->reader_, &kernel_data, 0);
605 intptr_t saved_relative_kernel_offset_ = relative_kernel_offset_; 605 intptr_t saved_relative_kernel_offset_ = relative_kernel_offset_;
606 relative_kernel_offset_ = class_field.kernel_offset(); 606 relative_kernel_offset_ = class_field.kernel_offset();
607 FieldHelper field_helper(builder_); 607 FieldHelper field_helper(builder_);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 case RawFunction::kImplicitSetter: { 659 case RawFunction::kImplicitSetter: {
660 ASSERT(builder_->PeekTag() == kField); 660 ASSERT(builder_->PeekTag() == kField);
661 if (IsStaticInitializer(function, Z)) { 661 if (IsStaticInitializer(function, Z)) {
662 VisitNode(); 662 VisitNode();
663 break; 663 break;
664 } 664 }
665 bool is_setter = function.IsImplicitSetterFunction(); 665 bool is_setter = function.IsImplicitSetterFunction();
666 bool is_method = !function.IsStaticFunction(); 666 bool is_method = !function.IsStaticFunction();
667 intptr_t pos = 0; 667 intptr_t pos = 0;
668 if (is_method) { 668 if (is_method) {
669 dart::Class& klass = dart::Class::Handle(Z, function.Owner()); 669 Class& klass = Class::Handle(Z, function.Owner());
670 Type& klass_type = H.GetCanonicalType(klass); 670 Type& klass_type = H.GetCanonicalType(klass);
671 LocalVariable* variable = 671 LocalVariable* variable =
672 MakeVariable(TokenPosition::kNoSource, TokenPosition::kNoSource, 672 MakeVariable(TokenPosition::kNoSource, TokenPosition::kNoSource,
673 Symbols::This(), klass_type); 673 Symbols::This(), klass_type);
674 scope_->InsertParameterAt(pos++, variable); 674 scope_->InsertParameterAt(pos++, variable);
675 result_->this_variable = variable; 675 result_->this_variable = variable;
676 } 676 }
677 if (is_setter) { 677 if (is_setter) {
678 result_->setter_value = 678 result_->setter_value =
679 MakeVariable(TokenPosition::kNoSource, TokenPosition::kNoSource, 679 MakeVariable(TokenPosition::kNoSource, TokenPosition::kNoSource,
680 Symbols::Value(), AbstractType::dynamic_type()); 680 Symbols::Value(), AbstractType::dynamic_type());
681 scope_->InsertParameterAt(pos++, result_->setter_value); 681 scope_->InsertParameterAt(pos++, result_->setter_value);
682 } 682 }
683 break; 683 break;
684 } 684 }
685 case RawFunction::kMethodExtractor: { 685 case RawFunction::kMethodExtractor: {
686 // Add a receiver parameter. Though it is captured, we emit code to 686 // Add a receiver parameter. Though it is captured, we emit code to
687 // explicitly copy it to a fixed offset in a freshly-allocated context 687 // explicitly copy it to a fixed offset in a freshly-allocated context
688 // instead of using the generic code for regular functions. 688 // instead of using the generic code for regular functions.
689 // Therefore, it isn't necessary to mark it as captured here. 689 // Therefore, it isn't necessary to mark it as captured here.
690 dart::Class& klass = dart::Class::Handle(Z, function.Owner()); 690 Class& klass = Class::Handle(Z, function.Owner());
691 Type& klass_type = H.GetCanonicalType(klass); 691 Type& klass_type = H.GetCanonicalType(klass);
692 LocalVariable* variable = 692 LocalVariable* variable =
693 MakeVariable(TokenPosition::kNoSource, TokenPosition::kNoSource, 693 MakeVariable(TokenPosition::kNoSource, TokenPosition::kNoSource,
694 Symbols::This(), klass_type); 694 Symbols::This(), klass_type);
695 scope_->InsertParameterAt(0, variable); 695 scope_->InsertParameterAt(0, variable);
696 result_->this_variable = variable; 696 result_->this_variable = variable;
697 break; 697 break;
698 } 698 }
699 case RawFunction::kNoSuchMethodDispatcher: 699 case RawFunction::kNoSuchMethodDispatcher:
700 case RawFunction::kInvokeFieldDispatcher: 700 case RawFunction::kInvokeFieldDispatcher:
701 for (intptr_t i = 0; i < function.NumParameters(); ++i) { 701 for (intptr_t i = 0; i < function.NumParameters(); ++i) {
702 LocalVariable* variable = MakeVariable( 702 LocalVariable* variable =
703 TokenPosition::kNoSource, TokenPosition::kNoSource, 703 MakeVariable(TokenPosition::kNoSource, TokenPosition::kNoSource,
704 dart::String::ZoneHandle(Z, function.ParameterNameAt(i)), 704 String::ZoneHandle(Z, function.ParameterNameAt(i)),
705 AbstractType::dynamic_type()); 705 AbstractType::dynamic_type());
706 scope_->InsertParameterAt(i, variable); 706 scope_->InsertParameterAt(i, variable);
707 } 707 }
708 break; 708 break;
709 case RawFunction::kSignatureFunction: 709 case RawFunction::kSignatureFunction:
710 case RawFunction::kIrregexpFunction: 710 case RawFunction::kIrregexpFunction:
711 UNREACHABLE(); 711 UNREACHABLE();
712 } 712 }
713 if (needs_expr_temp_) { 713 if (needs_expr_temp_) {
714 scope_->AddVariable(parsed_function_->EnsureExpressionTemp()); 714 scope_->AddVariable(parsed_function_->EnsureExpressionTemp());
715 } 715 }
(...skipping 28 matching lines...) Expand all
744 // compiled as if they appear in the constructor initializer list. This is 744 // compiled as if they appear in the constructor initializer list. This is
745 // important for closure-valued field initializers because the VM expects the 745 // important for closure-valued field initializers because the VM expects the
746 // corresponding closure functions to appear as if they were nested inside the 746 // corresponding closure functions to appear as if they were nested inside the
747 // constructor. 747 // constructor.
748 ConstructorHelper constructor_helper(builder_); 748 ConstructorHelper constructor_helper(builder_);
749 constructor_helper.ReadUntilExcluding(ConstructorHelper::kFunction); 749 constructor_helper.ReadUntilExcluding(ConstructorHelper::kFunction);
750 { 750 {
751 const Function& function = parsed_function_->function(); 751 const Function& function = parsed_function_->function();
752 Class& parent_class = Class::Handle(Z, function.Owner()); 752 Class& parent_class = Class::Handle(Z, function.Owner());
753 Array& class_fields = Array::Handle(Z, parent_class.fields()); 753 Array& class_fields = Array::Handle(Z, parent_class.fields());
754 dart::Field& class_field = dart::Field::Handle(Z); 754 Field& class_field = Field::Handle(Z);
755 for (intptr_t i = 0; i < class_fields.Length(); ++i) { 755 for (intptr_t i = 0; i < class_fields.Length(); ++i) {
756 class_field ^= class_fields.At(i); 756 class_field ^= class_fields.At(i);
757 if (!class_field.is_static()) { 757 if (!class_field.is_static()) {
758 TypedData& kernel_data = 758 TypedData& kernel_data =
759 TypedData::Handle(Z, class_field.kernel_data()); 759 TypedData::Handle(Z, class_field.kernel_data());
760 ASSERT(!kernel_data.IsNull()); 760 ASSERT(!kernel_data.IsNull());
761 AlternativeReadingScope alt(builder_->reader_, &kernel_data, 0); 761 AlternativeReadingScope alt(builder_->reader_, &kernel_data, 0);
762 intptr_t saved_relative_kernel_offset_ = relative_kernel_offset_; 762 intptr_t saved_relative_kernel_offset_ = relative_kernel_offset_;
763 relative_kernel_offset_ = class_field.kernel_offset(); 763 relative_kernel_offset_ = class_field.kernel_offset();
764 FieldHelper field_helper(builder_); 764 FieldHelper field_helper(builder_);
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 builder_->ReadUInt(); // read target_index. 1299 builder_->ReadUInt(); // read target_index.
1300 return; 1300 return;
1301 case kIfStatement: 1301 case kIfStatement:
1302 VisitExpression(); // read condition. 1302 VisitExpression(); // read condition.
1303 VisitStatement(); // read then. 1303 VisitStatement(); // read then.
1304 VisitStatement(); // read otherwise. 1304 VisitStatement(); // read otherwise.
1305 return; 1305 return;
1306 case kReturnStatement: { 1306 case kReturnStatement: {
1307 if ((depth_.function_ == 0) && (depth_.finally_ > 0) && 1307 if ((depth_.function_ == 0) && (depth_.finally_ > 0) &&
1308 (result_->finally_return_variable == NULL)) { 1308 (result_->finally_return_variable == NULL)) {
1309 const dart::String& name = H.DartSymbol(":try_finally_return_value"); 1309 const String& name = H.DartSymbol(":try_finally_return_value");
1310 LocalVariable* variable = 1310 LocalVariable* variable =
1311 MakeVariable(TokenPosition::kNoSource, TokenPosition::kNoSource, 1311 MakeVariable(TokenPosition::kNoSource, TokenPosition::kNoSource,
1312 name, AbstractType::dynamic_type()); 1312 name, AbstractType::dynamic_type());
1313 current_function_scope_->AddVariable(variable); 1313 current_function_scope_->AddVariable(variable);
1314 result_->finally_return_variable = variable; 1314 result_->finally_return_variable = variable;
1315 } 1315 }
1316 1316
1317 builder_->ReadPosition(); // read position 1317 builder_->ReadPosition(); // read position
1318 Tag tag = builder_->ReadTag(); // read (first part of) expression. 1318 Tag tag = builder_->ReadTag(); // read (first part of) expression.
1319 if (tag == kSomething) { 1319 if (tag == kSomething) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1434 1434
1435 intptr_t kernel_offset_no_tag = builder_->ReaderOffset(); 1435 intptr_t kernel_offset_no_tag = builder_->ReaderOffset();
1436 VariableDeclarationHelper helper(builder_); 1436 VariableDeclarationHelper helper(builder_);
1437 helper.ReadUntilExcluding(VariableDeclarationHelper::kType); 1437 helper.ReadUntilExcluding(VariableDeclarationHelper::kType);
1438 intptr_t offset_for_type = builder_->ReaderOffset(); 1438 intptr_t offset_for_type = builder_->ReaderOffset();
1439 AbstractType& type = T.BuildVariableType(); // read type. 1439 AbstractType& type = T.BuildVariableType(); // read type.
1440 1440
1441 // In case `declaration->IsConst()` the flow graph building will take care of 1441 // In case `declaration->IsConst()` the flow graph building will take care of
1442 // evaluating the constant and setting it via 1442 // evaluating the constant and setting it via
1443 // `declaration->SetConstantValue()`. 1443 // `declaration->SetConstantValue()`.
1444 const dart::String& name = (H.StringSize(helper.name_index_) == 0) 1444 const String& name = (H.StringSize(helper.name_index_) == 0)
1445 ? GenerateName(":var", name_index_++) 1445 ? GenerateName(":var", name_index_++)
1446 : H.DartSymbol(helper.name_index_); 1446 : H.DartSymbol(helper.name_index_);
1447 // We also need to visit the type. 1447 // We also need to visit the type.
1448 builder_->SetOffset(offset_for_type); 1448 builder_->SetOffset(offset_for_type);
1449 VisitDartType(); // read type. 1449 VisitDartType(); // read type.
1450 1450
1451 Tag tag = builder_->ReadTag(); // read (first part of) initializer. 1451 Tag tag = builder_->ReadTag(); // read (first part of) initializer.
1452 if (tag == kSomething) { 1452 if (tag == kSomething) {
1453 VisitExpression(); // read (actual) initializer. 1453 VisitExpression(); // read (actual) initializer.
1454 } 1454 }
1455 1455
1456 // Go to next token position so it ends *after* the last potentially 1456 // Go to next token position so it ends *after* the last potentially
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1658 // evaluator needs scope bindings. 1658 // evaluator needs scope bindings.
1659 Tag tag = builder_->ReadTag(); 1659 Tag tag = builder_->ReadTag();
1660 if (tag == kSomething) { 1660 if (tag == kSomething) {
1661 VisitExpression(); // read initializer. 1661 VisitExpression(); // read initializer.
1662 } 1662 }
1663 } 1663 }
1664 1664
1665 LocalVariable* StreamingScopeBuilder::MakeVariable( 1665 LocalVariable* StreamingScopeBuilder::MakeVariable(
1666 TokenPosition declaration_pos, 1666 TokenPosition declaration_pos,
1667 TokenPosition token_pos, 1667 TokenPosition token_pos,
1668 const dart::String& name, 1668 const String& name,
1669 const AbstractType& type) { 1669 const AbstractType& type) {
1670 return new (Z) LocalVariable(declaration_pos, token_pos, name, type); 1670 return new (Z) LocalVariable(declaration_pos, token_pos, name, type);
1671 } 1671 }
1672 1672
1673 void StreamingScopeBuilder::AddExceptionVariable( 1673 void StreamingScopeBuilder::AddExceptionVariable(
1674 GrowableArray<LocalVariable*>* variables, 1674 GrowableArray<LocalVariable*>* variables,
1675 const char* prefix, 1675 const char* prefix,
1676 intptr_t nesting_depth) { 1676 intptr_t nesting_depth) {
1677 LocalVariable* v = NULL; 1677 LocalVariable* v = NULL;
1678 1678
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1754 LocalVariable* variable = result_->locals.Lookup(declaration_binary_offset); 1754 LocalVariable* variable = result_->locals.Lookup(declaration_binary_offset);
1755 if (variable == NULL) { 1755 if (variable == NULL) {
1756 // We have not seen a declaration of the variable, so it must be the 1756 // We have not seen a declaration of the variable, so it must be the
1757 // case that we are compiling a nested function and the variable is 1757 // case that we are compiling a nested function and the variable is
1758 // declared in an outer scope. In that case, look it up in the scope by 1758 // declared in an outer scope. In that case, look it up in the scope by
1759 // name and add it to the variable map to simplify later lookup. 1759 // name and add it to the variable map to simplify later lookup.
1760 ASSERT(current_function_scope_->parent() != NULL); 1760 ASSERT(current_function_scope_->parent() != NULL);
1761 StringIndex var_name = builder_->GetNameFromVariableDeclaration( 1761 StringIndex var_name = builder_->GetNameFromVariableDeclaration(
1762 declaration_binary_offset, parsed_function_->function()); 1762 declaration_binary_offset, parsed_function_->function());
1763 1763
1764 const dart::String& name = H.DartSymbol(var_name); 1764 const String& name = H.DartSymbol(var_name);
1765 variable = current_function_scope_->parent()->LookupVariable(name, true); 1765 variable = current_function_scope_->parent()->LookupVariable(name, true);
1766 ASSERT(variable != NULL); 1766 ASSERT(variable != NULL);
1767 result_->locals.Insert(declaration_binary_offset, variable); 1767 result_->locals.Insert(declaration_binary_offset, variable);
1768 } 1768 }
1769 1769
1770 if (variable->owner()->function_level() < scope_->function_level()) { 1770 if (variable->owner()->function_level() < scope_->function_level()) {
1771 // We call `LocalScope->CaptureVariable(variable)` in two scenarios for two 1771 // We call `LocalScope->CaptureVariable(variable)` in two scenarios for two
1772 // different reasons: 1772 // different reasons:
1773 // Scenario 1: 1773 // Scenario 1:
1774 // We need to know which variables defined in this function 1774 // We need to know which variables defined in this function
1775 // are closed over by nested closures in order to ensure we will 1775 // are closed over by nested closures in order to ensure we will
1776 // create a [Context] object of appropriate size and store captured 1776 // create a [Context] object of appropriate size and store captured
1777 // variables there instead of the stack. 1777 // variables there instead of the stack.
1778 // Scenario 2: 1778 // Scenario 2:
1779 // We need to find out which variables defined in enclosing functions 1779 // We need to find out which variables defined in enclosing functions
1780 // are closed over by this function/closure or nested closures. This 1780 // are closed over by this function/closure or nested closures. This
1781 // is necessary in order to build a fat flattened [ContextScope] 1781 // is necessary in order to build a fat flattened [ContextScope]
1782 // object. 1782 // object.
1783 scope_->CaptureVariable(variable); 1783 scope_->CaptureVariable(variable);
1784 } else { 1784 } else {
1785 ASSERT(variable->owner()->function_level() == scope_->function_level()); 1785 ASSERT(variable->owner()->function_level() == scope_->function_level());
1786 } 1786 }
1787 } 1787 }
1788 1788
1789 const dart::String& StreamingScopeBuilder::GenerateName(const char* prefix, 1789 const String& StreamingScopeBuilder::GenerateName(const char* prefix,
1790 intptr_t suffix) { 1790 intptr_t suffix) {
1791 char name[64]; 1791 char name[64];
1792 OS::SNPrint(name, 64, "%s%" Pd "", prefix, suffix); 1792 OS::SNPrint(name, 64, "%s%" Pd "", prefix, suffix);
1793 return H.DartSymbol(name); 1793 return H.DartSymbol(name);
1794 } 1794 }
1795 1795
1796 void StreamingScopeBuilder::HandleSpecialLoad(LocalVariable** variable, 1796 void StreamingScopeBuilder::HandleSpecialLoad(LocalVariable** variable,
1797 const dart::String& symbol) { 1797 const String& symbol) {
1798 if (current_function_scope_->parent() != NULL) { 1798 if (current_function_scope_->parent() != NULL) {
1799 // We are building the scope tree of a closure function and saw [node]. We 1799 // We are building the scope tree of a closure function and saw [node]. We
1800 // lazily populate the variable using the parent function scope. 1800 // lazily populate the variable using the parent function scope.
1801 if (*variable == NULL) { 1801 if (*variable == NULL) {
1802 *variable = 1802 *variable =
1803 current_function_scope_->parent()->LookupVariable(symbol, true); 1803 current_function_scope_->parent()->LookupVariable(symbol, true);
1804 ASSERT(*variable != NULL); 1804 ASSERT(*variable != NULL);
1805 } 1805 }
1806 } 1806 }
1807 1807
1808 if ((current_function_scope_->parent() != NULL) || 1808 if ((current_function_scope_->parent() != NULL) ||
1809 (scope_->function_level() > 0)) { 1809 (scope_->function_level() > 0)) {
1810 // Every scope we use the [variable] from needs to be notified of the usage 1810 // Every scope we use the [variable] from needs to be notified of the usage
1811 // in order to ensure that preserving the context scope on that particular 1811 // in order to ensure that preserving the context scope on that particular
1812 // use-site also includes the [variable]. 1812 // use-site also includes the [variable].
1813 scope_->CaptureVariable(*variable); 1813 scope_->CaptureVariable(*variable);
1814 } 1814 }
1815 } 1815 }
1816 1816
1817 void StreamingScopeBuilder::LookupCapturedVariableByName( 1817 void StreamingScopeBuilder::LookupCapturedVariableByName(
1818 LocalVariable** variable, 1818 LocalVariable** variable,
1819 const dart::String& name) { 1819 const String& name) {
1820 if (*variable == NULL) { 1820 if (*variable == NULL) {
1821 *variable = scope_->LookupVariable(name, true); 1821 *variable = scope_->LookupVariable(name, true);
1822 ASSERT(*variable != NULL); 1822 ASSERT(*variable != NULL);
1823 scope_->CaptureVariable(*variable); 1823 scope_->CaptureVariable(*variable);
1824 } 1824 }
1825 } 1825 }
1826 1826
1827 StreamingDartTypeTranslator::StreamingDartTypeTranslator( 1827 StreamingDartTypeTranslator::StreamingDartTypeTranslator(
1828 StreamingFlowGraphBuilder* builder, 1828 StreamingFlowGraphBuilder* builder,
1829 bool finalize) 1829 bool finalize)
1830 : builder_(builder), 1830 : builder_(builder),
1831 translation_helper_(builder->translation_helper_), 1831 translation_helper_(builder->translation_helper_),
1832 active_class_(builder->active_class()), 1832 active_class_(builder->active_class()),
1833 type_parameter_scope_(NULL), 1833 type_parameter_scope_(NULL),
1834 zone_(translation_helper_.zone()), 1834 zone_(translation_helper_.zone()),
1835 result_(AbstractType::Handle(translation_helper_.zone())), 1835 result_(AbstractType::Handle(translation_helper_.zone())),
1836 finalize_(finalize) {} 1836 finalize_(finalize) {}
1837 1837
1838 AbstractType& StreamingDartTypeTranslator::BuildType() { 1838 AbstractType& StreamingDartTypeTranslator::BuildType() {
1839 BuildTypeInternal(); 1839 BuildTypeInternal();
1840 1840
1841 // We return a new `ZoneHandle` here on purpose: The intermediate language 1841 // We return a new `ZoneHandle` here on purpose: The intermediate language
1842 // instructions do not make a copy of the handle, so we do it. 1842 // instructions do not make a copy of the handle, so we do it.
1843 return dart::AbstractType::ZoneHandle(Z, result_.raw()); 1843 return AbstractType::ZoneHandle(Z, result_.raw());
1844 } 1844 }
1845 1845
1846 AbstractType& StreamingDartTypeTranslator::BuildTypeWithoutFinalization() { 1846 AbstractType& StreamingDartTypeTranslator::BuildTypeWithoutFinalization() {
1847 bool saved_finalize = finalize_; 1847 bool saved_finalize = finalize_;
1848 finalize_ = false; 1848 finalize_ = false;
1849 BuildTypeInternal(); 1849 BuildTypeInternal();
1850 finalize_ = saved_finalize; 1850 finalize_ = saved_finalize;
1851 1851
1852 // We return a new `ZoneHandle` here on purpose: The intermediate language 1852 // We return a new `ZoneHandle` here on purpose: The intermediate language
1853 // instructions do not make a copy of the handle, so we do it. 1853 // instructions do not make a copy of the handle, so we do it.
1854 return dart::AbstractType::ZoneHandle(Z, result_.raw()); 1854 return AbstractType::ZoneHandle(Z, result_.raw());
1855 } 1855 }
1856 1856
1857 AbstractType& StreamingDartTypeTranslator::BuildVariableType() { 1857 AbstractType& StreamingDartTypeTranslator::BuildVariableType() {
1858 AbstractType& abstract_type = BuildType(); 1858 AbstractType& abstract_type = BuildType();
1859 1859
1860 // We return a new `ZoneHandle` here on purpose: The intermediate language 1860 // We return a new `ZoneHandle` here on purpose: The intermediate language
1861 // instructions do not make a copy of the handle, so we do it. 1861 // instructions do not make a copy of the handle, so we do it.
1862 AbstractType& type = Type::ZoneHandle(Z); 1862 AbstractType& type = Type::ZoneHandle(Z);
1863 1863
1864 if (abstract_type.IsMalformed()) { 1864 if (abstract_type.IsMalformed()) {
1865 type = AbstractType::dynamic_type().raw(); 1865 type = AbstractType::dynamic_type().raw();
1866 } else { 1866 } else {
1867 type = result_.raw(); 1867 type = result_.raw();
1868 } 1868 }
1869 1869
1870 return type; 1870 return type;
1871 } 1871 }
1872 1872
1873 void StreamingDartTypeTranslator::BuildTypeInternal() { 1873 void StreamingDartTypeTranslator::BuildTypeInternal() {
1874 Tag tag = builder_->ReadTag(); 1874 Tag tag = builder_->ReadTag();
1875 switch (tag) { 1875 switch (tag) {
1876 case kInvalidType: 1876 case kInvalidType:
1877 result_ = ClassFinalizer::NewFinalizedMalformedType( 1877 result_ = ClassFinalizer::NewFinalizedMalformedType(
1878 Error::Handle(Z), // No previous error. 1878 Error::Handle(Z), // No previous error.
1879 dart::Script::Handle(Z, dart::Script::null()), 1879 Script::Handle(Z, Script::null()), TokenPosition::kNoSource,
1880 TokenPosition::kNoSource, "[InvalidType] in Kernel IR."); 1880 "[InvalidType] in Kernel IR.");
1881 break; 1881 break;
1882 case kDynamicType: 1882 case kDynamicType:
1883 result_ = Object::dynamic_type().raw(); 1883 result_ = Object::dynamic_type().raw();
1884 break; 1884 break;
1885 case kVoidType: 1885 case kVoidType:
1886 result_ = Object::void_type().raw(); 1886 result_ = Object::void_type().raw();
1887 break; 1887 break;
1888 case kVectorType: 1888 case kVectorType:
1889 result_ = Object::vector_type().raw(); 1889 result_ = Object::vector_type().raw();
1890 break; 1890 break;
1891 case kBottomType: 1891 case kBottomType:
1892 result_ = dart::Class::Handle(Z, I->object_store()->null_class()) 1892 result_ =
1893 .CanonicalType(); 1893 Class::Handle(Z, I->object_store()->null_class()).CanonicalType();
1894 break; 1894 break;
1895 case kInterfaceType: 1895 case kInterfaceType:
1896 BuildInterfaceType(false); 1896 BuildInterfaceType(false);
1897 break; 1897 break;
1898 case kSimpleInterfaceType: 1898 case kSimpleInterfaceType:
1899 BuildInterfaceType(true); 1899 BuildInterfaceType(true);
1900 break; 1900 break;
1901 case kFunctionType: 1901 case kFunctionType:
1902 BuildFunctionType(false); 1902 BuildFunctionType(false);
1903 break; 1903 break;
(...skipping 18 matching lines...) Expand all
1922 1922
1923 intptr_t length; 1923 intptr_t length;
1924 if (simple) { 1924 if (simple) {
1925 length = 0; 1925 length = 0;
1926 } else { 1926 } else {
1927 length = builder_->ReadListLength(); // read type_arguments list length. 1927 length = builder_->ReadListLength(); // read type_arguments list length.
1928 } 1928 }
1929 const TypeArguments& type_arguments = 1929 const TypeArguments& type_arguments =
1930 BuildTypeArguments(length); // read type arguments. 1930 BuildTypeArguments(length); // read type arguments.
1931 1931
1932 dart::Object& klass = 1932 Object& klass = Object::Handle(Z, H.LookupClassByKernelClass(klass_name));
1933 dart::Object::Handle(Z, H.LookupClassByKernelClass(klass_name));
1934 result_ = Type::New(klass, type_arguments, TokenPosition::kNoSource); 1933 result_ = Type::New(klass, type_arguments, TokenPosition::kNoSource);
1935 if (finalize_) { 1934 if (finalize_) {
1936 ASSERT(active_class_->klass != NULL); 1935 ASSERT(active_class_->klass != NULL);
1937 result_ = ClassFinalizer::FinalizeType(*active_class_->klass, result_); 1936 result_ = ClassFinalizer::FinalizeType(*active_class_->klass, result_);
1938 } 1937 }
1939 } 1938 }
1940 1939
1941 void StreamingDartTypeTranslator::BuildFunctionType(bool simple) { 1940 void StreamingDartTypeTranslator::BuildFunctionType(bool simple) {
1942 intptr_t list_length = 0; 1941 intptr_t list_length = 0;
1943 if (!simple) { 1942 if (!simple) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2001 // The additional first parameter is the receiver type (set to dynamic). 2000 // The additional first parameter is the receiver type (set to dynamic).
2002 signature_function.set_num_fixed_parameters(1 + required_count); 2001 signature_function.set_num_fixed_parameters(1 + required_count);
2003 signature_function.SetNumOptionalParameters( 2002 signature_function.SetNumOptionalParameters(
2004 all_count - required_count, positional_count > required_count); 2003 all_count - required_count, positional_count > required_count);
2005 2004
2006 if (!simple) { 2005 if (!simple) {
2007 const intptr_t named_count = 2006 const intptr_t named_count =
2008 builder_->ReadListLength(); // read named_parameters list length. 2007 builder_->ReadListLength(); // read named_parameters list length.
2009 for (intptr_t i = 0; i < named_count; ++i, ++pos) { 2008 for (intptr_t i = 0; i < named_count; ++i, ++pos) {
2010 // read string reference (i.e. named_parameters[i].name). 2009 // read string reference (i.e. named_parameters[i].name).
2011 dart::String& name = H.DartSymbol(builder_->ReadStringReference()); 2010 String& name = H.DartSymbol(builder_->ReadStringReference());
2012 BuildTypeInternal(); // read named_parameters[i].type. 2011 BuildTypeInternal(); // read named_parameters[i].type.
2013 if (result_.IsMalformed()) { 2012 if (result_.IsMalformed()) {
2014 result_ = AbstractType::dynamic_type().raw(); 2013 result_ = AbstractType::dynamic_type().raw();
2015 } 2014 }
2016 parameter_types.SetAt(pos, result_); 2015 parameter_types.SetAt(pos, result_);
2017 parameter_names.SetAt(pos, name); 2016 parameter_names.SetAt(pos, name);
2018 } 2017 }
2019 } 2018 }
2020 2019
2021 builder_->SkipListOfStrings(); // read positional parameter names. 2020 builder_->SkipListOfStrings(); // read positional parameter names.
(...skipping 20 matching lines...) Expand all
2042 } 2041 }
2043 2042
2044 result_ = signature_type.raw(); 2043 result_ = signature_type.raw();
2045 } 2044 }
2046 2045
2047 void StreamingDartTypeTranslator::BuildTypeParameterType() { 2046 void StreamingDartTypeTranslator::BuildTypeParameterType() {
2048 intptr_t parameter_index = builder_->ReadUInt(); // read parameter index. 2047 intptr_t parameter_index = builder_->ReadUInt(); // read parameter index.
2049 builder_->SkipOptionalDartType(); // read bound. 2048 builder_->SkipOptionalDartType(); // read bound.
2050 2049
2051 const TypeArguments& class_types = 2050 const TypeArguments& class_types =
2052 dart::TypeArguments::Handle(Z, active_class_->klass->type_parameters()); 2051 TypeArguments::Handle(Z, active_class_->klass->type_parameters());
2053 if (parameter_index < class_types.Length()) { 2052 if (parameter_index < class_types.Length()) {
2054 // The index of the type parameter in [parameters] is 2053 // The index of the type parameter in [parameters] is
2055 // the same index into the `klass->type_parameters()` array. 2054 // the same index into the `klass->type_parameters()` array.
2056 result_ ^= class_types.TypeAt(parameter_index); 2055 result_ ^= class_types.TypeAt(parameter_index);
2057 return; 2056 return;
2058 } 2057 }
2059 parameter_index -= class_types.Length(); 2058 parameter_index -= class_types.Length();
2060 2059
2061 if (active_class_->HasMember()) { 2060 if (active_class_->HasMember()) {
2062 if (active_class_->MemberIsFactoryProcedure()) { 2061 if (active_class_->MemberIsFactoryProcedure()) {
(...skipping 22 matching lines...) Expand all
2085 parameter_index -= class_types.Length(); 2084 parameter_index -= class_types.Length();
2086 } 2085 }
2087 2086
2088 intptr_t procedure_type_parameter_count = 2087 intptr_t procedure_type_parameter_count =
2089 active_class_->MemberIsProcedure() 2088 active_class_->MemberIsProcedure()
2090 ? active_class_->MemberTypeParameterCount(Z) 2089 ? active_class_->MemberTypeParameterCount(Z)
2091 : 0; 2090 : 0;
2092 if (procedure_type_parameter_count > 0) { 2091 if (procedure_type_parameter_count > 0) {
2093 if (procedure_type_parameter_count > parameter_index) { 2092 if (procedure_type_parameter_count > parameter_index) {
2094 if (FLAG_reify_generic_functions) { 2093 if (FLAG_reify_generic_functions) {
2095 result_ ^= dart::TypeArguments::Handle( 2094 result_ ^=
2096 Z, active_class_->member->type_parameters()) 2095 TypeArguments::Handle(Z, active_class_->member->type_parameters())
2097 .TypeAt(parameter_index); 2096 .TypeAt(parameter_index);
2098 } else { 2097 } else {
2099 result_ ^= dart::Type::DynamicType(); 2098 result_ ^= Type::DynamicType();
2100 } 2099 }
2101 return; 2100 return;
2102 } 2101 }
2103 parameter_index -= procedure_type_parameter_count; 2102 parameter_index -= procedure_type_parameter_count;
2104 } 2103 }
2105 } 2104 }
2106 2105
2107 if (type_parameter_scope_ != NULL && parameter_index >= 0 && 2106 if (type_parameter_scope_ != NULL && parameter_index >= 0 &&
2108 parameter_index < type_parameter_scope_->outer_parameter_count() + 2107 parameter_index < type_parameter_scope_->outer_parameter_count() +
2109 type_parameter_scope_->parameter_count()) { 2108 type_parameter_scope_->parameter_count()) {
2110 result_ ^= dart::Type::DynamicType(); 2109 result_ ^= Type::DynamicType();
2111 return; 2110 return;
2112 } 2111 }
2113 2112
2114 H.ReportError("Unexpected input. Please report this at dartbug.com."); 2113 H.ReportError("Unexpected input. Please report this at dartbug.com.");
2115 } 2114 }
2116 2115
2117 const TypeArguments& StreamingDartTypeTranslator::BuildTypeArguments( 2116 const TypeArguments& StreamingDartTypeTranslator::BuildTypeArguments(
2118 intptr_t length) { 2117 intptr_t length) {
2119 bool only_dynamic = true; 2118 bool only_dynamic = true;
2120 intptr_t offset = builder_->ReaderOffset(); 2119 intptr_t offset = builder_->ReaderOffset();
(...skipping 22 matching lines...) Expand all
2143 2142
2144 if (finalize_) { 2143 if (finalize_) {
2145 type_arguments = type_arguments.Canonicalize(); 2144 type_arguments = type_arguments.Canonicalize();
2146 } 2145 }
2147 } 2146 }
2148 return type_arguments; 2147 return type_arguments;
2149 } 2148 }
2150 2149
2151 const TypeArguments& 2150 const TypeArguments&
2152 StreamingDartTypeTranslator::BuildInstantiatedTypeArguments( 2151 StreamingDartTypeTranslator::BuildInstantiatedTypeArguments(
2153 const dart::Class& receiver_class, 2152 const Class& receiver_class,
2154 intptr_t length) { 2153 intptr_t length) {
2155 const TypeArguments& type_arguments = BuildTypeArguments(length); 2154 const TypeArguments& type_arguments = BuildTypeArguments(length);
2156 2155
2157 // If type_arguments is null all arguments are dynamic. 2156 // If type_arguments is null all arguments are dynamic.
2158 // If, however, this class doesn't specify all the type arguments directly we 2157 // If, however, this class doesn't specify all the type arguments directly we
2159 // still need to finalize the type below in order to get any non-dynamic types 2158 // still need to finalize the type below in order to get any non-dynamic types
2160 // from any super. See http://www.dartbug.com/29537. 2159 // from any super. See http://www.dartbug.com/29537.
2161 if (type_arguments.IsNull() && receiver_class.NumTypeArguments() == length) { 2160 if (type_arguments.IsNull() && receiver_class.NumTypeArguments() == length) {
2162 return type_arguments; 2161 return type_arguments;
2163 } 2162 }
2164 2163
2165 // We make a temporary [Type] object and use `ClassFinalizer::FinalizeType` to 2164 // We make a temporary [Type] object and use `ClassFinalizer::FinalizeType` to
2166 // finalize the argument types. 2165 // finalize the argument types.
2167 // (This can for example make the [type_arguments] vector larger) 2166 // (This can for example make the [type_arguments] vector larger)
2168 Type& type = Type::Handle( 2167 Type& type = Type::Handle(
2169 Z, Type::New(receiver_class, type_arguments, TokenPosition::kNoSource)); 2168 Z, Type::New(receiver_class, type_arguments, TokenPosition::kNoSource));
2170 if (finalize_) { 2169 if (finalize_) {
2171 type ^= ClassFinalizer::FinalizeType(*active_class_->klass, type); 2170 type ^= ClassFinalizer::FinalizeType(*active_class_->klass, type);
2172 } 2171 }
2173 2172
2174 const TypeArguments& instantiated_type_arguments = 2173 const TypeArguments& instantiated_type_arguments =
2175 TypeArguments::ZoneHandle(Z, type.arguments()); 2174 TypeArguments::ZoneHandle(Z, type.arguments());
2176 return instantiated_type_arguments; 2175 return instantiated_type_arguments;
2177 } 2176 }
2178 2177
2179 const Type& StreamingDartTypeTranslator::ReceiverType( 2178 const Type& StreamingDartTypeTranslator::ReceiverType(const Class& klass) {
2180 const dart::Class& klass) {
2181 ASSERT(!klass.IsNull()); 2179 ASSERT(!klass.IsNull());
2182 ASSERT(!klass.IsTypedefClass()); 2180 ASSERT(!klass.IsTypedefClass());
2183 // Note that if klass is _Closure, the returned type will be _Closure, 2181 // Note that if klass is _Closure, the returned type will be _Closure,
2184 // and not the signature type. 2182 // and not the signature type.
2185 Type& type = Type::ZoneHandle(Z, klass.CanonicalType()); 2183 Type& type = Type::ZoneHandle(Z, klass.CanonicalType());
2186 if (!type.IsNull()) { 2184 if (!type.IsNull()) {
2187 return type; 2185 return type;
2188 } 2186 }
2189 type = Type::New(klass, TypeArguments::Handle(Z, klass.type_parameters()), 2187 type = Type::New(klass, TypeArguments::Handle(Z, klass.type_parameters()),
2190 klass.token_pos()); 2188 klass.token_pos());
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
2403 builder_->ReadPosition(); // read position. 2401 builder_->ReadPosition(); // read position.
2404 intptr_t expression_offset = builder_->ReaderOffset(); 2402 intptr_t expression_offset = builder_->ReaderOffset();
2405 builder_->SkipExpression(); // read receiver. 2403 builder_->SkipExpression(); // read receiver.
2406 StringIndex name = builder_->ReadNameAsStringIndex(); // read name. 2404 StringIndex name = builder_->ReadNameAsStringIndex(); // read name.
2407 // Read unused "interface_target_reference". 2405 // Read unused "interface_target_reference".
2408 builder_->SkipCanonicalNameReference(); 2406 builder_->SkipCanonicalNameReference();
2409 2407
2410 if (H.StringEquals(name, "length")) { 2408 if (H.StringEquals(name, "length")) {
2411 EvaluateExpression(expression_offset); 2409 EvaluateExpression(expression_offset);
2412 if (result_.IsString()) { 2410 if (result_.IsString()) {
2413 const dart::String& str = 2411 const String& str = String::Handle(Z, String::RawCast(result_.raw()));
2414 dart::String::Handle(Z, dart::String::RawCast(result_.raw()));
2415 result_ = Integer::New(str.Length()); 2412 result_ = Integer::New(str.Length());
2416 } else { 2413 } else {
2417 H.ReportError( 2414 H.ReportError(
2418 "Constant expressions can only call " 2415 "Constant expressions can only call "
2419 "'length' on string constants."); 2416 "'length' on string constants.");
2420 } 2417 }
2421 } else { 2418 } else {
2422 UNREACHABLE(); 2419 UNREACHABLE();
2423 } 2420 }
2424 } 2421 }
2425 2422
2426 void StreamingConstantEvaluator::EvaluateStaticGet() { 2423 void StreamingConstantEvaluator::EvaluateStaticGet() {
2427 builder_->ReadPosition(); // read position. 2424 builder_->ReadPosition(); // read position.
2428 NameIndex target = 2425 NameIndex target =
2429 builder_->ReadCanonicalNameReference(); // read target_reference. 2426 builder_->ReadCanonicalNameReference(); // read target_reference.
2430 2427
2431 if (H.IsField(target)) { 2428 if (H.IsField(target)) {
2432 const dart::Field& field = 2429 const Field& field = Field::Handle(Z, H.LookupFieldByKernelField(target));
2433 dart::Field::Handle(Z, H.LookupFieldByKernelField(target));
2434 if (field.StaticValue() == Object::sentinel().raw() || 2430 if (field.StaticValue() == Object::sentinel().raw() ||
2435 field.StaticValue() == Object::transition_sentinel().raw()) { 2431 field.StaticValue() == Object::transition_sentinel().raw()) {
2436 field.EvaluateInitializer(); 2432 field.EvaluateInitializer();
2437 result_ = field.StaticValue(); 2433 result_ = field.StaticValue();
2438 result_ = H.Canonicalize(result_); 2434 result_ = H.Canonicalize(result_);
2439 field.SetStaticValue(result_, true); 2435 field.SetStaticValue(result_, true);
2440 } else { 2436 } else {
2441 result_ = field.StaticValue(); 2437 result_ = field.StaticValue();
2442 } 2438 }
2443 } else if (H.IsProcedure(target)) { 2439 } else if (H.IsProcedure(target)) {
2444 const Function& function = 2440 const Function& function =
2445 Function::ZoneHandle(Z, H.LookupStaticMethodByKernelProcedure(target)); 2441 Function::ZoneHandle(Z, H.LookupStaticMethodByKernelProcedure(target));
2446 2442
2447 if (H.IsMethod(target)) { 2443 if (H.IsMethod(target)) {
2448 Function& closure_function = 2444 Function& closure_function =
2449 Function::ZoneHandle(Z, function.ImplicitClosureFunction()); 2445 Function::ZoneHandle(Z, function.ImplicitClosureFunction());
2450 result_ = closure_function.ImplicitStaticClosure(); 2446 result_ = closure_function.ImplicitStaticClosure();
2451 result_ = H.Canonicalize(result_); 2447 result_ = H.Canonicalize(result_);
2452 } else if (H.IsGetter(target)) { 2448 } else if (H.IsGetter(target)) {
2453 UNIMPLEMENTED(); 2449 UNIMPLEMENTED();
2454 } else { 2450 } else {
2455 UNIMPLEMENTED(); 2451 UNIMPLEMENTED();
2456 } 2452 }
2457 } 2453 }
2458 } 2454 }
2459 2455
2460 void StreamingConstantEvaluator::EvaluateMethodInvocation() { 2456 void StreamingConstantEvaluator::EvaluateMethodInvocation() {
2461 builder_->ReadPosition(); // read position. 2457 builder_->ReadPosition(); // read position.
2462 // This method call wasn't cached, so receiver et al. isn't cached either. 2458 // This method call wasn't cached, so receiver et al. isn't cached either.
2463 const dart::Instance& receiver = 2459 const Instance& receiver =
2464 EvaluateExpression(builder_->ReaderOffset(), false); // read receiver. 2460 EvaluateExpression(builder_->ReaderOffset(), false); // read receiver.
2465 dart::Class& klass = dart::Class::Handle( 2461 Class& klass =
2466 Z, isolate_->class_table()->At(receiver.GetClassId())); 2462 Class::Handle(Z, isolate_->class_table()->At(receiver.GetClassId()));
2467 ASSERT(!klass.IsNull()); 2463 ASSERT(!klass.IsNull());
2468 2464
2469 // Search the superclass chain for the selector. 2465 // Search the superclass chain for the selector.
2470 dart::Function& function = dart::Function::Handle(Z); 2466 Function& function = Function::Handle(Z);
2471 const dart::String& method_name = 2467 const String& method_name = builder_->ReadNameAsMethodName(); // read name.
2472 builder_->ReadNameAsMethodName(); // read name.
2473 while (!klass.IsNull()) { 2468 while (!klass.IsNull()) {
2474 function = klass.LookupDynamicFunctionAllowPrivate(method_name); 2469 function = klass.LookupDynamicFunctionAllowPrivate(method_name);
2475 if (!function.IsNull()) break; 2470 if (!function.IsNull()) break;
2476 klass = klass.SuperClass(); 2471 klass = klass.SuperClass();
2477 } 2472 }
2478 2473
2479 // The frontend should guarantee that [MethodInvocation]s inside constant 2474 // The frontend should guarantee that [MethodInvocation]s inside constant
2480 // expressions are always valid. 2475 // expressions are always valid.
2481 ASSERT(!function.IsNull()); 2476 ASSERT(!function.IsNull());
2482 2477
(...skipping 11 matching lines...) Expand all
2494 builder_->SkipCanonicalNameReference(); // read "interface_target_reference" 2489 builder_->SkipCanonicalNameReference(); // read "interface_target_reference"
2495 } 2490 }
2496 2491
2497 void StreamingConstantEvaluator::EvaluateStaticInvocation() { 2492 void StreamingConstantEvaluator::EvaluateStaticInvocation() {
2498 builder_->ReadPosition(); // read position. 2493 builder_->ReadPosition(); // read position.
2499 NameIndex procedue_reference = 2494 NameIndex procedue_reference =
2500 builder_->ReadCanonicalNameReference(); // read procedure reference. 2495 builder_->ReadCanonicalNameReference(); // read procedure reference.
2501 2496
2502 const Function& function = Function::ZoneHandle( 2497 const Function& function = Function::ZoneHandle(
2503 Z, H.LookupStaticMethodByKernelProcedure(procedue_reference)); 2498 Z, H.LookupStaticMethodByKernelProcedure(procedue_reference));
2504 dart::Class& klass = dart::Class::Handle(Z, function.Owner()); 2499 Class& klass = Class::Handle(Z, function.Owner());
2505 2500
2506 intptr_t argument_count = 2501 intptr_t argument_count =
2507 builder_->ReadUInt(); // read arguments part #1: arguments count. 2502 builder_->ReadUInt(); // read arguments part #1: arguments count.
2508 2503
2509 // Build the type arguments vector (if necessary). 2504 // Build the type arguments vector (if necessary).
2510 const TypeArguments* type_arguments = 2505 const TypeArguments* type_arguments =
2511 TranslateTypeArguments(function, &klass); // read argument types. 2506 TranslateTypeArguments(function, &klass); // read argument types.
2512 2507
2513 // read positional and named parameters. 2508 // read positional and named parameters.
2514 const Object& result = 2509 const Object& result =
2515 RunFunction(function, argument_count, NULL, type_arguments); 2510 RunFunction(function, argument_count, NULL, type_arguments);
2516 result_ ^= result.raw(); 2511 result_ ^= result.raw();
2517 result_ = H.Canonicalize(result_); 2512 result_ = H.Canonicalize(result_);
2518 } 2513 }
2519 2514
2520 void StreamingConstantEvaluator::EvaluateConstructorInvocationInternal() { 2515 void StreamingConstantEvaluator::EvaluateConstructorInvocationInternal() {
2521 builder_->ReadPosition(); // read position. 2516 builder_->ReadPosition(); // read position.
2522 2517
2523 NameIndex target = builder_->ReadCanonicalNameReference(); // read target. 2518 NameIndex target = builder_->ReadCanonicalNameReference(); // read target.
2524 const Function& constructor = 2519 const Function& constructor =
2525 Function::Handle(Z, H.LookupConstructorByKernelConstructor(target)); 2520 Function::Handle(Z, H.LookupConstructorByKernelConstructor(target));
2526 dart::Class& klass = dart::Class::Handle(Z, constructor.Owner()); 2521 Class& klass = Class::Handle(Z, constructor.Owner());
2527 2522
2528 intptr_t argument_count = 2523 intptr_t argument_count =
2529 builder_->ReadUInt(); // read arguments part #1: arguments count. 2524 builder_->ReadUInt(); // read arguments part #1: arguments count.
2530 2525
2531 // Build the type arguments vector (if necessary). 2526 // Build the type arguments vector (if necessary).
2532 const TypeArguments* type_arguments = 2527 const TypeArguments* type_arguments =
2533 TranslateTypeArguments(constructor, &klass); // read argument types. 2528 TranslateTypeArguments(constructor, &klass); // read argument types.
2534 2529
2535 // Prepare either the instance or the type argument vector for the constructor 2530 // Prepare either the instance or the type argument vector for the constructor
2536 // call. 2531 // call.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
2600 2595
2601 bool all_string = true; 2596 bool all_string = true;
2602 const Array& strings = Array::Handle(Z, Array::New(length)); 2597 const Array& strings = Array::Handle(Z, Array::New(length));
2603 for (intptr_t i = 0; i < length; ++i) { 2598 for (intptr_t i = 0; i < length; ++i) {
2604 EvaluateExpression(builder_->ReaderOffset(), 2599 EvaluateExpression(builder_->ReaderOffset(),
2605 false); // read ith expression. 2600 false); // read ith expression.
2606 strings.SetAt(i, result_); 2601 strings.SetAt(i, result_);
2607 all_string = all_string && result_.IsString(); 2602 all_string = all_string && result_.IsString();
2608 } 2603 }
2609 if (all_string) { 2604 if (all_string) {
2610 result_ = dart::String::ConcatAll(strings, Heap::kOld); 2605 result_ = String::ConcatAll(strings, Heap::kOld);
2611 result_ = H.Canonicalize(result_); 2606 result_ = H.Canonicalize(result_);
2612 } else { 2607 } else {
2613 // Get string interpolation function. 2608 // Get string interpolation function.
2614 const dart::Class& cls = dart::Class::Handle( 2609 const Class& cls =
2615 Z, dart::Library::LookupCoreClass(Symbols::StringBase())); 2610 Class::Handle(Z, Library::LookupCoreClass(Symbols::StringBase()));
2616 ASSERT(!cls.IsNull()); 2611 ASSERT(!cls.IsNull());
2617 const Function& func = Function::Handle( 2612 const Function& func = Function::Handle(
2618 Z, cls.LookupStaticFunction( 2613 Z, cls.LookupStaticFunction(
2619 dart::Library::PrivateCoreLibName(Symbols::Interpolate()))); 2614 Library::PrivateCoreLibName(Symbols::Interpolate())));
2620 ASSERT(!func.IsNull()); 2615 ASSERT(!func.IsNull());
2621 2616
2622 // Build argument array to pass to the interpolation function. 2617 // Build argument array to pass to the interpolation function.
2623 const Array& interpolate_arg = Array::Handle(Z, Array::New(1, Heap::kOld)); 2618 const Array& interpolate_arg = Array::Handle(Z, Array::New(1, Heap::kOld));
2624 interpolate_arg.SetAt(0, strings); 2619 interpolate_arg.SetAt(0, strings);
2625 2620
2626 // Run and canonicalize. 2621 // Run and canonicalize.
2627 const Object& result = 2622 const Object& result =
2628 RunFunction(func, interpolate_arg, Array::null_array()); 2623 RunFunction(func, interpolate_arg, Array::null_array());
2629 result_ = H.Canonicalize(dart::String::Cast(result)); 2624 result_ = H.Canonicalize(String::Cast(result));
2630 } 2625 }
2631 } 2626 }
2632 2627
2633 void StreamingConstantEvaluator::EvaluateSymbolLiteral() { 2628 void StreamingConstantEvaluator::EvaluateSymbolLiteral() {
2634 const dart::String& symbol_value = H.DartSymbol( 2629 const String& symbol_value = H.DartSymbol(
2635 builder_->ReadStringReference()); // read index into string table. 2630 builder_->ReadStringReference()); // read index into string table.
2636 2631
2637 const dart::Class& symbol_class = 2632 const Class& symbol_class =
2638 dart::Class::ZoneHandle(Z, I->object_store()->symbol_class()); 2633 Class::ZoneHandle(Z, I->object_store()->symbol_class());
2639 ASSERT(!symbol_class.IsNull()); 2634 ASSERT(!symbol_class.IsNull());
2640 const dart::Function& symbol_constructor = Function::ZoneHandle( 2635 const Function& symbol_constructor = Function::ZoneHandle(
2641 Z, symbol_class.LookupConstructor(Symbols::SymbolCtor())); 2636 Z, symbol_class.LookupConstructor(Symbols::SymbolCtor()));
2642 ASSERT(!symbol_constructor.IsNull()); 2637 ASSERT(!symbol_constructor.IsNull());
2643 result_ ^= EvaluateConstConstructorCall( 2638 result_ ^= EvaluateConstConstructorCall(
2644 symbol_class, TypeArguments::Handle(Z), symbol_constructor, symbol_value); 2639 symbol_class, TypeArguments::Handle(Z), symbol_constructor, symbol_value);
2645 } 2640 }
2646 2641
2647 void StreamingConstantEvaluator::EvaluateTypeLiteral() { 2642 void StreamingConstantEvaluator::EvaluateTypeLiteral() {
2648 const AbstractType& type = T.BuildType(); 2643 const AbstractType& type = T.BuildType();
2649 if (type.IsMalformed()) { 2644 if (type.IsMalformed()) {
2650 H.ReportError("Malformed type literal in constant expression."); 2645 H.ReportError("Malformed type literal in constant expression.");
(...skipping 30 matching lines...) Expand all
2681 for (intptr_t i = 0; i < length; ++i) { 2676 for (intptr_t i = 0; i < length; ++i) {
2682 const_kv_array.SetAt(2 * i + 0, EvaluateExpression(builder_->ReaderOffset(), 2677 const_kv_array.SetAt(2 * i + 0, EvaluateExpression(builder_->ReaderOffset(),
2683 false)); // read key. 2678 false)); // read key.
2684 const_kv_array.SetAt(2 * i + 1, EvaluateExpression(builder_->ReaderOffset(), 2679 const_kv_array.SetAt(2 * i + 1, EvaluateExpression(builder_->ReaderOffset(),
2685 false)); // read value. 2680 false)); // read value.
2686 } 2681 }
2687 2682
2688 const_kv_array.MakeImmutable(); 2683 const_kv_array.MakeImmutable();
2689 const_kv_array ^= H.Canonicalize(const_kv_array); 2684 const_kv_array ^= H.Canonicalize(const_kv_array);
2690 2685
2691 const dart::Class& map_class = dart::Class::Handle( 2686 const Class& map_class =
2692 Z, dart::Library::LookupCoreClass(Symbols::ImmutableMap())); 2687 Class::Handle(Z, Library::LookupCoreClass(Symbols::ImmutableMap()));
2693 ASSERT(!map_class.IsNull()); 2688 ASSERT(!map_class.IsNull());
2694 ASSERT(map_class.NumTypeArguments() == 2); 2689 ASSERT(map_class.NumTypeArguments() == 2);
2695 2690
2696 const dart::Field& field = dart::Field::Handle( 2691 const Field& field = Field::Handle(
2697 Z, map_class.LookupInstanceFieldAllowPrivate(H.DartSymbol("_kvPairs"))); 2692 Z, map_class.LookupInstanceFieldAllowPrivate(H.DartSymbol("_kvPairs")));
2698 ASSERT(!field.IsNull()); 2693 ASSERT(!field.IsNull());
2699 2694
2700 // NOTE: This needs to be kept in sync with `runtime/lib/immutable_map.dart`! 2695 // NOTE: This needs to be kept in sync with `runtime/lib/immutable_map.dart`!
2701 result_ = Instance::New(map_class, Heap::kOld); 2696 result_ = Instance::New(map_class, Heap::kOld);
2702 ASSERT(!result_.IsNull()); 2697 ASSERT(!result_.IsNull());
2703 result_.SetTypeArguments(type_arguments); 2698 result_.SetTypeArguments(type_arguments);
2704 result_.SetField(field, const_kv_array); 2699 result_.SetField(field, const_kv_array);
2705 result_ = H.Canonicalize(result_); 2700 result_ = H.Canonicalize(result_);
2706 } 2701 }
2707 2702
2708 void StreamingConstantEvaluator::EvaluateLet() { 2703 void StreamingConstantEvaluator::EvaluateLet() {
2709 intptr_t kernel_position = 2704 intptr_t kernel_position =
2710 builder_->ReaderOffset() + builder_->relative_kernel_offset_; 2705 builder_->ReaderOffset() + builder_->relative_kernel_offset_;
2711 LocalVariable* local = builder_->LookupVariable(kernel_position); 2706 LocalVariable* local = builder_->LookupVariable(kernel_position);
2712 2707
2713 // read variable declaration. 2708 // read variable declaration.
2714 VariableDeclarationHelper helper(builder_); 2709 VariableDeclarationHelper helper(builder_);
2715 helper.ReadUntilExcluding(VariableDeclarationHelper::kInitializer); 2710 helper.ReadUntilExcluding(VariableDeclarationHelper::kInitializer);
2716 Tag tag = builder_->ReadTag(); // read (first part of) initializer. 2711 Tag tag = builder_->ReadTag(); // read (first part of) initializer.
2717 if (tag == kNothing) { 2712 if (tag == kNothing) {
2718 local->SetConstValue(Instance::ZoneHandle(Z, dart::Instance::null())); 2713 local->SetConstValue(Instance::ZoneHandle(Z, Instance::null()));
2719 } else { 2714 } else {
2720 local->SetConstValue(EvaluateExpression( 2715 local->SetConstValue(EvaluateExpression(
2721 builder_->ReaderOffset(), false)); // read rest of initializer. 2716 builder_->ReaderOffset(), false)); // read rest of initializer.
2722 } 2717 }
2723 2718
2724 EvaluateExpression(builder_->ReaderOffset(), false); // read body 2719 EvaluateExpression(builder_->ReaderOffset(), false); // read body
2725 } 2720 }
2726 2721
2727 void StreamingConstantEvaluator::EvaluateBigIntLiteral() { 2722 void StreamingConstantEvaluator::EvaluateBigIntLiteral() {
2728 const dart::String& value = 2723 const String& value =
2729 H.DartString(builder_->ReadStringReference()); // read string reference. 2724 H.DartString(builder_->ReadStringReference()); // read string reference.
2730 result_ = Integer::New(value, Heap::kOld); 2725 result_ = Integer::New(value, Heap::kOld);
2731 if (result_.IsNull()) { 2726 if (result_.IsNull()) {
2732 H.ReportError("Integer literal %s is out of range", value.ToCString()); 2727 H.ReportError("Integer literal %s is out of range", value.ToCString());
2733 UNREACHABLE(); 2728 UNREACHABLE();
2734 } 2729 }
2735 result_ = H.Canonicalize(result_); 2730 result_ = H.Canonicalize(result_);
2736 } 2731 }
2737 2732
2738 void StreamingConstantEvaluator::EvaluateStringLiteral() { 2733 void StreamingConstantEvaluator::EvaluateStringLiteral() {
2739 result_ = H.DartSymbol(builder_->ReadStringReference()) 2734 result_ = H.DartSymbol(builder_->ReadStringReference())
2740 .raw(); // read string reference. 2735 .raw(); // read string reference.
2741 } 2736 }
2742 2737
2743 void StreamingConstantEvaluator::EvaluateIntLiteral(uint8_t payload) { 2738 void StreamingConstantEvaluator::EvaluateIntLiteral(uint8_t payload) {
2744 int64_t value = static_cast<int32_t>(payload) - SpecializedIntLiteralBias; 2739 int64_t value = static_cast<int32_t>(payload) - SpecializedIntLiteralBias;
2745 result_ = dart::Integer::New(value, Heap::kOld); 2740 result_ = Integer::New(value, Heap::kOld);
2746 result_ = H.Canonicalize(result_); 2741 result_ = H.Canonicalize(result_);
2747 } 2742 }
2748 2743
2749 void StreamingConstantEvaluator::EvaluateIntLiteral(bool is_negative) { 2744 void StreamingConstantEvaluator::EvaluateIntLiteral(bool is_negative) {
2750 int64_t value = is_negative ? -static_cast<int64_t>(builder_->ReadUInt()) 2745 int64_t value = is_negative ? -static_cast<int64_t>(builder_->ReadUInt())
2751 : builder_->ReadUInt(); // read value. 2746 : builder_->ReadUInt(); // read value.
2752 result_ = dart::Integer::New(value, Heap::kOld); 2747 result_ = Integer::New(value, Heap::kOld);
2753 result_ = H.Canonicalize(result_); 2748 result_ = H.Canonicalize(result_);
2754 } 2749 }
2755 2750
2756 void StreamingConstantEvaluator::EvaluateDoubleLiteral() { 2751 void StreamingConstantEvaluator::EvaluateDoubleLiteral() {
2757 result_ = Double::New(H.DartString(builder_->ReadStringReference()), 2752 result_ = Double::New(H.DartString(builder_->ReadStringReference()),
2758 Heap::kOld); // read string reference. 2753 Heap::kOld); // read string reference.
2759 result_ = H.Canonicalize(result_); 2754 result_ = H.Canonicalize(result_);
2760 } 2755 }
2761 2756
2762 void StreamingConstantEvaluator::EvaluateBoolLiteral(bool value) { 2757 void StreamingConstantEvaluator::EvaluateBoolLiteral(bool value) {
2763 result_ = dart::Bool::Get(value).raw(); 2758 result_ = Bool::Get(value).raw();
2764 } 2759 }
2765 2760
2766 void StreamingConstantEvaluator::EvaluateNullLiteral() { 2761 void StreamingConstantEvaluator::EvaluateNullLiteral() {
2767 result_ = dart::Instance::null(); 2762 result_ = Instance::null();
2768 } 2763 }
2769 2764
2770 // This depends on being about to read the list of positionals on arguments. 2765 // This depends on being about to read the list of positionals on arguments.
2771 const Object& StreamingConstantEvaluator::RunFunction( 2766 const Object& StreamingConstantEvaluator::RunFunction(
2772 const Function& function, 2767 const Function& function,
2773 intptr_t argument_count, 2768 intptr_t argument_count,
2774 const Instance* receiver, 2769 const Instance* receiver,
2775 const TypeArguments* type_args) { 2770 const TypeArguments* type_args) {
2776 // We do not support generic methods yet. 2771 // We do not support generic methods yet.
2777 ASSERT((receiver == NULL) || (type_args == NULL)); 2772 ASSERT((receiver == NULL) || (type_args == NULL));
(...skipping 16 matching lines...) Expand all
2794 for (intptr_t i = 0; i < list_length; ++i) { 2789 for (intptr_t i = 0; i < list_length; ++i) {
2795 EvaluateExpression(builder_->ReaderOffset(), 2790 EvaluateExpression(builder_->ReaderOffset(),
2796 false); // read ith expression. 2791 false); // read ith expression.
2797 arguments.SetAt(pos++, result_); 2792 arguments.SetAt(pos++, result_);
2798 } 2793 }
2799 2794
2800 // List of named. 2795 // List of named.
2801 list_length = builder_->ReadListLength(); // read list length. 2796 list_length = builder_->ReadListLength(); // read list length.
2802 const Array& names = Array::ZoneHandle(Z, Array::New(list_length)); 2797 const Array& names = Array::ZoneHandle(Z, Array::New(list_length));
2803 for (intptr_t i = 0; i < list_length; ++i) { 2798 for (intptr_t i = 0; i < list_length; ++i) {
2804 dart::String& name = 2799 String& name =
2805 H.DartSymbol(builder_->ReadStringReference()); // read ith name index. 2800 H.DartSymbol(builder_->ReadStringReference()); // read ith name index.
2806 names.SetAt(i, name); 2801 names.SetAt(i, name);
2807 EvaluateExpression(builder_->ReaderOffset(), 2802 EvaluateExpression(builder_->ReaderOffset(),
2808 false); // read ith expression. 2803 false); // read ith expression.
2809 arguments.SetAt(pos++, result_); 2804 arguments.SetAt(pos++, result_);
2810 } 2805 }
2811 2806
2812 return RunFunction(function, arguments, names); 2807 return RunFunction(function, arguments, names);
2813 } 2808 }
2814 2809
2815 const Object& StreamingConstantEvaluator::RunFunction(const Function& function, 2810 const Object& StreamingConstantEvaluator::RunFunction(const Function& function,
2816 const Array& arguments, 2811 const Array& arguments,
2817 const Array& names) { 2812 const Array& names) {
2818 // We do not support generic methods yet. 2813 // We do not support generic methods yet.
2819 const int kTypeArgsLen = 0; 2814 const int kTypeArgsLen = 0;
2820 const Array& args_descriptor = Array::Handle( 2815 const Array& args_descriptor = Array::Handle(
2821 Z, ArgumentsDescriptor::New(kTypeArgsLen, arguments.Length(), names)); 2816 Z, ArgumentsDescriptor::New(kTypeArgsLen, arguments.Length(), names));
2822 const Object& result = Object::Handle( 2817 const Object& result = Object::Handle(
2823 Z, DartEntry::InvokeFunction(function, arguments, args_descriptor)); 2818 Z, DartEntry::InvokeFunction(function, arguments, args_descriptor));
2824 if (result.IsError()) { 2819 if (result.IsError()) {
2825 H.ReportError(Error::Cast(result), "error evaluating constant constructor"); 2820 H.ReportError(Error::Cast(result), "error evaluating constant constructor");
2826 } 2821 }
2827 return result; 2822 return result;
2828 } 2823 }
2829 2824
2830 RawObject* StreamingConstantEvaluator::EvaluateConstConstructorCall( 2825 RawObject* StreamingConstantEvaluator::EvaluateConstConstructorCall(
2831 const dart::Class& type_class, 2826 const Class& type_class,
2832 const TypeArguments& type_arguments, 2827 const TypeArguments& type_arguments,
2833 const Function& constructor, 2828 const Function& constructor,
2834 const Object& argument) { 2829 const Object& argument) {
2835 // Factories have one extra argument: the type arguments. 2830 // Factories have one extra argument: the type arguments.
2836 // Constructors have 1 extra arguments: receiver. 2831 // Constructors have 1 extra arguments: receiver.
2837 const int kTypeArgsLen = 0; 2832 const int kTypeArgsLen = 0;
2838 const int kNumArgs = 1; 2833 const int kNumArgs = 1;
2839 const int kNumExtraArgs = 1; 2834 const int kNumExtraArgs = 1;
2840 const int argument_count = kNumArgs + kNumExtraArgs; 2835 const int argument_count = kNumArgs + kNumExtraArgs;
2841 const Array& arg_values = 2836 const Array& arg_values =
(...skipping 21 matching lines...) Expand all
2863 ASSERT(!result.IsError()); 2858 ASSERT(!result.IsError());
2864 if (constructor.IsFactory()) { 2859 if (constructor.IsFactory()) {
2865 // The factory method returns the allocated object. 2860 // The factory method returns the allocated object.
2866 instance ^= result.raw(); 2861 instance ^= result.raw();
2867 } 2862 }
2868 return H.Canonicalize(instance); 2863 return H.Canonicalize(instance);
2869 } 2864 }
2870 2865
2871 const TypeArguments* StreamingConstantEvaluator::TranslateTypeArguments( 2866 const TypeArguments* StreamingConstantEvaluator::TranslateTypeArguments(
2872 const Function& target, 2867 const Function& target,
2873 dart::Class* target_klass) { 2868 Class* target_klass) {
2874 intptr_t type_count = builder_->ReadListLength(); // read type count. 2869 intptr_t type_count = builder_->ReadListLength(); // read type count.
2875 2870
2876 const TypeArguments* type_arguments = NULL; 2871 const TypeArguments* type_arguments = NULL;
2877 if (type_count > 0) { 2872 if (type_count > 0) {
2878 type_arguments = &T.BuildInstantiatedTypeArguments( 2873 type_arguments = &T.BuildInstantiatedTypeArguments(
2879 *target_klass, type_count); // read types. 2874 *target_klass, type_count); // read types.
2880 2875
2881 if (!(type_arguments->IsNull() || type_arguments->IsInstantiated())) { 2876 if (!(type_arguments->IsNull() || type_arguments->IsInstantiated())) {
2882 H.ReportError("Type must be constant in const constructor."); 2877 H.ReportError("Type must be constant in const constructor.");
2883 } 2878 }
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
3042 3037
3043 FlowGraph* StreamingFlowGraphBuilder::BuildGraphOfFieldAccessor( 3038 FlowGraph* StreamingFlowGraphBuilder::BuildGraphOfFieldAccessor(
3044 LocalVariable* setter_value) { 3039 LocalVariable* setter_value) {
3045 FieldHelper field_helper(this); 3040 FieldHelper field_helper(this);
3046 field_helper.ReadUntilIncluding(FieldHelper::kCanonicalName); 3041 field_helper.ReadUntilIncluding(FieldHelper::kCanonicalName);
3047 3042
3048 const Function& function = parsed_function()->function(); 3043 const Function& function = parsed_function()->function();
3049 3044
3050 bool is_setter = function.IsImplicitSetterFunction(); 3045 bool is_setter = function.IsImplicitSetterFunction();
3051 bool is_method = !function.IsStaticFunction(); 3046 bool is_method = !function.IsStaticFunction();
3052 dart::Field& field = dart::Field::ZoneHandle( 3047 Field& field = Field::ZoneHandle(
3053 Z, H.LookupFieldByKernelField(field_helper.canonical_name_)); 3048 Z, H.LookupFieldByKernelField(field_helper.canonical_name_));
3054 3049
3055 TargetEntryInstr* normal_entry = flow_graph_builder_->BuildTargetEntry(); 3050 TargetEntryInstr* normal_entry = flow_graph_builder_->BuildTargetEntry();
3056 flow_graph_builder_->graph_entry_ = new (Z) GraphEntryInstr( 3051 flow_graph_builder_->graph_entry_ = new (Z) GraphEntryInstr(
3057 *parsed_function(), normal_entry, Compiler::kNoOSRDeoptId); 3052 *parsed_function(), normal_entry, Compiler::kNoOSRDeoptId);
3058 3053
3059 Fragment body(normal_entry); 3054 Fragment body(normal_entry);
3060 if (is_setter) { 3055 if (is_setter) {
3061 if (is_method) { 3056 if (is_method) {
3062 body += LoadLocal(scopes()->this_variable); 3057 body += LoadLocal(scopes()->this_variable);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
3171 // List of named. 3166 // List of named.
3172 list_length = ReadListLength(); // read list length. 3167 list_length = ReadListLength(); // read list length.
3173 ASSERT(list_length == 0); 3168 ASSERT(list_length == 0);
3174 } 3169 }
3175 parsed_function()->set_default_parameter_values(default_values); 3170 parsed_function()->set_default_parameter_values(default_values);
3176 } 3171 }
3177 } 3172 }
3178 3173
3179 Fragment StreamingFlowGraphBuilder::BuildFieldInitializer( 3174 Fragment StreamingFlowGraphBuilder::BuildFieldInitializer(
3180 NameIndex canonical_name) { 3175 NameIndex canonical_name) {
3181 dart::Field& field = 3176 Field& field =
3182 dart::Field::ZoneHandle(Z, H.LookupFieldByKernelField(canonical_name)); 3177 Field::ZoneHandle(Z, H.LookupFieldByKernelField(canonical_name));
3183 if (PeekTag() == kNullLiteral) { 3178 if (PeekTag() == kNullLiteral) {
3184 SkipExpression(); // read past the null literal. 3179 SkipExpression(); // read past the null literal.
3185 field.RecordStore(Object::null_object()); 3180 field.RecordStore(Object::null_object());
3186 return Fragment(); 3181 return Fragment();
3187 } 3182 }
3188 3183
3189 Fragment instructions; 3184 Fragment instructions;
3190 instructions += LoadLocal(scopes()->this_variable); 3185 instructions += LoadLocal(scopes()->this_variable);
3191 instructions += BuildExpression(); 3186 instructions += BuildExpression();
3192 instructions += flow_graph_builder_->StoreInstanceFieldGuarded(field, true); 3187 instructions += flow_graph_builder_->StoreInstanceFieldGuarded(field, true);
(...skipping 29 matching lines...) Expand all
3222 } else if (PeekTag() == kFieldInitializer) { 3217 } else if (PeekTag() == kFieldInitializer) {
3223 no_field_initializers = false; 3218 no_field_initializers = false;
3224 } 3219 }
3225 SkipInitializer(); 3220 SkipInitializer();
3226 } 3221 }
3227 ASSERT(is_redirecting_constructor ? no_field_initializers : true); 3222 ASSERT(is_redirecting_constructor ? no_field_initializers : true);
3228 } 3223 }
3229 3224
3230 if (!is_redirecting_constructor) { 3225 if (!is_redirecting_constructor) {
3231 Array& class_fields = Array::Handle(Z, parent_class.fields()); 3226 Array& class_fields = Array::Handle(Z, parent_class.fields());
3232 dart::Field& class_field = dart::Field::Handle(Z); 3227 Field& class_field = Field::Handle(Z);
3233 for (intptr_t i = 0; i < class_fields.Length(); ++i) { 3228 for (intptr_t i = 0; i < class_fields.Length(); ++i) {
3234 class_field ^= class_fields.At(i); 3229 class_field ^= class_fields.At(i);
3235 if (!class_field.is_static()) { 3230 if (!class_field.is_static()) {
3236 TypedData& kernel_data = 3231 TypedData& kernel_data =
3237 TypedData::Handle(Z, class_field.kernel_data()); 3232 TypedData::Handle(Z, class_field.kernel_data());
3238 ASSERT(!kernel_data.IsNull()); 3233 ASSERT(!kernel_data.IsNull());
3239 AlternativeReadingScope alt(reader_, &kernel_data, 0); 3234 AlternativeReadingScope alt(reader_, &kernel_data, 0);
3240 intptr_t saved_relative_kernel_offset_ = relative_kernel_offset_; 3235 intptr_t saved_relative_kernel_offset_ = relative_kernel_offset_;
3241 relative_kernel_offset_ = class_field.kernel_offset(); 3236 relative_kernel_offset_ = class_field.kernel_offset();
3242 FieldHelper field_helper(this); 3237 FieldHelper field_helper(this);
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
3822 } 3817 }
3823 return new (Z) FlowGraph(*parsed_function(), graph_entry, 3818 return new (Z) FlowGraph(*parsed_function(), graph_entry,
3824 flow_graph_builder_->next_block_id_ - 1); 3819 flow_graph_builder_->next_block_id_ - 1);
3825 } 3820 }
3826 3821
3827 FlowGraph* StreamingFlowGraphBuilder::BuildGraph(intptr_t kernel_offset) { 3822 FlowGraph* StreamingFlowGraphBuilder::BuildGraph(intptr_t kernel_offset) {
3828 const Function& function = parsed_function()->function(); 3823 const Function& function = parsed_function()->function();
3829 3824
3830 // Setup a [ActiveClassScope] and a [ActiveMemberScope] which will be used 3825 // Setup a [ActiveClassScope] and a [ActiveMemberScope] which will be used
3831 // e.g. for type translation. 3826 // e.g. for type translation.
3832 const dart::Class& klass = 3827 const Class& klass =
3833 dart::Class::Handle(zone_, parsed_function()->function().Owner()); 3828 Class::Handle(zone_, parsed_function()->function().Owner());
3834 3829
3835 Function& outermost_function = Function::Handle(Z); 3830 Function& outermost_function = Function::Handle(Z);
3836 DiscoverEnclosingElements(Z, function, &outermost_function); 3831 DiscoverEnclosingElements(Z, function, &outermost_function);
3837 3832
3838 ActiveClassScope active_class_scope(active_class(), &klass); 3833 ActiveClassScope active_class_scope(active_class(), &klass);
3839 ActiveMemberScope active_member(active_class(), &outermost_function); 3834 ActiveMemberScope active_member(active_class(), &outermost_function);
3840 3835
3841 // The IR builder will create its own local variables and scopes, and it 3836 // The IR builder will create its own local variables and scopes, and it
3842 // will not need an AST. The code generator will assume that there is a 3837 // will not need an AST. The code generator will assume that there is a
3843 // local variable stack slot allocated for the current context and (I 3838 // local variable stack slot allocated for the current context and (I
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
4092 } 4087 }
4093 4088
4094 StringIndex StreamingFlowGraphBuilder::ReadNameAsStringIndex() { 4089 StringIndex StreamingFlowGraphBuilder::ReadNameAsStringIndex() {
4095 StringIndex name_index = ReadStringReference(); // read name index. 4090 StringIndex name_index = ReadStringReference(); // read name index.
4096 if ((H.StringSize(name_index) >= 1) && H.CharacterAt(name_index, 0) == '_') { 4091 if ((H.StringSize(name_index) >= 1) && H.CharacterAt(name_index, 0) == '_') {
4097 ReadUInt(); // read library index. 4092 ReadUInt(); // read library index.
4098 } 4093 }
4099 return name_index; 4094 return name_index;
4100 } 4095 }
4101 4096
4102 const dart::String& StreamingFlowGraphBuilder::ReadNameAsMethodName() { 4097 const String& StreamingFlowGraphBuilder::ReadNameAsMethodName() {
4103 StringIndex name_index = ReadStringReference(); // read name index. 4098 StringIndex name_index = ReadStringReference(); // read name index.
4104 if ((H.StringSize(name_index) >= 1) && H.CharacterAt(name_index, 0) == '_') { 4099 if ((H.StringSize(name_index) >= 1) && H.CharacterAt(name_index, 0) == '_') {
4105 NameIndex library_reference = 4100 NameIndex library_reference =
4106 ReadCanonicalNameReference(); // read library index. 4101 ReadCanonicalNameReference(); // read library index.
4107 return H.DartMethodName(library_reference, name_index); 4102 return H.DartMethodName(library_reference, name_index);
4108 } else { 4103 } else {
4109 return H.DartMethodName(NameIndex(), name_index); 4104 return H.DartMethodName(NameIndex(), name_index);
4110 } 4105 }
4111 } 4106 }
4112 4107
4113 const dart::String& StreamingFlowGraphBuilder::ReadNameAsSetterName() { 4108 const String& StreamingFlowGraphBuilder::ReadNameAsSetterName() {
4114 StringIndex name_index = ReadStringReference(); // read name index. 4109 StringIndex name_index = ReadStringReference(); // read name index.
4115 if ((H.StringSize(name_index) >= 1) && H.CharacterAt(name_index, 0) == '_') { 4110 if ((H.StringSize(name_index) >= 1) && H.CharacterAt(name_index, 0) == '_') {
4116 NameIndex library_reference = 4111 NameIndex library_reference =
4117 ReadCanonicalNameReference(); // read library index. 4112 ReadCanonicalNameReference(); // read library index.
4118 return H.DartSetterName(library_reference, name_index); 4113 return H.DartSetterName(library_reference, name_index);
4119 } else { 4114 } else {
4120 return H.DartSetterName(NameIndex(), name_index); 4115 return H.DartSetterName(NameIndex(), name_index);
4121 } 4116 }
4122 } 4117 }
4123 4118
4124 const dart::String& StreamingFlowGraphBuilder::ReadNameAsGetterName() { 4119 const String& StreamingFlowGraphBuilder::ReadNameAsGetterName() {
4125 StringIndex name_index = ReadStringReference(); // read name index. 4120 StringIndex name_index = ReadStringReference(); // read name index.
4126 if ((H.StringSize(name_index) >= 1) && H.CharacterAt(name_index, 0) == '_') { 4121 if ((H.StringSize(name_index) >= 1) && H.CharacterAt(name_index, 0) == '_') {
4127 NameIndex library_reference = 4122 NameIndex library_reference =
4128 ReadCanonicalNameReference(); // read library index. 4123 ReadCanonicalNameReference(); // read library index.
4129 return H.DartGetterName(library_reference, name_index); 4124 return H.DartGetterName(library_reference, name_index);
4130 } else { 4125 } else {
4131 return H.DartGetterName(NameIndex(), name_index); 4126 return H.DartGetterName(NameIndex(), name_index);
4132 } 4127 }
4133 } 4128 }
4134 4129
4135 const dart::String& StreamingFlowGraphBuilder::ReadNameAsFieldName() { 4130 const String& StreamingFlowGraphBuilder::ReadNameAsFieldName() {
4136 StringIndex name_index = ReadStringReference(); // read name index. 4131 StringIndex name_index = ReadStringReference(); // read name index.
4137 if ((H.StringSize(name_index) >= 1) && H.CharacterAt(name_index, 0) == '_') { 4132 if ((H.StringSize(name_index) >= 1) && H.CharacterAt(name_index, 0) == '_') {
4138 NameIndex library_reference = 4133 NameIndex library_reference =
4139 ReadCanonicalNameReference(); // read library index. 4134 ReadCanonicalNameReference(); // read library index.
4140 return H.DartFieldName(library_reference, name_index); 4135 return H.DartFieldName(library_reference, name_index);
4141 } else { 4136 } else {
4142 return H.DartFieldName(NameIndex(), name_index); 4137 return H.DartFieldName(NameIndex(), name_index);
4143 } 4138 }
4144 } 4139 }
4145 4140
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
4839 intptr_t list_length = ReadListLength(); // read list length. 4834 intptr_t list_length = ReadListLength(); // read list length.
4840 for (intptr_t i = 0; i < list_length; ++i) { 4835 for (intptr_t i = 0; i < list_length; ++i) {
4841 return ReadTag(); // read first tag. 4836 return ReadTag(); // read first tag.
4842 } 4837 }
4843 4838
4844 UNREACHABLE(); 4839 UNREACHABLE();
4845 return kNothing; 4840 return kNothing;
4846 } 4841 }
4847 4842
4848 const TypeArguments& StreamingFlowGraphBuilder::PeekArgumentsInstantiatedType( 4843 const TypeArguments& StreamingFlowGraphBuilder::PeekArgumentsInstantiatedType(
4849 const dart::Class& klass) { 4844 const Class& klass) {
4850 // read parts of arguments, then go back to before doing so. 4845 // read parts of arguments, then go back to before doing so.
4851 AlternativeReadingScope alt(reader_); 4846 AlternativeReadingScope alt(reader_);
4852 ReadUInt(); // read argument count. 4847 ReadUInt(); // read argument count.
4853 intptr_t list_length = ReadListLength(); // read types list length. 4848 intptr_t list_length = ReadListLength(); // read types list length.
4854 return T.BuildInstantiatedTypeArguments(klass, list_length); // read types. 4849 return T.BuildInstantiatedTypeArguments(klass, list_length); // read types.
4855 } 4850 }
4856 4851
4857 intptr_t StreamingFlowGraphBuilder::PeekArgumentsCount() { 4852 intptr_t StreamingFlowGraphBuilder::PeekArgumentsCount() {
4858 return PeekUInt(); 4853 return PeekUInt();
4859 } 4854 }
(...skipping 11 matching lines...) Expand all
4871 4866
4872 LocalVariable* StreamingFlowGraphBuilder::LookupVariable( 4867 LocalVariable* StreamingFlowGraphBuilder::LookupVariable(
4873 intptr_t kernel_offset) { 4868 intptr_t kernel_offset) {
4874 return flow_graph_builder_->LookupVariable(kernel_offset); 4869 return flow_graph_builder_->LookupVariable(kernel_offset);
4875 } 4870 }
4876 4871
4877 LocalVariable* StreamingFlowGraphBuilder::MakeTemporary() { 4872 LocalVariable* StreamingFlowGraphBuilder::MakeTemporary() {
4878 return flow_graph_builder_->MakeTemporary(); 4873 return flow_graph_builder_->MakeTemporary();
4879 } 4874 }
4880 4875
4881 Token::Kind StreamingFlowGraphBuilder::MethodKind(const dart::String& name) { 4876 Token::Kind StreamingFlowGraphBuilder::MethodKind(const String& name) {
4882 return flow_graph_builder_->MethodKind(name); 4877 return flow_graph_builder_->MethodKind(name);
4883 } 4878 }
4884 4879
4885 dart::RawFunction* StreamingFlowGraphBuilder::LookupMethodByMember( 4880 RawFunction* StreamingFlowGraphBuilder::LookupMethodByMember(
4886 NameIndex target, 4881 NameIndex target,
4887 const dart::String& method_name) { 4882 const String& method_name) {
4888 return flow_graph_builder_->LookupMethodByMember(target, method_name); 4883 return flow_graph_builder_->LookupMethodByMember(target, method_name);
4889 } 4884 }
4890 4885
4891 bool StreamingFlowGraphBuilder::NeedsDebugStepCheck(const Function& function, 4886 bool StreamingFlowGraphBuilder::NeedsDebugStepCheck(const Function& function,
4892 TokenPosition position) { 4887 TokenPosition position) {
4893 return flow_graph_builder_->NeedsDebugStepCheck(function, position); 4888 return flow_graph_builder_->NeedsDebugStepCheck(function, position);
4894 } 4889 }
4895 4890
4896 bool StreamingFlowGraphBuilder::NeedsDebugStepCheck(Value* value, 4891 bool StreamingFlowGraphBuilder::NeedsDebugStepCheck(Value* value,
4897 TokenPosition position) { 4892 TokenPosition position) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
4953 const Function& target, 4948 const Function& target,
4954 intptr_t argument_count, 4949 intptr_t argument_count,
4955 const Array& argument_names, 4950 const Array& argument_names,
4956 intptr_t type_args_count) { 4951 intptr_t type_args_count) {
4957 return flow_graph_builder_->StaticCall(position, target, argument_count, 4952 return flow_graph_builder_->StaticCall(position, target, argument_count,
4958 argument_names, type_args_count); 4953 argument_names, type_args_count);
4959 } 4954 }
4960 4955
4961 Fragment StreamingFlowGraphBuilder::InstanceCall( 4956 Fragment StreamingFlowGraphBuilder::InstanceCall(
4962 TokenPosition position, 4957 TokenPosition position,
4963 const dart::String& name, 4958 const String& name,
4964 Token::Kind kind, 4959 Token::Kind kind,
4965 intptr_t argument_count, 4960 intptr_t argument_count,
4966 intptr_t checked_argument_count) { 4961 intptr_t checked_argument_count) {
4967 return flow_graph_builder_->InstanceCall(position, name, kind, argument_count, 4962 return flow_graph_builder_->InstanceCall(position, name, kind, argument_count,
4968 checked_argument_count); 4963 checked_argument_count);
4969 } 4964 }
4970 4965
4971 Fragment StreamingFlowGraphBuilder::ThrowException(TokenPosition position) { 4966 Fragment StreamingFlowGraphBuilder::ThrowException(TokenPosition position) {
4972 return flow_graph_builder_->ThrowException(position); 4967 return flow_graph_builder_->ThrowException(position);
4973 } 4968 }
4974 4969
4975 Fragment StreamingFlowGraphBuilder::BooleanNegate() { 4970 Fragment StreamingFlowGraphBuilder::BooleanNegate() {
4976 return flow_graph_builder_->BooleanNegate(); 4971 return flow_graph_builder_->BooleanNegate();
4977 } 4972 }
4978 4973
4979 Fragment StreamingFlowGraphBuilder::TranslateInstantiatedTypeArguments( 4974 Fragment StreamingFlowGraphBuilder::TranslateInstantiatedTypeArguments(
4980 const TypeArguments& type_arguments) { 4975 const TypeArguments& type_arguments) {
4981 return flow_graph_builder_->TranslateInstantiatedTypeArguments( 4976 return flow_graph_builder_->TranslateInstantiatedTypeArguments(
4982 type_arguments); 4977 type_arguments);
4983 } 4978 }
4984 4979
4985 Fragment StreamingFlowGraphBuilder::StrictCompare(Token::Kind kind, 4980 Fragment StreamingFlowGraphBuilder::StrictCompare(Token::Kind kind,
4986 bool number_check) { 4981 bool number_check) {
4987 return flow_graph_builder_->StrictCompare(kind, number_check); 4982 return flow_graph_builder_->StrictCompare(kind, number_check);
4988 } 4983 }
4989 4984
4990 Fragment StreamingFlowGraphBuilder::AllocateObject(TokenPosition position, 4985 Fragment StreamingFlowGraphBuilder::AllocateObject(TokenPosition position,
4991 const dart::Class& klass, 4986 const Class& klass,
4992 intptr_t argument_count) { 4987 intptr_t argument_count) {
4993 return flow_graph_builder_->AllocateObject(position, klass, argument_count); 4988 return flow_graph_builder_->AllocateObject(position, klass, argument_count);
4994 } 4989 }
4995 4990
4996 Fragment StreamingFlowGraphBuilder::AllocateObject( 4991 Fragment StreamingFlowGraphBuilder::AllocateObject(
4997 const dart::Class& klass, 4992 const Class& klass,
4998 const Function& closure_function) { 4993 const Function& closure_function) {
4999 return flow_graph_builder_->AllocateObject(klass, closure_function); 4994 return flow_graph_builder_->AllocateObject(klass, closure_function);
5000 } 4995 }
5001 4996
5002 Fragment StreamingFlowGraphBuilder::AllocateContext(intptr_t size) { 4997 Fragment StreamingFlowGraphBuilder::AllocateContext(intptr_t size) {
5003 return flow_graph_builder_->AllocateContext(size); 4998 return flow_graph_builder_->AllocateContext(size);
5004 } 4999 }
5005 5000
5006 Fragment StreamingFlowGraphBuilder::LoadField(intptr_t offset) { 5001 Fragment StreamingFlowGraphBuilder::LoadField(intptr_t offset) {
5007 return flow_graph_builder_->LoadField(offset); 5002 return flow_graph_builder_->LoadField(offset);
5008 } 5003 }
5009 5004
5010 Fragment StreamingFlowGraphBuilder::InstanceCall( 5005 Fragment StreamingFlowGraphBuilder::InstanceCall(
5011 TokenPosition position, 5006 TokenPosition position,
5012 const dart::String& name, 5007 const String& name,
5013 Token::Kind kind, 5008 Token::Kind kind,
5014 intptr_t type_args_len, 5009 intptr_t type_args_len,
5015 intptr_t argument_count, 5010 intptr_t argument_count,
5016 const Array& argument_names, 5011 const Array& argument_names,
5017 intptr_t checked_argument_count) { 5012 intptr_t checked_argument_count) {
5018 return flow_graph_builder_->InstanceCall(position, name, kind, type_args_len, 5013 return flow_graph_builder_->InstanceCall(position, name, kind, type_args_len,
5019 argument_count, argument_names, 5014 argument_count, argument_names,
5020 checked_argument_count); 5015 checked_argument_count);
5021 } 5016 }
5022 5017
5023 Fragment StreamingFlowGraphBuilder::StoreLocal(TokenPosition position, 5018 Fragment StreamingFlowGraphBuilder::StoreLocal(TokenPosition position,
5024 LocalVariable* variable) { 5019 LocalVariable* variable) {
5025 return flow_graph_builder_->StoreLocal(position, variable); 5020 return flow_graph_builder_->StoreLocal(position, variable);
5026 } 5021 }
5027 5022
5028 Fragment StreamingFlowGraphBuilder::StoreStaticField(TokenPosition position, 5023 Fragment StreamingFlowGraphBuilder::StoreStaticField(TokenPosition position,
5029 const dart::Field& field) { 5024 const Field& field) {
5030 return flow_graph_builder_->StoreStaticField(position, field); 5025 return flow_graph_builder_->StoreStaticField(position, field);
5031 } 5026 }
5032 5027
5033 Fragment StreamingFlowGraphBuilder::StoreInstanceField(TokenPosition position, 5028 Fragment StreamingFlowGraphBuilder::StoreInstanceField(TokenPosition position,
5034 intptr_t offset) { 5029 intptr_t offset) {
5035 return flow_graph_builder_->StoreInstanceField(position, offset); 5030 return flow_graph_builder_->StoreInstanceField(position, offset);
5036 } 5031 }
5037 5032
5038 Fragment StreamingFlowGraphBuilder::StringInterpolate(TokenPosition position) { 5033 Fragment StreamingFlowGraphBuilder::StringInterpolate(TokenPosition position) {
5039 return flow_graph_builder_->StringInterpolate(position); 5034 return flow_graph_builder_->StringInterpolate(position);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
5142 Fragment StreamingFlowGraphBuilder::BuildImplicitClosureCreation( 5137 Fragment StreamingFlowGraphBuilder::BuildImplicitClosureCreation(
5143 const Function& target) { 5138 const Function& target) {
5144 return flow_graph_builder_->BuildImplicitClosureCreation(target); 5139 return flow_graph_builder_->BuildImplicitClosureCreation(target);
5145 } 5140 }
5146 5141
5147 Fragment StreamingFlowGraphBuilder::CheckBooleanInCheckedMode() { 5142 Fragment StreamingFlowGraphBuilder::CheckBooleanInCheckedMode() {
5148 return flow_graph_builder_->CheckBooleanInCheckedMode(); 5143 return flow_graph_builder_->CheckBooleanInCheckedMode();
5149 } 5144 }
5150 5145
5151 Fragment StreamingFlowGraphBuilder::CheckAssignableInCheckedMode( 5146 Fragment StreamingFlowGraphBuilder::CheckAssignableInCheckedMode(
5152 const dart::AbstractType& dst_type, 5147 const AbstractType& dst_type,
5153 const dart::String& dst_name) { 5148 const String& dst_name) {
5154 return flow_graph_builder_->CheckAssignableInCheckedMode(dst_type, dst_name); 5149 return flow_graph_builder_->CheckAssignableInCheckedMode(dst_type, dst_name);
5155 } 5150 }
5156 5151
5157 Fragment StreamingFlowGraphBuilder::CheckVariableTypeInCheckedMode( 5152 Fragment StreamingFlowGraphBuilder::CheckVariableTypeInCheckedMode(
5158 intptr_t variable_kernel_position) { 5153 intptr_t variable_kernel_position) {
5159 if (I->type_checks()) { 5154 if (I->type_checks()) {
5160 LocalVariable* variable = LookupVariable(variable_kernel_position); 5155 LocalVariable* variable = LookupVariable(variable_kernel_position);
5161 return flow_graph_builder_->CheckVariableTypeInCheckedMode( 5156 return flow_graph_builder_->CheckVariableTypeInCheckedMode(
5162 variable->type(), variable->name()); 5157 variable->type(), variable->name());
5163 } 5158 }
5164 return Fragment(); 5159 return Fragment();
5165 } 5160 }
5166 5161
5167 Fragment StreamingFlowGraphBuilder::CheckVariableTypeInCheckedMode( 5162 Fragment StreamingFlowGraphBuilder::CheckVariableTypeInCheckedMode(
5168 const AbstractType& dst_type, 5163 const AbstractType& dst_type,
5169 const dart::String& name_symbol) { 5164 const String& name_symbol) {
5170 return flow_graph_builder_->CheckVariableTypeInCheckedMode(dst_type, 5165 return flow_graph_builder_->CheckVariableTypeInCheckedMode(dst_type,
5171 name_symbol); 5166 name_symbol);
5172 } 5167 }
5173 5168
5174 Fragment StreamingFlowGraphBuilder::EnterScope(intptr_t kernel_offset, 5169 Fragment StreamingFlowGraphBuilder::EnterScope(intptr_t kernel_offset,
5175 bool* new_context) { 5170 bool* new_context) {
5176 return flow_graph_builder_->EnterScope(kernel_offset, new_context); 5171 return flow_graph_builder_->EnterScope(kernel_offset, new_context);
5177 } 5172 }
5178 5173
5179 Fragment StreamingFlowGraphBuilder::ExitScope(intptr_t kernel_offset) { 5174 Fragment StreamingFlowGraphBuilder::ExitScope(intptr_t kernel_offset) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
5224 if (!skip_push_arguments) instructions += PushArgument(); 5219 if (!skip_push_arguments) instructions += PushArgument();
5225 if (do_drop) instructions += Drop(); 5220 if (do_drop) instructions += Drop();
5226 } 5221 }
5227 5222
5228 // List of named. 5223 // List of named.
5229 list_length = ReadListLength(); // read list length. 5224 list_length = ReadListLength(); // read list length.
5230 if (argument_names != NULL && list_length > 0) { 5225 if (argument_names != NULL && list_length > 0) {
5231 *argument_names ^= Array::New(list_length, Heap::kOld); 5226 *argument_names ^= Array::New(list_length, Heap::kOld);
5232 } 5227 }
5233 for (intptr_t i = 0; i < list_length; ++i) { 5228 for (intptr_t i = 0; i < list_length; ++i) {
5234 dart::String& name = 5229 String& name = H.DartSymbol(ReadStringReference()); // read ith name index.
5235 H.DartSymbol(ReadStringReference()); // read ith name index.
5236 instructions += BuildExpression(); // read ith expression. 5230 instructions += BuildExpression(); // read ith expression.
5237 if (!skip_push_arguments) instructions += PushArgument(); 5231 if (!skip_push_arguments) instructions += PushArgument();
5238 if (do_drop) instructions += Drop(); 5232 if (do_drop) instructions += Drop();
5239 if (argument_names != NULL) { 5233 if (argument_names != NULL) {
5240 argument_names->SetAt(i, name); 5234 argument_names->SetAt(i, name);
5241 } 5235 }
5242 } 5236 }
5243 5237
5244 return instructions; 5238 return instructions;
5245 } 5239 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
5307 return instructions; 5301 return instructions;
5308 } 5302 }
5309 5303
5310 Fragment StreamingFlowGraphBuilder::BuildPropertyGet(TokenPosition* p) { 5304 Fragment StreamingFlowGraphBuilder::BuildPropertyGet(TokenPosition* p) {
5311 TokenPosition position = ReadPosition(); // read position. 5305 TokenPosition position = ReadPosition(); // read position.
5312 if (p != NULL) *p = position; 5306 if (p != NULL) *p = position;
5313 5307
5314 Fragment instructions = BuildExpression(); // read receiver. 5308 Fragment instructions = BuildExpression(); // read receiver.
5315 instructions += PushArgument(); 5309 instructions += PushArgument();
5316 5310
5317 const dart::String& getter_name = ReadNameAsGetterName(); // read name. 5311 const String& getter_name = ReadNameAsGetterName(); // read name.
5318 SkipCanonicalNameReference(); // Read unused "interface_target_reference". 5312 SkipCanonicalNameReference(); // Read unused "interface_target_reference".
5319 5313
5320 return instructions + InstanceCall(position, getter_name, Token::kGET, 1); 5314 return instructions + InstanceCall(position, getter_name, Token::kGET, 1);
5321 } 5315 }
5322 5316
5323 Fragment StreamingFlowGraphBuilder::BuildPropertySet(TokenPosition* p) { 5317 Fragment StreamingFlowGraphBuilder::BuildPropertySet(TokenPosition* p) {
5324 Fragment instructions(NullConstant()); 5318 Fragment instructions(NullConstant());
5325 LocalVariable* variable = MakeTemporary(); 5319 LocalVariable* variable = MakeTemporary();
5326 5320
5327 TokenPosition position = ReadPosition(); // read position. 5321 TokenPosition position = ReadPosition(); // read position.
5328 if (p != NULL) *p = position; 5322 if (p != NULL) *p = position;
5329 5323
5330 instructions += BuildExpression(); // read receiver. 5324 instructions += BuildExpression(); // read receiver.
5331 instructions += PushArgument(); 5325 instructions += PushArgument();
5332 5326
5333 const dart::String& setter_name = ReadNameAsSetterName(); // read name. 5327 const String& setter_name = ReadNameAsSetterName(); // read name.
5334 5328
5335 instructions += BuildExpression(); // read value. 5329 instructions += BuildExpression(); // read value.
5336 instructions += StoreLocal(TokenPosition::kNoSource, variable); 5330 instructions += StoreLocal(TokenPosition::kNoSource, variable);
5337 instructions += PushArgument(); 5331 instructions += PushArgument();
5338 5332
5339 SkipCanonicalNameReference(); // read unused "interface_target_reference". 5333 SkipCanonicalNameReference(); // read unused "interface_target_reference".
5340 5334
5341 instructions += InstanceCall(position, setter_name, Token::kSET, 2); 5335 instructions += InstanceCall(position, setter_name, Token::kSET, 2);
5342 return instructions + Drop(); 5336 return instructions + Drop();
5343 } 5337 }
(...skipping 14 matching lines...) Expand all
5358 // Undo stack change for the BuildExpression. 5352 // Undo stack change for the BuildExpression.
5359 Pop(); 5353 Pop();
5360 5354
5361 target = LookupMethodByMember(kernel_name, H.DartMethodName(kernel_name)); 5355 target = LookupMethodByMember(kernel_name, H.DartMethodName(kernel_name));
5362 target = target.ImplicitClosureFunction(); 5356 target = target.ImplicitClosureFunction();
5363 ASSERT(!target.IsNull()); 5357 ASSERT(!target.IsNull());
5364 return BuildImplicitClosureCreation(target); 5358 return BuildImplicitClosureCreation(target);
5365 } 5359 }
5366 } else { 5360 } else {
5367 ASSERT(H.IsField(kernel_name)); 5361 ASSERT(H.IsField(kernel_name));
5368 const dart::String& getter_name = H.DartGetterName(kernel_name); 5362 const String& getter_name = H.DartGetterName(kernel_name);
5369 target = LookupMethodByMember(kernel_name, getter_name); 5363 target = LookupMethodByMember(kernel_name, getter_name);
5370 ASSERT(target.IsGetterFunction() || target.IsImplicitGetterFunction()); 5364 ASSERT(target.IsGetterFunction() || target.IsImplicitGetterFunction());
5371 } 5365 }
5372 5366
5373 instructions += PushArgument(); 5367 instructions += PushArgument();
5374 return instructions + StaticCall(position, target, 1); 5368 return instructions + StaticCall(position, target, 1);
5375 } 5369 }
5376 5370
5377 Fragment StreamingFlowGraphBuilder::BuildDirectPropertySet(TokenPosition* p) { 5371 Fragment StreamingFlowGraphBuilder::BuildDirectPropertySet(TokenPosition* p) {
5378 TokenPosition position = ReadPosition(); // read position. 5372 TokenPosition position = ReadPosition(); // read position.
5379 if (p != NULL) *p = position; 5373 if (p != NULL) *p = position;
5380 5374
5381 Fragment instructions(NullConstant()); 5375 Fragment instructions(NullConstant());
5382 LocalVariable* value = MakeTemporary(); 5376 LocalVariable* value = MakeTemporary();
5383 5377
5384 instructions += BuildExpression(); // read receiver. 5378 instructions += BuildExpression(); // read receiver.
5385 instructions += PushArgument(); 5379 instructions += PushArgument();
5386 5380
5387 NameIndex target_reference = 5381 NameIndex target_reference =
5388 ReadCanonicalNameReference(); // read target_reference. 5382 ReadCanonicalNameReference(); // read target_reference.
5389 const dart::String& method_name = H.DartSetterName(target_reference); 5383 const String& method_name = H.DartSetterName(target_reference);
5390 const Function& target = Function::ZoneHandle( 5384 const Function& target = Function::ZoneHandle(
5391 Z, LookupMethodByMember(target_reference, method_name)); 5385 Z, LookupMethodByMember(target_reference, method_name));
5392 ASSERT(target.IsSetterFunction() || target.IsImplicitSetterFunction()); 5386 ASSERT(target.IsSetterFunction() || target.IsImplicitSetterFunction());
5393 5387
5394 instructions += BuildExpression(); // read value. 5388 instructions += BuildExpression(); // read value.
5395 instructions += StoreLocal(TokenPosition::kNoSource, value); 5389 instructions += StoreLocal(TokenPosition::kNoSource, value);
5396 instructions += PushArgument(); 5390 instructions += PushArgument();
5397 5391
5398 instructions += StaticCall(position, target, 2); 5392 instructions += StaticCall(position, target, 2);
5399 5393
5400 return instructions + Drop(); 5394 return instructions + Drop();
5401 } 5395 }
5402 5396
5403 Fragment StreamingFlowGraphBuilder::BuildStaticGet(TokenPosition* p) { 5397 Fragment StreamingFlowGraphBuilder::BuildStaticGet(TokenPosition* p) {
5404 intptr_t offset = ReaderOffset() - 1; // Include the tag. 5398 intptr_t offset = ReaderOffset() - 1; // Include the tag.
5405 5399
5406 TokenPosition position = ReadPosition(); // read position. 5400 TokenPosition position = ReadPosition(); // read position.
5407 if (p != NULL) *p = position; 5401 if (p != NULL) *p = position;
5408 5402
5409 NameIndex target = ReadCanonicalNameReference(); // read target_reference. 5403 NameIndex target = ReadCanonicalNameReference(); // read target_reference.
5410 5404
5411 if (H.IsField(target)) { 5405 if (H.IsField(target)) {
5412 const dart::Field& field = 5406 const Field& field =
5413 dart::Field::ZoneHandle(Z, H.LookupFieldByKernelField(target)); 5407 Field::ZoneHandle(Z, H.LookupFieldByKernelField(target));
5414 if (field.is_const()) { 5408 if (field.is_const()) {
5415 return Constant(constant_evaluator_.EvaluateExpression(offset)); 5409 return Constant(constant_evaluator_.EvaluateExpression(offset));
5416 } else { 5410 } else {
5417 const dart::Class& owner = dart::Class::Handle(Z, field.Owner()); 5411 const Class& owner = Class::Handle(Z, field.Owner());
5418 const dart::String& getter_name = H.DartGetterName(target); 5412 const String& getter_name = H.DartGetterName(target);
5419 const Function& getter = 5413 const Function& getter =
5420 Function::ZoneHandle(Z, owner.LookupStaticFunction(getter_name)); 5414 Function::ZoneHandle(Z, owner.LookupStaticFunction(getter_name));
5421 if (getter.IsNull() || !field.has_initializer()) { 5415 if (getter.IsNull() || !field.has_initializer()) {
5422 Fragment instructions = Constant(field); 5416 Fragment instructions = Constant(field);
5423 return instructions + LoadStaticField(); 5417 return instructions + LoadStaticField();
5424 } else { 5418 } else {
5425 return StaticCall(position, getter, 0); 5419 return StaticCall(position, getter, 0);
5426 } 5420 }
5427 } 5421 }
5428 } else { 5422 } else {
(...skipping 12 matching lines...) Expand all
5441 return Fragment(); 5435 return Fragment();
5442 } 5436 }
5443 5437
5444 Fragment StreamingFlowGraphBuilder::BuildStaticSet(TokenPosition* p) { 5438 Fragment StreamingFlowGraphBuilder::BuildStaticSet(TokenPosition* p) {
5445 TokenPosition position = ReadPosition(); // read position. 5439 TokenPosition position = ReadPosition(); // read position.
5446 if (p != NULL) *p = position; 5440 if (p != NULL) *p = position;
5447 5441
5448 NameIndex target = ReadCanonicalNameReference(); // read target_reference. 5442 NameIndex target = ReadCanonicalNameReference(); // read target_reference.
5449 5443
5450 if (H.IsField(target)) { 5444 if (H.IsField(target)) {
5451 const dart::Field& field = 5445 const Field& field =
5452 dart::Field::ZoneHandle(Z, H.LookupFieldByKernelField(target)); 5446 Field::ZoneHandle(Z, H.LookupFieldByKernelField(target));
5453 const AbstractType& dst_type = AbstractType::ZoneHandle(Z, field.type()); 5447 const AbstractType& dst_type = AbstractType::ZoneHandle(Z, field.type());
5454 Fragment instructions = BuildExpression(); // read expression. 5448 Fragment instructions = BuildExpression(); // read expression.
5455 if (NeedsDebugStepCheck(stack(), position)) { 5449 if (NeedsDebugStepCheck(stack(), position)) {
5456 instructions = DebugStepCheck(position) + instructions; 5450 instructions = DebugStepCheck(position) + instructions;
5457 } 5451 }
5458 instructions += CheckAssignableInCheckedMode( 5452 instructions += CheckAssignableInCheckedMode(
5459 dst_type, dart::String::ZoneHandle(Z, field.name())); 5453 dst_type, String::ZoneHandle(Z, field.name()));
5460 LocalVariable* variable = MakeTemporary(); 5454 LocalVariable* variable = MakeTemporary();
5461 instructions += LoadLocal(variable); 5455 instructions += LoadLocal(variable);
5462 return instructions + StoreStaticField(position, field); 5456 return instructions + StoreStaticField(position, field);
5463 } else { 5457 } else {
5464 ASSERT(H.IsProcedure(target)); 5458 ASSERT(H.IsProcedure(target));
5465 5459
5466 // Evaluate the expression on the right hand side. 5460 // Evaluate the expression on the right hand side.
5467 Fragment instructions = BuildExpression(); // read expression. 5461 Fragment instructions = BuildExpression(); // read expression.
5468 LocalVariable* variable = MakeTemporary(); 5462 LocalVariable* variable = MakeTemporary();
5469 5463
(...skipping 20 matching lines...) Expand all
5490 intptr_t offset = ReaderOffset() - 1; // Include the tag. 5484 intptr_t offset = ReaderOffset() - 1; // Include the tag.
5491 TokenPosition position = ReadPosition(); // read position. 5485 TokenPosition position = ReadPosition(); // read position.
5492 if (p != NULL) *p = position; 5486 if (p != NULL) *p = position;
5493 5487
5494 Tag receiver_tag = PeekTag(); // peek tag for receiver. 5488 Tag receiver_tag = PeekTag(); // peek tag for receiver.
5495 if (IsNumberLiteral(receiver_tag)) { 5489 if (IsNumberLiteral(receiver_tag)) {
5496 intptr_t before_branch_offset = ReaderOffset(); 5490 intptr_t before_branch_offset = ReaderOffset();
5497 5491
5498 SkipExpression(); // read receiver (it's just a number literal). 5492 SkipExpression(); // read receiver (it's just a number literal).
5499 5493
5500 const dart::String& name = ReadNameAsMethodName(); // read name. 5494 const String& name = ReadNameAsMethodName(); // read name.
5501 const Token::Kind token_kind = MethodKind(name); 5495 const Token::Kind token_kind = MethodKind(name);
5502 intptr_t argument_count = PeekArgumentsCount() + 1; 5496 intptr_t argument_count = PeekArgumentsCount() + 1;
5503 5497
5504 if ((argument_count == 1) && (token_kind == Token::kNEGATE)) { 5498 if ((argument_count == 1) && (token_kind == Token::kNEGATE)) {
5505 const Object& result = constant_evaluator_.EvaluateExpressionSafe(offset); 5499 const Object& result = constant_evaluator_.EvaluateExpressionSafe(offset);
5506 if (!result.IsError()) { 5500 if (!result.IsError()) {
5507 SkipArguments(); // read arguments, 5501 SkipArguments(); // read arguments,
5508 // read unused "interface_target_reference". 5502 // read unused "interface_target_reference".
5509 SkipCanonicalNameReference(); 5503 SkipCanonicalNameReference();
5510 return Constant(result); 5504 return Constant(result);
5511 } 5505 }
5512 } else if ((argument_count == 2) && 5506 } else if ((argument_count == 2) &&
5513 Token::IsBinaryArithmeticOperator(token_kind) && 5507 Token::IsBinaryArithmeticOperator(token_kind) &&
5514 IsNumberLiteral(PeekArgumentsFirstPositionalTag())) { 5508 IsNumberLiteral(PeekArgumentsFirstPositionalTag())) {
5515 const Object& result = constant_evaluator_.EvaluateExpressionSafe(offset); 5509 const Object& result = constant_evaluator_.EvaluateExpressionSafe(offset);
5516 if (!result.IsError()) { 5510 if (!result.IsError()) {
5517 SkipArguments(); 5511 SkipArguments();
5518 // read unused "interface_target_reference". 5512 // read unused "interface_target_reference".
5519 SkipCanonicalNameReference(); 5513 SkipCanonicalNameReference();
5520 return Constant(result); 5514 return Constant(result);
5521 } 5515 }
5522 } 5516 }
5523 5517
5524 SetOffset(before_branch_offset); 5518 SetOffset(before_branch_offset);
5525 } 5519 }
5526 5520
5527 Fragment instructions = BuildExpression(); // read receiver. 5521 Fragment instructions = BuildExpression(); // read receiver.
5528 5522
5529 const dart::String& name = ReadNameAsMethodName(); // read name. 5523 const String& name = ReadNameAsMethodName(); // read name.
5530 const Token::Kind token_kind = MethodKind(name); 5524 const Token::Kind token_kind = MethodKind(name);
5531 5525
5532 // Detect comparison with null. 5526 // Detect comparison with null.
5533 if ((token_kind == Token::kEQ || token_kind == Token::kNE) && 5527 if ((token_kind == Token::kEQ || token_kind == Token::kNE) &&
5534 PeekArgumentsCount() == 1 && 5528 PeekArgumentsCount() == 1 &&
5535 (receiver_tag == kNullLiteral || 5529 (receiver_tag == kNullLiteral ||
5536 PeekArgumentsFirstPositionalTag() == kNullLiteral)) { 5530 PeekArgumentsFirstPositionalTag() == kNullLiteral)) {
5537 // "==" or "!=" with null on either side. 5531 // "==" or "!=" with null on either side.
5538 instructions += BuildArguments(NULL, NULL, true); // read arguments. 5532 instructions += BuildArguments(NULL, NULL, true); // read arguments.
5539 SkipCanonicalNameReference(); // read unused "interface_target_reference". 5533 SkipCanonicalNameReference(); // read unused "interface_target_reference".
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
5581 Fragment StreamingFlowGraphBuilder::BuildDirectMethodInvocation( 5575 Fragment StreamingFlowGraphBuilder::BuildDirectMethodInvocation(
5582 TokenPosition* position) { 5576 TokenPosition* position) {
5583 if (position != NULL) *position = TokenPosition::kNoSource; 5577 if (position != NULL) *position = TokenPosition::kNoSource;
5584 5578
5585 // TODO(28109) Support generic methods in the VM or reify them away. 5579 // TODO(28109) Support generic methods in the VM or reify them away.
5586 Tag receiver_tag = PeekTag(); // peek tag for receiver. 5580 Tag receiver_tag = PeekTag(); // peek tag for receiver.
5587 Fragment instructions = BuildExpression(); // read receiver. 5581 Fragment instructions = BuildExpression(); // read receiver.
5588 5582
5589 NameIndex kernel_name = 5583 NameIndex kernel_name =
5590 ReadCanonicalNameReference(); // read target_reference. 5584 ReadCanonicalNameReference(); // read target_reference.
5591 const dart::String& method_name = H.DartProcedureName(kernel_name); 5585 const String& method_name = H.DartProcedureName(kernel_name);
5592 const Token::Kind token_kind = MethodKind(method_name); 5586 const Token::Kind token_kind = MethodKind(method_name);
5593 5587
5594 // Detect comparison with null. 5588 // Detect comparison with null.
5595 if ((token_kind == Token::kEQ || token_kind == Token::kNE) && 5589 if ((token_kind == Token::kEQ || token_kind == Token::kNE) &&
5596 PeekArgumentsCount() == 1 && 5590 PeekArgumentsCount() == 1 &&
5597 (receiver_tag == kNullLiteral || 5591 (receiver_tag == kNullLiteral ||
5598 PeekArgumentsFirstPositionalTag() == kNullLiteral)) { 5592 PeekArgumentsFirstPositionalTag() == kNullLiteral)) {
5599 // "==" or "!=" with null on either side. 5593 // "==" or "!=" with null on either side.
5600 instructions += BuildArguments(NULL, NULL, true); // read arguments. 5594 instructions += BuildArguments(NULL, NULL, true); // read arguments.
5601 Token::Kind strict_cmp_kind = 5595 Token::Kind strict_cmp_kind =
(...skipping 19 matching lines...) Expand all
5621 Fragment StreamingFlowGraphBuilder::BuildStaticInvocation(bool is_const, 5615 Fragment StreamingFlowGraphBuilder::BuildStaticInvocation(bool is_const,
5622 TokenPosition* p) { 5616 TokenPosition* p) {
5623 TokenPosition position = ReadPosition(); // read position. 5617 TokenPosition position = ReadPosition(); // read position.
5624 if (p != NULL) *p = position; 5618 if (p != NULL) *p = position;
5625 5619
5626 NameIndex procedue_reference = 5620 NameIndex procedue_reference =
5627 ReadCanonicalNameReference(); // read procedure reference. 5621 ReadCanonicalNameReference(); // read procedure reference.
5628 intptr_t argument_count = PeekArgumentsCount(); 5622 intptr_t argument_count = PeekArgumentsCount();
5629 const Function& target = Function::ZoneHandle( 5623 const Function& target = Function::ZoneHandle(
5630 Z, H.LookupStaticMethodByKernelProcedure(procedue_reference)); 5624 Z, H.LookupStaticMethodByKernelProcedure(procedue_reference));
5631 const dart::Class& klass = dart::Class::ZoneHandle(Z, target.Owner()); 5625 const Class& klass = Class::ZoneHandle(Z, target.Owner());
5632 if (target.IsGenerativeConstructor() || target.IsFactory()) { 5626 if (target.IsGenerativeConstructor() || target.IsFactory()) {
5633 // The VM requires a TypeArguments object as first parameter for 5627 // The VM requires a TypeArguments object as first parameter for
5634 // every factory constructor. 5628 // every factory constructor.
5635 ++argument_count; 5629 ++argument_count;
5636 } 5630 }
5637 5631
5638 Fragment instructions; 5632 Fragment instructions;
5639 LocalVariable* instance_variable = NULL; 5633 LocalVariable* instance_variable = NULL;
5640 5634
5641 // If we cross the Kernel -> VM core library boundary, a [StaticInvocation] 5635 // If we cross the Kernel -> VM core library boundary, a [StaticInvocation]
(...skipping 26 matching lines...) Expand all
5668 // 5662 //
5669 // TODO(27590): Get rid of this after we're using core libraries compiled 5663 // TODO(27590): Get rid of this after we're using core libraries compiled
5670 // into Kernel. 5664 // into Kernel.
5671 const TypeArguments& type_arguments = PeekArgumentsInstantiatedType(klass); 5665 const TypeArguments& type_arguments = PeekArgumentsInstantiatedType(klass);
5672 instructions += TranslateInstantiatedTypeArguments(type_arguments); 5666 instructions += TranslateInstantiatedTypeArguments(type_arguments);
5673 instructions += PushArgument(); 5667 instructions += PushArgument();
5674 } else { 5668 } else {
5675 // TODO(28109) Support generic methods in the VM or reify them away. 5669 // TODO(28109) Support generic methods in the VM or reify them away.
5676 } 5670 }
5677 5671
5678 bool special_case_identical = 5672 bool special_case_identical = klass.IsTopLevel() &&
5679 klass.IsTopLevel() && (klass.library() == dart::Library::CoreLibrary()) && 5673 (klass.library() == Library::CoreLibrary()) &&
5680 (target.name() == Symbols::Identical().raw()); 5674 (target.name() == Symbols::Identical().raw());
5681 5675
5682 Array& argument_names = Array::ZoneHandle(Z); 5676 Array& argument_names = Array::ZoneHandle(Z);
5683 instructions += BuildArguments(&argument_names, NULL, 5677 instructions += BuildArguments(&argument_names, NULL,
5684 special_case_identical); // read arguments. 5678 special_case_identical); // read arguments.
5685 const int kTypeArgsLen = 0; 5679 const int kTypeArgsLen = 0;
5686 ASSERT(target.AreValidArguments(kTypeArgsLen, argument_count, argument_names, 5680 ASSERT(target.AreValidArguments(kTypeArgsLen, argument_count, argument_names,
5687 NULL)); 5681 NULL));
5688 5682
5689 // Special case identical(x, y) call. 5683 // Special case identical(x, y) call.
5690 // TODO(27590) consider moving this into the inliner and force inline it 5684 // TODO(27590) consider moving this into the inliner and force inline it
(...skipping 25 matching lines...) Expand all
5716 SkipExpression(); // read past this ConstructorInvocation. 5710 SkipExpression(); // read past this ConstructorInvocation.
5717 return Constant(constant_evaluator_.EvaluateConstructorInvocation(offset)); 5711 return Constant(constant_evaluator_.EvaluateConstructorInvocation(offset));
5718 } 5712 }
5719 5713
5720 TokenPosition position = ReadPosition(); // read position. 5714 TokenPosition position = ReadPosition(); // read position.
5721 if (p != NULL) *p = position; 5715 if (p != NULL) *p = position;
5722 5716
5723 NameIndex kernel_name = 5717 NameIndex kernel_name =
5724 ReadCanonicalNameReference(); // read target_reference. 5718 ReadCanonicalNameReference(); // read target_reference.
5725 5719
5726 dart::Class& klass = dart::Class::ZoneHandle( 5720 Class& klass = Class::ZoneHandle(
5727 Z, H.LookupClassByKernelClass(H.EnclosingName(kernel_name))); 5721 Z, H.LookupClassByKernelClass(H.EnclosingName(kernel_name)));
5728 5722
5729 Fragment instructions; 5723 Fragment instructions;
5730 5724
5731 // Check for malbounded-ness of type. 5725 // Check for malbounded-ness of type.
5732 if (I->type_checks()) { 5726 if (I->type_checks()) {
5733 intptr_t offset = ReaderOffset(); 5727 intptr_t offset = ReaderOffset();
5734 5728
5735 const TypeArguments& type_arguments = BuildTypeArguments(); 5729 const TypeArguments& type_arguments = BuildTypeArguments();
5736 5730
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
5941 // Let condition be always true. 5935 // Let condition be always true.
5942 instructions += Constant(Bool::True()); 5936 instructions += Constant(Bool::True());
5943 } else { 5937 } else {
5944 instructions += PushArgument(); 5938 instructions += PushArgument();
5945 5939
5946 // See if simple instanceOf is applicable. 5940 // See if simple instanceOf is applicable.
5947 if (dart::FlowGraphBuilder::SimpleInstanceOfType(type)) { 5941 if (dart::FlowGraphBuilder::SimpleInstanceOfType(type)) {
5948 instructions += Constant(type); 5942 instructions += Constant(type);
5949 instructions += PushArgument(); // Type. 5943 instructions += PushArgument(); // Type.
5950 instructions += InstanceCall( 5944 instructions += InstanceCall(
5951 position, 5945 position, Library::PrivateCoreLibName(Symbols::_simpleInstanceOf()),
5952 dart::Library::PrivateCoreLibName(Symbols::_simpleInstanceOf()),
5953 Token::kIS, 2, 2); // 2 checked arguments. 5946 Token::kIS, 2, 2); // 2 checked arguments.
5954 return instructions; 5947 return instructions;
5955 } 5948 }
5956 5949
5957 if (!type.IsInstantiated(kCurrentClass)) { 5950 if (!type.IsInstantiated(kCurrentClass)) {
5958 instructions += LoadInstantiatorTypeArguments(); 5951 instructions += LoadInstantiatorTypeArguments();
5959 } else { 5952 } else {
5960 instructions += NullConstant(); 5953 instructions += NullConstant();
5961 } 5954 }
5962 instructions += PushArgument(); // Instantiator type arguments. 5955 instructions += PushArgument(); // Instantiator type arguments.
5963 5956
5964 if (!type.IsInstantiated(kFunctions)) { 5957 if (!type.IsInstantiated(kFunctions)) {
5965 instructions += LoadFunctionTypeArguments(); 5958 instructions += LoadFunctionTypeArguments();
5966 } else { 5959 } else {
5967 instructions += NullConstant(); 5960 instructions += NullConstant();
5968 } 5961 }
5969 instructions += PushArgument(); // Function type arguments. 5962 instructions += PushArgument(); // Function type arguments.
5970 5963
5971 instructions += Constant(type); 5964 instructions += Constant(type);
5972 instructions += PushArgument(); // Type. 5965 instructions += PushArgument(); // Type.
5973 5966
5974 instructions += InstanceCall( 5967 instructions += InstanceCall(
5975 position, dart::Library::PrivateCoreLibName(Symbols::_instanceOf()), 5968 position, Library::PrivateCoreLibName(Symbols::_instanceOf()),
5976 Token::kIS, 4); 5969 Token::kIS, 4);
5977 } 5970 }
5978 return instructions; 5971 return instructions;
5979 } 5972 }
5980 5973
5981 Fragment StreamingFlowGraphBuilder::BuildAsExpression(TokenPosition* p) { 5974 Fragment StreamingFlowGraphBuilder::BuildAsExpression(TokenPosition* p) {
5982 TokenPosition position = ReadPosition(); // read position. 5975 TokenPosition position = ReadPosition(); // read position.
5983 if (p != NULL) *p = position; 5976 if (p != NULL) *p = position;
5984 5977
5985 Fragment instructions = BuildExpression(); // read operand. 5978 Fragment instructions = BuildExpression(); // read operand.
(...skipping 28 matching lines...) Expand all
6014 instructions += LoadFunctionTypeArguments(); 6007 instructions += LoadFunctionTypeArguments();
6015 } else { 6008 } else {
6016 instructions += NullConstant(); 6009 instructions += NullConstant();
6017 } 6010 }
6018 instructions += PushArgument(); // Function type arguments. 6011 instructions += PushArgument(); // Function type arguments.
6019 6012
6020 instructions += Constant(type); 6013 instructions += Constant(type);
6021 instructions += PushArgument(); // Type. 6014 instructions += PushArgument(); // Type.
6022 6015
6023 instructions += InstanceCall( 6016 instructions += InstanceCall(
6024 position, dart::Library::PrivateCoreLibName(Symbols::_as()), Token::kAS, 6017 position, Library::PrivateCoreLibName(Symbols::_as()), Token::kAS, 4);
6025 4);
6026 } 6018 }
6027 return instructions; 6019 return instructions;
6028 } 6020 }
6029 6021
6030 Fragment StreamingFlowGraphBuilder::BuildSymbolLiteral( 6022 Fragment StreamingFlowGraphBuilder::BuildSymbolLiteral(
6031 TokenPosition* position) { 6023 TokenPosition* position) {
6032 if (position != NULL) *position = TokenPosition::kNoSource; 6024 if (position != NULL) *position = TokenPosition::kNoSource;
6033 6025
6034 intptr_t offset = ReaderOffset() - 1; // EvaluateExpression needs the tag. 6026 intptr_t offset = ReaderOffset() - 1; // EvaluateExpression needs the tag.
6035 SkipStringReference(); // read index into string table. 6027 SkipStringReference(); // read index into string table.
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
6144 instructions += IntConstant(i); 6136 instructions += IntConstant(i);
6145 instructions += BuildExpression(); // read ith expression. 6137 instructions += BuildExpression(); // read ith expression.
6146 instructions += CheckAssignableInCheckedMode( 6138 instructions += CheckAssignableInCheckedMode(
6147 list_type, Symbols::ListLiteralElement()); 6139 list_type, Symbols::ListLiteralElement());
6148 instructions += StoreIndexed(kArrayCid); 6140 instructions += StoreIndexed(kArrayCid);
6149 instructions += Drop(); 6141 instructions += Drop();
6150 } 6142 }
6151 } 6143 }
6152 instructions += PushArgument(); // The array. 6144 instructions += PushArgument(); // The array.
6153 6145
6154 const dart::Class& factory_class = 6146 const Class& factory_class =
6155 dart::Class::Handle(Z, dart::Library::LookupCoreClass(Symbols::List())); 6147 Class::Handle(Z, Library::LookupCoreClass(Symbols::List()));
6156 const Function& factory_method = Function::ZoneHandle( 6148 const Function& factory_method = Function::ZoneHandle(
6157 Z, factory_class.LookupFactory( 6149 Z, factory_class.LookupFactory(
6158 dart::Library::PrivateCoreLibName(Symbols::ListLiteralFactory()))); 6150 Library::PrivateCoreLibName(Symbols::ListLiteralFactory())));
6159 6151
6160 return instructions + StaticCall(position, factory_method, 2); 6152 return instructions + StaticCall(position, factory_method, 2);
6161 } 6153 }
6162 6154
6163 Fragment StreamingFlowGraphBuilder::BuildMapLiteral(bool is_const, 6155 Fragment StreamingFlowGraphBuilder::BuildMapLiteral(bool is_const,
6164 TokenPosition* p) { 6156 TokenPosition* p) {
6165 if (is_const) { 6157 if (is_const) {
6166 intptr_t offset = ReaderOffset() - 1; // Include the tag. 6158 intptr_t offset = ReaderOffset() - 1; // Include the tag.
6167 (p != NULL) ? * p = ReadPosition() : ReadPosition(); 6159 (p != NULL) ? * p = ReadPosition() : ReadPosition();
6168 6160
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
6204 6196
6205 instructions += LoadLocal(array); 6197 instructions += LoadLocal(array);
6206 instructions += IntConstant(2 * i + 1); 6198 instructions += IntConstant(2 * i + 1);
6207 instructions += BuildExpression(); // read ith value. 6199 instructions += BuildExpression(); // read ith value.
6208 instructions += StoreIndexed(kArrayCid); 6200 instructions += StoreIndexed(kArrayCid);
6209 instructions += Drop(); 6201 instructions += Drop();
6210 } 6202 }
6211 } 6203 }
6212 instructions += PushArgument(); // The array. 6204 instructions += PushArgument(); // The array.
6213 6205
6214 const dart::Class& map_class = 6206 const Class& map_class =
6215 dart::Class::Handle(Z, dart::Library::LookupCoreClass(Symbols::Map())); 6207 Class::Handle(Z, Library::LookupCoreClass(Symbols::Map()));
6216 const Function& factory_method = Function::ZoneHandle( 6208 const Function& factory_method = Function::ZoneHandle(
6217 Z, map_class.LookupFactory( 6209 Z, map_class.LookupFactory(
6218 dart::Library::PrivateCoreLibName(Symbols::MapLiteralFactory()))); 6210 Library::PrivateCoreLibName(Symbols::MapLiteralFactory())));
6219 6211
6220 return instructions + StaticCall(position, factory_method, 2); 6212 return instructions + StaticCall(position, factory_method, 2);
6221 } 6213 }
6222 6214
6223 Fragment StreamingFlowGraphBuilder::BuildFunctionExpression() { 6215 Fragment StreamingFlowGraphBuilder::BuildFunctionExpression() {
6224 ReadPosition(); // read position. 6216 ReadPosition(); // read position.
6225 return BuildFunctionNode(TokenPosition::kNoSource, StringIndex()); 6217 return BuildFunctionNode(TokenPosition::kNoSource, StringIndex());
6226 } 6218 }
6227 6219
6228 Fragment StreamingFlowGraphBuilder::BuildLet(TokenPosition* position) { 6220 Fragment StreamingFlowGraphBuilder::BuildLet(TokenPosition* position) {
6229 if (position != NULL) *position = TokenPosition::kNoSource; 6221 if (position != NULL) *position = TokenPosition::kNoSource;
6230 6222
6231 Fragment instructions = BuildVariableDeclaration(); // read variable. 6223 Fragment instructions = BuildVariableDeclaration(); // read variable.
6232 instructions += BuildExpression(); // read body. 6224 instructions += BuildExpression(); // read body.
6233 return instructions; 6225 return instructions;
6234 } 6226 }
6235 6227
6236 Fragment StreamingFlowGraphBuilder::BuildBigIntLiteral( 6228 Fragment StreamingFlowGraphBuilder::BuildBigIntLiteral(
6237 TokenPosition* position) { 6229 TokenPosition* position) {
6238 if (position != NULL) *position = TokenPosition::kNoSource; 6230 if (position != NULL) *position = TokenPosition::kNoSource;
6239 6231
6240 const dart::String& value = 6232 const String& value =
6241 H.DartString(ReadStringReference()); // read index into string table. 6233 H.DartString(ReadStringReference()); // read index into string table.
6242 const Integer& integer = 6234 const Integer& integer =
6243 Integer::ZoneHandle(Z, Integer::New(value, Heap::kOld)); 6235 Integer::ZoneHandle(Z, Integer::New(value, Heap::kOld));
6244 if (integer.IsNull()) { 6236 if (integer.IsNull()) {
6245 H.ReportError("Integer literal %s is out of range", value.ToCString()); 6237 H.ReportError("Integer literal %s is out of range", value.ToCString());
6246 UNREACHABLE(); 6238 UNREACHABLE();
6247 } 6239 }
6248 return Constant(integer); 6240 return Constant(integer);
6249 } 6241 }
6250 6242
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
6347 TokenPosition* position) { 6339 TokenPosition* position) {
6348 if (position != NULL) *position = TokenPosition::kNoSource; 6340 if (position != NULL) *position = TokenPosition::kNoSource;
6349 6341
6350 NameIndex function_reference = 6342 NameIndex function_reference =
6351 ReadCanonicalNameReference(); // read function reference. 6343 ReadCanonicalNameReference(); // read function reference.
6352 Function& function = Function::ZoneHandle( 6344 Function& function = Function::ZoneHandle(
6353 Z, H.LookupStaticMethodByKernelProcedure(function_reference)); 6345 Z, H.LookupStaticMethodByKernelProcedure(function_reference));
6354 function = function.ConvertedClosureFunction(); 6346 function = function.ConvertedClosureFunction();
6355 ASSERT(!function.IsNull()); 6347 ASSERT(!function.IsNull());
6356 6348
6357 const dart::Class& closure_class = 6349 const Class& closure_class =
6358 dart::Class::ZoneHandle(Z, I->object_store()->closure_class()); 6350 Class::ZoneHandle(Z, I->object_store()->closure_class());
6359 Fragment instructions = AllocateObject(closure_class, function); 6351 Fragment instructions = AllocateObject(closure_class, function);
6360 LocalVariable* closure = MakeTemporary(); 6352 LocalVariable* closure = MakeTemporary();
6361 6353
6362 instructions += BuildExpression(); // read context vector. 6354 instructions += BuildExpression(); // read context vector.
6363 LocalVariable* context = MakeTemporary(); 6355 LocalVariable* context = MakeTemporary();
6364 6356
6365 instructions += LoadLocal(closure); 6357 instructions += LoadLocal(closure);
6366 instructions += Constant(function); 6358 instructions += Constant(function);
6367 instructions += 6359 instructions +=
6368 StoreInstanceField(TokenPosition::kNoSource, Closure::function_offset()); 6360 StoreInstanceField(TokenPosition::kNoSource, Closure::function_offset());
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
6454 instructions += EvaluateAssertion(); 6446 instructions += EvaluateAssertion();
6455 instructions += CheckBooleanInCheckedMode(); 6447 instructions += CheckBooleanInCheckedMode();
6456 instructions += Constant(Bool::True()); 6448 instructions += Constant(Bool::True());
6457 instructions += BranchIfEqual(&then, &otherwise, false); 6449 instructions += BranchIfEqual(&then, &otherwise, false);
6458 6450
6459 TokenPosition condition_start_offset = 6451 TokenPosition condition_start_offset =
6460 ReadPosition(); // read condition start offset. 6452 ReadPosition(); // read condition start offset.
6461 TokenPosition condition_end_offset = 6453 TokenPosition condition_end_offset =
6462 ReadPosition(); // read condition end offset. 6454 ReadPosition(); // read condition end offset.
6463 6455
6464 const dart::Class& klass = dart::Class::ZoneHandle( 6456 const Class& klass =
6465 Z, dart::Library::LookupCoreClass(Symbols::AssertionError())); 6457 Class::ZoneHandle(Z, Library::LookupCoreClass(Symbols::AssertionError()));
6466 ASSERT(!klass.IsNull()); 6458 ASSERT(!klass.IsNull());
6467 const dart::Function& target = dart::Function::ZoneHandle( 6459 const Function& target = Function::ZoneHandle(
6468 Z, klass.LookupStaticFunctionAllowPrivate(Symbols::ThrowNew())); 6460 Z, klass.LookupStaticFunctionAllowPrivate(Symbols::ThrowNew()));
6469 ASSERT(!target.IsNull()); 6461 ASSERT(!target.IsNull());
6470 6462
6471 // Build call to _AsertionError._throwNew(start, end, message) 6463 // Build call to _AsertionError._throwNew(start, end, message)
6472 Fragment otherwise_fragment(otherwise); 6464 Fragment otherwise_fragment(otherwise);
6473 otherwise_fragment += IntConstant(condition_start_offset.Pos()); 6465 otherwise_fragment += IntConstant(condition_start_offset.Pos());
6474 otherwise_fragment += PushArgument(); // start 6466 otherwise_fragment += PushArgument(); // start
6475 otherwise_fragment += IntConstant(condition_end_offset.Pos()); 6467 otherwise_fragment += IntConstant(condition_end_offset.Pos());
6476 otherwise_fragment += PushArgument(); // end 6468 otherwise_fragment += PushArgument(); // end
6477 Tag tag = ReadTag(); // read (first part of) message. 6469 Tag tag = ReadTag(); // read (first part of) message.
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
6661 ReadPosition(); // read position. 6653 ReadPosition(); // read position.
6662 TokenPosition body_position = ReadPosition(); // read body position. 6654 TokenPosition body_position = ReadPosition(); // read body position.
6663 intptr_t variable_kernel_position = ReaderOffset() + relative_kernel_offset_; 6655 intptr_t variable_kernel_position = ReaderOffset() + relative_kernel_offset_;
6664 SkipVariableDeclaration(); // read variable. 6656 SkipVariableDeclaration(); // read variable.
6665 6657
6666 TokenPosition iterable_position = TokenPosition::kNoSource; 6658 TokenPosition iterable_position = TokenPosition::kNoSource;
6667 Fragment instructions = 6659 Fragment instructions =
6668 BuildExpression(&iterable_position); // read iterable. 6660 BuildExpression(&iterable_position); // read iterable.
6669 instructions += PushArgument(); 6661 instructions += PushArgument();
6670 6662
6671 const dart::String& iterator_getter = dart::String::ZoneHandle( 6663 const String& iterator_getter =
6672 Z, dart::Field::GetterSymbol(Symbols::Iterator())); 6664 String::ZoneHandle(Z, Field::GetterSymbol(Symbols::Iterator()));
6673 instructions += 6665 instructions +=
6674 InstanceCall(iterable_position, iterator_getter, Token::kGET, 1); 6666 InstanceCall(iterable_position, iterator_getter, Token::kGET, 1);
6675 LocalVariable* iterator = scopes()->iterator_variables[for_in_depth()]; 6667 LocalVariable* iterator = scopes()->iterator_variables[for_in_depth()];
6676 instructions += StoreLocal(TokenPosition::kNoSource, iterator); 6668 instructions += StoreLocal(TokenPosition::kNoSource, iterator);
6677 instructions += Drop(); 6669 instructions += Drop();
6678 6670
6679 for_in_depth_inc(); 6671 for_in_depth_inc();
6680 loop_depth_inc(); 6672 loop_depth_inc();
6681 Fragment condition = LoadLocal(iterator); 6673 Fragment condition = LoadLocal(iterator);
6682 condition += PushArgument(); 6674 condition += PushArgument();
6683 condition += 6675 condition +=
6684 InstanceCall(iterable_position, Symbols::MoveNext(), Token::kILLEGAL, 1); 6676 InstanceCall(iterable_position, Symbols::MoveNext(), Token::kILLEGAL, 1);
6685 TargetEntryInstr* body_entry; 6677 TargetEntryInstr* body_entry;
6686 TargetEntryInstr* loop_exit; 6678 TargetEntryInstr* loop_exit;
6687 condition += BranchIfTrue(&body_entry, &loop_exit, false); 6679 condition += BranchIfTrue(&body_entry, &loop_exit, false);
6688 6680
6689 Fragment body(body_entry); 6681 Fragment body(body_entry);
6690 body += EnterScope(offset + relative_kernel_offset_); 6682 body += EnterScope(offset + relative_kernel_offset_);
6691 body += LoadLocal(iterator); 6683 body += LoadLocal(iterator);
6692 body += PushArgument(); 6684 body += PushArgument();
6693 const dart::String& current_getter = dart::String::ZoneHandle( 6685 const String& current_getter =
6694 Z, dart::Field::GetterSymbol(Symbols::Current())); 6686 String::ZoneHandle(Z, Field::GetterSymbol(Symbols::Current()));
6695 body += InstanceCall(body_position, current_getter, Token::kGET, 1); 6687 body += InstanceCall(body_position, current_getter, Token::kGET, 1);
6696 body += StoreLocal(TokenPosition::kNoSource, 6688 body += StoreLocal(TokenPosition::kNoSource,
6697 LookupVariable(variable_kernel_position)); 6689 LookupVariable(variable_kernel_position));
6698 body += Drop(); 6690 body += Drop();
6699 body += BuildStatement(); // read body. 6691 body += BuildStatement(); // read body.
6700 body += ExitScope(offset + relative_kernel_offset_); 6692 body += ExitScope(offset + relative_kernel_offset_);
6701 6693
6702 if (body.is_open()) { 6694 if (body.is_open()) {
6703 JoinEntryInstr* join = BuildJoinEntry(); 6695 JoinEntryInstr* join = BuildJoinEntry();
6704 instructions += Goto(join); 6696 instructions += Goto(join);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
6756 6748
6757 if (body_fragment.entry == NULL) { 6749 if (body_fragment.entry == NULL) {
6758 // Make a NOP in order to ensure linking works properly. 6750 // Make a NOP in order to ensure linking works properly.
6759 body_fragment = NullConstant(); 6751 body_fragment = NullConstant();
6760 body_fragment += Drop(); 6752 body_fragment += Drop();
6761 } 6753 }
6762 6754
6763 // The Dart language specification mandates fall-throughs in [SwitchCase]es 6755 // The Dart language specification mandates fall-throughs in [SwitchCase]es
6764 // to be runtime errors. 6756 // to be runtime errors.
6765 if (!is_default && body_fragment.is_open() && (i < (case_count - 1))) { 6757 if (!is_default && body_fragment.is_open() && (i < (case_count - 1))) {
6766 const dart::Class& klass = dart::Class::ZoneHandle( 6758 const Class& klass = Class::ZoneHandle(
6767 Z, dart::Library::LookupCoreClass(Symbols::FallThroughError())); 6759 Z, Library::LookupCoreClass(Symbols::FallThroughError()));
6768 ASSERT(!klass.IsNull()); 6760 ASSERT(!klass.IsNull());
6769 const dart::Function& constructor = dart::Function::ZoneHandle( 6761 const Function& constructor = Function::ZoneHandle(
6770 Z, klass.LookupConstructorAllowPrivate( 6762 Z, klass.LookupConstructorAllowPrivate(
6771 H.DartSymbol("FallThroughError._create"))); 6763 H.DartSymbol("FallThroughError._create")));
6772 ASSERT(!constructor.IsNull()); 6764 ASSERT(!constructor.IsNull());
6773 const dart::String& url = H.DartString( 6765 const String& url = H.DartString(
6774 parsed_function()->function().ToLibNamePrefixedQualifiedCString(), 6766 parsed_function()->function().ToLibNamePrefixedQualifiedCString(),
6775 Heap::kOld); 6767 Heap::kOld);
6776 6768
6777 // Create instance of _FallThroughError 6769 // Create instance of _FallThroughError
6778 body_fragment += AllocateObject(TokenPosition::kNoSource, klass, 0); 6770 body_fragment += AllocateObject(TokenPosition::kNoSource, klass, 0);
6779 LocalVariable* instance = MakeTemporary(); 6771 LocalVariable* instance = MakeTemporary();
6780 6772
6781 // Call _FallThroughError._create constructor. 6773 // Call _FallThroughError._create constructor.
6782 body_fragment += LoadLocal(instance); 6774 body_fragment += LoadLocal(instance);
6783 body_fragment += PushArgument(); // this 6775 body_fragment += PushArgument(); // this
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
7091 if (!type_guard->IsInstantiated(kFunctions)) { 7083 if (!type_guard->IsInstantiated(kFunctions)) {
7092 catch_body += LoadFunctionTypeArguments(); 7084 catch_body += LoadFunctionTypeArguments();
7093 } else { 7085 } else {
7094 catch_body += NullConstant(); 7086 catch_body += NullConstant();
7095 } 7087 }
7096 catch_body += PushArgument(); // function type arguments 7088 catch_body += PushArgument(); // function type arguments
7097 catch_body += Constant(*type_guard); 7089 catch_body += Constant(*type_guard);
7098 catch_body += PushArgument(); // guard type 7090 catch_body += PushArgument(); // guard type
7099 catch_body += InstanceCall( 7091 catch_body += InstanceCall(
7100 TokenPosition::kNoSource, 7092 TokenPosition::kNoSource,
7101 dart::Library::PrivateCoreLibName(Symbols::_instanceOf()), 7093 Library::PrivateCoreLibName(Symbols::_instanceOf()), Token::kIS, 4);
7102 Token::kIS, 4);
7103 7094
7104 TargetEntryInstr* catch_entry; 7095 TargetEntryInstr* catch_entry;
7105 TargetEntryInstr* next_catch_entry; 7096 TargetEntryInstr* next_catch_entry;
7106 catch_body += BranchIfTrue(&catch_entry, &next_catch_entry, false); 7097 catch_body += BranchIfTrue(&catch_entry, &next_catch_entry, false);
7107 7098
7108 Fragment(catch_entry) + catch_handler_body; 7099 Fragment(catch_entry) + catch_handler_body;
7109 catch_body = Fragment(next_catch_entry); 7100 catch_body = Fragment(next_catch_entry);
7110 } 7101 }
7111 } else { 7102 } else {
7112 catch_body += catch_handler_body; 7103 catch_body += catch_handler_body;
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
7290 7281
7291 return continuation; 7282 return continuation;
7292 } 7283 }
7293 7284
7294 Fragment StreamingFlowGraphBuilder::BuildVariableDeclaration() { 7285 Fragment StreamingFlowGraphBuilder::BuildVariableDeclaration() {
7295 intptr_t kernel_position_no_tag = ReaderOffset() + relative_kernel_offset_; 7286 intptr_t kernel_position_no_tag = ReaderOffset() + relative_kernel_offset_;
7296 LocalVariable* variable = LookupVariable(kernel_position_no_tag); 7287 LocalVariable* variable = LookupVariable(kernel_position_no_tag);
7297 7288
7298 VariableDeclarationHelper helper(this); 7289 VariableDeclarationHelper helper(this);
7299 helper.ReadUntilExcluding(VariableDeclarationHelper::kType); 7290 helper.ReadUntilExcluding(VariableDeclarationHelper::kType);
7300 dart::String& name = H.DartSymbol(helper.name_index_); 7291 String& name = H.DartSymbol(helper.name_index_);
7301 AbstractType& type = T.BuildType(); // read type. 7292 AbstractType& type = T.BuildType(); // read type.
7302 Tag tag = ReadTag(); // read (first part of) initializer. 7293 Tag tag = ReadTag(); // read (first part of) initializer.
7303 7294
7304 Fragment instructions; 7295 Fragment instructions;
7305 if (tag == kNothing) { 7296 if (tag == kNothing) {
7306 instructions += NullConstant(); 7297 instructions += NullConstant();
7307 } else { 7298 } else {
7308 if (helper.IsConst()) { 7299 if (helper.IsConst()) {
7309 const Instance& constant_value = constant_evaluator_.EvaluateExpression( 7300 const Instance& constant_value = constant_evaluator_.EvaluateExpression(
7310 ReaderOffset()); // read initializer form current position. 7301 ReaderOffset()); // read initializer form current position.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
7372 Function& function = Function::ZoneHandle(Z); 7363 Function& function = Function::ZoneHandle(Z);
7373 7364
7374 // NOTE: This is not TokenPosition in the general sense! 7365 // NOTE: This is not TokenPosition in the general sense!
7375 function = I->LookupClosureFunction(parsed_function()->function(), position); 7366 function = I->LookupClosureFunction(parsed_function()->function(), position);
7376 if (function.IsNull()) { 7367 if (function.IsNull()) {
7377 for (intptr_t i = 0; i < scopes()->function_scopes.length(); ++i) { 7368 for (intptr_t i = 0; i < scopes()->function_scopes.length(); ++i) {
7378 if (scopes()->function_scopes[i].kernel_offset != offset) { 7369 if (scopes()->function_scopes[i].kernel_offset != offset) {
7379 continue; 7370 continue;
7380 } 7371 }
7381 7372
7382 const dart::String* name; 7373 const String* name;
7383 if (declaration) { 7374 if (declaration) {
7384 name = &H.DartSymbol(name_index); 7375 name = &H.DartSymbol(name_index);
7385 } else { 7376 } else {
7386 name = &Symbols::AnonymousClosure(); 7377 name = &Symbols::AnonymousClosure();
7387 } 7378 }
7388 // NOTE: This is not TokenPosition in the general sense! 7379 // NOTE: This is not TokenPosition in the general sense!
7389 function = Function::NewClosureFunction( 7380 function = Function::NewClosureFunction(
7390 *name, parsed_function()->function(), position); 7381 *name, parsed_function()->function(), position);
7391 7382
7392 function.set_is_debuggable(function_node_helper.dart_async_marker_ == 7383 function.set_is_debuggable(function_node_helper.dart_async_marker_ ==
(...skipping 19 matching lines...) Expand all
7412 if (function.IsAsyncClosure() || function.IsAsyncGenClosure()) { 7403 if (function.IsAsyncClosure() || function.IsAsyncGenClosure()) {
7413 function.set_is_inlinable(!FLAG_causal_async_stacks); 7404 function.set_is_inlinable(!FLAG_causal_async_stacks);
7414 } 7405 }
7415 7406
7416 function.set_end_token_pos(function_node_helper.end_position_); 7407 function.set_end_token_pos(function_node_helper.end_position_);
7417 LocalScope* scope = scopes()->function_scopes[i].scope; 7408 LocalScope* scope = scopes()->function_scopes[i].scope;
7418 const ContextScope& context_scope = ContextScope::Handle( 7409 const ContextScope& context_scope = ContextScope::Handle(
7419 Z, scope->PreserveOuterScope(flow_graph_builder_->context_depth_)); 7410 Z, scope->PreserveOuterScope(flow_graph_builder_->context_depth_));
7420 function.set_context_scope(context_scope); 7411 function.set_context_scope(context_scope);
7421 function.set_kernel_offset(offset); 7412 function.set_kernel_offset(offset);
7422 SetupFunctionParameters(dart::Class::Handle(Z), function, 7413 SetupFunctionParameters(Class::Handle(Z), function,
7423 false, // is_method 7414 false, // is_method
7424 true, // is_closure 7415 true, // is_closure
7425 &function_node_helper); 7416 &function_node_helper);
7426 function_node_helper.ReadUntilExcluding(FunctionNodeHelper::kEnd); 7417 function_node_helper.ReadUntilExcluding(FunctionNodeHelper::kEnd);
7427 TypedData& kernel_data = reader_->CopyDataToVMHeap( 7418 TypedData& kernel_data = reader_->CopyDataToVMHeap(
7428 Z, offset - relative_kernel_offset_, ReaderOffset()); 7419 Z, offset - relative_kernel_offset_, ReaderOffset());
7429 function.set_kernel_data(kernel_data); 7420 function.set_kernel_data(kernel_data);
7430 7421
7431 // Finalize function type. 7422 // Finalize function type.
7432 Type& signature_type = Type::Handle(Z, function.SignatureType()); 7423 Type& signature_type = Type::Handle(Z, function.SignatureType());
7433 signature_type ^= 7424 signature_type ^=
7434 ClassFinalizer::FinalizeType(*active_class()->klass, signature_type); 7425 ClassFinalizer::FinalizeType(*active_class()->klass, signature_type);
7435 function.SetSignatureType(signature_type); 7426 function.SetSignatureType(signature_type);
7436 7427
7437 I->AddClosureFunction(function); 7428 I->AddClosureFunction(function);
7438 break; 7429 break;
7439 } 7430 }
7440 } 7431 }
7441 7432
7442 function_node_helper.ReadUntilExcluding(FunctionNodeHelper::kEnd); 7433 function_node_helper.ReadUntilExcluding(FunctionNodeHelper::kEnd);
7443 7434
7444 const dart::Class& closure_class = 7435 const Class& closure_class =
7445 dart::Class::ZoneHandle(Z, I->object_store()->closure_class()); 7436 Class::ZoneHandle(Z, I->object_store()->closure_class());
7446 ASSERT(!closure_class.IsNull()); 7437 ASSERT(!closure_class.IsNull());
7447 Fragment instructions = 7438 Fragment instructions =
7448 flow_graph_builder_->AllocateObject(closure_class, function); 7439 flow_graph_builder_->AllocateObject(closure_class, function);
7449 LocalVariable* closure = MakeTemporary(); 7440 LocalVariable* closure = MakeTemporary();
7450 7441
7451 // The function signature can have uninstantiated class type parameters. 7442 // The function signature can have uninstantiated class type parameters.
7452 // 7443 //
7453 // TODO(regis): Also handle the case of a function signature that has 7444 // TODO(regis): Also handle the case of a function signature that has
7454 // uninstantiated function type parameters. 7445 // uninstantiated function type parameters.
7455 if (!function.HasInstantiatedSignature(kCurrentClass)) { 7446 if (!function.HasInstantiatedSignature(kCurrentClass)) {
(...skipping 12 matching lines...) Expand all
7468 7459
7469 instructions += LoadLocal(closure); 7460 instructions += LoadLocal(closure);
7470 instructions += LoadLocal(parsed_function()->current_context_var()); 7461 instructions += LoadLocal(parsed_function()->current_context_var());
7471 instructions += flow_graph_builder_->StoreInstanceField( 7462 instructions += flow_graph_builder_->StoreInstanceField(
7472 TokenPosition::kNoSource, Closure::context_offset()); 7463 TokenPosition::kNoSource, Closure::context_offset());
7473 7464
7474 return instructions; 7465 return instructions;
7475 } 7466 }
7476 7467
7477 void StreamingFlowGraphBuilder::SetupFunctionParameters( 7468 void StreamingFlowGraphBuilder::SetupFunctionParameters(
7478 const dart::Class& klass, 7469 const Class& klass,
7479 const dart::Function& function, 7470 const Function& function,
7480 bool is_method, 7471 bool is_method,
7481 bool is_closure, 7472 bool is_closure,
7482 FunctionNodeHelper* function_node_helper) { 7473 FunctionNodeHelper* function_node_helper) {
7483 ASSERT(!(is_method && is_closure)); 7474 ASSERT(!(is_method && is_closure));
7484 bool is_factory = function.IsFactory(); 7475 bool is_factory = function.IsFactory();
7485 intptr_t extra_parameters = (is_method || is_closure || is_factory) ? 1 : 0; 7476 intptr_t extra_parameters = (is_method || is_closure || is_factory) ? 1 : 0;
7486 7477
7487 function_node_helper->ReadUntilExcluding( 7478 function_node_helper->ReadUntilExcluding(
7488 FunctionNodeHelper::kPositionalParameters); 7479 FunctionNodeHelper::kPositionalParameters);
7489 7480
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
7780 } 7771 }
7781 } 7772 }
7782 7773
7783 return Array::Handle(Array::null()); 7774 return Array::Handle(Array::null());
7784 } 7775 }
7785 7776
7786 } // namespace kernel 7777 } // namespace kernel
7787 } // namespace dart 7778 } // namespace dart
7788 7779
7789 #endif // !defined(DART_PRECOMPILED_RUNTIME) 7780 #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