Hi Richard,<div><br></div><div>This should be fixed in latest svn. Thanks for reporting!</div><div><br></div><div>Cheers,</div><div>Nicolas<br><br><div class="gmail_quote">On Wed, Sep 15, 2010 at 4:37 PM, Allan Tong <span dir="ltr"><<a href="mailto:actong88@gmail.com">actong88@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">The attached patch should fix your issue, though it was actually<br>
created to get around another problem, that being that r109973 caused<br>
the mmtk/llvm-gcc build to fail due to the use of gc_root from<br>
ForceRuntimeLinking.<br>
<br>
Alternatively you could just remove references to j3OverflowThinLock,<br>
which was removed by r111784, from LinkJavaRuntime.h<br>
<font color="#888888"><br>
 - Allan<br>
</font><div><div></div><div class="h5"><br>
On Tue, Sep 14, 2010 at 5:27 PM, Richard Corsale <<a href="mailto:igf1@yahoo.com">igf1@yahoo.com</a>> wrote:<br>
> Hi all, I seem to get this error when running make:<br>
><br>
> llvm[1]: Linking Debug+Asserts executable vmjc<br>
> /media/tank/Downloads/VMKit/vmkit/Debug+Asserts/lib/libJ3.a(Jnjvm.o): In<br>
> function `ForceRuntimeLinking':<br>
> /media/tank/Downloads/VMKit/vmkit/lib/J3/VMCore/LinkJavaRuntime.h:108: undefined<br>
> reference to `j3OverflowThinLock'<br>
> collect2: ld returned 1 exit status<br>
> make[1]: *** [/media/tank/Downloads/VMKit/vmkit/Debug+Asserts/bin/vmjc] Error 1<br>
> make[1]: Leaving directory `/media/tank/Downloads/VMKit/vmkit/tools/vmjc'<br>
> make: *** [all] Error 1<br>
><br>
><br>
> I any idea what's going on?<br>
><br>
><br>
><br>
> ----- Original Message ----<br>
> From: "<a href="mailto:vmkit-commits-request@cs.uiuc.edu">vmkit-commits-request@cs.uiuc.edu</a>" <<a href="mailto:vmkit-commits-request@cs.uiuc.edu">vmkit-commits-request@cs.uiuc.edu</a>><br>
> To: <a href="mailto:vmkit-commits@cs.uiuc.edu">vmkit-commits@cs.uiuc.edu</a><br>
> Sent: Sun, September 12, 2010 1:00:07 PM<br>
> Subject: vmkit-commits Digest, Vol 28, Issue 2<br>
><br>
> Send vmkit-commits mailing list submissions to<br>
>    <a href="mailto:vmkit-commits@cs.uiuc.edu">vmkit-commits@cs.uiuc.edu</a><br>
><br>
> To subscribe or unsubscribe via the World Wide Web, visit<br>
>    <a href="http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits</a><br>
> or, via email, send a message with subject or body 'help' to<br>
>    <a href="mailto:vmkit-commits-request@cs.uiuc.edu">vmkit-commits-request@cs.uiuc.edu</a><br>
><br>
> You can reach the person managing the list at<br>
>    <a href="mailto:vmkit-commits-owner@cs.uiuc.edu">vmkit-commits-owner@cs.uiuc.edu</a><br>
><br>
> When replying, please edit your Subject line so it is more specific<br>
> than "Re: Contents of vmkit-commits digest..."<br>
><br>
><br>
> Today's Topics:<br>
><br>
>   1. [vmkit] r113706 - in /vmkit/branches/precise:<br>
>      include/mvm/JIT.h include/mvm/MethodInfo.h<br>
>      include/mvm/VirtualMachine.h lib/J3/Compiler/JavaJITCompiler.cpp<br>
>      lib/J3/Compiler/LLVMInfo.cpp lib/J3/VMCore/JavaClass.h<br>
>      lib/J3/VMCore/Jnjvm.cpp lib/J3/VMCore/JnjvmClassLoader.cpp<br>
>      lib/Mvm/Compiler/JIT.cpp lib/Mvm/Runtime/MethodInfo.cpp<br>
>      (Nicolas Geoffray)<br>
><br>
><br>
> ----------------------------------------------------------------------<br>
><br>
> Message: 1<br>
> Date: Sat, 11 Sep 2010 22:33:49 -0000<br>
> From: Nicolas Geoffray <<a href="mailto:nicolas.geoffray@lip6.fr">nicolas.geoffray@lip6.fr</a>><br>
> Subject: [vmkit-commits] [vmkit] r113706 - in /vmkit/branches/precise:<br>
>    include/mvm/JIT.h include/mvm/MethodInfo.h<br>
>    include/mvm/VirtualMachine.h lib/J3/Compiler/JavaJITCompiler.cpp<br>
>    lib/J3/Compiler/LLVMInfo.cpp lib/J3/VMCore/JavaClass.h<br>
>    lib/J3/VMCore/Jnjvm.cpp lib/J3/VMCore/JnjvmClassLoader.cpp<br>
>    lib/Mvm/Compiler/JIT.cpp lib/Mvm/Runtime/MethodInfo.cpp<br>
> To: <a href="mailto:vmkit-commits@cs.uiuc.edu">vmkit-commits@cs.uiuc.edu</a><br>
> Message-ID: <<a href="mailto:20100911223349.47BDA2A6C12C@llvm.org">20100911223349.47BDA2A6C12C@llvm.org</a>><br>
> Content-Type: text/plain; charset="utf-8"<br>
><br>
> Author: geoffray<br>
> Date: Sat Sep 11 17:33:49 2010<br>
> New Revision: 113706<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=113706&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=113706&view=rev</a><br>
> Log:<br>
> Have  a single function map per vm, and put exact ip information in it.<br>
><br>
><br>
> Modified:<br>
>    vmkit/branches/precise/include/mvm/JIT.h<br>
>    vmkit/branches/precise/include/mvm/MethodInfo.h<br>
>    vmkit/branches/precise/include/mvm/VirtualMachine.h<br>
>    vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp<br>
>    vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp<br>
>    vmkit/branches/precise/lib/J3/VMCore/JavaClass.h<br>
>    vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp<br>
>    vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp<br>
>    vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp<br>
>    vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp<br>
><br>
> Modified: vmkit/branches/precise/include/mvm/JIT.h<br>
> URL:<br>
> <a href="http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/mvm/JIT.h?rev=113706&r1=113705&r2=113706&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/mvm/JIT.h?rev=113706&r1=113705&r2=113706&view=diff</a><br>

><br>
> ==============================================================================<br>
> --- vmkit/branches/precise/include/mvm/JIT.h (original)<br>
> +++ vmkit/branches/precise/include/mvm/JIT.h Sat Sep 11 17:33:49 2010<br>
> @@ -30,6 +30,7 @@<br>
>   class FunctionPassManager;<br>
>   class GCFunctionInfo;<br>
>   class GCStrategy;<br>
> +  class JIT;<br>
>   class Module;<br>
>   class PointerType;<br>
>   class TargetData;<br>
> @@ -176,15 +177,13 @@<br>
><br>
><br>
> class MvmModule {<br>
> -private:<br>
> -   static llvm::ExecutionEngine* executionEngine;<br>
> -<br>
> public:<br>
>    static llvm::GCStrategy* TheGCStrategy;<br>
>    static mvm::LockRecursive protectEngine;<br>
>    static llvm::Module *globalModule;<br>
>    static const llvm::TargetData* TheTargetData;<br>
>    static mvm::BumpPtrAllocator* Allocator;<br>
> +   static llvm::ExecutionEngine* executionEngine;<br>
>    //static unsigned MetadataTypeKind;<br>
><br>
>    static uint64 getTypeSize(const llvm::Type* type);<br>
> @@ -209,6 +208,7 @@<br>
> public:<br>
>   virtual void scan(uintptr_t closure, void* ip, void* addr);<br>
>   JITMethodInfo(llvm::GCFunctionInfo* GFI) : GCInfo(GFI) {}<br>
> +  void addToVM(VirtualMachine* vm, llvm::JIT* jit);<br>
> };<br>
><br>
> class MvmJITMethodInfo : public JITMethodInfo {<br>
><br>
> Modified: vmkit/branches/precise/include/mvm/MethodInfo.h<br>
> URL:<br>
> <a href="http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/mvm/MethodInfo.h?rev=113706&r1=113705&r2=113706&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/mvm/MethodInfo.h?rev=113706&r1=113705&r2=113706&view=diff</a><br>

><br>
> ==============================================================================<br>
> --- vmkit/branches/precise/include/mvm/MethodInfo.h (original)<br>
> +++ vmkit/branches/precise/include/mvm/MethodInfo.h Sat Sep 11 17:33:49 2010<br>
> @@ -29,7 +29,6 @@<br>
>   void* getMetaInfo() const { return MetaInfo; }<br>
><br>
>   unsigned MethodType;<br>
> -  void* InstructionPointer;<br>
>   void* MetaInfo;<br>
> };<br>
><br>
> @@ -45,15 +44,15 @@<br>
> public:<br>
>   CamlFrame* CF;<br>
>   virtual void scan(uintptr_t closure, void* ip, void* addr);<br>
> -  CamlMethodInfo(CamlFrame* C, void* ip);<br>
> +  CamlMethodInfo(CamlFrame* C) : CF(C) { }<br>
> };<br>
><br>
> class StaticCamlMethodInfo : public CamlMethodInfo {<br>
>   const char* name;<br>
> public:<br>
>   virtual void print(void* ip, void* addr);<br>
> -  StaticCamlMethodInfo(CamlFrame* CF, void* ip, const char* n) :<br>
> -    CamlMethodInfo(CF, ip) {<br>
> +  StaticCamlMethodInfo(CamlFrame* CF, const char* n) :<br>
> +    CamlMethodInfo(CF) {<br>
>     name = n;<br>
>     MethodType = 0;<br>
>   }<br>
><br>
> Modified: vmkit/branches/precise/include/mvm/VirtualMachine.h<br>
> URL:<br>
> <a href="http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/mvm/VirtualMachine.h?rev=113706&r1=113705&r2=113706&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/mvm/VirtualMachine.h?rev=113706&r1=113705&r2=113706&view=diff</a><br>

><br>
> ==============================================================================<br>
> --- vmkit/branches/precise/include/mvm/VirtualMachine.h (original)<br>
> +++ vmkit/branches/precise/include/mvm/VirtualMachine.h Sat Sep 11 17:33:49 2010<br>
> @@ -48,79 +48,16 @@<br>
><br>
>   /// IPToMethodInfo - Map a code start instruction instruction to the<br>
> MethodInfo.<br>
>   ///<br>
> -  MethodInfo* CodeStartToMethodInfo(void* ip) {<br>
> -    FunctionMapLock.acquire();<br>
> -    std::map<void*, MethodInfo*>::iterator I = Functions.find(ip);<br>
> -    MethodInfo* res = NULL;<br>
> -    if (I != Functions.end()) {<br>
> -      res = I->second;<br>
> -    }<br>
> -    FunctionMapLock.release();<br>
> -    return res;<br>
> -  }<br>
> -};<br>
> -<br>
> -/// StartEndFunctionMap - This map is for functions for which we have<br>
> -/// a start and end address.<br>
> -///<br>
> -class StartEndFunctionMap : public FunctionMap {<br>
> -public:<br>
> -  /// addMethodInFunctionMap - A new method pointer in the function map.<br>
> -  ///<br>
> -  void addMethodInfo(MethodInfo* meth, void* start, void* end) {<br>
> -    FunctionMapLock.acquire();<br>
> -    Functions.insert(std::make_pair(start, meth));<br>
> -    Functions.insert(std::make_pair(end, meth));<br>
> -    FunctionMapLock.release();<br>
> -  }<br>
> -<br>
> -  /// IPToMethodInfo - Map an instruction pointer to the MethodInfo.<br>
> -  ///<br>
> -  MethodInfo* IPToMethodInfo(void* ip) {<br>
> -    FunctionMapLock.acquire();<br>
> -    std::map<void*, MethodInfo*>::iterator I = Functions.upper_bound(ip);<br>
> -    MethodInfo* res = 0;<br>
> -    if (I != Functions.end() && I != Functions.begin()) {<br>
> -      res = I->second;<br>
> -      if ((--I)->second != res) res = 0;<br>
> -    }<br>
> -    FunctionMapLock.release();<br>
> -    return res;<br>
> -  }<br>
> -};<br>
> -<br>
> -/// StartFunctionMap - This map is for static functions where getting an end<br>
> -/// address is cumbersome.<br>
> -///<br>
> -class StartFunctionMap : public FunctionMap {<br>
> -public:<br>
> -  /// addMethodInFunctionMap - A new method pointer in the function map.<br>
> -  ///<br>
> -  void addMethodInfo(MethodInfo* meth, void* addr) {<br>
> -    FunctionMapLock.acquire();<br>
> -    Functions.insert(std::make_pair((void*)addr, meth));<br>
> -    FunctionMapLock.release();<br>
> -  }<br>
> -<br>
> -  /// IPToMethodInfo - Map an instruction pointer to the MethodInfo.<br>
> -  ///<br>
>   MethodInfo* IPToMethodInfo(void* ip);<br>
> -<br>
> -};<br>
><br>
> -class SharedStartFunctionMap : public StartFunctionMap {<br>
> -public:<br>
> -  BumpPtrAllocator* StaticAllocator;<br>
> -  bool initialized;<br>
> -  SharedStartFunctionMap() {<br>
> -    initialized = false;<br>
> -  }<br>
> +  /// addMethodInfo - A new instruction pointer in the function map.<br>
> +  ///<br>
> +  void addMethodInfo(MethodInfo* meth, void* ip);<br>
><br>
> -  void initialize();<br>
> +  FunctionMap();<br>
> };<br>
><br>
><br>
> -<br>
> // Same values than JikesRVM<br>
> #define INITIAL_QUEUE_SIZE 256<br>
> #define GROW_FACTOR 2<br>
> @@ -232,7 +169,6 @@<br>
><br>
>     mainThread = 0;<br>
>     NumberOfThreads = 0;<br>
> -    if (!SharedStaticFunctions.initialized) SharedStaticFunctions.initialize();<br>
>   }<br>
> public:<br>
><br>
> @@ -529,13 +465,10 @@<br>
>   UncooperativeCollectionRV rendezvous;<br>
> #endif<br>
><br>
> -<br>
> -  StartEndFunctionMap RuntimeFunctions;<br>
> -  static StartEndFunctionMap SharedRuntimeFunctions;<br>
> -  StartFunctionMap StaticFunctions;<br>
> -  static SharedStartFunctionMap SharedStaticFunctions;<br>
> -<br>
> -  MethodInfo* IPToMethodInfo(void* ip);<br>
> +  FunctionMap FunctionsCache;<br>
> +  MethodInfo* IPToMethodInfo(void* ip) {<br>
> +    return FunctionsCache.IPToMethodInfo(ip);<br>
> +  }<br>
><br>
> #ifdef ISOLATE<br>
>   size_t IsolateID;<br>
><br>
> Modified: vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp<br>
> URL:<br>
> <a href="http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp?rev=113706&r1=113705&r2=113706&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp?rev=113706&r1=113705&r2=113706&view=diff</a><br>

><br>
> ==============================================================================<br>
> --- vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp (original)<br>
> +++ vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp Sat Sep 11<br>
> 17:33:49 2010<br>
> @@ -55,10 +55,16 @@<br>
>   if (ip) new_ip = isStub(ip, addr);<br>
>   JavaMethod* meth = (JavaMethod*)MetaInfo;<br>
>   CodeLineInfo* info = meth->lookupCodeLineInfo((uintptr_t)ip);<br>
> -  fprintf(stderr, "; %p in %s.%s (line %d, bytecode %d, code start %p)",<br>
> new_ip,<br>
> -          UTF8Buffer(meth->classDef->name).cString(),<br>
> -          UTF8Buffer(meth->name).cString(), info->lineNumber,<br>
> -          info->bytecodeIndex, meth->code);<br>
> +  if (info != NULL) {<br>
> +    fprintf(stderr, "; %p in %s.%s (line %d, bytecode %d, code start %p)",<br>
> new_ip,<br>
> +            UTF8Buffer(meth->classDef->name).cString(),<br>
> +            UTF8Buffer(meth->name).cString(), info->lineNumber,<br>
> +            info->bytecodeIndex, meth->code);<br>
> +  } else {<br>
> +    fprintf(stderr, "; %p in %s.%s (native method, code start %p)", new_ip,<br>
> +            UTF8Buffer(meth->classDef->name).cString(),<br>
> +            UTF8Buffer(meth->name).cString(), meth->code);<br>
> +  }<br>
>   if (ip != new_ip) fprintf(stderr, " (from stub)");<br>
>   fprintf(stderr, "\n");<br>
> }<br>
> @@ -71,41 +77,39 @@<br>
>   // The following could be changed to an assert when -load-bc supports<br>
>   // the verifier.<br>
>   if (F.getParent() != TheCompiler->getLLVMModule()) return;<br>
> +  assert(F.hasGC());<br>
><br>
>   Jnjvm* vm = JavaThread::get()->getJVM();<br>
>   mvm::BumpPtrAllocator& Alloc = TheCompiler->allocator;<br>
> -  llvm::GCFunctionInfo* GFI = 0;<br>
><br>
> -  if (F.hasGC()) {<br>
> -    if (TheCompiler->TheGCStrategy == NULL) {<br>
> -      assert(mvm::MvmModule::TheGCStrategy != NULL && "No GC strategy");<br>
> -      TheCompiler->TheGCStrategy = mvm::MvmModule::TheGCStrategy;<br>
> -      mvm::MvmModule::TheGCStrategy = NULL;<br>
> -    }<br>
> -    GCStrategy::iterator I = TheCompiler->TheGCStrategy->end();<br>
> +  // Fetch the GCStrategy if it wasn't created before.<br>
> +  if (TheCompiler->TheGCStrategy == NULL) {<br>
> +    assert(mvm::MvmModule::TheGCStrategy != NULL && "No GC strategy");<br>
> +    TheCompiler->TheGCStrategy = mvm::MvmModule::TheGCStrategy;<br>
> +    mvm::MvmModule::TheGCStrategy = NULL;<br>
> +  }<br>
> +<br>
> +  GCStrategy::iterator I = TheCompiler->TheGCStrategy->end();<br>
> +  I--;<br>
> +  while (&(*I)->getFunction() != &F) {<br>
> +    // This happens when the compilation of a function was post-poned.<br>
> +    assert(I != TheCompiler->TheGCStrategy->begin() && "No GC info");<br>
>     I--;<br>
> -    while (&(*I)->getFunction() != &F) {<br>
> -      // This happens when the compilation of a function was post-poned.<br>
> -      assert(I != TheCompiler->TheGCStrategy->begin() && "No GC info");<br>
> -      I--;<br>
> -    }<br>
> -    assert(&(*I)->getFunction() == &F &&<br>
> -        "GC Info and method do not correspond");<br>
> -    GFI = *I;<br>
>   }<br>
> +  assert(&(*I)->getFunction() == &F && "GC Info and method do not correspond");<br>
> +  llvm::GCFunctionInfo* GFI = *I;<br>
><br>
>   JavaMethod* meth = TheCompiler->getJavaMethod(F);<br>
> +  mvm::JITMethodInfo* MI = NULL;<br>
>   if (meth == NULL) {<br>
>     // This is a stub.<br>
> -    mvm::MvmJITMethodInfo* MI = new(Alloc, "JITMethodInfo")<br>
> -      mvm::MvmJITMethodInfo(GFI, &F);<br>
> -    vm->RuntimeFunctions.addMethodInfo(MI, Code,<br>
> -                                       (void*)((uintptr_t)Code + Size));<br>
> +    MI = new(Alloc, "JITMethodInfo") mvm::MvmJITMethodInfo(GFI, &F);<br>
>   } else {<br>
> -    JavaJITMethodInfo* MI = new(Alloc, "JavaJITMethodInfo")<br>
> -      JavaJITMethodInfo(GFI, meth);<br>
> -    vm->RuntimeFunctions.addMethodInfo(MI, Code,<br>
> -                                       (void*)((uintptr_t)Code + Size));<br>
> +    MI = new(Alloc, "JavaJITMethodInfo") JavaJITMethodInfo(GFI, meth);<br>
> +  }<br>
> +  MI->addToVM(vm, (JIT*)TheCompiler->executionEngine);<br>
> +<br>
> +  if (meth != NULL) {<br>
>     uint32 infoLength = Details.LineStarts.size();<br>
>     meth->codeInfoLength = infoLength;<br>
>     if (infoLength > 0) {<br>
><br>
> Modified: vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp<br>
> URL:<br>
> <a href="http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp?rev=113706&r1=113705&r2=113706&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp?rev=113706&r1=113705&r2=113706&view=diff</a><br>

><br>
> ==============================================================================<br>
> --- vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp (original)<br>
> +++ vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp Sat Sep 11 17:33:49 2010<br>
> @@ -169,9 +169,7 @@<br>
>                                         "", Compiler->getLLVMModule());<br>
>     }<br>
><br>
> -    if (Compiler->useCooperativeGC()) {<br>
> -      methodFunction->setGC("vmkit");<br>
> -    }<br>
> +    methodFunction->setGC("vmkit");<br>
><br>
>     Compiler->functions.insert(std::make_pair(methodFunction, methodDef));<br>
>     if (Compiler != JCL->getCompiler() && methodDef->code) {<br>
> @@ -404,10 +402,13 @@<br>
><br>
>   Value* val = CallInst::Create(func, Args.begin(), Args.end(), "",<br>
>                                 currentBlock);<br>
> -  if (!signature->getReturnType()->isVoid())<br>
> +  if (!signature->getReturnType()->isVoid()) {<br>
>     ReturnInst::Create(context, val, currentBlock);<br>
> -  else<br>
> +  } else {<br>
>     ReturnInst::Create(context, currentBlock);<br>
> +  }<br>
> +<br>
> +  res->setGC("vmkit");<br>
><br>
>   return res;<br>
> }<br>
> @@ -481,15 +482,14 @@<br>
><br>
>   Value* val = CallInst::Create(func, Args.begin(), Args.end(), "",<br>
>                                 currentBlock);<br>
> -  if (!signature->getReturnType()->isVoid())<br>
> +  if (!signature->getReturnType()->isVoid()) {<br>
>     ReturnInst::Create(context, val, currentBlock);<br>
> -  else<br>
> +  } else {<br>
>     ReturnInst::Create(context, currentBlock);<br>
> -<br>
> -  if (Compiler->useCooperativeGC()) {<br>
> -    res->setGC("vmkit");<br>
>   }<br>
><br>
> +  res->setGC("vmkit");<br>
> +<br>
>   return res;<br>
> }<br>
><br>
> @@ -545,7 +545,7 @@<br>
>   if (virt) {<br>
>     if (Compiler->useCooperativeGC()) {<br>
>       Args.push_back(new LoadInst(TempArgs[0], "", false, currentBlock));<br>
> -    }else {<br>
> +    } else {<br>
>       Args.push_back(TempArgs[0]);<br>
>     }<br>
>   }<br>
> @@ -587,9 +587,7 @@<br>
>     ReturnInst::Create(context, currentBlock);<br>
>   }<br>
><br>
> -  if (Compiler->useCooperativeGC()) {<br>
> -    stub->setGC("vmkit");<br>
> -  }<br>
> +  stub->setGC("vmkit");<br>
><br>
>   return stub;<br>
> }<br>
><br>
> Modified: vmkit/branches/precise/lib/J3/VMCore/JavaClass.h<br>
> URL:<br>
> <a href="http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JavaClass.h?rev=113706&r1=113705&r2=113706&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JavaClass.h?rev=113706&r1=113705&r2=113706&view=diff</a><br>

><br>
> ==============================================================================<br>
> --- vmkit/branches/precise/lib/J3/VMCore/JavaClass.h (original)<br>
> +++ vmkit/branches/precise/lib/J3/VMCore/JavaClass.h Sat Sep 11 17:33:49 2010<br>
> @@ -902,7 +902,7 @@<br>
>   virtual void print(void* ip, void* addr);<br>
><br>
>   JavaStaticMethodInfo(mvm::CamlMethodInfo* super, void* ip, JavaMethod* M) :<br>
> -    mvm::CamlMethodInfo(super != NULL ? super->CF : NULL, ip) {<br>
> +    mvm::CamlMethodInfo(super->CF) {<br>
>     MetaInfo = M;<br>
>     MethodType = 1;<br>
>   }<br>
><br>
> Modified: vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp<br>
> URL:<br>
> <a href="http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp?rev=113706&r1=113705&r2=113706&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp?rev=113706&r1=113705&r2=113706&view=diff</a><br>

><br>
> ==============================================================================<br>
> --- vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp (original)<br>
> +++ vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp Sat Sep 11 17:33:49 2010<br>
> @@ -1487,8 +1487,7 @@<br>
> }<br>
><br>
> void Jnjvm::removeMethodsInFunctionMaps(JnjvmClassLoader* loader) {<br>
> -  internalRemoveMethods(loader, RuntimeFunctions);<br>
> -  internalRemoveMethods(loader, StaticFunctions);<br>
> +  internalRemoveMethods(loader, FunctionsCache);<br>
> }<br>
><br>
><br>
><br>
> Modified: vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp<br>
> URL:<br>
> <a href="http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp?rev=113706&r1=113705&r2=113706&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp?rev=113706&r1=113705&r2=113706&view=diff</a><br>

><br>
> ==============================================================================<br>
> --- vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp (original)<br>
> +++ vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp Sat Sep 11<br>
> 17:33:49 2010<br>
> @@ -1073,7 +1073,7 @@<br>
>         if (!isAbstract(meth.access) && meth.code) {<br>
>           JavaStaticMethodInfo* MI = new (allocator, "JavaStaticMethodInfo")<br>
>             JavaStaticMethodInfo(0, meth.code, &meth);<br>
> -          vm->StaticFunctions.addMethodInfo(MI, meth.code);<br>
> +          vm->FunctionsCache.addMethodInfo(MI, meth.code);<br>
>         }<br>
>       }<br>
><br>
> @@ -1082,7 +1082,7 @@<br>
>         if (!isAbstract(meth.access) && meth.code) {<br>
>           JavaStaticMethodInfo* MI = new (allocator, "JavaStaticMethodInfo")<br>
>             JavaStaticMethodInfo(0, meth.code, &meth);<br>
> -          vm->StaticFunctions.addMethodInfo(MI, meth.code);<br>
> +          vm->FunctionsCache.addMethodInfo(MI, meth.code);<br>
>         }<br>
>       }<br>
>     }<br>
><br>
> Modified: vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp<br>
> URL:<br>
> <a href="http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp?rev=113706&r1=113705&r2=113706&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp?rev=113706&r1=113705&r2=113706&view=diff</a><br>

><br>
> ==============================================================================<br>
> --- vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp (original)<br>
> +++ vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp Sat Sep 11 17:33:49 2010<br>
> @@ -22,6 +22,7 @@<br>
> #include <llvm/Analysis/Verifier.h><br>
> #include <llvm/Assembly/Parser.h><br>
> #include <llvm/CodeGen/GCStrategy.h><br>
> +#include <llvm/CodeGen/JITCodeEmitter.h><br>
> #include <llvm/Config/config.h><br>
> #include <llvm/ExecutionEngine/ExecutionEngine.h><br>
> #include "llvm/ExecutionEngine/JITEventListener.h"<br>
> @@ -35,6 +36,7 @@<br>
> #include <llvm/Target/TargetMachine.h><br>
> #include <llvm/Target/TargetOptions.h><br>
> #include <llvm/Target/TargetSelect.h><br>
> +#include <../lib/ExecutionEngine/JIT/JIT.h><br>
><br>
> #include "mvm/JIT.h"<br>
> #include "mvm/Threads/Locks.h"<br>
> @@ -93,24 +95,33 @@<br>
>                                      void *Code, size_t Size,<br>
>                                      const EmittedFunctionDetails &Details) {<br>
>     assert(F.getParent() == MvmModule::globalModule);<br>
> -    llvm::GCFunctionInfo* GFI = 0;<br>
> +    assert(F.hasGC());<br>
>     // We know the last GC info is for this method.<br>
> -    if (F.hasGC()) {<br>
> -      GCStrategy::iterator I = mvm::MvmModule::TheGCStrategy->end();<br>
> -      I--;<br>
> -      DEBUG(errs() << (*I)->getFunction().getName() << '\n');<br>
> -      DEBUG(errs() << F.getName() << '\n');<br>
> -      assert(&(*I)->getFunction() == &F &&<br>
> +    GCStrategy::iterator I = mvm::MvmModule::TheGCStrategy->end();<br>
> +    I--;<br>
> +    DEBUG(errs() << (*I)->getFunction().getName() << '\n');<br>
> +    DEBUG(errs() << F.getName() << '\n');<br>
> +    assert(&(*I)->getFunction() == &F &&<br>
>         "GC Info and method do not correspond");<br>
> -      GFI = *I;<br>
> -    }<br>
> -    MethodInfo* MI =<br>
> +    llvm::GCFunctionInfo* GFI = *I;<br>
> +    JITMethodInfo* MI =<br>
>       new(*MvmModule::Allocator, "MvmJITMethodInfo") MvmJITMethodInfo(GFI, &F);<br>
> -    VirtualMachine::SharedRuntimeFunctions.addMethodInfo(MI, Code,<br>
> -                                            (void*)((uintptr_t)Code + Size));<br>
> +    MI->addToVM(mvm::Thread::get()->MyVM, (JIT*)MvmModule::executionEngine);<br>
>   }<br>
> };<br>
><br>
> +void JITMethodInfo::addToVM(VirtualMachine* VM, JIT* jit) {<br>
> +  JITCodeEmitter* JCE = jit->getCodeEmitter();<br>
> +  assert(GCInfo != NULL);<br>
> +  for (GCFunctionInfo::iterator I = GCInfo->begin(), E = GCInfo->end();<br>
> +       I != E;<br>
> +       I++) {<br>
> +    uintptr_t address = JCE->getLabelAddress(I->Label);<br>
> +    assert(address != 0);<br>
> +    VM->FunctionsCache.addMethodInfo(this, (void*)address);<br>
> +  }<br>
> +}<br>
> +<br>
> static MvmJITListener JITListener;<br>
><br>
> void MvmModule::loadBytecodeFile(const std::string& str) {<br>
> @@ -317,6 +328,7 @@<br>
>   unconditionalSafePoint = module->getFunction("unconditionalSafePoint");<br>
>   conditionalSafePoint = module->getFunction("conditionalSafePoint");<br>
>   AllocateFunction = module->getFunction("gcmalloc");<br>
> +  AllocateFunction->setGC("vmkit");<br>
>   assert(AllocateFunction && "No allocate function");<br>
>   AllocateUnresolvedFunction = module->getFunction("gcmallocUnresolved");<br>
>   assert(AllocateUnresolvedFunction && "No allocateUnresolved function");<br>
><br>
> Modified: vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp<br>
> URL:<br>
> <a href="http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp?rev=113706&r1=113705&r2=113706&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp?rev=113706&r1=113705&r2=113706&view=diff</a><br>

><br>
> ==============================================================================<br>
> --- vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp (original)<br>
> +++ vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp Sat Sep 11 17:33:49<br>
> 2010<br>
> @@ -24,19 +24,11 @@<br>
> using namespace mvm;<br>
><br>
> void CamlMethodInfo::scan(uintptr_t closure, void* ip, void* addr) {<br>
> -  if (!CF && InstructionPointer) {<br>
> -    MethodInfo* MI = VirtualMachine::SharedStaticFunctions.IPToMethodInfo(ip);<br>
> -    if (MI != &DefaultMethodInfo::DM) {<br>
> -      CF = ((CamlMethodInfo*)MI)->CF;<br>
> -    }<br>
> -  }<br>
> -<br>
> -  if (CF) {<br>
> -    //uintptr_t spaddr = (uintptr_t)addr + CF->FrameSize + sizeof(void*);<br>
> -    uintptr_t spaddr = ((uintptr_t*)addr)[0];<br>
> -    for (uint16 i = 0; i < CF->NumLiveOffsets; ++i) {<br>
> -      Collector::scanObject((void**)(spaddr + CF->LiveOffsets[i]), closure);<br>
> -    }<br>
> +  assert(CF != NULL);<br>
> +  //uintptr_t spaddr = (uintptr_t)addr + CF->FrameSize + sizeof(void*);<br>
> +  uintptr_t spaddr = ((uintptr_t*)addr)[0];<br>
> +  for (uint16 i = 0; i < CF->NumLiveOffsets; ++i) {<br>
> +    Collector::scanObject((void**)(spaddr + CF->LiveOffsets[i]), closure);<br>
>   }<br>
> }<br>
><br>
> @@ -59,52 +51,6 @@<br>
> void DefaultMethodInfo::scan(uintptr_t closure, void* ip, void* addr) {<br>
> }<br>
><br>
> -<br>
> -MethodInfo* StartFunctionMap::IPToMethodInfo(void* ip) {<br>
> -  FunctionMapLock.acquire();<br>
> -  std::map<void*, MethodInfo*>::iterator E = Functions.end();<br>
> -  std::map<void*, MethodInfo*>::iterator I = Functions.find(ip);<br>
> -  MethodInfo* MI = 0;<br>
> -  if (I == E) {<br>
> -    Dl_info info;<br>
> -    int res = dladdr(ip, &info);<br>
> -    if (res != 0) {<br>
> -      I = Functions.find(info.dli_saddr);<br>
> -      if (I == E) {<br>
> -        // The method is static, and we have no information for it.<br>
> -        // Just return the Default MethodInfo object.<br>
> -        MI = &DefaultMethodInfo::DM;<br>
> -      } else {<br>
> -        MI = I->second;<br>
> -      }<br>
> -    } else {<br>
> -      // The method is jitted, and no-one has intercepted its compilation.<br>
> -      // Just return the Default MethodInfo object.<br>
> -      MI = &DefaultMethodInfo::DM;<br>
> -    }<br>
> -    // Add it to the map, so that we don't need to call dladdr again.<br>
> -    Functions.insert(std::make_pair(ip, MI));<br>
> -  } else {<br>
> -    MI = I->second;<br>
> -  }<br>
> -  FunctionMapLock.release();<br>
> -  return MI;<br>
> -}<br>
> -<br>
> -MethodInfo* VirtualMachine::IPToMethodInfo(void* ip) {<br>
> -  MethodInfo* MI = RuntimeFunctions.IPToMethodInfo(ip);<br>
> -  if (MI) return MI;<br>
> -<br>
> -  MI = SharedRuntimeFunctions.IPToMethodInfo(ip);<br>
> -  if (MI) return MI;<br>
> -<br>
> -  MI = StaticFunctions.IPToMethodInfo(ip);<br>
> -  if (MI != &DefaultMethodInfo::DM) return MI;<br>
> -<br>
> -  MI = SharedStaticFunctions.IPToMethodInfo(ip);<br>
> -  return MI;<br>
> -}<br>
> -<br>
> struct CamlFrames {<br>
>   uint16_t NumDescriptors;<br>
>   CamlFrame frames[1];<br>
> @@ -114,14 +60,11 @@<br>
>   CamlFrames* frames ;<br>
>   uint32 currentDescriptor;<br>
>   CamlFrame* currentFrame;<br>
> -  Dl_info info;<br>
><br>
>   CamlFrameDecoder(CamlFrames* frames) {<br>
>     this->frames = frames;<br>
>     currentDescriptor = 0;<br>
>     currentFrame = &(frames->frames[0]);<br>
> -    int res = dladdr(currentFrame->ReturnAddress, &info);<br>
> -    assert(res != 0 && "No frame");<br>
>   }<br>
><br>
>   bool hasNext() {<br>
> @@ -135,55 +78,51 @@<br>
>       (currentFrame->NumLiveOffsets % 2) * sizeof(uint16_t) +<br>
>       currentFrame->NumLiveOffsets * sizeof(uint16_t) +<br>
>       sizeof(void*) + sizeof(uint16_t) + sizeof(uint16_t));<br>
> -    int res = dladdr(currentFrame->ReturnAddress, &info);<br>
> -    assert(res != 0 && "No frame");<br>
>   }<br>
><br>
> -  CamlFrame* next(void** funcAddress, const char** funcName) {<br>
> +  CamlFrame* next() {<br>
>     assert(hasNext());<br>
>     CamlFrame* result = currentFrame;<br>
> -    *funcAddress = info.dli_saddr;<br>
> -    *funcName = info.dli_sname;<br>
> -<br>
> -    // Skip the remaining ones.<br>
> -    do {<br>
> -      advance();<br>
> -    } while (hasNext() && (info.dli_saddr == *funcAddress));<br>
> -<br>
> -    // Skip the entries that start at another method.<br>
> -    while (hasNext() && (info.dli_saddr == currentFrame->ReturnAddress)) {<br>
> -      advance();<br>
> -    }<br>
> -<br>
> -    while (hasNext() && (info.dli_saddr == NULL)) {<br>
> -      advance();<br>
> -    }<br>
> +    advance();<br>
>     return result;<br>
>   }<br>
> };<br>
><br>
> -void SharedStartFunctionMap::initialize() {<br>
> +static BumpPtrAllocator* StaticAllocator = NULL;<br>
> +<br>
> +FunctionMap::FunctionMap() {<br>
>   CamlFrames* frames =<br>
>     (CamlFrames*)dlsym(SELF_HANDLE, "camlVmkitoptimized__frametable");<br>
> +  if (frames == NULL) return;<br>
> +<br>
>   StaticAllocator = new BumpPtrAllocator();<br>
> -  const char* name = NULL;<br>
> -  void* address = NULL;<br>
> -<br>
> -  if (frames != NULL) {<br>
> -    CamlFrameDecoder decoder(frames);<br>
> -    while (decoder.hasNext()) {<br>
> -      CamlFrame* frame = decoder.next(&address, &name);<br>
> -      StaticCamlMethodInfo* MI = new(*StaticAllocator, "StaticCamlMethodInfo")<br>
> -          StaticCamlMethodInfo(frame, address, name);<br>
> -      addMethodInfo(MI, address);<br>
> -    }<br>
> +  CamlFrameDecoder decoder(frames);<br>
> +  Dl_info info;<br>
> +  while (decoder.hasNext()) {<br>
> +    CamlFrame* frame = decoder.next();<br>
> +    int res = dladdr(frame->ReturnAddress, &info);<br>
> +    assert(res != 0 && "No frame");<br>
> +    StaticCamlMethodInfo* MI = new(*StaticAllocator, "StaticCamlMethodInfo")<br>
> +        StaticCamlMethodInfo(frame, info.dli_sname);<br>
> +    addMethodInfo(MI, frame->ReturnAddress);<br>
>   }<br>
> }<br>
><br>
> -CamlMethodInfo::CamlMethodInfo(CamlFrame* C, void* ip) {<br>
> -  InstructionPointer = ip;<br>
> -  CF = C;<br>
> +MethodInfo* FunctionMap::IPToMethodInfo(void* ip) {<br>
> +  FunctionMapLock.acquire();<br>
> +  std::map<void*, MethodInfo*>::iterator I = Functions.find(ip);<br>
> +  MethodInfo* res = NULL;<br>
> +  if (I != Functions.end()) {<br>
> +    res = I->second;<br>
> +  } else {<br>
> +    res = &DefaultMethodInfo::DM;<br>
> +  }<br>
> +  FunctionMapLock.release();<br>
> +  return res;<br>
> }<br>
><br>
> -StartEndFunctionMap VirtualMachine::SharedRuntimeFunctions;<br>
> -SharedStartFunctionMap VirtualMachine::SharedStaticFunctions;<br>
> +void FunctionMap::addMethodInfo(MethodInfo* meth, void* ip) {<br>
> +  FunctionMapLock.acquire();<br>
> +  Functions.insert(std::make_pair(ip, meth));<br>
> +  FunctionMapLock.release();<br>
> +}<br>
><br>
><br>
><br>
><br>
> ------------------------------<br>
><br>
> _______________________________________________<br>
> vmkit-commits mailing list<br>
> <a href="mailto:vmkit-commits@cs.uiuc.edu">vmkit-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits</a><br>
><br>
><br>
> End of vmkit-commits Digest, Vol 28, Issue 2<br>
> ********************************************<br>
><br>
><br>
><br>
><br>
> _______________________________________________<br>
> vmkit-commits mailing list<br>
> <a href="mailto:vmkit-commits@cs.uiuc.edu">vmkit-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits</a><br>
><br>
</div></div><br>_______________________________________________<br>
vmkit-commits mailing list<br>
<a href="mailto:vmkit-commits@cs.uiuc.edu">vmkit-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits</a><br>
<br></blockquote></div><br></div>