/* src/cacao/cacao.c - contains main() of cacao
- Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
- R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
- C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
- Institut f. Computersprachen - TU Wien
+ Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+ C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+ E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+ J. Wenninger, J. Wenninger, Institut f. Computersprachen - TU Wien
This file is part of CACAO.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
- Contact: cacao@complang.tuwien.ac.at
+ Contact: cacao@cacaojvm.org
Authors: Reinhard Grafl
- Calling the class loader
- Running the main method
- $Id: cacao.c 3940 2005-12-11 01:06:16Z twisti $
+ $Id: cacao.c 4357 2006-01-22 23:33:38Z twisti $
*/
+#include "config.h"
+
#include <assert.h>
#include <stdlib.h>
#include <string.h>
-#include "config.h"
+#include "vm/types.h"
+
#include "cacao/cacao.h"
#include "mm/boehm.h"
#include "mm/memory.h"
#include "vm/initialize.h"
#include "vm/loader.h"
#include "vm/options.h"
+#include "vm/properties.h"
#include "vm/signallocal.h"
#include "vm/statistics.h"
#include "vm/stringlocal.h"
JDK1_1InitArgs vm_args; /* JDK 1.1 VM initialization arguments */
-char *bootclasspath; /* contains the boot classpath */
-char *classpath; /* contains the classpath */
-
char *mainstring;
static classinfo *mainclass;
/* define command line options ************************************************/
-#define OPT_CLASSPATH 2
-#define OPT_D 3
-#define OPT_MS 4
-#define OPT_MX 5
-#define OPT_VERBOSE1 6
-#define OPT_VERBOSE 7
-#define OPT_VERBOSESPECIFIC 8
-#define OPT_VERBOSECALL 9
-#define OPT_NOIEEE 10
-#define OPT_SOFTNULL 11
-#define OPT_TIME 12
-
-#if defined(STATISTICS)
-#define OPT_STAT 13
-#endif /* defined(STATISTICS) */
-
-#define OPT_LOG 14
-#define OPT_CHECK 15
-#define OPT_LOAD 16
-#define OPT_METHOD 17
-#define OPT_SIGNATURE 18
-#define OPT_SHOW 19
-#define OPT_ALL 20
-#define OPT_OLOOP 24
-#define OPT_INLINING 25
+enum {
+ OPT_CLASSPATH,
+ OPT_D,
+ OPT_MS,
+ OPT_MX,
+ OPT_VERBOSE1,
+ OPT_VERBOSE,
+ OPT_VERBOSESPECIFIC,
+ OPT_VERBOSECALL,
+ OPT_NOIEEE,
+ OPT_SOFTNULL,
+ OPT_TIME,
+
+#if defined(ENABLE_STATISTICS)
+ OPT_STAT,
+#endif
+
+ OPT_LOG,
+ OPT_CHECK,
+ OPT_LOAD,
+ OPT_METHOD,
+ OPT_SIGNATURE,
+ OPT_SHOW,
+ OPT_ALL,
+ OPT_OLOOP,
+ OPT_INLINING,
#define STATIC_ANALYSIS
#if defined(STATIC_ANALYSIS)
-# define OPT_RT 26
-# define OPT_XTA 27
-# define OPT_VTA 28
-#endif /* defined(STATIC_ANALYSIS) */
+ OPT_RT,
+ OPT_XTA,
+ OPT_VTA,
+#endif
-#define OPT_VERBOSETC 29
-#define OPT_NOVERIFY 30
-#define OPT_LIBERALUTF 31
-#define OPT_VERBOSEEXCEPTION 32
-#define OPT_EAGER 33
+ OPT_VERBOSETC,
+ OPT_NOVERIFY,
+ OPT_LIBERALUTF,
+ OPT_VERBOSEEXCEPTION,
+ OPT_EAGER,
+
+#if defined(ENABLE_LSRA)
+ OPT_LSRA,
+#endif
-#if defined(LSRA)
-#define OPT_LSRA 34
-#endif /* defined(LSRA) */
+ OPT_JAR,
+ OPT_BOOTCLASSPATH,
+ OPT_BOOTCLASSPATH_A,
+ OPT_BOOTCLASSPATH_P,
+ OPT_VERSION,
+ OPT_SHOWVERSION,
+ OPT_FULLVERSION,
-#define OPT_JAR 35
-#define OPT_BOOTCLASSPATH 36
-#define OPT_BOOTCLASSPATH_A 37
-#define OPT_BOOTCLASSPATH_P 38
-#define OPT_VERSION 39
-#define OPT_SHOWVERSION 40
-#define OPT_FULLVERSION 41
+ OPT_HELP,
+ OPT_X,
-#define OPT_HELP 100
-#define OPT_X 101
+ OPT_JIT,
+ OPT_INTRP,
-#define OPT_JIT 102
-#define OPT_INTRP 103
+#if defined(ENABLE_INTRP)
+ /* interpreter options */
-#define OPT_STATIC_SUPERS 104
-#define OPT_TRACE 105
+ OPT_NO_DYNAMIC,
+ OPT_NO_REPLICATION,
+ OPT_NO_QUICKSUPER,
+ OPT_STATIC_SUPERS,
+ OPT_TRACE,
+#endif
-#define OPT_SS 106
+ OPT_SS,
#ifdef ENABLE_JVMTI
-#define OPT_DEBUG 107
-#define OPT_AGENTLIB 108
-#define OPT_AGENTPATH 109
-#endif
+ OPT_DEBUG,
+ OPT_AGENTLIB,
+ OPT_AGENTPATH,
+#endif
+
+ DUMMY
+};
-#define OPT_NO_DYNAMIC 110
opt_struct opts[] = {
{ "classpath", true, OPT_CLASSPATH },
#endif
{ "softnull", false, OPT_SOFTNULL },
{ "time", false, OPT_TIME },
-#if defined(STATISTICS)
+#if defined(ENABLE_STATISTICS)
{ "stat", false, OPT_STAT },
#endif
{ "log", true, OPT_LOG },
{ "xta", false, OPT_XTA },
{ "vta", false, OPT_VTA },
#endif
-#ifdef LSRA
+#if defined(ENABLE_LSRA)
{ "lsra", false, OPT_LSRA },
#endif
{ "jar", false, OPT_JAR },
{ "help", false, OPT_HELP },
{ "?", false, OPT_HELP },
+#if defined(ENABLE_INTRP)
/* interpreter options */
{ "trace", false, OPT_TRACE },
{ "static-supers", true, OPT_STATIC_SUPERS },
{ "no-dynamic", false, OPT_NO_DYNAMIC },
+ { "no-replication", false, OPT_NO_REPLICATION },
+ { "no-quicksuper", false, OPT_NO_QUICKSUPER },
+#endif
/* JVMTI Agent Command Line Options */
#ifdef ENABLE_JVMTI
printf(" -liberalutf don't warn about overlong UTF-8 sequences\n");
printf(" -softnull use software nullpointer check\n");
printf(" -time measure the runtime\n");
-#if defined(STATISTICS)
+#if defined(ENABLE_STATISTICS)
printf(" -stat detailed compiler statistics\n");
#endif
printf(" -log logfile specify a name for the logfile\n");
printf(" -xta use x type analysis\n");
printf(" -vta use variable type analysis\n");
#endif
-#ifdef LSRA
+#if defined(ENABLE_LSRA)
printf(" -lsra use linear scan register allocation\n");
#endif
printf("java version \""JAVA_VERSION"\"\n");
printf("CACAO version "VERSION"\n");
- printf("Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,\n");
- printf("R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,\n");
- printf("C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,\n");
- printf("Institut f. Computersprachen - TU Wien\n\n");
+ printf("Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,\n");
+ printf("C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,\n");
+ printf("E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,\n");
+ printf("J. Wenninger, Institut f. Computersprachen - TU Wien\n\n");
printf("This program is free software; you can redistribute it and/or\n");
printf("modify it under the terms of the GNU General Public License as\n");
if (!m)
throw_main_exception_exit();
- asm_calljavafunction(m, o, NULL, NULL, NULL);
+ ASM_CALLJAVAFUNCTION(m, o, NULL, NULL, NULL);
/* configure(transport,NULL) */
m = class_resolveclassmethod(
s = javastring_new_char(transport);
- asm_calljavafunction(m, o, s, NULL, NULL);
+
+ ASM_CALLJAVAFUNCTION(m, o, s, NULL, NULL);
+
if (!m)
throw_main_exception_exit();
if (!m)
throw_main_exception_exit();
- asm_calljavafunction(m, o, NULL, NULL, NULL);
+ ASM_CALLJAVAFUNCTION(m, o, NULL, NULL, NULL);
}
#endif
s = javastring_new_char(mainstring);
- asm_calljavafunction(m, o, s, NULL, NULL);
+ ASM_CALLJAVAFUNCTION(m, o, s, NULL, NULL);
if (*exceptionptr)
throw_main_exception_exit();
if (!m)
throw_main_exception_exit();
- o = asm_calljavafunction(m, o, NULL, NULL, NULL);
+ ASM_CALLJAVAFUNCTION_ADR(o, m, o, NULL, NULL, NULL);
if (!o) {
fprintf(stderr, "Could not get manifest from %s (invalid or corrupt jarfile?)\n", mainstring);
if (!m)
throw_main_exception_exit();
- o = asm_calljavafunction(m, o, NULL, NULL, NULL);
+ ASM_CALLJAVAFUNCTION_ADR(o, m, o, NULL, NULL, NULL);
if (!o) {
fprintf(stderr, "Could not get main attributes from %s (invalid or corrupt jarfile?)\n", mainstring);
s = javastring_new_char("Main-Class");
- o = asm_calljavafunction(m, o, s, NULL, NULL);
+ ASM_CALLJAVAFUNCTION_ADR(o, m, o, s, NULL, NULL);
if (!o)
throw_main_exception_exit();
/* set the bootclasspath */
cp = getenv("BOOTCLASSPATH");
+
if (cp) {
bootclasspath = MNEW(char, strlen(cp) + strlen("0"));
strcpy(bootclasspath, cp);
} else {
- cplen = strlen(CACAO_INSTALL_PREFIX) + strlen(CACAO_VM_ZIP_PATH) +
+ cplen = strlen(CACAO_VM_ZIP_PATH) +
strlen(":") +
- strlen(CLASSPATH_INSTALL_DIR) +
strlen(CLASSPATH_GLIBJ_ZIP_PATH) +
strlen("0");
bootclasspath = MNEW(char, cplen);
- strcpy(bootclasspath, CACAO_INSTALL_PREFIX);
strcat(bootclasspath, CACAO_VM_ZIP_PATH);
strcat(bootclasspath, ":");
- strcat(bootclasspath, CLASSPATH_INSTALL_DIR);
strcat(bootclasspath, CLASSPATH_GLIBJ_ZIP_PATH);
}
/* set the classpath */
cp = getenv("CLASSPATH");
+
if (cp) {
classpath = MNEW(char, strlen(cp) + strlen("0"));
strcat(classpath, cp);
heapstartsize = HEAP_STARTSIZE;
opt_stacksize = STACK_SIZE;
+ /* initialize properties before commandline handling */
+
+ if (!properties_init())
+ throw_cacao_exception_exit(string_java_lang_InternalError,
+ "Unable to init properties");
+
while ((i = get_opt(argc, argv, opts)) != OPT_DONE) {
switch (i) {
case OPT_IGNORE:
for (j = 0; j < strlen(opt_arg); j++) {
if (opt_arg[j] == '=') {
opt_arg[j] = '\0';
- create_property(opt_arg, opt_arg + j + 1);
+ properties_add(opt_arg, opt_arg + j + 1);
goto didit;
}
}
/* if no '=' is given, just create an empty property */
- create_property(opt_arg, "");
+
+ properties_add(opt_arg, "");
- didit: ;
+ didit:
+ ;
}
break;
getloadingtime = true;
break;
-#if defined(STATISTICS)
+#if defined(ENABLE_STATISTICS)
case OPT_STAT:
opt_stat = true;
break;
switch (opt_arg[j]) {
case 'n':
/* define in options.h; Used in main.c, jit.c & inline.c */
-#ifdef INAFTERMAIN
- useinliningm = true;
- useinlining = false;
-#else
- useinlining = true;
-#endif
+ /* inlining is currently deactivated */
break;
case 'v':
inlinevirtuals = true;
break;
#endif
-#ifdef LSRA
+#if defined(ENABLE_LSRA)
case OPT_LSRA:
opt_lsra = true;
break;
#endif
break;
+#if defined(ENABLE_INTRP)
case OPT_STATIC_SUPERS:
opt_static_supers = atoi(opt_arg);
break;
opt_no_dynamic = true;
break;
+ case OPT_NO_REPLICATION:
+ opt_no_replication = true;
+ break;
+
+ case OPT_NO_QUICKSUPER:
+ opt_no_quicksuper = true;
+ break;
+
case OPT_TRACE:
vm_debug = true;
break;
+#endif
default:
printf("Unknown option: %s\n", argv[opt_ind]);
if (!suck_init())
throw_main_exception_exit();
+ suck_add_from_property("java.endorsed.dirs");
suck_add(bootclasspath);
/* initialize the memory subsystem (must be done _after_
/* machine dependent initialization */
- md_init();
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+ if (opt_intrp)
+ intrp_md_init();
+ else
+# endif
+ md_init();
+#else
+ intrp_md_init();
+#endif
/* initialize the loader subsystems (must be done _after_
classcache_init) */
#endif
/* here we go... */
- asm_calljavafunction(m, a, NULL, NULL, NULL);
+ ASM_CALLJAVAFUNCTION(m, a, NULL, NULL, NULL);
/* exception occurred? */
+
if (*exceptionptr) {
throw_main_exception();
status = 1;
/* not sure if permanant or temp restriction */
if (inlinevirtuals) inlineoutsiders = false;
- asm_calljavafunction(m, (void *) (ptrint) status, NULL, NULL, NULL);
+ ASM_CALLJAVAFUNCTION(m, (void *) (ptrint) status, NULL, NULL, NULL);
/* this should never happen */
if (opt_verbose || getcompilingtime || opt_stat) {
log_text("CACAO terminated");
-#if defined(STATISTICS)
+#if defined(ENABLE_STATISTICS)
if (opt_stat) {
print_stats();
#ifdef TYPECHECK_STATISTICS