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

Qute ValueResolver generator - minor cleanup and optimization #29975

Merged
merged 1 commit into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
Expand Up @@ -71,6 +71,7 @@
import io.quarkus.gizmo.ClassOutput;
import io.quarkus.gizmo.DescriptorUtils;
import io.quarkus.gizmo.FunctionCreator;
import io.quarkus.gizmo.Gizmo;
import io.quarkus.gizmo.MethodCreator;
import io.quarkus.gizmo.MethodDescriptor;
import io.quarkus.gizmo.ResultHandle;
Expand Down Expand Up @@ -960,8 +961,7 @@ private void implementResolve(String defaultBundleImpl, ClassCreator bundleCreat
ResultHandle ret = resolve.newInstance(MethodDescriptor.ofConstructor(CompletableFuture.class));

// First handle dynamic messages, i.e. the "message" virtual method
BytecodeCreator dynamicMessage = resolve.ifTrue(resolve.invokeVirtualMethod(Descriptors.EQUALS,
resolve.load(MESSAGE), name))
BytecodeCreator dynamicMessage = resolve.ifTrue(Gizmo.equals(resolve, resolve.load(MESSAGE), name))
.trueBranch();
ResultHandle evaluatedMessageKey = dynamicMessage.invokeStaticMethod(Descriptors.EVALUATED_PARAMS_EVALUATE_MESSAGE_KEY,
evalContext);
Expand All @@ -988,8 +988,8 @@ private void implementResolve(String defaultBundleImpl, ClassCreator bundleCreat
nameIsNull.invokeVirtualMethod(Descriptors.COMPLETABLE_FUTURE_COMPLETE, whenRet,
resultNotFound);
nameIsNull.returnValue(null);
BytecodeCreator nameNotFound = success.ifTrue(success.invokeVirtualMethod(Descriptors.EQUALS,
whenComplete.getMethodParam(0), resultNotFound)).trueBranch();
BytecodeCreator nameNotFound = success.ifTrue(Gizmo.equals(success, whenComplete.getMethodParam(0), resultNotFound))
.trueBranch();
nameNotFound.invokeVirtualMethod(Descriptors.COMPLETABLE_FUTURE_COMPLETE, whenRet, resultNotFound);
nameNotFound.returnValue(null);

Expand Down Expand Up @@ -1067,8 +1067,7 @@ private void addMessageMethod(MethodCreator resolve, String key, MethodInfo meth
ResultHandle ret, String bundleClass) {
List<Type> methodParams = method.parameterTypes();

BytecodeCreator matched = resolve.ifTrue(resolve.invokeVirtualMethod(Descriptors.EQUALS,
resolve.load(key), name))
BytecodeCreator matched = resolve.ifTrue(Gizmo.equals(resolve, resolve.load(key), name))
.trueBranch();
if (method.parameterTypes().isEmpty()) {
matched.invokeVirtualMethod(Descriptors.COMPLETABLE_FUTURE_COMPLETE, ret,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ private Descriptors() {
boolean.class, Class.class);
public static final MethodDescriptor GET_CLASS = MethodDescriptor.ofMethod(Object.class, "getClass", Class.class);
public static final MethodDescriptor COLLECTION_SIZE = MethodDescriptor.ofMethod(Collection.class, "size", int.class);
public static final MethodDescriptor EQUALS = MethodDescriptor.ofMethod(Object.class, "equals", boolean.class,
Object.class);
public static final MethodDescriptor GET_NAME = MethodDescriptor.ofMethod(EvalContext.class, "getName", String.class);
public static final MethodDescriptor GET_BASE = MethodDescriptor.ofMethod(EvalContext.class, "getBase", Object.class);
public static final MethodDescriptor GET_PARAMS = MethodDescriptor.ofMethod(EvalContext.class, "getParams", List.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import io.quarkus.gizmo.ClassOutput;
import io.quarkus.gizmo.FieldDescriptor;
import io.quarkus.gizmo.FunctionCreator;
import io.quarkus.gizmo.Gizmo;
import io.quarkus.gizmo.MethodCreator;
import io.quarkus.gizmo.MethodDescriptor;
import io.quarkus.gizmo.ResultHandle;
Expand Down Expand Up @@ -393,14 +394,12 @@ private void implementAppliesTo(ClassCreator valueResolver, MethodInfo method, S
// Any of the name matches
BytecodeCreator namesMatch = appliesTo.createScope();
for (String match : matchNames) {
ResultHandle nameTest = namesMatch.invokeVirtualMethod(Descriptors.EQUALS, name,
namesMatch.load(match));
ResultHandle nameTest = Gizmo.equals(namesMatch, name, namesMatch.load(match));
namesMatch.ifTrue(nameTest).trueBranch().breakScope(namesMatch);
}
namesMatch.returnValue(namesMatch.load(false));
} else {
ResultHandle nameTest = appliesTo.invokeVirtualMethod(Descriptors.EQUALS, name,
appliesTo.load(matchName));
ResultHandle nameTest = Gizmo.equals(appliesTo, name, appliesTo.load(matchName));
BytecodeCreator nameNotMatched = appliesTo.ifFalse(nameTest).trueBranch();
nameNotMatched.returnValue(nameNotMatched.load(false));
}
Expand Down Expand Up @@ -634,15 +633,12 @@ private BytecodeCreator createNamespaceExtensionMatchScope(BytecodeCreator bytec
// Any of the name matches
BytecodeCreator namesMatch = matchScope.createScope();
for (String match : matchNames) {
ResultHandle nameTest = namesMatch.invokeVirtualMethod(Descriptors.EQUALS, name,
namesMatch.load(match));
ResultHandle nameTest = Gizmo.equals(namesMatch, name, namesMatch.load(match));
namesMatch.ifTrue(nameTest).trueBranch().breakScope(namesMatch);
}
namesMatch.breakScope(matchScope);
} else {
matchScope.ifTrue(matchScope.invokeVirtualMethod(Descriptors.EQUALS,
matchScope.load(matchName),
name))
matchScope.ifTrue(Gizmo.equals(matchScope, matchScope.load(matchName), name))
.falseBranch().breakScope(matchScope);
}
}
Expand Down
Loading