@@ -22,6 +22,10 @@ class PragmaAnnotation {
2222 final bool forFieldsOnly;
2323 final bool internalOnly;
2424
25+ // TODO(sra): Review [forFunctionsOnly] and [forFieldsOnly]. Fields have
26+ // implied getters and setters, so some annotations meant only for functions
27+ // could reasonable be placed on a field to apply to the getter and setter.
28+
2529 const PragmaAnnotation (this ._index, this .name,
2630 {this .forFunctionsOnly = false ,
2731 this .forFieldsOnly = false ,
@@ -41,15 +45,20 @@ class PragmaAnnotation {
4145 static const PragmaAnnotation tryInline =
4246 PragmaAnnotation (1 , 'tryInline' , forFunctionsOnly: true );
4347
48+ /// Annotation on a member that tells the optimizing compiler to disable
49+ /// inlining at call sites within the member.
50+ static const PragmaAnnotation disableInlining =
51+ PragmaAnnotation (2 , 'disable-inlining' );
52+
4453 static const PragmaAnnotation disableFinal = PragmaAnnotation (
45- 2 , 'disableFinal' ,
54+ 3 , 'disableFinal' ,
4655 forFunctionsOnly: true , internalOnly: true );
4756
48- static const PragmaAnnotation noElision = PragmaAnnotation (3 , 'noElision' );
57+ static const PragmaAnnotation noElision = PragmaAnnotation (4 , 'noElision' );
4958
5059 /// Tells the optimizing compiler that the annotated method cannot throw.
5160 /// Requires @pragma('dart2js:noInline') to function correctly.
52- static const PragmaAnnotation noThrows = PragmaAnnotation (4 , 'noThrows' ,
61+ static const PragmaAnnotation noThrows = PragmaAnnotation (5 , 'noThrows' ,
5362 forFunctionsOnly: true , internalOnly: true );
5463
5564 /// Tells the optimizing compiler that the annotated method has no
@@ -58,56 +67,57 @@ class PragmaAnnotation {
5867 ///
5968 /// Requires @pragma('dart2js:noInline') to function correctly.
6069 static const PragmaAnnotation noSideEffects = PragmaAnnotation (
61- 5 , 'noSideEffects' ,
70+ 6 , 'noSideEffects' ,
6271 forFunctionsOnly: true , internalOnly: true );
6372
6473 /// Use this as metadata on method declarations to disable closed world
6574 /// assumptions on parameters, effectively assuming that the runtime arguments
6675 /// could be any value. Note that the constraints due to static types still
6776 /// apply.
6877 static const PragmaAnnotation assumeDynamic = PragmaAnnotation (
69- 6 , 'assumeDynamic' ,
78+ 7 , 'assumeDynamic' ,
7079 forFunctionsOnly: true , internalOnly: true );
7180
72- static const PragmaAnnotation asTrust = PragmaAnnotation (7 , 'as:trust' ,
81+ static const PragmaAnnotation asTrust = PragmaAnnotation (8 , 'as:trust' ,
7382 forFunctionsOnly: false , internalOnly: false );
7483
75- static const PragmaAnnotation asCheck = PragmaAnnotation (8 , 'as:check' ,
84+ static const PragmaAnnotation asCheck = PragmaAnnotation (9 , 'as:check' ,
7685 forFunctionsOnly: false , internalOnly: false );
7786
78- static const PragmaAnnotation typesTrust = PragmaAnnotation (9 , 'types:trust' ,
87+ static const PragmaAnnotation typesTrust = PragmaAnnotation (10 , 'types:trust' ,
7988 forFunctionsOnly: false , internalOnly: false );
8089
81- static const PragmaAnnotation typesCheck = PragmaAnnotation (10 , 'types:check' ,
90+ static const PragmaAnnotation typesCheck = PragmaAnnotation (11 , 'types:check' ,
8291 forFunctionsOnly: false , internalOnly: false );
8392
8493 static const PragmaAnnotation parameterTrust = PragmaAnnotation (
85- 11 , 'parameter:trust' ,
94+ 12 , 'parameter:trust' ,
8695 forFunctionsOnly: false , internalOnly: false );
8796
8897 static const PragmaAnnotation parameterCheck = PragmaAnnotation (
89- 12 , 'parameter:check' ,
98+ 13 , 'parameter:check' ,
9099 forFunctionsOnly: false , internalOnly: false );
91100
92101 static const PragmaAnnotation downcastTrust = PragmaAnnotation (
93- 13 , 'downcast:trust' ,
102+ 14 , 'downcast:trust' ,
94103 forFunctionsOnly: false , internalOnly: false );
95104
96105 static const PragmaAnnotation downcastCheck = PragmaAnnotation (
97- 14 , 'downcast:check' ,
106+ 15 , 'downcast:check' ,
98107 forFunctionsOnly: false , internalOnly: false );
99108
100109 static const PragmaAnnotation indexBoundsTrust = PragmaAnnotation (
101- 15 , 'index-bounds:trust' ,
110+ 16 , 'index-bounds:trust' ,
102111 forFunctionsOnly: false , internalOnly: false );
103112
104113 static const PragmaAnnotation indexBoundsCheck = PragmaAnnotation (
105- 16 , 'index-bounds:check' ,
114+ 17 , 'index-bounds:check' ,
106115 forFunctionsOnly: false , internalOnly: false );
107116
108117 static const List <PragmaAnnotation > values = [
109118 noInline,
110119 tryInline,
120+ disableInlining,
111121 disableFinal,
112122 noElision,
113123 noThrows,
@@ -273,6 +283,9 @@ abstract class AnnotationsData {
273283 /// annotation.
274284 bool hasTryInline (MemberEntity member);
275285
286+ /// Returns `true` if inlining is disabled at call sites inside [member] .
287+ bool hasDisableInlining (MemberEntity member);
288+
276289 /// Returns `true` if [member] has a `@pragma('dart2js:disableFinal')`
277290 /// annotation.
278291 bool hasDisableFinal (MemberEntity member);
@@ -343,6 +356,7 @@ class AnnotationsDataImpl implements AnnotationsData {
343356 final CheckPolicy _defaultConditionCheckPolicy;
344357 final CheckPolicy _defaultExplicitCastCheckPolicy;
345358 final CheckPolicy _defaultIndexBoundsCheckPolicy;
359+ final bool _defaultDisableInlining;
346360 final Map <MemberEntity , EnumSet <PragmaAnnotation >> pragmaAnnotations;
347361
348362 AnnotationsDataImpl (CompilerOptions options, this .pragmaAnnotations)
@@ -353,7 +367,8 @@ class AnnotationsDataImpl implements AnnotationsData {
353367 this ._defaultExplicitCastCheckPolicy =
354368 options.defaultExplicitCastCheckPolicy,
355369 this ._defaultIndexBoundsCheckPolicy =
356- options.defaultIndexBoundsCheckPolicy;
370+ options.defaultIndexBoundsCheckPolicy,
371+ this ._defaultDisableInlining = options.disableInlining;
357372
358373 factory AnnotationsDataImpl .readFromDataSource (
359374 CompilerOptions options, DataSourceReader source) {
@@ -392,6 +407,11 @@ class AnnotationsDataImpl implements AnnotationsData {
392407 bool hasTryInline (MemberEntity member) =>
393408 _hasPragma (member, PragmaAnnotation .tryInline);
394409
410+ @override
411+ bool hasDisableInlining (MemberEntity member) =>
412+ _hasPragma (member, PragmaAnnotation .disableInlining) ||
413+ _defaultDisableInlining;
414+
395415 @override
396416 bool hasDisableFinal (MemberEntity member) =>
397417 _hasPragma (member, PragmaAnnotation .disableFinal);
0 commit comments