-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Proposal: store instantiate-to-bounds result in kernel #31581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Yes, my informal expectation was that kernel would record this information for the backend to use. Basically, I think of it as a set of "default arguments" for the type arguments that get computed by the frontend, and the backend just consumes them. For the common case that the default arguments are all "dynamic", you can presumably just elide them for compactness. |
thank youuuuuu!!!!! |
The front-end part of this change is not landed yet. The field currently contains null at all times. |
@stefantsov: when will you able to revisit this? I have an outstanding review in the VM which implements this support there, and can't be landed until it's available in the CFE. |
@sjindel-google It's very close to the top of my list, but I don't want to give promises because of the slight fuzziness on the other issues with seemingly higher priority. |
A brief status update. I'm working on the issue in two separate CLs:
Sorry for delaying this for some time. I hope I'll get it working soon now that I have enough time to finish the task. |
Another issue kicked in after the changes in the mentioned CLs. Namely, checks for the correct number of type arguments for types are need to be made early in the process in order to make everything work. I started implementing these checks in CL 51128. CL 50941 and CL 50945 are rebased to depend on that CL. |
CL 51128 is out for review. Basically, without changes from this CL we can't tell if the number of supplied type arguments in the supertypes, the mixins, and the bounds is correct or not (yes, until the CL is landed, you may try and use |
Ok, so the number of related CLs is still growing :-) There are 5 of them currently, and it should soon become 6. Here are the links to the existing ones, in the order from least dependent to most dependent:
The first 4 are sent out for the review. That's what it takes for the preparation to the actual fix :-) |
Small status update: CL 51128 has landed recently. |
CL 50945 is out for review, and it's the last piece of the puzzle. I hope to get it landed soon. I'll update the thread when it's done. |
I believe the front-end part of this issue is resolved as of 6fc4854. |
Uh oh!
There was an error while loading. Please reload this page.
[Edit eernstg Apr 2018: Note that as of today the instantiate-to-bounds algorithm has a feature spec.]
Dart 2.0 specifies a nontrivial algorithm for inferring type arguments from bounds: the "instantiate to bounds" algorithm. This algorithm needs to be used in several situations:
In most situations, these three cases can all be handled by the front end. However, there is one exception: when a generic method is invoked dynamically, the runtime must supply type parameters using the instantiate to bounds algorithm. This might happen, for example, when executing code like this:
This is really unfortunate, because it means that the instantiate-to-bounds algorithm needs to be replicated in all runtimes, and we need to test it carefully to make sure the implementations don't diverge.
It seems like it would be much easier to have the kernel representation for a generic function or method include a default set of generic types; the front end could fill in this set of types using instantiate-to-bounds at compile time, and the runtime could simply use it when needed. There would no longer be any need to replicate the instantiate-to-bounds algorithm in all the runtimes.
@leafpetersen does this seem feasible to you? (Am I missing some crucial detail that would prevent this from working?)
@kmillikin this would require changes to the kernel format--what do you think?
CC: @sigmundch
The text was updated successfully, but these errors were encountered: