[vmkit-commits] [vmkit] r58204 - in /vmkit/trunk/lib/JnJVM/VMCore: JnjvmModule.cpp JnjvmModule.h
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Sun Oct 26 15:32:45 PDT 2008
Author: geoffray
Date: Sun Oct 26 17:32:44 2008
New Revision: 58204
URL: http://llvm.org/viewvc/llvm-project?rev=58204&view=rev
Log:
Move creation of the tracer in a function.
Modified:
vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp
vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h
Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp?rev=58204&r1=58203&r2=58204&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp Sun Oct 26 17:32:44 2008
@@ -276,42 +276,8 @@
#endif
-VirtualTable* JnjvmModule::makeVT(Class* cl, bool stat) {
-
- VirtualTable* res = 0;
-#ifndef WITHOUT_VTABLE
- if (stat) {
-#endif
- mvm::BumpPtrAllocator& allocator = cl->classLoader->allocator;
- res = (VirtualTable*)allocator.Allocate(VT_SIZE);
- memcpy(res, JavaObject::VT, VT_SIZE);
-#ifndef WITHOUT_VTABLE
- } else {
- if (cl->super) {
- cl->virtualTableSize = cl->super->virtualTableSize;
- } else {
- cl->virtualTableSize = VT_NB_FUNCS;
- }
- res = allocateVT(cl, 0);
+llvm::Function* JnjvmModule::makeTracer(Class* cl, bool stat) {
- if (!(cl->super)) {
- uint32 size = (cl->virtualTableSize - VT_NB_FUNCS) * sizeof(void*);
-#define COPY(CLASS) \
- memcpy((void*)((unsigned)CLASS::VT + VT_SIZE), \
- (void*)((unsigned)res + VT_SIZE), size);
-
- COPY(JavaArray)
- COPY(JavaObject)
- COPY(ArrayObject)
-
-#undef COPY
- }
- }
-#endif
-
-
-
-#ifdef WITH_TRACER
LLVMClassInfo* LCI = (LLVMClassInfo*)getClassInfo(cl);
const Type* type = stat ? LCI->getStaticType() : LCI->getVirtualType();
JavaField* fields = 0;
@@ -323,7 +289,7 @@
fields = cl->getVirtualFields();
nbFields = cl->nbVirtualFields;
}
-
+
Function* func = Function::Create(JnjvmModule::MarkAndTraceType,
GlobalValue::ExternalLinkage,
"markAndTraceObject",
@@ -380,17 +346,57 @@
}
ReturnInst::Create(block);
-
- void* codePtr = mvm::MvmModule::executionEngine->getPointerToGlobal(func);
- ((void**)res)[VT_TRACER_OFFSET] = codePtr;
- func->deleteBody();
-
if (!stat) {
LCI->virtualTracerFunction = func;
} else {
LCI->staticTracerFunction = func;
}
+
+ return func;
+}
+
+VirtualTable* JnjvmModule::makeVT(Class* cl, bool stat) {
+
+ VirtualTable* res = 0;
+#ifndef WITHOUT_VTABLE
+ if (stat) {
+#endif
+ mvm::BumpPtrAllocator& allocator = cl->classLoader->allocator;
+ res = (VirtualTable*)allocator.Allocate(VT_SIZE);
+ memcpy(res, JavaObject::VT, VT_SIZE);
+#ifndef WITHOUT_VTABLE
+ } else {
+ if (cl->super) {
+ cl->virtualTableSize = cl->super->virtualTableSize;
+ } else {
+ cl->virtualTableSize = VT_NB_FUNCS;
+ }
+ res = allocateVT(cl, 0);
+
+ if (!(cl->super)) {
+ uint32 size = (cl->virtualTableSize - VT_NB_FUNCS) * sizeof(void*);
+#define COPY(CLASS) \
+ memcpy((void*)((unsigned)CLASS::VT + VT_SIZE), \
+ (void*)((unsigned)res + VT_SIZE), size);
+
+ COPY(JavaArray)
+ COPY(JavaObject)
+ COPY(ArrayObject)
+
+#undef COPY
+ }
+ }
+#endif
+
+#ifdef WITH_TRACER
+ llvm::Function* func = makeTracer(cl, stat);
+
+ void* codePtr = mvm::MvmModule::executionEngine->getPointerToGlobal(func);
+ ((void**)res)[VT_TRACER_OFFSET] = codePtr;
+
+ func->deleteBody();
+
#endif
return res;
}
Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h?rev=58204&r1=58203&r2=58204&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h Sun Oct 26 17:32:44 2008
@@ -210,7 +210,8 @@
-
+
+ llvm::Function* makeTracer(Class* cl, bool stat);
VirtualTable* makeVT(Class* cl, bool stat);
VirtualTable* allocateVT(Class* cl, uint32 index);
More information about the vmkit-commits
mailing list