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

Unified Diff: runtime/vm/parser.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/parser.cc
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
index f96c1a3ec17e9fb14636824aff397baba1ee81ab..a793b6d7485050709f05fbd1360883f94f60ca8e 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -311,6 +311,8 @@ void ParsedFunction::AllocateVariables() {
const intptr_t num_fixed_params = function().num_fixed_parameters();
const intptr_t num_opt_params = function().NumOptionalParameters();
const intptr_t num_params = num_fixed_params + num_opt_params;
+ const intptr_t type_args_slot = function().IsGeneric() ? 1 : 0;
+
// Compute start indices to parameters and locals, and the number of
// parameters to copy.
if (num_opt_params == 0) {
@@ -331,8 +333,8 @@ void ParsedFunction::AllocateVariables() {
// in the context(s).
bool found_captured_variables = false;
int next_free_frame_index = scope->AllocateVariables(
- first_parameter_index_, num_params, first_stack_local_index_, NULL,
- &found_captured_variables);
+ first_parameter_index_, num_params, type_args_slot,
+ first_stack_local_index_, NULL, &found_captured_variables);
// Frame indices are relative to the frame pointer and are decreasing.
ASSERT(next_free_frame_index <= first_stack_local_index_);
@@ -1769,6 +1771,10 @@ SequenceNode* Parser::ParseMethodExtractor(const Function& func) {
void Parser::BuildDispatcherScope(const Function& func,
const ArgumentsDescriptor& desc) {
+ if (desc.TypeArgsLen() > 0) {
+ // TODO(regis): Make func generic.
+ UNIMPLEMENTED();
+ }
ParamList params;
// Receiver first.
TokenPosition token_pos = func.token_pos();
@@ -1873,6 +1879,11 @@ SequenceNode* Parser::ParseInvokeFieldDispatcher(const Function& func) {
const Array& args_desc = Array::Handle(Z, func.saved_args_desc());
ArgumentsDescriptor desc(args_desc);
ASSERT(desc.Count() > 0);
+ if (desc.TypeArgsLen() > 0) {
+ ASSERT(func.IsGeneric());
+ // TODO(regis): Pass type argument vector.
+ UNIMPLEMENTED();
+ }
// Set up scope for this function.
BuildDispatcherScope(func, desc);
@@ -5699,7 +5710,11 @@ RawTypeArguments* Parser::ParseTypeArguments(
ReportError("right angle bracket expected");
}
if (finalization != ClassFinalizer::kIgnore) {
- return NewTypeArguments(types);
+ TypeArguments& type_args = TypeArguments::Handle(NewTypeArguments(types));
+ if (finalization == ClassFinalizer::kCanonicalize) {
+ type_args = type_args.Canonicalize();
+ }
+ return type_args.raw();
}
}
return TypeArguments::null();
@@ -12566,12 +12581,15 @@ void Parser::ResolveType(AbstractType* type) {
if (type->arguments() != TypeArguments::null()) {
const TypeArguments& arguments =
TypeArguments::Handle(Z, type->arguments());
- const intptr_t num_arguments = arguments.Length();
- AbstractType& type_argument = AbstractType::Handle(Z);
- for (intptr_t i = 0; i < num_arguments; i++) {
- type_argument = arguments.TypeAt(i);
- ResolveType(&type_argument);
- arguments.SetTypeAt(i, type_argument);
+ // Already resolved if canonical.
+ if (!arguments.IsCanonical()) {
+ const intptr_t num_arguments = arguments.Length();
+ AbstractType& type_argument = AbstractType::Handle(Z);
+ for (intptr_t i = 0; i < num_arguments; i++) {
+ type_argument = arguments.TypeAt(i);
+ ResolveType(&type_argument);
+ arguments.SetTypeAt(i, type_argument);
+ }
}
}
if (type->IsFunctionType()) {

Powered by Google App Engine
This is Rietveld 408576698