* src/vm/options.h, src/vm/method.c, src/vm/jit/inline/inline.c,
authoredwin <none@none>
Fri, 19 Jan 2007 01:13:48 +0000 (01:13 +0000)
committeredwin <none@none>
Fri, 19 Jan 2007 01:13:48 +0000 (01:13 +0000)
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
src/cacaoh/headers.c
src/vm/exceptions.c
src/vm/jit/inline/inline.c
src/vm/jit/jit.c
src/vm/linker.c
src/vm/method.c
src/vm/options.c
src/vm/options.h
src/vm/vm.c

index 6de3d7a35aadb7ab2d1f723872fc8509f8b39349..1fb7c017669a944211c5e6bdbf1941ca241bbcfb 100644 (file)
@@ -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],
index 454bc0b29d9d7e15cfaabd9253052a91b77957cc..1aee589588388ef0b07b8c7f7be9bf38e44a8b6d 100644 (file)
@@ -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)
index 7d9b45d1988447e6e1da280fb9645431baffb7b5..ada417089c7a095b2763dd3b402f69f3c739e9c2 100644 (file)
@@ -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;
index c27098e789a21e73dd8b85e115858e0fa743cc5f..f87dd507eaf135b4e861d6f2933229f8ade26162 100644 (file)
@@ -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 $
 
 */
 
 
 #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;
index 2e044fd08c70de6478c57e7314081e16a15a2262..72b5c535a366198f54bb287d4cced0820febb242 100644 (file)
@@ -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;
 
index 1755fc16b37c50d44fda766e7af081b57766afef..e967b3ba644e40cbe675be626439a4275741febc 100644 (file)
@@ -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
index c6c5df137a447b79b6997eae8aa34e4554d1b320..58e0da3b84a8ce68a4a88ab5b12650ee9dc80604 100644 (file)
@@ -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
index 4afbbdde1fafbab65df000f730e5a35e9afdfe97..17d063c04428f91b61ca2a11fb840d625e9b4924 100644 (file)
@@ -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 <string.h>
+#include <limits.h>
 
 #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)
index c919b6218cecf3d0d61710004115f241fd128c5f..983083c8934cc67cf2d8cb3888cd2c6cf2124afe 100644 (file)
@@ -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 *******************************************************/
 
index c0c8dca2b6c3d9bb54d73c8cfbe881194125bad8..c280c59a8e116443b7a55154f0430c6e25b353de 100644 (file)
@@ -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 <size>               set minimum size for inlined result");
+       puts("    -im <size>               set maximum size for inlined result");
+       puts("    -ie <number>             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) */