Skip to content

Commit

Permalink
Merge pull request eclipse-openj9#12372 from keithc-ca/compat-0.26.0
Browse files Browse the repository at this point in the history
(0.26.0) Fix uses of flags which were not always defined
  • Loading branch information
pshipton authored Apr 8, 2021
2 parents bb2e593 + 819b4d5 commit ca8cda0
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 37 deletions.
1 change: 0 additions & 1 deletion debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/j9/OptInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_ENCLOSING_METHOD;
import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_GENERIC_SIGNATURE;
import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_PERMITTEDSUBCLASSES_ATTRIBUTE;
import static com.ibm.j9ddr.vm29.structure.J9NonbuilderConstants.J9_ROMCLASS_OPTINFO_INJECTED_INTERFACE_INFO;
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;
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, 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 @@ -60,8 +60,8 @@ public static GCSegmentIterator fromJ9MemorySegmentList(J9MemorySegmentListPoint
public boolean hasNext()
{
try {
while(memorySegment.notNull()) {
if(memorySegment.type().allBitsIn(flags)) {
while (memorySegment.notNull()) {
if ((0 == flags) || memorySegment.type().allBitsIn(flags)) {
return true;
}
memorySegment = memorySegment.nextSegment();
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 @@ -87,7 +87,18 @@ public boolean isTagged(long mask) {
return 0 != (address & mask);
}

public boolean allBitsIn(long bitmask) {
public final boolean allBitsIn(long bitmask) {
if (0 == bitmask) {
/*
* In the vast majority of situations, the caller supplies a non-zero
* argument. However, in backwards-compatibility cases the argument
* may be derived from a constant which has not always been present.
* The behavior we want is for such tests to return false (such a bit
* could never have been set in core dumps generated before the constant
* existed).
*/
return false;
}
return bitmask == (address & bitmask);
}

Expand Down Expand Up @@ -153,7 +164,8 @@ public boolean notNull() {
public boolean eq(Object obj) {
return equals(obj);
}


@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
Expand All @@ -165,7 +177,8 @@ public boolean equals(Object obj) {

return address == ((AbstractPointer) obj).address;
}


@Override
public int hashCode() {
return (int)((0xFFFFFFFFL & address) ^ ((0xFFFFFFFF00000000L & address) >> 32));
}
Expand All @@ -183,7 +196,7 @@ public final long nonNullAddress() throws NullPointerDereference {
}

public String getHexAddress() {
return String.format("0x%0" + UDATA.SIZEOF * 2 + "X", address);
return String.format("0x%0" + (UDATA.SIZEOF * 2) + "X", address);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,18 +215,12 @@ public J9ClassPointer findJ9ClassInFlattenedClassCacheWithSigName(J9ClassPointer

@Override
public boolean isRomClassAValueType(J9ROMClassPointer romClass) throws CorruptDataException {
if (J9JavaAccessFlags.J9AccValueType != 0) {
return romClass.modifiers().allBitsIn(J9JavaAccessFlags.J9AccValueType);
}
return false;
return romClass.modifiers().allBitsIn(J9JavaAccessFlags.J9AccValueType);
}

@Override
public boolean isJ9ClassAValueType(J9ClassPointer clazz) throws CorruptDataException {
if (J9JavaClassFlags.J9ClassIsValueType != 0) {
return clazz.classFlags().allBitsIn(J9JavaClassFlags.J9ClassIsValueType);
}
return false;
return clazz.classFlags().allBitsIn(J9JavaClassFlags.J9ClassIsValueType);
}

@Override
Expand Down Expand Up @@ -254,34 +248,22 @@ public boolean isFieldInClassFlattened(J9ClassPointer clazz, String fieldName) t

@Override
public boolean isJ9ClassLargestAlignmentConstraintDouble(J9ClassPointer clazz) throws CorruptDataException {
if (J9JavaClassFlags.J9ClassLargestAlignmentConstraintDouble != 0) {
return J9ClassHelper.extendedClassFlags(clazz).allBitsIn(J9JavaClassFlags.J9ClassLargestAlignmentConstraintDouble);
}
return false;
return J9ClassHelper.extendedClassFlags(clazz).allBitsIn(J9JavaClassFlags.J9ClassLargestAlignmentConstraintDouble);
}

@Override
public boolean isJ9ClassLargestAlignmentConstraintReference(J9ClassPointer clazz) throws CorruptDataException {
if (J9JavaClassFlags.J9ClassLargestAlignmentConstraintReference != 0) {
return J9ClassHelper.extendedClassFlags(clazz).allBitsIn(J9JavaClassFlags.J9ClassLargestAlignmentConstraintReference);
}
return false;
return J9ClassHelper.extendedClassFlags(clazz).allBitsIn(J9JavaClassFlags.J9ClassLargestAlignmentConstraintReference);
}

@Override
public boolean isJ9ClassIsFlattened(J9ClassPointer clazz) throws CorruptDataException {
if (J9JavaClassFlags.J9ClassIsFlattened != 0) {
return J9ClassHelper.extendedClassFlags(clazz).allBitsIn(J9JavaClassFlags.J9ClassIsFlattened);
}
return false;
return J9ClassHelper.extendedClassFlags(clazz).allBitsIn(J9JavaClassFlags.J9ClassIsFlattened);
}

@Override
public boolean classRequires4BytePrePadding(J9ClassPointer clazz) throws CorruptDataException {
if (J9JavaClassFlags.J9ClassRequiresPrePadding != 0) {
return J9ClassHelper.extendedClassFlags(clazz).allBitsIn(J9JavaClassFlags.J9ClassRequiresPrePadding);
}
return false;
return J9ClassHelper.extendedClassFlags(clazz).allBitsIn(J9JavaClassFlags.J9ClassRequiresPrePadding);
}

@Override
Expand Down
17 changes: 14 additions & 3 deletions debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/types/Scalar.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2001, 2020 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 Down Expand Up @@ -68,7 +68,7 @@ public long longValue() {
}

public String getHexValue() {
return String.format("0x%0" + sizeof() * 2 + "X", data);
return String.format("0x%0" + (sizeof() * 2) + "X", data);
}

protected String toStringPattern;
Expand Down Expand Up @@ -217,7 +217,18 @@ protected static UDATA roundTo(UDATA value, long size)
return new UDATA(result);
}

public boolean allBitsIn(long bitmask) {
public final boolean allBitsIn(long bitmask) {
if (0 == bitmask) {
/*
* In the vast majority of situations, the caller supplies a non-zero
* argument. However, in backwards-compatibility cases the argument
* may be derived from a constant which has not always been present.
* The behavior we want is for such tests to return false (such a bit
* could never have been set in core dumps generated before the constant
* existed).
*/
return false;
}
return bitmask == (data & bitmask);
}

Expand Down

0 comments on commit ca8cda0

Please sign in to comment.