Skip to content
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

tear-off of function's call method might be expensive #31746

Closed
rakudrama opened this issue Jan 2, 2018 · 2 comments
Closed

tear-off of function's call method might be expensive #31746

rakudrama opened this issue Jan 2, 2018 · 2 comments
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-stale Closed as the issue or PR is assumed stale

Comments

@rakudrama
Copy link
Member

dart2js would like to minimize the extra metadata required for generic methods.

The Kernel instruction Instantiation, used to bind generic type arguments of a generic closure, currently is inserted at specific points - tear-off of instance method, escape of local or top-level method, use of an anonymous closure. At these points we can identify the target or set of targets fairly precisely and thus create metadata for supporting instantiation for specific methods.

However, there is a leak - the call method of functions can be torn off. Since get:call for a function returns the function itself, this means that any generic function that can flow to the tear-off site might be partially-applied by the injected Instantiation instruction. This would mean that more generic functions would need to support being instantiated - e.g. any function compatible with fun below:

int Function(int) g;
void foo(R Function<R>(R) fun) {
  g = fun;  //  g = Instantiate<int>(fun);
}

I propose that we disallow tear-offs of the call method until we can measure the impact of this information leak.

Related: #31665

@rakudrama rakudrama added the area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). label Jan 2, 2018
@stereotype441
Copy link
Member

It seems reasonable to me to disable implicit instantiation of function call methods for now, especially considering that the ability to refer directly to a function's call method is probably going to be removed from the language anyhow.

CL to disable implicit instantiation of function call methods is here: https://dart-review.googlesource.com/#/c/sdk/+/31751

whesse pushed a commit that referenced this issue Jan 2, 2018
Addresses the performance concern raised in #31746

Change-Id: Iabfb4b871fb7807c0fe625036adfd22d2e6c51ee
Reviewed-on: https://dart-review.googlesource.com/31751
Commit-Queue: Paul Berry <[email protected]>
Reviewed-by: Konstantin Shcheglov <[email protected]>
@lrhn lrhn closed this as completed Jan 12, 2024
@lrhn lrhn added the closed-stale Closed as the issue or PR is assumed stale label Jan 12, 2024
@lrhn
Copy link
Member

lrhn commented Jan 12, 2024

There are no restrictions on accessing call on functions. It's now the canonical way to do a null-aware invocation, fn?.call(args).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-stale Closed as the issue or PR is assumed stale
Projects
None yet
Development

No branches or pull requests

3 participants