2929import java .nio .file .Path ;
3030import java .util .ArrayList ;
3131import java .util .HashMap ;
32- import java .util .LinkedList ;
3332import java .util .List ;
3433import java .util .ListIterator ;
3534import java .util .Map ;
4039import com .oracle .objectfile .debuginfo .DebugInfoProvider .DebugFrameSizeChange ;
4140import com .oracle .objectfile .debuginfo .DebugInfoProvider .DebugInstanceTypeInfo ;
4241import com .oracle .objectfile .debuginfo .DebugInfoProvider .DebugMethodInfo ;
42+ import com .oracle .objectfile .debuginfo .DebugInfoProvider .DebugRangeInfo ;
4343import com .oracle .objectfile .debuginfo .DebugInfoProvider .DebugTypeInfo ;
4444import com .oracle .objectfile .debuginfo .DebugInfoProvider .DebugTypeInfo .DebugTypeKind ;
4545
@@ -97,10 +97,7 @@ public ClassEntry(String className, FileEntry fileEntry, int size) {
9797 super (className , size );
9898 this .interfaces = new ArrayList <>();
9999 this .fileEntry = fileEntry ;
100- // methods is a sorted list and we want to be able to add more elements to it while keeping
101- // it sorted,
102- // so a LinkedList seems more appropriate than an ArrayList. (see getMethodEntry)
103- this .methods = new LinkedList <>();
100+ this .methods = new ArrayList <>();
104101 this .primaryEntries = new ArrayList <>();
105102 this .primaryIndex = new HashMap <>();
106103 this .localFiles = new ArrayList <>();
@@ -140,7 +137,7 @@ public void addDebugInfo(DebugInfoBase debugInfoBase, DebugTypeInfo debugTypeInf
140137 /* Add details of fields and field types */
141138 debugInstanceTypeInfo .fieldInfoProvider ().forEach (debugFieldInfo -> this .processField (debugFieldInfo , debugInfoBase , debugContext ));
142139 /* Add details of methods and method types */
143- debugInstanceTypeInfo .methodInfoProvider ().forEach (methodFieldInfo -> this .methods .add (this .processMethod (methodFieldInfo , debugInfoBase , debugContext )));
140+ debugInstanceTypeInfo .methodInfoProvider ().forEach (methodFieldInfo -> this .methods .add (this .processMethod (methodFieldInfo , debugInfoBase , debugContext , false )));
144141 /* Sort methods to improve lookup speed */
145142 this .methods .sort (MethodEntry ::compareTo );
146143 }
@@ -157,8 +154,9 @@ public void indexPrimary(Range primary, List<DebugFrameSizeChange> frameSizeInfo
157154 assert includesDeoptTarget == false ;
158155 }
159156 FileEntry primaryFileEntry = primary .getFileEntry ();
160- assert primaryFileEntry != null ;
161- indexLocalFileEntry (primaryFileEntry );
157+ if (primaryFileEntry != null ) {
158+ indexLocalFileEntry (primaryFileEntry );
159+ }
162160 }
163161 }
164162
@@ -275,7 +273,7 @@ private void processInterface(String interfaceName, DebugInfoBase debugInfoBase,
275273 interfaceClassEntry .addImplementor (this , debugContext );
276274 }
277275
278- protected MethodEntry processMethod (DebugMethodInfo debugMethodInfo , DebugInfoBase debugInfoBase , DebugContext debugContext ) {
276+ protected MethodEntry processMethod (DebugMethodInfo debugMethodInfo , DebugInfoBase debugInfoBase , DebugContext debugContext , boolean fromRangeInfo ) {
279277 String methodName = debugInfoBase .uniqueDebugString (debugMethodInfo .name ());
280278 String resultTypeName = TypeEntry .canonicalize (debugMethodInfo .valueType ());
281279 int modifiers = debugMethodInfo .modifiers ();
@@ -294,15 +292,13 @@ protected MethodEntry processMethod(DebugMethodInfo debugMethodInfo, DebugInfoBa
294292 paramTypeArray [idx ++] = paramType ;
295293 }
296294 paramNameArray = paramNames .toArray (paramNameArray );
297- String fileName = debugMethodInfo .fileName ();
298- Path filePath = debugMethodInfo .filePath ();
299- Path cachePath = debugMethodInfo .cachePath ();
300295 /*
301296 * n.b. the method file may differ from the owning class file when the method is a
302297 * substitution
303298 */
304- FileEntry methodFileEntry = debugInfoBase .ensureFileEntry (fileName , filePath , cachePath );
305- return new MethodEntry (methodFileEntry , methodName , this , resultType , paramTypeArray , paramNameArray , modifiers , debugMethodInfo .isDeoptTarget ());
299+ FileEntry methodFileEntry = debugInfoBase .ensureFileEntry (debugMethodInfo );
300+ return new MethodEntry (methodFileEntry , debugMethodInfo .symbolNameForMethod (), methodName , this , resultType ,
301+ paramTypeArray , paramNameArray , modifiers , debugMethodInfo .isDeoptTarget (), fromRangeInfo );
306302 }
307303
308304 @ Override
@@ -343,32 +339,28 @@ public ClassEntry getSuperClass() {
343339 return superClass ;
344340 }
345341
346- public Range makePrimaryRange (String symbolName , StringTable stringTable , MethodEntry method , int lo , int hi , int primaryLine ) {
347- FileEntry fileEntryToUse = method .fileEntry ;
348- if (fileEntryToUse == null ) {
349- /* Last chance is the class's file entry. */
350- fileEntryToUse = this .fileEntry ;
351- }
352- return new Range (symbolName , stringTable , method , fileEntryToUse , lo , hi , primaryLine );
353- }
354-
355- public MethodEntry getMethodEntry (DebugMethodInfo debugMethodInfo , DebugInfoBase debugInfoBase , DebugContext debugContext ) {
342+ public MethodEntry ensureMethodEntryForDebugRangeInfo (DebugRangeInfo debugRangeInfo , DebugInfoBase debugInfoBase , DebugContext debugContext ) {
356343 assert listIsSorted (methods );
357- String methodName = debugInfoBase .uniqueDebugString (debugMethodInfo .name ());
358- String paramSignature = debugMethodInfo .paramSignature ();
359- String returnTypeName = debugMethodInfo .valueType ();
360344 ListIterator <MethodEntry > methodIterator = methods .listIterator ();
345+ String methodName = debugInfoBase .uniqueDebugString (debugRangeInfo .name ());
346+ String paramSignature = debugRangeInfo .paramSignature ();
347+ String returnTypeName = debugRangeInfo .valueType ();
361348 while (methodIterator .hasNext ()) {
362349 MethodEntry methodEntry = methodIterator .next ();
363350 int comparisonResult = methodEntry .compareTo (methodName , paramSignature , returnTypeName );
364351 if (comparisonResult == 0 ) {
352+ methodEntry .setInRangeAndUpdateFileEntry (debugInfoBase , debugRangeInfo );
353+ if (methodEntry .fileEntry != null ) {
354+ /* Ensure that the methodEntry's fileEntry is present in the localsFileIndex */
355+ indexLocalFileEntry (methodEntry .fileEntry );
356+ }
365357 return methodEntry ;
366358 } else if (comparisonResult > 0 ) {
367359 methodIterator .previous ();
368360 break ;
369361 }
370362 }
371- MethodEntry newMethodEntry = processMethod (debugMethodInfo , debugInfoBase , debugContext );
363+ MethodEntry newMethodEntry = processMethod (debugRangeInfo , debugInfoBase , debugContext , true );
372364 methodIterator .add (newMethodEntry );
373365 return newMethodEntry ;
374366 }
@@ -378,4 +370,8 @@ private static boolean listIsSorted(List<MethodEntry> list) {
378370 copy .sort (MethodEntry ::compareTo );
379371 return list .equals (copy );
380372 }
373+
374+ public List <MethodEntry > getMethods () {
375+ return methods ;
376+ }
381377}
0 commit comments