Commit 5168f1cf by Tom Tromey Committed by Tom Tromey

natObject.cc: Don't include assert.h.

	* java/lang/natObject.cc: Don't include assert.h.
	(heavy_lock_obj_finalization_proc): Use JvAssert.
	(remove_all_heavy): Likewise.
	(_Jv_MonitorEnter): Likewise.
	(_Jv_MonitorExit): Likewise.
	(wait): Likewise.

From-SVN: r63636
parent 5bedfc93
2003-03-01 Tom Tromey <tromey@redhat.com>
* java/lang/natObject.cc: Don't include assert.h.
(heavy_lock_obj_finalization_proc): Use JvAssert.
(remove_all_heavy): Likewise.
(_Jv_MonitorEnter): Likewise.
(_Jv_MonitorExit): Likewise.
(wait): Likewise.
2003-03-01 Ranjit Mathew <rmathew@hotmail.com> 2003-03-01 Ranjit Mathew <rmathew@hotmail.com>
* java/io/File (getAbsolutePath): Prefix drive specifier on * java/io/File (getAbsolutePath): Prefix drive specifier on
......
...@@ -303,7 +303,6 @@ _Jv_MonitorExit (jobject obj) ...@@ -303,7 +303,6 @@ _Jv_MonitorExit (jobject obj)
// that can atomically update only N bits at a time. // that can atomically update only N bits at a time.
// Author: Hans-J. Boehm (Hans_Boehm@hp.com, boehm@acm.org) // Author: Hans-J. Boehm (Hans_Boehm@hp.com, boehm@acm.org)
#include <assert.h>
#include <limits.h> #include <limits.h>
#include <unistd.h> // for usleep, sysconf. #include <unistd.h> // for usleep, sysconf.
#include <gcj/javaprims.h> #include <gcj/javaprims.h>
...@@ -605,7 +604,7 @@ heavy_lock_obj_finalization_proc (void *obj, void *cd) ...@@ -605,7 +604,7 @@ heavy_lock_obj_finalization_proc (void *obj, void *cd)
release_set(&(he -> address), he_address); release_set(&(he -> address), he_address);
return; return;
} }
assert(hl -> address == addr); JvAssert(hl -> address == addr);
GC_finalization_proc old_finalization_proc = hl -> old_finalization_proc; GC_finalization_proc old_finalization_proc = hl -> old_finalization_proc;
if (old_finalization_proc != 0) if (old_finalization_proc != 0)
{ {
...@@ -653,8 +652,8 @@ heavy_lock_obj_finalization_proc (void *obj, void *cd) ...@@ -653,8 +652,8 @@ heavy_lock_obj_finalization_proc (void *obj, void *cd)
static void static void
remove_all_heavy (hash_entry *he, obj_addr_t new_address_val) remove_all_heavy (hash_entry *he, obj_addr_t new_address_val)
{ {
assert(he -> heavy_count == 0); JvAssert(he -> heavy_count == 0);
assert(he -> address & LOCKED); JvAssert(he -> address & LOCKED);
heavy_lock *hl = he -> heavy_locks; heavy_lock *hl = he -> heavy_locks;
he -> heavy_locks = 0; he -> heavy_locks = 0;
// We would really like to release the lock bit here. Unfortunately, that // We would really like to release the lock bit here. Unfortunately, that
...@@ -664,8 +663,8 @@ remove_all_heavy (hash_entry *he, obj_addr_t new_address_val) ...@@ -664,8 +663,8 @@ remove_all_heavy (hash_entry *he, obj_addr_t new_address_val)
for(; 0 != hl; hl = hl->next) for(; 0 != hl; hl = hl->next)
{ {
obj_addr_t obj = hl -> address; obj_addr_t obj = hl -> address;
assert(0 != obj); // If this was previously finalized, it should no JvAssert(0 != obj); // If this was previously finalized, it should no
// longer appear on our list. // longer appear on our list.
hl -> address = 0; // Finalization proc might still see it after we hl -> address = 0; // Finalization proc might still see it after we
// finish. // finish.
GC_finalization_proc old_finalization_proc = hl -> old_finalization_proc; GC_finalization_proc old_finalization_proc = hl -> old_finalization_proc;
...@@ -782,13 +781,13 @@ _Jv_MonitorEnter (jobject obj) ...@@ -782,13 +781,13 @@ _Jv_MonitorEnter (jobject obj)
if (__builtin_expect(!addr, false)) if (__builtin_expect(!addr, false))
throw new java::lang::NullPointerException; throw new java::lang::NullPointerException;
assert(!(addr & FLAGS)); JvAssert(!(addr & FLAGS));
retry: retry:
if (__builtin_expect(compare_and_swap(&(he -> address), if (__builtin_expect(compare_and_swap(&(he -> address),
0, addr),true)) 0, addr),true))
{ {
assert(he -> light_thr_id == INVALID_THREAD_ID); JvAssert(he -> light_thr_id == INVALID_THREAD_ID);
assert(he -> light_count == 0); JvAssert(he -> light_count == 0);
he -> light_thr_id = self; he -> light_thr_id = self;
// Count fields are set correctly. Heavy_count was also zero, // Count fields are set correctly. Heavy_count was also zero,
// but can change asynchronously. // but can change asynchronously.
...@@ -836,7 +835,7 @@ retry: ...@@ -836,7 +835,7 @@ retry:
// only be held by other threads waiting for conversion, and // only be held by other threads waiting for conversion, and
// they, like us, drop it quickly without blocking. // they, like us, drop it quickly without blocking.
_Jv_MutexLock(&(hl->si.mutex)); _Jv_MutexLock(&(hl->si.mutex));
assert(he -> address == address | LOCKED ); JvAssert(he -> address == address | LOCKED );
release_set(&(he -> address), (address | REQUEST_CONVERSION | HEAVY)); release_set(&(he -> address), (address | REQUEST_CONVERSION | HEAVY));
// release lock on he // release lock on he
while ((he -> address & ~FLAGS) == (address & ~FLAGS)) while ((he -> address & ~FLAGS) == (address & ~FLAGS))
...@@ -849,7 +848,7 @@ retry: ...@@ -849,7 +848,7 @@ retry:
// Guarantee that hl doesn't get unlinked by finalizer. // Guarantee that hl doesn't get unlinked by finalizer.
// This is only an issue if the client fails to release // This is only an issue if the client fails to release
// the lock, which is unlikely. // the lock, which is unlikely.
assert(he -> address & HEAVY); JvAssert(he -> address & HEAVY);
// Lock has been converted, we hold the heavyweight lock, // Lock has been converted, we hold the heavyweight lock,
// heavy_count has been incremented. // heavy_count has been incremented.
return; return;
...@@ -866,7 +865,7 @@ retry: ...@@ -866,7 +865,7 @@ retry:
{ {
// Either was_heavy is true, or something changed out from under us, // Either was_heavy is true, or something changed out from under us,
// since the initial test for 0 failed. // since the initial test for 0 failed.
assert(!(address & REQUEST_CONVERSION)); JvAssert(!(address & REQUEST_CONVERSION));
// Can't convert a nonexistent lightweight lock. // Can't convert a nonexistent lightweight lock.
heavy_lock *hl; heavy_lock *hl;
hl = (was_heavy? find_heavy(addr, he) : 0); hl = (was_heavy? find_heavy(addr, he) : 0);
...@@ -879,15 +878,15 @@ retry: ...@@ -879,15 +878,15 @@ retry:
// one first and use that. // one first and use that.
he -> light_thr_id = self; // OK, since nobody else can hold he -> light_thr_id = self; // OK, since nobody else can hold
// light lock or do this at the same time. // light lock or do this at the same time.
assert(he -> light_count == 0); JvAssert(he -> light_count == 0);
assert(was_heavy == (he -> address & HEAVY)); JvAssert(was_heavy == (he -> address & HEAVY));
release_set(&(he -> address), (addr | was_heavy)); release_set(&(he -> address), (addr | was_heavy));
} }
else else
{ {
// Must use heavy lock. // Must use heavy lock.
++ (he -> heavy_count); ++ (he -> heavy_count);
assert(0 == (address & ~HEAVY)); JvAssert(0 == (address & ~HEAVY));
release_set(&(he -> address), HEAVY); release_set(&(he -> address), HEAVY);
_Jv_MutexLock(&(hl->si.mutex)); _Jv_MutexLock(&(hl->si.mutex));
keep_live(addr); keep_live(addr);
...@@ -898,7 +897,7 @@ retry: ...@@ -898,7 +897,7 @@ retry:
// We hold the lock on the hash entry, and he -> address can't // We hold the lock on the hash entry, and he -> address can't
// change from under us. Neither can the chain of heavy locks. // 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); heavy_lock *hl = get_heavy(addr, he);
++ (he -> heavy_count); ++ (he -> heavy_count);
release_set(&(he -> address), address | HEAVY); release_set(&(he -> address), address | HEAVY);
...@@ -1006,17 +1005,17 @@ retry: ...@@ -1006,17 +1005,17 @@ retry:
he -> light_count = count - 1; he -> light_count = count - 1;
return; return;
} }
assert(he -> light_thr_id == self); JvAssert(he -> light_thr_id == self);
assert(address & REQUEST_CONVERSION); JvAssert(address & REQUEST_CONVERSION);
// Conversion requested // Conversion requested
// Convert now. // Convert now.
if (!compare_and_swap(&(he -> address), address, address | LOCKED)) if (!compare_and_swap(&(he -> address), address, address | LOCKED))
goto retry; goto retry;
heavy_lock *hl = find_heavy(addr, he); heavy_lock *hl = find_heavy(addr, he);
assert (0 != hl); JvAssert (0 != hl);
// Requestor created it. // Requestor created it.
he -> light_count = 0; he -> light_count = 0;
assert(he -> heavy_count > 0); JvAssert(he -> heavy_count > 0);
// was incremented by requestor. // was incremented by requestor.
_Jv_MutexLock(&(hl->si.mutex)); _Jv_MutexLock(&(hl->si.mutex));
// Release the he lock after acquiring the mutex. // Release the he lock after acquiring the mutex.
...@@ -1033,8 +1032,8 @@ retry: ...@@ -1033,8 +1032,8 @@ retry:
return; return;
} }
// lightweight lock not for this object. // lightweight lock not for this object.
assert(!(address & LOCKED)); JvAssert(!(address & LOCKED));
assert((address & ~FLAGS) != addr); JvAssert((address & ~FLAGS) != addr);
if (!compare_and_swap(&(he -> address), address, address | LOCKED)) if (!compare_and_swap(&(he -> address), address, address | LOCKED))
goto retry; goto retry;
heavy_lock *hl = find_heavy(addr, he); heavy_lock *hl = find_heavy(addr, he);
...@@ -1049,9 +1048,9 @@ retry: ...@@ -1049,9 +1048,9 @@ retry:
throw new java::lang::IllegalMonitorStateException( throw new java::lang::IllegalMonitorStateException(
JvNewStringLatin1("current thread not owner")); JvNewStringLatin1("current thread not owner"));
} }
assert(address & HEAVY); JvAssert(address & HEAVY);
count = he -> heavy_count; count = he -> heavy_count;
assert(count > 0); JvAssert(count > 0);
--count; --count;
he -> heavy_count = count; he -> heavy_count = count;
if (0 == count) if (0 == count)
...@@ -1160,7 +1159,7 @@ retry: ...@@ -1160,7 +1159,7 @@ retry:
throw new IllegalMonitorStateException (JvNewStringLatin1 throw new IllegalMonitorStateException (JvNewStringLatin1
("current thread not owner")); ("current thread not owner"));
} }
assert(address & HEAVY); JvAssert(address & HEAVY);
} }
switch (_Jv_CondWait (&(hl->si.condition), &(hl->si.mutex), timeout, nanos)) switch (_Jv_CondWait (&(hl->si.condition), &(hl->si.mutex), timeout, nanos))
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment