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 |
11 #if !defined(DART_PRECOMPILED_RUNTIME) | 11 #if !defined(DART_PRECOMPILED_RUNTIME) |
12 | 12 |
13 namespace dart { | 13 namespace dart { |
14 namespace kernel { | 14 namespace kernel { |
15 | 15 |
16 #define Z (zone_) | 16 #define Z (zone_) |
17 #define H (translation_helper_) | 17 #define H (translation_helper_) |
18 #define T (type_translator_) | 18 #define T (type_translator_) |
19 #define I Isolate::Current() | 19 #define I Isolate::Current() |
20 | 20 |
21 static bool IsStaticInitializer(const Function& function, Zone* zone) { | 21 static bool IsStaticInitializer(const Function& function, Zone* zone) { |
22 return (function.kind() == RawFunction::kImplicitStaticFinalGetter) && | 22 return (function.kind() == RawFunction::kImplicitStaticFinalGetter) && |
23 dart::String::Handle(zone, function.name()) | 23 dart::String::Handle(zone, function.name()) |
24 .StartsWith(Symbols::InitPrefix()); | 24 .StartsWith(Symbols::InitPrefix()); |
25 } | 25 } |
26 | 26 |
27 | |
28 StreamingScopeBuilder::StreamingScopeBuilder(ParsedFunction* parsed_function, | 27 StreamingScopeBuilder::StreamingScopeBuilder(ParsedFunction* parsed_function, |
29 intptr_t kernel_offset, | 28 intptr_t kernel_offset, |
30 const uint8_t* buffer, | 29 const uint8_t* buffer, |
31 intptr_t buffer_length) | 30 intptr_t buffer_length) |
32 : result_(NULL), | 31 : result_(NULL), |
33 parsed_function_(parsed_function), | 32 parsed_function_(parsed_function), |
34 kernel_offset_(kernel_offset), | 33 kernel_offset_(kernel_offset), |
35 translation_helper_(Thread::Current()), | 34 translation_helper_(Thread::Current()), |
36 zone_(translation_helper_.zone()), | 35 zone_(translation_helper_.zone()), |
37 current_function_scope_(NULL), | 36 current_function_scope_(NULL), |
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 } | 809 } |
811 // TODO(jensj): From kernel_binary.cc | 810 // TODO(jensj): From kernel_binary.cc |
812 // forinstmt->variable_->set_end_position(forinstmt->position_); | 811 // forinstmt->variable_->set_end_position(forinstmt->position_); |
813 ExitScope(position, builder_->reader_->max_position()); | 812 ExitScope(position, builder_->reader_->max_position()); |
814 --depth_.loop_; | 813 --depth_.loop_; |
815 --depth_.for_in_; | 814 --depth_.for_in_; |
816 return; | 815 return; |
817 } | 816 } |
818 case kSwitchStatement: { | 817 case kSwitchStatement: { |
819 AddSwitchVariable(); | 818 AddSwitchVariable(); |
820 VisitExpression(); // read condition. | 819 VisitExpression(); // read condition. |
821 int case_count = builder_->ReadListLength(); // read number of cases. | 820 int case_count = builder_->ReadListLength(); // read number of cases. |
822 for (intptr_t i = 0; i < case_count; ++i) { | 821 for (intptr_t i = 0; i < case_count; ++i) { |
823 int expression_count = | 822 int expression_count = |
824 builder_->ReadListLength(); // read number of expressions. | 823 builder_->ReadListLength(); // read number of expressions. |
825 for (intptr_t j = 0; j < expression_count; ++j) { | 824 for (intptr_t j = 0; j < expression_count; ++j) { |
826 builder_->ReadPosition(); // read jth position. | 825 builder_->ReadPosition(); // read jth position. |
827 VisitExpression(); // read jth expression. | 826 VisitExpression(); // read jth expression. |
828 } | 827 } |
829 builder_->ReadBool(); // read is_default. | 828 builder_->ReadBool(); // read is_default. |
830 VisitStatement(); // read body. | 829 VisitStatement(); // read body. |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 current_function_scope_ = saved_function_scope; | 1131 current_function_scope_ = saved_function_scope; |
1133 current_function_async_marker_ = saved_function_async_marker; | 1132 current_function_async_marker_ = saved_function_async_marker; |
1134 } | 1133 } |
1135 | 1134 |
1136 void StreamingScopeBuilder::EnterScope(intptr_t kernel_offset) { | 1135 void StreamingScopeBuilder::EnterScope(intptr_t kernel_offset) { |
1137 scope_ = new (Z) LocalScope(scope_, depth_.function_, depth_.loop_); | 1136 scope_ = new (Z) LocalScope(scope_, depth_.function_, depth_.loop_); |
1138 ASSERT(kernel_offset >= 0); | 1137 ASSERT(kernel_offset >= 0); |
1139 result_->scopes.Insert(kernel_offset, scope_); | 1138 result_->scopes.Insert(kernel_offset, scope_); |
1140 } | 1139 } |
1141 | 1140 |
1142 | |
1143 void StreamingScopeBuilder::ExitScope(TokenPosition start_position, | 1141 void StreamingScopeBuilder::ExitScope(TokenPosition start_position, |
1144 TokenPosition end_position) { | 1142 TokenPosition end_position) { |
1145 scope_->set_begin_token_pos(start_position); | 1143 scope_->set_begin_token_pos(start_position); |
1146 scope_->set_end_token_pos(end_position); | 1144 scope_->set_end_token_pos(end_position); |
1147 scope_ = scope_->parent(); | 1145 scope_ = scope_->parent(); |
1148 } | 1146 } |
1149 | 1147 |
1150 void StreamingScopeBuilder::AddPositionalAndNamedParameters(intptr_t pos) { | 1148 void StreamingScopeBuilder::AddPositionalAndNamedParameters(intptr_t pos) { |
1151 // List of positional. | 1149 // List of positional. |
1152 intptr_t list_length = builder_->ReadListLength(); // read list length. | 1150 intptr_t list_length = builder_->ReadListLength(); // read list length. |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1239 } | 1237 } |
1240 | 1238 |
1241 variables->Add(v); | 1239 variables->Add(v); |
1242 } | 1240 } |
1243 | 1241 |
1244 void StreamingScopeBuilder::AddTryVariables() { | 1242 void StreamingScopeBuilder::AddTryVariables() { |
1245 AddExceptionVariable(&result_->catch_context_variables, | 1243 AddExceptionVariable(&result_->catch_context_variables, |
1246 ":saved_try_context_var", depth_.try_); | 1244 ":saved_try_context_var", depth_.try_); |
1247 } | 1245 } |
1248 | 1246 |
1249 | |
1250 void StreamingScopeBuilder::AddCatchVariables() { | 1247 void StreamingScopeBuilder::AddCatchVariables() { |
1251 AddExceptionVariable(&result_->exception_variables, ":exception", | 1248 AddExceptionVariable(&result_->exception_variables, ":exception", |
1252 depth_.catch_); | 1249 depth_.catch_); |
1253 AddExceptionVariable(&result_->stack_trace_variables, ":stack_trace", | 1250 AddExceptionVariable(&result_->stack_trace_variables, ":stack_trace", |
1254 depth_.catch_); | 1251 depth_.catch_); |
1255 } | 1252 } |
1256 | 1253 |
1257 | |
1258 void StreamingScopeBuilder::AddIteratorVariable() { | 1254 void StreamingScopeBuilder::AddIteratorVariable() { |
1259 if (depth_.function_ > 0) return; | 1255 if (depth_.function_ > 0) return; |
1260 if (result_->iterator_variables.length() >= depth_.for_in_) return; | 1256 if (result_->iterator_variables.length() >= depth_.for_in_) return; |
1261 | 1257 |
1262 ASSERT(result_->iterator_variables.length() == depth_.for_in_ - 1); | 1258 ASSERT(result_->iterator_variables.length() == depth_.for_in_ - 1); |
1263 LocalVariable* iterator = | 1259 LocalVariable* iterator = |
1264 MakeVariable(TokenPosition::kNoSource, TokenPosition::kNoSource, | 1260 MakeVariable(TokenPosition::kNoSource, TokenPosition::kNoSource, |
1265 GenerateName(":iterator", depth_.for_in_ - 1), | 1261 GenerateName(":iterator", depth_.for_in_ - 1), |
1266 AbstractType::dynamic_type()); | 1262 AbstractType::dynamic_type()); |
1267 current_function_scope_->AddVariable(iterator); | 1263 current_function_scope_->AddVariable(iterator); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1358 StreamingFlowGraphBuilder* builder, | 1354 StreamingFlowGraphBuilder* builder, |
1359 bool finalize) | 1355 bool finalize) |
1360 : builder_(builder), | 1356 : builder_(builder), |
1361 translation_helper_(builder->translation_helper_), | 1357 translation_helper_(builder->translation_helper_), |
1362 active_class_(builder->active_class()), | 1358 active_class_(builder->active_class()), |
1363 type_parameter_scope_(NULL), | 1359 type_parameter_scope_(NULL), |
1364 zone_(translation_helper_.zone()), | 1360 zone_(translation_helper_.zone()), |
1365 result_(AbstractType::Handle(translation_helper_.zone())), | 1361 result_(AbstractType::Handle(translation_helper_.zone())), |
1366 finalize_(finalize) {} | 1362 finalize_(finalize) {} |
1367 | 1363 |
1368 | |
1369 AbstractType& StreamingDartTypeTranslator::BuildType() { | 1364 AbstractType& StreamingDartTypeTranslator::BuildType() { |
1370 BuildTypeInternal(); | 1365 BuildTypeInternal(); |
1371 | 1366 |
1372 // We return a new `ZoneHandle` here on purpose: The intermediate language | 1367 // We return a new `ZoneHandle` here on purpose: The intermediate language |
1373 // instructions do not make a copy of the handle, so we do it. | 1368 // instructions do not make a copy of the handle, so we do it. |
1374 return dart::AbstractType::ZoneHandle(Z, result_.raw()); | 1369 return dart::AbstractType::ZoneHandle(Z, result_.raw()); |
1375 } | 1370 } |
1376 | 1371 |
1377 AbstractType& StreamingDartTypeTranslator::BuildTypeWithoutFinalization() { | 1372 AbstractType& StreamingDartTypeTranslator::BuildTypeWithoutFinalization() { |
1378 bool saved_finalize = finalize_; | 1373 bool saved_finalize = finalize_; |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1686 Z, Type::New(receiver_class, type_arguments, TokenPosition::kNoSource)); | 1681 Z, Type::New(receiver_class, type_arguments, TokenPosition::kNoSource)); |
1687 if (finalize_) { | 1682 if (finalize_) { |
1688 type ^= ClassFinalizer::FinalizeType(*active_class_->klass, type); | 1683 type ^= ClassFinalizer::FinalizeType(*active_class_->klass, type); |
1689 } | 1684 } |
1690 | 1685 |
1691 const TypeArguments& instantiated_type_arguments = | 1686 const TypeArguments& instantiated_type_arguments = |
1692 TypeArguments::ZoneHandle(Z, type.arguments()); | 1687 TypeArguments::ZoneHandle(Z, type.arguments()); |
1693 return instantiated_type_arguments; | 1688 return instantiated_type_arguments; |
1694 } | 1689 } |
1695 | 1690 |
1696 | |
1697 const Type& StreamingDartTypeTranslator::ReceiverType( | 1691 const Type& StreamingDartTypeTranslator::ReceiverType( |
1698 const dart::Class& klass) { | 1692 const dart::Class& klass) { |
1699 ASSERT(!klass.IsNull()); | 1693 ASSERT(!klass.IsNull()); |
1700 ASSERT(!klass.IsTypedefClass()); | 1694 ASSERT(!klass.IsTypedefClass()); |
1701 // Note that if klass is _Closure, the returned type will be _Closure, | 1695 // Note that if klass is _Closure, the returned type will be _Closure, |
1702 // and not the signature type. | 1696 // and not the signature type. |
1703 Type& type = Type::ZoneHandle(Z, klass.CanonicalType()); | 1697 Type& type = Type::ZoneHandle(Z, klass.CanonicalType()); |
1704 if (!type.IsNull()) { | 1698 if (!type.IsNull()) { |
1705 return type; | 1699 return type; |
1706 } | 1700 } |
1707 type = Type::New(klass, TypeArguments::Handle(Z, klass.type_parameters()), | 1701 type = Type::New(klass, TypeArguments::Handle(Z, klass.type_parameters()), |
1708 klass.token_pos()); | 1702 klass.token_pos()); |
1709 if (klass.is_type_finalized()) { | 1703 if (klass.is_type_finalized()) { |
1710 type ^= ClassFinalizer::FinalizeType(klass, type); | 1704 type ^= ClassFinalizer::FinalizeType(klass, type); |
1711 klass.SetCanonicalType(type); | 1705 klass.SetCanonicalType(type); |
1712 } | 1706 } |
1713 return type; | 1707 return type; |
1714 } | 1708 } |
1715 | 1709 |
1716 | |
1717 StreamingConstantEvaluator::StreamingConstantEvaluator( | 1710 StreamingConstantEvaluator::StreamingConstantEvaluator( |
1718 StreamingFlowGraphBuilder* builder) | 1711 StreamingFlowGraphBuilder* builder) |
1719 : builder_(builder), | 1712 : builder_(builder), |
1720 isolate_(Isolate::Current()), | 1713 isolate_(Isolate::Current()), |
1721 zone_(builder_->zone_), | 1714 zone_(builder_->zone_), |
1722 translation_helper_(builder_->translation_helper_), | 1715 translation_helper_(builder_->translation_helper_), |
1723 type_translator_(builder_->type_translator_), | 1716 type_translator_(builder_->type_translator_), |
1724 script_(Script::Handle( | 1717 script_(Script::Handle( |
1725 zone_, | 1718 zone_, |
1726 // TODO(jensj): This was added to temporarily be able to let the scope | 1719 // TODO(jensj): This was added to temporarily be able to let the scope |
1727 // builder have a StreamingFlowGraphBuilder to get access to | 1720 // builder have a StreamingFlowGraphBuilder to get access to |
1728 // reading functions. | 1721 // reading functions. |
1729 (builder == NULL || builder_->flow_graph_builder_ == NULL) | 1722 (builder == NULL || builder_->flow_graph_builder_ == NULL) |
1730 ? Script::null() | 1723 ? Script::null() |
1731 : builder_->parsed_function()->function().script())), | 1724 : builder_->parsed_function()->function().script())), |
1732 result_(Instance::Handle(zone_)) {} | 1725 result_(Instance::Handle(zone_)) {} |
1733 | 1726 |
1734 | |
1735 Instance& StreamingConstantEvaluator::EvaluateExpression(intptr_t offset, | 1727 Instance& StreamingConstantEvaluator::EvaluateExpression(intptr_t offset, |
1736 bool reset_position) { | 1728 bool reset_position) { |
1737 if (!GetCachedConstant(offset, &result_)) { | 1729 if (!GetCachedConstant(offset, &result_)) { |
1738 intptr_t original_offset = builder_->ReaderOffset(); | 1730 intptr_t original_offset = builder_->ReaderOffset(); |
1739 builder_->SetOffset(offset); | 1731 builder_->SetOffset(offset); |
1740 uint8_t payload = 0; | 1732 uint8_t payload = 0; |
1741 Tag tag = builder_->ReadTag(&payload); // read tag. | 1733 Tag tag = builder_->ReadTag(&payload); // read tag. |
1742 switch (tag) { | 1734 switch (tag) { |
1743 case kVariableGet: | 1735 case kVariableGet: |
1744 EvaluateVariableGet(); | 1736 EvaluateVariableGet(); |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2226 result_ = H.Canonicalize(result_); | 2218 result_ = H.Canonicalize(result_); |
2227 } | 2219 } |
2228 | 2220 |
2229 void StreamingConstantEvaluator::EvaluateLet() { | 2221 void StreamingConstantEvaluator::EvaluateLet() { |
2230 intptr_t kernel_position = builder_->ReaderOffset(); | 2222 intptr_t kernel_position = builder_->ReaderOffset(); |
2231 LocalVariable* local = builder_->LookupVariable(kernel_position); | 2223 LocalVariable* local = builder_->LookupVariable(kernel_position); |
2232 | 2224 |
2233 // read variable declaration. | 2225 // read variable declaration. |
2234 VariableDeclarationHelper helper(builder_); | 2226 VariableDeclarationHelper helper(builder_); |
2235 helper.ReadUntilExcluding(VariableDeclarationHelper::kInitializer); | 2227 helper.ReadUntilExcluding(VariableDeclarationHelper::kInitializer); |
2236 Tag tag = builder_->ReadTag(); // read (first part of) initializer. | 2228 Tag tag = builder_->ReadTag(); // read (first part of) initializer. |
2237 if (tag == kNothing) { | 2229 if (tag == kNothing) { |
2238 local->SetConstValue(Instance::ZoneHandle(Z, dart::Instance::null())); | 2230 local->SetConstValue(Instance::ZoneHandle(Z, dart::Instance::null())); |
2239 } else { | 2231 } else { |
2240 local->SetConstValue(EvaluateExpression( | 2232 local->SetConstValue(EvaluateExpression( |
2241 builder_->ReaderOffset(), false)); // read rest of initializer. | 2233 builder_->ReaderOffset(), false)); // read rest of initializer. |
2242 } | 2234 } |
2243 | 2235 |
2244 EvaluateExpression(builder_->ReaderOffset(), false); // read body | 2236 EvaluateExpression(builder_->ReaderOffset(), false); // read body |
2245 } | 2237 } |
2246 | 2238 |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2432 // Mutator compiler thread may add constants while background compiler | 2424 // Mutator compiler thread may add constants while background compiler |
2433 // is running, and thus change the value of 'compile_time_constants'; | 2425 // is running, and thus change the value of 'compile_time_constants'; |
2434 // do not assert that 'compile_time_constants' has not changed. | 2426 // do not assert that 'compile_time_constants' has not changed. |
2435 constants.Release(); | 2427 constants.Release(); |
2436 if (FLAG_compiler_stats && is_present) { | 2428 if (FLAG_compiler_stats && is_present) { |
2437 ++H.thread()->compiler_stats()->num_const_cache_hits; | 2429 ++H.thread()->compiler_stats()->num_const_cache_hits; |
2438 } | 2430 } |
2439 return is_present; | 2431 return is_present; |
2440 } | 2432 } |
2441 | 2433 |
2442 | |
2443 void StreamingConstantEvaluator::CacheConstantValue(intptr_t kernel_offset, | 2434 void StreamingConstantEvaluator::CacheConstantValue(intptr_t kernel_offset, |
2444 const Instance& value) { | 2435 const Instance& value) { |
2445 ASSERT(Thread::Current()->IsMutatorThread()); | 2436 ASSERT(Thread::Current()->IsMutatorThread()); |
2446 | 2437 |
2447 if (builder_ == NULL || builder_->flow_graph_builder_ == NULL) return; | 2438 if (builder_ == NULL || builder_->flow_graph_builder_ == NULL) return; |
2448 | 2439 |
2449 const Function& function = builder_->parsed_function()->function(); | 2440 const Function& function = builder_->parsed_function()->function(); |
2450 if (function.kind() == RawFunction::kImplicitStaticFinalGetter) { | 2441 if (function.kind() == RawFunction::kImplicitStaticFinalGetter) { |
2451 // Don't cache constants in initializer expressions. They get | 2442 // Don't cache constants in initializer expressions. They get |
2452 // evaluated only once. | 2443 // evaluated only once. |
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3393 case RawFunction::kInvokeFieldDispatcher: | 3384 case RawFunction::kInvokeFieldDispatcher: |
3394 return flow_graph_builder_->BuildGraphOfInvokeFieldDispatcher(function); | 3385 return flow_graph_builder_->BuildGraphOfInvokeFieldDispatcher(function); |
3395 case RawFunction::kSignatureFunction: | 3386 case RawFunction::kSignatureFunction: |
3396 case RawFunction::kIrregexpFunction: | 3387 case RawFunction::kIrregexpFunction: |
3397 break; | 3388 break; |
3398 } | 3389 } |
3399 UNREACHABLE(); | 3390 UNREACHABLE(); |
3400 return NULL; | 3391 return NULL; |
3401 } | 3392 } |
3402 | 3393 |
3403 | |
3404 Fragment StreamingFlowGraphBuilder::BuildStatementAt(intptr_t kernel_offset) { | 3394 Fragment StreamingFlowGraphBuilder::BuildStatementAt(intptr_t kernel_offset) { |
3405 SetOffset(kernel_offset); | 3395 SetOffset(kernel_offset); |
3406 return BuildStatement(); // read statement. | 3396 return BuildStatement(); // read statement. |
3407 } | 3397 } |
3408 | 3398 |
3409 Fragment StreamingFlowGraphBuilder::BuildExpression(TokenPosition* position) { | 3399 Fragment StreamingFlowGraphBuilder::BuildExpression(TokenPosition* position) { |
3410 uint8_t payload = 0; | 3400 uint8_t payload = 0; |
3411 Tag tag = ReadTag(&payload); // read tag. | 3401 Tag tag = ReadTag(&payload); // read tag. |
3412 switch (tag) { | 3402 switch (tag) { |
3413 case kInvalidExpression: | 3403 case kInvalidExpression: |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3700 void StreamingFlowGraphBuilder::SkipInterfaceType(bool simple) { | 3690 void StreamingFlowGraphBuilder::SkipInterfaceType(bool simple) { |
3701 ReadUInt(); // read klass_name. | 3691 ReadUInt(); // read klass_name. |
3702 if (!simple) { | 3692 if (!simple) { |
3703 SkipListOfDartTypes(); // read list of types. | 3693 SkipListOfDartTypes(); // read list of types. |
3704 } | 3694 } |
3705 } | 3695 } |
3706 | 3696 |
3707 void StreamingFlowGraphBuilder::SkipFunctionType(bool simple) { | 3697 void StreamingFlowGraphBuilder::SkipFunctionType(bool simple) { |
3708 if (!simple) { | 3698 if (!simple) { |
3709 SkipTypeParametersList(); // read type_parameters. | 3699 SkipTypeParametersList(); // read type_parameters. |
3710 ReadUInt(); // read required parameter count. | 3700 ReadUInt(); // read required parameter count. |
3711 ReadUInt(); // read total parameter count. | 3701 ReadUInt(); // read total parameter count. |
3712 } | 3702 } |
3713 | 3703 |
3714 SkipListOfDartTypes(); // read positional_parameters types. | 3704 SkipListOfDartTypes(); // read positional_parameters types. |
3715 | 3705 |
3716 if (!simple) { | 3706 if (!simple) { |
3717 const intptr_t named_count = | 3707 const intptr_t named_count = |
3718 ReadListLength(); // read named_parameters list length. | 3708 ReadListLength(); // read named_parameters list length. |
3719 for (intptr_t i = 0; i < named_count; ++i) { | 3709 for (intptr_t i = 0; i < named_count; ++i) { |
3720 // read string reference (i.e. named_parameters[i].name). | 3710 // read string reference (i.e. named_parameters[i].name). |
3721 SkipStringReference(); | 3711 SkipStringReference(); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3850 SkipBytes(1); // read operator. | 3840 SkipBytes(1); // read operator. |
3851 SkipExpression(); // read right. | 3841 SkipExpression(); // read right. |
3852 return; | 3842 return; |
3853 case kConditionalExpression: | 3843 case kConditionalExpression: |
3854 SkipExpression(); // read condition. | 3844 SkipExpression(); // read condition. |
3855 SkipExpression(); // read then. | 3845 SkipExpression(); // read then. |
3856 SkipExpression(); // read otherwise. | 3846 SkipExpression(); // read otherwise. |
3857 SkipOptionalDartType(); // read unused static type. | 3847 SkipOptionalDartType(); // read unused static type. |
3858 return; | 3848 return; |
3859 case kStringConcatenation: | 3849 case kStringConcatenation: |
3860 ReadPosition(); // read position. | 3850 ReadPosition(); // read position. |
3861 SkipListOfExpressions(); // read list of expressions. | 3851 SkipListOfExpressions(); // read list of expressions. |
3862 return; | 3852 return; |
3863 case kIsExpression: | 3853 case kIsExpression: |
3864 ReadPosition(); // read position. | 3854 ReadPosition(); // read position. |
3865 SkipExpression(); // read operand. | 3855 SkipExpression(); // read operand. |
3866 SkipDartType(); // read type. | 3856 SkipDartType(); // read type. |
3867 return; | 3857 return; |
3868 case kAsExpression: | 3858 case kAsExpression: |
3869 ReadPosition(); // read position. | 3859 ReadPosition(); // read position. |
3870 SkipExpression(); // read operand. | 3860 SkipExpression(); // read operand. |
3871 SkipDartType(); // read type. | 3861 SkipDartType(); // read type. |
3872 return; | 3862 return; |
3873 case kSymbolLiteral: | 3863 case kSymbolLiteral: |
3874 SkipStringReference(); // read index into string table. | 3864 SkipStringReference(); // read index into string table. |
3875 return; | 3865 return; |
3876 case kTypeLiteral: | 3866 case kTypeLiteral: |
3877 SkipDartType(); // read type. | 3867 SkipDartType(); // read type. |
3878 return; | 3868 return; |
3879 case kThisExpression: | 3869 case kThisExpression: |
3880 return; | 3870 return; |
3881 case kRethrow: | 3871 case kRethrow: |
3882 ReadPosition(); // read position. | 3872 ReadPosition(); // read position. |
3883 return; | 3873 return; |
3884 case kThrow: | 3874 case kThrow: |
3885 ReadPosition(); // read position. | 3875 ReadPosition(); // read position. |
3886 SkipExpression(); // read expression. | 3876 SkipExpression(); // read expression. |
3887 return; | 3877 return; |
3888 case kListLiteral: | 3878 case kListLiteral: |
3889 case kConstListLiteral: | 3879 case kConstListLiteral: |
3890 ReadPosition(); // read position. | 3880 ReadPosition(); // read position. |
3891 SkipDartType(); // read type. | 3881 SkipDartType(); // read type. |
3892 SkipListOfExpressions(); // read list of expressions. | 3882 SkipListOfExpressions(); // read list of expressions. |
3893 return; | 3883 return; |
3894 case kMapLiteral: | 3884 case kMapLiteral: |
3895 case kConstMapLiteral: { | 3885 case kConstMapLiteral: { |
3896 ReadPosition(); // read position. | 3886 ReadPosition(); // read position. |
3897 SkipDartType(); // read key type. | 3887 SkipDartType(); // read key type. |
3898 SkipDartType(); // read value type. | 3888 SkipDartType(); // read value type. |
3899 intptr_t list_length = ReadListLength(); // read list length. | 3889 intptr_t list_length = ReadListLength(); // read list length. |
3900 for (intptr_t i = 0; i < list_length; ++i) { | 3890 for (intptr_t i = 0; i < list_length; ++i) { |
3901 SkipExpression(); // read ith key. | 3891 SkipExpression(); // read ith key. |
3902 SkipExpression(); // read ith value. | 3892 SkipExpression(); // read ith value. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3975 case kWhileStatement: | 3965 case kWhileStatement: |
3976 SkipExpression(); // read condition. | 3966 SkipExpression(); // read condition. |
3977 SkipStatement(); // read body. | 3967 SkipStatement(); // read body. |
3978 return; | 3968 return; |
3979 case kDoStatement: | 3969 case kDoStatement: |
3980 SkipStatement(); // read body. | 3970 SkipStatement(); // read body. |
3981 SkipExpression(); // read condition. | 3971 SkipExpression(); // read condition. |
3982 return; | 3972 return; |
3983 case kForStatement: { | 3973 case kForStatement: { |
3984 SkipListOfVariableDeclarations(); // read variables. | 3974 SkipListOfVariableDeclarations(); // read variables. |
3985 Tag tag = ReadTag(); // Read first part of condition. | 3975 Tag tag = ReadTag(); // Read first part of condition. |
3986 if (tag == kSomething) { | 3976 if (tag == kSomething) { |
3987 SkipExpression(); // read rest of condition. | 3977 SkipExpression(); // read rest of condition. |
3988 } | 3978 } |
3989 SkipListOfExpressions(); // read updates. | 3979 SkipListOfExpressions(); // read updates. |
3990 SkipStatement(); // read body. | 3980 SkipStatement(); // read body. |
3991 return; | 3981 return; |
3992 } | 3982 } |
3993 case kForInStatement: | 3983 case kForInStatement: |
3994 case kAsyncForInStatement: | 3984 case kAsyncForInStatement: |
3995 ReadPosition(); // read position. | 3985 ReadPosition(); // read position. |
3996 SkipVariableDeclaration(); // read variable. | 3986 SkipVariableDeclaration(); // read variable. |
3997 SkipExpression(); // read iterable. | 3987 SkipExpression(); // read iterable. |
3998 SkipStatement(); // read body. | 3988 SkipStatement(); // read body. |
3999 return; | 3989 return; |
4000 case kSwitchStatement: { | 3990 case kSwitchStatement: { |
4001 SkipExpression(); // read condition. | 3991 SkipExpression(); // read condition. |
4002 int case_count = ReadListLength(); // read number of cases. | 3992 int case_count = ReadListLength(); // read number of cases. |
4003 for (intptr_t i = 0; i < case_count; ++i) { | 3993 for (intptr_t i = 0; i < case_count; ++i) { |
4004 int expression_count = ReadListLength(); // read number of expressions. | 3994 int expression_count = ReadListLength(); // read number of expressions. |
4005 for (intptr_t j = 0; j < expression_count; ++j) { | 3995 for (intptr_t j = 0; j < expression_count; ++j) { |
4006 ReadPosition(); // read jth position. | 3996 ReadPosition(); // read jth position. |
4007 SkipExpression(); // read jth expression. | 3997 SkipExpression(); // read jth expression. |
4008 } | 3998 } |
4009 ReadBool(); // read is_default. | 3999 ReadBool(); // read is_default. |
4010 SkipStatement(); // read body. | 4000 SkipStatement(); // read body. |
4011 } | 4001 } |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4284 intptr_t list_length = ReadListLength(); // read types list length. | 4274 intptr_t list_length = ReadListLength(); // read types list length. |
4285 return T.BuildInstantiatedTypeArguments(klass, list_length); // read types. | 4275 return T.BuildInstantiatedTypeArguments(klass, list_length); // read types. |
4286 } | 4276 } |
4287 | 4277 |
4288 intptr_t StreamingFlowGraphBuilder::PeekArgumentsCount() { | 4278 intptr_t StreamingFlowGraphBuilder::PeekArgumentsCount() { |
4289 return PeekUInt(); | 4279 return PeekUInt(); |
4290 } | 4280 } |
4291 | 4281 |
4292 intptr_t StreamingFlowGraphBuilder::PeekArgumentsTypeCount() { | 4282 intptr_t StreamingFlowGraphBuilder::PeekArgumentsTypeCount() { |
4293 AlternativeReadingScope alt(reader_); | 4283 AlternativeReadingScope alt(reader_); |
4294 ReadUInt(); // read arguments count. | 4284 ReadUInt(); // read arguments count. |
4295 return ReadListLength(); // read length of types list. | 4285 return ReadListLength(); // read length of types list. |
4296 } | 4286 } |
4297 | 4287 |
4298 void StreamingFlowGraphBuilder::SkipArgumentsBeforeActualArguments() { | 4288 void StreamingFlowGraphBuilder::SkipArgumentsBeforeActualArguments() { |
4299 ReadUInt(); // read arguments count. | 4289 ReadUInt(); // read arguments count. |
4300 SkipListOfDartTypes(); // read list of types. | 4290 SkipListOfDartTypes(); // read list of types. |
4301 } | 4291 } |
4302 | 4292 |
4303 LocalVariable* StreamingFlowGraphBuilder::LookupVariable( | 4293 LocalVariable* StreamingFlowGraphBuilder::LookupVariable( |
4304 intptr_t kernel_offset) { | 4294 intptr_t kernel_offset) { |
4305 return flow_graph_builder_->LookupVariable(kernel_offset); | 4295 return flow_graph_builder_->LookupVariable(kernel_offset); |
4306 } | 4296 } |
4307 | 4297 |
4308 LocalVariable* StreamingFlowGraphBuilder::MakeTemporary() { | 4298 LocalVariable* StreamingFlowGraphBuilder::MakeTemporary() { |
4309 return flow_graph_builder_->MakeTemporary(); | 4299 return flow_graph_builder_->MakeTemporary(); |
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5352 | 5342 |
5353 // Let condition be always true. | 5343 // Let condition be always true. |
5354 instructions += Constant(Bool::True()); | 5344 instructions += Constant(Bool::True()); |
5355 } else { | 5345 } else { |
5356 instructions += PushArgument(); | 5346 instructions += PushArgument(); |
5357 | 5347 |
5358 // See if simple instanceOf is applicable. | 5348 // See if simple instanceOf is applicable. |
5359 if (dart::FlowGraphBuilder::SimpleInstanceOfType(type)) { | 5349 if (dart::FlowGraphBuilder::SimpleInstanceOfType(type)) { |
5360 instructions += Constant(type); | 5350 instructions += Constant(type); |
5361 instructions += PushArgument(); // Type. | 5351 instructions += PushArgument(); // Type. |
5362 instructions += InstanceCall(position, dart::Library::PrivateCoreLibName( | 5352 instructions += InstanceCall( |
5363 Symbols::_simpleInstanceOf()), | 5353 position, |
5364 Token::kIS, 2, 2); // 2 checked arguments. | 5354 dart::Library::PrivateCoreLibName(Symbols::_simpleInstanceOf()), |
| 5355 Token::kIS, 2, 2); // 2 checked arguments. |
5365 return instructions; | 5356 return instructions; |
5366 } | 5357 } |
5367 | 5358 |
5368 if (!type.IsInstantiated(kCurrentClass)) { | 5359 if (!type.IsInstantiated(kCurrentClass)) { |
5369 instructions += LoadInstantiatorTypeArguments(); | 5360 instructions += LoadInstantiatorTypeArguments(); |
5370 } else { | 5361 } else { |
5371 instructions += NullConstant(); | 5362 instructions += NullConstant(); |
5372 } | 5363 } |
5373 instructions += PushArgument(); // Instantiator type arguments. | 5364 instructions += PushArgument(); // Instantiator type arguments. |
5374 | 5365 |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5615 | 5606 |
5616 instructions += LoadLocal(array); | 5607 instructions += LoadLocal(array); |
5617 instructions += IntConstant(2 * i + 1); | 5608 instructions += IntConstant(2 * i + 1); |
5618 instructions += BuildExpression(); // read ith value. | 5609 instructions += BuildExpression(); // read ith value. |
5619 instructions += StoreIndexed(kArrayCid); | 5610 instructions += StoreIndexed(kArrayCid); |
5620 instructions += Drop(); | 5611 instructions += Drop(); |
5621 } | 5612 } |
5622 } | 5613 } |
5623 instructions += PushArgument(); // The array. | 5614 instructions += PushArgument(); // The array. |
5624 | 5615 |
5625 | |
5626 const dart::Class& map_class = | 5616 const dart::Class& map_class = |
5627 dart::Class::Handle(Z, dart::Library::LookupCoreClass(Symbols::Map())); | 5617 dart::Class::Handle(Z, dart::Library::LookupCoreClass(Symbols::Map())); |
5628 const Function& factory_method = Function::ZoneHandle( | 5618 const Function& factory_method = Function::ZoneHandle( |
5629 Z, map_class.LookupFactory( | 5619 Z, map_class.LookupFactory( |
5630 dart::Library::PrivateCoreLibName(Symbols::MapLiteralFactory()))); | 5620 dart::Library::PrivateCoreLibName(Symbols::MapLiteralFactory()))); |
5631 | 5621 |
5632 return instructions + StaticCall(position, factory_method, 2); | 5622 return instructions + StaticCall(position, factory_method, 2); |
5633 } | 5623 } |
5634 | 5624 |
5635 Fragment StreamingFlowGraphBuilder::BuildFunctionExpression() { | 5625 Fragment StreamingFlowGraphBuilder::BuildFunctionExpression() { |
5636 intptr_t offset = ReaderOffset() - 1; // -1 to include tag byte. | 5626 intptr_t offset = ReaderOffset() - 1; // -1 to include tag byte. |
5637 return BuildFunctionNode(offset, TokenPosition::kNoSource, false, -1); | 5627 return BuildFunctionNode(offset, TokenPosition::kNoSource, false, -1); |
5638 } | 5628 } |
5639 | 5629 |
5640 Fragment StreamingFlowGraphBuilder::BuildLet(TokenPosition* position) { | 5630 Fragment StreamingFlowGraphBuilder::BuildLet(TokenPosition* position) { |
5641 if (position != NULL) *position = TokenPosition::kNoSource; | 5631 if (position != NULL) *position = TokenPosition::kNoSource; |
5642 | 5632 |
5643 Fragment instructions = BuildVariableDeclaration(); // read variable. | 5633 Fragment instructions = BuildVariableDeclaration(); // read variable. |
5644 instructions += BuildExpression(); // read body. | 5634 instructions += BuildExpression(); // read body. |
5645 return instructions; | 5635 return instructions; |
5646 } | 5636 } |
5647 | 5637 |
5648 | |
5649 Fragment StreamingFlowGraphBuilder::BuildBigIntLiteral( | 5638 Fragment StreamingFlowGraphBuilder::BuildBigIntLiteral( |
5650 TokenPosition* position) { | 5639 TokenPosition* position) { |
5651 if (position != NULL) *position = TokenPosition::kNoSource; | 5640 if (position != NULL) *position = TokenPosition::kNoSource; |
5652 | 5641 |
5653 const dart::String& value = | 5642 const dart::String& value = |
5654 H.DartString(ReadStringReference()); // read index into string table. | 5643 H.DartString(ReadStringReference()); // read index into string table. |
5655 return Constant(Integer::ZoneHandle(Z, Integer::New(value, Heap::kOld))); | 5644 return Constant(Integer::ZoneHandle(Z, Integer::New(value, Heap::kOld))); |
5656 } | 5645 } |
5657 | 5646 |
5658 Fragment StreamingFlowGraphBuilder::BuildStringLiteral( | 5647 Fragment StreamingFlowGraphBuilder::BuildStringLiteral( |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5772 const dart::Function& target = dart::Function::ZoneHandle( | 5761 const dart::Function& target = dart::Function::ZoneHandle( |
5773 Z, klass.LookupStaticFunctionAllowPrivate(Symbols::ThrowNew())); | 5762 Z, klass.LookupStaticFunctionAllowPrivate(Symbols::ThrowNew())); |
5774 ASSERT(!target.IsNull()); | 5763 ASSERT(!target.IsNull()); |
5775 | 5764 |
5776 // Build call to _AsertionError._throwNew(start, end, message) | 5765 // Build call to _AsertionError._throwNew(start, end, message) |
5777 Fragment otherwise_fragment(otherwise); | 5766 Fragment otherwise_fragment(otherwise); |
5778 otherwise_fragment += IntConstant(condition_start_offset.Pos()); | 5767 otherwise_fragment += IntConstant(condition_start_offset.Pos()); |
5779 otherwise_fragment += PushArgument(); // start | 5768 otherwise_fragment += PushArgument(); // start |
5780 otherwise_fragment += IntConstant(condition_end_offset.Pos()); | 5769 otherwise_fragment += IntConstant(condition_end_offset.Pos()); |
5781 otherwise_fragment += PushArgument(); // end | 5770 otherwise_fragment += PushArgument(); // end |
5782 Tag tag = ReadTag(); // read (first part of) message. | 5771 Tag tag = ReadTag(); // read (first part of) message. |
5783 if (tag == kSomething) { | 5772 if (tag == kSomething) { |
5784 otherwise_fragment += BuildExpression(); // read (rest of) message. | 5773 otherwise_fragment += BuildExpression(); // read (rest of) message. |
5785 } else { | 5774 } else { |
5786 otherwise_fragment += Constant(Instance::ZoneHandle(Z)); // null. | 5775 otherwise_fragment += Constant(Instance::ZoneHandle(Z)); // null. |
5787 } | 5776 } |
5788 otherwise_fragment += PushArgument(); // message | 5777 otherwise_fragment += PushArgument(); // message |
5789 | 5778 |
5790 otherwise_fragment += StaticCall(TokenPosition::kNoSource, target, 3); | 5779 otherwise_fragment += StaticCall(TokenPosition::kNoSource, target, 3); |
5791 otherwise_fragment += Drop(); | 5780 otherwise_fragment += Drop(); |
5792 | 5781 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5855 body += Goto(join); | 5844 body += Goto(join); |
5856 | 5845 |
5857 Fragment loop(join); | 5846 Fragment loop(join); |
5858 loop += CheckStackOverflow(); | 5847 loop += CheckStackOverflow(); |
5859 loop += condition; | 5848 loop += condition; |
5860 entry = new (Z) GotoInstr(join, Thread::Current()->GetNextDeoptId()); | 5849 entry = new (Z) GotoInstr(join, Thread::Current()->GetNextDeoptId()); |
5861 } else { | 5850 } else { |
5862 entry = condition.entry; | 5851 entry = condition.entry; |
5863 } | 5852 } |
5864 | 5853 |
5865 | |
5866 loop_depth_dec(); | 5854 loop_depth_dec(); |
5867 return Fragment(entry, loop_exit); | 5855 return Fragment(entry, loop_exit); |
5868 } | 5856 } |
5869 | 5857 |
5870 Fragment StreamingFlowGraphBuilder::BuildDoStatement() { | 5858 Fragment StreamingFlowGraphBuilder::BuildDoStatement() { |
5871 loop_depth_inc(); | 5859 loop_depth_inc(); |
5872 Fragment body = BuildStatement(); // read body. | 5860 Fragment body = BuildStatement(); // read body. |
5873 | 5861 |
5874 if (body.is_closed()) { | 5862 if (body.is_closed()) { |
5875 SkipExpression(); // read condition. | 5863 SkipExpression(); // read condition. |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6012 } | 6000 } |
6013 | 6001 |
6014 loop_depth_dec(); | 6002 loop_depth_dec(); |
6015 for_in_depth_dec(); | 6003 for_in_depth_dec(); |
6016 return Fragment(instructions.entry, loop_exit); | 6004 return Fragment(instructions.entry, loop_exit); |
6017 } | 6005 } |
6018 | 6006 |
6019 Fragment StreamingFlowGraphBuilder::BuildSwitchStatement() { | 6007 Fragment StreamingFlowGraphBuilder::BuildSwitchStatement() { |
6020 // We need the number of cases. So start by getting that, then go back. | 6008 // We need the number of cases. So start by getting that, then go back. |
6021 intptr_t offset = ReaderOffset(); | 6009 intptr_t offset = ReaderOffset(); |
6022 SkipExpression(); // temporarily skip condition | 6010 SkipExpression(); // temporarily skip condition |
6023 int case_count = ReadListLength(); // read number of cases. | 6011 int case_count = ReadListLength(); // read number of cases. |
6024 SetOffset(offset); | 6012 SetOffset(offset); |
6025 | 6013 |
6026 SwitchBlock block(flow_graph_builder_, case_count); | 6014 SwitchBlock block(flow_graph_builder_, case_count); |
6027 | 6015 |
6028 // Instead of using a variable we should reuse the expression on the stack, | 6016 // Instead of using a variable we should reuse the expression on the stack, |
6029 // since it won't be assigned again, we don't need phi nodes. | 6017 // since it won't be assigned again, we don't need phi nodes. |
6030 Fragment head_instructions = BuildExpression(); // read condition. | 6018 Fragment head_instructions = BuildExpression(); // read condition. |
6031 head_instructions += | 6019 head_instructions += |
6032 StoreLocal(TokenPosition::kNoSource, scopes()->switch_variable); | 6020 StoreLocal(TokenPosition::kNoSource, scopes()->switch_variable); |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6425 | 6413 |
6426 return Fragment(try_body.entry, after_try); | 6414 return Fragment(try_body.entry, after_try); |
6427 } | 6415 } |
6428 | 6416 |
6429 Fragment StreamingFlowGraphBuilder::BuildTryFinally() { | 6417 Fragment StreamingFlowGraphBuilder::BuildTryFinally() { |
6430 // Note on streaming: | 6418 // Note on streaming: |
6431 // We only stream this TryFinally if we can stream everything inside it, | 6419 // We only stream this TryFinally if we can stream everything inside it, |
6432 // so creating a "TryFinallyBlock" with a kernel binary offset instead of an | 6420 // so creating a "TryFinallyBlock" with a kernel binary offset instead of an |
6433 // AST node isn't a problem. | 6421 // AST node isn't a problem. |
6434 | 6422 |
6435 | |
6436 InlineBailout("kernel::FlowgraphBuilder::VisitTryFinally"); | 6423 InlineBailout("kernel::FlowgraphBuilder::VisitTryFinally"); |
6437 | 6424 |
6438 // There are 5 different cases where we need to execute the finally block: | 6425 // There are 5 different cases where we need to execute the finally block: |
6439 // | 6426 // |
6440 // a) 1/2/3th case: Special control flow going out of `node->body()`: | 6427 // a) 1/2/3th case: Special control flow going out of `node->body()`: |
6441 // | 6428 // |
6442 // * [BreakStatement] transfers control to a [LabledStatement] | 6429 // * [BreakStatement] transfers control to a [LabledStatement] |
6443 // * [ContinueSwitchStatement] transfers control to a [SwitchCase] | 6430 // * [ContinueSwitchStatement] transfers control to a [SwitchCase] |
6444 // * [ReturnStatement] returns a value | 6431 // * [ReturnStatement] returns a value |
6445 // | 6432 // |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6577 continuation += BranchIfNull(&no_error, &error); | 6564 continuation += BranchIfNull(&no_error, &error); |
6578 | 6565 |
6579 Fragment rethrow(error); | 6566 Fragment rethrow(error); |
6580 rethrow += LoadLocal(exception_var); | 6567 rethrow += LoadLocal(exception_var); |
6581 rethrow += PushArgument(); | 6568 rethrow += PushArgument(); |
6582 rethrow += LoadLocal(stack_trace_var); | 6569 rethrow += LoadLocal(stack_trace_var); |
6583 rethrow += PushArgument(); | 6570 rethrow += PushArgument(); |
6584 rethrow += RethrowException(position, CatchClauseNode::kInvalidTryIndex); | 6571 rethrow += RethrowException(position, CatchClauseNode::kInvalidTryIndex); |
6585 Drop(); | 6572 Drop(); |
6586 | 6573 |
6587 | |
6588 continuation = Fragment(continuation.entry, no_error); | 6574 continuation = Fragment(continuation.entry, no_error); |
6589 } | 6575 } |
6590 | 6576 |
6591 return continuation; | 6577 return continuation; |
6592 } | 6578 } |
6593 | 6579 |
6594 Fragment StreamingFlowGraphBuilder::BuildVariableDeclaration() { | 6580 Fragment StreamingFlowGraphBuilder::BuildVariableDeclaration() { |
6595 intptr_t kernel_position_no_tag = ReaderOffset(); | 6581 intptr_t kernel_position_no_tag = ReaderOffset(); |
6596 LocalVariable* variable = LookupVariable(kernel_position_no_tag); | 6582 LocalVariable* variable = LookupVariable(kernel_position_no_tag); |
6597 | 6583 |
6598 VariableDeclarationHelper helper(this); | 6584 VariableDeclarationHelper helper(this); |
6599 helper.ReadUntilExcluding(VariableDeclarationHelper::kType); | 6585 helper.ReadUntilExcluding(VariableDeclarationHelper::kType); |
6600 dart::String& name = H.DartSymbol(helper.name_index_); | 6586 dart::String& name = H.DartSymbol(helper.name_index_); |
6601 AbstractType& type = T.BuildType(); // read type. | 6587 AbstractType& type = T.BuildType(); // read type. |
6602 Tag tag = ReadTag(); // read (first part of) initializer. | 6588 Tag tag = ReadTag(); // read (first part of) initializer. |
6603 | 6589 |
6604 Fragment instructions; | 6590 Fragment instructions; |
6605 if (tag == kNothing) { | 6591 if (tag == kNothing) { |
6606 instructions += NullConstant(); | 6592 instructions += NullConstant(); |
6607 } else { | 6593 } else { |
6608 if (helper.IsConst()) { | 6594 if (helper.IsConst()) { |
6609 const Instance& constant_value = constant_evaluator_.EvaluateExpression( | 6595 const Instance& constant_value = constant_evaluator_.EvaluateExpression( |
6610 ReaderOffset()); // read initializer form current position. | 6596 ReaderOffset()); // read initializer form current position. |
6611 variable->SetConstValue(constant_value); | 6597 variable->SetConstValue(constant_value); |
6612 instructions += Constant(constant_value); | 6598 instructions += Constant(constant_value); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6761 TokenPosition::kNoSource, Closure::function_offset()); | 6747 TokenPosition::kNoSource, Closure::function_offset()); |
6762 | 6748 |
6763 instructions += LoadLocal(closure); | 6749 instructions += LoadLocal(closure); |
6764 instructions += LoadLocal(parsed_function()->current_context_var()); | 6750 instructions += LoadLocal(parsed_function()->current_context_var()); |
6765 instructions += flow_graph_builder_->StoreInstanceField( | 6751 instructions += flow_graph_builder_->StoreInstanceField( |
6766 TokenPosition::kNoSource, Closure::context_offset()); | 6752 TokenPosition::kNoSource, Closure::context_offset()); |
6767 | 6753 |
6768 return instructions; | 6754 return instructions; |
6769 } | 6755 } |
6770 | 6756 |
6771 | |
6772 void StreamingFlowGraphBuilder::SetupFunctionParameters( | 6757 void StreamingFlowGraphBuilder::SetupFunctionParameters( |
6773 const dart::Class& klass, | 6758 const dart::Class& klass, |
6774 const dart::Function& function, | 6759 const dart::Function& function, |
6775 bool is_method, | 6760 bool is_method, |
6776 bool is_closure, | 6761 bool is_closure, |
6777 FunctionNodeHelper* function_node_helper) { | 6762 FunctionNodeHelper* function_node_helper) { |
6778 ASSERT(!(is_method && is_closure)); | 6763 ASSERT(!(is_method && is_closure)); |
6779 bool is_factory = function.IsFactory(); | 6764 bool is_factory = function.IsFactory(); |
6780 intptr_t extra_parameters = (is_method || is_closure || is_factory) ? 1 : 0; | 6765 intptr_t extra_parameters = (is_method || is_closure || is_factory) ? 1 : 0; |
6781 | 6766 |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7069 } | 7054 } |
7070 } | 7055 } |
7071 | 7056 |
7072 return Array::Handle(Array::null()); | 7057 return Array::Handle(Array::null()); |
7073 } | 7058 } |
7074 | 7059 |
7075 } // namespace kernel | 7060 } // namespace kernel |
7076 } // namespace dart | 7061 } // namespace dart |
7077 | 7062 |
7078 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 7063 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
OLD | NEW |