Closed terrylucas closed 8 years ago
Out of curiosity, why is it it required for users to annotate in both places? Is this an implementation detail? (IOW are you doing book-keeping at the library declaration level?)
Also, where is the JS
annotation defined? What package do folks import to find it?
Its an optimization detail.
For JS interop to work in Dartium we must generate patch files at load time. In some applications there can be lots of Dart libraries. To find the @JS annotations in top-level declarations, classes or declarations in classes is expensive (if only a few of the total libraries are marked with @JS).
This optimization has reduced some Dart apps load times, under Dartium, by ~1000ms.
Its essentially a hint that we should interrogate this library using mirrors to look for the annotations otherwise we skip using mirrors on the ibrary. Every use of mirrors on a library can cause the VM to compile the library before its really needed. This also puts compilation to as needed instead of all up front at load time.
On Fri, Apr 8, 2016 at 9:34 AM, Phil Quitslund notifications@github.com wrote:
Also, where is the JS annotation defined? What package do folks import to find it?
— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/dart-lang/sdk/issues/26225#issuecomment-207505590
Also, where is the JS annotation defined? What package do folks import to find it?
There's a library js located in dart/pkg/js/lib In that library is a class JS
In a user's library will be a reference to:
import 'package:js/js.dart';
On Fri, Apr 8, 2016 at 9:59 AM, Phil Quitslund notifications@github.com wrote:
Also, where is the JS annotation defined? What package do folks import to find it?
Got it: https://pub.dartlang.org/packages/js
— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/dart-lang/sdk/issues/26225#issuecomment-207515804
Implemented and then fixed in ac48484a07ef3a8ad0109f4dfccfea2ce33267e0 and a2d14e8d5805fc50c210ec886f0306c8ec92100e respectively.
We're able to speed up JS interop by annotating a library with
@JS()
if it contains any@JS()
or@JS(...)
on any top-level declarations, classes or declarations in a class.The
@JS()
on a library must exist or Dartium will crash so the error should be fatal, not a warning.Here's an example of what we require: