Skip to content

Commit

Permalink
Add missing Q type checks
Browse files Browse the repository at this point in the history
- Add a Q type check in all locations in which a
Q type should be handled the same way as an L type

- Change comments after #else and #endif directives
to be consistent

For issue #15861

Signed-off-by: Ehren Julien-Neitzert <ehren.julien-neitzert@ibm.com>
  • Loading branch information
Ehren Julien-Neitzert committed Jan 17, 2023
1 parent f0ef7c0 commit e51ed56
Show file tree
Hide file tree
Showing 52 changed files with 317 additions and 170 deletions.
7 changes: 4 additions & 3 deletions debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/j9/ArgBits.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2009, 2014 IBM Corp. and others
* Copyright (c) 2009, 2023 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 @@ -22,6 +22,7 @@
package com.ibm.j9ddr.vm29.j9;

import java.util.Arrays;
import com.ibm.j9ddr.vm29.pointer.helper.J9ClassHelper;

/**
* @author andhall
Expand Down Expand Up @@ -49,7 +50,7 @@ public class ArgBits
/* Parse the signature inside the ()'s */
char thisChar;
while ((thisChar = signature.charAt(++stringPtr)) != ')') {
if ((thisChar == '[') || (thisChar == 'L')) {
if ((thisChar == '[') || J9ClassHelper.isRefOrValSignature(thisChar)) {
/* Mark a bit for objects or arrays */
resultArray[writePtr] |= argBit;

Expand All @@ -58,7 +59,7 @@ public class ArgBits
stringPtr++;
}

if (thisChar == 'L' ) {
if (J9ClassHelper.isRefOrValSignature(thisChar)) {
/* Walk past the name of the object class */
while ((thisChar = signature.charAt(stringPtr)) != ';') {
stringPtr++;
Expand Down
9 changes: 7 additions & 2 deletions debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/j9/SendSlot.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2009, 2014 IBM Corp. and others
* Copyright (c) 2009, 2023 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,6 +23,7 @@

import com.ibm.j9ddr.CorruptDataException;
import com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer;
import com.ibm.j9ddr.vm29.pointer.helper.J9ClassHelper;
import com.ibm.j9ddr.vm29.pointer.helper.J9UTF8Helper;
import com.ibm.j9ddr.vm29.types.UDATA;

Expand All @@ -46,13 +47,17 @@ public static UDATA getSendSlotsFromSignature(J9UTF8Pointer signature) throws Co
case '[':
/* skip all '['s */
for (i++; J9UTF8Helper.stringValue(signature).charAt(i) == '['; i++);
if (J9UTF8Helper.stringValue(signature).charAt(i) == 'L') {
char charAti = J9UTF8Helper.stringValue(signature).charAt(i);
if (J9ClassHelper.isRefOrValSignature(charAti)) {
/* FALL THRU */
} else {
sendArgs = sendArgs.add(1);
break;
}
case 'L':
/*[IF INLINE-TYPES]*/
case 'Q':
/*[ENDIF] INLINE-TYPES */
for (i++; J9UTF8Helper.stringValue(signature).charAt(i) != ';'; i++);
sendArgs = sendArgs.add(1);
break;
Expand Down
19 changes: 10 additions & 9 deletions debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/j9/stackmap/StackMap.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2009, 2019 IBM Corp. and others
* Copyright (c) 2009, 2023 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 @@ -75,6 +75,7 @@
import com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodRefPointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer;
import com.ibm.j9ddr.vm29.pointer.helper.J9ClassHelper;
import com.ibm.j9ddr.vm29.pointer.helper.J9UTF8Helper;
import com.ibm.j9ddr.vm29.types.I16;
import com.ibm.j9ddr.vm29.types.I32;
Expand Down Expand Up @@ -502,7 +503,7 @@ private int mapStack(U16 totalStack, byte[] map,
utf8Signature = J9ROMFieldRefPointer.cast(pool.add(index)).nameAndSignature().signature();

signature = J9UTF8Helper.stringValue(utf8Signature).charAt(0);
if ((signature == 'L') || (signature == '[')) {
if (J9ClassHelper.isRefOrValSignature(signature) || (signature == '[')) {
PUSH(OBJ);
} else {
PUSH(INT);
Expand All @@ -515,7 +516,7 @@ private int mapStack(U16 totalStack, byte[] map,
utf8Signature = J9ROMFieldRefPointer.cast(pool.add(index)).nameAndSignature().signature();

signature = J9UTF8Helper.stringValue(utf8Signature).charAt(0);
if ((signature == 'L') || (signature == '[')) {
if (J9ClassHelper.isRefOrValSignature(signature) || (signature == '[')) {
PUSH(OBJ);
} else {
PUSH(INT);
Expand Down Expand Up @@ -568,11 +569,11 @@ private int mapStack(U16 totalStack, byte[] map,
POP();
if (args[i] == '[') {
while (args[++i] == '[');
if (args[i] != 'L') {
if (J9ClassHelper.isRefOrValSignature(args[i])) {
continue;
}
}
if (args[i] == 'L') {
if (J9ClassHelper.isRefOrValSignature(args[i])) {
while (args[++i] != ';');
continue;
}
Expand All @@ -583,7 +584,7 @@ private int mapStack(U16 totalStack, byte[] map,

signature = args[i + 1];
if (signature != 'V') {
if ((signature == 'L') || (signature == '[')) {
if (J9ClassHelper.isRefOrValSignature(signature) || (signature == '[')) {
PUSH(OBJ);
} else {
PUSH(INT);
Expand Down Expand Up @@ -612,11 +613,11 @@ private int mapStack(U16 totalStack, byte[] map,
POP();
if (args[i] == '[') {
while (args[++i] == '[');
if (args[i] != 'L') {
if (J9ClassHelper.isRefOrValSignature(args[i])) {
continue;
}
}
if (args[i] == 'L') {
if (J9ClassHelper.isRefOrValSignature(args[i])) {
while (args[++i] != ';');
continue;
}
Expand All @@ -627,7 +628,7 @@ private int mapStack(U16 totalStack, byte[] map,

signature = args[i + 1];
if (signature != 'V') {
if ((signature == 'L') || (signature == '[')) {
if (J9ClassHelper.isRefOrValSignature(signature) || (signature == '[')) {
PUSH(OBJ);
} else {
PUSH(INT);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2009, 2022 IBM Corp. and others
* Copyright (c) 2009, 2023 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 @@ -555,10 +555,10 @@ private void jitWalkResolveMethodFrame(WalkState walkState) throws CorruptDataEx
while ((sigChar = jitNextSigChar(signatureString)) != ')') {

switch (sigChar) {
/*[IF INLINE-TYPES]*/
case 'Q': /* fall through */
/*[ENDIF] INLINE-TYPES*/
case 'L':
/*[IF INLINE-TYPES]*/
case 'Q':
/*[ENDIF] INLINE-TYPES */
if (J9SW_ARGUMENT_REGISTER_COUNT_DEFINED && ! stackSpillCount.eq(0) ) {
if ((walkState.flags & J9_STACKWALK_ITERATE_O_SLOTS) != 0) {
try {
Expand Down Expand Up @@ -635,10 +635,10 @@ private char jitNextSigChar(String signatureString) throws CorruptDataException
}
/* Fall through to consume type name, utfChar == 'L' for return value */

/*[IF INLINE-TYPES]*/
case 'Q': /* fall through */
/*[ENDIF] INLINE-TYPES*/
case 'L':
/*[IF INLINE-TYPES]*/
case 'Q':
/*[ENDIF] INLINE-TYPES */
while (signatureString.charAt(charIndex++) != ';') ;
}
return utfChar;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2001, 2021 IBM Corp. and others
* Copyright (c) 2001, 2023 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 @@ -167,8 +167,11 @@ public static String getJavaName(J9ClassPointer clazz) throws CorruptDataExcepti
case 'S': return "void" + aritySuffix;
case 'V': return "void" + aritySuffix;
case 'Z': return "boolean" + aritySuffix;

case 'L':

case 'L':
/*[IF INLINE-TYPES]*/
case 'Q':
/*[ENDIF] INLINE-TYPES */
return getName(arrayClass.leafComponentType()) + aritySuffix;
}

Expand Down Expand Up @@ -526,4 +529,18 @@ public static boolean isAnonymousClass(J9ClassPointer clazz) throws CorruptDataE
return J9ROMClassHelper.isAnonymousClass(clazz.romClass());
}

/**
* Queries if a given char is the first character of a reference or value type signature.
* Equivalent to J9's IS_REF_OR_VAL_SIGNATURE macro.
*
* @param firstChar the first character of the signature being checked
* @return true if the character indicates the beginning of a reference or value signature, false otherwise
*/
public static boolean isRefOrValSignature(char firstChar) {
return firstChar == 'L'
/*[IF INLINE-TYPES]*/
|| (firstChar == 'Q')
/*[ENDIF] INLINE-TYPES */
;
}
}
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, 2023 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 @@ -31,6 +31,7 @@
import com.ibm.j9ddr.vm29.pointer.generated.J9ClassLoaderPointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer;
import com.ibm.j9ddr.vm29.pointer.helper.J9ClassHelper;

public class J9ClassLoaderHelper
{
Expand Down Expand Up @@ -68,8 +69,8 @@ public static J9ClassPointer findClass(J9ClassLoaderPointer classLoader, String
Iterator<J9ClassPointer> classIterator = ClassIterator.fromJ9Classloader(classLoader);

int arity = calculateClassArity(signature);
if (arity > 0 && signature.charAt(arity) != 'L') {

if ((arity > 0) && !J9ClassHelper.isRefOrValSignature(signature.charAt(arity))) {
return PRIMITIVE_TO_CLASS.get(signature.charAt(arity));
} else {
while (classIterator.hasNext()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2001, 2021 IBM Corp. and others
* Copyright (c) 2001, 2023 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 @@ -291,8 +291,11 @@ public static void getData(J9IndexableObjectPointer objPointer, Object dst, int
getBooleanData(objPointer, (boolean[])dst, start, length, destStart);
break;
}

case 'L':
/*[IF INLINE-TYPES]*/
case 'Q':
/*[ENDIF] INLINE-TYPES */
case '[':
{
if (! (dst instanceof J9ObjectPointer[])) {
Expand Down Expand Up @@ -462,8 +465,11 @@ public static Object getData(J9IndexableObjectPointer objPointer) throws Corrupt
getBooleanData(objPointer, data, 0, arraySize, 0);
return data;
}

case 'L':
/*[IF INLINE-TYPES]*/
case 'Q':
/*[ENDIF] INLINE-TYPES */
case '[':
{
J9ObjectPointer[] data = new J9ObjectPointer[arraySize];
Expand Down Expand Up @@ -540,6 +546,9 @@ public static String getDataAsString(J9IndexableObjectPointer array, int dumpLim
break;

case 'L':
/*[IF INLINE-TYPES]*/
case 'Q':
/*[ENDIF] INLINE-TYPES */
case '[':
{
J9ObjectPointer item = ((J9ObjectPointer[])data)[i];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2001, 2019 IBM Corp. and others
* Copyright (c) 2001, 2023 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 @@ -84,6 +84,9 @@ public void run(String command, String[] args, Context context, PrintStream out)

switch (sig.charAt(0)) {
case 'L':
/*[IF INLINE-TYPES]*/
case 'Q':
/*[ENDIF] INLINE-TYPES */
case '[':
CommandUtils.dbgPrint(out, "\t%s %s %s (!j9romstaticfieldshape %s) = !j9object %s\n",
fieldAddress.getHexAddress(), name, sig, field.getHexAddress(), fieldAddress.at(0).getHexValue());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2010, 2020 IBM Corp. and others
* Copyright (c) 2010, 2023 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 @@ -221,13 +221,16 @@ private void formatArrayObject(PrintStream out, J9ClassPointer localClazz, U8Poi
}
break;
case 'L':
/*[IF INLINE-TYPES]*/
case 'Q':
/*[ENDIF] INLINE-TYPES */
case '[':
if (ValueTypeHelper.getValueTypeHelper().isJ9ClassIsFlattened(localClazz)) {
formatFlattenedObjectArray(out, tabLevel, begin, finish, array);
} else {
formatReferenceObjectArray(out, tabLevel, localClazz, begin, finish, array);
}
break;
break;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2021 IBM Corp. and others
* Copyright (c) 1991, 2023 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 @@ -326,8 +326,8 @@ boolean isObjectArray() throws CorruptDataException, com.ibm.j9ddr.CorruptDataEx
if (isArray()) {
J9ArrayClassPointer arrayClass = J9ArrayClassPointer.cast(j9class);

//Any multi-dimensional array is an object array, as is any single dimensional array with an object type (i.e. [Lwhatever;)
if(arrayClass.arity().gt(1) || getName().charAt(1) == 'L') {
// Any multi-dimensional array is an object array, as is any single dimensional array with an object type (i.e. [Lwhatever; or [Qwhatever;).
if (arrayClass.arity().gt(1) || J9ClassHelper.isRefOrValSignature(getName().charAt(1))) {
isObjectArray = true;
} else {
isObjectArray = false;
Expand Down
4 changes: 2 additions & 2 deletions jcl/src/java.base/share/classes/java/lang/J9VMInternals.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*[INCLUDE-IF JAVA_SPEC_VERSION >= 8]*/
/*******************************************************************************
* Copyright (c) 1998, 2022 IBM Corp. and others
* Copyright (c) 1998, 2023 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 @@ -507,7 +507,7 @@ static int fastIdentityHashCode(Object anObject) {
*/
static native int identityHashCode(Object anObject);

/*[IF INLINE-TYPES] */
/*[IF INLINE-TYPES]*/
/**
* Answers an integer hash code for the parameter.
* The caller must ensure that the parameter is a value type.
Expand Down
4 changes: 2 additions & 2 deletions jcl/src/java.base/share/classes/java/lang/Object.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*[INCLUDE-IF JAVA_SPEC_VERSION >= 8]*/
/*******************************************************************************
* Copyright (c) 1998, 2022 IBM Corp. and others
* Copyright (c) 1998, 2023 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 @@ -134,7 +134,7 @@ protected void finalize () throws Throwable {
* @see #equals
*/
public int hashCode() {
/*[IF INLINE-TYPES] */
/*[IF INLINE-TYPES]*/
if (this.getClass().isValue()) {
return J9VMInternals.valueHashCode(this);
}
Expand Down
Loading

0 comments on commit e51ed56

Please sign in to comment.