Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ROMClass walkers in DDR and VM consistent #11362

Merged
merged 2 commits into from
Jan 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -297,38 +297,38 @@ private J9ROMMethodPointer allSlotsInROMMethodDo(J9ROMMethodPointer method) thro

return J9ROMMethodPointer.cast(cursor);
}

private long allSlotsInMethodParametersDataDo(U32Pointer cursor) throws CorruptDataException
{
J9MethodParametersDataPointer methodParametersData = J9MethodParametersDataPointer.cast(cursor);
J9MethodParameterPointer parameters = methodParametersData.parameters();
long methodParametersSize = ROMHelp.J9_METHOD_PARAMS_SIZE_FROM_NUMBER_OF_PARAMS(methodParametersData.parameterCount().longValue());
long padding = U32.SIZEOF - (methodParametersSize % U32.SIZEOF);
long size = 0;

if (padding == U32.SIZEOF) {
padding = 0;
}

size = methodParametersSize + padding;

classWalkerCallback.addSlot(clazz, SlotType.J9_SRP, methodParametersData.parameterCountEA(), "parameterCount");

for (int i = 0; i < methodParametersData.parameterCount().longValue(); i++) {
classWalkerCallback.addSlot(clazz, SlotType.J9_SRP, parameters.nameEA(), "methodParameterName");
classWalkerCallback.addSlot(clazz, SlotType.J9_U16, parameters.flagsEA(), "methodParameterFlag");
classWalkerCallback.addSlot(clazz, SlotType.J9_ROM_UTF8, parameters.nameEA(), "methodParameterName");
keithc-ca marked this conversation as resolved.
Show resolved Hide resolved
classWalkerCallback.addSlot(clazz, SlotType.J9_U16, parameters.flagsEA(), "methodParameterFlag");
}

cursor = cursor.addOffset(methodParametersSize);
for (; padding > 0; padding--) {
classWalkerCallback.addSlot(clazz, SlotType.J9_U8, cursor, "MethodParameters padding");
cursor.addOffset(1);
}

classWalkerCallback.addSection(clazz, methodParametersData, size, "Method Parameters", true);
return size/U32.SIZEOF;
}

private int allSlotsInROMFieldDo(J9ROMFieldShapePointer field) throws CorruptDataException {
int fieldLength = 0;

Expand Down 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");
keithc-ca marked this conversation as resolved.
Show resolved Hide resolved
}
}
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
2 changes: 2 additions & 0 deletions runtime/ddr/overrides-vm
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ typeoverride.J9AnnotationInfoEntry.annotationType=J9SRP(J9UTF8)
typeoverride.J9AnnotationInfoEntry.memberName=J9SRP(J9UTF8)
typeoverride.J9AnnotationInfoEntry.memberSignature=J9SRP(J9UTF8)

typeoverride.J9MethodParameter.name=J9SRP(J9UTF8)

typeoverride.J9EnclosingObject.nameAndSignature=J9SRP(J9ROMNameAndSignature)

typeoverride.J9ROMClass.className=J9SRP(J9UTF8)
Expand Down
2 changes: 2 additions & 0 deletions runtime/ddr/vmddrstructs.properties
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ ddrblob.typeoverride.J9AnnotationInfoEntry.annotationType=J9SRP(struct J9UTF8)
ddrblob.typeoverride.J9AnnotationInfoEntry.memberName=J9SRP(struct J9UTF8)
ddrblob.typeoverride.J9AnnotationInfoEntry.memberSignature=J9SRP(struct J9UTF8)

ddrblob.typeoverride.J9MethodParameter.name=J9SRP(struct J9UTF8)

ddrblob.typeoverride.J9EnclosingObject.nameAndSignature=J9SRP(struct J9ROMNameAndSignature)

ddrblob.typeoverride.J9ROMClass.className=J9SRP(struct J9UTF8)
Expand Down