| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/intermediate_language.h" | 5 #include "vm/intermediate_language.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/bootstrap.h" | 8 #include "vm/bootstrap.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/constant_propagator.h" | 10 #include "vm/constant_propagator.h" |
| (...skipping 3158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3169 } | 3169 } |
| 3170 } | 3170 } |
| 3171 #endif | 3171 #endif |
| 3172 | 3172 |
| 3173 | 3173 |
| 3174 void InstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 3174 void InstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 3175 Zone* zone = compiler->zone(); | 3175 Zone* zone = compiler->zone(); |
| 3176 const ICData* call_ic_data = NULL; | 3176 const ICData* call_ic_data = NULL; |
| 3177 if (!FLAG_propagate_ic_data || !compiler->is_optimizing() || | 3177 if (!FLAG_propagate_ic_data || !compiler->is_optimizing() || |
| 3178 (ic_data() == NULL)) { | 3178 (ic_data() == NULL)) { |
| 3179 const Array& arguments_descriptor = Array::Handle( | 3179 const Array& arguments_descriptor = |
| 3180 zone, ArgumentsDescriptor::New(ArgumentCount(), argument_names())); | 3180 Array::Handle(zone, ArgumentsDescriptor::New( |
| 3181 type_args_len(), |
| 3182 ArgumentCount() - (type_args_len() > 0 ? 1 : 0), |
| 3183 argument_names())); |
| 3181 call_ic_data = compiler->GetOrAddInstanceCallICData( | 3184 call_ic_data = compiler->GetOrAddInstanceCallICData( |
| 3182 deopt_id(), function_name(), arguments_descriptor, | 3185 deopt_id(), function_name(), arguments_descriptor, |
| 3183 checked_argument_count()); | 3186 checked_argument_count()); |
| 3184 } else { | 3187 } else { |
| 3185 call_ic_data = &ICData::ZoneHandle(zone, ic_data()->raw()); | 3188 call_ic_data = &ICData::ZoneHandle(zone, ic_data()->raw()); |
| 3186 } | 3189 } |
| 3187 | 3190 |
| 3188 #if !defined(TARGET_ARCH_DBC) | 3191 #if !defined(TARGET_ARCH_DBC) |
| 3189 if (compiler->is_optimizing() && HasICData()) { | 3192 if (compiler->is_optimizing() && HasICData()) { |
| 3190 ASSERT(HasICData()); | 3193 ASSERT(HasICData()); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3341 } | 3344 } |
| 3342 | 3345 |
| 3343 | 3346 |
| 3344 // DBC does not support optimizing compiler and thus doesn't emit | 3347 // DBC does not support optimizing compiler and thus doesn't emit |
| 3345 // PolymorphicInstanceCallInstr. | 3348 // PolymorphicInstanceCallInstr. |
| 3346 #if !defined(TARGET_ARCH_DBC) | 3349 #if !defined(TARGET_ARCH_DBC) |
| 3347 void PolymorphicInstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 3350 void PolymorphicInstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 3348 if (!with_checks()) { | 3351 if (!with_checks()) { |
| 3349 ASSERT(targets().HasSingleTarget()); | 3352 ASSERT(targets().HasSingleTarget()); |
| 3350 const Function& target = targets().FirstTarget(); | 3353 const Function& target = targets().FirstTarget(); |
| 3351 compiler->GenerateStaticCall(deopt_id(), instance_call()->token_pos(), | 3354 compiler->GenerateStaticCall( |
| 3352 target, instance_call()->ArgumentCount(), | 3355 deopt_id(), instance_call()->token_pos(), target, |
| 3353 instance_call()->argument_names(), locs(), | 3356 instance_call()->type_args_len(), instance_call()->ArgumentCount(), |
| 3354 ICData::Handle()); | 3357 instance_call()->argument_names(), locs(), ICData::Handle()); |
| 3355 return; | 3358 return; |
| 3356 } | 3359 } |
| 3357 | 3360 |
| 3358 compiler->EmitPolymorphicInstanceCall( | 3361 compiler->EmitPolymorphicInstanceCall( |
| 3359 targets_, *instance_call(), instance_call()->ArgumentCount(), | 3362 targets_, *instance_call(), instance_call()->type_args_len(), |
| 3360 instance_call()->argument_names(), deopt_id(), | 3363 instance_call()->ArgumentCount(), instance_call()->argument_names(), |
| 3361 instance_call()->token_pos(), locs(), complete(), total_call_count()); | 3364 deopt_id(), instance_call()->token_pos(), locs(), complete(), |
| 3365 total_call_count()); |
| 3362 } | 3366 } |
| 3363 #endif | 3367 #endif |
| 3364 | 3368 |
| 3365 | 3369 |
| 3366 RawType* PolymorphicInstanceCallInstr::ComputeRuntimeType( | 3370 RawType* PolymorphicInstanceCallInstr::ComputeRuntimeType( |
| 3367 const CallTargets& targets) { | 3371 const CallTargets& targets) { |
| 3368 bool is_string = true; | 3372 bool is_string = true; |
| 3369 bool is_integer = true; | 3373 bool is_integer = true; |
| 3370 bool is_double = true; | 3374 bool is_double = true; |
| 3371 | 3375 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3468 LocationSummary* StaticCallInstr::MakeLocationSummary(Zone* zone, | 3472 LocationSummary* StaticCallInstr::MakeLocationSummary(Zone* zone, |
| 3469 bool optimizing) const { | 3473 bool optimizing) const { |
| 3470 return MakeCallSummary(zone); | 3474 return MakeCallSummary(zone); |
| 3471 } | 3475 } |
| 3472 | 3476 |
| 3473 | 3477 |
| 3474 void StaticCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 3478 void StaticCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 3475 const ICData* call_ic_data = NULL; | 3479 const ICData* call_ic_data = NULL; |
| 3476 if (!FLAG_propagate_ic_data || !compiler->is_optimizing() || | 3480 if (!FLAG_propagate_ic_data || !compiler->is_optimizing() || |
| 3477 (ic_data() == NULL)) { | 3481 (ic_data() == NULL)) { |
| 3478 const Array& arguments_descriptor = Array::Handle( | 3482 const Array& arguments_descriptor = Array::Handle(ArgumentsDescriptor::New( |
| 3479 ArgumentsDescriptor::New(ArgumentCount(), argument_names())); | 3483 type_args_len(), ArgumentCount() - (type_args_len() > 0 ? 1 : 0), |
| 3484 argument_names())); |
| 3480 MethodRecognizer::Kind recognized_kind = | 3485 MethodRecognizer::Kind recognized_kind = |
| 3481 MethodRecognizer::RecognizeKind(function()); | 3486 MethodRecognizer::RecognizeKind(function()); |
| 3482 int num_args_checked = 0; | 3487 int num_args_checked = 0; |
| 3483 switch (recognized_kind) { | 3488 switch (recognized_kind) { |
| 3484 case MethodRecognizer::kDoubleFromInteger: | 3489 case MethodRecognizer::kDoubleFromInteger: |
| 3485 case MethodRecognizer::kMathMin: | 3490 case MethodRecognizer::kMathMin: |
| 3486 case MethodRecognizer::kMathMax: | 3491 case MethodRecognizer::kMathMax: |
| 3487 num_args_checked = 2; | 3492 num_args_checked = 2; |
| 3488 break; | 3493 break; |
| 3489 default: | 3494 default: |
| 3490 break; | 3495 break; |
| 3491 } | 3496 } |
| 3492 call_ic_data = compiler->GetOrAddStaticCallICData( | 3497 call_ic_data = compiler->GetOrAddStaticCallICData( |
| 3493 deopt_id(), function(), arguments_descriptor, num_args_checked); | 3498 deopt_id(), function(), arguments_descriptor, num_args_checked); |
| 3494 } else { | 3499 } else { |
| 3495 call_ic_data = &ICData::ZoneHandle(ic_data()->raw()); | 3500 call_ic_data = &ICData::ZoneHandle(ic_data()->raw()); |
| 3496 } | 3501 } |
| 3497 | 3502 |
| 3498 #if !defined(TARGET_ARCH_DBC) | 3503 #if !defined(TARGET_ARCH_DBC) |
| 3499 compiler->GenerateStaticCall(deopt_id(), token_pos(), function(), | 3504 compiler->GenerateStaticCall(deopt_id(), token_pos(), function(), |
| 3500 ArgumentCount(), argument_names(), locs(), | 3505 type_args_len(), ArgumentCount(), |
| 3501 *call_ic_data); | 3506 argument_names(), locs(), *call_ic_data); |
| 3502 #else | 3507 #else |
| 3503 const Array& arguments_descriptor = | 3508 const Array& arguments_descriptor = |
| 3504 (ic_data() == NULL) ? Array::Handle(ArgumentsDescriptor::New( | 3509 (ic_data() == NULL) ? Array::Handle(ArgumentsDescriptor::New( |
| 3505 ArgumentCount(), argument_names())) | 3510 type_args_len(), |
| 3511 ArgumentCount() - (type_args_len() > 0 ? 1 : 0), |
| 3512 argument_names())) |
| 3506 : Array::Handle(ic_data()->arguments_descriptor()); | 3513 : Array::Handle(ic_data()->arguments_descriptor()); |
| 3507 const intptr_t argdesc_kidx = __ AddConstant(arguments_descriptor); | 3514 const intptr_t argdesc_kidx = __ AddConstant(arguments_descriptor); |
| 3508 | 3515 |
| 3509 compiler->AddCurrentDescriptor(RawPcDescriptors::kRewind, deopt_id(), | 3516 compiler->AddCurrentDescriptor(RawPcDescriptors::kRewind, deopt_id(), |
| 3510 token_pos()); | 3517 token_pos()); |
| 3511 if (compiler->is_optimizing()) { | 3518 if (compiler->is_optimizing()) { |
| 3512 __ PushConstant(function()); | 3519 __ PushConstant(function()); |
| 3513 __ StaticCall(ArgumentCount(), argdesc_kidx); | 3520 __ StaticCall(ArgumentCount(), argdesc_kidx); |
| 3514 compiler->AddCurrentDescriptor(RawPcDescriptors::kOther, deopt_id(), | 3521 compiler->AddCurrentDescriptor(RawPcDescriptors::kOther, deopt_id(), |
| 3515 token_pos()); | 3522 token_pos()); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3776 return Array::length_offset(); | 3783 return Array::length_offset(); |
| 3777 default: | 3784 default: |
| 3778 UNREACHABLE(); | 3785 UNREACHABLE(); |
| 3779 return -1; | 3786 return -1; |
| 3780 } | 3787 } |
| 3781 } | 3788 } |
| 3782 | 3789 |
| 3783 | 3790 |
| 3784 const Function& StringInterpolateInstr::CallFunction() const { | 3791 const Function& StringInterpolateInstr::CallFunction() const { |
| 3785 if (function_.IsNull()) { | 3792 if (function_.IsNull()) { |
| 3793 const int kTypeArgsLen = 0; |
| 3786 const int kNumberOfArguments = 1; | 3794 const int kNumberOfArguments = 1; |
| 3787 const Array& kNoArgumentNames = Object::null_array(); | 3795 const Array& kNoArgumentNames = Object::null_array(); |
| 3788 const Class& cls = | 3796 const Class& cls = |
| 3789 Class::Handle(Library::LookupCoreClass(Symbols::StringBase())); | 3797 Class::Handle(Library::LookupCoreClass(Symbols::StringBase())); |
| 3790 ASSERT(!cls.IsNull()); | 3798 ASSERT(!cls.IsNull()); |
| 3791 function_ = Resolver::ResolveStatic( | 3799 function_ = Resolver::ResolveStatic( |
| 3792 cls, Library::PrivateCoreLibName(Symbols::Interpolate()), | 3800 cls, Library::PrivateCoreLibName(Symbols::Interpolate()), kTypeArgsLen, |
| 3793 kNumberOfArguments, kNoArgumentNames); | 3801 kNumberOfArguments, kNoArgumentNames); |
| 3794 } | 3802 } |
| 3795 ASSERT(!function_.IsNull()); | 3803 ASSERT(!function_.IsNull()); |
| 3796 return function_; | 3804 return function_; |
| 3797 } | 3805 } |
| 3798 | 3806 |
| 3799 | 3807 |
| 3800 // Replace StringInterpolateInstr with a constant string if all inputs are | 3808 // Replace StringInterpolateInstr with a constant string if all inputs are |
| 3801 // constant of [string, number, boolean, null]. | 3809 // constant of [string, number, boolean, null]. |
| 3802 // Leave the CreateArrayInstr and StoreIndexedInstr in the stream in case | 3810 // Leave the CreateArrayInstr and StoreIndexedInstr in the stream in case |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4183 "native function '%s' (%" Pd " arguments) cannot be found", | 4191 "native function '%s' (%" Pd " arguments) cannot be found", |
| 4184 native_name().ToCString(), function().NumParameters()); | 4192 native_name().ToCString(), function().NumParameters()); |
| 4185 } | 4193 } |
| 4186 set_is_auto_scope(auto_setup_scope); | 4194 set_is_auto_scope(auto_setup_scope); |
| 4187 set_native_c_function(native_function); | 4195 set_native_c_function(native_function); |
| 4188 } | 4196 } |
| 4189 | 4197 |
| 4190 #undef __ | 4198 #undef __ |
| 4191 | 4199 |
| 4192 } // namespace dart | 4200 } // namespace dart |
| OLD | NEW |