2828
2929import com .oracle .objectfile .debugentry .ArrayTypeEntry ;
3030import com .oracle .objectfile .debugentry .ClassEntry ;
31+ import com .oracle .objectfile .debugentry .CompiledMethodEntry ;
3132import com .oracle .objectfile .debugentry .FieldEntry ;
3233import com .oracle .objectfile .debugentry .HeaderTypeEntry ;
3334import com .oracle .objectfile .debugentry .MemberEntry ;
3435import com .oracle .objectfile .debugentry .MethodEntry ;
35- import com .oracle .objectfile .debugentry .PrimaryEntry ;
3636import com .oracle .objectfile .debugentry .StructureTypeEntry ;
3737import com .oracle .objectfile .debugentry .TypeEntry ;
3838
@@ -149,15 +149,13 @@ CVTypeRecord buildType(TypeEntry typeEntry) {
149149 * @param entry primaryEntry containing entities whose type records must be added
150150 * @return type record for this function (may return existing matching record)
151151 */
152- CVTypeRecord buildFunction (PrimaryEntry entry ) {
152+ CVTypeRecord buildFunction (CompiledMethodEntry entry ) {
153153 return buildMemberFunction (entry .getClassEntry (), entry .getPrimary ().getMethodEntry ());
154154 }
155155
156156 static class FieldListBuilder {
157157
158- /* Size of the header part of a field list record (record type + size) */
159- private static final int FIELD_LIST_RECORD_OVERHEAD = Short .BYTES + Short .BYTES ;
160-
158+ static final int CV_INDEX_RECORD_SIZE = CVUtil .align4 (new CVTypeRecord .CVIndexRecord (0 ).computeSize ());
161159 final List <CVTypeRecord .FieldRecord > fields = new ArrayList <>();
162160
163161 FieldListBuilder () {
@@ -184,7 +182,13 @@ CVTypeRecord.CVFieldListRecord buildFieldListRecords(CVTypeSectionBuilder builde
184182
185183 /* Build all Field List records in field order (FIFO). */
186184 for (CVTypeRecord .FieldRecord fieldRecord : fields ) {
187- if (FIELD_LIST_RECORD_OVERHEAD + currentFieldList .getEstimatedSize () + CVUtil .align4 (fieldRecord .computeSize ()) >= CV_TYPE_RECORD_MAX_SIZE ) {
185+ /*
186+ * Calculate the potential size of the fieldList if the current fieldRecord and a
187+ * (potential) index record are added to it.
188+ */
189+ int sizeOfExpandedFieldList = currentFieldList .getEstimatedSize () + CVUtil .align4 (fieldRecord .computeSize ()) + CV_INDEX_RECORD_SIZE ;
190+ /* If there isn't enough room for the new fieldRecord, start a new CVFieldList. */
191+ if (sizeOfExpandedFieldList >= CV_TYPE_RECORD_MAX_SIZE ) {
188192 currentFieldList = new CVTypeRecord .CVFieldListRecord ();
189193 fl .add (currentFieldList );
190194 }
@@ -296,7 +300,7 @@ private CVTypeRecord buildStructureTypeEntry(final StructureTypeEntry typeEntry)
296300
297301 /* LF_MFUNCTION records */
298302 methods .stream ().filter (methodEntry -> methodEntry .methodName ().equals (mname )).forEach (m -> {
299- log ("overloaded method %s(%s) attr=(%s) valuetype=%s" , m . fieldName () , m .methodName (), m .getModifiersString (), m .getValueType ().getTypeName ());
303+ log ("overloaded method %s attr=(%s) valuetype=%s" , m .methodName (), m .getModifiersString (), m .getValueType ().getTypeName ());
300304 CVTypeRecord .CVTypeMFunctionRecord mFunctionRecord = buildMemberFunction ((ClassEntry ) typeEntry , m );
301305 short attr = modifiersToAttr (m );
302306 log (" overloaded method %s" , mFunctionRecord );
@@ -311,7 +315,7 @@ private CVTypeRecord buildStructureTypeEntry(final StructureTypeEntry typeEntry)
311315 });
312316
313317 methods .stream ().filter (methodEntry -> !overloaded .contains (methodEntry .methodName ())).forEach (m -> {
314- log ("`unique method %s %s %s (...)" , m . fieldName () , m .methodName (), m .getModifiersString (), m .getValueType ().getTypeName (), m .methodName ());
318+ log ("`unique method %s %s(...)" , m .methodName (), m .getModifiersString (), m .getValueType ().getTypeName (), m .methodName ());
315319 CVTypeRecord .CVOneMethodRecord method = buildMethod ((ClassEntry ) typeEntry , m );
316320 log (" unique method %s" , method );
317321 fieldListBuilder .addField (method );
@@ -335,7 +339,7 @@ private CVTypeRecord buildStructureTypeEntry(final StructureTypeEntry typeEntry)
335339 * Try to find a line number for the first function - if none, don't bother to create
336340 * the record.
337341 */
338- int line = classEntry .getPrimaryEntries ().isEmpty () ? 0 : classEntry .getPrimaryEntries ().get (0 ). getPrimary ( ).getLine ();
342+ int line = classEntry .getMethods ().isEmpty () ? 0 : classEntry .getMethods ().get (0 ).getLine ();
339343 if (line > 0 ) {
340344 int idIdx = typeSection .getStringId (classEntry .getFullFileName ()).getSequenceNumber ();
341345 CVTypeRecord .CVUdtTypeLineRecord udt = new CVTypeRecord .CVUdtTypeLineRecord (typeRecord .getSequenceNumber (), idIdx , line );
0 commit comments