Skip to content

Commit 1dc9bc4

Browse files
committed
Revert "Use symbolName to compare MethodEntrys"
This reverts commit e205cb0.
1 parent 6bd40df commit 1dc9bc4

File tree

2 files changed

+51
-4
lines changed

2 files changed

+51
-4
lines changed

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/ClassEntry.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,10 +341,13 @@ public ClassEntry getSuperClass() {
341341

342342
public MethodEntry ensureMethodEntryForDebugRangeInfo(DebugRangeInfo debugRangeInfo, DebugInfoBase debugInfoBase, DebugContext debugContext) {
343343
assert listIsSorted(methods);
344+
String methodName = debugInfoBase.uniqueDebugString(debugRangeInfo.name());
345+
String paramSignature = debugRangeInfo.paramSignature();
346+
String returnTypeName = debugRangeInfo.valueType();
344347
ListIterator<MethodEntry> methodIterator = methods.listIterator();
345348
while (methodIterator.hasNext()) {
346349
MethodEntry methodEntry = methodIterator.next();
347-
int comparisonResult = methodEntry.compareTo(debugRangeInfo.symbolNameForMethod());
350+
int comparisonResult = methodEntry.compareTo(methodName, paramSignature, returnTypeName);
348351
if (comparisonResult == 0) {
349352
methodEntry.setInRangeAndUpdateFileEntry(debugInfoBase, debugRangeInfo);
350353
if (methodEntry.fileEntry != null) {

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/MethodEntry.java

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,56 @@ public String getSymbolName() {
120120
return symbolName;
121121
}
122122

123-
public int compareTo(String symbolNameForMethod) {
124-
return symbolName.compareTo(symbolNameForMethod);
123+
public int compareTo(String methodName, String paramSignature, String returnTypeName) {
124+
int nameComparison = memberName.compareTo(methodName);
125+
if (nameComparison != 0) {
126+
return nameComparison;
127+
}
128+
int typeComparison = valueType.getTypeName().compareTo(returnTypeName);
129+
if (typeComparison != 0) {
130+
return typeComparison;
131+
}
132+
String[] paramTypeNames = paramSignature.split((","));
133+
int length;
134+
if (paramSignature.trim().length() == 0) {
135+
length = 0;
136+
} else {
137+
length = paramTypeNames.length;
138+
}
139+
int paramCountComparison = getParamCount() - length;
140+
if (paramCountComparison != 0) {
141+
return paramCountComparison;
142+
}
143+
for (int i = 0; i < getParamCount(); i++) {
144+
int paraComparison = getParamTypeName(i).compareTo(paramTypeNames[i].trim());
145+
if (paraComparison != 0) {
146+
return paraComparison;
147+
}
148+
}
149+
return 0;
125150
}
126151

127152
@Override
128153
public int compareTo(MethodEntry other) {
129-
return symbolName.compareTo(other.symbolName);
154+
assert other != null;
155+
int nameComparison = methodName().compareTo(other.methodName());
156+
if (nameComparison != 0) {
157+
return nameComparison;
158+
}
159+
int typeComparison = valueType.getTypeName().compareTo(other.valueType.getTypeName());
160+
if (typeComparison != 0) {
161+
return typeComparison;
162+
}
163+
int paramCountComparison = getParamCount() - other.getParamCount();
164+
if (paramCountComparison != 0) {
165+
return paramCountComparison;
166+
}
167+
for (int i = 0; i < getParamCount(); i++) {
168+
int paramComparison = getParamTypeName(i).compareTo(other.getParamTypeName(i));
169+
if (paramComparison != 0) {
170+
return paramComparison;
171+
}
172+
}
173+
return 0;
130174
}
131175
}

0 commit comments

Comments
 (0)