Skip to content

Commit 2db6b17

Browse files
committed
debug
Signed-off-by: Tobi Ajila <[email protected]>
1 parent cf0437b commit 2db6b17

File tree

11 files changed

+115
-79
lines changed

11 files changed

+115
-79
lines changed

jcl/src/java.base/share/classes/com/ibm/oti/vm/VM.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ public static int markCurrentThreadAsSystem()
631631
* constantpool associated with clazz
632632
*/
633633
public static ConstantPool getConstantPoolFromAnnotationBytes(Class<?> clazz, byte[] array) {
634-
/* Check the cp cache on the Class object first */
634+
/* Check the cp cache on the Class object first. */
635635
ConstantPool cp = VM.getVMLangAccess().getConstantPoolCache(clazz);
636636
if (null != cp) {
637637
return cp;

jcl/src/java.base/share/classes/com/ibm/oti/vm/VMLangAccess.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public interface VMLangAccess {
214214
/*[ENDIF] JAVA_SPEC_VERSION >= 11*/
215215

216216
/**
217-
* Returns a cached constantPool Object from a given java.lang.Class
217+
* Returns a cached constantPool Object from a given java.lang.Class.
218218
*
219219
* @param clazz
220220
*

jcl/src/java.base/share/classes/java/lang/InternalConstantPool.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0
2323
*/
2424

25+
import com.ibm.oti.vm.VM;
26+
2527
/**
2628
* Represents the internal J9ConstantPool
2729
*
@@ -34,5 +36,6 @@ final class InternalConstantPool {
3436
public InternalConstantPool(long addr, Class<?> clazz) {
3537
this.vmRef = addr;
3638
this.clazz = clazz;
39+
VM.dumpString("addr: " + addr + " clazz: " + clazz.getName());
3740
}
3841
}

runtime/gc_include/ObjectAllocationAPI.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,10 @@ class MM_ObjectAllocationAPI
346346
allocateSize = J9_GC_MINIMUM_OBJECT_SIZE;
347347
}
348348

349+
if (J9VMJAVALANGINTERNALCONSTANTPOOL_OR_NULL(currentThread->javaVM) == clazz) {
350+
return NULL;
351+
}
352+
349353
/* Allocate the object */
350354
switch(_gcAllocationType) {
351355
#if defined(J9VM_GC_THREAD_LOCAL_HEAP)
@@ -441,6 +445,7 @@ class MM_ObjectAllocationAPI
441445
VM_AtomicSupport::writeBarrier();
442446
}
443447
#endif /* J9VM_GC_THREAD_LOCAL_HEAP || J9VM_GC_SEGREGATED_HEAP */
448+
444449
return instance;
445450
}
446451

runtime/gc_modron_startup/mgcalloc.cpp

Lines changed: 60 additions & 50 deletions
Large diffs are not rendered by default.

runtime/include/ffi_cfi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#ifndef FFI_CFI_H
88
#define FFI_CFI_H
99

10+
#undef HAVE_AS_CFI_PSEUDO_OP
11+
1012
#ifdef HAVE_AS_CFI_PSEUDO_OP
1113

1214
# define cfi_startproc .cfi_startproc

runtime/jcl/common/com_ibm_oti_vm_VM.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,10 @@ Java_com_ibm_oti_vm_VM_markCurrentThreadAsSystemImpl(JNIEnv *env)
167167
jlong JNICALL
168168
Java_com_ibm_oti_vm_VM_getJ9ConstantPoolFromJ9Class(JNIEnv *env, jclass unused, jlong j9clazz)
169169
{
170-
J9Class *clazz = (J9Class *)JLONG_TO_POINTER(j9clazz);
171-
return JLONG_FROM_POINTER(clazz->ramConstantPool);
170+
J9Class *clazz = (J9Class *)(UDATA)j9clazz;
171+
172+
Trc_JCL_accessCPEntry2((J9VMThread*)env, clazz, clazz->ramConstantPool);
173+
return (jlong)(UDATA)clazz->ramConstantPool;
172174
}
173175

174176
/**

runtime/jcl/common/java_lang_Access.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ Java_java_lang_Access_getConstantPool(JNIEnv *env, jclass unusedClass, jobject c
4848
J9MemoryManagerFunctions *gcFunctions = vmThread->javaVM->memoryManagerFunctions;
4949
j9object_t classObject = NULL;
5050
J9Class *clazz = NULL;
51+
j9object_t debugObj = NULL;
52+
J9Class *debugClazz = NULL;
5153

5254
/* lazy-initialize the cached field IDs */
5355
if (NULL == sun_reflect_ConstantPool) {
@@ -67,8 +69,7 @@ Java_java_lang_Access_getConstantPool(JNIEnv *env, jclass unusedClass, jobject c
6769
vmFunctions->internalEnterVMFromJNI(vmThread);
6870
classObject = J9_JNI_UNWRAP_REFERENCE(classToIntrospect);
6971
if (J9VMJAVALANGCLASS_OR_NULL(vmThread->javaVM) == J9OBJECT_CLAZZ(vmThread, classObject)) {
70-
clazz = J9VM_J9CLASS_FROM_HEAPCLASS(vmThread, classObject);
71-
J9ConstantPool *j9CP = (J9ConstantPool *)clazz->ramConstantPool;
72+
J9ConstantPool *j9CP = NULL;
7273
J9Class *internalConstantPool = J9VMJAVALANGINTERNALCONSTANTPOOL_OR_NULL(vmThread->javaVM);
7374
Assert_JCL_notNull(internalConstantPool);
7475
j9object_t internalConstantPoolObject = gcFunctions->J9AllocateObject(vmThread, internalConstantPool, J9_GC_ALLOCATE_OBJECT_NON_INSTRUMENTABLE);
@@ -77,18 +78,26 @@ Java_java_lang_Access_getConstantPool(JNIEnv *env, jclass unusedClass, jobject c
7778
vmFunctions->internalExitVMToJNI(vmThread);
7879
return NULL;
7980
}
81+
classObject = J9_JNI_UNWRAP_REFERENCE(classToIntrospect);
82+
clazz = J9VM_J9CLASS_FROM_HEAPCLASS(vmThread, classObject);
83+
j9CP = (J9ConstantPool *)clazz->ramConstantPool;
8084
J9VMJAVALANGINTERNALCONSTANTPOOL_SET_VMREF(vmThread, internalConstantPoolObject, j9CP);
8185
J9VMJAVALANGINTERNALCONSTANTPOOL_SET_CLAZZ(vmThread, internalConstantPoolObject, classObject);
8286
classToIntrospect = vmFunctions->j9jni_createLocalRef(env, internalConstantPoolObject);
87+
Trc_JCL_accessCPEntry(vmThread, J9_JNI_UNWRAP_REFERENCE(constantPool), J9_JNI_UNWRAP_REFERENCE(classToIntrospect), clazz, j9CP);
8388
}
8489

8590
#if JAVA_SPEC_VERSION == 8
8691
J9VMSUNREFLECTCONSTANTPOOL_SET_CONSTANTPOOLOOP(vmThread, J9_JNI_UNWRAP_REFERENCE(constantPool), J9_JNI_UNWRAP_REFERENCE(classToIntrospect));
8792
#else /* JAVA_SPEC_VERSION == 8 */
8893
J9VMJDKINTERNALREFLECTCONSTANTPOOL_SET_CONSTANTPOOLOOP(vmThread, J9_JNI_UNWRAP_REFERENCE(constantPool), J9_JNI_UNWRAP_REFERENCE(classToIntrospect));
8994
#endif /* JAVA_SPEC_VERSION == 8 */
95+
debugObj = J9_JNI_UNWRAP_REFERENCE(classToIntrospect);
96+
debugClazz = J9OBJECT_CLAZZ(vmThread, classObject);
97+
Trc_JCL_accessCPEntry4(vmThread, J9_JNI_UNWRAP_REFERENCE(constantPool), debugObj, debugClazz, debugClazz->ramConstantPool);
9098

9199
if (NULL == clazz) {
100+
Trc_JCL_accessCPEntry3(vmThread, J9_JNI_UNWRAP_REFERENCE(constantPool), J9_JNI_UNWRAP_REFERENCE(classToIntrospect), debugClazz, debugClazz->ramConstantPool);
92101
/* If we are here then classToIntrospect is an InternalConstantPool object, find the class object. */
93102
classObject = J9VMJAVALANGINTERNALCONSTANTPOOL_CLAZZ(vmThread, J9_JNI_UNWRAP_REFERENCE(classToIntrospect));
94103
clazz = J9VM_J9CLASS_FROM_HEAPCLASS(vmThread, classObject);

runtime/jcl/common/jclcinit.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ initializeRequiredClasses(J9VMThread *vmThread, char* dllName)
554554
J9VMCONSTANTPOOL_JAVALANGTHREADFIELDHOLDER,
555555
J9VMCONSTANTPOOL_JAVALANGBASEVIRTUALTHREAD,
556556
#endif /* JAVA_SPEC_VERSION >= 19 */
557+
J9VMCONSTANTPOOL_JAVALANGINTERNALCONSTANTPOOL,
557558
};
558559

559560
/* Determine java/lang/String.value signature before any required class is initialized */

runtime/jcl/common/jclvm.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
typedef struct AllInstancesData {
4747
J9Class *clazz; /* class being looked for */
48-
J9VMThread *vmThread;
48+
J9VMThread *vmThread;
4949
J9IndexableObject *target; /* the array */
5050
UDATA size; /* size of the array */
5151
UDATA storeIndex; /* current index being stored */
@@ -118,16 +118,16 @@ jint JNICALL Java_com_ibm_oti_vm_VM_getClassPathCount(JNIEnv * env, jclass clazz
118118
* Fill in all the instances of clazz into target.
119119
* return the count of the instances in the system
120120
* if the count is > than the array size, there are more strings than fit.
121-
* if count is <= the array size, the array may have null references.
121+
* if count is <= the array size, the array may have null references.
122122
* static void allInstances (Class, Object[])
123123
*/
124-
jint JNICALL
125-
Java_com_ibm_oti_vm_VM_allInstances(JNIEnv * env, jclass unused, jclass clazz, jobjectArray target )
124+
jint JNICALL
125+
Java_com_ibm_oti_vm_VM_allInstances(JNIEnv * env, jclass unused, jclass clazz, jobjectArray target )
126126
{
127127
jint count = 0;
128128
J9VMThread *vmThread = (J9VMThread *) env;
129129
J9JavaVM *javaVM = vmThread->javaVM;
130-
130+
131131
if (OMR_GC_ALLOCATION_TYPE_SEGREGATED != javaVM->gcAllocationType) {
132132
UDATA savedGCFlags = 0;
133133

@@ -153,7 +153,7 @@ Java_com_ibm_oti_vm_VM_allInstances(JNIEnv * env, jclass unused, jclass clazz, j
153153
}
154154

155155
/**
156-
* Return a String object containing a summary of the classes on the heap,
156+
* Return a String object containing a summary of the classes on the heap,
157157
* the number of instances, and their aggregate size.
158158
* This string inserts Unix-style line separators. The caller is responsible for translating them if necessary.
159159
*/
@@ -317,12 +317,12 @@ printHeapStatistics(JNIEnv *env,J9HeapStatisticsTableEntry **statsArray,
317317
* String2 has its bytes set to be string1-> bytes if the offsets already match and the bytes are not already set to the same value
318318
* The bytes being set already could happen frequently as this primitive will be used repeatedly to remerge strings in the runtime
319319
*/
320-
jint JNICALL
321-
Java_com_ibm_oti_vm_VM_setCommonData(JNIEnv * env, jclass unused, jobject string1, jobject string2 )
320+
jint JNICALL
321+
Java_com_ibm_oti_vm_VM_setCommonData(JNIEnv * env, jclass unused, jobject string1, jobject string2 )
322322
{
323323
UDATA allowMerge = 0;
324324
J9VMThread *vmThread = (J9VMThread *) env;
325-
J9JavaVM *javaVM = vmThread->javaVM;
325+
J9JavaVM *javaVM = vmThread->javaVM;
326326

327327
if (OMR_GC_ALLOCATION_TYPE_SEGREGATED != javaVM->gcAllocationType) {
328328
if (string1 == NULL || string2 == NULL) {
@@ -343,7 +343,7 @@ Java_com_ibm_oti_vm_VM_setCommonData(JNIEnv * env, jclass unused, jobject string
343343
stringBytes2 = J9VMJAVALANGSTRING_VALUE(vmThread, unwrappedString2);
344344

345345
/* skip merging of bytes if they are already the same. As this primitive is called repeatedly, then its likely the character data will be the same
346-
* on repeat calls.
346+
* on repeat calls.
347347
*/
348348

349349
if (stringBytes1 == stringBytes2) {
@@ -359,13 +359,13 @@ Java_com_ibm_oti_vm_VM_setCommonData(JNIEnv * env, jclass unused, jobject string
359359
}
360360
}
361361

362-
362+
363363
return (jint)allowMerge;
364364
}
365365

366366

367-
static UDATA
368-
allInstances (JNIEnv * env, jclass clazz, jobjectArray target)
367+
static UDATA
368+
allInstances (JNIEnv * env, jclass clazz, jobjectArray target)
369369
{
370370
J9VMThread *vmThread = (J9VMThread *) env;
371371
AllInstancesData data;
@@ -408,9 +408,9 @@ collectInstances (J9JavaVM *vm, J9MM_IterateObjectDescriptor *objDesc, void *sta
408408
if (J9OBJECT_CLAZZ_VM(vm, obj) == data->clazz) {
409409
data->instanceCount++;
410410
/* fill in the array only if one was passed in */
411-
if (data->target != NULL) {
411+
if (data->target != NULL) {
412412
/* if no room, you can ignore the object and not store it */
413-
if (data->storeIndex < data->size) {
413+
if (data->storeIndex < data->size) {
414414
J9JAVAARRAYOFOBJECT_STORE_VM(vm, data->target, (I_32)data->storeIndex, obj);
415415
data->storeIndex++;
416416
}
@@ -420,8 +420,8 @@ collectInstances (J9JavaVM *vm, J9MM_IterateObjectDescriptor *objDesc, void *sta
420420
}
421421

422422

423-
static int
424-
hasActiveConstructor(J9VMThread *vmThread, J9Class *clazz)
423+
static int
424+
hasActiveConstructor(J9VMThread *vmThread, J9Class *clazz)
425425
{
426426
J9JavaVM *vm = vmThread->javaVM;
427427
J9VMThread * walkThread;
@@ -446,7 +446,7 @@ hasActiveConstructor(J9VMThread *vmThread, J9Class *clazz)
446446
}
447447

448448

449-
static UDATA
449+
static UDATA
450450
hasConstructor(J9VMThread *vmThread, J9StackWalkState *state)
451451
{
452452
J9Method *method = state->method;
@@ -458,9 +458,9 @@ hasConstructor(J9VMThread *vmThread, J9StackWalkState *state)
458458
J9Class *methodClass = J9_CLASS_FROM_METHOD(method);
459459
J9ROMMethod *romMethod = J9_ROM_METHOD_FROM_RAM_METHOD(method);
460460
J9UTF8 *methodName = J9ROMMETHOD_NAME(romMethod);
461-
461+
462462
/* if the method is a constructor in the class we're looking for then quit looking for more
463-
* a constructor is a non-static (to filter clinit) method which starts with '<'.
463+
* a constructor is a non-static (to filter clinit) method which starts with '<'.
464464
*/
465465
if (methodClass == classToFind) {
466466
if (!(romMethod->modifiers & J9AccStatic)) {
@@ -564,7 +564,7 @@ Java_com_ibm_oti_vm_VM_dumpString(JNIEnv * env, jclass clazz, jstring str)
564564

565565
if (utfChars != NULL) {
566566
Trc_JCL_com_ibm_oti_vm_VM_dumpString(env, utfChars);
567-
j9tty_printf(PORTLIB, "%s", utfChars);
567+
//j9tty_printf(PORTLIB, "%s", utfChars);
568568
(*env)->ReleaseStringUTFChars(env, str, utfChars);
569569
}
570570
}

0 commit comments

Comments
 (0)