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] dart2js should do better inlining of @Native method stubs #56062

Open
rakudrama opened this issue Jun 20, 2024 · 0 comments
Open

[dart2js] dart2js should do better inlining of @Native method stubs #56062

rakudrama opened this issue Jun 20, 2024 · 0 comments
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. dart2js-optimization P3 A lower priority bug or feature request web-dart2js

Comments

@rakudrama
Copy link
Member

In -O1 and -O2 code I see calls to NativeByteData's private methods that look like this:

      B.NativeByteData_methods._setInt32$3(t1, 12, 1, true);
...
    _setInt32$3(receiver, byteOffset, value, littleEndian) {
      return receiver.setInt32(byteOffset, value, littleEndian);
    },

When checks are disabled, the code is better:

      t1.setInt32(12, 1, true);

We should be able to generate the better code at -O1.

The problem is that inlining is inhibited if there is any chance of a parameter check.
Of course, there is no chance here since the 'dynamic invocation' is actually a type-safe interface call where only covariant parameters might need to be checked, and the target has not covariant parameters.

The best way forward would be to improve dart2js generally around interface calls when checks are enabled.

For the specific case like this example, of calling private methods of @Native classes, where the calls can only be in internal libraries, we can verify by inspection that all calls are from from interface call sites, and we can annotate the target with @pragma('dart2js:parameter:trust').

Low priority to fix since we are moving away from having many @Native classes in favor of more flexible interop.

@rakudrama rakudrama added web-dart2js P3 A lower priority bug or feature request dart2js-optimization area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. labels Jun 20, 2024
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 P3 A lower priority bug or feature request web-dart2js
Projects
None yet
Development

No branches or pull requests

1 participant