< prev index next >

src/hotspot/share/prims/jni.cpp

Print this page

        

*** 3809,3821 **** // but __sync_lock_test_and_set is not guaranteed to do what we want // on all architectures. So we check it works before relying on it. #if defined(ZERO) && defined(ASSERT) { jint a = 0xcafebabe; ! jint b = Atomic::xchg((jint) 0xdeadbeef, &a); void *c = &a; ! void *d = Atomic::xchg(&b, &c); assert(a == (jint) 0xdeadbeef && b == (jint) 0xcafebabe, "Atomic::xchg() works"); assert(c == &b && d == &a, "Atomic::xchg() works"); } #endif // ZERO && ASSERT --- 3809,3821 ---- // but __sync_lock_test_and_set is not guaranteed to do what we want // on all architectures. So we check it works before relying on it. #if defined(ZERO) && defined(ASSERT) { jint a = 0xcafebabe; ! jint b = Atomic::xchg(&a, (jint) 0xdeadbeef); void *c = &a; ! void *d = Atomic::xchg(&c, &b); assert(a == (jint) 0xdeadbeef && b == (jint) 0xcafebabe, "Atomic::xchg() works"); assert(c == &b && d == &a, "Atomic::xchg() works"); } #endif // ZERO && ASSERT
*** 3827,3840 **** // one thread can call this method at a time // We use Atomic::xchg rather than Atomic::add/dec since on some platforms // the add/dec implementations are dependent on whether we are running // on a multiprocessor Atomic::xchg does not have this problem. ! if (Atomic::xchg(1, &vm_created) == 1) { return JNI_EEXIST; // already created, or create attempt in progress } ! if (Atomic::xchg(0, &safe_to_recreate_vm) == 0) { return JNI_ERR; // someone tried and failed and retry not allowed. } assert(vm_created == 1, "vm_created is true during the creation"); --- 3827,3840 ---- // one thread can call this method at a time // We use Atomic::xchg rather than Atomic::add/dec since on some platforms // the add/dec implementations are dependent on whether we are running // on a multiprocessor Atomic::xchg does not have this problem. ! if (Atomic::xchg(&vm_created, 1) == 1) { return JNI_EEXIST; // already created, or create attempt in progress } ! if (Atomic::xchg(&safe_to_recreate_vm, 0) == 0) { return JNI_ERR; // someone tried and failed and retry not allowed. } assert(vm_created == 1, "vm_created is true during the creation");
< prev index next >