[vmkit-commits] [vmkit] r84440 - in /vmkit/trunk/lib/Mvm: Compiler/JIT.cpp MMTk/MvmGC.cpp MMTk/MvmGC.h
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Sun Oct 18 13:53:30 PDT 2009
Author: geoffray
Date: Sun Oct 18 15:53:30 2009
New Revision: 84440
URL: http://llvm.org/viewvc/llvm-project?rev=84440&view=rev
Log:
Add calls to checkAllocator and postAlloc.
Modified:
vmkit/trunk/lib/Mvm/Compiler/JIT.cpp
vmkit/trunk/lib/Mvm/MMTk/MvmGC.cpp
vmkit/trunk/lib/Mvm/MMTk/MvmGC.h
Modified: vmkit/trunk/lib/Mvm/Compiler/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/JIT.cpp?rev=84440&r1=84439&r2=84440&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original)
+++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Sun Oct 18 15:53:30 2009
@@ -158,6 +158,12 @@
F = dyn_cast<Function>(GA->getAliasee());
gc::MMTkGCPostAllocator = (gc::MMTkPostAllocType)
(uintptr_t)executionEngine->getPointerToFunction(F);
+
+ GA = dyn_cast<GlobalAlias>(globalModule->getNamedValue("MMTkCheckAllocator"));
+ assert(GA && "Could not find MMTkCheckAllocator alias");
+ F = dyn_cast<Function>(GA->getAliasee());
+ gc::MMTkCheckAllocator = (gc::MMTkCheckAllocatorType)
+ (uintptr_t)executionEngine->getPointerToFunction(F);
}
#endif
}
Modified: vmkit/trunk/lib/Mvm/MMTk/MvmGC.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/MMTk/MvmGC.cpp?rev=84440&r1=84439&r2=84440&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/MMTk/MvmGC.cpp (original)
+++ vmkit/trunk/lib/Mvm/MMTk/MvmGC.cpp Sun Oct 18 15:53:30 2009
@@ -17,14 +17,15 @@
gc::MMTkAllocType gc::MMTkGCAllocator = 0;
gc::MMTkPostAllocType gc::MMTkGCPostAllocator = 0;
+gc::MMTkCheckAllocatorType gc::MMTkCheckAllocator = 0;
static std::set<gc*> Set;
static mvm::SpinLock lock;
-extern "C" gc* internalMalloc(uintptr_t Mutator, uint32_t sz, uint32_t align,
- uint32_t offset, uint32_t allocator,
- uint32_t site) {
+extern "C" gc* internalMalloc(uintptr_t Mutator, int32_t sz, int32_t align,
+ int32_t offset, int32_t allocator,
+ int32_t site) {
gc* res = (gc*)malloc(sz);
@@ -37,6 +38,11 @@
return res;
}
+extern "C" int internalCheckAllocator(uintptr_t Mutator, int32_t sz,
+ int32_t align, int32_t alloc) {
+ return 0;
+}
+
void* Collector::begOf(gc* obj) {
if (gc::MMTkGCAllocator == internalMalloc) {
lock.acquire();
@@ -57,6 +63,7 @@
void Collector::initialise() {
if (!gc::MMTkGCAllocator) {
gc::MMTkGCAllocator = internalMalloc;
+ gc::MMTkCheckAllocator = internalCheckAllocator;
MutatorThread::MMTkMutatorSize = 0;
MutatorThread::MMTkCollectorSize = 0;
MutatorThread::MutatorInit = fakeInit;
Modified: vmkit/trunk/lib/Mvm/MMTk/MvmGC.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/MMTk/MvmGC.h?rev=84440&r1=84439&r2=84440&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/MMTk/MvmGC.h (original)
+++ vmkit/trunk/lib/Mvm/MMTk/MvmGC.h Sun Oct 18 15:53:30 2009
@@ -15,6 +15,9 @@
#include "mvm/VirtualMachine.h"
#include "mvm/GC/GC.h"
+#include "llvm/Support/MathExtras.h"
+
+
#define gc_allocator std::allocator
#define gc_new(Class) __gc_new(Class::VT) Class
#define __gc_new new
@@ -40,23 +43,31 @@
return 0;
}
- typedef gc* (*MMTkAllocType)(uintptr_t Mutator, uint32_t sz, uint32_t align,
- uint32_t offset, uint32_t allocator,
- uint32_t site);
+ typedef gc* (*MMTkAllocType)(uintptr_t Mutator, int32_t sz, int32_t align,
+ int32_t offset, int32_t allocator,
+ int32_t site);
typedef gc* (*MMTkPostAllocType)(uintptr_t Mutator, uintptr_t ref,
- uintptr_t typeref, uint32_t bytes,
- uint32_t allocator);
+ uintptr_t typeref, int32_t bytes,
+ int32_t allocator);
+
+ typedef int (*MMTkCheckAllocatorType)(uintptr_t Mutator, int32_t bytes,
+ int32_t align, int32_t allocator);
static MMTkAllocType MMTkGCAllocator;
static MMTkPostAllocType MMTkGCPostAllocator;
+
+ static MMTkCheckAllocatorType MMTkCheckAllocator;
void* operator new(size_t sz, VirtualTable *VT) {
- gc* res = (gc*)MMTkGCAllocator(mvm::MutatorThread::get()->MutatorContext,
- sz, 0, 0, 0, 0);
+ sz = llvm::RoundUpToAlignment(sz, sizeof(void*));
+ uintptr_t Mutator = mvm::MutatorThread::get()->MutatorContext;
+ int allocator = MMTkCheckAllocator(Mutator, sz, 0, 0);
+ gc* res = (gc*)MMTkGCAllocator(Mutator, sz, 0, 0, allocator, 0);
res->setVirtualTable(VT);
+ MMTkGCPostAllocator(Mutator, (uintptr_t)res, (uintptr_t)VT, sz, allocator);
if (VT->destructor) {
mvm::Thread::get()->MyVM->addFinalizationCandidate(res);
More information about the vmkit-commits
mailing list