Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Issue 11415067: Add annotations on native fields and methods (Closed)

Created:
8 years, 1 month ago by sra1
Modified:
8 years, 1 month ago
Reviewers:
vsm, ngeoffray
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Add annotations on native fields and methods Automatically add annotations on native fields and methods where the type is known to be a subtype of the API type. Example: The API is declared as returning List<Node>, but we know from the IDL that this is implemented by the native type _NodeList. Also add some manual annotations. The optimization is still hidden behind --enable-native-live-type-analysis Committed: https://code.google.com/p/dart/source/detail?r=15181

Patch Set 1 #

Total comments: 10

Patch Set 2 : regen #

Patch Set 3 : comment #

Unified diffs Side-by-side diffs Delta from patch set Stats (+141 lines, -43 lines) Patch
M sdk/lib/_internal/compiler/implementation/lib/js_array.dart View 1 1 chunk +1 line, -1 line 0 comments Download
M sdk/lib/_internal/compiler/implementation/lib/js_helper.dart View 1 2 2 chunks +53 lines, -0 lines 0 comments Download
M sdk/lib/html/dart2js/html_dart2js.dart View 1 44 chunks +54 lines, -15 lines 0 comments Download
M sdk/lib/html/scripts/generator.py View 3 chunks +16 lines, -12 lines 0 comments Download
M sdk/lib/html/scripts/systemhtml.py View 2 chunks +8 lines, -2 lines 0 comments Download
M sdk/lib/html/templates/html/dart2js/factoryprovider_MutationObserver.darttemplate View 1 chunk +3 lines, -13 lines 0 comments Download
M sdk/lib/html/templates/html/impl/impl_Element.darttemplate View 1 chunk +3 lines, -0 lines 0 comments Download
M sdk/lib/svg/dart2js/svg_dart2js.dart View 1 2 chunks +3 lines, -0 lines 0 comments Download

Messages

Total messages: 5 (0 generated)
sra1
This is the main win from native type liveness analysis. Half of the native classes ...
8 years, 1 month ago (2012-11-20 06:04:57 UTC) #1
ngeoffray
This is very nice! https://chromiumcodereview.appspot.com/11415067/diff/1/sdk/lib/html/templates/html/impl/impl_Element.darttemplate File sdk/lib/html/templates/html/impl/impl_Element.darttemplate (right): https://chromiumcodereview.appspot.com/11415067/diff/1/sdk/lib/html/templates/html/impl/impl_Element.darttemplate#newcode621 sdk/lib/html/templates/html/impl/impl_Element.darttemplate:621: @Creates('Null') // Set from Dart ...
8 years, 1 month ago (2012-11-20 08:50:13 UTC) #2
sra1
https://chromiumcodereview.appspot.com/11415067/diff/1/sdk/lib/html/templates/html/impl/impl_Element.darttemplate File sdk/lib/html/templates/html/impl/impl_Element.darttemplate (right): https://chromiumcodereview.appspot.com/11415067/diff/1/sdk/lib/html/templates/html/impl/impl_Element.darttemplate#newcode621 sdk/lib/html/templates/html/impl/impl_Element.darttemplate:621: @Creates('Null') // Set from Dart code; does not instantiate ...
8 years, 1 month ago (2012-11-20 09:01:42 UTC) #3
vsm
lgtm Nice results! https://chromiumcodereview.appspot.com/11415067/diff/1/sdk/lib/html/dart2js/html_dart2js.dart File sdk/lib/html/dart2js/html_dart2js.dart (right): https://chromiumcodereview.appspot.com/11415067/diff/1/sdk/lib/html/dart2js/html_dart2js.dart#newcode1131 sdk/lib/html/dart2js/html_dart2js.dart:1131: @Returns('_CSSRuleList') @Creates('_CSSRuleList') Does @Returns imply @Creates? ...
8 years, 1 month ago (2012-11-20 18:33:46 UTC) #4
sra1
8 years, 1 month ago (2012-11-20 19:26:33 UTC) #5
I will put or move some comments on to the declaration of Creates and Returns.

https://chromiumcodereview.appspot.com/11415067/diff/1/sdk/lib/html/dart2js/h...
File sdk/lib/html/dart2js/html_dart2js.dart (right):

https://chromiumcodereview.appspot.com/11415067/diff/1/sdk/lib/html/dart2js/h...
sdk/lib/html/dart2js/html_dart2js.dart:1131: @Returns('_CSSRuleList')
@Creates('_CSSRuleList')
On 2012/11/20 18:33:46, vsm wrote:
> Does @Returns imply @Creates?

No.  There is no cross-use of the annotations.
I could change that.

https://chromiumcodereview.appspot.com/11415067/diff/1/sdk/lib/html/dart2js/h...
sdk/lib/html/dart2js/html_dart2js.dart:12254: @Creates('Database')
@Creates('DatabaseSync')
On 2012/11/20 18:33:46, vsm wrote:
> FWIW, the first is redundant with the return type.  Does this really create a
> DatabaseSync?

1. If you give any Creates annotation, you must give them all.  Otherwise you
cant stop the pollution due to a a bad declared return type like Object.

2. The callback has both, which unions to Object, so the callback is causing
pollution.

3. I'm not sure if we can actually get the Sync version so this is conservative,
based on the types.

https://chromiumcodereview.appspot.com/11415067/diff/1/sdk/lib/html/dart2js/h...
sdk/lib/html/dart2js/html_dart2js.dart:13215: @Creates('=List')
On 2012/11/20 18:33:46, vsm wrote:
> What's the significance of the "="?

=List is a special hack to name JavaScript Array.
=Object is a special hack to name a plain JS Object.

https://chromiumcodereview.appspot.com/11415067/diff/1/sdk/lib/html/templates...
File
sdk/lib/html/templates/html/dart2js/factoryprovider_MutationObserver.darttemplate
(right):

https://chromiumcodereview.appspot.com/11415067/diff/1/sdk/lib/html/templates...
sdk/lib/html/templates/html/dart2js/factoryprovider_MutationObserver.darttemplate:10:
@Creates('MutationRecord')
On 2012/11/20 18:33:46, vsm wrote:
> Should MutationRecord be somehow specified on MutationCallback instead?  E.g.,
> if no passed in callback uses the MutationRecord, the type doesn't really leak
> anywhere else.

1. Inference through the callback is broken for two reasons - (a) lack of stored
type parameters in the compiler causes all Lists to be inferred (b) no concrete
type implementing List<MutationRecord>.

(a) can be fixed.  (b) is how we want it - you only create instances of T from
List<T> when you access the list.  The type inference is based on concrete
types, which have precise non-parameter types on operator[].  It would be much
more complicated to implement with non-concrete types.  In the few places that
actually return JS array we have no concrete type with a specialized type on the
accessors, so we make up for that manually.

2. If you give one @Creates you must give them all - i.e. specifying
MutationObserver inhibits the use of the (overly general) types inferred from
the callback's type.

Powered by Google App Engine
This is Rietveld 408576698