From 102a0485636ee02338009bd8f920ade1c68439be Mon Sep 17 00:00:00 2001 From: edwin Date: Fri, 19 Jan 2007 01:13:48 +0000 Subject: [PATCH] * src/vm/options.h, src/vm/method.c, src/vm/jit/inline/inline.c, src/vm/jit/jit.c, src/vm/vm.c, src/vm/linker.c, src/vm/options.c, src/cacaoh/headers.c: Cleaned up inlining options. * src/vm/exceptions.c: Removed a left-over use of "useinlining". * configure.ac: New configure flag --enable-inlining-debug. --- configure.ac | 19 +++++++- src/cacaoh/headers.c | 8 +-- src/vm/exceptions.c | 4 +- src/vm/jit/inline/inline.c | 61 ++++++++++++----------- src/vm/jit/jit.c | 7 ++- src/vm/linker.c | 5 +- src/vm/method.c | 5 +- src/vm/options.c | 26 +++++++--- src/vm/options.h | 24 ++++++--- src/vm/vm.c | 99 ++++++++++++++++++++++++++------------ 10 files changed, 166 insertions(+), 92 deletions(-) diff --git a/configure.ac b/configure.ac index 6de3d7a35..1fb7c0176 100644 --- a/configure.ac +++ b/configure.ac @@ -22,7 +22,7 @@ dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA dnl 02110-1301, USA. dnl -dnl $Id: configure.ac 7219 2007-01-16 22:18:57Z pm $ +dnl $Id: configure.ac 7228 2007-01-19 01:13:48Z edwin $ dnl Process this file with autoconf to produce a configure script. @@ -684,6 +684,23 @@ if test x"${ENABLE_INLINING}" = "xyes"; then fi +dnl check for inlining debug options +AC_MSG_CHECKING(whether method inlining debug options should be enabled) +AC_ARG_ENABLE([inlining-debug], + [AS_HELP_STRING(--enable-inlining-debug,enable method inlining debug options [[default=no]])], + [case "${enableval}" in + yes) ENABLE_INLINING_DEBUG=yes;; + *) ENABLE_INLINING_DEBUG=no;; + esac], + [ENABLE_INLINING_DEBUG=no]) +AC_MSG_RESULT(${ENABLE_INLINING_DEBUG}) +AM_CONDITIONAL([ENABLE_INLINING_DEBUG], test x"${ENABLE_INLINING_DEBUG}" = "xyes") + +if test x"${ENABLE_INLINING_DEBUG}" = "xyes"; then + AC_DEFINE([ENABLE_INLINING_DEBUG], 1, [enable method inlining debug options]) +fi + + dnl check for replacement AC_MSG_CHECKING(whether on-stack replacement should be supported) AC_ARG_ENABLE([replacement], diff --git a/src/cacaoh/headers.c b/src/cacaoh/headers.c index 454bc0b29..1aee58958 100644 --- a/src/cacaoh/headers.c +++ b/src/cacaoh/headers.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: headers.c 7218 2007-01-16 12:59:51Z twisti $ + $Id: headers.c 7228 2007-01-19 01:13:48Z edwin $ */ @@ -78,12 +78,6 @@ u1 *intrp_main_stack; #endif -#if !defined(NDEBUG) -/* dummy variable */ -bool inline_debug_log = false; -#endif - - /* for raising exceptions from native methods *********************************/ #if !defined(ENABLE_THREADS) diff --git a/src/vm/exceptions.c b/src/vm/exceptions.c index 7d9b45d19..ada417089 100644 --- a/src/vm/exceptions.c +++ b/src/vm/exceptions.c @@ -27,7 +27,7 @@ Authors: Christian Thalinger Edwin Steiner - $Id: exceptions.c 6598 2007-01-11 14:28:47Z twisti $ + $Id: exceptions.c 7228 2007-01-19 01:13:48Z edwin $ */ @@ -1036,8 +1036,6 @@ java_objectheader *exceptions_new_verifyerror(methodinfo *m, char *msg; s4 msglen; - useinlining = false; /* at least until sure inlining works with exceptions*/ - /* calculate exception message length */ msglen = 0; diff --git a/src/vm/jit/inline/inline.c b/src/vm/jit/inline/inline.c index c27098e78..f87dd507e 100644 --- a/src/vm/jit/inline/inline.c +++ b/src/vm/jit/inline/inline.c @@ -28,7 +28,7 @@ Changes: - $Id: inline.c 7209 2007-01-13 22:30:25Z edwin $ + $Id: inline.c 7228 2007-01-19 01:13:48Z edwin $ */ @@ -96,17 +96,18 @@ #if !defined(NDEBUG) #define INLINE_VERBOSE -bool inline_debug_log = 0; -bool inline_debug_log_names = 0; -int inline_debug_start_counter = 0; -int inline_debug_max_size = INT_MAX; -int inline_debug_min_size = 0; -int inline_debug_end_counter = INT_MAX; -#define DOLOG(code) do{ if (inline_debug_log) { code; } }while(0) +#define DOLOG(code) do{ if (opt_inline_debug_log) { code; } }while(0) #else #define DOLOG(code) #endif +#if defined(ENABLE_VERIFIER) && !defined(NDEBUG) +/* Define this to verify the resulting code after inlining. */ +/* Note: This is only useful for development and may require patches to the */ +/* verifier code. */ +/* #define INLINE_VERIFY_RESULT */ +#endif + /* types **********************************************************************/ @@ -1995,11 +1996,11 @@ static bool inline_transform(inline_node *iln, jitdata *jd) codegendata *n_cd; jitdata *n_jd; s4 i; - - -#if !defined(NDEBUG) - static int debug_verify_inlined_code = 1; /* XXX */ - static int debug_compile_inlined_code_counter = 0; +#if defined(INLINE_VERIFY_RESULT) + static int debug_verify_inlined_code = 1; +#endif +#if defined(ENABLE_INLINING_DEBUG) + static int debug_counter = 0; #endif DOLOG( dump_inline_tree(iln, 0); ); @@ -2039,9 +2040,9 @@ static bool inline_transform(inline_node *iln, jitdata *jd) n_jd->localcount = n_jd->vartop; - /* extra variables for verification (DEBUG) */ + /* extra variables for verification (debugging) */ -#if !defined(NDEBUG) +#if defined(INLINE_VERIFY_RESULT) if (debug_verify_inlined_code) { n_jd->vartop += VERIFIER_EXTRA_LOCALS + VERIFIER_EXTRA_VARS + 100 /* XXX m->maxstack */; if (n_jd->vartop > n_jd->varcount) { @@ -2050,7 +2051,7 @@ static bool inline_transform(inline_node *iln, jitdata *jd) n_jd->varcount = n_jd->vartop; } } -#endif +#endif /* defined(INLINE_VERIFY_RESULT) */ /* write inlined code */ @@ -2119,7 +2120,9 @@ static bool inline_transform(inline_node *iln, jitdata *jd) inline_interface_variables(iln); -#if defined(ENABLE_VERIFIER) && !defined(NDEBUG) && 0 + /* for debugging, verify the inlined result */ + +#if defined(INLINE_VERIFY_RESULT) if (debug_verify_inlined_code) { debug_verify_inlined_code = 0; DOLOG( printf("VERIFYING INLINED RESULT...\n"); fflush(stdout); ); @@ -2133,7 +2136,7 @@ static bool inline_transform(inline_node *iln, jitdata *jd) } debug_verify_inlined_code = 1; } -#endif /* defined(ENABLE_VERIFIER) */ +#endif /* defined(INLINE_VERIFY_RESULT) */ /* we need bigger free memory stacks (XXX these should not be allocated in reg_setup) */ @@ -2142,13 +2145,12 @@ static bool inline_transform(inline_node *iln, jitdata *jd) n_jd->rd->freemem_2 = DMNEW(s4, iln->ctx->maxinoutdepth + 1000) /* XXX max vars/block */; #endif -#if !defined(NDEBUG) - if (n_jd->instructioncount >= inline_debug_min_size - && n_jd->instructioncount <= inline_debug_max_size) +#if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG) + if ( (n_jd->instructioncount >= opt_inline_debug_min_size) + && (n_jd->instructioncount <= opt_inline_debug_max_size)) { - if (debug_compile_inlined_code_counter >= inline_debug_start_counter - && debug_compile_inlined_code_counter <= inline_debug_end_counter) -#endif /* NDEBUG */ + if (debug_counter <= opt_inline_debug_end_counter) +#endif /* defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG) */ { /* install the inlined result */ @@ -2156,12 +2158,14 @@ static bool inline_transform(inline_node *iln, jitdata *jd) n_jd->code = jd->code; *jd = *n_jd; + /* statistics and logging */ + #if !defined(NDEBUG) inline_stat_roots++; - /* inline_debug_log++; */ DOLOG( - printf("==== %d.INLINE ==================================================================\n", debug_compile_inlined_code_counter); + printf("==== %d.INLINE ==================================================================\n", + debug_counter); printf("\ninline tree:\n"); dump_inline_tree(iln, 0); n_jd->flags |= JITDATA_FLAG_SHOWINTERMEDIATE | JITDATA_FLAG_SHOWDISASSEMBLE; @@ -2169,12 +2173,11 @@ static bool inline_transform(inline_node *iln, jitdata *jd) printf("-------- DONE -----------------------------------------------------------\n"); fflush(stdout); ); - /* inline_debug_log--; */ #endif } -#if !defined(NDEBUG) - debug_compile_inlined_code_counter++; +#if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG) + debug_counter++; } #endif return true; diff --git a/src/vm/jit/jit.c b/src/vm/jit/jit.c index 2e044fd08..72b5c535a 100644 --- a/src/vm/jit/jit.c +++ b/src/vm/jit/jit.c @@ -31,7 +31,7 @@ Christian Thalinger Christian Ullrich - $Id: jit.c 7210 2007-01-13 22:37:26Z edwin $ + $Id: jit.c 7228 2007-01-19 01:13:48Z edwin $ */ @@ -1069,6 +1069,11 @@ u1 *jit_compile(methodinfo *m) jd->flags |= JITDATA_FLAG_IFCONV; #endif +#if defined(ENABLE_INLINING) && defined(ENABLE_INLINING_DEBUG) + if (opt_inlining && opt_inline_debug_all) + jd->flags |= JITDATA_FLAG_INLINE; +#endif + if (opt_showintermediate) jd->flags |= JITDATA_FLAG_SHOWINTERMEDIATE; diff --git a/src/vm/linker.c b/src/vm/linker.c index 1755fc16b..e967b3ba6 100644 --- a/src/vm/linker.c +++ b/src/vm/linker.c @@ -32,7 +32,7 @@ Edwin Steiner Christian Thalinger - $Id: linker.c 6251 2006-12-27 23:15:56Z twisti $ + $Id: linker.c 7228 2007-01-19 01:13:48Z edwin $ */ @@ -67,8 +67,7 @@ #if !defined(NDEBUG) && defined(ENABLE_INLINING) -extern bool inline_debug_log; -#define INLINELOG(code) do { if (inline_debug_log) { code } } while (0) +#define INLINELOG(code) do { if (opt_inline_debug_log) { code } } while (0) #else #define INLINELOG(code) #endif diff --git a/src/vm/method.c b/src/vm/method.c index c6c5df137..58e0da3b8 100644 --- a/src/vm/method.c +++ b/src/vm/method.c @@ -32,7 +32,7 @@ Edwin Steiner Christian Thalinger - $Id: method.c 6273 2007-01-03 22:20:25Z edwin $ + $Id: method.c 7228 2007-01-19 01:13:48Z edwin $ */ @@ -55,8 +55,7 @@ #if !defined(NDEBUG) && defined(ENABLE_INLINING) -extern bool inline_debug_log; -#define INLINELOG(code) do { if (inline_debug_log) { code } } while (0) +#define INLINELOG(code) do { if (opt_inline_debug_log) { code } } while (0) #else #define INLINELOG(code) #endif diff --git a/src/vm/options.c b/src/vm/options.c index 4afbbdde1..17d063c04 100644 --- a/src/vm/options.c +++ b/src/vm/options.c @@ -28,7 +28,7 @@ Changes: - $Id: options.c 5922 2006-11-05 21:43:09Z twisti $ + $Id: options.c 7228 2007-01-19 01:13:48Z edwin $ */ @@ -36,6 +36,7 @@ #include "config.h" #include +#include #include "vm/types.h" @@ -98,12 +99,6 @@ bool opt_showintermediate = false; /* generate intermediate code listing */ bool opt_showexceptionstubs = false; bool opt_shownativestub = false; -bool useinlining = false; /* use method inlining */ -bool inlinevirtuals = false; /* inline unique virtual methods */ -bool inlineexceptions = false; /* inline methods, that contain excptions */ -bool inlineparamopt = false; /* optimize parameter passing to inlined methods */ -bool inlineoutsiders = false; /* inline methods, that are not member of the invoker's class */ - bool checkbounds = true; /* check array bounds */ bool checknull = true; /* check null pointers */ bool opt_noieee = false; /* don't implement ieee compliant floats */ @@ -130,6 +125,23 @@ bool opt_prof_bb = false; #endif +/* inlining options ***********************************************************/ + +#if defined(ENABLE_INLINING) +bool opt_inlining = false; +#if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG) +s4 opt_replace_verbose = 0; +s4 opt_inline_debug_min_size = 0; +s4 opt_inline_debug_max_size = INT_MAX; +s4 opt_inline_debug_end_counter = INT_MAX; +bool opt_inline_debug_all = false; +#endif /* defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG) */ +#if !defined(NDEBUG) +bool opt_inline_debug_log = false; +#endif /* !defined(NDEBUG) */ +#endif /* defined(ENABLE_INLINING) */ + + /* optimization options *******************************************************/ #if defined(ENABLE_IFCONV) diff --git a/src/vm/options.h b/src/vm/options.h index c919b6218..983083c89 100644 --- a/src/vm/options.h +++ b/src/vm/options.h @@ -28,7 +28,7 @@ Changes: - $Id: options.h 5922 2006-11-05 21:43:09Z twisti $ + $Id: options.h 7228 2007-01-19 01:13:48Z edwin $ */ @@ -110,12 +110,6 @@ extern bool opt_showintermediate; extern bool opt_showexceptionstubs; extern bool opt_shownativestub; -extern bool useinlining; -extern bool inlinevirtuals; -extern bool inlineexceptions; -extern bool inlineparamopt; -extern bool inlineoutsiders; - extern bool checkbounds; extern bool checknull; extern bool opt_noieee; @@ -141,6 +135,22 @@ extern bool opt_prof; extern bool opt_prof_bb; #endif +/* inlining options ***********************************************************/ + +#if defined(ENABLE_INLINING) +extern bool opt_inlining; +#if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG) +extern s4 opt_replace_verbose; +extern s4 opt_inline_debug_min_size; +extern s4 opt_inline_debug_max_size; +extern s4 opt_inline_debug_end_counter; +extern bool opt_inline_debug_all; +#endif /* defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG) */ +#if !defined(NDEBUG) +extern bool opt_inline_debug_log; +#endif /* !defined(NDEBUG) */ +#endif /* defined(ENABLE_INLINING) */ + /* optimization options *******************************************************/ diff --git a/src/vm/vm.c b/src/vm/vm.c index c0c8dca2b..c280c59a8 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -210,7 +210,18 @@ enum { #if defined(ENABLE_INLINING) OPT_INLINING, -#endif +#if !defined(NDEBUG) + OPT_INLINE_LOG, +#endif +#if defined(ENABLE_INLINING_DEBUG) + OPT_INLINE_DEBUG_ALL, + OPT_INLINE_DEBUG_END, + OPT_INLINE_DEBUG_MIN, + OPT_INLINE_DEBUG_MAX, + OPT_INLINE_REPLACE_VERBOSE, + OPT_INLINE_REPLACE_VERBOSE2, +#endif /* defined(ENABLE_INLINING_DEBUG) */ +#endif /* defined(ENABLE_INLINING) */ #if defined(ENABLE_INTRP) /* interpreter options */ @@ -347,11 +358,24 @@ opt_struct opts[] = { { "Xprof", false, OPT_PROF }, #endif - /* keep these at the end of the list */ + /* inlining options */ #if defined(ENABLE_INLINING) - { "i", true, OPT_INLINING }, +#if defined(ENABLE_INLINING_DEBUG) + { "ia", false, OPT_INLINE_DEBUG_ALL }, + { "ii", true, OPT_INLINE_DEBUG_MIN }, + { "im", true, OPT_INLINE_DEBUG_MAX }, + { "ie", true, OPT_INLINE_DEBUG_END }, + { "ir", false, OPT_INLINE_REPLACE_VERBOSE }, + { "iR", false, OPT_INLINE_REPLACE_VERBOSE2 }, +#endif /* defined(ENABLE_INLINING_DEBUG) */ +#if !defined(NDEBUG) + { "il", false, OPT_INLINE_LOG }, #endif + { "i", false, OPT_INLINING }, +#endif /* defined(ENABLE_INLINING) */ + + /* keep these at the end of the list */ #if !defined(NDEBUG) { "m", true, OPT_METHOD }, @@ -497,13 +521,22 @@ static void XXusage(void) puts(" (n)ative disassembled native stubs"); #endif puts(" (d)atasegment data segment listing"); + #if defined(ENABLE_INLINING) - puts(" -i n(line) activate inlining"); - puts(" v(irtual) inline virtual methods (uses/turns rt option on)"); - puts(" e(exception) inline methods with exceptions"); - puts(" p(aramopt) optimize argument renaming"); - puts(" o(utsiders) inline methods of foreign classes"); + puts(" -i activate inlining"); +#if !defined(NDEBUG) + puts(" -il log inlining"); +#endif +#if defined(ENABLE_INLINING_DEBUG) + puts(" -ia use inlining for all methods"); + puts(" -ii set minimum size for inlined result"); + puts(" -im set maximum size for inlined result"); + puts(" -ie stop inlining after the given number of roots"); + puts(" -ir log on-stack replacement"); + puts(" -iR log on-stack replacement, more verbose"); +#endif /* defined(ENABLE_INLINING_DEBUG) */ #endif /* defined(ENABLE_INLINING) */ + #if defined(ENABLE_IFCONV) puts(" -ifconv use if-conversion"); #endif @@ -1207,30 +1240,34 @@ bool vm_create(JavaVMInitArgs *vm_args) #endif #if defined(ENABLE_INLINING) +#if defined(ENABLE_INLINING_DEBUG) + case OPT_INLINE_DEBUG_ALL: + opt_inline_debug_all = true; + break; + case OPT_INLINE_DEBUG_END: + opt_inline_debug_end_counter = atoi(opt_arg); + break; + case OPT_INLINE_DEBUG_MIN: + opt_inline_debug_min_size = atoi(opt_arg); + break; + case OPT_INLINE_DEBUG_MAX: + opt_inline_debug_max_size = atoi(opt_arg); + break; + case OPT_INLINE_REPLACE_VERBOSE: + opt_replace_verbose = 1; + break; + case OPT_INLINE_REPLACE_VERBOSE2: + opt_replace_verbose = 2; + break; +#endif /* defined(ENABLE_INLINING_DEBUG) */ +#if !defined(NDEBUG) + case OPT_INLINE_LOG: + opt_inline_debug_log = true; + break; +#endif /* !defined(NDEBUG) */ + case OPT_INLINING: - for (i = 0; i < strlen(opt_arg); i++) { - switch (opt_arg[i]) { - case 'n': - /* define in options.h; Used in main.c, jit.c - & inline.c inlining is currently - deactivated */ - break; - case 'v': - inlinevirtuals = true; - break; - case 'e': - inlineexceptions = true; - break; - case 'p': - inlineparamopt = true; - break; - case 'o': - inlineoutsiders = true; - break; - default: - usage(); - } - } + opt_inlining = true; break; #endif /* defined(ENABLE_INLINING) */ -- 2.25.1