summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2011-05-20 09:57:35 +0000
committerIvan Maidanski <ivmai@mail.ru>2012-11-14 13:50:42 +0400
commit9210c35043d6a76e4c65a37d235f69626ae55835 (patch)
tree3d0f325391d9a9ae5024aee7e175e017bbda0984
parent673d34fcb4f129d4494fcc8e4098ebcbc76c4490 (diff)
downloadbdwgc-9210c35043d6a76e4c65a37d235f69626ae55835.tar.gz
2011-05-20 Ivan Maidanski <ivmai@mail.ru>
* mark.c (alloc_mark_stack): Use FALSE/TRUE (instead of 0/1) for boolean local variables. * doc/README.macros (GC_PREFER_MPROTECT_VDB): Update. * os_dep.c (GC_page_was_dirty, GC_page_was_ever_dirty, GC_remove_protection): Define for GWW_VDB and PROC_VDB in a single place. * os_dep.c (GC_page_was_dirty, GC_page_was_ever_dirty): Compute PHT_HASH(h) only once (store result to a local variable). --HG-- branch : bdwgc
-rw-r--r--ChangeLog11
-rw-r--r--doc/README.macros5
-rw-r--r--mark.c4
-rw-r--r--os_dep.c168
4 files changed, 88 insertions, 100 deletions
diff --git a/ChangeLog b/ChangeLog
index 041cce51..54ad2e01 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2011-05-20 Ivan Maidanski <ivmai@mail.ru>
+ * mark.c (alloc_mark_stack): Use FALSE/TRUE (instead of 0/1) for
+ boolean local variables.
+ * doc/README.macros (GC_PREFER_MPROTECT_VDB): Update.
+ * os_dep.c (GC_page_was_dirty, GC_page_was_ever_dirty,
+ GC_remove_protection): Define for GWW_VDB and PROC_VDB in a single
+ place.
+ * os_dep.c (GC_page_was_dirty, GC_page_was_ever_dirty): Compute
+ PHT_HASH(h) only once (store result to a local variable).
+
+2011-05-20 Ivan Maidanski <ivmai@mail.ru>
+
* doc/README.solaris2: Update.
2011-05-19 Ivan Maidanski <ivmai@mail.ru> (really Jie Liu)
diff --git a/doc/README.macros b/doc/README.macros
index 4fd5c840..a6291baf 100644
--- a/doc/README.macros
+++ b/doc/README.macros
@@ -506,8 +506,9 @@ DONT_USE_USER32_DLL (Win32 only) Don't use "user32" DLL import library
(containing MessageBox() entry); useful for a static GC library.
GC_PREFER_MPROTECT_VDB Choose MPROTECT_VDB manually in case of multiple
- virtual dirty bit strategies are implemented (at present useful on Win32
- to force MPROTECT_VDB strategy instead of the default GWW_VDB one).
+ virtual dirty bit strategies are implemented (at present useful on Win32 and
+ Solaris to force MPROTECT_VDB strategy instead of the default GWW_VDB or
+ PROC_VDB ones).
GC_IGNORE_GCJ_INFO Disable GCJ-style type information (useful for
debugging on WinCE).
diff --git a/mark.c b/mark.c
index 5fd37aef..b962863b 100644
--- a/mark.c
+++ b/mark.c
@@ -1198,12 +1198,12 @@ static void alloc_mark_stack(size_t n)
# ifdef GWW_VDB
/* Don't recycle a stack segment obtained with the wrong flags. */
/* Win32 GetWriteWatch requires the right kind of memory. */
- static GC_bool GC_incremental_at_stack_alloc = 0;
+ static GC_bool GC_incremental_at_stack_alloc = FALSE;
GC_bool recycle_old = (!GC_incremental || GC_incremental_at_stack_alloc);
GC_incremental_at_stack_alloc = GC_incremental;
# else
-# define recycle_old 1
+# define recycle_old TRUE
# endif
GC_mark_stack_too_small = FALSE;
diff --git a/os_dep.c b/os_dep.c
index bff6cde9..1fc63625 100644
--- a/os_dep.c
+++ b/os_dep.c
@@ -1557,11 +1557,9 @@ void GC_register_data_segments(void)
# else /* !OS2 */
# if defined(GWW_VDB)
-
# ifndef MEM_WRITE_WATCH
# define MEM_WRITE_WATCH 0x200000
# endif
-
# ifndef WRITE_WATCH_FLAG_RESET
# define WRITE_WATCH_FLAG_RESET 1
# endif
@@ -1648,9 +1646,9 @@ void GC_register_data_segments(void)
done = TRUE;
}
-# else /* !GWW_VDB */
+# else
# define GetWriteWatch_alloc_flag 0
-# endif /* GWW_VDB */
+# endif /* !GWW_VDB */
# if defined(MSWIN32) || defined(MSWINCE) || defined(CYGWIN32)
@@ -2607,7 +2605,6 @@ STATIC void GC_default_push_other_roots(void)
# endif /* SN_TARGET_PS3 */
GC_INNER void (*GC_push_other_roots)(void) = GC_default_push_other_roots;
-
#endif /* THREADS */
/*
@@ -2658,9 +2655,45 @@ STATIC void GC_default_push_other_roots(void)
STATIC void GC_or_pages(page_hash_table pht1, page_hash_table pht2)
{
register int i;
-
for (i = 0; i < PHT_SIZE; i++) pht1[i] |= pht2[i];
}
+
+# ifdef MPROTECT_VDB
+ STATIC GC_bool GC_gww_page_was_dirty(struct hblk * h)
+# else
+ GC_INNER GC_bool GC_page_was_dirty(struct hblk * h)
+# endif
+ {
+ register word index;
+ if (HDR(h) == 0)
+ return TRUE;
+ index = PHT_HASH(h);
+ return get_pht_entry_from_index(GC_grungy_pages, index);
+ }
+
+# if defined(CHECKSUMS) || defined(PROC_VDB)
+ /* Used only if GWW_VDB. */
+# ifdef MPROTECT_VDB
+ STATIC GC_bool GC_gww_page_was_ever_dirty(struct hblk * h)
+# else
+ GC_INNER GC_bool GC_page_was_ever_dirty(struct hblk * h)
+# endif
+ {
+ register word index;
+ if (HDR(h) == 0)
+ return TRUE;
+ index = PHT_HASH(h);
+ return get_pht_entry_from_index(GC_written_pages, index);
+ }
+# endif /* CHECKSUMS || PROC_VDB */
+
+# ifndef MPROTECT_VDB
+ /* Ignore write hints. They don't help us here. */
+ /*ARGSUSED*/
+ GC_INNER void GC_remove_protection(struct hblk *h, word nblocks,
+ GC_bool is_ptrfree) {}
+# endif
+
#endif /* PROC_VDB || GWW_VDB */
#ifdef GWW_VDB
@@ -2682,7 +2715,7 @@ STATIC void GC_default_push_other_roots(void)
detect_GetWriteWatch();
GC_dirty_maintained = GC_GWW_AVAILABLE();
}
-# endif
+# endif /* !MPROTECT_VDB */
# ifdef MPROTECT_VDB
STATIC void GC_gww_read_dirty(void)
@@ -2761,40 +2794,9 @@ STATIC void GC_default_push_other_roots(void)
GC_or_pages(GC_written_pages, GC_grungy_pages);
}
-
-# ifdef MPROTECT_VDB
- STATIC GC_bool GC_gww_page_was_dirty(struct hblk * h)
-# else
- GC_INNER GC_bool GC_page_was_dirty(struct hblk * h)
-# endif
- {
- return HDR(h) == 0 ||
- get_pht_entry_from_index(GC_grungy_pages, PHT_HASH(h));
- }
-
-# ifdef CHECKSUMS
- /* Used only if GWW_VDB. */
-# ifdef MPROTECT_VDB
- STATIC GC_bool GC_gww_page_was_ever_dirty(struct hblk * h)
-# else
- GC_INNER GC_bool GC_page_was_ever_dirty(struct hblk * h)
-# endif
- {
- return HDR(h) == 0 ||
- get_pht_entry_from_index(GC_written_pages, PHT_HASH(h));
- }
-# endif /* CHECKSUMS */
-
-# ifndef MPROTECT_VDB
- /*ARGSUSED*/
- GC_INNER void GC_remove_protection(struct hblk *h, word nblocks,
- GC_bool is_ptrfree) {}
-# endif
-
#endif /* GWW_VDB */
#ifdef DEFAULT_VDB
-
/* All of the following assume the allocation lock is held. */
/* The client asserts that unallocated pages in the heap are never */
@@ -2847,17 +2849,15 @@ STATIC void GC_default_push_other_roots(void)
/*ARGSUSED*/
GC_INNER void GC_remove_protection(struct hblk *h, word nblocks,
GC_bool is_ptrfree) {}
-
#endif /* DEFAULT_VDB */
#ifdef MANUAL_VDB
-
/* Initialize virtual dirty bit implementation. */
GC_INNER void GC_dirty_init(void)
{
if (GC_print_stats == VERBOSE)
GC_log_printf("Initializing MANUAL_VDB...\n");
- /* GC_dirty_pages and GC_grungy_pages are already cleared. */
+ /* GC_dirty_pages and GC_grungy_pages are already cleared. */
GC_dirty_maintained = TRUE;
}
@@ -2904,9 +2904,7 @@ STATIC void GC_default_push_other_roots(void)
#endif /* MANUAL_VDB */
-
#ifdef MPROTECT_VDB
-
/* See DEFAULT_VDB for interface descriptions. */
/*
@@ -3591,25 +3589,23 @@ ssize_t read(int fd, void *buf, size_t nbyte)
/* We should probably also do this for __read, or whatever stdio */
/* actually calls. */
#endif
-
#endif /* 0 */
-#ifdef CHECKSUMS
- /*ARGSUSED*/
- GC_INNER GC_bool GC_page_was_ever_dirty(struct hblk *h)
- {
-# if defined(GWW_VDB)
- if (GC_GWW_AVAILABLE())
- return GC_gww_page_was_ever_dirty(h);
-# endif
- return(TRUE);
- }
-#endif /* CHECKSUMS */
-
-# endif /* MPROTECT_VDB */
+# ifdef CHECKSUMS
+ /*ARGSUSED*/
+ GC_INNER GC_bool GC_page_was_ever_dirty(struct hblk *h)
+ {
+# if defined(GWW_VDB)
+ if (GC_GWW_AVAILABLE())
+ return GC_gww_page_was_ever_dirty(h);
+# endif
+ return(TRUE);
+ }
+# endif /* CHECKSUMS */
-# ifdef PROC_VDB
+#endif /* MPROTECT_VDB */
+#ifdef PROC_VDB
/*
* See DEFAULT_VDB for interface descriptions.
*/
@@ -3621,19 +3617,18 @@ ssize_t read(int fd, void *buf, size_t nbyte)
* address space), but it avoids intercepting system calls.
*/
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/signal.h>
-#include <sys/fault.h>
-#include <sys/syscall.h>
-#include <sys/procfs.h>
-#include <sys/stat.h>
-
-#define INITIAL_BUF_SZ 16384
-STATIC word GC_proc_buf_size = INITIAL_BUF_SZ;
-STATIC char *GC_proc_buf = NULL;
+# include <errno.h>
+# include <sys/types.h>
+# include <sys/signal.h>
+# include <sys/fault.h>
+# include <sys/syscall.h>
+# include <sys/procfs.h>
+# include <sys/stat.h>
-STATIC int GC_proc_fd = 0;
+# define INITIAL_BUF_SZ 16384
+ STATIC word GC_proc_buf_size = INITIAL_BUF_SZ;
+ STATIC char *GC_proc_buf = NULL;
+ STATIC int GC_proc_fd = 0;
GC_INNER void GC_dirty_init(void)
{
@@ -3662,12 +3657,7 @@ GC_INNER void GC_dirty_init(void)
GC_proc_buf = GC_scratch_alloc(GC_proc_buf_size);
}
-/* Ignore write hints. They don't help us here. */
-/*ARGSUSED*/
-GC_INNER void GC_remove_protection(struct hblk *h, word nblocks,
- GC_bool is_ptrfree) {}
-
-#define READ read
+# define READ read
GC_INNER void GC_read_dirty(void)
{
@@ -3739,24 +3729,10 @@ GC_INNER void GC_read_dirty(void)
GC_or_pages(GC_written_pages, GC_grungy_pages);
}
-#undef READ
+# undef READ
+#endif /* PROC_VDB */
-GC_INNER GC_bool GC_page_was_dirty(struct hblk *h)
-{
- register word index = PHT_HASH(h);
- return get_pht_entry_from_index(GC_grungy_pages, index);
-}
-
-GC_INNER GC_bool GC_page_was_ever_dirty(struct hblk *h)
-{
- register word index = PHT_HASH(h);
- return get_pht_entry_from_index(GC_written_pages, index);
-}
-
-# endif /* PROC_VDB */
-
-
-# ifdef PCR_VDB
+#ifdef PCR_VDB
# include "vd/PCR_VD.h"
@@ -3817,7 +3793,7 @@ GC_INNER void GC_remove_protection(struct hblk *h, word nblocks,
PCR_VD_WriteProtectEnable(h, nblocks*HBLKSIZE);
}
-# endif /* PCR_VDB */
+#endif /* PCR_VDB */
#if defined(MPROTECT_VDB) && defined(DARWIN)
/* The following sources were used as a "reference" for this exception
@@ -3998,10 +3974,10 @@ typedef enum {
GC_INNER void GC_darwin_register_mach_handler_thread(mach_port_t thread);
# endif
-#else /* !THREADS */
+#else
/* The compiler should optimize away any GC_mprotect_state computations */
# define GC_mprotect_state GC_MP_NORMAL
-#endif
+#endif /* !THREADS */
STATIC void *GC_mprotect_thread(void *arg)
{