< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t006/ma10t006.cpp

Print this page
rev 52100 : 8212082: Remove the NSK_CPP_STUB macros for remaining vmTestbase/jvmti/[sS]*
Summary:
Reviewed-by:


  37 /* scaffold objects */
  38 static jlong timeout = 0;
  39 
  40 /* event counts */
  41 static int CompiledMethodLoadEventsCount = 0;
  42 static int CompiledMethodUnloadEventsCount = 0;
  43 
  44 /* ========================================================================== */
  45 
  46 /** callback functions **/
  47 
  48 static void JNICALL
  49 CompiledMethodLoad(jvmtiEnv *jvmti_env, jmethodID method,
  50         jint code_size, const void* code_addr, jint map_length,
  51         const jvmtiAddrLocationMap* map, const void* compile_info) {
  52     char *name = NULL;
  53     char *signature = NULL;
  54 
  55     CompiledMethodLoadEventsCount++;
  56 
  57     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetMethodName,
  58             jvmti_env, method, &name, &signature, NULL))) {
  59         nsk_jvmti_setFailStatus();
  60         return;
  61     }
  62     NSK_DISPLAY3("CompiledMethodLoad event: %s%s (0x%p)\n",
  63         name, signature, code_addr);
  64     if (name != NULL)
  65         NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)name);
  66     if (signature != NULL)
  67         NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)signature);
  68 }
  69 
  70 static void JNICALL
  71 CompiledMethodUnload(jvmtiEnv *jvmti_env, jmethodID method,
  72         const void* code_addr) {
  73     char *name = NULL;
  74     char *sig = NULL;
  75     jvmtiError err;
  76     CompiledMethodUnloadEventsCount++;
  77 
  78     NSK_DISPLAY0("CompiledMethodUnload event received\n");
  79     // Check for the case that the class has been unloaded
  80     err = jvmti_env->GetMethodName(method, &name, &sig, NULL);
  81     if (err == JVMTI_ERROR_NONE) {
  82         NSK_DISPLAY3("for: \tmethod: name=\"%s\" signature=\"%s\"\n\tnative address=0x%p\n",
  83           name, sig, code_addr);
  84         NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)name);
  85         NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)sig);
  86     }
  87 }
  88 
  89 /* ========================================================================== */
  90 
  91 /** Agent algorithm. */
  92 static void JNICALL
  93 agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
  94 
  95     if (!nsk_jvmti_waitForSync(timeout))
  96         return;
  97 
  98     NSK_DISPLAY1("CompiledMethodLoad events received: %d\n",
  99         CompiledMethodLoadEventsCount);
 100     if (CompiledMethodLoadEventsCount == 0) {
 101         NSK_DISPLAY0("# WARNING: no CompiledMethodLoad events\n");
 102         NSK_DISPLAY0("#    (VM might not compile any methods at all)\n");
 103     }
 104 
 105     NSK_DISPLAY1("CompiledMethodUnload events received: %d\n",


 131     jvmtiEnv* jvmti = NULL;
 132     jvmtiCapabilities caps;
 133     jvmtiEventCallbacks callbacks;
 134 
 135     NSK_DISPLAY0("Agent_OnLoad\n");
 136 
 137     if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
 138         return JNI_ERR;
 139 
 140     timeout = nsk_jvmti_getWaitTime() * 60 * 1000;
 141 
 142     if (!NSK_VERIFY((jvmti =
 143             nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
 144         return JNI_ERR;
 145 
 146     if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
 147         return JNI_ERR;
 148 
 149     memset(&caps, 0, sizeof(caps));
 150     caps.can_generate_compiled_method_load_events = 1;
 151     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) {
 152         return JNI_ERR;
 153     }
 154 
 155     memset(&callbacks, 0, sizeof(callbacks));
 156     callbacks.CompiledMethodLoad = &CompiledMethodLoad;
 157     callbacks.CompiledMethodUnload = &CompiledMethodUnload;
 158     if (!NSK_VERIFY(nsk_jvmti_init_MA(&callbacks)))
 159         return JNI_ERR;
 160 
 161     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
 162             jvmti, JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, NULL)))
 163         return JNI_ERR;
 164     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
 165             jvmti, JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_UNLOAD, NULL)))
 166         return JNI_ERR;
 167 
 168     return JNI_OK;
 169 }
 170 
 171 /* ========================================================================== */
 172 
 173 }


  37 /* scaffold objects */
  38 static jlong timeout = 0;
  39 
  40 /* event counts */
  41 static int CompiledMethodLoadEventsCount = 0;
  42 static int CompiledMethodUnloadEventsCount = 0;
  43 
  44 /* ========================================================================== */
  45 
  46 /** callback functions **/
  47 
  48 static void JNICALL
  49 CompiledMethodLoad(jvmtiEnv *jvmti_env, jmethodID method,
  50         jint code_size, const void* code_addr, jint map_length,
  51         const jvmtiAddrLocationMap* map, const void* compile_info) {
  52     char *name = NULL;
  53     char *signature = NULL;
  54 
  55     CompiledMethodLoadEventsCount++;
  56 
  57     if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &signature, NULL))) {

  58         nsk_jvmti_setFailStatus();
  59         return;
  60     }
  61     NSK_DISPLAY3("CompiledMethodLoad event: %s%s (0x%p)\n",
  62         name, signature, code_addr);
  63     if (name != NULL)
  64         jvmti_env->Deallocate((unsigned char*)name);
  65     if (signature != NULL)
  66         jvmti_env->Deallocate((unsigned char*)signature);
  67 }
  68 
  69 static void JNICALL
  70 CompiledMethodUnload(jvmtiEnv *jvmti_env, jmethodID method,
  71         const void* code_addr) {
  72     char *name = NULL;
  73     char *sig = NULL;
  74     jvmtiError err;
  75     CompiledMethodUnloadEventsCount++;
  76 
  77     NSK_DISPLAY0("CompiledMethodUnload event received\n");
  78     // Check for the case that the class has been unloaded
  79     err = jvmti_env->GetMethodName(method, &name, &sig, NULL);
  80     if (err == JVMTI_ERROR_NONE) {
  81         NSK_DISPLAY3("for: \tmethod: name=\"%s\" signature=\"%s\"\n\tnative address=0x%p\n",
  82           name, sig, code_addr);
  83         jvmti_env->Deallocate((unsigned char*)name);
  84         jvmti_env->Deallocate((unsigned char*)sig);
  85     }
  86 }
  87 
  88 /* ========================================================================== */
  89 
  90 /** Agent algorithm. */
  91 static void JNICALL
  92 agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
  93 
  94     if (!nsk_jvmti_waitForSync(timeout))
  95         return;
  96 
  97     NSK_DISPLAY1("CompiledMethodLoad events received: %d\n",
  98         CompiledMethodLoadEventsCount);
  99     if (CompiledMethodLoadEventsCount == 0) {
 100         NSK_DISPLAY0("# WARNING: no CompiledMethodLoad events\n");
 101         NSK_DISPLAY0("#    (VM might not compile any methods at all)\n");
 102     }
 103 
 104     NSK_DISPLAY1("CompiledMethodUnload events received: %d\n",


 130     jvmtiEnv* jvmti = NULL;
 131     jvmtiCapabilities caps;
 132     jvmtiEventCallbacks callbacks;
 133 
 134     NSK_DISPLAY0("Agent_OnLoad\n");
 135 
 136     if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
 137         return JNI_ERR;
 138 
 139     timeout = nsk_jvmti_getWaitTime() * 60 * 1000;
 140 
 141     if (!NSK_VERIFY((jvmti =
 142             nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
 143         return JNI_ERR;
 144 
 145     if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
 146         return JNI_ERR;
 147 
 148     memset(&caps, 0, sizeof(caps));
 149     caps.can_generate_compiled_method_load_events = 1;
 150     if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
 151         return JNI_ERR;
 152     }
 153 
 154     memset(&callbacks, 0, sizeof(callbacks));
 155     callbacks.CompiledMethodLoad = &CompiledMethodLoad;
 156     callbacks.CompiledMethodUnload = &CompiledMethodUnload;
 157     if (!NSK_VERIFY(nsk_jvmti_init_MA(&callbacks)))
 158         return JNI_ERR;
 159 
 160     if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_LOAD, NULL)))

 161         return JNI_ERR;
 162     if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_COMPILED_METHOD_UNLOAD, NULL)))

 163         return JNI_ERR;
 164 
 165     return JNI_OK;
 166 }
 167 
 168 /* ========================================================================== */
 169 
 170 }
< prev index next >