Skip to content

Commit cce2b88

Browse files
brad4dTyler Breisacher
authored and
Tyler Breisacher
committed
Create a @noinline annotation: currently a noop
Followup changes will modify inlining passes to honor this annotation. Related to #2751 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=179756574
1 parent 2621850 commit cce2b88

File tree

6 files changed

+43
-4
lines changed

6 files changed

+43
-4
lines changed

Diff for: src/com/google/javascript/jscomp/parsing/Annotation.java

+2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ enum Annotation {
6363
NO_ALIAS,
6464
NO_COLLAPSE,
6565
NO_COMPILE,
66+
NO_INLINE,
6667
NO_SIDE_EFFECTS,
6768
NOT_IMPLEMENTED,
6869
OVERRIDE,
@@ -133,6 +134,7 @@ enum Annotation {
133134
.put("noalias", Annotation.NO_ALIAS)
134135
.put("nocollapse", Annotation.NO_COLLAPSE)
135136
.put("nocompile", Annotation.NO_COMPILE)
137+
.put("noinline", Annotation.NO_INLINE)
136138
.put("nosideeffects", Annotation.NO_SIDE_EFFECTS)
137139
.put("override", Annotation.OVERRIDE)
138140
.put("owner", Annotation.AUTHOR)

Diff for: src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java

+6
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,12 @@ private JsDocToken parseAnnotation(JsDocToken token,
720720
}
721721
return eatUntilEOLIfNotAnnotation();
722722

723+
case NO_INLINE:
724+
if (!jsdocBuilder.recordNoInline()) {
725+
addParserWarning("msg.jsdoc.noinline");
726+
}
727+
return eatUntilEOLIfNotAnnotation();
728+
723729
case NOT_IMPLEMENTED:
724730
return eatUntilEOLIfNotAnnotation();
725731

Diff for: src/com/google/javascript/jscomp/resources.json

+1-1
Large diffs are not rendered by default.

Diff for: src/com/google/javascript/rhino/JSDocInfo.java

+14-3
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,7 @@ private static boolean areEquivalent(Marker m1, Marker m2) {
503503
private static final int MASK_DEPRECATED = 0x00000100; // @deprecated
504504
private static final int MASK_INTERFACE = 0x00000200; // @interface
505505
private static final int MASK_EXPORT = 0x00000400; // @export
506-
@SuppressWarnings("unused")
507-
private static final int MASK_UNUSED_2 = 0x00000800; //
506+
private static final int MASK_NOINLINE = 0x00000800; // @noinline
508507
private static final int MASK_FILEOVERVIEW = 0x00001000; // @fileoverview
509508
private static final int MASK_IMPLICITCAST = 0x00002000; // @implicitCast
510509
private static final int MASK_NOSIDEEFFECTS = 0x00004000; // @nosideeffects
@@ -732,6 +731,10 @@ void setNoCollapse(boolean value) {
732731
setFlag(value, MASK_NOCOLLAPSE);
733732
}
734733

734+
void setNoInline(boolean value) {
735+
setFlag(value, MASK_NOINLINE);
736+
}
737+
735738
private void setFlag(boolean value, int mask) {
736739
if (value) {
737740
bitset |= mask;
@@ -957,13 +960,21 @@ public boolean isNoCompile() {
957960
}
958961

959962
/**
960-
* Returns whether the {@code @nocompile} annotation is present on this
963+
* Returns whether the {@code @nocollapse} annotation is present on this
961964
* {@link JSDocInfo}.
962965
*/
963966
public boolean isNoCollapse() {
964967
return getFlag(MASK_NOCOLLAPSE);
965968
}
966969

970+
/**
971+
* Returns whether the {@code @noinline} annotation is present on this
972+
* {@link JSDocInfo}.
973+
*/
974+
public boolean isNoInline() {
975+
return getFlag(MASK_NOINLINE);
976+
}
977+
967978
/**
968979
* @return Whether there is a declaration present on this {@link JSDocInfo}.
969980
*/

Diff for: src/com/google/javascript/rhino/JSDocInfoBuilder.java

+17
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,23 @@ public boolean recordNoCollapse() {
887887
}
888888
}
889889

890+
/**
891+
* Records that the {@link JSDocInfo} being built should have its
892+
* {@link JSDocInfo#isNoInline()} flag set to {@code true}.
893+
*
894+
* @return {@code true} if the no inline flag was recorded and {@code false}
895+
* if it was already recorded
896+
*/
897+
public boolean recordNoInline() {
898+
if (!currentInfo.isNoInline()) {
899+
currentInfo.setNoInline(true);
900+
populated = true;
901+
return true;
902+
} else {
903+
return false;
904+
}
905+
}
906+
890907
/**
891908
* Records that the {@link JSDocInfo} being built should have its
892909
* {@link JSDocInfo#isConstructor()} flag set to {@code true}.

Diff for: src/com/google/javascript/rhino/Messages.properties

+3
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ msg.jsdoc.nocompile =\
247247
msg.jsdoc.nocollapse =\
248248
extra @nocollapse tag
249249

250+
msg.jsdoc.noinline =\
251+
extra @noinline tag
252+
250253
msg.jsdoc.seemissing =\
251254
@see tag missing description
252255

0 commit comments

Comments
 (0)