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

Unified Diff: runtime/vm/kernel_to_il.cc

Issue 2894953002: Support inlining of calls where type arguments are passed to generic functions. (Closed)
Patch Set: work in progress Created 3 years, 6 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/kernel_to_il.cc
diff --git a/runtime/vm/kernel_to_il.cc b/runtime/vm/kernel_to_il.cc
index 7635053d71dcc957bb8896bc0b7c96266c7faa66..4dcea86dff4f9848b4e27472e30d61c1a8e222db 100644
--- a/runtime/vm/kernel_to_il.cc
+++ b/runtime/vm/kernel_to_il.cc
@@ -320,6 +320,15 @@ ScopeBuildingResult* ScopeBuilder::BuildScopes() {
scope_->set_begin_token_pos(function.token_pos());
scope_->set_end_token_pos(function.end_token_pos());
+ if (FLAG_reify_generic_functions && function.IsGeneric()) {
+ LocalVariable* type_args_var = MakeVariable(
+ TokenPosition::kNoSource, TokenPosition::kNoSource,
+ Symbols::FunctionTypeArgumentsVar(), Object::dynamic_type());
+ type_args_var->set_is_forced_stack(); // TODO(regis): Necessary?
+ scope_->AddVariable(type_args_var);
+ ASSERT(parsed_function->function_type_arguments() == NULL);
+ parsed_function->set_function_type_arguments(type_args_var);
+ }
LocalVariable* context_var = parsed_function->current_context_var();
context_var->set_is_forced_stack();
scope_->AddVariable(context_var);
@@ -2549,13 +2558,14 @@ Fragment FlowGraphBuilder::InstanceCall(TokenPosition position,
}
-Fragment FlowGraphBuilder::ClosureCall(int argument_count,
+Fragment FlowGraphBuilder::ClosureCall(intptr_t type_args_len,
+ intptr_t argument_count,
const Array& argument_names) {
Value* function = Pop();
- ArgumentArray arguments = GetArguments(argument_count);
- const intptr_t kTypeArgsLen = 0; // Generic closures not yet supported.
+ const intptr_t total_count = argument_count + (type_args_len > 0 ? 1 : 0);
+ ArgumentArray arguments = GetArguments(total_count);
ClosureCallInstr* call = new (Z)
- ClosureCallInstr(function, arguments, kTypeArgsLen, argument_names,
+ ClosureCallInstr(function, arguments, type_args_len, argument_names,
TokenPosition::kNoSource, GetNextDeoptId());
Push(call);
return Fragment(call);
@@ -4216,6 +4226,13 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfInvokeFieldDispatcher(
LocalScope* scope = parsed_function_->node_sequence()->scope();
+ if (descriptor.TypeArgsLen() > 0) {
+ LocalVariable* type_args = parsed_function_->function_type_arguments();
+ ASSERT(type_args != NULL);
+ body += LoadLocal(type_args);
+ body += PushArgument();
+ }
+
LocalVariable* closure = NULL;
if (is_closure_call) {
closure = scope->VariableAt(0);
@@ -4244,8 +4261,12 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfInvokeFieldDispatcher(
body += LoadLocal(closure);
body += LoadField(Closure::function_offset());
- body += ClosureCall(descriptor.Count(), argument_names);
+ body += ClosureCall(descriptor.TypeArgsLen(), descriptor.Count(),
+ argument_names);
} else {
+ if (descriptor.TypeArgsLen() > 0) {
+ UNIMPLEMENTED();
+ }
body += InstanceCall(TokenPosition::kMinSource, Symbols::Call(),
Token::kILLEGAL, descriptor.Count(), argument_names);
}

Powered by Google App Engine
This is Rietveld 408576698