// that can atomically update only N bits at a time.
// Author: Hans-J. Boehm (Hans_Boehm@hp.com, boehm@acm.org)
-#include <assert.h>
#include <limits.h>
#include <unistd.h> // for usleep, sysconf.
#include <gcj/javaprims.h>
release_set(&(he -> address), he_address);
return;
}
- assert(hl -> address == addr);
+ JvAssert(hl -> address == addr);
GC_finalization_proc old_finalization_proc = hl -> old_finalization_proc;
if (old_finalization_proc != 0)
{
static void
remove_all_heavy (hash_entry *he, obj_addr_t new_address_val)
{
- assert(he -> heavy_count == 0);
- assert(he -> address & LOCKED);
+ JvAssert(he -> heavy_count == 0);
+ JvAssert(he -> address & LOCKED);
heavy_lock *hl = he -> heavy_locks;
he -> heavy_locks = 0;
// We would really like to release the lock bit here. Unfortunately, that
for(; 0 != hl; hl = hl->next)
{
obj_addr_t obj = hl -> address;
- assert(0 != obj); // If this was previously finalized, it should no
- // longer appear on our list.
+ JvAssert(0 != obj); // If this was previously finalized, it should no
+ // longer appear on our list.
hl -> address = 0; // Finalization proc might still see it after we
// finish.
GC_finalization_proc old_finalization_proc = hl -> old_finalization_proc;
if (__builtin_expect(!addr, false))
throw new java::lang::NullPointerException;
- assert(!(addr & FLAGS));
+ JvAssert(!(addr & FLAGS));
retry:
if (__builtin_expect(compare_and_swap(&(he -> address),
0, addr),true))
{
- assert(he -> light_thr_id == INVALID_THREAD_ID);
- assert(he -> light_count == 0);
+ JvAssert(he -> light_thr_id == INVALID_THREAD_ID);
+ JvAssert(he -> light_count == 0);
he -> light_thr_id = self;
// Count fields are set correctly. Heavy_count was also zero,
// but can change asynchronously.
// only be held by other threads waiting for conversion, and
// they, like us, drop it quickly without blocking.
_Jv_MutexLock(&(hl->si.mutex));
- assert(he -> address == address | LOCKED );
+ JvAssert(he -> address == address | LOCKED );
release_set(&(he -> address), (address | REQUEST_CONVERSION | HEAVY));
// release lock on he
while ((he -> address & ~FLAGS) == (address & ~FLAGS))
// Guarantee that hl doesn't get unlinked by finalizer.
// This is only an issue if the client fails to release
// the lock, which is unlikely.
- assert(he -> address & HEAVY);
+ JvAssert(he -> address & HEAVY);
// Lock has been converted, we hold the heavyweight lock,
// heavy_count has been incremented.
return;
{
// Either was_heavy is true, or something changed out from under us,
// since the initial test for 0 failed.
- assert(!(address & REQUEST_CONVERSION));
+ JvAssert(!(address & REQUEST_CONVERSION));
// Can't convert a nonexistent lightweight lock.
heavy_lock *hl;
hl = (was_heavy? find_heavy(addr, he) : 0);
// one first and use that.
he -> light_thr_id = self; // OK, since nobody else can hold
// light lock or do this at the same time.
- assert(he -> light_count == 0);
- assert(was_heavy == (he -> address & HEAVY));
+ JvAssert(he -> light_count == 0);
+ JvAssert(was_heavy == (he -> address & HEAVY));
release_set(&(he -> address), (addr | was_heavy));
}
else
{
// Must use heavy lock.
++ (he -> heavy_count);
- assert(0 == (address & ~HEAVY));
+ JvAssert(0 == (address & ~HEAVY));
release_set(&(he -> address), HEAVY);
_Jv_MutexLock(&(hl->si.mutex));
keep_live(addr);
// We hold the lock on the hash entry, and he -> address can't
// change from under us. Neither can the chain of heavy locks.
{
- assert(0 == he -> heavy_count || (address & HEAVY));
+ JvAssert(0 == he -> heavy_count || (address & HEAVY));
heavy_lock *hl = get_heavy(addr, he);
++ (he -> heavy_count);
release_set(&(he -> address), address | HEAVY);
he -> light_count = count - 1;
return;
}
- assert(he -> light_thr_id == self);
- assert(address & REQUEST_CONVERSION);
+ JvAssert(he -> light_thr_id == self);
+ JvAssert(address & REQUEST_CONVERSION);
// Conversion requested
// Convert now.
if (!compare_and_swap(&(he -> address), address, address | LOCKED))
goto retry;
heavy_lock *hl = find_heavy(addr, he);
- assert (0 != hl);
+ JvAssert (0 != hl);
// Requestor created it.
he -> light_count = 0;
- assert(he -> heavy_count > 0);
+ JvAssert(he -> heavy_count > 0);
// was incremented by requestor.
_Jv_MutexLock(&(hl->si.mutex));
// Release the he lock after acquiring the mutex.
return;
}
// lightweight lock not for this object.
- assert(!(address & LOCKED));
- assert((address & ~FLAGS) != addr);
+ JvAssert(!(address & LOCKED));
+ JvAssert((address & ~FLAGS) != addr);
if (!compare_and_swap(&(he -> address), address, address | LOCKED))
goto retry;
heavy_lock *hl = find_heavy(addr, he);
throw new java::lang::IllegalMonitorStateException(
JvNewStringLatin1("current thread not owner"));
}
- assert(address & HEAVY);
+ JvAssert(address & HEAVY);
count = he -> heavy_count;
- assert(count > 0);
+ JvAssert(count > 0);
--count;
he -> heavy_count = count;
if (0 == count)
throw new IllegalMonitorStateException (JvNewStringLatin1
("current thread not owner"));
}
- assert(address & HEAVY);
+ JvAssert(address & HEAVY);
}
switch (_Jv_CondWait (&(hl->si.condition), &(hl->si.mutex), timeout, nanos))
{