From 3c169b8183350bdfcd8fc233d2fcfee67cb1535e Mon Sep 17 00:00:00 2001 From: Foivos Zakkak Date: Thu, 18 Mar 2021 14:43:52 +0200 Subject: [PATCH 1/2] Remove methods from debug ClassEntry --- .../objectfile/debugentry/ClassEntry.java | 55 +------------------ .../debuginfo/DebugInfoProvider.java | 2 - .../image/NativeImageDebugInfoProvider.java | 5 -- 3 files changed, 2 insertions(+), 60 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/ClassEntry.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/ClassEntry.java index 7dc4e567b0df..c0d27f5253ec 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/ClassEntry.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/ClassEntry.java @@ -28,7 +28,6 @@ import com.oracle.objectfile.debuginfo.DebugInfoProvider; import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugFrameSizeChange; -import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugMethodInfo; import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo; import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugInstanceTypeInfo; import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugTypeInfo.DebugTypeKind; @@ -56,10 +55,6 @@ public class ClassEntry extends StructureTypeEntry { * Details of the associated file. */ private FileEntry fileEntry; - /** - * Details of methods located in this instance. - */ - protected List methods; /** * A list recording details of all primary ranges included in this class sorted by ascending * address range. @@ -94,7 +89,6 @@ public ClassEntry(String className, FileEntry fileEntry, int size) { super(className, size); this.interfaces = new LinkedList<>(); this.fileEntry = fileEntry; - this.methods = new LinkedList<>(); this.primaryEntries = new LinkedList<>(); this.primaryIndex = new HashMap<>(); this.localFiles = new LinkedList<>(); @@ -133,8 +127,6 @@ public void addDebugInfo(DebugInfoBase debugInfoBase, DebugTypeInfo debugTypeInf debugInstanceTypeInfo.interfaces().forEach(interfaceName -> processInterface(interfaceName, debugInfoBase, debugContext)); /* Add details of fields and field types */ debugInstanceTypeInfo.fieldInfoProvider().forEach(debugFieldInfo -> this.processField(debugFieldInfo, debugInfoBase, debugContext)); - /* Add details of methods and method types */ - debugInstanceTypeInfo.methodInfoProvider().forEach(methodFieldInfo -> this.processMethod(methodFieldInfo, debugInfoBase, debugContext)); } public void indexPrimary(Range primary, List frameSizeInfos, int frameSize) { @@ -267,36 +259,6 @@ private void processInterface(String interfaceName, DebugInfoBase debugInfoBase, interfaceClassEntry.addImplementor(this, debugContext); } - protected void processMethod(DebugMethodInfo debugMethodInfo, DebugInfoBase debugInfoBase, DebugContext debugContext) { - String methodName = debugInfoBase.uniqueDebugString(debugMethodInfo.name()); - String resultTypeName = TypeEntry.canonicalize(debugMethodInfo.valueType()); - int modifiers = debugMethodInfo.modifiers(); - List paramTypes = debugMethodInfo.paramTypes(); - List paramNames = debugMethodInfo.paramNames(); - assert paramTypes.size() == paramNames.size(); - int paramCount = paramTypes.size(); - debugContext.log("typename %s adding %s method %s %s(%s)\n", - typeName, memberModifiers(modifiers), resultTypeName, methodName, formatParams(paramTypes, paramNames)); - TypeEntry resultType = debugInfoBase.lookupTypeEntry(resultTypeName); - TypeEntry[] paramTypeArray = new TypeEntry[paramCount]; - String[] paramNameArray = new String[paramCount]; - int idx = 0; - for (String paramTypeName : paramTypes) { - TypeEntry paramType = debugInfoBase.lookupTypeEntry(TypeEntry.canonicalize(paramTypeName)); - paramTypeArray[idx++] = paramType; - } - paramNameArray = paramNames.toArray(paramNameArray); - String fileName = debugMethodInfo.fileName(); - Path filePath = debugMethodInfo.filePath(); - Path cachePath = debugMethodInfo.cachePath(); - /* - * n.b. the method file may differ from the owning class file when the method is a - * substitution - */ - FileEntry methodFileEntry = debugInfoBase.ensureFileEntry(fileName, filePath, cachePath); - methods.add(new MethodEntry(methodFileEntry, methodName, this, resultType, paramTypeArray, paramNameArray, modifiers)); - } - @Override protected FieldEntry addField(DebugInfoProvider.DebugFieldInfo debugFieldInfo, DebugInfoBase debugInfoBase, DebugContext debugContext) { FieldEntry fieldEntry = super.addField(debugFieldInfo, debugInfoBase, debugContext); @@ -340,21 +302,8 @@ public Range makePrimaryRange(String methodName, String symbolName, String param int modifiers, boolean isDeoptTarget) { FileEntry fileEntryToUse = primaryFileEntry; if (fileEntryToUse == null) { - /* - * Search for a matching method to supply the file entry or failing that use the one - * from this class. - */ - for (MethodEntry methodEntry : methods) { - if (methodEntry.match(methodName, paramSignature, returnTypeName)) { - /* maybe the method's file entry */ - fileEntryToUse = methodEntry.getFileEntry(); - break; - } - } - if (fileEntryToUse == null) { - /* Last chance is the class's file entry. */ - fileEntryToUse = this.fileEntry; - } + /* Last chance is the class's file entry. */ + fileEntryToUse = this.fileEntry; } return new Range(this.typeName, methodName, symbolName, paramSignature, returnTypeName, stringTable, fileEntryToUse, lo, hi, primaryLine, modifiers, isDeoptTarget); } diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debuginfo/DebugInfoProvider.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debuginfo/DebugInfoProvider.java index e98b94c817a8..49d65f2ed927 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debuginfo/DebugInfoProvider.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debuginfo/DebugInfoProvider.java @@ -134,8 +134,6 @@ interface DebugInstanceTypeInfo extends DebugTypeInfo { Stream fieldInfoProvider(); - Stream methodInfoProvider(); - String superName(); Stream interfaces(); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImageDebugInfoProvider.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImageDebugInfoProvider.java index a644b10ec30e..135dc102ec8a 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImageDebugInfoProvider.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImageDebugInfoProvider.java @@ -550,11 +550,6 @@ public Stream fieldInfoProvider() { } } - @Override - public Stream methodInfoProvider() { - return Arrays.stream(hostedType.getAllDeclaredMethods()).map(this::createDebugMethodInfo); - } - @Override public String superName() { HostedClass superClass = hostedType.getSuperclass(); From 26470f8ed9f664c45a84f5397f4d8edd47f5472e Mon Sep 17 00:00:00 2001 From: Foivos Zakkak Date: Thu, 18 Mar 2021 14:49:23 +0200 Subject: [PATCH 2/2] Remove ClassEntry#makePrimaryRange method --- .../com/oracle/objectfile/debugentry/ClassEntry.java | 11 ----------- .../oracle/objectfile/debugentry/DebugInfoBase.java | 5 ++++- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/ClassEntry.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/ClassEntry.java index c0d27f5253ec..ad2ffcc9956a 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/ClassEntry.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/ClassEntry.java @@ -296,15 +296,4 @@ public boolean isPrimary() { public ClassEntry getSuperClass() { return superClass; } - - public Range makePrimaryRange(String methodName, String symbolName, String paramSignature, String returnTypeName, StringTable stringTable, FileEntry primaryFileEntry, int lo, - int hi, int primaryLine, - int modifiers, boolean isDeoptTarget) { - FileEntry fileEntryToUse = primaryFileEntry; - if (fileEntryToUse == null) { - /* Last chance is the class's file entry. */ - fileEntryToUse = this.fileEntry; - } - return new Range(this.typeName, methodName, symbolName, paramSignature, returnTypeName, stringTable, fileEntryToUse, lo, hi, primaryLine, modifiers, isDeoptTarget); - } } diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/DebugInfoBase.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/DebugInfoBase.java index 3a4117403b3e..50f0156907a8 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/DebugInfoBase.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/DebugInfoBase.java @@ -251,7 +251,10 @@ public void installDebugInfo(DebugInfoProvider debugInfoProvider) { /* Search for a method defining this primary range. */ ClassEntry classEntry = ensureClassEntry(className); FileEntry fileEntry = ensureFileEntry(fileName, filePath, cachePath); - Range primaryRange = classEntry.makePrimaryRange(methodName, symbolName, paramSignature, returnTypeName, stringTable, fileEntry, lo, hi, primaryLine, modifiers, isDeoptTarget); + if (fileEntry == null) { + fileEntry = classEntry.getFileEntry(); + } + Range primaryRange = new Range(classEntry.getTypeName(), methodName, symbolName, paramSignature, returnTypeName, stringTable, fileEntry, lo, hi, primaryLine, modifiers, isDeoptTarget); debugContext.log(DebugContext.INFO_LEVEL, "PrimaryRange %s.%s %s %s:%d [0x%x, 0x%x]", className, methodName, filePath, fileName, primaryLine, lo, hi); classEntry.indexPrimary(primaryRange, debugCodeInfo.getFrameSizeChanges(), debugCodeInfo.getFrameSize()); debugCodeInfo.lineInfoProvider().forEach(debugLineInfo -> {