Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 | 6 |
| 7 #include "vm/compiler.h" | 7 #include "vm/compiler.h" |
| 8 #include "vm/longjump.h" | 8 #include "vm/longjump.h" |
| 9 #include "vm/object_store.h" | 9 #include "vm/object_store.h" |
| 10 | 10 |
| (...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1090 const intptr_t named_count = | 1090 const intptr_t named_count = |
| 1091 builder_->ReadListLength(); // read named_parameters list length. | 1091 builder_->ReadListLength(); // read named_parameters list length. |
| 1092 for (intptr_t i = 0; i < named_count; ++i) { | 1092 for (intptr_t i = 0; i < named_count; ++i) { |
| 1093 // read string reference (i.e. named_parameters[i].name). | 1093 // read string reference (i.e. named_parameters[i].name). |
| 1094 builder_->SkipStringReference(); | 1094 builder_->SkipStringReference(); |
| 1095 VisitDartType(); // read named_parameters[i].type. | 1095 VisitDartType(); // read named_parameters[i].type. |
| 1096 } | 1096 } |
| 1097 } | 1097 } |
| 1098 | 1098 |
| 1099 builder_->SkipListOfStrings(); // read positional parameter names. | 1099 builder_->SkipListOfStrings(); // read positional parameter names. |
| 1100 VisitDartType(); // read return type. | 1100 VisitDartType(); // read return type. |
| 1101 } | 1101 } |
| 1102 | 1102 |
| 1103 void StreamingScopeBuilder::VisitTypeParameterType() { | 1103 void StreamingScopeBuilder::VisitTypeParameterType() { |
| 1104 Function& function = Function::Handle(Z, parsed_function_->function().raw()); | 1104 Function& function = Function::Handle(Z, parsed_function_->function().raw()); |
| 1105 while (function.IsClosureFunction()) { | 1105 while (function.IsClosureFunction()) { |
| 1106 function = function.parent_function(); | 1106 function = function.parent_function(); |
| 1107 } | 1107 } |
| 1108 | 1108 |
| 1109 if (function.IsFactory()) { | 1109 if (function.IsFactory()) { |
| 1110 // The type argument vector is passed as the very first argument to the | 1110 // The type argument vector is passed as the very first argument to the |
| (...skipping 1702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2813 // These come from: | 2813 // These come from: |
| 2814 // class A { | 2814 // class A { |
| 2815 // var x = (expr); | 2815 // var x = (expr); |
| 2816 // } | 2816 // } |
| 2817 // We don't want to do that when this is a Redirecting Constructors though | 2817 // We don't want to do that when this is a Redirecting Constructors though |
| 2818 // (i.e. has a single initializer being of type kRedirectingInitializer). | 2818 // (i.e. has a single initializer being of type kRedirectingInitializer). |
| 2819 bool is_redirecting_constructor = false; | 2819 bool is_redirecting_constructor = false; |
| 2820 { | 2820 { |
| 2821 AlternativeReadingScope alt(reader_, initializers_offset); | 2821 AlternativeReadingScope alt(reader_, initializers_offset); |
| 2822 intptr_t list_length = ReadListLength(); // read initializers list length. | 2822 intptr_t list_length = ReadListLength(); // read initializers list length. |
| 2823 if (list_length == 1) { | 2823 bool no_field_initializers = true; |
| 2824 Tag tag = ReadTag(); | 2824 for (intptr_t i = 0; i < list_length; ++i) { |
| 2825 if (tag == kRedirectingInitializer) is_redirecting_constructor = true; | 2825 if (PeekTag() == kRedirectingInitializer) |
|
jensj
2017/08/07 09:12:21
nit: I think the style guide wants braces because
sjindel
2017/08/07 09:17:41
Done.
| |
| 2826 is_redirecting_constructor = true; | |
| 2827 else if (PeekTag() == kFieldInitializer) | |
| 2828 no_field_initializers = false; | |
| 2829 SkipInitializer(); | |
| 2826 } | 2830 } |
| 2831 ASSERT(is_redirecting_constructor ? no_field_initializers : true); | |
| 2827 } | 2832 } |
| 2828 | 2833 |
| 2829 if (!is_redirecting_constructor) { | 2834 if (!is_redirecting_constructor) { |
| 2830 AlternativeReadingScope alt(reader_, constructor_class_parent_offset); | 2835 AlternativeReadingScope alt(reader_, constructor_class_parent_offset); |
| 2831 ClassHelper class_helper(this); | 2836 ClassHelper class_helper(this); |
| 2832 class_helper.ReadUntilExcluding(ClassHelper::kFields); | 2837 class_helper.ReadUntilExcluding(ClassHelper::kFields); |
| 2833 intptr_t list_length = ReadListLength(); // read fields list length. | 2838 intptr_t list_length = ReadListLength(); // read fields list length. |
| 2834 | 2839 |
| 2835 for (intptr_t i = 0; i < list_length; ++i) { | 2840 for (intptr_t i = 0; i < list_length; ++i) { |
| 2836 intptr_t field_offset = ReaderOffset(); | 2841 intptr_t field_offset = ReaderOffset(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2885 argument_count += 1; | 2890 argument_count += 1; |
| 2886 | 2891 |
| 2887 const Function& target = Function::ZoneHandle( | 2892 const Function& target = Function::ZoneHandle( |
| 2888 Z, H.LookupConstructorByKernelConstructor(canonical_target)); | 2893 Z, H.LookupConstructorByKernelConstructor(canonical_target)); |
| 2889 instructions += StaticCall(TokenPosition::kNoSource, target, | 2894 instructions += StaticCall(TokenPosition::kNoSource, target, |
| 2890 argument_count, argument_names); | 2895 argument_count, argument_names); |
| 2891 instructions += Drop(); | 2896 instructions += Drop(); |
| 2892 break; | 2897 break; |
| 2893 } | 2898 } |
| 2894 case kRedirectingInitializer: { | 2899 case kRedirectingInitializer: { |
| 2895 ASSERT(list_length == 1); | |
| 2896 NameIndex canonical_target = | 2900 NameIndex canonical_target = |
| 2897 ReadCanonicalNameReference(); // read target_reference. | 2901 ReadCanonicalNameReference(); // read target_reference. |
| 2898 | 2902 |
| 2899 instructions += LoadLocal(scopes()->this_variable); | 2903 instructions += LoadLocal(scopes()->this_variable); |
| 2900 instructions += PushArgument(); | 2904 instructions += PushArgument(); |
| 2901 | 2905 |
| 2902 // TODO(jensj): ASSERT(init->arguments()->types().length() == 0); | 2906 // TODO(jensj): ASSERT(init->arguments()->types().length() == 0); |
| 2903 Array& argument_names = Array::ZoneHandle(Z); | 2907 Array& argument_names = Array::ZoneHandle(Z); |
| 2904 intptr_t argument_count; | 2908 intptr_t argument_count; |
| 2905 instructions += BuildArguments(&argument_names, | 2909 instructions += BuildArguments(&argument_names, |
| (...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3805 const intptr_t named_count = | 3809 const intptr_t named_count = |
| 3806 ReadListLength(); // read named_parameters list length. | 3810 ReadListLength(); // read named_parameters list length. |
| 3807 for (intptr_t i = 0; i < named_count; ++i) { | 3811 for (intptr_t i = 0; i < named_count; ++i) { |
| 3808 // read string reference (i.e. named_parameters[i].name). | 3812 // read string reference (i.e. named_parameters[i].name). |
| 3809 SkipStringReference(); | 3813 SkipStringReference(); |
| 3810 SkipDartType(); // read named_parameters[i].type. | 3814 SkipDartType(); // read named_parameters[i].type. |
| 3811 } | 3815 } |
| 3812 } | 3816 } |
| 3813 | 3817 |
| 3814 SkipListOfStrings(); // read positional parameter names. | 3818 SkipListOfStrings(); // read positional parameter names. |
| 3815 SkipDartType(); // read return type. | 3819 SkipDartType(); // read return type. |
| 3816 } | 3820 } |
| 3817 | 3821 |
| 3818 void StreamingFlowGraphBuilder::SkipListOfExpressions() { | 3822 void StreamingFlowGraphBuilder::SkipListOfExpressions() { |
| 3819 intptr_t list_length = ReadListLength(); // read list length. | 3823 intptr_t list_length = ReadListLength(); // read list length. |
| 3820 for (intptr_t i = 0; i < list_length; ++i) { | 3824 for (intptr_t i = 0; i < list_length; ++i) { |
| 3821 SkipExpression(); // read ith expression. | 3825 SkipExpression(); // read ith expression. |
| 3822 } | 3826 } |
| 3823 } | 3827 } |
| 3824 | 3828 |
| 3825 void StreamingFlowGraphBuilder::SkipListOfDartTypes() { | 3829 void StreamingFlowGraphBuilder::SkipListOfDartTypes() { |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 3844 } | 3848 } |
| 3845 | 3849 |
| 3846 void StreamingFlowGraphBuilder::SkipTypeParametersList() { | 3850 void StreamingFlowGraphBuilder::SkipTypeParametersList() { |
| 3847 intptr_t list_length = ReadListLength(); // read list length. | 3851 intptr_t list_length = ReadListLength(); // read list length. |
| 3848 for (intptr_t i = 0; i < list_length; ++i) { | 3852 for (intptr_t i = 0; i < list_length; ++i) { |
| 3849 SkipStringReference(); // read ith name index. | 3853 SkipStringReference(); // read ith name index. |
| 3850 SkipDartType(); // read ith bound. | 3854 SkipDartType(); // read ith bound. |
| 3851 } | 3855 } |
| 3852 } | 3856 } |
| 3853 | 3857 |
| 3858 void StreamingFlowGraphBuilder::SkipInitializer() { | |
| 3859 Tag tag = ReadTag(); | |
| 3860 ReadByte(); // read isSynthetic flag. | |
| 3861 switch (tag) { | |
| 3862 case kInvalidInitializer: | |
| 3863 return; | |
| 3864 case kFieldInitializer: | |
| 3865 SkipCanonicalNameReference(); // read field_reference. | |
| 3866 SkipExpression(); // read value. | |
| 3867 return; | |
| 3868 case kSuperInitializer: | |
| 3869 SkipCanonicalNameReference(); // read target_reference. | |
| 3870 SkipArguments(); // read arguments. | |
| 3871 return; | |
| 3872 case kRedirectingInitializer: | |
| 3873 SkipCanonicalNameReference(); // read target_reference. | |
| 3874 SkipArguments(); // read arguments. | |
| 3875 return; | |
| 3876 case kLocalInitializer: | |
| 3877 SkipVariableDeclaration(); // read variable. | |
| 3878 return; | |
| 3879 default: | |
| 3880 UNREACHABLE(); | |
| 3881 } | |
| 3882 } | |
| 3883 | |
| 3854 void StreamingFlowGraphBuilder::SkipExpression() { | 3884 void StreamingFlowGraphBuilder::SkipExpression() { |
| 3855 uint8_t payload = 0; | 3885 uint8_t payload = 0; |
| 3856 Tag tag = ReadTag(&payload); | 3886 Tag tag = ReadTag(&payload); |
| 3857 switch (tag) { | 3887 switch (tag) { |
| 3858 case kInvalidExpression: | 3888 case kInvalidExpression: |
| 3859 return; | 3889 return; |
| 3860 case kVariableGet: | 3890 case kVariableGet: |
| 3861 ReadPosition(); // read position. | 3891 ReadPosition(); // read position. |
| 3862 ReadUInt(); // read kernel position. | 3892 ReadUInt(); // read kernel position. |
| 3863 ReadUInt(); // read relative variable index. | 3893 ReadUInt(); // read relative variable index. |
| (...skipping 2060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5924 instructions += | 5954 instructions += |
| 5925 StoreInstanceField(TokenPosition::kNoSource, Closure::function_offset()); | 5955 StoreInstanceField(TokenPosition::kNoSource, Closure::function_offset()); |
| 5926 | 5956 |
| 5927 instructions += LoadLocal(closure); | 5957 instructions += LoadLocal(closure); |
| 5928 instructions += LoadLocal(context); | 5958 instructions += LoadLocal(context); |
| 5929 instructions += | 5959 instructions += |
| 5930 StoreInstanceField(TokenPosition::kNoSource, Closure::context_offset()); | 5960 StoreInstanceField(TokenPosition::kNoSource, Closure::context_offset()); |
| 5931 | 5961 |
| 5932 instructions += Drop(); | 5962 instructions += Drop(); |
| 5933 | 5963 |
| 5934 SkipDartType(); // skip function type of the closure. | 5964 SkipDartType(); // skip function type of the closure. |
| 5935 SkipListOfDartTypes(); // skip list of type arguments. | 5965 SkipListOfDartTypes(); // skip list of type arguments. |
| 5936 | 5966 |
| 5937 return instructions; | 5967 return instructions; |
| 5938 } | 5968 } |
| 5939 | 5969 |
| 5940 Fragment StreamingFlowGraphBuilder::BuildInvalidStatement() { | 5970 Fragment StreamingFlowGraphBuilder::BuildInvalidStatement() { |
| 5941 H.ReportError("Invalid statements not implemented yet!"); | 5971 H.ReportError("Invalid statements not implemented yet!"); |
| 5942 return Fragment(); | 5972 return Fragment(); |
| 5943 } | 5973 } |
| 5944 | 5974 |
| (...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7300 } | 7330 } |
| 7301 } | 7331 } |
| 7302 | 7332 |
| 7303 return Array::Handle(Array::null()); | 7333 return Array::Handle(Array::null()); |
| 7304 } | 7334 } |
| 7305 | 7335 |
| 7306 } // namespace kernel | 7336 } // namespace kernel |
| 7307 } // namespace dart | 7337 } // namespace dart |
| 7308 | 7338 |
| 7309 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 7339 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| OLD | NEW |