[vmkit-commits] [vmkit] r118707 - in /vmkit/branches/precise: include/j3/ include/mvm/Threads/ lib/J3/Classpath/ lib/J3/Compiler/ lib/J3/LLVMRuntime/ lib/J3/VMCore/ lib/Mvm/CommonThread/ lib/Mvm/Compiler/ lib/Mvm/MMTk/ mmtk/config/copyms/ mmtk/mmtk-alloc/ mmtk/mmtk-j3/

Nicolas Geoffray nicolas.geoffray at lip6.fr
Wed Nov 10 12:00:39 PST 2010


Author: geoffray
Date: Wed Nov 10 14:00:39 2010
New Revision: 118707

URL: http://llvm.org/viewvc/llvm-project?rev=118707&view=rev
Log:
Lots of GC fixes wrt to stack walking. Also class bytes are now allocated with malloc, not the GC.
- 


Modified:
    vmkit/branches/precise/include/j3/JavaJITCompiler.h
    vmkit/branches/precise/include/mvm/Threads/CollectionRV.h
    vmkit/branches/precise/include/mvm/Threads/Locks.h
    vmkit/branches/precise/include/mvm/Threads/Thread.h
    vmkit/branches/precise/lib/J3/Classpath/ClasspathVMClassLoader.inc
    vmkit/branches/precise/lib/J3/Classpath/ClasspathVMThrowable.inc
    vmkit/branches/precise/lib/J3/Compiler/JavaAOTCompiler.cpp
    vmkit/branches/precise/lib/J3/Compiler/JavaJIT.cpp
    vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp
    vmkit/branches/precise/lib/J3/LLVMRuntime/runtime-mmtk-thread.ll
    vmkit/branches/precise/lib/J3/VMCore/JavaArray.h
    vmkit/branches/precise/lib/J3/VMCore/JavaClass.cpp
    vmkit/branches/precise/lib/J3/VMCore/JavaClass.h
    vmkit/branches/precise/lib/J3/VMCore/JavaConstantPool.cpp
    vmkit/branches/precise/lib/J3/VMCore/JavaRuntimeJIT.cpp
    vmkit/branches/precise/lib/J3/VMCore/JavaThread.cpp
    vmkit/branches/precise/lib/J3/VMCore/JavaThread.h
    vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp
    vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp
    vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.h
    vmkit/branches/precise/lib/J3/VMCore/Reader.cpp
    vmkit/branches/precise/lib/J3/VMCore/Reader.h
    vmkit/branches/precise/lib/J3/VMCore/VirtualTables.cpp
    vmkit/branches/precise/lib/J3/VMCore/Zip.cpp
    vmkit/branches/precise/lib/J3/VMCore/Zip.h
    vmkit/branches/precise/lib/Mvm/CommonThread/CollectionRV.cpp
    vmkit/branches/precise/lib/Mvm/CommonThread/ctthread.cpp
    vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp
    vmkit/branches/precise/lib/Mvm/Compiler/VmkitGC.cpp
    vmkit/branches/precise/lib/Mvm/MMTk/MutatorThread.h
    vmkit/branches/precise/mmtk/config/copyms/MMTkInline.inc
    vmkit/branches/precise/mmtk/mmtk-alloc/Selected.cpp
    vmkit/branches/precise/mmtk/mmtk-j3/Memory.cpp
    vmkit/branches/precise/mmtk/mmtk-j3/VM.cpp

Modified: vmkit/branches/precise/include/j3/JavaJITCompiler.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/j3/JavaJITCompiler.h?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/include/j3/JavaJITCompiler.h (original)
+++ vmkit/branches/precise/include/j3/JavaJITCompiler.h Wed Nov 10 14:00:39 2010
@@ -10,6 +10,7 @@
 #ifndef J3_JIT_COMPILER_H
 #define J3_JIT_COMPILER_H
 
+#include "llvm/CodeGen/GCMetadata.h"
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
 #include "llvm/ExecutionEngine/JITEventListener.h"
 #include "j3/JavaLLVMCompiler.h"
@@ -38,7 +39,7 @@
   bool EmitFunctionName;
   JavaJITListener listener;
   llvm::ExecutionEngine* executionEngine;
-  llvm::GCStrategy* TheGCStrategy;
+  llvm::GCModuleInfo* GCInfo;
 
   JavaJITCompiler(const std::string &ModuleID);
   ~JavaJITCompiler();

Modified: vmkit/branches/precise/include/mvm/Threads/CollectionRV.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/mvm/Threads/CollectionRV.h?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/include/mvm/Threads/CollectionRV.h (original)
+++ vmkit/branches/precise/include/mvm/Threads/CollectionRV.h Wed Nov 10 14:00:39 2010
@@ -57,7 +57,7 @@
   virtual void synchronize() = 0;
 
   virtual void join() = 0;
-  virtual void joinAfterUncooperative() = 0;
+  virtual void joinAfterUncooperative(void* SP) = 0;
   virtual void joinBeforeUncooperative() = 0;
 };
 
@@ -67,7 +67,7 @@
   void synchronize();
 
   void join();
-  void joinAfterUncooperative();
+  void joinAfterUncooperative(void* SP);
   void joinBeforeUncooperative();
 };
 
@@ -77,7 +77,7 @@
   void synchronize();
 
   void join();
-  void joinAfterUncooperative();
+  void joinAfterUncooperative(void* SP);
   void joinBeforeUncooperative();
 };
 

Modified: vmkit/branches/precise/include/mvm/Threads/Locks.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/mvm/Threads/Locks.h?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/include/mvm/Threads/Locks.h (original)
+++ vmkit/branches/precise/include/mvm/Threads/Locks.h Wed Nov 10 14:00:39 2010
@@ -110,7 +110,7 @@
   
   /// lock - Acquire the lock.
   ///
-  virtual void lock() = 0;
+  virtual void lock() __attribute__ ((noinline)) = 0;
 
   /// unlock - Release the lock.
   ///
@@ -141,7 +141,7 @@
 public:
   LockNormal() : Lock() {}
 
-  virtual void lock();
+  virtual void lock() __attribute__ ((noinline));
   virtual void unlock();
 
 };
@@ -170,7 +170,7 @@
 public:
   LockRecursive() : Lock() { n = 0; }
   
-  virtual void lock();
+  virtual void lock() __attribute__ ((noinline));
   virtual void unlock();
   virtual int tryLock();
 
@@ -185,7 +185,7 @@
 
   /// lockAll - Acquire the lock count times.
   ///
-  void lockAll(int count);
+  void lockAll(int count) __attribute__ ((noinline));
 };
 
 /// SpinLock - This class implements a spin lock. A spin lock is OK to use

Modified: vmkit/branches/precise/include/mvm/Threads/Thread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/mvm/Threads/Thread.h?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/include/mvm/Threads/Thread.h (original)
+++ vmkit/branches/precise/include/mvm/Threads/Thread.h Wed Nov 10 14:00:39 2010
@@ -131,8 +131,9 @@
 
 class KnownFrame {
 public:
-  KnownFrame* previousFrame;
   void* currentFP;
+  void* currentIP;
+  KnownFrame* previousFrame;
 };
 
 
@@ -243,65 +244,12 @@
   void  setLastSP(void* V) { lastSP = V; }
   
   void joinRVBeforeEnter();
-  void joinRVAfterLeave();
+  void joinRVAfterLeave(void* savedSP);
 
-  void enterUncooperativeCode(unsigned level = 0) __attribute__ ((noinline)) {
-    if (isMvmThread()) {
-      if (!inRV) {
-        assert(!lastSP && "SP already set when entering uncooperative code");
-        ++level;
-        void* temp = __builtin_frame_address(0);
-        while (level--) temp = ((void**)temp)[0];
-        // The cas is not necessary, but it does a memory barrier.
-        __sync_bool_compare_and_swap(&lastSP, 0, temp);
-        if (doYield) joinRVBeforeEnter();
-        assert(lastSP && "No last SP when entering uncooperative code");
-      }
-    }
-  }
-  
-  void enterUncooperativeCode(void* SP) {
-    if (isMvmThread()) {
-      if (!inRV) {
-        assert(!lastSP && "SP already set when entering uncooperative code");
-        // The cas is not necessary, but it does a memory barrier.
-        __sync_bool_compare_and_swap(&lastSP, 0, SP);
-        if (doYield) joinRVBeforeEnter();
-        assert(lastSP && "No last SP when entering uncooperative code");
-      }
-    }
-  }
-
-  void leaveUncooperativeCode() {
-    if (isMvmThread()) {
-      if (!inRV) {
-        assert(lastSP && "No last SP when leaving uncooperative code");
-        // The cas is not necessary, but it does a memory barrier.
-        __sync_bool_compare_and_swap(&lastSP, lastSP, 0);
-        // A rendezvous has just been initiated, join it.
-        if (doYield) joinRVAfterLeave();
-        assert(!lastSP && "SP has a value after leaving uncooperative code");
-      }
-    }
-  }
-
-  void* waitOnSP() {
-    // First see if we can get lastSP directly.
-    void* sp = lastSP;
-    if (sp) return sp;
-    
-    // Then loop a fixed number of iterations to get lastSP.
-    for (uint32 count = 0; count < 1000; ++count) {
-      sp = lastSP;
-      if (sp) return sp;
-    }
-    
-    // Finally, yield until lastSP is not set.
-    while ((sp = lastSP) == NULL) mvm::Thread::yield();
-
-    assert(sp != NULL && "Still no sp");
-    return sp;
-  }
+  void enterUncooperativeCode(unsigned level = 0) __attribute__ ((noinline));
+  void enterUncooperativeCode(void* SP);
+  void leaveUncooperativeCode();
+  void* waitOnSP();
 
 
   /// clearException - Clear any pending exception of the current thread.
@@ -392,6 +340,8 @@
 
   void startKnownFrame(KnownFrame& F) __attribute__ ((noinline));
   void endKnownFrame();
+  void startUnknownFrame(KnownFrame& F) __attribute__ ((noinline));
+  void endUnknownFrame();
 };
 
 #ifndef RUNTIME_DWARF_EXCEPTIONS
@@ -423,17 +373,9 @@
   KnownFrame* frame;
   mvm::Thread* thread;
 
-  StackWalker(mvm::Thread* th) {
-    thread = th;
-    addr = mvm::Thread::get() == th ? (void**)FRAME_PTR() :
-                                      (void**)th->waitOnSP();
-    frame = th->lastKnownFrame;
-    assert(addr && "No address to start with");
-  }
-
+  StackWalker(mvm::Thread* th) __attribute__ ((noinline));
   void operator++();
   void* operator*();
-
   MethodInfo* get();
 
 };

Modified: vmkit/branches/precise/lib/J3/Classpath/ClasspathVMClassLoader.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Classpath/ClasspathVMClassLoader.inc?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/Classpath/ClasspathVMClassLoader.inc (original)
+++ vmkit/branches/precise/lib/J3/Classpath/ClasspathVMClassLoader.inc Wed Nov 10 14:00:39 2010
@@ -131,22 +131,27 @@
   BEGIN_NATIVE_EXCEPTION(0)
 
   Jnjvm* vm = JavaThread::get()->getJVM();
+
+  JnjvmClassLoader* JCL = 
+    JnjvmClassLoader::getJnjvmLoaderFromJavaObject(loader, vm);
  
+  int32_t size = JavaArray::getSize(bytes);
+  ClassBytes* classBytes = new (JCL->allocator, size) ClassBytes(size);
+  memcpy(classBytes->elements, JavaArray::getElements(bytes), size);
+   
   // Before creating a class, do a check on the bytes.  
-  Reader reader(&bytes);
+  Reader reader(classBytes);
   uint32 magic = reader.readU4();
   if (magic != Jnjvm::Magic) {
     JavaThread::get()->getJVM()->classFormatError("bad magic number");
   }
 
-  JnjvmClassLoader* JCL = 
-    JnjvmClassLoader::getJnjvmLoaderFromJavaObject(loader, vm);
   
   const UTF8* name = JavaString::javaToInternal(str, JCL->hashUTF8);
   UserCommonClass* cl = JCL->lookupClass(name);
   
   if (!cl) {
-    UserClass* cl = JCL->constructClass(name, bytes);
+    UserClass* cl = JCL->constructClass(name, classBytes);
     cl->resolveClass();
 
     res = cl->getClassDelegatee(vm, pd);

Modified: vmkit/branches/precise/lib/J3/Classpath/ClasspathVMThrowable.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Classpath/ClasspathVMThrowable.inc?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/Classpath/ClasspathVMThrowable.inc (original)
+++ vmkit/branches/precise/lib/J3/Classpath/ClasspathVMThrowable.inc Wed Nov 10 14:00:39 2010
@@ -103,7 +103,7 @@
   
   // We don't have the bytes if the class was vmjc'ed.
   if (sourceAtt && cl->getBytes()) {
-    Reader reader(sourceAtt, cl->getBytesPtr());
+    Reader reader(sourceAtt, cl->bytes);
     uint16 index = reader.readU2();
     sourceName = vm->internalUTF8ToStr(cl->getConstantPool()->UTF8At(index));
   }

Modified: vmkit/branches/precise/lib/J3/Compiler/JavaAOTCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Compiler/JavaAOTCompiler.cpp?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/Compiler/JavaAOTCompiler.cpp (original)
+++ vmkit/branches/precise/lib/J3/Compiler/JavaAOTCompiler.cpp Wed Nov 10 14:00:39 2010
@@ -446,7 +446,7 @@
         Elts.push_back(Constant::getNullValue(Ty));
       }
     } else {
-      Reader reader(attribut, &(cl->bytes));
+      Reader reader(attribut, cl->bytes);
       JavaConstantPool * ctpInfo = cl->ctpInfo;
       uint16 idx = reader.readU2();
       if (type->isPrimitive()) {
@@ -1904,14 +1904,14 @@
 
 
 
-void extractFiles(ArrayUInt8* bytes,
+void extractFiles(ClassBytes* bytes,
                   JavaAOTCompiler* M,
                   JnjvmBootstrapLoader* bootstrapLoader,
                   std::vector<Class*>& classes) {
   ZipArchive archive(bytes, bootstrapLoader->allocator);
    
-  mvm::ThreadAllocator allocator; 
-  char* realName = (char*)allocator.Allocate(4096);
+  mvm::BumpPtrAllocator allocator; 
+  char* realName = (char*)allocator.Allocate(4096, "temp");
   for (ZipArchive::table_iterator i = archive.filetable.begin(), 
        e = archive.filetable.end(); i != e; ++i) {
     ZipFile* file = i->second;
@@ -1928,9 +1928,7 @@
       classes.push_back(cl);  
     } else if (size > 4 && (!strcmp(&name[size - 4], ".jar") || 
                             !strcmp(&name[size - 4], ".zip"))) {
-      UserClassArray* array = bootstrapLoader->upcalls->ArrayOfByte;
-      ArrayUInt8* res = 
-        (ArrayUInt8*)array->doNew(file->ucsize, JavaThread::get()->getJVM());
+      ClassBytes* res = new (allocator, file->ucsize) ClassBytes(file->ucsize);
       int ok = archive.readFile(res, file);
       if (!ok) return;
       
@@ -1974,7 +1972,7 @@
       (!strcmp(&name[size - 4], ".jar") || !strcmp(&name[size - 4], ".zip"))) {
   
     std::vector<Class*> classes;
-    ArrayUInt8* bytes = Reader::openFile(bootstrapLoader, name);
+    ClassBytes* bytes = Reader::openFile(bootstrapLoader, name);
       
     if (!bytes) {
       fprintf(stderr, "Can't find zip file.\n");

Modified: vmkit/branches/precise/lib/J3/Compiler/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Compiler/JavaJIT.cpp?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/Compiler/JavaJIT.cpp (original)
+++ vmkit/branches/precise/lib/J3/Compiler/JavaJIT.cpp Wed Nov 10 14:00:39 2010
@@ -364,7 +364,7 @@
   Value* oldCLIN = new AllocaInst(PointerType::getUnqual(Type::getInt32Ty(*llvmContext)), "",
                                   currentBlock);
   
-  Constant* sizeF = ConstantInt::get(Type::getInt32Ty(*llvmContext), 2 * sizeof(void*));
+  Constant* sizeF = ConstantInt::get(Type::getInt32Ty(*llvmContext), sizeof(mvm::KnownFrame));
   Value* Frame = new AllocaInst(Type::getInt8Ty(*llvmContext), sizeF, "", currentBlock);
   
   uint32 nargs = func->arg_size() + 1 + (stat ? 1 : 0); 
@@ -752,7 +752,7 @@
     abort();
   }
 
-  Reader reader(codeAtt, &(compilingClass->bytes));
+  Reader reader(codeAtt, compilingClass->bytes);
   uint16 maxStack = reader.readU2();
   uint16 maxLocals = reader.readU2();
   uint32 codeLen = reader.readU4();
@@ -942,7 +942,7 @@
     abort();
   } 
 
-  Reader reader(codeAtt, &(compilingClass->bytes));
+  Reader reader(codeAtt, compilingClass->bytes);
   uint16 maxStack = reader.readU2();
   uint16 maxLocals = reader.readU2();
   uint32 codeLen = reader.readU4();
@@ -1291,7 +1291,7 @@
     compilingMethod->lookupAttribut(Attribut::annotationsAttribut);
   
   if (annotationsAtt) {
-    Reader reader(annotationsAtt, &(compilingClass->bytes));
+    Reader reader(annotationsAtt, compilingClass->bytes);
     AnnotationReader AR(reader, compilingClass);
     uint16 numAnnotations = reader.readU2();
     for (uint16 i = 0; i < numAnnotations; ++i) {
@@ -1473,25 +1473,7 @@
 }
 
 Value* JavaJIT::getTarget(FunctionType::param_iterator it, uint32 nb) {
-#if defined(ISOLATE_SHARING)
-  nb += 1;
-#endif
-#if defined(ISOLATE_SHARING)
-  sint32 start = nb - 2;
-  it--;
-  it--;
-#else
-  sint32 start = nb - 1;
-#endif
-  uint32 nbObjects = 0;
-  for (sint32 i = start; i >= 0; --i) {
-    it--;
-    if (it->get() == intrinsics->JavaObjectType) {
-      nbObjects++;
-    }
-  }
-  assert(nbObjects > 0 && "No this");
-  return objectStack[currentStackIndex - nbObjects];
+  return objectStack[currentStackIndex - nb];
 }
 
 Instruction* JavaJIT::lowerMathOps(const UTF8* name, 
@@ -2212,12 +2194,8 @@
  
   const llvm::Type* retType = virtualType->getReturnType();
   BasicBlock* endBlock = createBasicBlock("end interface invoke");
-  PHINode * node = 0;
-  if (retType != Type::getVoidTy(*llvmContext)) {
-    node = PHINode::Create(retType, "", endBlock);
-  }
-  
- 
+  PHINode * node = PHINode::Create(virtualPtrType, "", endBlock);
+   
   CommonClass* cl = 0;
   JavaMethod* meth = 0;
   ctpInfo->infoOfMethod(index, ACC_VIRTUAL, cl, meth);
@@ -2230,13 +2208,11 @@
                              intrinsics->JavaMethodType, 0, true);
   }
 
-  // Compute the arguments after calling getConstantPoolAt because the
-  // arguments will be loaded and the runtime may trigger GC.
-  std::vector<Value*> args; // size = [signature->nbIn + 3];
-
-  FunctionType::param_iterator it  = virtualType->param_end();
-  makeArgs(it, index, args, signature->nbArguments + 1);
-  JITVerifyNull(args[0]);
+  Value* targetObject = getTarget(virtualType->param_end(),
+                                  signature->nbArguments + 1);
+  targetObject = new LoadInst(
+          targetObject, "", TheCompiler->useCooperativeGC(), currentBlock);
+  JITVerifyNull(targetObject);
 
   BasicBlock* label_bb = createBasicBlock("bb");
   BasicBlock* label_bb4 = createBasicBlock("bb4");
@@ -2244,7 +2220,7 @@
   BasicBlock* label_bb7 = createBasicBlock("bb7");
     
   // Block entry (label_entry)
-  Value* VT = CallInst::Create(intrinsics->GetVTFunction, args[0], "",
+  Value* VT = CallInst::Create(intrinsics->GetVTFunction, targetObject, "",
                                currentBlock);
   Value* IMT = CallInst::Create(intrinsics->GetIMTFunction, VT, "",
                                 currentBlock);
@@ -2270,8 +2246,8 @@
   // Block bb (label_bb)
   currentBlock = label_bb;
   CastInst* ptr_22 = new IntToPtrInst(int32_19, virtualPtrType, "", currentBlock);
-  Value* ret = invoke(ptr_22, args, "", currentBlock);
-  if (node) node->addIncoming(ret, currentBlock);
+  
+  node->addIncoming(ptr_22, currentBlock);
   BranchInst::Create(endBlock, currentBlock);
     
   // Block bb4 (label_bb4)
@@ -2300,8 +2276,8 @@
   LoadInst* int32_32 = new LoadInst(ptr_31, "", false, currentBlock);
   CastInst* ptr_33 = new BitCastInst(int32_32, virtualPtrType, "",
                                      currentBlock);
-  ret = invoke(ptr_33, args, "", currentBlock);
-  if (node) node->addIncoming(ret, currentBlock);
+  node->addIncoming(ptr_33, currentBlock);
+
   BranchInst::Create(endBlock, currentBlock);
     
   // Block bb7 (label_bb7)
@@ -2332,12 +2308,17 @@
   ptr_table_0_lcssa->addIncoming(ptr_37, currentBlock);
       
   currentBlock = endBlock;
-  if (node) {
-    if (node->getType() == intrinsics->JavaObjectType) {
+
+  std::vector<Value*> args; // size = [signature->nbIn + 3];
+  FunctionType::param_iterator it  = virtualType->param_end();
+  makeArgs(it, index, args, signature->nbArguments + 1);
+  Value* ret = invoke(node, args, "", currentBlock);
+  if (retType != Type::getVoidTy(*llvmContext)) {
+    if (ret->getType() == intrinsics->JavaObjectType) {
       JnjvmClassLoader* JCL = compilingClass->classLoader;
-      push(node, false, signature->getReturnType()->findAssocClass(JCL));
+      push(ret, false, signature->getReturnType()->findAssocClass(JCL));
     } else {
-      push(node, signature->getReturnType()->isUnsigned());
+      push(ret, signature->getReturnType()->isUnsigned());
       if (retType == Type::getDoubleTy(*llvmContext) ||
           retType == Type::getInt64Ty(*llvmContext)) {
         push(intrinsics->constantZero, false);

Modified: vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp (original)
+++ vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp Wed Nov 10 14:00:39 2010
@@ -61,13 +61,13 @@
   JavaMethod* meth = (JavaMethod*)MetaInfo;
   CodeLineInfo* info = meth->lookupCodeLineInfo((uintptr_t)ip);
   if (info != NULL) {
-    fprintf(stderr, "; %p in %s.%s (line %d, bytecode %d, code start %p)", new_ip,
+    fprintf(stderr, "; %p (%p) in %s.%s (line %d, bytecode %d, code start %p)", new_ip, addr,
             UTF8Buffer(meth->classDef->name).cString(),
             UTF8Buffer(meth->name).cString(),
             meth->lookupLineNumber((uintptr_t)ip),
             info->bytecodeIndex, meth->code);
   } else {
-    fprintf(stderr, "; %p in %s.%s (native method, code start %p)", new_ip,
+    fprintf(stderr, "; %p (%p) in %s.%s (native method, code start %p)", new_ip, addr,
             UTF8Buffer(meth->classDef->name).cString(),
             UTF8Buffer(meth->name).cString(), meth->code);
   }
@@ -83,65 +83,14 @@
   // The following is necessary for -load-bc.
   if (F.getParent() != TheCompiler->getLLVMModule()) return;
   assert(F.hasGC());
-
-  Jnjvm* vm = JavaThread::get()->getJVM();
-  mvm::BumpPtrAllocator& Alloc = TheCompiler->allocator;
-
-  // Fetch the GCStrategy if it wasn't created before.
-  if (TheCompiler->TheGCStrategy == NULL) {
-    assert(mvm::MvmModule::TheGCStrategy != NULL && "No GC strategy");
-    TheCompiler->TheGCStrategy = mvm::MvmModule::TheGCStrategy;
-    mvm::MvmModule::TheGCStrategy = NULL;
-  }
-  
-  GCStrategy::iterator I = TheCompiler->TheGCStrategy->end();
-  I--;
-  while (&(*I)->getFunction() != &F) {
-    // This happens when the compilation of a function was post-poned.
-    assert(I != TheCompiler->TheGCStrategy->begin() && "No GC info");
-    I--;
-  }
-  assert(&(*I)->getFunction() == &F && "GC Info and method do not correspond");
-  llvm::GCFunctionInfo* GFI = *I;
-
-  JavaMethod* meth = TheCompiler->getJavaMethod(F);
-  mvm::JITMethodInfo* MI = NULL;
-  if (meth == NULL) {
-    // This is a stub.
-    MI = new(Alloc, "JITMethodInfo") mvm::MvmJITMethodInfo(GFI, &F, TheCompiler);
-  } else {
-    MI = new(Alloc, "JavaJITMethodInfo") JavaJITMethodInfo(GFI, meth);
-  }
-  JIT* jit = (JIT*)TheCompiler->executionEngine;
-  MI->addToVM(vm, jit);
-
-  if (meth == NULL) return;
-
-  uint32_t infoLength = GFI->size();
-  meth->codeInfoLength = infoLength;
-  if (infoLength == 0) {
-    meth->codeInfo = NULL;
+  if (TheCompiler->GCInfo != NULL) {
+    assert(TheCompiler->GCInfo == Details.MF->getGMI());
     return;
   }
-
-  mvm::BumpPtrAllocator& JavaAlloc = meth->classDef->classLoader->allocator;
-  CodeLineInfo* infoTable =
-    new(JavaAlloc, "CodeLineInfo") CodeLineInfo[infoLength];
-  uint32_t index = 0;
-  for (GCFunctionInfo::iterator I = GFI->begin(), E = GFI->end();
-       I != E;
-       I++, index++) {
-    DebugLoc DL = I->Loc;
-    uint32_t bytecodeIndex = DL.getLine();
-    uint32_t second = DL.getCol();
-    assert(second == 0 && "Wrong column number");
-    uintptr_t address = jit->getCodeEmitter()->getLabelAddress(I->Label);
-    infoTable[index].address = address;
-    infoTable[index].bytecodeIndex = bytecodeIndex;
-  }
-  meth->codeInfo = infoTable;
+  TheCompiler->GCInfo = Details.MF->getGMI();
 }
 
+
 Constant* JavaJITCompiler::getNativeClass(CommonClass* classDef) {
   const llvm::Type* Ty = classDef->isClass() ? JavaIntrinsics.JavaClassType :
                                                JavaIntrinsics.JavaCommonClassType;
@@ -250,15 +199,10 @@
   JavaLLVMCompiler(ModuleID), listener(this) {
 
   EmitFunctionName = false;
+  GCInfo = NULL;
 
-  // Protect IR for the GC.
-  mvm::MvmModule::protectIR();
   executionEngine = ExecutionEngine::createJIT(TheModule, 0,
                                                0, llvm::CodeGenOpt::Default, false);
-  TheGCStrategy = mvm::MvmModule::TheGCStrategy;
-  mvm::MvmModule::TheGCStrategy = NULL;
-  mvm::MvmModule::unprotectIR();
- 
   executionEngine->RegisterJITEventListener(&listener);
 
   addJavaPasses();
@@ -405,7 +349,41 @@
   mvm::MvmModule::protectIR();
   Function* func = parseFunction(meth);
   void* res = executionEngine->getPointerToGlobal(func);
-  // Now that it's compiled, we don't need the IR anymore
+ 
+  if (!func->isDeclaration()) {
+    llvm::GCFunctionInfo* GFI = &(GCInfo->getFunctionInfo(*func));
+    assert((GFI != NULL) && "No GC information");
+  
+    Jnjvm* vm = JavaThread::get()->getJVM();
+    mvm::JITMethodInfo* MI = 
+      new(allocator, "JavaJITMethodInfo") JavaJITMethodInfo(GFI, meth);
+    MI->addToVM(vm, (JIT*)executionEngine);
+
+    uint32_t infoLength = GFI->size();
+    meth->codeInfoLength = infoLength;
+    if (infoLength == 0) {
+      meth->codeInfo = NULL;
+    } else {
+      mvm::BumpPtrAllocator& JavaAlloc = meth->classDef->classLoader->allocator;
+      CodeLineInfo* infoTable =
+        new(JavaAlloc, "CodeLineInfo") CodeLineInfo[infoLength];
+      uint32_t index = 0;
+      for (GCFunctionInfo::iterator I = GFI->begin(), E = GFI->end();
+           I != E;
+           I++, index++) {
+        DebugLoc DL = I->Loc;
+        uint32_t bytecodeIndex = DL.getLine();
+        uint32_t second = DL.getCol();
+        assert(second == 0 && "Wrong column number");
+        uintptr_t address =
+            ((JIT*)executionEngine)->getCodeEmitter()->getLabelAddress(I->Label);
+        infoTable[index].address = address;
+        infoTable[index].bytecodeIndex = bytecodeIndex;
+      }
+      meth->codeInfo = infoTable;
+    }
+  }
+    // Now that it's compiled, we don't need the IR anymore
   func->deleteBody();
   mvm::MvmModule::unprotectIR();
   return res;
@@ -414,6 +392,15 @@
 void* JavaJITCompiler::GenerateStub(llvm::Function* F) {
   mvm::MvmModule::protectIR();
   void* res = executionEngine->getPointerToGlobal(F);
+  
+  llvm::GCFunctionInfo* GFI = &(GCInfo->getFunctionInfo(*F));
+  assert((GFI != NULL) && "No GC information");
+  
+  Jnjvm* vm = JavaThread::get()->getJVM();
+  mvm::JITMethodInfo* MI = 
+    new(allocator, "JITMethodInfo") mvm::MvmJITMethodInfo(GFI, F, this);
+  MI->addToVM(vm, (JIT*)executionEngine);
+  
   // Now that it's compiled, we don't need the IR anymore
   F->deleteBody();
   mvm::MvmModule::unprotectIR();

Modified: vmkit/branches/precise/lib/J3/LLVMRuntime/runtime-mmtk-thread.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/LLVMRuntime/runtime-mmtk-thread.ll?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/LLVMRuntime/runtime-mmtk-thread.ll (original)
+++ vmkit/branches/precise/lib/J3/LLVMRuntime/runtime-mmtk-thread.ll Wed Nov 10 14:00:39 2010
@@ -1,4 +1,4 @@
-%BumpPtrAllocator = type { i32, i8*, i8*, i8*, i8*, i8*, i8*, i8* }
+%ThreadAllocator = type { i8*, i8*, i8*, i8*, i8*, i8*, i8* }
 
 ;;; Field 0: the VT of threads
 ;;; Field 1: next
@@ -13,9 +13,9 @@
 ;;; Field 10: internalThreadID
 ;;; field 11: routine
 ;;; field 12: lastKnownFrame
-;;; field 13: lastKnownBufer
+;;; field 13: lastKnownBuffer
 ;;; field 14: allocator
 ;;; field 15: MutatorContext
 ;;; field 16: realRoutine
 %MutatorThread = type { %VT*, %JavaThread*, %JavaThread*, i8*, i8*, i8*, i1, i1,
-                        i1, i8*, i8*, i8*, i8*, i8*, %BumpPtrAllocator, i8*, i8* }
+                        i1, i8*, i8*, i8*, i8*, i8*, %ThreadAllocator, i8*, i8* }

Modified: vmkit/branches/precise/lib/J3/VMCore/JavaArray.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JavaArray.h?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/VMCore/JavaArray.h (original)
+++ vmkit/branches/precise/lib/J3/VMCore/JavaArray.h Wed Nov 10 14:00:39 2010
@@ -98,6 +98,7 @@
   static void setElement(ArrayObject* self, JavaObject* value, uint32_t i) {
     llvm_gcroot(self, 0);
     llvm_gcroot(value, 0);
+    if (value != NULL) assert(value->getVirtualTable());
     self->elements[i] = value;
   }
 

Modified: vmkit/branches/precise/lib/J3/VMCore/JavaClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JavaClass.cpp?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/VMCore/JavaClass.cpp (original)
+++ vmkit/branches/precise/lib/J3/VMCore/JavaClass.cpp Wed Nov 10 14:00:39 2010
@@ -216,9 +216,8 @@
   logSize = nb;
 }
 
-Class::Class(JnjvmClassLoader* loader, const UTF8* n, ArrayUInt8* B) : 
+Class::Class(JnjvmClassLoader* loader, const UTF8* n, ClassBytes* B) : 
     CommonClass(loader, n) {
-  llvm_gcroot(B, 0);
   virtualVT = 0;
   bytes = B;
   super = 0;
@@ -601,7 +600,7 @@
   if (!attribut) {
     InitNullStaticField();
   } else {
-    Reader reader(attribut, &(classDef->bytes));
+    Reader reader(attribut, classDef->bytes);
     JavaConstantPool * ctpInfo = classDef->ctpInfo;
     uint16 idx = reader.readU2();
     if (type->isPrimitive()) {
@@ -687,7 +686,7 @@
   Attribut* codeAtt = meth.lookupAttribut(Attribut::codeAttribut);
    
   if (codeAtt) {
-    Reader reader(codeAtt, &(meth.classDef->bytes));
+    Reader reader(codeAtt, meth.classDef->bytes);
     //uint16 maxStack =
     reader.readU2();
     //uint16 maxLocals = 
@@ -888,7 +887,7 @@
   PRINT_DEBUG(JNJVM_LOAD, 0, LIGHT_GREEN, "reading ", 0);
   PRINT_DEBUG(JNJVM_LOAD, 0, COLOR_NORMAL, "%s\n", mvm::PrintBuffer(this).cString());
 
-  Reader reader(&bytes);
+  Reader reader(bytes);
   uint32 magic = reader.readU4();
   assert(magic == Jnjvm::Magic && "I've created a class but magic is no good!");
 
@@ -942,7 +941,7 @@
   if (!innerOuterResolved) {
     Attribut* attribut = lookupAttribut(Attribut::innerClassesAttribut);
     if (attribut != 0) {
-      Reader reader(attribut, getBytesPtr());
+      Reader reader(attribut, bytes);
       uint16 nbi = reader.readU2();
       for (uint16 i = 0; i < nbi; ++i) {
         uint16 inner = reader.readU2();
@@ -1019,7 +1018,7 @@
     return (ArrayObject*)vm->upcalls->classArrayClass->doNew(0, vm);
   } else {
     UserConstantPool* ctp = classDef->getConstantPool();
-    Reader reader(exceptionAtt, classDef->getBytesPtr());
+    Reader reader(exceptionAtt, classDef->bytes);
     uint16 nbe = reader.readU2();
     res = (ArrayObject*)vm->upcalls->classArrayClass->doNew(nbe, vm);
 
@@ -1757,7 +1756,7 @@
     if (codeInfo[i].address == ip) {
       Attribut* codeAtt = lookupAttribut(Attribut::codeAttribut);      
       if (codeAtt == NULL) return 0;
-      Reader reader(codeAtt, &(classDef->bytes));
+      Reader reader(codeAtt, classDef->bytes);
       reader.readU2(); // max_stack
       reader.readU2(); // max_locals;
       uint32_t codeLength = reader.readU4();
@@ -1790,7 +1789,7 @@
   for(uint16 i = 0; i < codeInfoLength; ++i) {
     if (codeInfo[i].address == ip) {
       Attribut* codeAtt = lookupAttribut(Attribut::codeAttribut);
-      Reader reader(codeAtt, &(classDef->bytes));
+      Reader reader(codeAtt, classDef->bytes);
       reader.cursor = reader.cursor + 2 + 2 + 4 + codeInfo[i].bytecodeIndex + 1;
       return reader.readU2();
     }

Modified: vmkit/branches/precise/lib/J3/VMCore/JavaClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JavaClass.h?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/VMCore/JavaClass.h (original)
+++ vmkit/branches/precise/lib/J3/VMCore/JavaClass.h Wed Nov 10 14:00:39 2010
@@ -34,6 +34,7 @@
 class ArrayUInt16;
 class Class;
 class ClassArray;
+class ClassBytes;
 class JavaArray;
 class JavaConstantPool;
 class JavaField;
@@ -457,7 +458,7 @@
   
   /// bytes - The .class file of this class.
   ///
-  ArrayUInt8* bytes;
+  ClassBytes* bytes;
 
   /// ctpInfo - The constant pool info of this class.
   ///
@@ -621,7 +622,7 @@
   
   /// Class - Create a class in the given virtual machine and with the given
   /// name.
-  Class(JnjvmClassLoader* loader, const UTF8* name, ArrayUInt8* bytes);
+  Class(JnjvmClassLoader* loader, const UTF8* name, ClassBytes* bytes);
   
   /// readParents - Reads the parents, i.e. super and interfaces, of the class.
   ///
@@ -656,14 +657,10 @@
 
   /// getBytes - Get the bytes of the class file.
   ///
-  ArrayUInt8* getBytes() const {
+  ClassBytes* getBytes() const {
     return bytes;
   }
   
-  ArrayUInt8** getBytesPtr() {
-    return &bytes;
-  }
-  
   /// resolveInnerOuterClasses - Resolve the inner/outer information.
   ///
   void resolveInnerOuterClasses();
@@ -1300,6 +1297,7 @@
 
   void setStaticObjectField(JavaObject* val) {
     llvm_gcroot(val, 0);
+    if (val != NULL) assert(val->getVirtualTable());
     assert(classDef->isResolved());
     void* ptr = (void*)((uint64)classDef->getStaticInstance() + ptrOffset);
     ((JavaObject**)ptr)[0] = val;
@@ -1315,6 +1313,7 @@
   void setInstanceObjectField(JavaObject* obj, JavaObject* val) {
     llvm_gcroot(obj, 0);
     llvm_gcroot(val, 0);
+    if (val != NULL) assert(val->getVirtualTable());
     assert(classDef->isResolved());
     void* ptr = (void*)((uint64)obj + ptrOffset);
     ((JavaObject**)ptr)[0] = val;

Modified: vmkit/branches/precise/lib/J3/VMCore/JavaConstantPool.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JavaConstantPool.cpp?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/VMCore/JavaConstantPool.cpp (original)
+++ vmkit/branches/precise/lib/J3/VMCore/JavaConstantPool.cpp Wed Nov 10 14:00:39 2010
@@ -190,7 +190,7 @@
   
   if (!ctpRes[entry]) {
     mvm::ThreadAllocator allocator;
-    Reader reader(&(classDef->bytes), ctpDef[entry]);
+    Reader reader(classDef->bytes, ctpDef[entry]);
     uint32 len = reader.readU2();
     uint16* buf = (uint16*)allocator.Allocate(len * sizeof(uint16));
     uint32 n = 0;

Modified: vmkit/branches/precise/lib/J3/VMCore/JavaRuntimeJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JavaRuntimeJIT.cpp?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/VMCore/JavaRuntimeJIT.cpp (original)
+++ vmkit/branches/precise/lib/J3/VMCore/JavaRuntimeJIT.cpp Wed Nov 10 14:00:39 2010
@@ -360,9 +360,10 @@
  
   *oldLocalReferencesNumber = th->currentAddedReferences;
   th->currentAddedReferences = localReferencesNumber;
-  th->startKnownFrame(*Frame);
-
-  th->startJNI(1);
+  th->startJNI();
+  th->startUnknownFrame(*Frame);
+  th->enterUncooperativeCode();
+  assert(th->getLastSP() == th->lastKnownFrame->currentFP);
 
   return Frame->currentFP;
 }

Modified: vmkit/branches/precise/lib/J3/VMCore/JavaThread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JavaThread.cpp?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/VMCore/JavaThread.cpp (original)
+++ vmkit/branches/precise/lib/J3/VMCore/JavaThread.cpp Wed Nov 10 14:00:39 2010
@@ -62,9 +62,16 @@
   th->internalThrowException();
 }
 
-void JavaThread::startJNI(int level) {
-  // Start uncooperative mode.
-  enterUncooperativeCode(level);
+void JavaThread::startJNI() {
+  // Interesting, but no need to do anything.
+}
+
+void JavaThread::endJNI() {
+  localJNIRefs->removeJNIReferences(this, *currentAddedReferences);
+  endUnknownFrame();
+   
+  // Go back to cooperative mode.
+  leaveUncooperativeCode();
 }
 
 uint32 JavaThread::getJavaFrameContext(void** buffer) {

Modified: vmkit/branches/precise/lib/J3/VMCore/JavaThread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JavaThread.h?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/VMCore/JavaThread.h (original)
+++ vmkit/branches/precise/lib/J3/VMCore/JavaThread.h Wed Nov 10 14:00:39 2010
@@ -186,16 +186,9 @@
 
   /// startJNI - Record that we are entering native code.
   ///
-  void startJNI(int level) __attribute__ ((noinline));
+  void startJNI();
 
-  void endJNI() {
-    localJNIRefs->removeJNIReferences(this, *currentAddedReferences);
-   
-    // Go back to cooperative mode.
-    leaveUncooperativeCode();
-   
-    endKnownFrame();
-  }
+  void endJNI();
 
   /// getCallingMethod - Get the Java method in the stack at the specified
   /// level.

Modified: vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp (original)
+++ vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp Wed Nov 10 14:00:39 2010
@@ -811,19 +811,18 @@
 }
 
 
-char* findInformation(Jnjvm* vm, ArrayUInt8* manifest, const char* entry,
-                      uint32 len) {
-  llvm_gcroot(manifest, 0);
-  sint32 index = sys_strnstr((char*)ArrayUInt8::getElements(manifest), entry);
+static char* findInformation(Jnjvm* vm, ClassBytes* manifest, const char* entry,
+                             uint32 len) {
+  sint32 index = sys_strnstr((char*)manifest->elements, entry);
   if (index != -1) {
     index += len;
-    sint32 end = sys_strnstr((char*)ArrayUInt8::getElements(manifest) + index, "\n");
-    if (end == -1) end = ArrayUInt8::getSize(manifest);
+    sint32 end = sys_strnstr((char*)manifest->elements + index, "\n");
+    if (end == -1) end = manifest->size;
     else end += index;
 
     sint32 length = end - index - 1;
     char* name = (char*)vm->allocator.Allocate(length + 1, "class name");
-    memcpy(name, ArrayUInt8::getElements(manifest) + index, length);
+    memcpy(name, manifest->elements + index, length);
     name[length] = 0;
     return name;
   } else {
@@ -833,10 +832,8 @@
 
 void ClArgumentsInfo::extractClassFromJar(Jnjvm* vm, int argc, char** argv, 
                                           int i) {
-  ArrayUInt8* bytes = NULL;
-  ArrayUInt8* res = NULL;
-  llvm_gcroot(bytes, 0);
-  llvm_gcroot(res, 0);
+  ClassBytes* bytes = NULL;
+  ClassBytes* res = NULL;
   jarFile = argv[i];
 
   vm->setClasspath(jarFile);
@@ -851,13 +848,10 @@
   mvm::BumpPtrAllocator allocator;
   ZipArchive* archive = new(allocator, "TempZipArchive")
       ZipArchive(bytes, allocator);
-  // Make sure it gets GC'd.
-  vm->bootstrapLoader->bootArchives.push_back(archive);
   if (archive->getOfscd() != -1) {
     ZipFile* file = archive->getFile(PATH_MANIFEST);
     if (file != NULL) {
-      UserClassArray* array = vm->bootstrapLoader->upcalls->ArrayOfByte;
-      res = (ArrayUInt8*)array->doNew(file->ucsize, vm);
+      res = new (allocator, file->ucsize) ClassBytes(file->ucsize);
       int ok = archive->readFile(res, file);
       if (ok) {
         char* mainClass = findInformation(vm, res, MAIN_CLASS,
@@ -880,8 +874,6 @@
   } else {
     printf("Can't find archive %s\n", jarFile);
   }
-  // We don't need this archive anymore.
-  vm->bootstrapLoader->bootArchives.pop_back();
 }
 
 void ClArgumentsInfo::nyi() {

Modified: vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp (original)
+++ vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp Wed Nov 10 14:00:39 2010
@@ -308,9 +308,8 @@
   TheCompiler = Comp;
 }
 
-ArrayUInt8* JnjvmBootstrapLoader::openName(const UTF8* utf8) {
-  ArrayUInt8* res = 0;
-  llvm_gcroot(res, 0);
+ClassBytes* JnjvmBootstrapLoader::openName(const UTF8* utf8) {
+  ClassBytes* res = 0;
   mvm::ThreadAllocator threadAllocator;
 
   char* asciiz = (char*)threadAllocator.Allocate(utf8->size + 1);
@@ -348,8 +347,7 @@
 UserClass* JnjvmBootstrapLoader::internalLoad(const UTF8* name,
                                               bool doResolve,
                                               JavaString* strName) {
-  ArrayUInt8* bytes = NULL;
-  llvm_gcroot(bytes, 0);
+  ClassBytes* bytes = NULL;
   llvm_gcroot(strName, 0);
 
   UserCommonClass* cl = lookupClass(name);
@@ -667,9 +665,8 @@
 }
 
 UserClass* JnjvmClassLoader::constructClass(const UTF8* name,
-                                            ArrayUInt8* bytes) {
+                                            ClassBytes* bytes) {
   JavaObject* excp = NULL;
-  llvm_gcroot(bytes, 0);
   llvm_gcroot(excp, 0);
   UserClass* res = NULL;
   lock.lock();
@@ -688,6 +685,8 @@
       getCompiler()->resolveVirtualClass(res);
       getCompiler()->resolveStaticClass(res);
       classes->lock.lock();
+      assert(res->getDelegatee() == NULL);
+      assert(res->getStaticInstance() == NULL);
       bool success = classes->map.insert(std::make_pair(internalName, res)).second;
       classes->lock.unlock();
       assert(success && "Could not add class in map");
@@ -967,8 +966,7 @@
 }
 
 void JnjvmBootstrapLoader::analyseClasspathEnv(const char* str) {
-  ArrayUInt8* bytes = NULL;
-  llvm_gcroot(bytes, 0);
+  ClassBytes* bytes = NULL;
   mvm::ThreadAllocator threadAllocator;
   if (str != 0) {
     unsigned int len = strlen(str);

Modified: vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.h?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.h (original)
+++ vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.h Wed Nov 10 14:00:39 2010
@@ -26,9 +26,9 @@
 
 namespace j3 {
 
-class ArrayUInt8;
 class UserClass;
 class UserClassArray;
+class ClassBytes;
 class ClassMap;
 class Classpath;
 class UserCommonClass;
@@ -209,7 +209,7 @@
   /// constructClass - Hashes a runtime representation of a class with
   /// the given name.
   ///
-  UserClass* constructClass(const UTF8* name, ArrayUInt8* bytes);
+  UserClass* constructClass(const UTF8* name, ClassBytes* bytes);
   
   /// constructType - Hashes a Typedef, an internal representation of a class
   /// still not loaded.
@@ -326,7 +326,7 @@
   /// openName - Opens a file of the given name and returns it as an array
   /// of byte.
   ///
-  ArrayUInt8* openName(const UTF8* utf8);
+  ClassBytes* openName(const UTF8* utf8);
   
 public:
   

Modified: vmkit/branches/precise/lib/J3/VMCore/Reader.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/Reader.cpp?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/VMCore/Reader.cpp (original)
+++ vmkit/branches/precise/lib/J3/VMCore/Reader.cpp Wed Nov 10 14:00:39 2010
@@ -12,10 +12,7 @@
 
 #include "types.h"
 
-#include "Jnjvm.h"
-#include "JavaArray.h"
-#include "JavaThread.h"
-#include "JavaUpcalls.h"
+#include "JnjvmClassLoader.h"
 #include "Reader.h"
 #include "Zip.h"
 
@@ -25,17 +22,15 @@
 const int Reader::SeekCur = SEEK_CUR;
 const int Reader::SeekEnd = SEEK_END;
 
-ArrayUInt8* Reader::openFile(JnjvmBootstrapLoader* loader, const char* path) {
-  ArrayUInt8* res = NULL;
-  llvm_gcroot(res, 0);
+ClassBytes* Reader::openFile(JnjvmClassLoader* loader, const char* path) {
+  ClassBytes* res = NULL;
   FILE* fp = fopen(path, "r");
   if (fp != 0) {
     fseek(fp, 0, SeekEnd);
     long nbb = ftell(fp);
     fseek(fp, 0, SeekSet);
-    UserClassArray* array = loader->upcalls->ArrayOfByte;
-    res = (ArrayUInt8*)array->doNew((sint32)nbb, JavaThread::get()->getJVM());
-    if (fread(ArrayUInt8::getElements(res), nbb, 1, fp) == 0) {
+    res = new (loader->allocator, nbb) ClassBytes(nbb);
+    if (fread(res->elements, nbb, 1, fp) == 0) {
       fprintf(stderr, "fread error\n");
       abort();  
     }
@@ -44,14 +39,12 @@
   return res;
 }
 
-ArrayUInt8* Reader::openZip(JnjvmBootstrapLoader* loader, ZipArchive* archive,
+ClassBytes* Reader::openZip(JnjvmClassLoader* loader, ZipArchive* archive,
                             const char* filename) {
-  ArrayUInt8* res = 0;
-  llvm_gcroot(res, 0);
+  ClassBytes* res = 0;
   ZipFile* file = archive->getFile(filename);
   if (file != 0) {
-    UserClassArray* array = loader->upcalls->ArrayOfByte;
-    res = (ArrayUInt8*)array->doNew((sint32)file->ucsize, JavaThread::get()->getJVM());
+    res = new (loader->allocator, file->ucsize) ClassBytes(file->ucsize);
     if (archive->readFile(res, file) != 0) {
       return res;
     }

Modified: vmkit/branches/precise/lib/J3/VMCore/Reader.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/Reader.h?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/VMCore/Reader.h (original)
+++ vmkit/branches/precise/lib/J3/VMCore/Reader.h Wed Nov 10 14:00:39 2010
@@ -20,18 +20,35 @@
 namespace j3 {
 
 class JnjvmBootstrapLoader;
+class JnjvmClassLoader;
 class ZipArchive;
 
+
+class ClassBytes {
+ public:
+  ClassBytes(int l) {
+    size = l;
+  }
+
+  void* operator new(size_t sz, mvm::BumpPtrAllocator& allocator, int n) {
+    return allocator.Allocate(sizeof(uint32_t) + n * sizeof(uint8_t),
+                              "Class bytes");
+  }
+
+  uint32_t size;
+  uint8_t elements[1];
+};
+
 class Reader {
 public:
   // bytes - Pointer to a reference array. The array is not manipulated directly
   // in order to support copying GC.
-  ArrayUInt8** bytes;
+  ClassBytes* bytes;
   uint32 min;
   uint32 cursor;
   uint32 max;
 
-  Reader(Attribut* attr, ArrayUInt8** bytes) {
+  Reader(Attribut* attr, ClassBytes* bytes) {
     this->bytes = bytes;
     this->cursor = attr->start;
     this->min = attr->start;
@@ -78,18 +95,18 @@
   static const int SeekCur;
   static const int SeekEnd;
 
-  static ArrayUInt8* openFile(JnjvmBootstrapLoader* loader, const char* path);
-  static ArrayUInt8* openZip(JnjvmBootstrapLoader* loader, ZipArchive* archive,
+  static ClassBytes* openFile(JnjvmClassLoader* loader, const char* path);
+  static ClassBytes* openZip(JnjvmClassLoader* loader, ZipArchive* archive,
                              const char* filename);
   
   uint8 readU1() {
     ++cursor;
-    return ArrayUInt8::getElement(*bytes, cursor - 1);
+    return bytes->elements[cursor - 1];
   }
   
   sint8 readS1() {
     ++cursor;
-    return ArrayUInt8::getElement(*bytes, cursor - 1);
+    return bytes->elements[cursor - 1];
   }
   
   uint16 readU2() {
@@ -122,8 +139,8 @@
     return tmp | ((sint64)(readU4()));
   }
 
-  Reader(ArrayUInt8** array, uint32 start = 0, uint32 end = 0) {
-    if (!end) end = ArrayUInt8::getSize(*array);
+  Reader(ClassBytes* array, uint32 start = 0, uint32 end = 0) {
+    if (!end) end = array->size;
     this->bytes = array;
     this->cursor = start;
     this->min = start;

Modified: vmkit/branches/precise/lib/J3/VMCore/VirtualTables.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/VirtualTables.cpp?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/VMCore/VirtualTables.cpp (original)
+++ vmkit/branches/precise/lib/J3/VMCore/VirtualTables.cpp Wed Nov 10 14:00:39 2010
@@ -142,8 +142,7 @@
 // (2) The delegatee object (java.lang.Class) if it exists.
 //
 // Additionaly, non-primitive and non-array classes must trace:
-// (3) The bytes that represent the class file.
-// (4) The static instance.
+// (3) The static instance.
 //===----------------------------------------------------------------------===//
 
 void CommonClass::tracer(uintptr_t closure) {
@@ -174,7 +173,6 @@
 
 void Class::tracer(uintptr_t closure) {
   CommonClass::tracer(closure);
-  mvm::Collector::markAndTraceRoot(&bytes, closure);
   
   for (uint32 i = 0; i < NR_ISOLATES; ++i) {
     TaskClassMirror &M = IsolateInfo[i];
@@ -243,11 +241,6 @@
   TRACE_DELEGATEE(upcalls->OfLong);
   TRACE_DELEGATEE(upcalls->OfDouble);
 #undef TRACE_DELEGATEE
-  
-  for (std::vector<ZipArchive*>::iterator i = bootArchives.begin(),
-       e = bootArchives.end(); i != e; i++) {
-    mvm::Collector::markAndTraceRoot(&((*i)->bytes), closure);
-  }
 }
 
 //===----------------------------------------------------------------------===//

Modified: vmkit/branches/precise/lib/J3/VMCore/Zip.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/Zip.cpp?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/VMCore/Zip.cpp (original)
+++ vmkit/branches/precise/lib/J3/VMCore/Zip.cpp Wed Nov 10 14:00:39 2010
@@ -17,8 +17,7 @@
 
 using namespace j3;
 
-ZipArchive::ZipArchive(ArrayUInt8* bytes, mvm::BumpPtrAllocator& A) : allocator(A) {
-  llvm_gcroot(bytes, 0);
+ZipArchive::ZipArchive(ClassBytes* bytes, mvm::BumpPtrAllocator& A) : allocator(A) {
   this->bytes = bytes;
   findOfscd();
   if (ofscd > -1) addFiles();
@@ -74,7 +73,7 @@
   sint32 minOffs = 0;
   sint32 st = END_CENTRAL_DIRECTORY_FILE_HEADER_SIZE + 4;
   
-  Reader reader(&bytes);
+  Reader reader(bytes);
   curOffs = reader.max;
   if (curOffs >= (65535 + END_CENTRAL_DIRECTORY_FILE_HEADER_SIZE + 4)) {
     minOffs = curOffs - (65535 + END_CENTRAL_DIRECTORY_FILE_HEADER_SIZE + 4);
@@ -104,8 +103,8 @@
     if (searchPos >= st) {
       sint32 searchPtr = temp + (searchPos - st);
       while (searchPtr > temp) {
-        if (ArrayUInt8::getElement(bytes, searchPtr) == 'P' && 
-          !(memcmp(ArrayUInt8::getElements(bytes) + searchPtr, HDR_ENDCENTRAL, 4))) {
+        if (bytes->elements[searchPtr] == 'P' && 
+          !(memcmp(bytes->elements + searchPtr, HDR_ENDCENTRAL, 4))) {
           sint32 offset = searchPtr + 4 + E_OFFSET_START_CENTRAL_DIRECTORY;
           reader.cursor = offset;
           this->ofscd = readEndianDep4(reader);
@@ -120,11 +119,11 @@
 void ZipArchive::addFiles() {
   sint32 temp = ofscd;
   
-  Reader reader(&bytes);
+  Reader reader(bytes);
   reader.cursor = temp;
 
   while (true) {
-    if (memcmp(ArrayUInt8::getElements(bytes) + temp, HDR_CENTRAL, 4)) return;
+    if (memcmp(bytes->elements + temp, HDR_CENTRAL, 4)) return;
     ZipFile* ptr = new(allocator, "ZipFile") ZipFile();
     reader.cursor = temp + 4 + C_COMPRESSION_METHOD;
     ptr->compressionMethod = readEndianDep2(reader);
@@ -148,7 +147,7 @@
 
     ptr->filename = (char*)allocator.Allocate(ptr->filenameLength + 1,
                                               "Zip file name");
-    memcpy(ptr->filename, ArrayUInt8::getElements(bytes) + temp,
+    memcpy(ptr->filename, bytes->elements + temp,
            ptr->filenameLength);
     ptr->filename[ptr->filenameLength] = 0;
 
@@ -161,17 +160,16 @@
   }
 }
 
-sint32 ZipArchive::readFile(ArrayUInt8* array, const ZipFile* file) {
-  llvm_gcroot(array, 0);
+sint32 ZipArchive::readFile(ClassBytes* array, const ZipFile* file) {
   uint32 bytesLeft = 0;
   uint32 filenameLength = 0;
   uint32 extraFieldLength = 0;
   uint32 temp = 0;
 
-  Reader reader(&bytes);
+  Reader reader(bytes);
   reader.cursor = file->rolh;
   
-  if (!(memcmp(ArrayUInt8::getElements(bytes) + file->rolh, HDR_LOCAL, 4))) {
+  if (!(memcmp(bytes->elements + file->rolh, HDR_LOCAL, 4))) {
     reader.cursor += 4;
     temp = reader.cursor;
     reader.cursor += L_FILENAME_LENGTH;
@@ -182,14 +180,14 @@
       temp + extraFieldLength + filenameLength + LOCAL_FILE_HEADER_SIZE;
 
     if (file->compressionMethod == ZIP_STORE) {
-      memcpy(ArrayUInt8::getElements(array), ArrayUInt8::getElements(bytes) + reader.cursor, file->ucsize);
+      memcpy(array->elements, bytes->elements + reader.cursor, file->ucsize);
       return 1;
     } else if (file->compressionMethod == ZIP_DEFLATE) {
       z_stream stre;
       sint32 err = 0;
       
       bytesLeft = file->csize;
-      stre.next_out = (Bytef*)ArrayUInt8::getElements(array);
+      stre.next_out = (Bytef*)array->elements;
       stre.avail_out = file->ucsize;
       stre.zalloc = 0;
       stre.zfree = 0;
@@ -202,7 +200,7 @@
 
       while (bytesLeft) {
         uint32 size = 0;
-        stre.next_in = ArrayUInt8::getElements(bytes) + reader.cursor;
+        stre.next_in = bytes->elements + reader.cursor;
         if (bytesLeft > 1024) size = 1024;
         else size = bytesLeft;
 

Modified: vmkit/branches/precise/lib/J3/VMCore/Zip.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/Zip.h?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/VMCore/Zip.h (original)
+++ vmkit/branches/precise/lib/J3/VMCore/Zip.h Wed Nov 10 14:00:39 2010
@@ -16,7 +16,7 @@
 
 namespace j3 {
 
-class ArrayUInt8;
+class classBytes;
 class JnjvmBootstrapLoader;
 
 struct ZipFile : public mvm::PermanentObject {
@@ -49,7 +49,7 @@
 public:
   std::map<const char*, ZipFile*, ltstr> filetable;
   typedef std::map<const char*, ZipFile*, ltstr>::iterator table_iterator;
-  ArrayUInt8* bytes;
+  ClassBytes* bytes;
 
 private:
   
@@ -70,9 +70,9 @@
   }
 
   int getOfscd() { return ofscd; }
-  ZipArchive(ArrayUInt8* bytes, mvm::BumpPtrAllocator& allocator);
+  ZipArchive(ClassBytes* bytes, mvm::BumpPtrAllocator& allocator);
   ZipFile* getFile(const char* filename);
-  int readFile(ArrayUInt8* array, const ZipFile* file);
+  int readFile(ClassBytes* array, const ZipFile* file);
 
 };
 

Modified: vmkit/branches/precise/lib/Mvm/CommonThread/CollectionRV.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/Mvm/CommonThread/CollectionRV.cpp?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/lib/Mvm/CommonThread/CollectionRV.cpp (original)
+++ vmkit/branches/precise/lib/Mvm/CommonThread/CollectionRV.cpp Wed Nov 10 14:00:39 2010
@@ -154,7 +154,7 @@
   th->inRV = false;
 }
 
-void CooperativeCollectionRV::joinAfterUncooperative() {
+void CooperativeCollectionRV::joinAfterUncooperative(void* SP) {
   mvm::Thread* th = mvm::Thread::get();
   assert((th->getLastSP() == NULL) &&
          "SP set after entering uncooperative code");
@@ -163,7 +163,7 @@
 
   lockRV();
   if (th->doYield) {
-    th->setLastSP(FRAME_PTR());
+    th->setLastSP(SP);
     if (!th->joinedRV) {
       th->joinedRV = true;
       another_mark();
@@ -213,7 +213,7 @@
   initiator->inRV = false;
 }
 
-void UncooperativeCollectionRV::joinAfterUncooperative() {
+void UncooperativeCollectionRV::joinAfterUncooperative(void* SP) {
   UNREACHABLE();
 }
 

Modified: vmkit/branches/precise/lib/Mvm/CommonThread/ctthread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/Mvm/CommonThread/ctthread.cpp?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/lib/Mvm/CommonThread/ctthread.cpp (original)
+++ vmkit/branches/precise/lib/Mvm/CommonThread/ctthread.cpp Wed Nov 10 14:00:39 2010
@@ -56,8 +56,8 @@
   MyVM->rendezvous.joinBeforeUncooperative(); 
 }
 
-void Thread::joinRVAfterLeave() {
-  MyVM->rendezvous.joinAfterUncooperative(); 
+void Thread::joinRVAfterLeave(void* savedSP) {
+  MyVM->rendezvous.joinAfterUncooperative(savedSP); 
 }
 
 void Thread::startKnownFrame(KnownFrame& F) {
@@ -67,10 +67,29 @@
   cur = (void**)cur[0];
   F.previousFrame = lastKnownFrame;
   F.currentFP = cur;
+  // This is used as a marker.
+  F.currentIP = NULL;
   lastKnownFrame = &F;
 }
 
 void Thread::endKnownFrame() {
+  assert(lastKnownFrame->currentIP == NULL);
+  lastKnownFrame = lastKnownFrame->previousFrame;
+}
+
+void Thread::startUnknownFrame(KnownFrame& F) {
+  // Get the caller of this function
+  void** cur = (void**)FRAME_PTR();
+  // Get the caller of the caller.
+  cur = (void**)cur[0];
+  F.previousFrame = lastKnownFrame;
+  F.currentFP = cur;
+  F.currentIP = FRAME_IP(cur);
+  lastKnownFrame = &F;
+}
+
+void Thread::endUnknownFrame() {
+  assert(lastKnownFrame->currentIP != NULL);
   lastKnownFrame = lastKnownFrame->previousFrame;
 }
 
@@ -155,23 +174,40 @@
 }
 
 void StackWalker::operator++() {
-  if (addr < thread->baseSP && addr < addr[0]) {
-    if (frame && addr == frame->currentFP) {
+  if (addr != thread->baseSP) {
+    assert((addr < thread->baseSP) && "Corrupted stack");
+    assert((addr < addr[0]) && "Corrupted stack");
+    if ((frame != NULL) && (addr == frame->currentFP)) {
+      assert(frame->currentIP == NULL);
+      frame = frame->previousFrame;
+      assert(frame != NULL);
+      assert(frame->currentIP != NULL);
+      addr = (void**)frame->currentFP;
       frame = frame->previousFrame;
-      if  (frame) {
-        addr = (void**)frame->currentFP;
-        frame = frame->previousFrame;
-      } else {
-        addr = (void**)addr[0];
-      }
     } else {
       addr = (void**)addr[0];
     }
-  } else {
-    addr = (void**)thread->baseSP;
   }
 }
 
+StackWalker::StackWalker(mvm::Thread* th) {
+  thread = th;
+  frame = th->lastKnownFrame;
+  if (mvm::Thread::get() == th) {
+    addr = (void**)FRAME_PTR();
+    addr = (void**)addr[0];
+  } else {
+    addr = (void**)th->waitOnSP();
+    if (frame) {
+      assert(frame->currentFP >= addr);
+    }
+    if (frame && (addr == frame->currentFP)) {
+      frame = frame->previousFrame;
+      assert((frame == NULL) || (frame->currentIP == NULL));
+    }
+  }
+  assert(addr && "No address to start with");
+}
 
 uintptr_t Thread::baseAddr = 0;
 
@@ -286,7 +322,7 @@
 /// given routine of th.
 ///
 void Thread::internalThreadStart(mvm::Thread* th) {
-  th->baseSP  = (void*)&th;
+  th->baseSP  = FRAME_PTR();
 
   // Set the SIGSEGV handler to diagnose errors.
   struct sigaction sa;
@@ -368,7 +404,6 @@
 #ifdef WITH_LLVM_GCC
 void Thread::scanStack(uintptr_t closure) {
   StackWalker Walker(this);
-
   while (MethodInfo* MI = Walker.get()) {
     MI->scan(closure, Walker.ip, Walker.addr);
     ++Walker;
@@ -390,3 +425,64 @@
   }
 }
 #endif
+
+void Thread::enterUncooperativeCode(unsigned level) {
+  if (isMvmThread()) {
+    if (!inRV) {
+      assert(!lastSP && "SP already set when entering uncooperative code");
+      // Get the caller.
+      void* temp = FRAME_PTR();
+      // Make sure to at least get the caller of the caller.
+      ++level;
+      while (level--) temp = ((void**)temp)[0];
+      // The cas is not necessary, but it does a memory barrier.
+      __sync_bool_compare_and_swap(&lastSP, 0, temp);
+      if (doYield) joinRVBeforeEnter();
+      assert(lastSP && "No last SP when entering uncooperative code");
+    }
+  }
+}
+
+void Thread::enterUncooperativeCode(void* SP) {
+  if (isMvmThread()) {
+    if (!inRV) {
+      assert(!lastSP && "SP already set when entering uncooperative code");
+      // The cas is not necessary, but it does a memory barrier.
+      __sync_bool_compare_and_swap(&lastSP, 0, SP);
+      if (doYield) joinRVBeforeEnter();
+      assert(lastSP && "No last SP when entering uncooperative code");
+    }
+  }
+}
+
+void Thread::leaveUncooperativeCode() {
+  if (isMvmThread()) {
+    if (!inRV) {
+      assert(lastSP && "No last SP when leaving uncooperative code");
+      void* savedSP = lastSP;
+      // The cas is not necessary, but it does a memory barrier.
+      __sync_bool_compare_and_swap(&lastSP, lastSP, 0);
+      // A rendezvous has just been initiated, join it.
+      if (doYield) joinRVAfterLeave(savedSP);
+      assert(!lastSP && "SP has a value after leaving uncooperative code");
+    }
+  }
+}
+
+void* Thread::waitOnSP() {
+  // First see if we can get lastSP directly.
+  void* sp = lastSP;
+  if (sp) return sp;
+  
+  // Then loop a fixed number of iterations to get lastSP.
+  for (uint32 count = 0; count < 1000; ++count) {
+    sp = lastSP;
+    if (sp) return sp;
+  }
+  
+  // Finally, yield until lastSP is not set.
+  while ((sp = lastSP) == NULL) mvm::Thread::yield();
+
+  assert(sp != NULL && "Still no sp");
+  return sp;
+}

Modified: vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp (original)
+++ vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp Wed Nov 10 14:00:39 2010
@@ -85,7 +85,7 @@
 }
 
 void MvmJITMethodInfo::print(void* ip, void* addr) {
-  fprintf(stderr, "; %p in %s LLVM method\n", ip,
+  fprintf(stderr, "; %p (%p) in %s LLVM method\n", ip, addr,
       ((llvm::Function*)MetaInfo)->getName().data());
 }
 
@@ -200,7 +200,8 @@
     "ILorg_vmmagic_unboxed_ObjectReference_2";
   if (dlsym(SELF_HANDLE, MMTkSymbol)) {
     // If we have found MMTk, read the gcmalloc function.
-    mvm::mmtk_runtime::makeLLVMFunction(module);
+    // TODO: re-enable this.
+    //mvm::mmtk_runtime::makeLLVMFunction(module);
   }
 #endif
   mvm::llvm_runtime::makeLLVMModuleContents(module);

Modified: vmkit/branches/precise/lib/Mvm/Compiler/VmkitGC.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/Mvm/Compiler/VmkitGC.cpp?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/lib/Mvm/Compiler/VmkitGC.cpp (original)
+++ vmkit/branches/precise/lib/Mvm/Compiler/VmkitGC.cpp Wed Nov 10 14:00:39 2010
@@ -32,5 +32,4 @@
 
 VmkitGC::VmkitGC() {
   NeededSafePoints = 1 << GC::PostCall;
-  mvm::MvmModule::TheGCStrategy = this;
 }

Modified: vmkit/branches/precise/lib/Mvm/MMTk/MutatorThread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/Mvm/MMTk/MutatorThread.h?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/lib/Mvm/MMTk/MutatorThread.h (original)
+++ vmkit/branches/precise/lib/Mvm/MMTk/MutatorThread.h Wed Nov 10 14:00:39 2010
@@ -21,7 +21,7 @@
   MutatorThread() : mvm::Thread() {
     MutatorContext = 0;
   }
-  mvm::BumpPtrAllocator Allocator;
+  mvm::ThreadAllocator Allocator;
   uintptr_t MutatorContext;
   
   /// realRoutine - The function to invoke when the thread starts.

Modified: vmkit/branches/precise/mmtk/config/copyms/MMTkInline.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/mmtk/config/copyms/MMTkInline.inc?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/mmtk/config/copyms/MMTkInline.inc (original)
+++ vmkit/branches/precise/mmtk/config/copyms/MMTkInline.inc Wed Nov 10 14:00:39 2010
@@ -62,12 +62,12 @@
 std::vector<const Type*>StructTy_struct_llvm__BumpPtrAllocator_fields;
 StructTy_struct_llvm__BumpPtrAllocator_fields.push_back(IntegerType::get(mod->getContext(), 32));
 StructTy_struct_llvm__BumpPtrAllocator_fields.push_back(IntegerType::get(mod->getContext(), 32));
-std::vector<const Type*>StructTy_struct_gcRoot_fields;
-StructTy_struct_gcRoot_fields.push_back(PointerTy_5);
-StructType* StructTy_struct_gcRoot = StructType::get(mod->getContext(), StructTy_struct_gcRoot_fields, /*isPacked=*/false);
-mod->addTypeName("struct.gcRoot", StructTy_struct_gcRoot);
+std::vector<const Type*>StructTy_struct_llvm__SlabAllocator_fields;
+StructTy_struct_llvm__SlabAllocator_fields.push_back(PointerTy_5);
+StructType* StructTy_struct_llvm__SlabAllocator = StructType::get(mod->getContext(), StructTy_struct_llvm__SlabAllocator_fields, /*isPacked=*/false);
+mod->addTypeName("struct.llvm::SlabAllocator", StructTy_struct_llvm__SlabAllocator);
 
-PointerType* PointerTy_11 = PointerType::get(StructTy_struct_gcRoot, 0);
+PointerType* PointerTy_11 = PointerType::get(StructTy_struct_llvm__SlabAllocator, 0);
 
 StructTy_struct_llvm__BumpPtrAllocator_fields.push_back(PointerTy_11);
 std::vector<const Type*>StructTy_struct_llvm__MemSlab_fields;
@@ -102,60 +102,9 @@
 StructTy_struct_mvm__VirtualMachine_fields.push_back(PointerTy_13);
 StructTy_struct_mvm__VirtualMachine_fields.push_back(IntegerType::get(mod->getContext(), 32));
 StructTy_struct_mvm__VirtualMachine_fields.push_back(StructTy_struct_mvm__SpinLock);
-std::vector<const Type*>StructTy_struct_mvm__ReferenceQueue_fields;
-std::vector<const Type*>StructTy_struct_gc_fields;
-StructTy_struct_gc_fields.push_back(StructTy_struct_gcRoot);
-StructType* StructTy_struct_gc = StructType::get(mod->getContext(), StructTy_struct_gc_fields, /*isPacked=*/false);
-mod->addTypeName("struct.gc", StructTy_struct_gc);
-
-PointerType* PointerTy_15 = PointerType::get(StructTy_struct_gc, 0);
-
-PointerType* PointerTy_14 = PointerType::get(PointerTy_15, 0);
-
-StructTy_struct_mvm__ReferenceQueue_fields.push_back(PointerTy_14);
-StructTy_struct_mvm__ReferenceQueue_fields.push_back(IntegerType::get(mod->getContext(), 32));
-StructTy_struct_mvm__ReferenceQueue_fields.push_back(IntegerType::get(mod->getContext(), 32));
-StructTy_struct_mvm__ReferenceQueue_fields.push_back(StructTy_struct_mvm__SpinLock);
-StructTy_struct_mvm__ReferenceQueue_fields.push_back(IntegerType::get(mod->getContext(), 8));
-StructType* StructTy_struct_mvm__ReferenceQueue = StructType::get(mod->getContext(), StructTy_struct_mvm__ReferenceQueue_fields, /*isPacked=*/false);
-mod->addTypeName("struct.mvm::ReferenceQueue", StructTy_struct_mvm__ReferenceQueue);
-
-StructTy_struct_mvm__VirtualMachine_fields.push_back(StructTy_struct_mvm__ReferenceQueue);
-StructTy_struct_mvm__VirtualMachine_fields.push_back(StructTy_struct_mvm__ReferenceQueue);
-StructTy_struct_mvm__VirtualMachine_fields.push_back(StructTy_struct_mvm__ReferenceQueue);
-StructTy_struct_mvm__VirtualMachine_fields.push_back(StructTy_struct_mvm__SpinLock);
-StructTy_struct_mvm__VirtualMachine_fields.push_back(PointerTy_14);
-StructTy_struct_mvm__VirtualMachine_fields.push_back(IntegerType::get(mod->getContext(), 32));
-StructTy_struct_mvm__VirtualMachine_fields.push_back(IntegerType::get(mod->getContext(), 32));
-StructTy_struct_mvm__VirtualMachine_fields.push_back(PointerTy_14);
-StructTy_struct_mvm__VirtualMachine_fields.push_back(IntegerType::get(mod->getContext(), 32));
-StructTy_struct_mvm__VirtualMachine_fields.push_back(IntegerType::get(mod->getContext(), 32));
-std::vector<const Type*>StructTy_struct_mvm__Cond_fields;
-std::vector<const Type*>StructTy_union_pthread_cond_t_fields;
-std::vector<const Type*>StructTy_struct__2__13_fields;
-StructTy_struct__2__13_fields.push_back(IntegerType::get(mod->getContext(), 32));
-StructTy_struct__2__13_fields.push_back(IntegerType::get(mod->getContext(), 32));
-StructTy_struct__2__13_fields.push_back(IntegerType::get(mod->getContext(), 64));
-StructTy_struct__2__13_fields.push_back(IntegerType::get(mod->getContext(), 64));
-StructTy_struct__2__13_fields.push_back(IntegerType::get(mod->getContext(), 64));
-StructTy_struct__2__13_fields.push_back(PointerTy_0);
-StructTy_struct__2__13_fields.push_back(IntegerType::get(mod->getContext(), 32));
-StructTy_struct__2__13_fields.push_back(IntegerType::get(mod->getContext(), 32));
-StructType* StructTy_struct__2__13 = StructType::get(mod->getContext(), StructTy_struct__2__13_fields, /*isPacked=*/false);
-mod->addTypeName("struct..2._13", StructTy_struct__2__13);
-
-StructTy_union_pthread_cond_t_fields.push_back(StructTy_struct__2__13);
-ArrayType* ArrayTy_16 = ArrayType::get(IntegerType::get(mod->getContext(), 32), 1);
-
-StructTy_union_pthread_cond_t_fields.push_back(ArrayTy_16);
-StructType* StructTy_union_pthread_cond_t = StructType::get(mod->getContext(), StructTy_union_pthread_cond_t_fields, /*isPacked=*/false);
-mod->addTypeName("union.pthread_cond_t", StructTy_union_pthread_cond_t);
-
-StructTy_struct_mvm__Cond_fields.push_back(StructTy_union_pthread_cond_t);
-StructType* StructTy_struct_mvm__Cond = StructType::get(mod->getContext(), StructTy_struct_mvm__Cond_fields, /*isPacked=*/false);
-mod->addTypeName("struct.mvm::Cond", StructTy_struct_mvm__Cond);
-
-StructTy_struct_mvm__VirtualMachine_fields.push_back(StructTy_struct_mvm__Cond);
+std::vector<const Type*>StructTy_struct_mvm__CooperativeCollectionRV_fields;
+std::vector<const Type*>StructTy_struct_mvm__CollectionRV_fields;
+StructTy_struct_mvm__CollectionRV_fields.push_back(PointerTy_5);
 std::vector<const Type*>StructTy_struct_mvm__LockNormal_fields;
 std::vector<const Type*>StructTy_struct_mvm__Lock_fields;
 StructTy_struct_mvm__Lock_fields.push_back(PointerTy_5);
@@ -183,26 +132,43 @@
 StructType* StructTy_struct_mvm__LockNormal = StructType::get(mod->getContext(), StructTy_struct_mvm__LockNormal_fields, /*isPacked=*/false);
 mod->addTypeName("struct.mvm::LockNormal", StructTy_struct_mvm__LockNormal);
 
-StructTy_struct_mvm__VirtualMachine_fields.push_back(StructTy_struct_mvm__LockNormal);
-StructTy_struct_mvm__VirtualMachine_fields.push_back(PointerTy_14);
-StructTy_struct_mvm__VirtualMachine_fields.push_back(IntegerType::get(mod->getContext(), 32));
-StructTy_struct_mvm__VirtualMachine_fields.push_back(IntegerType::get(mod->getContext(), 32));
-StructTy_struct_mvm__VirtualMachine_fields.push_back(StructTy_struct_mvm__LockNormal);
-StructTy_struct_mvm__VirtualMachine_fields.push_back(StructTy_struct_mvm__Cond);
-StructTy_struct_mvm__VirtualMachine_fields.push_back(StructTy_struct_mvm__SpinLock);
-StructTy_struct_mvm__VirtualMachine_fields.push_back(PointerTy_11);
-std::vector<const Type*>StructTy_struct_mvm__CollectionRV_fields;
 StructTy_struct_mvm__CollectionRV_fields.push_back(StructTy_struct_mvm__LockNormal);
+std::vector<const Type*>StructTy_struct_mvm__Cond_fields;
+std::vector<const Type*>StructTy_union_pthread_cond_t_fields;
+std::vector<const Type*>StructTy_struct__2__13_fields;
+StructTy_struct__2__13_fields.push_back(IntegerType::get(mod->getContext(), 32));
+StructTy_struct__2__13_fields.push_back(IntegerType::get(mod->getContext(), 32));
+StructTy_struct__2__13_fields.push_back(IntegerType::get(mod->getContext(), 64));
+StructTy_struct__2__13_fields.push_back(IntegerType::get(mod->getContext(), 64));
+StructTy_struct__2__13_fields.push_back(IntegerType::get(mod->getContext(), 64));
+StructTy_struct__2__13_fields.push_back(PointerTy_0);
+StructTy_struct__2__13_fields.push_back(IntegerType::get(mod->getContext(), 32));
+StructTy_struct__2__13_fields.push_back(IntegerType::get(mod->getContext(), 32));
+StructType* StructTy_struct__2__13 = StructType::get(mod->getContext(), StructTy_struct__2__13_fields, /*isPacked=*/false);
+mod->addTypeName("struct..2._13", StructTy_struct__2__13);
+
+StructTy_union_pthread_cond_t_fields.push_back(StructTy_struct__2__13);
+ArrayType* ArrayTy_14 = ArrayType::get(IntegerType::get(mod->getContext(), 32), 1);
+
+StructTy_union_pthread_cond_t_fields.push_back(ArrayTy_14);
+StructType* StructTy_union_pthread_cond_t = StructType::get(mod->getContext(), StructTy_union_pthread_cond_t_fields, /*isPacked=*/false);
+mod->addTypeName("union.pthread_cond_t", StructTy_union_pthread_cond_t);
+
+StructTy_struct_mvm__Cond_fields.push_back(StructTy_union_pthread_cond_t);
+StructType* StructTy_struct_mvm__Cond = StructType::get(mod->getContext(), StructTy_struct_mvm__Cond_fields, /*isPacked=*/false);
+mod->addTypeName("struct.mvm::Cond", StructTy_struct_mvm__Cond);
+
 StructTy_struct_mvm__CollectionRV_fields.push_back(StructTy_struct_mvm__Cond);
 StructTy_struct_mvm__CollectionRV_fields.push_back(StructTy_struct_mvm__Cond);
 StructTy_struct_mvm__CollectionRV_fields.push_back(IntegerType::get(mod->getContext(), 32));
-StructTy_struct_mvm__CollectionRV_fields.push_back(IntegerType::get(mod->getContext(), 8));
-StructTy_struct_mvm__CollectionRV_fields.push_back(IntegerType::get(mod->getContext(), 32));
 StructType* StructTy_struct_mvm__CollectionRV = StructType::get(mod->getContext(), StructTy_struct_mvm__CollectionRV_fields, /*isPacked=*/false);
 mod->addTypeName("struct.mvm::CollectionRV", StructTy_struct_mvm__CollectionRV);
 
-StructTy_struct_mvm__VirtualMachine_fields.push_back(StructTy_struct_mvm__CollectionRV);
-std::vector<const Type*>StructTy_struct_mvm__StartEndFunctionMap_fields;
+StructTy_struct_mvm__CooperativeCollectionRV_fields.push_back(StructTy_struct_mvm__CollectionRV);
+StructType* StructTy_struct_mvm__CooperativeCollectionRV = StructType::get(mod->getContext(), StructTy_struct_mvm__CooperativeCollectionRV_fields, /*isPacked=*/false);
+mod->addTypeName("struct.mvm::CooperativeCollectionRV", StructTy_struct_mvm__CooperativeCollectionRV);
+
+StructTy_struct_mvm__VirtualMachine_fields.push_back(StructTy_struct_mvm__CooperativeCollectionRV);
 std::vector<const Type*>StructTy_struct_mvm__FunctionMap_fields;
 std::vector<const Type*>StructTy_struct_std__map_const_char_j3__ClassPrimitive__std__less_const_char__std__allocator_std__pair_const_char__j3__ClassPrimitive_______fields;
 std::vector<const Type*>StructTy_struct_std___Rb_tree_const_char_std__pair_const_char__j3__ClassPrimitive___std___Select1st_std__pair_const_char__j3__ClassPrimitive_____std__less_const_char__std__allocator_std__pair_const_char__j3__ClassPrimitive_______fields;
@@ -216,11 +182,11 @@
 std::vector<const Type*>StructTy_struct_std___Rb_tree_node_base_fields;
 StructTy_struct_std___Rb_tree_node_base_fields.push_back(IntegerType::get(mod->getContext(), 32));
 PATypeHolder StructTy_struct_std___Rb_tree_node_base_fwd = OpaqueType::get(mod->getContext());
-PointerType* PointerTy_17 = PointerType::get(StructTy_struct_std___Rb_tree_node_base_fwd, 0);
+PointerType* PointerTy_15 = PointerType::get(StructTy_struct_std___Rb_tree_node_base_fwd, 0);
 
-StructTy_struct_std___Rb_tree_node_base_fields.push_back(PointerTy_17);
-StructTy_struct_std___Rb_tree_node_base_fields.push_back(PointerTy_17);
-StructTy_struct_std___Rb_tree_node_base_fields.push_back(PointerTy_17);
+StructTy_struct_std___Rb_tree_node_base_fields.push_back(PointerTy_15);
+StructTy_struct_std___Rb_tree_node_base_fields.push_back(PointerTy_15);
+StructTy_struct_std___Rb_tree_node_base_fields.push_back(PointerTy_15);
 StructType* StructTy_struct_std___Rb_tree_node_base = StructType::get(mod->getContext(), StructTy_struct_std___Rb_tree_node_base_fields, /*isPacked=*/false);
 mod->addTypeName("struct.std::_Rb_tree_node_base", StructTy_struct_std___Rb_tree_node_base);
 cast<OpaqueType>(StructTy_struct_std___Rb_tree_node_base_fwd.get())->refineAbstractTypeTo(StructTy_struct_std___Rb_tree_node_base);
@@ -245,12 +211,7 @@
 StructType* StructTy_struct_mvm__FunctionMap = StructType::get(mod->getContext(), StructTy_struct_mvm__FunctionMap_fields, /*isPacked=*/false);
 mod->addTypeName("struct.mvm::FunctionMap", StructTy_struct_mvm__FunctionMap);
 
-StructTy_struct_mvm__StartEndFunctionMap_fields.push_back(StructTy_struct_mvm__FunctionMap);
-StructType* StructTy_struct_mvm__StartEndFunctionMap = StructType::get(mod->getContext(), StructTy_struct_mvm__StartEndFunctionMap_fields, /*isPacked=*/false);
-mod->addTypeName("struct.mvm::StartEndFunctionMap", StructTy_struct_mvm__StartEndFunctionMap);
-
-StructTy_struct_mvm__VirtualMachine_fields.push_back(StructTy_struct_mvm__StartEndFunctionMap);
-StructTy_struct_mvm__VirtualMachine_fields.push_back(StructTy_struct_mvm__StartEndFunctionMap);
+StructTy_struct_mvm__VirtualMachine_fields.push_back(StructTy_struct_mvm__FunctionMap);
 StructType* StructTy_struct_mvm__VirtualMachine = StructType::get(mod->getContext(), StructTy_struct_mvm__VirtualMachine_fields, /*isPacked=*/false);
 mod->addTypeName("struct.mvm::VirtualMachine", StructTy_struct_mvm__VirtualMachine);
 
@@ -263,41 +224,41 @@
 StructTy_struct_mvm__Thread_fields.push_back(IntegerType::get(mod->getContext(), 8));
 StructTy_struct_mvm__Thread_fields.push_back(PointerTy_0);
 StructTy_struct_mvm__Thread_fields.push_back(PointerTy_0);
-std::vector<const Type*>FuncTy_19_args;
-FuncTy_19_args.push_back(PointerTy_13);
-FunctionType* FuncTy_19 = FunctionType::get(
+std::vector<const Type*>FuncTy_17_args;
+FuncTy_17_args.push_back(PointerTy_13);
+FunctionType* FuncTy_17 = FunctionType::get(
  /*Result=*/Type::getVoidTy(mod->getContext()),
- /*Params=*/FuncTy_19_args,
+ /*Params=*/FuncTy_17_args,
  /*isVarArg=*/false);
 
-PointerType* PointerTy_18 = PointerType::get(FuncTy_19, 0);
+PointerType* PointerTy_16 = PointerType::get(FuncTy_17, 0);
 
-StructTy_struct_mvm__Thread_fields.push_back(PointerTy_18);
+StructTy_struct_mvm__Thread_fields.push_back(PointerTy_16);
 std::vector<const Type*>StructTy_struct_mvm__KnownFrame_fields;
-PATypeHolder PointerTy_20_fwd = OpaqueType::get(mod->getContext());
-StructTy_struct_mvm__KnownFrame_fields.push_back(PointerTy_20_fwd);
+PATypeHolder PointerTy_18_fwd = OpaqueType::get(mod->getContext());
+StructTy_struct_mvm__KnownFrame_fields.push_back(PointerTy_18_fwd);
 StructTy_struct_mvm__KnownFrame_fields.push_back(PointerTy_0);
 StructType* StructTy_struct_mvm__KnownFrame = StructType::get(mod->getContext(), StructTy_struct_mvm__KnownFrame_fields, /*isPacked=*/false);
 mod->addTypeName("struct.mvm::KnownFrame", StructTy_struct_mvm__KnownFrame);
 
-PointerType* PointerTy_20 = PointerType::get(StructTy_struct_mvm__KnownFrame, 0);
-cast<OpaqueType>(PointerTy_20_fwd.get())->refineAbstractTypeTo(PointerTy_20);
-PointerTy_20 = cast<PointerType>(PointerTy_20_fwd.get());
+PointerType* PointerTy_18 = PointerType::get(StructTy_struct_mvm__KnownFrame, 0);
+cast<OpaqueType>(PointerTy_18_fwd.get())->refineAbstractTypeTo(PointerTy_18);
+PointerTy_18 = cast<PointerType>(PointerTy_18_fwd.get());
 
 
-StructTy_struct_mvm__Thread_fields.push_back(PointerTy_20);
+StructTy_struct_mvm__Thread_fields.push_back(PointerTy_18);
 std::vector<const Type*>StructTy_struct_mvm__ExceptionBuffer_fields;
-PATypeHolder PointerTy_21_fwd = OpaqueType::get(mod->getContext());
-StructTy_struct_mvm__ExceptionBuffer_fields.push_back(PointerTy_21_fwd);
+PATypeHolder PointerTy_19_fwd = OpaqueType::get(mod->getContext());
+StructTy_struct_mvm__ExceptionBuffer_fields.push_back(PointerTy_19_fwd);
 std::vector<const Type*>StructTy_struct___jmp_buf_tag_fields;
-ArrayType* ArrayTy_23 = ArrayType::get(IntegerType::get(mod->getContext(), 32), 6);
+ArrayType* ArrayTy_21 = ArrayType::get(IntegerType::get(mod->getContext(), 32), 6);
 
-StructTy_struct___jmp_buf_tag_fields.push_back(ArrayTy_23);
+StructTy_struct___jmp_buf_tag_fields.push_back(ArrayTy_21);
 StructTy_struct___jmp_buf_tag_fields.push_back(IntegerType::get(mod->getContext(), 32));
 std::vector<const Type*>StructTy_struct___sigset_t_fields;
-ArrayType* ArrayTy_24 = ArrayType::get(IntegerType::get(mod->getContext(), 32), 32);
+ArrayType* ArrayTy_22 = ArrayType::get(IntegerType::get(mod->getContext(), 32), 32);
 
-StructTy_struct___sigset_t_fields.push_back(ArrayTy_24);
+StructTy_struct___sigset_t_fields.push_back(ArrayTy_22);
 StructType* StructTy_struct___sigset_t = StructType::get(mod->getContext(), StructTy_struct___sigset_t_fields, /*isPacked=*/false);
 mod->addTypeName("struct.__sigset_t", StructTy_struct___sigset_t);
 
@@ -305,18 +266,18 @@
 StructType* StructTy_struct___jmp_buf_tag = StructType::get(mod->getContext(), StructTy_struct___jmp_buf_tag_fields, /*isPacked=*/false);
 mod->addTypeName("struct.__jmp_buf_tag", StructTy_struct___jmp_buf_tag);
 
-ArrayType* ArrayTy_22 = ArrayType::get(StructTy_struct___jmp_buf_tag, 1);
+ArrayType* ArrayTy_20 = ArrayType::get(StructTy_struct___jmp_buf_tag, 1);
 
-StructTy_struct_mvm__ExceptionBuffer_fields.push_back(ArrayTy_22);
+StructTy_struct_mvm__ExceptionBuffer_fields.push_back(ArrayTy_20);
 StructType* StructTy_struct_mvm__ExceptionBuffer = StructType::get(mod->getContext(), StructTy_struct_mvm__ExceptionBuffer_fields, /*isPacked=*/false);
 mod->addTypeName("struct.mvm::ExceptionBuffer", StructTy_struct_mvm__ExceptionBuffer);
 
-PointerType* PointerTy_21 = PointerType::get(StructTy_struct_mvm__ExceptionBuffer, 0);
-cast<OpaqueType>(PointerTy_21_fwd.get())->refineAbstractTypeTo(PointerTy_21);
-PointerTy_21 = cast<PointerType>(PointerTy_21_fwd.get());
+PointerType* PointerTy_19 = PointerType::get(StructTy_struct_mvm__ExceptionBuffer, 0);
+cast<OpaqueType>(PointerTy_19_fwd.get())->refineAbstractTypeTo(PointerTy_19);
+PointerTy_19 = cast<PointerType>(PointerTy_19_fwd.get());
 
 
-StructTy_struct_mvm__Thread_fields.push_back(PointerTy_21);
+StructTy_struct_mvm__Thread_fields.push_back(PointerTy_19);
 StructType* StructTy_struct_mvm__Thread = StructType::get(mod->getContext(), StructTy_struct_mvm__Thread_fields, /*isPacked=*/false);
 mod->addTypeName("struct.mvm::Thread", StructTy_struct_mvm__Thread);
 cast<OpaqueType>(StructTy_struct_mvm__Thread_fwd.get())->refineAbstractTypeTo(StructTy_struct_mvm__Thread);
@@ -324,55 +285,150 @@
 
 
 StructTy_struct_mvm__MutatorThread_fields.push_back(StructTy_struct_mvm__Thread);
-StructTy_struct_mvm__MutatorThread_fields.push_back(StructTy_struct_mvm__BumpPtrAllocator);
+std::vector<const Type*>StructTy_struct_mvm__ThreadAllocator_fields;
+StructTy_struct_mvm__ThreadAllocator_fields.push_back(StructTy_struct_llvm__BumpPtrAllocator);
+StructType* StructTy_struct_mvm__ThreadAllocator = StructType::get(mod->getContext(), StructTy_struct_mvm__ThreadAllocator_fields, /*isPacked=*/false);
+mod->addTypeName("struct.mvm::ThreadAllocator", StructTy_struct_mvm__ThreadAllocator);
+
+StructTy_struct_mvm__MutatorThread_fields.push_back(StructTy_struct_mvm__ThreadAllocator);
 StructTy_struct_mvm__MutatorThread_fields.push_back(IntegerType::get(mod->getContext(), 32));
-StructTy_struct_mvm__MutatorThread_fields.push_back(PointerTy_18);
+StructTy_struct_mvm__MutatorThread_fields.push_back(PointerTy_16);
 StructType* StructTy_struct_mvm__MutatorThread = StructType::get(mod->getContext(), StructTy_struct_mvm__MutatorThread_fields, /*isPacked=*/false);
 mod->addTypeName("struct.mvm::MutatorThread", StructTy_struct_mvm__MutatorThread);
 
 PointerType* PointerTy_4 = PointerType::get(StructTy_struct_mvm__MutatorThread, 0);
 
-PointerType* PointerTy_25 = PointerType::get(IntegerType::get(mod->getContext(), 32), 0);
+PointerType* PointerTy_23 = PointerType::get(IntegerType::get(mod->getContext(), 32), 0);
 
 std::vector<const Type*>StructTy_struct_j3__JavaObject_fields;
+std::vector<const Type*>StructTy_struct_gc_fields;
+std::vector<const Type*>StructTy_struct_gcRoot_fields;
+StructTy_struct_gcRoot_fields.push_back(PointerTy_5);
+StructTy_struct_gcRoot_fields.push_back(IntegerType::get(mod->getContext(), 32));
+StructType* StructTy_struct_gcRoot = StructType::get(mod->getContext(), StructTy_struct_gcRoot_fields, /*isPacked=*/false);
+mod->addTypeName("struct.gcRoot", StructTy_struct_gcRoot);
+
+StructTy_struct_gc_fields.push_back(StructTy_struct_gcRoot);
+StructType* StructTy_struct_gc = StructType::get(mod->getContext(), StructTy_struct_gc_fields, /*isPacked=*/false);
+mod->addTypeName("struct.gc", StructTy_struct_gc);
+
 StructTy_struct_j3__JavaObject_fields.push_back(StructTy_struct_gc);
-StructTy_struct_j3__JavaObject_fields.push_back(StructTy_struct_mvm__SpinLock);
 StructType* StructTy_struct_j3__JavaObject = StructType::get(mod->getContext(), StructTy_struct_j3__JavaObject_fields, /*isPacked=*/false);
 mod->addTypeName("struct.j3::JavaObject", StructTy_struct_j3__JavaObject);
 
-PointerType* PointerTy_26 = PointerType::get(StructTy_struct_j3__JavaObject, 0);
+PointerType* PointerTy_24 = PointerType::get(StructTy_struct_j3__JavaObject, 0);
 
 std::vector<const Type*>StructTy_JavaObject_fields;
 ArrayType* ArrayTy_VT = ArrayType::get(PointerTy_6, 0);
 mod->addTypeName("VT", ArrayTy_VT);
 
-PointerType* PointerTy_29 = PointerType::get(ArrayTy_VT, 0);
+PointerType* PointerTy_27 = PointerType::get(ArrayTy_VT, 0);
 
-StructTy_JavaObject_fields.push_back(PointerTy_29);
+StructTy_JavaObject_fields.push_back(PointerTy_27);
 StructTy_JavaObject_fields.push_back(PointerTy_0);
 StructType* StructTy_JavaObject = StructType::get(mod->getContext(), StructTy_JavaObject_fields, /*isPacked=*/false);
 mod->addTypeName("JavaObject", StructTy_JavaObject);
 
-PointerType* PointerTy_28 = PointerType::get(StructTy_JavaObject, 0);
+PointerType* PointerTy_26 = PointerType::get(StructTy_JavaObject, 0);
+
+PointerType* PointerTy_25 = PointerType::get(PointerTy_26, 0);
+
+std::vector<const Type*>StructTy_struct__IO_FILE_fields;
+StructTy_struct__IO_FILE_fields.push_back(IntegerType::get(mod->getContext(), 32));
+StructTy_struct__IO_FILE_fields.push_back(PointerTy_0);
+StructTy_struct__IO_FILE_fields.push_back(PointerTy_0);
+StructTy_struct__IO_FILE_fields.push_back(PointerTy_0);
+StructTy_struct__IO_FILE_fields.push_back(PointerTy_0);
+StructTy_struct__IO_FILE_fields.push_back(PointerTy_0);
+StructTy_struct__IO_FILE_fields.push_back(PointerTy_0);
+StructTy_struct__IO_FILE_fields.push_back(PointerTy_0);
+StructTy_struct__IO_FILE_fields.push_back(PointerTy_0);
+StructTy_struct__IO_FILE_fields.push_back(PointerTy_0);
+StructTy_struct__IO_FILE_fields.push_back(PointerTy_0);
+StructTy_struct__IO_FILE_fields.push_back(PointerTy_0);
+std::vector<const Type*>StructTy_struct__IO_marker_fields;
+PATypeHolder PointerTy_29_fwd = OpaqueType::get(mod->getContext());
+StructTy_struct__IO_marker_fields.push_back(PointerTy_29_fwd);
+PATypeHolder PointerTy_28_fwd = OpaqueType::get(mod->getContext());
+StructTy_struct__IO_marker_fields.push_back(PointerTy_28_fwd);
+StructTy_struct__IO_marker_fields.push_back(IntegerType::get(mod->getContext(), 32));
+StructType* StructTy_struct__IO_marker = StructType::get(mod->getContext(), StructTy_struct__IO_marker_fields, /*isPacked=*/false);
+mod->addTypeName("struct._IO_marker", StructTy_struct__IO_marker);
+
+PointerType* PointerTy_29 = PointerType::get(StructTy_struct__IO_marker, 0);
+cast<OpaqueType>(PointerTy_29_fwd.get())->refineAbstractTypeTo(PointerTy_29);
+PointerTy_29 = cast<PointerType>(PointerTy_29_fwd.get());
+
+
+StructTy_struct__IO_FILE_fields.push_back(PointerTy_29);
+StructTy_struct__IO_FILE_fields.push_back(PointerTy_28_fwd);
+StructTy_struct__IO_FILE_fields.push_back(IntegerType::get(mod->getContext(), 32));
+StructTy_struct__IO_FILE_fields.push_back(IntegerType::get(mod->getContext(), 32));
+StructTy_struct__IO_FILE_fields.push_back(IntegerType::get(mod->getContext(), 32));
+StructTy_struct__IO_FILE_fields.push_back(IntegerType::get(mod->getContext(), 16));
+StructTy_struct__IO_FILE_fields.push_back(IntegerType::get(mod->getContext(), 8));
+ArrayType* ArrayTy_30 = ArrayType::get(IntegerType::get(mod->getContext(), 8), 1);
+
+StructTy_struct__IO_FILE_fields.push_back(ArrayTy_30);
+StructTy_struct__IO_FILE_fields.push_back(PointerTy_0);
+StructTy_struct__IO_FILE_fields.push_back(IntegerType::get(mod->getContext(), 64));
+StructTy_struct__IO_FILE_fields.push_back(PointerTy_0);
+StructTy_struct__IO_FILE_fields.push_back(PointerTy_0);
+StructTy_struct__IO_FILE_fields.push_back(PointerTy_0);
+StructTy_struct__IO_FILE_fields.push_back(PointerTy_0);
+StructTy_struct__IO_FILE_fields.push_back(IntegerType::get(mod->getContext(), 32));
+StructTy_struct__IO_FILE_fields.push_back(IntegerType::get(mod->getContext(), 32));
+ArrayType* ArrayTy_31 = ArrayType::get(IntegerType::get(mod->getContext(), 8), 40);
+
+StructTy_struct__IO_FILE_fields.push_back(ArrayTy_31);
+StructType* StructTy_struct__IO_FILE = StructType::get(mod->getContext(), StructTy_struct__IO_FILE_fields, /*isPacked=*/false);
+mod->addTypeName("struct._IO_FILE", StructTy_struct__IO_FILE);
+
+PointerType* PointerTy_28 = PointerType::get(StructTy_struct__IO_FILE, 0);
+cast<OpaqueType>(PointerTy_28_fwd.get())->refineAbstractTypeTo(PointerTy_28);
+PointerTy_28 = cast<PointerType>(PointerTy_28_fwd.get());
+
+
+PointerType* PointerTy_32 = PointerType::get(PointerTy_28, 0);
+
+ArrayType* ArrayTy_34 = ArrayType::get(IntegerType::get(mod->getContext(), 8), 7);
+
+PointerType* PointerTy_33 = PointerType::get(ArrayTy_34, 0);
+
+std::vector<const Type*>FuncTy_36_args;
+FuncTy_36_args.push_back(PointerTy_28);
+FuncTy_36_args.push_back(PointerTy_0);
+FunctionType* FuncTy_36 = FunctionType::get(
+ /*Result=*/IntegerType::get(mod->getContext(), 32),
+ /*Params=*/FuncTy_36_args,
+ /*isVarArg=*/true);
+
+PointerType* PointerTy_35 = PointerType::get(FuncTy_36, 0);
 
-PointerType* PointerTy_27 = PointerType::get(PointerTy_28, 0);
+std::vector<const Type*>FuncTy_38_args;
+FunctionType* FuncTy_38 = FunctionType::get(
+ /*Result=*/Type::getVoidTy(mod->getContext()),
+ /*Params=*/FuncTy_38_args,
+ /*isVarArg=*/false);
+
+PointerType* PointerTy_37 = PointerType::get(FuncTy_38, 0);
 
-PointerType* PointerTy_30 = PointerType::get(PointerTy_0, 0);
+PointerType* PointerTy_39 = PointerType::get(PointerTy_0, 0);
 
-PointerType* PointerTy_31 = PointerType::get(PointerTy_29, 0);
+PointerType* PointerTy_40 = PointerType::get(PointerTy_27, 0);
 
-std::vector<const Type*>FuncTy_33_args;
-FuncTy_33_args.push_back(PointerTy_28);
-FuncTy_33_args.push_back(PointerTy_28);
-FuncTy_33_args.push_back(PointerTy_28);
-FuncTy_33_args.push_back(IntegerType::get(mod->getContext(), 32));
-FuncTy_33_args.push_back(IntegerType::get(mod->getContext(), 32));
-FunctionType* FuncTy_33 = FunctionType::get(
- /*Result=*/PointerTy_28,
- /*Params=*/FuncTy_33_args,
+std::vector<const Type*>FuncTy_42_args;
+FuncTy_42_args.push_back(PointerTy_26);
+FuncTy_42_args.push_back(PointerTy_26);
+FuncTy_42_args.push_back(PointerTy_26);
+FuncTy_42_args.push_back(IntegerType::get(mod->getContext(), 32));
+FuncTy_42_args.push_back(IntegerType::get(mod->getContext(), 32));
+FunctionType* FuncTy_42 = FunctionType::get(
+ /*Result=*/PointerTy_26,
+ /*Params=*/FuncTy_42_args,
  /*isVarArg=*/false);
 
-PointerType* PointerTy_32 = PointerType::get(FuncTy_33, 0);
+PointerType* PointerTy_41 = PointerType::get(FuncTy_42, 0);
 
 
 // Function Declarations
@@ -393,11 +449,56 @@
 }
 func_llvm_frameaddress->setAttributes(func_llvm_frameaddress_PAL);
 
+Function* func__ZN3mvm6Thread14printBacktraceEv = Function::Create(
+ /*Type=*/FuncTy_17,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"_ZN3mvm6Thread14printBacktraceEv", mod); // (external, no body)
+func__ZN3mvm6Thread14printBacktraceEv->setCallingConv(CallingConv::C);
+AttrListPtr func__ZN3mvm6Thread14printBacktraceEv_PAL;
+func__ZN3mvm6Thread14printBacktraceEv->setAttributes(func__ZN3mvm6Thread14printBacktraceEv_PAL);
+
+Function* func_fprintf = Function::Create(
+ /*Type=*/FuncTy_36,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"fprintf", mod); // (external, no body)
+func_fprintf->setCallingConv(CallingConv::C);
+AttrListPtr func_fprintf_PAL;
+{
+ SmallVector<AttributeWithIndex, 4> Attrs;
+ AttributeWithIndex PAWI;
+ PAWI.Index = 1U; PAWI.Attrs = 0  | Attribute::NoAlias | Attribute::NoCapture;
+ Attrs.push_back(PAWI);
+ PAWI.Index = 2U; PAWI.Attrs = 0  | Attribute::NoAlias | Attribute::NoCapture;
+ Attrs.push_back(PAWI);
+ PAWI.Index = 4294967295U; PAWI.Attrs = 0  | Attribute::NoUnwind;
+ Attrs.push_back(PAWI);
+ func_fprintf_PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
+ 
+}
+func_fprintf->setAttributes(func_fprintf_PAL);
+
+Function* func_abort = Function::Create(
+ /*Type=*/FuncTy_38,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"abort", mod); // (external, no body)
+func_abort->setCallingConv(CallingConv::C);
+AttrListPtr func_abort_PAL;
+{
+ SmallVector<AttributeWithIndex, 4> Attrs;
+ AttributeWithIndex PAWI;
+ PAWI.Index = 4294967295U; PAWI.Attrs = 0  | Attribute::NoReturn | Attribute::NoUnwind;
+ Attrs.push_back(PAWI);
+ func_abort_PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
+ 
+}
+func_abort->setAttributes(func_abort_PAL);
+
 Function* func_JnJVM_org_mmtk_utility_alloc_BumpPointer_allocSlow__Lorg_vmmagic_unboxed_Address_2Lorg_vmmagic_unboxed_Address_2II = Function::Create(
- /*Type=*/FuncTy_33,
+ /*Type=*/FuncTy_42,
  /*Linkage=*/GlobalValue::ExternalLinkage,
  /*Name=*/"JnJVM_org_mmtk_utility_alloc_BumpPointer_allocSlow__Lorg_vmmagic_unboxed_Address_2Lorg_vmmagic_unboxed_Address_2II", mod); 
 func_JnJVM_org_mmtk_utility_alloc_BumpPointer_allocSlow__Lorg_vmmagic_unboxed_Address_2Lorg_vmmagic_unboxed_Address_2II->setCallingConv(CallingConv::C);
+func_JnJVM_org_mmtk_utility_alloc_BumpPointer_allocSlow__Lorg_vmmagic_unboxed_Address_2Lorg_vmmagic_unboxed_Address_2II->setGC("vmkit");
 AttrListPtr func_JnJVM_org_mmtk_utility_alloc_BumpPointer_allocSlow__Lorg_vmmagic_unboxed_Address_2Lorg_vmmagic_unboxed_Address_2II_PAL;
 {
  SmallVector<AttributeWithIndex, 4> Attrs;
@@ -411,14 +512,46 @@
 
 // Global Variable Declarations
 
+GlobalVariable* gvar_ptr_stderr = new GlobalVariable(/*Module=*/*mod, 
+/*Type=*/PointerTy_28,
+/*isConstant=*/false,
+/*Linkage=*/GlobalValue::ExternalLinkage,
+/*Initializer=*/0, 
+/*Name=*/"stderr");
+
+GlobalVariable* gvar_array__str14 = new GlobalVariable(/*Module=*/*mod, 
+/*Type=*/ArrayTy_34,
+/*isConstant=*/true,
+/*Linkage=*/GlobalValue::PrivateLinkage,
+/*Initializer=*/0, // has initializer, specified below
+/*Name=*/".str14");
+gvar_array__str14->setAlignment(1);
+
+GlobalVariable* gvar_array__str1246 = new GlobalVariable(/*Module=*/*mod, 
+/*Type=*/ArrayTy_34,
+/*isConstant=*/true,
+/*Linkage=*/GlobalValue::PrivateLinkage,
+/*Initializer=*/0, // has initializer, specified below
+/*Name=*/".str1246");
+gvar_array__str1246->setAlignment(1);
+
 // Constant Definitions
-ConstantInt* const_int32_34 = ConstantInt::get(mod->getContext(), APInt(32, StringRef("3"), 10));
-ConstantInt* const_int32_35 = ConstantInt::get(mod->getContext(), APInt(32, StringRef("-4"), 10));
-ConstantInt* const_int32_36 = ConstantInt::get(mod->getContext(), APInt(32, StringRef("0"), 10));
-ConstantInt* const_int32_37 = ConstantInt::get(mod->getContext(), APInt(32, StringRef("2146435072"), 10));
-ConstantInt* const_int32_38 = ConstantInt::get(mod->getContext(), APInt(32, StringRef("2"), 10));
-ConstantInt* const_int32_39 = ConstantInt::get(mod->getContext(), APInt(32, StringRef("5"), 10));
-ConstantInt* const_int32_40 = ConstantInt::get(mod->getContext(), APInt(32, StringRef("1"), 10));
+ConstantInt* const_int32_43 = ConstantInt::get(mod->getContext(), APInt(32, StringRef("0"), 10));
+ConstantInt* const_int32_44 = ConstantInt::get(mod->getContext(), APInt(32, StringRef("2146435072"), 10));
+ConstantInt* const_int32_45 = ConstantInt::get(mod->getContext(), APInt(32, StringRef("2"), 10));
+ConstantInt* const_int32_46 = ConstantInt::get(mod->getContext(), APInt(32, StringRef("5"), 10));
+ConstantInt* const_int32_47 = ConstantInt::get(mod->getContext(), APInt(32, StringRef("1"), 10));
+ConstantInt* const_int32_48 = ConstantInt::get(mod->getContext(), APInt(32, StringRef("3"), 10));
+std::vector<Constant*> const_ptr_49_indices;
+const_ptr_49_indices.push_back(const_int32_43);
+const_ptr_49_indices.push_back(const_int32_43);
+Constant* const_ptr_49 = ConstantExpr::getGetElementPtr(gvar_array__str14, &const_ptr_49_indices[0], const_ptr_49_indices.size());
+std::vector<Constant*> const_ptr_50_indices;
+const_ptr_50_indices.push_back(const_int32_43);
+const_ptr_50_indices.push_back(const_int32_43);
+Constant* const_ptr_50 = ConstantExpr::getGetElementPtr(gvar_array__str1246, &const_ptr_50_indices[0], const_ptr_50_indices.size());
+ConstantInt* const_int32_51 = ConstantInt::get(mod->getContext(), APInt(32, StringRef("41"), 10));
+ConstantInt* const_int32_52 = ConstantInt::get(mod->getContext(), APInt(32, StringRef("-4"), 10));
 
 // Global Variable Definitions
 
@@ -427,6 +560,7 @@
  /*Linkage=*/GlobalValue::ExternalLinkage,
  /*Name=*/"gcmalloc", mod); 
 func_gcmalloc->setCallingConv(CallingConv::C);
+func_gcmalloc->setGC("vmkit");
 AttrListPtr func_gcmalloc_PAL;
 {
  SmallVector<AttributeWithIndex, 4> Attrs;
@@ -443,100 +577,163 @@
 Value* ptr_VT = args++;
 ptr_VT->setName("VT");
 
-BasicBlock* label_entry = BasicBlock::Create(mod->getContext(), "entry",func_gcmalloc,0);
+BasicBlock* label_Java_org_j3_runtime_VM__1assert__Z_exit_i = BasicBlock::Create(mod->getContext(), "Java_org_j3_runtime_VM__1assert__Z.exit.i",func_gcmalloc,0);
+BasicBlock* label_bb_i1_i = BasicBlock::Create(mod->getContext(), "bb.i1.i",func_gcmalloc,0);
+BasicBlock* label_Java_org_j3_runtime_VM__1assert__Z_exit2_i = BasicBlock::Create(mod->getContext(), "Java_org_j3_runtime_VM__1assert__Z.exit2.i",func_gcmalloc,0);
 BasicBlock* label_JnJVM_org_mmtk_utility_alloc_Allocator_fillAlignmentGap__Lorg_vmmagic_unboxed_Address_2Lorg_vmmagic_unboxed_Address_2_exit_i_i_i = BasicBlock::Create(mod->getContext(), "JnJVM_org_mmtk_utility_alloc_Allocator_fillAlignmentGap__Lorg_vmmagic_unboxed_Address_2Lorg_vmmagic_unboxed_Address_2.exit.i.i.i",func_gcmalloc,0);
 BasicBlock* label_false_IFEQ_i_i_i = BasicBlock::Create(mod->getContext(), "false IFEQ.i.i.i",func_gcmalloc,0);
 BasicBlock* label_JnJVM_org_j3_bindings_Bindings_gcmalloc__ILorg_vmmagic_unboxed_ObjectReference_2_exit = BasicBlock::Create(mod->getContext(), "JnJVM_org_j3_bindings_Bindings_gcmalloc__ILorg_vmmagic_unboxed_ObjectReference_2.exit",func_gcmalloc,0);
 
-// Block entry (label_entry)
-BinaryOperator* int32_41 = BinaryOperator::Create(Instruction::Add, int32_sz, const_int32_34, "", label_entry);
-BinaryOperator* int32_42 = BinaryOperator::Create(Instruction::And, int32_41, const_int32_35, "", label_entry);
-CallInst* ptr_43 = CallInst::Create(func_llvm_frameaddress, const_int32_36, "", label_entry);
-ptr_43->setCallingConv(CallingConv::C);
-ptr_43->setTailCall(true);
-AttrListPtr ptr_43_PAL;
+// Block Java_org_j3_runtime_VM__1assert__Z.exit.i (label_Java_org_j3_runtime_VM__1assert__Z_exit_i)
+CallInst* ptr_53 = CallInst::Create(func_llvm_frameaddress, const_int32_43, "", label_Java_org_j3_runtime_VM__1assert__Z_exit_i);
+ptr_53->setCallingConv(CallingConv::C);
+ptr_53->setTailCall(true);
+AttrListPtr ptr_53_PAL;
+{
+ SmallVector<AttributeWithIndex, 4> Attrs;
+ AttributeWithIndex PAWI;
+ PAWI.Index = 4294967295U; PAWI.Attrs = 0  | Attribute::NoUnwind;
+ Attrs.push_back(PAWI);
+ ptr_53_PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
+ 
+}
+ptr_53->setAttributes(ptr_53_PAL);
+
+CastInst* int32_54 = new PtrToIntInst(ptr_53, IntegerType::get(mod->getContext(), 32), "", label_Java_org_j3_runtime_VM__1assert__Z_exit_i);
+BinaryOperator* int32_55 = BinaryOperator::Create(Instruction::And, int32_54, const_int32_44, "", label_Java_org_j3_runtime_VM__1assert__Z_exit_i);
+CastInst* ptr_56 = new IntToPtrInst(int32_55, PointerTy_4, "", label_Java_org_j3_runtime_VM__1assert__Z_exit_i);
+std::vector<Value*> ptr_57_indices;
+ptr_57_indices.push_back(const_int32_43);
+ptr_57_indices.push_back(const_int32_45);
+Instruction* ptr_57 = GetElementPtrInst::Create(ptr_56, ptr_57_indices.begin(), ptr_57_indices.end(), "", label_Java_org_j3_runtime_VM__1assert__Z_exit_i);
+LoadInst* int32_58 = new LoadInst(ptr_57, "", false, label_Java_org_j3_runtime_VM__1assert__Z_exit_i);
+CastInst* ptr_59 = new IntToPtrInst(int32_58, PointerTy_24, "", label_Java_org_j3_runtime_VM__1assert__Z_exit_i);
+GetElementPtrInst* ptr_60 = GetElementPtrInst::Create(ptr_59, const_int32_46, "", label_Java_org_j3_runtime_VM__1assert__Z_exit_i);
+CastInst* ptr_61 = new BitCastInst(ptr_60, PointerTy_25, "", label_Java_org_j3_runtime_VM__1assert__Z_exit_i);
+LoadInst* ptr_62 = new LoadInst(ptr_61, "", false, label_Java_org_j3_runtime_VM__1assert__Z_exit_i);
+GetElementPtrInst* ptr_63 = GetElementPtrInst::Create(ptr_62, const_int32_47, "", label_Java_org_j3_runtime_VM__1assert__Z_exit_i);
+CastInst* ptr_64 = new BitCastInst(ptr_63, PointerTy_25, "", label_Java_org_j3_runtime_VM__1assert__Z_exit_i);
+LoadInst* ptr_65 = new LoadInst(ptr_64, "", false, label_Java_org_j3_runtime_VM__1assert__Z_exit_i);
+CastInst* int32_66 = new PtrToIntInst(ptr_65, IntegerType::get(mod->getContext(), 32), "", label_Java_org_j3_runtime_VM__1assert__Z_exit_i);
+BinaryOperator* int32_67 = BinaryOperator::Create(Instruction::And, int32_66, const_int32_48, "", label_Java_org_j3_runtime_VM__1assert__Z_exit_i);
+ICmpInst* int1_68 = new ICmpInst(*label_Java_org_j3_runtime_VM__1assert__Z_exit_i, ICmpInst::ICMP_EQ, int32_67, const_int32_43, "");
+BranchInst::Create(label_Java_org_j3_runtime_VM__1assert__Z_exit2_i, label_bb_i1_i, int1_68, label_Java_org_j3_runtime_VM__1assert__Z_exit_i);
+
+// Block bb.i1.i (label_bb_i1_i)
+CastInst* ptr_70 = new IntToPtrInst(int32_55, PointerTy_13, "", label_bb_i1_i);
+CallInst* void_71 = CallInst::Create(func__ZN3mvm6Thread14printBacktraceEv, ptr_70, "", label_bb_i1_i);
+void_71->setCallingConv(CallingConv::C);
+void_71->setTailCall(true);
+AttrListPtr void_71_PAL;
+{
+ SmallVector<AttributeWithIndex, 4> Attrs;
+ AttributeWithIndex PAWI;
+ PAWI.Index = 4294967295U; PAWI.Attrs = 0  | Attribute::NoUnwind;
+ Attrs.push_back(PAWI);
+ void_71_PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
+ 
+}
+void_71->setAttributes(void_71_PAL);
+
+LoadInst* ptr_72 = new LoadInst(gvar_ptr_stderr, "", false, label_bb_i1_i);
+std::vector<Value*> int32_73_params;
+int32_73_params.push_back(ptr_72);
+int32_73_params.push_back(const_ptr_49);
+int32_73_params.push_back(const_ptr_50);
+int32_73_params.push_back(const_int32_51);
+CallInst* int32_73 = CallInst::Create(func_fprintf, int32_73_params.begin(), int32_73_params.end(), "", label_bb_i1_i);
+int32_73->setCallingConv(CallingConv::C);
+int32_73->setTailCall(true);
+AttrListPtr int32_73_PAL;
 {
  SmallVector<AttributeWithIndex, 4> Attrs;
  AttributeWithIndex PAWI;
+ PAWI.Index = 1U; PAWI.Attrs = 0  | Attribute::NoAlias;
+ Attrs.push_back(PAWI);
+ PAWI.Index = 2U; PAWI.Attrs = 0  | Attribute::NoAlias;
+ Attrs.push_back(PAWI);
  PAWI.Index = 4294967295U; PAWI.Attrs = 0  | Attribute::NoUnwind;
  Attrs.push_back(PAWI);
- ptr_43_PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
+ int32_73_PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
  
 }
-ptr_43->setAttributes(ptr_43_PAL);
+int32_73->setAttributes(int32_73_PAL);
+
+CallInst* void_74 = CallInst::Create(func_abort, "", label_bb_i1_i);
+void_74->setCallingConv(CallingConv::C);
+void_74->setTailCall(true);
+AttrListPtr void_74_PAL;
+{
+ SmallVector<AttributeWithIndex, 4> Attrs;
+ AttributeWithIndex PAWI;
+ PAWI.Index = 4294967295U; PAWI.Attrs = 0  | Attribute::NoReturn | Attribute::NoUnwind;
+ Attrs.push_back(PAWI);
+ void_74_PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
+ 
+}
+void_74->setAttributes(void_74_PAL);
+
+new UnreachableInst(mod->getContext(), label_bb_i1_i);
 
-CastInst* int32_44 = new PtrToIntInst(ptr_43, IntegerType::get(mod->getContext(), 32), "", label_entry);
-BinaryOperator* int32_45 = BinaryOperator::Create(Instruction::And, int32_44, const_int32_37, "", label_entry);
-CastInst* ptr_46 = new IntToPtrInst(int32_45, PointerTy_4, "", label_entry);
-std::vector<Value*> ptr_47_indices;
-ptr_47_indices.push_back(const_int32_36);
-ptr_47_indices.push_back(const_int32_38);
-Instruction* ptr_47 = GetElementPtrInst::Create(ptr_46, ptr_47_indices.begin(), ptr_47_indices.end(), "", label_entry);
-LoadInst* int32_48 = new LoadInst(ptr_47, "", false, label_entry);
-CastInst* ptr_49 = new IntToPtrInst(int32_48, PointerTy_26, "", label_entry);
-GetElementPtrInst* ptr_50 = GetElementPtrInst::Create(ptr_49, const_int32_39, "", label_entry);
-CastInst* ptr_51 = new BitCastInst(ptr_50, PointerTy_27, "", label_entry);
-LoadInst* ptr_52 = new LoadInst(ptr_51, "", false, label_entry);
-GetElementPtrInst* ptr_53 = GetElementPtrInst::Create(ptr_52, const_int32_40, "", label_entry);
-CastInst* ptr_54 = new BitCastInst(ptr_53, PointerTy_27, "", label_entry);
-LoadInst* ptr_55 = new LoadInst(ptr_54, "", false, label_entry);
-CastInst* int32_56 = new PtrToIntInst(ptr_55, IntegerType::get(mod->getContext(), 32), "", label_entry);
-BinaryOperator* int32_57 = BinaryOperator::Create(Instruction::Add, int32_56, int32_42, "", label_entry);
-CastInst* ptr_58 = new IntToPtrInst(int32_57, PointerTy_28, "", label_entry);
-std::vector<Value*> ptr_59_indices;
-ptr_59_indices.push_back(const_int32_40);
-ptr_59_indices.push_back(const_int32_40);
-Instruction* ptr_59 = GetElementPtrInst::Create(ptr_52, ptr_59_indices.begin(), ptr_59_indices.end(), "", label_entry);
-LoadInst* ptr_60 = new LoadInst(ptr_59, "", false, label_entry);
-CastInst* ptr_61 = new BitCastInst(ptr_60, PointerTy_28, "", label_entry);
-ICmpInst* int1_62 = new ICmpInst(*label_entry, ICmpInst::ICMP_UGT, ptr_58, ptr_61, "");
-BranchInst::Create(label_false_IFEQ_i_i_i, label_JnJVM_org_mmtk_utility_alloc_Allocator_fillAlignmentGap__Lorg_vmmagic_unboxed_Address_2Lorg_vmmagic_unboxed_Address_2_exit_i_i_i, int1_62, label_entry);
+// Block Java_org_j3_runtime_VM__1assert__Z.exit2.i (label_Java_org_j3_runtime_VM__1assert__Z_exit2_i)
+BinaryOperator* int32_76 = BinaryOperator::Create(Instruction::Add, int32_sz, const_int32_48, "", label_Java_org_j3_runtime_VM__1assert__Z_exit2_i);
+BinaryOperator* int32_77 = BinaryOperator::Create(Instruction::And, int32_76, const_int32_52, "", label_Java_org_j3_runtime_VM__1assert__Z_exit2_i);
+BinaryOperator* int32_78 = BinaryOperator::Create(Instruction::Add, int32_66, int32_77, "", label_Java_org_j3_runtime_VM__1assert__Z_exit2_i);
+CastInst* ptr_79 = new IntToPtrInst(int32_78, PointerTy_26, "", label_Java_org_j3_runtime_VM__1assert__Z_exit2_i);
+std::vector<Value*> ptr_80_indices;
+ptr_80_indices.push_back(const_int32_47);
+ptr_80_indices.push_back(const_int32_47);
+Instruction* ptr_80 = GetElementPtrInst::Create(ptr_62, ptr_80_indices.begin(), ptr_80_indices.end(), "", label_Java_org_j3_runtime_VM__1assert__Z_exit2_i);
+LoadInst* ptr_81 = new LoadInst(ptr_80, "", false, label_Java_org_j3_runtime_VM__1assert__Z_exit2_i);
+CastInst* ptr_82 = new BitCastInst(ptr_81, PointerTy_26, "", label_Java_org_j3_runtime_VM__1assert__Z_exit2_i);
+ICmpInst* int1_83 = new ICmpInst(*label_Java_org_j3_runtime_VM__1assert__Z_exit2_i, ICmpInst::ICMP_UGT, ptr_79, ptr_82, "");
+BranchInst::Create(label_false_IFEQ_i_i_i, label_JnJVM_org_mmtk_utility_alloc_Allocator_fillAlignmentGap__Lorg_vmmagic_unboxed_Address_2Lorg_vmmagic_unboxed_Address_2_exit_i_i_i, int1_83, label_Java_org_j3_runtime_VM__1assert__Z_exit2_i);
 
 // Block JnJVM_org_mmtk_utility_alloc_Allocator_fillAlignmentGap__Lorg_vmmagic_unboxed_Address_2Lorg_vmmagic_unboxed_Address_2.exit.i.i.i (label_JnJVM_org_mmtk_utility_alloc_Allocator_fillAlignmentGap__Lorg_vmmagic_unboxed_Address_2Lorg_vmmagic_unboxed_Address_2_exit_i_i_i)
-std::vector<Value*> ptr_64_indices;
-ptr_64_indices.push_back(const_int32_40);
-ptr_64_indices.push_back(const_int32_36);
-Instruction* ptr_64 = GetElementPtrInst::Create(ptr_52, ptr_64_indices.begin(), ptr_64_indices.end(), "", label_JnJVM_org_mmtk_utility_alloc_Allocator_fillAlignmentGap__Lorg_vmmagic_unboxed_Address_2Lorg_vmmagic_unboxed_Address_2_exit_i_i_i);
-CastInst* ptr__c_i_i_i = new IntToPtrInst(int32_57, PointerTy_29, ".c.i.i.i", label_JnJVM_org_mmtk_utility_alloc_Allocator_fillAlignmentGap__Lorg_vmmagic_unboxed_Address_2Lorg_vmmagic_unboxed_Address_2_exit_i_i_i);
- new StoreInst(ptr__c_i_i_i, ptr_64, false, label_JnJVM_org_mmtk_utility_alloc_Allocator_fillAlignmentGap__Lorg_vmmagic_unboxed_Address_2Lorg_vmmagic_unboxed_Address_2_exit_i_i_i);
+std::vector<Value*> ptr_85_indices;
+ptr_85_indices.push_back(const_int32_47);
+ptr_85_indices.push_back(const_int32_43);
+Instruction* ptr_85 = GetElementPtrInst::Create(ptr_62, ptr_85_indices.begin(), ptr_85_indices.end(), "", label_JnJVM_org_mmtk_utility_alloc_Allocator_fillAlignmentGap__Lorg_vmmagic_unboxed_Address_2Lorg_vmmagic_unboxed_Address_2_exit_i_i_i);
+CastInst* ptr__c_i_i_i = new IntToPtrInst(int32_78, PointerTy_27, ".c.i.i.i", label_JnJVM_org_mmtk_utility_alloc_Allocator_fillAlignmentGap__Lorg_vmmagic_unboxed_Address_2Lorg_vmmagic_unboxed_Address_2_exit_i_i_i);
+ new StoreInst(ptr__c_i_i_i, ptr_85, false, label_JnJVM_org_mmtk_utility_alloc_Allocator_fillAlignmentGap__Lorg_vmmagic_unboxed_Address_2Lorg_vmmagic_unboxed_Address_2_exit_i_i_i);
 BranchInst::Create(label_JnJVM_org_j3_bindings_Bindings_gcmalloc__ILorg_vmmagic_unboxed_ObjectReference_2_exit, label_JnJVM_org_mmtk_utility_alloc_Allocator_fillAlignmentGap__Lorg_vmmagic_unboxed_Address_2Lorg_vmmagic_unboxed_Address_2_exit_i_i_i);
 
 // Block false IFEQ.i.i.i (label_false_IFEQ_i_i_i)
-std::vector<Value*> ptr_67_params;
-ptr_67_params.push_back(ptr_52);
-ptr_67_params.push_back(ptr_55);
-ptr_67_params.push_back(ptr_58);
-ptr_67_params.push_back(const_int32_36);
-ptr_67_params.push_back(const_int32_36);
-CallInst* ptr_67 = CallInst::Create(func_JnJVM_org_mmtk_utility_alloc_BumpPointer_allocSlow__Lorg_vmmagic_unboxed_Address_2Lorg_vmmagic_unboxed_Address_2II, ptr_67_params.begin(), ptr_67_params.end(), "", label_false_IFEQ_i_i_i);
-ptr_67->setCallingConv(CallingConv::C);
-ptr_67->setTailCall(true);
-AttrListPtr ptr_67_PAL;
+std::vector<Value*> ptr_88_params;
+ptr_88_params.push_back(ptr_62);
+ptr_88_params.push_back(ptr_65);
+ptr_88_params.push_back(ptr_79);
+ptr_88_params.push_back(const_int32_43);
+ptr_88_params.push_back(const_int32_43);
+CallInst* ptr_88 = CallInst::Create(func_JnJVM_org_mmtk_utility_alloc_BumpPointer_allocSlow__Lorg_vmmagic_unboxed_Address_2Lorg_vmmagic_unboxed_Address_2II, ptr_88_params.begin(), ptr_88_params.end(), "", label_false_IFEQ_i_i_i);
+ptr_88->setCallingConv(CallingConv::C);
+ptr_88->setTailCall(true);
+AttrListPtr ptr_88_PAL;
 {
  SmallVector<AttributeWithIndex, 4> Attrs;
  AttributeWithIndex PAWI;
  PAWI.Index = 4294967295U; PAWI.Attrs = 0  | Attribute::NoUnwind;
  Attrs.push_back(PAWI);
- ptr_67_PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
+ ptr_88_PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
  
 }
-ptr_67->setAttributes(ptr_67_PAL);
+ptr_88->setAttributes(ptr_88_PAL);
 
 BranchInst::Create(label_JnJVM_org_j3_bindings_Bindings_gcmalloc__ILorg_vmmagic_unboxed_ObjectReference_2_exit, label_false_IFEQ_i_i_i);
 
 // Block JnJVM_org_j3_bindings_Bindings_gcmalloc__ILorg_vmmagic_unboxed_ObjectReference_2.exit (label_JnJVM_org_j3_bindings_Bindings_gcmalloc__ILorg_vmmagic_unboxed_ObjectReference_2_exit)
-PHINode* ptr_69 = PHINode::Create(PointerTy_28, "", label_JnJVM_org_j3_bindings_Bindings_gcmalloc__ILorg_vmmagic_unboxed_ObjectReference_2_exit);
-ptr_69->reserveOperandSpace(2);
-ptr_69->addIncoming(ptr_55, label_JnJVM_org_mmtk_utility_alloc_Allocator_fillAlignmentGap__Lorg_vmmagic_unboxed_Address_2Lorg_vmmagic_unboxed_Address_2_exit_i_i_i);
-ptr_69->addIncoming(ptr_67, label_false_IFEQ_i_i_i);
-
-std::vector<Value*> ptr_70_indices;
-ptr_70_indices.push_back(const_int32_36);
-ptr_70_indices.push_back(const_int32_36);
-Instruction* ptr_70 = GetElementPtrInst::Create(ptr_69, ptr_70_indices.begin(), ptr_70_indices.end(), "", label_JnJVM_org_j3_bindings_Bindings_gcmalloc__ILorg_vmmagic_unboxed_ObjectReference_2_exit);
-CastInst* ptr__c_i = new BitCastInst(ptr_VT, PointerTy_29, ".c.i", label_JnJVM_org_j3_bindings_Bindings_gcmalloc__ILorg_vmmagic_unboxed_ObjectReference_2_exit);
- new StoreInst(ptr__c_i, ptr_70, false, label_JnJVM_org_j3_bindings_Bindings_gcmalloc__ILorg_vmmagic_unboxed_ObjectReference_2_exit);
-CastInst* ptr_tmp1 = new BitCastInst(ptr_69, PointerTy_0, "tmp1", label_JnJVM_org_j3_bindings_Bindings_gcmalloc__ILorg_vmmagic_unboxed_ObjectReference_2_exit);
+PHINode* ptr_90 = PHINode::Create(PointerTy_26, "", label_JnJVM_org_j3_bindings_Bindings_gcmalloc__ILorg_vmmagic_unboxed_ObjectReference_2_exit);
+ptr_90->reserveOperandSpace(2);
+ptr_90->addIncoming(ptr_65, label_JnJVM_org_mmtk_utility_alloc_Allocator_fillAlignmentGap__Lorg_vmmagic_unboxed_Address_2Lorg_vmmagic_unboxed_Address_2_exit_i_i_i);
+ptr_90->addIncoming(ptr_88, label_false_IFEQ_i_i_i);
+
+std::vector<Value*> ptr_91_indices;
+ptr_91_indices.push_back(const_int32_43);
+ptr_91_indices.push_back(const_int32_43);
+Instruction* ptr_91 = GetElementPtrInst::Create(ptr_90, ptr_91_indices.begin(), ptr_91_indices.end(), "", label_JnJVM_org_j3_bindings_Bindings_gcmalloc__ILorg_vmmagic_unboxed_ObjectReference_2_exit);
+CastInst* ptr__c_i = new BitCastInst(ptr_VT, PointerTy_27, ".c.i", label_JnJVM_org_j3_bindings_Bindings_gcmalloc__ILorg_vmmagic_unboxed_ObjectReference_2_exit);
+ new StoreInst(ptr__c_i, ptr_91, false, label_JnJVM_org_j3_bindings_Bindings_gcmalloc__ILorg_vmmagic_unboxed_ObjectReference_2_exit);
+CastInst* ptr_tmp1 = new BitCastInst(ptr_90, PointerTy_0, "tmp1", label_JnJVM_org_j3_bindings_Bindings_gcmalloc__ILorg_vmmagic_unboxed_ObjectReference_2_exit);
 ReturnInst::Create(mod->getContext(), ptr_tmp1, label_JnJVM_org_j3_bindings_Bindings_gcmalloc__ILorg_vmmagic_unboxed_ObjectReference_2_exit);
 return func_gcmalloc;
 }

Modified: vmkit/branches/precise/mmtk/mmtk-alloc/Selected.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/mmtk/mmtk-alloc/Selected.cpp?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/mmtk/mmtk-alloc/Selected.cpp (original)
+++ vmkit/branches/precise/mmtk/mmtk-alloc/Selected.cpp Wed Nov 10 14:00:39 2010
@@ -51,7 +51,10 @@
 
 extern "C" void* gcmalloc(uint32_t sz, void* VT) {
   sz = llvm::RoundUpToAlignment(sz, sizeof(void*));
-  return JnJVM_org_j3_bindings_Bindings_gcmalloc__ILorg_vmmagic_unboxed_ObjectReference_2(sz, VT);
+  gc* res = (gc*)JnJVM_org_j3_bindings_Bindings_gcmalloc__ILorg_vmmagic_unboxed_ObjectReference_2(sz, VT);
+  assert(VT != NULL);
+  assert(res->getVirtualTable() == VT);
+  return res;
 }
 
 extern "C" void addFinalizationCandidate(void* obj) __attribute__((always_inline));
@@ -84,14 +87,26 @@
 }
 
 void Collector::scanObject(void** ptr, uintptr_t closure) {
+  if ((*ptr) != NULL) {
+    assert(((gc*)(*ptr))->getVirtualTable());
+  }
   JnJVM_org_j3_bindings_Bindings_reportDelayedRootEdge__Lorg_mmtk_plan_TraceLocal_2Lorg_vmmagic_unboxed_Address_2(closure, ptr);
 }
  
 void Collector::markAndTrace(void* source, void* ptr, uintptr_t closure) {
+  void** ptr_ = (void**)ptr;
+  if ((*ptr_) != NULL) {
+    assert(((gc*)(*ptr_))->getVirtualTable());
+  }
+  if ((*(void**)ptr) != NULL) assert(((gc*)(*(void**)ptr))->getVirtualTable());
   JnJVM_org_j3_bindings_Bindings_processEdge__Lorg_mmtk_plan_TransitiveClosure_2Lorg_vmmagic_unboxed_ObjectReference_2Lorg_vmmagic_unboxed_Address_2(closure, source, ptr);
 }
   
 void Collector::markAndTraceRoot(void* ptr, uintptr_t closure) {
+  void** ptr_ = (void**)ptr;
+  if ((*ptr_) != NULL) {
+    assert(((gc*)(*ptr_))->getVirtualTable());
+  }
   JnJVM_org_j3_bindings_Bindings_processRootEdge__Lorg_mmtk_plan_TraceLocal_2Lorg_vmmagic_unboxed_Address_2Z(closure, ptr, true);
 }
 
@@ -127,7 +142,7 @@
 #else
   uint32 flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED;
 #endif
-  void* baseAddr = mmap((void*)0x30000000, 0x40000000, PROT_READ | PROT_WRITE,
+  void* baseAddr = mmap((void*)0x30000000, 0x30000000, PROT_READ | PROT_WRITE,
                         flags, -1, 0);
   if (baseAddr == MAP_FAILED) {
     perror("mmap");
@@ -138,7 +153,7 @@
 }
 
 extern "C" void* MMTkMutatorAllocate(uint32_t size, VirtualTable* VT) {
-  void* val = MutatorThread::get()->Allocator.Allocate(size, "MMTk");
+  void* val = MutatorThread::get()->Allocator.Allocate(size);
   ((void**)val)[0] = VT;
   return val;
 }

Modified: vmkit/branches/precise/mmtk/mmtk-j3/Memory.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/mmtk/mmtk-j3/Memory.cpp?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/mmtk/mmtk-j3/Memory.cpp (original)
+++ vmkit/branches/precise/mmtk/mmtk-j3/Memory.cpp Wed Nov 10 14:00:39 2010
@@ -22,7 +22,7 @@
 }
 
 extern "C" uintptr_t Java_org_j3_mmtk_Memory_getHeapEndConstant__ (JavaObject* M) {
-  return (uintptr_t)0x70000000;
+  return (uintptr_t)0x60000000;
 }
 
 extern "C" uintptr_t Java_org_j3_mmtk_Memory_getAvailableStartConstant__ (JavaObject* M) {
@@ -30,7 +30,7 @@
 }
 
 extern "C" uintptr_t Java_org_j3_mmtk_Memory_getAvailableEndConstant__ (JavaObject* M) {
-  return (uintptr_t)0x70000000;
+  return (uintptr_t)0x60000000;
 }
 
 extern "C" sint32
@@ -41,14 +41,16 @@
   return 0;
 }
 
-extern "C" void
+extern "C" uint8_t
 Java_org_j3_mmtk_Memory_mprotect__Lorg_vmmagic_unboxed_Address_2I (JavaObject* M, uintptr_t address, sint32 size) {
-  mprotect((void*)address, size, PROT_NONE);
+  int val = mprotect((void*)address, size, PROT_NONE);
+  return (val == 0);
 }
 
-extern "C" void
+extern "C" uint8_t
 Java_org_j3_mmtk_Memory_munprotect__Lorg_vmmagic_unboxed_Address_2I (JavaObject* M, uintptr_t address, sint32 size) {
-  mprotect((void*)address, size, PROT_READ | PROT_WRITE);
+  int val = mprotect((void*)address, size, PROT_READ | PROT_WRITE);
+  return (val == 0);
 }
 
 extern "C" void

Modified: vmkit/branches/precise/mmtk/mmtk-j3/VM.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/mmtk/mmtk-j3/VM.cpp?rev=118707&r1=118706&r2=118707&view=diff
==============================================================================
--- vmkit/branches/precise/mmtk/mmtk-j3/VM.cpp (original)
+++ vmkit/branches/precise/mmtk/mmtk-j3/VM.cpp Wed Nov 10 14:00:39 2010
@@ -58,7 +58,7 @@
 }
 
 extern "C" bool Java_org_j3_runtime_VM_verifyAssertions__ () {
-#ifdef DEBUG
+#if 1//def DEBUG
   return true;
 #else
   return false;





More information about the vmkit-commits mailing list