[llvm-commits] [llvm] r131305 - /llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp

Jim Grosbach grosbach at apple.com
Fri May 13 13:12:14 PDT 2011


Author: grosbach
Date: Fri May 13 15:12:14 2011
New Revision: 131305

URL: http://llvm.org/viewvc/llvm-project?rev=131305&view=rev
Log:
Teach the RtDyld to tell the memory manager about how much space a function
actually takes rather than how much memory was allocated for it. This
is more accurate and should help the manager pack things more effectively.

Modified:
    llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp

Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=131305&r1=131304&r2=131305&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Fri May 13 15:12:14 2011
@@ -129,18 +129,19 @@
                                       uint8_t *EndAddress) {
   // Allocate memory for the function via the memory manager.
   uintptr_t Size = EndAddress - StartAddress + 1;
-  uint8_t *Mem = MemMgr->startFunctionBody(Name.data(), Size);
+  uintptr_t AllocSize = Size;
+  uint8_t *Mem = MemMgr->startFunctionBody(Name.data(), AllocSize);
   assert(Size >= (uint64_t)(EndAddress - StartAddress + 1) &&
          "Memory manager failed to allocate enough memory!");
   // Copy the function payload into the memory block.
-  memcpy(Mem, StartAddress, EndAddress - StartAddress + 1);
+  memcpy(Mem, StartAddress, Size);
   MemMgr->endFunctionBody(Name.data(), Mem, Mem + Size);
   // Remember where we put it.
   Functions[Name] = sys::MemoryBlock(Mem, Size);
   // Default the assigned address for this symbol to wherever this
   // allocated it.
   SymbolTable[Name] = Mem;
-  DEBUG(dbgs() << "    allocated to " << Mem << "\n");
+  DEBUG(dbgs() << "    allocated to [" << Mem << ", " << Mem + Size << "]\n");
 }
 
 bool RuntimeDyldImpl::





More information about the llvm-commits mailing list