[vmkit-commits] [vmkit] r60536 - /vmkit/trunk/lib/Mvm/Runtime/EscapeAnalysis.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Thu Dec 4 05:36:01 PST 2008


Author: geoffray
Date: Thu Dec  4 07:35:59 2008
New Revision: 60536

URL: http://llvm.org/viewvc/llvm-project?rev=60536&view=rev
Log:
don't allocate objects of more than a page size on stack.


Modified:
    vmkit/trunk/lib/Mvm/Runtime/EscapeAnalysis.cpp

Modified: vmkit/trunk/lib/Mvm/Runtime/EscapeAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Runtime/EscapeAnalysis.cpp?rev=60536&r1=60535&r2=60536&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/Runtime/EscapeAnalysis.cpp (original)
+++ vmkit/trunk/lib/Mvm/Runtime/EscapeAnalysis.cpp Thu Dec  4 07:35:59 2008
@@ -16,6 +16,7 @@
 #include "llvm/Support/Debug.h"
 
 #include <map>
+#include "unistd.h"
 
 #include "mvm/GC/GC.h"
 
@@ -26,9 +27,11 @@
   class VISIBILITY_HIDDEN EscapeAnalysis : public FunctionPass {
   public:
     static char ID;
+    uint64_t pageSize;
     EscapeAnalysis(Function* alloc = 0) : 
       FunctionPass((intptr_t)&ID) {
       Allocator = alloc;
+      pageSize = getpagesize();
     }
 
     virtual bool runOnFunction(Function &F);
@@ -112,10 +115,12 @@
   if (CE) {
     ConstantInt* C = (ConstantInt*)CE->getOperand(0);
     VirtualTable* Table = (VirtualTable*)C->getZExtValue();
+    ConstantInt* CI = dyn_cast<ConstantInt>(Size);
     // If the class has a finalize method, do not stack allocate the object.
-    if (!((void**)Table)[0]) {
+    if (!((void**)Table)[0] && CI) {
       std::map<Instruction*, bool> visited;
-      if (!(escapes(Alloc, visited))) {
+      uint64_t NSize = CI->getZExtValue();
+      if (NSize < pageSize && !(escapes(Alloc, visited))) {
         AllocaInst* AI = new AllocaInst(Type::Int8Ty, Size, "", Alloc);
         BitCastInst* BI = new BitCastInst(AI, Alloc->getType(), "", Alloc);
         DOUT << "escape" << Alloc->getParent()->getParent()->getName() << "\n";





More information about the vmkit-commits mailing list