From 416bc7432f5d527ad7f8e79f2e6bcbe5555605fb Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Fri, 16 Dec 2022 11:22:01 -0500 Subject: [PATCH 01/48] Add local variable records and function parameter definitions. --- .../objectfile/pecoff/cv/CVConstants.java | 110 ++++++- .../pecoff/cv/CVDebugConstants.java | 13 +- .../pecoff/cv/CVSymbolSubrecord.java | 244 +++++++++++++++ .../pecoff/cv/CVSymbolSubsectionBuilder.java | 178 ++++++++++- .../objectfile/pecoff/cv/CVTypeRecord.java | 293 ++++++++++++++++++ 5 files changed, 818 insertions(+), 20 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVConstants.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVConstants.java index 9bea2634bbdc..93c38d61df2f 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVConstants.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVConstants.java @@ -36,12 +36,106 @@ public abstract class CVConstants { /* CodeView section header signature */ static final int CV_SIGNATURE_C13 = 4; - static final int CV_AMD64_R8 = 336; - static final int CV_AMD64_R9 = 337; - static final int CV_AMD64_R10 = 338; - static final int CV_AMD64_R11 = 339; - static final int CV_AMD64_R12 = 340; - static final int CV_AMD64_R13 = 341; - static final int CV_AMD64_R14 = 342; - static final int CV_AMD64_R15 = 343; + /* Register definitions */ + + /* 8 bit registers. */ + static final short CV_AMD64_R8B = 344; + static final short CV_AMD64_R9B = 345; + static final short CV_AMD64_R10B = 346; + static final short CV_AMD64_R11B = 347; + static final short CV_AMD64_R12B = 348; + static final short CV_AMD64_R13B = 349; + static final short CV_AMD64_R14B = 350; + static final short CV_AMD64_R15B = 351; + + static final short CV_AMD64_AL = 1; + static final short CV_AMD64_CL = 2; + static final short CV_AMD64_DL = 3; + static final short CV_AMD64_BL = 4; + + static final short CV_AMD64_SIL = 324; + static final short CV_AMD64_DIL = 325; + static final short CV_AMD64_BPL = 326; + static final short CV_AMD64_SPL = 327; + + /* 16 bit registers. */ + static final short CV_AMD64_R8W = 352; + static final short CV_AMD64_R9W = 353; + static final short CV_AMD64_R10W = 354; + static final short CV_AMD64_R11W = 355; + static final short CV_AMD64_R12W = 356; + static final short CV_AMD64_R13W = 357; + static final short CV_AMD64_R14W = 358; + static final short CV_AMD64_R15W = 359; + + static final short CV_AMD64_AX = 9; + static final short CV_AMD64_CX = 10; + static final short CV_AMD64_DX = 11; + static final short CV_AMD64_BX = 12; + static final short CV_AMD64_SP = 13; + static final short CV_AMD64_BP = 14; + static final short CV_AMD64_SI = 15; + static final short CV_AMD64_DI = 16; + + /* 32 bit registers. */ + static final short CV_AMD64_R8D = 360; + static final short CV_AMD64_R9D = 361; + static final short CV_AMD64_R10D = 362; + static final short CV_AMD64_R11D = 363; + static final short CV_AMD64_R12D = 364; + static final short CV_AMD64_R13D = 365; + static final short CV_AMD64_R14D = 366; + static final short CV_AMD64_R15D = 367; + + static final short CV_AMD64_EAX = 17; + static final short CV_AMD64_ECX = 18; + static final short CV_AMD64_EDX = 19; + static final short CV_AMD64_EBX = 20; + static final short CV_AMD64_ESP = 21; + static final short CV_AMD64_EBP = 22; + static final short CV_AMD64_ESI = 23; + static final short CV_AMD64_EDI = 24; + + /* 64 bit registers. */ + static final short CV_AMD64_RAX = 328; + static final short CV_AMD64_RBX = 329; + static final short CV_AMD64_RCX = 330; + static final short CV_AMD64_RDX = 331; + static final short CV_AMD64_RSI = 332; + static final short CV_AMD64_RDI = 333; + static final short CV_AMD64_RBP = 334; + static final short CV_AMD64_RSP = 335; + + static final short CV_AMD64_R8 = 336; + static final short CV_AMD64_R9 = 337; + static final short CV_AMD64_R10 = 338; + static final short CV_AMD64_R11 = 339; + static final short CV_AMD64_R12 = 340; + static final short CV_AMD64_R13 = 341; + static final short CV_AMD64_R14 = 342; + static final short CV_AMD64_R15 = 343; + + /* FP registers. */ + static final short CV_AMD64_XMM0 = 154; + static final short CV_AMD64_XMM1 = 155; + static final short CV_AMD64_XMM2 = 156; + static final short CV_AMD64_XMM3 = 157; + static final short CV_AMD64_XMM4 = 158; + static final short CV_AMD64_XMM5 = 159; + static final short CV_AMD64_XMM6 = 160; + static final short CV_AMD64_XMM7 = 161; + + static final short CV_AMD64_XMM0L = 194; + static final short CV_AMD64_XMM1L = 195; + static final short CV_AMD64_XMM2L = 196; + static final short CV_AMD64_XMM3L = 197; + static final short CV_AMD64_XMM4L = 198; + static final short CV_AMD64_XMM5L = 199; + static final short CV_AMD64_XMM6L = 200; + static final short CV_AMD64_XMM7L = 201; + + static final short CV_AMD64_XMM0_0 = 162; + static final short CV_AMD64_XMM1_0 = 166; + static final short CV_AMD64_XMM2_0 = 170; + static final short CV_AMD64_XMM3_0 = 174; } diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVDebugConstants.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVDebugConstants.java index 13e266c1fa1f..8010c31459cb 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVDebugConstants.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVDebugConstants.java @@ -37,11 +37,22 @@ public abstract class CVDebugConstants { static final short S_END = 0x0006; static final short S_FRAMEPROC = 0x1012; static final short S_OBJNAME = 0x1101; - static final short S_UDT = 0x1108; + static final short S_BLOCK32 = 0x1103; + static final short S_REGISTER = 0x1106; /* Register variable. */ + static final short S_CONSTANT = 0x1107; /* Constant. */ + static final short S_UDT = 0x1108; /* User defined type. */ static final short S_LDATA32 = 0x110c; /* Local static. */ static final short S_GDATA32 = 0x110d; /* Global static. */ static final short S_GPROC32 = 0x1110; /* Global procedure. */ static final short S_REGREL32 = 0x1111; static final short S_COMPILE3 = 0x113c; static final short S_ENVBLOCK = 0x113d; + static final short S_LOCAL = 0x113e; + static final short S_DEFRANGE = 0x113f; + // static final short S_DEFRANGE_SUBFIELD = 0x1140; + static final short S_DEFRANGE_REGISTER = 0x1141; + static final short S_DEFRANGE_FRAMEPOINTER_REL = 0x1142; + // static final short S_DEFRANGE_SUBFIELD_REGISTER = 0x1143; + static final short S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE = 0x1144; + static final short S_DEFRANGE_REGISTER_REL = 0x1145; } diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java index 29d819c743f1..a2ef6b96e2f8 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java @@ -27,10 +27,13 @@ package com.oracle.objectfile.pecoff.cv; import com.oracle.objectfile.debugentry.ClassEntry; +import org.graalvm.compiler.debug.GraalError; import java.util.HashMap; import java.util.Map; +import static com.oracle.objectfile.pecoff.cv.CVDebugConstants.S_BLOCK32; + /* * A CVSymbolSubrecord is a record in a DEBUG_S_SYMBOL record within a .debug$S section within a PECOFF file. */ @@ -301,6 +304,181 @@ public String toString() { } } + + public static class CVSymbolRegisterRecord extends CVSymbolSubrecord { + + private final String name; + private final int typeIndex; + private final short register; + + CVSymbolRegisterRecord(CVDebugInfo debugInfo, String name, int typeIndex, short register) { + super(debugInfo, CVDebugConstants.S_REGISTER); + this.name = name; + this.typeIndex = typeIndex; + this.register = register; + } + + @Override + protected int computeContents(byte[] buffer, int initialPos) { + int pos = CVUtil.putInt(typeIndex, buffer, initialPos); + pos = CVUtil.putShort(register, buffer, pos); + pos = CVUtil.putUTF8StringBytes(name, buffer, pos); + return pos; + } + + @Override + public String toString() { + return String.format("S_REGISTER name=%s r%d type=0x%x)", name, register, typeIndex); + } + } + + public static class CVSymbolLocalRecord extends CVSymbolSubrecord { + + private final String name; + private final int typeIndex; + private final int flags; + + CVSymbolLocalRecord(CVDebugInfo debugInfo, String name, int typeIndex, int flags) { + super(debugInfo, CVDebugConstants.S_LOCAL); + this.name = name; + this.typeIndex = typeIndex; + this.flags = flags; + } + + @Override + protected int computeContents(byte[] buffer, int initialPos) { + int pos = CVUtil.putInt(typeIndex, buffer, initialPos); + pos = CVUtil.putShort((short) flags, buffer, pos); + pos = CVUtil.putUTF8StringBytes(name, buffer, pos); + return pos; + } + + @Override + public String toString() { + return String.format("S_LOCAL name=%s type=0x%x flags=0x%x)", name, typeIndex, flags); + } + } + + private abstract static class CVSymbolDefRangeBase extends CVSymbolSubrecord { + + protected final int gapCount; + protected final String procName; + protected final int procOffset; + protected final short range; + + protected CVSymbolDefRangeBase(CVDebugInfo debugInfo, short recordType, String procName, int procOffset, short range) { + super(debugInfo, recordType); + this.procName = procName; + this.procOffset = procOffset; + this.range = range; + this.gapCount = 0; + if (procOffset != 0) { + GraalError.shouldNotReachHere("procOffset not implemented"); + } + } + + void addGap() { + /* TODO */ + } + + int computeRange(byte[] buffer, int initialPos) { + /* Emit CV_LVAR_ADDR_RANGE. */ + // int pos = cvDebugInfo.getCVSymbolSection().markRelocationSite(buffer, initialPos, + // procName, (long) procOffset); + int pos = cvDebugInfo.getCVSymbolSection().markRelocationSite(buffer, initialPos, procName); + pos = CVUtil.putShort(range, buffer, pos); + return pos; + } + + int computeGaps(@SuppressWarnings("unused") byte[] buffer, int initialPos) { + /* Emit gaps. Not Yet implemented. */ + assert gapCount == 0; + return initialPos; + } + + int computeRangeAndGaps(byte[] buffer, int initialPos) { + int pos = computeRange(buffer, initialPos); + return computeGaps(buffer, pos); + } + } + + public static class CVSymbolDefRangeFramepointerRelFullScope extends CVSymbolSubrecord { + + private final int frameOffset; + + CVSymbolDefRangeFramepointerRelFullScope(CVDebugInfo debugInfo, int frameOffset) { + super(debugInfo, CVDebugConstants.S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE); + this.frameOffset = frameOffset; + } + + @Override + protected int computeContents(byte[] buffer, int initialPos) { + return CVUtil.putInt(frameOffset, buffer, initialPos); + } + + @Override + public String toString() { + return String.format("S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE frameOffset=0x%x", frameOffset); + } + } + + public static class CVSymbolDefRangeRegisterRecord extends CVSymbolDefRangeBase { + + private final short register; + private final short attr; + + CVSymbolDefRangeRegisterRecord(CVDebugInfo debugInfo, short register, String procName, int procOffset, int length) { + super(debugInfo, CVDebugConstants.S_DEFRANGE_REGISTER, procName, procOffset, (short) length); + this.register = register; + this.attr = 0; + } + + @Override + protected int computeContents(byte[] buffer, int initialPos) { + int pos = CVUtil.putShort(register, buffer, initialPos); + pos = CVUtil.putShort(attr, buffer, pos); + pos = computeRangeAndGaps(buffer, pos); + return pos; + } + + @Override + public String toString() { + return String.format("S_DEFRANGE_REGISTER r%d attr=0x%x %s+0x%x range=0x%x %d gaps)", register, attr, procName, procOffset, range, gapCount); + } + } + + public static class CVSymbolDefRangeRegisterRel extends CVSymbolDefRangeBase { + + private final short baseRegister; + private final short spilledUdtMember; + private final short parentOffset; + private final int bpOffset; + + CVSymbolDefRangeRegisterRel(CVDebugInfo debugInfo, String procName, int procOffset, short range, short baseRegister) { + super(debugInfo, CVDebugConstants.S_DEFRANGE_REGISTER_REL, procName, procOffset, range); + this.baseRegister = baseRegister; + this.spilledUdtMember = 0; + this.parentOffset = 0; + this.bpOffset = 0; + } + + @Override + protected int computeContents(byte[] buffer, int initialPos) { + int pos = CVUtil.putShort(baseRegister, buffer, initialPos); + /* bitfield spilledUDTMember : 1, pad : 3, parentOffset : 12 */ + pos = CVUtil.putShort((short) (spilledUdtMember + (parentOffset << 4)), buffer, pos); + pos = CVUtil.putInt(bpOffset, buffer, pos); + pos = computeRangeAndGaps(buffer, pos); + return pos; + } + + @Override + public String toString() { + return String.format("S_DEFRANGE_REGISTER_REL r%d spilled=%d parentOffset=0x%x %s+0x%x range=0x%x %d gaps)", baseRegister, spilledUdtMember, parentOffset, procName, procOffset, range, + gapCount); + } + } + public static class CVSymbolRegRel32Record extends CVSymbolSubrecord { private final String name; @@ -331,6 +509,61 @@ public String toString() { } } + public static class CVSymbolDefRangeFramepointerRel extends CVSymbolDefRangeBase { + + private final int fpOffset; + + CVSymbolDefRangeFramepointerRel(CVDebugInfo debugInfo, String name, int procOffset, short range, int fpOffset) { + super(debugInfo, CVDebugConstants.S_DEFRANGE_FRAMEPOINTER_REL, name, procOffset, range); + this.fpOffset = fpOffset; + } + + @Override + protected int computeContents(byte[] buffer, int initialPos) { + int pos = CVUtil.putInt(fpOffset, buffer, initialPos); + pos = computeRangeAndGaps(buffer, pos); + return pos; + } + + @Override + public String toString() { + return String.format("S_DEFRANGE_FRAMEPOINTER_REL name=%s+0x%x fpOfffset=0x%x)", procName, procOffset, fpOffset); + } + } + + public static class CVSymbolBlock32Record extends CVSymbolSubrecord { + // K32 name= parent=0x0 end=0x0 len=0x8 codeoffset=0x0:70 + // reloc addr=0x0008e5 type=11 sym=main IMAGE_REL_AMD64_SECREL(0x0b) + final String procName; + String name = ""; + int parent = 0; + int end = 0; + int len = 8; + int offset = 0; + short segment = 0; + + CVSymbolBlock32Record(CVDebugInfo cvDebugInfo, String procName) { + super(cvDebugInfo, S_BLOCK32); + this.procName = procName; + /* TODO probably need to implement procOffset here, too. */ + } + + @Override + protected int computeContents(byte[] buffer, int initialPos) { + int pos = CVUtil.putInt(parent, buffer, initialPos); + pos = CVUtil.putInt(end, buffer, pos); + pos = CVUtil.putInt(len, buffer, pos); + pos = cvDebugInfo.getCVSymbolSection().markRelocationSite(buffer, pos, procName); + pos = CVUtil.putUTF8StringBytes(name, buffer, pos); + return pos; + } + + @Override + public String toString() { + return String.format("S_BLOCK32 name=%s parent=0x%x end=0x%x len=0x%x offset=0x%x:0x%x", name, parent, end, len, segment, offset); + } + } + /* * Creating a proc32 record has a side effect: two relocation entries are added to the section * relocation table; they refer back to the global symbol. @@ -389,6 +622,17 @@ public String toString() { public static final class CVSymbolFrameProcRecord extends CVSymbolSubrecord { + /* TODO: This may change in the presence of isolates. */ + + /* Async exception handling (vc++ uses 1, clang uses 0). */ + public static final int FRAME_ASYNC_EH = 1 << 9; + + /* Local base pointer = SP (0=none, 1=sp, 2=bp 3=r13). */ + public static final int FRAME_LOCAL_BP = 1 << 14; + + /* Param base pointer = SP. */ + public static final int FRAME_PARAM_BP = 1 << 16; + private final int framelen; private final int padLen; private final int padOffset; diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java index dd2b8e972f83..ed3af02a83cf 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java @@ -30,16 +30,64 @@ import com.oracle.objectfile.debugentry.ClassEntry; import com.oracle.objectfile.debugentry.CompiledMethodEntry; import com.oracle.objectfile.debugentry.FieldEntry; +import com.oracle.objectfile.debugentry.MethodEntry; import com.oracle.objectfile.debugentry.Range; import com.oracle.objectfile.debugentry.TypeEntry; +import org.graalvm.compiler.debug.GraalError; import java.lang.reflect.Modifier; +import java.util.ArrayList; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_CL; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_CX; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_DI; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_DIL; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_DL; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_DX; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_ECX; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_EDI; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_EDX; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_ESI; import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R8; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R8B; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R8D; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R8W; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R9; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R9B; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R9D; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R9W; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_RCX; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_RDI; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_RDX; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_RSI; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_SI; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_SIL; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM0L; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM0_0; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM1L; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM1_0; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM2L; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM2_0; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM3L; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM3_0; +import static com.oracle.objectfile.pecoff.cv.CVSymbolSubrecord.CVSymbolFrameProcRecord.FRAME_ASYNC_EH; +import static com.oracle.objectfile.pecoff.cv.CVSymbolSubrecord.CVSymbolFrameProcRecord.FRAME_LOCAL_BP; +import static com.oracle.objectfile.pecoff.cv.CVSymbolSubrecord.CVSymbolFrameProcRecord.FRAME_PARAM_BP; +import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.T_REAL32; +import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.T_REAL64; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.MAX_PRIMITIVE; final class CVSymbolSubsectionBuilder { + private static final short[] javaGP64registers = {CV_AMD64_RDX, CV_AMD64_R8, CV_AMD64_R9, CV_AMD64_RDI, CV_AMD64_RSI, CV_AMD64_RCX}; + private static final short[] javaGP32registers = {CV_AMD64_EDX, CV_AMD64_R8D, CV_AMD64_R9D, CV_AMD64_EDI, CV_AMD64_ESI, CV_AMD64_ECX}; + private static final short[] javaGP16registers = {CV_AMD64_DX, CV_AMD64_R8W, CV_AMD64_R9W, CV_AMD64_DI, CV_AMD64_SI, CV_AMD64_CX}; + private static final short[] javaGP8registers = {CV_AMD64_DL, CV_AMD64_R8B, CV_AMD64_R9B, CV_AMD64_DIL, CV_AMD64_SIL, CV_AMD64_CL}; + // private static final short[] javaFP128registers = {CV_AMD64_XMM0, CV_AMD64_XMM1, + // CV_AMD64_XMM2, CV_AMD64_XMM3}; + private static final short[] javaFP64registers = {CV_AMD64_XMM0L, CV_AMD64_XMM1L, CV_AMD64_XMM2L, CV_AMD64_XMM3L}; + private static final short[] javaFP32registers = {CV_AMD64_XMM0_0, CV_AMD64_XMM1_0, CV_AMD64_XMM2_0, CV_AMD64_XMM3_0}; + private final CVDebugInfo cvDebugInfo; private final CVSymbolSubsection cvSymbolSubsection; private final CVLineRecordBuilder lineRecordBuilder; @@ -127,23 +175,17 @@ private void buildFunction(CompiledMethodEntry compiledEntry) { final String externalName = primaryRange.getSymbolName(); /* S_PROC32 add function definition. */ - int functionTypeIndex = addTypeRecords(compiledEntry); - byte funcFlags = 0; + final int functionTypeIndex = addTypeRecords(compiledEntry); + final byte funcFlags = 0; CVSymbolSubrecord.CVSymbolGProc32Record proc32 = new CVSymbolSubrecord.CVSymbolGProc32Record(cvDebugInfo, externalName, debuggerName, 0, 0, 0, primaryRange.getHi() - primaryRange.getLo(), 0, 0, functionTypeIndex, (short) 0, funcFlags); addSymbolRecord(proc32); - /* S_FRAMEPROC add frame definitions. */ - int asynceh = 1 << 9; /* Async exception handling (vc++ uses 1, clang uses 0). */ - /* TODO: This may change in the presence of isolates. */ - int localBP = 1 << 14; /* Local base pointer = SP (0=none, 1=sp, 2=bp 3=r13). */ - int paramBP = 1 << 16; /* Param base pointer = SP. */ - int frameFlags = asynceh + localBP + paramBP; /* NB: LLVM uses 0x14000. */ + /* NB: LLVM uses 0x14000. */ + final int frameFlags = FRAME_ASYNC_EH + FRAME_LOCAL_BP + FRAME_PARAM_BP; addSymbolRecord(new CVSymbolSubrecord.CVSymbolFrameProcRecord(cvDebugInfo, compiledEntry.getFrameSize(), frameFlags)); - /* TODO: add parameter definitions (types have been added already). */ - /* TODO: add local variables, and their types. */ - /* TODO: add block definitions. */ + addLocals(compiledEntry); /* S_END add end record. */ addSymbolRecord(new CVSymbolSubrecord.CVSymbolEndRecord(cvDebugInfo)); @@ -152,6 +194,120 @@ private void buildFunction(CompiledMethodEntry compiledEntry) { addLineNumberRecords(compiledEntry); } + + void addLocals(CompiledMethodEntry primaryEntry) { + final Range primaryRange = primaryEntry.getPrimary(); + /* The name as exposed to the linker. */ + final String externalName = primaryRange.getSymbolName(); + + /* Add register parameters - only valid for the first instruction or two. */ + // addToSymbolSubsection(new CVSymbolSubrecord.CVSymbolBlock32Record(cvDebugInfo, + // externalName)); + + MethodEntry method = primaryRange.getMethodEntry(); + ArrayList regRelRecords = new ArrayList<>(method.getParamCount() + 1); + int gpRegisterIndex = 0; + int fpRegisterIndex = 0; + + /* define 'this' as a local just as we define other object pointers */ + if (!Modifier.isStatic(method.getModifiers())) { + final TypeEntry thisType = primaryEntry.getClassEntry(); + final int typeIndex = cvDebugInfo.getCVTypeSection().getIndexForPointer(thisType); + addSymbolRecord(new CVSymbolSubrecord.CVSymbolLocalRecord(cvDebugInfo, "this", typeIndex, 1)); + addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeRegisterRecord(cvDebugInfo, javaGP64registers[gpRegisterIndex], externalName, 0, 8)); + addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeFramepointerRelFullScope(cvDebugInfo, 0)); + gpRegisterIndex++; + } + + /* define function parameters accoording to the calling convention */ + for (int i = 0; i < method.getParamCount(); i++) { + final TypeEntry paramType = method.getParamType(i); + final int typeIndex = cvDebugInfo.getCVTypeSection().addTypeRecords(paramType).getSequenceNumber(); + final String paramName = "p" + (i + 1); + if (typeIndex == T_REAL64 || typeIndex == T_REAL32) { + /* floating point primitive */ + if (fpRegisterIndex < javaFP64registers.length) { + final short register = typeIndex == T_REAL64 ? javaFP64registers[fpRegisterIndex] : javaFP32registers[fpRegisterIndex]; + addSymbolRecord(new CVSymbolSubrecord.CVSymbolLocalRecord(cvDebugInfo, paramName, typeIndex, 1)); + // addSymbolRecord(new CVSymbolSubrecord.CVSymbolRegisterRecord(cvDebugInfo, + // paramName, typeIndex, javaFPregisters[fpRegisterIndex])); + addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeRegisterRecord(cvDebugInfo, register, externalName, 0, 8)); + // addSymbolRecord(new + // CVSymbolSubrecord.CVSymbolDefRangeFramepointerRel(cvDebugInfo, "main", 8, + // (short) 8, 32)); + addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeFramepointerRelFullScope(cvDebugInfo, 0)); + // regRelRecords.add(new + // CVSymbolSubrecord.CVSymbolRegRel32Record(cvDebugInfo, paramName, + // typeIndex, 0, javaFPregisters[fpRegisterIndex])); + fpRegisterIndex++; + } else { + /* TODO: stack parameter; keep track of stack offset, etc. */ + break; + } + } else if (paramType.isPrimitive()) { + /* simple primitive */ + if (gpRegisterIndex < javaGP64registers.length) { + final short register; + if (paramType.getSize() == 8) { + register = javaGP64registers[gpRegisterIndex]; + } else if (paramType.getSize() == 4) { + register = javaGP32registers[gpRegisterIndex]; + } else if (paramType.getSize() == 2) { + register = javaGP16registers[gpRegisterIndex]; + } else if (paramType.getSize() == 1) { + register = javaGP8registers[gpRegisterIndex]; + } else { + register = 0; /* Avoid warning. */ + GraalError.shouldNotReachHere("Unknown primitive (type" + paramType.getTypeName() + ") size:" + paramType.getSize()); + } + addSymbolRecord(new CVSymbolSubrecord.CVSymbolLocalRecord(cvDebugInfo, paramName, typeIndex, 1)); + // addSymbolRecord(new + // CVSymbolSubrecord.CVSymbolRegisterRecord(cvDebugInfo, paramName, + // typeIndex, javaGPregisters[gpRegisterIndex])); + addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeRegisterRecord(cvDebugInfo, register, externalName, 0, 8)); + // addSymbolRecord(new + // CVSymbolSubrecord.CVSymbolDefRangeFramepointerRel(cvDebugInfo, + // "main", 8, (short) 8, 32)); + addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeFramepointerRelFullScope(cvDebugInfo, 8)); + // regRelRecords.add(new + // CVSymbolSubrecord.CVSymbolRegRel32Record(cvDebugInfo, paramName, + // typeIndex, 0, javaGPregisters[gpRegisterIndex])); + gpRegisterIndex++; + } else { + /* TODO: stack parameter; keep track of stack offset, etc. */ + break; + } + } else { + /* Java object. */ + if (gpRegisterIndex < javaGP64registers.length) { + // int pointerIndex = + // cvDebugInfo.getCVTypeSection().getIndexForPointer(paramType); + // define as offset from register addSymbolRecord(new + // CVSymbolSubrecord.CVSymbolRegRel32Record(cvDebugInfo, paramName, + // typeIndex, 0, javaGPregisters[gpRegisterIndex])); + addSymbolRecord(new CVSymbolSubrecord.CVSymbolLocalRecord(cvDebugInfo, paramName, typeIndex, 1)); + addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeRegisterRecord(cvDebugInfo, javaGP64registers[gpRegisterIndex], externalName, 0, 8)); + addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeFramepointerRelFullScope(cvDebugInfo, 0)); + // regRelRecords.add(new + // CVSymbolSubrecord.CVSymbolRegRel32Record(cvDebugInfo, paramName, + // typeIndex, 0, javaGPregisters[gpRegisterIndex])); + gpRegisterIndex++; + } else { + // TODO: stack parameter; keep track of stack offset, etc. + break; + } + } + } + for (CVSymbolSubrecord record : regRelRecords) { + addSymbolRecord(record); + } + /* TODO: add entries for stack parameters. */ + // addToSymbolSubsection(new CVSymbolSubrecord.CVSymbolEndRecord(cvDebugInfo)); + + /* TODO: add local variables, and their types. */ + /* TODO: add block definitions. */ + } + private void addLineNumberRecords(CompiledMethodEntry compiledEntry) { CVLineRecord record = lineRecordBuilder.build(compiledEntry); /* diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeRecord.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeRecord.java index 94dfc59bd8b7..a166b651c890 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeRecord.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeRecord.java @@ -35,20 +35,27 @@ import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_ARGLIST; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_ARRAY; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_BCLASS; +import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_BITFIELD; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_CLASS; +import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_ENUM; +import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_ENUMERATE; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_FIELDLIST; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_INDEX; +import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_INTERFACE; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_MEMBER; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_METHOD; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_METHODLIST; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_MFUNCTION; +import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_MODIFIER; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_ONEMETHOD; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_PAD1; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_PAD2; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_PAD3; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_POINTER; +import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_PROCEDURE; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_STMEMBER; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_STRING_ID; +import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_STRUCTURE; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_UDT_SRC_LINE; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.MPROP_ABSTRACT; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.MPROP_COMPGENX; @@ -357,6 +364,113 @@ public boolean equals(Object obj) { } } + @SuppressWarnings("unused") + static final class CVTypeModifierRecord extends CVTypeRecord { + + private final int typeIndex; + private final short attrs; + + CVTypeModifierRecord(int typeIndex, short attrs) { + super(LF_MODIFIER); + this.typeIndex = typeIndex; + this.attrs = attrs; + } + + CVTypeModifierRecord(int typeIndex, boolean isConst, boolean isVolatile, boolean isUnaligned) { + this(typeIndex, (short) ((isConst ? 1 : 0) + (isVolatile ? 2 : 0) + (isUnaligned ? 4 : 0))); + } + + @Override + public int computeContents(byte[] buffer, int initialPos) { + int pos = CVUtil.putInt(typeIndex, buffer, initialPos); + return CVUtil.putShort(attrs, buffer, pos); + } + + @Override + public String toString() { + boolean isConst = (attrs & 0x0001) == 0x0001; + boolean isVolatile = (attrs & 0x0002) == 0x0002; + boolean isUnaligned = (attrs & 0x0004) == 0x0004; + return String.format("LF_MODIFIER 0x%04x attr=0x%x%s%s%s pointTo=0x%04x", getSequenceNumber(), attrs, isConst ? " const" : "", isVolatile ? " volatile" : "", + isUnaligned ? " unaligned" : "", typeIndex); + } + + @Override + public int hashCode() { + int h = type; + h = 31 * h + typeIndex; + h = 31 * h + attrs; + return h; + } + + @Override + public boolean equals(Object obj) { + if (!super.equals(obj)) { + return false; + } + CVTypeModifierRecord other = (CVTypeModifierRecord) obj; + return this.typeIndex == other.typeIndex && this.attrs == other.attrs; + } + } + + static final class CVTypeProcedureRecord extends CVTypeRecord { + + private int returnType = -1; + private CVTypeArglistRecord argList = null; + + CVTypeProcedureRecord() { + super(LF_PROCEDURE); + } + + public CVTypeProcedureRecord setReturnType(int leaf) { + this.returnType = leaf; + return this; + } + + public CVTypeProcedureRecord setReturnType(CVTypeRecord leaf) { + this.returnType = leaf.getSequenceNumber(); + return this; + } + + CVTypeProcedureRecord setArgList(CVTypeArglistRecord leaf) { + this.argList = leaf; + return this; + } + + @Override + public int computeContents(byte[] buffer, int initialPos) { + int pos = CVUtil.putInt(returnType, buffer, initialPos); + pos = CVUtil.putByte((byte) CV_CALL_NEAR_C, buffer, pos); + pos = CVUtil.putByte((byte) 0, buffer, pos); /* TODO funcAttr */ + pos = CVUtil.putShort((short) argList.getSize(), buffer, pos); + pos = CVUtil.putInt(argList.getSequenceNumber(), buffer, pos); + return pos; + } + + @Override + public String toString() { + return String.format("LF_PROCEDURE 0x%04x ret=0x%04x arg=0x%04x ", getSequenceNumber(), returnType, argList.getSequenceNumber()); + } + + @Override + public int hashCode() { + int h = type; + h = 31 * h + returnType; + h = 31 * h + argList.hashCode(); + /* callType and funcAttr are always the same so do not add them to the hash */ + return h; + } + + @Override + public boolean equals(Object obj) { + if (!super.equals(obj)) { + return false; + } + CVTypeProcedureRecord other = (CVTypeProcedureRecord) obj; + return this.returnType == other.returnType && this.argList == other.argList; + } + } + static final class CVTypeArglistRecord extends CVTypeRecord { private final ArrayList args = new ArrayList<>(); @@ -1034,6 +1148,18 @@ public boolean equals(Object obj) { } } + @SuppressWarnings("unused") + static final class CVStructRecord extends CVClassRecord { + CVStructRecord(short count, short attrs, int fieldIndex, int derivedFromIndex, int vshape, long size, String name) { + super(LF_STRUCTURE, count, attrs, fieldIndex, derivedFromIndex, vshape, size, name, null); + } + + @Override + public String toString() { + return toString("LF_STRUCT"); + } + } + static final class CVFieldListRecord extends CVTypeRecord { static final int INITIAL_CAPACITY = 10; @@ -1053,6 +1179,10 @@ void add(FieldRecord m) { members.add(m); } + int count() { + return members.size(); + } + int getEstimatedSize() { return estimatedSize; } @@ -1089,6 +1219,169 @@ public String toString() { } } + /* + * Unused in Graal - enums are actually implemented as classes, and enumerations are static + * instances. + */ + @SuppressWarnings("unused") + static final class CVEnumerateRecord extends FieldRecord { + + private final long value; + + CVEnumerateRecord(short attrs, long value, String name) { + super(LF_ENUMERATE, attrs, name); + this.value = value; + } + + @Override + public int computeContents(byte[] buffer, int initialPos) { + int pos = CVUtil.putShort(type, buffer, initialPos); + pos = CVUtil.putShort(attrs, buffer, pos); + pos = CVUtil.putLfNumeric(value, buffer, pos); + pos = CVUtil.putUTF8StringBytes(name, buffer, pos); + return pos; + } + + @Override + public String toString() { + return String.format("LF_ENUMERATE 0x%04x attr=0x%x(%s) val=0x%x %s", type, attrs, attrString(attrs), value, name); + } + + @Override + public int hashCode() { + int h = super.hashCode(); + h = 31 * h + (int) value; + h = 31 * h + name.hashCode(); + return h; + } + + @Override + public boolean equals(Object obj) { + if (!super.equals(obj)) { + return false; + } + CVEnumerateRecord other = (CVEnumerateRecord) obj; + return this.value == other.value; + } + } + + /* + * Unused in Graal - enums are actually implemented as classes, and enumerations are static + * instances. + */ + @SuppressWarnings("unused") + static final class CVEnumRecord extends CVTypeRecord { + + private final String name; + private final int attrs; + private final int underlyingTypeIndex; + private final CVFieldListRecord fieldRecord; + + CVEnumRecord(short attrs, int underlyingTypeIndex, CVFieldListRecord fieldRecord, String name) { + super(LF_ENUM); + this.attrs = attrs; + this.underlyingTypeIndex = underlyingTypeIndex; + this.fieldRecord = fieldRecord; + this.name = name; + } + + @Override + protected int computeContents(byte[] buffer, int initialPos) { + int pos = CVUtil.putShort((short) attrs, buffer, initialPos); + pos = CVUtil.putInt(underlyingTypeIndex, buffer, pos); + pos = CVUtil.putInt(fieldRecord.getSequenceNumber(), buffer, pos); + pos = CVUtil.putUTF8StringBytes(name, buffer, pos); + return pos; + } + + @Override + public int hashCode() { + int hash = type; + hash = 31 * hash + name.hashCode(); + hash = 31 * hash + attrs; + hash = 31 * hash + underlyingTypeIndex; + hash = 31 * hash + fieldRecord.hashCode(); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (!super.equals(obj)) { + return false; + } + CVEnumRecord other = (CVEnumRecord) obj; + return attrs == other.attrs && fieldRecord.equals(other.fieldRecord) && underlyingTypeIndex == other.underlyingTypeIndex && name.equals(other.name); + } + + @Override + public String toString() { + return String.format("LF_ENUM attrs=0x%x(%s) count=%d %s", attrs, propertyString(attrs), fieldRecord.count(), name); + } + } + + @SuppressWarnings("unused") + static final class CVInterfaceRecord extends CVClassRecord { + CVInterfaceRecord(short count, short attrs, int fieldIndex, int derivedFromIndex, int vshape, String name) { + super(LF_INTERFACE, count, attrs, fieldIndex, derivedFromIndex, vshape, 0, name, null); + } + + @Override + public String toString() { + return toString("LF_INTERFACE"); + } + } + + @SuppressWarnings("unused") + static final class CVTypeBitfieldRecord extends CVTypeRecord { + + private final byte length; + private final byte position; + private final int typeIndex; + + CVTypeBitfieldRecord(int length, int position, int typeIndex) { + super(LF_BITFIELD); + this.length = (byte) length; + this.position = (byte) position; + this.typeIndex = typeIndex; + } + + @Override + public int computeSize(int initialPos) { + return initialPos + Integer.BYTES + Byte.BYTES + Byte.BYTES; + } + + @Override + public int computeContents(byte[] buffer, int initialPos) { + int pos = CVUtil.putInt(typeIndex, buffer, initialPos); + pos = CVUtil.putByte(length, buffer, pos); + pos = CVUtil.putByte(position, buffer, pos); + return pos; + } + + @Override + public String toString() { + return String.format("LF_BITFIELD 0x%04x, type=0x%04x len=%d pos=%d", getSequenceNumber(), typeIndex, length, position); + } + + @Override + public int hashCode() { + int h = type; + h = 31 * h + position; + h = 31 * h + length; + h = 31 * h + typeIndex; + return h; + } + + @Override + public boolean equals(Object obj) { + if (!super.equals(obj)) { + return false; + } + CVTypeBitfieldRecord other = (CVTypeBitfieldRecord) obj; + return this.position == other.position && this.length == other.length && this.typeIndex == other.typeIndex; + } + } + static final class CVTypeArrayRecord extends CVTypeRecord { private final int elementTypeIndex; From 6faffc6ede4fda704f20b2e38b3f5c5c0d255ccc Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Fri, 16 Dec 2022 12:45:56 -0500 Subject: [PATCH 02/48] Small cleanup to get rid of unused record types. --- .../pecoff/cv/CVDebugConstants.java | 4 +- .../pecoff/cv/CVSymbolSubrecord.java | 12 +- .../objectfile/pecoff/cv/CVTypeRecord.java | 180 ------------------ 3 files changed, 10 insertions(+), 186 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVDebugConstants.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVDebugConstants.java index 8010c31459cb..15092a78d4cd 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVDebugConstants.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVDebugConstants.java @@ -49,10 +49,10 @@ public abstract class CVDebugConstants { static final short S_ENVBLOCK = 0x113d; static final short S_LOCAL = 0x113e; static final short S_DEFRANGE = 0x113f; - // static final short S_DEFRANGE_SUBFIELD = 0x1140; + static final short S_DEFRANGE_SUBFIELD = 0x1140; static final short S_DEFRANGE_REGISTER = 0x1141; static final short S_DEFRANGE_FRAMEPOINTER_REL = 0x1142; - // static final short S_DEFRANGE_SUBFIELD_REGISTER = 0x1143; + static final short S_DEFRANGE_SUBFIELD_REGISTER = 0x1143; static final short S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE = 0x1144; static final short S_DEFRANGE_REGISTER_REL = 0x1145; } diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java index a2ef6b96e2f8..7d0ed1b4ea1f 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java @@ -304,7 +304,7 @@ public String toString() { } } - + @SuppressWarnings("unused") public static class CVSymbolRegisterRecord extends CVSymbolSubrecord { private final String name; @@ -379,6 +379,7 @@ protected CVSymbolDefRangeBase(CVDebugInfo debugInfo, short recordType, String p void addGap() { /* TODO */ + GraalError.shouldNotReachHere("addGap() not implemented"); } int computeRange(byte[] buffer, int initialPos) { @@ -391,7 +392,7 @@ int computeRange(byte[] buffer, int initialPos) { } int computeGaps(@SuppressWarnings("unused") byte[] buffer, int initialPos) { - /* Emit gaps. Not Yet implemented. */ + /* Emit gaps. Not yet implemented. */ assert gapCount == 0; return initialPos; } @@ -447,6 +448,7 @@ public String toString() { } } + @SuppressWarnings("unused") public static class CVSymbolDefRangeRegisterRel extends CVSymbolDefRangeBase { private final short baseRegister; @@ -509,6 +511,7 @@ public String toString() { } } + @SuppressWarnings("unused") public static class CVSymbolDefRangeFramepointerRel extends CVSymbolDefRangeBase { private final int fpOffset; @@ -531,6 +534,7 @@ public String toString() { } } + @SuppressWarnings("unused") public static class CVSymbolBlock32Record extends CVSymbolSubrecord { // K32 name= parent=0x0 end=0x0 len=0x8 codeoffset=0x0:70 // reloc addr=0x0008e5 type=11 sym=main IMAGE_REL_AMD64_SECREL(0x0b) @@ -545,7 +549,7 @@ public static class CVSymbolBlock32Record extends CVSymbolSubrecord { CVSymbolBlock32Record(CVDebugInfo cvDebugInfo, String procName) { super(cvDebugInfo, S_BLOCK32); this.procName = procName; - /* TODO probably need to implement procOffset here, too. */ + /* TODO - may need to implement procOffset here. */ } @Override @@ -622,7 +626,7 @@ public String toString() { public static final class CVSymbolFrameProcRecord extends CVSymbolSubrecord { - /* TODO: This may change in the presence of isolates. */ + /* This may change in the presence of isolates. */ /* Async exception handling (vc++ uses 1, clang uses 0). */ public static final int FRAME_ASYNC_EH = 1 << 9; diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeRecord.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeRecord.java index a166b651c890..0b700c54464a 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeRecord.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeRecord.java @@ -35,13 +35,9 @@ import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_ARGLIST; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_ARRAY; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_BCLASS; -import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_BITFIELD; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_CLASS; -import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_ENUM; -import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_ENUMERATE; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_FIELDLIST; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_INDEX; -import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_INTERFACE; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_MEMBER; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_METHOD; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_METHODLIST; @@ -55,7 +51,6 @@ import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_PROCEDURE; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_STMEMBER; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_STRING_ID; -import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_STRUCTURE; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_UDT_SRC_LINE; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.MPROP_ABSTRACT; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.MPROP_COMPGENX; @@ -1148,18 +1143,6 @@ public boolean equals(Object obj) { } } - @SuppressWarnings("unused") - static final class CVStructRecord extends CVClassRecord { - CVStructRecord(short count, short attrs, int fieldIndex, int derivedFromIndex, int vshape, long size, String name) { - super(LF_STRUCTURE, count, attrs, fieldIndex, derivedFromIndex, vshape, size, name, null); - } - - @Override - public String toString() { - return toString("LF_STRUCT"); - } - } - static final class CVFieldListRecord extends CVTypeRecord { static final int INITIAL_CAPACITY = 10; @@ -1219,169 +1202,6 @@ public String toString() { } } - /* - * Unused in Graal - enums are actually implemented as classes, and enumerations are static - * instances. - */ - @SuppressWarnings("unused") - static final class CVEnumerateRecord extends FieldRecord { - - private final long value; - - CVEnumerateRecord(short attrs, long value, String name) { - super(LF_ENUMERATE, attrs, name); - this.value = value; - } - - @Override - public int computeContents(byte[] buffer, int initialPos) { - int pos = CVUtil.putShort(type, buffer, initialPos); - pos = CVUtil.putShort(attrs, buffer, pos); - pos = CVUtil.putLfNumeric(value, buffer, pos); - pos = CVUtil.putUTF8StringBytes(name, buffer, pos); - return pos; - } - - @Override - public String toString() { - return String.format("LF_ENUMERATE 0x%04x attr=0x%x(%s) val=0x%x %s", type, attrs, attrString(attrs), value, name); - } - - @Override - public int hashCode() { - int h = super.hashCode(); - h = 31 * h + (int) value; - h = 31 * h + name.hashCode(); - return h; - } - - @Override - public boolean equals(Object obj) { - if (!super.equals(obj)) { - return false; - } - CVEnumerateRecord other = (CVEnumerateRecord) obj; - return this.value == other.value; - } - } - - /* - * Unused in Graal - enums are actually implemented as classes, and enumerations are static - * instances. - */ - @SuppressWarnings("unused") - static final class CVEnumRecord extends CVTypeRecord { - - private final String name; - private final int attrs; - private final int underlyingTypeIndex; - private final CVFieldListRecord fieldRecord; - - CVEnumRecord(short attrs, int underlyingTypeIndex, CVFieldListRecord fieldRecord, String name) { - super(LF_ENUM); - this.attrs = attrs; - this.underlyingTypeIndex = underlyingTypeIndex; - this.fieldRecord = fieldRecord; - this.name = name; - } - - @Override - protected int computeContents(byte[] buffer, int initialPos) { - int pos = CVUtil.putShort((short) attrs, buffer, initialPos); - pos = CVUtil.putInt(underlyingTypeIndex, buffer, pos); - pos = CVUtil.putInt(fieldRecord.getSequenceNumber(), buffer, pos); - pos = CVUtil.putUTF8StringBytes(name, buffer, pos); - return pos; - } - - @Override - public int hashCode() { - int hash = type; - hash = 31 * hash + name.hashCode(); - hash = 31 * hash + attrs; - hash = 31 * hash + underlyingTypeIndex; - hash = 31 * hash + fieldRecord.hashCode(); - return hash; - } - - @Override - public boolean equals(Object obj) { - if (!super.equals(obj)) { - return false; - } - CVEnumRecord other = (CVEnumRecord) obj; - return attrs == other.attrs && fieldRecord.equals(other.fieldRecord) && underlyingTypeIndex == other.underlyingTypeIndex && name.equals(other.name); - } - - @Override - public String toString() { - return String.format("LF_ENUM attrs=0x%x(%s) count=%d %s", attrs, propertyString(attrs), fieldRecord.count(), name); - } - } - - @SuppressWarnings("unused") - static final class CVInterfaceRecord extends CVClassRecord { - CVInterfaceRecord(short count, short attrs, int fieldIndex, int derivedFromIndex, int vshape, String name) { - super(LF_INTERFACE, count, attrs, fieldIndex, derivedFromIndex, vshape, 0, name, null); - } - - @Override - public String toString() { - return toString("LF_INTERFACE"); - } - } - - @SuppressWarnings("unused") - static final class CVTypeBitfieldRecord extends CVTypeRecord { - - private final byte length; - private final byte position; - private final int typeIndex; - - CVTypeBitfieldRecord(int length, int position, int typeIndex) { - super(LF_BITFIELD); - this.length = (byte) length; - this.position = (byte) position; - this.typeIndex = typeIndex; - } - - @Override - public int computeSize(int initialPos) { - return initialPos + Integer.BYTES + Byte.BYTES + Byte.BYTES; - } - - @Override - public int computeContents(byte[] buffer, int initialPos) { - int pos = CVUtil.putInt(typeIndex, buffer, initialPos); - pos = CVUtil.putByte(length, buffer, pos); - pos = CVUtil.putByte(position, buffer, pos); - return pos; - } - - @Override - public String toString() { - return String.format("LF_BITFIELD 0x%04x, type=0x%04x len=%d pos=%d", getSequenceNumber(), typeIndex, length, position); - } - - @Override - public int hashCode() { - int h = type; - h = 31 * h + position; - h = 31 * h + length; - h = 31 * h + typeIndex; - return h; - } - - @Override - public boolean equals(Object obj) { - if (!super.equals(obj)) { - return false; - } - CVTypeBitfieldRecord other = (CVTypeBitfieldRecord) obj; - return this.position == other.position && this.length == other.length && this.typeIndex == other.typeIndex; - } - } - static final class CVTypeArrayRecord extends CVTypeRecord { private final int elementTypeIndex; From f2f013afb5489f5f6a967bd23f60d5b38a01e4d2 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Fri, 16 Dec 2022 14:31:16 -0500 Subject: [PATCH 03/48] CHanges for Github gate. --- .../pecoff/cv/CVSymbolSubrecord.java | 3 +- .../pecoff/cv/CVSymbolSubsectionBuilder.java | 48 ++----------------- 2 files changed, 6 insertions(+), 45 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java index 7d0ed1b4ea1f..cb0a9a41dea0 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java @@ -377,6 +377,7 @@ protected CVSymbolDefRangeBase(CVDebugInfo debugInfo, short recordType, String p } } + @SuppressWarnings("unused") void addGap() { /* TODO */ GraalError.shouldNotReachHere("addGap() not implemented"); @@ -384,8 +385,6 @@ void addGap() { int computeRange(byte[] buffer, int initialPos) { /* Emit CV_LVAR_ADDR_RANGE. */ - // int pos = cvDebugInfo.getCVSymbolSection().markRelocationSite(buffer, initialPos, - // procName, (long) procOffset); int pos = cvDebugInfo.getCVSymbolSection().markRelocationSite(buffer, initialPos, procName); pos = CVUtil.putShort(range, buffer, pos); return pos; diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java index ed3af02a83cf..0463a15286e1 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java @@ -36,7 +36,6 @@ import org.graalvm.compiler.debug.GraalError; import java.lang.reflect.Modifier; -import java.util.ArrayList; import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_CL; import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_CX; @@ -83,8 +82,6 @@ final class CVSymbolSubsectionBuilder { private static final short[] javaGP32registers = {CV_AMD64_EDX, CV_AMD64_R8D, CV_AMD64_R9D, CV_AMD64_EDI, CV_AMD64_ESI, CV_AMD64_ECX}; private static final short[] javaGP16registers = {CV_AMD64_DX, CV_AMD64_R8W, CV_AMD64_R9W, CV_AMD64_DI, CV_AMD64_SI, CV_AMD64_CX}; private static final short[] javaGP8registers = {CV_AMD64_DL, CV_AMD64_R8B, CV_AMD64_R9B, CV_AMD64_DIL, CV_AMD64_SIL, CV_AMD64_CL}; - // private static final short[] javaFP128registers = {CV_AMD64_XMM0, CV_AMD64_XMM1, - // CV_AMD64_XMM2, CV_AMD64_XMM3}; private static final short[] javaFP64registers = {CV_AMD64_XMM0L, CV_AMD64_XMM1L, CV_AMD64_XMM2L, CV_AMD64_XMM3L}; private static final short[] javaFP32registers = {CV_AMD64_XMM0_0, CV_AMD64_XMM1_0, CV_AMD64_XMM2_0, CV_AMD64_XMM3_0}; @@ -174,14 +171,13 @@ private void buildFunction(CompiledMethodEntry compiledEntry) { /* The name as exposed to the linker. */ final String externalName = primaryRange.getSymbolName(); - /* S_PROC32 add function definition. */ + /* add function definition. */ final int functionTypeIndex = addTypeRecords(compiledEntry); final byte funcFlags = 0; CVSymbolSubrecord.CVSymbolGProc32Record proc32 = new CVSymbolSubrecord.CVSymbolGProc32Record(cvDebugInfo, externalName, debuggerName, 0, 0, 0, primaryRange.getHi() - primaryRange.getLo(), 0, 0, functionTypeIndex, (short) 0, funcFlags); addSymbolRecord(proc32); - /* NB: LLVM uses 0x14000. */ final int frameFlags = FRAME_ASYNC_EH + FRAME_LOCAL_BP + FRAME_PARAM_BP; addSymbolRecord(new CVSymbolSubrecord.CVSymbolFrameProcRecord(cvDebugInfo, compiledEntry.getFrameSize(), frameFlags)); @@ -194,18 +190,14 @@ private void buildFunction(CompiledMethodEntry compiledEntry) { addLineNumberRecords(compiledEntry); } - void addLocals(CompiledMethodEntry primaryEntry) { final Range primaryRange = primaryEntry.getPrimary(); /* The name as exposed to the linker. */ final String externalName = primaryRange.getSymbolName(); /* Add register parameters - only valid for the first instruction or two. */ - // addToSymbolSubsection(new CVSymbolSubrecord.CVSymbolBlock32Record(cvDebugInfo, - // externalName)); MethodEntry method = primaryRange.getMethodEntry(); - ArrayList regRelRecords = new ArrayList<>(method.getParamCount() + 1); int gpRegisterIndex = 0; int fpRegisterIndex = 0; @@ -219,7 +211,7 @@ void addLocals(CompiledMethodEntry primaryEntry) { gpRegisterIndex++; } - /* define function parameters accoording to the calling convention */ + /* define function parameters (p1, p2...) according to the calling convention */ for (int i = 0; i < method.getParamCount(); i++) { final TypeEntry paramType = method.getParamType(i); final int typeIndex = cvDebugInfo.getCVTypeSection().addTypeRecords(paramType).getSequenceNumber(); @@ -229,19 +221,11 @@ void addLocals(CompiledMethodEntry primaryEntry) { if (fpRegisterIndex < javaFP64registers.length) { final short register = typeIndex == T_REAL64 ? javaFP64registers[fpRegisterIndex] : javaFP32registers[fpRegisterIndex]; addSymbolRecord(new CVSymbolSubrecord.CVSymbolLocalRecord(cvDebugInfo, paramName, typeIndex, 1)); - // addSymbolRecord(new CVSymbolSubrecord.CVSymbolRegisterRecord(cvDebugInfo, - // paramName, typeIndex, javaFPregisters[fpRegisterIndex])); addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeRegisterRecord(cvDebugInfo, register, externalName, 0, 8)); - // addSymbolRecord(new - // CVSymbolSubrecord.CVSymbolDefRangeFramepointerRel(cvDebugInfo, "main", 8, - // (short) 8, 32)); addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeFramepointerRelFullScope(cvDebugInfo, 0)); - // regRelRecords.add(new - // CVSymbolSubrecord.CVSymbolRegRel32Record(cvDebugInfo, paramName, - // typeIndex, 0, javaFPregisters[fpRegisterIndex])); fpRegisterIndex++; } else { - /* TODO: stack parameter; keep track of stack offset, etc. */ + /* TODO: handle stack parameter; keep track of stack offset, etc. */ break; } } else if (paramType.isPrimitive()) { @@ -261,49 +245,27 @@ void addLocals(CompiledMethodEntry primaryEntry) { GraalError.shouldNotReachHere("Unknown primitive (type" + paramType.getTypeName() + ") size:" + paramType.getSize()); } addSymbolRecord(new CVSymbolSubrecord.CVSymbolLocalRecord(cvDebugInfo, paramName, typeIndex, 1)); - // addSymbolRecord(new - // CVSymbolSubrecord.CVSymbolRegisterRecord(cvDebugInfo, paramName, - // typeIndex, javaGPregisters[gpRegisterIndex])); addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeRegisterRecord(cvDebugInfo, register, externalName, 0, 8)); - // addSymbolRecord(new - // CVSymbolSubrecord.CVSymbolDefRangeFramepointerRel(cvDebugInfo, - // "main", 8, (short) 8, 32)); addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeFramepointerRelFullScope(cvDebugInfo, 8)); - // regRelRecords.add(new - // CVSymbolSubrecord.CVSymbolRegRel32Record(cvDebugInfo, paramName, - // typeIndex, 0, javaGPregisters[gpRegisterIndex])); gpRegisterIndex++; } else { - /* TODO: stack parameter; keep track of stack offset, etc. */ + /* TODO: handle stack parameter; keep track of stack offset, etc. */ break; } } else { /* Java object. */ if (gpRegisterIndex < javaGP64registers.length) { - // int pointerIndex = - // cvDebugInfo.getCVTypeSection().getIndexForPointer(paramType); - // define as offset from register addSymbolRecord(new - // CVSymbolSubrecord.CVSymbolRegRel32Record(cvDebugInfo, paramName, - // typeIndex, 0, javaGPregisters[gpRegisterIndex])); addSymbolRecord(new CVSymbolSubrecord.CVSymbolLocalRecord(cvDebugInfo, paramName, typeIndex, 1)); addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeRegisterRecord(cvDebugInfo, javaGP64registers[gpRegisterIndex], externalName, 0, 8)); addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeFramepointerRelFullScope(cvDebugInfo, 0)); - // regRelRecords.add(new - // CVSymbolSubrecord.CVSymbolRegRel32Record(cvDebugInfo, paramName, - // typeIndex, 0, javaGPregisters[gpRegisterIndex])); gpRegisterIndex++; } else { - // TODO: stack parameter; keep track of stack offset, etc. + /* TODO: handle stack parameter; keep track of stack offset, etc. */ break; } } } - for (CVSymbolSubrecord record : regRelRecords) { - addSymbolRecord(record); - } /* TODO: add entries for stack parameters. */ - // addToSymbolSubsection(new CVSymbolSubrecord.CVSymbolEndRecord(cvDebugInfo)); - /* TODO: add local variables, and their types. */ /* TODO: add block definitions. */ } From 569ab0dd142a03293797238ada09017854fd70a9 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Fri, 13 Jan 2023 16:03:13 -0500 Subject: [PATCH 04/48] Changes per @adinn review --- .../pecoff/cv/CVSymbolSubsectionBuilder.java | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java index 0463a15286e1..c24630c68674 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java @@ -31,12 +31,15 @@ import com.oracle.objectfile.debugentry.CompiledMethodEntry; import com.oracle.objectfile.debugentry.FieldEntry; import com.oracle.objectfile.debugentry.MethodEntry; +import com.oracle.objectfile.debugentry.PrimitiveTypeEntry; import com.oracle.objectfile.debugentry.Range; import com.oracle.objectfile.debugentry.TypeEntry; import org.graalvm.compiler.debug.GraalError; import java.lang.reflect.Modifier; +import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugPrimitiveTypeInfo.FLAG_INTEGRAL; +import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugPrimitiveTypeInfo.FLAG_NUMERIC; import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_CL; import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_CX; import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_DI; @@ -72,8 +75,6 @@ import static com.oracle.objectfile.pecoff.cv.CVSymbolSubrecord.CVSymbolFrameProcRecord.FRAME_ASYNC_EH; import static com.oracle.objectfile.pecoff.cv.CVSymbolSubrecord.CVSymbolFrameProcRecord.FRAME_LOCAL_BP; import static com.oracle.objectfile.pecoff.cv.CVSymbolSubrecord.CVSymbolFrameProcRecord.FRAME_PARAM_BP; -import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.T_REAL32; -import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.T_REAL64; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.MAX_PRIMITIVE; final class CVSymbolSubsectionBuilder { @@ -216,21 +217,23 @@ void addLocals(CompiledMethodEntry primaryEntry) { final TypeEntry paramType = method.getParamType(i); final int typeIndex = cvDebugInfo.getCVTypeSection().addTypeRecords(paramType).getSequenceNumber(); final String paramName = "p" + (i + 1); - if (typeIndex == T_REAL64 || typeIndex == T_REAL32) { - /* floating point primitive */ - if (fpRegisterIndex < javaFP64registers.length) { - final short register = typeIndex == T_REAL64 ? javaFP64registers[fpRegisterIndex] : javaFP32registers[fpRegisterIndex]; - addSymbolRecord(new CVSymbolSubrecord.CVSymbolLocalRecord(cvDebugInfo, paramName, typeIndex, 1)); - addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeRegisterRecord(cvDebugInfo, register, externalName, 0, 8)); - addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeFramepointerRelFullScope(cvDebugInfo, 0)); - fpRegisterIndex++; - } else { - /* TODO: handle stack parameter; keep track of stack offset, etc. */ - break; - } - } else if (paramType.isPrimitive()) { + if (paramType.isPrimitive()) { /* simple primitive */ - if (gpRegisterIndex < javaGP64registers.length) { + final PrimitiveTypeEntry primitiveTypeEntry = (PrimitiveTypeEntry) paramType; + final boolean isFloatingPoint = ((primitiveTypeEntry.getFlags() & FLAG_NUMERIC) != 0 && (primitiveTypeEntry.getFlags() & FLAG_INTEGRAL) == 0); + if (isFloatingPoint) { + /* floating point primitive */ + if (fpRegisterIndex < javaFP64registers.length) { + final short register = paramType.getSize() == Double.BYTES ? javaFP64registers[fpRegisterIndex] : javaFP32registers[fpRegisterIndex]; + addSymbolRecord(new CVSymbolSubrecord.CVSymbolLocalRecord(cvDebugInfo, paramName, typeIndex, 1)); + addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeRegisterRecord(cvDebugInfo, register, externalName, 0, 8)); + addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeFramepointerRelFullScope(cvDebugInfo, 0)); + fpRegisterIndex++; + } else { + /* TODO: handle stack parameter; keep track of stack offset, etc. */ + break; + } + } else if (gpRegisterIndex < javaGP64registers.length) { final short register; if (paramType.getSize() == 8) { register = javaGP64registers[gpRegisterIndex]; @@ -271,13 +274,13 @@ void addLocals(CompiledMethodEntry primaryEntry) { } private void addLineNumberRecords(CompiledMethodEntry compiledEntry) { - CVLineRecord record = lineRecordBuilder.build(compiledEntry); + CVLineRecord lineRecord = lineRecordBuilder.build(compiledEntry); /* * If there are no file entries (perhaps for a synthetic function?), we don't add this * record. */ - if (!record.isEmpty()) { - cvDebugInfo.getCVSymbolSection().addRecord(record); + if (!lineRecord.isEmpty()) { + cvDebugInfo.getCVSymbolSection().addRecord(lineRecord); } } From 82b891e6b4f4cb68d8bc0f186b4c7d6614951214 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Fri, 5 May 2023 13:01:14 -0400 Subject: [PATCH 05/48] use real names for parameter variables --- .../pecoff/cv/CVSymbolSubsectionBuilder.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java index 4556c7c16ea7..d575ad14181c 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java @@ -34,6 +34,7 @@ import com.oracle.objectfile.debugentry.MethodEntry; import com.oracle.objectfile.debugentry.PrimitiveTypeEntry; import com.oracle.objectfile.debugentry.range.Range; +import com.oracle.objectfile.debuginfo.DebugInfoProvider; import java.lang.reflect.Modifier; @@ -204,8 +205,9 @@ void addLocals(CompiledMethodEntry primaryEntry) { /* define 'this' as a local just as we define other object pointers */ if (!Modifier.isStatic(method.getModifiers())) { final TypeEntry thisType = primaryEntry.getClassEntry(); + DebugInfoProvider.DebugLocalInfo thisparam = method.getThisParam(); final int typeIndex = cvDebugInfo.getCVTypeSection().getIndexForPointer(thisType); - addSymbolRecord(new CVSymbolSubrecord.CVSymbolLocalRecord(cvDebugInfo, "this", typeIndex, 1)); + addSymbolRecord(new CVSymbolSubrecord.CVSymbolLocalRecord(cvDebugInfo, thisparam.name(), typeIndex, 1)); addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeRegisterRecord(cvDebugInfo, javaGP64registers[gpRegisterIndex], externalName, 0, 8)); addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeFramepointerRelFullScope(cvDebugInfo, 0)); gpRegisterIndex++; @@ -213,9 +215,9 @@ void addLocals(CompiledMethodEntry primaryEntry) { /* define function parameters (p1, p2...) according to the calling convention */ for (int i = 0; i < method.getParamCount(); i++) { + final DebugInfoProvider.DebugLocalInfo paramInfo = method.getParam(i); final TypeEntry paramType = method.getParamType(i); final int typeIndex = cvDebugInfo.getCVTypeSection().addTypeRecords(paramType).getSequenceNumber(); - final String paramName = "p" + (i + 1); if (paramType.isPrimitive()) { /* simple primitive */ final PrimitiveTypeEntry primitiveTypeEntry = (PrimitiveTypeEntry) paramType; @@ -224,7 +226,7 @@ void addLocals(CompiledMethodEntry primaryEntry) { /* floating point primitive */ if (fpRegisterIndex < javaFP64registers.length) { final short register = paramType.getSize() == Double.BYTES ? javaFP64registers[fpRegisterIndex] : javaFP32registers[fpRegisterIndex]; - addSymbolRecord(new CVSymbolSubrecord.CVSymbolLocalRecord(cvDebugInfo, paramName, typeIndex, 1)); + addSymbolRecord(new CVSymbolSubrecord.CVSymbolLocalRecord(cvDebugInfo, paramInfo.name(), typeIndex, 1)); addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeRegisterRecord(cvDebugInfo, register, externalName, 0, 8)); addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeFramepointerRelFullScope(cvDebugInfo, 0)); fpRegisterIndex++; @@ -246,7 +248,7 @@ void addLocals(CompiledMethodEntry primaryEntry) { register = 0; /* Avoid warning. */ throw new RuntimeException("Unknown primitive (type" + paramType.getTypeName() + ") size:" + paramType.getSize()); } - addSymbolRecord(new CVSymbolSubrecord.CVSymbolLocalRecord(cvDebugInfo, paramName, typeIndex, 1)); + addSymbolRecord(new CVSymbolSubrecord.CVSymbolLocalRecord(cvDebugInfo, paramInfo.name(), typeIndex, 1)); addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeRegisterRecord(cvDebugInfo, register, externalName, 0, 8)); addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeFramepointerRelFullScope(cvDebugInfo, 8)); gpRegisterIndex++; @@ -257,7 +259,7 @@ void addLocals(CompiledMethodEntry primaryEntry) { } else { /* Java object. */ if (gpRegisterIndex < javaGP64registers.length) { - addSymbolRecord(new CVSymbolSubrecord.CVSymbolLocalRecord(cvDebugInfo, paramName, typeIndex, 1)); + addSymbolRecord(new CVSymbolSubrecord.CVSymbolLocalRecord(cvDebugInfo, paramInfo.name(), typeIndex, 1)); addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeRegisterRecord(cvDebugInfo, javaGP64registers[gpRegisterIndex], externalName, 0, 8)); addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeFramepointerRelFullScope(cvDebugInfo, 0)); gpRegisterIndex++; From 0b010df37d122d1c302f328741d9cf8a47fcdec5 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Fri, 25 Aug 2023 14:06:08 -0400 Subject: [PATCH 06/48] Define functions using S_GPROC32_ID records. --- .../pecoff/cv/CVDebugConstants.java | 3 + .../pecoff/cv/CVSymbolSubrecord.java | 67 ++++++++++--- .../pecoff/cv/CVSymbolSubsectionBuilder.java | 15 +-- .../objectfile/pecoff/cv/CVTypeRecord.java | 95 +++++++++++++++++++ .../pecoff/cv/CVTypeSectionBuilder.java | 11 ++- 5 files changed, 171 insertions(+), 20 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVDebugConstants.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVDebugConstants.java index 15092a78d4cd..95df3802b70f 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVDebugConstants.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVDebugConstants.java @@ -55,4 +55,7 @@ public abstract class CVDebugConstants { static final short S_DEFRANGE_SUBFIELD_REGISTER = 0x1143; static final short S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE = 0x1144; static final short S_DEFRANGE_REGISTER_REL = 0x1145; + static final short S_LPROC32_ID = 0x1146; + static final short S_GPROC32_ID = 0x1147; + static final short S_PROC_ID_END = 0x114f; } diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java index cb0a9a41dea0..959a711c21c2 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java @@ -573,17 +573,17 @@ public String toString() { */ public static class CVSymbolGProc32Record extends CVSymbolSubrecord { - private final int pparent; - private final int pend; - private final int pnext; - private final int proclen; - private final int debugStart; - private final int debugEnd; - private final int typeIndex; - private final short segment; - private final byte flags; - private final String symbolName; - private final String displayName; + protected final int pparent; + protected final int pend; + protected final int pnext; + protected final int proclen; + protected final int debugStart; + protected final int debugEnd; + protected final int typeIndex; + protected final short segment; + protected final byte flags; + protected final String symbolName; + protected final String displayName; CVSymbolGProc32Record(CVDebugInfo cvDebugInfo, String symbolName, String displayName, int pparent, int pend, int pnext, int proclen, int debugStart, int debugEnd, int typeIndex, short segment, byte flags) { @@ -601,6 +601,22 @@ public static class CVSymbolGProc32Record extends CVSymbolSubrecord { this.flags = flags; } + protected CVSymbolGProc32Record(CVDebugInfo cvDebugInfo, short cmd, String symbolName, String displayName, int pparent, int pend, int pnext, int proclen, int debugStart, int debugEnd, int typeIndex, + short segment, byte flags) { + super(cvDebugInfo, cmd); + this.symbolName = symbolName; + this.displayName = displayName; + this.pparent = pparent; + this.pend = pend; + this.pnext = pnext; + this.proclen = proclen; + this.debugStart = debugStart; + this.debugEnd = debugEnd; + this.typeIndex = typeIndex; + this.segment = segment; + this.flags = flags; + } + @Override protected int computeContents(byte[] buffer, int initialPos) { int pos = CVUtil.putInt(pparent, buffer, initialPos); @@ -623,6 +639,21 @@ public String toString() { } } + public static class CVSymbolGProc32IdRecord extends CVSymbolGProc32Record { + + CVSymbolGProc32IdRecord(CVDebugInfo cvDebugInfo, String symbolName, String displayName, int pparent, int pend, int pnext, int proclen, int debugStart, int debugEnd, int typeIndex, + short segment, byte flags) { + + super(cvDebugInfo, CVDebugConstants.S_GPROC32_ID, symbolName, displayName, pparent, pend, pnext, proclen, debugStart, debugEnd, typeIndex, segment, flags); + } + + @Override + public String toString() { + return String.format("S_GPROC32_ID name=%s/%s parent=%d debugstart=0x%x debugend=0x%x len=0x%x seg:offset=0x%x:0 type=0x%x flags=0x%x)", displayName, symbolName, pparent, debugStart, + debugEnd, proclen, segment, typeIndex, flags); + } + } + public static final class CVSymbolFrameProcRecord extends CVSymbolSubrecord { /* This may change in the presence of isolates. */ @@ -703,7 +734,7 @@ public String toString() { public static class CVSymbolEndRecord extends CVSymbolSubrecord { - CVSymbolEndRecord(CVDebugInfo cvDebugInfo, short cmd) { + protected CVSymbolEndRecord(CVDebugInfo cvDebugInfo, short cmd) { super(cvDebugInfo, cmd); } @@ -722,4 +753,16 @@ public String toString() { return "S_END"; } } + + public static class CVSymbolProcIdEndRecord extends CVSymbolEndRecord { + + CVSymbolProcIdEndRecord(CVDebugInfo cvDebugInfo) { + super(cvDebugInfo, CVDebugConstants.S_PROC_ID_END); + } + + @Override + public String toString() { + return "S_PROC_ID_END"; + } + } } diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java index d575ad14181c..053e0e3061c6 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java @@ -130,8 +130,8 @@ void build() { */ private void buildClass(ClassEntry classEntry) { - /* Define all the functions in this class all functions defined in this class. */ - classEntry.compiledEntries().forEach(this::buildFunction); + /* Define all functions defined in this class. */ + classEntry.compiledEntries().toList().forEach(this::buildFunction); /* Define the class itself. */ addTypeRecords(classEntry); @@ -164,6 +164,7 @@ private static boolean isManifestedStaticField(FieldEntry fieldEntry) { * @param compiledEntry compiled method for this function */ private void buildFunction(CompiledMethodEntry compiledEntry) { + final Range primaryRange = compiledEntry.getPrimary(); /* The name as it will appear in the debugger. */ @@ -175,17 +176,17 @@ private void buildFunction(CompiledMethodEntry compiledEntry) { /* add function definition. */ final int functionTypeIndex = addTypeRecords(compiledEntry); final byte funcFlags = 0; - CVSymbolSubrecord.CVSymbolGProc32Record proc32 = new CVSymbolSubrecord.CVSymbolGProc32Record(cvDebugInfo, externalName, debuggerName, 0, 0, 0, primaryRange.getHi() - primaryRange.getLo(), 0, + CVSymbolSubrecord.CVSymbolGProc32IdRecord proc32 = new CVSymbolSubrecord.CVSymbolGProc32IdRecord(cvDebugInfo, externalName, debuggerName, 0, 0, 0, primaryRange.getHi() - primaryRange.getLo(), 0, 0, functionTypeIndex, (short) 0, funcFlags); addSymbolRecord(proc32); - final int frameFlags = FRAME_ASYNC_EH + FRAME_LOCAL_BP + FRAME_PARAM_BP; + final int frameFlags = FRAME_LOCAL_BP + FRAME_PARAM_BP; addSymbolRecord(new CVSymbolSubrecord.CVSymbolFrameProcRecord(cvDebugInfo, compiledEntry.getFrameSize(), frameFlags)); addLocals(compiledEntry); - /* S_END add end record. */ - addSymbolRecord(new CVSymbolSubrecord.CVSymbolEndRecord(cvDebugInfo)); + /* S_PROC_ID_END add end record. */ + addSymbolRecord(new CVSymbolSubrecord.CVSymbolProcIdEndRecord(cvDebugInfo)); /* Add line number records. */ addLineNumberRecords(compiledEntry); @@ -314,7 +315,7 @@ private void addTypeRecords(TypeEntry typeEntry) { } /** - * Add type records for a class and all its members. + * Add type records for a method. * * @param entry compiled method containing entities whos type records must be added * @return type index of function type diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeRecord.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeRecord.java index a2c47f8d292e..8004d92c40fb 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeRecord.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeRecord.java @@ -33,11 +33,13 @@ import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_BCLASS; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_CLASS; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_FIELDLIST; +import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_FUNC_ID; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_INDEX; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_MEMBER; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_METHOD; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_METHODLIST; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_MFUNCTION; +import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_MFUNC_ID; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_MODIFIER; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_ONEMETHOD; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_PAD1; @@ -315,6 +317,95 @@ public boolean equals(Object obj) { } } + static final class CVTypeFuncIdRecord extends CVTypeRecord { + + int scopeIdx; + int typeIdx; + String name; + + CVTypeFuncIdRecord(int scopeIdx, int typeIdx, String name) { + super(LF_FUNC_ID); + this.scopeIdx = scopeIdx; + this.typeIdx = typeIdx; + this.name = name; + } + + @Override + public int computeContents(byte[] buffer, int initialPos) { + int pos = CVUtil.putInt(scopeIdx, buffer, initialPos); + pos = CVUtil.putInt(typeIdx, buffer, pos); + return CVUtil.putUTF8StringBytes(name, buffer, pos); + } + + @Override + public String toString() { + return String.format("LF_FUNC_ID 0x%04x scopeIdx=0x%x typeIdx=0x%x %s", getSequenceNumber(), scopeIdx, typeIdx, name); + } + + @Override + public int hashCode() { + int h = type; + h = 31 * h + scopeIdx; + h = 31 * h + typeIdx; + h = 31 * h + name.hashCode(); + return h; + } + + @Override + public boolean equals(Object obj) { + if (!super.equals(obj)) { + return false; + } + CVTypeFuncIdRecord other = (CVTypeFuncIdRecord) obj; + return this.typeIdx == other.typeIdx && this.name.equals(other.name) && this.scopeIdx == other.scopeIdx; + } + } + + + static final class CVTypeMFuncIdRecord extends CVTypeRecord { + + int parentTypeIdx; + int typeIdx; + String name; + + CVTypeMFuncIdRecord(int parentTypeIdx, int typeIdx, String name) { + super(LF_MFUNC_ID); + this.parentTypeIdx = parentTypeIdx; + this.typeIdx = typeIdx; + this.name = name; + } + + @Override + public int computeContents(byte[] buffer, int initialPos) { + int pos = CVUtil.putInt(parentTypeIdx, buffer, initialPos); + pos = CVUtil.putInt(typeIdx, buffer, pos); + return CVUtil.putUTF8StringBytes(name, buffer, pos); + } + + @Override + public String toString() { + return String.format("LF_MFUNC_ID 0x%04x parentTypeIdx=0x%x typeIdx=0x%x %s", getSequenceNumber(), parentTypeIdx, typeIdx, name); + } + + @Override + public int hashCode() { + int h = type; + h = 31 * h + parentTypeIdx; + h = 31 * h + typeIdx; + h = 31 * h + name.hashCode(); + return h; + } + + @Override + public boolean equals(Object obj) { + if (!super.equals(obj)) { + return false; + } + CVTypeMFuncIdRecord other = (CVTypeMFuncIdRecord) obj; + return this.typeIdx == other.typeIdx && this.name.equals(other.name) && this.parentTypeIdx == other.parentTypeIdx; + } + } + static final class CVTypeStringIdRecord extends CVTypeRecord { String string; @@ -544,6 +635,10 @@ void setClassType(int classType) { this.classType = classType; } + int getClassType() { + return classType; + } + void setThisType(int thisType) { this.thisType = thisType; } diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java index fc6901ada56e..02d755c7235f 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java @@ -151,7 +151,8 @@ CVTypeRecord buildType(TypeEntry typeEntry) { * @return type record for this function (may return existing matching record) */ CVTypeRecord buildFunction(CompiledMethodEntry entry) { - return buildMemberFunction(entry.getClassEntry(), entry.getPrimary().getMethodEntry()); + CVTypeRecord.CVTypeMFunctionRecord mFunctionRecord = buildMemberFunction(entry.getClassEntry(), entry.getPrimary().getMethodEntry()); + return buildFuncIdRecord(mFunctionRecord, entry.getPrimary().getMethodName()); } static class FieldListBuilder { @@ -431,6 +432,14 @@ CVTypeRecord.CVTypeMFunctionRecord buildMemberFunction(ClassEntry classEntry, Me return addTypeRecord(mFunctionRecord); } + CVTypeRecord buildFuncIdRecord(CVTypeRecord.CVTypeMFunctionRecord mFunctionRecord, String functionName) { + if (mFunctionRecord.getClassType() != 0) { + return addTypeRecord(new CVTypeRecord.CVTypeMFuncIdRecord(mFunctionRecord.getClassType(), mFunctionRecord.getSequenceNumber(), functionName)); + } else { + return addTypeRecord(new CVTypeRecord.CVTypeFuncIdRecord(0, mFunctionRecord.getSequenceNumber(), functionName)); + } + } + private T addTypeRecord(T record) { return types.addTypeRecord(record); } From e41cbf5f660849231d9e38e7379454d15b095185 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Fri, 25 Aug 2023 14:24:05 -0400 Subject: [PATCH 07/48] Define 'this' and parameters using debug local info. --- .../objectfile/pecoff/cv/CVConstants.java | 14 +- .../pecoff/cv/CVSymbolSubrecord.java | 80 ++++-- .../pecoff/cv/CVSymbolSubsectionBuilder.java | 256 ++++++++++-------- .../oracle/objectfile/pecoff/cv/CVUtil.java | 144 ++++++++++ 4 files changed, 359 insertions(+), 135 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVConstants.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVConstants.java index 93c38d61df2f..03fed1d1a860 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVConstants.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVConstants.java @@ -125,6 +125,15 @@ public abstract class CVConstants { static final short CV_AMD64_XMM6 = 160; static final short CV_AMD64_XMM7 = 161; + static final short CV_AMD64_XMM0_0 = 162; + static final short CV_AMD64_XMM1_0 = 166; + static final short CV_AMD64_XMM2_0 = 170; + static final short CV_AMD64_XMM3_0 = 174; + static final short CV_AMD64_XMM4_0 = 178; + static final short CV_AMD64_XMM5_0 = 182; + static final short CV_AMD64_XMM6_0 = 186; + static final short CV_AMD64_XMM7_0 = 190; + static final short CV_AMD64_XMM0L = 194; static final short CV_AMD64_XMM1L = 195; static final short CV_AMD64_XMM2L = 196; @@ -133,9 +142,4 @@ public abstract class CVConstants { static final short CV_AMD64_XMM5L = 199; static final short CV_AMD64_XMM6L = 200; static final short CV_AMD64_XMM7L = 201; - - static final short CV_AMD64_XMM0_0 = 162; - static final short CV_AMD64_XMM1_0 = 166; - static final short CV_AMD64_XMM2_0 = 170; - static final short CV_AMD64_XMM3_0 = 174; } diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java index 959a711c21c2..ed1a82428ab0 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java @@ -27,9 +27,10 @@ package com.oracle.objectfile.pecoff.cv; import com.oracle.objectfile.debugentry.ClassEntry; -import org.graalvm.compiler.debug.GraalError; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import static com.oracle.objectfile.pecoff.cv.CVDebugConstants.S_BLOCK32; @@ -359,49 +360,77 @@ public String toString() { } } - private abstract static class CVSymbolDefRangeBase extends CVSymbolSubrecord { + abstract static class CVSymbolDefRangeBase extends CVSymbolSubrecord { - protected final int gapCount; + private static final int GAP_ARRAY_SIZE = 5; protected final String procName; protected final int procOffset; - protected final short range; + protected short range; + private List gaps = null; + + /* It might be more efficient to use an array of shorts instead of a List of Gaps. */ + private static class Gap { + public final short start; + public final short length; + public Gap(short start, short length) { + this.start = start; + this.length = length; + } + } protected CVSymbolDefRangeBase(CVDebugInfo debugInfo, short recordType, String procName, int procOffset, short range) { super(debugInfo, recordType); this.procName = procName; this.procOffset = procOffset; this.range = range; - this.gapCount = 0; - if (procOffset != 0) { - GraalError.shouldNotReachHere("procOffset not implemented"); - } } - @SuppressWarnings("unused") - void addGap() { - /* TODO */ - GraalError.shouldNotReachHere("addGap() not implemented"); + void addGap(short start, short length) { + if (gaps == null) { + gaps = new ArrayList<>(GAP_ARRAY_SIZE); + } + gaps.add(new Gap(start, length)); } int computeRange(byte[] buffer, int initialPos) { /* Emit CV_LVAR_ADDR_RANGE. */ - int pos = cvDebugInfo.getCVSymbolSection().markRelocationSite(buffer, initialPos, procName); + int pos = cvDebugInfo.getCVSymbolSection().markRelocationSite(buffer, initialPos, procName, procOffset); pos = CVUtil.putShort(range, buffer, pos); return pos; } - int computeGaps(@SuppressWarnings("unused") byte[] buffer, int initialPos) { - /* Emit gaps. Not yet implemented. */ - assert gapCount == 0; - return initialPos; + private int computeGaps(byte[] buffer, int initialPos) { + int pos = initialPos; + if (gaps != null) { + for (Gap gap : gaps) { + pos = CVUtil.putShort(gap.start, buffer, pos); + pos = CVUtil.putShort(gap.length, buffer, pos); + } + } + return pos; } int computeRangeAndGaps(byte[] buffer, int initialPos) { int pos = computeRange(buffer, initialPos); return computeGaps(buffer, pos); } + + protected int gapCount() { + return gaps != null ? gaps.size() : 0; + } + + protected String gapString() { + String s = ""; + if (gaps != null) { + for (Gap gap : gaps) { + s = String.format("%s\n - gap=0x%x len=0x%x last=0x%x", s, gap.start, gap.length, gap.start + gap.length - 1); + } + } + return s; + } } + @SuppressWarnings("unused") public static class CVSymbolDefRangeFramepointerRelFullScope extends CVSymbolSubrecord { private final int frameOffset; @@ -427,7 +456,7 @@ public static class CVSymbolDefRangeRegisterRecord extends CVSymbolDefRangeBase private final short register; private final short attr; - CVSymbolDefRangeRegisterRecord(CVDebugInfo debugInfo, short register, String procName, int procOffset, int length) { + CVSymbolDefRangeRegisterRecord(CVDebugInfo debugInfo, String procName, int procOffset, int length, short register) { super(debugInfo, CVDebugConstants.S_DEFRANGE_REGISTER, procName, procOffset, (short) length); this.register = register; this.attr = 0; @@ -443,7 +472,7 @@ protected int computeContents(byte[] buffer, int initialPos) { @Override public String toString() { - return String.format("S_DEFRANGE_REGISTER r%d attr=0x%x %s+0x%x range=0x%x %d gaps)", register, attr, procName, procOffset, range, gapCount); + return String.format("S_DEFRANGE_REGISTER r%d attr=0x%x %s+0x%x range=0x%x gaps=%d)%s", register, attr, procName, procOffset, range, gapCount(), gapString()); } } @@ -475,8 +504,8 @@ protected int computeContents(byte[] buffer, int initialPos) { @Override public String toString() { - return String.format("S_DEFRANGE_REGISTER_REL r%d spilled=%d parentOffset=0x%x %s+0x%x range=0x%x %d gaps)", baseRegister, spilledUdtMember, parentOffset, procName, procOffset, range, - gapCount); + return String.format("S_DEFRANGE_REGISTER_REL r%d spilled=%d parentOffset=0x%x %s+0x%x range=0x%x gaps=%d)%s", baseRegister, spilledUdtMember, parentOffset, procName, procOffset, range, + gapCount(), gapString()); } } @@ -515,8 +544,8 @@ public static class CVSymbolDefRangeFramepointerRel extends CVSymbolDefRangeBase private final int fpOffset; - CVSymbolDefRangeFramepointerRel(CVDebugInfo debugInfo, String name, int procOffset, short range, int fpOffset) { - super(debugInfo, CVDebugConstants.S_DEFRANGE_FRAMEPOINTER_REL, name, procOffset, range); + CVSymbolDefRangeFramepointerRel(CVDebugInfo debugInfo, String procName, int procOffset, short range, int fpOffset) { + super(debugInfo, CVDebugConstants.S_DEFRANGE_FRAMEPOINTER_REL, procName, procOffset, range); this.fpOffset = fpOffset; } @@ -529,7 +558,7 @@ protected int computeContents(byte[] buffer, int initialPos) { @Override public String toString() { - return String.format("S_DEFRANGE_FRAMEPOINTER_REL name=%s+0x%x fpOfffset=0x%x)", procName, procOffset, fpOffset); + return String.format("S_DEFRANGE_FRAMEPOINTER_REL name=%s+0x%x range=0x%x fpOffset=0x%x)%s", procName, procOffset, range, fpOffset, gapString()); } } @@ -585,6 +614,7 @@ public static class CVSymbolGProc32Record extends CVSymbolSubrecord { protected final String symbolName; protected final String displayName; + @SuppressWarnings("unused") CVSymbolGProc32Record(CVDebugInfo cvDebugInfo, String symbolName, String displayName, int pparent, int pend, int pnext, int proclen, int debugStart, int debugEnd, int typeIndex, short segment, byte flags) { super(cvDebugInfo, CVDebugConstants.S_GPROC32); @@ -659,6 +689,7 @@ public static final class CVSymbolFrameProcRecord extends CVSymbolSubrecord { /* This may change in the presence of isolates. */ /* Async exception handling (vc++ uses 1, clang uses 0). */ + @SuppressWarnings("unused") public static final int FRAME_ASYNC_EH = 1 << 9; /* Local base pointer = SP (0=none, 1=sp, 2=bp 3=r13). */ @@ -738,6 +769,7 @@ protected CVSymbolEndRecord(CVDebugInfo cvDebugInfo, short cmd) { super(cvDebugInfo, cmd); } + @SuppressWarnings("unused") CVSymbolEndRecord(CVDebugInfo cvDebugInfo) { this(cvDebugInfo, CVDebugConstants.S_END); } diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java index 053e0e3061c6..bf246d5b4d70 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java @@ -32,59 +32,32 @@ import com.oracle.objectfile.debugentry.FieldEntry; import com.oracle.objectfile.debugentry.TypeEntry; import com.oracle.objectfile.debugentry.MethodEntry; -import com.oracle.objectfile.debugentry.PrimitiveTypeEntry; import com.oracle.objectfile.debugentry.range.Range; +import com.oracle.objectfile.debugentry.range.SubRange; import com.oracle.objectfile.debuginfo.DebugInfoProvider; +import jdk.vm.ci.amd64.AMD64; +import jdk.vm.ci.meta.JavaConstant; + import java.lang.reflect.Modifier; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugLocalValueInfo.LocalKind.CONSTANT; +import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugLocalValueInfo.LocalKind.REGISTER; +import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugLocalValueInfo.LocalKind.STACKSLOT; -import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugPrimitiveTypeInfo.FLAG_INTEGRAL; -import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugPrimitiveTypeInfo.FLAG_NUMERIC; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_CL; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_CX; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_DI; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_DIL; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_DL; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_DX; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_ECX; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_EDI; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_EDX; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_ESI; import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R8; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R8B; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R8D; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R8W; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R9; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R9B; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R9D; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R9W; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_RCX; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_RDI; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_RDX; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_RSI; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_SI; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_SIL; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM0L; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM0_0; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM1L; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM1_0; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM2L; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM2_0; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM3L; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM3_0; -import static com.oracle.objectfile.pecoff.cv.CVSymbolSubrecord.CVSymbolFrameProcRecord.FRAME_ASYNC_EH; import static com.oracle.objectfile.pecoff.cv.CVSymbolSubrecord.CVSymbolFrameProcRecord.FRAME_LOCAL_BP; import static com.oracle.objectfile.pecoff.cv.CVSymbolSubrecord.CVSymbolFrameProcRecord.FRAME_PARAM_BP; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.MAX_PRIMITIVE; +import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.T_INT4; +import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.T_INT8; final class CVSymbolSubsectionBuilder { - private static final short[] javaGP64registers = {CV_AMD64_RDX, CV_AMD64_R8, CV_AMD64_R9, CV_AMD64_RDI, CV_AMD64_RSI, CV_AMD64_RCX}; - private static final short[] javaGP32registers = {CV_AMD64_EDX, CV_AMD64_R8D, CV_AMD64_R9D, CV_AMD64_EDI, CV_AMD64_ESI, CV_AMD64_ECX}; - private static final short[] javaGP16registers = {CV_AMD64_DX, CV_AMD64_R8W, CV_AMD64_R9W, CV_AMD64_DI, CV_AMD64_SI, CV_AMD64_CX}; - private static final short[] javaGP8registers = {CV_AMD64_DL, CV_AMD64_R8B, CV_AMD64_R9B, CV_AMD64_DIL, CV_AMD64_SIL, CV_AMD64_CL}; - private static final short[] javaFP64registers = {CV_AMD64_XMM0L, CV_AMD64_XMM1L, CV_AMD64_XMM2L, CV_AMD64_XMM3L}; - private static final short[] javaFP32registers = {CV_AMD64_XMM0_0, CV_AMD64_XMM1_0, CV_AMD64_XMM2_0, CV_AMD64_XMM3_0}; + private static final int S_LOCAL_FLAGS_IS_PARAM = 1; private final CVDebugInfo cvDebugInfo; private final CVSymbolSubsection cvSymbolSubsection; @@ -93,14 +66,20 @@ final class CVSymbolSubsectionBuilder { private final String heapName; private final short heapRegister; + /** + * Create a symbol section by iterating over all classes, emitting types and line numbers as we go. + * See substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/SubstrateAMD64RegisterConfig.java + * + * @param cvDebugInfo debugInfo container + */ CVSymbolSubsectionBuilder(CVDebugInfo cvDebugInfo) { this.cvDebugInfo = cvDebugInfo; this.cvSymbolSubsection = new CVSymbolSubsection(cvDebugInfo); this.lineRecordBuilder = new CVLineRecordBuilder(cvDebugInfo); this.heapName = SectionName.SVM_HEAP.getFormatDependentName(cvDebugInfo.getCVSymbolSection().getOwner().getFormat()); /* For isolates, Graal currently uses r14; this code will handle r8-r15. */ - assert 8 <= cvDebugInfo.getHeapbaseRegister() && cvDebugInfo.getHeapbaseRegister() <= 15; - this.heapRegister = (short) (CV_AMD64_R8 + cvDebugInfo.getHeapbaseRegister() - 8); + assert AMD64.r8.number <= cvDebugInfo.getHeapbaseRegister() && cvDebugInfo.getHeapbaseRegister() <= AMD64.r15.number; + this.heapRegister = (short) (CV_AMD64_R8 + cvDebugInfo.getHeapbaseRegister() - AMD64.r8.number); } /** @@ -183,7 +162,13 @@ private void buildFunction(CompiledMethodEntry compiledEntry) { final int frameFlags = FRAME_LOCAL_BP + FRAME_PARAM_BP; addSymbolRecord(new CVSymbolSubrecord.CVSymbolFrameProcRecord(cvDebugInfo, compiledEntry.getFrameSize(), frameFlags)); - addLocals(compiledEntry); + /* it's costly to compute this, so only compute it once */ + HashMap> varRangeMap = primaryRange.getVarRangeMap(); + + if (primaryRange.getClassName().contains("ListDir")) { + addParameters(compiledEntry, varRangeMap); + /* IN the future: addLocals(compiledEntry, varRangeMap); */ + } /* S_PROC_ID_END add end record. */ addSymbolRecord(new CVSymbolSubrecord.CVSymbolProcIdEndRecord(cvDebugInfo)); @@ -192,87 +177,146 @@ private void buildFunction(CompiledMethodEntry compiledEntry) { addLineNumberRecords(compiledEntry); } - void addLocals(CompiledMethodEntry primaryEntry) { + void addParameters(CompiledMethodEntry primaryEntry, HashMap> varRangeMap) { final Range primaryRange = primaryEntry.getPrimary(); /* The name as exposed to the linker. */ final String externalName = primaryRange.getSymbolName(); - /* Add register parameters - only valid for the first instruction or two. */ - - MethodEntry method = primaryRange.getMethodEntry(); - int gpRegisterIndex = 0; - int fpRegisterIndex = 0; + MethodEntry method = primaryRange.isPrimary() ? primaryRange.getMethodEntry() : primaryRange.getFirstCallee().getMethodEntry(); /* define 'this' as a local just as we define other object pointers */ if (!Modifier.isStatic(method.getModifiers())) { - final TypeEntry thisType = primaryEntry.getClassEntry(); + final TypeEntry typeEntry = primaryEntry.getClassEntry(); DebugInfoProvider.DebugLocalInfo thisparam = method.getThisParam(); - final int typeIndex = cvDebugInfo.getCVTypeSection().getIndexForPointer(thisType); - addSymbolRecord(new CVSymbolSubrecord.CVSymbolLocalRecord(cvDebugInfo, thisparam.name(), typeIndex, 1)); - addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeRegisterRecord(cvDebugInfo, javaGP64registers[gpRegisterIndex], externalName, 0, 8)); - addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeFramepointerRelFullScope(cvDebugInfo, 0)); - gpRegisterIndex++; + final int typeIndex = cvDebugInfo.getCVTypeSection().getIndexForPointer(typeEntry); + emitLocal(thisparam, varRangeMap, thisparam.name(), typeEntry, typeIndex, true, externalName, primaryRange); } - /* define function parameters (p1, p2...) according to the calling convention */ + /* define function parameters */ for (int i = 0; i < method.getParamCount(); i++) { final DebugInfoProvider.DebugLocalInfo paramInfo = method.getParam(i); - final TypeEntry paramType = method.getParamType(i); - final int typeIndex = cvDebugInfo.getCVTypeSection().addTypeRecords(paramType).getSequenceNumber(); - if (paramType.isPrimitive()) { - /* simple primitive */ - final PrimitiveTypeEntry primitiveTypeEntry = (PrimitiveTypeEntry) paramType; - final boolean isFloatingPoint = ((primitiveTypeEntry.getFlags() & FLAG_NUMERIC) != 0 && (primitiveTypeEntry.getFlags() & FLAG_INTEGRAL) == 0); - if (isFloatingPoint) { - /* floating point primitive */ - if (fpRegisterIndex < javaFP64registers.length) { - final short register = paramType.getSize() == Double.BYTES ? javaFP64registers[fpRegisterIndex] : javaFP32registers[fpRegisterIndex]; - addSymbolRecord(new CVSymbolSubrecord.CVSymbolLocalRecord(cvDebugInfo, paramInfo.name(), typeIndex, 1)); - addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeRegisterRecord(cvDebugInfo, register, externalName, 0, 8)); - addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeFramepointerRelFullScope(cvDebugInfo, 0)); - fpRegisterIndex++; - } else { - /* TODO: handle stack parameter; keep track of stack offset, etc. */ - break; - } - } else if (gpRegisterIndex < javaGP64registers.length) { - final short register; - if (paramType.getSize() == 8) { - register = javaGP64registers[gpRegisterIndex]; - } else if (paramType.getSize() == 4) { - register = javaGP32registers[gpRegisterIndex]; - } else if (paramType.getSize() == 2) { - register = javaGP16registers[gpRegisterIndex]; - } else if (paramType.getSize() == 1) { - register = javaGP8registers[gpRegisterIndex]; - } else { - register = 0; /* Avoid warning. */ - throw new RuntimeException("Unknown primitive (type" + paramType.getTypeName() + ") size:" + paramType.getSize()); + final TypeEntry typeEntry = method.getParamType(i); + final int typeIndex = cvDebugInfo.getCVTypeSection().addTypeRecords(typeEntry).getSequenceNumber(); + emitLocal(paramInfo, varRangeMap, paramInfo.name(), typeEntry, typeIndex, true, externalName, primaryRange); + } + } + + private int infoTypeToInt(DebugInfoProvider.DebugLocalValueInfo info) { + switch (info.localKind()) { + case REGISTER: + return info.regIndex(); + case STACKSLOT: + /* TODO: are stack slots either 0 or negative? */ + return -info.stackSlot(); + default: + return 0; + } + } + + void emitLocal(DebugInfoProvider.DebugLocalInfo info, HashMap> varRangeMap, String name, TypeEntry typeEntry, int typeIndex, boolean isParam, String procName, Range range) { + int flags = isParam ? S_LOCAL_FLAGS_IS_PARAM : 0; + List ranges = varRangeMap.get(info); + addSymbolRecord(new CVSymbolSubrecord.CVSymbolLocalRecord(cvDebugInfo, name, typeIndex, flags)); + int currentHigh = Integer.MIN_VALUE; + int registerOrSlot = 0; /* -slot or +register or 0=unknown */ + CVSymbolSubrecord.CVSymbolDefRangeBase currentRecord = null; + for (SubRange subrange : ranges) { + DebugInfoProvider.DebugLocalValueInfo value = subrange.lookupValue(info); + if (value != null) { + if (subrange.getLo() == currentHigh && registerOrSlot == infoTypeToInt(value)) { + /* if we can, merge records */ + currentHigh = subrange.getHi(); + if (currentRecord != null) { + currentRecord.range = (short) (currentHigh - currentRecord.procOffset); } - addSymbolRecord(new CVSymbolSubrecord.CVSymbolLocalRecord(cvDebugInfo, paramInfo.name(), typeIndex, 1)); - addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeRegisterRecord(cvDebugInfo, register, externalName, 0, 8)); - addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeFramepointerRelFullScope(cvDebugInfo, 8)); - gpRegisterIndex++; + continue; + } + currentHigh = subrange.getHi(); + registerOrSlot = infoTypeToInt(value); + if (value.localKind() == REGISTER) { + short cvreg = CVUtil.getCVRegister(value.regIndex(), typeEntry); + currentRecord = new CVSymbolSubrecord.CVSymbolDefRangeRegisterRecord(cvDebugInfo, procName, subrange.getLo() - range.getLo(), (short) (subrange.getHi() - subrange.getLo()), cvreg); + addSymbolRecord(currentRecord); + } else if (value.localKind() == STACKSLOT) { + currentRecord = new CVSymbolSubrecord.CVSymbolDefRangeFramepointerRel(cvDebugInfo, procName, subrange.getLo() - range.getLo(), (short) (subrange.getHi() - subrange.getLo()), value.stackSlot()); + addSymbolRecord(currentRecord); + } else if (value.localKind() == CONSTANT) { + /* For now, silently ifnore constant definitions an parameters. */ + /* JavaConstant constant = value.constantValue(); */ } else { - /* TODO: handle stack parameter; keep track of stack offset, etc. */ - break; + /* Unimplemented - this is a surprise. */ + assert(false); } - } else { - /* Java object. */ - if (gpRegisterIndex < javaGP64registers.length) { - addSymbolRecord(new CVSymbolSubrecord.CVSymbolLocalRecord(cvDebugInfo, paramInfo.name(), typeIndex, 1)); - addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeRegisterRecord(cvDebugInfo, javaGP64registers[gpRegisterIndex], externalName, 0, 8)); - addSymbolRecord(new CVSymbolSubrecord.CVSymbolDefRangeFramepointerRelFullScope(cvDebugInfo, 0)); - gpRegisterIndex++; + } + } + } + + @SuppressWarnings("unused") + void addLocals(CompiledMethodEntry primaryEntry, HashMap> varRangeMap) { + processVarMap(primaryEntry, varRangeMap); + } + + @SuppressWarnings("unused") + void processVarMap(CompiledMethodEntry primaryEntry, HashMap> varRangeMap) { + final Range primaryRange = primaryEntry.getPrimary(); + /* The name as exposed to the linker. */ + final String externalName = primaryRange.getSymbolName(); + System.out.format("func %s:\n", externalName); + processRange(primaryRange); + } + + @SuppressWarnings("unused") + void processRange(Range range) { + final String procName = range.getSymbolName(); + HashMap> varmap = range.getVarRangeMap(); + for (Map.Entry> entry : varmap.entrySet()) { + DebugInfoProvider.DebugLocalInfo v = entry.getKey(); + final int typeIndex = v.slotCount() == 1 ? T_INT4 : T_INT8; + System.out.format(" var %s jk=%s tn=%s vt=%s line=%d slot=%d n=%d\n", v.name(), v.javaKind(), v.typeName(), v.valueType(), v.line(), v.slot(), v.slotCount()); + //addSymbolRecord(new CVSymbolSubrecord.CVSymbolLocalRecord(cvDebugInfo, procName + "x", typeIndex, 1)); + CVSymbolSubrecord.CVSymbolDefRangeFramepointerRel rangeRecord = new CVSymbolSubrecord.CVSymbolDefRangeFramepointerRel(cvDebugInfo, procName, range.getLo(), (short) (range.getHi() - range.getLo()), v.slot() + 4); + int low = Integer.MAX_VALUE; + int high = Integer.MIN_VALUE; + int currentLow = Integer.MAX_VALUE; + int currentHigh = Integer.MIN_VALUE; + List subRanges = entry.getValue(); + for (SubRange sr : subRanges) { + //System.out.format(" subrange line=%d low=0x%x high=0x%x depth=%d\n", sr.getLine(), sr.getLo(), sr.getHi(), sr.getDepth()); + high = sr.getHi(); + if (currentLow == Integer.MAX_VALUE) { + /* initial subrange */ + low = sr.getLo(); + currentLow = sr.getLo(); + currentHigh = sr.getHi(); + } else if (sr.getLo() == currentHigh) { + /* extend current subrange as the new one is contiguous */ + currentHigh = sr.getHi(); } else { - /* TODO: handle stack parameter; keep track of stack offset, etc. */ - break; + /* non-contiguous; emit previous subrange */ + System.out.format(" xxsubrange low=0x%x high=0x%x slot=%d depth=%d\n", currentLow, currentHigh, v.slot(), 0); + System.out.format(" xxgap low=0x%x len=0x%x\n", (currentHigh + 1) - low, sr.getLo() - 1 - low); + rangeRecord.addGap((short) ((currentHigh + 1) - low), (short) (sr.getLo() - 1 - low)); + //emitLocalX(v.name(), typeIndex, (short) 0, v.slot(), procName, currentLow, currentHigh); + currentLow = sr.getLo(); + currentHigh = sr.getHi(); } + /* + for (Map.Entry> subentry : varmap.entrySet()) { + DebugInfoProvider.DebugLocalInfo v2 = subentry.getKey(); + List subRanges2 = subentry.getValue(); + System.out.format(" var %s jk=%s tn=%s vt=%s line=%d slot=%d n=%d\n", v2.name(), v2.javaKind(), v2.typeName(), v2.valueType(), v2.line(), v2.slot(), v2.slotCount()); + for (SubRange sr2 : subRanges2) { + System.out.format(" subrange %d 0x%x 0x%x \n", sr2.getLine(), sr2.getLo(), sr2.getHi()); + } + }*/ + } + if (currentLow != Integer.MAX_VALUE) { + /* clear out last subrange */ + System.out.format(" xxsubrange low=0x%x high=0x%x depth=%d\n", currentLow, currentHigh, 0); + //emitLocalX(v.name(), typeIndex, (short) 0, v.slot(), procName, currentLow, currentHigh); } + // addSymbolRecord(rageRecord); } - /* TODO: add entries for stack parameters. */ - /* TODO: add local variables, and their types. */ - /* TODO: add block definitions. */ } private void addLineNumberRecords(CompiledMethodEntry compiledEntry) { diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java index 8cec084ccc1b..1d6dd869e17a 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java @@ -26,14 +26,97 @@ package com.oracle.objectfile.pecoff.cv; +import com.oracle.objectfile.debugentry.TypeEntry; import com.oracle.objectfile.io.Utf8; +import jdk.vm.ci.amd64.AMD64; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_AL; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_AX; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_BL; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_BP; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_BPL; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_BX; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_CL; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_CX; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_DI; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_DIL; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_DL; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_DX; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_EAX; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_EBP; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_EBX; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_ECX; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_EDI; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_EDX; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_ESI; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_ESP; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R10; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R10B; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R10D; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R10W; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R11; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R11B; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R11D; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R11W; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R12; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R12B; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R12D; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R12W; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R13; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R13B; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R13D; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R13W; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R14; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R14B; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R14D; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R14W; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R15; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R15B; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R15D; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R15W; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R8; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R8B; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R8D; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R8W; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R9; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R9B; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R9D; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R9W; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_RAX; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_RBP; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_RBX; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_RCX; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_RDI; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_RDX; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_RSI; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_RSP; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_SI; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_SIL; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_SP; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_SPL; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM0L; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM0_0; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM1L; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM1_0; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM2L; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM2_0; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM3L; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM3_0; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM4L; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM4_0; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM5L; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM5_0; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM6L; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM6_0; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM7L; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM7_0; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_CHAR; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_LONG; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_QUADWORD; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_SHORT; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_ULONG; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_USHORT; + import static java.nio.charset.StandardCharsets.UTF_8; abstract class CVUtil { @@ -185,4 +268,65 @@ static int align4(int initialPos) { } return pos; } + + /* First index is AMD64.(register).number, second is 1,2,4,8 bytes. */ + private static final short[][] javaToCvRegisters = { + /* 8, 16, 32, 64 bits */ + /* rax=0 */ { CV_AMD64_AL, CV_AMD64_AX, CV_AMD64_EAX, CV_AMD64_RAX }, + /* rcx */ { CV_AMD64_CL, CV_AMD64_CX, CV_AMD64_ECX, CV_AMD64_RCX }, + /* rdx */ { CV_AMD64_DL, CV_AMD64_DX, CV_AMD64_EDX, CV_AMD64_RDX }, + /* rbx */ { CV_AMD64_BL, CV_AMD64_BX, CV_AMD64_EBX, CV_AMD64_RBX }, + /* rsp */ { CV_AMD64_SPL, CV_AMD64_SP, CV_AMD64_ESP, CV_AMD64_RSP }, + /* rbp */ { CV_AMD64_BPL, CV_AMD64_BP, CV_AMD64_EBP, CV_AMD64_RBP }, + /* rsi */ { CV_AMD64_SIL, CV_AMD64_SI, CV_AMD64_ESI, CV_AMD64_RSI }, + /* rdi */ { CV_AMD64_DIL, CV_AMD64_DI, CV_AMD64_EDI, CV_AMD64_RDI }, + /* r8 */ { CV_AMD64_R8B, CV_AMD64_R8W, CV_AMD64_R8D, CV_AMD64_R8 }, + /* r9 */ { CV_AMD64_R9B, CV_AMD64_R9W, CV_AMD64_R9D, CV_AMD64_R9 }, + /* r10 */ { CV_AMD64_R10B, CV_AMD64_R10W, CV_AMD64_R10D, CV_AMD64_R10 }, + /* r11 */ { CV_AMD64_R11B, CV_AMD64_R11W, CV_AMD64_R11D, CV_AMD64_R11 }, + /* r12 */ { CV_AMD64_R12B, CV_AMD64_R12W, CV_AMD64_R12D, CV_AMD64_R12 }, + /* r13 */ { CV_AMD64_R13B, CV_AMD64_R13W, CV_AMD64_R13D, CV_AMD64_R13 }, + /* r14 */ { CV_AMD64_R14B, CV_AMD64_R14W, CV_AMD64_R14D, CV_AMD64_R14 }, + /* r15 */ { CV_AMD64_R15B, CV_AMD64_R15W, CV_AMD64_R15D, CV_AMD64_R15 }, + + /* xmm0=16 */ { -1, -1, CV_AMD64_XMM0_0, CV_AMD64_XMM0L}, + /* xmm1 */ { -1, -1, CV_AMD64_XMM1_0, CV_AMD64_XMM1L}, + /* xmm2 */ { -1, -1, CV_AMD64_XMM2_0, CV_AMD64_XMM2L}, + /* xmm3 */ { -1, -1, CV_AMD64_XMM3_0, CV_AMD64_XMM3L}, + /* xmm4 */ { -1, -1, CV_AMD64_XMM4_0, CV_AMD64_XMM4L}, + /* xmm5 */ { -1, -1, CV_AMD64_XMM5_0, CV_AMD64_XMM5L}, + /* xmm6 */ { -1, -1, CV_AMD64_XMM6_0, CV_AMD64_XMM6L}, + /* xmm7=23 */ { -1, -1, CV_AMD64_XMM7_0, CV_AMD64_XMM7L}, + }; + + static short getCVRegister(int javaReg, TypeEntry typeEntry) { + assert 0 <= javaReg && javaReg <= AMD64.xmm7.number; + final int bytes; + if (typeEntry.isPrimitive()) { + switch (typeEntry.getSize()) { + case 1: + bytes = 0; + break; + case 2: + bytes = 1; + break; + case 4: + bytes = 2; + break; + case 8: + bytes = 3; + break; + default: + bytes = -1; + break; + } + } else { + /* Objects are represented by pointers. */ + bytes = 3; + } + assert bytes >= 0 && bytes < javaToCvRegisters[javaReg].length; + short cvreg = javaToCvRegisters[javaReg][bytes]; + assert cvreg != -1; + return cvreg; + } } From f94280ce8f6ea7948262d616eb2b9a5d755f3c00 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Fri, 25 Aug 2023 14:25:53 -0400 Subject: [PATCH 08/48] Clean up unused functions. --- .../pecoff/cv/CVSymbolSubsectionBuilder.java | 74 +------------------ 1 file changed, 1 insertion(+), 73 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java index bf246d5b4d70..93af815ca7c4 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java @@ -37,12 +37,10 @@ import com.oracle.objectfile.debuginfo.DebugInfoProvider; import jdk.vm.ci.amd64.AMD64; -import jdk.vm.ci.meta.JavaConstant; import java.lang.reflect.Modifier; import java.util.HashMap; import java.util.List; -import java.util.Map; import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugLocalValueInfo.LocalKind.CONSTANT; import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugLocalValueInfo.LocalKind.REGISTER; @@ -52,8 +50,6 @@ import static com.oracle.objectfile.pecoff.cv.CVSymbolSubrecord.CVSymbolFrameProcRecord.FRAME_LOCAL_BP; import static com.oracle.objectfile.pecoff.cv.CVSymbolSubrecord.CVSymbolFrameProcRecord.FRAME_PARAM_BP; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.MAX_PRIMITIVE; -import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.T_INT4; -import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.T_INT8; final class CVSymbolSubsectionBuilder { @@ -241,7 +237,7 @@ void emitLocal(DebugInfoProvider.DebugLocalInfo info, HashMap> varRangeMap) { - processVarMap(primaryEntry, varRangeMap); - } - - @SuppressWarnings("unused") - void processVarMap(CompiledMethodEntry primaryEntry, HashMap> varRangeMap) { - final Range primaryRange = primaryEntry.getPrimary(); - /* The name as exposed to the linker. */ - final String externalName = primaryRange.getSymbolName(); - System.out.format("func %s:\n", externalName); - processRange(primaryRange); - } - - @SuppressWarnings("unused") - void processRange(Range range) { - final String procName = range.getSymbolName(); - HashMap> varmap = range.getVarRangeMap(); - for (Map.Entry> entry : varmap.entrySet()) { - DebugInfoProvider.DebugLocalInfo v = entry.getKey(); - final int typeIndex = v.slotCount() == 1 ? T_INT4 : T_INT8; - System.out.format(" var %s jk=%s tn=%s vt=%s line=%d slot=%d n=%d\n", v.name(), v.javaKind(), v.typeName(), v.valueType(), v.line(), v.slot(), v.slotCount()); - //addSymbolRecord(new CVSymbolSubrecord.CVSymbolLocalRecord(cvDebugInfo, procName + "x", typeIndex, 1)); - CVSymbolSubrecord.CVSymbolDefRangeFramepointerRel rangeRecord = new CVSymbolSubrecord.CVSymbolDefRangeFramepointerRel(cvDebugInfo, procName, range.getLo(), (short) (range.getHi() - range.getLo()), v.slot() + 4); - int low = Integer.MAX_VALUE; - int high = Integer.MIN_VALUE; - int currentLow = Integer.MAX_VALUE; - int currentHigh = Integer.MIN_VALUE; - List subRanges = entry.getValue(); - for (SubRange sr : subRanges) { - //System.out.format(" subrange line=%d low=0x%x high=0x%x depth=%d\n", sr.getLine(), sr.getLo(), sr.getHi(), sr.getDepth()); - high = sr.getHi(); - if (currentLow == Integer.MAX_VALUE) { - /* initial subrange */ - low = sr.getLo(); - currentLow = sr.getLo(); - currentHigh = sr.getHi(); - } else if (sr.getLo() == currentHigh) { - /* extend current subrange as the new one is contiguous */ - currentHigh = sr.getHi(); - } else { - /* non-contiguous; emit previous subrange */ - System.out.format(" xxsubrange low=0x%x high=0x%x slot=%d depth=%d\n", currentLow, currentHigh, v.slot(), 0); - System.out.format(" xxgap low=0x%x len=0x%x\n", (currentHigh + 1) - low, sr.getLo() - 1 - low); - rangeRecord.addGap((short) ((currentHigh + 1) - low), (short) (sr.getLo() - 1 - low)); - //emitLocalX(v.name(), typeIndex, (short) 0, v.slot(), procName, currentLow, currentHigh); - currentLow = sr.getLo(); - currentHigh = sr.getHi(); - } - /* - for (Map.Entry> subentry : varmap.entrySet()) { - DebugInfoProvider.DebugLocalInfo v2 = subentry.getKey(); - List subRanges2 = subentry.getValue(); - System.out.format(" var %s jk=%s tn=%s vt=%s line=%d slot=%d n=%d\n", v2.name(), v2.javaKind(), v2.typeName(), v2.valueType(), v2.line(), v2.slot(), v2.slotCount()); - for (SubRange sr2 : subRanges2) { - System.out.format(" subrange %d 0x%x 0x%x \n", sr2.getLine(), sr2.getLo(), sr2.getHi()); - } - }*/ - } - if (currentLow != Integer.MAX_VALUE) { - /* clear out last subrange */ - System.out.format(" xxsubrange low=0x%x high=0x%x depth=%d\n", currentLow, currentHigh, 0); - //emitLocalX(v.name(), typeIndex, (short) 0, v.slot(), procName, currentLow, currentHigh); - } - // addSymbolRecord(rageRecord); - } - } - private void addLineNumberRecords(CompiledMethodEntry compiledEntry) { CVLineRecord lineRecord = lineRecordBuilder.build(compiledEntry); /* From d48135160465da0804fe72d3e53af3a8f240c2dd Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Fri, 25 Aug 2023 18:24:30 -0400 Subject: [PATCH 09/48] Fixes for GraalVM gate. --- .../oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java index 93af815ca7c4..332ba0c759de 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java @@ -197,12 +197,11 @@ void addParameters(CompiledMethodEntry primaryEntry, HashMap Date: Mon, 28 Aug 2023 08:17:07 -0400 Subject: [PATCH 10/48] Changes for Graal gate --- .../pecoff/cv/CVSymbolSubrecord.java | 12 ++--- .../objectfile/pecoff/cv/CVTypeRecord.java | 1 - .../oracle/objectfile/pecoff/cv/CVUtil.java | 50 +++++++++---------- 3 files changed, 31 insertions(+), 32 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java index ed1a82428ab0..7b29659ce013 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java @@ -372,6 +372,7 @@ abstract static class CVSymbolDefRangeBase extends CVSymbolSubrecord { private static class Gap { public final short start; public final short length; + public Gap(short start, short length) { this.start = start; this.length = length; @@ -631,8 +632,8 @@ public static class CVSymbolGProc32Record extends CVSymbolSubrecord { this.flags = flags; } - protected CVSymbolGProc32Record(CVDebugInfo cvDebugInfo, short cmd, String symbolName, String displayName, int pparent, int pend, int pnext, int proclen, int debugStart, int debugEnd, int typeIndex, - short segment, byte flags) { + protected CVSymbolGProc32Record(CVDebugInfo cvDebugInfo, short cmd, String symbolName, String displayName, int pparent, int pend, int pnext, int proclen, int debugStart, int debugEnd, + int typeIndex, short segment, byte flags) { super(cvDebugInfo, cmd); this.symbolName = symbolName; this.displayName = displayName; @@ -672,7 +673,7 @@ public String toString() { public static class CVSymbolGProc32IdRecord extends CVSymbolGProc32Record { CVSymbolGProc32IdRecord(CVDebugInfo cvDebugInfo, String symbolName, String displayName, int pparent, int pend, int pnext, int proclen, int debugStart, int debugEnd, int typeIndex, - short segment, byte flags) { + short segment, byte flags) { super(cvDebugInfo, CVDebugConstants.S_GPROC32_ID, symbolName, displayName, pparent, pend, pnext, proclen, debugStart, debugEnd, typeIndex, segment, flags); } @@ -680,7 +681,7 @@ public static class CVSymbolGProc32IdRecord extends CVSymbolGProc32Record { @Override public String toString() { return String.format("S_GPROC32_ID name=%s/%s parent=%d debugstart=0x%x debugend=0x%x len=0x%x seg:offset=0x%x:0 type=0x%x flags=0x%x)", displayName, symbolName, pparent, debugStart, - debugEnd, proclen, segment, typeIndex, flags); + debugEnd, proclen, segment, typeIndex, flags); } } @@ -689,8 +690,7 @@ public static final class CVSymbolFrameProcRecord extends CVSymbolSubrecord { /* This may change in the presence of isolates. */ /* Async exception handling (vc++ uses 1, clang uses 0). */ - @SuppressWarnings("unused") - public static final int FRAME_ASYNC_EH = 1 << 9; + @SuppressWarnings("unused") public static final int FRAME_ASYNC_EH = 1 << 9; /* Local base pointer = SP (0=none, 1=sp, 2=bp 3=r13). */ public static final int FRAME_LOCAL_BP = 1 << 14; diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeRecord.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeRecord.java index 8004d92c40fb..63871fc5cbc8 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeRecord.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeRecord.java @@ -361,7 +361,6 @@ public boolean equals(Object obj) { } } - static final class CVTypeMFuncIdRecord extends CVTypeRecord { int parentTypeIdx; diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java index 1d6dd869e17a..c53d7abdcede 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java @@ -271,32 +271,32 @@ static int align4(int initialPos) { /* First index is AMD64.(register).number, second is 1,2,4,8 bytes. */ private static final short[][] javaToCvRegisters = { - /* 8, 16, 32, 64 bits */ - /* rax=0 */ { CV_AMD64_AL, CV_AMD64_AX, CV_AMD64_EAX, CV_AMD64_RAX }, - /* rcx */ { CV_AMD64_CL, CV_AMD64_CX, CV_AMD64_ECX, CV_AMD64_RCX }, - /* rdx */ { CV_AMD64_DL, CV_AMD64_DX, CV_AMD64_EDX, CV_AMD64_RDX }, - /* rbx */ { CV_AMD64_BL, CV_AMD64_BX, CV_AMD64_EBX, CV_AMD64_RBX }, - /* rsp */ { CV_AMD64_SPL, CV_AMD64_SP, CV_AMD64_ESP, CV_AMD64_RSP }, - /* rbp */ { CV_AMD64_BPL, CV_AMD64_BP, CV_AMD64_EBP, CV_AMD64_RBP }, - /* rsi */ { CV_AMD64_SIL, CV_AMD64_SI, CV_AMD64_ESI, CV_AMD64_RSI }, - /* rdi */ { CV_AMD64_DIL, CV_AMD64_DI, CV_AMD64_EDI, CV_AMD64_RDI }, - /* r8 */ { CV_AMD64_R8B, CV_AMD64_R8W, CV_AMD64_R8D, CV_AMD64_R8 }, - /* r9 */ { CV_AMD64_R9B, CV_AMD64_R9W, CV_AMD64_R9D, CV_AMD64_R9 }, - /* r10 */ { CV_AMD64_R10B, CV_AMD64_R10W, CV_AMD64_R10D, CV_AMD64_R10 }, - /* r11 */ { CV_AMD64_R11B, CV_AMD64_R11W, CV_AMD64_R11D, CV_AMD64_R11 }, - /* r12 */ { CV_AMD64_R12B, CV_AMD64_R12W, CV_AMD64_R12D, CV_AMD64_R12 }, - /* r13 */ { CV_AMD64_R13B, CV_AMD64_R13W, CV_AMD64_R13D, CV_AMD64_R13 }, - /* r14 */ { CV_AMD64_R14B, CV_AMD64_R14W, CV_AMD64_R14D, CV_AMD64_R14 }, - /* r15 */ { CV_AMD64_R15B, CV_AMD64_R15W, CV_AMD64_R15D, CV_AMD64_R15 }, + /* 8, 16, 32, 64 bits */ + { CV_AMD64_AL, CV_AMD64_AX, CV_AMD64_EAX, CV_AMD64_RAX }, /* rax=0 */ + { CV_AMD64_CL, CV_AMD64_CX, CV_AMD64_ECX, CV_AMD64_RCX }, /* rcx */ + { CV_AMD64_DL, CV_AMD64_DX, CV_AMD64_EDX, CV_AMD64_RDX }, /* rdx */ + { CV_AMD64_BL, CV_AMD64_BX, CV_AMD64_EBX, CV_AMD64_RBX }, /* rbx */ + { CV_AMD64_SPL, CV_AMD64_SP, CV_AMD64_ESP, CV_AMD64_RSP }, /* rsp */ + { CV_AMD64_BPL, CV_AMD64_BP, CV_AMD64_EBP, CV_AMD64_RBP }, /* rbp */ + { CV_AMD64_SIL, CV_AMD64_SI, CV_AMD64_ESI, CV_AMD64_RSI }, /* rsi */ + { CV_AMD64_DIL, CV_AMD64_DI, CV_AMD64_EDI, CV_AMD64_RDI }, /* rdi */ + { CV_AMD64_R8B, CV_AMD64_R8W, CV_AMD64_R8D, CV_AMD64_R8 }, /* r8 */ + { CV_AMD64_R9B, CV_AMD64_R9W, CV_AMD64_R9D, CV_AMD64_R9 }, /* r9 */ + { CV_AMD64_R10B, CV_AMD64_R10W, CV_AMD64_R10D, CV_AMD64_R10 }, /* r10 */ + { CV_AMD64_R11B, CV_AMD64_R11W, CV_AMD64_R11D, CV_AMD64_R11 }, /* r11 */ + { CV_AMD64_R12B, CV_AMD64_R12W, CV_AMD64_R12D, CV_AMD64_R12 }, /* r12 */ + { CV_AMD64_R13B, CV_AMD64_R13W, CV_AMD64_R13D, CV_AMD64_R13 }, /* r13 */ + { CV_AMD64_R14B, CV_AMD64_R14W, CV_AMD64_R14D, CV_AMD64_R14 }, /* r14 */ + { CV_AMD64_R15B, CV_AMD64_R15W, CV_AMD64_R15D, CV_AMD64_R15 }, /* r15 */ - /* xmm0=16 */ { -1, -1, CV_AMD64_XMM0_0, CV_AMD64_XMM0L}, - /* xmm1 */ { -1, -1, CV_AMD64_XMM1_0, CV_AMD64_XMM1L}, - /* xmm2 */ { -1, -1, CV_AMD64_XMM2_0, CV_AMD64_XMM2L}, - /* xmm3 */ { -1, -1, CV_AMD64_XMM3_0, CV_AMD64_XMM3L}, - /* xmm4 */ { -1, -1, CV_AMD64_XMM4_0, CV_AMD64_XMM4L}, - /* xmm5 */ { -1, -1, CV_AMD64_XMM5_0, CV_AMD64_XMM5L}, - /* xmm6 */ { -1, -1, CV_AMD64_XMM6_0, CV_AMD64_XMM6L}, - /* xmm7=23 */ { -1, -1, CV_AMD64_XMM7_0, CV_AMD64_XMM7L}, + { -1, -1, CV_AMD64_XMM0_0, CV_AMD64_XMM0L}, /* xmm0=16 */ + { -1, -1, CV_AMD64_XMM1_0, CV_AMD64_XMM1L}, /* xmm1 */ + { -1, -1, CV_AMD64_XMM2_0, CV_AMD64_XMM2L}, /* xmm2 */ + { -1, -1, CV_AMD64_XMM3_0, CV_AMD64_XMM3L}, /* xmm3 */ + { -1, -1, CV_AMD64_XMM4_0, CV_AMD64_XMM4L}, /* xmm4 */ + { -1, -1, CV_AMD64_XMM5_0, CV_AMD64_XMM5L}, /* xmm5 */ + { -1, -1, CV_AMD64_XMM6_0, CV_AMD64_XMM6L}, /* xmm6 */ + { -1, -1, CV_AMD64_XMM7_0, CV_AMD64_XMM7L}, /* xmm7=23 */ }; static short getCVRegister(int javaReg, TypeEntry typeEntry) { From e8a2077788083a286e3f4aaaae5cc97e11964717 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Mon, 28 Aug 2023 09:28:23 -0400 Subject: [PATCH 11/48] Changes for Graal gate. --- .../pecoff/cv/CVSymbolSubrecord.java | 2 +- .../pecoff/cv/CVSymbolSubsectionBuilder.java | 22 ++++----- .../oracle/objectfile/pecoff/cv/CVUtil.java | 48 +++++++++---------- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java index 7b29659ce013..f050279e0320 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java @@ -633,7 +633,7 @@ public static class CVSymbolGProc32Record extends CVSymbolSubrecord { } protected CVSymbolGProc32Record(CVDebugInfo cvDebugInfo, short cmd, String symbolName, String displayName, int pparent, int pend, int pnext, int proclen, int debugStart, int debugEnd, - int typeIndex, short segment, byte flags) { + int typeIndex, short segment, byte flags) { super(cvDebugInfo, cmd); this.symbolName = symbolName; this.displayName = displayName; diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java index 332ba0c759de..3689403c7623 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java @@ -63,8 +63,8 @@ final class CVSymbolSubsectionBuilder { private final short heapRegister; /** - * Create a symbol section by iterating over all classes, emitting types and line numbers as we go. - * See substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/SubstrateAMD64RegisterConfig.java + * Create a symbol section by iterating over all classes, emitting types and line numbers as we + * go. See SubstrateAMD64RegisterConfig.java * * @param cvDebugInfo debugInfo container */ @@ -151,8 +151,8 @@ private void buildFunction(CompiledMethodEntry compiledEntry) { /* add function definition. */ final int functionTypeIndex = addTypeRecords(compiledEntry); final byte funcFlags = 0; - CVSymbolSubrecord.CVSymbolGProc32IdRecord proc32 = new CVSymbolSubrecord.CVSymbolGProc32IdRecord(cvDebugInfo, externalName, debuggerName, 0, 0, 0, primaryRange.getHi() - primaryRange.getLo(), 0, - 0, functionTypeIndex, (short) 0, funcFlags); + CVSymbolSubrecord.CVSymbolGProc32IdRecord proc32 = new CVSymbolSubrecord.CVSymbolGProc32IdRecord(cvDebugInfo, externalName, debuggerName, 0, 0, 0, primaryRange.getHi() - primaryRange.getLo(), + 0, 0, functionTypeIndex, (short) 0, funcFlags); addSymbolRecord(proc32); final int frameFlags = FRAME_LOCAL_BP + FRAME_PARAM_BP; @@ -161,10 +161,8 @@ private void buildFunction(CompiledMethodEntry compiledEntry) { /* it's costly to compute this, so only compute it once */ HashMap> varRangeMap = primaryRange.getVarRangeMap(); - if (primaryRange.getClassName().contains("ListDir")) { - addParameters(compiledEntry, varRangeMap); - /* IN the future: addLocals(compiledEntry, varRangeMap); */ - } + addParameters(compiledEntry, varRangeMap); + /* In the future: addLocals(compiledEntry, varRangeMap); */ /* S_PROC_ID_END add end record. */ addSymbolRecord(new CVSymbolSubrecord.CVSymbolProcIdEndRecord(cvDebugInfo)); @@ -208,7 +206,8 @@ private static int infoTypeToInt(DebugInfoProvider.DebugLocalValueInfo info) { } } - void emitLocal(DebugInfoProvider.DebugLocalInfo info, HashMap> varRangeMap, String name, TypeEntry typeEntry, int typeIndex, boolean isParam, String procName, Range range) { + void emitLocal(DebugInfoProvider.DebugLocalInfo info, HashMap> varRangeMap, String name, TypeEntry typeEntry, int typeIndex, boolean isParam, + String procName, Range range) { int flags = isParam ? S_LOCAL_FLAGS_IS_PARAM : 0; List ranges = varRangeMap.get(info); addSymbolRecord(new CVSymbolSubrecord.CVSymbolLocalRecord(cvDebugInfo, name, typeIndex, flags)); @@ -233,14 +232,15 @@ void emitLocal(DebugInfoProvider.DebugLocalInfo info, HashMap Date: Mon, 28 Aug 2023 09:43:14 -0400 Subject: [PATCH 12/48] Changes for Graal gate. --- .../oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java | 2 +- .../src/com/oracle/objectfile/pecoff/cv/CVUtil.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java index f050279e0320..6c80fdd804e2 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java @@ -681,7 +681,7 @@ public static class CVSymbolGProc32IdRecord extends CVSymbolGProc32Record { @Override public String toString() { return String.format("S_GPROC32_ID name=%s/%s parent=%d debugstart=0x%x debugend=0x%x len=0x%x seg:offset=0x%x:0 type=0x%x flags=0x%x)", displayName, symbolName, pparent, debugStart, - debugEnd, proclen, segment, typeIndex, flags); + debugEnd, proclen, segment, typeIndex, flags); } } diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java index 1699ad6d081e..62fb8e84fb84 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java @@ -280,14 +280,14 @@ static int align4(int initialPos) { {CV_AMD64_BPL, CV_AMD64_BP, CV_AMD64_EBP, CV_AMD64_RBP}, /* rbp */ {CV_AMD64_SIL, CV_AMD64_SI, CV_AMD64_ESI, CV_AMD64_RSI}, /* rsi */ {CV_AMD64_DIL, CV_AMD64_DI, CV_AMD64_EDI, CV_AMD64_RDI}, /* rdi */ - {CV_AMD64_R8B, CV_AMD64_R8W, CV_AMD64_R8D, CV_AMD64_R8}, /* r8 */ - {CV_AMD64_R9B, CV_AMD64_R9W, CV_AMD64_R9D, CV_AMD64_R9}, /* r9 */ + {CV_AMD64_R8B, CV_AMD64_R8W, CV_AMD64_R8D, CV_AMD64_R8}, /* r8 */ + {CV_AMD64_R9B, CV_AMD64_R9W, CV_AMD64_R9D, CV_AMD64_R9}, /* r9 */ {CV_AMD64_R10B, CV_AMD64_R10W, CV_AMD64_R10D, CV_AMD64_R10}, /* r10 */ {CV_AMD64_R11B, CV_AMD64_R11W, CV_AMD64_R11D, CV_AMD64_R11}, /* r11 */ {CV_AMD64_R12B, CV_AMD64_R12W, CV_AMD64_R12D, CV_AMD64_R12}, /* r12 */ - {CV_AMD64_R13B, CV_AMD64_R13W, CV_AMD64_R13D, CV_AMD64_R13}, /* r13 */ + {CV_AMD64_R13B, CV_AMD64_R13W, CV_AMD64_R13D, CV_AMD64_R13}, /* r13 */ {CV_AMD64_R14B, CV_AMD64_R14W, CV_AMD64_R14D, CV_AMD64_R14}, /* r14 */ - {CV_AMD64_R15B, CV_AMD64_R15W, CV_AMD64_R15D, CV_AMD64_R15}, /* r15 */ + {CV_AMD64_R15B, CV_AMD64_R15W, CV_AMD64_R15D, CV_AMD64_R15}, /* r15 */ {-1, -1, CV_AMD64_XMM0_0, CV_AMD64_XMM0L}, /* xmm0=16 */ {-1, -1, CV_AMD64_XMM1_0, CV_AMD64_XMM1L}, /* xmm1 */ From 6e9fc17079a446400e159256c43b62d6cf7350b1 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Mon, 28 Aug 2023 10:40:27 -0400 Subject: [PATCH 13/48] Changes for Graal gate. --- .../src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java index 6c80fdd804e2..3f7e551b854e 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java @@ -424,7 +424,7 @@ protected String gapString() { String s = ""; if (gaps != null) { for (Gap gap : gaps) { - s = String.format("%s\n - gap=0x%x len=0x%x last=0x%x", s, gap.start, gap.length, gap.start + gap.length - 1); + s = String.format("%s%n - gap=0x%x len=0x%x last=0x%x", s, gap.start, gap.length, gap.start + gap.length - 1); } } return s; From e8fd9438c3aa8f36db7f69b6ccd54e49e5b1d42e Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Mon, 28 Aug 2023 10:41:37 -0400 Subject: [PATCH 14/48] Changes for Graal gate. --- .../src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java index 3f7e551b854e..23b636dd208e 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java @@ -373,7 +373,7 @@ private static class Gap { public final short start; public final short length; - public Gap(short start, short length) { + Gap(short start, short length) { this.start = start; this.length = length; } From b8143afca9d74726bef67580853e522efba58bc2 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Fri, 25 Aug 2023 14:25:53 -0400 Subject: [PATCH 15/48] Changes and cleanup for Graal gate. --- .../pecoff/cv/CVSymbolSubrecord.java | 16 +-- .../pecoff/cv/CVSymbolSubsectionBuilder.java | 99 +++---------------- .../objectfile/pecoff/cv/CVTypeRecord.java | 1 - .../oracle/objectfile/pecoff/cv/CVUtil.java | 50 +++++----- 4 files changed, 46 insertions(+), 120 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java index ed1a82428ab0..23b636dd208e 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java @@ -372,7 +372,8 @@ abstract static class CVSymbolDefRangeBase extends CVSymbolSubrecord { private static class Gap { public final short start; public final short length; - public Gap(short start, short length) { + + Gap(short start, short length) { this.start = start; this.length = length; } @@ -423,7 +424,7 @@ protected String gapString() { String s = ""; if (gaps != null) { for (Gap gap : gaps) { - s = String.format("%s\n - gap=0x%x len=0x%x last=0x%x", s, gap.start, gap.length, gap.start + gap.length - 1); + s = String.format("%s%n - gap=0x%x len=0x%x last=0x%x", s, gap.start, gap.length, gap.start + gap.length - 1); } } return s; @@ -631,8 +632,8 @@ public static class CVSymbolGProc32Record extends CVSymbolSubrecord { this.flags = flags; } - protected CVSymbolGProc32Record(CVDebugInfo cvDebugInfo, short cmd, String symbolName, String displayName, int pparent, int pend, int pnext, int proclen, int debugStart, int debugEnd, int typeIndex, - short segment, byte flags) { + protected CVSymbolGProc32Record(CVDebugInfo cvDebugInfo, short cmd, String symbolName, String displayName, int pparent, int pend, int pnext, int proclen, int debugStart, int debugEnd, + int typeIndex, short segment, byte flags) { super(cvDebugInfo, cmd); this.symbolName = symbolName; this.displayName = displayName; @@ -672,7 +673,7 @@ public String toString() { public static class CVSymbolGProc32IdRecord extends CVSymbolGProc32Record { CVSymbolGProc32IdRecord(CVDebugInfo cvDebugInfo, String symbolName, String displayName, int pparent, int pend, int pnext, int proclen, int debugStart, int debugEnd, int typeIndex, - short segment, byte flags) { + short segment, byte flags) { super(cvDebugInfo, CVDebugConstants.S_GPROC32_ID, symbolName, displayName, pparent, pend, pnext, proclen, debugStart, debugEnd, typeIndex, segment, flags); } @@ -680,7 +681,7 @@ public static class CVSymbolGProc32IdRecord extends CVSymbolGProc32Record { @Override public String toString() { return String.format("S_GPROC32_ID name=%s/%s parent=%d debugstart=0x%x debugend=0x%x len=0x%x seg:offset=0x%x:0 type=0x%x flags=0x%x)", displayName, symbolName, pparent, debugStart, - debugEnd, proclen, segment, typeIndex, flags); + debugEnd, proclen, segment, typeIndex, flags); } } @@ -689,8 +690,7 @@ public static final class CVSymbolFrameProcRecord extends CVSymbolSubrecord { /* This may change in the presence of isolates. */ /* Async exception handling (vc++ uses 1, clang uses 0). */ - @SuppressWarnings("unused") - public static final int FRAME_ASYNC_EH = 1 << 9; + @SuppressWarnings("unused") public static final int FRAME_ASYNC_EH = 1 << 9; /* Local base pointer = SP (0=none, 1=sp, 2=bp 3=r13). */ public static final int FRAME_LOCAL_BP = 1 << 14; diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java index bf246d5b4d70..3689403c7623 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java @@ -37,12 +37,10 @@ import com.oracle.objectfile.debuginfo.DebugInfoProvider; import jdk.vm.ci.amd64.AMD64; -import jdk.vm.ci.meta.JavaConstant; import java.lang.reflect.Modifier; import java.util.HashMap; import java.util.List; -import java.util.Map; import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugLocalValueInfo.LocalKind.CONSTANT; import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugLocalValueInfo.LocalKind.REGISTER; @@ -52,8 +50,6 @@ import static com.oracle.objectfile.pecoff.cv.CVSymbolSubrecord.CVSymbolFrameProcRecord.FRAME_LOCAL_BP; import static com.oracle.objectfile.pecoff.cv.CVSymbolSubrecord.CVSymbolFrameProcRecord.FRAME_PARAM_BP; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.MAX_PRIMITIVE; -import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.T_INT4; -import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.T_INT8; final class CVSymbolSubsectionBuilder { @@ -67,8 +63,8 @@ final class CVSymbolSubsectionBuilder { private final short heapRegister; /** - * Create a symbol section by iterating over all classes, emitting types and line numbers as we go. - * See substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/SubstrateAMD64RegisterConfig.java + * Create a symbol section by iterating over all classes, emitting types and line numbers as we + * go. See SubstrateAMD64RegisterConfig.java * * @param cvDebugInfo debugInfo container */ @@ -155,8 +151,8 @@ private void buildFunction(CompiledMethodEntry compiledEntry) { /* add function definition. */ final int functionTypeIndex = addTypeRecords(compiledEntry); final byte funcFlags = 0; - CVSymbolSubrecord.CVSymbolGProc32IdRecord proc32 = new CVSymbolSubrecord.CVSymbolGProc32IdRecord(cvDebugInfo, externalName, debuggerName, 0, 0, 0, primaryRange.getHi() - primaryRange.getLo(), 0, - 0, functionTypeIndex, (short) 0, funcFlags); + CVSymbolSubrecord.CVSymbolGProc32IdRecord proc32 = new CVSymbolSubrecord.CVSymbolGProc32IdRecord(cvDebugInfo, externalName, debuggerName, 0, 0, 0, primaryRange.getHi() - primaryRange.getLo(), + 0, 0, functionTypeIndex, (short) 0, funcFlags); addSymbolRecord(proc32); final int frameFlags = FRAME_LOCAL_BP + FRAME_PARAM_BP; @@ -165,10 +161,8 @@ private void buildFunction(CompiledMethodEntry compiledEntry) { /* it's costly to compute this, so only compute it once */ HashMap> varRangeMap = primaryRange.getVarRangeMap(); - if (primaryRange.getClassName().contains("ListDir")) { - addParameters(compiledEntry, varRangeMap); - /* IN the future: addLocals(compiledEntry, varRangeMap); */ - } + addParameters(compiledEntry, varRangeMap); + /* In the future: addLocals(compiledEntry, varRangeMap); */ /* S_PROC_ID_END add end record. */ addSymbolRecord(new CVSymbolSubrecord.CVSymbolProcIdEndRecord(cvDebugInfo)); @@ -201,19 +195,19 @@ void addParameters(CompiledMethodEntry primaryEntry, HashMap> varRangeMap, String name, TypeEntry typeEntry, int typeIndex, boolean isParam, String procName, Range range) { + void emitLocal(DebugInfoProvider.DebugLocalInfo info, HashMap> varRangeMap, String name, TypeEntry typeEntry, int typeIndex, boolean isParam, + String procName, Range range) { int flags = isParam ? S_LOCAL_FLAGS_IS_PARAM : 0; List ranges = varRangeMap.get(info); addSymbolRecord(new CVSymbolSubrecord.CVSymbolLocalRecord(cvDebugInfo, name, typeIndex, flags)); @@ -238,87 +232,20 @@ void emitLocal(DebugInfoProvider.DebugLocalInfo info, HashMap> varRangeMap) { - processVarMap(primaryEntry, varRangeMap); - } - - @SuppressWarnings("unused") - void processVarMap(CompiledMethodEntry primaryEntry, HashMap> varRangeMap) { - final Range primaryRange = primaryEntry.getPrimary(); - /* The name as exposed to the linker. */ - final String externalName = primaryRange.getSymbolName(); - System.out.format("func %s:\n", externalName); - processRange(primaryRange); - } - - @SuppressWarnings("unused") - void processRange(Range range) { - final String procName = range.getSymbolName(); - HashMap> varmap = range.getVarRangeMap(); - for (Map.Entry> entry : varmap.entrySet()) { - DebugInfoProvider.DebugLocalInfo v = entry.getKey(); - final int typeIndex = v.slotCount() == 1 ? T_INT4 : T_INT8; - System.out.format(" var %s jk=%s tn=%s vt=%s line=%d slot=%d n=%d\n", v.name(), v.javaKind(), v.typeName(), v.valueType(), v.line(), v.slot(), v.slotCount()); - //addSymbolRecord(new CVSymbolSubrecord.CVSymbolLocalRecord(cvDebugInfo, procName + "x", typeIndex, 1)); - CVSymbolSubrecord.CVSymbolDefRangeFramepointerRel rangeRecord = new CVSymbolSubrecord.CVSymbolDefRangeFramepointerRel(cvDebugInfo, procName, range.getLo(), (short) (range.getHi() - range.getLo()), v.slot() + 4); - int low = Integer.MAX_VALUE; - int high = Integer.MIN_VALUE; - int currentLow = Integer.MAX_VALUE; - int currentHigh = Integer.MIN_VALUE; - List subRanges = entry.getValue(); - for (SubRange sr : subRanges) { - //System.out.format(" subrange line=%d low=0x%x high=0x%x depth=%d\n", sr.getLine(), sr.getLo(), sr.getHi(), sr.getDepth()); - high = sr.getHi(); - if (currentLow == Integer.MAX_VALUE) { - /* initial subrange */ - low = sr.getLo(); - currentLow = sr.getLo(); - currentHigh = sr.getHi(); - } else if (sr.getLo() == currentHigh) { - /* extend current subrange as the new one is contiguous */ - currentHigh = sr.getHi(); - } else { - /* non-contiguous; emit previous subrange */ - System.out.format(" xxsubrange low=0x%x high=0x%x slot=%d depth=%d\n", currentLow, currentHigh, v.slot(), 0); - System.out.format(" xxgap low=0x%x len=0x%x\n", (currentHigh + 1) - low, sr.getLo() - 1 - low); - rangeRecord.addGap((short) ((currentHigh + 1) - low), (short) (sr.getLo() - 1 - low)); - //emitLocalX(v.name(), typeIndex, (short) 0, v.slot(), procName, currentLow, currentHigh); - currentLow = sr.getLo(); - currentHigh = sr.getHi(); - } - /* - for (Map.Entry> subentry : varmap.entrySet()) { - DebugInfoProvider.DebugLocalInfo v2 = subentry.getKey(); - List subRanges2 = subentry.getValue(); - System.out.format(" var %s jk=%s tn=%s vt=%s line=%d slot=%d n=%d\n", v2.name(), v2.javaKind(), v2.typeName(), v2.valueType(), v2.line(), v2.slot(), v2.slotCount()); - for (SubRange sr2 : subRanges2) { - System.out.format(" subrange %d 0x%x 0x%x \n", sr2.getLine(), sr2.getLo(), sr2.getHi()); - } - }*/ - } - if (currentLow != Integer.MAX_VALUE) { - /* clear out last subrange */ - System.out.format(" xxsubrange low=0x%x high=0x%x depth=%d\n", currentLow, currentHigh, 0); - //emitLocalX(v.name(), typeIndex, (short) 0, v.slot(), procName, currentLow, currentHigh); - } - // addSymbolRecord(rageRecord); - } - } - private void addLineNumberRecords(CompiledMethodEntry compiledEntry) { CVLineRecord lineRecord = lineRecordBuilder.build(compiledEntry); /* diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeRecord.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeRecord.java index 8004d92c40fb..63871fc5cbc8 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeRecord.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeRecord.java @@ -361,7 +361,6 @@ public boolean equals(Object obj) { } } - static final class CVTypeMFuncIdRecord extends CVTypeRecord { int parentTypeIdx; diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java index 1d6dd869e17a..62fb8e84fb84 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java @@ -271,32 +271,32 @@ static int align4(int initialPos) { /* First index is AMD64.(register).number, second is 1,2,4,8 bytes. */ private static final short[][] javaToCvRegisters = { - /* 8, 16, 32, 64 bits */ - /* rax=0 */ { CV_AMD64_AL, CV_AMD64_AX, CV_AMD64_EAX, CV_AMD64_RAX }, - /* rcx */ { CV_AMD64_CL, CV_AMD64_CX, CV_AMD64_ECX, CV_AMD64_RCX }, - /* rdx */ { CV_AMD64_DL, CV_AMD64_DX, CV_AMD64_EDX, CV_AMD64_RDX }, - /* rbx */ { CV_AMD64_BL, CV_AMD64_BX, CV_AMD64_EBX, CV_AMD64_RBX }, - /* rsp */ { CV_AMD64_SPL, CV_AMD64_SP, CV_AMD64_ESP, CV_AMD64_RSP }, - /* rbp */ { CV_AMD64_BPL, CV_AMD64_BP, CV_AMD64_EBP, CV_AMD64_RBP }, - /* rsi */ { CV_AMD64_SIL, CV_AMD64_SI, CV_AMD64_ESI, CV_AMD64_RSI }, - /* rdi */ { CV_AMD64_DIL, CV_AMD64_DI, CV_AMD64_EDI, CV_AMD64_RDI }, - /* r8 */ { CV_AMD64_R8B, CV_AMD64_R8W, CV_AMD64_R8D, CV_AMD64_R8 }, - /* r9 */ { CV_AMD64_R9B, CV_AMD64_R9W, CV_AMD64_R9D, CV_AMD64_R9 }, - /* r10 */ { CV_AMD64_R10B, CV_AMD64_R10W, CV_AMD64_R10D, CV_AMD64_R10 }, - /* r11 */ { CV_AMD64_R11B, CV_AMD64_R11W, CV_AMD64_R11D, CV_AMD64_R11 }, - /* r12 */ { CV_AMD64_R12B, CV_AMD64_R12W, CV_AMD64_R12D, CV_AMD64_R12 }, - /* r13 */ { CV_AMD64_R13B, CV_AMD64_R13W, CV_AMD64_R13D, CV_AMD64_R13 }, - /* r14 */ { CV_AMD64_R14B, CV_AMD64_R14W, CV_AMD64_R14D, CV_AMD64_R14 }, - /* r15 */ { CV_AMD64_R15B, CV_AMD64_R15W, CV_AMD64_R15D, CV_AMD64_R15 }, + /* 8, 16, 32, 64 bits */ + {CV_AMD64_AL, CV_AMD64_AX, CV_AMD64_EAX, CV_AMD64_RAX}, /* rax=0 */ + {CV_AMD64_CL, CV_AMD64_CX, CV_AMD64_ECX, CV_AMD64_RCX}, /* rcx */ + {CV_AMD64_DL, CV_AMD64_DX, CV_AMD64_EDX, CV_AMD64_RDX}, /* rdx */ + {CV_AMD64_BL, CV_AMD64_BX, CV_AMD64_EBX, CV_AMD64_RBX}, /* rbx */ + {CV_AMD64_SPL, CV_AMD64_SP, CV_AMD64_ESP, CV_AMD64_RSP}, /* rsp */ + {CV_AMD64_BPL, CV_AMD64_BP, CV_AMD64_EBP, CV_AMD64_RBP}, /* rbp */ + {CV_AMD64_SIL, CV_AMD64_SI, CV_AMD64_ESI, CV_AMD64_RSI}, /* rsi */ + {CV_AMD64_DIL, CV_AMD64_DI, CV_AMD64_EDI, CV_AMD64_RDI}, /* rdi */ + {CV_AMD64_R8B, CV_AMD64_R8W, CV_AMD64_R8D, CV_AMD64_R8}, /* r8 */ + {CV_AMD64_R9B, CV_AMD64_R9W, CV_AMD64_R9D, CV_AMD64_R9}, /* r9 */ + {CV_AMD64_R10B, CV_AMD64_R10W, CV_AMD64_R10D, CV_AMD64_R10}, /* r10 */ + {CV_AMD64_R11B, CV_AMD64_R11W, CV_AMD64_R11D, CV_AMD64_R11}, /* r11 */ + {CV_AMD64_R12B, CV_AMD64_R12W, CV_AMD64_R12D, CV_AMD64_R12}, /* r12 */ + {CV_AMD64_R13B, CV_AMD64_R13W, CV_AMD64_R13D, CV_AMD64_R13}, /* r13 */ + {CV_AMD64_R14B, CV_AMD64_R14W, CV_AMD64_R14D, CV_AMD64_R14}, /* r14 */ + {CV_AMD64_R15B, CV_AMD64_R15W, CV_AMD64_R15D, CV_AMD64_R15}, /* r15 */ - /* xmm0=16 */ { -1, -1, CV_AMD64_XMM0_0, CV_AMD64_XMM0L}, - /* xmm1 */ { -1, -1, CV_AMD64_XMM1_0, CV_AMD64_XMM1L}, - /* xmm2 */ { -1, -1, CV_AMD64_XMM2_0, CV_AMD64_XMM2L}, - /* xmm3 */ { -1, -1, CV_AMD64_XMM3_0, CV_AMD64_XMM3L}, - /* xmm4 */ { -1, -1, CV_AMD64_XMM4_0, CV_AMD64_XMM4L}, - /* xmm5 */ { -1, -1, CV_AMD64_XMM5_0, CV_AMD64_XMM5L}, - /* xmm6 */ { -1, -1, CV_AMD64_XMM6_0, CV_AMD64_XMM6L}, - /* xmm7=23 */ { -1, -1, CV_AMD64_XMM7_0, CV_AMD64_XMM7L}, + {-1, -1, CV_AMD64_XMM0_0, CV_AMD64_XMM0L}, /* xmm0=16 */ + {-1, -1, CV_AMD64_XMM1_0, CV_AMD64_XMM1L}, /* xmm1 */ + {-1, -1, CV_AMD64_XMM2_0, CV_AMD64_XMM2L}, /* xmm2 */ + {-1, -1, CV_AMD64_XMM3_0, CV_AMD64_XMM3L}, /* xmm3 */ + {-1, -1, CV_AMD64_XMM4_0, CV_AMD64_XMM4L}, /* xmm4 */ + {-1, -1, CV_AMD64_XMM5_0, CV_AMD64_XMM5L}, /* xmm5 */ + {-1, -1, CV_AMD64_XMM6_0, CV_AMD64_XMM6L}, /* xmm6 */ + {-1, -1, CV_AMD64_XMM7_0, CV_AMD64_XMM7L}, /* xmm7=23 */ }; static short getCVRegister(int javaReg, TypeEntry typeEntry) { From a0f48b592e1a679a88577fcd8376a7b7c3161bff Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Wed, 6 Sep 2023 16:01:12 -0400 Subject: [PATCH 16/48] Corrected variable range calculation. --- .../objectfile/pecoff/cv/CVSymbolSubrecord.java | 14 +++++++------- .../pecoff/cv/CVSymbolSubsectionBuilder.java | 5 ++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java index 23b636dd208e..a8f5de01fdff 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java @@ -365,7 +365,7 @@ abstract static class CVSymbolDefRangeBase extends CVSymbolSubrecord { private static final int GAP_ARRAY_SIZE = 5; protected final String procName; protected final int procOffset; - protected short range; + protected short length; private List gaps = null; /* It might be more efficient to use an array of shorts instead of a List of Gaps. */ @@ -379,11 +379,11 @@ private static class Gap { } } - protected CVSymbolDefRangeBase(CVDebugInfo debugInfo, short recordType, String procName, int procOffset, short range) { + protected CVSymbolDefRangeBase(CVDebugInfo debugInfo, short recordType, String procName, int procOffset, short length) { super(debugInfo, recordType); this.procName = procName; this.procOffset = procOffset; - this.range = range; + this.length = length; } void addGap(short start, short length) { @@ -396,7 +396,7 @@ void addGap(short start, short length) { int computeRange(byte[] buffer, int initialPos) { /* Emit CV_LVAR_ADDR_RANGE. */ int pos = cvDebugInfo.getCVSymbolSection().markRelocationSite(buffer, initialPos, procName, procOffset); - pos = CVUtil.putShort(range, buffer, pos); + pos = CVUtil.putShort(length, buffer, pos); return pos; } @@ -473,7 +473,7 @@ protected int computeContents(byte[] buffer, int initialPos) { @Override public String toString() { - return String.format("S_DEFRANGE_REGISTER r%d attr=0x%x %s+0x%x range=0x%x gaps=%d)%s", register, attr, procName, procOffset, range, gapCount(), gapString()); + return String.format("S_DEFRANGE_REGISTER r%d attr=0x%x %s+0x%x length=0x%x gaps=%d)%s", register, attr, procName, procOffset, length, gapCount(), gapString()); } } @@ -505,7 +505,7 @@ protected int computeContents(byte[] buffer, int initialPos) { @Override public String toString() { - return String.format("S_DEFRANGE_REGISTER_REL r%d spilled=%d parentOffset=0x%x %s+0x%x range=0x%x gaps=%d)%s", baseRegister, spilledUdtMember, parentOffset, procName, procOffset, range, + return String.format("S_DEFRANGE_REGISTER_REL r%d spilled=%d parentOffset=0x%x %s+0x%x length=0x%x gaps=%d)%s", baseRegister, spilledUdtMember, parentOffset, procName, procOffset, length, gapCount(), gapString()); } } @@ -559,7 +559,7 @@ protected int computeContents(byte[] buffer, int initialPos) { @Override public String toString() { - return String.format("S_DEFRANGE_FRAMEPOINTER_REL name=%s+0x%x range=0x%x fpOffset=0x%x)%s", procName, procOffset, range, fpOffset, gapString()); + return String.format("S_DEFRANGE_FRAMEPOINTER_REL name=%s+0x%x length=0x%x fpOffset=0x%x)%s", procName, procOffset, length, fpOffset, gapString()); } } diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java index 3689403c7623..26b9a43829c6 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java @@ -175,8 +175,7 @@ void addParameters(CompiledMethodEntry primaryEntry, HashMap Date: Wed, 6 Sep 2023 16:13:48 -0400 Subject: [PATCH 17/48] Changes for Github gate. --- .../oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java index a8f5de01fdff..b648c8694690 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java @@ -371,11 +371,11 @@ abstract static class CVSymbolDefRangeBase extends CVSymbolSubrecord { /* It might be more efficient to use an array of shorts instead of a List of Gaps. */ private static class Gap { public final short start; - public final short length; + public final short gapLength; - Gap(short start, short length) { + Gap(short start, short gapLength) { this.start = start; - this.length = length; + this.gapLength = gapLength; } } @@ -405,7 +405,7 @@ private int computeGaps(byte[] buffer, int initialPos) { if (gaps != null) { for (Gap gap : gaps) { pos = CVUtil.putShort(gap.start, buffer, pos); - pos = CVUtil.putShort(gap.length, buffer, pos); + pos = CVUtil.putShort(gap.gapLength, buffer, pos); } } return pos; @@ -424,7 +424,7 @@ protected String gapString() { String s = ""; if (gaps != null) { for (Gap gap : gaps) { - s = String.format("%s%n - gap=0x%x len=0x%x last=0x%x", s, gap.start, gap.length, gap.start + gap.length - 1); + s = String.format("%s%n - gap=0x%x len=0x%x last=0x%x", s, gap.start, gap.gapLength, gap.start + gap.gapLength - 1); } } return s; From 5f917c7abadfda40729a7be7534904d312c3ecbc Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Thu, 7 Sep 2023 08:14:04 -0400 Subject: [PATCH 18/48] Changes for Github gate --- .../objectfile/pecoff/cv/CVSymbolSubrecord.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java index b648c8694690..78fdf6c02415 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java @@ -370,11 +370,11 @@ abstract static class CVSymbolDefRangeBase extends CVSymbolSubrecord { /* It might be more efficient to use an array of shorts instead of a List of Gaps. */ private static class Gap { - public final short start; + public final short gapStart; public final short gapLength; - Gap(short start, short gapLength) { - this.start = start; + Gap(short gapStart, short gapLength) { + this.gapStart = gapStart; this.gapLength = gapLength; } } @@ -386,11 +386,11 @@ protected CVSymbolDefRangeBase(CVDebugInfo debugInfo, short recordType, String p this.length = length; } - void addGap(short start, short length) { + void addGap(short gapStart, short gapLength) { if (gaps == null) { gaps = new ArrayList<>(GAP_ARRAY_SIZE); } - gaps.add(new Gap(start, length)); + gaps.add(new Gap(gapStart, gapLength)); } int computeRange(byte[] buffer, int initialPos) { @@ -404,7 +404,7 @@ private int computeGaps(byte[] buffer, int initialPos) { int pos = initialPos; if (gaps != null) { for (Gap gap : gaps) { - pos = CVUtil.putShort(gap.start, buffer, pos); + pos = CVUtil.putShort(gap.gapStart, buffer, pos); pos = CVUtil.putShort(gap.gapLength, buffer, pos); } } @@ -424,7 +424,7 @@ protected String gapString() { String s = ""; if (gaps != null) { for (Gap gap : gaps) { - s = String.format("%s%n - gap=0x%x len=0x%x last=0x%x", s, gap.start, gap.gapLength, gap.start + gap.gapLength - 1); + s = String.format("%s%n - gap=0x%x len=0x%x last=0x%x", s, gap.gapStart, gap.gapLength, gap.gapStart + gap.gapLength - 1); } } return s; From e61f73d9fec86d13dedb419245975e44b13ea678 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Tue, 3 Sep 2024 17:28:07 -0400 Subject: [PATCH 19/48] fix aob error in regester code --- .../objectfile/pecoff/cv/CVConstants.java | 27 ++++ .../oracle/objectfile/pecoff/cv/CVUtil.java | 138 +++++++++++++----- 2 files changed, 126 insertions(+), 39 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVConstants.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVConstants.java index 03fed1d1a860..9d3edef0bcbc 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVConstants.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVConstants.java @@ -125,6 +125,15 @@ public abstract class CVConstants { static final short CV_AMD64_XMM6 = 160; static final short CV_AMD64_XMM7 = 161; + static final short CV_AMD64_XMM8 = 252; + static final short CV_AMD64_XMM9 = 253; + static final short CV_AMD64_XMM10 = 254; + static final short CV_AMD64_XMM11 = 255; + static final short CV_AMD64_XMM12 = 256; + static final short CV_AMD64_XMM13 = 257; + static final short CV_AMD64_XMM14 = 258; + static final short CV_AMD64_XMM15 = 259; + static final short CV_AMD64_XMM0_0 = 162; static final short CV_AMD64_XMM1_0 = 166; static final short CV_AMD64_XMM2_0 = 170; @@ -134,6 +143,15 @@ public abstract class CVConstants { static final short CV_AMD64_XMM6_0 = 186; static final short CV_AMD64_XMM7_0 = 190; + static final short CV_AMD64_XMM8_0 = 260; + static final short CV_AMD64_XMM9_0 = 261; + static final short CV_AMD64_XMM10_0 = 262; + static final short CV_AMD64_XMM11_0 = 263; + static final short CV_AMD64_XMM12_0 = 264; + static final short CV_AMD64_XMM13_0 = 265; + static final short CV_AMD64_XMM14_0 = 266; + static final short CV_AMD64_XMM15_0 = 267; + static final short CV_AMD64_XMM0L = 194; static final short CV_AMD64_XMM1L = 195; static final short CV_AMD64_XMM2L = 196; @@ -142,4 +160,13 @@ public abstract class CVConstants { static final short CV_AMD64_XMM5L = 199; static final short CV_AMD64_XMM6L = 200; static final short CV_AMD64_XMM7L = 201; + + static final short CV_AMD64_XMM8L = 292; + static final short CV_AMD64_XMM9L = 293; + static final short CV_AMD64_XMM10L = 294; + static final short CV_AMD64_XMM11L = 295; + static final short CV_AMD64_XMM12L = 296; + static final short CV_AMD64_XMM13L = 297; + static final short CV_AMD64_XMM14L = 298; + static final short CV_AMD64_XMM15L = 299; } diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java index 62fb8e84fb84..0bcdcab36a5b 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java @@ -29,6 +29,7 @@ import com.oracle.objectfile.debugentry.TypeEntry; import com.oracle.objectfile.io.Utf8; import jdk.vm.ci.amd64.AMD64; +import jdk.vm.ci.code.Register; import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_AL; import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_AX; @@ -96,6 +97,18 @@ import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_SPL; import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM0L; import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM0_0; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM10L; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM10_0; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM11L; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM11_0; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM12L; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM12_0; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM13L; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM13_0; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM14L; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM14_0; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM15L; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM15_0; import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM1L; import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM1_0; import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM2L; @@ -110,6 +123,10 @@ import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM6_0; import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM7L; import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM7_0; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM8L; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM8_0; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM9L; +import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM9_0; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_CHAR; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_LONG; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_QUADWORD; @@ -269,64 +286,107 @@ static int align4(int initialPos) { return pos; } + static class CvRegDef { + final Register register; + final short cv1; + final short cv2; + final short cv4; + final short cv8; + CvRegDef(Register r, short cv1, short cv2, short cv4, short cv8) { + this.register = r; + this.cv1 = cv1; + this.cv2 = cv2; + this.cv4 = cv4; + this.cv8 = cv8; + } + CvRegDef(Register r, short cv4, short cv8) { + this.register = r; + this.cv1 = -1; + this.cv2 = -2; + this.cv4 = cv4; + this.cv8 = cv8; + } + } + /* First index is AMD64.(register).number, second is 1,2,4,8 bytes. */ - private static final short[][] javaToCvRegisters = { - /* 8, 16, 32, 64 bits */ - {CV_AMD64_AL, CV_AMD64_AX, CV_AMD64_EAX, CV_AMD64_RAX}, /* rax=0 */ - {CV_AMD64_CL, CV_AMD64_CX, CV_AMD64_ECX, CV_AMD64_RCX}, /* rcx */ - {CV_AMD64_DL, CV_AMD64_DX, CV_AMD64_EDX, CV_AMD64_RDX}, /* rdx */ - {CV_AMD64_BL, CV_AMD64_BX, CV_AMD64_EBX, CV_AMD64_RBX}, /* rbx */ - {CV_AMD64_SPL, CV_AMD64_SP, CV_AMD64_ESP, CV_AMD64_RSP}, /* rsp */ - {CV_AMD64_BPL, CV_AMD64_BP, CV_AMD64_EBP, CV_AMD64_RBP}, /* rbp */ - {CV_AMD64_SIL, CV_AMD64_SI, CV_AMD64_ESI, CV_AMD64_RSI}, /* rsi */ - {CV_AMD64_DIL, CV_AMD64_DI, CV_AMD64_EDI, CV_AMD64_RDI}, /* rdi */ - {CV_AMD64_R8B, CV_AMD64_R8W, CV_AMD64_R8D, CV_AMD64_R8}, /* r8 */ - {CV_AMD64_R9B, CV_AMD64_R9W, CV_AMD64_R9D, CV_AMD64_R9}, /* r9 */ - {CV_AMD64_R10B, CV_AMD64_R10W, CV_AMD64_R10D, CV_AMD64_R10}, /* r10 */ - {CV_AMD64_R11B, CV_AMD64_R11W, CV_AMD64_R11D, CV_AMD64_R11}, /* r11 */ - {CV_AMD64_R12B, CV_AMD64_R12W, CV_AMD64_R12D, CV_AMD64_R12}, /* r12 */ - {CV_AMD64_R13B, CV_AMD64_R13W, CV_AMD64_R13D, CV_AMD64_R13}, /* r13 */ - {CV_AMD64_R14B, CV_AMD64_R14W, CV_AMD64_R14D, CV_AMD64_R14}, /* r14 */ - {CV_AMD64_R15B, CV_AMD64_R15W, CV_AMD64_R15D, CV_AMD64_R15}, /* r15 */ + private static final CvRegDef[] compactRegDefs = { + /* 8, 16, 32, 64 bits */ + new CvRegDef(AMD64.rax, CV_AMD64_AL, CV_AMD64_AX, CV_AMD64_EAX, CV_AMD64_RAX), /* rax=0 */ + new CvRegDef(AMD64.rcx, CV_AMD64_CL, CV_AMD64_CX, CV_AMD64_ECX, CV_AMD64_RCX), /* rcx */ + new CvRegDef(AMD64.rdx, CV_AMD64_DL, CV_AMD64_DX, CV_AMD64_EDX, CV_AMD64_RDX), /* rdx */ + new CvRegDef(AMD64.rbx, CV_AMD64_BL, CV_AMD64_BX, CV_AMD64_EBX, CV_AMD64_RBX), /* rbx */ + new CvRegDef(AMD64.rsp, CV_AMD64_SPL, CV_AMD64_SP, CV_AMD64_ESP, CV_AMD64_RSP), /* rsp */ + new CvRegDef(AMD64.rbp, CV_AMD64_BPL, CV_AMD64_BP, CV_AMD64_EBP, CV_AMD64_RBP), /* rbp */ + new CvRegDef(AMD64.rsi, CV_AMD64_SIL, CV_AMD64_SI, CV_AMD64_ESI, CV_AMD64_RSI), /* rsi */ + new CvRegDef(AMD64.rdi, CV_AMD64_DIL, CV_AMD64_DI, CV_AMD64_EDI, CV_AMD64_RDI), /* rdi */ + new CvRegDef(AMD64.r8, CV_AMD64_R8B, CV_AMD64_R8W, CV_AMD64_R8D, CV_AMD64_R8), /* r8 */ + new CvRegDef(AMD64.r9, CV_AMD64_R9B, CV_AMD64_R9W, CV_AMD64_R9D, CV_AMD64_R9), /* r9 */ + new CvRegDef(AMD64.r10, CV_AMD64_R10B, CV_AMD64_R10W, CV_AMD64_R10D, CV_AMD64_R10), /* r10 */ + new CvRegDef(AMD64.r11, CV_AMD64_R11B, CV_AMD64_R11W, CV_AMD64_R11D, CV_AMD64_R11), /* r11 */ + new CvRegDef(AMD64.r12, CV_AMD64_R12B, CV_AMD64_R12W, CV_AMD64_R12D, CV_AMD64_R12), /* r12 */ + new CvRegDef(AMD64.r13, CV_AMD64_R13B, CV_AMD64_R13W, CV_AMD64_R13D, CV_AMD64_R13), /* r13 */ + new CvRegDef(AMD64.r14, CV_AMD64_R14B, CV_AMD64_R14W, CV_AMD64_R14D, CV_AMD64_R14), /* r14 */ + new CvRegDef(AMD64.r15, CV_AMD64_R15B, CV_AMD64_R15W, CV_AMD64_R15D, CV_AMD64_R15), /* r15 */ + + new CvRegDef(AMD64.xmm0, CV_AMD64_XMM0_0, CV_AMD64_XMM0L), /* xmm0=16 */ + new CvRegDef(AMD64.xmm1, CV_AMD64_XMM1_0, CV_AMD64_XMM1L), /* xmm1 */ + new CvRegDef(AMD64.xmm2, CV_AMD64_XMM2_0, CV_AMD64_XMM2L), /* xmm2 */ + new CvRegDef(AMD64.xmm3, CV_AMD64_XMM3_0, CV_AMD64_XMM3L), /* xmm3 */ + new CvRegDef(AMD64.xmm4, CV_AMD64_XMM4_0, CV_AMD64_XMM4L), /* xmm4 */ + new CvRegDef(AMD64.xmm5, CV_AMD64_XMM5_0, CV_AMD64_XMM5L), /* xmm5 */ + new CvRegDef(AMD64.xmm6, CV_AMD64_XMM6_0, CV_AMD64_XMM6L), /* xmm6 */ + new CvRegDef(AMD64.xmm7, CV_AMD64_XMM7_0, CV_AMD64_XMM7L), /* xmm7=23 */ - {-1, -1, CV_AMD64_XMM0_0, CV_AMD64_XMM0L}, /* xmm0=16 */ - {-1, -1, CV_AMD64_XMM1_0, CV_AMD64_XMM1L}, /* xmm1 */ - {-1, -1, CV_AMD64_XMM2_0, CV_AMD64_XMM2L}, /* xmm2 */ - {-1, -1, CV_AMD64_XMM3_0, CV_AMD64_XMM3L}, /* xmm3 */ - {-1, -1, CV_AMD64_XMM4_0, CV_AMD64_XMM4L}, /* xmm4 */ - {-1, -1, CV_AMD64_XMM5_0, CV_AMD64_XMM5L}, /* xmm5 */ - {-1, -1, CV_AMD64_XMM6_0, CV_AMD64_XMM6L}, /* xmm6 */ - {-1, -1, CV_AMD64_XMM7_0, CV_AMD64_XMM7L}, /* xmm7=23 */ + new CvRegDef(AMD64.xmm8, CV_AMD64_XMM8_0, CV_AMD64_XMM8L), /* xmm8=24 */ + new CvRegDef(AMD64.xmm9, CV_AMD64_XMM9_0, CV_AMD64_XMM9L), /* xmm9 */ + new CvRegDef(AMD64.xmm10, CV_AMD64_XMM10_0, CV_AMD64_XMM10L), /* xmm10 */ + new CvRegDef(AMD64.xmm11, CV_AMD64_XMM11_0, CV_AMD64_XMM11L), /* xmm11 */ + new CvRegDef(AMD64.xmm12, CV_AMD64_XMM12_0, CV_AMD64_XMM12L), /* xmm12 */ + new CvRegDef(AMD64.xmm13, CV_AMD64_XMM13_0, CV_AMD64_XMM13L), /* xmm13 */ + new CvRegDef(AMD64.xmm14, CV_AMD64_XMM14_0, CV_AMD64_XMM14L), /* xmm14 */ + new CvRegDef(AMD64.xmm15, CV_AMD64_XMM15_0, CV_AMD64_XMM15L), /* xmm15 */ }; + private static final CvRegDef[] javaToCvRegisters = new CvRegDef[AMD64.xmm15.number + 1]; + + static { + for (CvRegDef def : compactRegDefs) { + assert 0 <= def.register.number && def.register.number <= AMD64.xmm15.number; + javaToCvRegisters[def.register.number] = def; + } + } + + /* convert a Java register number to a CodeView register code */ + /* thos Codeview code depends upon the register type and size */ static short getCVRegister(int javaReg, TypeEntry typeEntry) { - assert 0 <= javaReg && javaReg <= AMD64.xmm7.number; - final int bytes; + assert 0 <= javaReg && javaReg <= AMD64.xmm15.number; + CvRegDef cvReg = javaToCvRegisters[javaReg]; + assert cvReg != null; + + final short cvCode; if (typeEntry.isPrimitive()) { switch (typeEntry.getSize()) { case 1: - bytes = 0; + cvCode = cvReg.cv1; break; case 2: - bytes = 1; + cvCode = cvReg.cv2; break; case 4: - bytes = 2; + cvCode = cvReg.cv4; break; case 8: - bytes = 3; + cvCode = cvReg.cv8; break; default: - bytes = -1; + cvCode = -1; break; } } else { - /* Objects are represented by pointers. */ - bytes = 3; + /* Objects are represented by 8 byte pointers. */ + cvCode = cvReg.cv8; } - assert bytes >= 0 && bytes < javaToCvRegisters[javaReg].length; - short cvreg = javaToCvRegisters[javaReg][bytes]; - assert cvreg != -1; - return cvreg; + assert cvCode != -1; + return cvCode; } } From 0947272549f5b3c8a773332ef151ea58e1b9c831 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Wed, 4 Sep 2024 06:12:30 -0400 Subject: [PATCH 20/48] changes for Graal style gate --- .../oracle/objectfile/pecoff/cv/CVUtil.java | 72 ++++++++++--------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java index 0bcdcab36a5b..663cb918dcb3 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java @@ -292,6 +292,7 @@ static class CvRegDef { final short cv2; final short cv4; final short cv8; + CvRegDef(Register r, short cv1, short cv2, short cv4, short cv8) { this.register = r; this.cv1 = cv1; @@ -299,6 +300,7 @@ static class CvRegDef { this.cv4 = cv4; this.cv8 = cv8; } + CvRegDef(Register r, short cv4, short cv8) { this.register = r; this.cv1 = -1; @@ -308,43 +310,43 @@ static class CvRegDef { } } - /* First index is AMD64.(register).number, second is 1,2,4,8 bytes. */ + /* List of Graal assignable registers and CodeView register IDs. */ private static final CvRegDef[] compactRegDefs = { - /* 8, 16, 32, 64 bits */ - new CvRegDef(AMD64.rax, CV_AMD64_AL, CV_AMD64_AX, CV_AMD64_EAX, CV_AMD64_RAX), /* rax=0 */ - new CvRegDef(AMD64.rcx, CV_AMD64_CL, CV_AMD64_CX, CV_AMD64_ECX, CV_AMD64_RCX), /* rcx */ - new CvRegDef(AMD64.rdx, CV_AMD64_DL, CV_AMD64_DX, CV_AMD64_EDX, CV_AMD64_RDX), /* rdx */ - new CvRegDef(AMD64.rbx, CV_AMD64_BL, CV_AMD64_BX, CV_AMD64_EBX, CV_AMD64_RBX), /* rbx */ - new CvRegDef(AMD64.rsp, CV_AMD64_SPL, CV_AMD64_SP, CV_AMD64_ESP, CV_AMD64_RSP), /* rsp */ - new CvRegDef(AMD64.rbp, CV_AMD64_BPL, CV_AMD64_BP, CV_AMD64_EBP, CV_AMD64_RBP), /* rbp */ - new CvRegDef(AMD64.rsi, CV_AMD64_SIL, CV_AMD64_SI, CV_AMD64_ESI, CV_AMD64_RSI), /* rsi */ - new CvRegDef(AMD64.rdi, CV_AMD64_DIL, CV_AMD64_DI, CV_AMD64_EDI, CV_AMD64_RDI), /* rdi */ - new CvRegDef(AMD64.r8, CV_AMD64_R8B, CV_AMD64_R8W, CV_AMD64_R8D, CV_AMD64_R8), /* r8 */ - new CvRegDef(AMD64.r9, CV_AMD64_R9B, CV_AMD64_R9W, CV_AMD64_R9D, CV_AMD64_R9), /* r9 */ - new CvRegDef(AMD64.r10, CV_AMD64_R10B, CV_AMD64_R10W, CV_AMD64_R10D, CV_AMD64_R10), /* r10 */ - new CvRegDef(AMD64.r11, CV_AMD64_R11B, CV_AMD64_R11W, CV_AMD64_R11D, CV_AMD64_R11), /* r11 */ - new CvRegDef(AMD64.r12, CV_AMD64_R12B, CV_AMD64_R12W, CV_AMD64_R12D, CV_AMD64_R12), /* r12 */ - new CvRegDef(AMD64.r13, CV_AMD64_R13B, CV_AMD64_R13W, CV_AMD64_R13D, CV_AMD64_R13), /* r13 */ - new CvRegDef(AMD64.r14, CV_AMD64_R14B, CV_AMD64_R14W, CV_AMD64_R14D, CV_AMD64_R14), /* r14 */ - new CvRegDef(AMD64.r15, CV_AMD64_R15B, CV_AMD64_R15W, CV_AMD64_R15D, CV_AMD64_R15), /* r15 */ - - new CvRegDef(AMD64.xmm0, CV_AMD64_XMM0_0, CV_AMD64_XMM0L), /* xmm0=16 */ - new CvRegDef(AMD64.xmm1, CV_AMD64_XMM1_0, CV_AMD64_XMM1L), /* xmm1 */ - new CvRegDef(AMD64.xmm2, CV_AMD64_XMM2_0, CV_AMD64_XMM2L), /* xmm2 */ - new CvRegDef(AMD64.xmm3, CV_AMD64_XMM3_0, CV_AMD64_XMM3L), /* xmm3 */ - new CvRegDef(AMD64.xmm4, CV_AMD64_XMM4_0, CV_AMD64_XMM4L), /* xmm4 */ - new CvRegDef(AMD64.xmm5, CV_AMD64_XMM5_0, CV_AMD64_XMM5L), /* xmm5 */ - new CvRegDef(AMD64.xmm6, CV_AMD64_XMM6_0, CV_AMD64_XMM6L), /* xmm6 */ - new CvRegDef(AMD64.xmm7, CV_AMD64_XMM7_0, CV_AMD64_XMM7L), /* xmm7=23 */ + /* 8, 16, 32, 64 bits */ + new CvRegDef(AMD64.rax, CV_AMD64_AL, CV_AMD64_AX, CV_AMD64_EAX, CV_AMD64_RAX), + new CvRegDef(AMD64.rcx, CV_AMD64_CL, CV_AMD64_CX, CV_AMD64_ECX, CV_AMD64_RCX), + new CvRegDef(AMD64.rdx, CV_AMD64_DL, CV_AMD64_DX, CV_AMD64_EDX, CV_AMD64_RDX), + new CvRegDef(AMD64.rbx, CV_AMD64_BL, CV_AMD64_BX, CV_AMD64_EBX, CV_AMD64_RBX), + new CvRegDef(AMD64.rsp, CV_AMD64_SPL, CV_AMD64_SP, CV_AMD64_ESP, CV_AMD64_RSP), + new CvRegDef(AMD64.rbp, CV_AMD64_BPL, CV_AMD64_BP, CV_AMD64_EBP, CV_AMD64_RBP), + new CvRegDef(AMD64.rsi, CV_AMD64_SIL, CV_AMD64_SI, CV_AMD64_ESI, CV_AMD64_RSI), + new CvRegDef(AMD64.rdi, CV_AMD64_DIL, CV_AMD64_DI, CV_AMD64_EDI, CV_AMD64_RDI), + new CvRegDef(AMD64.r8, CV_AMD64_R8B, CV_AMD64_R8W, CV_AMD64_R8D, CV_AMD64_R8), + new CvRegDef(AMD64.r9, CV_AMD64_R9B, CV_AMD64_R9W, CV_AMD64_R9D, CV_AMD64_R9), + new CvRegDef(AMD64.r10, CV_AMD64_R10B, CV_AMD64_R10W, CV_AMD64_R10D, CV_AMD64_R10), + new CvRegDef(AMD64.r11, CV_AMD64_R11B, CV_AMD64_R11W, CV_AMD64_R11D, CV_AMD64_R11), + new CvRegDef(AMD64.r12, CV_AMD64_R12B, CV_AMD64_R12W, CV_AMD64_R12D, CV_AMD64_R12), + new CvRegDef(AMD64.r13, CV_AMD64_R13B, CV_AMD64_R13W, CV_AMD64_R13D, CV_AMD64_R13), + new CvRegDef(AMD64.r14, CV_AMD64_R14B, CV_AMD64_R14W, CV_AMD64_R14D, CV_AMD64_R14), + new CvRegDef(AMD64.r15, CV_AMD64_R15B, CV_AMD64_R15W, CV_AMD64_R15D, CV_AMD64_R15), - new CvRegDef(AMD64.xmm8, CV_AMD64_XMM8_0, CV_AMD64_XMM8L), /* xmm8=24 */ - new CvRegDef(AMD64.xmm9, CV_AMD64_XMM9_0, CV_AMD64_XMM9L), /* xmm9 */ - new CvRegDef(AMD64.xmm10, CV_AMD64_XMM10_0, CV_AMD64_XMM10L), /* xmm10 */ - new CvRegDef(AMD64.xmm11, CV_AMD64_XMM11_0, CV_AMD64_XMM11L), /* xmm11 */ - new CvRegDef(AMD64.xmm12, CV_AMD64_XMM12_0, CV_AMD64_XMM12L), /* xmm12 */ - new CvRegDef(AMD64.xmm13, CV_AMD64_XMM13_0, CV_AMD64_XMM13L), /* xmm13 */ - new CvRegDef(AMD64.xmm14, CV_AMD64_XMM14_0, CV_AMD64_XMM14L), /* xmm14 */ - new CvRegDef(AMD64.xmm15, CV_AMD64_XMM15_0, CV_AMD64_XMM15L), /* xmm15 */ + /* 32, 64 bits */ + new CvRegDef(AMD64.xmm0, CV_AMD64_XMM0_0, CV_AMD64_XMM0L), /* xmm0=16 */ + new CvRegDef(AMD64.xmm1, CV_AMD64_XMM1_0, CV_AMD64_XMM1L), + new CvRegDef(AMD64.xmm2, CV_AMD64_XMM2_0, CV_AMD64_XMM2L), + new CvRegDef(AMD64.xmm3, CV_AMD64_XMM3_0, CV_AMD64_XMM3L), + new CvRegDef(AMD64.xmm4, CV_AMD64_XMM4_0, CV_AMD64_XMM4L), + new CvRegDef(AMD64.xmm5, CV_AMD64_XMM5_0, CV_AMD64_XMM5L), + new CvRegDef(AMD64.xmm6, CV_AMD64_XMM6_0, CV_AMD64_XMM6L), + new CvRegDef(AMD64.xmm7, CV_AMD64_XMM7_0, CV_AMD64_XMM7L), + new CvRegDef(AMD64.xmm8, CV_AMD64_XMM8_0, CV_AMD64_XMM8L), + new CvRegDef(AMD64.xmm9, CV_AMD64_XMM9_0, CV_AMD64_XMM9L), + new CvRegDef(AMD64.xmm10, CV_AMD64_XMM10_0, CV_AMD64_XMM10L), + new CvRegDef(AMD64.xmm11, CV_AMD64_XMM11_0, CV_AMD64_XMM11L), + new CvRegDef(AMD64.xmm12, CV_AMD64_XMM12_0, CV_AMD64_XMM12L), + new CvRegDef(AMD64.xmm13, CV_AMD64_XMM13_0, CV_AMD64_XMM13L), + new CvRegDef(AMD64.xmm14, CV_AMD64_XMM14_0, CV_AMD64_XMM14L), + new CvRegDef(AMD64.xmm15, CV_AMD64_XMM15_0, CV_AMD64_XMM15L), }; private static final CvRegDef[] javaToCvRegisters = new CvRegDef[AMD64.xmm15.number + 1]; From d91bd40f2581d3da08dcd57adfd91c84f5f72710 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Thu, 31 Oct 2024 20:24:59 +0100 Subject: [PATCH 21/48] add CVRegisterUtil --- .../objectfile/pecoff/cv/CVConstants.java | 134 --------- .../pecoff/cv/CVLineRecordBuilder.java | 2 +- .../pecoff/cv/CVSymbolSubsectionBuilder.java | 14 +- .../oracle/objectfile/pecoff/cv/CVUtil.java | 205 -------------- .../objectfile/pecoff/cv/CvRegisterUtil.java | 257 ++++++++++++++++++ 5 files changed, 267 insertions(+), 345 deletions(-) create mode 100644 substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CvRegisterUtil.java diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVConstants.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVConstants.java index 9d3edef0bcbc..5465da967165 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVConstants.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVConstants.java @@ -35,138 +35,4 @@ public abstract class CVConstants { /* CodeView section header signature */ static final int CV_SIGNATURE_C13 = 4; - - /* Register definitions */ - - /* 8 bit registers. */ - static final short CV_AMD64_R8B = 344; - static final short CV_AMD64_R9B = 345; - static final short CV_AMD64_R10B = 346; - static final short CV_AMD64_R11B = 347; - static final short CV_AMD64_R12B = 348; - static final short CV_AMD64_R13B = 349; - static final short CV_AMD64_R14B = 350; - static final short CV_AMD64_R15B = 351; - - static final short CV_AMD64_AL = 1; - static final short CV_AMD64_CL = 2; - static final short CV_AMD64_DL = 3; - static final short CV_AMD64_BL = 4; - - static final short CV_AMD64_SIL = 324; - static final short CV_AMD64_DIL = 325; - static final short CV_AMD64_BPL = 326; - static final short CV_AMD64_SPL = 327; - - /* 16 bit registers. */ - static final short CV_AMD64_R8W = 352; - static final short CV_AMD64_R9W = 353; - static final short CV_AMD64_R10W = 354; - static final short CV_AMD64_R11W = 355; - static final short CV_AMD64_R12W = 356; - static final short CV_AMD64_R13W = 357; - static final short CV_AMD64_R14W = 358; - static final short CV_AMD64_R15W = 359; - - static final short CV_AMD64_AX = 9; - static final short CV_AMD64_CX = 10; - static final short CV_AMD64_DX = 11; - static final short CV_AMD64_BX = 12; - static final short CV_AMD64_SP = 13; - static final short CV_AMD64_BP = 14; - static final short CV_AMD64_SI = 15; - static final short CV_AMD64_DI = 16; - - /* 32 bit registers. */ - static final short CV_AMD64_R8D = 360; - static final short CV_AMD64_R9D = 361; - static final short CV_AMD64_R10D = 362; - static final short CV_AMD64_R11D = 363; - static final short CV_AMD64_R12D = 364; - static final short CV_AMD64_R13D = 365; - static final short CV_AMD64_R14D = 366; - static final short CV_AMD64_R15D = 367; - - static final short CV_AMD64_EAX = 17; - static final short CV_AMD64_ECX = 18; - static final short CV_AMD64_EDX = 19; - static final short CV_AMD64_EBX = 20; - static final short CV_AMD64_ESP = 21; - static final short CV_AMD64_EBP = 22; - static final short CV_AMD64_ESI = 23; - static final short CV_AMD64_EDI = 24; - - /* 64 bit registers. */ - static final short CV_AMD64_RAX = 328; - static final short CV_AMD64_RBX = 329; - static final short CV_AMD64_RCX = 330; - static final short CV_AMD64_RDX = 331; - static final short CV_AMD64_RSI = 332; - static final short CV_AMD64_RDI = 333; - static final short CV_AMD64_RBP = 334; - static final short CV_AMD64_RSP = 335; - - static final short CV_AMD64_R8 = 336; - static final short CV_AMD64_R9 = 337; - static final short CV_AMD64_R10 = 338; - static final short CV_AMD64_R11 = 339; - static final short CV_AMD64_R12 = 340; - static final short CV_AMD64_R13 = 341; - static final short CV_AMD64_R14 = 342; - static final short CV_AMD64_R15 = 343; - - /* FP registers. */ - static final short CV_AMD64_XMM0 = 154; - static final short CV_AMD64_XMM1 = 155; - static final short CV_AMD64_XMM2 = 156; - static final short CV_AMD64_XMM3 = 157; - static final short CV_AMD64_XMM4 = 158; - static final short CV_AMD64_XMM5 = 159; - static final short CV_AMD64_XMM6 = 160; - static final short CV_AMD64_XMM7 = 161; - - static final short CV_AMD64_XMM8 = 252; - static final short CV_AMD64_XMM9 = 253; - static final short CV_AMD64_XMM10 = 254; - static final short CV_AMD64_XMM11 = 255; - static final short CV_AMD64_XMM12 = 256; - static final short CV_AMD64_XMM13 = 257; - static final short CV_AMD64_XMM14 = 258; - static final short CV_AMD64_XMM15 = 259; - - static final short CV_AMD64_XMM0_0 = 162; - static final short CV_AMD64_XMM1_0 = 166; - static final short CV_AMD64_XMM2_0 = 170; - static final short CV_AMD64_XMM3_0 = 174; - static final short CV_AMD64_XMM4_0 = 178; - static final short CV_AMD64_XMM5_0 = 182; - static final short CV_AMD64_XMM6_0 = 186; - static final short CV_AMD64_XMM7_0 = 190; - - static final short CV_AMD64_XMM8_0 = 260; - static final short CV_AMD64_XMM9_0 = 261; - static final short CV_AMD64_XMM10_0 = 262; - static final short CV_AMD64_XMM11_0 = 263; - static final short CV_AMD64_XMM12_0 = 264; - static final short CV_AMD64_XMM13_0 = 265; - static final short CV_AMD64_XMM14_0 = 266; - static final short CV_AMD64_XMM15_0 = 267; - - static final short CV_AMD64_XMM0L = 194; - static final short CV_AMD64_XMM1L = 195; - static final short CV_AMD64_XMM2L = 196; - static final short CV_AMD64_XMM3L = 197; - static final short CV_AMD64_XMM4L = 198; - static final short CV_AMD64_XMM5L = 199; - static final short CV_AMD64_XMM6L = 200; - static final short CV_AMD64_XMM7L = 201; - - static final short CV_AMD64_XMM8L = 292; - static final short CV_AMD64_XMM9L = 293; - static final short CV_AMD64_XMM10L = 294; - static final short CV_AMD64_XMM11L = 295; - static final short CV_AMD64_XMM12L = 296; - static final short CV_AMD64_XMM13L = 297; - static final short CV_AMD64_XMM14L = 298; - static final short CV_AMD64_XMM15L = 299; } diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVLineRecordBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVLineRecordBuilder.java index dd7f777b3bbe..264621b34349 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVLineRecordBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVLineRecordBuilder.java @@ -101,7 +101,7 @@ private void processRange(Range range) { lineRecord.addNewFile(fileId); } - /* Add line record. */ + /* Add line record. Address is relative to start of function. */ int lineLoAddr = range.getLo() - compiledEntry.getPrimary().getLo(); int line = Math.max(range.getLine(), 1); debug(" processRange: addNewLine: 0x%05x-0x%05x %s", lineLoAddr, range.getHi() - compiledEntry.getPrimary().getLo(), line); diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java index 26b9a43829c6..9a9fa9e17896 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java @@ -46,10 +46,10 @@ import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugLocalValueInfo.LocalKind.REGISTER; import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugLocalValueInfo.LocalKind.STACKSLOT; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R8; import static com.oracle.objectfile.pecoff.cv.CVSymbolSubrecord.CVSymbolFrameProcRecord.FRAME_LOCAL_BP; import static com.oracle.objectfile.pecoff.cv.CVSymbolSubrecord.CVSymbolFrameProcRecord.FRAME_PARAM_BP; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.MAX_PRIMITIVE; +import static com.oracle.objectfile.pecoff.cv.CvRegisterUtil.CV_AMD64_R8; final class CVSymbolSubsectionBuilder { @@ -227,15 +227,19 @@ void emitLocal(DebugInfoProvider.DebugLocalInfo info, HashMap= 0) { + currentRecord = new CVSymbolSubrecord.CVSymbolDefRangeRegisterRecord(cvDebugInfo, procName, subrange.getLo() - range.getLo(), (short) (subrange.getHi() - subrange.getLo()), cvreg); + addSymbolRecord(currentRecord); + } } else if (value.localKind() == STACKSLOT) { currentRecord = new CVSymbolSubrecord.CVSymbolDefRangeFramepointerRel(cvDebugInfo, procName, subrange.getLo() - range.getLo(), (short) (subrange.getHi() - subrange.getLo()), value.stackSlot()); addSymbolRecord(currentRecord); } else if (value.localKind() == CONSTANT) { - /* For now, silently ignore constant definitions an parameters. */ + /* For now, silently ignore constant definitions as parameters. */ /* JavaConstant constant = value.constantValue(); */ } else { /* Unimplemented - this is a surprise. */ diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java index 663cb918dcb3..52f7c27d8242 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java @@ -26,107 +26,8 @@ package com.oracle.objectfile.pecoff.cv; -import com.oracle.objectfile.debugentry.TypeEntry; import com.oracle.objectfile.io.Utf8; -import jdk.vm.ci.amd64.AMD64; -import jdk.vm.ci.code.Register; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_AL; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_AX; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_BL; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_BP; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_BPL; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_BX; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_CL; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_CX; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_DI; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_DIL; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_DL; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_DX; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_EAX; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_EBP; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_EBX; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_ECX; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_EDI; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_EDX; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_ESI; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_ESP; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R10; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R10B; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R10D; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R10W; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R11; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R11B; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R11D; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R11W; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R12; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R12B; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R12D; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R12W; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R13; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R13B; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R13D; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R13W; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R14; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R14B; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R14D; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R14W; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R15; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R15B; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R15D; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R15W; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R8; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R8B; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R8D; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R8W; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R9; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R9B; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R9D; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R9W; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_RAX; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_RBP; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_RBX; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_RCX; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_RDI; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_RDX; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_RSI; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_RSP; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_SI; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_SIL; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_SP; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_SPL; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM0L; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM0_0; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM10L; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM10_0; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM11L; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM11_0; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM12L; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM12_0; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM13L; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM13_0; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM14L; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM14_0; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM15L; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM15_0; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM1L; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM1_0; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM2L; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM2_0; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM3L; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM3_0; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM4L; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM4_0; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM5L; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM5_0; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM6L; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM6_0; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM7L; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM7_0; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM8L; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM8_0; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM9L; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_XMM9_0; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_CHAR; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_LONG; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.LF_QUADWORD; @@ -285,110 +186,4 @@ static int align4(int initialPos) { } return pos; } - - static class CvRegDef { - final Register register; - final short cv1; - final short cv2; - final short cv4; - final short cv8; - - CvRegDef(Register r, short cv1, short cv2, short cv4, short cv8) { - this.register = r; - this.cv1 = cv1; - this.cv2 = cv2; - this.cv4 = cv4; - this.cv8 = cv8; - } - - CvRegDef(Register r, short cv4, short cv8) { - this.register = r; - this.cv1 = -1; - this.cv2 = -2; - this.cv4 = cv4; - this.cv8 = cv8; - } - } - - /* List of Graal assignable registers and CodeView register IDs. */ - private static final CvRegDef[] compactRegDefs = { - /* 8, 16, 32, 64 bits */ - new CvRegDef(AMD64.rax, CV_AMD64_AL, CV_AMD64_AX, CV_AMD64_EAX, CV_AMD64_RAX), - new CvRegDef(AMD64.rcx, CV_AMD64_CL, CV_AMD64_CX, CV_AMD64_ECX, CV_AMD64_RCX), - new CvRegDef(AMD64.rdx, CV_AMD64_DL, CV_AMD64_DX, CV_AMD64_EDX, CV_AMD64_RDX), - new CvRegDef(AMD64.rbx, CV_AMD64_BL, CV_AMD64_BX, CV_AMD64_EBX, CV_AMD64_RBX), - new CvRegDef(AMD64.rsp, CV_AMD64_SPL, CV_AMD64_SP, CV_AMD64_ESP, CV_AMD64_RSP), - new CvRegDef(AMD64.rbp, CV_AMD64_BPL, CV_AMD64_BP, CV_AMD64_EBP, CV_AMD64_RBP), - new CvRegDef(AMD64.rsi, CV_AMD64_SIL, CV_AMD64_SI, CV_AMD64_ESI, CV_AMD64_RSI), - new CvRegDef(AMD64.rdi, CV_AMD64_DIL, CV_AMD64_DI, CV_AMD64_EDI, CV_AMD64_RDI), - new CvRegDef(AMD64.r8, CV_AMD64_R8B, CV_AMD64_R8W, CV_AMD64_R8D, CV_AMD64_R8), - new CvRegDef(AMD64.r9, CV_AMD64_R9B, CV_AMD64_R9W, CV_AMD64_R9D, CV_AMD64_R9), - new CvRegDef(AMD64.r10, CV_AMD64_R10B, CV_AMD64_R10W, CV_AMD64_R10D, CV_AMD64_R10), - new CvRegDef(AMD64.r11, CV_AMD64_R11B, CV_AMD64_R11W, CV_AMD64_R11D, CV_AMD64_R11), - new CvRegDef(AMD64.r12, CV_AMD64_R12B, CV_AMD64_R12W, CV_AMD64_R12D, CV_AMD64_R12), - new CvRegDef(AMD64.r13, CV_AMD64_R13B, CV_AMD64_R13W, CV_AMD64_R13D, CV_AMD64_R13), - new CvRegDef(AMD64.r14, CV_AMD64_R14B, CV_AMD64_R14W, CV_AMD64_R14D, CV_AMD64_R14), - new CvRegDef(AMD64.r15, CV_AMD64_R15B, CV_AMD64_R15W, CV_AMD64_R15D, CV_AMD64_R15), - - /* 32, 64 bits */ - new CvRegDef(AMD64.xmm0, CV_AMD64_XMM0_0, CV_AMD64_XMM0L), /* xmm0=16 */ - new CvRegDef(AMD64.xmm1, CV_AMD64_XMM1_0, CV_AMD64_XMM1L), - new CvRegDef(AMD64.xmm2, CV_AMD64_XMM2_0, CV_AMD64_XMM2L), - new CvRegDef(AMD64.xmm3, CV_AMD64_XMM3_0, CV_AMD64_XMM3L), - new CvRegDef(AMD64.xmm4, CV_AMD64_XMM4_0, CV_AMD64_XMM4L), - new CvRegDef(AMD64.xmm5, CV_AMD64_XMM5_0, CV_AMD64_XMM5L), - new CvRegDef(AMD64.xmm6, CV_AMD64_XMM6_0, CV_AMD64_XMM6L), - new CvRegDef(AMD64.xmm7, CV_AMD64_XMM7_0, CV_AMD64_XMM7L), - new CvRegDef(AMD64.xmm8, CV_AMD64_XMM8_0, CV_AMD64_XMM8L), - new CvRegDef(AMD64.xmm9, CV_AMD64_XMM9_0, CV_AMD64_XMM9L), - new CvRegDef(AMD64.xmm10, CV_AMD64_XMM10_0, CV_AMD64_XMM10L), - new CvRegDef(AMD64.xmm11, CV_AMD64_XMM11_0, CV_AMD64_XMM11L), - new CvRegDef(AMD64.xmm12, CV_AMD64_XMM12_0, CV_AMD64_XMM12L), - new CvRegDef(AMD64.xmm13, CV_AMD64_XMM13_0, CV_AMD64_XMM13L), - new CvRegDef(AMD64.xmm14, CV_AMD64_XMM14_0, CV_AMD64_XMM14L), - new CvRegDef(AMD64.xmm15, CV_AMD64_XMM15_0, CV_AMD64_XMM15L), - }; - - private static final CvRegDef[] javaToCvRegisters = new CvRegDef[AMD64.xmm15.number + 1]; - - static { - for (CvRegDef def : compactRegDefs) { - assert 0 <= def.register.number && def.register.number <= AMD64.xmm15.number; - javaToCvRegisters[def.register.number] = def; - } - } - - /* convert a Java register number to a CodeView register code */ - /* thos Codeview code depends upon the register type and size */ - static short getCVRegister(int javaReg, TypeEntry typeEntry) { - assert 0 <= javaReg && javaReg <= AMD64.xmm15.number; - CvRegDef cvReg = javaToCvRegisters[javaReg]; - assert cvReg != null; - - final short cvCode; - if (typeEntry.isPrimitive()) { - switch (typeEntry.getSize()) { - case 1: - cvCode = cvReg.cv1; - break; - case 2: - cvCode = cvReg.cv2; - break; - case 4: - cvCode = cvReg.cv4; - break; - case 8: - cvCode = cvReg.cv8; - break; - default: - cvCode = -1; - break; - } - } else { - /* Objects are represented by 8 byte pointers. */ - cvCode = cvReg.cv8; - } - assert cvCode != -1; - return cvCode; - } } diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CvRegisterUtil.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CvRegisterUtil.java new file mode 100644 index 000000000000..3e5260c64595 --- /dev/null +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CvRegisterUtil.java @@ -0,0 +1,257 @@ +package com.oracle.objectfile.pecoff.cv; + +import com.oracle.objectfile.debugentry.TypeEntry; +import jdk.vm.ci.amd64.AMD64; +import jdk.vm.ci.code.Register; + +public class CvRegisterUtil { + + private static final int MAX_JAVA_REGISTER_NUMBER = AMD64.xmm15.number; + + /* Register definitions */ + + /* 8 bit registers. */ + private static final short CV_AMD64_R8B = 344; + private static final short CV_AMD64_R9B = 345; + private static final short CV_AMD64_R10B = 346; + private static final short CV_AMD64_R11B = 347; + private static final short CV_AMD64_R12B = 348; + private static final short CV_AMD64_R13B = 349; + private static final short CV_AMD64_R14B = 350; + private static final short CV_AMD64_R15B = 351; + + private static final short CV_AMD64_AL = 1; + private static final short CV_AMD64_CL = 2; + private static final short CV_AMD64_DL = 3; + private static final short CV_AMD64_BL = 4; + + private static final short CV_AMD64_SIL = 324; + private static final short CV_AMD64_DIL = 325; + private static final short CV_AMD64_BPL = 326; + private static final short CV_AMD64_SPL = 327; + + /* 16 bit registers. */ + private static final short CV_AMD64_R8W = 352; + private static final short CV_AMD64_R9W = 353; + private static final short CV_AMD64_R10W = 354; + private static final short CV_AMD64_R11W = 355; + private static final short CV_AMD64_R12W = 356; + private static final short CV_AMD64_R13W = 357; + private static final short CV_AMD64_R14W = 358; + private static final short CV_AMD64_R15W = 359; + + private static final short CV_AMD64_AX = 9; + private static final short CV_AMD64_CX = 10; + private static final short CV_AMD64_DX = 11; + private static final short CV_AMD64_BX = 12; + private static final short CV_AMD64_SP = 13; + private static final short CV_AMD64_BP = 14; + private static final short CV_AMD64_SI = 15; + private static final short CV_AMD64_DI = 16; + + /* 32 bit registers. */ + private static final short CV_AMD64_R8D = 360; + private static final short CV_AMD64_R9D = 361; + private static final short CV_AMD64_R10D = 362; + private static final short CV_AMD64_R11D = 363; + private static final short CV_AMD64_R12D = 364; + private static final short CV_AMD64_R13D = 365; + private static final short CV_AMD64_R14D = 366; + private static final short CV_AMD64_R15D = 367; + + private static final short CV_AMD64_EAX = 17; + private static final short CV_AMD64_ECX = 18; + private static final short CV_AMD64_EDX = 19; + private static final short CV_AMD64_EBX = 20; + private static final short CV_AMD64_ESP = 21; + private static final short CV_AMD64_EBP = 22; + private static final short CV_AMD64_ESI = 23; + private static final short CV_AMD64_EDI = 24; + + /* 64 bit registers. */ + private static final short CV_AMD64_RAX = 328; + private static final short CV_AMD64_RBX = 329; + private static final short CV_AMD64_RCX = 330; + private static final short CV_AMD64_RDX = 331; + private static final short CV_AMD64_RSI = 332; + private static final short CV_AMD64_RDI = 333; + private static final short CV_AMD64_RBP = 334; + private static final short CV_AMD64_RSP = 335; + + static final short CV_AMD64_R8 = 336; + private static final short CV_AMD64_R9 = 337; + private static final short CV_AMD64_R10 = 338; + private static final short CV_AMD64_R11 = 339; + private static final short CV_AMD64_R12 = 340; + private static final short CV_AMD64_R13 = 341; + private static final short CV_AMD64_R14 = 342; + private static final short CV_AMD64_R15 = 343; + + /* FP registers. */ + private static final short CV_AMD64_XMM0 = 154; + private static final short CV_AMD64_XMM1 = 155; + private static final short CV_AMD64_XMM2 = 156; + private static final short CV_AMD64_XMM3 = 157; + private static final short CV_AMD64_XMM4 = 158; + private static final short CV_AMD64_XMM5 = 159; + private static final short CV_AMD64_XMM6 = 160; + private static final short CV_AMD64_XMM7 = 161; + + private static final short CV_AMD64_XMM8 = 252; + private static final short CV_AMD64_XMM9 = 253; + private static final short CV_AMD64_XMM10 = 254; + private static final short CV_AMD64_XMM11 = 255; + private static final short CV_AMD64_XMM12 = 256; + private static final short CV_AMD64_XMM13 = 257; + private static final short CV_AMD64_XMM14 = 258; + private static final short CV_AMD64_XMM15 = 259; + + private static final short CV_AMD64_XMM0_0 = 162; + private static final short CV_AMD64_XMM1_0 = 166; + private static final short CV_AMD64_XMM2_0 = 170; + private static final short CV_AMD64_XMM3_0 = 174; + private static final short CV_AMD64_XMM4_0 = 178; + private static final short CV_AMD64_XMM5_0 = 182; + private static final short CV_AMD64_XMM6_0 = 186; + private static final short CV_AMD64_XMM7_0 = 190; + + private static final short CV_AMD64_XMM8_0 = 260; + private static final short CV_AMD64_XMM9_0 = 261; + private static final short CV_AMD64_XMM10_0 = 262; + private static final short CV_AMD64_XMM11_0 = 263; + private static final short CV_AMD64_XMM12_0 = 264; + private static final short CV_AMD64_XMM13_0 = 265; + private static final short CV_AMD64_XMM14_0 = 266; + private static final short CV_AMD64_XMM15_0 = 267; + + private static final short CV_AMD64_XMM0L = 194; + private static final short CV_AMD64_XMM1L = 195; + private static final short CV_AMD64_XMM2L = 196; + private static final short CV_AMD64_XMM3L = 197; + private static final short CV_AMD64_XMM4L = 198; + private static final short CV_AMD64_XMM5L = 199; + private static final short CV_AMD64_XMM6L = 200; + private static final short CV_AMD64_XMM7L = 201; + + private static final short CV_AMD64_XMM8L = 292; + private static final short CV_AMD64_XMM9L = 293; + private static final short CV_AMD64_XMM10L = 294; + private static final short CV_AMD64_XMM11L = 295; + private static final short CV_AMD64_XMM12L = 296; + private static final short CV_AMD64_XMM13L = 297; + private static final short CV_AMD64_XMM14L = 298; + private static final short CV_AMD64_XMM15L = 299; + + private static class CvRegDef { + final Register register; + final short cv1; + final short cv2; + final short cv4; + final short cv8; + + CvRegDef(Register r, short cv1, short cv2, short cv4, short cv8) { + this.register = r; + this.cv1 = cv1; + this.cv2 = cv2; + this.cv4 = cv4; + this.cv8 = cv8; + } + + CvRegDef(Register r, short cv4, short cv8) { + this.register = r; + this.cv1 = -1; + this.cv2 = -1; + this.cv4 = cv4; + this.cv8 = cv8; + } + } + + /* List of Graal assignable registers and CodeView register IDs. */ + private static final CvRegDef[] compactRegDefs = { + /* 8, 16, 32, 64 bits */ + new CvRegDef(AMD64.rax, CV_AMD64_AL, CV_AMD64_AX, CV_AMD64_EAX, CV_AMD64_RAX), + new CvRegDef(AMD64.rcx, CV_AMD64_CL, CV_AMD64_CX, CV_AMD64_ECX, CV_AMD64_RCX), + new CvRegDef(AMD64.rdx, CV_AMD64_DL, CV_AMD64_DX, CV_AMD64_EDX, CV_AMD64_RDX), + new CvRegDef(AMD64.rbx, CV_AMD64_BL, CV_AMD64_BX, CV_AMD64_EBX, CV_AMD64_RBX), + new CvRegDef(AMD64.rsp, CV_AMD64_SPL, CV_AMD64_SP, CV_AMD64_ESP, CV_AMD64_RSP), + new CvRegDef(AMD64.rbp, CV_AMD64_BPL, CV_AMD64_BP, CV_AMD64_EBP, CV_AMD64_RBP), + new CvRegDef(AMD64.rsi, CV_AMD64_SIL, CV_AMD64_SI, CV_AMD64_ESI, CV_AMD64_RSI), + new CvRegDef(AMD64.rdi, CV_AMD64_DIL, CV_AMD64_DI, CV_AMD64_EDI, CV_AMD64_RDI), + new CvRegDef(AMD64.r8, CV_AMD64_R8B, CV_AMD64_R8W, CV_AMD64_R8D, CV_AMD64_R8), + new CvRegDef(AMD64.r9, CV_AMD64_R9B, CV_AMD64_R9W, CV_AMD64_R9D, CV_AMD64_R9), + new CvRegDef(AMD64.r10, CV_AMD64_R10B, CV_AMD64_R10W, CV_AMD64_R10D, CV_AMD64_R10), + new CvRegDef(AMD64.r11, CV_AMD64_R11B, CV_AMD64_R11W, CV_AMD64_R11D, CV_AMD64_R11), + new CvRegDef(AMD64.r12, CV_AMD64_R12B, CV_AMD64_R12W, CV_AMD64_R12D, CV_AMD64_R12), + new CvRegDef(AMD64.r13, CV_AMD64_R13B, CV_AMD64_R13W, CV_AMD64_R13D, CV_AMD64_R13), + new CvRegDef(AMD64.r14, CV_AMD64_R14B, CV_AMD64_R14W, CV_AMD64_R14D, CV_AMD64_R14), + new CvRegDef(AMD64.r15, CV_AMD64_R15B, CV_AMD64_R15W, CV_AMD64_R15D, CV_AMD64_R15), + + /* 32, 64 bits */ + new CvRegDef(AMD64.xmm0, CV_AMD64_XMM0_0, CV_AMD64_XMM0L), /* xmm0=16 */ + new CvRegDef(AMD64.xmm1, CV_AMD64_XMM1_0, CV_AMD64_XMM1L), + new CvRegDef(AMD64.xmm2, CV_AMD64_XMM2_0, CV_AMD64_XMM2L), + new CvRegDef(AMD64.xmm3, CV_AMD64_XMM3_0, CV_AMD64_XMM3L), + new CvRegDef(AMD64.xmm4, CV_AMD64_XMM4_0, CV_AMD64_XMM4L), + new CvRegDef(AMD64.xmm5, CV_AMD64_XMM5_0, CV_AMD64_XMM5L), + new CvRegDef(AMD64.xmm6, CV_AMD64_XMM6_0, CV_AMD64_XMM6L), + new CvRegDef(AMD64.xmm7, CV_AMD64_XMM7_0, CV_AMD64_XMM7L), + new CvRegDef(AMD64.xmm8, CV_AMD64_XMM8_0, CV_AMD64_XMM8L), + new CvRegDef(AMD64.xmm9, CV_AMD64_XMM9_0, CV_AMD64_XMM9L), + new CvRegDef(AMD64.xmm10, CV_AMD64_XMM10_0, CV_AMD64_XMM10L), + new CvRegDef(AMD64.xmm11, CV_AMD64_XMM11_0, CV_AMD64_XMM11L), + new CvRegDef(AMD64.xmm12, CV_AMD64_XMM12_0, CV_AMD64_XMM12L), + new CvRegDef(AMD64.xmm13, CV_AMD64_XMM13_0, CV_AMD64_XMM13L), + new CvRegDef(AMD64.xmm14, CV_AMD64_XMM14_0, CV_AMD64_XMM14L), + new CvRegDef(AMD64.xmm15, CV_AMD64_XMM15_0, CV_AMD64_XMM15L), + }; + + private static final CvRegDef[] javaToCvRegisters = new CvRegDef[MAX_JAVA_REGISTER_NUMBER + 1]; + + static { + for (CvRegDef def : compactRegDefs) { + assert 0 <= def.register.number && def.register.number <= MAX_JAVA_REGISTER_NUMBER; + javaToCvRegisters[def.register.number] = def; + } + } + + /* convert a Java register number to a CodeView register code */ + /* thos Codeview code depends upon the register type and size */ + static short getCVRegister(int javaReg, TypeEntry typeEntry) { + assert 0 <= javaReg && javaReg <= MAX_JAVA_REGISTER_NUMBER; + if (javaReg > MAX_JAVA_REGISTER_NUMBER) { + return -1; + } + CvRegDef cvReg = javaToCvRegisters[javaReg]; + assert cvReg != null; + assert cvReg.register.number == javaReg; + if (cvReg == null) { + return -1; + } + + final short cvCode; + if (typeEntry.isPrimitive()) { + switch (typeEntry.getSize()) { + case 1: + cvCode = cvReg.cv1; + break; + case 2: + cvCode = cvReg.cv2; + break; + case 4: + cvCode = cvReg.cv4; + break; + case 8: + cvCode = cvReg.cv8; + break; + default: + cvCode = -1; + break; + } + } else { + /* Objects are represented by 8 byte pointers. */ + cvCode = cvReg.cv8; + } + assert cvCode != -1; + return cvCode; + } +} From 6d00d34e05fd5c2255d2eb12ed8c703e2d8d4ecb Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Thu, 7 Nov 2024 17:22:13 +0100 Subject: [PATCH 22/48] CvRegusterUtil->CVReguiaterUtil --- .../objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java | 4 ++-- .../pecoff/cv/{CvRegisterUtil.java => CVxxRegisterUtil.java} | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/{CvRegisterUtil.java => CVxxRegisterUtil.java} (99%) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java index 9a9fa9e17896..21eb525f6256 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java @@ -49,7 +49,7 @@ import static com.oracle.objectfile.pecoff.cv.CVSymbolSubrecord.CVSymbolFrameProcRecord.FRAME_LOCAL_BP; import static com.oracle.objectfile.pecoff.cv.CVSymbolSubrecord.CVSymbolFrameProcRecord.FRAME_PARAM_BP; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.MAX_PRIMITIVE; -import static com.oracle.objectfile.pecoff.cv.CvRegisterUtil.CV_AMD64_R8; +import static com.oracle.objectfile.pecoff.cv.CVxxRegisterUtil.CV_AMD64_R8; final class CVSymbolSubsectionBuilder { @@ -227,7 +227,7 @@ void emitLocal(DebugInfoProvider.DebugLocalInfo info, HashMap= 0) { diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CvRegisterUtil.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVxxRegisterUtil.java similarity index 99% rename from substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CvRegisterUtil.java rename to substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVxxRegisterUtil.java index 3e5260c64595..ad70b4dbfabe 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CvRegisterUtil.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVxxRegisterUtil.java @@ -4,7 +4,7 @@ import jdk.vm.ci.amd64.AMD64; import jdk.vm.ci.code.Register; -public class CvRegisterUtil { +public class CVxxRegisterUtil { private static final int MAX_JAVA_REGISTER_NUMBER = AMD64.xmm15.number; From 005e14f936181cbd49374ac86d5314c00857f4d3 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Thu, 7 Nov 2024 17:23:15 +0100 Subject: [PATCH 23/48] CvRegusterUtil->CVReguiaterUtil complete --- .../pecoff/cv/{CVxxRegisterUtil.java => CVRegisterUtil.java} | 2 +- .../objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/{CVxxRegisterUtil.java => CVRegisterUtil.java} (99%) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVxxRegisterUtil.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java similarity index 99% rename from substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVxxRegisterUtil.java rename to substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java index ad70b4dbfabe..613629604844 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVxxRegisterUtil.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java @@ -4,7 +4,7 @@ import jdk.vm.ci.amd64.AMD64; import jdk.vm.ci.code.Register; -public class CVxxRegisterUtil { +public class CVRegisterUtil { private static final int MAX_JAVA_REGISTER_NUMBER = AMD64.xmm15.number; diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java index 21eb525f6256..03dade6d413e 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java @@ -49,7 +49,7 @@ import static com.oracle.objectfile.pecoff.cv.CVSymbolSubrecord.CVSymbolFrameProcRecord.FRAME_LOCAL_BP; import static com.oracle.objectfile.pecoff.cv.CVSymbolSubrecord.CVSymbolFrameProcRecord.FRAME_PARAM_BP; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.MAX_PRIMITIVE; -import static com.oracle.objectfile.pecoff.cv.CVxxRegisterUtil.CV_AMD64_R8; +import static com.oracle.objectfile.pecoff.cv.CVRegisterUtil.CV_AMD64_R8; final class CVSymbolSubsectionBuilder { @@ -227,7 +227,7 @@ void emitLocal(DebugInfoProvider.DebugLocalInfo info, HashMap= 0) { From c9323b6dfa3a3d1cc695330b14c9542b65e39f15 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Thu, 7 Nov 2024 17:27:00 +0100 Subject: [PATCH 24/48] remve unused constants --- .../objectfile/pecoff/cv/CVRegisterUtil.java | 24 +++---------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java index 613629604844..4b75e354ada4 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java @@ -88,24 +88,6 @@ public class CVRegisterUtil { private static final short CV_AMD64_R15 = 343; /* FP registers. */ - private static final short CV_AMD64_XMM0 = 154; - private static final short CV_AMD64_XMM1 = 155; - private static final short CV_AMD64_XMM2 = 156; - private static final short CV_AMD64_XMM3 = 157; - private static final short CV_AMD64_XMM4 = 158; - private static final short CV_AMD64_XMM5 = 159; - private static final short CV_AMD64_XMM6 = 160; - private static final short CV_AMD64_XMM7 = 161; - - private static final short CV_AMD64_XMM8 = 252; - private static final short CV_AMD64_XMM9 = 253; - private static final short CV_AMD64_XMM10 = 254; - private static final short CV_AMD64_XMM11 = 255; - private static final short CV_AMD64_XMM12 = 256; - private static final short CV_AMD64_XMM13 = 257; - private static final short CV_AMD64_XMM14 = 258; - private static final short CV_AMD64_XMM15 = 259; - private static final short CV_AMD64_XMM0_0 = 162; private static final short CV_AMD64_XMM1_0 = 166; private static final short CV_AMD64_XMM2_0 = 170; @@ -205,12 +187,12 @@ private static class CvRegDef { new CvRegDef(AMD64.xmm15, CV_AMD64_XMM15_0, CV_AMD64_XMM15L), }; - private static final CvRegDef[] javaToCvRegisters = new CvRegDef[MAX_JAVA_REGISTER_NUMBER + 1]; + private static final CvRegDef[] javaToCVRegisters = new CvRegDef[MAX_JAVA_REGISTER_NUMBER + 1]; static { for (CvRegDef def : compactRegDefs) { assert 0 <= def.register.number && def.register.number <= MAX_JAVA_REGISTER_NUMBER; - javaToCvRegisters[def.register.number] = def; + javaToCVRegisters[def.register.number] = def; } } @@ -221,7 +203,7 @@ static short getCVRegister(int javaReg, TypeEntry typeEntry) { if (javaReg > MAX_JAVA_REGISTER_NUMBER) { return -1; } - CvRegDef cvReg = javaToCvRegisters[javaReg]; + CvRegDef cvReg = javaToCVRegisters[javaReg]; assert cvReg != null; assert cvReg.register.number == javaReg; if (cvReg == null) { From c53323bf8e6ab937f46cccccb250578f3c775a85 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Thu, 7 Nov 2024 19:17:13 +0100 Subject: [PATCH 25/48] style changes from Graal gate --- .../objectfile/pecoff/cv/CVLineRecordBuilder.java | 2 +- .../pecoff/cv/CVSymbolSubsectionBuilder.java | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVLineRecordBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVLineRecordBuilder.java index 264621b34349..58a681c01e59 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVLineRecordBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVLineRecordBuilder.java @@ -101,7 +101,7 @@ private void processRange(Range range) { lineRecord.addNewFile(fileId); } - /* Add line record. Address is relative to start of function. */ + /* Add line record. Address is relative to start of function. */ int lineLoAddr = range.getLo() - compiledEntry.getPrimary().getLo(); int line = Math.max(range.getLine(), 1); debug(" processRange: addNewLine: 0x%05x-0x%05x %s", lineLoAddr, range.getHi() - compiledEntry.getPrimary().getLo(), line); diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java index 03dade6d413e..1762840dc9a8 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java @@ -228,10 +228,17 @@ void emitLocal(DebugInfoProvider.DebugLocalInfo info, HashMap= 0) { - currentRecord = new CVSymbolSubrecord.CVSymbolDefRangeRegisterRecord(cvDebugInfo, procName, subrange.getLo() - range.getLo(), (short) (subrange.getHi() - subrange.getLo()), cvreg); + currentRecord = new CVSymbolSubrecord.CVSymbolDefRangeRegisterRecord(cvDebugInfo, procName, subrange.getLo() - range.getLo(), (short) (subrange.getHi() - subrange.getLo()), + cvreg); addSymbolRecord(currentRecord); } } else if (value.localKind() == STACKSLOT) { From bdebea40eb71fe9a57d630e582ac2e23806230e5 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Thu, 7 Nov 2024 21:05:15 +0100 Subject: [PATCH 26/48] style changes from Eclipseformat --- .../objectfile/pecoff/cv/CVRegisterUtil.java | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java index 4b75e354ada4..bce565aec9ad 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java @@ -150,41 +150,41 @@ private static class CvRegDef { /* List of Graal assignable registers and CodeView register IDs. */ private static final CvRegDef[] compactRegDefs = { - /* 8, 16, 32, 64 bits */ - new CvRegDef(AMD64.rax, CV_AMD64_AL, CV_AMD64_AX, CV_AMD64_EAX, CV_AMD64_RAX), - new CvRegDef(AMD64.rcx, CV_AMD64_CL, CV_AMD64_CX, CV_AMD64_ECX, CV_AMD64_RCX), - new CvRegDef(AMD64.rdx, CV_AMD64_DL, CV_AMD64_DX, CV_AMD64_EDX, CV_AMD64_RDX), - new CvRegDef(AMD64.rbx, CV_AMD64_BL, CV_AMD64_BX, CV_AMD64_EBX, CV_AMD64_RBX), - new CvRegDef(AMD64.rsp, CV_AMD64_SPL, CV_AMD64_SP, CV_AMD64_ESP, CV_AMD64_RSP), - new CvRegDef(AMD64.rbp, CV_AMD64_BPL, CV_AMD64_BP, CV_AMD64_EBP, CV_AMD64_RBP), - new CvRegDef(AMD64.rsi, CV_AMD64_SIL, CV_AMD64_SI, CV_AMD64_ESI, CV_AMD64_RSI), - new CvRegDef(AMD64.rdi, CV_AMD64_DIL, CV_AMD64_DI, CV_AMD64_EDI, CV_AMD64_RDI), - new CvRegDef(AMD64.r8, CV_AMD64_R8B, CV_AMD64_R8W, CV_AMD64_R8D, CV_AMD64_R8), - new CvRegDef(AMD64.r9, CV_AMD64_R9B, CV_AMD64_R9W, CV_AMD64_R9D, CV_AMD64_R9), - new CvRegDef(AMD64.r10, CV_AMD64_R10B, CV_AMD64_R10W, CV_AMD64_R10D, CV_AMD64_R10), - new CvRegDef(AMD64.r11, CV_AMD64_R11B, CV_AMD64_R11W, CV_AMD64_R11D, CV_AMD64_R11), - new CvRegDef(AMD64.r12, CV_AMD64_R12B, CV_AMD64_R12W, CV_AMD64_R12D, CV_AMD64_R12), - new CvRegDef(AMD64.r13, CV_AMD64_R13B, CV_AMD64_R13W, CV_AMD64_R13D, CV_AMD64_R13), - new CvRegDef(AMD64.r14, CV_AMD64_R14B, CV_AMD64_R14W, CV_AMD64_R14D, CV_AMD64_R14), - new CvRegDef(AMD64.r15, CV_AMD64_R15B, CV_AMD64_R15W, CV_AMD64_R15D, CV_AMD64_R15), - - /* 32, 64 bits */ - new CvRegDef(AMD64.xmm0, CV_AMD64_XMM0_0, CV_AMD64_XMM0L), /* xmm0=16 */ - new CvRegDef(AMD64.xmm1, CV_AMD64_XMM1_0, CV_AMD64_XMM1L), - new CvRegDef(AMD64.xmm2, CV_AMD64_XMM2_0, CV_AMD64_XMM2L), - new CvRegDef(AMD64.xmm3, CV_AMD64_XMM3_0, CV_AMD64_XMM3L), - new CvRegDef(AMD64.xmm4, CV_AMD64_XMM4_0, CV_AMD64_XMM4L), - new CvRegDef(AMD64.xmm5, CV_AMD64_XMM5_0, CV_AMD64_XMM5L), - new CvRegDef(AMD64.xmm6, CV_AMD64_XMM6_0, CV_AMD64_XMM6L), - new CvRegDef(AMD64.xmm7, CV_AMD64_XMM7_0, CV_AMD64_XMM7L), - new CvRegDef(AMD64.xmm8, CV_AMD64_XMM8_0, CV_AMD64_XMM8L), - new CvRegDef(AMD64.xmm9, CV_AMD64_XMM9_0, CV_AMD64_XMM9L), - new CvRegDef(AMD64.xmm10, CV_AMD64_XMM10_0, CV_AMD64_XMM10L), - new CvRegDef(AMD64.xmm11, CV_AMD64_XMM11_0, CV_AMD64_XMM11L), - new CvRegDef(AMD64.xmm12, CV_AMD64_XMM12_0, CV_AMD64_XMM12L), - new CvRegDef(AMD64.xmm13, CV_AMD64_XMM13_0, CV_AMD64_XMM13L), - new CvRegDef(AMD64.xmm14, CV_AMD64_XMM14_0, CV_AMD64_XMM14L), - new CvRegDef(AMD64.xmm15, CV_AMD64_XMM15_0, CV_AMD64_XMM15L), + /* 8, 16, 32, 64 bits */ + new CvRegDef(AMD64.rax, CV_AMD64_AL, CV_AMD64_AX, CV_AMD64_EAX, CV_AMD64_RAX), + new CvRegDef(AMD64.rcx, CV_AMD64_CL, CV_AMD64_CX, CV_AMD64_ECX, CV_AMD64_RCX), + new CvRegDef(AMD64.rdx, CV_AMD64_DL, CV_AMD64_DX, CV_AMD64_EDX, CV_AMD64_RDX), + new CvRegDef(AMD64.rbx, CV_AMD64_BL, CV_AMD64_BX, CV_AMD64_EBX, CV_AMD64_RBX), + new CvRegDef(AMD64.rsp, CV_AMD64_SPL, CV_AMD64_SP, CV_AMD64_ESP, CV_AMD64_RSP), + new CvRegDef(AMD64.rbp, CV_AMD64_BPL, CV_AMD64_BP, CV_AMD64_EBP, CV_AMD64_RBP), + new CvRegDef(AMD64.rsi, CV_AMD64_SIL, CV_AMD64_SI, CV_AMD64_ESI, CV_AMD64_RSI), + new CvRegDef(AMD64.rdi, CV_AMD64_DIL, CV_AMD64_DI, CV_AMD64_EDI, CV_AMD64_RDI), + new CvRegDef(AMD64.r8, CV_AMD64_R8B, CV_AMD64_R8W, CV_AMD64_R8D, CV_AMD64_R8), + new CvRegDef(AMD64.r9, CV_AMD64_R9B, CV_AMD64_R9W, CV_AMD64_R9D, CV_AMD64_R9), + new CvRegDef(AMD64.r10, CV_AMD64_R10B, CV_AMD64_R10W, CV_AMD64_R10D, CV_AMD64_R10), + new CvRegDef(AMD64.r11, CV_AMD64_R11B, CV_AMD64_R11W, CV_AMD64_R11D, CV_AMD64_R11), + new CvRegDef(AMD64.r12, CV_AMD64_R12B, CV_AMD64_R12W, CV_AMD64_R12D, CV_AMD64_R12), + new CvRegDef(AMD64.r13, CV_AMD64_R13B, CV_AMD64_R13W, CV_AMD64_R13D, CV_AMD64_R13), + new CvRegDef(AMD64.r14, CV_AMD64_R14B, CV_AMD64_R14W, CV_AMD64_R14D, CV_AMD64_R14), + new CvRegDef(AMD64.r15, CV_AMD64_R15B, CV_AMD64_R15W, CV_AMD64_R15D, CV_AMD64_R15), + + /* 32, 64 bits */ + new CvRegDef(AMD64.xmm0, CV_AMD64_XMM0_0, CV_AMD64_XMM0L), /* xmm0=16 */ + new CvRegDef(AMD64.xmm1, CV_AMD64_XMM1_0, CV_AMD64_XMM1L), + new CvRegDef(AMD64.xmm2, CV_AMD64_XMM2_0, CV_AMD64_XMM2L), + new CvRegDef(AMD64.xmm3, CV_AMD64_XMM3_0, CV_AMD64_XMM3L), + new CvRegDef(AMD64.xmm4, CV_AMD64_XMM4_0, CV_AMD64_XMM4L), + new CvRegDef(AMD64.xmm5, CV_AMD64_XMM5_0, CV_AMD64_XMM5L), + new CvRegDef(AMD64.xmm6, CV_AMD64_XMM6_0, CV_AMD64_XMM6L), + new CvRegDef(AMD64.xmm7, CV_AMD64_XMM7_0, CV_AMD64_XMM7L), + new CvRegDef(AMD64.xmm8, CV_AMD64_XMM8_0, CV_AMD64_XMM8L), + new CvRegDef(AMD64.xmm9, CV_AMD64_XMM9_0, CV_AMD64_XMM9L), + new CvRegDef(AMD64.xmm10, CV_AMD64_XMM10_0, CV_AMD64_XMM10L), + new CvRegDef(AMD64.xmm11, CV_AMD64_XMM11_0, CV_AMD64_XMM11L), + new CvRegDef(AMD64.xmm12, CV_AMD64_XMM12_0, CV_AMD64_XMM12L), + new CvRegDef(AMD64.xmm13, CV_AMD64_XMM13_0, CV_AMD64_XMM13L), + new CvRegDef(AMD64.xmm14, CV_AMD64_XMM14_0, CV_AMD64_XMM14L), + new CvRegDef(AMD64.xmm15, CV_AMD64_XMM15_0, CV_AMD64_XMM15L), }; private static final CvRegDef[] javaToCVRegisters = new CvRegDef[MAX_JAVA_REGISTER_NUMBER + 1]; From d62db1d0d5b5203f0a74dea334551fbea8bc7a5e Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Thu, 7 Nov 2024 21:27:37 +0100 Subject: [PATCH 27/48] update copyright --- .../objectfile/pecoff/cv/CVConstants.java | 4 +-- .../pecoff/cv/CVDebugConstants.java | 4 +-- .../objectfile/pecoff/cv/CVDebugInfo.java | 4 +-- .../pecoff/cv/CVLineRecordBuilder.java | 4 +-- .../objectfile/pecoff/cv/CVRegisterUtil.java | 26 +++++++++++++++++++ .../pecoff/cv/CVSymbolSubrecord.java | 4 +-- .../pecoff/cv/CVSymbolSubsectionBuilder.java | 4 +-- .../objectfile/pecoff/cv/CVTypeRecord.java | 4 +-- .../pecoff/cv/CVTypeSectionBuilder.java | 5 ++-- .../oracle/objectfile/pecoff/cv/CVUtil.java | 4 +-- 10 files changed, 45 insertions(+), 18 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVConstants.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVConstants.java index 5465da967165..6bfad558bb92 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVConstants.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVConstants.java @@ -1,6 +1,6 @@ /* - * Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2020, 2020, Red Hat Inc. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVDebugConstants.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVDebugConstants.java index 95df3802b70f..ce3cee63d78d 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVDebugConstants.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVDebugConstants.java @@ -1,6 +1,6 @@ /* - * Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2020, 2020, Red Hat Inc. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVDebugInfo.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVDebugInfo.java index 27e0efc5cf04..54ad571c0ba8 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVDebugInfo.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVDebugInfo.java @@ -1,6 +1,6 @@ /* - * Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2020, 2020, Red Hat Inc. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVLineRecordBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVLineRecordBuilder.java index 58a681c01e59..87a13a1bde35 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVLineRecordBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVLineRecordBuilder.java @@ -1,6 +1,6 @@ /* - * Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2020, 2020, Red Hat Inc. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java index bce565aec9ad..db016dc0a699 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java @@ -1,3 +1,29 @@ +/* + * Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2024, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + package com.oracle.objectfile.pecoff.cv; import com.oracle.objectfile.debugentry.TypeEntry; diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java index 78fdf6c02415..e728a38c8f20 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java @@ -1,6 +1,6 @@ /* - * Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2020, 2020, Red Hat Inc. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java index 1762840dc9a8..27ed4eaab880 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java @@ -1,6 +1,6 @@ /* - * Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2020, 2020, Red Hat Inc. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeRecord.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeRecord.java index 7174ae597203..c1d0f25c957b 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeRecord.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeRecord.java @@ -1,6 +1,6 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2020, 2021, Red Hat Inc. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java index 525cb8378bd2..d49ea91744c2 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java @@ -1,6 +1,6 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2020, 2021, Red Hat Inc. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package com.oracle.objectfile.pecoff.cv; import com.oracle.objectfile.debugentry.ArrayTypeEntry; diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java index 52f7c27d8242..b70eb8a29084 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVUtil.java @@ -1,6 +1,6 @@ /* - * Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2020, 2020, Red Hat Inc. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it From c4de8ca2e2f7c0bd86db308872a33655639fa3e8 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Thu, 29 May 2025 13:49:23 -0400 Subject: [PATCH 28/48] fix capitalization --- .../objectfile/pecoff/cv/CVRegisterUtil.java | 96 +++++++++++-------- .../pecoff/cv/CVSymbolSubsectionBuilder.java | 11 +-- 2 files changed, 61 insertions(+), 46 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java index db016dc0a699..9ae7f4a1c5eb 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java @@ -1,6 +1,6 @@ /* - * Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2024, 2024, Red Hat Inc. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -114,6 +114,24 @@ public class CVRegisterUtil { private static final short CV_AMD64_R15 = 343; /* FP registers. */ + private static final short CV_AMD64_XMM0 = 154; + private static final short CV_AMD64_XMM1 = 155; + private static final short CV_AMD64_XMM2 = 156; + private static final short CV_AMD64_XMM3 = 157; + private static final short CV_AMD64_XMM4 = 158; + private static final short CV_AMD64_XMM5 = 159; + private static final short CV_AMD64_XMM6 = 160; + private static final short CV_AMD64_XMM7 = 161; + + private static final short CV_AMD64_XMM8 = 252; + private static final short CV_AMD64_XMM9 = 253; + private static final short CV_AMD64_XMM10 = 254; + private static final short CV_AMD64_XMM11 = 255; + private static final short CV_AMD64_XMM12 = 256; + private static final short CV_AMD64_XMM13 = 257; + private static final short CV_AMD64_XMM14 = 258; + private static final short CV_AMD64_XMM15 = 259; + private static final short CV_AMD64_XMM0_0 = 162; private static final short CV_AMD64_XMM1_0 = 166; private static final short CV_AMD64_XMM2_0 = 170; @@ -176,49 +194,49 @@ private static class CvRegDef { /* List of Graal assignable registers and CodeView register IDs. */ private static final CvRegDef[] compactRegDefs = { - /* 8, 16, 32, 64 bits */ - new CvRegDef(AMD64.rax, CV_AMD64_AL, CV_AMD64_AX, CV_AMD64_EAX, CV_AMD64_RAX), - new CvRegDef(AMD64.rcx, CV_AMD64_CL, CV_AMD64_CX, CV_AMD64_ECX, CV_AMD64_RCX), - new CvRegDef(AMD64.rdx, CV_AMD64_DL, CV_AMD64_DX, CV_AMD64_EDX, CV_AMD64_RDX), - new CvRegDef(AMD64.rbx, CV_AMD64_BL, CV_AMD64_BX, CV_AMD64_EBX, CV_AMD64_RBX), - new CvRegDef(AMD64.rsp, CV_AMD64_SPL, CV_AMD64_SP, CV_AMD64_ESP, CV_AMD64_RSP), - new CvRegDef(AMD64.rbp, CV_AMD64_BPL, CV_AMD64_BP, CV_AMD64_EBP, CV_AMD64_RBP), - new CvRegDef(AMD64.rsi, CV_AMD64_SIL, CV_AMD64_SI, CV_AMD64_ESI, CV_AMD64_RSI), - new CvRegDef(AMD64.rdi, CV_AMD64_DIL, CV_AMD64_DI, CV_AMD64_EDI, CV_AMD64_RDI), - new CvRegDef(AMD64.r8, CV_AMD64_R8B, CV_AMD64_R8W, CV_AMD64_R8D, CV_AMD64_R8), - new CvRegDef(AMD64.r9, CV_AMD64_R9B, CV_AMD64_R9W, CV_AMD64_R9D, CV_AMD64_R9), - new CvRegDef(AMD64.r10, CV_AMD64_R10B, CV_AMD64_R10W, CV_AMD64_R10D, CV_AMD64_R10), - new CvRegDef(AMD64.r11, CV_AMD64_R11B, CV_AMD64_R11W, CV_AMD64_R11D, CV_AMD64_R11), - new CvRegDef(AMD64.r12, CV_AMD64_R12B, CV_AMD64_R12W, CV_AMD64_R12D, CV_AMD64_R12), - new CvRegDef(AMD64.r13, CV_AMD64_R13B, CV_AMD64_R13W, CV_AMD64_R13D, CV_AMD64_R13), - new CvRegDef(AMD64.r14, CV_AMD64_R14B, CV_AMD64_R14W, CV_AMD64_R14D, CV_AMD64_R14), - new CvRegDef(AMD64.r15, CV_AMD64_R15B, CV_AMD64_R15W, CV_AMD64_R15D, CV_AMD64_R15), + /* 8, 16, 32, 64 bits */ + new CvRegDef(AMD64.rax, CV_AMD64_AL, CV_AMD64_AX, CV_AMD64_EAX, CV_AMD64_RAX), + new CvRegDef(AMD64.rcx, CV_AMD64_CL, CV_AMD64_CX, CV_AMD64_ECX, CV_AMD64_RCX), + new CvRegDef(AMD64.rdx, CV_AMD64_DL, CV_AMD64_DX, CV_AMD64_EDX, CV_AMD64_RDX), + new CvRegDef(AMD64.rbx, CV_AMD64_BL, CV_AMD64_BX, CV_AMD64_EBX, CV_AMD64_RBX), + new CvRegDef(AMD64.rsp, CV_AMD64_SPL, CV_AMD64_SP, CV_AMD64_ESP, CV_AMD64_RSP), + new CvRegDef(AMD64.rbp, CV_AMD64_BPL, CV_AMD64_BP, CV_AMD64_EBP, CV_AMD64_RBP), + new CvRegDef(AMD64.rsi, CV_AMD64_SIL, CV_AMD64_SI, CV_AMD64_ESI, CV_AMD64_RSI), + new CvRegDef(AMD64.rdi, CV_AMD64_DIL, CV_AMD64_DI, CV_AMD64_EDI, CV_AMD64_RDI), + new CvRegDef(AMD64.r8, CV_AMD64_R8B, CV_AMD64_R8W, CV_AMD64_R8D, CV_AMD64_R8), + new CvRegDef(AMD64.r9, CV_AMD64_R9B, CV_AMD64_R9W, CV_AMD64_R9D, CV_AMD64_R9), + new CvRegDef(AMD64.r10, CV_AMD64_R10B, CV_AMD64_R10W, CV_AMD64_R10D, CV_AMD64_R10), + new CvRegDef(AMD64.r11, CV_AMD64_R11B, CV_AMD64_R11W, CV_AMD64_R11D, CV_AMD64_R11), + new CvRegDef(AMD64.r12, CV_AMD64_R12B, CV_AMD64_R12W, CV_AMD64_R12D, CV_AMD64_R12), + new CvRegDef(AMD64.r13, CV_AMD64_R13B, CV_AMD64_R13W, CV_AMD64_R13D, CV_AMD64_R13), + new CvRegDef(AMD64.r14, CV_AMD64_R14B, CV_AMD64_R14W, CV_AMD64_R14D, CV_AMD64_R14), + new CvRegDef(AMD64.r15, CV_AMD64_R15B, CV_AMD64_R15W, CV_AMD64_R15D, CV_AMD64_R15), - /* 32, 64 bits */ - new CvRegDef(AMD64.xmm0, CV_AMD64_XMM0_0, CV_AMD64_XMM0L), /* xmm0=16 */ - new CvRegDef(AMD64.xmm1, CV_AMD64_XMM1_0, CV_AMD64_XMM1L), - new CvRegDef(AMD64.xmm2, CV_AMD64_XMM2_0, CV_AMD64_XMM2L), - new CvRegDef(AMD64.xmm3, CV_AMD64_XMM3_0, CV_AMD64_XMM3L), - new CvRegDef(AMD64.xmm4, CV_AMD64_XMM4_0, CV_AMD64_XMM4L), - new CvRegDef(AMD64.xmm5, CV_AMD64_XMM5_0, CV_AMD64_XMM5L), - new CvRegDef(AMD64.xmm6, CV_AMD64_XMM6_0, CV_AMD64_XMM6L), - new CvRegDef(AMD64.xmm7, CV_AMD64_XMM7_0, CV_AMD64_XMM7L), - new CvRegDef(AMD64.xmm8, CV_AMD64_XMM8_0, CV_AMD64_XMM8L), - new CvRegDef(AMD64.xmm9, CV_AMD64_XMM9_0, CV_AMD64_XMM9L), - new CvRegDef(AMD64.xmm10, CV_AMD64_XMM10_0, CV_AMD64_XMM10L), - new CvRegDef(AMD64.xmm11, CV_AMD64_XMM11_0, CV_AMD64_XMM11L), - new CvRegDef(AMD64.xmm12, CV_AMD64_XMM12_0, CV_AMD64_XMM12L), - new CvRegDef(AMD64.xmm13, CV_AMD64_XMM13_0, CV_AMD64_XMM13L), - new CvRegDef(AMD64.xmm14, CV_AMD64_XMM14_0, CV_AMD64_XMM14L), - new CvRegDef(AMD64.xmm15, CV_AMD64_XMM15_0, CV_AMD64_XMM15L), + /* 32, 64 bits */ + new CvRegDef(AMD64.xmm0, CV_AMD64_XMM0_0, CV_AMD64_XMM0L), /* xmm0=16 */ + new CvRegDef(AMD64.xmm1, CV_AMD64_XMM1_0, CV_AMD64_XMM1L), + new CvRegDef(AMD64.xmm2, CV_AMD64_XMM2_0, CV_AMD64_XMM2L), + new CvRegDef(AMD64.xmm3, CV_AMD64_XMM3_0, CV_AMD64_XMM3L), + new CvRegDef(AMD64.xmm4, CV_AMD64_XMM4_0, CV_AMD64_XMM4L), + new CvRegDef(AMD64.xmm5, CV_AMD64_XMM5_0, CV_AMD64_XMM5L), + new CvRegDef(AMD64.xmm6, CV_AMD64_XMM6_0, CV_AMD64_XMM6L), + new CvRegDef(AMD64.xmm7, CV_AMD64_XMM7_0, CV_AMD64_XMM7L), + new CvRegDef(AMD64.xmm8, CV_AMD64_XMM8_0, CV_AMD64_XMM8L), + new CvRegDef(AMD64.xmm9, CV_AMD64_XMM9_0, CV_AMD64_XMM9L), + new CvRegDef(AMD64.xmm10, CV_AMD64_XMM10_0, CV_AMD64_XMM10L), + new CvRegDef(AMD64.xmm11, CV_AMD64_XMM11_0, CV_AMD64_XMM11L), + new CvRegDef(AMD64.xmm12, CV_AMD64_XMM12_0, CV_AMD64_XMM12L), + new CvRegDef(AMD64.xmm13, CV_AMD64_XMM13_0, CV_AMD64_XMM13L), + new CvRegDef(AMD64.xmm14, CV_AMD64_XMM14_0, CV_AMD64_XMM14L), + new CvRegDef(AMD64.xmm15, CV_AMD64_XMM15_0, CV_AMD64_XMM15L), }; - private static final CvRegDef[] javaToCVRegisters = new CvRegDef[MAX_JAVA_REGISTER_NUMBER + 1]; + private static final CvRegDef[] javaToCvRegisters = new CvRegDef[MAX_JAVA_REGISTER_NUMBER + 1]; static { for (CvRegDef def : compactRegDefs) { assert 0 <= def.register.number && def.register.number <= MAX_JAVA_REGISTER_NUMBER; - javaToCVRegisters[def.register.number] = def; + javaToCvRegisters[def.register.number] = def; } } @@ -229,7 +247,7 @@ static short getCVRegister(int javaReg, TypeEntry typeEntry) { if (javaReg > MAX_JAVA_REGISTER_NUMBER) { return -1; } - CvRegDef cvReg = javaToCVRegisters[javaReg]; + CvRegDef cvReg = javaToCvRegisters[javaReg]; assert cvReg != null; assert cvReg.register.number == javaReg; if (cvReg == null) { diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java index 27ed4eaab880..6dfa699c35a3 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java @@ -1,6 +1,6 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2020, 2024, Red Hat Inc. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -230,11 +230,8 @@ void emitLocal(DebugInfoProvider.DebugLocalInfo info, HashMap= 0) { currentRecord = new CVSymbolSubrecord.CVSymbolDefRangeRegisterRecord(cvDebugInfo, procName, subrange.getLo() - range.getLo(), (short) (subrange.getHi() - subrange.getLo()), From c79a9a8adfd6dd4f172f85cad1b4d55dd0f30414 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Thu, 29 May 2025 14:58:29 -0400 Subject: [PATCH 29/48] mark some xmm register defs unused --- .../src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java | 1 + 1 file changed, 1 insertion(+) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java index 9ae7f4a1c5eb..81cb7322b46d 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java @@ -30,6 +30,7 @@ import jdk.vm.ci.amd64.AMD64; import jdk.vm.ci.code.Register; +@SuppressWarnings("unused") public class CVRegisterUtil { private static final int MAX_JAVA_REGISTER_NUMBER = AMD64.xmm15.number; From adacbf8052b99208d86ae97a7e4c5bfb9fad02c6 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Thu, 29 May 2025 15:37:45 -0400 Subject: [PATCH 30/48] fix indentation --- .../objectfile/pecoff/cv/CVRegisterUtil.java | 68 +++++++++---------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java index 81cb7322b46d..3d1f4c6af391 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java @@ -195,41 +195,41 @@ private static class CvRegDef { /* List of Graal assignable registers and CodeView register IDs. */ private static final CvRegDef[] compactRegDefs = { - /* 8, 16, 32, 64 bits */ - new CvRegDef(AMD64.rax, CV_AMD64_AL, CV_AMD64_AX, CV_AMD64_EAX, CV_AMD64_RAX), - new CvRegDef(AMD64.rcx, CV_AMD64_CL, CV_AMD64_CX, CV_AMD64_ECX, CV_AMD64_RCX), - new CvRegDef(AMD64.rdx, CV_AMD64_DL, CV_AMD64_DX, CV_AMD64_EDX, CV_AMD64_RDX), - new CvRegDef(AMD64.rbx, CV_AMD64_BL, CV_AMD64_BX, CV_AMD64_EBX, CV_AMD64_RBX), - new CvRegDef(AMD64.rsp, CV_AMD64_SPL, CV_AMD64_SP, CV_AMD64_ESP, CV_AMD64_RSP), - new CvRegDef(AMD64.rbp, CV_AMD64_BPL, CV_AMD64_BP, CV_AMD64_EBP, CV_AMD64_RBP), - new CvRegDef(AMD64.rsi, CV_AMD64_SIL, CV_AMD64_SI, CV_AMD64_ESI, CV_AMD64_RSI), - new CvRegDef(AMD64.rdi, CV_AMD64_DIL, CV_AMD64_DI, CV_AMD64_EDI, CV_AMD64_RDI), - new CvRegDef(AMD64.r8, CV_AMD64_R8B, CV_AMD64_R8W, CV_AMD64_R8D, CV_AMD64_R8), - new CvRegDef(AMD64.r9, CV_AMD64_R9B, CV_AMD64_R9W, CV_AMD64_R9D, CV_AMD64_R9), - new CvRegDef(AMD64.r10, CV_AMD64_R10B, CV_AMD64_R10W, CV_AMD64_R10D, CV_AMD64_R10), - new CvRegDef(AMD64.r11, CV_AMD64_R11B, CV_AMD64_R11W, CV_AMD64_R11D, CV_AMD64_R11), - new CvRegDef(AMD64.r12, CV_AMD64_R12B, CV_AMD64_R12W, CV_AMD64_R12D, CV_AMD64_R12), - new CvRegDef(AMD64.r13, CV_AMD64_R13B, CV_AMD64_R13W, CV_AMD64_R13D, CV_AMD64_R13), - new CvRegDef(AMD64.r14, CV_AMD64_R14B, CV_AMD64_R14W, CV_AMD64_R14D, CV_AMD64_R14), - new CvRegDef(AMD64.r15, CV_AMD64_R15B, CV_AMD64_R15W, CV_AMD64_R15D, CV_AMD64_R15), + /* 8, 16, 32, 64 bits */ + new CvRegDef(AMD64.rax, CV_AMD64_AL, CV_AMD64_AX, CV_AMD64_EAX, CV_AMD64_RAX), + new CvRegDef(AMD64.rcx, CV_AMD64_CL, CV_AMD64_CX, CV_AMD64_ECX, CV_AMD64_RCX), + new CvRegDef(AMD64.rdx, CV_AMD64_DL, CV_AMD64_DX, CV_AMD64_EDX, CV_AMD64_RDX), + new CvRegDef(AMD64.rbx, CV_AMD64_BL, CV_AMD64_BX, CV_AMD64_EBX, CV_AMD64_RBX), + new CvRegDef(AMD64.rsp, CV_AMD64_SPL, CV_AMD64_SP, CV_AMD64_ESP, CV_AMD64_RSP), + new CvRegDef(AMD64.rbp, CV_AMD64_BPL, CV_AMD64_BP, CV_AMD64_EBP, CV_AMD64_RBP), + new CvRegDef(AMD64.rsi, CV_AMD64_SIL, CV_AMD64_SI, CV_AMD64_ESI, CV_AMD64_RSI), + new CvRegDef(AMD64.rdi, CV_AMD64_DIL, CV_AMD64_DI, CV_AMD64_EDI, CV_AMD64_RDI), + new CvRegDef(AMD64.r8, CV_AMD64_R8B, CV_AMD64_R8W, CV_AMD64_R8D, CV_AMD64_R8), + new CvRegDef(AMD64.r9, CV_AMD64_R9B, CV_AMD64_R9W, CV_AMD64_R9D, CV_AMD64_R9), + new CvRegDef(AMD64.r10, CV_AMD64_R10B, CV_AMD64_R10W, CV_AMD64_R10D, CV_AMD64_R10), + new CvRegDef(AMD64.r11, CV_AMD64_R11B, CV_AMD64_R11W, CV_AMD64_R11D, CV_AMD64_R11), + new CvRegDef(AMD64.r12, CV_AMD64_R12B, CV_AMD64_R12W, CV_AMD64_R12D, CV_AMD64_R12), + new CvRegDef(AMD64.r13, CV_AMD64_R13B, CV_AMD64_R13W, CV_AMD64_R13D, CV_AMD64_R13), + new CvRegDef(AMD64.r14, CV_AMD64_R14B, CV_AMD64_R14W, CV_AMD64_R14D, CV_AMD64_R14), + new CvRegDef(AMD64.r15, CV_AMD64_R15B, CV_AMD64_R15W, CV_AMD64_R15D, CV_AMD64_R15), - /* 32, 64 bits */ - new CvRegDef(AMD64.xmm0, CV_AMD64_XMM0_0, CV_AMD64_XMM0L), /* xmm0=16 */ - new CvRegDef(AMD64.xmm1, CV_AMD64_XMM1_0, CV_AMD64_XMM1L), - new CvRegDef(AMD64.xmm2, CV_AMD64_XMM2_0, CV_AMD64_XMM2L), - new CvRegDef(AMD64.xmm3, CV_AMD64_XMM3_0, CV_AMD64_XMM3L), - new CvRegDef(AMD64.xmm4, CV_AMD64_XMM4_0, CV_AMD64_XMM4L), - new CvRegDef(AMD64.xmm5, CV_AMD64_XMM5_0, CV_AMD64_XMM5L), - new CvRegDef(AMD64.xmm6, CV_AMD64_XMM6_0, CV_AMD64_XMM6L), - new CvRegDef(AMD64.xmm7, CV_AMD64_XMM7_0, CV_AMD64_XMM7L), - new CvRegDef(AMD64.xmm8, CV_AMD64_XMM8_0, CV_AMD64_XMM8L), - new CvRegDef(AMD64.xmm9, CV_AMD64_XMM9_0, CV_AMD64_XMM9L), - new CvRegDef(AMD64.xmm10, CV_AMD64_XMM10_0, CV_AMD64_XMM10L), - new CvRegDef(AMD64.xmm11, CV_AMD64_XMM11_0, CV_AMD64_XMM11L), - new CvRegDef(AMD64.xmm12, CV_AMD64_XMM12_0, CV_AMD64_XMM12L), - new CvRegDef(AMD64.xmm13, CV_AMD64_XMM13_0, CV_AMD64_XMM13L), - new CvRegDef(AMD64.xmm14, CV_AMD64_XMM14_0, CV_AMD64_XMM14L), - new CvRegDef(AMD64.xmm15, CV_AMD64_XMM15_0, CV_AMD64_XMM15L), + /* 32, 64 bits */ + new CvRegDef(AMD64.xmm0, CV_AMD64_XMM0_0, CV_AMD64_XMM0L), /* xmm0=16 */ + new CvRegDef(AMD64.xmm1, CV_AMD64_XMM1_0, CV_AMD64_XMM1L), + new CvRegDef(AMD64.xmm2, CV_AMD64_XMM2_0, CV_AMD64_XMM2L), + new CvRegDef(AMD64.xmm3, CV_AMD64_XMM3_0, CV_AMD64_XMM3L), + new CvRegDef(AMD64.xmm4, CV_AMD64_XMM4_0, CV_AMD64_XMM4L), + new CvRegDef(AMD64.xmm5, CV_AMD64_XMM5_0, CV_AMD64_XMM5L), + new CvRegDef(AMD64.xmm6, CV_AMD64_XMM6_0, CV_AMD64_XMM6L), + new CvRegDef(AMD64.xmm7, CV_AMD64_XMM7_0, CV_AMD64_XMM7L), + new CvRegDef(AMD64.xmm8, CV_AMD64_XMM8_0, CV_AMD64_XMM8L), + new CvRegDef(AMD64.xmm9, CV_AMD64_XMM9_0, CV_AMD64_XMM9L), + new CvRegDef(AMD64.xmm10, CV_AMD64_XMM10_0, CV_AMD64_XMM10L), + new CvRegDef(AMD64.xmm11, CV_AMD64_XMM11_0, CV_AMD64_XMM11L), + new CvRegDef(AMD64.xmm12, CV_AMD64_XMM12_0, CV_AMD64_XMM12L), + new CvRegDef(AMD64.xmm13, CV_AMD64_XMM13_0, CV_AMD64_XMM13L), + new CvRegDef(AMD64.xmm14, CV_AMD64_XMM14_0, CV_AMD64_XMM14L), + new CvRegDef(AMD64.xmm15, CV_AMD64_XMM15_0, CV_AMD64_XMM15L), }; private static final CvRegDef[] javaToCvRegisters = new CvRegDef[MAX_JAVA_REGISTER_NUMBER + 1]; From 8e93dd59a48857635a7097e0b6e48c845c986085 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Wed, 4 Jun 2025 13:24:38 -0400 Subject: [PATCH 31/48] fix hub member in class objects --- .../oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java index d49ea91744c2..8c415231c6bd 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java @@ -248,6 +248,14 @@ private CVTypeRecord buildStructureTypeEntry(final StructureTypeEntry typeEntry) fieldListBuilder.addField(btype); } + if (typeEntry.isHeader()) { + FieldEntry hubField = ((HeaderTypeEntry)typeEntry).getHubField(); + log("field %s attr=(%s) offset=%d size=%d valuetype=%s", hubField.fieldName(), hubField.getModifiersString(), hubField.getOffset(), hubField.getSize(), hubField.getValueType().getTypeName()); + CVTypeRecord.FieldRecord fieldRecord = buildField(hubField); + log("field %s", fieldRecord); + fieldListBuilder.addField(fieldRecord); + } + /* Only define manifested fields. */ typeEntry.fields().filter(CVTypeSectionBuilder::isManifestedField).forEach(f -> { log("field %s attr=(%s) offset=%d size=%d valuetype=%s", f.fieldName(), f.getModifiersString(), f.getOffset(), f.getSize(), f.getValueType().getTypeName()); From 72efb93589e25aa9a6e4d7bdbb6a42a10479922c Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Wed, 4 Jun 2025 13:28:50 -0400 Subject: [PATCH 32/48] fix hub member in class objects --- .../oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java index 525cb8378bd2..8ae89b68a395 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java @@ -247,6 +247,14 @@ private CVTypeRecord buildStructureTypeEntry(final StructureTypeEntry typeEntry) fieldListBuilder.addField(btype); } + if (typeEntry.isHeader()) { + FieldEntry hubField = ((HeaderTypeEntry)typeEntry).getHubField(); + log("field %s attr=(%s) offset=%d size=%d valuetype=%s", hubField.fieldName(), hubField.getModifiersString(), hubField.getOffset(), hubField.getSize(), hubField.getValueType().getTypeName()); + CVTypeRecord.FieldRecord fieldRecord = buildField(hubField); + log("field %s", fieldRecord); + fieldListBuilder.addField(fieldRecord); + } + /* Only define manifested fields. */ typeEntry.fields().filter(CVTypeSectionBuilder::isManifestedField).forEach(f -> { log("field %s attr=(%s) offset=%d size=%d valuetype=%s", f.fieldName(), f.getModifiersString(), f.getOffset(), f.getSize(), f.getValueType().getTypeName()); From bdd27d5eb9cb6db48b45a1fcbc0673fa2b5416e2 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Wed, 4 Jun 2025 13:58:02 -0400 Subject: [PATCH 33/48] add new register definitions --- .../objectfile/pecoff/cv/CVConstants.java | 107 ------- .../objectfile/pecoff/cv/CVRegisterUtil.java | 284 ++++++++++++++++++ .../pecoff/cv/CVSymbolSubsectionBuilder.java | 4 +- .../oracle/objectfile/pecoff/cv/CVUtil.java | 143 --------- 4 files changed, 286 insertions(+), 252 deletions(-) create mode 100644 substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVConstants.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVConstants.java index 03fed1d1a860..5465da967165 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVConstants.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVConstants.java @@ -35,111 +35,4 @@ public abstract class CVConstants { /* CodeView section header signature */ static final int CV_SIGNATURE_C13 = 4; - - /* Register definitions */ - - /* 8 bit registers. */ - static final short CV_AMD64_R8B = 344; - static final short CV_AMD64_R9B = 345; - static final short CV_AMD64_R10B = 346; - static final short CV_AMD64_R11B = 347; - static final short CV_AMD64_R12B = 348; - static final short CV_AMD64_R13B = 349; - static final short CV_AMD64_R14B = 350; - static final short CV_AMD64_R15B = 351; - - static final short CV_AMD64_AL = 1; - static final short CV_AMD64_CL = 2; - static final short CV_AMD64_DL = 3; - static final short CV_AMD64_BL = 4; - - static final short CV_AMD64_SIL = 324; - static final short CV_AMD64_DIL = 325; - static final short CV_AMD64_BPL = 326; - static final short CV_AMD64_SPL = 327; - - /* 16 bit registers. */ - static final short CV_AMD64_R8W = 352; - static final short CV_AMD64_R9W = 353; - static final short CV_AMD64_R10W = 354; - static final short CV_AMD64_R11W = 355; - static final short CV_AMD64_R12W = 356; - static final short CV_AMD64_R13W = 357; - static final short CV_AMD64_R14W = 358; - static final short CV_AMD64_R15W = 359; - - static final short CV_AMD64_AX = 9; - static final short CV_AMD64_CX = 10; - static final short CV_AMD64_DX = 11; - static final short CV_AMD64_BX = 12; - static final short CV_AMD64_SP = 13; - static final short CV_AMD64_BP = 14; - static final short CV_AMD64_SI = 15; - static final short CV_AMD64_DI = 16; - - /* 32 bit registers. */ - static final short CV_AMD64_R8D = 360; - static final short CV_AMD64_R9D = 361; - static final short CV_AMD64_R10D = 362; - static final short CV_AMD64_R11D = 363; - static final short CV_AMD64_R12D = 364; - static final short CV_AMD64_R13D = 365; - static final short CV_AMD64_R14D = 366; - static final short CV_AMD64_R15D = 367; - - static final short CV_AMD64_EAX = 17; - static final short CV_AMD64_ECX = 18; - static final short CV_AMD64_EDX = 19; - static final short CV_AMD64_EBX = 20; - static final short CV_AMD64_ESP = 21; - static final short CV_AMD64_EBP = 22; - static final short CV_AMD64_ESI = 23; - static final short CV_AMD64_EDI = 24; - - /* 64 bit registers. */ - static final short CV_AMD64_RAX = 328; - static final short CV_AMD64_RBX = 329; - static final short CV_AMD64_RCX = 330; - static final short CV_AMD64_RDX = 331; - static final short CV_AMD64_RSI = 332; - static final short CV_AMD64_RDI = 333; - static final short CV_AMD64_RBP = 334; - static final short CV_AMD64_RSP = 335; - - static final short CV_AMD64_R8 = 336; - static final short CV_AMD64_R9 = 337; - static final short CV_AMD64_R10 = 338; - static final short CV_AMD64_R11 = 339; - static final short CV_AMD64_R12 = 340; - static final short CV_AMD64_R13 = 341; - static final short CV_AMD64_R14 = 342; - static final short CV_AMD64_R15 = 343; - - /* FP registers. */ - static final short CV_AMD64_XMM0 = 154; - static final short CV_AMD64_XMM1 = 155; - static final short CV_AMD64_XMM2 = 156; - static final short CV_AMD64_XMM3 = 157; - static final short CV_AMD64_XMM4 = 158; - static final short CV_AMD64_XMM5 = 159; - static final short CV_AMD64_XMM6 = 160; - static final short CV_AMD64_XMM7 = 161; - - static final short CV_AMD64_XMM0_0 = 162; - static final short CV_AMD64_XMM1_0 = 166; - static final short CV_AMD64_XMM2_0 = 170; - static final short CV_AMD64_XMM3_0 = 174; - static final short CV_AMD64_XMM4_0 = 178; - static final short CV_AMD64_XMM5_0 = 182; - static final short CV_AMD64_XMM6_0 = 186; - static final short CV_AMD64_XMM7_0 = 190; - - static final short CV_AMD64_XMM0L = 194; - static final short CV_AMD64_XMM1L = 195; - static final short CV_AMD64_XMM2L = 196; - static final short CV_AMD64_XMM3L = 197; - static final short CV_AMD64_XMM4L = 198; - static final short CV_AMD64_XMM5L = 199; - static final short CV_AMD64_XMM6L = 200; - static final short CV_AMD64_XMM7L = 201; } diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java new file mode 100644 index 000000000000..2367f60968bb --- /dev/null +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java @@ -0,0 +1,284 @@ +/* + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.oracle.objectfile.pecoff.cv; + +import com.oracle.objectfile.debugentry.TypeEntry; +import jdk.vm.ci.amd64.AMD64; +import jdk.vm.ci.code.Register; + +@SuppressWarnings("unused") +public class CVRegisterUtil { + + private static final int MAX_JAVA_REGISTER_NUMBER = AMD64.xmm15.number; + + /* Register definitions */ + + /* 8 bit registers. */ + private static final short CV_AMD64_R8B = 344; + private static final short CV_AMD64_R9B = 345; + private static final short CV_AMD64_R10B = 346; + private static final short CV_AMD64_R11B = 347; + private static final short CV_AMD64_R12B = 348; + private static final short CV_AMD64_R13B = 349; + private static final short CV_AMD64_R14B = 350; + private static final short CV_AMD64_R15B = 351; + + private static final short CV_AMD64_AL = 1; + private static final short CV_AMD64_CL = 2; + private static final short CV_AMD64_DL = 3; + private static final short CV_AMD64_BL = 4; + + private static final short CV_AMD64_SIL = 324; + private static final short CV_AMD64_DIL = 325; + private static final short CV_AMD64_BPL = 326; + private static final short CV_AMD64_SPL = 327; + + /* 16 bit registers. */ + private static final short CV_AMD64_R8W = 352; + private static final short CV_AMD64_R9W = 353; + private static final short CV_AMD64_R10W = 354; + private static final short CV_AMD64_R11W = 355; + private static final short CV_AMD64_R12W = 356; + private static final short CV_AMD64_R13W = 357; + private static final short CV_AMD64_R14W = 358; + private static final short CV_AMD64_R15W = 359; + + private static final short CV_AMD64_AX = 9; + private static final short CV_AMD64_CX = 10; + private static final short CV_AMD64_DX = 11; + private static final short CV_AMD64_BX = 12; + private static final short CV_AMD64_SP = 13; + private static final short CV_AMD64_BP = 14; + private static final short CV_AMD64_SI = 15; + private static final short CV_AMD64_DI = 16; + + /* 32 bit registers. */ + private static final short CV_AMD64_R8D = 360; + private static final short CV_AMD64_R9D = 361; + private static final short CV_AMD64_R10D = 362; + private static final short CV_AMD64_R11D = 363; + private static final short CV_AMD64_R12D = 364; + private static final short CV_AMD64_R13D = 365; + private static final short CV_AMD64_R14D = 366; + private static final short CV_AMD64_R15D = 367; + + private static final short CV_AMD64_EAX = 17; + private static final short CV_AMD64_ECX = 18; + private static final short CV_AMD64_EDX = 19; + private static final short CV_AMD64_EBX = 20; + private static final short CV_AMD64_ESP = 21; + private static final short CV_AMD64_EBP = 22; + private static final short CV_AMD64_ESI = 23; + private static final short CV_AMD64_EDI = 24; + + /* 64 bit registers. */ + private static final short CV_AMD64_RAX = 328; + private static final short CV_AMD64_RBX = 329; + private static final short CV_AMD64_RCX = 330; + private static final short CV_AMD64_RDX = 331; + private static final short CV_AMD64_RSI = 332; + private static final short CV_AMD64_RDI = 333; + private static final short CV_AMD64_RBP = 334; + private static final short CV_AMD64_RSP = 335; + + static final short CV_AMD64_R8 = 336; + private static final short CV_AMD64_R9 = 337; + private static final short CV_AMD64_R10 = 338; + private static final short CV_AMD64_R11 = 339; + private static final short CV_AMD64_R12 = 340; + private static final short CV_AMD64_R13 = 341; + private static final short CV_AMD64_R14 = 342; + private static final short CV_AMD64_R15 = 343; + + /* FP registers. */ + private static final short CV_AMD64_XMM0 = 154; + private static final short CV_AMD64_XMM1 = 155; + private static final short CV_AMD64_XMM2 = 156; + private static final short CV_AMD64_XMM3 = 157; + private static final short CV_AMD64_XMM4 = 158; + private static final short CV_AMD64_XMM5 = 159; + private static final short CV_AMD64_XMM6 = 160; + private static final short CV_AMD64_XMM7 = 161; + + private static final short CV_AMD64_XMM8 = 252; + private static final short CV_AMD64_XMM9 = 253; + private static final short CV_AMD64_XMM10 = 254; + private static final short CV_AMD64_XMM11 = 255; + private static final short CV_AMD64_XMM12 = 256; + private static final short CV_AMD64_XMM13 = 257; + private static final short CV_AMD64_XMM14 = 258; + private static final short CV_AMD64_XMM15 = 259; + + private static final short CV_AMD64_XMM0_0 = 162; + private static final short CV_AMD64_XMM1_0 = 166; + private static final short CV_AMD64_XMM2_0 = 170; + private static final short CV_AMD64_XMM3_0 = 174; + private static final short CV_AMD64_XMM4_0 = 178; + private static final short CV_AMD64_XMM5_0 = 182; + private static final short CV_AMD64_XMM6_0 = 186; + private static final short CV_AMD64_XMM7_0 = 190; + + private static final short CV_AMD64_XMM8_0 = 260; + private static final short CV_AMD64_XMM9_0 = 261; + private static final short CV_AMD64_XMM10_0 = 262; + private static final short CV_AMD64_XMM11_0 = 263; + private static final short CV_AMD64_XMM12_0 = 264; + private static final short CV_AMD64_XMM13_0 = 265; + private static final short CV_AMD64_XMM14_0 = 266; + private static final short CV_AMD64_XMM15_0 = 267; + + private static final short CV_AMD64_XMM0L = 194; + private static final short CV_AMD64_XMM1L = 195; + private static final short CV_AMD64_XMM2L = 196; + private static final short CV_AMD64_XMM3L = 197; + private static final short CV_AMD64_XMM4L = 198; + private static final short CV_AMD64_XMM5L = 199; + private static final short CV_AMD64_XMM6L = 200; + private static final short CV_AMD64_XMM7L = 201; + + private static final short CV_AMD64_XMM8L = 292; + private static final short CV_AMD64_XMM9L = 293; + private static final short CV_AMD64_XMM10L = 294; + private static final short CV_AMD64_XMM11L = 295; + private static final short CV_AMD64_XMM12L = 296; + private static final short CV_AMD64_XMM13L = 297; + private static final short CV_AMD64_XMM14L = 298; + private static final short CV_AMD64_XMM15L = 299; + + private static class CvRegDef { + final Register register; + final short cv1; + final short cv2; + final short cv4; + final short cv8; + + CvRegDef(Register r, short cv1, short cv2, short cv4, short cv8) { + this.register = r; + this.cv1 = cv1; + this.cv2 = cv2; + this.cv4 = cv4; + this.cv8 = cv8; + } + + CvRegDef(Register r, short cv4, short cv8) { + this.register = r; + this.cv1 = -1; + this.cv2 = -1; + this.cv4 = cv4; + this.cv8 = cv8; + } + } + + /* List of Graal assignable registers and CodeView register IDs. */ + private static final CvRegDef[] compactRegDefs = { + /* 8, 16, 32, 64 bits */ + new CvRegDef(AMD64.rax, CV_AMD64_AL, CV_AMD64_AX, CV_AMD64_EAX, CV_AMD64_RAX), + new CvRegDef(AMD64.rcx, CV_AMD64_CL, CV_AMD64_CX, CV_AMD64_ECX, CV_AMD64_RCX), + new CvRegDef(AMD64.rdx, CV_AMD64_DL, CV_AMD64_DX, CV_AMD64_EDX, CV_AMD64_RDX), + new CvRegDef(AMD64.rbx, CV_AMD64_BL, CV_AMD64_BX, CV_AMD64_EBX, CV_AMD64_RBX), + new CvRegDef(AMD64.rsp, CV_AMD64_SPL, CV_AMD64_SP, CV_AMD64_ESP, CV_AMD64_RSP), + new CvRegDef(AMD64.rbp, CV_AMD64_BPL, CV_AMD64_BP, CV_AMD64_EBP, CV_AMD64_RBP), + new CvRegDef(AMD64.rsi, CV_AMD64_SIL, CV_AMD64_SI, CV_AMD64_ESI, CV_AMD64_RSI), + new CvRegDef(AMD64.rdi, CV_AMD64_DIL, CV_AMD64_DI, CV_AMD64_EDI, CV_AMD64_RDI), + new CvRegDef(AMD64.r8, CV_AMD64_R8B, CV_AMD64_R8W, CV_AMD64_R8D, CV_AMD64_R8), + new CvRegDef(AMD64.r9, CV_AMD64_R9B, CV_AMD64_R9W, CV_AMD64_R9D, CV_AMD64_R9), + new CvRegDef(AMD64.r10, CV_AMD64_R10B, CV_AMD64_R10W, CV_AMD64_R10D, CV_AMD64_R10), + new CvRegDef(AMD64.r11, CV_AMD64_R11B, CV_AMD64_R11W, CV_AMD64_R11D, CV_AMD64_R11), + new CvRegDef(AMD64.r12, CV_AMD64_R12B, CV_AMD64_R12W, CV_AMD64_R12D, CV_AMD64_R12), + new CvRegDef(AMD64.r13, CV_AMD64_R13B, CV_AMD64_R13W, CV_AMD64_R13D, CV_AMD64_R13), + new CvRegDef(AMD64.r14, CV_AMD64_R14B, CV_AMD64_R14W, CV_AMD64_R14D, CV_AMD64_R14), + new CvRegDef(AMD64.r15, CV_AMD64_R15B, CV_AMD64_R15W, CV_AMD64_R15D, CV_AMD64_R15), + + /* 32, 64 bits */ + new CvRegDef(AMD64.xmm0, CV_AMD64_XMM0_0, CV_AMD64_XMM0L), /* xmm0=16 */ + new CvRegDef(AMD64.xmm1, CV_AMD64_XMM1_0, CV_AMD64_XMM1L), + new CvRegDef(AMD64.xmm2, CV_AMD64_XMM2_0, CV_AMD64_XMM2L), + new CvRegDef(AMD64.xmm3, CV_AMD64_XMM3_0, CV_AMD64_XMM3L), + new CvRegDef(AMD64.xmm4, CV_AMD64_XMM4_0, CV_AMD64_XMM4L), + new CvRegDef(AMD64.xmm5, CV_AMD64_XMM5_0, CV_AMD64_XMM5L), + new CvRegDef(AMD64.xmm6, CV_AMD64_XMM6_0, CV_AMD64_XMM6L), + new CvRegDef(AMD64.xmm7, CV_AMD64_XMM7_0, CV_AMD64_XMM7L), + new CvRegDef(AMD64.xmm8, CV_AMD64_XMM8_0, CV_AMD64_XMM8L), + new CvRegDef(AMD64.xmm9, CV_AMD64_XMM9_0, CV_AMD64_XMM9L), + new CvRegDef(AMD64.xmm10, CV_AMD64_XMM10_0, CV_AMD64_XMM10L), + new CvRegDef(AMD64.xmm11, CV_AMD64_XMM11_0, CV_AMD64_XMM11L), + new CvRegDef(AMD64.xmm12, CV_AMD64_XMM12_0, CV_AMD64_XMM12L), + new CvRegDef(AMD64.xmm13, CV_AMD64_XMM13_0, CV_AMD64_XMM13L), + new CvRegDef(AMD64.xmm14, CV_AMD64_XMM14_0, CV_AMD64_XMM14L), + new CvRegDef(AMD64.xmm15, CV_AMD64_XMM15_0, CV_AMD64_XMM15L), + }; + + private static final CvRegDef[] javaToCvRegisters = new CvRegDef[MAX_JAVA_REGISTER_NUMBER + 1]; + + static { + for (CvRegDef def : compactRegDefs) { + assert 0 <= def.register.number && def.register.number <= MAX_JAVA_REGISTER_NUMBER; + javaToCvRegisters[def.register.number] = def; + } + } + + /* Convert a Java register number to a CodeView register code */ + /* the CodeView code depends upon the register type and size */ + static short getCVRegister(int javaReg, TypeEntry typeEntry) { + assert 0 <= javaReg && javaReg <= MAX_JAVA_REGISTER_NUMBER; + if (javaReg > MAX_JAVA_REGISTER_NUMBER) { + return -1; + } + CvRegDef cvReg = javaToCvRegisters[javaReg]; + assert cvReg != null; + assert cvReg.register.number == javaReg; + if (cvReg == null) { + return -1; + } + + final short cvCode; + if (typeEntry.isPrimitive()) { + switch (typeEntry.getSize()) { + case 1: + cvCode = cvReg.cv1; + break; + case 2: + cvCode = cvReg.cv2; + break; + case 4: + cvCode = cvReg.cv4; + break; + case 8: + cvCode = cvReg.cv8; + break; + default: + cvCode = -1; + break; + } + } else { + /* Objects are represented by 8 byte pointers. */ + cvCode = cvReg.cv8; + } + assert cvCode != -1; + return cvCode; + } +} diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java index 26b9a43829c6..ed79249c4b63 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java @@ -46,7 +46,7 @@ import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugLocalValueInfo.LocalKind.REGISTER; import static com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugLocalValueInfo.LocalKind.STACKSLOT; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R8; +import static com.oracle.objectfile.pecoff.cv.CVRegisterUtil.CV_AMD64_R8; import static com.oracle.objectfile.pecoff.cv.CVSymbolSubrecord.CVSymbolFrameProcRecord.FRAME_LOCAL_BP; import static com.oracle.objectfile.pecoff.cv.CVSymbolSubrecord.CVSymbolFrameProcRecord.FRAME_PARAM_BP; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.MAX_PRIMITIVE; @@ -227,7 +227,7 @@ void emitLocal(DebugInfoProvider.DebugLocalInfo info, HashMap= 0 && bytes < javaToCvRegisters[javaReg].length; - short cvreg = javaToCvRegisters[javaReg][bytes]; - assert cvreg != -1; - return cvreg; - } } From 1997e9195b767067195fbcb58a3f2207e4bfe6a2 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Wed, 4 Jun 2025 14:07:51 -0400 Subject: [PATCH 34/48] graal formatting fix --- .../oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java index 8ae89b68a395..d193551be4cd 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java @@ -248,8 +248,9 @@ private CVTypeRecord buildStructureTypeEntry(final StructureTypeEntry typeEntry) } if (typeEntry.isHeader()) { - FieldEntry hubField = ((HeaderTypeEntry)typeEntry).getHubField(); - log("field %s attr=(%s) offset=%d size=%d valuetype=%s", hubField.fieldName(), hubField.getModifiersString(), hubField.getOffset(), hubField.getSize(), hubField.getValueType().getTypeName()); + FieldEntry hubField = ((HeaderTypeEntry) typeEntry).getHubField(); + log("field %s attr=(%s) offset=%d size=%d valuetype=%s", hubField.fieldName(), hubField.getModifiersString(), hubField.getOffset(), hubField.getSize(), + hubField.getValueType().getTypeName()); CVTypeRecord.FieldRecord fieldRecord = buildField(hubField); log("field %s", fieldRecord); fieldListBuilder.addField(fieldRecord); From 34c0b7e63024999837672859478607bf85a6484c Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Wed, 2 Jul 2025 08:31:15 -0400 Subject: [PATCH 35/48] fix github formatting gate isue --- .../oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java index 8c415231c6bd..b7ec9b326d38 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java @@ -249,8 +249,9 @@ private CVTypeRecord buildStructureTypeEntry(final StructureTypeEntry typeEntry) } if (typeEntry.isHeader()) { - FieldEntry hubField = ((HeaderTypeEntry)typeEntry).getHubField(); - log("field %s attr=(%s) offset=%d size=%d valuetype=%s", hubField.fieldName(), hubField.getModifiersString(), hubField.getOffset(), hubField.getSize(), hubField.getValueType().getTypeName()); + FieldEntry hubField = ((HeaderTypeEntry) typeEntry).getHubField(); + log("field %s attr=(%s) offset=%d size=%d valuetype=%s", hubField.fieldName(), + hubField.getModifiersString(), hubField.getOffset(), hubField.getSize(), hubField.getValueType().getTypeName()); CVTypeRecord.FieldRecord fieldRecord = buildField(hubField); log("field %s", fieldRecord); fieldListBuilder.addField(fieldRecord); From 55023919e211c4fbc46c33afcc48ab8a1e1b8fa0 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Mon, 28 Jul 2025 10:54:03 -0400 Subject: [PATCH 36/48] Merge branch 'master' into pr_update_codeview --- .../oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java index 66817ff6a41c..f3a324596561 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java @@ -66,7 +66,7 @@ final class CVSymbolSubsectionBuilder { this.cvSymbolSubsection = new CVSymbolSubsection(cvDebugInfo); this.lineRecordBuilder = new CVLineRecordBuilder(cvDebugInfo); this.heapName = SectionName.SVM_HEAP.getFormatDependentName(cvDebugInfo.getCVSymbolSection().getOwner().getFormat()); - /* For isolates, Graal currently uses r14; this code will handle r8-r15. */ + /* For isolates, Graal currently uses r14 as the heap base; this code will handle r8-r15. */ assert AMD64.r8.number <= cvDebugInfo.getHeapbaseRegister() && cvDebugInfo.getHeapbaseRegister() <= AMD64.r15.number; this.heapRegister = (short) (CV_AMD64_R8 + cvDebugInfo.getHeapbaseRegister() - AMD64.r8.number); } From 23e296e5948ddff7131865375d077e6700e3174c Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Tue, 29 Jul 2025 07:36:36 -0400 Subject: [PATCH 37/48] changes for runtime debug option --- .../objectfile/pecoff/cv/CVRegisterUtil.java | 32 +++---- .../pecoff/cv/CVSymbolSubrecord.java | 12 ++- .../pecoff/cv/CVSymbolSubsectionBuilder.java | 93 ++++++++++--------- .../pecoff/cv/CVTypeSectionBuilder.java | 6 +- 4 files changed, 71 insertions(+), 72 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java index 2367f60968bb..f4cbd91566f3 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java @@ -26,10 +26,13 @@ package com.oracle.objectfile.pecoff.cv; +import com.oracle.objectfile.debugentry.PrimitiveTypeEntry; import com.oracle.objectfile.debugentry.TypeEntry; import jdk.vm.ci.amd64.AMD64; import jdk.vm.ci.code.Register; +import java.util.Objects; + @SuppressWarnings("unused") public class CVRegisterUtil { @@ -256,26 +259,15 @@ static short getCVRegister(int javaReg, TypeEntry typeEntry) { } final short cvCode; - if (typeEntry.isPrimitive()) { - switch (typeEntry.getSize()) { - case 1: - cvCode = cvReg.cv1; - break; - case 2: - cvCode = cvReg.cv2; - break; - case 4: - cvCode = cvReg.cv4; - break; - case 8: - cvCode = cvReg.cv8; - break; - default: - cvCode = -1; - break; - } - } else { - /* Objects are represented by 8 byte pointers. */ + if (Objects.requireNonNull(typeEntry) instanceof PrimitiveTypeEntry) { + cvCode = switch (typeEntry.getSize()) { + case 1 -> cvReg.cv1; + case 2 -> cvReg.cv2; + case 4 -> cvReg.cv4; + case 8 -> cvReg.cv8; + default -> -1; + }; + } else {/* Objects are represented by 8 byte pointers. */ cvCode = cvReg.cv8; } assert cvCode != -1; diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java index 0df89d1e574a..b9a6c3e67a92 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java @@ -616,7 +616,7 @@ public static class CVSymbolGProc32Record extends CVSymbolSubrecord { protected final String displayName; @SuppressWarnings("unused") - CVSymbolGProc32Record(CVDebugInfo cvDebugInfo, String symbolName, String displayName, int pparent, int pend, int pnext, int proclen, int debugStart, int debugEnd, int typeIndex, + CVSymbolGProc32Record(CVDebugInfo cvDebugInfo, String symbolName, String displayName, int pparent, int pend, int pnext, long proclen, int debugStart, int debugEnd, int typeIndex, short segment, byte flags) { super(cvDebugInfo, CVDebugConstants.S_GPROC32); this.symbolName = symbolName; @@ -624,7 +624,8 @@ public static class CVSymbolGProc32Record extends CVSymbolSubrecord { this.pparent = pparent; this.pend = pend; this.pnext = pnext; - this.proclen = proclen; + assert proclen <= Integer.MAX_VALUE; + this.proclen = (int) proclen; this.debugStart = debugStart; this.debugEnd = debugEnd; this.typeIndex = typeIndex; @@ -632,7 +633,7 @@ public static class CVSymbolGProc32Record extends CVSymbolSubrecord { this.flags = flags; } - protected CVSymbolGProc32Record(CVDebugInfo cvDebugInfo, short cmd, String symbolName, String displayName, int pparent, int pend, int pnext, int proclen, int debugStart, int debugEnd, + protected CVSymbolGProc32Record(CVDebugInfo cvDebugInfo, short cmd, String symbolName, String displayName, int pparent, int pend, int pnext, long proclen, int debugStart, int debugEnd, int typeIndex, short segment, byte flags) { super(cvDebugInfo, cmd); this.symbolName = symbolName; @@ -640,7 +641,8 @@ protected CVSymbolGProc32Record(CVDebugInfo cvDebugInfo, short cmd, String symbo this.pparent = pparent; this.pend = pend; this.pnext = pnext; - this.proclen = proclen; + assert proclen <= Integer.MAX_VALUE; + this.proclen = (int) proclen; this.debugStart = debugStart; this.debugEnd = debugEnd; this.typeIndex = typeIndex; @@ -672,7 +674,7 @@ public String toString() { public static class CVSymbolGProc32IdRecord extends CVSymbolGProc32Record { - CVSymbolGProc32IdRecord(CVDebugInfo cvDebugInfo, String symbolName, String displayName, int pparent, int pend, int pnext, int proclen, int debugStart, int debugEnd, int typeIndex, + CVSymbolGProc32IdRecord(CVDebugInfo cvDebugInfo, String symbolName, String displayName, int pparent, int pend, int pnext, long proclen, int debugStart, int debugEnd, int typeIndex, short segment, byte flags) { super(cvDebugInfo, CVDebugConstants.S_GPROC32_ID, symbolName, displayName, pparent, pend, pnext, proclen, debugStart, debugEnd, typeIndex, segment, flags); diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java index f3a324596561..a1a545739314 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java @@ -26,22 +26,26 @@ package com.oracle.objectfile.pecoff.cv; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R8; -import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.MAX_PRIMITIVE; - import java.lang.reflect.Modifier; import com.oracle.objectfile.SectionName; import com.oracle.objectfile.debugentry.ClassEntry; import com.oracle.objectfile.debugentry.CompiledMethodEntry; +import com.oracle.objectfile.debugentry.ConstantValueEntry; import com.oracle.objectfile.debugentry.FieldEntry; +import com.oracle.objectfile.debugentry.LocalEntry; +import com.oracle.objectfile.debugentry.LocalValueEntry; +import com.oracle.objectfile.debugentry.RegisterValueEntry; +import com.oracle.objectfile.debugentry.StackValueEntry; import com.oracle.objectfile.debugentry.TypeEntry; import com.oracle.objectfile.debugentry.MethodEntry; import com.oracle.objectfile.debugentry.range.Range; +import jdk.vm.ci.amd64.AMD64; -import java.lang.reflect.Modifier; +import java.util.List; +import java.util.Map; -import static com.oracle.objectfile.pecoff.cv.CVConstants.CV_AMD64_R8; +import static com.oracle.objectfile.pecoff.cv.CVRegisterUtil.CV_AMD64_R8; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.MAX_PRIMITIVE; final class CVSymbolSubsectionBuilder { @@ -153,10 +157,10 @@ private void buildFunction(CompiledMethodEntry compiledEntry) { int localBP = 1 << 14; /* Local base pointer = SP (0=none, 1=sp, 2=bp 3=r13). */ int paramBP = 1 << 16; /* Param base pointer = SP. */ int frameFlags = asynceh + localBP + paramBP; /* NB: LLVM uses 0x14000. */ - addSymbolRecord(new CVSymbolSubrecord.CVSymbolFrameProcRecord(cvDebugInfo, compiledEntry.getFrameSize(), frameFlags)); + addSymbolRecord(new CVSymbolSubrecord.CVSymbolFrameProcRecord(cvDebugInfo, compiledEntry.frameSize(), frameFlags)); /* it's costly to compute this, so only compute it once */ - HashMap> varRangeMap = primaryRange.getVarRangeMap(); + Map> varRangeMap = primaryRange.getVarRangeMap(); addParameters(compiledEntry, varRangeMap); /* In the future: addLocals(compiledEntry, varRangeMap); */ @@ -168,50 +172,46 @@ private void buildFunction(CompiledMethodEntry compiledEntry) { addLineNumberRecords(compiledEntry); } - void addParameters(CompiledMethodEntry primaryEntry, HashMap> varRangeMap) { - final Range primaryRange = primaryEntry.getPrimary(); + void addParameters(CompiledMethodEntry primaryEntry, Map> varRangeMap) { + final Range primaryRange = primaryEntry.primary(); /* The name as exposed to the linker. */ final String externalName = primaryRange.getSymbolName(); - final MethodEntry method = primaryRange.isPrimary() ? primaryRange.getMethodEntry() : primaryRange.getFirstCallee().getMethodEntry(); + final MethodEntry method = primaryRange.isPrimary() ? primaryRange.getMethodEntry() : primaryRange.getCallees().getFirst().getMethodEntry(); /* define 'this' as a local just as we define other object pointers */ if (!Modifier.isStatic(method.getModifiers())) { - final TypeEntry typeEntry = primaryEntry.getClassEntry(); - DebugInfoProvider.DebugLocalInfo thisparam = method.getThisParam(); + final TypeEntry typeEntry = primaryEntry.ownerType(); + LocalEntry thisParam = method.getThisParam(); final int typeIndex = cvDebugInfo.getCVTypeSection().getIndexForPointer(typeEntry); - emitLocal(thisparam, varRangeMap, thisparam.name(), typeEntry, typeIndex, true, externalName, primaryRange); + emitLocal(thisParam, varRangeMap, thisParam.name(), typeEntry, typeIndex, true, externalName, primaryRange); } /* define function parameters */ - for (int i = 0; i < method.getParamCount(); i++) { - final DebugInfoProvider.DebugLocalInfo paramInfo = method.getParam(i); - final TypeEntry typeEntry = method.getParamType(i); + for (LocalEntry paramInfo : method.getParams()) { + final TypeEntry typeEntry = paramInfo.type(); final int typeIndex = cvDebugInfo.getCVTypeSection().addTypeRecords(typeEntry).getSequenceNumber(); emitLocal(paramInfo, varRangeMap, paramInfo.name(), typeEntry, typeIndex, true, externalName, primaryRange); } } - private static int infoTypeToInt(DebugInfoProvider.DebugLocalValueInfo info) { - switch (info.localKind()) { - case REGISTER: - return info.regIndex(); - case STACKSLOT: - return -info.stackSlot(); - default: - return 0; + private static int infoTypeToInt(LocalValueEntry info) { + return switch (info) { + case RegisterValueEntry p -> p.regIndex(); + case StackValueEntry p -> -p.stackSlot(); + default -> 0; } - } +; } - void emitLocal(DebugInfoProvider.DebugLocalInfo info, HashMap> varRangeMap, String name, TypeEntry typeEntry, int typeIndex, boolean isParam, + void emitLocal(LocalEntry info, Map> varRangeMap, String name, TypeEntry typeEntry, int typeIndex, boolean isParam, String procName, Range range) { int flags = isParam ? S_LOCAL_FLAGS_IS_PARAM : 0; - List ranges = varRangeMap.get(info); + List ranges = varRangeMap.get(info); addSymbolRecord(new CVSymbolSubrecord.CVSymbolLocalRecord(cvDebugInfo, name, typeIndex, flags)); - int currentHigh = Integer.MIN_VALUE; + long currentHigh = Integer.MIN_VALUE; int registerOrSlot = 0; /* -slot or +register or 0=unknown */ CVSymbolSubrecord.CVSymbolDefRangeBase currentRecord = null; - for (SubRange subrange : ranges) { - DebugInfoProvider.DebugLocalValueInfo value = subrange.lookupValue(info); + for (Range subrange : ranges) { + LocalValueEntry value = subrange.lookupValue(info); if (value != null) { if (subrange.getLo() == currentHigh && registerOrSlot == infoTypeToInt(value)) { /* if we can, merge records */ @@ -223,20 +223,25 @@ void emitLocal(DebugInfoProvider.DebugLocalInfo info, HashMap { + short cvreg = CVRegisterUtil.getCVRegister(v.regIndex(), typeEntry); + currentRecord = new CVSymbolSubrecord.CVSymbolDefRangeRegisterRecord(cvDebugInfo, procName, (int) (subrange.getLo() - range.getLo()), (short) (subrange.getHi() - subrange.getLo()), cvreg); + addSymbolRecord(currentRecord); + } + case StackValueEntry v -> { + currentRecord = new CVSymbolSubrecord.CVSymbolDefRangeFramepointerRel(cvDebugInfo, procName, (int) (subrange.getLo() - range.getLo()), (short) (subrange.getHi() - subrange.getLo()), + v.stackSlot()); + addSymbolRecord(currentRecord); + } + case ConstantValueEntry v -> { + /* For now, silently ignore constant definitions an parameters. */ + /* JavaConstant constant = value.constantValue(); */ + } + default -> { + /* Unimplemented - this is a surprise. */ + assert (false); + } } } } diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java index 9b67dd972e21..9dcd6233602c 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java @@ -149,8 +149,8 @@ CVTypeRecord buildType(TypeEntry typeEntry) { CVTypeRecord buildFunction(CompiledMethodEntry entry) { ClassEntry ownerType = entry.ownerType(); assert ownerType != null; - CVTypeRecord.CVTypeMFunctionRecord mFunctionRecord = buildMemberFunction(ownerType, entry.getPrimary().getMethodEntry()); - return buildFuncIdRecord(mFunctionRecord, entry.getPrimary().getMethodName()); + CVTypeRecord.CVTypeMFunctionRecord mFunctionRecord = buildMemberFunction(ownerType, entry.primary().getMethodEntry()); + return buildFuncIdRecord(mFunctionRecord, entry.primary().getMethodName()); } static class FieldListBuilder { @@ -309,7 +309,7 @@ private CVTypeRecord buildStructureTypeEntry(final StructureTypeEntry typeEntry) fieldListBuilder.addField(btype); } - if (typeEntry.isHeader()) { + if (typeEntry instanceof HeaderTypeEntry) { FieldEntry hubField = ((HeaderTypeEntry) typeEntry).getHubField(); log("field %s attr=(%s) offset=%d size=%d valuetype=%s", hubField.fieldName(), hubField.getModifiersString(), hubField.getOffset(), hubField.getSize(), hubField.getValueType().getTypeName()); From 6ac77fb46dddfabbb52791d97cbd42f741245095 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Thu, 31 Jul 2025 15:49:09 -0400 Subject: [PATCH 38/48] fix up varinfo pr --- .../oracle/objectfile/pecoff/cv/CVLineRecordBuilder.java | 6 +++--- .../objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java | 2 ++ .../oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java | 2 +- .../src/com/oracle/svm/core/util/EnvVariableUtils.java | 3 +-- .../svm/hosted/TemporaryBuildDirectoryProviderImpl.java | 6 +++--- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVLineRecordBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVLineRecordBuilder.java index 34fc589c8780..46f2c52b7736 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVLineRecordBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVLineRecordBuilder.java @@ -59,16 +59,16 @@ public void debug(String format, Object... args) { */ CVLineRecord build(CompiledMethodEntry entry) { this.compiledEntry = entry; - Range primaryRange = compiledEntry.getPrimary(); + Range primaryRange = compiledEntry.primary(); debug("DEBUG_S_LINES linerecord for 0x%05x file: %s:%d", primaryRange.getLo(), primaryRange.getFileName(), primaryRange.getLine()); this.lineRecord = new CVLineRecord(cvDebugInfo, primaryRange.getSymbolName()); debug("CVLineRecord.computeContents: processing primary range %s", primaryRange); processRange(primaryRange); - Iterator iterator = compiledEntry.leafRangeIterator(); + Iterator iterator = compiledEntry.leafRangeStream().iterator(); while (iterator.hasNext()) { - SubRange subRange = iterator.next(); + Range subRange = iterator.next(); debug("CVLineRecord.computeContents: processing range %s", subRange); processRange(subRange); } diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java index c7a1e1ba9ed5..d08699f4a201 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java @@ -46,6 +46,8 @@ import java.util.Map; import static com.oracle.objectfile.pecoff.cv.CVRegisterUtil.CV_AMD64_R8; +import static com.oracle.objectfile.pecoff.cv.CVSymbolSubrecord.CVSymbolFrameProcRecord.FRAME_LOCAL_BP; +import static com.oracle.objectfile.pecoff.cv.CVSymbolSubrecord.CVSymbolFrameProcRecord.FRAME_PARAM_BP; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.MAX_PRIMITIVE; import static com.oracle.objectfile.pecoff.cv.CVRegisterUtil.CV_AMD64_R8; diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java index 4931aae10801..5d42b3821482 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java @@ -117,7 +117,7 @@ CVTypeRecord buildType(TypeEntry typeEntry) { * If we've never seen the class or only defined it as a forward reference, define it now. */ if (typeRecord != null && typeRecord.type == LF_CLASS && !((CVTypeRecord.CVClassRecord) typeRecord).isForwardRef()) { - log("buildType() type %s(%s) is known %s", typeEntry.getTypeName(), typeEntry.getClass().getTypeName(); typeRecord); + log("buildType() type %s(%s) is known %s", typeEntry.getTypeName(), typeEntry.getClass().getTypeName(), typeRecord); } else { log("buildType() %s %s size=%d - begin", typeEntry.getClass().getTypeName(), typeEntry.getTypeName(), typeEntry.getSize()); switch (typeEntry) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/EnvVariableUtils.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/EnvVariableUtils.java index 43a5884f6eed..f4faed834355 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/EnvVariableUtils.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/EnvVariableUtils.java @@ -82,8 +82,7 @@ public boolean isKeyRequired() { } public static boolean isKeyRequired(String key) { - mapKey(key); - return isKeyRequiredCondition(key); + return isKeyRequiredCondition(mapKey(key)); } private static String mapKey(String key) { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/TemporaryBuildDirectoryProviderImpl.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/TemporaryBuildDirectoryProviderImpl.java index db983240dda8..d008f5b400b9 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/TemporaryBuildDirectoryProviderImpl.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/TemporaryBuildDirectoryProviderImpl.java @@ -50,11 +50,11 @@ public synchronized Path getTemporaryBuildDirectory() { if (tempDirectory == null) { try { if (tempDirectoryOptionValue == null) { - tempDirectory = Files.createTempDirectory("SVM-"); + tempDirectory = Files.createTempDirectory("SXX-"); deleteTempDirectory = true; } else { - tempDirectory = tempDirectoryOptionValue.resolve("SVM-" + TimeUtils.currentTimeMillis()); - assert !Files.exists(tempDirectory); + tempDirectory = tempDirectoryOptionValue.resolve("SVM-" + 0); + //assert !Files.exists(tempDirectory); Files.createDirectories(tempDirectory); } } catch (IOException ex) { From 29e725a94f5df137bfcef7dbafee480e4a10853f Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Tue, 12 Aug 2025 15:37:59 -0400 Subject: [PATCH 39/48] fixes for new Method API --- .../pecoff/cv/CVSymbolSubsectionBuilder.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java index d08699f4a201..ad915cf00b33 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java @@ -176,19 +176,14 @@ void addParameters(CompiledMethodEntry primaryEntry, Map final String externalName = primaryRange.getSymbolName(); final MethodEntry method = primaryRange.isPrimary() ? primaryRange.getMethodEntry() : primaryRange.getCallees().getFirst().getMethodEntry(); - /* define 'this' as a local just as we define other object pointers */ - if (!Modifier.isStatic(method.getModifiers())) { - final TypeEntry typeEntry = primaryEntry.ownerType(); - LocalEntry thisParam = method.getThisParam(); - final int typeIndex = cvDebugInfo.getCVTypeSection().getIndexForPointer(typeEntry); - emitLocal(thisParam, varRangeMap, thisParam.name(), typeEntry, typeIndex, true, externalName, primaryRange); - } - /* define function parameters */ + assert Modifier.isStatic(method.getModifiers()) || !method.getParams().isEmpty(); for (LocalEntry paramInfo : method.getParams()) { - final TypeEntry typeEntry = paramInfo.type(); - final int typeIndex = cvDebugInfo.getCVTypeSection().addTypeRecords(typeEntry).getSequenceNumber(); - emitLocal(paramInfo, varRangeMap, paramInfo.name(), typeEntry, typeIndex, true, externalName, primaryRange); + final TypeEntry paramType = paramInfo.type(); + final int typeIndex = method.isThisParam(paramInfo) + ? cvDebugInfo.getCVTypeSection().getIndexForPointer(paramType) + : cvDebugInfo.getCVTypeSection().addTypeRecords(paramType).getSequenceNumber(); + emitLocal(paramInfo, varRangeMap, paramInfo.name(), paramType, typeIndex, true, externalName, primaryRange); } } From 33449e44f05f9983def472c5670ae1b453306a69 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Wed, 13 Aug 2025 08:30:30 -0400 Subject: [PATCH 40/48] revert test files --- .../src/com/oracle/svm/core/util/EnvVariableUtils.java | 3 ++- .../svm/hosted/TemporaryBuildDirectoryProviderImpl.java | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/EnvVariableUtils.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/EnvVariableUtils.java index f4faed834355..43a5884f6eed 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/EnvVariableUtils.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/EnvVariableUtils.java @@ -82,7 +82,8 @@ public boolean isKeyRequired() { } public static boolean isKeyRequired(String key) { - return isKeyRequiredCondition(mapKey(key)); + mapKey(key); + return isKeyRequiredCondition(key); } private static String mapKey(String key) { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/TemporaryBuildDirectoryProviderImpl.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/TemporaryBuildDirectoryProviderImpl.java index d008f5b400b9..db983240dda8 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/TemporaryBuildDirectoryProviderImpl.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/TemporaryBuildDirectoryProviderImpl.java @@ -50,11 +50,11 @@ public synchronized Path getTemporaryBuildDirectory() { if (tempDirectory == null) { try { if (tempDirectoryOptionValue == null) { - tempDirectory = Files.createTempDirectory("SXX-"); + tempDirectory = Files.createTempDirectory("SVM-"); deleteTempDirectory = true; } else { - tempDirectory = tempDirectoryOptionValue.resolve("SVM-" + 0); - //assert !Files.exists(tempDirectory); + tempDirectory = tempDirectoryOptionValue.resolve("SVM-" + TimeUtils.currentTimeMillis()); + assert !Files.exists(tempDirectory); Files.createDirectories(tempDirectory); } } catch (IOException ex) { From 945f1cb338460424f5ff3c571eb3c7dc92a24139 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Thu, 21 Aug 2025 11:08:24 -0400 Subject: [PATCH 41/48] remove duplicate import --- .../oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java | 1 - 1 file changed, 1 deletion(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java index ad915cf00b33..2730662037d6 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java @@ -49,7 +49,6 @@ import static com.oracle.objectfile.pecoff.cv.CVSymbolSubrecord.CVSymbolFrameProcRecord.FRAME_LOCAL_BP; import static com.oracle.objectfile.pecoff.cv.CVSymbolSubrecord.CVSymbolFrameProcRecord.FRAME_PARAM_BP; import static com.oracle.objectfile.pecoff.cv.CVTypeConstants.MAX_PRIMITIVE; -import static com.oracle.objectfile.pecoff.cv.CVRegisterUtil.CV_AMD64_R8; final class CVSymbolSubsectionBuilder { From 3d06cb377f0e7d5dca00afb3fa396fa444213e12 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Thu, 21 Aug 2025 12:33:07 -0400 Subject: [PATCH 42/48] changes for graal gate --- .../objectfile/pecoff/cv/CVRegisterUtil.java | 68 +++++++++---------- .../pecoff/cv/CVSymbolSubsectionBuilder.java | 16 +++-- 2 files changed, 43 insertions(+), 41 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java index f4cbd91566f3..9995dec7c376 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java @@ -198,41 +198,41 @@ private static class CvRegDef { /* List of Graal assignable registers and CodeView register IDs. */ private static final CvRegDef[] compactRegDefs = { - /* 8, 16, 32, 64 bits */ - new CvRegDef(AMD64.rax, CV_AMD64_AL, CV_AMD64_AX, CV_AMD64_EAX, CV_AMD64_RAX), - new CvRegDef(AMD64.rcx, CV_AMD64_CL, CV_AMD64_CX, CV_AMD64_ECX, CV_AMD64_RCX), - new CvRegDef(AMD64.rdx, CV_AMD64_DL, CV_AMD64_DX, CV_AMD64_EDX, CV_AMD64_RDX), - new CvRegDef(AMD64.rbx, CV_AMD64_BL, CV_AMD64_BX, CV_AMD64_EBX, CV_AMD64_RBX), - new CvRegDef(AMD64.rsp, CV_AMD64_SPL, CV_AMD64_SP, CV_AMD64_ESP, CV_AMD64_RSP), - new CvRegDef(AMD64.rbp, CV_AMD64_BPL, CV_AMD64_BP, CV_AMD64_EBP, CV_AMD64_RBP), - new CvRegDef(AMD64.rsi, CV_AMD64_SIL, CV_AMD64_SI, CV_AMD64_ESI, CV_AMD64_RSI), - new CvRegDef(AMD64.rdi, CV_AMD64_DIL, CV_AMD64_DI, CV_AMD64_EDI, CV_AMD64_RDI), - new CvRegDef(AMD64.r8, CV_AMD64_R8B, CV_AMD64_R8W, CV_AMD64_R8D, CV_AMD64_R8), - new CvRegDef(AMD64.r9, CV_AMD64_R9B, CV_AMD64_R9W, CV_AMD64_R9D, CV_AMD64_R9), - new CvRegDef(AMD64.r10, CV_AMD64_R10B, CV_AMD64_R10W, CV_AMD64_R10D, CV_AMD64_R10), - new CvRegDef(AMD64.r11, CV_AMD64_R11B, CV_AMD64_R11W, CV_AMD64_R11D, CV_AMD64_R11), - new CvRegDef(AMD64.r12, CV_AMD64_R12B, CV_AMD64_R12W, CV_AMD64_R12D, CV_AMD64_R12), - new CvRegDef(AMD64.r13, CV_AMD64_R13B, CV_AMD64_R13W, CV_AMD64_R13D, CV_AMD64_R13), - new CvRegDef(AMD64.r14, CV_AMD64_R14B, CV_AMD64_R14W, CV_AMD64_R14D, CV_AMD64_R14), - new CvRegDef(AMD64.r15, CV_AMD64_R15B, CV_AMD64_R15W, CV_AMD64_R15D, CV_AMD64_R15), + /* 8, 16, 32, 64 bits */ + new CvRegDef(AMD64.rax, CV_AMD64_AL, CV_AMD64_AX, CV_AMD64_EAX, CV_AMD64_RAX), + new CvRegDef(AMD64.rcx, CV_AMD64_CL, CV_AMD64_CX, CV_AMD64_ECX, CV_AMD64_RCX), + new CvRegDef(AMD64.rdx, CV_AMD64_DL, CV_AMD64_DX, CV_AMD64_EDX, CV_AMD64_RDX), + new CvRegDef(AMD64.rbx, CV_AMD64_BL, CV_AMD64_BX, CV_AMD64_EBX, CV_AMD64_RBX), + new CvRegDef(AMD64.rsp, CV_AMD64_SPL, CV_AMD64_SP, CV_AMD64_ESP, CV_AMD64_RSP), + new CvRegDef(AMD64.rbp, CV_AMD64_BPL, CV_AMD64_BP, CV_AMD64_EBP, CV_AMD64_RBP), + new CvRegDef(AMD64.rsi, CV_AMD64_SIL, CV_AMD64_SI, CV_AMD64_ESI, CV_AMD64_RSI), + new CvRegDef(AMD64.rdi, CV_AMD64_DIL, CV_AMD64_DI, CV_AMD64_EDI, CV_AMD64_RDI), + new CvRegDef(AMD64.r8, CV_AMD64_R8B, CV_AMD64_R8W, CV_AMD64_R8D, CV_AMD64_R8), + new CvRegDef(AMD64.r9, CV_AMD64_R9B, CV_AMD64_R9W, CV_AMD64_R9D, CV_AMD64_R9), + new CvRegDef(AMD64.r10, CV_AMD64_R10B, CV_AMD64_R10W, CV_AMD64_R10D, CV_AMD64_R10), + new CvRegDef(AMD64.r11, CV_AMD64_R11B, CV_AMD64_R11W, CV_AMD64_R11D, CV_AMD64_R11), + new CvRegDef(AMD64.r12, CV_AMD64_R12B, CV_AMD64_R12W, CV_AMD64_R12D, CV_AMD64_R12), + new CvRegDef(AMD64.r13, CV_AMD64_R13B, CV_AMD64_R13W, CV_AMD64_R13D, CV_AMD64_R13), + new CvRegDef(AMD64.r14, CV_AMD64_R14B, CV_AMD64_R14W, CV_AMD64_R14D, CV_AMD64_R14), + new CvRegDef(AMD64.r15, CV_AMD64_R15B, CV_AMD64_R15W, CV_AMD64_R15D, CV_AMD64_R15), - /* 32, 64 bits */ - new CvRegDef(AMD64.xmm0, CV_AMD64_XMM0_0, CV_AMD64_XMM0L), /* xmm0=16 */ - new CvRegDef(AMD64.xmm1, CV_AMD64_XMM1_0, CV_AMD64_XMM1L), - new CvRegDef(AMD64.xmm2, CV_AMD64_XMM2_0, CV_AMD64_XMM2L), - new CvRegDef(AMD64.xmm3, CV_AMD64_XMM3_0, CV_AMD64_XMM3L), - new CvRegDef(AMD64.xmm4, CV_AMD64_XMM4_0, CV_AMD64_XMM4L), - new CvRegDef(AMD64.xmm5, CV_AMD64_XMM5_0, CV_AMD64_XMM5L), - new CvRegDef(AMD64.xmm6, CV_AMD64_XMM6_0, CV_AMD64_XMM6L), - new CvRegDef(AMD64.xmm7, CV_AMD64_XMM7_0, CV_AMD64_XMM7L), - new CvRegDef(AMD64.xmm8, CV_AMD64_XMM8_0, CV_AMD64_XMM8L), - new CvRegDef(AMD64.xmm9, CV_AMD64_XMM9_0, CV_AMD64_XMM9L), - new CvRegDef(AMD64.xmm10, CV_AMD64_XMM10_0, CV_AMD64_XMM10L), - new CvRegDef(AMD64.xmm11, CV_AMD64_XMM11_0, CV_AMD64_XMM11L), - new CvRegDef(AMD64.xmm12, CV_AMD64_XMM12_0, CV_AMD64_XMM12L), - new CvRegDef(AMD64.xmm13, CV_AMD64_XMM13_0, CV_AMD64_XMM13L), - new CvRegDef(AMD64.xmm14, CV_AMD64_XMM14_0, CV_AMD64_XMM14L), - new CvRegDef(AMD64.xmm15, CV_AMD64_XMM15_0, CV_AMD64_XMM15L), + /* 32, 64 bits */ + new CvRegDef(AMD64.xmm0, CV_AMD64_XMM0_0, CV_AMD64_XMM0L), /* xmm0=16 */ + new CvRegDef(AMD64.xmm1, CV_AMD64_XMM1_0, CV_AMD64_XMM1L), + new CvRegDef(AMD64.xmm2, CV_AMD64_XMM2_0, CV_AMD64_XMM2L), + new CvRegDef(AMD64.xmm3, CV_AMD64_XMM3_0, CV_AMD64_XMM3L), + new CvRegDef(AMD64.xmm4, CV_AMD64_XMM4_0, CV_AMD64_XMM4L), + new CvRegDef(AMD64.xmm5, CV_AMD64_XMM5_0, CV_AMD64_XMM5L), + new CvRegDef(AMD64.xmm6, CV_AMD64_XMM6_0, CV_AMD64_XMM6L), + new CvRegDef(AMD64.xmm7, CV_AMD64_XMM7_0, CV_AMD64_XMM7L), + new CvRegDef(AMD64.xmm8, CV_AMD64_XMM8_0, CV_AMD64_XMM8L), + new CvRegDef(AMD64.xmm9, CV_AMD64_XMM9_0, CV_AMD64_XMM9L), + new CvRegDef(AMD64.xmm10, CV_AMD64_XMM10_0, CV_AMD64_XMM10L), + new CvRegDef(AMD64.xmm11, CV_AMD64_XMM11_0, CV_AMD64_XMM11L), + new CvRegDef(AMD64.xmm12, CV_AMD64_XMM12_0, CV_AMD64_XMM12L), + new CvRegDef(AMD64.xmm13, CV_AMD64_XMM13_0, CV_AMD64_XMM13L), + new CvRegDef(AMD64.xmm14, CV_AMD64_XMM14_0, CV_AMD64_XMM14L), + new CvRegDef(AMD64.xmm15, CV_AMD64_XMM15_0, CV_AMD64_XMM15L), }; private static final CvRegDef[] javaToCvRegisters = new CvRegDef[MAX_JAVA_REGISTER_NUMBER + 1]; diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java index 2730662037d6..fee81ad1d1b8 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java @@ -180,8 +180,8 @@ void addParameters(CompiledMethodEntry primaryEntry, Map for (LocalEntry paramInfo : method.getParams()) { final TypeEntry paramType = paramInfo.type(); final int typeIndex = method.isThisParam(paramInfo) - ? cvDebugInfo.getCVTypeSection().getIndexForPointer(paramType) - : cvDebugInfo.getCVTypeSection().addTypeRecords(paramType).getSequenceNumber(); + ? cvDebugInfo.getCVTypeSection().getIndexForPointer(paramType) + : cvDebugInfo.getCVTypeSection().addTypeRecords(paramType).getSequenceNumber(); emitLocal(paramInfo, varRangeMap, paramInfo.name(), paramType, typeIndex, true, externalName, primaryRange); } } @@ -220,17 +220,19 @@ void emitLocal(LocalEntry info, Map> varRangeMap, String short cvreg = CVRegisterUtil.getCVRegister(v.regIndex(), typeEntry); /* * It could be that Graal has allocated a register that we don't know how to - * represent in CodeView. In that case, getCVRegister() will return a negative - * number and no local variable record is issued. + * represent in CodeView. In that case, getCVRegister() will return a + * negative number and no local variable record is issued. */ if (cvreg >= 0) { - currentRecord = new CVSymbolSubrecord.CVSymbolDefRangeRegisterRecord(cvDebugInfo, procName, (int) (subrange.getLo() - range.getLo()), (short) (subrange.getHi() - subrange.getLo()), cvreg); + currentRecord = new CVSymbolSubrecord.CVSymbolDefRangeRegisterRecord(cvDebugInfo, procName, (int) (subrange.getLo() - range.getLo()), + (short) (subrange.getHi() - subrange.getLo()), cvreg); addSymbolRecord(currentRecord); } } case StackValueEntry v -> { - currentRecord = new CVSymbolSubrecord.CVSymbolDefRangeFramepointerRel(cvDebugInfo, procName, (int) (subrange.getLo() - range.getLo()), (short) (subrange.getHi() - subrange.getLo()), - v.stackSlot()); + currentRecord = new CVSymbolSubrecord.CVSymbolDefRangeFramepointerRel(cvDebugInfo, procName, (int) (subrange.getLo() - range.getLo()), + (short) (subrange.getHi() - subrange.getLo()), + v.stackSlot()); addSymbolRecord(currentRecord); } case ConstantValueEntry v -> { From 03b2e1de3d0b6dcc4f62ddf2605a3eafa0675d1a Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Thu, 21 Aug 2025 12:46:08 -0400 Subject: [PATCH 43/48] changes for graal checkstyle --- .../src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java index 9995dec7c376..6e1e7e1ea7d9 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java @@ -267,7 +267,8 @@ static short getCVRegister(int javaReg, TypeEntry typeEntry) { case 8 -> cvReg.cv8; default -> -1; }; - } else {/* Objects are represented by 8 byte pointers. */ + } else { + /* Objects are represented by 8 byte pointers. */ cvCode = cvReg.cv8; } assert cvCode != -1; From 69894e3ad4c8e8a9de133b78f9fe50c204677e5b Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Tue, 23 Sep 2025 10:35:24 -0400 Subject: [PATCH 44/48] changes from code review --- .../objectfile/pecoff/cv/CVRegisterUtil.java | 108 ++++++++++-------- .../objectfile/pecoff/cv/CVSectionImpl.java | 4 + .../pecoff/cv/CVSymbolSubsectionBuilder.java | 4 +- 3 files changed, 67 insertions(+), 49 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java index 6e1e7e1ea7d9..a96149764e30 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java @@ -146,13 +146,13 @@ public class CVRegisterUtil { private static final short CV_AMD64_XMM7_0 = 190; private static final short CV_AMD64_XMM8_0 = 260; - private static final short CV_AMD64_XMM9_0 = 261; - private static final short CV_AMD64_XMM10_0 = 262; - private static final short CV_AMD64_XMM11_0 = 263; - private static final short CV_AMD64_XMM12_0 = 264; - private static final short CV_AMD64_XMM13_0 = 265; - private static final short CV_AMD64_XMM14_0 = 266; - private static final short CV_AMD64_XMM15_0 = 267; + private static final short CV_AMD64_XMM9_0 = 264; + private static final short CV_AMD64_XMM10_0 = 268; + private static final short CV_AMD64_XMM11_0 = 272; + private static final short CV_AMD64_XMM12_0 = 276; + private static final short CV_AMD64_XMM13_0 = 280; + private static final short CV_AMD64_XMM14_0 = 284; + private static final short CV_AMD64_XMM15_0 = 288; private static final short CV_AMD64_XMM0L = 194; private static final short CV_AMD64_XMM1L = 195; @@ -196,70 +196,81 @@ private static class CvRegDef { } } - /* List of Graal assignable registers and CodeView register IDs. */ - private static final CvRegDef[] compactRegDefs = { - /* 8, 16, 32, 64 bits */ - new CvRegDef(AMD64.rax, CV_AMD64_AL, CV_AMD64_AX, CV_AMD64_EAX, CV_AMD64_RAX), - new CvRegDef(AMD64.rcx, CV_AMD64_CL, CV_AMD64_CX, CV_AMD64_ECX, CV_AMD64_RCX), - new CvRegDef(AMD64.rdx, CV_AMD64_DL, CV_AMD64_DX, CV_AMD64_EDX, CV_AMD64_RDX), - new CvRegDef(AMD64.rbx, CV_AMD64_BL, CV_AMD64_BX, CV_AMD64_EBX, CV_AMD64_RBX), - new CvRegDef(AMD64.rsp, CV_AMD64_SPL, CV_AMD64_SP, CV_AMD64_ESP, CV_AMD64_RSP), - new CvRegDef(AMD64.rbp, CV_AMD64_BPL, CV_AMD64_BP, CV_AMD64_EBP, CV_AMD64_RBP), - new CvRegDef(AMD64.rsi, CV_AMD64_SIL, CV_AMD64_SI, CV_AMD64_ESI, CV_AMD64_RSI), - new CvRegDef(AMD64.rdi, CV_AMD64_DIL, CV_AMD64_DI, CV_AMD64_EDI, CV_AMD64_RDI), - new CvRegDef(AMD64.r8, CV_AMD64_R8B, CV_AMD64_R8W, CV_AMD64_R8D, CV_AMD64_R8), - new CvRegDef(AMD64.r9, CV_AMD64_R9B, CV_AMD64_R9W, CV_AMD64_R9D, CV_AMD64_R9), - new CvRegDef(AMD64.r10, CV_AMD64_R10B, CV_AMD64_R10W, CV_AMD64_R10D, CV_AMD64_R10), - new CvRegDef(AMD64.r11, CV_AMD64_R11B, CV_AMD64_R11W, CV_AMD64_R11D, CV_AMD64_R11), - new CvRegDef(AMD64.r12, CV_AMD64_R12B, CV_AMD64_R12W, CV_AMD64_R12D, CV_AMD64_R12), - new CvRegDef(AMD64.r13, CV_AMD64_R13B, CV_AMD64_R13W, CV_AMD64_R13D, CV_AMD64_R13), - new CvRegDef(AMD64.r14, CV_AMD64_R14B, CV_AMD64_R14W, CV_AMD64_R14D, CV_AMD64_R14), - new CvRegDef(AMD64.r15, CV_AMD64_R15B, CV_AMD64_R15W, CV_AMD64_R15D, CV_AMD64_R15), - - /* 32, 64 bits */ - new CvRegDef(AMD64.xmm0, CV_AMD64_XMM0_0, CV_AMD64_XMM0L), /* xmm0=16 */ - new CvRegDef(AMD64.xmm1, CV_AMD64_XMM1_0, CV_AMD64_XMM1L), - new CvRegDef(AMD64.xmm2, CV_AMD64_XMM2_0, CV_AMD64_XMM2L), - new CvRegDef(AMD64.xmm3, CV_AMD64_XMM3_0, CV_AMD64_XMM3L), - new CvRegDef(AMD64.xmm4, CV_AMD64_XMM4_0, CV_AMD64_XMM4L), - new CvRegDef(AMD64.xmm5, CV_AMD64_XMM5_0, CV_AMD64_XMM5L), - new CvRegDef(AMD64.xmm6, CV_AMD64_XMM6_0, CV_AMD64_XMM6L), - new CvRegDef(AMD64.xmm7, CV_AMD64_XMM7_0, CV_AMD64_XMM7L), - new CvRegDef(AMD64.xmm8, CV_AMD64_XMM8_0, CV_AMD64_XMM8L), - new CvRegDef(AMD64.xmm9, CV_AMD64_XMM9_0, CV_AMD64_XMM9L), - new CvRegDef(AMD64.xmm10, CV_AMD64_XMM10_0, CV_AMD64_XMM10L), - new CvRegDef(AMD64.xmm11, CV_AMD64_XMM11_0, CV_AMD64_XMM11L), - new CvRegDef(AMD64.xmm12, CV_AMD64_XMM12_0, CV_AMD64_XMM12L), - new CvRegDef(AMD64.xmm13, CV_AMD64_XMM13_0, CV_AMD64_XMM13L), - new CvRegDef(AMD64.xmm14, CV_AMD64_XMM14_0, CV_AMD64_XMM14L), - new CvRegDef(AMD64.xmm15, CV_AMD64_XMM15_0, CV_AMD64_XMM15L), - }; - private static final CvRegDef[] javaToCvRegisters = new CvRegDef[MAX_JAVA_REGISTER_NUMBER + 1]; static { + /* List of Graal assignable registers and CodeView register IDs. */ + final CvRegDef[] compactRegDefs = { + /* 8, 16, 32, 64 bits */ + new CvRegDef(AMD64.rax, CV_AMD64_AL, CV_AMD64_AX, CV_AMD64_EAX, CV_AMD64_RAX), + new CvRegDef(AMD64.rcx, CV_AMD64_CL, CV_AMD64_CX, CV_AMD64_ECX, CV_AMD64_RCX), + new CvRegDef(AMD64.rdx, CV_AMD64_DL, CV_AMD64_DX, CV_AMD64_EDX, CV_AMD64_RDX), + new CvRegDef(AMD64.rbx, CV_AMD64_BL, CV_AMD64_BX, CV_AMD64_EBX, CV_AMD64_RBX), + new CvRegDef(AMD64.rsp, CV_AMD64_SPL, CV_AMD64_SP, CV_AMD64_ESP, CV_AMD64_RSP), + new CvRegDef(AMD64.rbp, CV_AMD64_BPL, CV_AMD64_BP, CV_AMD64_EBP, CV_AMD64_RBP), + new CvRegDef(AMD64.rsi, CV_AMD64_SIL, CV_AMD64_SI, CV_AMD64_ESI, CV_AMD64_RSI), + new CvRegDef(AMD64.rdi, CV_AMD64_DIL, CV_AMD64_DI, CV_AMD64_EDI, CV_AMD64_RDI), + new CvRegDef(AMD64.r8, CV_AMD64_R8B, CV_AMD64_R8W, CV_AMD64_R8D, CV_AMD64_R8), + new CvRegDef(AMD64.r9, CV_AMD64_R9B, CV_AMD64_R9W, CV_AMD64_R9D, CV_AMD64_R9), + new CvRegDef(AMD64.r10, CV_AMD64_R10B, CV_AMD64_R10W, CV_AMD64_R10D, CV_AMD64_R10), + new CvRegDef(AMD64.r11, CV_AMD64_R11B, CV_AMD64_R11W, CV_AMD64_R11D, CV_AMD64_R11), + new CvRegDef(AMD64.r12, CV_AMD64_R12B, CV_AMD64_R12W, CV_AMD64_R12D, CV_AMD64_R12), + new CvRegDef(AMD64.r13, CV_AMD64_R13B, CV_AMD64_R13W, CV_AMD64_R13D, CV_AMD64_R13), + new CvRegDef(AMD64.r14, CV_AMD64_R14B, CV_AMD64_R14W, CV_AMD64_R14D, CV_AMD64_R14), + new CvRegDef(AMD64.r15, CV_AMD64_R15B, CV_AMD64_R15W, CV_AMD64_R15D, CV_AMD64_R15), + + /* 32, 64 bits */ + new CvRegDef(AMD64.xmm0, CV_AMD64_XMM0_0, CV_AMD64_XMM0L), /* xmm0=16 */ + new CvRegDef(AMD64.xmm1, CV_AMD64_XMM1_0, CV_AMD64_XMM1L), + new CvRegDef(AMD64.xmm2, CV_AMD64_XMM2_0, CV_AMD64_XMM2L), + new CvRegDef(AMD64.xmm3, CV_AMD64_XMM3_0, CV_AMD64_XMM3L), + new CvRegDef(AMD64.xmm4, CV_AMD64_XMM4_0, CV_AMD64_XMM4L), + new CvRegDef(AMD64.xmm5, CV_AMD64_XMM5_0, CV_AMD64_XMM5L), + new CvRegDef(AMD64.xmm6, CV_AMD64_XMM6_0, CV_AMD64_XMM6L), + new CvRegDef(AMD64.xmm7, CV_AMD64_XMM7_0, CV_AMD64_XMM7L), + new CvRegDef(AMD64.xmm8, CV_AMD64_XMM8_0, CV_AMD64_XMM8L), + new CvRegDef(AMD64.xmm9, CV_AMD64_XMM9_0, CV_AMD64_XMM9L), + new CvRegDef(AMD64.xmm10, CV_AMD64_XMM10_0, CV_AMD64_XMM10L), + new CvRegDef(AMD64.xmm11, CV_AMD64_XMM11_0, CV_AMD64_XMM11L), + new CvRegDef(AMD64.xmm12, CV_AMD64_XMM12_0, CV_AMD64_XMM12L), + new CvRegDef(AMD64.xmm13, CV_AMD64_XMM13_0, CV_AMD64_XMM13L), + new CvRegDef(AMD64.xmm14, CV_AMD64_XMM14_0, CV_AMD64_XMM14L), + new CvRegDef(AMD64.xmm15, CV_AMD64_XMM15_0, CV_AMD64_XMM15L), + }; + for (CvRegDef def : compactRegDefs) { assert 0 <= def.register.number && def.register.number <= MAX_JAVA_REGISTER_NUMBER; javaToCvRegisters[def.register.number] = def; } } - /* Convert a Java register number to a CodeView register code */ + /* + * Convert a Java register number to a CodeView register code. + * In release mode, return -1 so caller can emit a warning and continue. + * In debug mode, throw an assert. + * + * This can (and has) happened when Graal is enhanced to use more registers + * but there is no test for that in the test suite. + */ /* the CodeView code depends upon the register type and size */ static short getCVRegister(int javaReg, TypeEntry typeEntry) { assert 0 <= javaReg && javaReg <= MAX_JAVA_REGISTER_NUMBER; if (javaReg > MAX_JAVA_REGISTER_NUMBER) { + /* Register is unimplemented. */ return -1; } CvRegDef cvReg = javaToCvRegisters[javaReg]; assert cvReg != null; - assert cvReg.register.number == javaReg; if (cvReg == null) { + /* Register is unimplemented. */ return -1; } + /* Sanity check */ + assert cvReg.register.number == javaReg; final short cvCode; if (Objects.requireNonNull(typeEntry) instanceof PrimitiveTypeEntry) { + /* Find correct sub-register given the primitive type length. */ cvCode = switch (typeEntry.getSize()) { case 1 -> cvReg.cv1; case 2 -> cvReg.cv2; @@ -271,6 +282,7 @@ static short getCVRegister(int javaReg, TypeEntry typeEntry) { /* Objects are represented by 8 byte pointers. */ cvCode = cvReg.cv8; } + /* Check for unimplemented size. */ assert cvCode != -1; return cvCode; } diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSectionImpl.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSectionImpl.java index 73a23ec78163..584f686846ba 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSectionImpl.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSectionImpl.java @@ -73,6 +73,10 @@ protected void enableLog(DebugContext debugContext) { } } + protected void warn(String format, Object... args) { + System.out.printf("Warning:" + format + "\n", args); + } + protected void log(String format, Object... args) { if (debug) { getDebugContext().logv(DebugContext.INFO_LEVEL, format, args); diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java index fee81ad1d1b8..b685bbc1aaee 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubsectionBuilder.java @@ -221,12 +221,14 @@ void emitLocal(LocalEntry info, Map> varRangeMap, String /* * It could be that Graal has allocated a register that we don't know how to * represent in CodeView. In that case, getCVRegister() will return a - * negative number and no local variable record is issued. + * negative number and no local variable record is issued; instead a warning */ if (cvreg >= 0) { currentRecord = new CVSymbolSubrecord.CVSymbolDefRangeRegisterRecord(cvDebugInfo, procName, (int) (subrange.getLo() - range.getLo()), (short) (subrange.getHi() - subrange.getLo()), cvreg); addSymbolRecord(currentRecord); + } else { + cvDebugInfo.getCVSymbolSection().warn("Register %s unimplemented in Windows debug support", v.toString()); } } case StackValueEntry v -> { From 19328a7431c277d1f10e6ef9dc9d7b5945935e82 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Tue, 23 Sep 2025 11:14:11 -0400 Subject: [PATCH 45/48] fix for Graal style gate --- .../objectfile/pecoff/cv/CVRegisterUtil.java | 77 +++++++++---------- 1 file changed, 38 insertions(+), 39 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java index a96149764e30..23de325df5e2 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVRegisterUtil.java @@ -201,41 +201,41 @@ private static class CvRegDef { static { /* List of Graal assignable registers and CodeView register IDs. */ final CvRegDef[] compactRegDefs = { - /* 8, 16, 32, 64 bits */ - new CvRegDef(AMD64.rax, CV_AMD64_AL, CV_AMD64_AX, CV_AMD64_EAX, CV_AMD64_RAX), - new CvRegDef(AMD64.rcx, CV_AMD64_CL, CV_AMD64_CX, CV_AMD64_ECX, CV_AMD64_RCX), - new CvRegDef(AMD64.rdx, CV_AMD64_DL, CV_AMD64_DX, CV_AMD64_EDX, CV_AMD64_RDX), - new CvRegDef(AMD64.rbx, CV_AMD64_BL, CV_AMD64_BX, CV_AMD64_EBX, CV_AMD64_RBX), - new CvRegDef(AMD64.rsp, CV_AMD64_SPL, CV_AMD64_SP, CV_AMD64_ESP, CV_AMD64_RSP), - new CvRegDef(AMD64.rbp, CV_AMD64_BPL, CV_AMD64_BP, CV_AMD64_EBP, CV_AMD64_RBP), - new CvRegDef(AMD64.rsi, CV_AMD64_SIL, CV_AMD64_SI, CV_AMD64_ESI, CV_AMD64_RSI), - new CvRegDef(AMD64.rdi, CV_AMD64_DIL, CV_AMD64_DI, CV_AMD64_EDI, CV_AMD64_RDI), - new CvRegDef(AMD64.r8, CV_AMD64_R8B, CV_AMD64_R8W, CV_AMD64_R8D, CV_AMD64_R8), - new CvRegDef(AMD64.r9, CV_AMD64_R9B, CV_AMD64_R9W, CV_AMD64_R9D, CV_AMD64_R9), - new CvRegDef(AMD64.r10, CV_AMD64_R10B, CV_AMD64_R10W, CV_AMD64_R10D, CV_AMD64_R10), - new CvRegDef(AMD64.r11, CV_AMD64_R11B, CV_AMD64_R11W, CV_AMD64_R11D, CV_AMD64_R11), - new CvRegDef(AMD64.r12, CV_AMD64_R12B, CV_AMD64_R12W, CV_AMD64_R12D, CV_AMD64_R12), - new CvRegDef(AMD64.r13, CV_AMD64_R13B, CV_AMD64_R13W, CV_AMD64_R13D, CV_AMD64_R13), - new CvRegDef(AMD64.r14, CV_AMD64_R14B, CV_AMD64_R14W, CV_AMD64_R14D, CV_AMD64_R14), - new CvRegDef(AMD64.r15, CV_AMD64_R15B, CV_AMD64_R15W, CV_AMD64_R15D, CV_AMD64_R15), + /* 8, 16, 32, 64 bits */ + new CvRegDef(AMD64.rax, CV_AMD64_AL, CV_AMD64_AX, CV_AMD64_EAX, CV_AMD64_RAX), + new CvRegDef(AMD64.rcx, CV_AMD64_CL, CV_AMD64_CX, CV_AMD64_ECX, CV_AMD64_RCX), + new CvRegDef(AMD64.rdx, CV_AMD64_DL, CV_AMD64_DX, CV_AMD64_EDX, CV_AMD64_RDX), + new CvRegDef(AMD64.rbx, CV_AMD64_BL, CV_AMD64_BX, CV_AMD64_EBX, CV_AMD64_RBX), + new CvRegDef(AMD64.rsp, CV_AMD64_SPL, CV_AMD64_SP, CV_AMD64_ESP, CV_AMD64_RSP), + new CvRegDef(AMD64.rbp, CV_AMD64_BPL, CV_AMD64_BP, CV_AMD64_EBP, CV_AMD64_RBP), + new CvRegDef(AMD64.rsi, CV_AMD64_SIL, CV_AMD64_SI, CV_AMD64_ESI, CV_AMD64_RSI), + new CvRegDef(AMD64.rdi, CV_AMD64_DIL, CV_AMD64_DI, CV_AMD64_EDI, CV_AMD64_RDI), + new CvRegDef(AMD64.r8, CV_AMD64_R8B, CV_AMD64_R8W, CV_AMD64_R8D, CV_AMD64_R8), + new CvRegDef(AMD64.r9, CV_AMD64_R9B, CV_AMD64_R9W, CV_AMD64_R9D, CV_AMD64_R9), + new CvRegDef(AMD64.r10, CV_AMD64_R10B, CV_AMD64_R10W, CV_AMD64_R10D, CV_AMD64_R10), + new CvRegDef(AMD64.r11, CV_AMD64_R11B, CV_AMD64_R11W, CV_AMD64_R11D, CV_AMD64_R11), + new CvRegDef(AMD64.r12, CV_AMD64_R12B, CV_AMD64_R12W, CV_AMD64_R12D, CV_AMD64_R12), + new CvRegDef(AMD64.r13, CV_AMD64_R13B, CV_AMD64_R13W, CV_AMD64_R13D, CV_AMD64_R13), + new CvRegDef(AMD64.r14, CV_AMD64_R14B, CV_AMD64_R14W, CV_AMD64_R14D, CV_AMD64_R14), + new CvRegDef(AMD64.r15, CV_AMD64_R15B, CV_AMD64_R15W, CV_AMD64_R15D, CV_AMD64_R15), - /* 32, 64 bits */ - new CvRegDef(AMD64.xmm0, CV_AMD64_XMM0_0, CV_AMD64_XMM0L), /* xmm0=16 */ - new CvRegDef(AMD64.xmm1, CV_AMD64_XMM1_0, CV_AMD64_XMM1L), - new CvRegDef(AMD64.xmm2, CV_AMD64_XMM2_0, CV_AMD64_XMM2L), - new CvRegDef(AMD64.xmm3, CV_AMD64_XMM3_0, CV_AMD64_XMM3L), - new CvRegDef(AMD64.xmm4, CV_AMD64_XMM4_0, CV_AMD64_XMM4L), - new CvRegDef(AMD64.xmm5, CV_AMD64_XMM5_0, CV_AMD64_XMM5L), - new CvRegDef(AMD64.xmm6, CV_AMD64_XMM6_0, CV_AMD64_XMM6L), - new CvRegDef(AMD64.xmm7, CV_AMD64_XMM7_0, CV_AMD64_XMM7L), - new CvRegDef(AMD64.xmm8, CV_AMD64_XMM8_0, CV_AMD64_XMM8L), - new CvRegDef(AMD64.xmm9, CV_AMD64_XMM9_0, CV_AMD64_XMM9L), - new CvRegDef(AMD64.xmm10, CV_AMD64_XMM10_0, CV_AMD64_XMM10L), - new CvRegDef(AMD64.xmm11, CV_AMD64_XMM11_0, CV_AMD64_XMM11L), - new CvRegDef(AMD64.xmm12, CV_AMD64_XMM12_0, CV_AMD64_XMM12L), - new CvRegDef(AMD64.xmm13, CV_AMD64_XMM13_0, CV_AMD64_XMM13L), - new CvRegDef(AMD64.xmm14, CV_AMD64_XMM14_0, CV_AMD64_XMM14L), - new CvRegDef(AMD64.xmm15, CV_AMD64_XMM15_0, CV_AMD64_XMM15L), + /* 32, 64 bits */ + new CvRegDef(AMD64.xmm0, CV_AMD64_XMM0_0, CV_AMD64_XMM0L), /* xmm0=16 */ + new CvRegDef(AMD64.xmm1, CV_AMD64_XMM1_0, CV_AMD64_XMM1L), + new CvRegDef(AMD64.xmm2, CV_AMD64_XMM2_0, CV_AMD64_XMM2L), + new CvRegDef(AMD64.xmm3, CV_AMD64_XMM3_0, CV_AMD64_XMM3L), + new CvRegDef(AMD64.xmm4, CV_AMD64_XMM4_0, CV_AMD64_XMM4L), + new CvRegDef(AMD64.xmm5, CV_AMD64_XMM5_0, CV_AMD64_XMM5L), + new CvRegDef(AMD64.xmm6, CV_AMD64_XMM6_0, CV_AMD64_XMM6L), + new CvRegDef(AMD64.xmm7, CV_AMD64_XMM7_0, CV_AMD64_XMM7L), + new CvRegDef(AMD64.xmm8, CV_AMD64_XMM8_0, CV_AMD64_XMM8L), + new CvRegDef(AMD64.xmm9, CV_AMD64_XMM9_0, CV_AMD64_XMM9L), + new CvRegDef(AMD64.xmm10, CV_AMD64_XMM10_0, CV_AMD64_XMM10L), + new CvRegDef(AMD64.xmm11, CV_AMD64_XMM11_0, CV_AMD64_XMM11L), + new CvRegDef(AMD64.xmm12, CV_AMD64_XMM12_0, CV_AMD64_XMM12L), + new CvRegDef(AMD64.xmm13, CV_AMD64_XMM13_0, CV_AMD64_XMM13L), + new CvRegDef(AMD64.xmm14, CV_AMD64_XMM14_0, CV_AMD64_XMM14L), + new CvRegDef(AMD64.xmm15, CV_AMD64_XMM15_0, CV_AMD64_XMM15L), }; for (CvRegDef def : compactRegDefs) { @@ -245,12 +245,11 @@ private static class CvRegDef { } /* - * Convert a Java register number to a CodeView register code. - * In release mode, return -1 so caller can emit a warning and continue. - * In debug mode, throw an assert. + * Convert a Java register number to a CodeView register code. In release mode, return -1 so + * caller can emit a warning and continue. In debug mode, throw an assert. * - * This can (and has) happened when Graal is enhanced to use more registers - * but there is no test for that in the test suite. + * This can (and has) happened when Graal is enhanced to use more registers but there is no test + * for that in the test suite. */ /* the CodeView code depends upon the register type and size */ static short getCVRegister(int javaReg, TypeEntry typeEntry) { From 04d6db78780409e33364cb5ccdcecf5b552d5738 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Tue, 23 Sep 2025 13:27:56 -0400 Subject: [PATCH 46/48] use different logger --- .../src/com/oracle/objectfile/pecoff/cv/CVSectionImpl.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSectionImpl.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSectionImpl.java index 584f686846ba..25cae145cf75 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSectionImpl.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSectionImpl.java @@ -31,6 +31,7 @@ import com.oracle.objectfile.LayoutDecision; import com.oracle.objectfile.LayoutDecisionMap; import com.oracle.objectfile.ObjectFile; + import jdk.graal.compiler.debug.DebugContext; import java.util.Map; @@ -74,7 +75,9 @@ protected void enableLog(DebugContext debugContext) { } protected void warn(String format, Object... args) { - System.out.printf("Warning:" + format + "\n", args); + if (debug) { + getDebugContext().logv(DebugContext.BASIC_LEVEL, "Warning: " + format + "%n", args); + } } protected void log(String format, Object... args) { From e4524eda42dbba287879c622e981985defaf8d04 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Tue, 23 Sep 2025 13:41:31 -0400 Subject: [PATCH 47/48] use different logger --- .../src/com/oracle/objectfile/pecoff/cv/CVSectionImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSectionImpl.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSectionImpl.java index 25cae145cf75..2e277fb40879 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSectionImpl.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSectionImpl.java @@ -76,7 +76,7 @@ protected void enableLog(DebugContext debugContext) { protected void warn(String format, Object... args) { if (debug) { - getDebugContext().logv(DebugContext.BASIC_LEVEL, "Warning: " + format + "%n", args); + getDebugContext().logv(DebugContext.BASIC_LEVEL, format, args); } } From 156645dd5ccd38a147253a54daa0ddaf37375b25 Mon Sep 17 00:00:00 2001 From: Simon Tooke Date: Mon, 29 Sep 2025 12:41:42 -0400 Subject: [PATCH 48/48] use MFuncId instead of FuncId record --- .../objectfile/pecoff/cv/CVTypeRecord.java | 102 ------------------ .../pecoff/cv/CVTypeSectionBuilder.java | 10 +- 2 files changed, 3 insertions(+), 109 deletions(-) diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeRecord.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeRecord.java index c1d0f25c957b..285988b56e2d 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeRecord.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeRecord.java @@ -317,50 +317,6 @@ public boolean equals(Object obj) { } } - static final class CVTypeFuncIdRecord extends CVTypeRecord { - - int scopeIdx; - int typeIdx; - String name; - - CVTypeFuncIdRecord(int scopeIdx, int typeIdx, String name) { - super(LF_FUNC_ID); - this.scopeIdx = scopeIdx; - this.typeIdx = typeIdx; - this.name = name; - } - - @Override - public int computeContents(byte[] buffer, int initialPos) { - int pos = CVUtil.putInt(scopeIdx, buffer, initialPos); - pos = CVUtil.putInt(typeIdx, buffer, pos); - return CVUtil.putUTF8StringBytes(name, buffer, pos); - } - - @Override - public String toString() { - return String.format("LF_FUNC_ID 0x%04x scopeIdx=0x%x typeIdx=0x%x %s", getSequenceNumber(), scopeIdx, typeIdx, name); - } - - @Override - public int hashCode() { - int h = type; - h = 31 * h + scopeIdx; - h = 31 * h + typeIdx; - h = 31 * h + name.hashCode(); - return h; - } - - @Override - public boolean equals(Object obj) { - if (!super.equals(obj)) { - return false; - } - CVTypeFuncIdRecord other = (CVTypeFuncIdRecord) obj; - return this.typeIdx == other.typeIdx && this.name.equals(other.name) && this.scopeIdx == other.scopeIdx; - } - } - static final class CVTypeMFuncIdRecord extends CVTypeRecord { int parentTypeIdx; @@ -498,64 +454,6 @@ public boolean equals(Object obj) { } } - static final class CVTypeProcedureRecord extends CVTypeRecord { - - private int returnType = -1; - private CVTypeArglistRecord argList = null; - - CVTypeProcedureRecord() { - super(LF_PROCEDURE); - } - - public CVTypeProcedureRecord setReturnType(int leaf) { - this.returnType = leaf; - return this; - } - - public CVTypeProcedureRecord setReturnType(CVTypeRecord leaf) { - this.returnType = leaf.getSequenceNumber(); - return this; - } - - CVTypeProcedureRecord setArgList(CVTypeArglistRecord leaf) { - this.argList = leaf; - return this; - } - - @Override - public int computeContents(byte[] buffer, int initialPos) { - int pos = CVUtil.putInt(returnType, buffer, initialPos); - pos = CVUtil.putByte((byte) CV_CALL_NEAR_C, buffer, pos); - pos = CVUtil.putByte((byte) 0, buffer, pos); /* TODO funcAttr */ - pos = CVUtil.putShort((short) argList.getSize(), buffer, pos); - pos = CVUtil.putInt(argList.getSequenceNumber(), buffer, pos); - return pos; - } - - @Override - public String toString() { - return String.format("LF_PROCEDURE 0x%04x ret=0x%04x arg=0x%04x ", getSequenceNumber(), returnType, argList.getSequenceNumber()); - } - - @Override - public int hashCode() { - int h = type; - h = 31 * h + returnType; - h = 31 * h + argList.hashCode(); - /* callType and funcAttr are always the same so do not add them to the hash */ - return h; - } - - @Override - public boolean equals(Object obj) { - if (!super.equals(obj)) { - return false; - } - CVTypeProcedureRecord other = (CVTypeProcedureRecord) obj; - return this.returnType == other.returnType && this.argList == other.argList; - } - } - static final class CVTypeArglistRecord extends CVTypeRecord { private final ArrayList args = new ArrayList<>(); diff --git a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java index d55633fbb44f..c6f36f85aa3a 100644 --- a/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java +++ b/substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVTypeSectionBuilder.java @@ -150,7 +150,7 @@ CVTypeRecord buildFunction(CompiledMethodEntry entry) { ClassEntry ownerType = entry.ownerType(); assert ownerType != null; CVTypeRecord.CVTypeMFunctionRecord mFunctionRecord = buildMemberFunction(ownerType, entry.primary().getMethodEntry()); - return buildFuncIdRecord(mFunctionRecord, entry.primary().getMethodName()); + return buildMFuncIdRecord(mFunctionRecord, entry.primary().getMethodName()); } static class FieldListBuilder { @@ -500,12 +500,8 @@ CVTypeRecord.CVTypeMFunctionRecord buildMemberFunction(ClassEntry classEntry, Me return addTypeRecord(mFunctionRecord); } - CVTypeRecord buildFuncIdRecord(CVTypeRecord.CVTypeMFunctionRecord mFunctionRecord, String functionName) { - if (mFunctionRecord.getClassType() != 0) { - return addTypeRecord(new CVTypeRecord.CVTypeMFuncIdRecord(mFunctionRecord.getClassType(), mFunctionRecord.getSequenceNumber(), functionName)); - } else { - return addTypeRecord(new CVTypeRecord.CVTypeFuncIdRecord(0, mFunctionRecord.getSequenceNumber(), functionName)); - } + CVTypeRecord buildMFuncIdRecord(CVTypeRecord.CVTypeMFunctionRecord mFunctionRecord, String functionName) { + return addTypeRecord(new CVTypeRecord.CVTypeMFuncIdRecord(mFunctionRecord.getClassType(), mFunctionRecord.getSequenceNumber(), functionName)); } private T addTypeRecord(T record) {