Skip to content

Commit f10368c

Browse files
committed
Merge master HEAD into openj9-staging
Signed-off-by: J9 Build <[email protected]>
2 parents b6be74b + fff84aa commit f10368c

30 files changed

+725
-150
lines changed

src/java.compiler/share/classes/javax/tools/JavaFileManager.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ interface Location {
170170
* @since 9
171171
*/
172172
default boolean isModuleOrientedLocation() {
173-
return getName().matches("\\bMODULE\\b");
173+
return StandardLocation.computeIsModuleOrientedLocation(getName());
174174
}
175175
}
176176

src/java.compiler/share/classes/javax/tools/StandardLocation.java

+50-15
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727

2828
import javax.tools.JavaFileManager.Location;
2929

30+
import java.util.Objects;
3031
import java.util.concurrent.*;
32+
import java.util.regex.Pattern;
3133

3234
/**
3335
* Standard locations of file objects.
@@ -109,6 +111,22 @@ public enum StandardLocation implements Location {
109111
*/
110112
PATCH_MODULE_PATH;
111113

114+
/**
115+
* Canonical location instances.
116+
*/
117+
private static final ConcurrentHashMap<String, Location> LOCATIONS = new ConcurrentHashMap<>();
118+
119+
private static class LazyPatternHolder {
120+
/**
121+
* Regexp that checks for the word "MODULE".
122+
*/
123+
static final Pattern MODULE_WORD_PATTERN = Pattern.compile("\\bMODULE\\b");
124+
}
125+
126+
/* package private */ static final boolean computeIsModuleOrientedLocation(String name) {
127+
return LazyPatternHolder.MODULE_WORD_PATTERN.matcher(name).matches();
128+
}
129+
112130
/**
113131
* Returns a location object with the given name. The following
114132
* property must hold: {@code locationFor(x) ==
@@ -122,23 +140,40 @@ public enum StandardLocation implements Location {
122140
* @return a location
123141
*/
124142
public static Location locationFor(final String name) {
125-
if (locations.isEmpty()) {
126-
// can't use valueOf which throws IllegalArgumentException
127-
for (Location location : values())
128-
locations.putIfAbsent(location.getName(), location);
143+
Objects.requireNonNull(name, "name");
144+
145+
// Check for immediate hit.
146+
Location loc = LOCATIONS.get(name);
147+
if (loc != null) {
148+
return loc;
149+
}
150+
151+
// Need to create the cache entry.
152+
Location newLoc = null;
153+
154+
// See if this is one of the known Locations first.
155+
for (Location location : values()) {
156+
if (location.getName().equals(name)) {
157+
newLoc = location;
158+
break;
159+
}
129160
}
130-
name.getClass(); /* null-check */
131-
locations.putIfAbsent(name, new Location() {
132-
@Override
133-
public String getName() { return name; }
134-
@Override
135-
public boolean isOutputLocation() { return name.endsWith("_OUTPUT"); }
136-
});
137-
return locations.get(name);
161+
162+
// Compute the fitting instance for unknown location, if needed.
163+
if (newLoc == null) {
164+
boolean isOutputLocation = name.endsWith("_OUTPUT");
165+
boolean isModuleOrientedLocation = computeIsModuleOrientedLocation(name);
166+
newLoc = new Location() {
167+
@Override public String getName() { return name; }
168+
@Override public boolean isOutputLocation() { return isOutputLocation; }
169+
@Override public boolean isModuleOrientedLocation() { return isModuleOrientedLocation; }
170+
};
171+
}
172+
173+
// Thread-safe install.
174+
Location exist = LOCATIONS.putIfAbsent(name, newLoc);
175+
return (exist != null) ? exist : newLoc;
138176
}
139-
//where
140-
private static final ConcurrentMap<String,Location> locations
141-
= new ConcurrentHashMap<>();
142177

143178
@Override
144179
public String getName() { return name(); }

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractVector.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ abstract class AbstractVector<E> extends Vector<E> {
4444
/**
4545
* The order of vector bytes when stored in natural,
4646
* array elements of the same lane type.
47-
* This is the also the behavior of the
47+
* This is also the behavior of the
4848
* VectorSupport load/store instructions.
4949
* If these instructions gain the capability to do
5050
* byte swapping on the fly, add a bit to those
@@ -302,8 +302,9 @@ public DoubleVector reinterpretAsDoubles() {
302302
Vector<F> convert(Conversion<E,F> conv, int part) {
303303
// Shape invariance is simple to implement.
304304
// It's part of the API because shape invariance
305-
// is the default mode of operation, and shape
306-
// shifting operations must advertise themselves.
305+
// is the default mode of operation, and
306+
// shape-shifting operations must advertise
307+
// themselves.
307308
ConversionImpl<E,F> c = (ConversionImpl<E,F>) conv;
308309
@SuppressWarnings("unchecked")
309310
VectorSpecies<F> rsp = (VectorSpecies<F>)

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static boolean opKind(Operator op, int bit) {
8484
// super.bOp((Byte128Vector) o);
8585
// The purpose of that is to forcibly inline
8686
// the generic definition from this file
87-
// into a sharply type- and size-specific
87+
// into a sharply-typed and size-specific
8888
// wrapper in the subclass file, so that
8989
// the JIT can specialize the code.
9090
// The code is only inlined and expanded
@@ -554,7 +554,7 @@ static ByteVector selectFromTwoVectorHelper(Vector<Byte> indexes, Vector<Byte> s
554554
// Note: A surprising behavior in javadoc
555555
// sometimes makes a lone /** {@inheritDoc} */
556556
// comment drop the method altogether,
557-
// apparently if the method mentions an
557+
// apparently if the method mentions a
558558
// parameter or return type of Vector<Byte>
559559
// instead of Vector<E> as originally specified.
560560
// Adding an empty HTML fragment appears to
@@ -1748,7 +1748,7 @@ public final ByteVector max(byte e) {
17481748
* Computes the bitwise logical conjunction ({@code &})
17491749
* of this vector and a second input vector.
17501750
*
1751-
* This is a lane-wise binary operation which applies the
1751+
* This is a lane-wise binary operation which applies
17521752
* the primitive bitwise "and" operation ({@code &})
17531753
* to each pair of corresponding lane values.
17541754
*
@@ -1781,7 +1781,7 @@ public final ByteVector and(Vector<Byte> v) {
17811781
* Computes the bitwise logical conjunction ({@code &})
17821782
* of this vector and a scalar.
17831783
*
1784-
* This is a lane-wise binary operation which applies the
1784+
* This is a lane-wise binary operation which applies
17851785
* the primitive bitwise "and" operation ({@code &})
17861786
* to each pair of corresponding lane values.
17871787
*
@@ -1805,7 +1805,7 @@ public final ByteVector and(byte e) {
18051805
* Computes the bitwise logical disjunction ({@code |})
18061806
* of this vector and a second input vector.
18071807
*
1808-
* This is a lane-wise binary operation which applies the
1808+
* This is a lane-wise binary operation which applies
18091809
* the primitive bitwise "or" operation ({@code |})
18101810
* to each pair of corresponding lane values.
18111811
*
@@ -1838,7 +1838,7 @@ public final ByteVector or(Vector<Byte> v) {
18381838
* Computes the bitwise logical disjunction ({@code |})
18391839
* of this vector and a scalar.
18401840
*
1841-
* This is a lane-wise binary operation which applies the
1841+
* This is a lane-wise binary operation which applies
18421842
* the primitive bitwise "or" operation ({@code |})
18431843
* to each pair of corresponding lane values.
18441844
*
@@ -1906,7 +1906,7 @@ static byte reverse(byte a) {
19061906
* Computes the bitwise logical complement ({@code ~})
19071907
* of this vector.
19081908
*
1909-
* This is a lane-wise binary operation which applies the
1909+
* This is a lane-wise binary operation which applies
19101910
* the primitive bitwise "not" operation ({@code ~})
19111911
* to each lane value.
19121912
*
@@ -2950,7 +2950,7 @@ public final byte[] toArray() {
29502950

29512951
/** {@inheritDoc} <!--workaround-->
29522952
* @implNote
2953-
* When this method is used on used on vectors
2953+
* When this method is used on vectors
29542954
* of type {@code ByteVector},
29552955
* there will be no loss of precision or range,
29562956
* and so no {@code UnsupportedOperationException} will
@@ -2970,7 +2970,7 @@ public final int[] toIntArray() {
29702970

29712971
/** {@inheritDoc} <!--workaround-->
29722972
* @implNote
2973-
* When this method is used on used on vectors
2973+
* When this method is used on vectors
29742974
* of type {@code ByteVector},
29752975
* there will be no loss of precision or range,
29762976
* and so no {@code UnsupportedOperationException} will
@@ -2990,7 +2990,7 @@ public final long[] toLongArray() {
29902990

29912991
/** {@inheritDoc} <!--workaround-->
29922992
* @implNote
2993-
* When this method is used on used on vectors
2993+
* When this method is used on vectors
29942994
* of type {@code ByteVector},
29952995
* there will be no loss of precision.
29962996
*/

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static boolean opKind(Operator op, int bit) {
8484
// super.bOp((Byte128Vector) o);
8585
// The purpose of that is to forcibly inline
8686
// the generic definition from this file
87-
// into a sharply type- and size-specific
87+
// into a sharply-typed and size-specific
8888
// wrapper in the subclass file, so that
8989
// the JIT can specialize the code.
9090
// The code is only inlined and expanded
@@ -543,7 +543,7 @@ static DoubleVector selectFromTwoVectorHelper(Vector<Double> indexes, Vector<Dou
543543
// Note: A surprising behavior in javadoc
544544
// sometimes makes a lone /** {@inheritDoc} */
545545
// comment drop the method altogether,
546-
// apparently if the method mentions an
546+
// apparently if the method mentions a
547547
// parameter or return type of Vector<Double>
548548
// instead of Vector<E> as originally specified.
549549
// Adding an empty HTML fragment appears to
@@ -2771,7 +2771,7 @@ public final long[] toLongArray() {
27712771
/** {@inheritDoc} <!--workaround-->
27722772
* @implNote
27732773
* This is an alias for {@link #toArray()}
2774-
* When this method is used on used on vectors
2774+
* When this method is used on vectors
27752775
* of type {@code DoubleVector},
27762776
* there will be no loss of precision.
27772777
*/

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float16.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -2262,7 +2262,7 @@ static long pow10(int e) {
22622262
* &lt; 10<sup><i>k</i>+1</sup>.
22632263
* <p>
22642264
* The result is correct when |{@code e}| &le; 6_432_162.
2265-
* Otherwise the result is undefined.
2265+
* Otherwise, the result is undefined.
22662266
*
22672267
* @param e The exponent of 2, which should meet
22682268
* |{@code e}| &le; 6_432_162 for safe results.
@@ -2279,7 +2279,7 @@ static int flog10pow2(int e) {
22792279
* <p>
22802280
* The result is correct when
22812281
* -3_606_689 &le; {@code e} &le; 3_150_619.
2282-
* Otherwise the result is undefined.
2282+
* Otherwise, the result is undefined.
22832283
*
22842284
* @param e The exponent of 2, which should meet
22852285
* -3_606_689 &le; {@code e} &le; 3_150_619 for safe results.
@@ -2296,7 +2296,7 @@ static int flog10threeQuartersPow2(int e) {
22962296
* &lt; 2<sup><i>k</i>+1</sup>.
22972297
* <p>
22982298
* The result is correct when |{@code e}| &le; 1_838_394.
2299-
* Otherwise the result is undefined.
2299+
* Otherwise, the result is undefined.
23002300
*
23012301
* @param e The exponent of 10, which should meet
23022302
* |{@code e}| &le; 1_838_394 for safe results.

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static boolean opKind(Operator op, int bit) {
8484
// super.bOp((Byte128Vector) o);
8585
// The purpose of that is to forcibly inline
8686
// the generic definition from this file
87-
// into a sharply type- and size-specific
87+
// into a sharply-typed and size-specific
8888
// wrapper in the subclass file, so that
8989
// the JIT can specialize the code.
9090
// The code is only inlined and expanded
@@ -543,7 +543,7 @@ static FloatVector selectFromTwoVectorHelper(Vector<Float> indexes, Vector<Float
543543
// Note: A surprising behavior in javadoc
544544
// sometimes makes a lone /** {@inheritDoc} */
545545
// comment drop the method altogether,
546-
// apparently if the method mentions an
546+
// apparently if the method mentions a
547547
// parameter or return type of Vector<Float>
548548
// instead of Vector<E> as originally specified.
549549
// Adding an empty HTML fragment appears to
@@ -2790,7 +2790,7 @@ public final long[] toLongArray() {
27902790

27912791
/** {@inheritDoc} <!--workaround-->
27922792
* @implNote
2793-
* When this method is used on used on vectors
2793+
* When this method is used on vectors
27942794
* of type {@code FloatVector},
27952795
* there will be no loss of precision.
27962796
*/

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static boolean opKind(Operator op, int bit) {
8484
// super.bOp((Byte128Vector) o);
8585
// The purpose of that is to forcibly inline
8686
// the generic definition from this file
87-
// into a sharply type- and size-specific
87+
// into a sharply-typed and size-specific
8888
// wrapper in the subclass file, so that
8989
// the JIT can specialize the code.
9090
// The code is only inlined and expanded
@@ -554,7 +554,7 @@ static IntVector selectFromTwoVectorHelper(Vector<Integer> indexes, Vector<Integ
554554
// Note: A surprising behavior in javadoc
555555
// sometimes makes a lone /** {@inheritDoc} */
556556
// comment drop the method altogether,
557-
// apparently if the method mentions an
557+
// apparently if the method mentions a
558558
// parameter or return type of Vector<Integer>
559559
// instead of Vector<E> as originally specified.
560560
// Adding an empty HTML fragment appears to
@@ -1751,7 +1751,7 @@ public final IntVector max(int e) {
17511751
* Computes the bitwise logical conjunction ({@code &})
17521752
* of this vector and a second input vector.
17531753
*
1754-
* This is a lane-wise binary operation which applies the
1754+
* This is a lane-wise binary operation which applies
17551755
* the primitive bitwise "and" operation ({@code &})
17561756
* to each pair of corresponding lane values.
17571757
*
@@ -1784,7 +1784,7 @@ public final IntVector and(Vector<Integer> v) {
17841784
* Computes the bitwise logical conjunction ({@code &})
17851785
* of this vector and a scalar.
17861786
*
1787-
* This is a lane-wise binary operation which applies the
1787+
* This is a lane-wise binary operation which applies
17881788
* the primitive bitwise "and" operation ({@code &})
17891789
* to each pair of corresponding lane values.
17901790
*
@@ -1808,7 +1808,7 @@ public final IntVector and(int e) {
18081808
* Computes the bitwise logical disjunction ({@code |})
18091809
* of this vector and a second input vector.
18101810
*
1811-
* This is a lane-wise binary operation which applies the
1811+
* This is a lane-wise binary operation which applies
18121812
* the primitive bitwise "or" operation ({@code |})
18131813
* to each pair of corresponding lane values.
18141814
*
@@ -1841,7 +1841,7 @@ public final IntVector or(Vector<Integer> v) {
18411841
* Computes the bitwise logical disjunction ({@code |})
18421842
* of this vector and a scalar.
18431843
*
1844-
* This is a lane-wise binary operation which applies the
1844+
* This is a lane-wise binary operation which applies
18451845
* the primitive bitwise "or" operation ({@code |})
18461846
* to each pair of corresponding lane values.
18471847
*
@@ -1891,7 +1891,7 @@ IntVector abs() {
18911891
* Computes the bitwise logical complement ({@code ~})
18921892
* of this vector.
18931893
*
1894-
* This is a lane-wise binary operation which applies the
1894+
* This is a lane-wise binary operation which applies
18951895
* the primitive bitwise "not" operation ({@code ~})
18961896
* to each lane value.
18971897
*
@@ -2936,7 +2936,7 @@ public final int[] toArray() {
29362936
/**
29372937
* {@inheritDoc} <!--workaround-->
29382938
* This is an alias for {@link #toArray()}
2939-
* When this method is used on used on vectors
2939+
* When this method is used on vectors
29402940
* of type {@code IntVector},
29412941
* there will be no loss of range or precision.
29422942
*/
@@ -2948,7 +2948,7 @@ public final int[] toIntArray() {
29482948

29492949
/** {@inheritDoc} <!--workaround-->
29502950
* @implNote
2951-
* When this method is used on used on vectors
2951+
* When this method is used on vectors
29522952
* of type {@code IntVector},
29532953
* there will be no loss of precision or range,
29542954
* and so no {@code UnsupportedOperationException} will
@@ -2968,7 +2968,7 @@ public final long[] toLongArray() {
29682968

29692969
/** {@inheritDoc} <!--workaround-->
29702970
* @implNote
2971-
* When this method is used on used on vectors
2971+
* When this method is used on vectors
29722972
* of type {@code IntVector},
29732973
* there will be no loss of precision.
29742974
*/

0 commit comments

Comments
 (0)