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

[dart2js] Indirect Uint8List(0) as List<int> not optimized #59935

Open
rakudrama opened this issue Jan 18, 2025 · 0 comments
Open

[dart2js] Indirect Uint8List(0) as List<int> not optimized #59935

rakudrama opened this issue Jan 18, 2025 · 0 comments
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. dart2js-optimization dart2js-ssa web-dart2js

Comments

@rakudrama
Copy link
Member

Source:

import 'dart:typed_data';

class Check {
  List<int> check(Object list) => list as List<int>;
}

main() {
  print(Check().check(Uint8List(5)));
}

Output:

    main() {
      A.printString(A.S(type$.List_int._as(new Uint8Array(5))));
    }

Global type inference determines that list is a NativeUint8List.
Inlining brings the typed list adjacent to the check.
Either should be sufficient to determine that the as-check always passes.

B5
r27 ForeignCode : Instance of 'New' (i3] [exact=NativeUint8List]    
r30 TypeKnown : r27 is [subclass=Object] [exact=NativeUint8List]    
v32 LoadType : TypeExpressionRecipe(List<int>)   [null|subclass=Object]    
r33 AsCheck : CastError v32, r30 [exact=NativeUint8List]    
s36 Stringify : r33 [exact=JSString] ! ? 
c38 Goto : (B6)]
@rakudrama rakudrama added area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. dart2js-optimization dart2js-ssa web-dart2js labels Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. dart2js-optimization dart2js-ssa web-dart2js
Projects
None yet
Development

No branches or pull requests

1 participant