Skip to content

Make 'as' cheaper in AOT #34582

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
Hixie opened this issue Sep 25, 2018 · 4 comments
Closed

Make 'as' cheaper in AOT #34582

Hixie opened this issue Sep 25, 2018 · 4 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. customer-flutter type-performance Issue relates to performance or code size

Comments

@Hixie
Copy link
Contributor

Hixie commented Sep 25, 2018

In flutter/flutter#21813, @mraleph wrote:

x as String is compiled down to some big code. if you do an implicit cast:

    String name1 = json["name1"] /* as String */;

that should yield smaller AOT code.

Is there any chance we could make as generate the same cheap code as an implicit cast in an assignment? My understanding is that with Dart2 there's now no reason why they should be different.

Flutter would like to disable all implicit casts and replace them all with as. We currently can't do that because we have the avoid_as lint enabled specifically because of this performance concern.

@matanlurey matanlurey 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 customer-flutter labels Sep 25, 2018
@matanlurey
Copy link
Contributor

That is indeed confusing considering the VM has to do checks either way.

@mraleph
Copy link
Member

mraleph commented Sep 25, 2018

Is there any chance we could make as generate the same cheap code as an implicit cast in an assignment?

Yes, we are going to look at this soon. @mkustermann has a CL which we will land when he is back from vacation. This is legacy stuff (implicit and explicit as checks throw different errors and also there were some runtime feedback based optimizations applied to explicit as - which makes no sense in AOT case at all).

@mkustermann
Copy link
Member

Now that I'm back from vacation I'll start working on this.

In #34097 we got the green light from the language team to treat implicit and explicit casts the same way.

dart-bot pushed a commit that referenced this issue Oct 10, 2018
This makes explicit downcasts more efficient by re-using the
optimizations we already have for implicit downcasts.

For implicit/explicit as checks we use the symbol to distinguish which
exception to throw if the check fails.  So this does not actually
require unification of _CastError and _TypeError.

Issue #34582
Issue #30632
Issue #30571

Change-Id: I7b8818d2698e249c90a3e1b8790bad69ada649a9
Reviewed-on: https://dart-review.googlesource.com/c/78748
Commit-Queue: Martin Kustermann <[email protected]>
Reviewed-by: Alexander Markov <[email protected]>
Reviewed-by: Vyacheslav Egorov <[email protected]>
@mkustermann
Copy link
Member

Closing this, as implicit/explicit as should have same performance characteristics since the change above landed.

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. customer-flutter type-performance Issue relates to performance or code size
Projects
None yet
Development

No branches or pull requests

4 participants