Skip to content

Commit

Permalink
Remove legacy DDR code
Browse files Browse the repository at this point in the history
* adapt to lack of 'united' view of VM code
  (e.g. MM_HeapLinkedFreeHeader which has a single 64-bit _next field
  or two 32-bit fields (_next and _nextHighBits). OMR's ddrgen sees
  only one of these situations and never generates anything related
  to '_next_v1'.
* remove references to obsolete concepts that will not be output by
  new code generation flow (e.g. J9VariableInfo)
* use Long.bitCount()

Issue: eclipse-openj9#378
Signed-off-by: Keith W. Campbell <[email protected]>
  • Loading branch information
keithc-ca authored and yanluo7 committed Mar 28, 2018
1 parent c8f6483 commit cde14ea
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 152 deletions.
40 changes: 4 additions & 36 deletions debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/j9/OptInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_SIMPLE_NAME;
import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_SOURCE_DEBUG_EXTENSION;
import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_SOURCE_FILE_NAME;
import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_VARIABLE_TABLE_HAS_GENERIC;
import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_TYPE_ANNOTATION_INFO;

import java.util.Iterator;
Expand All @@ -39,6 +38,7 @@
import com.ibm.j9ddr.CorruptDataException;
import com.ibm.j9ddr.vm29.j9.walkers.LineNumber;
import com.ibm.j9ddr.vm29.j9.walkers.LineNumberIterator;
import com.ibm.j9ddr.vm29.j9.walkers.LocalVariableTableIterator;
import com.ibm.j9ddr.vm29.pointer.SelfRelativePointer;
import com.ibm.j9ddr.vm29.pointer.U32Pointer;
import com.ibm.j9ddr.vm29.pointer.U8Pointer;
Expand All @@ -49,12 +49,9 @@
import com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9SourceDebugExtensionPointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9VariableInfoPointer;
import com.ibm.j9ddr.vm29.pointer.helper.J9MethodDebugInfoHelper;
import com.ibm.j9ddr.vm29.pointer.helper.J9UTF8Helper;
import com.ibm.j9ddr.vm29.structure.J9LineNumber;
import com.ibm.j9ddr.vm29.structure.J9MethodDebugInfo;
import com.ibm.j9ddr.vm29.structure.J9VariableInfo;
import com.ibm.j9ddr.vm29.types.U32;
import com.ibm.j9ddr.vm29.types.UDATA;

Expand Down Expand Up @@ -147,30 +144,14 @@ private static SelfRelativePointer getSRPPtr(U32Pointer ptr, U32 flags, long opt
}

public static int countBits(U32 word) {
int count;

long x = word.longValue();

for (count = 0; x != 0; x >>= 1) {
if ((x & 1) != 0) {
count++;
}
}

return count;
return Long.bitCount(word.longValue());
}

/**
* This method should be used when VM_LOCAL_VARIABLE_TABLE_VERSION < 1
*/
public static J9VariableInfoPointer getV0VariableTableForROMClass(J9MethodDebugInfoPointer methodInfo) throws CorruptDataException {
return J9VariableInfoPointer.cast(OptInfo._getVariableTableForMethodDebugInfo(methodInfo));
}

/**
* This method should be used when VM_LOCAL_VARIABLE_TABLE_VERSION >= 1
*/
public static U8Pointer getV1VariableTableForMethodDebugInfo(J9MethodDebugInfoPointer methodInfo) throws CorruptDataException {
LocalVariableTableIterator.checkVariableTableVersion();
return U8Pointer.cast(OptInfo._getVariableTableForMethodDebugInfo(methodInfo));
}
private static VoidPointer _getVariableTableForMethodDebugInfo(J9MethodDebugInfoPointer methodInfo) throws CorruptDataException {
Expand All @@ -182,12 +163,7 @@ private static VoidPointer _getVariableTableForMethodDebugInfo(J9MethodDebugInfo
* low tag indicates that debug information is in line
* skip over J9MethodDebugInfo header and the J9LineNumber table
*/
U32 lineNumberTableSize;
if (AlgorithmVersion.getVersionOf("VM_LINE_NUMBER_TABLE_VERSION").getAlgorithmVersion() < 1) {
lineNumberTableSize = methodInfo.lineNumberCount().mult((int) J9LineNumber.SIZEOF);
} else {
lineNumberTableSize = J9MethodDebugInfoHelper.getLineNumberCompressedSize(methodInfo);
}
U32 lineNumberTableSize = J9MethodDebugInfoHelper.getLineNumberCompressedSize(methodInfo);
return VoidPointer.cast(((U8Pointer.cast(methodInfo).addOffset(J9MethodDebugInfo.SIZEOF).addOffset(lineNumberTableSize))));
} else {
/*
Expand All @@ -200,14 +176,6 @@ private static VoidPointer _getVariableTableForMethodDebugInfo(J9MethodDebugInfo
return VoidPointer.NULL;
}

public static UDATA variableInfoSize(UDATA modifiers) {
UDATA size = new UDATA(J9VariableInfo.SIZEOF);
if (modifiers.allBitsIn(J9_ROMCLASS_OPTINFO_VARIABLE_TABLE_HAS_GENERIC)) {
size = size.add(U32.SIZEOF);
}
return size;
}

public static U32 COUNT_MASK(U32 value, long mask) {
return (value.bitAnd(((mask) << 1) - 1));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2014 IBM Corp. and others
* Copyright (c) 1991, 2018 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 @@ -23,11 +23,14 @@

import com.ibm.j9ddr.AddressedCorruptDataException;
import com.ibm.j9ddr.CorruptDataException;
import com.ibm.j9ddr.vm29.pointer.Pointer;
import com.ibm.j9ddr.vm29.pointer.U32Pointer;
import com.ibm.j9ddr.vm29.pointer.UDATAPointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9BuildFlags;
import com.ibm.j9ddr.vm29.pointer.generated.MM_HeapLinkedFreeHeaderPointer;
import com.ibm.j9ddr.vm29.structure.J9Consts;
import com.ibm.j9ddr.vm29.types.U32;
import com.ibm.j9ddr.vm29.types.UDATA;
import com.ibm.j9ddr.vm29.pointer.generated.J9BuildFlags;
import com.ibm.j9ddr.vm29.structure.J9Consts;

class GCHeapLinkedFreeHeader_V1 extends GCHeapLinkedFreeHeader {
protected GCHeapLinkedFreeHeader_V1(MM_HeapLinkedFreeHeaderPointer heapLinkedFreeHeaderPointer)
Expand All @@ -42,13 +45,16 @@ protected GCHeapLinkedFreeHeader_V1(UDATA udata) throws CorruptDataException

private UDATA getNextImpl() throws CorruptDataException
{
if(J9BuildFlags.interp_compressedObjectHeader) {
//_next_v1() is the compr version
U32 lowBits = heapLinkedFreeHeaderPointer._next_v1();
U32 highBits = heapLinkedFreeHeaderPointer._nextHighBits();
Pointer nextEA = heapLinkedFreeHeaderPointer._nextEA();

if (J9BuildFlags.interp_compressedObjectHeader) {
U32Pointer nextPointer = U32Pointer.cast(nextEA);
U32 lowBits = nextPointer.at(0);
U32 highBits = nextPointer.at(1);

return new UDATA(highBits).leftShift(32).bitOr(lowBits);
} else {
return heapLinkedFreeHeaderPointer._next();
return UDATAPointer.cast(nextEA).at(0);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/

package com.ibm.j9ddr.vm29.j9.walkers;

import java.util.Iterator;
Expand All @@ -34,7 +33,6 @@
import com.ibm.j9ddr.vm29.pointer.U8Pointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9MethodDebugInfoPointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9VariableInfoPointer;
import com.ibm.j9ddr.vm29.structure.J9UTF8;
import com.ibm.j9ddr.vm29.types.I32;
import com.ibm.j9ddr.vm29.types.U16;
Expand All @@ -44,78 +42,24 @@

public abstract class LocalVariableTableIterator implements Iterator<LocalVariableTable> {

public static LocalVariableTableIterator localVariableTableIteratorFor(J9MethodDebugInfoPointer methodInfo) throws CorruptDataException {
/* If the version is right */
if (AlgorithmVersion.getVersionOf("VM_LOCAL_VARIABLE_TABLE_VERSION").getAlgorithmVersion() < 1) {
return new LocalVariableTableIterator_V0(methodInfo);
} else {
return new LocalVariableTableIterator_V1(methodInfo);
public static void checkVariableTableVersion() throws CorruptDataException {
int version = AlgorithmVersion.getVersionOf("VM_LOCAL_VARIABLE_TABLE_VERSION").getAlgorithmVersion();
if (version < 1) {
throw new CorruptDataException("Unexpected local variable table version " + version);
}
}

public static LocalVariableTableIterator localVariableTableIteratorFor(J9MethodDebugInfoPointer methodInfo) throws CorruptDataException {
checkVariableTableVersion();
return new LocalVariableTableIterator_V1(methodInfo);
}

public void remove() {
throw new UnsupportedOperationException();
}

public abstract U8Pointer getLocalVariableTablePtr();

private static class LocalVariableTableIterator_V0 extends LocalVariableTableIterator {
private long variablesLeft;
private J9VariableInfoPointer variable;

public LocalVariableTableIterator_V0(J9MethodDebugInfoPointer methodInfo) throws CorruptDataException {
variablesLeft = methodInfo.varInfoCount().longValue();
variable = OptInfo.getV0VariableTableForROMClass(methodInfo);
}
public boolean hasNext() {
return variablesLeft != 0;
}

public LocalVariableTable next() {
variablesLeft--;
try {
J9VariableInfoPointer result = variable;

/* Move to the next J9VariableInfo */
variable = variable.add(1);

U32 slotNumber = result.slotNumber();
U32 startVisibility = result.startVisibility();
U32 visibilityLength = result.visibilityLength();

J9UTF8Pointer name = result.name();
J9UTF8Pointer signature = result.signature();
J9UTF8Pointer genericSignature = null;
if (visibilityLength.anyBitsIn(J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_VARIABLE_TABLE_HAS_GENERIC)) {
visibilityLength = visibilityLength.bitAnd(~J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_VARIABLE_TABLE_HAS_GENERIC);
/**
* If J9VariableInfo has generic structure,
* then SRP to the generic structure is stored in the first 4 bytes
* starting the end of the current J9VariableInfo structure, which overlaps with the following
* J9VariableInfo's first 4 bytes which is J9SRP name field. So this field can be used to get the generic structure.
*/
result = result.add(1);
genericSignature = result.name();

/* If the J9VariableInfo has generic signature then
* it uses another 4 bytes for SRP to the generic structure after the end of the current J9VariableInfo.
* Therefore, move next J9VariableInfo address another 4 bytes.
*/
variable = variable.addOffset(SelfRelativePointer.SIZEOF);
}

return new LocalVariableTable(slotNumber, startVisibility, visibilityLength, genericSignature, name, signature);
} catch (CorruptDataException ex) {
EventManager.raiseCorruptDataEvent("CorruptData encountered walking local variable table.", ex, false);
return null;
}
}
@Override
public U8Pointer getLocalVariableTablePtr() {
return U8Pointer.cast(variable);
}
}

private static class LocalVariableTableIterator_V1 extends LocalVariableTableIterator {
private J9MethodDebugInfoPointer methodInfo;
private U32 count = new U32(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ private void allSlotsInRAMStaticsDo() throws CorruptDataException {
if (ramClass.ramStatics().isNull()) {
return;
}
Iterator ofoIterator = J9ObjectFieldOffsetIterator.J9ObjectFieldOffsetIteratorFor(ramClass, J9ClassHelper.superclass(ramClass), new U32(J9ROMFieldOffsetWalkState.J9VM_FIELD_OFFSET_WALK_INCLUDE_STATIC));
Iterator<?> ofoIterator = J9ObjectFieldOffsetIterator.J9ObjectFieldOffsetIteratorFor(ramClass, J9ClassHelper.superclass(ramClass), new U32(J9ROMFieldOffsetWalkState.J9VM_FIELD_OFFSET_WALK_INCLUDE_STATIC));
J9ObjectFieldOffset fields = null;
while (ofoIterator.hasNext()) {
fields = (J9ObjectFieldOffset) ofoIterator.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
import com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodTypeRefPointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9ROMNameAndSignaturePointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9ROMStringRefPointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9VariableInfoPointer;
import com.ibm.j9ddr.vm29.pointer.helper.J9MethodDebugInfoHelper;
import com.ibm.j9ddr.vm29.pointer.helper.J9ROMClassHelper;
import com.ibm.j9ddr.vm29.pointer.helper.J9ROMMethodHelper;
Expand All @@ -94,7 +93,6 @@
import com.ibm.j9ddr.vm29.structure.J9MethodDebugInfo;
import com.ibm.j9ddr.vm29.structure.J9ROMClass;
import com.ibm.j9ddr.vm29.structure.J9ROMConstantPoolItem;
import com.ibm.j9ddr.vm29.structure.J9VariableInfo;
import com.ibm.j9ddr.vm29.tools.ddrinteractive.IClassWalkCallbacks.SlotType;
import com.ibm.j9ddr.vm29.types.I32;
import com.ibm.j9ddr.vm29.types.U16;
Expand Down Expand Up @@ -966,49 +964,30 @@ long allSlotsInMethodDebugInfoDo(U32Pointer cursor) throws CorruptDataException
}
}
}

if (AlgorithmVersion.getVersionOf("VM_LOCAL_VARIABLE_TABLE_VERSION").getAlgorithmVersion() < 1) {
J9VariableInfoPointer variableTable = OptInfo.getV0VariableTableForROMClass(methodDebugInfo);
if (variableTable.notNull()) {
for (int j = 0; j < methodDebugInfo.varInfoCount().longValue(); j++) {
long entryLength = J9VariableInfo.SIZEOF;

addObjectsasSlot(variableTable);

if (variableTable.visibilityLength().anyBitsIn(J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_VARIABLE_TABLE_HAS_GENERIC)) {
U32Pointer typePtr = U32Pointer.cast(variableTable.add(1));
classWalkerCallback.addSlot(clazz, SlotType.J9_ROM_UTF8, typePtr, "methodVariableGeneric");
entryLength += SelfRelativePointer.SIZEOF;
}
classWalkerCallback.addSection(clazz, variableTable, entryLength, "variableInfo" + (inlineDebugExtension?" Inline":""), inlineDebugExtension);
variableTable = J9VariableInfoPointer.cast(variableTable.addOffset(entryLength));

U8Pointer variableTable = OptInfo.getV1VariableTableForMethodDebugInfo(methodDebugInfo);
if (variableTable.notNull()) {
LocalVariableTableIterator variableInfoValuesIterator = LocalVariableTableIterator.localVariableTableIteratorFor(methodDebugInfo);
U8Pointer start = variableInfoValuesIterator.getLocalVariableTablePtr();
while (variableInfoValuesIterator.hasNext()) {
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");
if (values.getGenericSignature().notNull()) {
classWalkerCallback.addSlot(clazz, SlotType.J9_UTF8, values.getGenericSignature(), "getGenericSignature");
}
}
} else {
U8Pointer variableTable = OptInfo.getV1VariableTableForMethodDebugInfo(methodDebugInfo);
if (variableTable.notNull()) {
LocalVariableTableIterator variableInfoValuesIterator = LocalVariableTableIterator.localVariableTableIteratorFor(methodDebugInfo);
U8Pointer start = variableInfoValuesIterator.getLocalVariableTablePtr();
while (variableInfoValuesIterator.hasNext()) {
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");
if (values.getGenericSignature().notNull()) {
classWalkerCallback.addSlot(clazz, SlotType.J9_UTF8, values.getGenericSignature(), "getGenericSignature");
}
}
U8Pointer end = variableInfoValuesIterator.getLocalVariableTablePtr();
int localVariableSectionSize = end.sub(start).intValue();

for (int j = 0; j < localVariableSectionSize; j++) {
classWalkerCallback.addSlot(clazz, SlotType.J9_U8, start, "variableInfo compressed");
start = start.add(1);
}

classWalkerCallback.addSection(clazz, variableTable, localVariableSectionSize, "variableInfo" + (inlineDebugExtension?" Inline":""), inlineDebugExtension);
U8Pointer end = variableInfoValuesIterator.getLocalVariableTablePtr();
int localVariableSectionSize = end.sub(start).intValue();

for (int j = 0; j < localVariableSectionSize; j++) {
classWalkerCallback.addSlot(clazz, SlotType.J9_U8, start, "variableInfo compressed");
start = start.add(1);
}

classWalkerCallback.addSection(clazz, variableTable, localVariableSectionSize, "variableInfo" + (inlineDebugExtension?" Inline":""), inlineDebugExtension);
}
classWalkerCallback.addSection(clazz, methodDebugInfo, sectionSizeBytes, "methodDebugInfo" + (inlineDebugExtension?" Inline":""), inlineDebugExtension);
return inlineSize;
Expand Down

0 comments on commit cde14ea

Please sign in to comment.