#endif
/* Unregisters given link and returns the link entry to free. */
-/* Assume the lock is held. */
GC_INLINE struct disappearing_link *GC_unregister_disappearing_link_inner(
struct dl_hashtbl_s *dl_hashtbl, void **link)
{
struct disappearing_link *prev_dl = NULL;
size_t index;
+ GC_ASSERT(I_HOLD_LOCK());
if (dl_hashtbl->log_size == -1)
return NULL; /* prevent integer shift by a negative amount */
word curr_hidden_link;
word new_hidden_link;
+ GC_ASSERT(I_HOLD_LOCK());
if (dl_hashtbl->log_size == -1)
return GC_NOT_FOUND; /* prevent integer shift by a negative amount */
size_t i; \
size_t dl_size = dl_hashtbl->log_size == -1 ? 0 : \
(size_t)1 << dl_hashtbl->log_size; \
+ GC_ASSERT(I_HOLD_LOCK()); \
for (i = 0; i < dl_size; i++) { \
struct disappearing_link *prev_dl = NULL; \
curr_dl = dl_hashtbl -> head[i]; \
size_t fo_size = log_fo_table_size == -1 ? 0 :
(size_t)1 << log_fo_table_size;
+ GC_ASSERT(I_HOLD_LOCK());
# ifndef SMALL_CONFIG
/* Save current GC_[dl/ll]_entries value for stats printing */
GC_old_dl_entries = GC_dl_hashtbl.entries;
#ifndef JAVA_FINALIZATION_NOT_NEEDED
- /* Enqueue all remaining finalizers to be run - Assumes lock is held. */
+ /* Enqueue all remaining finalizers to be run. */
STATIC void GC_enqueue_all_finalizers(void)
{
struct finalizable_object * next_fo;
int i;
int fo_size;
+ GC_ASSERT(I_HOLD_LOCK());
fo_size = log_fo_table_size == -1 ? 0 : 1 << log_fo_table_size;
GC_bytes_finalized = 0;
for (i = 0; i < fo_size; i++) {
GC_bytes_finalized +=
curr_fo -> fo_object_size + sizeof(struct finalizable_object);
curr_fo = next_fo;
- }
+ }
}
GC_fo_entries = 0; /* all entries deleted from the hash table */
}
#endif /* DEBUG_THREADS */
/* It may not be safe to allocate when we register the first thread. */
+/* As "next" and "status" fields are unused, no need to push this. */
static struct GC_Thread_Rep first_thread;
/* Add a thread to GC_threads. We assume it wasn't already there. */
if (!EXPECT(first_thread_used, TRUE)) {
result = &first_thread;
first_thread_used = TRUE;
+ GC_ASSERT(NULL == GC_threads[hv]);
# if defined(THREAD_SANITIZER) && defined(CPPCHECK)
GC_noop1(result->dummy[0]);
# endif
if (prev == 0) {
GC_threads[hv] = p -> next;
} else {
+ GC_ASSERT(prev != &first_thread);
prev -> next = p -> next;
}
if (p != &first_thread) {
if (prev == 0) {
GC_threads[hv] = p -> next;
} else {
+ GC_ASSERT(prev != &first_thread);
prev -> next = p -> next;
}
# ifdef GC_DARWIN_THREADS
if (!EXPECT(first_thread_used, TRUE)) {
result = &first_thread;
first_thread_used = TRUE;
+ GC_ASSERT(NULL == GC_threads[hv]);
} else {
GC_ASSERT(!GC_win32_dll_threads);
result = (struct GC_Thread_Rep *)
if (prev == 0) {
GC_threads[hv] = p -> tm.next;
} else {
+ GC_ASSERT(prev != &first_thread);
prev -> tm.next = p -> tm.next;
}
}
if (prev == 0) {
GC_threads[hv] = p -> tm.next;
} else {
+ GC_ASSERT(prev != &first_thread);
prev -> tm.next = p -> tm.next;
}
- if (p != &first_thread) {
+ if (EXPECT(p != &first_thread, TRUE)) {
GC_INTERNAL_FREE(p);
}
}
/* we don't need to hold the allocation lock during pthread_create. */
me = GC_register_my_thread_inner(sb, thread_id);
SET_PTHREAD_MAP_CACHE(pthread_id, thread_id);
+ GC_ASSERT(me != &first_thread);
me -> pthread_id = pthread_id;
if (si->detached) me -> flags |= DETACHED;
UNLOCK();