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 = GetArgumentsDescriptor(zone); |
3180 zone, ArgumentsDescriptor::New(ArgumentCount(), argument_names())); | |
3181 call_ic_data = compiler->GetOrAddInstanceCallICData( | 3180 call_ic_data = compiler->GetOrAddInstanceCallICData( |
3182 deopt_id(), function_name(), arguments_descriptor, | 3181 deopt_id(), function_name(), arguments_descriptor, |
3183 checked_argument_count()); | 3182 checked_argument_count()); |
3184 } else { | 3183 } else { |
3185 call_ic_data = &ICData::ZoneHandle(zone, ic_data()->raw()); | 3184 call_ic_data = &ICData::ZoneHandle(zone, ic_data()->raw()); |
3186 } | 3185 } |
3187 | 3186 |
3188 #if !defined(TARGET_ARCH_DBC) | 3187 #if !defined(TARGET_ARCH_DBC) |
3189 if (compiler->is_optimizing() && HasICData()) { | 3188 if (compiler->is_optimizing() && HasICData()) { |
3190 ASSERT(HasICData()); | 3189 ASSERT(HasICData()); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3338 | 3337 |
3339 intptr_t PolymorphicInstanceCallInstr::CallCount() const { | 3338 intptr_t PolymorphicInstanceCallInstr::CallCount() const { |
3340 return targets().AggregateCallCount(); | 3339 return targets().AggregateCallCount(); |
3341 } | 3340 } |
3342 | 3341 |
3343 | 3342 |
3344 // DBC does not support optimizing compiler and thus doesn't emit | 3343 // DBC does not support optimizing compiler and thus doesn't emit |
3345 // PolymorphicInstanceCallInstr. | 3344 // PolymorphicInstanceCallInstr. |
3346 #if !defined(TARGET_ARCH_DBC) | 3345 #if !defined(TARGET_ARCH_DBC) |
3347 void PolymorphicInstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 3346 void PolymorphicInstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 3347 ArgumentsInfo args_info(instance_call()->type_args_len(), |
| 3348 instance_call()->ArgumentCount(), |
| 3349 instance_call()->argument_names()); |
3348 if (!with_checks()) { | 3350 if (!with_checks()) { |
3349 ASSERT(targets().HasSingleTarget()); | 3351 ASSERT(targets().HasSingleTarget()); |
3350 const Function& target = targets().FirstTarget(); | 3352 const Function& target = targets().FirstTarget(); |
3351 compiler->GenerateStaticCall(deopt_id(), instance_call()->token_pos(), | 3353 compiler->GenerateStaticCall(deopt_id(), instance_call()->token_pos(), |
3352 target, instance_call()->ArgumentCount(), | 3354 target, args_info, locs(), ICData::Handle()); |
3353 instance_call()->argument_names(), locs(), | |
3354 ICData::Handle()); | |
3355 return; | 3355 return; |
3356 } | 3356 } |
3357 | 3357 |
3358 compiler->EmitPolymorphicInstanceCall( | 3358 compiler->EmitPolymorphicInstanceCall( |
3359 targets_, *instance_call(), instance_call()->ArgumentCount(), | 3359 targets_, *instance_call(), args_info, deopt_id(), |
3360 instance_call()->argument_names(), deopt_id(), | |
3361 instance_call()->token_pos(), locs(), complete(), total_call_count()); | 3360 instance_call()->token_pos(), locs(), complete(), total_call_count()); |
3362 } | 3361 } |
3363 #endif | 3362 #endif |
3364 | 3363 |
3365 | 3364 |
3366 RawType* PolymorphicInstanceCallInstr::ComputeRuntimeType( | 3365 RawType* PolymorphicInstanceCallInstr::ComputeRuntimeType( |
3367 const CallTargets& targets) { | 3366 const CallTargets& targets) { |
3368 bool is_string = true; | 3367 bool is_string = true; |
3369 bool is_integer = true; | 3368 bool is_integer = true; |
3370 bool is_double = true; | 3369 bool is_double = true; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3465 } | 3464 } |
3466 | 3465 |
3467 | 3466 |
3468 LocationSummary* StaticCallInstr::MakeLocationSummary(Zone* zone, | 3467 LocationSummary* StaticCallInstr::MakeLocationSummary(Zone* zone, |
3469 bool optimizing) const { | 3468 bool optimizing) const { |
3470 return MakeCallSummary(zone); | 3469 return MakeCallSummary(zone); |
3471 } | 3470 } |
3472 | 3471 |
3473 | 3472 |
3474 void StaticCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 3473 void StaticCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 3474 Zone* zone = compiler->zone(); |
3475 const ICData* call_ic_data = NULL; | 3475 const ICData* call_ic_data = NULL; |
3476 if (!FLAG_propagate_ic_data || !compiler->is_optimizing() || | 3476 if (!FLAG_propagate_ic_data || !compiler->is_optimizing() || |
3477 (ic_data() == NULL)) { | 3477 (ic_data() == NULL)) { |
3478 const Array& arguments_descriptor = Array::Handle( | 3478 const Array& arguments_descriptor = GetArgumentsDescriptor(zone); |
3479 ArgumentsDescriptor::New(ArgumentCount(), argument_names())); | |
3480 MethodRecognizer::Kind recognized_kind = | 3479 MethodRecognizer::Kind recognized_kind = |
3481 MethodRecognizer::RecognizeKind(function()); | 3480 MethodRecognizer::RecognizeKind(function()); |
3482 int num_args_checked = 0; | 3481 int num_args_checked = 0; |
3483 switch (recognized_kind) { | 3482 switch (recognized_kind) { |
3484 case MethodRecognizer::kDoubleFromInteger: | 3483 case MethodRecognizer::kDoubleFromInteger: |
3485 case MethodRecognizer::kMathMin: | 3484 case MethodRecognizer::kMathMin: |
3486 case MethodRecognizer::kMathMax: | 3485 case MethodRecognizer::kMathMax: |
3487 num_args_checked = 2; | 3486 num_args_checked = 2; |
3488 break; | 3487 break; |
3489 default: | 3488 default: |
3490 break; | 3489 break; |
3491 } | 3490 } |
3492 call_ic_data = compiler->GetOrAddStaticCallICData( | 3491 call_ic_data = compiler->GetOrAddStaticCallICData( |
3493 deopt_id(), function(), arguments_descriptor, num_args_checked); | 3492 deopt_id(), function(), arguments_descriptor, num_args_checked); |
3494 } else { | 3493 } else { |
3495 call_ic_data = &ICData::ZoneHandle(ic_data()->raw()); | 3494 call_ic_data = &ICData::ZoneHandle(ic_data()->raw()); |
3496 } | 3495 } |
3497 | 3496 |
3498 #if !defined(TARGET_ARCH_DBC) | 3497 #if !defined(TARGET_ARCH_DBC) |
3499 compiler->GenerateStaticCall(deopt_id(), token_pos(), function(), | 3498 ArgumentsInfo args_info(type_args_len(), ArgumentCount(), argument_names()); |
3500 ArgumentCount(), argument_names(), locs(), | 3499 compiler->GenerateStaticCall(deopt_id(), token_pos(), function(), args_info, |
3501 *call_ic_data); | 3500 locs(), *call_ic_data); |
3502 #else | 3501 #else |
3503 const Array& arguments_descriptor = | 3502 const Array& arguments_descriptor = |
3504 (ic_data() == NULL) ? Array::Handle(ArgumentsDescriptor::New( | 3503 (ic_data() == NULL) ? GetArgumentsDescriptor(zone) |
3505 ArgumentCount(), argument_names())) | |
3506 : Array::Handle(ic_data()->arguments_descriptor()); | 3504 : Array::Handle(ic_data()->arguments_descriptor()); |
3507 const intptr_t argdesc_kidx = __ AddConstant(arguments_descriptor); | 3505 const intptr_t argdesc_kidx = __ AddConstant(arguments_descriptor); |
3508 | 3506 |
3509 compiler->AddCurrentDescriptor(RawPcDescriptors::kRewind, deopt_id(), | 3507 compiler->AddCurrentDescriptor(RawPcDescriptors::kRewind, deopt_id(), |
3510 token_pos()); | 3508 token_pos()); |
3511 if (compiler->is_optimizing()) { | 3509 if (compiler->is_optimizing()) { |
3512 __ PushConstant(function()); | 3510 __ PushConstant(function()); |
3513 __ StaticCall(ArgumentCount(), argdesc_kidx); | 3511 __ StaticCall(ArgumentCount(), argdesc_kidx); |
3514 compiler->AddCurrentDescriptor(RawPcDescriptors::kOther, deopt_id(), | 3512 compiler->AddCurrentDescriptor(RawPcDescriptors::kOther, deopt_id(), |
3515 token_pos()); | 3513 token_pos()); |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3776 return Array::length_offset(); | 3774 return Array::length_offset(); |
3777 default: | 3775 default: |
3778 UNREACHABLE(); | 3776 UNREACHABLE(); |
3779 return -1; | 3777 return -1; |
3780 } | 3778 } |
3781 } | 3779 } |
3782 | 3780 |
3783 | 3781 |
3784 const Function& StringInterpolateInstr::CallFunction() const { | 3782 const Function& StringInterpolateInstr::CallFunction() const { |
3785 if (function_.IsNull()) { | 3783 if (function_.IsNull()) { |
| 3784 const int kTypeArgsLen = 0; |
3786 const int kNumberOfArguments = 1; | 3785 const int kNumberOfArguments = 1; |
3787 const Array& kNoArgumentNames = Object::null_array(); | 3786 const Array& kNoArgumentNames = Object::null_array(); |
3788 const Class& cls = | 3787 const Class& cls = |
3789 Class::Handle(Library::LookupCoreClass(Symbols::StringBase())); | 3788 Class::Handle(Library::LookupCoreClass(Symbols::StringBase())); |
3790 ASSERT(!cls.IsNull()); | 3789 ASSERT(!cls.IsNull()); |
3791 function_ = Resolver::ResolveStatic( | 3790 function_ = Resolver::ResolveStatic( |
3792 cls, Library::PrivateCoreLibName(Symbols::Interpolate()), | 3791 cls, Library::PrivateCoreLibName(Symbols::Interpolate()), kTypeArgsLen, |
3793 kNumberOfArguments, kNoArgumentNames); | 3792 kNumberOfArguments, kNoArgumentNames); |
3794 } | 3793 } |
3795 ASSERT(!function_.IsNull()); | 3794 ASSERT(!function_.IsNull()); |
3796 return function_; | 3795 return function_; |
3797 } | 3796 } |
3798 | 3797 |
3799 | 3798 |
3800 // Replace StringInterpolateInstr with a constant string if all inputs are | 3799 // Replace StringInterpolateInstr with a constant string if all inputs are |
3801 // constant of [string, number, boolean, null]. | 3800 // constant of [string, number, boolean, null]. |
3802 // Leave the CreateArrayInstr and StoreIndexedInstr in the stream in case | 3801 // 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", | 4182 "native function '%s' (%" Pd " arguments) cannot be found", |
4184 native_name().ToCString(), function().NumParameters()); | 4183 native_name().ToCString(), function().NumParameters()); |
4185 } | 4184 } |
4186 set_is_auto_scope(auto_setup_scope); | 4185 set_is_auto_scope(auto_setup_scope); |
4187 set_native_c_function(native_function); | 4186 set_native_c_function(native_function); |
4188 } | 4187 } |
4189 | 4188 |
4190 #undef __ | 4189 #undef __ |
4191 | 4190 |
4192 } // namespace dart | 4191 } // namespace dart |
OLD | NEW |