Skip to content

Commit 02bc9c6

Browse files
committed
further fixes after latest review
1 parent 2ef088d commit 02bc9c6

File tree

8 files changed

+53
-81
lines changed

8 files changed

+53
-81
lines changed

substratevm/DebugInfo.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ compiled method.
106106

107107
### Currently Missing Features
108108

109-
- reference by name to values boudn to parameter and local vars
109+
- reference by name to values bound to parameter and local vars
110110

111111
This feature is scheduled for inclusion in a later release.
112112

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public class ClassEntry extends StructureTypeEntry {
7474
*/
7575
private Map<FileEntry, Integer> localFilesIndex;
7676
/**
77-
* a list of the same files.
77+
* A list of the same files.
7878
*/
7979
private LinkedList<FileEntry> localFiles;
8080
/**
@@ -86,7 +86,7 @@ public class ClassEntry extends StructureTypeEntry {
8686
*/
8787
private LinkedList<DirEntry> localDirs;
8888
/**
89-
* true iff the entry includes methods that are deopt targets.
89+
* This flag is true iff the entry includes methods that are deopt targets.
9090
*/
9191
private boolean includesDeoptTarget;
9292

@@ -289,8 +289,10 @@ protected void processMethod(DebugMethodInfo debugMethodInfo, DebugInfoBase debu
289289
String fileName = debugMethodInfo.fileName();
290290
Path filePath = debugMethodInfo.filePath();
291291
Path cachePath = debugMethodInfo.cachePath();
292-
// n.b. the method file may differ from the owning class file when the method is a
293-
// substitution
292+
/*
293+
* n.b. the method file may differ from the owning class file when the method is a
294+
* substitution
295+
*/
294296
FileEntry methodFileEntry = debugInfoBase.ensureFileEntry(fileName, filePath, cachePath);
295297
methods.add(new MethodEntry(methodFileEntry, methodName, this, resultType, paramTypeArray, paramNameArray, modifiers));
296298
}
@@ -344,13 +346,13 @@ public Range makePrimaryRange(String methodName, String symbolName, String param
344346
*/
345347
for (MethodEntry methodEntry : methods) {
346348
if (methodEntry.match(methodName, paramSignature, returnTypeName)) {
347-
// maybe the method's file entry
349+
/* maybe the method's file entry */
348350
fileEntryToUse = methodEntry.getFileEntry();
349351
break;
350352
}
351353
}
352354
if (fileEntryToUse == null) {
353-
/* last chance is the class's file entry */
355+
/* Last chance is the class's file entry. */
354356
fileEntryToUse = this.fileEntry;
355357
}
356358
}

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,18 +160,18 @@ public void installDebugInfo(DebugInfoProvider debugInfoProvider) {
160160
*/
161161

162162
/*
163-
* track whether we need to use a heap base regsiter
163+
* Track whether we need to use a heap base register.
164164
*/
165165
useHeapBase = debugInfoProvider.useHeapBase();
166166

167167
/*
168-
* save count of low order tag bits that may appear in references
168+
* Save count of low order tag bits that may appear in references.
169169
*/
170170
int oopTagsMask = debugInfoProvider.oopTagsMask();
171171

172-
/* tag bits must be between 1 and 32 for us to emit as DW_OP_lit<n> */
172+
/* Tag bits must be between 1 and 32 for us to emit as DW_OP_lit<n>. */
173173
assert oopTagsMask > 0 && oopTagsMask < 32;
174-
/* mask must be contiguous from bit 0 */
174+
/* Mask must be contiguous from bit 0. */
175175
assert ((oopTagsMask + 1) & oopTagsMask) == 0;
176176

177177
oopTagsCount = Integer.bitCount(oopTagsMask);
@@ -185,13 +185,13 @@ public void installDebugInfo(DebugInfoProvider debugInfoProvider) {
185185
/* Save number of bytes in a reference field. */
186186
oopReferenceSize = debugInfoProvider.oopReferenceSize();
187187

188-
/* Save alignment of a reference */
188+
/* Save alignment of a reference. */
189189
oopAlignment = debugInfoProvider.oopAlignment();
190190

191-
/* Save alignment of a reference */
191+
/* Save alignment of a reference. */
192192
oopAlignShift = Integer.bitCount(oopAlignment - 1);
193193

194-
/* reference alignment must be 8 bytes */
194+
/* Reference alignment must be 8 bytes. */
195195
assert oopAlignment == 8;
196196

197197
/* Ensure we have a null string in the string section. */
@@ -499,7 +499,8 @@ public boolean isHubClassEntry(ClassEntry classEntry) {
499499
public int classLayoutAbbrevCode(ClassEntry classEntry) {
500500
if (useHeapBase & isHubClassEntry(classEntry)) {
501501
/*
502-
* this layout adds special logic to remove tag bits from indirect pointers to this type
502+
* This layout adds special logic to remove tag bits from indirect pointers to this
503+
* type.
503504
*/
504505
return DwarfDebugInfo.DW_ABBREV_CODE_class_layout2;
505506
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ protected FieldEntry addField(DebugFieldInfo debugFieldInfo, DebugInfoBase debug
7171
String fileName = debugFieldInfo.fileName();
7272
Path filePath = debugFieldInfo.filePath();
7373
Path cachePath = debugFieldInfo.cachePath();
74-
// n.b. the field file may differ from the owning class file when the field is a
75-
// substitution
74+
/*
75+
* n.b. the field file may differ from the owning class file when the field is a
76+
* substitution
77+
*/
7678
FileEntry fileEntry = debugInfoBase.ensureFileEntry(fileName, filePath, cachePath);
7779
FieldEntry fieldEntry = new FieldEntry(fileEntry, fieldName, this, valueType, fieldSize, fieldoffset, fieldModifiers);
7880
fields.add(fieldEntry);

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfAbbrevSectionImpl.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ private int writeMethodDeclarationAbbrev(@SuppressWarnings("unused") DebugContex
948948
/* We don't (yet?) have a proper start line for the method itself */
949949
// pos = writeAttrType(DwarfDebugInfo.DW_AT_decl_line, buffer, pos);
950950
// pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data2, buffer, pos);
951-
/* This probably needs to use the symbol name -- n.b. it is not in DWARF2 */
951+
/* This probably needs to use the symbol name */
952952
// pos = writeAttrType(DwarfDebugInfo.DW_AT_linkage_name, buffer, pos);
953953
// pos = writeAttrForm(DwarfDebugInfo.DW_FORM_strp, buffer, pos);
954954
pos = writeAttrType(DwarfDebugInfo.DW_AT_type, buffer, pos);
@@ -1187,7 +1187,7 @@ private int writeStaticFieldLocationAbbrev(@SuppressWarnings("unused") DebugCont
11871187
pos = writeFlag(DwarfDebugInfo.DW_CHILDREN_no, buffer, pos);
11881188
pos = writeAttrType(DwarfDebugInfo.DW_AT_specification, buffer, pos);
11891189
pos = writeAttrForm(DwarfDebugInfo.DW_FORM_ref_addr, buffer, pos);
1190-
/* Do we have a symbol name to use here? n.b. this is not in DWARF2. */
1190+
/* Do we have a symbol name to use here? */
11911191
// pos = writeAttrType(DwarfDebugInfo.DW_AT_linkage_name, buffer, pos);
11921192
// pos = writeAttrForm(DwarfDebugInfo.DW_FORM_strp, buffer, pos);
11931193
pos = writeAttrType(DwarfDebugInfo.DW_AT_location, buffer, pos);
@@ -1209,11 +1209,9 @@ private int writeSuperReferenceAbbrev(@SuppressWarnings("unused") DebugContext c
12091209
pos = writeAttrType(DwarfDebugInfo.DW_AT_type, buffer, pos);
12101210
pos = writeAttrForm(DwarfDebugInfo.DW_FORM_ref_addr, buffer, pos);
12111211
pos = writeAttrType(DwarfDebugInfo.DW_AT_data_member_location, buffer, pos);
1212-
pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data1, buffer, pos); // = offset? in which
1213-
// segment though?
1212+
pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data1, buffer, pos);
12141213
pos = writeAttrType(DwarfDebugInfo.DW_AT_accessibility, buffer, pos);
1215-
pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data1, buffer, pos); // = offset? in which
1216-
// segment though?
1214+
pos = writeAttrForm(DwarfDebugInfo.DW_FORM_data1, buffer, pos);
12171215
/*
12181216
* Now terminate.
12191217
*/

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfDebugInfo.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,14 @@ public class DwarfDebugInfo extends DebugInfoBase {
255255
public static final byte rthread_x86 = (byte) 15;
256256

257257
/*
258-
* prefix used to label indirect types used to ensure gdb performs oop reference --> raw address
259-
* translation
258+
* A prefix used to label indirect types used to ensure gdb performs oop reference --> raw
259+
* address translation
260260
*/
261261
public static final String INDIRECT_PREFIX = "_z_.";
262-
/* name of type for hub field which needs special case processing to remove tag bits */
262+
/*
263+
* The name of the type for header field hub which needs special case processing to remove tag
264+
* bits
265+
*/
263266
public static final String HUB_TYPE_NAME = "java.lang.Class";
264267

265268
private DwarfStrSectionImpl dwarfStrSection;
@@ -343,11 +346,11 @@ public byte getThreadRegister() {
343346
*/
344347
static class DwarfTypeProperties {
345348
/**
346-
* index in debug_info section of type declaration for this class.
349+
* Index in debug_info section of type declaration for this class.
347350
*/
348351
private int typeInfoIndex;
349352
/**
350-
* index in debug_info section of indirect type declaration for this class.
353+
* Index in debug_info section of indirect type declaration for this class.
351354
*
352355
* this is normally just the same as the index of the normal type declaration, however, when
353356
* oops are stored in static and instance fields as offsets from the heapbase register gdb

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/dwarf/DwarfInfoSectionImpl.java

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,43 +1344,7 @@ public int writeAttrAccessibility(int modifiers, byte[] buffer, int p) {
13441344
public int writeIndirectOopConversionExpression(boolean isHub, byte[] buffer, int p) {
13451345
int pos = p;
13461346
/*
1347-
* The conversion rules are different depending on whether they apply to the hub class or
1348-
* any other class.
1349-
*
1350-
* They also vary according to whether isolates are in use and, if so, whether it is
1351-
* combined with compression.
1352-
*
1353-
* Finally, they depend on the choice of GC, specifically it's influence on the number of GC
1354-
* tag bits.
1355-
*
1356-
* The rules are as follows:
1357-
*
1358-
* H:-SpawnIsolates (explicitly disabled isolates support)
1359-
*
1360-
* <ul> <li>Regular oops: address64 = val64 <li> Oops pointing to hubs: address64 = val64 &
1361-
* "GC-bits bitmask" </ul>
1362-
*
1363-
* -H:+SpawnIsolates -H:-UseCompressedReferences (CE default)
1364-
*
1365-
* <ul> <li> Regular oops: address64 = val64 + r14 <li> Oops pointing to hubs: address64 =
1366-
* ((val64 >> "num GC bits") << "objectAlignmentBits") + r14 </ul>
1367-
*
1368-
* objectAlignmentBits should always be 3
1369-
*
1370-
* -H:+SpawnIsolates+ -H:+UseCompressedReferences (EE default)
1371-
*
1372-
* <ul> <li> Regular oops: address64 = (val32 << "compressShift") + r14 <li> Oops pointing
1373-
* to hubs: address64 = ((val32 >> "num GC bits") << "compressShift") + r14 </ul>
1374-
*
1375-
* compressShift should always be 3.
1376-
*
1377-
* For Serial garbage collector (CE)
1378-
*
1379-
* <ul> <li>"num GC bits": 3 <li> "GC-bits bitmask": ~0b111 </ul>
1380-
*
1381-
* For G1 garbage collector (EE only)
1382-
*
1383-
* <ul> <li>"num GC bits": 5 <li> "GC-bits bitmask": ~0b11111 </ul>
1347+
* For an explanation of the conversion rules @see com.oracle.svm.core.heap.ReferenceAccess
13841348
*
13851349
* n.b.
13861350
*

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImageDebugInfoProvider.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ class NativeImageDebugInfoProvider implements DebugInfoProvider {
114114
this.useHeapBase = false;
115115
this.compressShift = 0;
116116
}
117-
this.referenceSize = OBJECTLAYOUT.getReferenceSize();
118-
this.referenceAlignment = OBJECTLAYOUT.getAlignment();
117+
this.referenceSize = getObjectLayout().getReferenceSize();
118+
this.referenceAlignment = getObjectLayout().getAlignment();
119119
/* Offsets need to be adjusted relative to the heap base plus partition-specific offset. */
120120
primitiveStartOffset = (int) primitiveFields.getOffset();
121121
referenceStartOffset = (int) objectFields.getOffset();
@@ -163,7 +163,9 @@ public Stream<DebugDataInfo> dataInfoProvider() {
163163
return heap.getObjects().stream().filter(this::acceptObjectInfo).map(this::createDebugDataInfo);
164164
}
165165

166-
static ObjectLayout OBJECTLAYOUT = ConfigurationValues.getObjectLayout();
166+
static ObjectLayout getObjectLayout() {
167+
return ConfigurationValues.getObjectLayout();
168+
}
167169

168170
/*
169171
* HostedType wraps an AnalysisType and both HostedType and AnalysisType punt calls to
@@ -345,10 +347,10 @@ public int size() {
345347
return ((HostedInstanceClass) hostedType).getInstanceSize();
346348
} else if (hostedType instanceof HostedArrayClass) {
347349
/* Use the size of header common to all arrays of this type. */
348-
return OBJECTLAYOUT.getArrayBaseOffset(hostedType.getComponentType().getStorageKind());
350+
return getObjectLayout().getArrayBaseOffset(hostedType.getComponentType().getStorageKind());
349351
} else if (hostedType instanceof HostedInterface) {
350352
/* Use the size of the header common to all implementors. */
351-
return OBJECTLAYOUT.getFirstFieldOffset();
353+
return getObjectLayout().getFirstFieldOffset();
352354
} else {
353355
/* Use the number of bytes needed needed to store the value. */
354356
assert hostedType instanceof HostedPrimitiveType;
@@ -485,12 +487,12 @@ public Path cachePath() {
485487

486488
private Stream<DebugTypeInfo> computeHeaderTypeInfo() {
487489
List<DebugTypeInfo> infos = new LinkedList<>();
488-
int hubOffset = OBJECTLAYOUT.getHubOffset();
490+
int hubOffset = getObjectLayout().getHubOffset();
489491
int hubFieldSize = referenceSize;
490492
String hubTypeName = "java.lang.Class";
491-
int idHashOffset = OBJECTLAYOUT.getIdentityHashCodeOffset();
492-
int idHashSize = OBJECTLAYOUT.sizeInBytes(JavaKind.Int);
493-
int objHeaderSize = OBJECTLAYOUT.getMinimumInstanceObjectSize();
493+
int idHashOffset = getObjectLayout().getIdentityHashCodeOffset();
494+
int idHashSize = getObjectLayout().sizeInBytes(JavaKind.Int);
495+
int objHeaderSize = getObjectLayout().getMinimumInstanceObjectSize();
494496

495497
/* We need array headers for all Java kinds */
496498

@@ -528,7 +530,7 @@ public DebugTypeKind typeKind() {
528530

529531
@Override
530532
public int headerSize() {
531-
return OBJECTLAYOUT.getFirstFieldOffset();
533+
return getObjectLayout().getFirstFieldOffset();
532534
}
533535

534536
@Override
@@ -621,7 +623,7 @@ public int offset() {
621623

622624
@Override
623625
public int size() {
624-
return OBJECTLAYOUT.sizeInBytes(field.getType().getStorageKind());
626+
return getObjectLayout().sizeInBytes(field.getType().getStorageKind());
625627
}
626628

627629
@Override
@@ -720,9 +722,9 @@ private class NativeImageDebugArrayTypeInfo extends NativeImageDebugTypeInfo imp
720722
this.arrayClass = arrayClass;
721723
this.fieldInfos = new LinkedList<>();
722724
JavaKind arrayKind = arrayClass.getBaseType().getJavaKind();
723-
int headerSize = OBJECTLAYOUT.getArrayBaseOffset(arrayKind);
724-
int arrayLengthOffset = OBJECTLAYOUT.getArrayLengthOffset();
725-
int arrayLengthSize = OBJECTLAYOUT.sizeInBytes(JavaKind.Int);
725+
int headerSize = getObjectLayout().getArrayBaseOffset(arrayKind);
726+
int arrayLengthOffset = getObjectLayout().getArrayLengthOffset();
727+
int arrayLengthSize = getObjectLayout().sizeInBytes(JavaKind.Int);
726728
assert arrayLengthOffset + arrayLengthSize <= headerSize;
727729

728730
addField("len", "int", arrayLengthOffset, arrayLengthSize);
@@ -740,12 +742,12 @@ public DebugTypeKind typeKind() {
740742

741743
@Override
742744
public int baseSize() {
743-
return OBJECTLAYOUT.getArrayBaseOffset(arrayClass.getComponentType().getStorageKind());
745+
return getObjectLayout().getArrayBaseOffset(arrayClass.getComponentType().getStorageKind());
744746
}
745747

746748
@Override
747749
public int lengthOffset() {
748-
return OBJECTLAYOUT.getArrayLengthOffset();
750+
return getObjectLayout().getArrayLengthOffset();
749751
}
750752

751753
@Override

0 commit comments

Comments
 (0)