Skip to content

TFA has suboptimal handling of tearoffs #39688

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

Closed
sjindel-google opened this issue Dec 6, 2019 · 2 comments
Closed

TFA has suboptimal handling of tearoffs #39688

sjindel-google opened this issue Dec 6, 2019 · 2 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-performance Issue relates to performance or code size

Comments

@sjindel-google
Copy link
Contributor

We currently treat any method tearoff as an all-dynamic call to the function.

We can instead treat the tearoff as an inline closure (a, b, ...) => m.foo(a, b, ...) to at least regain some information about the parameters.

/cc @alexmarkov @mkustermann

@sjindel-google sjindel-google added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-performance Issue relates to performance or code size labels Dec 6, 2019
@sjindel-google sjindel-google self-assigned this Dec 6, 2019
@alexmarkov
Copy link
Contributor

All-dynamic are narrowed using static types, so we're getting static types of parameters in case of tear-offs. Closures are treated similarly - all their parameters are approximated using static types.

Could you elaborate how you'd like to improve handling of tear-offs?

I created a separate issue #39692 to track work related to more accurate handling of closure calls, which may also include more accurate handling of tear-offs.

@sjindel-google
Copy link
Contributor Author

sjindel-google commented Dec 6, 2019

This is actually not TFA's fault. I rewrote:

List<int>.generate(...).reduce(min)

as

List<int>.generate(...).reduce((x, y) => min(x, y))

Type-inference triggers in the second case and fills in the types of x and y as int, so TFA can infer that the calls to < inside min are against ints.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-performance Issue relates to performance or code size
Projects
None yet
Development

No branches or pull requests

2 participants