[vmkit-commits] [vmkit] r99545 - in /vmkit/trunk: Makefile Makefile.rules include/mvm/JIT.h lib/J3/Compiler/JavaAOTCompiler.cpp lib/Mvm/Compiler/JIT.cpp lib/Mvm/Compiler/MMTkInline.inc lib/Mvm/MMTk/MutatorThread.cpp lib/Mvm/MMTk/MutatorThread.h lib/Mvm/MMTk/MvmGC.cpp lib/Mvm/MMTk/MvmGC.h lib/Mvm/StaticGCPass/StaticGCPass.cpp mmtk/Makefile mmtk/magic/LowerJavaRT.cpp mmtk/mmtk-alloc/Selected.cpp mmtk/mmtk-fake/ tools/j3/Makefile tools/vmkit/Makefile
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Thu Mar 25 12:57:10 PDT 2010
Author: geoffray
Date: Thu Mar 25 14:57:09 2010
New Revision: 99545
URL: http://llvm.org/viewvc/llvm-project?rev=99545&view=rev
Log:
Clean up MMTk interface and now link MMTk at compile-time. We are still
able to inline malloc by loading a cpp version of it.
Removed:
vmkit/trunk/mmtk/mmtk-fake/
Modified:
vmkit/trunk/Makefile
vmkit/trunk/Makefile.rules
vmkit/trunk/include/mvm/JIT.h
vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp
vmkit/trunk/lib/Mvm/Compiler/JIT.cpp
vmkit/trunk/lib/Mvm/Compiler/MMTkInline.inc
vmkit/trunk/lib/Mvm/MMTk/MutatorThread.cpp
vmkit/trunk/lib/Mvm/MMTk/MutatorThread.h
vmkit/trunk/lib/Mvm/MMTk/MvmGC.cpp
vmkit/trunk/lib/Mvm/MMTk/MvmGC.h
vmkit/trunk/lib/Mvm/StaticGCPass/StaticGCPass.cpp
vmkit/trunk/mmtk/Makefile
vmkit/trunk/mmtk/magic/LowerJavaRT.cpp
vmkit/trunk/mmtk/mmtk-alloc/Selected.cpp
vmkit/trunk/tools/j3/Makefile
vmkit/trunk/tools/vmkit/Makefile
Modified: vmkit/trunk/Makefile
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/Makefile?rev=99545&r1=99544&r2=99545&view=diff
==============================================================================
--- vmkit/trunk/Makefile (original)
+++ vmkit/trunk/Makefile Thu Mar 25 14:57:09 2010
@@ -13,12 +13,14 @@
# Top-Level vmkit Build Stages:
#
-DIRS := lib tools
+DIRS := lib tools/vmjc
ifeq ($(GC_MMTK), 1)
DIRS += mmtk
endif
+DIRS += tools
+
EXTRA_DIST=include
include $(LEVEL)/Makefile.common
Modified: vmkit/trunk/Makefile.rules
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/Makefile.rules?rev=99545&r1=99544&r2=99545&view=diff
==============================================================================
--- vmkit/trunk/Makefile.rules (original)
+++ vmkit/trunk/Makefile.rules Thu Mar 25 14:57:09 2010
@@ -133,7 +133,7 @@
$(Verb) $(ANT) -buildfile $(PROJ_SRC_ROOT)/mmtk/java/build.xml
$(Echo) Building $(BuildMode) $(JARNAME).jar $(notdir $@)
$(Verb) $(LOPT) -load=$(LibDir)/JITGCPass$(SHLIBEXT) -std-compile-opts -JITGCPass -f $(LibDir)/MMTKAlloc.bc -o $(LibDir)/MMTKAlloc.bc
- $(Verb) $(VMJC) -std-compile-opts $(ADDITIONAL_ARGS) -load=$(LibDir)/MMTKFake$(SHLIBEXT) -load=$(LibDir)/MMTKMagic$(SHLIBEXT) -LowerMagic -verify $(PROJ_SRC_ROOT)/mmtk/java/$(JARNAME).jar -disable-exceptions -disable-cooperativegc -with-clinit=org/mmtk/vm/VM,org/mmtk/utility/*,org/mmtk/policy/*,org/j3/config/* -Dmmtk.hostjvm=org.j3.mmtk.Factory -o $(JARNAME).bc -Dmmtk.properties=$(PROJ_SRC_ROOT)/mmtk/java/vmkit.properties -disable-stubs -assume-compiled -llvm-lazy
+ $(Verb) $(VMJC) -std-compile-opts $(ADDITIONAL_ARGS) -load=$(LibDir)/MMTKMagic$(SHLIBEXT) -LowerMagic -verify $(PROJ_SRC_ROOT)/mmtk/java/$(JARNAME).jar -disable-exceptions -disable-cooperativegc -with-clinit=org/mmtk/vm/VM,org/mmtk/utility/*,org/mmtk/policy/*,org/j3/config/* -Dmmtk.hostjvm=org.j3.mmtk.Factory -o $(JARNAME).bc -Dmmtk.properties=$(PROJ_SRC_ROOT)/mmtk/java/vmkit.properties -disable-stubs -assume-compiled -llvm-lazy
$(Verb) $(LOPT) -load=$(LibDir)/MMTKMagic$(SHLIBEXT) -std-compile-opts -LowerJavaRT -f $(JARNAME).bc -o $(JARNAME)-optimized.bc
$(Verb) $(LLVMLD) -r -o $(LibDir)/FinalMMTk.bc $(LibDir)/MMTKAlloc.bc $(JARNAME)-optimized.bc $(LibDir)/MMTKRuntime.bc
$(Verb) $(LOPT) -std-compile-opts $(LibDir)/FinalMMTk.bc -o $(LibDir)/FinalMMTk.bc
Modified: vmkit/trunk/include/mvm/JIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/JIT.h?rev=99545&r1=99544&r2=99545&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/JIT.h (original)
+++ vmkit/trunk/include/mvm/JIT.h Thu Mar 25 14:57:09 2010
@@ -181,7 +181,6 @@
static llvm::GCStrategy* TheGCStrategy;
static mvm::LockRecursive protectEngine;
static llvm::Module *globalModule;
- static llvm::FunctionPassManager* globalFunctionPasses;
static const llvm::TargetData* TheTargetData;
static mvm::BumpPtrAllocator* Allocator;
//static unsigned MetadataTypeKind;
Modified: vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp?rev=99545&r1=99544&r2=99545&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp Thu Mar 25 14:57:09 2010
@@ -353,8 +353,9 @@
}
Module& Mod = *getLLVMModule();
- varGV = new GlobalVariable(Mod, Ty, false, GlobalValue::InternalLinkage,
- 0, "final object");
+ // Set as External, so that inlining MMTk code works.
+ varGV = new GlobalVariable(Mod, Ty, false, GlobalValue::ExternalLinkage,
+ 0, "finalObject");
Constant* C = ConstantExpr::getBitCast(varGV,
JavaIntrinsics.JavaObjectType);
Modified: vmkit/trunk/lib/Mvm/Compiler/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/JIT.cpp?rev=99545&r1=99544&r2=99545&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original)
+++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Thu Mar 25 14:57:09 2010
@@ -44,8 +44,15 @@
#include "MutatorThread.h"
#include "MvmGC.h"
+#include <dlfcn.h>
#include <sys/mman.h>
+#if defined(__MACH__)
+#define SELF_HANDLE RTLD_DEFAULT
+#else
+#define SELF_HANDLE 0
+#endif
+
using namespace mvm;
using namespace llvm;
@@ -169,9 +176,6 @@
TheTargetData = T->getTargetData();
}
- globalFunctionPasses = new FunctionPassManager(globalModule);
-
-
//LLVMContext& Context = globalModule->getContext();
//MetadataTypeKind = Context.getMDKindID("HighLevelType");
@@ -179,163 +183,6 @@
e = LoadBytecodeFiles.end(); i != e; ++i) {
loadBytecodeFile(*i);
}
-
-#ifdef WITH_MMTK
- llvm::GlobalVariable* GV = globalModule->getGlobalVariable("MMTkCollectorSize", false);
- if (GV && executionEngine) {
- // Allocate the memory for MMTk right now, to avoid conflicts with
- // other allocators.
-#if defined (__MACH__)
- uint32 flags = MAP_PRIVATE | MAP_ANON | MAP_FIXED;
-#else
- uint32 flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED;
-#endif
- void* baseAddr = mmap((void*)0x30000000, 0x40000000, PROT_READ | PROT_WRITE,
- flags, -1, 0);
- if (baseAddr == MAP_FAILED) {
- perror("mmap");
- abort();
- }
-
- ConstantInt* C = dyn_cast<ConstantInt>(GV->getInitializer());
- uint64_t val = C->getZExtValue();
- MutatorThread::MMTkCollectorSize = val;
-
- GV = globalModule->getGlobalVariable("MMTkMutatorSize", false);
- assert(GV && "Could not find MMTkMutatorSize");
- C = dyn_cast<ConstantInt>(GV->getInitializer());
- val = C->getZExtValue();
- MutatorThread::MMTkMutatorSize = val;
-
- Function* F = globalModule->getFunction("JnJVM_org_j3_config_Selected_00024Mutator__0003Cinit_0003E__");
- assert(F && "Could not find <init> from Mutator");
- MutatorThread::MutatorInit = (MutatorThread::MMTkInitType)
- (uintptr_t)executionEngine->getPointerToFunction(F);
-
- F = globalModule->getFunction("JnJVM_org_mmtk_plan_MutatorContext_initMutator__I");
- assert(F && "Could not find init from Mutator");
- MutatorThread::MutatorCallInit = (MutatorThread::MMTkInitIntType)
- (uintptr_t)executionEngine->getPointerToFunction(F);
-
- F = globalModule->getFunction("JnJVM_org_mmtk_plan_MutatorContext_deinitMutator__");
- assert(F && "Could not find deinit from Mutator");
- MutatorThread::MutatorCallDeinit = (MutatorThread::MMTkInitType)
- (uintptr_t)executionEngine->getPointerToFunction(F);
-
-
- GV = globalModule->getGlobalVariable("org_j3_config_Selected_4Mutator_VT", false);
- assert(GV && "Could not find VT from Mutator");
- MutatorThread::MutatorVT = (VirtualTable*)executionEngine->getPointerToGlobal(GV);
-
- F = globalModule->getFunction("JnJVM_org_j3_config_Selected_00024Collector__0003Cinit_0003E__");
- assert(F && "Could not find <init> from Collector");
- MutatorThread::CollectorInit = (MutatorThread::MMTkInitType)
- (uintptr_t)executionEngine->getPointerToFunction(F);
-
- GV = globalModule->getGlobalVariable("org_j3_config_Selected_4Collector_VT", false);
- assert(GV && "Could not find VT from Collector");
- MutatorThread::CollectorVT = (VirtualTable*)executionEngine->getPointerToGlobal(GV);
-
- GlobalAlias* GA = dyn_cast<GlobalAlias>(globalModule->getNamedValue("MMTkAlloc"));
- assert(GA && "Could not find MMTkAlloc alias");
- F = dyn_cast<Function>(GA->getAliasee());
- gc::MMTkGCAllocator = (gc::MMTkAllocType)
- (uintptr_t)executionEngine->getPointerToFunction(F);
-
- GA = dyn_cast<GlobalAlias>(globalModule->getNamedValue("MMTkPostAlloc"));
- assert(GA && "Could not find MMTkPostAlloc alias");
- 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);
-
- F = globalModule->getFunction("JnJVM_org_mmtk_utility_heap_HeapGrowthManager_boot__Lorg_vmmagic_unboxed_Extent_2Lorg_vmmagic_unboxed_Extent_2");
- assert(F && "Could not find boot from HeapGrowthManager");
- BootHeapType BootHeap = (BootHeapType)
- (uintptr_t)executionEngine->getPointerToFunction(F);
- BootHeap(128 * 1024 * 1024, 1024 * 1024 * 1024);
-
- GV = globalModule->getGlobalVariable("org_j3_config_Selected_4Plan_static", false);
- assert(GV && "No global plan.");
- uintptr_t Plan = *((uintptr_t*)executionEngine->getPointerToGlobal(GV));
-
- GA = dyn_cast<GlobalAlias>(globalModule->getNamedValue("MMTkPlanBoot"));
- assert(GA && "Could not find MMTkPlanBoot alias");
- F = dyn_cast<Function>(GA->getAliasee());
- BootType Boot = (BootType)
- (uintptr_t)executionEngine->getPointerToFunction(F);
- Boot(Plan);
-
- GA = dyn_cast<GlobalAlias>(globalModule->getNamedValue("MMTkPlanPostBoot"));
- assert(GA && "Could not find MMTkPlanPostBoot alias");
- F = dyn_cast<Function>(GA->getAliasee());
- Boot = (BootType)(uintptr_t)executionEngine->getPointerToFunction(F);
- Boot(Plan);
-
- GA = dyn_cast<GlobalAlias>(globalModule->getNamedValue("MMTkPlanFullBoot"));
- assert(GA && "Could not find MMTkPlanFullBoot alias");
- F = dyn_cast<Function>(GA->getAliasee());
- Boot = (BootType)(uintptr_t)executionEngine->getPointerToFunction(F);
- Boot(Plan);
-
- F = globalModule->getFunction("Java_org_j3_mmtk_Collection_triggerCollection__I");
- assert(F && "Could not find external collect");
- gc::MMTkTriggerCollection = (gc::MMTkCollectType)
- (uintptr_t)executionEngine->getPointerToFunction(F);
-
- //===-------------------- TODO: make those virtual. -------------------===//
- F = globalModule->getFunction("JnJVM_org_mmtk_plan_TraceLocal_reportDelayedRootEdge__Lorg_vmmagic_unboxed_Address_2");
- assert(F && "Could not find reportDelayedRootEdge from TraceLocal");
- gc::MMTkDelayedRoot = (gc::MMTkDelayedRootType)
- (uintptr_t)executionEngine->getPointerToFunction(F);
-
- F = globalModule->getFunction("JnJVM_org_mmtk_plan_TraceLocal_processEdge__Lorg_vmmagic_unboxed_ObjectReference_2Lorg_vmmagic_unboxed_Address_2");
- assert(F && "Could not find processEdge from TraceLocal");
- gc::MMTkProcessEdge = (gc::MMTkProcessEdgeType)
- (uintptr_t)executionEngine->getPointerToFunction(F);
-
- F = globalModule->getFunction("JnJVM_org_mmtk_plan_TraceLocal_processRootEdge__Lorg_vmmagic_unboxed_Address_2Z");
- assert(F && "Could not find processEdge from TraceLocal");
- gc::MMTkProcessRootEdge = (gc::MMTkProcessRootEdgeType)
- (uintptr_t)executionEngine->getPointerToFunction(F);
-
- F = globalModule->getFunction("JnJVM_org_mmtk_plan_marksweep_MSTraceLocal_isLive__Lorg_vmmagic_unboxed_ObjectReference_2");
- assert(F && "Could not find isLive from TraceLocal");
- gc::MMTkIsLive = (gc::MMTkIsLiveType)
- (uintptr_t)executionEngine->getPointerToFunction(F);
-
- F = globalModule->getFunction("JnJVM_org_mmtk_plan_TraceLocal_retainForFinalize__Lorg_vmmagic_unboxed_ObjectReference_2");
- assert(F && "Could not find isLive from TraceLocal");
- gc::MMTkRetainForFinalize = (gc::MMTkRetainForFinalizeType)
- (uintptr_t)executionEngine->getPointerToFunction(F);
-
- F = globalModule->getFunction("JnJVM_org_mmtk_plan_TraceLocal_retainReferent__Lorg_vmmagic_unboxed_ObjectReference_2");
- assert(F && "Could not find isLive from TraceLocal");
- gc::MMTkRetainReferent = (gc::MMTkRetainReferentType)
- (uintptr_t)executionEngine->getPointerToFunction(F);
-
- F = globalModule->getFunction("JnJVM_org_mmtk_plan_TraceLocal_getForwardedReference__Lorg_vmmagic_unboxed_ObjectReference_2");
- assert(F && "Could not find isLive from TraceLocal");
- gc::MMTkGetForwardedReference = (gc::MMTkGetForwardedReferenceType)
- (uintptr_t)executionEngine->getPointerToFunction(F);
-
- F = globalModule->getFunction("JnJVM_org_mmtk_plan_TraceLocal_getForwardedReferent__Lorg_vmmagic_unboxed_ObjectReference_2");
- assert(F && "Could not find isLive from TraceLocal");
- gc::MMTkGetForwardedReferent = (gc::MMTkGetForwardedReferentType)
- (uintptr_t)executionEngine->getPointerToFunction(F);
-
- F = globalModule->getFunction("JnJVM_org_mmtk_plan_TraceLocal_getForwardedFinalizable__Lorg_vmmagic_unboxed_ObjectReference_2");
- assert(F && "Could not find isLive from TraceLocal");
- gc::MMTkGetForwardedFinalizable = (gc::MMTkGetForwardedFinalizableType)
- (uintptr_t)executionEngine->getPointerToFunction(F);
-
- }
-#endif
}
@@ -345,35 +192,10 @@
module->setTargetTriple(MvmModule::globalModule->getTargetTriple());
LLVMContext& Context = module->getContext();
-#ifdef WITH_MMTK
- if (MutatorThread::MMTkCollectorSize) {
- // If we have found MMTk, read the gcmalloc function and set the address of
- // global variables and functions used by gcmalloc.
+ if (dlsym(SELF_HANDLE, "MMTkPlanBoot")) {
+ // If we have found MMTk, read the gcmalloc function.
mvm::mmtk_runtime::makeLLVMFunction(module);
- if (MvmModule::executionEngine) {
- for (Module::global_iterator i = module->global_begin(),
- e = module->global_end(); i != e; ++i) {
- if (i->isDeclaration()) {
- GlobalVariable* GV =
- MvmModule::globalModule->getGlobalVariable(i->getName(), true);
- assert(GV && "GV can not be found");
- void* ptr = MvmModule::executionEngine->getPointerToGlobal(GV);
- MvmModule::executionEngine->updateGlobalMapping(i, ptr);
- }
- }
- for (Module::iterator i = module->begin(), e = module->end();
- i != e; ++i) {
- if (i->isDeclaration() && !i->isIntrinsic()) {
- Function* F =
- MvmModule::globalModule->getFunction(i->getName());
- assert(F && "Function can not be found");
- void* ptr = MvmModule::executionEngine->getPointerToFunction(F);
- MvmModule::executionEngine->updateGlobalMapping(i, ptr);
- }
- }
- }
}
-#endif
mvm::llvm_runtime::makeLLVMModuleContents(module);
@@ -511,7 +333,6 @@
const llvm::TargetData* MvmModule::TheTargetData;
llvm::GCStrategy* MvmModule::TheGCStrategy;
llvm::Module *MvmModule::globalModule;
-llvm::FunctionPassManager* MvmModule::globalFunctionPasses;
llvm::ExecutionEngine* MvmModule::executionEngine;
mvm::LockRecursive MvmModule::protectEngine;
mvm::BumpPtrAllocator* MvmModule::Allocator;
@@ -694,4 +515,3 @@
}
}
}
-
Modified: vmkit/trunk/lib/Mvm/Compiler/MMTkInline.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/MMTkInline.inc?rev=99545&r1=99544&r2=99545&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Compiler/MMTkInline.inc (original)
+++ vmkit/trunk/lib/Mvm/Compiler/MMTkInline.inc Thu Mar 25 14:57:09 2010
@@ -582,21 +582,21 @@
/*isConstant=*/false,
/*Linkage=*/GlobalValue::InternalLinkage,
/*Initializer=*/0, // has initializer, specified below
-/*Name=*/"final object67");
+/*Name=*/"finalObject67");
GlobalVariable* gvar_struct_final_object2 = new GlobalVariable(/*Module=*/ *mod,
/*Type=*/StructTy_40,
/*isConstant=*/false,
/*Linkage=*/GlobalValue::InternalLinkage,
/*Initializer=*/0, // has initializer, specified below
-/*Name=*/"final object2");
+/*Name=*/"finalObject2");
GlobalVariable* gvar_struct_final_object32 = new GlobalVariable(/*Module=*/ *mod,
/*Type=*/StructTy_42,
/*isConstant=*/false,
/*Linkage=*/GlobalValue::InternalLinkage,
/*Initializer=*/0, // has initializer, specified below
-/*Name=*/"final object32");
+/*Name=*/"finalObject32");
GlobalVariable* gvar_struct_org_mmtk_utility_DoublyLinkedList_static = new GlobalVariable(/*Module=*/ *mod,
/*Type=*/StructTy_45,
@@ -610,21 +610,21 @@
/*isConstant=*/false,
/*Linkage=*/GlobalValue::InternalLinkage,
/*Initializer=*/0, // has initializer, specified below
-/*Name=*/"final object85");
+/*Name=*/"finalObject85");
GlobalVariable* gvar_struct_final_object101 = new GlobalVariable(/*Module=*/ *mod,
/*Type=*/StructTy_42,
/*isConstant=*/false,
/*Linkage=*/GlobalValue::InternalLinkage,
/*Initializer=*/0, // has initializer, specified below
-/*Name=*/"final object101");
+/*Name=*/"finalObject101");
GlobalVariable* gvar_struct_final_object122 = new GlobalVariable(/*Module=*/ *mod,
/*Type=*/StructTy_36,
/*isConstant=*/false,
/*Linkage=*/GlobalValue::InternalLinkage,
/*Initializer=*/0, // has initializer, specified below
-/*Name=*/"final object122");
+/*Name=*/"finalObject122");
// Constant Definitions
ConstantInt* const_int32_50 = ConstantInt::get(mod->getContext(), APInt(32, StringRef("1"), 10));
Modified: vmkit/trunk/lib/Mvm/MMTk/MutatorThread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/MMTk/MutatorThread.cpp?rev=99545&r1=99544&r2=99545&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/MMTk/MutatorThread.cpp (original)
+++ vmkit/trunk/lib/Mvm/MMTk/MutatorThread.cpp Thu Mar 25 14:57:09 2010
@@ -12,20 +12,3 @@
#include "MvmGC.h"
using namespace mvm;
-
-uint32_t MutatorThread::MMTkMutatorSize = 0;
-uint32_t MutatorThread::MMTkCollectorSize = 0;
-
-MutatorThread::MMTkInitType MutatorThread::MutatorInit = 0;
-MutatorThread::MMTkInitIntType MutatorThread::MutatorCallInit = 0;
-MutatorThread::MMTkInitType MutatorThread::MutatorCallDeinit = 0;
-MutatorThread::MMTkInitType MutatorThread::CollectorInit = 0;
-
-VirtualTable* MutatorThread::MutatorVT = 0;
-VirtualTable* MutatorThread::CollectorVT = 0;
-
-extern "C" void* MMTkMutatorAllocate(uint32_t size, VirtualTable* VT) {
- void* val = MutatorThread::get()->Allocator.Allocate(size, "MMTk");
- ((void**)val)[0] = VT;
- return val;
-}
Modified: vmkit/trunk/lib/Mvm/MMTk/MutatorThread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/MMTk/MutatorThread.h?rev=99545&r1=99544&r2=99545&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/MMTk/MutatorThread.h (original)
+++ vmkit/trunk/lib/Mvm/MMTk/MutatorThread.h Thu Mar 25 14:57:09 2010
@@ -24,31 +24,8 @@
/// realRoutine - The function to invoke when the thread starts.
///
void (*realRoutine)(mvm::Thread*);
-
- static uint32_t MMTkMutatorSize;
- static uint32_t MMTkCollectorSize;
-
- typedef void (*MMTkInitType)(uintptr_t);
- typedef void (*MMTkInitIntType)(uintptr_t, int32_t);
- static MMTkInitType MutatorInit;
- static MMTkInitIntType MutatorCallInit;
- static MMTkInitType MutatorCallDeinit;
- static MMTkInitType CollectorInit;
-
- static VirtualTable* MutatorVT;
- static VirtualTable* CollectorVT;
-
- static void init(Thread* _th) {
- MutatorThread* th = (MutatorThread*)_th;
- th->MutatorContext =
- (uintptr_t)th->Allocator.Allocate(MMTkMutatorSize, "Mutator");
- ((VirtualTable**)th->MutatorContext)[0] = MutatorVT;
- MutatorInit(th->MutatorContext);
- MutatorCallInit(th->MutatorContext, (int32_t)_th->getThreadID());
- th->realRoutine(_th);
- MutatorCallDeinit(th->MutatorContext);
- }
+ static void init(Thread* _th);
static MutatorThread* get() {
return (MutatorThread*)mvm::Thread::get();
Modified: vmkit/trunk/lib/Mvm/MMTk/MvmGC.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/MMTk/MvmGC.cpp?rev=99545&r1=99544&r2=99545&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/MMTk/MvmGC.cpp (original)
+++ vmkit/trunk/lib/Mvm/MMTk/MvmGC.cpp Thu Mar 25 14:57:09 2010
@@ -7,94 +7,108 @@
//
//===----------------------------------------------------------------------===//
-
#include "MvmGC.h"
-#include "MutatorThread.h"
#include <set>
using namespace mvm;
-gc::MMTkAllocType gc::MMTkGCAllocator = 0;
-gc::MMTkPostAllocType gc::MMTkGCPostAllocator = 0;
-gc::MMTkCheckAllocatorType gc::MMTkCheckAllocator = 0;
-gc::MMTkDelayedRootType gc::MMTkDelayedRoot = 0;
-gc::MMTkProcessEdgeType gc::MMTkProcessEdge = 0;
-gc::MMTkProcessRootEdgeType gc::MMTkProcessRootEdge = 0;
-gc::MMTkIsLiveType gc::MMTkIsLive = 0;
-
-gc::MMTkRetainReferentType gc::MMTkRetainReferent = 0;
-gc::MMTkRetainForFinalizeType gc::MMTkRetainForFinalize = 0;
-gc::MMTkGetForwardedReferentType gc::MMTkGetForwardedReferent = 0;
-gc::MMTkGetForwardedReferenceType gc::MMTkGetForwardedReference = 0;
-gc::MMTkGetForwardedFinalizableType gc::MMTkGetForwardedFinalizable = 0;
-gc::MMTkCollectType gc::MMTkTriggerCollection = 0;
-
-uintptr_t Collector::TraceLocal = 0;
-
-
static mvm::SpinLock lock;
-
-
std::set<gc*> __InternalSet__;
-extern "C" int internalCheckAllocator(uintptr_t Mutator, int32_t sz,
- int32_t align, int32_t alloc) {
- return 0;
-}
-
-extern "C" void internalPostMalloc(uintptr_t Mutator, uintptr_t ref,
- uintptr_t typeref, int32_t bytes,
- int32_t allocator) {
-}
-
-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);
+extern "C" void* gcmalloc(size_t sz, void* _VT) {
+ gc* res = 0;
+ VirtualTable* VT = (VirtualTable*)_VT;
+ sz = llvm::RoundUpToAlignment(sz, sizeof(void*));
+ res = (gc*)malloc(sz);
memset(res, 0, sz);
lock.acquire();
__InternalSet__.insert(res);
lock.release();
+ res->setVirtualTable(VT);
+ return res;
+}
+
+extern "C" void* gcmallocUnresolved(size_t sz, VirtualTable* VT) {
+ gc* res = (gc*)gcmalloc(sz, VT);
+ if (VT->destructor)
+ mvm::Thread::get()->MyVM->addFinalizationCandidate(res);
return res;
}
+extern "C" void addFinalizationCandidate(gc* obj) {
+ mvm::Thread::get()->MyVM->addFinalizationCandidate(obj);
+}
+
+extern "C" void* AllocateMagicArray(int32_t sz, void* length) {
+ gc* res = (gc*)malloc(sz);
+ memset(res, 0, sz);
+ ((void**)res)[0] = length;
+ return res;
+}
void* Collector::begOf(gc* obj) {
- if (gc::MMTkGCAllocator == internalMalloc) {
- lock.acquire();
- std::set<gc*>::iterator I = __InternalSet__.find(obj);
- std::set<gc*>::iterator E = __InternalSet__.end();
- lock.release();
+ lock.acquire();
+ std::set<gc*>::iterator I = __InternalSet__.find(obj);
+ std::set<gc*>::iterator E = __InternalSet__.end();
+ lock.release();
- if (I != E) return obj;
- return 0;
- } else {
- abort();
- }
+ if (I != E) return obj;
+ return 0;
}
-extern "C" void fakeInit(uintptr_t) {
+void MutatorThread::init(Thread* _th) {
+ MutatorThread* th = (MutatorThread*)_th;
+ th->realRoutine(_th);
}
-extern "C" void fakeInitInt(uintptr_t, int32_t) {
+bool Collector::isLive(gc* ptr) {
+ abort();
+ return false;
}
-void Collector::initialise() {
- if (!gc::MMTkGCAllocator) {
- gc::MMTkGCAllocator = internalMalloc;
- gc::MMTkGCPostAllocator = internalPostMalloc;
- gc::MMTkCheckAllocator = internalCheckAllocator;
- MutatorThread::MMTkMutatorSize = 0;
- MutatorThread::MMTkCollectorSize = 0;
- MutatorThread::MutatorInit = fakeInit;
- MutatorThread::CollectorInit = fakeInit;
- MutatorThread::MutatorCallDeinit = fakeInit;
- MutatorThread::MutatorCallInit = fakeInitInt;
- }
+void Collector::scanObject(void** ptr) {
+ abort();
+}
+
+void Collector::markAndTrace(void* source, void* ptr) {
+ abort();
+}
+
+void Collector::markAndTraceRoot(void* ptr) {
+ abort();
+}
+
+gc* Collector::retainForFinalize(gc* val) {
+ abort();
+ return NULL;
+}
+
+gc* Collector::retainReferent(gc* val) {
+ abort();
+ return NULL;
+}
+
+gc* Collector::getForwardedFinalizable(gc* val) {
+ abort();
+ return NULL;
+}
+
+gc* Collector::getForwardedReference(gc* val) {
+ abort();
+ return NULL;
+}
+
+gc* Collector::getForwardedReferent(gc* val) {
+ abort();
+ return NULL;
+}
+
+void Collector::collect() {
+ // Do nothing.
}
+void Collector::initialise() {
+}
Modified: vmkit/trunk/lib/Mvm/MMTk/MvmGC.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/MMTk/MvmGC.h?rev=99545&r1=99544&r2=99545&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/MMTk/MvmGC.h (original)
+++ vmkit/trunk/lib/Mvm/MMTk/MvmGC.h Thu Mar 25 14:57:09 2010
@@ -28,6 +28,7 @@
#define CALL_TRACER tracer()
+extern "C" void* gcmallocUnresolved(size_t sz, VirtualTable* VT);
class gc : public gcRoot {
public:
@@ -38,75 +39,8 @@
return 0;
}
- typedef gc* (*MMTkAllocType)(uintptr_t Mutator, int32_t sz, int32_t align,
- int32_t offset, int32_t allocator,
- int32_t site);
-
- typedef void (*MMTkPostAllocType)(uintptr_t Mutator, uintptr_t ref,
- uintptr_t typeref, int32_t bytes,
- int32_t allocator);
-
- typedef int (*MMTkCheckAllocatorType)(uintptr_t Mutator, int32_t bytes,
- int32_t align, int32_t allocator);
-
- typedef void (*MMTkDelayedRootType)(uintptr_t TraceLocal, void** slot);
-
- typedef void (*MMTkProcessEdgeType)(uintptr_t TraceLocal, void* source,
- void* slot);
-
- typedef void (*MMTkProcessRootEdgeType)(uintptr_t TraceLocal, void* slot,
- uint8_t untraced);
-
- typedef uint8_t (*MMTkIsLiveType)(uintptr_t TraceLocal, void* obj);
-
- typedef gc* (*MMTkRetainReferentType)(uintptr_t TraceLocal, void* obj);
- typedef MMTkRetainReferentType MMTkRetainForFinalizeType;
- typedef MMTkRetainReferentType MMTkGetForwardedReferenceType;
- typedef MMTkRetainReferentType MMTkGetForwardedReferentType;
- typedef MMTkRetainReferentType MMTkGetForwardedFinalizableType;
- typedef void (*MMTkCollectType)(uintptr_t, int32_t);
-
- static MMTkAllocType MMTkGCAllocator;
-
- static MMTkPostAllocType MMTkGCPostAllocator;
-
- static MMTkCheckAllocatorType MMTkCheckAllocator;
-
- static MMTkDelayedRootType MMTkDelayedRoot;
-
- static MMTkProcessEdgeType MMTkProcessEdge;
-
- static MMTkProcessRootEdgeType MMTkProcessRootEdge;
-
- static MMTkIsLiveType MMTkIsLive;
-
- static MMTkRetainReferentType MMTkRetainReferent;
- static MMTkRetainForFinalizeType MMTkRetainForFinalize;
- static MMTkGetForwardedReferenceType MMTkGetForwardedReference;
- static MMTkGetForwardedReferentType MMTkGetForwardedReferent;
- static MMTkGetForwardedFinalizableType MMTkGetForwardedFinalizable;
-
- static MMTkCollectType MMTkTriggerCollection;
-
void* operator new(size_t sz, VirtualTable *VT) {
- gc* res = 0;
- llvm_gcroot(res, 0);
- assert(VT->tracer && "VT without a tracer");
- sz = llvm::RoundUpToAlignment(sz, sizeof(void*));
- uintptr_t Mutator = mvm::MutatorThread::get()->MutatorContext;
- int allocator = MMTkCheckAllocator(Mutator, sz, 0, 0);
- res = (gc*)MMTkGCAllocator(Mutator, sz, 0, 0, allocator, 0);
- assert(res && "Allocation failed");
- assert(res->getVirtualTable() == 0 && "Allocation not zeroed");
- res->setVirtualTable(VT);
- MMTkGCPostAllocator(Mutator, (uintptr_t)res, (uintptr_t)VT, sz, allocator);
-
- // operator new is called by C++ code, that does not call the
- // addFinalizationCandidate, unlike application code. Call it here.
- if (VT->destructor) {
- mvm::Thread::get()->MyVM->addFinalizationCandidate(res);
- }
- return res;
+ return gcmallocUnresolved(sz, VT);
}
};
@@ -118,54 +52,25 @@
static uintptr_t TraceLocal;
- static bool isLive(gc* ptr) {
- return gc::MMTkIsLive(TraceLocal, ptr);
- }
+ static bool isLive(gc* ptr);
- static void scanObject(void** ptr) {
- assert(gc::MMTkDelayedRoot && "scanning without a function");
- assert(TraceLocal && "scanning without a trace local");
- gc::MMTkDelayedRoot(TraceLocal, ptr);
- }
+ static void scanObject(void** ptr);
- static void markAndTrace(void* source, void* ptr) {
- assert(TraceLocal && "scanning without a trace local");
- gc::MMTkProcessEdge(TraceLocal, source, ptr);
- }
+ static void markAndTrace(void* source, void* ptr);
- static void markAndTraceRoot(void* ptr) {
- assert(TraceLocal && "scanning without a trace local");
- gc::MMTkProcessRootEdge(TraceLocal, ptr, true);
- }
+ static void markAndTraceRoot(void* ptr);
- static gc* retainForFinalize(gc* val) {
- assert(TraceLocal && "scanning without a trace local");
- return gc::MMTkRetainForFinalize(TraceLocal, val);
- }
+ static gc* retainForFinalize(gc* val);
- static gc* retainReferent(gc* val) {
- assert(TraceLocal && "scanning without a trace local");
- return gc::MMTkRetainReferent(TraceLocal, val);
- }
+ static gc* retainReferent(gc* val);
- static gc* getForwardedFinalizable(gc* val) {
- assert(TraceLocal && "scanning without a trace local");
- return gc::MMTkGetForwardedFinalizable(TraceLocal, val);
- }
+ static gc* getForwardedFinalizable(gc* val);
- static gc* getForwardedReference(gc* val) {
- assert(TraceLocal && "scanning without a trace local");
- return gc::MMTkGetForwardedReference(TraceLocal, val);
- }
+ static gc* getForwardedReference(gc* val);
- static gc* getForwardedReferent(gc* val) {
- assert(TraceLocal && "scanning without a trace local");
- return gc::MMTkGetForwardedReferent(TraceLocal, val);
- }
+ static gc* getForwardedReferent(gc* val);
- static void collect() {
- if (gc::MMTkTriggerCollection) gc::MMTkTriggerCollection(NULL, 2);
- }
+ static void collect();
static void initialise();
Modified: vmkit/trunk/lib/Mvm/StaticGCPass/StaticGCPass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/StaticGCPass/StaticGCPass.cpp?rev=99545&r1=99544&r2=99545&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/StaticGCPass/StaticGCPass.cpp (original)
+++ vmkit/trunk/lib/Mvm/StaticGCPass/StaticGCPass.cpp Thu Mar 25 14:57:09 2010
@@ -40,24 +40,27 @@
bool StaticGCPass::runOnModule(Module& M) {
Function* F = M.getFunction("__llvm_gcroot");
- if (F) {
- Function *gcrootFun = Intrinsic::getDeclaration(&M, Intrinsic::gcroot);
+ Function *gcrootFun = Intrinsic::getDeclaration(&M, Intrinsic::gcroot);
+ if (F) {
F->replaceAllUsesWith(gcrootFun);
F->eraseFromParent();
+ }
- for (Value::use_iterator I = gcrootFun->use_begin(),
- E = gcrootFun->use_end(); I != E; ++I) {
- if (Instruction* II = dyn_cast<Instruction>(I)) {
- Function* F = II->getParent()->getParent();
- if (!F->hasGC()) F->setGC("ocaml");
- }
+ for (Value::use_iterator I = gcrootFun->use_begin(),
+ E = gcrootFun->use_end(); I != E; ++I) {
+ if (Instruction* II = dyn_cast<Instruction>(I)) {
+ Function* F = II->getParent()->getParent();
+ if (F->hasGC()) F->clearGC();
+ F->setGC("ocaml");
}
+ }
- return true;
+ for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
+ if (I->hasGC() && !strcmp(I->getGC(), "vmkit")) I->setGC("ocaml");
}
- return false;
+ return true;
}
}
Modified: vmkit/trunk/mmtk/Makefile
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/mmtk/Makefile?rev=99545&r1=99544&r2=99545&view=diff
==============================================================================
--- vmkit/trunk/mmtk/Makefile (original)
+++ vmkit/trunk/mmtk/Makefile Thu Mar 25 14:57:09 2010
@@ -8,7 +8,7 @@
##===----------------------------------------------------------------------===##
LEVEL = ..
-DIRS = magic mmtk-j3 mmtk-fake mmtk-alloc java
+DIRS = magic mmtk-j3 mmtk-alloc java
include $(LEVEL)/Makefile.config
Modified: vmkit/trunk/mmtk/magic/LowerJavaRT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/mmtk/magic/LowerJavaRT.cpp?rev=99545&r1=99544&r2=99545&view=diff
==============================================================================
--- vmkit/trunk/mmtk/magic/LowerJavaRT.cpp (original)
+++ vmkit/trunk/mmtk/magic/LowerJavaRT.cpp Thu Mar 25 14:57:09 2010
@@ -67,7 +67,9 @@
GlobalValue& GV = *I;
++I;
if (!strncmp(GV.getName().data(), "JnJVM_java", 10) ||
- !strncmp(GV.getName().data(), "java", 4)) {
+ !strncmp(GV.getName().data(), "java", 4) ||
+ !strncmp(GV.getName().data(), "JnJVM_gnu", 9) ||
+ !strncmp(GV.getName().data(), "gnu", 3)) {
GV.replaceAllUsesWith(Constant::getNullValue(GV.getType()));
GV.eraseFromParent();
}
Modified: vmkit/trunk/mmtk/mmtk-alloc/Selected.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/mmtk/mmtk-alloc/Selected.cpp?rev=99545&r1=99544&r2=99545&view=diff
==============================================================================
--- vmkit/trunk/mmtk/mmtk-alloc/Selected.cpp (original)
+++ vmkit/trunk/mmtk/mmtk-alloc/Selected.cpp Thu Mar 25 14:57:09 2010
@@ -7,19 +7,54 @@
//
//===----------------------------------------------------------------------===//
-#include "JavaArray.h"
-#include "JavaClass.h"
-#include "JavaObject.h"
-#include "JavaThread.h"
#include "MutatorThread.h"
+#include "MvmGC.h"
-using namespace j3;
+#include <sys/mman.h>
+#include <set>
+
+using namespace mvm;
+
+uintptr_t Collector::TraceLocal = 0;
extern "C" void* JnJVM_org_mmtk_plan_marksweep_MSMutator_alloc__IIIII(uintptr_t Mutator, int32_t sz, int32_t align, int32_t offset, int32_t allocator, int32_t site) __attribute__((always_inline));
extern "C" int32_t JnJVM_org_mmtk_plan_MutatorContext_checkAllocator__III(uintptr_t Mutator, int32_t bytes, int32_t align, int32_t allocator) __attribute__((always_inline));
extern "C" void JnJVM_org_mmtk_plan_marksweep_MSMutator_postAlloc__Lorg_vmmagic_unboxed_ObjectReference_2Lorg_vmmagic_unboxed_ObjectReference_2II(uintptr_t Mutator, uintptr_t ref, uintptr_t typeref,
int32_t bytes, int32_t allocator) __attribute__((always_inline));
+extern "C" uint32_t MMTkMutatorSize;
+extern "C" void JnJVM_org_j3_config_Selected_00024Mutator__0003Cinit_0003E__(uintptr_t);
+extern "C" VirtualTable* org_j3_config_Selected_4Mutator_VT;
+extern "C" void JnJVM_org_mmtk_plan_MutatorContext_initMutator__I(uintptr_t, int32_t);
+extern "C" void JnJVM_org_mmtk_plan_MutatorContext_deinitMutator__(uintptr_t);
+
+extern "C" void JnJVM_org_j3_config_Selected_00024Collector__0003Cinit_0003E__(uintptr_t);
+extern "C" VirtualTable* org_j3_config_Selected_4Collector_VT;
+extern "C" uint32_t MMTkCollectorSize;
+
+extern "C" void JnJVM_org_mmtk_utility_heap_HeapGrowthManager_boot__Lorg_vmmagic_unboxed_Extent_2Lorg_vmmagic_unboxed_Extent_2(intptr_t, intptr_t);
+extern "C" uintptr_t* org_j3_config_Selected_4Plan_static;
+extern "C" void MMTkPlanBoot(uintptr_t);
+extern "C" void MMTkPlanPostBoot(uintptr_t);
+extern "C" void MMTkPlanFullBoot(uintptr_t);
+
+extern "C" void Java_org_j3_mmtk_Collection_triggerCollection__I(uintptr_t, int32_t);
+//===-------------------- TODO: make those virtual. -------------------===//
+extern "C" void JnJVM_org_mmtk_plan_TraceLocal_reportDelayedRootEdge__Lorg_vmmagic_unboxed_Address_2(uintptr_t TraceLocal, void** slot);
+extern "C" void JnJVM_org_mmtk_plan_TraceLocal_processEdge__Lorg_vmmagic_unboxed_ObjectReference_2Lorg_vmmagic_unboxed_Address_2(
+ uintptr_t TraceLocal, void* source, void* slot);
+extern "C" void JnJVM_org_mmtk_plan_TraceLocal_processRootEdge__Lorg_vmmagic_unboxed_Address_2Z(
+ uintptr_t TraceLocal, void* slot, uint8_t untraced);
+
+extern "C" gc* JnJVM_org_mmtk_plan_TraceLocal_retainForFinalize__Lorg_vmmagic_unboxed_ObjectReference_2(uintptr_t TraceLocal, void* obj);
+extern "C" gc* JnJVM_org_mmtk_plan_TraceLocal_retainReferent__Lorg_vmmagic_unboxed_ObjectReference_2(uintptr_t TraceLocal, void* obj);
+extern "C" gc* JnJVM_org_mmtk_plan_TraceLocal_getForwardedReference__Lorg_vmmagic_unboxed_ObjectReference_2(uintptr_t TraceLocal, void* obj);
+extern "C" gc* JnJVM_org_mmtk_plan_TraceLocal_getForwardedReferent__Lorg_vmmagic_unboxed_ObjectReference_2(uintptr_t TraceLocal, void* obj);
+extern "C" gc* JnJVM_org_mmtk_plan_TraceLocal_getForwardedFinalizable__Lorg_vmmagic_unboxed_ObjectReference_2(uintptr_t TraceLocal, void* obj);
+
+extern "C" uint8_t JnJVM_org_mmtk_plan_marksweep_MSTraceLocal_isLive__Lorg_vmmagic_unboxed_ObjectReference_2(uintptr_t TraceLocal, void* obj);
+
+
extern "C" void* gcmalloc(uint32_t sz, void* _VT) {
gc* res = 0;
llvm_gcroot(res, 0);
@@ -40,13 +75,103 @@
mvm::Thread::get()->MyVM->addFinalizationCandidate((gc*)obj);
}
-extern "C" void* gcmallocUnresolved(uint32_t sz, void* _VT) {
+extern "C" void* gcmallocUnresolved(uint32_t sz, VirtualTable* VT) {
gc* res = 0;
llvm_gcroot(res, 0);
- VirtualTable* VT = (VirtualTable*)_VT;
res = (gc*)gcmalloc(sz, VT);
if (VT->destructor) addFinalizationCandidate(res);
return res;
}
+void MutatorThread::init(Thread* _th) {
+ MutatorThread* th = (MutatorThread*)_th;
+ th->MutatorContext =
+ (uintptr_t)th->Allocator.Allocate(MMTkMutatorSize, "Mutator");
+ ((VirtualTable**)th->MutatorContext)[0] = org_j3_config_Selected_4Mutator_VT;
+ JnJVM_org_j3_config_Selected_00024Mutator__0003Cinit_0003E__(th->MutatorContext);
+ JnJVM_org_mmtk_plan_MutatorContext_initMutator__I(th->MutatorContext, (int32_t)_th->getThreadID());
+ th->realRoutine(_th);
+ JnJVM_org_mmtk_plan_MutatorContext_deinitMutator__(th->MutatorContext);
+}
+bool Collector::isLive(gc* ptr) {
+ return JnJVM_org_mmtk_plan_marksweep_MSTraceLocal_isLive__Lorg_vmmagic_unboxed_ObjectReference_2(TraceLocal, ptr);
+}
+
+void Collector::scanObject(void** ptr) {
+ JnJVM_org_mmtk_plan_TraceLocal_reportDelayedRootEdge__Lorg_vmmagic_unboxed_Address_2(TraceLocal, ptr);
+}
+
+void Collector::markAndTrace(void* source, void* ptr) {
+ assert(TraceLocal && "scanning without a trace local");
+ JnJVM_org_mmtk_plan_TraceLocal_processEdge__Lorg_vmmagic_unboxed_ObjectReference_2Lorg_vmmagic_unboxed_Address_2(TraceLocal, source, ptr);
+}
+
+void Collector::markAndTraceRoot(void* ptr) {
+ assert(TraceLocal && "scanning without a trace local");
+ JnJVM_org_mmtk_plan_TraceLocal_processRootEdge__Lorg_vmmagic_unboxed_Address_2Z(TraceLocal, ptr, true);
+}
+
+gc* Collector::retainForFinalize(gc* val) {
+ assert(TraceLocal && "scanning without a trace local");
+ return JnJVM_org_mmtk_plan_TraceLocal_retainForFinalize__Lorg_vmmagic_unboxed_ObjectReference_2(TraceLocal, val);
+}
+
+gc* Collector::retainReferent(gc* val) {
+ assert(TraceLocal && "scanning without a trace local");
+ return JnJVM_org_mmtk_plan_TraceLocal_retainReferent__Lorg_vmmagic_unboxed_ObjectReference_2(TraceLocal, val);
+}
+
+gc* Collector::getForwardedFinalizable(gc* val) {
+ assert(TraceLocal && "scanning without a trace local");
+ return JnJVM_org_mmtk_plan_TraceLocal_getForwardedFinalizable__Lorg_vmmagic_unboxed_ObjectReference_2(TraceLocal, val);
+}
+
+gc* Collector::getForwardedReference(gc* val) {
+ assert(TraceLocal && "scanning without a trace local");
+ return JnJVM_org_mmtk_plan_TraceLocal_getForwardedReference__Lorg_vmmagic_unboxed_ObjectReference_2(TraceLocal, val);
+}
+
+gc* Collector::getForwardedReferent(gc* val) {
+ assert(TraceLocal && "scanning without a trace local");
+ return JnJVM_org_mmtk_plan_TraceLocal_getForwardedReferent__Lorg_vmmagic_unboxed_ObjectReference_2(TraceLocal, val);
+}
+
+void Collector::collect() {
+ Java_org_j3_mmtk_Collection_triggerCollection__I(NULL, 2);
+}
+
+void Collector::initialise() {
+ // Allocate the memory for MMTk right now, to avoid conflicts with
+ // other allocators.
+#if defined (__MACH__)
+ uint32 flags = MAP_PRIVATE | MAP_ANON | MAP_FIXED;
+#else
+ uint32 flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED;
+#endif
+ void* baseAddr = mmap((void*)0x30000000, 0x40000000, PROT_READ | PROT_WRITE,
+ flags, -1, 0);
+ if (baseAddr == MAP_FAILED) {
+ perror("mmap");
+ abort();
+ }
+
+ JnJVM_org_mmtk_utility_heap_HeapGrowthManager_boot__Lorg_vmmagic_unboxed_Extent_2Lorg_vmmagic_unboxed_Extent_2(128 * 1024 * 1024, 1024 * 1024 * 1024);
+
+ uintptr_t Plan = *org_j3_config_Selected_4Plan_static;
+ MMTkPlanBoot(Plan);
+ MMTkPlanPostBoot(Plan);
+ MMTkPlanFullBoot(Plan);
+}
+
+extern "C" void* MMTkMutatorAllocate(uint32_t size, VirtualTable* VT) {
+ void* val = MutatorThread::get()->Allocator.Allocate(size, "MMTk");
+ ((void**)val)[0] = VT;
+ return val;
+}
+
+//TODO: Remove these.
+std::set<gc*> __InternalSet__;
+void* Collector::begOf(gc* obj) {
+ abort();
+}
Modified: vmkit/trunk/tools/j3/Makefile
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/j3/Makefile?rev=99545&r1=99544&r2=99545&view=diff
==============================================================================
--- vmkit/trunk/tools/j3/Makefile (original)
+++ vmkit/trunk/tools/j3/Makefile Thu Mar 25 14:57:09 2010
@@ -16,7 +16,13 @@
MODULESNAME = j3
USEDMODULES = J3.bc Classpath.bc J3Compiler.bc Allocator.bc CommonThread.bc \
- Mvm.bc MvmCompiler.bc $(GCLIB).bc
+ Mvm.bc MvmCompiler.bc
+
+ ifeq ($(GC_MMTK), 1)
+ USEDMODULES += FinalMMTk.bc
+ else
+ USEDMODULES += $(GCLIB).bc
+ endif
ifeq ($(ISOLATE_SHARING_BUILD), 1)
USEDMODULES += Isolate.bc
Modified: vmkit/trunk/tools/vmkit/Makefile
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmkit/Makefile?rev=99545&r1=99544&r2=99545&view=diff
==============================================================================
--- vmkit/trunk/tools/vmkit/Makefile (original)
+++ vmkit/trunk/tools/vmkit/Makefile Thu Mar 25 14:57:09 2010
@@ -29,7 +29,13 @@
USEDMODULES += N3.bc PNetLib.bc
endif
- USEDMODULES += Allocator.bc CommonThread.bc Mvm.bc MvmCompiler.bc $(GCLIB).bc
+ USEDMODULES += Allocator.bc CommonThread.bc Mvm.bc MvmCompiler.bc
+
+ ifeq ($(GC_MMTK), 1)
+ USEDMODULES += FinalMMTk.bc
+ else
+ USEDMODULES += $(GCLIB).bc
+ endif
BUILT_SOURCES = vmkit.s
SOURCES = vmkit.s $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp))
More information about the vmkit-commits
mailing list