Skip to content
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 @@ -121,11 +121,11 @@ public Value emitExtendMemory(boolean isSigned, AArch64Kind accessKind, int resu
* Issue an extending load of the proper bit size and set the result to the proper kind.
*/
GraalError.guarantee(accessKind.isInteger(), "can only extend integer kinds");
Variable result = getLIRGen().newVariable(LIRKind.value(resultBits == 32 ? AArch64Kind.DWORD : AArch64Kind.QWORD));
AArch64Kind resultKind = resultBits <= 32 ? AArch64Kind.DWORD : AArch64Kind.QWORD;
Variable result = getLIRGen().newVariable(LIRKind.value(resultKind));

int dstBitSize = resultBits <= 32 ? 32 : 64;
AArch64Move.ExtendKind extend = isSigned ? AArch64Move.ExtendKind.SIGN_EXTEND : AArch64Move.ExtendKind.ZERO_EXTEND;
getLIRGen().append(new AArch64Move.LoadOp(accessKind, dstBitSize, extend, result, address, state));
getLIRGen().append(new AArch64Move.LoadOp(accessKind, resultKind.getSizeInBytes() * Byte.SIZE, extend, result, address, state));
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ public StackTraceElement[] getParsingContext() {
List<StackTraceElement> parsingContext = new ArrayList<>();
InvokeTypeFlow invokeFlow = parsingReason;

while (invokeFlow != null) {
/* Defend against cycles in the parsing context. GR-35744 should fix this properly. */
int maxSize = 100;

while (invokeFlow != null && parsingContext.size() < maxSize) {
parsingContext.add(invokeFlow.getSource().getMethod().asStackTraceElement(invokeFlow.getSource().getBCI()));
invokeFlow = ((PointsToAnalysisMethod) invokeFlow.getSource().getMethod()).getTypeFlow().parsingReason;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ private void collectMethodImplementations() {
public static Set<AnalysisMethod> getMethodImplementations(BigBang bb, AnalysisMethod method, boolean includeInlinedMethods) {
Set<AnalysisMethod> implementations = new LinkedHashSet<>();
if (method.wrapped.canBeStaticallyBound() || method.isConstructor()) {
if (method.isImplementationInvoked()) {
if (includeInlinedMethods ? method.isReachable() : method.isImplementationInvoked()) {
implementations.add(method);
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ public String name() {

@Override
public String valueType() {
return hostedMethod.getSignature().getReturnType(null).toJavaName();
return toJavaName((HostedType) hostedMethod.getSignature().getReturnType(null));

Choose a reason for hiding this comment

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

@adinn @zakkak This fixes some errors related to Lambda types. LambdaSubstitutionType injects a new stable name for such types. For the CE debug information, you unwrap the substitutions (I don't really know why, but certainly don't want to change it either). These two usages were the only ones I could find that were missing the unwrapping.

Copy link
Collaborator

@zakkak zakkak Dec 13, 2021

Choose a reason for hiding this comment

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

@christianwimmer thanks for catching and fixing this. Your changes look good to me and I was also not able to find other usages missing the unwrapping.

I don't really get how this change relates to LambdaSubstitutionType's stableName though. AFAICS LambdaSubstitutionType#toJavaName() invokes toJavaName() on the original ResolvedJavaType, so it's now not using the stableName.

@Override
public String toJavaName() {
return original.toJavaName();
}

As for the why we do the unwrapping:

/*
* HostedType wraps an AnalysisType and both HostedType and AnalysisType punt calls to
* getSourceFilename to the wrapped class so for consistency we need to do type names and path
* lookup relative to the doubly unwrapped HostedType.
*
* However, note that the result of the unwrap on the AnalysisType may be a SubstitutionType
* which wraps both an original type and the annotated type that substitutes it. Unwrapping
* normally returns the AnnotatedType which we need to use to resolve the file name. However, we
* need to use the original to name the owning type to ensure that names found in method param
* and return types resolve correctly.
*/

Copy link

@christianwimmer christianwimmer Dec 14, 2021

Choose a reason for hiding this comment

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

With my current work to use more factory methods in #4085 it is now possible that a lambda type is used as the return type of a method (that cannot occur in "normal" bytecode because the lambda type is only created on-the-fly by the LambdaMetaFactory and not mentioned as a return type in any generated method).

With a lambda type as a method return type, some code paths were using the class name generated by the LambdaMetaFactory, and some code paths were using the new name as rewritten by LambdaSubstitutionType. Your debug info code goes back to the original name from HotSpot, so it is now (consistently) using the original name that comes from LambdaMetaFactory.

}

@Override
Expand All @@ -669,7 +669,7 @@ public List<String> paramTypes() {
int parameterCount = signature.getParameterCount(false);
List<String> paramTypes = new ArrayList<>(parameterCount);
for (int i = 0; i < parameterCount; i++) {
paramTypes.add(signature.getParameterType(i, null).toJavaName());
paramTypes.add(toJavaName((HostedType) signature.getParameterType(i, null)));
}
return paramTypes;
}
Expand Down