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: used-type inference for hidden native classes during codegen #1525
Comments
Marked this as blocking #1519. |
Additional to the above, exception types need to be marked. Exaample: Swarm contains this code because IDBDatabaseException is marked as used by the blanket 'mark all native types rule'. // ********** Code for _IDBDatabaseExceptionJs ************** There are ~35 IDL operations that are marked in the IDL as raising this exception, but this information is not currently carried to the Dart code. We could use the 'dummy code' feature to generate a reference. class _IDBRequestJs implements IDBRequest { IDBAny get result() native 'return this.result' { throw new _IDBDatabaseExceptionJs(); } _IDBDatabaseExceptionJs might not have a constructor. |
Additional to the above, there is one callback with an imprecise argument type. module storage { --> This could be made precise by making Database and DatabaseSync extend a common marker interface. |
Removed Area-Frog label. |
Is this a DOM issue? Removed Area-Dart2JS, FromAreaFrog labels. |
This is a dart2js issue - the compiler emits code for native classes that cannot exist in the given program. There is sufficient information in the library to eliminate many of these. I prototyped an analysis in Frog. The results are listed in a document called "Investigation: Frog used-type analysis for native classes" Removed Area-DOM label. |
Added this to the Later milestone. |
Added this to the M2 milestone. |
Removed Priority-Medium label. |
Kasper: Why did you move the priority to Low? This is a key piece to reducing the size cost of dart:html. |
Removed Priority-Low label. |
Nicolas, Stephen, are you guys looking at this? cc @rakudrama. |
This comment was originally written by ngeoffray@google.com Yes, Stephen is working on this, and we're looking at the interaction with dart2js's enqueuer. |
Set owner to @rakudrama. |
First part of this has been implemented in r14977. The libraries now need to be correctly annotated before this can be the default. After that, codegen based analysis should be implemented to improve on the resolution based results. |
Libraries have been mostly annotated r15569 r15705 Feature enabled by default r15660 I'm moving this issue to M3 for the codegen based analysis. Removed this from the M2 milestone. |
@rakudrama - seems like this is now been done for quite some time? I'm closing the issue assuming so, but please reopen if not. |
Instances of hidden native classes can reach the Dart program via four paths:
(1) returned from a native method or getter,
e.g. aha = document.getElementById();
(2) passed to functions which escape to the native world
e.g. element.addEventListenter((e) => doIt());
(3) passed to methods on objects which escape to the native world.
(4) anything transitively reachable from the results of (2), (3) also escapes.
For dart:dom and dart:html we only need to consider (1) and (2), since all objects in class (3) have been typedef-ed as callback functions, and all callbacks return simple types.
This analysis will prevent the gratuitous generation of code like the following since in most programs, Float64Array will be determined to be unused:
// ********** Code for _Float64ArrayJs **************
var _Float64ArrayJs = {};
$dynamic("get$length").Float64Array = function() {
return this.length;
}
$dynamic("$index").Float64Array = function(index) {
return this[index];
}
The text was updated successfully, but these errors were encountered: