test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP04/ap04t001/ap04t001.cpp
changeset 52221 27ba7cc31f9f
parent 52049 a986ec4ff214
equal deleted inserted replaced
52220:9c260a6b6471 52221:27ba7cc31f9f
   107 }
   107 }
   108 
   108 
   109 /***********************************************************************/
   109 /***********************************************************************/
   110 
   110 
   111 jvmtiIterationControl JNICALL
   111 jvmtiIterationControl JNICALL
   112 heapObjectCallback( jlong  class_tag,
   112 heapObjectCallback(jlong  class_tag,
   113                     jlong  size,
   113                    jlong  size,
   114                     jlong* tag_ptr,
   114                    jlong* tag_ptr,
   115                     void*  user_data) {
   115                    void*  user_data) {
   116 
   116 
   117     int count = 0;
   117     int count = 0;
   118 
   118 
   119     /* clean eventCount on first iteration */
   119     /* clean eventCount on first iteration */
   120     if (getCounter(&iterationCount) == 0) {
   120     if (getCounter(&iterationCount) == 0) {
   131     return JVMTI_ITERATION_CONTINUE;
   131     return JVMTI_ITERATION_CONTINUE;
   132 }
   132 }
   133 
   133 
   134 /* jvmtiHeapRootCallback */
   134 /* jvmtiHeapRootCallback */
   135 jvmtiIterationControl JNICALL
   135 jvmtiIterationControl JNICALL
   136 heapRootCallback( jvmtiHeapRootKind root_kind,
   136 heapRootCallback(jvmtiHeapRootKind root_kind,
   137                   jlong class_tag,
   137                  jlong class_tag,
   138                   jlong size,
   138                  jlong size,
   139                   jlong* tag_ptr,
   139                  jlong* tag_ptr,
   140                   void* user_data) {
   140                  void* user_data) {
   141 
   141 
   142     int count = 0;
   142     int count = 0;
   143 
   143 
   144     /* clean eventCount on first iteration */
   144     /* clean eventCount on first iteration */
   145     if (getCounter(&iterationCount) == 0) {
   145     if (getCounter(&iterationCount) == 0) {
   156     return JVMTI_ITERATION_CONTINUE;
   156     return JVMTI_ITERATION_CONTINUE;
   157 }
   157 }
   158 
   158 
   159 /* jvmtiStackReferenceCallback */
   159 /* jvmtiStackReferenceCallback */
   160 jvmtiIterationControl JNICALL
   160 jvmtiIterationControl JNICALL
   161 stackReferenceCallback( jvmtiHeapRootKind root_kind,
   161 stackReferenceCallback(jvmtiHeapRootKind root_kind,
   162                         jlong     class_tag,
   162                        jlong     class_tag,
   163                         jlong     size,
   163                        jlong     size,
   164                         jlong*    tag_ptr,
   164                        jlong*    tag_ptr,
   165                         jlong     thread_tag,
   165                        jlong     thread_tag,
   166                         jint      depth,
   166                        jint      depth,
   167                         jmethodID method,
   167                        jmethodID method,
   168                         jint      slot,
   168                        jint      slot,
   169                         void*     user_data) {
   169                        void*     user_data) {
   170 
   170 
   171     int count = 0;
   171     int count = 0;
   172 
   172 
   173     /* clean eventCount on first iteration */
   173     /* clean eventCount on first iteration */
   174     if (getCounter(&iterationCount) == 0) {
   174     if (getCounter(&iterationCount) == 0) {
   186 }
   186 }
   187 
   187 
   188 
   188 
   189 /* jvmtiObjectReferenceCallback */
   189 /* jvmtiObjectReferenceCallback */
   190 jvmtiIterationControl JNICALL
   190 jvmtiIterationControl JNICALL
   191 objectReferenceCallback( jvmtiObjectReferenceKind reference_kind,
   191 objectReferenceCallback(jvmtiObjectReferenceKind reference_kind,
   192                          jlong  class_tag,
   192                         jlong  class_tag,
   193                          jlong  size,
   193                         jlong  size,
   194                          jlong* tag_ptr,
   194                         jlong* tag_ptr,
   195                          jlong  referrer_tag,
   195                         jlong  referrer_tag,
   196                          jint   referrer_index,
   196                         jint   referrer_index,
   197                          void*  user_data) {
   197                         void*  user_data) {
   198 
   198 
   199     int count = 0;
   199     int count = 0;
   200 
   200 
   201     /* clean eventCount on first iteration */
   201     /* clean eventCount on first iteration */
   202     if (getCounter(&iterationCount) == 0) {
   202     if (getCounter(&iterationCount) == 0) {
   235 }
   235 }
   236 
   236 
   237 /***********************************************************************/
   237 /***********************************************************************/
   238 
   238 
   239 JNIEXPORT void JNICALL
   239 JNIEXPORT void JNICALL
   240 Java_nsk_jvmti_scenarios_allocation_AP04_ap04t001_setTag( JNIEnv* jni,
   240 Java_nsk_jvmti_scenarios_allocation_AP04_ap04t001_setTag(JNIEnv* jni,
   241                                                           jclass  klass,
   241                                                          jclass  klass,
   242                                                           jobject target, /* object to be tagged */
   242                                                          jobject target, /* object to be tagged */
   243                                                           jlong   tag ) {
   243                                                          jlong   tag) {
   244 
   244 
   245     if (!NSK_JVMTI_VERIFY(jvmti->SetTag(target, tag))) {
   245     if (!NSK_JVMTI_VERIFY(jvmti->SetTag(target, tag))) {
   246         nsk_jvmti_setFailStatus();
   246         nsk_jvmti_setFailStatus();
   247     }
   247     }
   248 }
   248 }
   249 
   249 
   250 JNIEXPORT void JNICALL
   250 JNIEXPORT void JNICALL
   251 Java_nsk_jvmti_scenarios_allocation_AP04_ap04t001_forceGC( JNIEnv* jni,
   251 Java_nsk_jvmti_scenarios_allocation_AP04_ap04t001_forceGC(JNIEnv* jni,
   252                                                           jclass  klass) {
   252                                                           jclass  klass) {
   253 
   253 
   254 NSK_DISPLAY0("  run: ForceGarbageCollection\n");
   254 NSK_DISPLAY0("  run: ForceGarbageCollection\n");
   255     if (!NSK_JVMTI_VERIFY(jvmti->ForceGarbageCollection())) {
   255     if (!NSK_JVMTI_VERIFY(jvmti->ForceGarbageCollection())) {
   256         nsk_jvmti_setFailStatus();
   256         nsk_jvmti_setFailStatus();
   257     }
   257     }
   258 }
   258 }
   259 
   259 
   260 JNIEXPORT void JNICALL
   260 JNIEXPORT void JNICALL
   261 Java_nsk_jvmti_scenarios_allocation_AP04_ap04t001_runIterateOverHeap( JNIEnv* jni,
   261 Java_nsk_jvmti_scenarios_allocation_AP04_ap04t001_runIterateOverHeap(JNIEnv* jni,
   262                                                                       jclass  klass ) {
   262                                                                      jclass  klass) {
   263     int count = 0;
   263     int count = 0;
   264 
   264 
   265     setCounter(&errorCount, 0);
   265     setCounter(&errorCount, 0);
   266     setCounter(&eventCount, 0);
   266     setCounter(&eventCount, 0);
   267     setCounter(&iterationCount, 0);
   267     setCounter(&iterationCount, 0);
   284         nsk_jvmti_setFailStatus();
   284         nsk_jvmti_setFailStatus();
   285     }
   285     }
   286 }
   286 }
   287 
   287 
   288 JNIEXPORT void JNICALL
   288 JNIEXPORT void JNICALL
   289 Java_nsk_jvmti_scenarios_allocation_AP04_ap04t001_runIterateOverReachableObjects( JNIEnv* jni,
   289 Java_nsk_jvmti_scenarios_allocation_AP04_ap04t001_runIterateOverReachableObjects(JNIEnv* jni,
   290                                                                                   jclass  klass ) {
   290                                                                                  jclass  klass) {
   291     int count = 0;
   291     int count = 0;
   292 
   292 
   293     setCounter(&errorCount, 0);
   293     setCounter(&errorCount, 0);
   294     setCounter(&eventCount, 0);
   294     setCounter(&eventCount, 0);
   295     setCounter(&iterationCount, 0);
   295     setCounter(&iterationCount, 0);
   313         nsk_jvmti_setFailStatus();
   313         nsk_jvmti_setFailStatus();
   314     }
   314     }
   315 }
   315 }
   316 
   316 
   317 JNIEXPORT void JNICALL
   317 JNIEXPORT void JNICALL
   318 Java_nsk_jvmti_scenarios_allocation_AP04_ap04t001_runIterateOverInstancesOfClass( JNIEnv* jni,
   318 Java_nsk_jvmti_scenarios_allocation_AP04_ap04t001_runIterateOverInstancesOfClass(JNIEnv* jni,
   319                                                                                   jclass  klass ) {
   319                                                                                  jclass  klass) {
   320     int count = 0;
   320     int count = 0;
   321 
   321 
   322     setCounter(&errorCount, 0);
   322     setCounter(&errorCount, 0);
   323     setCounter(&eventCount, 0);
   323     setCounter(&eventCount, 0);
   324     setCounter(&iterationCount, 0);
   324     setCounter(&iterationCount, 0);
   342         nsk_jvmti_setFailStatus();
   342         nsk_jvmti_setFailStatus();
   343     }
   343     }
   344 }
   344 }
   345 
   345 
   346 JNIEXPORT void JNICALL
   346 JNIEXPORT void JNICALL
   347 Java_nsk_jvmti_scenarios_allocation_AP04_ap04t001_runIterateOverObjectsReachableFromObject( JNIEnv* jni,
   347 Java_nsk_jvmti_scenarios_allocation_AP04_ap04t001_runIterateOverObjectsReachableFromObject(JNIEnv* jni,
   348                                                                                             jclass  klass ) {
   348                                                                                            jclass  klass) {
   349 
   349 
   350     jobject root = NULL;
   350     jobject root = NULL;
   351     int count = 0;
   351     int count = 0;
   352 
   352 
   353     if (!NSK_JNI_VERIFY(jni, (root =
   353     if (!NSK_JNI_VERIFY(jni, (root =
   354             jni->GetStaticObjectField(debugeeClass, rootFieldID)) != NULL )) {
   354             jni->GetStaticObjectField(debugeeClass, rootFieldID)) != NULL)) {
   355         NSK_COMPLAIN0("GetStaticObjectField returned NULL for 'root' field value\n\n");
   355         NSK_COMPLAIN0("GetStaticObjectField returned NULL for 'root' field value\n\n");
   356         nsk_jvmti_setFailStatus();
   356         nsk_jvmti_setFailStatus();
   357         return;
   357         return;
   358     }
   358     }
   359 
   359 
   400     if (!NSK_JNI_VERIFY(jni, (debugeeClass = (jclass)jni->NewGlobalRef(debugeeClass)) != NULL))
   400     if (!NSK_JNI_VERIFY(jni, (debugeeClass = (jclass)jni->NewGlobalRef(debugeeClass)) != NULL))
   401         return;
   401         return;
   402 
   402 
   403     NSK_DISPLAY1("Find ID of 'root' field: %s\n", ROOT_SIGNATURE);
   403     NSK_DISPLAY1("Find ID of 'root' field: %s\n", ROOT_SIGNATURE);
   404     if (!NSK_JNI_VERIFY(jni, (rootFieldID =
   404     if (!NSK_JNI_VERIFY(jni, (rootFieldID =
   405             jni->GetStaticFieldID(debugeeClass, "root", ROOT_SIGNATURE)) != NULL )) {
   405             jni->GetStaticFieldID(debugeeClass, "root", ROOT_SIGNATURE)) != NULL)) {
   406         nsk_jvmti_setFailStatus();
   406         nsk_jvmti_setFailStatus();
   407         return;
   407         return;
   408     }
   408     }
   409 
   409 
   410     NSK_DISPLAY1("Find ID of 'unlockSecondary' method: %s\n", ROOT_SIGNATURE);
   410     NSK_DISPLAY1("Find ID of 'unlockSecondary' method: %s\n", ROOT_SIGNATURE);
   411     if (!NSK_JNI_VERIFY(jni, (unlockSecondaryID =
   411     if (!NSK_JNI_VERIFY(jni, (unlockSecondaryID =
   412             jni->GetStaticMethodID(debugeeClass, "unlockSecondary", "()V")) != NULL )) {
   412             jni->GetStaticMethodID(debugeeClass, "unlockSecondary", "()V")) != NULL)) {
   413         nsk_jvmti_setFailStatus();
   413         nsk_jvmti_setFailStatus();
   414         return;
   414         return;
   415     }
   415     }
   416 
   416 
   417 
   417