Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concat Transform Optimizations #149

Closed
wants to merge 8 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -92,26 +92,22 @@ static void buildFromTree(Block.Builder block, Op.Result builder, Value v) {
}

private static Op append(Block.Builder block, Value builder, Value arg) {
return append(block, builder, arg, arg.type());
}

private static Op append(Block.Builder block, Value builder, Value arg, TypeElement type) {
// Check if we need to widen unsupported integer types in the StringBuilder API
// Strings are fed in as-is, everything else given as an Object.
TypeElement appendType = type;
Value appendValue = arg;
if (type instanceof PrimitiveType || type.equals(JavaType.J_L_STRING)) {
//Widen if we need to.
TypeElement type = arg.type();
if (type instanceof PrimitiveType) {
//Widen Short and Byte to Int.
if (type.equals(JavaType.BYTE) || type.equals(JavaType.SHORT)) {
appendValue = block.op(CoreOp.conv(JavaType.INT, arg));
appendType = JavaType.INT;
arg = block.op(CoreOp.conv(JavaType.INT, arg));
type = JavaType.INT;
}
} else if (!type.equals(JavaType.J_L_STRING)){
type = JavaType.J_L_OBJECT;
}
else {
appendType = JavaType.J_L_OBJECT;
}
MethodRef methodDesc = MethodRef.method(J_L_STRING_BUILDER, "append", J_L_STRING_BUILDER, appendType);
return CoreOp.invoke(methodDesc, builder, appendValue);

MethodRef methodDesc = MethodRef.method(J_L_STRING_BUILDER, "append", J_L_STRING_BUILDER, type);
return CoreOp.invoke(methodDesc, builder, arg);
}


}