< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverReachableObjects/iterreachobj002/iterreachobj002.cpp

Print this page
rev 52200 : [mq]: spaces


  47     struct ObjectDescStruct *next;
  48 } ObjectDesc;
  49 
  50 static ObjectDesc *objectDescList, *objectDescListStart, *objectDescBuf;
  51 static ObjectDesc* *objectDescArr;
  52 static short* deallocatedFlagsArr;
  53 
  54 /* ============================================================================= */
  55 
  56 void JNICALL
  57 ObjectFree(jvmtiEnv *jvmti_env, jlong tag) {
  58     /* decrement number of expected objects  */
  59     objectCount--;
  60 }
  61 
  62 /* ============================================================================= */
  63 
  64 
  65 /** jvmtiHeapRootCallback for first iteration. */
  66 jvmtiIterationControl JNICALL
  67 heapRootCallbackForFirstObjectsIteration( jvmtiHeapRootKind root_kind,
  68                    jlong class_tag,
  69                    jlong size,
  70                    jlong* tag_ptr,
  71                    void* user_data) {
  72 
  73     if (*tag_ptr != 0) return JVMTI_ITERATION_CONTINUE;
  74 
  75     /* Set tag */
  76     *tag_ptr = (jlong)++objectCount;
  77 
  78     if (!NSK_JVMTI_VERIFY(jvmti->Allocate((sizeof(ObjectDesc)), (unsigned char**)&objectDescBuf))) {
  79         nsk_jvmti_setFailStatus();
  80         callbackAborted = 1;
  81         NSK_COMPLAIN0("heapRootCallbackForFirstObjectsIteration: Allocation failed. Iteration aborted.\n");
  82         return JVMTI_ITERATION_ABORT;
  83     }
  84 
  85     (*objectDescList).tag = *tag_ptr;
  86     (*objectDescList).size = size;
  87     (*objectDescList).next = objectDescBuf;
  88 
  89     /* step to next list element */
  90     objectDescList = (*objectDescList).next;
  91 
  92     return JVMTI_ITERATION_CONTINUE;
  93 }
  94 
  95 /** jvmtiHeapRootCallback for second iteration. */
  96 jvmtiIterationControl JNICALL
  97 heapRootCallbackForSecondObjectsIteration( jvmtiHeapRootKind root_kind,
  98                    jlong class_tag,
  99                    jlong size,
 100                    jlong* tag_ptr,
 101                    void* user_data) {
 102 
 103     long ind = (long)((*tag_ptr) - 1);
 104 
 105     if (*tag_ptr == 0) return JVMTI_ITERATION_CONTINUE;
 106 
 107 /*
 108     ObjectDesc *objectDesc = objectDescArr[ind];
 109     jlong tag = (*objectDesc).tag;
 110 */
 111     if (ind < 0 || ind > objectCountMax ) {
 112         NSK_COMPLAIN1("heapRootCallbackForSecondObjectsIteration: invalid object tag value: %d\n", (long)*tag_ptr);
 113         nsk_jvmti_setFailStatus();
 114         callbackAborted = 1;
 115         return JVMTI_ITERATION_ABORT;
 116     }
 117 /*
 118     NSK_DISPLAY3("heapRootCallbackForSecondObjectsIteration: *tag_ptr %6d , tag %6d , objectCount %6d\n",
 119                      (long)*tag_ptr, (long)tag, objectCount);
 120 */
 121     /* Deallocate memory of list element*/
 122     if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)objectDescArr[ind]))) {
 123         nsk_jvmti_setFailStatus();
 124         callbackAborted = 1;
 125         NSK_COMPLAIN0("heapRootCallbackForSecondObjectsIteration: Deallocation failed. Iteration aborted.\n");
 126         return JVMTI_ITERATION_ABORT;
 127     }
 128 
 129     numberOfDeallocatedFromCallbacksDescriptors++;
 130     deallocatedFlagsArr[ind] = 1;
 131 
 132     /* unset tag */
 133     *tag_ptr = 0;
 134     objectCount--;
 135 
 136     return JVMTI_ITERATION_CONTINUE;
 137 }
 138 
 139 /** jvmtiStackReferenceCallback for first iteration. */
 140 jvmtiIterationControl JNICALL
 141 stackReferenceCallbackForFirstObjectsIteration( jvmtiHeapRootKind root_kind,
 142                          jlong     class_tag,
 143                          jlong     size,
 144                          jlong*    tag_ptr,
 145                          jlong     thread_tag,
 146                          jint      depth,
 147                          jmethodID method,
 148                          jint      slot,
 149                          void*     user_data) {
 150 
 151     if (*tag_ptr != 0) return JVMTI_ITERATION_CONTINUE;
 152 
 153     /* Set tag */
 154     *tag_ptr = (jlong)++objectCount;
 155 
 156     if (!NSK_JVMTI_VERIFY(jvmti->Allocate((sizeof(ObjectDesc)), (unsigned char**)&objectDescBuf))) {
 157         nsk_jvmti_setFailStatus();
 158         callbackAborted = 1;
 159         NSK_COMPLAIN0("stackReferenceCallbackForFirstObjectsIteration: Allocation failed. Iteration aborted.\n");
 160         return JVMTI_ITERATION_ABORT;
 161     }
 162 
 163     (*objectDescList).tag = *tag_ptr;
 164     (*objectDescList).size = size;
 165     (*objectDescList).next = objectDescBuf;
 166 
 167     /* step to next list element */
 168     objectDescList = (*objectDescList).next;
 169 
 170     return JVMTI_ITERATION_CONTINUE;
 171 }
 172 
 173 /** jvmtiStackReferenceCallback for second iteration. */
 174 jvmtiIterationControl JNICALL
 175 stackReferenceCallbackForSecondObjectsIteration( jvmtiHeapRootKind root_kind,
 176                          jlong     class_tag,
 177                          jlong     size,
 178                          jlong*    tag_ptr,
 179                          jlong     thread_tag,
 180                          jint      depth,
 181                          jmethodID method,
 182                          jint      slot,
 183                          void*     user_data) {
 184 
 185     long ind = (long)((*tag_ptr) - 1);
 186 
 187     if (*tag_ptr == 0) return JVMTI_ITERATION_CONTINUE;
 188 
 189 /*
 190     ObjectDesc *objectDesc = objectDescArr[ind];
 191     jlong tag = (*objectDesc).tag;
 192 */
 193     if (ind < 0 || ind > objectCountMax ) {
 194         NSK_COMPLAIN1("stackReferenceCallbackForSecondObjectsIteration: invalid object tag value: %d\n", (long)*tag_ptr);
 195         nsk_jvmti_setFailStatus();
 196         callbackAborted = 1;
 197         return JVMTI_ITERATION_ABORT;
 198     }
 199 /*
 200     NSK_DISPLAY3("stackReferenceCallbackForSecondObjectsIteration: *tag_ptr %6d , tag %6d , objectCount %6d\n",
 201                      (long)*tag_ptr, (long)tag, objectCount);
 202 */
 203     /* Deallocate memory of list element*/
 204     if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)objectDescArr[ind]))) {
 205         nsk_jvmti_setFailStatus();
 206         callbackAborted = 1;
 207         NSK_COMPLAIN0("stackReferenceCallbackForSecondObjectsIteration: Deallocation failed. Iteration aborted.\n");
 208         return JVMTI_ITERATION_ABORT;
 209     }
 210 
 211     numberOfDeallocatedFromCallbacksDescriptors++;
 212     deallocatedFlagsArr[ind] = 1;
 213 
 214     /* unset tag */
 215     *tag_ptr = 0;
 216     objectCount--;
 217 
 218     return JVMTI_ITERATION_CONTINUE;
 219 }
 220 
 221 /** jvmtiObjectReferenceCallback for first iteration. */
 222 jvmtiIterationControl JNICALL
 223 objectReferenceCallbackForFirstObjectsIteration( jvmtiObjectReferenceKind reference_kind,
 224                           jlong  class_tag,
 225                           jlong  size,
 226                           jlong* tag_ptr,
 227                           jlong  referrer_tag,
 228                           jint   referrer_index,
 229                           void*  user_data) {
 230 
 231     if (*tag_ptr != 0) return JVMTI_ITERATION_CONTINUE;
 232 
 233     /* Set tag */
 234     *tag_ptr = (jlong)++objectCount;
 235 
 236     if (!NSK_JVMTI_VERIFY(jvmti->Allocate((sizeof(ObjectDesc)), (unsigned char**)&objectDescBuf))) {
 237         nsk_jvmti_setFailStatus();
 238         callbackAborted = 1;
 239         NSK_COMPLAIN0("objectReferenceCallbackForFirstObjectsIteration: Allocation failed. Iteration aborted.\n");
 240         return JVMTI_ITERATION_ABORT;
 241     }
 242 
 243     (*objectDescList).tag = *tag_ptr;
 244     (*objectDescList).size = size;
 245     (*objectDescList).next = objectDescBuf;
 246 
 247     /* step to next list element */
 248     objectDescList = (*objectDescList).next;
 249 
 250     return JVMTI_ITERATION_CONTINUE;
 251 }
 252 
 253 /** jvmtiObjectReferenceCallback for second iteration. */
 254 jvmtiIterationControl JNICALL
 255 objectReferenceCallbackForSecondObjectsIteration( jvmtiObjectReferenceKind reference_kind,
 256                           jlong  class_tag,
 257                           jlong  size,
 258                           jlong* tag_ptr,
 259                           jlong  referrer_tag,
 260                           jint   referrer_index,
 261                           void*  user_data) {
 262 
 263     long ind = (long)((*tag_ptr) - 1);
 264 
 265     if (*tag_ptr == 0) return JVMTI_ITERATION_CONTINUE;
 266 
 267 /*
 268     ObjectDesc *objectDesc = objectDescArr[ind];
 269     jlong tag = (*objectDesc).tag;
 270 */
 271     if (ind < 0 || ind > objectCountMax ) {
 272         NSK_COMPLAIN1("objectReferenceCallbackForSecondObjectsIteration: invalid object tag value: %d\n", (long)*tag_ptr);
 273         nsk_jvmti_setFailStatus();
 274         callbackAborted = 1;
 275         return JVMTI_ITERATION_ABORT;
 276     }
 277 /*
 278     NSK_DISPLAY3("objectReferenceCallbackForSecondObjectsIteration: *tag_ptr %6d , tag %6d , objectCount %6d\n",
 279                      (long)*tag_ptr, (long)tag, objectCount);
 280 */
 281     /* Deallocate memory of list element*/
 282     if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)objectDescArr[ind]))) {
 283         nsk_jvmti_setFailStatus();
 284         callbackAborted = 1;
 285         NSK_COMPLAIN0("objectReferenceCallbackForSecondObjectsIteration: Deallocation failed. Iteration aborted.\n");
 286         return JVMTI_ITERATION_ABORT;
 287     }
 288 
 289     numberOfDeallocatedFromCallbacksDescriptors++;
 290     deallocatedFlagsArr[ind] = 1;
 291 




  47     struct ObjectDescStruct *next;
  48 } ObjectDesc;
  49 
  50 static ObjectDesc *objectDescList, *objectDescListStart, *objectDescBuf;
  51 static ObjectDesc* *objectDescArr;
  52 static short* deallocatedFlagsArr;
  53 
  54 /* ============================================================================= */
  55 
  56 void JNICALL
  57 ObjectFree(jvmtiEnv *jvmti_env, jlong tag) {
  58     /* decrement number of expected objects  */
  59     objectCount--;
  60 }
  61 
  62 /* ============================================================================= */
  63 
  64 
  65 /** jvmtiHeapRootCallback for first iteration. */
  66 jvmtiIterationControl JNICALL
  67 heapRootCallbackForFirstObjectsIteration(jvmtiHeapRootKind root_kind,
  68                                          jlong class_tag,
  69                                          jlong size,
  70                                          jlong* tag_ptr,
  71                                          void* user_data) {
  72 
  73     if (*tag_ptr != 0) return JVMTI_ITERATION_CONTINUE;
  74 
  75     /* Set tag */
  76     *tag_ptr = (jlong)++objectCount;
  77 
  78     if (!NSK_JVMTI_VERIFY(jvmti->Allocate((sizeof(ObjectDesc)), (unsigned char**)&objectDescBuf))) {
  79         nsk_jvmti_setFailStatus();
  80         callbackAborted = 1;
  81         NSK_COMPLAIN0("heapRootCallbackForFirstObjectsIteration: Allocation failed. Iteration aborted.\n");
  82         return JVMTI_ITERATION_ABORT;
  83     }
  84 
  85     (*objectDescList).tag = *tag_ptr;
  86     (*objectDescList).size = size;
  87     (*objectDescList).next = objectDescBuf;
  88 
  89     /* step to next list element */
  90     objectDescList = (*objectDescList).next;
  91 
  92     return JVMTI_ITERATION_CONTINUE;
  93 }
  94 
  95 /** jvmtiHeapRootCallback for second iteration. */
  96 jvmtiIterationControl JNICALL
  97 heapRootCallbackForSecondObjectsIteration(jvmtiHeapRootKind root_kind,
  98                                           jlong class_tag,
  99                                           jlong size,
 100                                           jlong* tag_ptr,
 101                                           void* user_data) {
 102 
 103     long ind = (long)((*tag_ptr) - 1);
 104 
 105     if (*tag_ptr == 0) return JVMTI_ITERATION_CONTINUE;
 106 
 107 /*
 108     ObjectDesc *objectDesc = objectDescArr[ind];
 109     jlong tag = (*objectDesc).tag;
 110 */
 111     if (ind < 0 || ind > objectCountMax) {
 112         NSK_COMPLAIN1("heapRootCallbackForSecondObjectsIteration: invalid object tag value: %d\n", (long)*tag_ptr);
 113         nsk_jvmti_setFailStatus();
 114         callbackAborted = 1;
 115         return JVMTI_ITERATION_ABORT;
 116     }
 117 /*
 118     NSK_DISPLAY3("heapRootCallbackForSecondObjectsIteration: *tag_ptr %6d , tag %6d , objectCount %6d\n",
 119                      (long)*tag_ptr, (long)tag, objectCount);
 120 */
 121     /* Deallocate memory of list element*/
 122     if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)objectDescArr[ind]))) {
 123         nsk_jvmti_setFailStatus();
 124         callbackAborted = 1;
 125         NSK_COMPLAIN0("heapRootCallbackForSecondObjectsIteration: Deallocation failed. Iteration aborted.\n");
 126         return JVMTI_ITERATION_ABORT;
 127     }
 128 
 129     numberOfDeallocatedFromCallbacksDescriptors++;
 130     deallocatedFlagsArr[ind] = 1;
 131 
 132     /* unset tag */
 133     *tag_ptr = 0;
 134     objectCount--;
 135 
 136     return JVMTI_ITERATION_CONTINUE;
 137 }
 138 
 139 /** jvmtiStackReferenceCallback for first iteration. */
 140 jvmtiIterationControl JNICALL
 141 stackReferenceCallbackForFirstObjectsIteration(jvmtiHeapRootKind root_kind,
 142                                                jlong     class_tag,
 143                                                jlong     size,
 144                                                jlong*    tag_ptr,
 145                                                jlong     thread_tag,
 146                                                jint      depth,
 147                                                jmethodID method,
 148                                                jint      slot,
 149                                                void*     user_data) {
 150 
 151     if (*tag_ptr != 0) return JVMTI_ITERATION_CONTINUE;
 152 
 153     /* Set tag */
 154     *tag_ptr = (jlong)++objectCount;
 155 
 156     if (!NSK_JVMTI_VERIFY(jvmti->Allocate((sizeof(ObjectDesc)), (unsigned char**)&objectDescBuf))) {
 157         nsk_jvmti_setFailStatus();
 158         callbackAborted = 1;
 159         NSK_COMPLAIN0("stackReferenceCallbackForFirstObjectsIteration: Allocation failed. Iteration aborted.\n");
 160         return JVMTI_ITERATION_ABORT;
 161     }
 162 
 163     (*objectDescList).tag = *tag_ptr;
 164     (*objectDescList).size = size;
 165     (*objectDescList).next = objectDescBuf;
 166 
 167     /* step to next list element */
 168     objectDescList = (*objectDescList).next;
 169 
 170     return JVMTI_ITERATION_CONTINUE;
 171 }
 172 
 173 /** jvmtiStackReferenceCallback for second iteration. */
 174 jvmtiIterationControl JNICALL
 175 stackReferenceCallbackForSecondObjectsIteration(jvmtiHeapRootKind root_kind,
 176                          jlong     class_tag,
 177                          jlong     size,
 178                          jlong*    tag_ptr,
 179                          jlong     thread_tag,
 180                          jint      depth,
 181                          jmethodID method,
 182                          jint      slot,
 183                          void*     user_data) {
 184 
 185     long ind = (long)((*tag_ptr) - 1);
 186 
 187     if (*tag_ptr == 0) return JVMTI_ITERATION_CONTINUE;
 188 
 189 /*
 190     ObjectDesc *objectDesc = objectDescArr[ind];
 191     jlong tag = (*objectDesc).tag;
 192 */
 193     if (ind < 0 || ind > objectCountMax) {
 194         NSK_COMPLAIN1("stackReferenceCallbackForSecondObjectsIteration: invalid object tag value: %d\n", (long)*tag_ptr);
 195         nsk_jvmti_setFailStatus();
 196         callbackAborted = 1;
 197         return JVMTI_ITERATION_ABORT;
 198     }
 199 /*
 200     NSK_DISPLAY3("stackReferenceCallbackForSecondObjectsIteration: *tag_ptr %6d , tag %6d , objectCount %6d\n",
 201                      (long)*tag_ptr, (long)tag, objectCount);
 202 */
 203     /* Deallocate memory of list element*/
 204     if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)objectDescArr[ind]))) {
 205         nsk_jvmti_setFailStatus();
 206         callbackAborted = 1;
 207         NSK_COMPLAIN0("stackReferenceCallbackForSecondObjectsIteration: Deallocation failed. Iteration aborted.\n");
 208         return JVMTI_ITERATION_ABORT;
 209     }
 210 
 211     numberOfDeallocatedFromCallbacksDescriptors++;
 212     deallocatedFlagsArr[ind] = 1;
 213 
 214     /* unset tag */
 215     *tag_ptr = 0;
 216     objectCount--;
 217 
 218     return JVMTI_ITERATION_CONTINUE;
 219 }
 220 
 221 /** jvmtiObjectReferenceCallback for first iteration. */
 222 jvmtiIterationControl JNICALL
 223 objectReferenceCallbackForFirstObjectsIteration(jvmtiObjectReferenceKind reference_kind,
 224                                                 jlong  class_tag,
 225                                                 jlong  size,
 226                                                 jlong* tag_ptr,
 227                                                 jlong  referrer_tag,
 228                                                 jint   referrer_index,
 229                                                 void*  user_data) {
 230 
 231     if (*tag_ptr != 0) return JVMTI_ITERATION_CONTINUE;
 232 
 233     /* Set tag */
 234     *tag_ptr = (jlong)++objectCount;
 235 
 236     if (!NSK_JVMTI_VERIFY(jvmti->Allocate((sizeof(ObjectDesc)), (unsigned char**)&objectDescBuf))) {
 237         nsk_jvmti_setFailStatus();
 238         callbackAborted = 1;
 239         NSK_COMPLAIN0("objectReferenceCallbackForFirstObjectsIteration: Allocation failed. Iteration aborted.\n");
 240         return JVMTI_ITERATION_ABORT;
 241     }
 242 
 243     (*objectDescList).tag = *tag_ptr;
 244     (*objectDescList).size = size;
 245     (*objectDescList).next = objectDescBuf;
 246 
 247     /* step to next list element */
 248     objectDescList = (*objectDescList).next;
 249 
 250     return JVMTI_ITERATION_CONTINUE;
 251 }
 252 
 253 /** jvmtiObjectReferenceCallback for second iteration. */
 254 jvmtiIterationControl JNICALL
 255 objectReferenceCallbackForSecondObjectsIteration(jvmtiObjectReferenceKind reference_kind,
 256                                                  jlong  class_tag,
 257                                                  jlong  size,
 258                                                  jlong* tag_ptr,
 259                                                  jlong  referrer_tag,
 260                                                  jint   referrer_index,
 261                                                  void*  user_data) {
 262 
 263     long ind = (long)((*tag_ptr) - 1);
 264 
 265     if (*tag_ptr == 0) return JVMTI_ITERATION_CONTINUE;
 266 
 267 /*
 268     ObjectDesc *objectDesc = objectDescArr[ind];
 269     jlong tag = (*objectDesc).tag;
 270 */
 271     if (ind < 0 || ind > objectCountMax) {
 272         NSK_COMPLAIN1("objectReferenceCallbackForSecondObjectsIteration: invalid object tag value: %d\n", (long)*tag_ptr);
 273         nsk_jvmti_setFailStatus();
 274         callbackAborted = 1;
 275         return JVMTI_ITERATION_ABORT;
 276     }
 277 /*
 278     NSK_DISPLAY3("objectReferenceCallbackForSecondObjectsIteration: *tag_ptr %6d , tag %6d , objectCount %6d\n",
 279                      (long)*tag_ptr, (long)tag, objectCount);
 280 */
 281     /* Deallocate memory of list element*/
 282     if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)objectDescArr[ind]))) {
 283         nsk_jvmti_setFailStatus();
 284         callbackAborted = 1;
 285         NSK_COMPLAIN0("objectReferenceCallbackForSecondObjectsIteration: Deallocation failed. Iteration aborted.\n");
 286         return JVMTI_ITERATION_ABORT;
 287     }
 288 
 289     numberOfDeallocatedFromCallbacksDescriptors++;
 290     deallocatedFlagsArr[ind] = 1;
 291 


< prev index next >