* src/threads/posix/thread-posix.cpp: Eliminated some easy-to-fix or pointless compil...
[cacao.git] / src / vm / options.c
index ade24918c6a4304ef36fdcd4962749a7a8e36fd0..f503ce6829c78cd958d273a3a8c10b98e7b06267 100644 (file)
@@ -1,6 +1,6 @@
 /* src/vm/options.c - contains global options
 
-   Copyright (C) 1996-2005, 2006, 2007, 2008
+   Copyright (C) 1996-2005, 2006, 2007, 2008, 2010
    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
@@ -30,7 +30,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include "mm/memory.h"
+#include "mm/memory.hpp"
 
 #include "vm/options.h"
 #include "vm/os.hpp"
@@ -62,7 +62,6 @@ s4   opt_stacksize     = 0;     /* thread stack size                          */
 
 bool opt_verbose = false;
 bool opt_debugcolor = false;   /* use ANSI terminal sequences                */
-bool compileall = false;
 
 bool loadverbose = false;
 bool initverbose = false;
@@ -76,9 +75,6 @@ bool showmethods = false;
 bool showconstantpool = false;
 bool showutf = false;
 
-char *opt_method = NULL;
-char *opt_signature = NULL;
-
 bool compileverbose =  false;           /* trace compiler actions             */
 bool showstack = false;
 
@@ -160,6 +156,11 @@ int      opt_ThreadStackSize              = 0;
 
 /* Debugging options which can be turned off. */
 
+bool     opt_AlwaysEmitLongBranches       = false;
+bool     opt_AlwaysMmapFirstPage          = false;
+int      opt_CompileAll                   = 0;
+char*    opt_CompileMethod                = NULL;
+char*    opt_CompileSignature             = NULL;
 int      opt_DebugExceptions              = 0;
 int      opt_DebugFinalizer               = 0;
 int      opt_DebugLocalReferences         = 0;
@@ -190,12 +191,15 @@ int      opt_InlineMinSize                = 0;
 #endif
 #endif
 int      opt_PrintConfig                  = 0;
+int      opt_PrintWarnings                = 0;
 int      opt_ProfileGCMemoryUsage         = 0;
 int      opt_ProfileMemoryUsage           = 0;
 FILE    *opt_ProfileMemoryUsageGNUPlot    = NULL;
+int      opt_RegallocSpillAll             = 0;
 #if defined(ENABLE_REPLACEMENT)
 int      opt_TestReplacement              = 0;
 #endif
+int      opt_TraceBuiltinCalls            = 0;
 int      opt_TraceCompilerCalls           = 0;
 int      opt_TraceExceptions              = 0;
 int      opt_TraceHPI                     = 0;
@@ -203,9 +207,13 @@ int      opt_TraceHPI                     = 0;
 int      opt_TraceInlining                = 0;
 #endif
 int      opt_TraceJavaCalls               = 0;
+bool     opt_TraceJMMCalls                = false;
 int      opt_TraceJNICalls                = 0;
 int      opt_TraceJVMCalls                = 0;
 int      opt_TraceJVMCallsVerbose         = 0;
+#if defined(ENABLE_JVMTI)
+int      opt_TraceJVMTICalls              = 0;
+#endif
 int      opt_TraceLinkClass               = 0;
 #if defined(ENABLE_REPLACEMENT)
 int      opt_TraceReplacement             = 0;
@@ -230,6 +238,11 @@ enum {
 
        /* Debugging options which can be turned off. */
 
+       OPT_AlwaysEmitLongBranches,
+       OPT_AlwaysMmapFirstPage,
+       OPT_CompileAll,
+       OPT_CompileMethod,
+       OPT_CompileSignature,
        OPT_DebugExceptions,
        OPT_DebugFinalizer,
        OPT_DebugLocalReferences,
@@ -250,18 +263,23 @@ enum {
        OPT_InlineMaxSize,
        OPT_InlineMinSize,
        OPT_PrintConfig,
+       OPT_PrintWarnings,
        OPT_ProfileGCMemoryUsage,
        OPT_ProfileMemoryUsage,
        OPT_ProfileMemoryUsageGNUPlot,
+       OPT_RegallocSpillAll,
        OPT_TestReplacement,
+       OPT_TraceBuiltinCalls,
        OPT_TraceCompilerCalls,
        OPT_TraceExceptions,
        OPT_TraceHPI,
        OPT_TraceInlining,
        OPT_TraceJavaCalls,
+       OPT_TraceJMMCalls,
        OPT_TraceJNICalls,
        OPT_TraceJVMCalls,
        OPT_TraceJVMCallsVerbose,
+       OPT_TraceJVMTICalls,
        OPT_TraceLinkClass,
        OPT_TraceReplacement,
        OPT_TraceSubsystemInitialization,
@@ -283,6 +301,11 @@ option_t options_XX[] = {
 
        /* Debugging options which can be turned off. */
 
+       { "AlwaysEmitLongBranches",       OPT_AlwaysEmitLongBranches,       OPT_TYPE_BOOLEAN, "Always emit long-branches." },
+       { "AlwaysMmapFirstPage",          OPT_AlwaysMmapFirstPage,          OPT_TYPE_BOOLEAN, "Always mmap memory page at address 0x0." },
+       { "CompileAll",                   OPT_CompileAll,                   OPT_TYPE_BOOLEAN, "compile all methods, no execution" },
+       { "CompileMethod",                OPT_CompileMethod,                OPT_TYPE_VALUE,   "compile only a specific method" },
+       { "CompileSignature",             OPT_CompileSignature,             OPT_TYPE_VALUE,   "specify signature for a specific method" },
        { "DebugExceptions",              OPT_DebugExceptions,              OPT_TYPE_BOOLEAN, "debug exceptions" },
        { "DebugFinalizer",               OPT_DebugFinalizer,               OPT_TYPE_BOOLEAN, "debug finalizer thread" },
        { "DebugLocalReferences",         OPT_DebugLocalReferences,         OPT_TYPE_BOOLEAN, "print debug information for local reference tables" },
@@ -313,12 +336,15 @@ option_t options_XX[] = {
 #endif
 #endif
        { "PrintConfig",                  OPT_PrintConfig,                  OPT_TYPE_BOOLEAN, "print VM configuration" },
+       { "PrintWarnings",                OPT_PrintWarnings,                OPT_TYPE_BOOLEAN, "print warnings about suspicious behavior"},
        { "ProfileGCMemoryUsage",         OPT_ProfileGCMemoryUsage,         OPT_TYPE_VALUE,   "profiles GC memory usage in the given interval, <value> is in seconds (default: 5)" },
        { "ProfileMemoryUsage",           OPT_ProfileMemoryUsage,           OPT_TYPE_VALUE,   "TODO" },
        { "ProfileMemoryUsageGNUPlot",    OPT_ProfileMemoryUsageGNUPlot,    OPT_TYPE_VALUE,   "TODO" },
+       { "RegallocSpillAll",             OPT_RegallocSpillAll,             OPT_TYPE_BOOLEAN, "spill all variables to the stack" },
 #if defined(ENABLE_REPLACEMENT)
        { "TestReplacement",              OPT_TestReplacement,              OPT_TYPE_BOOLEAN, "activate all replacement points during code generation" },
 #endif
+       { "TraceBuiltinCalls",            OPT_TraceBuiltinCalls,            OPT_TYPE_BOOLEAN, "trace calls to VM builtin functions" },
        { "TraceCompilerCalls",           OPT_TraceCompilerCalls,           OPT_TYPE_BOOLEAN, "trace JIT compiler calls" },
        { "TraceExceptions",              OPT_TraceExceptions,              OPT_TYPE_BOOLEAN, "trace Exception throwing" },
        { "TraceHPI",                     OPT_TraceHPI,                     OPT_TYPE_BOOLEAN, "Trace Host Porting Interface (HPI)" },
@@ -328,9 +354,13 @@ option_t options_XX[] = {
 #if !defined(ENABLE_VMLOG)
        { "TraceJavaCalls",               OPT_TraceJavaCalls,               OPT_TYPE_BOOLEAN, "trace Java method calls" },
 #endif
+       { "TraceJMMCalls",                OPT_TraceJMMCalls,                OPT_TYPE_BOOLEAN, "trace JMM method calls" },
        { "TraceJNICalls",                OPT_TraceJNICalls,                OPT_TYPE_BOOLEAN, "trace JNI method calls" },
        { "TraceJVMCalls",                OPT_TraceJVMCalls,                OPT_TYPE_BOOLEAN, "trace JVM method calls but omit very frequent ones" },
        { "TraceJVMCallsVerbose",         OPT_TraceJVMCallsVerbose,         OPT_TYPE_BOOLEAN, "trace all JVM method calls" },
+#if defined(ENABLE_JVMTI)
+       { "TraceJVMTICalls",              OPT_TraceJVMTICalls,              OPT_TYPE_BOOLEAN, "trace JVMTI method calls" },
+#endif
        { "TraceLinkClass",               OPT_TraceLinkClass,               OPT_TYPE_BOOLEAN, "trace class linking" },
 #if defined(ENABLE_REPLACEMENT)
        { "TraceReplacement",             OPT_TraceReplacement,             OPT_TYPE_VALUE,   "trace on-stack replacement with the given verbosity level (default: 1)" },
@@ -615,6 +645,30 @@ void options_xx(JavaVMInitArgs *vm_args)
 
                /* Debugging options which can be turned off. */
 
+               case OPT_AlwaysEmitLongBranches:
+                       opt_AlwaysEmitLongBranches = enable;
+                       break;
+
+               case OPT_AlwaysMmapFirstPage:
+                       opt_AlwaysMmapFirstPage = enable;
+                       break;
+
+               case OPT_CompileAll:
+                       opt_CompileAll = enable;
+                       opt_run = false;
+                       makeinitializations = false;
+                       break;
+
+               case OPT_CompileMethod:
+                       opt_CompileMethod = value;
+                       opt_run = false;
+                       makeinitializations = false;
+                       break;
+
+               case OPT_CompileSignature:
+                       opt_CompileSignature = value;
+                       break;
+
                case OPT_DebugExceptions:
                        opt_DebugExceptions = enable;
                        break;
@@ -707,6 +761,10 @@ void options_xx(JavaVMInitArgs *vm_args)
                        opt_PrintConfig = enable;
                        break;
 
+               case OPT_PrintWarnings:
+                       opt_PrintWarnings = enable;
+                       break;
+
                case OPT_ProfileGCMemoryUsage:
                        if (value == NULL)
                                opt_ProfileGCMemoryUsage = 5;
@@ -736,17 +794,27 @@ void options_xx(JavaVMInitArgs *vm_args)
                        file = fopen(filename, "w");
 
                        if (file == NULL)
-                               vm_abort_errno("options_xx: fopen failed");
+                               /* FIXME Use below method instead! */
+                               //os::abort_errno("options_xx: fopen failed");
+                               vm_abort("options_xx: fopen failed");
 
                        opt_ProfileMemoryUsageGNUPlot = file;
                        break;
 
+               case OPT_RegallocSpillAll:
+                       opt_RegallocSpillAll = enable;
+                       break;
+
 #if defined(ENABLE_REPLACEMENT)
                case OPT_TestReplacement:
                        opt_TestReplacement = enable;
                        break;
 #endif
 
+               case OPT_TraceBuiltinCalls:
+                       opt_TraceBuiltinCalls = enable;
+                       break;
+
                case OPT_TraceCompilerCalls:
                        opt_TraceCompilerCalls = enable;
                        break;
@@ -773,6 +841,10 @@ void options_xx(JavaVMInitArgs *vm_args)
                        opt_TraceJavaCalls = enable;
                        break;
 
+               case OPT_TraceJMMCalls:
+                       opt_TraceJMMCalls = enable;
+                       break;
+
                case OPT_TraceJNICalls:
                        opt_TraceJNICalls = enable;
                        break;
@@ -785,6 +857,12 @@ void options_xx(JavaVMInitArgs *vm_args)
                        opt_TraceJVMCallsVerbose = enable;
                        break;
 
+#if defined(ENABLE_JVMTI)
+               case OPT_TraceJVMTICalls:
+                       opt_TraceJVMTICalls = enable;
+                       break;
+#endif
+
                case OPT_TraceLinkClass:
                        opt_TraceLinkClass = enable;
                        break;
@@ -828,7 +906,7 @@ void options_xx(JavaVMInitArgs *vm_args)
 #endif
 
                default:
-                       printf("Unknown -XX option: %s\n", name);
+                       fprintf(stderr, "Unknown -XX option: %s\n", name);
                        break;
                }
        }