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

Unified Diff: runtime/vm/aot_optimizer.cc

Issue 2859673002: Pass type argument vector to generic functions (if --reify-generic-functions is (Closed)
Patch Set: Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/aot_optimizer.cc
diff --git a/runtime/vm/aot_optimizer.cc b/runtime/vm/aot_optimizer.cc
index a30e36b328a0b24abbbb54cc6b4e084b11729764..c1cb3506fe1c7cadf3d74de81f056fc84a0bc097 100644
--- a/runtime/vm/aot_optimizer.cc
+++ b/runtime/vm/aot_optimizer.cc
@@ -113,9 +113,11 @@ bool AotOptimizer::RecognizeRuntimeTypeGetter(InstanceCallInstr* call) {
// There is only a single function Object.get:runtimeType that can be invoked
// by this call. Convert dynamic invocation to a static one.
const Class& cls = Class::Handle(Z, I->object_store()->object_class());
+ const intptr_t kTypeArgsLen = 0;
+ ASSERT(call->type_args_len() == kTypeArgsLen);
const Array& args_desc_array = Array::Handle(
- Z,
- ArgumentsDescriptor::New(call->ArgumentCount(), call->argument_names()));
+ Z, ArgumentsDescriptor::New(kTypeArgsLen, call->ArgumentCount(),
+ call->argument_names()));
ArgumentsDescriptor args_desc(args_desc_array);
const Function& function =
Function::Handle(Z, Resolver::ResolveDynamicForReceiverClass(
@@ -128,7 +130,7 @@ bool AotOptimizer::RecognizeRuntimeTypeGetter(InstanceCallInstr* call) {
args->Add(call->PushArgumentAt(i));
}
StaticCallInstr* static_call = new (Z) StaticCallInstr(
- call->token_pos(), Function::ZoneHandle(Z, function.raw()),
+ call->token_pos(), Function::ZoneHandle(Z, function.raw()), kTypeArgsLen,
call->argument_names(), args, call->deopt_id());
static_call->set_result_cid(kTypeCid);
call->ReplaceWith(static_call, current_iterator());
@@ -222,9 +224,11 @@ bool AotOptimizer::TryCreateICData(InstanceCallInstr* call) {
// finalized yet.
return false;
}
- const Array& args_desc_array =
- Array::Handle(Z, ArgumentsDescriptor::New(call->ArgumentCount(),
- call->argument_names()));
+ const Array& args_desc_array = Array::Handle(
+ Z, ArgumentsDescriptor::New(
+ call->type_args_len(),
+ call->ArgumentCount() - (call->type_args_len() > 0 ? 1 : 0),
zra 2017/05/03 15:03:24 This pattern gets repeated a lot. I'd recommend mo
regis 2017/05/09 18:31:22 Done.
+ call->argument_names()));
ArgumentsDescriptor args_desc(args_desc_array);
const Function& function = Function::Handle(
Z, Resolver::ResolveDynamicForReceiverClass(
@@ -253,10 +257,16 @@ bool AotOptimizer::TryCreateICData(InstanceCallInstr* call) {
// Check if the target is unique.
Function& target_function = Function::Handle(Z);
GetUniqueDynamicTarget(isolate(), call->function_name(), &target_function);
- // Calls with named arguments must be resolved/checked at runtime.
+ // Calls passing named arguments and calls to a function taking named
+ // arguments must be resolved/checked at runtime.
+ // Calls passing a type argument vector and calls to a generic function must
+ // be resolved/checked at runtime.
if (!target_function.IsNull() &&
!target_function.HasOptionalNamedParameters() &&
- target_function.AreValidArgumentCounts(call->ArgumentCount(), 0,
+ !target_function.IsGeneric() &&
+ target_function.AreValidArgumentCounts(call->type_args_len(),
+ call->ArgumentCount(),
+ call->argument_names().Length(),
/* error_message = */ NULL)) {
const Class& cls = Class::Handle(Z, target_function.Owner());
if (!CHA::IsImplemented(cls) && !CHA::HasSubclasses(cls)) {
@@ -649,10 +659,11 @@ bool AotOptimizer::TryReplaceWithHaveSameRuntimeType(InstanceCallInstr* call) {
arg = new (Z) PushArgumentInstr(new (Z) Value(right->ArgumentAt(0)));
InsertBefore(call, arg, NULL, FlowGraph::kEffect);
args->Add(arg);
- StaticCallInstr* static_call =
- new (Z) StaticCallInstr(call->token_pos(), have_same_runtime_type,
- Object::null_array(), // argument_names
- args, call->deopt_id());
+ const intptr_t kTypeArgsLen = 0;
zra 2017/05/03 15:03:24 ASSERT(call->type_args_len() == kTypeArgsLen) ?
regis 2017/05/09 18:31:22 Done, although arguments names and others were not
+ StaticCallInstr* static_call = new (Z)
+ StaticCallInstr(call->token_pos(), have_same_runtime_type, kTypeArgsLen,
+ Object::null_array(), // argument_names
+ args, call->deopt_id());
static_call->set_result_cid(kBoolCid);
ReplaceCall(call, static_call);
return true;
@@ -1515,8 +1526,9 @@ void AotOptimizer::ReplaceWithInstanceOf(InstanceCallInstr* call) {
ASSERT(!target.IsNull());
ASSERT(target.IsRecognized() && target.always_inline());
+ const intptr_t kTypeArgsLen = 0;
zra 2017/05/03 15:03:24 ditto.
regis 2017/05/09 18:31:22 Done.
StaticCallInstr* new_call =
- new (Z) StaticCallInstr(call->token_pos(), target,
+ new (Z) StaticCallInstr(call->token_pos(), target, kTypeArgsLen,
Object::null_array(), // argument_names
args, call->deopt_id());
Environment* copy = call->env()->DeepCopy(
@@ -1607,8 +1619,9 @@ void AotOptimizer::ReplaceWithTypeCast(InstanceCallInstr* call) {
ASSERT(target.IsRecognized());
ASSERT(target.always_inline());
+ const intptr_t kTypeArgsLen = 0;
zra 2017/05/03 15:03:24 ditto.
regis 2017/05/09 18:31:22 Done.
StaticCallInstr* new_call =
- new (Z) StaticCallInstr(call->token_pos(), target,
+ new (Z) StaticCallInstr(call->token_pos(), target, kTypeArgsLen,
Object::null_array(), // argument_names
args, call->deopt_id());
Environment* copy =
@@ -1670,8 +1683,9 @@ void AotOptimizer::ReplaceWithTypeCast(InstanceCallInstr* call) {
ASSERT(target.IsRecognized());
ASSERT(target.always_inline());
+ const intptr_t kTypeArgsLen = 0;
zra 2017/05/03 15:03:24 ditto.
regis 2017/05/09 18:31:22 Done.
StaticCallInstr* new_call =
- new (Z) StaticCallInstr(call->token_pos(), target,
+ new (Z) StaticCallInstr(call->token_pos(), target, kTypeArgsLen,
Object::null_array(), // argument_names
args, call->deopt_id());
Environment* copy = call->env()->DeepCopy(
@@ -1901,9 +1915,11 @@ void AotOptimizer::VisitInstanceCall(InstanceCallInstr* instr) {
const Class& receiver_class =
Class::Handle(Z, isolate()->class_table()->At(receiver_cid));
- const Array& args_desc_array =
- Array::Handle(Z, ArgumentsDescriptor::New(instr->ArgumentCount(),
- instr->argument_names()));
+ const Array& args_desc_array = Array::Handle(
+ Z, ArgumentsDescriptor::New(
+ instr->type_args_len(),
+ instr->ArgumentCount() - (instr->type_args_len() > 0 ? 1 : 0),
+ instr->argument_names()));
ArgumentsDescriptor args_desc(args_desc_array);
Function& function = Function::Handle(
Z, Resolver::ResolveDynamicForReceiverClass(
@@ -1952,9 +1968,11 @@ void AotOptimizer::VisitInstanceCall(InstanceCallInstr* instr) {
Function& single_target = Function::Handle(Z);
ICData& ic_data = ICData::Handle(Z);
- const Array& args_desc_array =
- Array::Handle(Z, ArgumentsDescriptor::New(instr->ArgumentCount(),
- instr->argument_names()));
+ const Array& args_desc_array = Array::Handle(
+ Z, ArgumentsDescriptor::New(
+ instr->type_args_len(),
+ instr->ArgumentCount() - (instr->type_args_len() > 0 ? 1 : 0),
+ instr->argument_names()));
ArgumentsDescriptor args_desc(args_desc_array);
Function& target = Function::Handle(Z);
@@ -2032,7 +2050,8 @@ void AotOptimizer::VisitInstanceCall(InstanceCallInstr* instr) {
}
StaticCallInstr* call = new (Z) StaticCallInstr(
instr->token_pos(), Function::ZoneHandle(Z, single_target.raw()),
- instr->argument_names(), args, instr->deopt_id());
+ instr->type_args_len(), instr->argument_names(), args,
+ instr->deopt_id());
instr->ReplaceWith(call, current_iterator());
return;
} else if ((ic_data.raw() != ICData::null()) &&
@@ -2074,9 +2093,12 @@ void AotOptimizer::VisitPolymorphicInstanceCall(
const Class& receiver_class =
Class::Handle(Z, isolate()->class_table()->At(receiver_cid));
+ const intptr_t type_args_len = call->instance_call()->type_args_len();
const Array& args_desc_array = Array::Handle(
- Z, ArgumentsDescriptor::New(call->ArgumentCount(),
- call->instance_call()->argument_names()));
+ Z, ArgumentsDescriptor::New(
+ type_args_len,
+ call->ArgumentCount() - (type_args_len > 0 ? 1 : 0),
+ call->instance_call()->argument_names()));
ArgumentsDescriptor args_desc(args_desc_array);
const Function& function = Function::Handle(
Z, Resolver::ResolveDynamicForReceiverClass(

Powered by Google App Engine
This is Rietveld 408576698