[vmkit-commits] vmkit-commits Digest, Vol 28, Issue 2

Allan Tong actong88 at gmail.com
Wed Sep 15 07:37:04 PDT 2010


The attached patch should fix your issue, though it was actually
created to get around another problem, that being that r109973 caused
the mmtk/llvm-gcc build to fail due to the use of gc_root from
ForceRuntimeLinking.

Alternatively you could just remove references to j3OverflowThinLock,
which was removed by r111784, from LinkJavaRuntime.h

 - Allan

On Tue, Sep 14, 2010 at 5:27 PM, Richard Corsale <igf1 at yahoo.com> wrote:
> Hi all, I seem to get this error when running make:
>
> llvm[1]: Linking Debug+Asserts executable vmjc
> /media/tank/Downloads/VMKit/vmkit/Debug+Asserts/lib/libJ3.a(Jnjvm.o): In
> function `ForceRuntimeLinking':
> /media/tank/Downloads/VMKit/vmkit/lib/J3/VMCore/LinkJavaRuntime.h:108: undefined
> reference to `j3OverflowThinLock'
> collect2: ld returned 1 exit status
> make[1]: *** [/media/tank/Downloads/VMKit/vmkit/Debug+Asserts/bin/vmjc] Error 1
> make[1]: Leaving directory `/media/tank/Downloads/VMKit/vmkit/tools/vmjc'
> make: *** [all] Error 1
>
>
> I any idea what's going on?
>
>
>
> ----- Original Message ----
> From: "vmkit-commits-request at cs.uiuc.edu" <vmkit-commits-request at cs.uiuc.edu>
> To: vmkit-commits at cs.uiuc.edu
> Sent: Sun, September 12, 2010 1:00:07 PM
> Subject: vmkit-commits Digest, Vol 28, Issue 2
>
> Send vmkit-commits mailing list submissions to
>    vmkit-commits at cs.uiuc.edu
>
> To subscribe or unsubscribe via the World Wide Web, visit
>    http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits
> or, via email, send a message with subject or body 'help' to
>    vmkit-commits-request at cs.uiuc.edu
>
> You can reach the person managing the list at
>    vmkit-commits-owner at cs.uiuc.edu
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of vmkit-commits digest..."
>
>
> Today's Topics:
>
>   1. [vmkit] r113706 - in /vmkit/branches/precise:
>      include/mvm/JIT.h include/mvm/MethodInfo.h
>      include/mvm/VirtualMachine.h lib/J3/Compiler/JavaJITCompiler.cpp
>      lib/J3/Compiler/LLVMInfo.cpp lib/J3/VMCore/JavaClass.h
>      lib/J3/VMCore/Jnjvm.cpp lib/J3/VMCore/JnjvmClassLoader.cpp
>      lib/Mvm/Compiler/JIT.cpp lib/Mvm/Runtime/MethodInfo.cpp
>      (Nicolas Geoffray)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sat, 11 Sep 2010 22:33:49 -0000
> From: Nicolas Geoffray <nicolas.geoffray at lip6.fr>
> Subject: [vmkit-commits] [vmkit] r113706 - in /vmkit/branches/precise:
>    include/mvm/JIT.h include/mvm/MethodInfo.h
>    include/mvm/VirtualMachine.h lib/J3/Compiler/JavaJITCompiler.cpp
>    lib/J3/Compiler/LLVMInfo.cpp lib/J3/VMCore/JavaClass.h
>    lib/J3/VMCore/Jnjvm.cpp lib/J3/VMCore/JnjvmClassLoader.cpp
>    lib/Mvm/Compiler/JIT.cpp lib/Mvm/Runtime/MethodInfo.cpp
> To: vmkit-commits at cs.uiuc.edu
> Message-ID: <20100911223349.47BDA2A6C12C at llvm.org>
> Content-Type: text/plain; charset="utf-8"
>
> Author: geoffray
> Date: Sat Sep 11 17:33:49 2010
> New Revision: 113706
>
> URL: http://llvm.org/viewvc/llvm-project?rev=113706&view=rev
> Log:
> Have  a single function map per vm, and put exact ip information in it.
>
>
> Modified:
>    vmkit/branches/precise/include/mvm/JIT.h
>    vmkit/branches/precise/include/mvm/MethodInfo.h
>    vmkit/branches/precise/include/mvm/VirtualMachine.h
>    vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp
>    vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp
>    vmkit/branches/precise/lib/J3/VMCore/JavaClass.h
>    vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp
>    vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp
>    vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp
>    vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp
>
> Modified: vmkit/branches/precise/include/mvm/JIT.h
> URL:
> http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/mvm/JIT.h?rev=113706&r1=113705&r2=113706&view=diff
>
> ==============================================================================
> --- vmkit/branches/precise/include/mvm/JIT.h (original)
> +++ vmkit/branches/precise/include/mvm/JIT.h Sat Sep 11 17:33:49 2010
> @@ -30,6 +30,7 @@
>   class FunctionPassManager;
>   class GCFunctionInfo;
>   class GCStrategy;
> +  class JIT;
>   class Module;
>   class PointerType;
>   class TargetData;
> @@ -176,15 +177,13 @@
>
>
> class MvmModule {
> -private:
> -   static llvm::ExecutionEngine* executionEngine;
> -
> public:
>    static llvm::GCStrategy* TheGCStrategy;
>    static mvm::LockRecursive protectEngine;
>    static llvm::Module *globalModule;
>    static const llvm::TargetData* TheTargetData;
>    static mvm::BumpPtrAllocator* Allocator;
> +   static llvm::ExecutionEngine* executionEngine;
>    //static unsigned MetadataTypeKind;
>
>    static uint64 getTypeSize(const llvm::Type* type);
> @@ -209,6 +208,7 @@
> public:
>   virtual void scan(uintptr_t closure, void* ip, void* addr);
>   JITMethodInfo(llvm::GCFunctionInfo* GFI) : GCInfo(GFI) {}
> +  void addToVM(VirtualMachine* vm, llvm::JIT* jit);
> };
>
> class MvmJITMethodInfo : public JITMethodInfo {
>
> Modified: vmkit/branches/precise/include/mvm/MethodInfo.h
> URL:
> http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/mvm/MethodInfo.h?rev=113706&r1=113705&r2=113706&view=diff
>
> ==============================================================================
> --- vmkit/branches/precise/include/mvm/MethodInfo.h (original)
> +++ vmkit/branches/precise/include/mvm/MethodInfo.h Sat Sep 11 17:33:49 2010
> @@ -29,7 +29,6 @@
>   void* getMetaInfo() const { return MetaInfo; }
>
>   unsigned MethodType;
> -  void* InstructionPointer;
>   void* MetaInfo;
> };
>
> @@ -45,15 +44,15 @@
> public:
>   CamlFrame* CF;
>   virtual void scan(uintptr_t closure, void* ip, void* addr);
> -  CamlMethodInfo(CamlFrame* C, void* ip);
> +  CamlMethodInfo(CamlFrame* C) : CF(C) { }
> };
>
> class StaticCamlMethodInfo : public CamlMethodInfo {
>   const char* name;
> public:
>   virtual void print(void* ip, void* addr);
> -  StaticCamlMethodInfo(CamlFrame* CF, void* ip, const char* n) :
> -    CamlMethodInfo(CF, ip) {
> +  StaticCamlMethodInfo(CamlFrame* CF, const char* n) :
> +    CamlMethodInfo(CF) {
>     name = n;
>     MethodType = 0;
>   }
>
> Modified: vmkit/branches/precise/include/mvm/VirtualMachine.h
> URL:
> http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/mvm/VirtualMachine.h?rev=113706&r1=113705&r2=113706&view=diff
>
> ==============================================================================
> --- vmkit/branches/precise/include/mvm/VirtualMachine.h (original)
> +++ vmkit/branches/precise/include/mvm/VirtualMachine.h Sat Sep 11 17:33:49 2010
> @@ -48,79 +48,16 @@
>
>   /// IPToMethodInfo - Map a code start instruction instruction to the
> MethodInfo.
>   ///
> -  MethodInfo* CodeStartToMethodInfo(void* ip) {
> -    FunctionMapLock.acquire();
> -    std::map<void*, MethodInfo*>::iterator I = Functions.find(ip);
> -    MethodInfo* res = NULL;
> -    if (I != Functions.end()) {
> -      res = I->second;
> -    }
> -    FunctionMapLock.release();
> -    return res;
> -  }
> -};
> -
> -/// StartEndFunctionMap - This map is for functions for which we have
> -/// a start and end address.
> -///
> -class StartEndFunctionMap : public FunctionMap {
> -public:
> -  /// addMethodInFunctionMap - A new method pointer in the function map.
> -  ///
> -  void addMethodInfo(MethodInfo* meth, void* start, void* end) {
> -    FunctionMapLock.acquire();
> -    Functions.insert(std::make_pair(start, meth));
> -    Functions.insert(std::make_pair(end, meth));
> -    FunctionMapLock.release();
> -  }
> -
> -  /// IPToMethodInfo - Map an instruction pointer to the MethodInfo.
> -  ///
> -  MethodInfo* IPToMethodInfo(void* ip) {
> -    FunctionMapLock.acquire();
> -    std::map<void*, MethodInfo*>::iterator I = Functions.upper_bound(ip);
> -    MethodInfo* res = 0;
> -    if (I != Functions.end() && I != Functions.begin()) {
> -      res = I->second;
> -      if ((--I)->second != res) res = 0;
> -    }
> -    FunctionMapLock.release();
> -    return res;
> -  }
> -};
> -
> -/// StartFunctionMap - This map is for static functions where getting an end
> -/// address is cumbersome.
> -///
> -class StartFunctionMap : public FunctionMap {
> -public:
> -  /// addMethodInFunctionMap - A new method pointer in the function map.
> -  ///
> -  void addMethodInfo(MethodInfo* meth, void* addr) {
> -    FunctionMapLock.acquire();
> -    Functions.insert(std::make_pair((void*)addr, meth));
> -    FunctionMapLock.release();
> -  }
> -
> -  /// IPToMethodInfo - Map an instruction pointer to the MethodInfo.
> -  ///
>   MethodInfo* IPToMethodInfo(void* ip);
> -
> -};
>
> -class SharedStartFunctionMap : public StartFunctionMap {
> -public:
> -  BumpPtrAllocator* StaticAllocator;
> -  bool initialized;
> -  SharedStartFunctionMap() {
> -    initialized = false;
> -  }
> +  /// addMethodInfo - A new instruction pointer in the function map.
> +  ///
> +  void addMethodInfo(MethodInfo* meth, void* ip);
>
> -  void initialize();
> +  FunctionMap();
> };
>
>
> -
> // Same values than JikesRVM
> #define INITIAL_QUEUE_SIZE 256
> #define GROW_FACTOR 2
> @@ -232,7 +169,6 @@
>
>     mainThread = 0;
>     NumberOfThreads = 0;
> -    if (!SharedStaticFunctions.initialized) SharedStaticFunctions.initialize();
>   }
> public:
>
> @@ -529,13 +465,10 @@
>   UncooperativeCollectionRV rendezvous;
> #endif
>
> -
> -  StartEndFunctionMap RuntimeFunctions;
> -  static StartEndFunctionMap SharedRuntimeFunctions;
> -  StartFunctionMap StaticFunctions;
> -  static SharedStartFunctionMap SharedStaticFunctions;
> -
> -  MethodInfo* IPToMethodInfo(void* ip);
> +  FunctionMap FunctionsCache;
> +  MethodInfo* IPToMethodInfo(void* ip) {
> +    return FunctionsCache.IPToMethodInfo(ip);
> +  }
>
> #ifdef ISOLATE
>   size_t IsolateID;
>
> 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=113706&r1=113705&r2=113706&view=diff
>
> ==============================================================================
> --- vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp (original)
> +++ vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp Sat Sep 11
> 17:33:49 2010
> @@ -55,10 +55,16 @@
>   if (ip) new_ip = isStub(ip, addr);
>   JavaMethod* meth = (JavaMethod*)MetaInfo;
>   CodeLineInfo* info = meth->lookupCodeLineInfo((uintptr_t)ip);
> -  fprintf(stderr, "; %p in %s.%s (line %d, bytecode %d, code start %p)",
> new_ip,
> -          UTF8Buffer(meth->classDef->name).cString(),
> -          UTF8Buffer(meth->name).cString(), info->lineNumber,
> -          info->bytecodeIndex, meth->code);
> +  if (info != NULL) {
> +    fprintf(stderr, "; %p in %s.%s (line %d, bytecode %d, code start %p)",
> new_ip,
> +            UTF8Buffer(meth->classDef->name).cString(),
> +            UTF8Buffer(meth->name).cString(), info->lineNumber,
> +            info->bytecodeIndex, meth->code);
> +  } else {
> +    fprintf(stderr, "; %p in %s.%s (native method, code start %p)", new_ip,
> +            UTF8Buffer(meth->classDef->name).cString(),
> +            UTF8Buffer(meth->name).cString(), meth->code);
> +  }
>   if (ip != new_ip) fprintf(stderr, " (from stub)");
>   fprintf(stderr, "\n");
> }
> @@ -71,41 +77,39 @@
>   // The following could be changed to an assert when -load-bc supports
>   // the verifier.
>   if (F.getParent() != TheCompiler->getLLVMModule()) return;
> +  assert(F.hasGC());
>
>   Jnjvm* vm = JavaThread::get()->getJVM();
>   mvm::BumpPtrAllocator& Alloc = TheCompiler->allocator;
> -  llvm::GCFunctionInfo* GFI = 0;
>
> -  if (F.hasGC()) {
> -    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();
> +  // 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--;
> -    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");
> -    GFI = *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.
> -    mvm::MvmJITMethodInfo* MI = new(Alloc, "JITMethodInfo")
> -      mvm::MvmJITMethodInfo(GFI, &F);
> -    vm->RuntimeFunctions.addMethodInfo(MI, Code,
> -                                       (void*)((uintptr_t)Code + Size));
> +    MI = new(Alloc, "JITMethodInfo") mvm::MvmJITMethodInfo(GFI, &F);
>   } else {
> -    JavaJITMethodInfo* MI = new(Alloc, "JavaJITMethodInfo")
> -      JavaJITMethodInfo(GFI, meth);
> -    vm->RuntimeFunctions.addMethodInfo(MI, Code,
> -                                       (void*)((uintptr_t)Code + Size));
> +    MI = new(Alloc, "JavaJITMethodInfo") JavaJITMethodInfo(GFI, meth);
> +  }
> +  MI->addToVM(vm, (JIT*)TheCompiler->executionEngine);
> +
> +  if (meth != NULL) {
>     uint32 infoLength = Details.LineStarts.size();
>     meth->codeInfoLength = infoLength;
>     if (infoLength > 0) {
>
> Modified: vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp?rev=113706&r1=113705&r2=113706&view=diff
>
> ==============================================================================
> --- vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp (original)
> +++ vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp Sat Sep 11 17:33:49 2010
> @@ -169,9 +169,7 @@
>                                         "", Compiler->getLLVMModule());
>     }
>
> -    if (Compiler->useCooperativeGC()) {
> -      methodFunction->setGC("vmkit");
> -    }
> +    methodFunction->setGC("vmkit");
>
>     Compiler->functions.insert(std::make_pair(methodFunction, methodDef));
>     if (Compiler != JCL->getCompiler() && methodDef->code) {
> @@ -404,10 +402,13 @@
>
>   Value* val = CallInst::Create(func, Args.begin(), Args.end(), "",
>                                 currentBlock);
> -  if (!signature->getReturnType()->isVoid())
> +  if (!signature->getReturnType()->isVoid()) {
>     ReturnInst::Create(context, val, currentBlock);
> -  else
> +  } else {
>     ReturnInst::Create(context, currentBlock);
> +  }
> +
> +  res->setGC("vmkit");
>
>   return res;
> }
> @@ -481,15 +482,14 @@
>
>   Value* val = CallInst::Create(func, Args.begin(), Args.end(), "",
>                                 currentBlock);
> -  if (!signature->getReturnType()->isVoid())
> +  if (!signature->getReturnType()->isVoid()) {
>     ReturnInst::Create(context, val, currentBlock);
> -  else
> +  } else {
>     ReturnInst::Create(context, currentBlock);
> -
> -  if (Compiler->useCooperativeGC()) {
> -    res->setGC("vmkit");
>   }
>
> +  res->setGC("vmkit");
> +
>   return res;
> }
>
> @@ -545,7 +545,7 @@
>   if (virt) {
>     if (Compiler->useCooperativeGC()) {
>       Args.push_back(new LoadInst(TempArgs[0], "", false, currentBlock));
> -    }else {
> +    } else {
>       Args.push_back(TempArgs[0]);
>     }
>   }
> @@ -587,9 +587,7 @@
>     ReturnInst::Create(context, currentBlock);
>   }
>
> -  if (Compiler->useCooperativeGC()) {
> -    stub->setGC("vmkit");
> -  }
> +  stub->setGC("vmkit");
>
>   return stub;
> }
>
> 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=113706&r1=113705&r2=113706&view=diff
>
> ==============================================================================
> --- vmkit/branches/precise/lib/J3/VMCore/JavaClass.h (original)
> +++ vmkit/branches/precise/lib/J3/VMCore/JavaClass.h Sat Sep 11 17:33:49 2010
> @@ -902,7 +902,7 @@
>   virtual void print(void* ip, void* addr);
>
>   JavaStaticMethodInfo(mvm::CamlMethodInfo* super, void* ip, JavaMethod* M) :
> -    mvm::CamlMethodInfo(super != NULL ? super->CF : NULL, ip) {
> +    mvm::CamlMethodInfo(super->CF) {
>     MetaInfo = M;
>     MethodType = 1;
>   }
>
> 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=113706&r1=113705&r2=113706&view=diff
>
> ==============================================================================
> --- vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp (original)
> +++ vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp Sat Sep 11 17:33:49 2010
> @@ -1487,8 +1487,7 @@
> }
>
> void Jnjvm::removeMethodsInFunctionMaps(JnjvmClassLoader* loader) {
> -  internalRemoveMethods(loader, RuntimeFunctions);
> -  internalRemoveMethods(loader, StaticFunctions);
> +  internalRemoveMethods(loader, FunctionsCache);
> }
>
>
>
> 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=113706&r1=113705&r2=113706&view=diff
>
> ==============================================================================
> --- vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp (original)
> +++ vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp Sat Sep 11
> 17:33:49 2010
> @@ -1073,7 +1073,7 @@
>         if (!isAbstract(meth.access) && meth.code) {
>           JavaStaticMethodInfo* MI = new (allocator, "JavaStaticMethodInfo")
>             JavaStaticMethodInfo(0, meth.code, &meth);
> -          vm->StaticFunctions.addMethodInfo(MI, meth.code);
> +          vm->FunctionsCache.addMethodInfo(MI, meth.code);
>         }
>       }
>
> @@ -1082,7 +1082,7 @@
>         if (!isAbstract(meth.access) && meth.code) {
>           JavaStaticMethodInfo* MI = new (allocator, "JavaStaticMethodInfo")
>             JavaStaticMethodInfo(0, meth.code, &meth);
> -          vm->StaticFunctions.addMethodInfo(MI, meth.code);
> +          vm->FunctionsCache.addMethodInfo(MI, meth.code);
>         }
>       }
>     }
>
> 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=113706&r1=113705&r2=113706&view=diff
>
> ==============================================================================
> --- vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp (original)
> +++ vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp Sat Sep 11 17:33:49 2010
> @@ -22,6 +22,7 @@
> #include <llvm/Analysis/Verifier.h>
> #include <llvm/Assembly/Parser.h>
> #include <llvm/CodeGen/GCStrategy.h>
> +#include <llvm/CodeGen/JITCodeEmitter.h>
> #include <llvm/Config/config.h>
> #include <llvm/ExecutionEngine/ExecutionEngine.h>
> #include "llvm/ExecutionEngine/JITEventListener.h"
> @@ -35,6 +36,7 @@
> #include <llvm/Target/TargetMachine.h>
> #include <llvm/Target/TargetOptions.h>
> #include <llvm/Target/TargetSelect.h>
> +#include <../lib/ExecutionEngine/JIT/JIT.h>
>
> #include "mvm/JIT.h"
> #include "mvm/Threads/Locks.h"
> @@ -93,24 +95,33 @@
>                                      void *Code, size_t Size,
>                                      const EmittedFunctionDetails &Details) {
>     assert(F.getParent() == MvmModule::globalModule);
> -    llvm::GCFunctionInfo* GFI = 0;
> +    assert(F.hasGC());
>     // We know the last GC info is for this method.
> -    if (F.hasGC()) {
> -      GCStrategy::iterator I = mvm::MvmModule::TheGCStrategy->end();
> -      I--;
> -      DEBUG(errs() << (*I)->getFunction().getName() << '\n');
> -      DEBUG(errs() << F.getName() << '\n');
> -      assert(&(*I)->getFunction() == &F &&
> +    GCStrategy::iterator I = mvm::MvmModule::TheGCStrategy->end();
> +    I--;
> +    DEBUG(errs() << (*I)->getFunction().getName() << '\n');
> +    DEBUG(errs() << F.getName() << '\n');
> +    assert(&(*I)->getFunction() == &F &&
>         "GC Info and method do not correspond");
> -      GFI = *I;
> -    }
> -    MethodInfo* MI =
> +    llvm::GCFunctionInfo* GFI = *I;
> +    JITMethodInfo* MI =
>       new(*MvmModule::Allocator, "MvmJITMethodInfo") MvmJITMethodInfo(GFI, &F);
> -    VirtualMachine::SharedRuntimeFunctions.addMethodInfo(MI, Code,
> -                                            (void*)((uintptr_t)Code + Size));
> +    MI->addToVM(mvm::Thread::get()->MyVM, (JIT*)MvmModule::executionEngine);
>   }
> };
>
> +void JITMethodInfo::addToVM(VirtualMachine* VM, JIT* jit) {
> +  JITCodeEmitter* JCE = jit->getCodeEmitter();
> +  assert(GCInfo != NULL);
> +  for (GCFunctionInfo::iterator I = GCInfo->begin(), E = GCInfo->end();
> +       I != E;
> +       I++) {
> +    uintptr_t address = JCE->getLabelAddress(I->Label);
> +    assert(address != 0);
> +    VM->FunctionsCache.addMethodInfo(this, (void*)address);
> +  }
> +}
> +
> static MvmJITListener JITListener;
>
> void MvmModule::loadBytecodeFile(const std::string& str) {
> @@ -317,6 +328,7 @@
>   unconditionalSafePoint = module->getFunction("unconditionalSafePoint");
>   conditionalSafePoint = module->getFunction("conditionalSafePoint");
>   AllocateFunction = module->getFunction("gcmalloc");
> +  AllocateFunction->setGC("vmkit");
>   assert(AllocateFunction && "No allocate function");
>   AllocateUnresolvedFunction = module->getFunction("gcmallocUnresolved");
>   assert(AllocateUnresolvedFunction && "No allocateUnresolved function");
>
> Modified: vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp?rev=113706&r1=113705&r2=113706&view=diff
>
> ==============================================================================
> --- vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp (original)
> +++ vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp Sat Sep 11 17:33:49
> 2010
> @@ -24,19 +24,11 @@
> using namespace mvm;
>
> void CamlMethodInfo::scan(uintptr_t closure, void* ip, void* addr) {
> -  if (!CF && InstructionPointer) {
> -    MethodInfo* MI = VirtualMachine::SharedStaticFunctions.IPToMethodInfo(ip);
> -    if (MI != &DefaultMethodInfo::DM) {
> -      CF = ((CamlMethodInfo*)MI)->CF;
> -    }
> -  }
> -
> -  if (CF) {
> -    //uintptr_t spaddr = (uintptr_t)addr + CF->FrameSize + sizeof(void*);
> -    uintptr_t spaddr = ((uintptr_t*)addr)[0];
> -    for (uint16 i = 0; i < CF->NumLiveOffsets; ++i) {
> -      Collector::scanObject((void**)(spaddr + CF->LiveOffsets[i]), closure);
> -    }
> +  assert(CF != NULL);
> +  //uintptr_t spaddr = (uintptr_t)addr + CF->FrameSize + sizeof(void*);
> +  uintptr_t spaddr = ((uintptr_t*)addr)[0];
> +  for (uint16 i = 0; i < CF->NumLiveOffsets; ++i) {
> +    Collector::scanObject((void**)(spaddr + CF->LiveOffsets[i]), closure);
>   }
> }
>
> @@ -59,52 +51,6 @@
> void DefaultMethodInfo::scan(uintptr_t closure, void* ip, void* addr) {
> }
>
> -
> -MethodInfo* StartFunctionMap::IPToMethodInfo(void* ip) {
> -  FunctionMapLock.acquire();
> -  std::map<void*, MethodInfo*>::iterator E = Functions.end();
> -  std::map<void*, MethodInfo*>::iterator I = Functions.find(ip);
> -  MethodInfo* MI = 0;
> -  if (I == E) {
> -    Dl_info info;
> -    int res = dladdr(ip, &info);
> -    if (res != 0) {
> -      I = Functions.find(info.dli_saddr);
> -      if (I == E) {
> -        // The method is static, and we have no information for it.
> -        // Just return the Default MethodInfo object.
> -        MI = &DefaultMethodInfo::DM;
> -      } else {
> -        MI = I->second;
> -      }
> -    } else {
> -      // The method is jitted, and no-one has intercepted its compilation.
> -      // Just return the Default MethodInfo object.
> -      MI = &DefaultMethodInfo::DM;
> -    }
> -    // Add it to the map, so that we don't need to call dladdr again.
> -    Functions.insert(std::make_pair(ip, MI));
> -  } else {
> -    MI = I->second;
> -  }
> -  FunctionMapLock.release();
> -  return MI;
> -}
> -
> -MethodInfo* VirtualMachine::IPToMethodInfo(void* ip) {
> -  MethodInfo* MI = RuntimeFunctions.IPToMethodInfo(ip);
> -  if (MI) return MI;
> -
> -  MI = SharedRuntimeFunctions.IPToMethodInfo(ip);
> -  if (MI) return MI;
> -
> -  MI = StaticFunctions.IPToMethodInfo(ip);
> -  if (MI != &DefaultMethodInfo::DM) return MI;
> -
> -  MI = SharedStaticFunctions.IPToMethodInfo(ip);
> -  return MI;
> -}
> -
> struct CamlFrames {
>   uint16_t NumDescriptors;
>   CamlFrame frames[1];
> @@ -114,14 +60,11 @@
>   CamlFrames* frames ;
>   uint32 currentDescriptor;
>   CamlFrame* currentFrame;
> -  Dl_info info;
>
>   CamlFrameDecoder(CamlFrames* frames) {
>     this->frames = frames;
>     currentDescriptor = 0;
>     currentFrame = &(frames->frames[0]);
> -    int res = dladdr(currentFrame->ReturnAddress, &info);
> -    assert(res != 0 && "No frame");
>   }
>
>   bool hasNext() {
> @@ -135,55 +78,51 @@
>       (currentFrame->NumLiveOffsets % 2) * sizeof(uint16_t) +
>       currentFrame->NumLiveOffsets * sizeof(uint16_t) +
>       sizeof(void*) + sizeof(uint16_t) + sizeof(uint16_t));
> -    int res = dladdr(currentFrame->ReturnAddress, &info);
> -    assert(res != 0 && "No frame");
>   }
>
> -  CamlFrame* next(void** funcAddress, const char** funcName) {
> +  CamlFrame* next() {
>     assert(hasNext());
>     CamlFrame* result = currentFrame;
> -    *funcAddress = info.dli_saddr;
> -    *funcName = info.dli_sname;
> -
> -    // Skip the remaining ones.
> -    do {
> -      advance();
> -    } while (hasNext() && (info.dli_saddr == *funcAddress));
> -
> -    // Skip the entries that start at another method.
> -    while (hasNext() && (info.dli_saddr == currentFrame->ReturnAddress)) {
> -      advance();
> -    }
> -
> -    while (hasNext() && (info.dli_saddr == NULL)) {
> -      advance();
> -    }
> +    advance();
>     return result;
>   }
> };
>
> -void SharedStartFunctionMap::initialize() {
> +static BumpPtrAllocator* StaticAllocator = NULL;
> +
> +FunctionMap::FunctionMap() {
>   CamlFrames* frames =
>     (CamlFrames*)dlsym(SELF_HANDLE, "camlVmkitoptimized__frametable");
> +  if (frames == NULL) return;
> +
>   StaticAllocator = new BumpPtrAllocator();
> -  const char* name = NULL;
> -  void* address = NULL;
> -
> -  if (frames != NULL) {
> -    CamlFrameDecoder decoder(frames);
> -    while (decoder.hasNext()) {
> -      CamlFrame* frame = decoder.next(&address, &name);
> -      StaticCamlMethodInfo* MI = new(*StaticAllocator, "StaticCamlMethodInfo")
> -          StaticCamlMethodInfo(frame, address, name);
> -      addMethodInfo(MI, address);
> -    }
> +  CamlFrameDecoder decoder(frames);
> +  Dl_info info;
> +  while (decoder.hasNext()) {
> +    CamlFrame* frame = decoder.next();
> +    int res = dladdr(frame->ReturnAddress, &info);
> +    assert(res != 0 && "No frame");
> +    StaticCamlMethodInfo* MI = new(*StaticAllocator, "StaticCamlMethodInfo")
> +        StaticCamlMethodInfo(frame, info.dli_sname);
> +    addMethodInfo(MI, frame->ReturnAddress);
>   }
> }
>
> -CamlMethodInfo::CamlMethodInfo(CamlFrame* C, void* ip) {
> -  InstructionPointer = ip;
> -  CF = C;
> +MethodInfo* FunctionMap::IPToMethodInfo(void* ip) {
> +  FunctionMapLock.acquire();
> +  std::map<void*, MethodInfo*>::iterator I = Functions.find(ip);
> +  MethodInfo* res = NULL;
> +  if (I != Functions.end()) {
> +    res = I->second;
> +  } else {
> +    res = &DefaultMethodInfo::DM;
> +  }
> +  FunctionMapLock.release();
> +  return res;
> }
>
> -StartEndFunctionMap VirtualMachine::SharedRuntimeFunctions;
> -SharedStartFunctionMap VirtualMachine::SharedStaticFunctions;
> +void FunctionMap::addMethodInfo(MethodInfo* meth, void* ip) {
> +  FunctionMapLock.acquire();
> +  Functions.insert(std::make_pair(ip, meth));
> +  FunctionMapLock.release();
> +}
>
>
>
>
> ------------------------------
>
> _______________________________________________
> vmkit-commits mailing list
> vmkit-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits
>
>
> End of vmkit-commits Digest, Vol 28, Issue 2
> ********************************************
>
>
>
>
> _______________________________________________
> vmkit-commits mailing list
> vmkit-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: linkjavaruntime.patch
Type: application/octet-stream
Size: 17018 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/vmkit-commits/attachments/20100915/4da2500d/attachment.obj>


More information about the vmkit-commits mailing list