[PATCH] D13630: [JIT] Towards a working small memory model

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 13 23:03:26 PDT 2015


lhames added a comment.

Hi David,

Excellent! This is exactly the kind of thing I was looking for - thank you.

What do you mean 'don't keep track of function memory / data memory' though? We may run in to issues for platforms that don't allow us to allocate RWX sections, in which case we'd have to make that distinction, but if we can get RWX memory I think we can just use one pool.

- Lang.


================
Comment at: tools/llvm-rtdyld/llvm-rtdyld.cpp:193-200
@@ +192,10 @@
+
+  uint8_t *allocateFromSlab(uintptr_t Size) {
+    if (CurrentSlabOffset + Size > SlabSize)
+      report_fatal_error("Can't allocate enough memory. Tune --preallocate");
+
+    uintptr_t OldSlabOffset = CurrentSlabOffset;
+    CurrentSlabOffset += Size;
+    return (uint8_t*)OldSlabOffset;
+  }
+
----------------
allocateFromSlab needs to respect the requested alignment. There's a RoundUpToAlignment function in MathExtras.h that you can use for this.

================
Comment at: tools/llvm-rtdyld/llvm-rtdyld.cpp:377-384
@@ -340,2 +376,10 @@
 
+  // Allocate a slab of memory upfront, if required. This is used if
+  // we want to test small code models.
+  if (PreallocMemory <= 0)
+    return Error("Pre-allocated bytes of memory must be a positive integer.");
+
+  // FIXME: Limit the amount of memory that can be preallocated?
+  MemMgr.preallocateSlab(PreallocMemory);
+
   // FIXME: Preserve buffers until resolveRelocations time to work around a bug
----------------
Can you add the preallocate call to linkAndVerify? We'll want it there too so we can write relocation verifier tests for the small code model.


Repository:
  rL LLVM

http://reviews.llvm.org/D13630





More information about the llvm-commits mailing list