Skip to content

Commit

Permalink
Use J9_ROM_UTF8 instead of J9_UTF8 in DDR ROMClass walker
Browse files Browse the repository at this point in the history
Match the ROMClass walk implementation used in VM and cfdumper in the
way it handles UTF8 strings in method debug info.

Signed-off-by: Alexey Khrabrov <khrabrov@cs.toronto.edu>
  • Loading branch information
AlexeyKhrabrov committed Jan 28, 2021
1 parent 23e2ca0 commit 10c3df5
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2001, 2014 IBM Corp. and others
* Copyright (c) 2001, 2021 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand All @@ -21,28 +21,36 @@
*******************************************************************************/
package com.ibm.j9ddr.vm29.j9.walkers;

import com.ibm.j9ddr.vm29.pointer.SelfRelativePointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer;
import com.ibm.j9ddr.vm29.types.U32;

public class LocalVariableTable {
public LocalVariableTable(U32 slotNumber, U32 startVisibility,
U32 visibilityLength,
J9UTF8Pointer genericSignature, J9UTF8Pointer name, J9UTF8Pointer signature) {
public LocalVariableTable(U32 slotNumber, U32 startVisibility, U32 visibilityLength,
SelfRelativePointer genericSignatureSrp, J9UTF8Pointer genericSignature,
SelfRelativePointer nameSrp, J9UTF8Pointer name,
SelfRelativePointer signatureSrp, J9UTF8Pointer signature) {
this.slotNumber = slotNumber;
this.startVisibility = startVisibility;
this.visibilityLength = visibilityLength;
this.genericSignatureSrp = genericSignatureSrp;
this.genericSignature = genericSignature;
this.nameSrp = nameSrp;
this.name = name;
this.signatureSrp = signatureSrp;
this.signature = signature;
}

private U32 slotNumber;
private U32 startVisibility;
private U32 visibilityLength;
private SelfRelativePointer genericSignatureSrp;
private J9UTF8Pointer genericSignature;
private SelfRelativePointer nameSrp;
private J9UTF8Pointer name;
private SelfRelativePointer signatureSrp;
private J9UTF8Pointer signature;

public U32 getSlotNumber() {
return slotNumber;
}
Expand All @@ -52,12 +60,21 @@ public U32 getStartVisibility() {
public U32 getVisibilityLength() {
return visibilityLength;
}
public SelfRelativePointer getGenericSignatureSrp() {
return genericSignatureSrp;
}
public J9UTF8Pointer getGenericSignature() {
return genericSignature;
}
public SelfRelativePointer getNameSrp() {
return nameSrp;
}
public J9UTF8Pointer getName() {
return name;
}
public SelfRelativePointer getSignatureSrp() {
return signatureSrp;
}
public J9UTF8Pointer getSignature() {
return signature;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2020 IBM Corp. and others
* Copyright (c) 1991, 2021 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -83,8 +83,11 @@ public boolean hasNext() {

public LocalVariableTable next() {
count = count.add(1);
SelfRelativePointer nameSrp;
J9UTF8Pointer name;
SelfRelativePointer signatureSrp;
J9UTF8Pointer signature;
SelfRelativePointer genericSignatureSrp;
J9UTF8Pointer genericSignature;
try {
U8 firstByte = localVariableTablePtr.at(0);
Expand Down Expand Up @@ -139,16 +142,21 @@ public LocalVariableTable next() {
} else {
return null;
}
name = J9UTF8Pointer.cast(SelfRelativePointer.cast(localVariableTablePtr).get());

nameSrp = SelfRelativePointer.cast(localVariableTablePtr);
name = J9UTF8Pointer.cast(nameSrp.get());
localVariableTablePtr = localVariableTablePtr.add(SelfRelativePointer.SIZEOF);

signature = J9UTF8Pointer.cast(SelfRelativePointer.cast(localVariableTablePtr).get());

signatureSrp = SelfRelativePointer.cast(localVariableTablePtr);
signature = J9UTF8Pointer.cast(signatureSrp.get());
localVariableTablePtr = localVariableTablePtr.add(SelfRelativePointer.SIZEOF);

if (visibilityLength.anyBitsIn(J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_VARIABLE_TABLE_HAS_GENERIC)) {
genericSignature = J9UTF8Pointer.cast(SelfRelativePointer.cast(localVariableTablePtr).get());
genericSignatureSrp = SelfRelativePointer.cast(localVariableTablePtr);
genericSignature = J9UTF8Pointer.cast(genericSignatureSrp.get());
localVariableTablePtr = localVariableTablePtr.add(SelfRelativePointer.SIZEOF);
} else {
genericSignatureSrp = SelfRelativePointer.NULL;
genericSignature = J9UTF8Pointer.NULL;
}

Expand All @@ -157,7 +165,8 @@ public LocalVariableTable next() {
EventManager.raiseCorruptDataEvent("CorruptData encountered walking local variable table.", ex, false);
return null;
}
return new LocalVariableTable(slotNumber, startVisibility, visibilityLength, genericSignature, name, signature);
return new LocalVariableTable(slotNumber, startVisibility, visibilityLength,
genericSignatureSrp, genericSignature, nameSrp, name, signatureSrp, signature);
}
private static I32 signExtend(I32 i32, int numberBits){
int shiftAmount = (I32.SIZEOF * 8) - numberBits;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,7 @@ int allSlotsInAnnotationDo(U32Pointer annotation, String annotationSectionName)
classWalkerCallback.addSection(clazz, annotation, increment * U32.SIZEOF, annotationSectionName, true);
return increment;
}

long allSlotsInMethodDebugInfoDo(U32Pointer cursor) throws CorruptDataException
{
J9MethodDebugInfoPointer methodDebugInfo;
Expand Down Expand Up @@ -1036,7 +1037,7 @@ long allSlotsInMethodDebugInfoDo(U32Pointer cursor) throws CorruptDataException
if (methodDebugInfo.lineNumberCount().allBitsIn(1)) {
classWalkerCallback.addSlot(clazz, SlotType.J9_U32, U32Pointer.cast(methodDebugInfo.add(1)), "compressed line number size");
}

currentLineNumberPtr = J9MethodDebugInfoHelper.getCompressedLineNumberTableForROMClassV1(methodDebugInfo);
if (currentLineNumberPtr.notNull()) {
for (int j = 0; j < J9MethodDebugInfoHelper.getLineNumberCompressedSize(methodDebugInfo).intValue(); j++) {
Expand All @@ -1054,10 +1055,10 @@ long allSlotsInMethodDebugInfoDo(U32Pointer cursor) throws CorruptDataException
LocalVariableTable values = variableInfoValuesIterator.next();

// Need to walk the name and signature to add them to the UTF8 section
classWalkerCallback.addSlot(clazz, SlotType.J9_UTF8, values.getName(), "name");
classWalkerCallback.addSlot(clazz, SlotType.J9_UTF8, values.getSignature(), "getSignature");
classWalkerCallback.addSlot(clazz, SlotType.J9_ROM_UTF8, values.getNameSrp(), "name");
classWalkerCallback.addSlot(clazz, SlotType.J9_ROM_UTF8, values.getSignatureSrp(), "signature");
if (values.getGenericSignature().notNull()) {
classWalkerCallback.addSlot(clazz, SlotType.J9_UTF8, values.getGenericSignature(), "getGenericSignature");
classWalkerCallback.addSlot(clazz, SlotType.J9_ROM_UTF8, values.getGenericSignatureSrp(), "genericSignature");
}
}
U8Pointer end = variableInfoValuesIterator.getLocalVariableTablePtr();
Expand All @@ -1073,6 +1074,7 @@ long allSlotsInMethodDebugInfoDo(U32Pointer cursor) throws CorruptDataException
classWalkerCallback.addSection(clazz, methodDebugInfo, sectionSizeBytes, "methodDebugInfo" + (inlineDebugExtension?" Inline":""), inlineDebugExtension);
return inlineSize;
}

void allSlotsInEnclosingObjectDo(J9EnclosingObjectPointer enclosingObject) throws CorruptDataException
{
if (enclosingObject.isNull()) {
Expand Down

0 comments on commit 10c3df5

Please sign in to comment.