mirror of
https://github.com/encounter/bdwgc.git
synced 2026-03-30 10:57:55 -07:00
06009b0a08
Manual VDB is now enabled by GC_set_manual_vdb_allowed(1) if called before entering the GC incremental mode. * alloc.c (GC_allocobj): Expand TRUE_INCREMENTAL macro. * darwin_stop_world.c [MPROTECT_VDB] (GC_stop_world, GC_start_world): Use GC_auto_incremental instead of GC_incremental. * mark.c (alloc_mark_stack): Likewise. * mark.c [PROC_VDB] (GC_push_all): Likewise. * mark.c [!NEED_FIXUP_POINTER && THREADS && MPROTECT_VDB] (GC_push_all_stack): Likewise. * pthread_support.c [CAN_HANDLE_FORK && GC_DARWIN_THREADS && MPROTECT_VDB] (GC_atfork_prepare): Likewise. * win32_threads.c [MPROTECT_VDB && !CYGWIN32] (GC_register_my_thread_inner): Likewise. * win32_threads.c [MPROTECT_VDB] (UNPROTECT_THREAD): Likewise. * doc/gcdescr.md (Generational Collection and Dirty Bits): Update documentation for the manual VDB. * include/gc.h (GC_end_stubborn_change): Update comment. * mark_rts.c (GC_push_all_stack_partially_eager): Likewise. * include/gc.h (GC_set_manual_vdb_allowed, GC_get_manual_vdb_allowed): New public function. * include/private/gc_priv.h (GC_grungy_pages, GC_dirty_pages): Define for all VDB modes. * include/private/gc_priv.h (GC_auto_incremental, GC_manual_vdb): Define. * include/private/gc_priv.h [!GC_DISABLE_INCREMENTAL] (GC_dirty): Use GC_manual_vdb instead of GC_incremental. * include/private/gcconfig.h (GWW_VDB, MPROTECT_VDB, PCR_VDB): Do not undefine if MANUAL_VDB. * mallocx.c (GC_generic_malloc_many): Always allocate a single object (and call GC_dirty_inner/REACHABLE_AFTER_DIRTY) if GC_manual_vdb. * misc.c [!CAN_HANDLE_FORK && DARWIN && MPROTECT_VDB && !THREADS && !SMALL_CONFIG] (GC_set_handle_fork): Do not ABORT if GC_manual_vdb. * misc.c [!SMALL_CONFIG] (manual_vdb_allowed): New static variable. * misc.c [!SMALL_CONFIG] (GC_set_manual_vdb_allowed, GC_get_manual_vdb_allowed): Implement. * misc.c [!CHECKSUMS && !SMALL_CONFIG] (GC_init, GC_enable_incremental): Set GC_manual_vdb and GC_incremental to true if manual_vdb_allowed; do not call GC_dirty_init if manual_vdb_allowed. * os_dep.c: Update comment about MANUAL_VDB. * os_dep.c [MANUAL_VDB] (GC_dirty_init, async_set_pht_entry_from_index): Remove. * os_dep.c [!GC_DISABLE_INCREMENTAL] (GC_manual_vdb): Define global variable. * os_dep.c [!GC_DISABLE_INCREMENTAL] (GC_dirty_inner): Define regardless of the VDB mode; add FIXME. * os_dep.c [!GC_DISABLE_INCREMENTAL] (GC_read_dirty, GC_page_was_dirty, GC_remove_protection): Implement for the case of GC_manual_vdb is true; do not depend on MANUAL_VDB. * tests/disclaim_test.c [TEST_MANUAL_VDB] (main): Call GC_set_manual_vdb_allowed(1) before GC_INIT. * tests/staticrootslib.c [TEST_MANUAL_VDB] (libsrl_init): Likewise. * tests/test_cpp.cc [TEST_MANUAL_VDB] (main): Likewise. * tests/test.c (INIT_MANUAL_VDB_ALLOWED): New macro. * tests/test.c (GC_COND_INIT): Invoke INIT_MANUAL_VDB_ALLOWED (before GC_OPT_INIT). * tests/test.c [!SMALL_CONFIG] (main): Call GC_get_manual_vdb_allowed.
73 lines
1.6 KiB
C
73 lines
1.6 KiB
C
|
|
/* This test file is intended to be compiled into a DLL. */
|
|
|
|
#ifndef GC_DEBUG
|
|
# define GC_DEBUG
|
|
#endif
|
|
|
|
#include "gc.h"
|
|
|
|
#ifndef GC_TEST_EXPORT_API
|
|
# if defined(GC_VISIBILITY_HIDDEN_SET) \
|
|
&& !defined(__CEGCC__) && !defined(__CYGWIN__) && !defined(__MINGW32__)
|
|
# define GC_TEST_EXPORT_API \
|
|
extern __attribute__((__visibility__("default")))
|
|
# else
|
|
# define GC_TEST_EXPORT_API extern
|
|
# endif
|
|
#endif
|
|
|
|
struct treenode {
|
|
struct treenode *x;
|
|
struct treenode *y;
|
|
};
|
|
|
|
static struct treenode *root[10] = { 0 };
|
|
static struct treenode *root_nz[10] = { (struct treenode *)(GC_word)2 };
|
|
|
|
#ifdef STATICROOTSLIB2
|
|
# define libsrl_getpelem libsrl_getpelem2
|
|
#else
|
|
|
|
GC_TEST_EXPORT_API struct treenode * libsrl_mktree(int i)
|
|
{
|
|
struct treenode * r = GC_NEW(struct treenode);
|
|
if (0 == i)
|
|
return 0;
|
|
if (1 == i)
|
|
r = (struct treenode *)GC_MALLOC_ATOMIC(sizeof(struct treenode));
|
|
if (r) {
|
|
struct treenode *x = libsrl_mktree(i - 1);
|
|
struct treenode *y = libsrl_mktree(i - 1);
|
|
r -> x = x;
|
|
r -> y = y;
|
|
if (i != 1) {
|
|
GC_END_STUBBORN_CHANGE(r);
|
|
GC_reachable_here(x);
|
|
GC_reachable_here(y);
|
|
}
|
|
}
|
|
return r;
|
|
}
|
|
|
|
GC_TEST_EXPORT_API void * libsrl_init(void)
|
|
{
|
|
# ifdef TEST_MANUAL_VDB
|
|
GC_set_manual_vdb_allowed(1);
|
|
# endif
|
|
# ifndef STATICROOTSLIB_INIT_IN_MAIN
|
|
GC_INIT();
|
|
# endif
|
|
# ifndef NO_INCREMENTAL
|
|
GC_enable_incremental();
|
|
# endif
|
|
return GC_MALLOC(sizeof(struct treenode));
|
|
}
|
|
|
|
#endif /* !STATICROOTSLIB2 */
|
|
|
|
GC_TEST_EXPORT_API struct treenode ** libsrl_getpelem(int i, int j)
|
|
{
|
|
return &((j & 1) != 0 ? root_nz : root)[i];
|
|
}
|