[vmkit-commits] [vmkit] r73028 - in /vmkit/trunk: ./ autoconf/ include/mvm/ include/mvm/Threads/ lib/JnJVM/Classpath/ lib/JnJVM/Compiler/ lib/JnJVM/VMCore/ lib/Mvm/Allocator/ lib/Mvm/BoehmGC/ lib/Mvm/CommonThread/ lib/Mvm/Compiler/ lib/Mvm/GCMmap2/ lib/Mvm/Runtime/ lib/N3/VMCore/ tools/jnjvm/ tools/n3-mono/ tools/n3-pnetlib/ tools/vmjc/ tools/vmkit/

Nicolas Geoffray nicolas.geoffray at lip6.fr
Sun Jun 7 07:01:13 PDT 2009


Author: geoffray
Date: Sun Jun  7 09:01:12 2009
New Revision: 73028

URL: http://llvm.org/viewvc/llvm-project?rev=73028&view=rev
Log:
Code cleanup in GCMmap2.
Add an optimization when tracing fields.


Removed:
    vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h
Modified:
    vmkit/trunk/autoconf/configure.ac
    vmkit/trunk/configure
    vmkit/trunk/include/mvm/Allocator.h
    vmkit/trunk/include/mvm/JIT.h
    vmkit/trunk/include/mvm/Object.h
    vmkit/trunk/include/mvm/PrintBuffer.h
    vmkit/trunk/include/mvm/Threads/Thread.h
    vmkit/trunk/include/mvm/VirtualMachine.h
    vmkit/trunk/lib/JnJVM/Classpath/ClasspathReflect.h
    vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp
    vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h
    vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
    vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h
    vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.h
    vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp
    vmkit/trunk/lib/Mvm/Allocator/gcchunk.h
    vmkit/trunk/lib/Mvm/BoehmGC/MvmGC.h
    vmkit/trunk/lib/Mvm/BoehmGC/gc.cpp
    vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp
    vmkit/trunk/lib/Mvm/Compiler/JIT.cpp
    vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h
    vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp
    vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp
    vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cpp
    vmkit/trunk/lib/Mvm/GCMmap2/gcthread.cpp
    vmkit/trunk/lib/Mvm/Runtime/Object.cpp
    vmkit/trunk/lib/N3/VMCore/MSCorlib.cpp
    vmkit/trunk/tools/jnjvm/Main.cpp
    vmkit/trunk/tools/n3-mono/Main.cpp
    vmkit/trunk/tools/n3-pnetlib/Main.cpp
    vmkit/trunk/tools/vmjc/vmjc.cpp
    vmkit/trunk/tools/vmkit/CommandLine.h
    vmkit/trunk/tools/vmkit/Launcher.cpp

Modified: vmkit/trunk/autoconf/configure.ac
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/autoconf/configure.ac?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/autoconf/configure.ac (original)
+++ vmkit/trunk/autoconf/configure.ac Sun Jun  7 09:01:12 2009
@@ -208,11 +208,11 @@
 else
   GC_LIBS=GCMmap2
   if test "x$gc" = "xmulti-mmap"; then
-    GC_FLAGS="-I\$(PROJ_SRC_ROOT)/lib/Mvm/GCMmap2 -DWITH_TRACER -DMULTIPLE_GC"
+    GC_FLAGS="-I\$(PROJ_SRC_ROOT)/lib/Mvm/GCMmap2 -DWITH_TRACER -DMULTIPLE_GC -I\$(PROJ_SRC_ROOT)/lib/Mvm/Allocator"
     AC_SUBST([GC_MULTI_MMAP], [1])
     AC_SUBST([GC_SINGLE_MMAP], [0])
   else
-    GC_FLAGS="-I\$(PROJ_SRC_ROOT)/lib/Mvm/GCMmap2 -DWITH_TRACER"
+    GC_FLAGS="-I\$(PROJ_SRC_ROOT)/lib/Mvm/GCMmap2 -DWITH_TRACER -I\$(PROJ_SRC_ROOT)/lib/Mvm/Allocator"
     AC_SUBST([GC_MULTI_MMAP], [0])
     AC_SUBST([GC_SINGLE_MMAP], [1])
   fi

Modified: vmkit/trunk/configure
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/configure?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/configure (original)
+++ vmkit/trunk/configure Sun Jun  7 09:01:12 2009
@@ -3932,13 +3932,13 @@
 else
   GC_LIBS=GCMmap2
   if test "x$gc" = "xmulti-mmap"; then
-    GC_FLAGS="-I\$(PROJ_SRC_ROOT)/lib/Mvm/GCMmap2 -DWITH_TRACER -DMULTIPLE_GC"
+    GC_FLAGS="-I\$(PROJ_SRC_ROOT)/lib/Mvm/GCMmap2 -DWITH_TRACER -DMULTIPLE_GC -I\$(PROJ_SRC_ROOT)/lib/Mvm/Allocator"
     GC_MULTI_MMAP=1
 
     GC_SINGLE_MMAP=0
 
   else
-    GC_FLAGS="-I\$(PROJ_SRC_ROOT)/lib/Mvm/GCMmap2 -DWITH_TRACER"
+    GC_FLAGS="-I\$(PROJ_SRC_ROOT)/lib/Mvm/GCMmap2 -DWITH_TRACER -I\$(PROJ_SRC_ROOT)/lib/Mvm/Allocator"
     GC_MULTI_MMAP=0
 
     GC_SINGLE_MMAP=1

Modified: vmkit/trunk/include/mvm/Allocator.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Allocator.h?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/include/mvm/Allocator.h (original)
+++ vmkit/trunk/include/mvm/Allocator.h Sun Jun  7 09:01:12 2009
@@ -16,50 +16,25 @@
 
 #include "llvm/Support/Allocator.h"
 
-#include "MvmGC.h"
 #include "mvm/Threads/Locks.h"
 
-#ifdef MULTIPLE_GC
-#define allocator_new(alloc, cl) collector_new(cl, alloc.GC)
-#else
-#define allocator_new(alloc, cl) gc_new(cl)
-#endif
+class VirtualTable;
 
 namespace mvm {
 
-class Allocator {
-private:
-#ifdef MULTIPLE_GC
-  Collector* GC;
-#endif
 
+class Allocator {
 public:
   
-#ifndef MULTIPLE_GC
-  void* allocateManagedObject(unsigned int sz, VirtualTable* VT) {
-    return gc::operator new(sz, VT);
-  }
-#else
-  void* allocateManagedObject(unsigned int sz, VirtualTable* VT) {
-    return gc::operator new(sz, VT, GC);
-  }
-#endif
+  void* allocateManagedObject(unsigned int sz, VirtualTable* VT);
   
-  void* allocatePermanentMemory(unsigned int sz) {
-    return malloc(sz); 
-  }
+  void* allocatePermanentMemory(unsigned int sz);
   
-  void freePermanentMemory(void* obj) {
-    return free(obj); 
-  }
+  void freePermanentMemory(void* obj);
   
-  void* allocateTemporaryMemory(unsigned int sz) {
-    return malloc(sz); 
-  }
+  void* allocateTemporaryMemory(unsigned int sz);
   
-  void freeTemporaryMemory(void* obj) {
-    return free(obj); 
-  }
+  void freeTemporaryMemory(void* obj);
 };
 
 class BumpPtrAllocator {

Modified: vmkit/trunk/include/mvm/JIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/JIT.h?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/include/mvm/JIT.h (original)
+++ vmkit/trunk/include/mvm/JIT.h Sun Jun  7 09:01:12 2009
@@ -185,6 +185,8 @@
   static void copyDefinitions(llvm::Module* Dst, llvm::Module* Src);
 
   static void AddStandardCompilePasses();
+
+  static const char* getHostTriple();
 };
 
 } // end namespace mvm

Modified: vmkit/trunk/include/mvm/Object.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Object.h?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/include/mvm/Object.h (original)
+++ vmkit/trunk/include/mvm/Object.h Sun Jun  7 09:01:12 2009
@@ -39,7 +39,7 @@
 
   /// tracer - Default implementation of tracer. Does nothing.
   ///
-  virtual void      TRACER {}
+  virtual void tracer() {}
 
   /// print - Default implementation of print.
   ///

Modified: vmkit/trunk/include/mvm/PrintBuffer.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/PrintBuffer.h?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/include/mvm/PrintBuffer.h (original)
+++ vmkit/trunk/include/mvm/PrintBuffer.h Sun Jun  7 09:01:12 2009
@@ -188,8 +188,8 @@
 
   /// tracer - Traces this PrintBuffer.
   ///
-  static void STATIC_TRACER(PrintBuffer) {
-    obj->contents()->MARK_AND_TRACE;
+  static void staticTracer(PrintBuffer* obj) {
+    obj->contents()->markAndTrace();
   }
 };
 

Modified: vmkit/trunk/include/mvm/Threads/Thread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Threads/Thread.h?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/include/mvm/Threads/Thread.h (original)
+++ vmkit/trunk/include/mvm/Threads/Thread.h Sun Jun  7 09:01:12 2009
@@ -12,9 +12,6 @@
 
 #include "types.h"
 
-#include "MvmGC.h"
-
-
 namespace mvm {
 
 class VirtualMachine;
@@ -173,7 +170,7 @@
   /// tracer - Does nothing. Used for child classes which may defined
   /// a tracer.
   ///
-  virtual void TRACER {}
+  virtual void tracer() {}
 
 
   /// clearException - Clear any pending exception of the current thread.

Modified: vmkit/trunk/include/mvm/VirtualMachine.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/VirtualMachine.h?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/include/mvm/VirtualMachine.h (original)
+++ vmkit/trunk/include/mvm/VirtualMachine.h Sun Jun  7 09:01:12 2009
@@ -16,8 +16,6 @@
 #define MVM_VIRTUALMACHINE_H
 
 #include "mvm/Allocator.h"
-#include "mvm/CompilationUnit.h"
-#include "mvm/Object.h"
 #include "mvm/Threads/Cond.h"
 #include "mvm/Threads/Locks.h"
 
@@ -29,6 +27,8 @@
   class JnjvmClassLoader;
 }
 
+class gc;
+
 namespace mvm {
 
 
@@ -36,6 +36,7 @@
 #define INITIAL_QUEUE_SIZE 256
 #define GROW_FACTOR 2
 
+class CompilationUnit;
 class VirtualMachine;
 
 class ReferenceQueue {
@@ -125,7 +126,7 @@
   }
 public:
 
-  virtual void TRACER {}
+  virtual void tracer() {}
 
   virtual ~VirtualMachine() {}
 

Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathReflect.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathReflect.h?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Classpath/ClasspathReflect.h (original)
+++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathReflect.h Sun Jun  7 09:01:12 2009
@@ -35,14 +35,14 @@
     return vmdata;
   }
 
-  static void STATIC_TRACER(JavaObjectClass) {
+  static void staticTracer(JavaObjectClass* obj) {
     JavaObjectTracer(obj);
-    obj->pd->MARK_AND_TRACE;
-    obj->signers->MARK_AND_TRACE;
-    obj->constructor->MARK_AND_TRACE;
+    obj->pd->markAndTrace();
+    obj->signers->markAndTrace();
+    obj->constructor->markAndTrace();
     if (obj->vmdata) {
       JavaObject* Obj = obj->vmdata->classLoader->getJavaClassLoader();
-      if (Obj) Obj->MARK_AND_TRACE;
+      if (Obj) Obj->markAndTrace();
     }
   }
 };
@@ -56,10 +56,10 @@
 
 public:
 
-  static void STATIC_TRACER(JavaObjectField) {
+  static void staticTracer(JavaObjectField* obj) {
     JavaObjectTracer(obj);
-    obj->name->MARK_AND_TRACE;
-    obj->declaringClass->MARK_AND_TRACE;
+    obj->name->markAndTrace();
+    obj->declaringClass->markAndTrace();
   }
 
   JavaField* getInternalField() {
@@ -81,10 +81,10 @@
 
 public:
   
-  static void STATIC_TRACER(JavaObjectMethod) {
+  static void staticTracer(JavaObjectMethod* obj) {
     JavaObjectTracer(obj);
-    obj->name->MARK_AND_TRACE;
-    obj->declaringClass->MARK_AND_TRACE;
+    obj->name->markAndTrace();
+    obj->declaringClass->markAndTrace();
   }
   
   JavaMethod* getInternalMethod() {
@@ -104,9 +104,9 @@
   uint32 slot;
 
 public:
-  static void STATIC_TRACER(JavaObjectConstructor) {
+  static void staticTracer(JavaObjectConstructor* obj) {
     JavaObjectTracer(obj);
-    obj->clazz->MARK_AND_TRACE;
+    obj->clazz->markAndTrace();
   }
   
   JavaMethod* getInternalMethod() {
@@ -169,9 +169,9 @@
   JavaObject* getReferent() const { return referent; }
   void setReferent(JavaObject* r) { referent = r; }
   
-  static void STATIC_TRACER(JavaObjectReference) {
-    obj->queue->MARK_AND_TRACE;
-    obj->nextOnQueue->MARK_AND_TRACE;
+  static void staticTracer(JavaObjectReference* obj) {
+    obj->queue->markAndTrace();
+    obj->nextOnQueue->markAndTrace();
   }
 };
 

Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp Sun Jun  7 09:01:12 2009
@@ -132,7 +132,7 @@
 ) {
   BEGIN_NATIVE_EXCEPTION(0)
   
-  Collector::collect();
+  mvm::Collector::collect();
 
   END_NATIVE_EXCEPTION
 }
@@ -189,7 +189,7 @@
 jclass clazz,
 #endif
 ) {
-  return (jlong)Collector::getFreeMemory();
+  return (jlong)mvm::Collector::getFreeMemory();
 }
 
 JNIEXPORT jlong Java_java_lang_VMRuntime_totalMemory(
@@ -198,7 +198,7 @@
 jclass clazz,
 #endif
 ) {
-  return (jlong)Collector::getTotalMemory();
+  return (jlong)mvm::Collector::getTotalMemory();
 }
 
 JNIEXPORT jlong Java_java_lang_VMRuntime_maxMemory(
@@ -207,7 +207,7 @@
 jclass clazz,
 #endif
 ) {
-  return (jlong)Collector::getMaxMemory();
+  return (jlong)mvm::Collector::getMaxMemory();
 }
 
 JNIEXPORT jint Java_java_lang_VMRuntime_availableProcessors(){

Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp Sun Jun  7 09:01:12 2009
@@ -246,7 +246,7 @@
   llvm::llvm_shutdown_obj X;  
    
   mvm::MvmModule::initialise();
-  Collector::initialise(0);
+  mvm::Collector::initialise();
  
   char** newArgv = new char*[argc + 1];
   memcpy(newArgv + 1, argv, argc * sizeof(void*));

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h Sun Jun  7 09:01:12 2009
@@ -266,7 +266,7 @@
 
   /// tracer - The tracer of this GC-allocated class.
   ///
-  void TRACER;
+  void tracer();
   
   /// inheritName - Does this class in its class hierarchy inherits
   /// the given name? Equality is on the name. This function does not take
@@ -619,7 +619,7 @@
   
   /// tracer - Tracer function of instances of Class.
   ///
-  void TRACER;
+  void tracer();
   
   ~Class();
   Class();

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h Sun Jun  7 09:01:12 2009
@@ -109,7 +109,7 @@
 
   /// tracer - Traces GC-objects pointed by this thread object.
   ///
-  virtual void TRACER;
+  virtual void tracer();
 
   /// JavaThread - Empty constructor, used to get the VT.
   ///

Modified: vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp Sun Jun  7 09:01:12 2009
@@ -1307,7 +1307,7 @@
 
 // Helper function to run Jnjvm without JIT.
 extern "C" int StartJnjvmWithoutJIT(int argc, char** argv, char* mainClass) {
-  Collector::initialise(0);
+  mvm::Collector::initialise();
   
   char** newArgv = new char*[argc + 1];
   memcpy(newArgv + 1, argv, argc * sizeof(char*));

Modified: vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h Sun Jun  7 09:01:12 2009
@@ -176,7 +176,7 @@
   
   /// tracer - Traces instances of this class.
   ///
-  virtual void TRACER;
+  virtual void tracer();
   
   /// dirSeparator - Directory separator for file paths, e.g. '\' for windows,
   /// '/' for Unix.

Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.h?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.h Sun Jun  7 09:01:12 2009
@@ -131,7 +131,7 @@
 
   /// tracer - Traces a JnjvmClassLoader for GC.
   ///
-  virtual void TRACER;
+  virtual void tracer();
   
   /// getJnjvmLoaderFromJavaObject - Return the Jnjvm runtime representation
   /// of the given class loader.
@@ -313,7 +313,7 @@
   
   /// tracer - Traces instances of this class.
   ///
-  virtual void TRACER;
+  virtual void tracer();
 
   /// libClasspathEnv - The paths for dynamic libraries of Classpath, separated
   /// by ':'.
@@ -433,8 +433,8 @@
   static VirtualTable VT;
 
   /// TRACER - Trace the internal class loader.
-  static void STATIC_TRACER(VMClassLoader) {
-    if (obj->JCL) obj->JCL->CALL_TRACER;
+  static void staticTracer(VMClassLoader* obj) {
+    if (obj->JCL) obj->JCL->tracer();
   }
 
   /// ~VMClassLoader - Delete the internal class loader.

Modified: vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp Sun Jun  7 09:01:12 2009
@@ -99,7 +99,7 @@
   LockObj* l = obj->lockObj();
   if (l) l->markAndTrace();
   for (sint32 i = 0; i < obj->size; i++) {
-    if (obj->elements[i]) obj->elements[i]->MARK_AND_TRACE;
+    if (obj->elements[i]) obj->elements[i]->markAndTrace();
   } 
 }
 

Modified: vmkit/trunk/lib/Mvm/Allocator/gcchunk.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Allocator/gcchunk.h?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/Allocator/gcchunk.h (original)
+++ vmkit/trunk/lib/Mvm/Allocator/gcchunk.h Sun Jun  7 09:01:12 2009
@@ -72,6 +72,14 @@
  		p->_next = this;
  		_next->_prev = this;
  	}
+	
+  /* ajoute this à p */
+ 	inline void prepend(GCChunkNode *p) {
+ 		_next = p;
+    _prev = p->_prev;
+    p->_prev = this;
+    _prev->_next = this;
+ 	}
 
 	/* enleve this de sa liste */
  	inline void remove() {

Modified: vmkit/trunk/lib/Mvm/BoehmGC/MvmGC.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/BoehmGC/MvmGC.h?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/BoehmGC/MvmGC.h (original)
+++ vmkit/trunk/lib/Mvm/BoehmGC/MvmGC.h Sun Jun  7 09:01:12 2009
@@ -76,16 +76,9 @@
 class Collector {
 public:
 
-  typedef void (*markerFn)(void*);
-  
-  static void initialise(markerFn mark);
+  static void initialise();
   static void destroy() {}
 
-  static void die_if_sigsegv_occured_during_collection(void *addr){}
-  static int isStable(gc_lock_recovery_fct_t, int, int, int, int,
-                                 int, int, int, int) { 
-    return 1;
-  }
   static unsigned int enable(unsigned int n) {
     int old = GC_dont_gc;
     if(n)

Modified: vmkit/trunk/lib/Mvm/BoehmGC/gc.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/BoehmGC/gc.cpp?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/BoehmGC/gc.cpp (original)
+++ vmkit/trunk/lib/Mvm/BoehmGC/gc.cpp Sun Jun  7 09:01:12 2009
@@ -16,7 +16,7 @@
   GC_init();
 }
 
-void Collector::initialise(markerFn mark) {
+void Collector::initialise() {
   GC_INIT();
 }
 

Modified: vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp (original)
+++ vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp Sun Jun  7 09:01:12 2009
@@ -7,6 +7,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "MvmGC.h"
 #include "mvm/VirtualMachine.h"
 #include "mvm/Threads/Cond.h"
 #include "mvm/Threads/Locks.h"

Modified: vmkit/trunk/lib/Mvm/Compiler/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/JIT.cpp?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original)
+++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Sun Jun  7 09:01:12 2009
@@ -18,6 +18,7 @@
 #include <llvm/Type.h>
 #include <llvm/Analysis/LoopPass.h>
 #include <llvm/Analysis/Verifier.h>
+#include <llvm/Config/config.h>
 #include <llvm/ExecutionEngine/ExecutionEngine.h>
 #include <llvm/Support/MutexGuard.h>
 #include <llvm/Target/TargetData.h>
@@ -25,9 +26,7 @@
 #include <llvm/Target/TargetOptions.h>
 
 
-#include "mvm/CompilationUnit.h"
 #include "mvm/JIT.h"
-#include "mvm/Object.h"
 #include "mvm/Threads/Locks.h"
 #include "mvm/Threads/Thread.h"
 
@@ -41,6 +40,11 @@
   }
 }
 
+const char* MvmModule::getHostTriple() {
+  return LLVM_HOSTTRIPLE;
+}
+
+
 void MvmModule::initialise(CodeGenOpt::Level level, Module* M,
                            TargetMachine* T) {
   llvm::NoFramePointerElim = true;

Modified: vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h Sun Jun  7 09:01:12 2009
@@ -11,83 +11,352 @@
 #ifndef MVM_MMAP_GC_H
 #define MVM_MMAP_GC_H
 
+#include "mvm/Config/config.h"
 #include <sys/types.h>
 #include "mvm/GC/GC.h"
 #include "types.h"
+#include "gcalloc.h"
+#include "gcthread.h"
 
 #define gc_allocator std::allocator
 #define gc_new(Class)  __gc_new(Class::VT) Class
 #define __gc_new new
 
 
-#ifdef MULTIPLE_GC
-#define STATIC_TRACER(type) staticTracer(type* obj, void* GC)
-#define TRACER tracer(void* GC)
-#define CALL_TRACER tracer(GC)
-#define MARK_AND_TRACE markAndTrace((Collector*)GC)
-#else
-#define STATIC_TRACER(type) staticTracer(type* obj)
 #define TRACER tracer()
-#define CALL_TRACER tracer()
 #define MARK_AND_TRACE markAndTrace()
-#endif
+#define CALL_TRACER tracer()
 
 namespace mvm {
   class Thread;
 }
 
-class Collector;
 
-class gc : public gcRoot {
+
+
+namespace mvm {
+
+class Collector {
+#ifdef HAVE_PTHREAD
+  friend class GCThread;
+#endif
+  static GCAllocator  *allocator;      /* The allocator */
+
+
+  static GCChunkNode  *used_nodes;     /* Used memory nodes */
+  static GCChunkNode  *unused_nodes;   /* Unused memory nodes */
+  static unsigned int   current_mark;
+
+  static int  _collect_freq_auto;      /* Collection frequency in gcmalloc/gcrealloc */
+  static int  _collect_freq_maybe;     /* Collection frequency  in maybeCollect */
+  static int  _since_last_collection;  /* Bytes left since last collection */
+  static bool _enable_auto;            /* Automatic collection? */
+  static bool _enable_maybe;           /* Collection in maybeCollect()? */
+  static bool _enable_collection;      /* collection authorized? */
+  static int  status;
+  
+  
+  enum { stat_collect, stat_finalize, stat_alloc, stat_broken };
+
+#ifdef HAVE_PTHREAD
+  static void  siggc_handler(int);
+  static inline void  lock()   { threads->lock(); }
+  static inline void  unlock() { threads->unlock(); }
+#else
+  static void  siggc_handler(int) { }
+  static inline void  lock()   { }
+  static inline void  unlock() { }
+#endif
+  
+  /* Interface for collection, verifies enable_collect */
+  static void collect_unprotect();    
+  /* The collection */  
+  static void do_collect();           
+
+  static inline GCChunkNode *o2node(const void *p) {
+    if (!p) return 0;
+    return GCHash::get((void*)p)->o2node((void*)p, GCChunkNode::maskCollectable);
+  }
+
+  static inline size_t real_nbb(GCChunkNode *n) { 
+    return n->nbb() - sizeof(gc_header);
+  }
+
 public:
- 
-#ifndef MULTIPLE_GC
-  void    markAndTrace() const;
-  size_t  objectSize() const;
-  void *  operator new(size_t sz, VirtualTable *VT);
-  void *  operator new(size_t sz);
-  void    operator delete(void *);
-  void *  realloc(size_t n);
+  static GCThread *threads;        /* le gestionnaire de thread et de synchro */
+  static void (*internMemoryError)(unsigned int);
 
+  static bool isLive(void* ptr) {
+    GCChunkNode *node = o2node(ptr);
+    
+    if(node && isMarked(node)) return true;
+    else return false;
+  }
+
+  static void initialise();
+  static void destroy();
+
+  static int siggc();
+
+  static void inject_my_thread(mvm::Thread* th);
+  static inline void  remove_my_thread(mvm::Thread* th) {
+    threads->remove(th);
+  }
+
+  static inline void *allocate_unprotected(size_t sz) {
+    return allocator->alloc(sz);
+  }
+  
+  static inline void  free_unprotected(void *ptr) {
+    allocator->free(ptr);
+  }
+
+  static inline void *begOf(const void *p) {
+    GCChunkNode *node = o2node(p);
+    if(node)
+      return node->chunk()->_2gc();
+    else
+      return 0;
+  }
+
+  static void gcStats(size_t *no, size_t *nbb);
+
+  static inline size_t objectSize(void *ptr) {
+    GCChunkNode *node = o2node(ptr);
+    return node ? real_nbb(node) : 0;
+  }
+
+  static inline void collect() {
+    lock();
+    collect_unprotect();
+    unlock();
+  }
+
+  static inline void maybeCollect() {
+    if(_enable_auto && 
+#ifdef SERVICE
+       (mvm::Thread::get()->MyVM->_since_last_collection <= (_collect_freq_auto - _collect_freq_maybe))
 #else
-  void    markAndTrace(Collector* GC) const;
-  size_t  objectSize(Collector* GC) const;
-  void *  operator new(size_t sz, VirtualTable *VT, Collector* GC);
-  void *  operator new(size_t sz, Collector* GC);
-  void    operator delete(void *, Collector* GC);
-  void *  realloc(size_t n, Collector* GC);
+       (_since_last_collection <= (_collect_freq_auto - _collect_freq_maybe))
 #endif
+      )
+      collect(); 
+  }
+
+  static inline void *gcmalloc(VirtualTable *vt, size_t n) {
+#if (__WORDSIZE == 64)
+    void* res = malloc(n);
+    memset(res, 0, n);
+    ((void**)res)[0] = vt;
+    return res;
+#else
+    lock();
+
+#ifdef SERVICE
+    if (threads->get_nb_threads()) {
+      VirtualMachine* vm = mvm::Thread::get()->MyVM;
+      vm->_since_last_collection -= n;
+      if (_enable_auto && (vm->_since_last_collection <= 0)) {
+        vm->gcTriggered++;
+        if (vm->gcTriggered > vm->GCLimit) {
+          vm->_since_last_collection += n;
+          unlock();
+          vm->stopService();
+          return 0;
+        }
+        collect_unprotect();
+      }
+      
+      if (vm->memoryUsed + n > vm->memoryLimit) {
+        vm->_since_last_collection += n;
+        unlock();
+        vm->stopService();
+        return 0;
+      }
+    } else {
+#endif
+    
+    _since_last_collection -= n;
+    if(_enable_auto && (_since_last_collection <= 0)) {
+      collect_unprotect();
+    }
+#ifdef SERVICE
+    }
+#endif
+    register GCChunkNode *header = allocator->alloc_chunk(n, 1, current_mark & 1);
+
+#ifdef SERVICE
+    if (threads->get_nb_threads()) {
+      VirtualMachine* vm = mvm::Thread::get()->MyVM;
+      header->meta = vm;
+      vm->memoryUsed += n;
+    }
+#endif
+    header->append(used_nodes);
+    //printf("Allocate %d bytes at %p [%p] %d %d\n", n, header->chunk()->_2gc(),
+    //       header, header->nbb(), real_nbb(header));
+    register struct gc_header *p = header->chunk();
+    p->_XXX_vt = vt;
+
+
+    unlock();
+
+    if (vt->destructor) {
+      mvm::Thread::get()->MyVM->addFinalizationCandidate((gc*)p->_2gc());
+    }
+
+    return p->_2gc();
+#endif
+  }
+
+  static inline void *gcrealloc(void *ptr, size_t n) {
+#if (__WORDSIZE == 64)
+    void* res = realloc(ptr, n);
+    return res;
+#else
+    lock();
+    
+    GCPage      *desc = GCHash::get(ptr);
+    GCChunkNode  *node = desc->o2node(ptr, GCChunkNode::maskCollectable);
+
+    if(!node)
+      gcfatal("%p isn't a avalid object", ptr);
+
+    size_t      old_sz = node->nbb();
+#ifdef SERVICE
+    if (threads->get_nb_threads()) {
+      VirtualMachine* vm = mvm::Thread::get()->MyVM;
+      vm->_since_last_collection -= (n - old_sz);
+      if (_enable_auto && (vm->_since_last_collection <= 0)) {
+        if (vm->gcTriggered + 1 > vm->GCLimit) {
+          unlock();
+          vm->stopService();
+          return 0;
+        }
+        vm->gcTriggered++;
+        collect_unprotect();
+      }
+      
+      if (vm->memoryUsed + (n - old_sz) > vm->memoryLimit) {
+        vm->_since_last_collection += (n - old_sz);
+        unlock();
+        vm->stopService();
+        return 0;
+      }
+    } else {
+#endif
+    
+    _since_last_collection -= (n - old_sz);
+
+    if(_enable_auto && (_since_last_collection <= 0)) {
+      collect_unprotect();
+    }
+
+#ifdef SERVICE
+    }
+#endif
+
+    GCChunkNode  *res = allocator->realloc_chunk(desc, node, n);
+
+#ifdef SERVICE
+    if (threads->get_nb_threads()) {
+      VirtualMachine* vm = mvm::Thread::get()->MyVM;
+      res->meta = vm;
+      vm->memoryUsed += (n - old_sz);
+    }
+#endif
+
+    if(res != node) {
+      res->append(used_nodes);
+      mark(res);
+    }
+
+    gc_header *obj = res->chunk();
+
+    unlock();
+    return obj->_2gc();
+#endif
+  }
+
+  static inline unsigned int enable(unsigned int n)  {
+    register unsigned int old = _enable_collection;
+    _enable_collection = n; 
+    return old;
+  }
+
+  static inline bool isMarked(GCChunkNode *node) { 
+    return node->mark() == (current_mark & 1);
+  }
+  
+  static inline void mark(GCChunkNode *node) {
+    node->_mark(current_mark & 1);
+  }
+
+  static inline void trace(GCChunkNode *node) {
+    gc_header *o = node->chunk();
+    o->_2gc()->tracer();
+  }
+
+  static inline void markAndTrace(void *ptr) {
+    GCChunkNode *node = o2node(ptr);
+
+    if(node && !isMarked(node)) {
+      mark(node);
+      node->remove();
+      node->prepend(used_nodes);
+    }
+  }
+
+  static int getMaxMemory() {
+    return 0;
+  }
+  
+  static int getFreeMemory() {
+    return 0;
+  }
+  
+  static int getTotalMemory() {
+    return 0;
+  }
+
+  void setMaxMemory(size_t sz){
+  }
+
+  void setMinMemory(size_t sz){
+  }
 
 };
 
-class Collector {
+}
+
+
+class gc : public gcRoot {
 public:
-  typedef void (*markerFn)(void*);
-  
-  static void  initialise(markerFn mark);
-  static void  destroy();
+ 
+  void markAndTrace() const {
+    mvm::Collector::markAndTrace((void*)this);
+  }
+
+  size_t objectSize() const {
+    return mvm::Collector::objectSize((void*)this);
+  }
+
+  void* operator new(size_t sz, VirtualTable *VT) {
+    return mvm::Collector::gcmalloc(VT, sz);
+  }
+
+  void* operator new(size_t sz) {
+    return malloc(sz);
+  }
+
+  void operator delete(void *) {
+    gcfatal(0, "never call directly a destructor.....");
+  }
+
+  void* realloc(size_t n) {
+    return mvm::Collector::gcrealloc(this, n);
+  }
 
-  static void           die_if_sigsegv_occured_during_collection(void *addr);
-  static int            isStable(gc_lock_recovery_fct_t, int, int, int, int,
-                                 int, int, int, int);
-  static unsigned int   enable(unsigned int n);
-  static void           gcStats(size_t &no, size_t &nbb);
-  static void           maybeCollect();
-  static void           collect(void);
-  static void           inject_my_thread(mvm::Thread* th);
-  static void           remove_my_thread(mvm::Thread* th);
-
-  static bool           isLive(void* ptr);
-  static gc             *begOf(const void *o);
-  static int            byteOffset(void *o);
-  inline static bool    isObject(const void *o) { return begOf((void*)o); }
-        static void     applyFunc(void (*func)(gcRoot *o, void *data), void *data);
-        static void     registerMemoryError(void (*func)(unsigned int));
-        static int      getMaxMemory(void);
-        static int      getFreeMemory(void);
-        static int      getTotalMemory(void);
-        static void     setMaxMemory(size_t);
-        static void     setMinMemory(size_t);
 };
 
 #endif

Modified: vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp Sun Jun  7 09:01:12 2009
@@ -11,195 +11,42 @@
 #include <cstdlib>
 
 #include "mvm/GC/GC.h"
-#include "gccollector.h"
+#include "MvmGC.h"
 #include "gcerror.h"
 
 using namespace mvm;
 
 
-typedef void (*memoryError_t)(unsigned int);
-
-memoryError_t GCCollector::internMemoryError;
-
-#ifndef MULTIPLE_GC
-
-void gc::markAndTrace() const {
-  GCCollector::markAndTrace((void*)this);
-}
-
 extern "C" void MarkAndTrace(gc* gc) {
-  GCCollector::markAndTrace((void*)gc);
+  Collector::markAndTrace((void*)gc);
 }
 
-extern "C" gc* gcmalloc(size_t sz, VirtualTable* VT) {
-  return (gc*)GCCollector::gcmalloc(VT, sz);
-}
-
-size_t gc::objectSize() const {
-  return GCCollector::objectSize((gc*)this);
-}
-
-void *gc::operator new(size_t sz, VirtualTable *vt) {
-  return GCCollector::gcmalloc(vt, sz);
-}
-
-void *gc::operator new(size_t sz) {
-  return malloc(sz);
-}
-
-void gc::operator delete(void *) { 
-  gcfatal(0, "never call directly a destructor....."); 
-}
-
-void *gc::realloc(size_t n) {
-  return GCCollector::gcrealloc(this, n);
-}
-
-#else
-
-void gc::markAndTrace(Collector* GC) const {
-  ((GCCollector*)GC)->markAndTrace((void*)this);
-}
-
-extern "C" void MarkAndTrace(gc* gc, Collector* GC) {
-  ((GCCollector*)GC)->markAndTrace((void*)gc);
-}
-
-extern "C" gc* gcmalloc(size_t sz, VirtualTable* VT, Collector* GC) {
-  return (gc*)((GCCollector*)GC)->gcmalloc(VT, sz);
-}
-
-size_t gc::objectSize(Collector* GC) const {
-  return ((GCCollector*)GC)->objectSize((gc*)this);
-}
-
-void *gc::operator new(size_t sz, VirtualTable *VT, Collector* GC) {
-  return ((GCCollector*)GC)->gcmalloc(VT, sz);
-}
-
-void *gc::operator new(size_t sz, Collector* GC) {
-  return malloc(sz);
-}
-
-void gc::operator delete(void *, Collector* GC) {
-  gcfatal(0, "never call directly a destructor....."); 
-}
-
-void *gc::realloc(size_t n, Collector* GC) {
-  return ((GCCollector*)GC)->gcrealloc(this, n);
-}
-#endif
-
-unsigned int Collector::enable(unsigned int n) {
-   return GCCollector::enable(n);
-}
-
-int Collector::isStable(gc_lock_recovery_fct_t fct, int a0, int a1, int a2, 
-                        int a3, int a4, int a5, int a6, int a7) {
-  return GCCollector::isStable(fct, a0, a1, a2, a3, a4, a5, a6, a7);
-}
-
-void Collector::die_if_sigsegv_occured_during_collection(void *addr) {
-  GCCollector::die_if_sigsegv_occured_during_collection(addr);
-}
-
-void Collector::gcStats(size_t &no, size_t &nbb) {
-  GCCollector::gcStats(&no, &nbb);
-}
-
-void Collector::initialise(markerFn marker) {
-  GCCollector::initialise(marker);
-}
-
-void Collector::destroy() {
-  GCCollector::destroy();
-}
-
-void Collector::inject_my_thread(mvm::Thread* th) {
-#ifdef HAVE_PTHREAD
-  GCCollector::inject_my_thread(th);
-#endif
-}
-
-void Collector::maybeCollect() {
-   GCCollector::maybeCollect();
-}
-
-void Collector::collect(void) {
-   GCCollector::collect();
-}
-
-gc *Collector::begOf(const void *obj) {
-  return (gc*)GCCollector::begOf((void*)obj);
-}
-
-int Collector::byteOffset(void *obj) {
-  int beg = (intptr_t)GCCollector::begOf(obj);
-  intptr_t off = (intptr_t)obj;
-  return (off-beg);
-}
-
-bool Collector::isLive(void* ptr) {
-  return GCCollector::isLive(ptr);
-}
-
-void Collector::applyFunc(void (*func)(gcRoot *o, void *data), void *data) {
-  return GCCollector::applyFunc(func, data);
-}
-
-int Collector::getMaxMemory(void){
-  return 0;
-}
-
-int Collector::getFreeMemory(void){
-  return 0;
-}
-
-int Collector::getTotalMemory(void){
-  return 0;
-}
-
-void Collector::setMaxMemory(size_t sz){
-}
-
-void Collector::setMinMemory(size_t sz){
-}
-
-void Collector::registerMemoryError(void (*func)(unsigned int)){
-  GCCollector::internMemoryError = func;
-  //onMemoryError = &GCCollector::defaultMemoryError;
-}
-
-void Collector::remove_my_thread(mvm::Thread* th) {
-#ifdef HAVE_PTHREAD
-  GCCollector::remove_thread(th);
-#endif
+extern "C" void* gcmalloc(size_t sz, VirtualTable* VT) {
+  return Collector::gcmalloc(VT, sz);
 }
 
 void GCThread::waitCollection() {
   mvm::Thread* th = mvm::Thread::get();
-  unsigned int cm = GCCollector::current_mark;
+  unsigned int cm = Collector::current_mark;
 
   if(th != current_collector) {
     collectorGo();
-    while((GCCollector::current_mark == cm) && 
-          (GCCollector::status == GCCollector::stat_collect))
+    while((Collector::current_mark == cm) && 
+          (Collector::status == Collector::stat_collect))
       _collectionCond.wait(&_stackLock);
   }
 }
 
-#ifdef HAVE_PTHREAD
-
-void GCCollector::siggc_handler(int) {
+void Collector::siggc_handler(int) {
   mvm::Thread* th = mvm::Thread::get();
 
   jmp_buf buf;
   setjmp(buf);
   
-  GCCollector::threads->stackLock();
+  Collector::threads->stackLock();
   
   if(!th) /* The thread is being destroyed */
-    GCCollector::threads->another_mark();
+    Collector::threads->another_mark();
   else {
     register unsigned int  **cur = (unsigned int**)(void*)&buf;
     register unsigned int  **max = (unsigned int**)th->baseSP;
@@ -207,16 +54,15 @@
     GCChunkNode *node;
     
     for(; cur<max; cur++) {
-      if((node = o2node(*cur)) && (!GCCollector::isMarked(node))) {
+      if((node = o2node(*cur)) && (!Collector::isMarked(node))) {
         node->remove();
-        node->append(GCCollector::used_nodes);
-        GCCollector::mark(node);
+        node->append(Collector::used_nodes);
+        Collector::mark(node);
       }
     }
     
-    GCCollector::threads->another_mark();
-    GCCollector::threads->waitCollection();
+    Collector::threads->another_mark();
+    Collector::threads->waitCollection();
   }
-  GCCollector::threads->stackUnlock();
+  Collector::threads->stackUnlock();
 }
-#endif // HAVE_PTHREAD

Modified: vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp Sun Jun  7 09:01:12 2009
@@ -7,37 +7,32 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "gccollector.h"
+#include "MvmGC.h"
 
 using namespace mvm;
 
-GCAllocator   *GCCollector::allocator = 0;
+GCAllocator   *Collector::allocator = 0;
 #ifdef HAVE_PTHREAD
-GCThread      *GCCollector::threads;
+GCThread      *Collector::threads;
 #endif
 
-GCCollector::markerFn   GCCollector::_marker;
 
+int           Collector::status;
 
-int           GCCollector::status;
+GCChunkNode    *Collector::used_nodes;
+GCChunkNode    *Collector::unused_nodes;
 
-GCChunkNode    *GCCollector::used_nodes;
-GCChunkNode    *GCCollector::unused_nodes;
+unsigned int   Collector::current_mark;
 
-unsigned int   GCCollector::current_mark;
+int  Collector::_collect_freq_auto;
+int  Collector::_collect_freq_maybe;
+int  Collector::_since_last_collection;
 
-int  GCCollector::_collect_freq_auto;
-int  GCCollector::_collect_freq_maybe;
-int  GCCollector::_since_last_collection;
+bool Collector::_enable_auto;
+bool Collector::_enable_maybe;
+bool Collector::_enable_collection;
 
-bool GCCollector::_enable_auto;
-bool GCCollector::_enable_maybe;
-bool GCCollector::_enable_collection;
-
-typedef void (*destructor_t)(void*);
-
-void GCCollector::do_collect() {
-  //printf("----- do collect -----\n");
+void Collector::do_collect() {
   GCChunkNode  *cur;
 #ifdef SERVICE
   mvm::Thread::get()->MyVM->_since_last_collection = _collect_freq_auto;
@@ -52,9 +47,7 @@
   mvm::Thread* th = mvm::Thread::get();
   th->MyVM->startCollection();
 
-#ifdef HAVE_PTHREAD
   threads->synchronize();
-#endif
 
   mvm::Thread* tcur = th;
 
@@ -83,59 +76,36 @@
   // (7) Trace the phantom reference queue.
   th->MyVM->scanPhantomReferencesQueue();
 
-  if(_marker)
-    _marker(0);
   status = stat_finalize;
 
   /* finalize */
   GCChunkNode  finalizable;
   finalizable.attrape(unused_nodes);
 
-  status = stat_alloc;
   
   /* kill everyone */
   GCChunkNode *next = 0;
   for(cur=finalizable.next(); cur!=&finalizable; cur=next) {
-    //printf("    !!!! reject %p [%p]\n", cur->chunk()->_2gc(), cur);
     next = cur->next();
     allocator->reject_chunk(cur);
   }
 
+  status = stat_alloc;
 
   th->MyVM->endCollection();
-#ifdef HAVE_PTHREAD
   threads->collectionFinished();
-#endif
   th->MyVM->wakeUpFinalizers();
   th->MyVM->wakeUpEnqueue();
 }
 
-void GCCollector::collect_unprotect() {
+void Collector::collect_unprotect() {
   if(_enable_collection && (status == stat_alloc)) {
     status = stat_collect;
     do_collect();
   }
 }
 
-#ifdef HAVE_PTHREAD
-void GCCollector::die_if_sigsegv_occured_during_collection(void *addr) {
-  if(!isStable(0, 0, 0, 0, 0, 0, 0, 0, 0)) {
-    printf("; ****************************************************** ;\n");
-    printf(";         SIGSEGV occured during a collection            ;\n");
-    printf(";   I'm trying to let the allocator in a coherent stat   ;\n");
-    printf("; but the collector is DEAD and will never collect again ;\n");
-    printf("; ****************************************************** ;\n");
-    
-    status = stat_broken;                 /* Collection is finished and no other collection will happend */
-    threads->cancel();                    /* Emulates a full collection to unlock mutators */
-    used_nodes->eat(unused_nodes);        /* All nodes are uses. Finalized are lost */
-    unlock_dont_recovery();               /* Unlocks the GC lock */
-    //gcfatal("SIGSEGV occured during collection at %p", addr);
-  }
-}
-#endif /* HAVE_PTHREAD */
-
-void GCCollector::gcStats(size_t *_no, size_t *_nbb) {
+void Collector::gcStats(size_t *_no, size_t *_nbb) {
    register unsigned int n, tot;
    register GCChunkNode *cur;
    lock();

Removed: vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h?rev=73027&view=auto

==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h (removed)
@@ -1,324 +0,0 @@
-//===------------ gccollector.h - Mvm Garbage Collector -------------------===//
-//
-//                              Mvm
-//
-// This file is distributed under the University of Illinois Open Source 
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _GC_COLLECTOR_H_
-#define _GC_COLLECTOR_H_
-
-#include "mvm/Config/config.h"
-#include "gcalloc.h"
-#ifdef HAVE_PTHREAD
-#include "gcthread.h"
-#endif
-#include "mvm/GC/GC.h"
-
-namespace mvm {
-
-class GCCollector : public Collector {
-  friend class Collector;
-#ifdef HAVE_PTHREAD
-  friend class GCThread;
-#endif
-  static GCAllocator  *allocator;      /* The allocator */
-
-
-  static GCChunkNode  *used_nodes;     /* Used memory nodes */
-  static GCChunkNode  *unused_nodes;   /* Unused memory nodes */
-  static unsigned int   current_mark;
-
-  static int  _collect_freq_auto;      /* Collection frequency in gcmalloc/gcrealloc */
-  static int  _collect_freq_maybe;     /* Collection frequency  in maybeCollect */
-  static int  _since_last_collection;  /* Bytes left since last collection */
-  static bool _enable_auto;            /* Automatic collection? */
-  static bool _enable_maybe;           /* Collection in maybeCollect()? */
-  static bool _enable_collection;      /* collection authorized? */
-  static int  status;
-  
-  
-  enum { stat_collect, stat_finalize, stat_alloc, stat_broken };
-
-#ifdef HAVE_PTHREAD
-  static void  siggc_handler(int);
-  static inline void  lock()   { threads->lock(); }
-  static inline void  unlock() { threads->unlock(); }
-#else
-  static void  siggc_handler(int) { }
-  static inline void  lock()   { }
-  static inline void  unlock() { }
-#endif
-  
-  /* Interface for collection, verifies enable_collect */
-  static void collect_unprotect();    
-  /* The collection */  
-  static void do_collect();           
-
-  static inline GCChunkNode *o2node(void *p) {
-    if (!p) return 0;
-    return GCHash::get(p)->o2node(p, GCChunkNode::maskCollectable);
-  }
-
-  static inline size_t real_nbb(GCChunkNode *n) { 
-    return n->nbb() - sizeof(gc_header);
-  }
-
-public:
-  static Collector::markerFn  _marker; /* The function which traces roots */
-  static GCThread *threads;        /* le gestionnaire de thread et de synchro */
-  static void (*internMemoryError)(unsigned int);
-
-  static bool isLive(void* ptr) {
-    GCChunkNode *node = o2node(ptr);
-    
-    if(node && isMarked(node)) return true;
-    else return false;
-  }
-
-#ifdef HAVE_PTHREAD
-  static inline void  unlock_dont_recovery() { threads->unlock_dont_recovery(); }
-  static void die_if_sigsegv_occured_during_collection(void *addr);
-#else
-  static void die_if_sigsegv_occured_during_collection(void *addr) { }
-#endif
-
-  static void defaultMemoryError(unsigned int sz){
-    unlock();
-    internMemoryError(sz);
-    lock();
-  }
-
-  static void initialise(Collector::markerFn marker);
-  static void destroy();
-
-  static int siggc();
-
-#ifdef HAVE_PTHREAD
-  static void inject_my_thread(mvm::Thread* th);
-  static inline void  remove_thread(mvm::Thread* th) {
-    threads->remove(th);
-  }
-  static inline int isStable(gc_lock_recovery_fct_t fct, int a0, int a1, int a2, 
-                             int a3, int a4, int a5, int a6, int a7) {
-    return threads->isStable(fct, a0, a1, a2, a3, a4, a5, a6, a7);
-  }
-#else
-  static inline int isStable(gc_lock_recovery_fct_t fct, int a0, int a1, int a2,
-                             int a3, int a4, int a5, int a6, int a7) {
-    return 0;
-  }
-#endif
-
-  static inline void *allocate_unprotected(size_t sz) {
-    return allocator->alloc(sz);
-  }
-  
-  static inline void  free_unprotected(void *ptr) {
-    allocator->free(ptr);
-  }
-
-  static inline void *begOf(void *p) {
-    GCChunkNode *node = o2node(p);
-    if(node)
-      return node->chunk()->_2gc();
-    else
-      return 0;
-  }
-
-  static void gcStats(size_t *no, size_t *nbb);
-
-  static inline size_t objectSize(void *ptr) {
-    GCChunkNode *node = o2node(ptr);
-    return node ? real_nbb(node) : 0;
-  }
-
-  static inline void collect() {
-    lock();
-    collect_unprotect();
-    unlock();
-  }
-
-  static inline void maybeCollect() {
-    if(_enable_auto && 
-#ifdef SERVICE
-       (mvm::Thread::get()->MyVM->_since_last_collection <= (_collect_freq_auto - _collect_freq_maybe))
-#else
-       (_since_last_collection <= (_collect_freq_auto - _collect_freq_maybe))
-#endif
-      )
-      collect(); 
-  }
-
-  static inline void *gcmalloc(VirtualTable *vt, size_t n) {
-#if (__WORDSIZE == 64)
-    void* res = malloc(n);
-    memset(res, 0, n);
-    ((void**)res)[0] = vt;
-    return res;
-#else
-    lock();
-
-#ifdef SERVICE
-    if (threads->get_nb_threads()) {
-      VirtualMachine* vm = mvm::Thread::get()->MyVM;
-      vm->_since_last_collection -= n;
-      if (_enable_auto && (vm->_since_last_collection <= 0)) {
-        vm->gcTriggered++;
-        if (vm->gcTriggered > vm->GCLimit) {
-          vm->_since_last_collection += n;
-          unlock();
-          vm->stopService();
-          return 0;
-        }
-        collect_unprotect();
-      }
-      
-      if (vm->memoryUsed + n > vm->memoryLimit) {
-        vm->_since_last_collection += n;
-        unlock();
-        vm->stopService();
-        return 0;
-      }
-    } else {
-#endif
-    
-    _since_last_collection -= n;
-    if(_enable_auto && (_since_last_collection <= 0)) {
-      collect_unprotect();
-    }
-#ifdef SERVICE
-    }
-#endif
-    register GCChunkNode *header = allocator->alloc_chunk(n, 1, current_mark & 1);
-
-#ifdef SERVICE
-    if (threads->get_nb_threads()) {
-      VirtualMachine* vm = mvm::Thread::get()->MyVM;
-      header->meta = vm;
-      vm->memoryUsed += n;
-    }
-#endif
-    header->append(used_nodes);
-    //printf("Allocate %d bytes at %p [%p] %d %d\n", n, header->chunk()->_2gc(),
-    //       header, header->nbb(), real_nbb(header));
-    register struct gc_header *p = header->chunk();
-    p->_XXX_vt = vt;
-
-
-    unlock();
-
-    if (vt->destructor) {
-      mvm::Thread::get()->MyVM->addFinalizationCandidate((gc*)p->_2gc());
-    }
-
-    return p->_2gc();
-#endif
-  }
-
-  static inline void *gcrealloc(void *ptr, size_t n) {
-#if (__WORDSIZE == 64)
-    void* res = realloc(ptr, n);
-    return res;
-#else
-    lock();
-    
-    GCPage      *desc = GCHash::get(ptr);
-    GCChunkNode  *node = desc->o2node(ptr, GCChunkNode::maskCollectable);
-
-    if(!node)
-      gcfatal("%p isn't a avalid object", ptr);
-
-    size_t      old_sz = node->nbb();
-#ifdef SERVICE
-    if (threads->get_nb_threads()) {
-      VirtualMachine* vm = mvm::Thread::get()->MyVM;
-      vm->_since_last_collection -= (n - old_sz);
-      if (_enable_auto && (vm->_since_last_collection <= 0)) {
-        if (vm->gcTriggered + 1 > vm->GCLimit) {
-          unlock();
-          vm->stopService();
-          return 0;
-        }
-        vm->gcTriggered++;
-        collect_unprotect();
-      }
-      
-      if (vm->memoryUsed + (n - old_sz) > vm->memoryLimit) {
-        vm->_since_last_collection += (n - old_sz);
-        unlock();
-        vm->stopService();
-        return 0;
-      }
-    } else {
-#endif
-    
-    _since_last_collection -= (n - old_sz);
-
-    if(_enable_auto && (_since_last_collection <= 0)) {
-      collect_unprotect();
-    }
-
-#ifdef SERVICE
-    }
-#endif
-
-    GCChunkNode  *res = allocator->realloc_chunk(desc, node, n);
-
-#ifdef SERVICE
-    if (threads->get_nb_threads()) {
-      VirtualMachine* vm = mvm::Thread::get()->MyVM;
-      res->meta = vm;
-      vm->memoryUsed += (n - old_sz);
-    }
-#endif
-
-    if(res != node) {
-      res->append(used_nodes);
-      mark(res);
-    }
-
-    gc_header *obj = res->chunk();
-
-    unlock();
-    return obj->_2gc();
-#endif
-  }
-
-  static inline unsigned int enable(unsigned int n)  {
-    register unsigned int old = _enable_collection;
-    _enable_collection = n; 
-    return old;
-  }
-
-  static inline bool isMarked(GCChunkNode *node) { 
-    return node->mark() == (current_mark & 1);
-  }
-  
-  static inline void mark(GCChunkNode *node) {
-    node->_mark(current_mark & 1);
-  }
-
-  static inline void trace(GCChunkNode *node) {
-    gc_header *o = node->chunk();
-    o->_2gc()->tracer();
-    markAndTrace(o);
-  }
-
-  static inline void markAndTrace(void *ptr) {
-    GCChunkNode *node = o2node(ptr);
-
-    if(node && !isMarked(node)) {
-      mark(node);
-      node->remove();
-      node->append(used_nodes);
-      trace(node);
-    }
-  }
-
-};
-
-}
-#endif

Modified: vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cpp?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cpp (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cpp Sun Jun  7 09:01:12 2009
@@ -8,7 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include <signal.h>
-#include "gccollector.h"
+#include "MvmGC.h"
 
 using namespace mvm;
 
@@ -21,11 +21,11 @@
 # define SIGGC  SIGPWR
 #endif
 
-int GCCollector::siggc() {
+int Collector::siggc() {
   return SIGGC;
 }
 
-void GCCollector::initialise(Collector::markerFn marker) {
+void Collector::initialise() {
  
   used_nodes = new GCChunkNode();
   unused_nodes = new GCChunkNode();
@@ -49,9 +49,8 @@
 
   allocator = new GCAllocator();
    
-  _marker = marker;
-
   used_nodes->alone();
+  unused_nodes->alone();
 
   current_mark = 0;
   status = stat_alloc;
@@ -67,13 +66,13 @@
 
 }
 
-void GCCollector::destroy() {
+void Collector::destroy() {
   delete allocator;
   allocator = 0;
 }
 
 #ifdef HAVE_PTHREAD
-void GCCollector::inject_my_thread(mvm::Thread* th) {
+void Collector::inject_my_thread(mvm::Thread* th) {
   threads->inject(th);
 }
 #endif

Modified: vmkit/trunk/lib/Mvm/GCMmap2/gcthread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gcthread.cpp?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gcthread.cpp (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gcthread.cpp Sun Jun  7 09:01:12 2009
@@ -8,7 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include <cassert>
-#include "gccollector.h"
+#include "MvmGC.h"
 
 using namespace mvm;
 
@@ -20,7 +20,7 @@
 }
 
 void GCThread::synchronize() {
-	int signo = GCCollector::siggc();
+	int signo = Collector::siggc();
   mvm::Thread* self = mvm::Thread::get();
   assert(self && "No thread local data for this thread");
 	current_collector = self;
@@ -31,7 +31,7 @@
     cur->kill(signo);
 	}
 
-	GCCollector::siggc_handler(signo);
+	Collector::siggc_handler(signo);
 	
   waitStacks();
 }

Modified: vmkit/trunk/lib/Mvm/Runtime/Object.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Runtime/Object.cpp?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/Runtime/Object.cpp (original)
+++ vmkit/trunk/lib/Mvm/Runtime/Object.cpp Sun Jun  7 09:01:12 2009
@@ -287,3 +287,23 @@
 
   CurrentIndex = NewIndex;
 }
+
+void* Allocator::allocateManagedObject(unsigned int sz, VirtualTable* VT) {
+  return gc::operator new(sz, VT);
+}
+  
+void* Allocator::allocatePermanentMemory(unsigned int sz) {
+  return malloc(sz); 
+}
+  
+void Allocator::freePermanentMemory(void* obj) {
+  return free(obj); 
+}
+  
+void* Allocator::allocateTemporaryMemory(unsigned int sz) {
+  return malloc(sz); 
+}
+  
+void Allocator::freeTemporaryMemory(void* obj) {
+  return free(obj); 
+}

Modified: vmkit/trunk/lib/N3/VMCore/MSCorlib.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/MSCorlib.cpp?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/MSCorlib.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/MSCorlib.cpp Sun Jun  7 09:01:12 2009
@@ -226,7 +226,7 @@
 #ifdef MULTIPLE_GC
   VMThread::get()->GC->collect();
 #else
-  Collector::collect();
+  mvm::Collector::collect();
 #endif
 }
 

Modified: vmkit/trunk/tools/jnjvm/Main.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/jnjvm/Main.cpp?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/tools/jnjvm/Main.cpp (original)
+++ vmkit/trunk/tools/jnjvm/Main.cpp Sun Jun  7 09:01:12 2009
@@ -27,7 +27,7 @@
   llvm::llvm_shutdown_obj X;  
     
   MvmModule::initialise();
-  Collector::initialise(0);
+  Collector::initialise();
  
   JavaJITCompiler* Comp = new JavaJITCompiler("JITModule");
   mvm::MvmModule::AddStandardCompilePasses();

Modified: vmkit/trunk/tools/n3-mono/Main.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/n3-mono/Main.cpp?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/tools/n3-mono/Main.cpp (original)
+++ vmkit/trunk/tools/n3-mono/Main.cpp Sun Jun  7 09:01:12 2009
@@ -21,7 +21,7 @@
   llvm::llvm_shutdown_obj X;  
     
   MvmModule::initialise();
-  Collector::initialise(0);
+  Collector::initialise();
 
   VirtualMachine::initialiseCLIVM();
   VirtualMachine* vm = VirtualMachine::createCLIVM();

Modified: vmkit/trunk/tools/n3-pnetlib/Main.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/n3-pnetlib/Main.cpp?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/tools/n3-pnetlib/Main.cpp (original)
+++ vmkit/trunk/tools/n3-pnetlib/Main.cpp Sun Jun  7 09:01:12 2009
@@ -21,7 +21,7 @@
   llvm::llvm_shutdown_obj X;  
     
   MvmModule::initialise();
-  Collector::initialise(0);
+  Collector::initialise();
 
   VirtualMachine::initialiseCLIVM();
   VirtualMachine* vm = VirtualMachine::createCLIVM();

Modified: vmkit/trunk/tools/vmjc/vmjc.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmjc/vmjc.cpp?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/tools/vmjc/vmjc.cpp (original)
+++ vmkit/trunk/tools/vmjc/vmjc.cpp Sun Jun  7 09:01:12 2009
@@ -22,7 +22,6 @@
 #include "llvm/PassManager.h"
 #include "llvm/Assembly/PrintModulePass.h"
 #include "llvm/CodeGen/LinkAllCodegenComponents.h"
-#include "llvm/Config/config.h"
 #include "llvm/Bitcode/ReaderWriter.h"
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
 #include "llvm/Support/CommandLine.h"
@@ -186,7 +185,7 @@
       if (!TargetTriple.empty())
         TheModule->setTargetTriple(TargetTriple);
       else
-        TheModule->setTargetTriple(LLVM_HOSTTRIPLE);
+        TheModule->setTargetTriple(mvm::MvmModule::getHostTriple());
     
       // Create the TargetMachine we will be generating code with.
       std::string Err; 
@@ -213,8 +212,8 @@
       Comp = new JavaJITCompiler("JIT");
     }
 
-    Collector::initialise(0);
-    Collector::enable(0);
+    mvm::Collector::initialise();
+    mvm::Collector::enable(0);
 
     JnjvmClassLoader* JCL = mvm::VirtualMachine::initialiseJVM(Comp, false);
     addCommandLinePass(argv);

Modified: vmkit/trunk/tools/vmkit/CommandLine.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmkit/CommandLine.h?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/tools/vmkit/CommandLine.h (original)
+++ vmkit/trunk/tools/vmkit/CommandLine.h Sun Jun  7 09:01:12 2009
@@ -14,6 +14,7 @@
 
 #include <string.h>
 
+#include "mvm/Object.h"
 #include "mvm/VirtualMachine.h"
 
 #if defined(__APPLE__)

Modified: vmkit/trunk/tools/vmkit/Launcher.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmkit/Launcher.cpp?rev=73028&r1=73027&r2=73028&view=diff

==============================================================================
--- vmkit/trunk/tools/vmkit/Launcher.cpp (original)
+++ vmkit/trunk/tools/vmkit/Launcher.cpp Sun Jun  7 09:01:12 2009
@@ -133,7 +133,7 @@
   }
   
   mvm::MvmModule::initialise(Fast ? CodeGenOpt::None : CodeGenOpt::Aggressive);
-  Collector::initialise(0);
+  mvm::Collector::initialise();
 
   if (VMToRun == RunJava) {
 #if WITH_JNJVM





More information about the vmkit-commits mailing list