@@ -22,6 +22,10 @@ class PragmaAnnotation {
22
22
final bool forFieldsOnly;
23
23
final bool internalOnly;
24
24
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
+
25
29
const PragmaAnnotation (this ._index, this .name,
26
30
{this .forFunctionsOnly = false ,
27
31
this .forFieldsOnly = false ,
@@ -41,15 +45,20 @@ class PragmaAnnotation {
41
45
static const PragmaAnnotation tryInline =
42
46
PragmaAnnotation (1 , 'tryInline' , forFunctionsOnly: true );
43
47
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
+
44
53
static const PragmaAnnotation disableFinal = PragmaAnnotation (
45
- 2 , 'disableFinal' ,
54
+ 3 , 'disableFinal' ,
46
55
forFunctionsOnly: true , internalOnly: true );
47
56
48
- static const PragmaAnnotation noElision = PragmaAnnotation (3 , 'noElision' );
57
+ static const PragmaAnnotation noElision = PragmaAnnotation (4 , 'noElision' );
49
58
50
59
/// Tells the optimizing compiler that the annotated method cannot throw.
51
60
/// Requires @pragma('dart2js:noInline') to function correctly.
52
- static const PragmaAnnotation noThrows = PragmaAnnotation (4 , 'noThrows' ,
61
+ static const PragmaAnnotation noThrows = PragmaAnnotation (5 , 'noThrows' ,
53
62
forFunctionsOnly: true , internalOnly: true );
54
63
55
64
/// Tells the optimizing compiler that the annotated method has no
@@ -58,56 +67,57 @@ class PragmaAnnotation {
58
67
///
59
68
/// Requires @pragma('dart2js:noInline') to function correctly.
60
69
static const PragmaAnnotation noSideEffects = PragmaAnnotation (
61
- 5 , 'noSideEffects' ,
70
+ 6 , 'noSideEffects' ,
62
71
forFunctionsOnly: true , internalOnly: true );
63
72
64
73
/// Use this as metadata on method declarations to disable closed world
65
74
/// assumptions on parameters, effectively assuming that the runtime arguments
66
75
/// could be any value. Note that the constraints due to static types still
67
76
/// apply.
68
77
static const PragmaAnnotation assumeDynamic = PragmaAnnotation (
69
- 6 , 'assumeDynamic' ,
78
+ 7 , 'assumeDynamic' ,
70
79
forFunctionsOnly: true , internalOnly: true );
71
80
72
- static const PragmaAnnotation asTrust = PragmaAnnotation (7 , 'as:trust' ,
81
+ static const PragmaAnnotation asTrust = PragmaAnnotation (8 , 'as:trust' ,
73
82
forFunctionsOnly: false , internalOnly: false );
74
83
75
- static const PragmaAnnotation asCheck = PragmaAnnotation (8 , 'as:check' ,
84
+ static const PragmaAnnotation asCheck = PragmaAnnotation (9 , 'as:check' ,
76
85
forFunctionsOnly: false , internalOnly: false );
77
86
78
- static const PragmaAnnotation typesTrust = PragmaAnnotation (9 , 'types:trust' ,
87
+ static const PragmaAnnotation typesTrust = PragmaAnnotation (10 , 'types:trust' ,
79
88
forFunctionsOnly: false , internalOnly: false );
80
89
81
- static const PragmaAnnotation typesCheck = PragmaAnnotation (10 , 'types:check' ,
90
+ static const PragmaAnnotation typesCheck = PragmaAnnotation (11 , 'types:check' ,
82
91
forFunctionsOnly: false , internalOnly: false );
83
92
84
93
static const PragmaAnnotation parameterTrust = PragmaAnnotation (
85
- 11 , 'parameter:trust' ,
94
+ 12 , 'parameter:trust' ,
86
95
forFunctionsOnly: false , internalOnly: false );
87
96
88
97
static const PragmaAnnotation parameterCheck = PragmaAnnotation (
89
- 12 , 'parameter:check' ,
98
+ 13 , 'parameter:check' ,
90
99
forFunctionsOnly: false , internalOnly: false );
91
100
92
101
static const PragmaAnnotation downcastTrust = PragmaAnnotation (
93
- 13 , 'downcast:trust' ,
102
+ 14 , 'downcast:trust' ,
94
103
forFunctionsOnly: false , internalOnly: false );
95
104
96
105
static const PragmaAnnotation downcastCheck = PragmaAnnotation (
97
- 14 , 'downcast:check' ,
106
+ 15 , 'downcast:check' ,
98
107
forFunctionsOnly: false , internalOnly: false );
99
108
100
109
static const PragmaAnnotation indexBoundsTrust = PragmaAnnotation (
101
- 15 , 'index-bounds:trust' ,
110
+ 16 , 'index-bounds:trust' ,
102
111
forFunctionsOnly: false , internalOnly: false );
103
112
104
113
static const PragmaAnnotation indexBoundsCheck = PragmaAnnotation (
105
- 16 , 'index-bounds:check' ,
114
+ 17 , 'index-bounds:check' ,
106
115
forFunctionsOnly: false , internalOnly: false );
107
116
108
117
static const List <PragmaAnnotation > values = [
109
118
noInline,
110
119
tryInline,
120
+ disableInlining,
111
121
disableFinal,
112
122
noElision,
113
123
noThrows,
@@ -273,6 +283,9 @@ abstract class AnnotationsData {
273
283
/// annotation.
274
284
bool hasTryInline (MemberEntity member);
275
285
286
+ /// Returns `true` if inlining is disabled at call sites inside [member] .
287
+ bool hasDisableInlining (MemberEntity member);
288
+
276
289
/// Returns `true` if [member] has a `@pragma('dart2js:disableFinal')`
277
290
/// annotation.
278
291
bool hasDisableFinal (MemberEntity member);
@@ -343,6 +356,7 @@ class AnnotationsDataImpl implements AnnotationsData {
343
356
final CheckPolicy _defaultConditionCheckPolicy;
344
357
final CheckPolicy _defaultExplicitCastCheckPolicy;
345
358
final CheckPolicy _defaultIndexBoundsCheckPolicy;
359
+ final bool _defaultDisableInlining;
346
360
final Map <MemberEntity , EnumSet <PragmaAnnotation >> pragmaAnnotations;
347
361
348
362
AnnotationsDataImpl (CompilerOptions options, this .pragmaAnnotations)
@@ -353,7 +367,8 @@ class AnnotationsDataImpl implements AnnotationsData {
353
367
this ._defaultExplicitCastCheckPolicy =
354
368
options.defaultExplicitCastCheckPolicy,
355
369
this ._defaultIndexBoundsCheckPolicy =
356
- options.defaultIndexBoundsCheckPolicy;
370
+ options.defaultIndexBoundsCheckPolicy,
371
+ this ._defaultDisableInlining = options.disableInlining;
357
372
358
373
factory AnnotationsDataImpl .readFromDataSource (
359
374
CompilerOptions options, DataSourceReader source) {
@@ -392,6 +407,11 @@ class AnnotationsDataImpl implements AnnotationsData {
392
407
bool hasTryInline (MemberEntity member) =>
393
408
_hasPragma (member, PragmaAnnotation .tryInline);
394
409
410
+ @override
411
+ bool hasDisableInlining (MemberEntity member) =>
412
+ _hasPragma (member, PragmaAnnotation .disableInlining) ||
413
+ _defaultDisableInlining;
414
+
395
415
@override
396
416
bool hasDisableFinal (MemberEntity member) =>
397
417
_hasPragma (member, PragmaAnnotation .disableFinal);
0 commit comments