Skip to content

Commit b62e37c

Browse files
committed
rework after second review
1 parent 74de69e commit b62e37c

File tree

8 files changed

+54
-55
lines changed

8 files changed

+54
-55
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public void createContent() {
207207
*
208208
* Details of each specific DIE contents are as follows:
209209
*
210-
* A single instance of the level 0 <code>buitin_unit</code> compile unit provides details
210+
* A single instance of the level 0 <code>builtin_unit</code> compile unit provides details
211211
* of all Java primitive types and of the struct type which describes the layout of object
212212
* headers, including array headers.
213213
*
@@ -697,7 +697,7 @@ public void createContent() {
697697
*
698698
* Array Structure: Each array_unit DIE contains four level 1 DIEs. The first one describes
699699
* the array layout. It has only one child, a super_reference DIE (see above) that
700-
* references the appropriate array header type for an object arary or primitive array of
700+
* references the appropriate array header type for an object array or primitive array of
701701
* the relevant primitive type). The size of the array layout is the same as the size of the
702702
* array header.
703703
*

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

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -78,44 +78,44 @@ public class DwarfDebugInfo extends DebugInfoBase {
7878
public static final int DW_ABBREV_CODE_primitive_type = 5;
7979
public static final int DW_ABBREV_CODE_void_type = 6;
8080
public static final int DW_ABBREV_CODE_object_header = 7;
81-
public static final int DW_ABBREV_CODE_namespace = 41;
82-
public static final int DW_ABBREV_CODE_class_layout1 = 8;
83-
public static final int DW_ABBREV_CODE_class_layout2 = 9;
84-
public static final int DW_ABBREV_CODE_class_pointer = 10;
85-
public static final int DW_ABBREV_CODE_method_location = 11;
86-
public static final int DW_ABBREV_CODE_abstract_inline_method = 12;
87-
public static final int DW_ABBREV_CODE_static_field_location = 13;
88-
public static final int DW_ABBREV_CODE_array_layout = 14;
89-
public static final int DW_ABBREV_CODE_array_pointer = 15;
90-
public static final int DW_ABBREV_CODE_interface_layout = 16;
91-
public static final int DW_ABBREV_CODE_interface_pointer = 17;
92-
public static final int DW_ABBREV_CODE_indirect_layout = 18;
93-
public static final int DW_ABBREV_CODE_indirect_pointer = 19;
81+
public static final int DW_ABBREV_CODE_namespace = 8;
82+
public static final int DW_ABBREV_CODE_class_layout1 = 9;
83+
public static final int DW_ABBREV_CODE_class_layout2 = 10;
84+
public static final int DW_ABBREV_CODE_class_pointer = 11;
85+
public static final int DW_ABBREV_CODE_method_location = 12;
86+
public static final int DW_ABBREV_CODE_abstract_inline_method = 13;
87+
public static final int DW_ABBREV_CODE_static_field_location = 14;
88+
public static final int DW_ABBREV_CODE_array_layout = 15;
89+
public static final int DW_ABBREV_CODE_array_pointer = 16;
90+
public static final int DW_ABBREV_CODE_interface_layout = 17;
91+
public static final int DW_ABBREV_CODE_interface_pointer = 18;
92+
public static final int DW_ABBREV_CODE_indirect_layout = 19;
93+
public static final int DW_ABBREV_CODE_indirect_pointer = 20;
9494
/* Level 2 DIEs. */
95-
public static final int DW_ABBREV_CODE_method_declaration = 20;
96-
public static final int DW_ABBREV_CODE_method_declaration_static = 21;
97-
public static final int DW_ABBREV_CODE_field_declaration1 = 22;
98-
public static final int DW_ABBREV_CODE_field_declaration2 = 23;
99-
public static final int DW_ABBREV_CODE_field_declaration3 = 24;
100-
public static final int DW_ABBREV_CODE_field_declaration4 = 25;
101-
public static final int DW_ABBREV_CODE_header_field = 26;
102-
public static final int DW_ABBREV_CODE_array_data_type = 27;
103-
public static final int DW_ABBREV_CODE_super_reference = 28;
104-
public static final int DW_ABBREV_CODE_interface_implementor = 29;
95+
public static final int DW_ABBREV_CODE_method_declaration = 21;
96+
public static final int DW_ABBREV_CODE_method_declaration_static = 22;
97+
public static final int DW_ABBREV_CODE_field_declaration1 = 23;
98+
public static final int DW_ABBREV_CODE_field_declaration2 = 24;
99+
public static final int DW_ABBREV_CODE_field_declaration3 = 25;
100+
public static final int DW_ABBREV_CODE_field_declaration4 = 26;
101+
public static final int DW_ABBREV_CODE_header_field = 27;
102+
public static final int DW_ABBREV_CODE_array_data_type = 28;
103+
public static final int DW_ABBREV_CODE_super_reference = 29;
104+
public static final int DW_ABBREV_CODE_interface_implementor = 30;
105105
/* Level 2+K DIEs (where inline depth K >= 0) */
106-
public static final int DW_ABBREV_CODE_inlined_subroutine = 30;
107-
public static final int DW_ABBREV_CODE_inlined_subroutine_with_children = 31;
106+
public static final int DW_ABBREV_CODE_inlined_subroutine = 31;
107+
public static final int DW_ABBREV_CODE_inlined_subroutine_with_children = 32;
108108
/* Level 2 DIEs. */
109-
public static final int DW_ABBREV_CODE_method_parameter_declaration1 = 32;
110-
public static final int DW_ABBREV_CODE_method_parameter_declaration2 = 33;
111-
public static final int DW_ABBREV_CODE_method_parameter_declaration3 = 34;
112-
public static final int DW_ABBREV_CODE_method_local_declaration1 = 35;
113-
public static final int DW_ABBREV_CODE_method_local_declaration2 = 36;
109+
public static final int DW_ABBREV_CODE_method_parameter_declaration1 = 33;
110+
public static final int DW_ABBREV_CODE_method_parameter_declaration2 = 34;
111+
public static final int DW_ABBREV_CODE_method_parameter_declaration3 = 35;
112+
public static final int DW_ABBREV_CODE_method_local_declaration1 = 36;
113+
public static final int DW_ABBREV_CODE_method_local_declaration2 = 37;
114114
/* Level 3 DIEs. */
115-
public static final int DW_ABBREV_CODE_method_parameter_location1 = 37;
116-
public static final int DW_ABBREV_CODE_method_parameter_location2 = 38;
117-
public static final int DW_ABBREV_CODE_method_local_location1 = 39;
118-
public static final int DW_ABBREV_CODE_method_local_location2 = 40;
115+
public static final int DW_ABBREV_CODE_method_parameter_location1 = 38;
116+
public static final int DW_ABBREV_CODE_method_parameter_location2 = 39;
117+
public static final int DW_ABBREV_CODE_method_local_location1 = 40;
118+
public static final int DW_ABBREV_CODE_method_local_location2 = 41;
119119

120120
/*
121121
* Define all the Dwarf tags we need for our DIEs.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ private int writeCompiledClassUnit(DebugContext context, ClassEntry classEntry,
500500
private int writeNameSpace(DebugContext context, String id, byte[] buffer, int p) {
501501
int pos = p;
502502
String name = uniqueDebugString(id);
503+
assert !id.isEmpty();
503504
log(context, " [0x%08x] namespace %s", pos, name);
504505
int abbrevCode = DwarfDebugInfo.DW_ABBREV_CODE_namespace;
505506
log(context, " [0x%08x] <1> Abbrev Number %d", pos, abbrevCode);

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/UniqueShortNameProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,5 @@ static UniqueShortNameProvider singleton() {
7474
* @param classLoader the loader whose unique short name is desired
7575
* @return a unique short name for the loader or an empty string
7676
*/
77-
String uniqueShortName(ClassLoader classLoader);
77+
String uniqueShortLoaderName(ClassLoader classLoader);
7878
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/UniqueShortNameProviderDefaultImpl.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,19 @@ public String uniqueShortName(Member m) {
8686
}
8787

8888
@Override
89-
public String uniqueShortName(ClassLoader classLoader) {
89+
public String uniqueShortLoaderName(ClassLoader classLoader) {
9090
return SubstrateUtil.classLoaderNameAndId(classLoader);
9191
}
9292

9393
public static class UseDefault implements BooleanSupplier {
9494

95+
public static boolean useDefaultProvider() {
96+
return !(OS.LINUX.isCurrent() && SubstrateOptions.GenerateDebugInfo.getValue() > 0);
97+
}
98+
9599
@Override
96100
public boolean getAsBoolean() {
97-
return !(OS.LINUX.isCurrent() && SubstrateOptions.GenerateDebugInfo.getValue() > 0);
101+
return useDefaultProvider();
98102
}
99103
}
100104
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class NativeImageBFDNameProvider implements UniqueShortNameProvider {
6161

6262
@Override
6363
public String uniqueShortName(ClassLoader loader, ResolvedJavaType declaringClass, String methodName, Signature methodSignature, boolean isConstructor) {
64-
String loaderName = uniqueShortName(loader);
64+
String loaderName = uniqueShortLoaderName(loader);
6565
return bfdMangle(loaderName, declaringClass, methodName, methodSignature, isConstructor);
6666
}
6767

@@ -71,7 +71,7 @@ public String uniqueShortName(Member m) {
7171
}
7272

7373
@Override
74-
public String uniqueShortName(ClassLoader loader) {
74+
public String uniqueShortLoaderName(ClassLoader loader) {
7575
// no need to qualify classes loaded by a builtin loader
7676
if (isBuiltinLoader(loader)) {
7777
return "";
@@ -89,7 +89,7 @@ public String uniqueShortName(ClassLoader loader) {
8989
}
9090

9191
private String classLoaderNameAndId(ResolvedJavaType type) {
92-
return uniqueShortName(getClassLoader(type));
92+
return uniqueShortLoaderName(getClassLoader(type));
9393
}
9494

9595
private static String stripOuterClass(String name) {
@@ -385,7 +385,7 @@ public String mangle(String loaderName, ResolvedJavaType declaringClass, String
385385

386386
public String mangle(Member member) {
387387
Class<?> declaringClass = member.getDeclaringClass();
388-
String loaderName = nameProvider.uniqueShortName(declaringClass.getClassLoader());
388+
String loaderName = nameProvider.uniqueShortLoaderName(declaringClass.getClassLoader());
389389
String className = declaringClass.getName();
390390
String selector = member.getName();
391391
boolean isConstructor = member instanceof Constructor<?>;
@@ -517,7 +517,7 @@ private void mangleType(Class<?> type) {
517517
mangleArrayType(type);
518518
} else {
519519
sb.append('P');
520-
mangleClassName(nameProvider.uniqueShortName(type.getClassLoader()), type.getName());
520+
mangleClassName(nameProvider.uniqueShortLoaderName(type.getClassLoader()), type.getName());
521521
}
522522
}
523523

@@ -545,7 +545,7 @@ private void mangleArrayType(Class<?> arrayType) {
545545
while (baseType.isArray()) {
546546
baseType = baseType.getComponentType();
547547
}
548-
String loaderName = nameProvider.uniqueShortName(baseType.getClassLoader());
548+
String loaderName = nameProvider.uniqueShortLoaderName(baseType.getClassLoader());
549549
mangleArrayName(loaderName, baseType.getName(), count);
550550
}
551551

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,13 @@
2424
*/
2525
package com.oracle.svm.hosted.image;
2626

27-
import com.oracle.svm.core.OS;
28-
import com.oracle.svm.core.SubstrateOptions;
2927
import com.oracle.svm.core.UniqueShortNameProvider;
28+
import com.oracle.svm.core.UniqueShortNameProviderDefaultImpl;
3029
import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature;
3130
import com.oracle.svm.core.feature.InternalFeature;
3231
import com.oracle.svm.hosted.FeatureImpl;
3332
import org.graalvm.nativeimage.ImageSingletons;
3433

35-
import java.util.ArrayList;
3634
import java.util.List;
3735

3836
/**
@@ -44,7 +42,7 @@
4442
class NativeImageDebugInfoFeature implements InternalFeature {
4543
@Override
4644
public void afterRegistration(AfterRegistrationAccess access) {
47-
if (OS.LINUX.isCurrent() && SubstrateOptions.GenerateDebugInfo.getValue() > 0) {
45+
if (!UniqueShortNameProviderDefaultImpl.UseDefault.useDefaultProvider()) {
4846
if (!ImageSingletons.contains(UniqueShortNameProvider.class)) {
4947
// configure a BFD mangler to provide unique short names for method and field
5048
// symbols
@@ -59,11 +57,7 @@ public void afterRegistration(AfterRegistrationAccess access) {
5957
// the app and image loader should both have the same parent
6058
assert imageLoaderParent == appLoader.getParent();
6159
// ensure the mangle ignores prefix generation for Graal loaders
62-
List<ClassLoader> ignored = new ArrayList<>();
63-
ignored.add(systemLoader);
64-
ignored.add(imageLoaderParent);
65-
ignored.add(appLoader);
66-
ignored.add(imageLoader);
60+
List<ClassLoader> ignored = List.of(systemLoader, imageLoaderParent, appLoader, imageLoader);
6761
ImageSingletons.add(UniqueShortNameProvider.class, new NativeImageBFDNameProvider(ignored));
6862
}
6963
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ public int headerSize() {
677677
@Override
678678
public String loaderName() {
679679

680-
return UniqueShortNameProvider.singleton().uniqueShortName(hostedType.getJavaClass().getClassLoader());
680+
return UniqueShortNameProvider.singleton().uniqueShortLoaderName(hostedType.getJavaClass().getClassLoader());
681681
}
682682

683683
@Override

0 commit comments

Comments
 (0)