* src/mm/cacao-gc/rootset.c (rootset_readout): Ignore threads in state new.
[cacao.git] / src / native / tools / gennativetable.c
index fa3601c57a198526dbead91a7350b598d9106848..7a9fe1206be7948473a731787689b67f534ad1e8 100644 (file)
@@ -28,8 +28,6 @@
 
    Changes:
 
-   $Id: gennativetable.c 4879 2006-05-05 17:34:49Z edwin $
-
 */
 
 
 #include "vm/types.h"
 
 #include "cacaoh/headers.h"
-#include "mm/boehm.h"
+#include "mm/gc-common.h"
 #include "mm/memory.h"
 
-#if defined(USE_THREADS)
-# if defined(NATIVE_THREADS)
-#  include "threads/native/threads.h"
-# else
-#  include "threads/green/threads.h"
-# endif
+#if defined(ENABLE_THREADS)
+# include "threads/native/threads.h"
 #endif
 
 #include "toolbox/chain.h"
@@ -60,6 +54,7 @@
 #include "vm/global.h"
 #include "vm/loader.h"
 #include "vm/options.h"
+#include "vm/stringlocal.h"
 #include "vm/suck.h"
 
 
@@ -68,6 +63,8 @@
 #define HEAP_MAXSIZE      4 * 1024 * 1024   /* default 4MB                    */
 #define HEAP_STARTSIZE    100 * 1024        /* default 100kB                  */
 
+#define ACC_NATIVELY_OVERLOADED    0x10000000
+
 
 /* define cacaoh options ******************************************************/
 
@@ -90,8 +87,12 @@ opt_struct opts[] = {
 };
 
 
+static JavaVMInitArgs *gennativetable_options_prepare(int argc, char **argv);
+
+
 int main(int argc, char **argv)
 {
+       JavaVMInitArgs *vm_args;
        char *bootclasspath;
 
        chain *nativemethod_chain;
@@ -105,13 +106,13 @@ int main(int argc, char **argv)
        methodinfo *m2;
        bool nativelyoverloaded;
 
-       void *dummy;
-
 #if defined(DISABLE_GC)
-       nogc_init(HEAP_MAXSIZE, HEAP_STARTSIZE);
+       gc_init(HEAP_MAXSIZE, HEAP_STARTSIZE);
 #endif
 
-       while ((i = get_opt(argc, argv, opts)) != OPT_DONE) {
+       vm_args = gennativetable_options_prepare(argc, argv);
+
+       while ((i = options_get(opts, vm_args)) != OPT_DONE) {
                switch (i) {
                case OPT_IGNORE:
                        break;
@@ -145,12 +146,9 @@ int main(int argc, char **argv)
 
        gc_init(HEAP_MAXSIZE, HEAP_STARTSIZE);
 
-#if defined(USE_THREADS)
-#if defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
        threads_preinit();
 #endif
-       initLocks();
-#endif
 
        /* initialize the string hashtable stuff: lock (must be done
           _after_ threads_preinit) */
@@ -181,7 +179,7 @@ int main(int argc, char **argv)
        /* initialize the loader subsystems (must be done _after_
        classcache_init) */
 
-       if (!loader_init((u1 *) &dummy))
+       if (!loader_init())
                throw_main_exception_exit();
 
 
@@ -205,7 +203,7 @@ int main(int argc, char **argv)
                        for (clsen = nmen->classes; clsen; clsen = clsen->next) {
                                c = clsen->classobj;
 
-                               if (!c)
+                               if (c == NULL)
                                        continue;
 
                                /* find overloaded methods */
@@ -216,11 +214,7 @@ int main(int argc, char **argv)
                                        if (!(m->flags & ACC_NATIVE))
                                                continue;
 
-                                       /* ATTENTION: We use the methodinfo's isleafmethod
-                                          variable as nativelyoverloaded, so we can save
-                                          some space during runtime. */
-
-                                       if (!m->isleafmethod) {
+                                       if (!(m->flags & ACC_NATIVELY_OVERLOADED)) {
                                                nativelyoverloaded = false;
                                
                                                for (j = i + 1; j < c->methodscount; j++) {
@@ -230,12 +224,13 @@ int main(int argc, char **argv)
                                                                continue;
 
                                                        if (m->name == m2->name) {
-                                                               m2->isleafmethod = true;
-                                                               nativelyoverloaded = true;
+                                                               m2->flags          |= ACC_NATIVELY_OVERLOADED;
+                                                               nativelyoverloaded  = true;
                                                        }
                                                }
 
-                                               m->isleafmethod = nativelyoverloaded;
+                                               if (nativelyoverloaded == true)
+                                                       m->flags |= ACC_NATIVELY_OVERLOADED;
                                        }
                                }
 
@@ -288,11 +283,7 @@ int main(int argc, char **argv)
                fprintf(file, "_");
                printID(m->name);
         
-               /* ATTENTION: We use the methodinfo's isleafmethod variable as
-                  nativelyoverloaded, so we can save some space during
-                  runtime. */
-
-               if (m->isleafmethod)
+               if (m->flags & ACC_NATIVELY_OVERLOADED)
                        printOverloadPart(m->descriptor);
 
                fprintf(file,"\n   },\n");
@@ -316,6 +307,29 @@ int main(int argc, char **argv)
 }
 
 
+/* gennativetable_options_prepare **********************************************
+
+   Prepare the JavaVMInitArgs.
+
+*******************************************************************************/
+
+static JavaVMInitArgs *gennativetable_options_prepare(int argc, char **argv)
+{
+       JavaVMInitArgs *vm_args;
+       s4              i;
+
+       vm_args = NEW(JavaVMInitArgs);
+
+       vm_args->nOptions = argc - 1;
+       vm_args->options  = MNEW(JavaVMOption, argc);
+
+       for (i = 1; i < argc; i++)
+               vm_args->options[i - 1].optionString = argv[i];
+
+       return vm_args;
+}
+
+
 /*
  * These are local overrides for various environment variables in Emacs.
  * Please do not remove this and leave it at the end of the file, where