Skip to content

eliminate implicit casts/dynamic dispatch in DDC's SDK impl #30481

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

Open
jmesserly opened this issue Aug 18, 2017 · 6 comments
Open

eliminate implicit casts/dynamic dispatch in DDC's SDK impl #30481

jmesserly opened this issue Aug 18, 2017 · 6 comments
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. type-performance Issue relates to performance or code size web-dev-compiler
Milestone

Comments

@jmesserly
Copy link

jmesserly commented Aug 18, 2017

Implicit casts and dynamic operations sometimes sneak into the generated code, causing a loss of performance. We could disable these to prevent them from being used in our private patch files/SDK implementation libraries. I'm unsure if the shared SDK code uses either of these, but we could specialize (via external) so DDC can implement those in a typed way.

EDIT: and to be clear, I'm mainly concerned with DDC's own SDK impl code. Because we're using a fair amount of JS builtins, it's easy to accidentally end up with implicit casts or dynamic where you didn't intend to do that.

@leafpetersen
Copy link
Member

Yeah, this could definitely be useful. It's not far off of what @matanlurey was looking for with a flag to turn off dynamic operations as well - I'd bet if we could surface this in a nice way, then performance sensitive users might be interested in opting in to this.

It would be great to be able to audit the core SDK libraries in some way as well. I found some dynamic calls in json parsing by profiling, but I'm sure there's more lurking in there.

@jmesserly jmesserly added type-performance Issue relates to performance or code size and removed dev-compiler-performance labels Apr 19, 2018
@jmesserly
Copy link
Author

I've done a few passes of cleanups, but this would still be good to look into.

@vsmenon vsmenon closed this as completed Apr 24, 2019
@vsmenon vsmenon reopened this Apr 24, 2019
@jmesserly
Copy link
Author

I had some progress in this CL, if someone wants to revive it https://dart-review.googlesource.com/c/sdk/+/77016

@jmesserly jmesserly added this to the D24 Release milestone Apr 24, 2019
@jmesserly jmesserly changed the title disable implicit casts, dynamic operations in DDC's SDK? eliminate implicit casts/dynamic dispatch in DDC's SDK impl Apr 24, 2019
@vsmenon vsmenon modified the milestones: D24 Release, Future May 21, 2019
@aadilmaan aadilmaan modified the milestones: Future, D25 Release Jun 4, 2019
@vsmenon vsmenon added the area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. label Jul 20, 2019
@natebosch
Copy link
Member

@sigmundch - I'd imagine a bunch of implicit casts got cleaned up with the null safety migration.

Do you know if there is still more worth doing here?

@sigmundch
Copy link
Member

Since implicit downcasts from dynamic are still allowed, I expect we may still have some left. It might be worth adding some unit test to detect them, that way we prevent accidentally adding more.

Dart2js already has a similar test, so we may be able to adapt it (the test basically ensures all dynamic accesses are previously mentioned in these whitelist file https://github.com/dart-lang/sdk/blob/master/pkg/compiler/test/analyses/api_allowed_nnbd.json)

@srawlins
Copy link
Member

strict-casts (enabled in dev_compiler's analysis options) reports casts from dynamic.

avoid_dynamic_calls is a lint rule which reports dynamic calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. type-performance Issue relates to performance or code size web-dev-compiler
Projects
None yet
Development

No branches or pull requests

7 participants