Skip to content

Commit 569ab0d

Browse files
committed
Changes per @adinn review
1 parent f2f013a commit 569ab0d

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@
3131
import com.oracle.objectfile.debugentry.CompiledMethodEntry;
3232
import com.oracle.objectfile.debugentry.FieldEntry;
3333
import com.oracle.objectfile.debugentry.MethodEntry;
34+
import com.oracle.objectfile.debugentry.PrimitiveTypeEntry;
3435
import com.oracle.objectfile.debugentry.Range;
3536
import com.oracle.objectfile.debugentry.TypeEntry;
3637
import org.graalvm.compiler.debug.GraalError;
3738

3839
import java.lang.reflect.Modifier;
3940

41+
import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugPrimitiveTypeInfo.FLAG_INTEGRAL;
42+
import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugPrimitiveTypeInfo.FLAG_NUMERIC;
4043
import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_CL;
4144
import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_CX;
4245
import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_DI;
@@ -72,8 +75,6 @@
7275
import static com.oracle.objectfile.pecoff.cv.CVSymbolSubrecord.CVSymbolFrameProcRecord.FRAME_ASYNC_EH;
7376
import static com.oracle.objectfile.pecoff.cv.CVSymbolSubrecord.CVSymbolFrameProcRecord.FRAME_LOCAL_BP;
7477
import static com.oracle.objectfile.pecoff.cv.CVSymbolSubrecord.CVSymbolFrameProcRecord.FRAME_PARAM_BP;
75-
import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.T_REAL32;
76-
import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.T_REAL64;
7778
import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.MAX_PRIMITIVE;
7879

7980
final class CVSymbolSubsectionBuilder {
@@ -216,21 +217,23 @@ void addLocals(CompiledMethodEntry primaryEntry) {
216217
final TypeEntry paramType = method.getParamType(i);
217218
final int typeIndex = cvDebugInfo.getCVTypeSection().addTypeRecords(paramType).getSequenceNumber();
218219
final String paramName = "p" + (i + 1);
219-
if (typeIndex == T_REAL64 || typeIndex == T_REAL32) {
220-
/* floating point primitive */
221-
if (fpRegisterIndex < javaFP64registers.length) {
222-
final short register = typeIndex == T_REAL64 ? javaFP64registers[fpRegisterIndex] : javaFP32registers[fpRegisterIndex];
223-
addSymbolRecord(new CVSymbolSubrecord.CVSymbolLocalRecord(cvDebugInfo, paramName, typeIndex, 1));
224-
addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeRegisterRecord(cvDebugInfo, register, externalName, 0, 8));
225-
addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeFramepointerRelFullScope(cvDebugInfo, 0));
226-
fpRegisterIndex++;
227-
} else {
228-
/* TODO: handle stack parameter; keep track of stack offset, etc. */
229-
break;
230-
}
231-
} else if (paramType.isPrimitive()) {
220+
if (paramType.isPrimitive()) {
232221
/* simple primitive */
233-
if (gpRegisterIndex < javaGP64registers.length) {
222+
final PrimitiveTypeEntry primitiveTypeEntry = (PrimitiveTypeEntry) paramType;
223+
final boolean isFloatingPoint = ((primitiveTypeEntry.getFlags() & FLAG_NUMERIC) != 0 && (primitiveTypeEntry.getFlags() & FLAG_INTEGRAL) == 0);
224+
if (isFloatingPoint) {
225+
/* floating point primitive */
226+
if (fpRegisterIndex < javaFP64registers.length) {
227+
final short register = paramType.getSize() == Double.BYTES ? javaFP64registers[fpRegisterIndex] : javaFP32registers[fpRegisterIndex];
228+
addSymbolRecord(new CVSymbolSubrecord.CVSymbolLocalRecord(cvDebugInfo, paramName, typeIndex, 1));
229+
addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeRegisterRecord(cvDebugInfo, register, externalName, 0, 8));
230+
addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeFramepointerRelFullScope(cvDebugInfo, 0));
231+
fpRegisterIndex++;
232+
} else {
233+
/* TODO: handle stack parameter; keep track of stack offset, etc. */
234+
break;
235+
}
236+
} else if (gpRegisterIndex < javaGP64registers.length) {
234237
final short register;
235238
if (paramType.getSize() == 8) {
236239
register = javaGP64registers[gpRegisterIndex];
@@ -271,13 +274,13 @@ void addLocals(CompiledMethodEntry primaryEntry) {
271274
}
272275

273276
private void addLineNumberRecords(CompiledMethodEntry compiledEntry) {
274-
CVLineRecord record = lineRecordBuilder.build(compiledEntry);
277+
CVLineRecord lineRecord = lineRecordBuilder.build(compiledEntry);
275278
/*
276279
* If there are no file entries (perhaps for a synthetic function?), we don't add this
277280
* record.
278281
*/
279-
if (!record.isEmpty()) {
280-
cvDebugInfo.getCVSymbolSection().addRecord(record);
282+
if (!lineRecord.isEmpty()) {
283+
cvDebugInfo.getCVSymbolSection().addRecord(lineRecord);
281284
}
282285
}
283286

0 commit comments

Comments
 (0)