Skip to content

Commit

Permalink
Merge pull request #29975 from mkouba/qute-generator-minor-cleanup
Browse files Browse the repository at this point in the history
Qute ValueResolver generator - minor cleanup and optimization
  • Loading branch information
mkouba authored Dec 20, 2022
2 parents 3534e9d + 2d45ce3 commit aaeda3e
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 140 deletions.
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

0 comments on commit aaeda3e

Please sign in to comment.