[llvm-commits] [vmkit] r49859 - in /vmkit/trunk: ./ include/mvm/ include/mvm/GC/ include/mvm/Threads/ lib/JnJVM/Classpath/ lib/JnJVM/VMCore/ lib/Mvm/ lib/Mvm/GCMmap2/ lib/N3/VMCore/

Nicolas Geoffray nicolas.geoffray at lip6.fr
Thu Apr 17 09:45:26 PDT 2008


Author: geoffray
Date: Thu Apr 17 11:45:26 2008
New Revision: 49859

URL: http://llvm.org/viewvc/llvm-project?rev=49859&view=rev
Log:
More multi-mmap porting. In a multi-mmap environment, the collector is given as a parameter to trace functions


Modified:
    vmkit/trunk/configure.ac
    vmkit/trunk/include/mvm/CollectableArea.h
    vmkit/trunk/include/mvm/GC/GC.h
    vmkit/trunk/include/mvm/Method.h
    vmkit/trunk/include/mvm/MvmMemoryManager.h
    vmkit/trunk/include/mvm/Object.h
    vmkit/trunk/include/mvm/PrintBuffer.h
    vmkit/trunk/include/mvm/Threads/Cond.h
    vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMStackWalker.cpp
    vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaArray.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaCache.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaObject.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaPrimitive.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaString.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.h
    vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
    vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h
    vmkit/trunk/lib/JnJVM/VMCore/LockedMap.h
    vmkit/trunk/lib/JnJVM/VMCore/Reader.h
    vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp
    vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h
    vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp
    vmkit/trunk/lib/JnJVM/VMCore/Zip.h
    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/gccollector.h
    vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cpp
    vmkit/trunk/lib/Mvm/JIT.cpp
    vmkit/trunk/lib/Mvm/MvmMemoryManager.cpp
    vmkit/trunk/lib/Mvm/Object.cpp
    vmkit/trunk/lib/N3/VMCore/Assembly.h
    vmkit/trunk/lib/N3/VMCore/BackTrace.cpp
    vmkit/trunk/lib/N3/VMCore/CLIJit.cpp
    vmkit/trunk/lib/N3/VMCore/CLIJit.h
    vmkit/trunk/lib/N3/VMCore/CLIString.h
    vmkit/trunk/lib/N3/VMCore/LockedMap.h
    vmkit/trunk/lib/N3/VMCore/N3.h
    vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp
    vmkit/trunk/lib/N3/VMCore/Reader.h
    vmkit/trunk/lib/N3/VMCore/VMArray.h
    vmkit/trunk/lib/N3/VMCore/VMCache.h
    vmkit/trunk/lib/N3/VMCore/VMClass.h
    vmkit/trunk/lib/N3/VMCore/VMObject.h
    vmkit/trunk/lib/N3/VMCore/VMThread.h
    vmkit/trunk/lib/N3/VMCore/VirtualMachine.h
    vmkit/trunk/lib/N3/VMCore/VirtualTables.cpp

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

==============================================================================
--- vmkit/trunk/configure.ac (original)
+++ vmkit/trunk/configure.ac Thu Apr 17 11:45:26 2008
@@ -177,10 +177,10 @@
 dnl **************************************************************************
 AC_ARG_WITH(gc,
        [AS_HELP_STRING(--with-gc=something,
-           [GC type ('mmap2' or 'boehm')])],
+           [GC type ('single-mmap' 'multi-mmap' or 'boehm')])],
        [[gc=$withval]],
        [[ echo Using mmap2 as vvm gc type.
-                gc=mmap2
+                gc=single-mmap
        ]]
 )
 
@@ -203,6 +203,10 @@
     ;;
   esac
 else
+  if test "x$gc" = "xmulti-mmap"; then
+    CFLAGS="$CFLAGS -I$PWD/lib/Mvm/GCMmap2 -DWITH_TRACER -DMULTIPLE_GC"
+    CXXFLAGS="$CXXFLAGS -I$PWD/lib/Mvm/GCMmap2 -DWITH_TRACER -DMULTIPLE_GC"
+  fi
   GC_LIBS="$PWD/lib/Mvm/GCMmap2/libuvm_gc_mmap2.a \
            $PWD/lib/Mvm/Allocator/libuvm_alloc.a"
   CFLAGS="$CFLAGS -I$PWD/lib/Mvm/GCMmap2 -DWITH_TRACER"

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

==============================================================================
--- vmkit/trunk/include/mvm/CollectableArea.h (original)
+++ vmkit/trunk/include/mvm/CollectableArea.h Thu Apr 17 11:45:26 2008
@@ -59,7 +59,7 @@
   }
 
 
-  virtual void tracer(size_t sz) {
+  virtual void TRACER {
     CollectableArea *const self= (CollectableArea *)this;
     register T **e = self->elements();
     size_t lim= self->lastIndex;
@@ -67,7 +67,7 @@
     lim = ((lim << 2) < sz) ? lim : 0;
     idx = ((idx << 2) < sz) ? idx : (sz >> 2); 
     for (; idx < lim; ++idx)
-      e[idx]->markAndTrace();
+      e[idx]->MARK_AND_TRACE;
   }
 };
 

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

==============================================================================
--- vmkit/trunk/include/mvm/GC/GC.h (original)
+++ vmkit/trunk/include/mvm/GC/GC.h Thu Apr 17 11:45:26 2008
@@ -21,7 +21,11 @@
 public:
   virtual           ~gcRoot() {}
   virtual void      destroyer(size_t) {}
-  virtual void      tracer(size_t) {}
+#ifdef MULTIPLE_GC
+  virtual void      tracer(void* GC) {}
+#else
+  virtual void      tracer(void) {}
+#endif
 };
 
 class gc_header {

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

==============================================================================
--- vmkit/trunk/include/mvm/Method.h (original)
+++ vmkit/trunk/include/mvm/Method.h Thu Apr 17 11:45:26 2008
@@ -11,6 +11,11 @@
 #define MVM_METHOD_H
 
 #include "mvm/Object.h"
+#include "mvm/Threads/Thread.h"
+
+namespace llvm {
+  class Function;
+}
 
 namespace mvm {
 
@@ -26,6 +31,7 @@
   GC_defass(Object, definition);
   GC_defass(Object, literals);
   GC_defass(ExceptionTable, exceptionTable);
+  const llvm::Function* llvmFunction;
   size_t  codeSize;
 
   /* use this constructor to map a function which is compiled by llvm  */
@@ -35,7 +41,7 @@
   }
 
   virtual void print(PrintBuffer *buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 };
 
 
@@ -57,7 +63,15 @@
   inline Method *method() { return meth; }
 
   virtual void print(PrintBuffer *buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
+
+  static Code* getCodeFromPointer(void* ptr) {
+#ifdef MULTIPLE_GC
+    return (mvm::Code*)mvm::Thread::get()->GC->begOf(ptr);
+#else
+    return (mvm::Code*)Collector::begOf(ptr);
+#endif
+  }
 };
 
 class ExceptionTable : public Object {

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

==============================================================================
--- vmkit/trunk/include/mvm/MvmMemoryManager.h (original)
+++ vmkit/trunk/include/mvm/MvmMemoryManager.h Thu Apr 17 11:45:26 2008
@@ -29,7 +29,7 @@
   Method* currentMethod;       // Current method being compiled
   unsigned char *GOTBase;      // Target Specific reserved memory
 #ifdef MULTIPLE_GC
-  std::map<Module*, Collector*> GCMap;
+  std::map<const Module*, Collector*> GCMap;
   mvm::Lock* lock;
 #endif
 public:

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

==============================================================================
--- vmkit/trunk/include/mvm/Object.h (original)
+++ vmkit/trunk/include/mvm/Object.h Thu Apr 17 11:45:26 2008
@@ -54,7 +54,7 @@
 #endif
   
   virtual void      destroyer(size_t) {}
-  virtual void      tracer(size_t) {}
+  virtual void      TRACER {}
   virtual void      print(PrintBuffer *buf) const;
   virtual intptr_t  hashCode(){ return (intptr_t)this;}
 

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

==============================================================================
--- vmkit/trunk/include/mvm/PrintBuffer.h (original)
+++ vmkit/trunk/include/mvm/PrintBuffer.h Thu Apr 17 11:45:26 2008
@@ -139,7 +139,7 @@
 public:
   static PrintBuffer *alloc(void);
 
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 };
 
 } // end namespace mvm

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

==============================================================================
--- vmkit/trunk/include/mvm/Threads/Cond.h (original)
+++ vmkit/trunk/include/mvm/Threads/Cond.h Thu Apr 17 11:45:26 2008
@@ -25,6 +25,8 @@
   unsigned int    go; 
   unsigned int    n_wait;
 public:
+  
+  Cond() : no_barrier(0), go(0), n_wait(0) { }
   static Cond *allocCond(void);
   void broadcast(void);
   void wait(Lock *l);

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMStackWalker.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMStackWalker.cpp Thu Apr 17 11:45:26 2008
@@ -31,12 +31,7 @@
 
 ArrayObject* recGetClassContext(int** stack, uint32 size, uint32 first, uint32 rec) {
   if (size != first) {
-#ifdef MULTIPLE_GC
-    int *begIp = (int*)mvm::Thread::get()->GC->begOf(stack[first]);
-#else
-    int *begIp = (int*)Collector::begOf(stack[first]);
-#endif
-    JavaMethod* meth = ip_to_meth(begIp);
+    JavaMethod* meth = ip_to_meth(stack[first]);
     if (meth) {
       ArrayObject* res = recGetClassContext(stack, size, first + 1, rec + 1); 
       res->setAt(rec, meth->classDef->getClassDelegatee());
@@ -63,12 +58,7 @@
   CommonClass* cl = Classpath::vmStackWalker; 
 
   while (i < real_size) {
-#ifdef MULTIPLE_GC
-    int *begIp = (int*)mvm::Thread::get()->GC->begOf(ips[i++]);
-#else
-    int *begIp = (int*)Collector::begOf(ips[i++]);
-#endif
-    JavaMethod* meth = ip_to_meth(begIp);
+    JavaMethod* meth = ip_to_meth(ips[i++]);
     if (meth && meth->classDef == cl) {
       first = i;
       break;
@@ -96,12 +86,7 @@
   int i = 0;
   
   while (i < real_size) {
-#ifdef MULTIPLE_GC
-    int *begIp = (int*)mvm::Thread::get()->GC->begOf(ips[i++]);
-#else
-    int *begIp = (int*)Collector::begOf(ips[i++]);
-#endif
-    JavaMethod* meth = ip_to_meth(begIp);
+    JavaMethod* meth = ip_to_meth(ips[i++]);
     if (meth) {
       ++n;
       if (n == 1) return meth->classDef->getClassDelegatee();
@@ -118,12 +103,7 @@
   int i = 0;
   
   while (i < real_size) {
-#ifdef MULTIPLE_GC
-    int *begIp = (int*)mvm::Thread::get()->GC->begOf(ips[i++]);
-#else
-    int *begIp = (int*)Collector::begOf(ips[i++]);
-#endif
-    JavaMethod* meth = ip_to_meth(begIp);
+    JavaMethod* meth = ip_to_meth(ips[i++]);
     if (meth) {
       ++n;
       if (n == 1) return meth->classDef->classLoader;

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp Thu Apr 17 11:45:26 2008
@@ -67,6 +67,9 @@
     ts->nonDaemonLock->unlock();
   }
   
+#ifdef SERVICE_DOMAIN
+  ((ServiceDomain*)isolate)->numThreads++;
+#endif
   JavaMethod* method = vmthClass->lookupMethod(Jnjvm::runName, Jnjvm::clinitType, ACC_VIRTUAL, true);
   method->invokeIntSpecial(isolate, vmThread);
 
@@ -79,6 +82,10 @@
     ts->nonDaemonLock->unlock();
   }
 
+#ifdef SERVICE_DOMAIN
+  ((ServiceDomain*)isolate)->numThreads--;
+#endif
+
 #ifdef MULTIPLE_GC
   intern->GC->remove_my_thread();
 #else
@@ -94,9 +101,10 @@
   JavaObject* vmThread = (JavaObject*)_vmThread;
   JavaObject* javaThread = (JavaObject*)(*ClasspathThread::assocThread)(vmThread).PointerVal;
   assert(javaThread);
+  Jnjvm* vm = JavaThread::get()->isolate;
 
-  JavaThread* th = vm_new(JavaThread::get()->isolate, JavaThread)();
-  th->initialise(javaThread, JavaThread::get()->isolate);
+  JavaThread* th = vm_new(vm, JavaThread)();
+  th->initialise(javaThread, vm);
   (*ClasspathThread::vmdata)(vmThread, (JavaObject*)th);
   int tid = 0;
   arg_thread_t* arg = (arg_thread_t*)malloc(sizeof(arg_thread_t));
@@ -105,6 +113,7 @@
 #ifdef MULTIPLE_GC
   th->GC = mvm::Thread::get()->GC;
 #endif
+
   mvm::Thread::start(&tid, (int (*)(void *))start, (void*)arg);
 }
 

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp Thu Apr 17 11:45:26 2008
@@ -63,7 +63,7 @@
     else if (n > JavaArray::MaxArraySize)                                   \
       JavaThread::get()->isolate->outOfMemoryError(n);                      \
     name* res = (name*)                                                     \
-      (Object*) vm->allocateObject(sizeof(name) + n * primSize, name::VT);        \
+      (Object*) vm->allocateObject(sizeof(name) + n * primSize, name::VT);  \
     res->initialise(atype);                                                 \
     res->size = n;                                                          \
     memset(res->elements, 0, primSize * n);                                 \

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaArray.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaArray.h Thu Apr 17 11:45:26 2008
@@ -57,7 +57,7 @@
   static llvm::ConstantInt* elementsOffset();
   static JavaArray* multiCallNew(ClassArray* cl, uint32 len, ...);
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 
 };
 
@@ -73,7 +73,7 @@
   elmt at(sint32) const;                                              \
   void setAt(sint32, elmt);                                           \
   virtual void print(mvm::PrintBuffer* buf) const;                    \
-  virtual void tracer(size_t sz);                                     \
+  virtual void TRACER;                                                \
 }
 
 ARRAYCLASS(ArrayUInt8,  uint8);
@@ -97,7 +97,7 @@
   JavaObject* at(sint32) const;
   void setAt(sint32, JavaObject*);
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 };
 
 class UTF8 : public JavaArray {

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp Thu Apr 17 11:45:26 2008
@@ -9,6 +9,7 @@
 
 #include <stdio.h>
 #include <dlfcn.h>
+#include <execinfo.h>
 
 #include "llvm/Function.h"
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
@@ -25,161 +26,42 @@
 
 using namespace jnjvm;
 
-extern "C" int** get_frame_pointer() {
-/*
-  int** fp = 0;
-#if defined (__PPC__)
-  asm volatile("1:\n"
-    " mr %0, 1\n"
-    : "=&r"(fp));
-#else
-  asm volatile("1:\n"
-    " movl %%ebp, %0\n"
-    : "=&r"(fp));
-#endif
-  return fp;
-*/
-  return (int**)__builtin_frame_address(0);
-}
-
-extern "C" int *debug_frame_ip(int **fp) {
-#if defined(__MACH__) && !defined(__i386__)
-	return fp[2];
-#else
-	return fp[1];
-#endif
-}
-
-extern "C" int **debug_frame_caller_fp(int **fp) {
-	return (int**)fp[0];
-}
-
-
-extern "C" int **debug_frame_caller_from_first_fp(int **fp) {
-#if defined (__PPC__)
-  return fp;
-#else
-  return fp;
-#endif
-}
-
-extern "C" bool frame_end(int **fp) {
-#if defined(__PPC__)
-  return fp == 0;
-#else
-  return fp == 0;
-#endif
-}
-    
 extern "C" JavaMethod* ip_to_meth(int* begIp) {
-  if (begIp) {
-    unsigned char* val = (unsigned char*)begIp + sizeof(mvm::Code);
-    const llvm::GlobalValue * glob = 
-      mvm::jit::executionEngine->getGlobalValueAtAddress(val);
-    if (glob) {
-      if (llvm::isa<llvm::Function>(glob)) {
-        mvm::Code* c = (mvm::Code*)begIp;
-        mvm::Method* m = c->method();
-        JavaMethod* meth = (JavaMethod*)m->definition();
-        if (meth && meth->getVirtualTable() == JavaMethod::VT) {
-          return meth;
-        }
-      }
+  mvm::Code* val = mvm::Code::getCodeFromPointer(begIp);
+  if (val) {
+    mvm::Method* m = val->method();
+    mvm::Object* meth = m->definition();
+    if (meth && meth->getVirtualTable() == JavaMethod::VT) {
+      return (JavaMethod*)meth;
     }
   }
   return 0;
 }
 
-#if 0
-extern "C" int backtrace(void** ips, int size) {
-  int** fp = get_frame_pointer();
-  fp = debug_frame_caller_from_first_fp(fp);
-  int i = 0;
-  while ((!frame_end(fp)) && (debug_frame_ip(fp) != 0) && i < size) {
-    int * ip = debug_frame_ip(fp);
-    ips[i++] = (void*)ip;
-    fp = debug_frame_caller_fp(fp);
-  }
-  return i;
-}
-#else
-#include <execinfo.h>
-#endif
-extern "C" int backtrace_fp(int** ips, int size, int** fp) {
-  fp = debug_frame_caller_from_first_fp(fp);
-  int i = 0;
-  while ((!frame_end(fp)) && (debug_frame_ip(fp) != 0) && i < size) {
-    int * ip = debug_frame_ip(fp);
-    ips[i++] = ip;
-    fp = debug_frame_caller_fp(fp);
-  }
-  return i;
-}
-
-extern "C" void debug_backtrace(int **fp) {
-  fp = debug_frame_caller_from_first_fp(fp);
-  while ((!frame_end(fp)) && (debug_frame_ip(fp) != 0)) {
-    int * ip = debug_frame_ip(fp);
-#ifdef MULTIPLE_GC
-    int *begIp = (int*)mvm::Thread::get()->GC->begOf(ip);
-#else
-    int *begIp = (int*)Collector::begOf(ip);
-#endif
-    if (begIp) {
-      unsigned char* val = (unsigned char*)begIp + sizeof(mvm::Code);
-      const llvm::GlobalValue * glob = 
-        mvm::jit::executionEngine->getGlobalValueAtAddress(val);
-      if (glob) {
-        if (llvm::isa<llvm::Function>(glob)) {
-          printf("; 0x%p in %s\n",  ip, 
-                 ((llvm::Function*)glob)->getNameStr().c_str());
-        } else JavaThread::get()->isolate->unknownError("in global variable?");
-      } else printf("; 0x%p in stub\n",  ip);
-    } else {
-      Dl_info info;
-      int res = dladdr(begIp, &info);
-      if (res != 0) {
-        printf("; 0x%p in %s\n", ip, info.dli_fname);
-      }
-    }
-    fp = debug_frame_caller_fp(fp);
-  }
-}
-
-
 void JavaJIT::printBacktrace() {
   int* ips[100];
   int real_size = backtrace((void**)(void*)ips, 100);
   int n = 0;
   while (n < real_size) {
-#ifdef MULTIPLE_GC
-    int *begIp = (int*)mvm::Thread::get()->GC->begOf(ips[n++]);
-#else
-    int *begIp = (int*)Collector::begOf(ips[n++]);
-#endif
-    if (begIp) {
-      unsigned char* val = (unsigned char*)begIp + sizeof(mvm::Code);
-      const llvm::GlobalValue * glob = 
-        mvm::jit::executionEngine->getGlobalValueAtAddress(val);
-      if (glob) {
-        if (llvm::isa<llvm::Function>(glob)) {
-          mvm::Code* c = (mvm::Code*)begIp;
-          mvm::Method* m = c->method();
-          JavaMethod* meth = (JavaMethod*)m->definition();
-          if (meth) 
-            printf("; 0x%p in %s\n",  ips[n - 1], meth->printString());
-          else
-            printf("; 0x%p in %s\n",  ips[n - 1],
-                   ((llvm::Function*)glob)->getNameStr().c_str());
-        } else JavaThread::get()->isolate->unknownError("in global variable?");
-      } else printf("; 0x%p in stub\n", ips[n - 1]);
+    mvm::Code* code = mvm::Code::getCodeFromPointer(ips[n++]);
+    if (code) {
+      mvm::Method* m = code->method();
+      mvm::Object* meth = m->definition();
+      if (meth && meth->getVirtualTable() == JavaMethod::VT) {
+        printf("; %p in %s\n",  ips[n - 1], meth->printString());
+      } else if (m->llvmFunction) {
+        printf("; %p in %s\n",  ips[n - 1],
+                   m->llvmFunction->getNameStr().c_str());
+      } else {
+        printf("; %p in %s\n",  ips[n - 1], "stub (probably)");
+      }
     } else {
       Dl_info info;
-      int res = dladdr(begIp, &info);
+      int res = dladdr(ips[n++], &info);
       if (res != 0) {
-        printf("; 0x%p in %s\n",  ips[n - 1], info.dli_fname);
+        printf("; %p in %s\n",  ips[n - 1], info.dli_sname);
       } else {
-        printf("; 0x%p in Unknown\n", ips[n - 1]);
+        printf("; %p in Unknown\n", ips[n - 1]);
       }
     }
   }
@@ -194,25 +76,14 @@
   int n = 0;
   int i = 0;
   while (n < real_size) {
-#ifdef MULTIPLE_GC
-    int *begIp = (int*)mvm::Thread::get()->GC->begOf(ips[n++]);
-#else
-    int *begIp = (int*)Collector::begOf(ips[n++]);
-#endif
-    if (begIp) {
-      unsigned char* val = (unsigned char*)begIp + sizeof(mvm::Code);
-      const llvm::GlobalValue * glob = 
-        mvm::jit::executionEngine->getGlobalValueAtAddress(val);
-      if (glob) {
-        if (llvm::isa<llvm::Function>(glob)) {
-          mvm::Code* c = (mvm::Code*)begIp;
-          mvm::Method* m = c->method();
-          JavaMethod* meth = (JavaMethod*)m->definition();
-          if (meth && i == 1) return meth->classDef;
-          else ++i;
-        } else {
-          JavaThread::get()->isolate->unknownError("in global variable?");
-        }
+    mvm::Code* code = mvm::Code::getCodeFromPointer(ips[n++]);
+    if (code) {
+      mvm::Method* m = code->method();
+      mvm::Object* meth = m->definition();
+      if (meth && meth->getVirtualTable() == JavaMethod::VT && i == 0) {
+        return ((JavaMethod*)meth)->classDef;
+      } else {
+        ++i;
       }
     }
   }
@@ -225,27 +96,13 @@
   int n = 0;
   int i = 0;
   while (n < real_size) {
-#ifdef MULTIPLE_GC
-    int *begIp = (int*)mvm::Thread::get()->GC->begOf(ips[n++]);
-#else
-    int *begIp = (int*)Collector::begOf(ips[n++]);
-#endif
-    if (begIp) {
-      unsigned char* val = (unsigned char*)begIp + sizeof(mvm::Code);
-      const llvm::GlobalValue * glob = 
-        mvm::jit::executionEngine->getGlobalValueAtAddress(val);
-      if (glob) {
-        if (llvm::isa<llvm::Function>(glob)) {
-          mvm::Code* c = (mvm::Code*)begIp;
-          mvm::Method* m = c->method();
-          JavaMethod* meth = (JavaMethod*)m->definition();
-          if (meth && i == 1) {
-            return meth->classDef;
-          } else ++i;
-        } else {
-          JavaThread::get()->isolate->unknownError("in global variable?");
-        }
-      }
+    mvm::Code* code = mvm::Code::getCodeFromPointer(ips[n++]);
+    if (code) {
+      mvm::Method* m = code->method();
+      mvm::Object* meth = m->definition();
+      if (meth && meth->getVirtualTable() == JavaMethod::VT && i == 1) {
+        return ((JavaMethod*)meth)->classDef;
+      } else ++i;
     }
   }
   return 0;

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp Thu Apr 17 11:45:26 2008
@@ -31,6 +31,10 @@
 using namespace jnjvm;
 using namespace llvm;
 
+void Enveloppe::destroyer(size_t sz) {
+  delete cacheLock;
+}
+
 void CacheNode::print(mvm::PrintBuffer* buf) const {
   buf->write("CacheNode<");
   if (lastCible) {

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaCache.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaCache.h Thu Apr 17 11:45:26 2008
@@ -28,7 +28,7 @@
 public:
   static VirtualTable* VT;
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 
   void* methPtr;
   Class* lastCible;
@@ -43,9 +43,10 @@
 class Enveloppe : public mvm::Object {
 public:
   static VirtualTable* VT;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
   virtual void print(mvm::PrintBuffer* buf) const;
-  
+  virtual void destroyer(size_t sz);
+
   CacheNode *firstCache;
   JavaCtpInfo* ctpInfo;
   mvm::Lock* cacheLock;

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp Thu Apr 17 11:45:26 2008
@@ -226,11 +226,11 @@
       // We can compile it, since if we're here, it's for a  good reason
       void* val = mvm::jit::executionEngine->getPointerToGlobal(methPtr);
 #ifndef MULTIPLE_GC
-      if (Collector::isObject(val)) {
+      mvm::Code* temp = (mvm::Code*)(Collector::begOf(val));
 #else
-      if (classDef->isolate->GC->isObject(val)) {
+      mvm::Code* temp = (mvm::Code*)(classDef->isolate->GC->begOf(val));
 #endif
-        mvm::Code* temp = (mvm::Code*)((unsigned*)val - 2);
+      if (temp) {
         temp->method()->definition(this);
       }
       code = (mvm::Code*)val;

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h Thu Apr 17 11:45:26 2008
@@ -69,7 +69,7 @@
   static const UTF8* sourceFileAttribut;
   
   virtual void print(mvm::PrintBuffer *buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 };
 
 class CommonClass : public mvm::Object {
@@ -134,7 +134,7 @@
 
 
   virtual void print(mvm::PrintBuffer *buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 
   bool inheritName(const UTF8* Tname);
   bool isOfTypeName(const UTF8* Tname);
@@ -193,7 +193,7 @@
   JavaObject* doNewUnknown(Jnjvm* vm);
   JavaObject* initialiseObject(JavaObject* obj);
   virtual void print(mvm::PrintBuffer *buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 
   JavaObject* operator()(Jnjvm* vm);
 
@@ -224,7 +224,7 @@
                                  unsigned int end);
 
   virtual void print(mvm::PrintBuffer *buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 
   static CommonClass* SuperArray;
   static std::vector<Class*>        InterfacesArray;
@@ -250,7 +250,7 @@
   mvm::Code* code;
 
   virtual void print(mvm::PrintBuffer *buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 
   void* compiledPtr();
   const llvm::FunctionType* llvmType;
@@ -325,7 +325,7 @@
   void initField(JavaObject* obj);
 
   virtual void print(mvm::PrintBuffer *buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
   
   llvm::GenericValue operator()(JavaObject* obj = 0);
   void operator()(JavaObject* obj, float val);

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.h Thu Apr 17 11:45:26 2008
@@ -50,7 +50,7 @@
   static const uint32 ConstantNameAndType;
   
   virtual void print(mvm::PrintBuffer* buf);
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 
   static ctpReader funcsReader[16];
 

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp Thu Apr 17 11:45:26 2008
@@ -326,6 +326,9 @@
 }
 
 void JavaIsolate::executeClass(const char* className, ArrayObject* args) {
+#ifdef SERVICE_VM
+  JavaThread::get()->executionTime = time(0);
+#endif
   try {
     JavaJIT::invokeOnceVoid(this, appClassLoader, className, "main",
                         "([Ljava/lang/String;)V", ACC_STATIC, args);
@@ -438,14 +441,11 @@
                                                        isolate->functions);  
   JavaJIT::initialiseJITIsolateVM(isolate);
   
-
   isolate->bootstrapThread = vm_new(isolate, JavaThread)();
   isolate->bootstrapThread->initialise(0, isolate);
-#ifndef MULTIPLE_GC
-  mvm::Thread* th = mvm::Thread::get();
-  isolate->bootstrapThread->GC = th->GC;
-#else
+#ifdef MULTIPLE_GC
   isolate->bootstrapThread->GC = isolate->GC;
+  isolate->GC->inject_my_thread(0);
   mvm::jit::memoryManager->addGCForModule(isolate->module, isolate->GC);
 #endif 
   JavaThread::threadKey->set(isolate->bootstrapThread);
@@ -505,11 +505,9 @@
   
   isolate->bootstrapThread = vm_new(isolate, JavaThread)();
   isolate->bootstrapThread->initialise(0, isolate);
-#ifndef MULTIPLE_GC
-  mvm::Thread* th = mvm::Thread::get();
-  isolate->bootstrapThread->GC = th->GC;
-#else
+#ifdef MULTIPLE_GC
   isolate->bootstrapThread->GC = isolate->GC;
+  isolate->GC->inject_my_thread(0);
   mvm::jit::memoryManager->addGCForModule(isolate->module, isolate->GC);
 #endif 
   JavaThread::threadKey->set(isolate->bootstrapThread);
@@ -540,5 +538,5 @@
 }
 
 void JavaIsolate::destroyer(size_t sz) {
-  Jnjvm::destroyer();
+  Jnjvm::destroyer(sz);
 }

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.h Thu Apr 17 11:45:26 2008
@@ -31,7 +31,7 @@
   mvm::Cond* nonDaemonVar;
 
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 
   void initialise();
 };
@@ -43,7 +43,7 @@
   JavaThread* bootstrapThread;
   
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
   virtual void destroyer(size_t sz);
 
   JavaObject* loadAppClassLoader();

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Thu Apr 17 11:45:26 2008
@@ -322,8 +322,8 @@
   if (compilingClass->isolate == Jnjvm::bootstrapVM) {
     isolateLocal = args[args.size() - 1];
   } else {
-    ServiceDomain* vm = 
-      (ServiceDomain*)(*Classpath::vmdataClassLoader)(compilingClass->classLoader).PointerVal;
+    JavaObject* loader = compilingClass->classLoader;
+    ServiceDomain* vm = ServiceDomain::getDomainFromLoader(loader);
     isolateLocal = new LoadInst(vm->llvmDelegatee(), "", currentBlock);
   }
 #endif
@@ -450,8 +450,8 @@
   if (compilingClass->isolate == Jnjvm::bootstrapVM) {
     isolateLocal = i;
   } else {
-    ServiceDomain* vm = 
-      (ServiceDomain*)(*Classpath::vmdataClassLoader)(compilingClass->classLoader).PointerVal;
+    JavaObject* loader = compilingClass->classLoader;
+    ServiceDomain* vm = ServiceDomain::getDomainFromLoader(loader);
     isolateLocal = new LoadInst(vm->llvmDelegatee(), "", currentBlock);
   }
 #endif
@@ -1182,9 +1182,24 @@
     val = lowerMathOps(name, args);
   }
 
+
   if (!val) {
     Function* func = ctpInfo->infoOfStaticOrSpecialMethod(index, ACC_VIRTUAL,
                                                           signature, meth);
+#ifdef SERVICE_VM
+    bool serviceCall = false;
+    if (meth && meth->classDef->classLoader != compilingClass->classLoader &&
+        meth->classDef->isolate != Jnjvm::bootstrapVM){
+      JavaObject* loader = meth->classDef->classLoader;
+      ServiceDomain* calling = ServiceDomain::getDomainFromLoader(loader);
+      serviceCall = true;
+      std::vector<Value*> Args;
+      Args.push_back(isolateLocal);
+      Args.push_back(calling->llvmDelegatee());
+      CallInst::Create(ServiceDomain::serviceCallStartLLVM, Args.begin(),
+                       Args.end(), "", currentBlock);
+    }
+#endif
 
     if (meth && meth->canBeInlined && meth != compilingMethod && 
         inlineMethods[meth] == 0) {
@@ -1192,6 +1207,19 @@
     } else {
       val = invoke(func, args, "", currentBlock);
     }
+
+#ifdef SERVICE_VM
+    if (serviceCall) {  
+      JavaObject* loader = meth->classDef->classLoader;
+      ServiceDomain* calling = ServiceDomain::getDomainFromLoader(loader);
+      serviceCall = true;
+      std::vector<Value*> Args;
+      Args.push_back(isolateLocal);
+      Args.push_back(calling->llvmDelegatee());
+      CallInst::Create(ServiceDomain::serviceCallStopLLVM, Args.begin(),
+                       Args.end(), "", currentBlock);
+    }
+#endif
   }
   
   const llvm::Type* retType = signature->virtualType->getReturnType();
@@ -1225,6 +1253,21 @@
   if (!val) {
     Function* func = ctpInfo->infoOfStaticOrSpecialMethod(index, ACC_STATIC,
                                                           signature, meth);
+    
+#ifdef SERVICE_VM
+    bool serviceCall = false;
+    if (meth && meth->classDef->classLoader != compilingClass->classLoader &&
+        meth->classDef->isolate != Jnjvm::bootstrapVM){
+      JavaObject* loader = meth->classDef->classLoader;
+      ServiceDomain* calling = ServiceDomain::getDomainFromLoader(loader);
+      serviceCall = true;
+      std::vector<Value*> Args;
+      Args.push_back(isolateLocal);
+      Args.push_back(calling->llvmDelegatee());
+      CallInst::Create(ServiceDomain::serviceCallStartLLVM, Args.begin(),
+                       Args.end(), "", currentBlock);
+    }
+#endif
 
     if (meth && meth->canBeInlined && meth != compilingMethod && 
         inlineMethods[meth] == 0) {
@@ -1232,6 +1275,18 @@
     } else {
       val = invoke(func, args, "", currentBlock);
     }
+
+#ifdef SERVICE_VM
+    if (serviceCall) {  
+      JavaObject* loader = meth->classDef->classLoader;
+      ServiceDomain* calling = ServiceDomain::getDomainFromLoader(loader);
+      std::vector<Value*> Args;
+      Args.push_back(isolateLocal);
+      Args.push_back(calling->llvmDelegatee());
+      CallInst::Create(ServiceDomain::serviceCallStopLLVM, Args.begin(), Args.end(), "",
+                       currentBlock);
+    }
+#endif
   }
 
   const llvm::Type* retType = signature->staticType->getReturnType();
@@ -1290,6 +1345,14 @@
   ctpInfo->checkInfoOfClass(index);
   
   Class* cl = (Class*)(ctpInfo->getMethodClassIfLoaded(index));
+#ifdef SERVICE_VM
+  if (cl && cl->classLoader != compilingClass->classLoader && 
+      cl->isolate != Jnjvm::bootstrapVM) {
+    ServiceDomain* vm = (ServiceDomain*)JavaThread::get()->isolate;
+    assert(vm->getVirtualTable() == ServiceDomain::VT && "vm not a service?");
+    vm->serviceError("The service called new on another service");
+  }
+#endif
   Value* val = 0;
   if (!cl || !cl->isReady()) {
     Value* node = getInitializedClass(index);

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp Thu Apr 17 11:45:26 2008
@@ -24,6 +24,9 @@
 #include "JavaThread.h"
 #include "Jnjvm.h"
 #include "JnjvmModuleProvider.h"
+#ifdef SERVICE_VM
+#include "ServiceDomain.h"
+#endif
 
 using namespace jnjvm;
 using namespace llvm;
@@ -144,10 +147,17 @@
   {
   std::vector<const Type*> args;
   args.push_back(JavaObject::llvmType);
+#ifdef MULTIPLE_GC
+  args.push_back(mvm::jit::ptrType);
+#endif
   const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
   javaObjectTracerLLVM = Function::Create(type,
                                       GlobalValue::ExternalLinkage,
-                                      "_ZN5jnjvm10JavaObject6tracerEj",
+#ifdef MULTIPLE_GC
+                                      "_ZN5jnjvm10JavaObject6tracerEPv",
+#else
+                                      "_ZN5jnjvm10JavaObject6tracerEv",
+#endif
                                       module);
   }
   
@@ -545,19 +555,41 @@
     
   }
 
-
 #ifdef WITH_TRACER
   // Create markAndTraceLLVM
   {
   std::vector<const Type*> args;
   args.push_back(JavaObject::llvmType);
+#ifdef MULTIPLE_GC
+  args.push_back(mvm::jit::ptrType);
+#endif
   markAndTraceLLVMType = FunctionType::get(llvm::Type::VoidTy, args, false);
   markAndTraceLLVM = Function::Create(markAndTraceLLVMType,
                                   GlobalValue::ExternalLinkage,
+#ifdef MULTIPLE_GC
+                                  "_ZNK2gc12markAndTraceEP9Collector",
+#else
                                   "_ZNK2gc12markAndTraceEv",
+#endif
                                   module);
   }
 #endif
+#ifdef SERVICE_VM
+  // Create serviceCallStart/Stop
+  {
+  std::vector<const Type*> args;
+  args.push_back(mvm::jit::ptrType);
+  args.push_back(mvm::jit::ptrType);
+  const FunctionType* type = FunctionType::get(llvm::Type::VoidTy, args, false);
+  ServiceDomain::serviceCallStartLLVM = 
+    Function::Create(type, GlobalValue::ExternalLinkage, "serviceCallStart",
+                     module);
+  
+  ServiceDomain::serviceCallStopLLVM = 
+    Function::Create(type, GlobalValue::ExternalLinkage, "serviceCallStop",
+                     module);
+  }
+#endif
   mvm::jit::unprotectTypes();//->unlock();
   mvm::jit::protectConstants();//->lock();
   constantUTF8Null = Constant::getNullValue(UTF8::llvmType); 

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp Thu Apr 17 11:45:26 2008
@@ -191,13 +191,26 @@
   Argument* arg = func->arg_begin();
   BasicBlock* block = BasicBlock::Create("", func);
   llvm::Value* realArg = new BitCastInst(arg, type, "", block);
-  
+
+#ifdef MULTIPLE_GC
+  Value* GC = ++func->arg_begin();
+  std::vector<Value*> Args;
+  Args.push_back(arg);
+  Args.push_back(GC);
+  if (stat || cl->super == 0) {
+    CallInst::Create(javaObjectTracerLLVM, Args.begin(), Args.end(), "", block);
+  } else {
+    CallInst::Create(((Class*)cl->super)->virtualTracer, Args.begin(),
+                     Args.end(), "", block);
+  }
+#else  
   if (stat || cl->super == 0) {
     CallInst::Create(javaObjectTracerLLVM, arg, "", block);
   } else {
     CallInst::Create(((Class*)cl->super)->virtualTracer, arg, "", block);
   }
-
+#endif
+  
   for (std::vector<JavaField*>::iterator i = fields.begin(), 
             e = fields.end(); i!= e; ++i) {
     if ((*i)->signature->funcs->doTrace) {
@@ -208,7 +221,14 @@
                                          block);
       Value* val = new LoadInst(ptr, "", block);
       Value* valCast = new BitCastInst(val, JavaObject::llvmType, "", block);
+#ifdef MULTIPLE_GC
+      std::vector<Value*> Args;
+      Args.push_back(valCast);
+      Args.push_back(GC);
+      CallInst::Create(markAndTraceLLVM, Args.begin(), Args.end(), "", block);
+#else
       CallInst::Create(markAndTraceLLVM, valCast, "", block);
+#endif
     }
   }
 

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaObject.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaObject.h Thu Apr 17 11:45:26 2008
@@ -41,7 +41,7 @@
   void wait(JavaThread* th);
   void remove(JavaThread* th);
 
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 };
 
 
@@ -52,7 +52,7 @@
   JavaCond* varcond;
 
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 
   static LockObj* allocate();
   void aquire();
@@ -70,7 +70,7 @@
   static const llvm::Type* llvmType;
   
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
   
   void aquire();
   void unlock();

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaPrimitive.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaPrimitive.h Thu Apr 17 11:45:26 2008
@@ -43,7 +43,7 @@
   static JavaPrimitive* funcsToPrimitive(AssessorDesc* funcs);
 
   virtual void print(mvm::PrintBuffer* buf);
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 };
 
 } // end namespace jnjvm

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaString.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaString.h Thu Apr 17 11:45:26 2008
@@ -25,7 +25,7 @@
   virtual void print(mvm::PrintBuffer* buf) const {
     buf->write("Java string");
   }
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 
   // CLASSPATH FIELDS!!
   const UTF8* value;

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h Thu Apr 17 11:45:26 2008
@@ -48,7 +48,7 @@
   JavaObject* cacheObject; // cache for allocations patching
 
   virtual void print(mvm::PrintBuffer *buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
   virtual void destroyer(size_t sz);
   
   void initialise(JavaObject* thread, Jnjvm* isolate);
@@ -62,6 +62,9 @@
   static bool compareException(Class*);
   static JavaObject* getJavaException();
   void returnFromNative();
+#ifdef SERVICE_VM
+  time_t executionTime;
+#endif
 };
 
 } // end namespace jnjvm

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h Thu Apr 17 11:45:26 2008
@@ -82,7 +82,7 @@
   
 
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 
   static void analyseIntern(const UTF8* name, uint32 pos,
                             uint32 meth, AssessorDesc*& ass,
@@ -118,7 +118,7 @@
   Jnjvm* isolate;
 
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
   
   CommonClass* assocClass(JavaObject* loader);
   void typePrint(mvm::PrintBuffer* buf);
@@ -148,7 +148,7 @@
   uint32 nbIn;
   
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 
   static const llvm::FunctionType* createVirtualType(
                         const std::vector<Typedef*>*, Typedef*);

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.h Thu Apr 17 11:45:26 2008
@@ -36,6 +36,7 @@
 class JavaField;
 class JavaMethod;
 class Class;
+class ClassArray;
 
 class ClasspathThread {
 public:

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp Thu Apr 17 11:45:26 2008
@@ -643,7 +643,7 @@
     ServiceDomain* vm = 
       (ServiceDomain*)(*Classpath::vmdataClassLoader)(loader).PointerVal;
     if (!vm) {
-      vm = ServiceDomain::allocateService(Jnjvm::bootstrapVM);
+      vm = ServiceDomain::allocateService((JavaIsolate*)Jnjvm::bootstrapVM);
       (*Classpath::vmdataClassLoader)(loader, (JavaObject*)vm);
     }
     map = vm->classes;
@@ -693,7 +693,7 @@
     ServiceDomain* vm = 
       (ServiceDomain*)(*Classpath::vmdataClassLoader)(loader).PointerVal;
     if (!vm) {
-      vm = ServiceDomain::allocateService(Jnjvm::bootstrapVM);
+      vm = ServiceDomain::allocateService((JavaIsolate*)Jnjvm::bootstrapVM);
       (*Classpath::vmdataClassLoader)(loader, (JavaObject*)vm);
     }
     map = vm->classes;
@@ -735,7 +735,7 @@
     ServiceDomain* vm = 
       (ServiceDomain*)(*Classpath::vmdataClassLoader)(loader).PointerVal;
     if (!vm) {
-      vm = ServiceDomain::allocateService(Jnjvm::bootstrapVM);
+      vm = ServiceDomain::allocateService((JavaIsolate*)Jnjvm::bootstrapVM);
       (*Classpath::vmdataClassLoader)(loader, (JavaObject*)vm);
     }
     map = vm->classes;
@@ -837,6 +837,7 @@
 
 #ifndef MULTIPLE_VM
 JavaObject* Jnjvm::getClassDelegatee(CommonClass* cl) {
+  cl->aquire();
   if (!(cl->delegatee)) {
     JavaObject* delegatee = (*Classpath::newClass)(this);
     cl->delegatee = delegatee;
@@ -848,10 +849,12 @@
     Classpath::initClassWithProtectionDomain->invokeIntSpecial(this, delegatee,
                                                                cl, pd);
   }
+  cl->release();
   return cl->delegatee;
 }
 #else
 JavaObject* Jnjvm::getClassDelegatee(CommonClass* cl) {
+  cl->aquire();
   JavaObject* val = delegatees->lookup(cl);
   if (!val) {
     val = (*Classpath::newClass)(this);
@@ -860,15 +863,17 @@
   } else if (val->classOf != Classpath::newClass) {
     JavaObject* pd = val;
     val = (*Classpath::newClass)(this);
+    delegatees->remove(cl);
     delegatees->hash(cl, val);
     Classpath::initClassWithProtectionDomain->invokeIntSpecial(this, val, cl,
                                                                pd);
   }
+  cl->release();
   return val;
 }
 #endif
 
-void Jnjvm::destroyer() {
+void Jnjvm::destroyer(size_t sz) {
 #ifdef MULTIPLE_GC
   GC->destroy();
   delete GC;

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h Thu Apr 17 11:45:26 2008
@@ -218,12 +218,12 @@
   JavaObject* getClassDelegatee(CommonClass*);
   CommonClass* loadInClassLoader(const UTF8* utf8, JavaObject* loader);
 
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
   virtual void print(mvm::PrintBuffer* buf) const {
     buf->write("Jnjvm<>");
   }
   
-  virtual void destroyer();
+  virtual void destroyer(size_t sz);
 
   void addProperty(char* key, char* value);
  
@@ -264,13 +264,13 @@
   JnjvmModuleProvider* TheModuleProvider;
   FunctionMap* functions;
 
-#ifndef MULTIPLE_VM
+#ifndef MULTIPLE_GC
   void* allocateObject(unsigned int sz, VirtualTable* VT) {
     return gc::operator new(sz, VT);
   }
 #else
   void* allocateObject(unsigned int sz, VirtualTable* VT) {
-    return gc::operator new(sz, VT);
+    return gc::operator new(sz, VT, GC);
   }
 #endif
 };

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/LockedMap.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/LockedMap.h Thu Apr 17 11:45:26 2008
@@ -73,6 +73,12 @@
       return ((Container)(I->second));
     }
   }
+  
+  inline void remove(Key V) {
+    lock->lock();
+    map.erase(V);
+    lock->unlock();
+  }
 
   inline Container lookup(Key V) {
     lock->lock();
@@ -108,12 +114,7 @@
   const UTF8* lookupAsciiz(const char* asciiz); 
   const UTF8* lookupReader(const uint16* buf, uint32 size);
   
-  virtual void tracer(size_t sz) {
-    //lock->markAndTrace();
-    for (iterator i = map.begin(), e = map.end(); i!= e; ++i) {
-      i->second->markAndTrace();
-    }
-  }
+  virtual void TRACER;
 
   virtual void print(mvm::PrintBuffer* buf) {
     buf->write("UTF8 Hashtable<>");
@@ -160,12 +161,7 @@
     lock = mvm::Lock::allocNormal();
   }
   
-  virtual void tracer(size_t sz) {
-    //lock->markAndTrace();
-    for (iterator i = map.begin(), e = map.end(); i!= e; ++i) {
-      i->second->markAndTrace();
-    }
-  }
+  virtual void TRACER;
 };
 
 class FieldMap :
@@ -177,12 +173,7 @@
     lock = mvm::Lock::allocNormal();
   }
   
-  virtual void tracer(size_t sz) {
-    //lock->markAndTrace();
-    for (iterator i = map.begin(), e = map.end(); i!= e; ++i) {
-      i->second->markAndTrace();
-    }
-  }
+  virtual void TRACER;
 };
 
 class MethodMap :
@@ -194,12 +185,7 @@
     lock = mvm::Lock::allocNormal();
   }
   
-  virtual void tracer(size_t sz) {
-    //lock->markAndTrace();
-    for (iterator i = map.begin(), e = map.end(); i!= e; ++i) {
-      i->second->markAndTrace();
-    }
-  }
+  virtual void TRACER;
 };
 
 struct ltstr
@@ -219,12 +205,7 @@
     lock = mvm::Lock::allocNormal();
   }
   
-  virtual void tracer(size_t sz) {
-    //lock->markAndTrace();
-    for (iterator i = map.begin(), e = map.end(); i!= e; ++i) {
-      i->second->markAndTrace();
-    }
-  }
+  virtual void TRACER;
 };
 
 class StringMap :
@@ -236,12 +217,7 @@
     lock = mvm::Lock::allocRecursive();
   }
   
-  virtual void tracer(size_t sz) {
-    //lock->markAndTrace();
-    for (iterator i = map.begin(), e = map.end(); i!= e; ++i) {
-      i->second->markAndTrace();
-    }
-  }
+  virtual void TRACER;
 };
 
 class FunctionMap :
@@ -253,12 +229,7 @@
     lock = mvm::Lock::allocNormal();
   }
 
-  virtual void tracer(size_t sz) {
-    //lock->markAndTrace();
-    for (iterator i = map.begin(), e = map.end(); i!= e; ++i) {
-      i->second->first->markAndTrace();
-    }
-  }
+  virtual void TRACER;
 };
 
 class FunctionDefMap :
@@ -270,12 +241,7 @@
     lock = mvm::Lock::allocNormal();
   }
 
-  virtual void tracer(size_t sz) {
-    //lock->markAndTrace();
-    for (iterator i = map.begin(), e = map.end(); i!= e; ++i) {
-      i->second->markAndTrace();
-    }
-  }
+  virtual void TRACER;
 };
 
 class TypeMap :
@@ -292,12 +258,7 @@
     lock = mvm::Lock::allocRecursive();
   }
   
-  virtual void tracer(size_t sz) {
-    //lock->markAndTrace();
-    for (iterator i = map.begin(), e = map.end(); i!= e; ++i) {
-      i->second->markAndTrace();
-    }
-  }
+  virtual void TRACER;
     
 };
 
@@ -310,13 +271,7 @@
     lock = mvm::Lock::allocNormal();
   }
   
-  virtual void tracer(size_t sz) {
-    //lock->markAndTrace();
-    for (iterator i = map.begin(), e = map.end(); i!= e; ++i) {
-      i->first->markAndTrace();
-      i->second->second->markAndTrace();
-    }
-  }
+  virtual void TRACER;
 
   virtual void destroyer(size_t sz) {
     for (iterator i = map.begin(), e = map.end(); i!= e; ++i) {
@@ -334,13 +289,7 @@
     lock = mvm::Lock::allocNormal();
   }
   
-  virtual void tracer(size_t sz) {
-    //lock->markAndTrace();
-    for (iterator i = map.begin(), e = map.end(); i!= e; ++i) {
-      i->first->markAndTrace();
-      i->second->markAndTrace();
-    }
-  }
+  virtual void TRACER;
 }; 
 
 } // end namespace jnjvm

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Reader.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Reader.h Thu Apr 17 11:45:26 2008
@@ -51,7 +51,7 @@
   void seek(uint32 pos, int from);
 
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 };
 
 } // end namespace jnjvm

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp Thu Apr 17 11:45:26 2008
@@ -10,6 +10,8 @@
 #include "mvm/JIT.h"
 
 #include "JavaJIT.h"
+#include "JavaThread.h"
+#include "JavaUpcalls.h"
 #include "JnjvmModuleProvider.h"
 #include "ServiceDomain.h"
 
@@ -19,8 +21,12 @@
 extern "C" struct JNINativeInterface JNI_JNIEnvTable;
 extern "C" const struct JNIInvokeInterface JNI_JavaVMTable;
 
+
 using namespace jnjvm;
 
+llvm::Function* ServiceDomain::serviceCallStartLLVM;
+llvm::Function* ServiceDomain::serviceCallStopLLVM;
+
 
 GlobalVariable* ServiceDomain::llvmDelegatee() {
   if (!_llvmDelegatee) {
@@ -48,11 +54,8 @@
 
 
 void ServiceDomain::destroyer(size_t sz) {
-  mvm::jit::protectEngine->lock();
-  mvm::jit::executionEngine->removeModuleProvider(TheModuleProvider);
-  mvm::jit::protectEngine->unlock();
-  delete TheModuleProvider;
-  delete module;
+  Jnjvm::destroyer(sz);
+  delete lock;
 }
 
 void ServiceDomain::print(mvm::PrintBuffer* buf) const {
@@ -60,9 +63,13 @@
   buf->write(name);
 }
 
-ServiceDomain* ServiceDomain::allocateService(Jnjvm* callingVM) {
+ServiceDomain* ServiceDomain::allocateService(JavaIsolate* callingVM) {
   ServiceDomain* service = vm_new(callingVM, ServiceDomain)();
-  
+  service->threadSystem = callingVM->threadSystem;
+#ifdef MULTIPLE_GC
+  service->GC = Collector::allocate();
+#endif
+
   service->functions = vm_new(service, FunctionMap)();
   service->module = new llvm::Module("Service Domain");
   service->protectModule = mvm::Lock::allocNormal();
@@ -92,7 +99,6 @@
   // Here are the classes it loaded
   service->classes = vm_new(service, ClassMap)();
 
-  service->started = 0;
   service->executionTime = 0;
   service->memoryUsed = 0;
   service->gcTriggered = 0;
@@ -109,3 +115,41 @@
   loadName(asciizConstructUTF8("java/lang/Math"), 
            CommonClass::jnjvmClassLoader, true, true, true);
 }
+
+void ServiceDomain::serviceError(const char* str) {
+  fprintf(stderr, str);
+  abort();
+}
+
+ServiceDomain* ServiceDomain::getDomainFromLoader(JavaObject* loader) {
+  ServiceDomain* vm = 
+    (ServiceDomain*)(*Classpath::vmdataClassLoader)(loader).PointerVal;
+  return vm;
+}
+
+#ifdef SERVICE_VM
+extern "C" void ServiceDomainStart(ServiceDomain* caller,
+                                   ServiceDomain* callee) {
+  JavaThread* th = JavaThread::get();
+  th->isolate = callee;
+  time_t t = time(NULL);
+  caller->lock->lock();
+  caller->executionTime += t - th->executionTime;
+  caller->interactions[callee]++;
+  caller->lock->unlock();
+  th->executionTime = t;
+
+}
+
+extern "C" void ServiceDomainStop(ServiceDomain* caller,
+                                  ServiceDomain* callee) {
+  JavaThread* th = JavaThread::get();
+  th->isolate = caller;
+  time_t t = time(NULL);
+  callee->lock->lock();
+  callee->executionTime += t - th->executionTime;
+  callee->lock->unlock();
+  th->executionTime = t;
+}
+
+#endif

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h Thu Apr 17 11:45:26 2008
@@ -11,11 +11,15 @@
 #define JNJVM_SERVICE_DOMAIN_H
 
 #include <sys/time.h>
+#include <time.h>
 
-#include "Jnjvm.h"
+#include <map>
+
+#include "JavaIsolate.h"
 
 namespace llvm {
   class GlobalVariable;
+  class Function;
 }
 
 namespace mvm {
@@ -26,26 +30,32 @@
 
 class ClassMap;
 
-class ServiceDomain : public Jnjvm {
+class ServiceDomain : public JavaIsolate {
 private:
   llvm::GlobalVariable* _llvmDelegatee;
-  mvm::Lock* lock;
 public:
   static VirtualTable* VT;
 
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
   virtual void destroyer(size_t sz);
   void loadBootstrap();
-  static ServiceDomain* allocateService(Jnjvm* callingVM);
+  static ServiceDomain* allocateService(JavaIsolate* callingVM);
   llvm::GlobalVariable* llvmDelegatee();
+  void serviceError(const char* str);
   
+  mvm::Lock* lock;
   ClassMap* classes;
-  time_t started;
+  struct timeval started;
   uint64 executionTime;
   uint64 memoryUsed;
   uint64 gcTriggered;
   uint64 numThreads;
+  std::map<ServiceDomain*, uint64> interactions;
+
+  static ServiceDomain* getDomainFromLoader(JavaObject* loader);
+  static llvm::Function* serviceCallStartLLVM;
+  static llvm::Function* serviceCallStopLLVM;
 };
 
 } // end namespace jnjvm

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp Thu Apr 17 11:45:26 2008
@@ -82,20 +82,20 @@
 
 #undef INIT
 
-void JavaArray::tracer(size_t sz) {
-  JavaObject::tracer(sz);
+void JavaArray::TRACER {
+  JavaObject::PARENT_TRACER;
 }
 
-void ArrayObject::tracer(size_t sz) {
-  JavaObject::tracer(sz);
+void ArrayObject::TRACER {
+  JavaObject::PARENT_TRACER;
   for (sint32 i = 0; i < size; i++) {
-    elements[i]->markAndTrace();
+    elements[i]->MARK_AND_TRACE;
   }
 }
 
 #define ARRAYTRACER(name)         \
-  void name::tracer(size_t sz) {  \
-    JavaObject::tracer(sz);       \
+  void name::TRACER {             \
+    JavaObject::PARENT_TRACER;    \
   }
   
 
@@ -112,181 +112,250 @@
 #undef ARRAYTRACER
 
 
-void Attribut::tracer(size_t sz) {
-  name->markAndTrace();
+void Attribut::TRACER {
+  name->MARK_AND_TRACE;
 }
 
 #define TRACE_VECTOR(type,alloc,name) {                             \
   for (std::vector<type, alloc<type> >::iterator i = name.begin(),  \
        e = name.end(); i!= e; ++i) {                                \
-    (*i)->markAndTrace(); }}
+    (*i)->MARK_AND_TRACE; }}
 
-void CommonClass::tracer(size_t sz) {
-  name->markAndTrace();
-  super->markAndTrace();
-  superUTF8->markAndTrace();
+void CommonClass::TRACER {
+  name->MARK_AND_TRACE;
+  super->MARK_AND_TRACE;
+  superUTF8->MARK_AND_TRACE;
   TRACE_VECTOR(const UTF8*, std::allocator, interfacesUTF8);
   TRACE_VECTOR(Class*, std::allocator, interfaces);
-  //lockVar->markAndTrace();
-  //condVar->markAndTrace();
+  //lockVar->MARK_AND_TRACE;
+  //condVar->MARK_AND_TRACE;
   TRACE_VECTOR(JavaMethod*, std::allocator, virtualMethods);
   TRACE_VECTOR(JavaMethod*, std::allocator, staticMethods);
   TRACE_VECTOR(JavaField*, std::allocator, virtualFields);
   TRACE_VECTOR(JavaField*, std::allocator, staticFields);
-  classLoader->markAndTrace();
+  classLoader->MARK_AND_TRACE;
 #ifndef MULTIPLE_VM
-  delegatee->markAndTrace();
+  delegatee->MARK_AND_TRACE;
 #endif
   TRACE_VECTOR(CommonClass*, std::allocator, display);
-  isolate->markAndTrace();
+  isolate->MARK_AND_TRACE;
 }
 
-void Class::tracer(size_t sz) {
-  CommonClass::tracer(sz);
-  bytes->markAndTrace();
-  _staticInstance->markAndTrace();
-  virtualInstance->markAndTrace();
-  ctpInfo->markAndTrace();
+void Class::TRACER {
+  CommonClass::PARENT_TRACER;
+  bytes->MARK_AND_TRACE;
+  _staticInstance->MARK_AND_TRACE;
+  virtualInstance->MARK_AND_TRACE;
+  ctpInfo->MARK_AND_TRACE;
   TRACE_VECTOR(Attribut*, gc_allocator, attributs);
   TRACE_VECTOR(Class*, std::allocator, innerClasses);
-  outerClass->markAndTrace();
-  codeStaticTracer->markAndTrace();
-  codeVirtualTracer->markAndTrace();
+  outerClass->MARK_AND_TRACE;
+  codeStaticTracer->MARK_AND_TRACE;
+  codeVirtualTracer->MARK_AND_TRACE;
 }
 
-void ClassArray::tracer(size_t sz) {
-  CommonClass::tracer(sz);
-  _baseClass->markAndTrace();
-  _funcs->markAndTrace();
+void ClassArray::TRACER {
+  CommonClass::PARENT_TRACER;
+  _baseClass->MARK_AND_TRACE;
+  _funcs->MARK_AND_TRACE;
 
 }
 
-void JavaMethod::tracer(size_t sz) {
-  signature->markAndTrace();
+void JavaMethod::TRACER {
+  signature->MARK_AND_TRACE;
   TRACE_VECTOR(Attribut*, gc_allocator, attributs);
   TRACE_VECTOR(Enveloppe*, gc_allocator, caches);
-  classDef->markAndTrace();
-  name->markAndTrace();
-  type->markAndTrace();
-  code->markAndTrace();
+  classDef->MARK_AND_TRACE;
+  name->MARK_AND_TRACE;
+  type->MARK_AND_TRACE;
+  code->MARK_AND_TRACE;
 }
 
-void JavaField::tracer(size_t sz) {
-  name->markAndTrace();
-  signature->markAndTrace();
-  type->markAndTrace();
+void JavaField::TRACER {
+  name->MARK_AND_TRACE;
+  signature->MARK_AND_TRACE;
+  type->MARK_AND_TRACE;
   TRACE_VECTOR(Attribut*, gc_allocator, attributs);
-  classDef->markAndTrace();
+  classDef->MARK_AND_TRACE;
 }
 
-void JavaCtpInfo::tracer(size_t sz) {
-  classDef->markAndTrace();
+void JavaCtpInfo::TRACER {
+  classDef->MARK_AND_TRACE;
   // Everything is hashed in the constant pool,
   // do not trace them here
 }
 
-void JavaCond::tracer(size_t sz) {
+void JavaCond::TRACER {
   TRACE_VECTOR(JavaThread*, std::allocator, threads);
 }
 
-void LockObj::tracer(size_t sz) {
-  //lock->markAndTrace();
-  varcond->markAndTrace();
+void LockObj::TRACER {
+  //lock->MARK_AND_TRACE;
+  varcond->MARK_AND_TRACE;
 }
 
-void JavaObject::tracer(size_t sz) {
-  classOf->markAndTrace();
-  lockObj->markAndTrace();
+void JavaObject::TRACER {
+  classOf->MARK_AND_TRACE;
+  lockObj->MARK_AND_TRACE;
 }
 
-void JavaThread::tracer(size_t sz) {
-  javaThread->markAndTrace();
-  isolate->markAndTrace();
-  //lock->markAndTrace();
-  //varcond->markAndTrace();
-  pendingException->markAndTrace();
+void JavaThread::TRACER {
+  javaThread->MARK_AND_TRACE;
+  isolate->MARK_AND_TRACE;
+  //lock->MARK_AND_TRACE;
+  //varcond->MARK_AND_TRACE;
+  pendingException->MARK_AND_TRACE;
 }
 
-void AssessorDesc::tracer(size_t sz) {
-  classType->markAndTrace();
+void AssessorDesc::TRACER {
+  classType->MARK_AND_TRACE;
 }
 
-void Typedef::tracer(size_t sz) {
-  keyName->markAndTrace();
-  pseudoAssocClassName->markAndTrace();
-  funcs->markAndTrace();
-  isolate->markAndTrace();
+void Typedef::TRACER {
+  keyName->MARK_AND_TRACE;
+  pseudoAssocClassName->MARK_AND_TRACE;
+  funcs->MARK_AND_TRACE;
+  isolate->MARK_AND_TRACE;
 }
 
-void Signdef::tracer(size_t sz) {
-  Typedef::tracer(sz);
+void Signdef::TRACER {
+  Typedef::PARENT_TRACER;
   TRACE_VECTOR(Typedef*, std::allocator, args);
-  ret->markAndTrace();
-  _staticCallBuf->markAndTrace();
-  _virtualCallBuf->markAndTrace();
-  _staticCallAP->markAndTrace();
-  _virtualCallAP->markAndTrace();
-}
-
-void ThreadSystem::tracer(size_t sz) {
-  //nonDaemonLock->markAndTrace();
-  //nonDaemonVar->markAndTrace();
-}
-
-void Jnjvm::tracer(size_t sz) {
-  appClassLoader->markAndTrace();
-  hashUTF8->markAndTrace();
-  hashStr->markAndTrace();
-  bootstrapClasses->markAndTrace();
-  loadedMethods->markAndTrace();
-  loadedFields->markAndTrace();
-  javaTypes->markAndTrace();
+  ret->MARK_AND_TRACE;
+  _staticCallBuf->MARK_AND_TRACE;
+  _virtualCallBuf->MARK_AND_TRACE;
+  _staticCallAP->MARK_AND_TRACE;
+  _virtualCallAP->MARK_AND_TRACE;
+}
+
+void ThreadSystem::TRACER {
+  //nonDaemonLock->MARK_AND_TRACE;
+  //nonDaemonVar->MARK_AND_TRACE;
+}
+
+void Jnjvm::TRACER {
+  appClassLoader->MARK_AND_TRACE;
+  hashUTF8->MARK_AND_TRACE;
+  hashStr->MARK_AND_TRACE;
+  bootstrapClasses->MARK_AND_TRACE;
+  loadedMethods->MARK_AND_TRACE;
+  loadedFields->MARK_AND_TRACE;
+  javaTypes->MARK_AND_TRACE;
   TRACE_VECTOR(JavaObject*, gc_allocator, globalRefs);
-  //globalRefsLock->markAndTrace();
-  functions->markAndTrace();
+  //globalRefsLock->MARK_AND_TRACE;
+  functions->MARK_AND_TRACE;
 #ifdef MULTIPLE_VM
-  statics->markAndTrace();
-  delegatees->markAndTrace();
+  statics->MARK_AND_TRACE;
+  delegatees->MARK_AND_TRACE;
 #endif
-  //protectModule->markAndTrace();
+  //protectModule->MARK_AND_TRACE;
 }
 
-void Reader::tracer(size_t sz) {
-  bytes->markAndTrace();
+void Reader::TRACER {
+  bytes->MARK_AND_TRACE;
 }
 
-void ZipFile::tracer(size_t sz) {
+void ZipFile::TRACER {
 }
 
-void ZipArchive::tracer(size_t sz) {
-  reader->markAndTrace();
-  filetable->markAndTrace();
+void ZipArchive::TRACER {
+  reader->MARK_AND_TRACE;
+  filetable->MARK_AND_TRACE;
 }
 
-void JavaIsolate::tracer(size_t sz) {
-  Jnjvm::tracer(sz);
-  threadSystem->markAndTrace();
-  bootstrapThread->markAndTrace();
+void JavaIsolate::TRACER {
+  Jnjvm::PARENT_TRACER;
+  threadSystem->MARK_AND_TRACE;
+  bootstrapThread->MARK_AND_TRACE;
 }
 
-void JavaString::tracer(size_t sz) {
+void JavaString::TRACER {
 }
 
-void CacheNode::tracer(size_t sz) {
-  ((mvm::Object*)methPtr)->markAndTrace();
-  lastCible->markAndTrace();
-  next->markAndTrace();
-  enveloppe->markAndTrace();
+void CacheNode::TRACER {
+  ((mvm::Object*)methPtr)->MARK_AND_TRACE;
+  lastCible->MARK_AND_TRACE;
+  next->MARK_AND_TRACE;
+  enveloppe->MARK_AND_TRACE;
 }
 
-void Enveloppe::tracer(size_t sz) {
-  firstCache->markAndTrace();
-  ctpInfo->markAndTrace();
-  //cacheLock->markAndTrace();
+void Enveloppe::TRACER {
+  firstCache->MARK_AND_TRACE;
+  ctpInfo->MARK_AND_TRACE;
+  //cacheLock->MARK_AND_TRACE;
+}
+
+void UTF8Map::TRACER {
+  for (iterator i = map.begin(), e = map.end(); i!= e; ++i) {
+    i->second->MARK_AND_TRACE;
+  }
+}
+
+void ClassMap::TRACER {
+  for (iterator i = map.begin(), e = map.end(); i!= e; ++i) {
+    i->second->MARK_AND_TRACE;
+  }
+}
+
+void FieldMap::TRACER {
+  for (iterator i = map.begin(), e = map.end(); i!= e; ++i) {
+    i->second->MARK_AND_TRACE;
+  }
+}
+
+  
+void MethodMap::TRACER {
+  for (iterator i = map.begin(), e = map.end(); i!= e; ++i) {
+    i->second->MARK_AND_TRACE;
+  }
+}
+
+void ZipFileMap::TRACER {
+  for (iterator i = map.begin(), e = map.end(); i!= e; ++i) {
+    i->second->MARK_AND_TRACE;
+  }
+}
+
+void StringMap::TRACER {
+  for (iterator i = map.begin(), e = map.end(); i!= e; ++i) {
+    i->second->MARK_AND_TRACE;
+  }
+}
+
+void FunctionMap::TRACER {
+  for (iterator i = map.begin(), e = map.end(); i!= e; ++i) {
+    i->second->first->MARK_AND_TRACE;
+  }
+}
+
+void FunctionDefMap::TRACER {
+  for (iterator i = map.begin(), e = map.end(); i!= e; ++i) {
+    i->second->MARK_AND_TRACE;
+  }
+}
+
+void TypeMap::TRACER {
+  for (iterator i = map.begin(), e = map.end(); i!= e; ++i) {
+    i->second->MARK_AND_TRACE;
+  }
+}
+
+void StaticInstanceMap::TRACER {
+  for (iterator i = map.begin(), e = map.end(); i!= e; ++i) {
+    i->first->MARK_AND_TRACE;
+    i->second->second->MARK_AND_TRACE;
+  }
+}
+
+void DelegateeMap::TRACER {
+  for (iterator i = map.begin(), e = map.end(); i!= e; ++i) {
+    i->first->MARK_AND_TRACE;
+    i->second->MARK_AND_TRACE;
+  }
 }
 
 #ifdef SERVICE_VM
-void ServiceDomain::tracer(size_t sz) {
-  Jnjvm::tracer(sz);
+void ServiceDomain::TRACER {
+  JavaIsolate::PARENT_TRACER;
 }
 #endif

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Zip.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Zip.h Thu Apr 17 11:45:26 2008
@@ -39,7 +39,7 @@
     buf->write(filename);
     buf->write(">");
   }
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 };
 
 class ZipArchive : public mvm::Object {
@@ -56,7 +56,7 @@
     buf->write(name);
     buf->write(">");
   }
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 
   static ZipArchive* hashedArchive(Jnjvm* vm, char* archname);
   static ZipArchive* singleArchive(Jnjvm* vm, char* archname);

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

==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h Thu Apr 17 11:45:26 2008
@@ -18,12 +18,25 @@
 #define gc_new(Class)  __gc_new(Class::VT) Class
 #define __gc_new new
 
+
+#ifdef MULTIPLE_GC
+#define TRACER tracer(void* GC)
+#define PARENT_TRACER tracer(GC)
+#define MARK_AND_TRACE markAndTrace((Collector*)GC)
+#else
+#define TRACER tracer()
+#define PARENT_TRACER tracer()
+#define MARK_AND_TRACE markAndTrace()
+#endif
+
 class Collector;
 
 class gc : public gcRoot {
 public:
-  
+ 
+#ifndef MULTIPLE_GC
   void    markAndTrace() const;
+#endif
   size_t  objectSize() const;
   void *  operator new(size_t sz, VirtualTable *VT);
   void *  operator new(size_t sz);
@@ -65,7 +78,9 @@
   STATIC void           collect(void);
   STATIC void           inject_my_thread(void *sp);
   STATIC void           remove_my_thread();
+#ifdef MULTIPLE_GC
   static Collector*     allocate();
+#endif
 
   STATIC gc             *begOf(const void *o);
   STATIC int            byteOffset(void *o);

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

==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp Thu Apr 17 11:45:26 2008
@@ -26,9 +26,15 @@
 
 memoryError_t GCCollector::internMemoryError;
 
+#ifdef MULTIPLE_GC
+void gc::markAndTrace(Collector* GC) const {
+  ((GCCollector*)GC)->markAndTrace((void*)this);
+}
+#else
 void gc::markAndTrace() const {
-  COLLECTOR markAndTrace((void*)this);
+  GCCollector::markAndTrace((void*)this);
 }
+#endif
 
 size_t gc::objectSize() const {
   return COLLECTOR objectSize((gc*)this);
@@ -52,9 +58,6 @@
 
 
 #ifdef MULTIPLE_GC
-void gc::markAndTrace(Collector* GC) const {
-  ((GCCollector*)GC)->markAndTrace((void*)this);
-}
 
 size_t gc::objectSize(Collector* GC) const {
   return ((GCCollector*)GC)->objectSize((gc*)this);
@@ -104,6 +107,7 @@
 void Collector::initialise(markerFn marker, void *base_sp) {
 #ifdef MULTIPLE_GC
   GCCollector* GC = new GCCollector();
+  GCCollector::bootstrapGC = GC;
   mvm::Thread::get()->GC = GC;
   GC->initialise(marker);
   GC->inject_my_thread(base_sp);
@@ -190,8 +194,12 @@
 
 #undef COLLECTOR
 void GCCollector::siggc_handler(int) {
-#ifdef MULTIPLE_GC
+#if defined(MULTIPLE_GC)
+#if defined(SERVICE_GC)
+  GCCollector* GC = collectingGC;
+#else
   GCCollector* GC = ((GCCollector*)mvm::Thread::get()->GC);
+#endif
 #define COLLECTOR GC->
 #else
 #define COLLECTOR GCCollector::
@@ -227,12 +235,12 @@
   COLLECTOR threads->stackUnlock();
 #undef COLLECTOR
 }
-#endif
-
+#endif // HAVE_PTHREAD
 
+#ifdef MULTIPLE_GC
 Collector* Collector::allocate() {
   GCCollector* GC = new GCCollector();
-  GC->initialise(0);
+  GC->initialise(GCCollector::bootstrapGC->_marker);
   return GC;
 }
-
+#endif // MULTIPLE_GC

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

==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp Thu Apr 17 11:45:26 2008
@@ -34,8 +34,13 @@
 GCChunkNode    *GCCollector::unused_nodes;
 
 unsigned int   GCCollector::current_mark;
+#else
+GCCollector* GCCollector::bootstrapGC;
 #endif
 
+#ifdef SERVICE_GC
+GCCollector* GCCollector::collectingGC;
+#endif
 
 void GCCollector::do_collect() {
 	//printf("----- do collect -----\n");
@@ -48,6 +53,10 @@
 
  	unused_nodes->attrape(used_nodes);
 
+#ifdef SERVICE_GC
+  collectingGC = this;
+#endif
+
 #ifdef HAVE_PTHREAD
 	threads->synchronize();
 #endif
@@ -81,7 +90,7 @@
 		//printf("    !!!! reject %p [%p]\n", cur->chunk()->_2gc(), cur);
  		allocator->reject_chunk(cur);
  	}
-
+  used_nodes->alone();
 }
 
 void GCCollector::collect_unprotect() {

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

==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h Thu Apr 17 11:45:26 2008
@@ -31,7 +31,6 @@
 #endif
   STATIC GCAllocator  *allocator;      /* The allocator */
 
-  STATIC Collector::markerFn  _marker; /* The function which traces roots */
 
   STATIC GCChunkNode  *used_nodes;     /* Used memory nodes */
   STATIC GCChunkNode  *unused_nodes;   /* Unused memory nodes */
@@ -45,7 +44,8 @@
   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
@@ -72,6 +72,13 @@
   }
 
 public:
+  STATIC Collector::markerFn  _marker; /* The function which traces roots */
+#ifdef SERVICE_GC
+  static GCCollector* collectingGC;
+#endif
+#ifdef MULTIPLE_GC
+  static GCCollector* bootstrapGC;
+#endif
   STATIC GCThread *threads;        /* le gestionnaire de thread et de synchro */
   static void (*internMemoryError)(unsigned int);
 
@@ -206,7 +213,11 @@
 
   STATIC inline void trace(GCChunkNode *node) {
     gc_header *o = node->chunk();
-    o->_2gc()->tracer(real_nbb(node));
+#ifdef MULTIPLE_GC
+    o->_2gc()->tracer(this);
+#else
+    o->_2gc()->tracer();
+#endif
     markAndTrace(o);
   }
 

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

==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cpp (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cpp Thu Apr 17 11:45:26 2008
@@ -30,8 +30,15 @@
   used_nodes = new GCChunkNode();
   unused_nodes = new GCChunkNode();
 #ifdef HAVE_PTHREAD
+#ifdef SERVICE_GC
+  if (this != bootstrapGC)
+    threads = bootstrapGC->threads;
+  else
+    threads = new GCThread();
+#else
   threads = new GCThread();
 #endif
+#endif
   
   struct sigaction sa;
 	sigset_t mask;

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

==============================================================================
--- vmkit/trunk/lib/Mvm/JIT.cpp (original)
+++ vmkit/trunk/lib/Mvm/JIT.cpp Thu Apr 17 11:45:26 2008
@@ -553,17 +553,8 @@
 
   constantPtrNull = Constant::getNullValue(ptrType); 
   arrayPtrType = PointerType::getUnqual(ArrayType::get(Type::Int8Ty, 0));
-  
 
-  //mvm::jit::protectTypes = mvm::Lock::allocNormal();
-  //mvm::Object::pushRoot((mvm::Object*)mvm::jit::protectTypes);
-  
-  //mvm::jit::protectConstants = mvm::Lock::allocNormal();
-  //mvm::Object::pushRoot((mvm::Object*)mvm::jit::protectConstants);
-  
   mvm::jit::protectEngine = mvm::Lock::allocNormal();
-  mvm::Object::pushRoot((mvm::Object*)mvm::jit::protectEngine);
-
 }
 
 llvm::Function* mvm::jit::llvm_memcpy_i32;

Modified: vmkit/trunk/lib/Mvm/MvmMemoryManager.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/MvmMemoryManager.cpp?rev=49859&r1=49858&r2=49859&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/MvmMemoryManager.cpp (original)
+++ vmkit/trunk/lib/Mvm/MvmMemoryManager.cpp Thu Apr 17 11:45:26 2008
@@ -20,8 +20,8 @@
 unsigned char* MvmMemoryManager::startFunctionBody(const Function* F, 
                                                    uintptr_t &ActualSize) {
   size_t nbb = ((ActualSize - 1) & -4) + 4 + sizeof(Method *);
-#ifdef MUTLIPLE_GC
-  Collector* GC = GCMap[F->getModule()];
+#ifdef MULTIPLE_GC
+  Collector* GC = GCMap[F->getParent()];
   assert(GC && "GC not available in a multi-GC environment");
   Code *res = (Code *)gc::operator new(nbb, Code::VT, GC);
   Method* meth = collector_new(Method, GC)(res, ActualSize);
@@ -29,6 +29,7 @@
   Code *res = (Code *)gc::operator new(nbb, Code::VT);
   Method* meth = gc_new(Method)(res, ActualSize);
 #endif
+  meth->llvmFunction = F;
   res->method(meth);
   currentMethod = meth;
   return (unsigned char*)((unsigned int*)res + 2);
@@ -65,8 +66,8 @@
 
 unsigned char *MvmMemoryManager::startExceptionTable(const Function* F, 
                                                      uintptr_t &ActualSize) {
-#ifdef MUTLIPLE_GC
-  Collector* GC = GCMap[F->getModule()];
+#ifdef MULTIPLE_GC
+  Collector* GC = GCMap[F->getParent()];
   assert(GC && "GC not available in a multi-GC environment");
   ExceptionTable *res = (ExceptionTable*)gc::operator new(ActualSize + 4, 
                                                           ExceptionTable::VT,

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

==============================================================================
--- vmkit/trunk/lib/Mvm/Object.cpp (original)
+++ vmkit/trunk/lib/Mvm/Object.cpp Thu Apr 17 11:45:26 2008
@@ -47,7 +47,11 @@
 
 void Object::markAndTraceRoots(void) {
   for (int i= 0; i < rootTableSize; ++i)
-    rootTable[i]->markAndTrace();
+#ifdef MULTIPLE_GC
+    rootTable[i]->markAndTrace(mvm::Thread::get()->GC);
+#else
+    rootTable[i]->markAndTrace();;
+#endif
 }
 
 void Object::initialise() {
@@ -65,21 +69,21 @@
 #undef INIT
 }
 
-void Code::tracer(size_t sz) {
-  this->method(sz)->markAndTrace();
+void Code::TRACER {
+  this->method()->MARK_AND_TRACE;
 }
 
-void Method::tracer(size_t sz) {
+void Method::TRACER {
   Method *const self= (Method *)this;
-  self->definition()->markAndTrace();
-  self->literals()->markAndTrace();
-  self->name()->markAndTrace();
-  self->code()->markAndTrace();
-  self->exceptionTable()->markAndTrace();
+  self->definition()->MARK_AND_TRACE;
+  self->literals()->MARK_AND_TRACE;
+  self->name()->MARK_AND_TRACE;
+  self->code()->MARK_AND_TRACE;
+  self->exceptionTable()->MARK_AND_TRACE;
 }
 
-void PrintBuffer::tracer(size_t sz) {
-  ((PrintBuffer *)this)->contents()->markAndTrace();
+void PrintBuffer::TRACER {
+  ((PrintBuffer *)this)->contents()->MARK_AND_TRACE;
 }
 
 PrintBuffer *PrintBuffer::alloc(void) {
@@ -88,7 +92,11 @@
 
 
 PrintBuffer *PrintBuffer::writeObj(const Object *obj) {
+#ifdef MULTIPLE_GC
   Object *beg = (Object*)mvm::Thread::get()->GC->begOf(obj);
+#else
+  Object *beg = (Object*)Collector::begOf(obj);
+#endif
   
   if(beg) {
     if(beg == obj) {

Modified: vmkit/trunk/lib/N3/VMCore/Assembly.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/Assembly.h?rev=49859&r1=49858&r2=49859&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/Assembly.h (original)
+++ vmkit/trunk/lib/N3/VMCore/Assembly.h Thu Apr 17 11:45:26 2008
@@ -53,7 +53,7 @@
 public:
   static VirtualTable* VT;
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
   
   char* name;
   uint32 virtualSize;
@@ -73,7 +73,7 @@
 public:
   static VirtualTable* VT;
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 
   char* name;
   uint32 realOffset;
@@ -84,7 +84,7 @@
 public:
   static VirtualTable* VT;
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 
   uint32 offset;
   uint32 rowsNumber;
@@ -102,7 +102,7 @@
 public:
   static VirtualTable* VT;
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 
   uint32 signature;
   uint32 major;
@@ -134,7 +134,7 @@
 public:
   static VirtualTable* VT;
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 
   VMClassPointer* constructPointer(VMCommonClass* base, uint32 dims);
   VMClassArray* constructArray(VMCommonClass* base, uint32 dims);

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

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/BackTrace.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/BackTrace.cpp Thu Apr 17 11:45:26 2008
@@ -35,34 +35,25 @@
   int real_size = backtrace((void**)(void*)ips, 100);
   int n = 0;
   while (n < real_size) {
-#ifdef MULTIPLE_GC
-    int *begIp = (int*)mvm::Thread::get()->GC->begOf(ips[n++]);
-#else
-    int *begIp = (int*)Collector::begOf(ips[n++]);
-#endif
-    if (begIp) {
-      unsigned char* val = (unsigned char*)begIp + sizeof(mvm::Code);
-      const llvm::GlobalValue * glob = 
-        mvm::jit::executionEngine->getGlobalValueAtAddress(val);
-      if (glob) {
-        if (llvm::isa<llvm::Function>(glob)) {
-          mvm::Code* c = (mvm::Code*)begIp;
-          mvm::Method* m = c->method();
-          VMMethod* meth = (VMMethod*)m->definition();
-          if (meth) 
-            printf("; 0x%08x in %s\n", (uint32) ips[n - 1], meth->printString());
-          else
-            printf("; 0x%08x in %s\n", (uint32) ips[n - 1],
-                   ((llvm::Function*)glob)->getNameStr().c_str());
-        } else VMThread::get()->vm->unknownError("in global variable?");
-      } else printf("; 0x%08x in stub\n", (uint32) ips[n - 1]);
+    mvm::Code* code = mvm::Code::getCodeFromPointer(ips[n++]);
+    if (code) {
+      mvm::Method* m = code->method();
+      mvm::Object* meth = m->definition();
+      if (meth && meth->getVirtualTable() == VMMethod::VT) {
+        printf("; %p in %s\n",  ips[n - 1], meth->printString());
+      } else if (m->llvmFunction) {
+        printf("; %p in %s\n",  ips[n - 1],
+                   m->llvmFunction->getNameStr().c_str());
+      } else {
+        printf("; %p in %s\n",  ips[n - 1], "stub (probably)");
+      }
     } else {
       Dl_info info;
-      int res = dladdr(begIp, &info);
+      int res = dladdr(ips[n++], &info);
       if (res != 0) {
-        printf("; 0x%08x in %s\n", (uint32) ips[n - 1], info.dli_fname);
+        printf("; %p in %s\n",  ips[n - 1], info.dli_sname);
       } else {
-        printf("; 0x%08x in Unknown\n", (uint32) ips[n - 1]);
+        printf("; %p in Unknown\n", ips[n - 1]);
       }
     }
   }
@@ -74,30 +65,13 @@
   int* ips[10];
   int real_size = backtrace((void**)(void*)ips, 10);
   int n = 0;
-  int i = 0;
   while (n < real_size) {
-#ifdef MULTIPLE_GC
-    int *begIp = (int*)mvm::Thread::get()->GC->begOf(ips[n++]);
-#else
-    int *begIp = (int*)Collector::begOf(ips[n++]);
-#endif
-    if (begIp) {
-      unsigned char* val = (unsigned char*)begIp + sizeof(mvm::Code);
-      const llvm::GlobalValue * glob = 
-        mvm::jit::executionEngine->getGlobalValueAtAddress(val);
-      if (glob) {
-        if (llvm::isa<llvm::Function>(glob)) {
-          mvm::Code* c = (mvm::Code*)begIp;
-          mvm::Method* m = c->method();
-          VMMethod* meth = (VMMethod*)m->definition();
-          if (meth && meth->getVirtualTable() == VMMethod::VT) {
-            return meth->classDef->assembly;
-          } else {
-            ++i;
-          }
-        } else {
-          VMThread::get()->vm->unknownError("in global variable?");
-        }
+    mvm::Code* code = mvm::Code::getCodeFromPointer(ips[n++]);
+    if (code) {
+      mvm::Method* m = code->method();
+      mvm::Object* meth = m->definition();
+      if (meth && meth->getVirtualTable() == VMMethod::VT) {
+        return ((VMMethod*)meth)->classDef->assembly;
       }
     }
   }
@@ -110,28 +84,14 @@
   int n = 0;
   int i = 0;
   while (n < real_size) {
-#ifdef MULTIPLE_GC
-    int *begIp = (int*)mvm::Thread::get()->GC->begOf(ips[n++]);
-#else
-    int *begIp = (int*)Collector::begOf(ips[n++]);
-#endif
-    if (begIp) {
-      unsigned char* val = (unsigned char*)begIp + sizeof(mvm::Code);
-      const llvm::GlobalValue * glob = 
-        mvm::jit::executionEngine->getGlobalValueAtAddress(val);
-      if (glob) {
-        if (llvm::isa<llvm::Function>(glob)) {
-          mvm::Code* c = (mvm::Code*)begIp;
-          mvm::Method* m = c->method();
-          VMMethod* meth = (VMMethod*)m->definition();
-          if (meth && i >= 1 && meth->getVirtualTable() == VMMethod::VT) {
-            return meth->classDef->assembly;
-          } else {
-            ++i;
-          }
-        } else {
-          VMThread::get()->vm->unknownError("in global variable?");
-        }
+    mvm::Code* code = mvm::Code::getCodeFromPointer(ips[n++]);
+    if (code) {
+      mvm::Method* m = code->method();
+      mvm::Object* meth = m->definition();
+      if (meth && i >= 1 && meth->getVirtualTable() == VMMethod::VT) {
+        return ((VMMethod*)meth)->classDef->assembly;
+      } else {
+        ++i;
       }
     }
   }

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

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/CLIJit.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/CLIJit.cpp Thu Apr 17 11:45:26 2008
@@ -55,9 +55,14 @@
 
 #ifdef WITH_TRACER
 // for structs
-static void traceStruct(VMCommonClass* cl, BasicBlock* block, Value* arg) { 
+static void traceStruct(VMCommonClass* cl, BasicBlock* block, Value* arg) {
+#ifdef MULTIPLE_GC
+  Value* GC = ++(block->getParent()->arg_begin());
+#endif
+
   for (std::vector<VMField*>::iterator i = cl->virtualFields.begin(), 
             e = cl->virtualFields.end(); i!= e; ++i) {
+
     VMField* field = *i;
     if (field->signature->super == N3::pValue) {
       if (!field->signature->isPrimitive) {
@@ -67,11 +72,27 @@
       } else if (field->signature == N3::pIntPtr || 
                  field->signature == N3::pUIntPtr)  {
         Value* valCast = new BitCastInst(arg, VMObject::llvmType, "", block);
+#ifdef MULTIPLE_GC
+        std::vector<Value*> Args;
+        Args.push_back(valCast);
+        Args.push_back(GC);
+        CallInst::Create(CLIJit::markAndTraceLLVM, Args.begin(), Args.end(),
+                         "", block);
+#else
         CallInst::Create(CLIJit::markAndTraceLLVM, valCast, "", block);
+#endif
       }
     } else if (field->signature->super != N3::pEnum) {
       Value* valCast = new BitCastInst(arg, VMObject::llvmType, "", block);
+#ifdef MULTIPLE_GC
+      std::vector<Value*> Args;
+      Args.push_back(valCast);
+      Args.push_back(GC);
+      CallInst::Create(CLIJit::markAndTraceLLVM, Args.begin(), Args.end(),
+                       "", block);
+#else
       CallInst::Create(CLIJit::markAndTraceLLVM, valCast, "", block);
+#endif
     }
   }
 }
@@ -80,6 +101,9 @@
 // Always classes
 static void traceClass(VMCommonClass* cl, BasicBlock* block, Value* arg, 
                        std::vector<VMField*>& fields, bool boxed = false) {
+#ifdef MULTIPLE_GC
+  Value* GC = ++(block->getParent()->arg_begin());
+#endif
   
   Constant* zero = mvm::jit::constantZero;
   for (std::vector<VMField*>::iterator i = fields.begin(), 
@@ -112,7 +136,15 @@
                                          block);
       Value* val = new LoadInst(ptr, "", block);
       Value* valCast = new BitCastInst(val, VMObject::llvmType, "", block);
+#ifdef MULTIPLE_GC
+        std::vector<Value*> Args;
+        Args.push_back(valCast);
+        Args.push_back(GC);
+        CallInst::Create(CLIJit::markAndTraceLLVM, Args.begin(), Args.end(),
+                         "", block);
+#else
       CallInst::Create(CLIJit::markAndTraceLLVM, valCast, "", block);
+#endif
     }
   }
 }
@@ -127,7 +159,9 @@
                                 "markAndTraceObject",
                                 cl->vm->module);
   Argument* arg = func->arg_begin();
-  
+#ifdef MULTIPLE_GC 
+  Argument* GC = ++(func->arg_begin());
+#endif
     // Constant Definitions
   Constant* const_int32_8 = mvm::jit::constantZero;
   ConstantInt* const_int32_9 = mvm::jit::constantOne;
@@ -181,7 +215,15 @@
     } else if (cl->baseClass->super != N3::pEnum) {
       LoadInst* ptr_tmp4 = new LoadInst(ptr_tmp3, "tmp4", false, label_bb);
       Value* arg = new BitCastInst(ptr_tmp4, VMObject::llvmType, "", label_bb);
+#ifdef MULTIPLE_GC
+      std::vector<Value*> Args;
+      Args.push_back(arg);
+      Args.push_back(GC);
+      CallInst::Create(markAndTraceLLVM, Args.begin(), Args.end(), "",
+                       label_bb);
+#else
       CallInst::Create(markAndTraceLLVM, arg, "", label_bb);
+#endif
     }
     BinaryOperator* int32_tmp6 = 
       BinaryOperator::create(Instruction::Add, int32_i_015_0, const_int32_9,
@@ -202,7 +244,7 @@
   void* tracer = mvm::jit::executionEngine->getPointerToGlobal(func);
   ((void**)res)[VT_TRACER_OFFSET] = tracer;
   cl->virtualTracer = func;
-  cl->codeVirtualTracer = (mvm::Code*)((intptr_t)tracer - sizeof(intptr_t));
+  cl->codeVirtualTracer = mvm::Code::getCodeFromPointer(tracer);
 #endif
 
   return res;
@@ -221,14 +263,29 @@
                                 cl->vm->module);
 
   Argument* arg = func->arg_begin();
+#ifdef MULTIPLE_GC 
+  Argument* GC = ++(func->arg_begin());
+#endif
   BasicBlock* block = BasicBlock::Create("", func);
   llvm::Value* realArg = new BitCastInst(arg, type, "", block);
-  
+ 
+#ifdef MULTIPLE_GC
+  std::vector<Value*> Args;
+  Args.push_back(arg);
+  Args.push_back(GC);
+  if (stat || cl->super == 0) {
+    CallInst::Create(vmObjectTracerLLVM, Args.begin(), Args.end(), "", block);
+  } else {
+    CallInst::Create(((VMClass*)cl->super)->virtualTracer, Args.begin(),
+                     Args.end(), "", block);
+  }
+#else
   if (stat || cl->super == 0) {
     CallInst::Create(vmObjectTracerLLVM, arg, "", block);
   } else {
     CallInst::Create(((VMClass*)cl->super)->virtualTracer, arg, "", block);
   }
+#endif
   
   traceClass(cl, block, realArg, fields, (cl->super == N3::pValue && !stat));
   ReturnInst::Create(block);
@@ -238,10 +295,10 @@
   
   if (!stat) {
     cl->virtualTracer = func;
-    cl->codeVirtualTracer = (mvm::Code*)((intptr_t)tracer - sizeof(intptr_t));
+    cl->codeVirtualTracer = mvm::Code::getCodeFromPointer(tracer);
   } else {
     cl->staticTracer = func;
-    cl->codeStaticTracer = (mvm::Code*)((intptr_t)tracer - sizeof(intptr_t));
+    cl->codeStaticTracer = mvm::Code::getCodeFromPointer(tracer);
   }
 #endif
   return res;
@@ -1443,11 +1500,7 @@
 
 
 extern "C" bool isInCode(void* value) {
-#ifdef MULTIPLE_GC
-  mvm::Object* obj = (mvm::Object*)mvm::Thread::get()->GC->begOf(value);
-#else
-  mvm::Object* obj = (mvm::Object*)Collector::begOf(value);
-#endif
+  mvm::Object *obj = mvm::Code::getCodeFromPointer(value);
   if (obj && obj->getVirtualTable() == mvm::Code::VT) {
     return true;
   } else {
@@ -1584,10 +1637,17 @@
   {
   std::vector<const Type*> args;
   args.push_back(VMObject::llvmType);
+#ifdef MULTIPLE_GC
+  args.push_back(mvm::jit::ptrType);
+#endif
   markAndTraceLLVMType = FunctionType::get(llvm::Type::VoidTy, args, false);
   markAndTraceLLVM = Function::Create(markAndTraceLLVMType,
                                   GlobalValue::ExternalLinkage,
+#ifdef MULTIPLE_GC
+                                  "_ZNK2gc12markAndTraceEP9Collector",
+#else
                                   "_ZNK2gc12markAndTraceEv",
+#endif
                                   module);
   }
 #endif
@@ -1596,10 +1656,17 @@
   {
   std::vector<const Type*> args;
   args.push_back(VMObject::llvmType);
+#ifdef MULTIPLE_GC
+  args.push_back(mvm::jit::ptrType);
+#endif
   const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
   vmObjectTracerLLVM = Function::Create(type,
                                     GlobalValue::ExternalLinkage,
-                                    "_ZN2n38VMObject6tracerEj",
+#ifdef MULTIPLE_GC
+                                    "_ZN2n38VMObject6tracerEPv",
+#else
+                                    "_ZN2n38VMObject6tracerEv",
+#endif
                                     module);
   }
 

Modified: vmkit/trunk/lib/N3/VMCore/CLIJit.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIJit.h?rev=49859&r1=49858&r2=49859&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/CLIJit.h (original)
+++ vmkit/trunk/lib/N3/VMCore/CLIJit.h Thu Apr 17 11:45:26 2008
@@ -50,7 +50,7 @@
   llvm::BasicBlock* handler;
 
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 };
 
 class Opinfo : public mvm::Object {
@@ -64,7 +64,7 @@
   virtual void print(mvm::PrintBuffer* buf) const {
     buf->write("Opinfo");
   }
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 };
 
 
@@ -75,7 +75,7 @@
   virtual void print(mvm::PrintBuffer* buf) const {
     buf->write("CLIJit");
   }
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
   
   
   static const char* OpcodeNames[0xE1];

Modified: vmkit/trunk/lib/N3/VMCore/CLIString.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIString.h?rev=49859&r1=49858&r2=49859&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/CLIString.h (original)
+++ vmkit/trunk/lib/N3/VMCore/CLIString.h Thu Apr 17 11:45:26 2008
@@ -28,7 +28,7 @@
   virtual void print(mvm::PrintBuffer* buf) const {
     buf->write("CLI string");
   }
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
   
   // !!! pnetlib layout !!!
   sint32 capacity;

Modified: vmkit/trunk/lib/N3/VMCore/LockedMap.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/LockedMap.h?rev=49859&r1=49858&r2=49859&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/LockedMap.h (original)
+++ vmkit/trunk/lib/N3/VMCore/LockedMap.h Thu Apr 17 11:45:26 2008
@@ -90,10 +90,10 @@
     lock->unlock();
   }
 
-  virtual void tracer(size_t sz) {
-    //lock->markAndTrace();
+  virtual void TRACER {
+    //lock->MARK_AND_TRACE;
     for (iterator i = map.begin(), e = map.end(); i!= e; ++i) {
-      i->second->markAndTrace();
+      i->second->MARK_AND_TRACE;
     }
   }
 
@@ -210,10 +210,10 @@
   const UTF8* lookupOrCreateAsciiz(const char* asciiz); 
   const UTF8* lookupOrCreateReader(const uint16* buf, uint32 size);
   
-  virtual void tracer(size_t sz) {
-    //lock->markAndTrace();
+  virtual void TRACER {
+    //lock->MARK_AND_TRACE;
     for (iterator i = map.begin(), e = map.end(); i!= e; ++i) {
-      i->second->markAndTrace();
+      i->second->MARK_AND_TRACE;
     }
   }
 

Modified: vmkit/trunk/lib/N3/VMCore/N3.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/N3.h?rev=49859&r1=49858&r2=49859&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/N3.h (original)
+++ vmkit/trunk/lib/N3/VMCore/N3.h Thu Apr 17 11:45:26 2008
@@ -36,7 +36,7 @@
 public:
   static VirtualTable* VT;
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 
   VMObject*     asciizToStr(const char* asciiz);
   VMObject*     UTF8ToStr(const UTF8* utf8);

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

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp Thu Apr 17 11:45:26 2008
@@ -40,7 +40,7 @@
       if (res == 0) {
         CLIJit::compile(meth->classDef, meth);
         void* res = mvm::jit::executionEngine->getPointerToGlobal(meth->methPtr);
-        meth->code = (mvm::Code*)((intptr_t)res - sizeof(mvm::Code));
+        meth->code = mvm::Code::getCodeFromPointer(res);
         meth->code->method()->definition(meth);
       }
       meth->classDef->release();

Modified: vmkit/trunk/lib/N3/VMCore/Reader.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/Reader.h?rev=49859&r1=49858&r2=49859&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/Reader.h (original)
+++ vmkit/trunk/lib/N3/VMCore/Reader.h Thu Apr 17 11:45:26 2008
@@ -50,7 +50,7 @@
   void seek(uint32 pos, int from);
 
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 };
 
 static sint8 inline READ_S1(ArrayUInt8* bytes, uint32& offset) {

Modified: vmkit/trunk/lib/N3/VMCore/VMArray.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMArray.h?rev=49859&r1=49858&r2=49859&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMArray.h (original)
+++ vmkit/trunk/lib/N3/VMCore/VMArray.h Thu Apr 17 11:45:26 2008
@@ -37,7 +37,7 @@
   static llvm::ConstantInt* sizeOffset();
   static llvm::ConstantInt* elementsOffset();
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 
 };
 
@@ -54,7 +54,7 @@
   elmt at(sint32) const;                                              \
   void setAt(sint32, elmt);                                           \
   virtual void print(mvm::PrintBuffer* buf) const;                    \
-  virtual void tracer(size_t sz);                                     \
+  virtual void TRACER;                                     \
 }
 
 ARRAYCLASS(ArrayUInt8,  uint8);
@@ -79,7 +79,7 @@
   VMObject* at(sint32) const;
   void setAt(sint32, VMObject*);
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 };
 
 class UTF8 : public VMArray {

Modified: vmkit/trunk/lib/N3/VMCore/VMCache.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMCache.h?rev=49859&r1=49858&r2=49859&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMCache.h (original)
+++ vmkit/trunk/lib/N3/VMCore/VMCache.h Thu Apr 17 11:45:26 2008
@@ -29,7 +29,7 @@
 public:
   static VirtualTable* VT;
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 
   void* methPtr;
   VMClass* lastCible;
@@ -46,7 +46,7 @@
 class Enveloppe : public mvm::Object {
 public:
   static VirtualTable* VT;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
   virtual void print(mvm::PrintBuffer* buf) const;
   
   CacheNode *firstCache;

Modified: vmkit/trunk/lib/N3/VMCore/VMClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMClass.h?rev=49859&r1=49858&r2=49859&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMClass.h (original)
+++ vmkit/trunk/lib/N3/VMCore/VMClass.h Thu Apr 17 11:45:26 2008
@@ -45,7 +45,7 @@
 public:
   static VirtualTable* VT;
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 
   std::vector<VMMethod*> virtualMethods;
   std::vector<VMMethod*> staticMethods;
@@ -130,7 +130,7 @@
 public:
   static VirtualTable* VT;
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
   
   void resolveFields();
   void resolveStaticFields();
@@ -153,7 +153,7 @@
 public:
   static VirtualTable* VT;
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 
   uint32 dims;
   VMCommonClass* baseClass;
@@ -175,7 +175,7 @@
 public:
   static VirtualTable* VT;
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 
   uint32 dims;
   VMCommonClass* baseClass;
@@ -187,7 +187,7 @@
 public:
   static VirtualTable* VT;
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
   
   uint32 flags;
   uint32 offset;
@@ -228,7 +228,7 @@
 public:
   static VirtualTable* VT;
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
   
   uint32 flags;
   llvm::ConstantInt* offset;
@@ -261,7 +261,7 @@
 public:
   static VirtualTable* VT;
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 
   uint32 flags;
   uint32 sequence;
@@ -273,7 +273,7 @@
 public:
   static VirtualTable* VT;
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
   
   std::vector<VMCommonClass*> parameters;
   VMCommonClass* type;

Modified: vmkit/trunk/lib/N3/VMCore/VMObject.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMObject.h?rev=49859&r1=49858&r2=49859&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMObject.h (original)
+++ vmkit/trunk/lib/N3/VMCore/VMObject.h Thu Apr 17 11:45:26 2008
@@ -41,7 +41,7 @@
   void wait(VMThread* th);
   void remove(VMThread* th);
 
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 };
 
 
@@ -52,7 +52,7 @@
   VMCond* varcond;
 
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 
   static LockObj* allocate();
   void aquire();
@@ -72,7 +72,7 @@
   static const llvm::Type* llvmType;
   
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
   
   static VMObject* allocate(VMCommonClass* cl);
   void aquire();

Modified: vmkit/trunk/lib/N3/VMCore/VMThread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMThread.h?rev=49859&r1=49858&r2=49859&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMThread.h (original)
+++ vmkit/trunk/lib/N3/VMCore/VMThread.h Thu Apr 17 11:45:26 2008
@@ -44,7 +44,7 @@
   static const unsigned int StateInterrupted;
 
   virtual void print(mvm::PrintBuffer *buf);
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
   virtual void destroyer(size_t sz);
   
   static VMThread* get();

Modified: vmkit/trunk/lib/N3/VMCore/VirtualMachine.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VirtualMachine.h?rev=49859&r1=49858&r2=49859&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VirtualMachine.h (original)
+++ vmkit/trunk/lib/N3/VMCore/VirtualMachine.h Thu Apr 17 11:45:26 2008
@@ -38,7 +38,7 @@
   mvm::Cond* nonDaemonVar;
 
   virtual void print(mvm::PrintBuffer* buf) const;
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
 
   static ThreadSystem* allocateThreadSystem();
 };
@@ -110,7 +110,7 @@
   void error(const char* className, const char* fmt, va_list ap);
 
   
-  virtual void tracer(size_t sz);
+  virtual void TRACER;
   virtual void print(mvm::PrintBuffer* buf) const {
     buf->write("Virtual Machine<>");
   }

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

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VirtualTables.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/VirtualTables.cpp Thu Apr 17 11:45:26 2008
@@ -76,50 +76,50 @@
   
 #undef INIT
 
-void Opinfo::tracer(size_t sz) {
+void Opinfo::TRACER {
 }
 
-void CLIJit::tracer(size_t sz) {
-  compilingMethod->markAndTrace();
-  compilingClass->markAndTrace();
+void CLIJit::TRACER {
+  compilingMethod->MARK_AND_TRACE;
+  compilingClass->MARK_AND_TRACE;
 }
 
-void ThreadSystem::tracer(size_t sz) {
-  //nonDaemonLock->markAndTrace();
-  //nonDaemonVar->markAndTrace();
+void ThreadSystem::TRACER {
+  //nonDaemonLock->MARK_AND_TRACE;
+  //nonDaemonVar->MARK_AND_TRACE;
 }
 
-void Reader::tracer(size_t sz) {
-  bytes->markAndTrace();
+void Reader::TRACER {
+  bytes->MARK_AND_TRACE;
 }
 
-void CacheNode::tracer(size_t sz) {
-  ((mvm::Object*)methPtr)->markAndTrace();
-  lastCible->markAndTrace();
-  next->markAndTrace();
-  enveloppe->markAndTrace();
+void CacheNode::TRACER {
+  ((mvm::Object*)methPtr)->MARK_AND_TRACE;
+  lastCible->MARK_AND_TRACE;
+  next->MARK_AND_TRACE;
+  enveloppe->MARK_AND_TRACE;
 }
 
-void Enveloppe::tracer(size_t sz) {
-  firstCache->markAndTrace();
-  //cacheLock->markAndTrace();
-  originalMethod->markAndTrace();
+void Enveloppe::TRACER {
+  firstCache->MARK_AND_TRACE;
+  //cacheLock->MARK_AND_TRACE;
+  originalMethod->MARK_AND_TRACE;
 }
 
-void VMArray::tracer(size_t sz) {
-  VMObject::tracer(sz);
+void VMArray::TRACER {
+  VMObject::PARENT_TRACER;
 }
 
-void ArrayObject::tracer(size_t sz) {
-  VMObject::tracer(sz);
+void ArrayObject::TRACER {
+  VMObject::PARENT_TRACER;
   for (sint32 i = 0; i < size; i++) {
-    elements[i]->markAndTrace();
+    elements[i]->MARK_AND_TRACE;
   }
 }
 
 #define ARRAYTRACER(name)         \
-  void name::tracer(size_t sz) {  \
-    VMObject::tracer(sz);         \
+  void name::TRACER {             \
+    VMObject::PARENT_TRACER;      \
   }
   
 
@@ -139,154 +139,154 @@
 #define TRACE_VECTOR(type, name, alloc) { \
   for (std::vector<type, alloc<type> >::iterator i = name.begin(), e = name.end(); \
        i!= e; ++i) {                                                    \
-    (*i)->markAndTrace(); }}
+    (*i)->MARK_AND_TRACE; }}
 
-void VMCommonClass::tracer(size_t sz) {
-  name->markAndTrace();
-  nameSpace->markAndTrace();
-  super->markAndTrace();
+void VMCommonClass::TRACER {
+  name->MARK_AND_TRACE;
+  nameSpace->MARK_AND_TRACE;
+  super->MARK_AND_TRACE;
   TRACE_VECTOR(VMClass*, interfaces, std::allocator);
-  //lockVar->markAndTrace();
-  //condVar->markAndTrace();
+  //lockVar->MARK_AND_TRACE;
+  //condVar->MARK_AND_TRACE;
   TRACE_VECTOR(VMMethod*, virtualMethods, std::allocator);
   TRACE_VECTOR(VMMethod*, staticMethods, std::allocator);
   TRACE_VECTOR(VMField*, virtualFields, std::allocator);
   TRACE_VECTOR(VMField*, staticFields, std::allocator);
-  delegatee->markAndTrace();
+  delegatee->MARK_AND_TRACE;
   TRACE_VECTOR(VMCommonClass*, display, std::allocator);
-  vm->markAndTrace();
+  vm->MARK_AND_TRACE;
 
-  assembly->markAndTrace();
-  //funcs->markAndTrace();
+  assembly->MARK_AND_TRACE;
+  //funcs->MARK_AND_TRACE;
   TRACE_VECTOR(Property*, properties, gc_allocator);
-  codeVirtualTracer->markAndTrace();
-  codeStaticTracer->markAndTrace();
+  codeVirtualTracer->MARK_AND_TRACE;
+  codeStaticTracer->MARK_AND_TRACE;
 }
 
-void VMClass::tracer(size_t sz) {
-  VMCommonClass::tracer(sz);
-  staticInstance->markAndTrace();
-  virtualInstance->markAndTrace();
+void VMClass::TRACER {
+  VMCommonClass::PARENT_TRACER;
+  staticInstance->MARK_AND_TRACE;
+  virtualInstance->MARK_AND_TRACE;
   TRACE_VECTOR(VMClass*, innerClasses, std::allocator);
-  outerClass->markAndTrace();
+  outerClass->MARK_AND_TRACE;
 }
 
-void VMClassArray::tracer(size_t sz) {
-  VMCommonClass::tracer(sz);
-  baseClass->markAndTrace();
+void VMClassArray::TRACER {
+  VMCommonClass::PARENT_TRACER;
+  baseClass->MARK_AND_TRACE;
 }
 
-void VMClassPointer::tracer(size_t sz) {
-  VMCommonClass::tracer(sz);
-  baseClass->markAndTrace();
+void VMClassPointer::TRACER {
+  VMCommonClass::PARENT_TRACER;
+  baseClass->MARK_AND_TRACE;
 }
 
 
-void VMMethod::tracer(size_t sz) {
-  delegatee->markAndTrace();
-  //signature->markAndTrace();
-  classDef->markAndTrace();
+void VMMethod::TRACER {
+  delegatee->MARK_AND_TRACE;
+  //signature->MARK_AND_TRACE;
+  classDef->MARK_AND_TRACE;
   TRACE_VECTOR(Param*, params, gc_allocator);
   TRACE_VECTOR(Enveloppe*, caches, gc_allocator);
-  name->markAndTrace();
-  code->markAndTrace();
+  name->MARK_AND_TRACE;
+  code->MARK_AND_TRACE;
 }
 
-void VMField::tracer(size_t sz) {
-  signature->markAndTrace();
-  classDef->markAndTrace();
-  name->markAndTrace();
+void VMField::TRACER {
+  signature->MARK_AND_TRACE;
+  classDef->MARK_AND_TRACE;
+  name->MARK_AND_TRACE;
 }
 
-void VMCond::tracer(size_t sz) {
+void VMCond::TRACER {
   TRACE_VECTOR(VMThread*, threads, std::allocator);
 }
 
-void LockObj::tracer(size_t sz) {
-  //lock->markAndTrace();
-  varcond->markAndTrace();
-}
-
-void VMObject::tracer(size_t sz) {
-  classOf->markAndTrace();
-  lockObj->markAndTrace();
-}
-
-void VMThread::tracer(size_t sz) {
-  vmThread->markAndTrace();
-  vm->markAndTrace();
-  //lock->markAndTrace();
-  //varcond->markAndTrace();
-  pendingException->markAndTrace();
-}
-
-void VirtualMachine::tracer(size_t sz) {
-  threadSystem->markAndTrace();
-  hashUTF8->markAndTrace();
-  functions->markAndTrace();
-  //protectModule->markAndTrace();
-  bootstrapThread->markAndTrace();
-}
-
-void Param::tracer(size_t sz) {
-  method->markAndTrace();
-  name->markAndTrace();
-}
-
-void Property::tracer(size_t sz) {
-  type->markAndTrace();
-  //signature->markAndTrace();
-  name->markAndTrace();
-  delegatee->markAndTrace();
-}
-
-void Assembly::tracer(size_t sz) {
-  loadedNameClasses->markAndTrace();
-  loadedTokenClasses->markAndTrace();
-  loadedTokenMethods->markAndTrace();
-  loadedTokenFields->markAndTrace();
-  //lockVar->markAndTrace();
-  //condVar->markAndTrace();
-  name->markAndTrace();
-  bytes->markAndTrace();
-  textSection->markAndTrace();
-  rsrcSection->markAndTrace();
-  relocSection->markAndTrace();
-  CLIHeader->markAndTrace();
-  vm->markAndTrace();
-  delegatee->markAndTrace();
+void LockObj::TRACER {
+  //lock->MARK_AND_TRACE;
+  varcond->MARK_AND_TRACE;
+}
+
+void VMObject::TRACER {
+  classOf->MARK_AND_TRACE;
+  lockObj->MARK_AND_TRACE;
+}
+
+void VMThread::TRACER {
+  vmThread->MARK_AND_TRACE;
+  vm->MARK_AND_TRACE;
+  //lock->MARK_AND_TRACE;
+  //varcond->MARK_AND_TRACE;
+  pendingException->MARK_AND_TRACE;
+}
+
+void VirtualMachine::TRACER {
+  threadSystem->MARK_AND_TRACE;
+  hashUTF8->MARK_AND_TRACE;
+  functions->MARK_AND_TRACE;
+  //protectModule->MARK_AND_TRACE;
+  bootstrapThread->MARK_AND_TRACE;
+}
+
+void Param::TRACER {
+  method->MARK_AND_TRACE;
+  name->MARK_AND_TRACE;
+}
+
+void Property::TRACER {
+  type->MARK_AND_TRACE;
+  //signature->MARK_AND_TRACE;
+  name->MARK_AND_TRACE;
+  delegatee->MARK_AND_TRACE;
+}
+
+void Assembly::TRACER {
+  loadedNameClasses->MARK_AND_TRACE;
+  loadedTokenClasses->MARK_AND_TRACE;
+  loadedTokenMethods->MARK_AND_TRACE;
+  loadedTokenFields->MARK_AND_TRACE;
+  //lockVar->MARK_AND_TRACE;
+  //condVar->MARK_AND_TRACE;
+  name->MARK_AND_TRACE;
+  bytes->MARK_AND_TRACE;
+  textSection->MARK_AND_TRACE;
+  rsrcSection->MARK_AND_TRACE;
+  relocSection->MARK_AND_TRACE;
+  CLIHeader->MARK_AND_TRACE;
+  vm->MARK_AND_TRACE;
+  delegatee->MARK_AND_TRACE;
   // TODO trace assembly refs...
 }
 
-void N3::tracer(size_t sz) {
-  VirtualMachine::tracer(sz);
-  hashUTF8->markAndTrace();
-  hashStr->markAndTrace();
-  loadedAssemblies->markAndTrace();
+void N3::TRACER {
+  VirtualMachine::PARENT_TRACER;
+  hashUTF8->MARK_AND_TRACE;
+  hashStr->MARK_AND_TRACE;
+  loadedAssemblies->MARK_AND_TRACE;
 }
 
-void Section::tracer(size_t sz) {
+void Section::TRACER {
 }
 
-void Stream::tracer(size_t sz) {
+void Stream::TRACER {
 }
 
-void Table::tracer(size_t sz) {
+void Table::TRACER {
 }
 
-void Header::tracer(size_t sz) {
-  versionName->markAndTrace();
-  tildStream->markAndTrace();
-  stringStream->markAndTrace();
-  usStream->markAndTrace();
-  blobStream->markAndTrace();
-  guidStream->markAndTrace();
+void Header::TRACER {
+  versionName->MARK_AND_TRACE;
+  tildStream->MARK_AND_TRACE;
+  stringStream->MARK_AND_TRACE;
+  usStream->MARK_AND_TRACE;
+  blobStream->MARK_AND_TRACE;
+  guidStream->MARK_AND_TRACE;
   TRACE_VECTOR(Table*, tables, gc_allocator);
 }
 
-void CLIString::tracer(size_t sz) {
+void CLIString::TRACER {
 }
 
-void Exception::tracer(size_t sz) {
-  catchClass->markAndTrace();
+void Exception::TRACER {
+  catchClass->MARK_AND_TRACE;
 }





More information about the llvm-commits mailing list