src/hotspot/share/jvmci/jvmciCompilerToVM.cpp
changeset 59252 623722a6aeb9
parent 59056 15936b142f86
child 59290 97d13893ec3c
equal deleted inserted replaced
59251:4cbfa5077d68 59252:623722a6aeb9
  1584       extern struct JavaVM_ main_vm;
  1584       extern struct JavaVM_ main_vm;
  1585       JNIEnv* hotspotEnv;
  1585       JNIEnv* hotspotEnv;
  1586       jint res = main_vm.AttachCurrentThread((void**)&hotspotEnv, NULL);
  1586       jint res = main_vm.AttachCurrentThread((void**)&hotspotEnv, NULL);
  1587       _attached = res == JNI_OK;
  1587       _attached = res == JNI_OK;
  1588       static volatile int report_attach_error = 0;
  1588       static volatile int report_attach_error = 0;
  1589       if (res != JNI_OK && report_attach_error == 0 && Atomic::cmpxchg(1, &report_attach_error, 0) == 0) {
  1589       if (res != JNI_OK && report_attach_error == 0 && Atomic::cmpxchg(&report_attach_error, 0, 1) == 0) {
  1590         // Only report an attach error once
  1590         // Only report an attach error once
  1591         jio_printf("Warning: attaching current thread to VM failed with %d (future attach errors are suppressed)\n", res);
  1591         jio_printf("Warning: attaching current thread to VM failed with %d (future attach errors are suppressed)\n", res);
  1592       }
  1592       }
  1593     } else {
  1593     } else {
  1594       _attached = false;
  1594       _attached = false;
  1597   ~AttachDetach() {
  1597   ~AttachDetach() {
  1598     if (_attached && get_current_thread() != NULL) {
  1598     if (_attached && get_current_thread() != NULL) {
  1599       extern struct JavaVM_ main_vm;
  1599       extern struct JavaVM_ main_vm;
  1600       jint res = main_vm.DetachCurrentThread();
  1600       jint res = main_vm.DetachCurrentThread();
  1601       static volatile int report_detach_error = 0;
  1601       static volatile int report_detach_error = 0;
  1602       if (res != JNI_OK && report_detach_error == 0 && Atomic::cmpxchg(1, &report_detach_error, 0) == 0) {
  1602       if (res != JNI_OK && report_detach_error == 0 && Atomic::cmpxchg(&report_detach_error, 0, 1) == 0) {
  1603         // Only report an attach error once
  1603         // Only report an attach error once
  1604         jio_printf("Warning: detaching current thread from VM failed with %d (future attach errors are suppressed)\n", res);
  1604         jio_printf("Warning: detaching current thread from VM failed with %d (future attach errors are suppressed)\n", res);
  1605       }
  1605       }
  1606     }
  1606     }
  1607   }
  1607   }