[vmkit-commits] [vmkit] r84094 - /vmkit/trunk/mmtk/magic/LowerJavaRT.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Wed Oct 14 04:51:12 PDT 2009
Author: geoffray
Date: Wed Oct 14 06:51:11 2009
New Revision: 84094
URL: http://llvm.org/viewvc/llvm-project?rev=84094&view=rev
Log:
Create aliases and global variables with simple names for VMKit/MMTk
interface.
Modified:
vmkit/trunk/mmtk/magic/LowerJavaRT.cpp
Modified: vmkit/trunk/mmtk/magic/LowerJavaRT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/mmtk/magic/LowerJavaRT.cpp?rev=84094&r1=84093&r2=84094&view=diff
==============================================================================
--- vmkit/trunk/mmtk/magic/LowerJavaRT.cpp (original)
+++ vmkit/trunk/mmtk/magic/LowerJavaRT.cpp Wed Oct 14 06:51:11 2009
@@ -16,10 +16,10 @@
#include "llvm/Support/CallSite.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/raw_ostream.h"
#include "jnjvm/JnjvmModule.h"
-#include <iostream>
using namespace llvm;
@@ -60,8 +60,68 @@
GV.eraseFromParent();
}
}
+
+ // Replace gcmalloc with the allocator of MMTk objects in VMKit
+ Function* F = M.getFunction("gcmalloc");
+
+ Function* NewFunction =
+ Function::Create(F->getFunctionType(), GlobalValue::ExternalLinkage,
+ "MMTkMutatorAllocate", &M);
+
+ F->replaceAllUsesWith(NewFunction);
+ F->eraseFromParent();
+
+ // Declare two global variables for allocating a MutatorContext object
+ // and a CollectorContext object.
+
+ const Type* Ty = IntegerType::getInt32Ty(M.getContext());
+ GlobalVariable* GV = M.getGlobalVariable("org_j3_config_Selected_4Collector",
+ false);
+ Constant* C = GV->getInitializer();
+ C = C->getOperand(1);
+ new GlobalVariable(M, Ty, true, GlobalValue::ExternalLinkage,
+ C, "MMTkCollectorSize");
+
+
+ GV = M.getGlobalVariable("org_j3_config_Selected_4Mutator", false);
+ C = GV->getInitializer();
+ C = C->getOperand(1);
+ new GlobalVariable(M, Ty, true, GlobalValue::ExternalLinkage,
+ C, "MMTkMutatorSize");
+
+
+ GV = M.getGlobalVariable("org_mmtk_plan_MutatorContext_VT", false);
+ ConstantArray* CA = dyn_cast<ConstantArray>(GV->getInitializer());
+
+ Function* Alloc = M.getFunction("JnJVM_org_mmtk_plan_MutatorContext_alloc__IIIII");
+ Function* PostAlloc = M.getFunction("JnJVM_org_mmtk_plan_MutatorContext_postAlloc__Lorg_vmmagic_unboxed_ObjectReference_2Lorg_vmmagic_unboxed_ObjectReference_2II");
+ uint32_t AllocIndex = 0;
+ uint32_t PostAllocIndex = 0;
+ for (uint32_t i = 0; i < CA->getNumOperands(); ++i) {
+ ConstantExpr* CE = dyn_cast<ConstantExpr>(CA->getOperand(i));
+ if (CE) {
+ C = CE->getOperand(0);
+ if (C == Alloc) {
+ AllocIndex = i;
+ } else if (C == PostAlloc) {
+ PostAllocIndex = i;
+ }
+ }
+ }
+ GV = M.getGlobalVariable("org_j3_config_Selected_4Mutator_VT", false);
+ CA = dyn_cast<ConstantArray>(GV->getInitializer());
+ C = CA->getOperand(AllocIndex);
+ C = C->getOperand(0);
+ new GlobalAlias(C->getType(), GlobalValue::ExternalLinkage, "MMTkAlloc",
+ C, &M);
+
+ C = CA->getOperand(PostAllocIndex);
+ C = C->getOperand(0);
+ new GlobalAlias(C->getType(), GlobalValue::ExternalLinkage, "MMTkPostAlloc",
+ C, &M);
+
return Changed;
}
More information about the vmkit-commits
mailing list