Skip to content

Commit

Permalink
8287013: StringConcatFactory: remove short and byte mixers/prependers
Browse files Browse the repository at this point in the history
Reviewed-by: jlaskey
  • Loading branch information
cl4es committed May 20, 2022
1 parent 828dc89 commit d5d19f5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 75 deletions.
56 changes: 0 additions & 56 deletions src/java.base/share/classes/java/lang/StringConcatHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,6 @@ static long mix(long lengthCoder, boolean value) {
return checkOverflow(lengthCoder + (value ? 4 : 5));
}

/**
* Mix value length and coder into current length and coder.
* @param lengthCoder String length with coder packed into higher bits
* the upper word.
* @param value value to mix in
* @return new length and coder
*/
static long mix(long lengthCoder, byte value) {
return mix(lengthCoder, (int)value);
}

/**
* Mix value length and coder into current length and coder.
* @param lengthCoder String length with coder packed into higher bits
Expand All @@ -90,17 +79,6 @@ static long mix(long lengthCoder, char value) {
return checkOverflow(lengthCoder + 1) | (StringLatin1.canEncode(value) ? 0 : UTF16);
}

/**
* Mix value length and coder into current length and coder.
* @param lengthCoder String length with coder packed into higher bits
* the upper word.
* @param value value to mix in
* @return new length and coder
*/
static long mix(long lengthCoder, short value) {
return mix(lengthCoder, (int)value);
}

/**
* Mix value length and coder into current length and coder.
* @param lengthCoder String length with coder packed into higher bits
Expand Down Expand Up @@ -198,23 +176,6 @@ static long prepend(long indexCoder, byte[] buf, boolean value, String prefix) {
return indexCoder;
}

/**
* Prepends constant and the stringly representation of value into buffer,
* given the coder and final index. Index is measured in chars, not in bytes!
*
* @param indexCoder final char index in the buffer, along with coder packed
* into higher bits.
* @param buf buffer to append to
* @param value boolean value to encode
* @param prefix a constant to prepend before value
* @return updated index (coder value retained)
*/
static long prepend(long indexCoder, byte[] buf, byte value, String prefix) {
indexCoder = prepend(indexCoder, buf, (int)value);
if (prefix != null) indexCoder = prepend(indexCoder, buf, prefix);
return indexCoder;
}

/**
* Prepends the stringly representation of char value into buffer,
* given the coder and final index. Index is measured in chars, not in bytes!
Expand Down Expand Up @@ -251,23 +212,6 @@ static long prepend(long indexCoder, byte[] buf, char value, String prefix) {
return indexCoder;
}

/**
* Prepends constant and the stringly representation of value into buffer,
* given the coder and final index. Index is measured in chars, not in bytes!
*
* @param indexCoder final char index in the buffer, along with coder packed
* into higher bits.
* @param buf buffer to append to
* @param value boolean value to encode
* @param prefix a constant to prepend before value
* @return updated index (coder value retained)
*/
static long prepend(long indexCoder, byte[] buf, short value, String prefix) {
indexCoder = prepend(indexCoder, buf, (int)value);
if (prefix != null) indexCoder = prepend(indexCoder, buf, prefix);
return indexCoder;
}

/**
* Prepends the stringly representation of integer value into buffer,
* given the coder and final index. Index is measured in chars, not in bytes!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,19 @@ private static MethodHandle generateMHInlineCopy(MethodType mt, List<String> ele
Class<?>[] ptypes = mt.erase().parameterArray();
MethodHandle[] filters = null;
for (int i = 0; i < ptypes.length; i++) {
MethodHandle filter = stringifierFor(ptypes[i]);
Class<?> cl = ptypes[i];
MethodHandle filter = null;
if (cl == byte.class || cl == short.class) {
// use int for subword integral types; still need special mixers
// and prependers for char, boolean
ptypes[i] = int.class;
} else if (cl == Object.class) {
filter = objectStringifier();
} else if (cl == float.class) {
filter = floatStringifier();
} else if (cl == double.class) {
filter = doubleStringifier();
}
if (filter != null) {
if (filters == null) {
filters = new MethodHandle[ptypes.length];
Expand Down Expand Up @@ -825,24 +837,6 @@ private static MethodHandle unaryConcat(Class<?> cl) {
MIXERS = new ConcurrentHashMap<>();
}

/**
* Returns a stringifier for references and floats/doubles only.
* Always returns null for other primitives.
*
* @param t class to stringify
* @return stringifier; null, if not available
*/
private static MethodHandle stringifierFor(Class<?> t) {
if (t == Object.class) {
return objectStringifier();
} else if (t == float.class) {
return floatStringifier();
} else if (t == double.class) {
return doubleStringifier();
}
return null;
}

private static MethodHandle lookupStatic(Lookup lookup, Class<?> refc, String name,
Class<?> rtype, Class<?>... ptypes) {
try {
Expand Down

1 comment on commit d5d19f5

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.