Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(300)

Side by Side Diff: runtime/vm/intermediate_language.cc

Issue 2859673002: Pass type argument vector to generic functions (if --reify-generic-functions is (Closed)
Patch Set: fix dartk and sync Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 3248 matching lines...) Expand 10 before | Expand all | Expand 10 after
3259 } 3259 }
3260 } 3260 }
3261 #endif 3261 #endif
3262 3262
3263 3263
3264 void InstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 3264 void InstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
3265 Zone* zone = compiler->zone(); 3265 Zone* zone = compiler->zone();
3266 const ICData* call_ic_data = NULL; 3266 const ICData* call_ic_data = NULL;
3267 if (!FLAG_propagate_ic_data || !compiler->is_optimizing() || 3267 if (!FLAG_propagate_ic_data || !compiler->is_optimizing() ||
3268 (ic_data() == NULL)) { 3268 (ic_data() == NULL)) {
3269 const Array& arguments_descriptor = Array::Handle( 3269 const Array& arguments_descriptor =
3270 zone, ArgumentsDescriptor::New(ArgumentCount(), argument_names())); 3270 Array::Handle(zone, GetArgumentsDescriptor());
3271 call_ic_data = compiler->GetOrAddInstanceCallICData( 3271 call_ic_data = compiler->GetOrAddInstanceCallICData(
3272 deopt_id(), function_name(), arguments_descriptor, 3272 deopt_id(), function_name(), arguments_descriptor,
3273 checked_argument_count()); 3273 checked_argument_count());
3274 } else { 3274 } else {
3275 call_ic_data = &ICData::ZoneHandle(zone, ic_data()->raw()); 3275 call_ic_data = &ICData::ZoneHandle(zone, ic_data()->raw());
3276 } 3276 }
3277 3277
3278 #if !defined(TARGET_ARCH_DBC) 3278 #if !defined(TARGET_ARCH_DBC)
3279 if (compiler->is_optimizing() && HasICData()) { 3279 if (compiler->is_optimizing() && HasICData()) {
3280 ASSERT(HasICData()); 3280 ASSERT(HasICData());
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
3415 3415
3416 intptr_t PolymorphicInstanceCallInstr::CallCount() const { 3416 intptr_t PolymorphicInstanceCallInstr::CallCount() const {
3417 return targets().AggregateCallCount(); 3417 return targets().AggregateCallCount();
3418 } 3418 }
3419 3419
3420 3420
3421 // DBC does not support optimizing compiler and thus doesn't emit 3421 // DBC does not support optimizing compiler and thus doesn't emit
3422 // PolymorphicInstanceCallInstr. 3422 // PolymorphicInstanceCallInstr.
3423 #if !defined(TARGET_ARCH_DBC) 3423 #if !defined(TARGET_ARCH_DBC)
3424 void PolymorphicInstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 3424 void PolymorphicInstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
3425 ArgumentsInfo args_info(instance_call()->type_args_len(),
3426 instance_call()->ArgumentCount(),
3427 instance_call()->argument_names());
3425 if (!with_checks()) { 3428 if (!with_checks()) {
3426 ASSERT(targets().HasSingleTarget()); 3429 ASSERT(targets().HasSingleTarget());
3427 const Function& target = targets().FirstTarget(); 3430 const Function& target = targets().FirstTarget();
3428 compiler->GenerateStaticCall(deopt_id(), instance_call()->token_pos(), 3431 compiler->GenerateStaticCall(deopt_id(), instance_call()->token_pos(),
3429 target, instance_call()->ArgumentCount(), 3432 target, args_info, locs(), ICData::Handle());
3430 instance_call()->argument_names(), locs(),
3431 ICData::Handle());
3432 return; 3433 return;
3433 } 3434 }
3434 3435
3435 compiler->EmitPolymorphicInstanceCall( 3436 compiler->EmitPolymorphicInstanceCall(
3436 targets_, *instance_call(), instance_call()->ArgumentCount(), 3437 targets_, *instance_call(), args_info, deopt_id(),
3437 instance_call()->argument_names(), deopt_id(),
3438 instance_call()->token_pos(), locs(), complete(), total_call_count()); 3438 instance_call()->token_pos(), locs(), complete(), total_call_count());
3439 } 3439 }
3440 #endif 3440 #endif
3441 3441
3442 3442
3443 RawType* PolymorphicInstanceCallInstr::ComputeRuntimeType( 3443 RawType* PolymorphicInstanceCallInstr::ComputeRuntimeType(
3444 const CallTargets& targets) { 3444 const CallTargets& targets) {
3445 bool is_string = true; 3445 bool is_string = true;
3446 bool is_integer = true; 3446 bool is_integer = true;
3447 bool is_double = true; 3447 bool is_double = true;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
3543 } 3543 }
3544 3544
3545 3545
3546 LocationSummary* StaticCallInstr::MakeLocationSummary(Zone* zone, 3546 LocationSummary* StaticCallInstr::MakeLocationSummary(Zone* zone,
3547 bool optimizing) const { 3547 bool optimizing) const {
3548 return MakeCallSummary(zone); 3548 return MakeCallSummary(zone);
3549 } 3549 }
3550 3550
3551 3551
3552 void StaticCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 3552 void StaticCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
3553 Zone* zone = compiler->zone();
3553 const ICData* call_ic_data = NULL; 3554 const ICData* call_ic_data = NULL;
3554 if (!FLAG_propagate_ic_data || !compiler->is_optimizing() || 3555 if (!FLAG_propagate_ic_data || !compiler->is_optimizing() ||
3555 (ic_data() == NULL)) { 3556 (ic_data() == NULL)) {
3556 const Array& arguments_descriptor = Array::Handle( 3557 const Array& arguments_descriptor =
3557 ArgumentsDescriptor::New(ArgumentCount(), argument_names())); 3558 Array::Handle(zone, GetArgumentsDescriptor());
3558 MethodRecognizer::Kind recognized_kind = 3559 MethodRecognizer::Kind recognized_kind =
3559 MethodRecognizer::RecognizeKind(function()); 3560 MethodRecognizer::RecognizeKind(function());
3560 int num_args_checked = 0; 3561 int num_args_checked = 0;
3561 switch (recognized_kind) { 3562 switch (recognized_kind) {
3562 case MethodRecognizer::kDoubleFromInteger: 3563 case MethodRecognizer::kDoubleFromInteger:
3563 case MethodRecognizer::kMathMin: 3564 case MethodRecognizer::kMathMin:
3564 case MethodRecognizer::kMathMax: 3565 case MethodRecognizer::kMathMax:
3565 num_args_checked = 2; 3566 num_args_checked = 2;
3566 break; 3567 break;
3567 default: 3568 default:
3568 break; 3569 break;
3569 } 3570 }
3570 call_ic_data = compiler->GetOrAddStaticCallICData( 3571 call_ic_data = compiler->GetOrAddStaticCallICData(
3571 deopt_id(), function(), arguments_descriptor, num_args_checked); 3572 deopt_id(), function(), arguments_descriptor, num_args_checked);
3572 } else { 3573 } else {
3573 call_ic_data = &ICData::ZoneHandle(ic_data()->raw()); 3574 call_ic_data = &ICData::ZoneHandle(ic_data()->raw());
3574 } 3575 }
3575 3576
3576 #if !defined(TARGET_ARCH_DBC) 3577 #if !defined(TARGET_ARCH_DBC)
3577 compiler->GenerateStaticCall(deopt_id(), token_pos(), function(), 3578 ArgumentsInfo args_info(type_args_len(), ArgumentCount(), argument_names());
3578 ArgumentCount(), argument_names(), locs(), 3579 compiler->GenerateStaticCall(deopt_id(), token_pos(), function(), args_info,
3579 *call_ic_data); 3580 locs(), *call_ic_data);
3580 #else 3581 #else
3581 const Array& arguments_descriptor = 3582 const Array& arguments_descriptor = Array::Handle(
3582 (ic_data() == NULL) ? Array::Handle(ArgumentsDescriptor::New( 3583 zone, (ic_data() == NULL) ? GetArgumentsDescriptor()
3583 ArgumentCount(), argument_names())) 3584 : ic_data()->arguments_descriptor());
3584 : Array::Handle(ic_data()->arguments_descriptor());
3585 const intptr_t argdesc_kidx = __ AddConstant(arguments_descriptor); 3585 const intptr_t argdesc_kidx = __ AddConstant(arguments_descriptor);
3586 3586
3587 compiler->AddCurrentDescriptor(RawPcDescriptors::kRewind, deopt_id(), 3587 compiler->AddCurrentDescriptor(RawPcDescriptors::kRewind, deopt_id(),
3588 token_pos()); 3588 token_pos());
3589 if (compiler->is_optimizing()) { 3589 if (compiler->is_optimizing()) {
3590 __ PushConstant(function()); 3590 __ PushConstant(function());
3591 __ StaticCall(ArgumentCount(), argdesc_kidx); 3591 __ StaticCall(ArgumentCount(), argdesc_kidx);
3592 compiler->AddCurrentDescriptor(RawPcDescriptors::kOther, deopt_id(), 3592 compiler->AddCurrentDescriptor(RawPcDescriptors::kOther, deopt_id(),
3593 token_pos()); 3593 token_pos());
3594 compiler->RecordAfterCall(this, FlowGraphCompiler::kHasResult); 3594 compiler->RecordAfterCall(this, FlowGraphCompiler::kHasResult);
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
3901 return Array::length_offset(); 3901 return Array::length_offset();
3902 default: 3902 default:
3903 UNREACHABLE(); 3903 UNREACHABLE();
3904 return -1; 3904 return -1;
3905 } 3905 }
3906 } 3906 }
3907 3907
3908 3908
3909 const Function& StringInterpolateInstr::CallFunction() const { 3909 const Function& StringInterpolateInstr::CallFunction() const {
3910 if (function_.IsNull()) { 3910 if (function_.IsNull()) {
3911 const int kTypeArgsLen = 0;
3911 const int kNumberOfArguments = 1; 3912 const int kNumberOfArguments = 1;
3912 const Array& kNoArgumentNames = Object::null_array(); 3913 const Array& kNoArgumentNames = Object::null_array();
3913 const Class& cls = 3914 const Class& cls =
3914 Class::Handle(Library::LookupCoreClass(Symbols::StringBase())); 3915 Class::Handle(Library::LookupCoreClass(Symbols::StringBase()));
3915 ASSERT(!cls.IsNull()); 3916 ASSERT(!cls.IsNull());
3916 function_ = Resolver::ResolveStatic( 3917 function_ = Resolver::ResolveStatic(
3917 cls, Library::PrivateCoreLibName(Symbols::Interpolate()), 3918 cls, Library::PrivateCoreLibName(Symbols::Interpolate()), kTypeArgsLen,
3918 kNumberOfArguments, kNoArgumentNames); 3919 kNumberOfArguments, kNoArgumentNames);
3919 } 3920 }
3920 ASSERT(!function_.IsNull()); 3921 ASSERT(!function_.IsNull());
3921 return function_; 3922 return function_;
3922 } 3923 }
3923 3924
3924 3925
3925 // Replace StringInterpolateInstr with a constant string if all inputs are 3926 // Replace StringInterpolateInstr with a constant string if all inputs are
3926 // constant of [string, number, boolean, null]. 3927 // constant of [string, number, boolean, null].
3927 // Leave the CreateArrayInstr and StoreIndexedInstr in the stream in case 3928 // Leave the CreateArrayInstr and StoreIndexedInstr in the stream in case
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
4308 "native function '%s' (%" Pd " arguments) cannot be found", 4309 "native function '%s' (%" Pd " arguments) cannot be found",
4309 native_name().ToCString(), function().NumParameters()); 4310 native_name().ToCString(), function().NumParameters());
4310 } 4311 }
4311 set_is_auto_scope(auto_setup_scope); 4312 set_is_auto_scope(auto_setup_scope);
4312 set_native_c_function(native_function); 4313 set_native_c_function(native_function);
4313 } 4314 }
4314 4315
4315 #undef __ 4316 #undef __
4316 4317
4317 } // namespace dart 4318 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698