[Gc] Renewed amendment for my patch for WinCE - part 1/2

Ivan Maidanski ivmai at mail.ru
Fri Aug 28 12:37:20 PDT 2009


This patch (ivmai120a.diff, ivmai120b.diff) fully supersedes my previous small ivmai119.diff. The patch grows from my comments to Zeyi Lee's suggestions and his experiments on a WinCE-driven hardware.

The patch addresses the following major WinCE issues:
- greater compile-time tunability (since no getenv());
- private sections are no longer registered by GC_register_dynamic_libraries() (it's still unclear whether we are doing right but otherwise GC_mark_from() generates SEGV fault, and, even, if we use __try/__exception, it logs "Data Abort", moreover, GCC toolchains don't support SEH, so this requires inline assembly for the embedded CPUS if we really need to catch SEGVs);
- a small fix for SH4;
- CeGCC/mingw32ce toolchains support added (also requires ivmai121.diff patch);
- use OutputDebugStringW() for reporting problems;
- use smaller values in test.c if VERY_SMALL_CONFIG;
- don't use/store thread handles (use threadId instead, and don't close it);
- allow PARALLEL_MARK pthread-based implementation (while using native Win32 threads and sync for th rest) since SignalObjectAndWait not available;
- get available cpus count from GC_sysinfo (or explicitly set at compile-time);
- in WinMain() abort (instead of silently return -1) if failed to create the main thread.

The patch is against CVS plus my diff114a/b/c applied (https://permalink.gmane.org/gmane.comp.programming.garbage-collection.boehmgc/2962).

ChangeLog entries:

	comment for.
	* misc.c (GC_init_inner): Recognize GC_PRINT_VERBOSE_STATS (new
	* dyn_load.c (GC_wnt): Change definition to TRUE for WinCE; add
	FIXME and the comment for WinCE.
	* gcj_mlc.c (GC_init_gcj_malloc): Recognize GC_IGNORE_GCJ_INFO
	(new macro).
	* include/gc.h (GC_HAVE_BUILTIN_BACKTRACE): Don't define for VC++
	WinCE (since backtrace() is unimplemented).
	* include/private/gc_priv.h (GC_n_heap_bases): Remove declaration
	(since static).
	* os_dep.c (GC_n_heap_bases): Define as STATIC; move the
	definition to be above GC_is_heap_base().
	* include/private/gcconfig.h: Don't define NOSYS for WinCE on ARM
	(both for MinGW and CeGCC toolchains).
	* include/private/gcconfig.h: Recognize __CEGCC__ and
	__MINGW32CE__ (as synonyms for __WIN32_WCE).
	* include/private/gcconfig.h: If SH4 then don't set config
	parameters for SH.
	* include/private/thread_local_alloc.h (GC_key_create): Don't
	abort on failures, just return -1 in these cases (this also
	prevents compilation error for targets where ABORT is defined
	indirectly as an inline assembler sequence).
	* mark.c (WRAP_MARK_SOME): Also define for WinCE; add FIXME for
	the GCC-based cross-compiler.
	* mark.c (ext_ex_regn, mark_ex_handler): Don't define unless
	WRAP_MARK_SOME is defined; define also for WinCE case; don't
	check for _WIN64 (since WRAP_MARK_SOME is undefined for it).
	* mark.c (GC_mark_some): Use __try/__except also for WinCE; update
	the comment.
	* misc.c: Include signal.h after gc_pmark.h included; check for
	MSWINCE instead of _WIN32_WCE.
	* misc.c (GC_init_inner): Remove duplicate GC_setpagesize() call.
	* misc.c: Don't include <crtdbg.h> for WinCE targets.
	* misc.c (GC_write): Define _MAX_PATH if undefined (workaround for
	CeGCC toolchain).
	* misc.c (GC_write): Use OutputDebugStringW() instead of
	_CrtDbgReport() for WinCE targets.
	* os_dep.c (GC_least_described_address): Define as STATIC.
	* os_dep.c (GC_register_data_segments): Fix code indentation.
	* os_dep.c (GC_wince_get_mem): Initialize "result" local variable
	(to prevent a compiler warning).
	* os_dep.c (GC_dirty_init): Add comment for WinCE target.
	* tests/test.c: Don't include winbase.h directly if GCC for WinCE,
	include assert.h instead.
	* tests/test.c (tiny_reverse_test): Define and use
	useful for WinCE.
	* win32_threads.c (GC_Thread_Rep): Don't declare "handle" field
	for WinCE (since thread Id is used as a "real" thread handle).
	* win32_threads.c (THREAD_HANDLE): New macro.
	* win32_threads.c (GC_register_my_thread_inner): Don't recognize
	DONT_IMPORT_GETCURTHREAD anymore; don't record thread handle on
	* Makefile.direct (DONT_IMPORT_GETCURTHREAD): Remove comment for.
	* win32_threads.c (UNPROTECT, GC_fault_handler_lock): Don't check
	* win32_threads.c (GC_delete_gc_thread, GC_delete_thread): Don't
	close thread handle on WinCE (since it's a thread Id).
	* win32_threads.c (GC_suspend): Don't check for MSWINCE in the
	MPROTECT-related code (for the case if MPROTECT_VDB would be
	implemented for WinCE).
	* win32_threads.c (GC_suspend, GC_start_world, GC_push_stack_for):
	Use THREAD_HANDLE(t) to obtain thread handle.
	* win32_threads.c (GC_PTHREADS_PARAMARK): New macro recognized;
	implicitly define GC_PTHREADS_PARAMARK if GC_PTHREADS; include
	pthread.h; define NUMERIC_THREAD_ID(id) if undefined yet; replace
	GC_PTHREADS with GC_PTHREADS_PARAMARK where appropriate (for the
	parallel mark support).
	* win32_threads.c (start_mark_threads): Use int type for "i" local
	variable (instead of "unsigned") to prevent a compiler warning.
	* win32_threads.c (start_mark_threads): Don't check CreateThread()
	result for -1; call CloseHandle() for the handle created by
	CreateThread() (on WinCE); don't use errno (since errno.h is
	missing on some targets like WinCE) when printing warning on a
	marker thread creation failure.
	* win32_threads.c (signalObjectAndWait_func): Define for WinCE.
	* win32_threads.c (GC_wait_marker): Remove unnecessary assertion
	for non-zero signalObjectAndWait_func (to make the code compilable
	for WinCE).
	* win32_threads.c (GC_thr_init): Allow PARALLEL_MARK for WinCE;
	use GC_sysinfo to get processors count if WinCE; don't check for
	SignalObjectAndWait() if WinCE; replace GC_PTHREADS with
	* win32_threads.c (GC_thr_init): Recognize GC_MIN_MARKERS new
	macro (useful for testing parallel marking on WinCE).
	* win32_threads.c (GC_win32_start, main_thread_start): Define as
	* win32_threads.c: Don't define main_thread_args,
	main_thread_start(), WinMain() for WinCE if GC_DLL.
	* win32_threads.c (WINCE_MAIN_STACK_SIZE): Remove useless macro
	(since the stack size parameter is ignored on WinCE).
	* win32_threads.c (main_thread_start): Remove forward declaration;
	place its definition before WinMain() one.
	* win32_threads.c (WinMain): Abort if GC_CreateThread() or
	WaitForSingleObject() failed (for the main thread).

Note: to compile with the parallel support you also need another my patch ivmai123.diff and also "pthread-w32" v2.8.0 release (both for armv6+ and pre-v6).

Note 2: compilation by CeGCC or mingw32ce requires ivmai121.diff (parallel marking is not supported).

Note 3: USE_MUNMAP seem to work; and THREAD_LOCAL_ALLOC too; PARALLEL_MARK is untested (for now).

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ivmai120a.diff
Type: application/octet-stream
Size: 16049 bytes
Desc: not available
Url : https://napali.hpl.hp.com/pipermail/gc/attachments/20090828/15520476/ivmai120a-0001.obj

More information about the Gc mailing list