# HG changeset patch # User nkeynes # Date 1224938202 0 # Node ID 18e0cdea76aa85d4ef2a1fe18e54dc160200005b # Parent fc3cfc0859fb8e3b7293387db7c343c06f53dc6f Add --enable-optimized flag (on by default). When optimized, add -fomit-frame-pointer -fexceptions on non-Mac x86 (Unwinding doesn't seem to work correctly on Mac) --- a/config.h.in Fri Oct 24 10:38:43 2008 +0000 +++ b/config.h.in Sat Oct 25 12:36:42 2008 +0000 @@ -43,6 +43,9 @@ /* Have esound support */ #undef HAVE_ESOUND +/* Have exception stack-frame information */ +#undef HAVE_EXCEPTIONS + /* Define if the GNU gettext() function is already present or preinstalled. */ #undef HAVE_GETTEXT --- a/configure Fri Oct 24 10:38:43 2008 +0000 +++ b/configure Sat Oct 25 12:36:42 2008 +0000 @@ -804,6 +804,7 @@ enable_dependency_tracking enable_strict_warn enable_translator +enable_optimized enable_trace enable_watch enable_sh4stats @@ -1469,7 +1470,9 @@ --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors --enable-strict-warn Enable strict compilation warnings - --disable-translator Disable the SH4 translator (Enable by default) + --disable-translator Disable the SH4 translator (Enabled by default) + --disable-optimized Disable compile-time optimizations (Enabled by + default) --enable-trace Enable generation of IO traces (warning: hurts performance) --enable-watch Enable watchpoints in the debugger (warning: hurts @@ -6565,6 +6568,13 @@ enable_translator=yes fi +# Check whether --enable-optimized was given. +if test "${enable_optimized+set}" = set; then + enableval=$enable_optimized; true +else + enable_optimized=yes +fi + # Check whether --enable-trace was given. if test "${enable_trace+set}" = set; then enableval=$enable_trace; if test "$enableval" == "yes"; then @@ -6628,11 +6638,17 @@ +if test "x$enable_optimized" = "xyes"; then + CFLAGS="-g -O2" +else + CFLAGS="-g3" +fi if test "x$GCC" = "xyes"; then CFLAGS="$CFLAGS -fno-strict-aliasing" fi + lxdream_save_cppflags="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -x objective-c" cat >conftest.$ac_ext <<_ACEOF @@ -6849,6 +6865,14 @@ _ACEOF fi +if test "x$enable_optimized" = "xyes" -a "x$APPLE_BUILD" != "xyes"; then + CFLAGS="$CFLAGS -fexceptions -fomit-frame-pointer" + +cat >>confdefs.h <<\_ACEOF +#define HAVE_EXCEPTIONS 1 +_ACEOF + +fi --- a/configure.in Fri Oct 24 10:38:43 2008 +0000 +++ b/configure.in Sat Oct 25 12:36:42 2008 +0000 @@ -23,8 +23,11 @@ AS_HELP_STRING( [--enable-strict-warn], [Enable strict compilation warnings]), [CFLAGS="$CFLAGS -Werror -Wall -Wno-unused"], []) AC_ARG_ENABLE( translator, - AS_HELP_STRING( [--disable-translator], [Disable the SH4 translator (Enable by default)]), + AS_HELP_STRING( [--disable-translator], [Disable the SH4 translator (Enabled by default)]), [true], [enable_translator=yes] ) +AC_ARG_ENABLE( optimized, + AS_HELP_STRING( [--disable-optimized], [Disable compile-time optimizations (Enabled by default)]), + [true], [enable_optimized=yes] ) AC_ARG_ENABLE( trace, AS_HELP_STRING( [--enable-trace], [Enable generation of IO traces (warning: hurts performance)]), [if test "$enableval" == "yes"; then @@ -52,10 +55,16 @@ dnl ------------ +if test "x$enable_optimized" = "xyes"; then + CFLAGS="-g -O2" +else + CFLAGS="-g3" +fi if test "x$GCC" = "xyes"; then CFLAGS="$CFLAGS -fno-strict-aliasing" fi + dnl ------------ Check if we're building on Darwin -------------- dnl For starters, do we have a working objective-c compiler? @@ -82,6 +91,10 @@ if test "x$HAVE_COCOA" = 'xyes' -a "x$with_gtk" = "xno"; then AC_DEFINE(OSX_BUNDLE, [1], [Generating a bundled application]) fi +if test "x$enable_optimized" = "xyes" -a "x$APPLE_BUILD" != "xyes"; then + CFLAGS="$CFLAGS -fexceptions -fomit-frame-pointer" + AC_DEFINE(HAVE_EXCEPTIONS, [1], [Have exception stack-frame information]) +fi dnl ----------- Check for mandatory dependencies -------------- dnl Check for libpng (required) --- a/src/sh4/ia32abi.h Fri Oct 24 10:38:43 2008 +0000 +++ b/src/sh4/ia32abi.h Sat Oct 25 12:36:42 2008 +0000 @@ -264,6 +264,46 @@ } } +/** + * The unwind methods only work if we compiled with DWARF2 frame information + * (ie -fexceptions), otherwise we have to use the direct frame scan. + */ +#ifdef HAVE_EXCEPTIONS +#include + +struct UnwindInfo { + int have_result; + void *pc; +}; + +_Unwind_Reason_Code xlat_check_frame( struct _Unwind_Context *context, void *arg ) +{ + void *ebp = (void *)_Unwind_GetGR(context, 5); + void *expect = (((uint8_t *)&sh4r) + 128 ); + struct UnwindInfo *info = arg; + if( ebp == expect ) { + info->have_result = 1; + info->pc = (void *)_Unwind_GetIP(context); + } else if( info->have_result ) { + return _URC_NORMAL_STOP; + } + + return _URC_NO_REASON; +} + +void *xlat_get_native_pc() +{ + struct _Unwind_Exception exc; + struct UnwindInfo info; + + info.have_result = 0; + void *result = NULL; + _Unwind_Backtrace( xlat_check_frame, &info ); + if( info.have_result ) + return info.pc; + return NULL; +} +#else void *xlat_get_native_pc() { void *result = NULL; @@ -286,6 +326,7 @@ : "eax", "ecx", "edx" ); return result; } +#endif #endif /* !lxdream_ia32abi_H */