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: inline identical definitions for natives #7465
Comments
Added TriageForM5 label. |
Is there more work to do for this? Removed this from the M5 milestone. |
We have done everything except the case where multiple classes have identical definitions for the native class or field. There are 17 SVG classes that extend StyledElement and implement SVGLocatable. I believe this only affects SVG code, and only code written to use the interfaces, so the priority is low. I'd be happy to close this issue if another was opened specifically for the multi-implementation case. Removed Priority-Medium label. |
Updated the summary to reflect what's missing. Changed the title to: "dart2js: inline identical definitions for natives". |
Removed this from the Later milestone. |
Removed Oldschool-Milestone-Later label. |
The specific case of getBBox() seems to have been solved by having it on SVGGraphicElement. |
Native methods from dart:html and friends can be aggressively inlined.
Given...
@JSName('jsfoo') int foo(int x) native;
... we can inline a Dart call "a.foo(b)" and generate, instead of "a.foo$1(b)", the inlined code "a.jsfoo(b)".
The foo$1 wrapper performs several functions. These are known in the compiler so can be generated or checked in the inlined code without implementing full inlining. They are (1) arity check (2) type annotation checks (in checked mode) (3) (rare) some conversions (wrapping callables in JS functions).
In checked mode we need to satisfy the checks that are inserted into foo$1, i.e. the precondition (b is int) needs to hold.
We can be more general that requiring "a" to be at one point in the inheritance hierarchy - this is especially important for SVG where many methods are inherited from secondary interfaces and explicitly implemented.
Considering the set of concrete types at "a":
If ...
... then we can replace "a.foo$1(b)" with "a.jsfoo(b)".
These conditions can often be satisfied with no knowledge of the type of "a", e.g. the name "foo" is used only by native class methods and no classes implement noSuchMethod.
We arrange via method and field name generation that no other types use the names of native methods and fields, so there can be no accidental call to some other element called "jsfoo".
The text was updated successfully, but these errors were encountered: