| 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 #include "vm/compiler.h" | 6 #include "vm/compiler.h" |
| 7 #include "vm/longjump.h" | 7 #include "vm/longjump.h" |
| 8 #include "vm/object_store.h" | 8 #include "vm/object_store.h" |
| 9 | 9 |
| 10 #if !defined(DART_PRECOMPILED_RUNTIME) | 10 #if !defined(DART_PRECOMPILED_RUNTIME) |
| (...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 intptr_t variable_kernel_offset = | 935 intptr_t variable_kernel_offset = |
| 936 builder_->ReadUInt(); // read kernel position. | 936 builder_->ReadUInt(); // read kernel position. |
| 937 LookupVariable(variable_kernel_offset); | 937 LookupVariable(variable_kernel_offset); |
| 938 VisitExpression(); // read expression. | 938 VisitExpression(); // read expression. |
| 939 return; | 939 return; |
| 940 } | 940 } |
| 941 case kPropertyGet: | 941 case kPropertyGet: |
| 942 builder_->ReadPosition(); // read position. | 942 builder_->ReadPosition(); // read position. |
| 943 VisitExpression(); // read receiver. | 943 VisitExpression(); // read receiver. |
| 944 builder_->SkipName(); // read name. | 944 builder_->SkipName(); // read name. |
| 945 // Read unused "interface_target_reference". | 945 // read interface_target_reference. |
| 946 builder_->SkipCanonicalNameReference(); | 946 builder_->SkipCanonicalNameReference(); |
| 947 return; | 947 return; |
| 948 case kPropertySet: | 948 case kPropertySet: |
| 949 builder_->ReadPosition(); // read position. | 949 builder_->ReadPosition(); // read position. |
| 950 VisitExpression(); // read receiver. | 950 VisitExpression(); // read receiver. |
| 951 builder_->SkipName(); // read name. | 951 builder_->SkipName(); // read name. |
| 952 VisitExpression(); // read value. | 952 VisitExpression(); // read value. |
| 953 // read unused "interface_target_reference". | 953 // read interface_target_reference. |
| 954 builder_->SkipCanonicalNameReference(); | 954 builder_->SkipCanonicalNameReference(); |
| 955 return; | 955 return; |
| 956 case kDirectPropertyGet: | 956 case kDirectPropertyGet: |
| 957 builder_->ReadPosition(); // read position. | 957 builder_->ReadPosition(); // read position. |
| 958 VisitExpression(); // read receiver. | 958 VisitExpression(); // read receiver. |
| 959 builder_->SkipCanonicalNameReference(); // read target_reference. | 959 builder_->SkipCanonicalNameReference(); // read target_reference. |
| 960 return; | 960 return; |
| 961 case kDirectPropertySet: | 961 case kDirectPropertySet: |
| 962 builder_->ReadPosition(); // read position. | 962 builder_->ReadPosition(); // read position. |
| 963 VisitExpression(); // read receiver. | 963 VisitExpression(); // read receiver. |
| 964 builder_->SkipCanonicalNameReference(); // read target_reference. | 964 builder_->SkipCanonicalNameReference(); // read target_reference. |
| 965 VisitExpression(); // read value· | 965 VisitExpression(); // read value· |
| 966 return; | 966 return; |
| 967 case kStaticGet: | 967 case kStaticGet: |
| 968 builder_->ReadPosition(); // read position. | 968 builder_->ReadPosition(); // read position. |
| 969 builder_->SkipCanonicalNameReference(); // read target_reference. | 969 builder_->SkipCanonicalNameReference(); // read target_reference. |
| 970 return; | 970 return; |
| 971 case kStaticSet: | 971 case kStaticSet: |
| 972 builder_->ReadPosition(); // read position. | 972 builder_->ReadPosition(); // read position. |
| 973 builder_->SkipCanonicalNameReference(); // read target_reference. | 973 builder_->SkipCanonicalNameReference(); // read target_reference. |
| 974 VisitExpression(); // read expression. | 974 VisitExpression(); // read expression. |
| 975 return; | 975 return; |
| 976 case kMethodInvocation: | 976 case kMethodInvocation: |
| 977 builder_->ReadPosition(); // read position. | 977 builder_->ReadPosition(); // read position. |
| 978 VisitExpression(); // read receiver. | 978 VisitExpression(); // read receiver. |
| 979 builder_->SkipName(); // read name. | 979 builder_->SkipName(); // read name. |
| 980 VisitArguments(); // read arguments. | 980 VisitArguments(); // read arguments. |
| 981 // read unused "interface_target_reference". | 981 // read interface_target_reference. |
| 982 builder_->SkipCanonicalNameReference(); | 982 builder_->SkipCanonicalNameReference(); |
| 983 return; | 983 return; |
| 984 case kDirectMethodInvocation: | 984 case kDirectMethodInvocation: |
| 985 VisitExpression(); // read receiver. | 985 VisitExpression(); // read receiver. |
| 986 builder_->SkipCanonicalNameReference(); // read target_reference. | 986 builder_->SkipCanonicalNameReference(); // read target_reference. |
| 987 VisitArguments(); // read arguments. | 987 VisitArguments(); // read arguments. |
| 988 return; | 988 return; |
| 989 case kStaticInvocation: | 989 case kStaticInvocation: |
| 990 case kConstStaticInvocation: | 990 case kConstStaticInvocation: |
| 991 builder_->ReadPosition(); // read position. | 991 builder_->ReadPosition(); // read position. |
| (...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2397 LocalVariable* variable = builder_->LookupVariable(variable_kernel_position); | 2397 LocalVariable* variable = builder_->LookupVariable(variable_kernel_position); |
| 2398 ASSERT(variable->IsConst()); | 2398 ASSERT(variable->IsConst()); |
| 2399 result_ = variable->ConstValue()->raw(); | 2399 result_ = variable->ConstValue()->raw(); |
| 2400 } | 2400 } |
| 2401 | 2401 |
| 2402 void StreamingConstantEvaluator::EvaluatePropertyGet() { | 2402 void StreamingConstantEvaluator::EvaluatePropertyGet() { |
| 2403 builder_->ReadPosition(); // read position. | 2403 builder_->ReadPosition(); // read position. |
| 2404 intptr_t expression_offset = builder_->ReaderOffset(); | 2404 intptr_t expression_offset = builder_->ReaderOffset(); |
| 2405 builder_->SkipExpression(); // read receiver. | 2405 builder_->SkipExpression(); // read receiver. |
| 2406 StringIndex name = builder_->ReadNameAsStringIndex(); // read name. | 2406 StringIndex name = builder_->ReadNameAsStringIndex(); // read name. |
| 2407 // Read unused "interface_target_reference". | 2407 builder_->SkipCanonicalNameReference(); // read interface_target_reference. |
| 2408 builder_->SkipCanonicalNameReference(); | |
| 2409 | 2408 |
| 2410 if (H.StringEquals(name, "length")) { | 2409 if (H.StringEquals(name, "length")) { |
| 2411 EvaluateExpression(expression_offset); | 2410 EvaluateExpression(expression_offset); |
| 2412 if (result_.IsString()) { | 2411 if (result_.IsString()) { |
| 2413 const dart::String& str = | 2412 const dart::String& str = |
| 2414 dart::String::Handle(Z, dart::String::RawCast(result_.raw())); | 2413 dart::String::Handle(Z, dart::String::RawCast(result_.raw())); |
| 2415 result_ = Integer::New(str.Length()); | 2414 result_ = Integer::New(str.Length()); |
| 2416 } else { | 2415 } else { |
| 2417 H.ReportError( | 2416 H.ReportError( |
| 2418 "Constant expressions can only call " | 2417 "Constant expressions can only call " |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2484 intptr_t argument_count = builder_->PeekArgumentsCount(); | 2483 intptr_t argument_count = builder_->PeekArgumentsCount(); |
| 2485 // Dart does not support generic methods yet. | 2484 // Dart does not support generic methods yet. |
| 2486 ASSERT(builder_->PeekArgumentsTypeCount() == 0); | 2485 ASSERT(builder_->PeekArgumentsTypeCount() == 0); |
| 2487 builder_->SkipArgumentsBeforeActualArguments(); | 2486 builder_->SkipArgumentsBeforeActualArguments(); |
| 2488 | 2487 |
| 2489 // Run the method and canonicalize the result. | 2488 // Run the method and canonicalize the result. |
| 2490 const Object& result = RunFunction(function, argument_count, &receiver, NULL); | 2489 const Object& result = RunFunction(function, argument_count, &receiver, NULL); |
| 2491 result_ ^= result.raw(); | 2490 result_ ^= result.raw(); |
| 2492 result_ = H.Canonicalize(result_); | 2491 result_ = H.Canonicalize(result_); |
| 2493 | 2492 |
| 2494 builder_->SkipCanonicalNameReference(); // read "interface_target_reference" | 2493 builder_->SkipCanonicalNameReference(); // read interface_target_reference. |
| 2495 } | 2494 } |
| 2496 | 2495 |
| 2497 void StreamingConstantEvaluator::EvaluateStaticInvocation() { | 2496 void StreamingConstantEvaluator::EvaluateStaticInvocation() { |
| 2498 builder_->ReadPosition(); // read position. | 2497 builder_->ReadPosition(); // read position. |
| 2499 NameIndex procedue_reference = | 2498 NameIndex procedue_reference = |
| 2500 builder_->ReadCanonicalNameReference(); // read procedure reference. | 2499 builder_->ReadCanonicalNameReference(); // read procedure reference. |
| 2501 | 2500 |
| 2502 const Function& function = Function::ZoneHandle( | 2501 const Function& function = Function::ZoneHandle( |
| 2503 Z, H.LookupStaticMethodByKernelProcedure(procedue_reference)); | 2502 Z, H.LookupStaticMethodByKernelProcedure(procedue_reference)); |
| 2504 dart::Class& klass = dart::Class::Handle(Z, function.Owner()); | 2503 dart::Class& klass = dart::Class::Handle(Z, function.Owner()); |
| (...skipping 1808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4313 return; | 4312 return; |
| 4314 case kSpecializedVariableSet: | 4313 case kSpecializedVariableSet: |
| 4315 ReadPosition(); // read position. | 4314 ReadPosition(); // read position. |
| 4316 ReadUInt(); // read kernel position. | 4315 ReadUInt(); // read kernel position. |
| 4317 SkipExpression(); // read expression. | 4316 SkipExpression(); // read expression. |
| 4318 return; | 4317 return; |
| 4319 case kPropertyGet: | 4318 case kPropertyGet: |
| 4320 ReadPosition(); // read position. | 4319 ReadPosition(); // read position. |
| 4321 SkipExpression(); // read receiver. | 4320 SkipExpression(); // read receiver. |
| 4322 SkipName(); // read name. | 4321 SkipName(); // read name. |
| 4323 // Read unused "interface_target_reference". | 4322 SkipCanonicalNameReference(); // read interface_target_reference. |
| 4324 SkipCanonicalNameReference(); | |
| 4325 return; | 4323 return; |
| 4326 case kPropertySet: | 4324 case kPropertySet: |
| 4327 ReadPosition(); // read position. | 4325 ReadPosition(); // read position. |
| 4328 SkipExpression(); // read receiver. | 4326 SkipExpression(); // read receiver. |
| 4329 SkipName(); // read name. | 4327 SkipName(); // read name. |
| 4330 SkipExpression(); // read value. | 4328 SkipExpression(); // read value. |
| 4331 // read unused "interface_target_reference". | 4329 SkipCanonicalNameReference(); // read interface_target_reference. |
| 4332 SkipCanonicalNameReference(); | |
| 4333 return; | 4330 return; |
| 4334 case kDirectPropertyGet: | 4331 case kDirectPropertyGet: |
| 4335 ReadPosition(); // read position. | 4332 ReadPosition(); // read position. |
| 4336 SkipExpression(); // read receiver. | 4333 SkipExpression(); // read receiver. |
| 4337 SkipCanonicalNameReference(); // read target_reference. | 4334 SkipCanonicalNameReference(); // read target_reference. |
| 4338 return; | 4335 return; |
| 4339 case kDirectPropertySet: | 4336 case kDirectPropertySet: |
| 4340 ReadPosition(); // read position. | 4337 ReadPosition(); // read position. |
| 4341 SkipExpression(); // read receiver. | 4338 SkipExpression(); // read receiver. |
| 4342 SkipCanonicalNameReference(); // read target_reference. | 4339 SkipCanonicalNameReference(); // read target_reference. |
| 4343 SkipExpression(); // read value· | 4340 SkipExpression(); // read value· |
| 4344 return; | 4341 return; |
| 4345 case kStaticGet: | 4342 case kStaticGet: |
| 4346 ReadPosition(); // read position. | 4343 ReadPosition(); // read position. |
| 4347 SkipCanonicalNameReference(); // read target_reference. | 4344 SkipCanonicalNameReference(); // read target_reference. |
| 4348 return; | 4345 return; |
| 4349 case kStaticSet: | 4346 case kStaticSet: |
| 4350 ReadPosition(); // read position. | 4347 ReadPosition(); // read position. |
| 4351 SkipCanonicalNameReference(); // read target_reference. | 4348 SkipCanonicalNameReference(); // read target_reference. |
| 4352 SkipExpression(); // read expression. | 4349 SkipExpression(); // read expression. |
| 4353 return; | 4350 return; |
| 4354 case kMethodInvocation: | 4351 case kMethodInvocation: |
| 4355 ReadPosition(); // read position. | 4352 ReadPosition(); // read position. |
| 4356 SkipExpression(); // read receiver. | 4353 SkipExpression(); // read receiver. |
| 4357 SkipName(); // read name. | 4354 SkipName(); // read name. |
| 4358 SkipArguments(); // read arguments. | 4355 SkipArguments(); // read arguments. |
| 4359 // read unused "interface_target_reference". | 4356 SkipCanonicalNameReference(); // read interface_target_reference. |
| 4360 SkipCanonicalNameReference(); | |
| 4361 return; | 4357 return; |
| 4362 case kDirectMethodInvocation: | 4358 case kDirectMethodInvocation: |
| 4363 SkipExpression(); // read receiver. | 4359 SkipExpression(); // read receiver. |
| 4364 SkipCanonicalNameReference(); // read target_reference. | 4360 SkipCanonicalNameReference(); // read target_reference. |
| 4365 SkipArguments(); // read arguments. | 4361 SkipArguments(); // read arguments. |
| 4366 return; | 4362 return; |
| 4367 case kStaticInvocation: | 4363 case kStaticInvocation: |
| 4368 case kConstStaticInvocation: | 4364 case kConstStaticInvocation: |
| 4369 ReadPosition(); // read position. | 4365 ReadPosition(); // read position. |
| 4370 SkipCanonicalNameReference(); // read procedure_reference. | 4366 SkipCanonicalNameReference(); // read procedure_reference. |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4957 return flow_graph_builder_->StaticCall(position, target, argument_count, | 4953 return flow_graph_builder_->StaticCall(position, target, argument_count, |
| 4958 argument_names, type_args_count); | 4954 argument_names, type_args_count); |
| 4959 } | 4955 } |
| 4960 | 4956 |
| 4961 Fragment StreamingFlowGraphBuilder::InstanceCall( | 4957 Fragment StreamingFlowGraphBuilder::InstanceCall( |
| 4962 TokenPosition position, | 4958 TokenPosition position, |
| 4963 const dart::String& name, | 4959 const dart::String& name, |
| 4964 Token::Kind kind, | 4960 Token::Kind kind, |
| 4965 intptr_t argument_count, | 4961 intptr_t argument_count, |
| 4966 intptr_t checked_argument_count) { | 4962 intptr_t checked_argument_count) { |
| 4967 return flow_graph_builder_->InstanceCall(position, name, kind, argument_count, | 4963 const intptr_t kTypeArgsLen = 0; |
| 4968 checked_argument_count); | 4964 return flow_graph_builder_->InstanceCall( |
| 4965 position, name, kind, kTypeArgsLen, argument_count, Array::null_array(), |
| 4966 checked_argument_count, Function::null_function()); |
| 4967 } |
| 4968 |
| 4969 Fragment StreamingFlowGraphBuilder::InstanceCall( |
| 4970 TokenPosition position, |
| 4971 const dart::String& name, |
| 4972 Token::Kind kind, |
| 4973 intptr_t type_args_len, |
| 4974 intptr_t argument_count, |
| 4975 const Array& argument_names, |
| 4976 intptr_t checked_argument_count, |
| 4977 const Function& interface_target) { |
| 4978 return flow_graph_builder_->InstanceCall( |
| 4979 position, name, kind, type_args_len, argument_count, argument_names, |
| 4980 checked_argument_count, interface_target); |
| 4969 } | 4981 } |
| 4970 | 4982 |
| 4971 Fragment StreamingFlowGraphBuilder::ThrowException(TokenPosition position) { | 4983 Fragment StreamingFlowGraphBuilder::ThrowException(TokenPosition position) { |
| 4972 return flow_graph_builder_->ThrowException(position); | 4984 return flow_graph_builder_->ThrowException(position); |
| 4973 } | 4985 } |
| 4974 | 4986 |
| 4975 Fragment StreamingFlowGraphBuilder::BooleanNegate() { | 4987 Fragment StreamingFlowGraphBuilder::BooleanNegate() { |
| 4976 return flow_graph_builder_->BooleanNegate(); | 4988 return flow_graph_builder_->BooleanNegate(); |
| 4977 } | 4989 } |
| 4978 | 4990 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 5000 } | 5012 } |
| 5001 | 5013 |
| 5002 Fragment StreamingFlowGraphBuilder::AllocateContext(intptr_t size) { | 5014 Fragment StreamingFlowGraphBuilder::AllocateContext(intptr_t size) { |
| 5003 return flow_graph_builder_->AllocateContext(size); | 5015 return flow_graph_builder_->AllocateContext(size); |
| 5004 } | 5016 } |
| 5005 | 5017 |
| 5006 Fragment StreamingFlowGraphBuilder::LoadField(intptr_t offset) { | 5018 Fragment StreamingFlowGraphBuilder::LoadField(intptr_t offset) { |
| 5007 return flow_graph_builder_->LoadField(offset); | 5019 return flow_graph_builder_->LoadField(offset); |
| 5008 } | 5020 } |
| 5009 | 5021 |
| 5010 Fragment StreamingFlowGraphBuilder::InstanceCall( | |
| 5011 TokenPosition position, | |
| 5012 const dart::String& name, | |
| 5013 Token::Kind kind, | |
| 5014 intptr_t type_args_len, | |
| 5015 intptr_t argument_count, | |
| 5016 const Array& argument_names, | |
| 5017 intptr_t checked_argument_count) { | |
| 5018 return flow_graph_builder_->InstanceCall(position, name, kind, type_args_len, | |
| 5019 argument_count, argument_names, | |
| 5020 checked_argument_count); | |
| 5021 } | |
| 5022 | |
| 5023 Fragment StreamingFlowGraphBuilder::StoreLocal(TokenPosition position, | 5022 Fragment StreamingFlowGraphBuilder::StoreLocal(TokenPosition position, |
| 5024 LocalVariable* variable) { | 5023 LocalVariable* variable) { |
| 5025 return flow_graph_builder_->StoreLocal(position, variable); | 5024 return flow_graph_builder_->StoreLocal(position, variable); |
| 5026 } | 5025 } |
| 5027 | 5026 |
| 5028 Fragment StreamingFlowGraphBuilder::StoreStaticField(TokenPosition position, | 5027 Fragment StreamingFlowGraphBuilder::StoreStaticField(TokenPosition position, |
| 5029 const dart::Field& field) { | 5028 const dart::Field& field) { |
| 5030 return flow_graph_builder_->StoreStaticField(position, field); | 5029 return flow_graph_builder_->StoreStaticField(position, field); |
| 5031 } | 5030 } |
| 5032 | 5031 |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5308 } | 5307 } |
| 5309 | 5308 |
| 5310 Fragment StreamingFlowGraphBuilder::BuildPropertyGet(TokenPosition* p) { | 5309 Fragment StreamingFlowGraphBuilder::BuildPropertyGet(TokenPosition* p) { |
| 5311 TokenPosition position = ReadPosition(); // read position. | 5310 TokenPosition position = ReadPosition(); // read position. |
| 5312 if (p != NULL) *p = position; | 5311 if (p != NULL) *p = position; |
| 5313 | 5312 |
| 5314 Fragment instructions = BuildExpression(); // read receiver. | 5313 Fragment instructions = BuildExpression(); // read receiver. |
| 5315 instructions += PushArgument(); | 5314 instructions += PushArgument(); |
| 5316 | 5315 |
| 5317 const dart::String& getter_name = ReadNameAsGetterName(); // read name. | 5316 const dart::String& getter_name = ReadNameAsGetterName(); // read name. |
| 5318 SkipCanonicalNameReference(); // Read unused "interface_target_reference". | |
| 5319 | 5317 |
| 5320 return instructions + InstanceCall(position, getter_name, Token::kGET, 1); | 5318 const Function* interface_target = &Function::null_function(); |
| 5319 NameIndex itarget_name = |
| 5320 ReadCanonicalNameReference(); // read interface_target_reference. |
| 5321 if (FLAG_experimental_strong_mode && !H.IsRoot(itarget_name) && |
| 5322 (H.IsGetter(itarget_name) || H.IsField(itarget_name))) { |
| 5323 interface_target = &Function::ZoneHandle( |
| 5324 Z, LookupMethodByMember(itarget_name, H.DartGetterName(itarget_name))); |
| 5325 } |
| 5326 |
| 5327 const intptr_t kTypeArgsLen = 0; |
| 5328 const intptr_t kNumArgsChecked = 1; |
| 5329 return instructions + InstanceCall(position, getter_name, Token::kGET, |
| 5330 kTypeArgsLen, 1, Array::null_array(), |
| 5331 kNumArgsChecked, *interface_target); |
| 5321 } | 5332 } |
| 5322 | 5333 |
| 5323 Fragment StreamingFlowGraphBuilder::BuildPropertySet(TokenPosition* p) { | 5334 Fragment StreamingFlowGraphBuilder::BuildPropertySet(TokenPosition* p) { |
| 5324 Fragment instructions(NullConstant()); | 5335 Fragment instructions(NullConstant()); |
| 5325 LocalVariable* variable = MakeTemporary(); | 5336 LocalVariable* variable = MakeTemporary(); |
| 5326 | 5337 |
| 5327 TokenPosition position = ReadPosition(); // read position. | 5338 TokenPosition position = ReadPosition(); // read position. |
| 5328 if (p != NULL) *p = position; | 5339 if (p != NULL) *p = position; |
| 5329 | 5340 |
| 5330 instructions += BuildExpression(); // read receiver. | 5341 instructions += BuildExpression(); // read receiver. |
| 5331 instructions += PushArgument(); | 5342 instructions += PushArgument(); |
| 5332 | 5343 |
| 5333 const dart::String& setter_name = ReadNameAsSetterName(); // read name. | 5344 const dart::String& setter_name = ReadNameAsSetterName(); // read name. |
| 5334 | 5345 |
| 5335 instructions += BuildExpression(); // read value. | 5346 instructions += BuildExpression(); // read value. |
| 5336 instructions += StoreLocal(TokenPosition::kNoSource, variable); | 5347 instructions += StoreLocal(TokenPosition::kNoSource, variable); |
| 5337 instructions += PushArgument(); | 5348 instructions += PushArgument(); |
| 5338 | 5349 |
| 5339 SkipCanonicalNameReference(); // read unused "interface_target_reference". | 5350 const Function* interface_target = &Function::null_function(); |
| 5351 NameIndex itarget_name = |
| 5352 ReadCanonicalNameReference(); // read interface_target_reference. |
| 5353 if (FLAG_experimental_strong_mode && !H.IsRoot(itarget_name)) { |
| 5354 interface_target = &Function::ZoneHandle( |
| 5355 Z, LookupMethodByMember(itarget_name, H.DartSetterName(itarget_name))); |
| 5356 } |
| 5340 | 5357 |
| 5341 instructions += InstanceCall(position, setter_name, Token::kSET, 2); | 5358 const intptr_t kTypeArgsLen = 0; |
| 5359 const intptr_t kNumArgsChecked = 1; |
| 5360 instructions += |
| 5361 InstanceCall(position, setter_name, Token::kSET, kTypeArgsLen, 2, |
| 5362 Array::null_array(), kNumArgsChecked, *interface_target); |
| 5363 |
| 5342 return instructions + Drop(); | 5364 return instructions + Drop(); |
| 5343 } | 5365 } |
| 5344 | 5366 |
| 5345 Fragment StreamingFlowGraphBuilder::BuildDirectPropertyGet(TokenPosition* p) { | 5367 Fragment StreamingFlowGraphBuilder::BuildDirectPropertyGet(TokenPosition* p) { |
| 5346 TokenPosition position = ReadPosition(); // read position. | 5368 TokenPosition position = ReadPosition(); // read position. |
| 5347 if (p != NULL) *p = position; | 5369 if (p != NULL) *p = position; |
| 5348 | 5370 |
| 5349 Fragment instructions = BuildExpression(); // read receiver. | 5371 Fragment instructions = BuildExpression(); // read receiver. |
| 5350 NameIndex kernel_name = | 5372 NameIndex kernel_name = |
| 5351 ReadCanonicalNameReference(); // read target_reference. | 5373 ReadCanonicalNameReference(); // read target_reference. |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5497 | 5519 |
| 5498 SkipExpression(); // read receiver (it's just a number literal). | 5520 SkipExpression(); // read receiver (it's just a number literal). |
| 5499 | 5521 |
| 5500 const dart::String& name = ReadNameAsMethodName(); // read name. | 5522 const dart::String& name = ReadNameAsMethodName(); // read name. |
| 5501 const Token::Kind token_kind = MethodKind(name); | 5523 const Token::Kind token_kind = MethodKind(name); |
| 5502 intptr_t argument_count = PeekArgumentsCount() + 1; | 5524 intptr_t argument_count = PeekArgumentsCount() + 1; |
| 5503 | 5525 |
| 5504 if ((argument_count == 1) && (token_kind == Token::kNEGATE)) { | 5526 if ((argument_count == 1) && (token_kind == Token::kNEGATE)) { |
| 5505 const Object& result = constant_evaluator_.EvaluateExpressionSafe(offset); | 5527 const Object& result = constant_evaluator_.EvaluateExpressionSafe(offset); |
| 5506 if (!result.IsError()) { | 5528 if (!result.IsError()) { |
| 5507 SkipArguments(); // read arguments, | 5529 SkipArguments(); // read arguments. |
| 5508 // read unused "interface_target_reference". | 5530 SkipCanonicalNameReference(); // read interface_target_reference. |
| 5509 SkipCanonicalNameReference(); | |
| 5510 return Constant(result); | 5531 return Constant(result); |
| 5511 } | 5532 } |
| 5512 } else if ((argument_count == 2) && | 5533 } else if ((argument_count == 2) && |
| 5513 Token::IsBinaryArithmeticOperator(token_kind) && | 5534 Token::IsBinaryArithmeticOperator(token_kind) && |
| 5514 IsNumberLiteral(PeekArgumentsFirstPositionalTag())) { | 5535 IsNumberLiteral(PeekArgumentsFirstPositionalTag())) { |
| 5515 const Object& result = constant_evaluator_.EvaluateExpressionSafe(offset); | 5536 const Object& result = constant_evaluator_.EvaluateExpressionSafe(offset); |
| 5516 if (!result.IsError()) { | 5537 if (!result.IsError()) { |
| 5517 SkipArguments(); | 5538 SkipArguments(); // read arguments. |
| 5518 // read unused "interface_target_reference". | 5539 SkipCanonicalNameReference(); // read interface_target_reference. |
| 5519 SkipCanonicalNameReference(); | |
| 5520 return Constant(result); | 5540 return Constant(result); |
| 5521 } | 5541 } |
| 5522 } | 5542 } |
| 5523 | 5543 |
| 5524 SetOffset(before_branch_offset); | 5544 SetOffset(before_branch_offset); |
| 5525 } | 5545 } |
| 5526 | 5546 |
| 5527 Fragment instructions = BuildExpression(); // read receiver. | 5547 Fragment instructions = BuildExpression(); // read receiver. |
| 5528 | 5548 |
| 5529 const dart::String& name = ReadNameAsMethodName(); // read name. | 5549 const dart::String& name = ReadNameAsMethodName(); // read name. |
| 5530 const Token::Kind token_kind = MethodKind(name); | 5550 const Token::Kind token_kind = MethodKind(name); |
| 5531 | 5551 |
| 5532 // Detect comparison with null. | 5552 // Detect comparison with null. |
| 5533 if ((token_kind == Token::kEQ || token_kind == Token::kNE) && | 5553 if ((token_kind == Token::kEQ || token_kind == Token::kNE) && |
| 5534 PeekArgumentsCount() == 1 && | 5554 PeekArgumentsCount() == 1 && |
| 5535 (receiver_tag == kNullLiteral || | 5555 (receiver_tag == kNullLiteral || |
| 5536 PeekArgumentsFirstPositionalTag() == kNullLiteral)) { | 5556 PeekArgumentsFirstPositionalTag() == kNullLiteral)) { |
| 5537 // "==" or "!=" with null on either side. | 5557 // "==" or "!=" with null on either side. |
| 5538 instructions += BuildArguments(NULL, NULL, true); // read arguments. | 5558 instructions += BuildArguments(NULL, NULL, true); // read arguments. |
| 5539 SkipCanonicalNameReference(); // read unused "interface_target_reference". | 5559 SkipCanonicalNameReference(); // read interface_target_reference. |
| 5540 Token::Kind strict_cmp_kind = | 5560 Token::Kind strict_cmp_kind = |
| 5541 token_kind == Token::kEQ ? Token::kEQ_STRICT : Token::kNE_STRICT; | 5561 token_kind == Token::kEQ ? Token::kEQ_STRICT : Token::kNE_STRICT; |
| 5542 return instructions + | 5562 return instructions + |
| 5543 StrictCompare(strict_cmp_kind, /*number_check = */ true); | 5563 StrictCompare(strict_cmp_kind, /*number_check = */ true); |
| 5544 } | 5564 } |
| 5545 | 5565 |
| 5546 instructions += PushArgument(); // push receiver as argument. | 5566 instructions += PushArgument(); // push receiver as argument. |
| 5547 | 5567 |
| 5548 // TODO(28109) Support generic methods in the VM or reify them away. | 5568 // TODO(28109) Support generic methods in the VM or reify them away. |
| 5549 const intptr_t kTypeArgsLen = 0; | 5569 const intptr_t kTypeArgsLen = 0; |
| 5550 Array& argument_names = Array::ZoneHandle(Z); | 5570 Array& argument_names = Array::ZoneHandle(Z); |
| 5551 intptr_t argument_count; | 5571 intptr_t argument_count; |
| 5552 instructions += | 5572 instructions += |
| 5553 BuildArguments(&argument_names, &argument_count); // read arguments. | 5573 BuildArguments(&argument_names, &argument_count); // read arguments. |
| 5554 ++argument_count; | 5574 ++argument_count; |
| 5555 | 5575 |
| 5556 intptr_t checked_argument_count = 1; | 5576 intptr_t checked_argument_count = 1; |
| 5557 // If we have a special operation (e.g. +/-/==) we mark both arguments as | 5577 // If we have a special operation (e.g. +/-/==) we mark both arguments as |
| 5558 // to be checked. | 5578 // to be checked. |
| 5559 if (token_kind != Token::kILLEGAL) { | 5579 if (token_kind != Token::kILLEGAL) { |
| 5560 ASSERT(argument_count <= 2); | 5580 ASSERT(argument_count <= 2); |
| 5561 checked_argument_count = argument_count; | 5581 checked_argument_count = argument_count; |
| 5562 } | 5582 } |
| 5563 | 5583 |
| 5584 const Function* interface_target = &Function::null_function(); |
| 5585 NameIndex itarget_name = |
| 5586 ReadCanonicalNameReference(); // read interface_target_reference. |
| 5587 if (FLAG_experimental_strong_mode && !H.IsRoot(itarget_name)) { |
| 5588 interface_target = &Function::ZoneHandle( |
| 5589 Z, |
| 5590 LookupMethodByMember(itarget_name, H.DartProcedureName(itarget_name))); |
| 5591 } |
| 5592 |
| 5564 instructions += | 5593 instructions += |
| 5565 InstanceCall(position, name, token_kind, kTypeArgsLen, argument_count, | 5594 InstanceCall(position, name, token_kind, kTypeArgsLen, argument_count, |
| 5566 argument_names, checked_argument_count); | 5595 argument_names, checked_argument_count, *interface_target); |
| 5567 // Later optimization passes assume that result of a x.[]=(...) call is not | 5596 // Later optimization passes assume that result of a x.[]=(...) call is not |
| 5568 // used. We must guarantee this invariant because violation will lead to an | 5597 // used. We must guarantee this invariant because violation will lead to an |
| 5569 // illegal IL once we replace x.[]=(...) with a sequence that does not | 5598 // illegal IL once we replace x.[]=(...) with a sequence that does not |
| 5570 // actually produce any value. See http://dartbug.com/29135 for more details. | 5599 // actually produce any value. See http://dartbug.com/29135 for more details. |
| 5571 if (name.raw() == Symbols::AssignIndexToken().raw()) { | 5600 if (name.raw() == Symbols::AssignIndexToken().raw()) { |
| 5572 instructions += Drop(); | 5601 instructions += Drop(); |
| 5573 instructions += NullConstant(); | 5602 instructions += NullConstant(); |
| 5574 } | 5603 } |
| 5575 | 5604 |
| 5576 SkipCanonicalNameReference(); // read unused "interface_target_reference". | |
| 5577 | |
| 5578 return instructions; | 5605 return instructions; |
| 5579 } | 5606 } |
| 5580 | 5607 |
| 5581 Fragment StreamingFlowGraphBuilder::BuildDirectMethodInvocation( | 5608 Fragment StreamingFlowGraphBuilder::BuildDirectMethodInvocation( |
| 5582 TokenPosition* position) { | 5609 TokenPosition* position) { |
| 5583 if (position != NULL) *position = TokenPosition::kNoSource; | 5610 if (position != NULL) *position = TokenPosition::kNoSource; |
| 5584 | 5611 |
| 5585 // TODO(28109) Support generic methods in the VM or reify them away. | 5612 // TODO(28109) Support generic methods in the VM or reify them away. |
| 5586 Tag receiver_tag = PeekTag(); // peek tag for receiver. | 5613 Tag receiver_tag = PeekTag(); // peek tag for receiver. |
| 5587 Fragment instructions = BuildExpression(); // read receiver. | 5614 Fragment instructions = BuildExpression(); // read receiver. |
| (...skipping 2192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7780 } | 7807 } |
| 7781 } | 7808 } |
| 7782 | 7809 |
| 7783 return Array::Handle(Array::null()); | 7810 return Array::Handle(Array::null()); |
| 7784 } | 7811 } |
| 7785 | 7812 |
| 7786 } // namespace kernel | 7813 } // namespace kernel |
| 7787 } // namespace dart | 7814 } // namespace dart |
| 7788 | 7815 |
| 7789 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 7816 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| OLD | NEW |