Code refactoring of GC_push_finalizer/thread/typed_structures
authorIvan Maidanski <ivmai@mail.ru>
Mon, 17 Aug 2015 11:32:19 +0000 (14:32 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Wed, 26 Aug 2015 08:15:38 +0000 (11:15 +0300)
* finalize.c (GC_push_finalizer_structures): Replace GC_push_all with
GC_PUSH_ALL_SYM invocation.
* pthread_support.c (GC_push_thread_structures): Likewise.
* typd_mlc.c (GC_push_typed_structures_proc): Likewise.
* win32_threads.c (GC_push_thread_structures): Likewise.
* include/private/gc_priv.h (GC_PUSH_ALL_SYM): New macro (handy one to
push a symbol content).

finalize.c
include/private/gc_priv.h
pthread_support.c
typd_mlc.c
win32_threads.c

index c7d78e3..beb0d61 100644 (file)
@@ -76,21 +76,16 @@ static signed_word log_fo_table_size = -1;
 
 GC_API void GC_CALL GC_push_finalizer_structures(void)
 {
-    GC_ASSERT((word)&GC_dl_hashtbl.head % sizeof(word) == 0);
-    GC_ASSERT((word)&GC_fo_head % sizeof(word) == 0);
-    GC_ASSERT((word)&GC_finalize_now % sizeof(word) == 0);
-
+  GC_ASSERT((word)&GC_dl_hashtbl.head % sizeof(word) == 0);
+  GC_ASSERT((word)&GC_fo_head % sizeof(word) == 0);
+  GC_ASSERT((word)&GC_finalize_now % sizeof(word) == 0);
 # ifndef GC_LONG_REFS_NOT_NEEDED
     GC_ASSERT((word)&GC_ll_hashtbl.head % sizeof(word) == 0);
-    GC_push_all((ptr_t)(&GC_ll_hashtbl.head),
-                (ptr_t)(&GC_ll_hashtbl.head) + sizeof(word));
+    GC_PUSH_ALL_SYM(GC_ll_hashtbl.head);
 # endif
-
-    GC_push_all((ptr_t)(&GC_dl_hashtbl.head),
-                (ptr_t)(&GC_dl_hashtbl.head) + sizeof(word));
-    GC_push_all((ptr_t)(&GC_fo_head), (ptr_t)(&GC_fo_head) + sizeof(word));
-    GC_push_all((ptr_t)(&GC_finalize_now),
-                (ptr_t)(&GC_finalize_now) + sizeof(word));
+  GC_PUSH_ALL_SYM(GC_dl_hashtbl.head);
+  GC_PUSH_ALL_SYM(GC_fo_head);
+  GC_PUSH_ALL_SYM(GC_finalize_now);
 }
 
 /* Double the size of a hash table. *size_ptr is the log of its current */
index f3a26d2..bb652c6 100644 (file)
@@ -1603,6 +1603,9 @@ GC_INNER GC_bool GC_collection_in_progress(void);
 # define GC_PUSH_CONDITIONAL(b, t, all) GC_push_all((ptr_t)(b), (ptr_t)(t))
 #endif
 
+#define GC_PUSH_ALL_SYM(sym) \
+                GC_push_all((ptr_t)&(sym), (ptr_t)&(sym) + sizeof(sym))
+
 GC_INNER void GC_push_all_stack(ptr_t b, ptr_t t);
                                     /* As GC_push_all but consider      */
                                     /* interior pointers as valid.      */
index bb56f4b..e15912b 100644 (file)
@@ -458,10 +458,9 @@ GC_INNER volatile GC_thread GC_threads[THREAD_TABLE_SZ] = {0};
 void GC_push_thread_structures(void)
 {
     GC_ASSERT(I_HOLD_LOCK());
-    GC_push_all((ptr_t)(GC_threads), (ptr_t)(GC_threads)+sizeof(GC_threads));
+    GC_PUSH_ALL_SYM(GC_threads);
 #   if defined(THREAD_LOCAL_ALLOC)
-      GC_push_all((ptr_t)(&GC_thread_key),
-                  (ptr_t)(&GC_thread_key) + sizeof(GC_thread_key));
+      GC_PUSH_ALL_SYM(GC_thread_key);
 #   endif
 }
 
index d39c381..43affcc 100644 (file)
@@ -102,8 +102,7 @@ STATIC int GC_array_mark_proc_index = 0; /* procedures.                 */
 
 STATIC void GC_push_typed_structures_proc(void)
 {
-  GC_push_all((ptr_t)&GC_ext_descriptors,
-              (ptr_t)&GC_ext_descriptors + sizeof(word));
+  GC_PUSH_ALL_SYM(GC_ext_descriptors);
 }
 
 /* Add a multiword bitmap to GC_ext_descriptors arrays.  Return */
index 7032a26..9113708 100644 (file)
@@ -1134,11 +1134,10 @@ void GC_push_thread_structures(void)
     } else
 # endif
   /* else */ {
-    GC_push_all((ptr_t)(GC_threads), (ptr_t)(GC_threads)+sizeof(GC_threads));
+    GC_PUSH_ALL_SYM(GC_threads);
   }
 # if defined(THREAD_LOCAL_ALLOC)
-    GC_push_all((ptr_t)(&GC_thread_key),
-                (ptr_t)(&GC_thread_key) + sizeof(GC_thread_key));
+    GC_PUSH_ALL_SYM(GC_thread_key);
     /* Just in case we ever use our own TLS implementation.     */
 # endif
 }