* src/mm/cacao-gc/rootset.c (rootset_readout): Ignore threads in state new.
[cacao.git] / src / native / tools / gennativetable.c
index 2daa62e0260a7d3d7ac32561a2d073b14ad41326..7a9fe1206be7948473a731787689b67f534ad1e8 100644 (file)
@@ -28,8 +28,6 @@
 
    Changes:
 
-   $Id: gennativetable.c 4921 2006-05-15 14:24:36Z twisti $
-
 */
 
 
@@ -43,7 +41,7 @@
 #include "vm/types.h"
 
 #include "cacaoh/headers.h"
-#include "mm/boehm.h"
+#include "mm/gc-common.h"
 #include "mm/memory.h"
 
 #if defined(ENABLE_THREADS)
@@ -56,6 +54,7 @@
 #include "vm/global.h"
 #include "vm/loader.h"
 #include "vm/options.h"
+#include "vm/stringlocal.h"
 #include "vm/suck.h"
 
 
@@ -64,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 ******************************************************/
 
@@ -86,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;
@@ -102,10 +107,12 @@ int main(int argc, char **argv)
        bool nativelyoverloaded;
 
 #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;
@@ -196,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 */
@@ -207,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++) {
@@ -221,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;
                                        }
                                }
 
@@ -279,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");
@@ -307,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