[vmkit-commits] [vmkit] r57349 - in /vmkit/trunk: include/mvm/ lib/JnJVM/Classpath/ lib/JnJVM/VMCore/ lib/Mvm/GCMmap2/ lib/Mvm/Runtime/ lib/N3/Mono/ lib/N3/PNetLib/ lib/N3/VMCore/ tools/jnjvm/ tools/n3-mono/ tools/n3-pnetlib/ tools/vmkit/
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Fri Oct 10 05:51:55 PDT 2008
Author: geoffray
Date: Fri Oct 10 07:51:51 2008
New Revision: 57349
URL: http://llvm.org/viewvc/llvm-project?rev=57349&view=rev
Log:
On the way to isolate llvm::Modules in jnjvm...
And when isolation works, we'll be able to call the Verifier. Yay!
Modified:
vmkit/trunk/include/mvm/JIT.h
vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMStackWalker.cpp
vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.h
vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp
vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp
vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp
vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h
vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp
vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp
vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp
vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h
vmkit/trunk/lib/Mvm/Runtime/Disassembler.cpp
vmkit/trunk/lib/Mvm/Runtime/EscapeAnalysis.cpp
vmkit/trunk/lib/Mvm/Runtime/JIT.cpp
vmkit/trunk/lib/Mvm/Runtime/LLVMRuntime.ll
vmkit/trunk/lib/Mvm/Runtime/MvmMemoryManager.cpp
vmkit/trunk/lib/N3/Mono/MonoMSCorlib.cpp
vmkit/trunk/lib/N3/Mono/MonoString.cpp
vmkit/trunk/lib/N3/PNetLib/PNetMSCorlib.cpp
vmkit/trunk/lib/N3/PNetLib/PNetString.cpp
vmkit/trunk/lib/N3/VMCore/BackTrace.cpp
vmkit/trunk/lib/N3/VMCore/CLIJit.cpp
vmkit/trunk/lib/N3/VMCore/CLIJit.h
vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp
vmkit/trunk/lib/N3/VMCore/CLIRuntimeJIT.cpp
vmkit/trunk/lib/N3/VMCore/LowerArrayLength.cpp
vmkit/trunk/lib/N3/VMCore/N3.cpp
vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp
vmkit/trunk/lib/N3/VMCore/Opcodes.cpp
vmkit/trunk/lib/N3/VMCore/VMCache.cpp
vmkit/trunk/lib/N3/VMCore/VMClass.cpp
vmkit/trunk/lib/N3/VMCore/VirtualMachine.h
vmkit/trunk/lib/N3/VMCore/VirtualTables.cpp
vmkit/trunk/tools/jnjvm/Main.cpp
vmkit/trunk/tools/n3-mono/Main.cpp
vmkit/trunk/tools/n3-pnetlib/Main.cpp
vmkit/trunk/tools/vmkit/Launcher.cpp
Modified: vmkit/trunk/include/mvm/JIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/JIT.h?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/JIT.h (original)
+++ vmkit/trunk/include/mvm/JIT.h Fri Oct 10 07:51:51 2008
@@ -39,9 +39,6 @@
virtual ~JITInfo() {}
};
-
-namespace jit {
-
const double MaxDouble = +INFINITY; //1.0 / 0.0;
const double MinDouble = -INFINITY;//-1.0 / 0.0;
const double MaxLongDouble = 9223372036854775807.0;
@@ -61,134 +58,139 @@
const float NaNFloat = NAN; //(float)(((float)0.0) / (float)0.0);
const double NaNDouble = NAN; //0.0 / 0.0;
-extern llvm::Function* exceptionEndCatch;
-extern llvm::Function* exceptionBeginCatch;
-extern llvm::Function* unwindResume;
-extern llvm::Function* exceptionSelector;
-extern llvm::Function* personality;
-extern llvm::Function* llvmGetException;
-
-extern llvm::Function* printFloatLLVM;
-extern llvm::Function* printDoubleLLVM;
-extern llvm::Function* printLongLLVM;
-extern llvm::Function* printIntLLVM;
-extern llvm::Function* printObjectLLVM;
-
-extern llvm::Function* setjmpLLVM;
-
-extern llvm::Function* func_llvm_fabs_f32;
-extern llvm::Function* func_llvm_fabs_f64;
-extern llvm::Function* func_llvm_sqrt_f64;
-extern llvm::Function* func_llvm_sin_f64;
-extern llvm::Function* func_llvm_cos_f64;
-extern llvm::Function* func_llvm_tan_f64;
-extern llvm::Function* func_llvm_asin_f64;
-extern llvm::Function* func_llvm_acos_f64;
-extern llvm::Function* func_llvm_atan_f64;
-extern llvm::Function* func_llvm_atan2_f64;
-extern llvm::Function* func_llvm_exp_f64;
-extern llvm::Function* func_llvm_log_f64;
-extern llvm::Function* func_llvm_pow_f64;
-extern llvm::Function* func_llvm_ceil_f64;
-extern llvm::Function* func_llvm_floor_f64;
-extern llvm::Function* func_llvm_rint_f64;
-extern llvm::Function* func_llvm_cbrt_f64;
-extern llvm::Function* func_llvm_cosh_f64;
-extern llvm::Function* func_llvm_expm1_f64;
-extern llvm::Function* func_llvm_hypot_f64;
-extern llvm::Function* func_llvm_log10_f64;
-extern llvm::Function* func_llvm_log1p_f64;
-extern llvm::Function* func_llvm_sinh_f64;
-extern llvm::Function* func_llvm_tanh_f64;
-
-extern llvm::Function* llvm_memcpy_i32;
-extern llvm::Function* llvm_memset_i32;
-extern llvm::Function* llvm_atomic_lcs_i8;
-extern llvm::Function* llvm_atomic_lcs_i16;
-extern llvm::Function* llvm_atomic_lcs_i32;
-extern llvm::Function* llvm_atomic_lcs_i64;
-
-extern llvm::ExecutionEngine* executionEngine;
-
-extern uint64 getTypeSize(const llvm::Type* type);
-extern void AddStandardCompilePasses(llvm::FunctionPassManager*);
-extern void runPasses(llvm::Function* func, llvm::FunctionPassManager*);
-extern void initialise();
-
-
-extern mvm::Lock* protectEngine;
-extern llvm::ConstantInt* constantInt8Zero;
-extern llvm::ConstantInt* constantZero;
-extern llvm::ConstantInt* constantOne;
-extern llvm::ConstantInt* constantTwo;
-extern llvm::ConstantInt* constantThree;
-extern llvm::ConstantInt* constantFour;
-extern llvm::ConstantInt* constantFive;
-extern llvm::ConstantInt* constantSix;
-extern llvm::ConstantInt* constantSeven;
-extern llvm::ConstantInt* constantEight;
-extern llvm::ConstantInt* constantMinusOne;
-extern llvm::ConstantInt* constantLongMinusOne;
-extern llvm::ConstantInt* constantLongZero;
-extern llvm::ConstantInt* constantLongOne;
-extern llvm::ConstantInt* constantMinInt;
-extern llvm::ConstantInt* constantMaxInt;
-extern llvm::ConstantInt* constantMinLong;
-extern llvm::ConstantInt* constantMaxLong;
-extern llvm::ConstantFP* constantFloatZero;
-extern llvm::ConstantFP* constantFloatOne;
-extern llvm::ConstantFP* constantFloatTwo;
-extern llvm::ConstantFP* constantDoubleZero;
-extern llvm::ConstantFP* constantDoubleOne;
-extern llvm::ConstantFP* constantMaxIntFloat;
-extern llvm::ConstantFP* constantMinIntFloat;
-extern llvm::ConstantFP* constantMinLongFloat;
-extern llvm::ConstantFP* constantMinLongDouble;
-extern llvm::ConstantFP* constantMaxLongFloat;
-extern llvm::ConstantFP* constantMaxIntDouble;
-extern llvm::ConstantFP* constantMinIntDouble;
-extern llvm::ConstantFP* constantMaxLongDouble;
-extern llvm::ConstantFP* constantDoubleInfinity;
-extern llvm::ConstantFP* constantDoubleMinusInfinity;
-extern llvm::ConstantFP* constantFloatInfinity;
-extern llvm::ConstantFP* constantFloatMinusInfinity;
-extern llvm::ConstantFP* constantFloatMinusZero;
-extern llvm::ConstantFP* constantDoubleMinusZero;
-extern llvm::Constant* constantPtrNull;
-extern llvm::ConstantInt* constantPtrSize;
-extern const llvm::PointerType* ptrType;
-extern const llvm::PointerType* ptr32Type;
-extern const llvm::PointerType* ptrPtrType;
-extern const llvm::Type* arrayPtrType;
-
-
-extern llvm::Module *globalModule;
-extern llvm::ExistingModuleProvider *globalModuleProvider;
-extern mvm::MvmMemoryManager *memoryManager;
-
-extern int disassemble(unsigned int* addr);
-
-extern int getBacktrace(void** stack, int size);
-extern Code* getCodeFromPointer(void* addr);
-extern void addMethodInfo(void* end, Code* c);
-
-extern uint8 (*llvm_atomic_cmp_swap_i8) ( uint8* ptr, uint8 cmp, uint8 val );
-extern uint16 (*llvm_atomic_cmp_swap_i16) ( uint16* ptr, uint16 cmp, uint16 val );
-extern uint32 (*llvm_atomic_cmp_swap_i32) ( uint32* ptr, uint32 cmp, uint32 val );
-extern uint64 (*llvm_atomic_cmp_swap_i64) ( uint64* ptr, uint64 cmp, uint64 val );
-
-extern llvm::GlobalVariable* executionEnvironment;
-extern mvm::Thread* (*getExecutionEnvironment)();
-extern void (*setExecutionEnvironment)(mvm::Thread*);
+class MvmModule : public llvm::Module {
+public:
+
+ MvmModule(const std::string& ModuleID);
+
+ llvm::Function* exceptionEndCatch;
+ llvm::Function* exceptionBeginCatch;
+ llvm::Function* unwindResume;
+ llvm::Function* exceptionSelector;
+ llvm::Function* personality;
+ llvm::Function* llvmGetException;
+
+ llvm::Function* printFloatLLVM;
+ llvm::Function* printDoubleLLVM;
+ llvm::Function* printLongLLVM;
+ llvm::Function* printIntLLVM;
+ llvm::Function* printObjectLLVM;
+
+ llvm::Function* setjmpLLVM;
+
+ llvm::Function* func_llvm_fabs_f32;
+ llvm::Function* func_llvm_fabs_f64;
+ llvm::Function* func_llvm_sqrt_f64;
+ llvm::Function* func_llvm_sin_f64;
+ llvm::Function* func_llvm_cos_f64;
+ llvm::Function* func_llvm_tan_f64;
+ llvm::Function* func_llvm_asin_f64;
+ llvm::Function* func_llvm_acos_f64;
+ llvm::Function* func_llvm_atan_f64;
+ llvm::Function* func_llvm_atan2_f64;
+ llvm::Function* func_llvm_exp_f64;
+ llvm::Function* func_llvm_log_f64;
+ llvm::Function* func_llvm_pow_f64;
+ llvm::Function* func_llvm_ceil_f64;
+ llvm::Function* func_llvm_floor_f64;
+ llvm::Function* func_llvm_rint_f64;
+ llvm::Function* func_llvm_cbrt_f64;
+ llvm::Function* func_llvm_cosh_f64;
+ llvm::Function* func_llvm_expm1_f64;
+ llvm::Function* func_llvm_hypot_f64;
+ llvm::Function* func_llvm_log10_f64;
+ llvm::Function* func_llvm_log1p_f64;
+ llvm::Function* func_llvm_sinh_f64;
+ llvm::Function* func_llvm_tanh_f64;
+
+ llvm::Function* llvm_memcpy_i32;
+ llvm::Function* llvm_memset_i32;
+ llvm::Function* llvm_atomic_lcs_i8;
+ llvm::Function* llvm_atomic_lcs_i16;
+ llvm::Function* llvm_atomic_lcs_i32;
+ llvm::Function* llvm_atomic_lcs_i64;
+
+ static llvm::ExecutionEngine* executionEngine;
+ static mvm::Lock* protectEngine;
+
+ static uint64 getTypeSize(const llvm::Type* type);
+ static void AddStandardCompilePasses(llvm::FunctionPassManager*);
+ static void runPasses(llvm::Function* func, llvm::FunctionPassManager*);
+ static void initialise();
+
+ static llvm::ConstantInt* constantInt8Zero;
+ static llvm::ConstantInt* constantZero;
+ static llvm::ConstantInt* constantOne;
+ static llvm::ConstantInt* constantTwo;
+ static llvm::ConstantInt* constantThree;
+ static llvm::ConstantInt* constantFour;
+ static llvm::ConstantInt* constantFive;
+ static llvm::ConstantInt* constantSix;
+ static llvm::ConstantInt* constantSeven;
+ static llvm::ConstantInt* constantEight;
+ static llvm::ConstantInt* constantMinusOne;
+ static llvm::ConstantInt* constantLongMinusOne;
+ static llvm::ConstantInt* constantLongZero;
+ static llvm::ConstantInt* constantLongOne;
+ static llvm::ConstantInt* constantMinInt;
+ static llvm::ConstantInt* constantMaxInt;
+ static llvm::ConstantInt* constantMinLong;
+ static llvm::ConstantInt* constantMaxLong;
+ static llvm::ConstantFP* constantFloatZero;
+ static llvm::ConstantFP* constantFloatOne;
+ static llvm::ConstantFP* constantFloatTwo;
+ static llvm::ConstantFP* constantDoubleZero;
+ static llvm::ConstantFP* constantDoubleOne;
+ static llvm::ConstantFP* constantMaxIntFloat;
+ static llvm::ConstantFP* constantMinIntFloat;
+ static llvm::ConstantFP* constantMinLongFloat;
+ static llvm::ConstantFP* constantMinLongDouble;
+ static llvm::ConstantFP* constantMaxLongFloat;
+ static llvm::ConstantFP* constantMaxIntDouble;
+ static llvm::ConstantFP* constantMinIntDouble;
+ static llvm::ConstantFP* constantMaxLongDouble;
+ static llvm::ConstantFP* constantDoubleInfinity;
+ static llvm::ConstantFP* constantDoubleMinusInfinity;
+ static llvm::ConstantFP* constantFloatInfinity;
+ static llvm::ConstantFP* constantFloatMinusInfinity;
+ static llvm::ConstantFP* constantFloatMinusZero;
+ static llvm::ConstantFP* constantDoubleMinusZero;
+ static llvm::Constant* constantPtrNull;
+ static llvm::ConstantInt* constantPtrSize;
+ static const llvm::PointerType* ptrType;
+ static const llvm::PointerType* ptr32Type;
+ static const llvm::PointerType* ptrPtrType;
+ static const llvm::Type* arrayPtrType;
+
+
+ static llvm::Module *globalModule;
+ static llvm::ExistingModuleProvider *globalModuleProvider;
+ static mvm::MvmMemoryManager *memoryManager;
+
+ static int disassemble(unsigned int* addr);
+
+ static int getBacktrace(void** stack, int size);
+ static Code* getCodeFromPointer(void* addr);
+ static void addMethodInfo(void* end, Code* c);
+
+ static uint8 (*llvm_atomic_cmp_swap_i8) ( uint8* ptr, uint8 cmp, uint8 val );
+ static uint16 (*llvm_atomic_cmp_swap_i16) ( uint16* ptr, uint16 cmp, uint16 val );
+ static uint32 (*llvm_atomic_cmp_swap_i32) ( uint32* ptr, uint32 cmp, uint32 val );
+ static uint64 (*llvm_atomic_cmp_swap_i64) ( uint64* ptr, uint64 cmp, uint64 val );
+
+ static llvm::GlobalVariable* executionEnvironment;
+ static mvm::Thread* (*getExecutionEnvironment)();
+ static void (*setExecutionEnvironment)(mvm::Thread*);
+
+};
// TODO: find what macro for gcc < 4.2
#if 1
#define __sync_bool_compare_and_swap(ptr, cmp, val) \
- (mvm::jit::llvm_atomic_cmp_swap_i32((uint32*)(ptr), (uint32)(cmp), (uint32)(val)) == (uint32)(cmp))
+ (mvm::MvmModule::llvm_atomic_cmp_swap_i32((uint32*)(ptr), (uint32)(cmp), (uint32)(val)) == (uint32)(cmp))
#define __sync_val_compare_and_swap(ptr, cmp,val) \
- mvm::jit::llvm_atomic_cmp_swap_i32((uint32*)(ptr), (uint32)(cmp), (uint32)(val))
+ mvm::MvmModule::llvm_atomic_cmp_swap_i32((uint32*)(ptr), (uint32)(cmp), (uint32)(val))
#endif
-} // end namespace jit
} // end namespace mvm
Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMStackWalker.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMStackWalker.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMStackWalker.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMStackWalker.cpp Fri Oct 10 07:51:51 2008
@@ -103,7 +103,7 @@
) {
Jnjvm* vm = JavaThread::get()->isolate;
int* ips[100];
- int real_size = mvm::jit::getBacktrace((void**)(void*)ips, 100);
+ int real_size = mvm::MvmModule::getBacktrace((void**)(void*)ips, 100);
#ifdef ISOLATE_SHARING
UserConstantPool* pools[100];
getPools(pools, 100);
Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp Fri Oct 10 07:51:51 2008
@@ -39,7 +39,7 @@
jobject throwable) {
Jnjvm* vm = JavaThread::get()->isolate;
int** stack = (int**)malloc(sizeof(int*) * 100);
- int real_size = mvm::jit::getBacktrace((void**)stack, 100);
+ int real_size = mvm::MvmModule::getBacktrace((void**)stack, 100);
stack[real_size] = 0;
JavaObject* vmThrowable = vm->upcalls->newVMThrowable->doNew(vm);
uint64 ptr = (uint64)vmThrowable + vm->upcalls->vmDataVMThrowable->ptrOffset;
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp Fri Oct 10 07:51:51 2008
@@ -23,7 +23,7 @@
using namespace jnjvm;
JavaMethod* JavaJIT::IPToJavaMethod(void* begIp) {
- mvm::Code* code = mvm::jit::getCodeFromPointer(begIp);
+ mvm::Code* code = mvm::MvmModule::getCodeFromPointer(begIp);
if (code) {
JavaMethod* meth = (JavaMethod*)code->getMetaInfo();
if (meth) {
@@ -35,10 +35,10 @@
void JavaJIT::printBacktrace() {
int* ips[100];
- int real_size = mvm::jit::getBacktrace((void**)(void*)ips, 100);
+ int real_size = mvm::MvmModule::getBacktrace((void**)(void*)ips, 100);
int n = 0;
while (n < real_size) {
- mvm::Code* code = mvm::jit::getCodeFromPointer(ips[n++]);
+ mvm::Code* code = mvm::MvmModule::getCodeFromPointer(ips[n++]);
if (code) {
JavaMethod* meth = (JavaMethod*)code->getMetaInfo();
if (meth) {
@@ -64,11 +64,11 @@
#ifndef ISOLATE_SHARING
UserClass* JavaJIT::getCallingClass() {
int* ips[10];
- int real_size = mvm::jit::getBacktrace((void**)(void*)ips, 10);
+ int real_size = mvm::MvmModule::getBacktrace((void**)(void*)ips, 10);
int n = 0;
int i = 0;
while (n < real_size) {
- mvm::Code* code = mvm::jit::getCodeFromPointer(ips[n++]);
+ mvm::Code* code = mvm::MvmModule::getCodeFromPointer(ips[n++]);
if (code) {
JavaMethod* meth = (JavaMethod*)code->getMetaInfo();
if (meth) {
@@ -85,11 +85,11 @@
UserClass* JavaJIT::getCallingClassWalker() {
int* ips[10];
- int real_size = mvm::jit::getBacktrace((void**)(void*)ips, 10);
+ int real_size = mvm::MvmModule::getBacktrace((void**)(void*)ips, 10);
int n = 0;
int i = 0;
while (n < real_size) {
- mvm::Code* code = mvm::jit::getCodeFromPointer(ips[n++]);
+ mvm::Code* code = mvm::MvmModule::getCodeFromPointer(ips[n++]);
if (code) {
JavaMethod* meth = (JavaMethod*)code->getMetaInfo();
if (meth) {
@@ -109,11 +109,11 @@
Class* res = 0;
int* ips[10];
- int real_size = mvm::jit::getBacktrace((void**)(void*)ips, 10);
+ int real_size = mvm::MvmModule::getBacktrace((void**)(void*)ips, 10);
int n = 0;
int i = 0;
while (n < real_size) {
- mvm::Code* code = mvm::jit::getCodeFromPointer(ips[n++]);
+ mvm::Code* code = mvm::MvmModule::getCodeFromPointer(ips[n++]);
if (code) {
JavaMethod* meth = (JavaMethod*)code->getMetaInfo();
if (meth) {
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp Fri Oct 10 07:51:51 2008
@@ -101,12 +101,12 @@
lockVar = 0;
condVar = 0;
virtualVT = 0;
- JInfo = 0;
}
Class::Class() {
ctpInfo = 0;
staticVT = 0;
+ JInfo = 0;
}
Class::~Class() {
@@ -263,7 +263,6 @@
this->classLoader = loader;
this->array = isArray;
this->primitive = false;
- this->JInfo = 0;
#if !defined(ISOLATE) && !defined(ISOLATE_SHARING)
this->delegatee = 0;
#endif
@@ -286,6 +285,7 @@
bytes = B;
super = 0;
ctpInfo = 0;
+ JInfo = 0;
#if !defined(ISOLATE) && !defined(ISOLATE_SHARING)
_staticInstance = 0;
#endif
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h Fri Oct 10 07:51:51 2008
@@ -498,18 +498,6 @@
///
CommonClass();
- mvm::JITInfo* JInfo;
- template<typename Ty>
- Ty *getInfo() {
- if (!JInfo) {
- JInfo = new Ty(this);
- }
-
- assert((void*)dynamic_cast<Ty*>(JInfo) == (void*)JInfo &&
- "Invalid concrete type or multiple inheritence for getInfo");
- return static_cast<Ty*>(JInfo);
- }
-
void getDeclaredConstructors(std::vector<JavaMethod*>& res, bool publicOnly);
void getDeclaredMethods(std::vector<JavaMethod*>& res, bool publicOnly);
void getDeclaredFields(std::vector<JavaField*>& res, bool publicOnly);
@@ -696,6 +684,18 @@
return &innerClasses;
}
#endif
+
+ mvm::JITInfo* JInfo;
+ template<typename Ty>
+ Ty *getInfo() {
+ if (!JInfo) {
+ JInfo = new Ty(this);
+ }
+
+ assert((void*)dynamic_cast<Ty*>(JInfo) == (void*)JInfo &&
+ "Invalid concrete type or multiple inheritence for getInfo");
+ return static_cast<Ty*>(JInfo);
+ }
};
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp Fri Oct 10 07:51:51 2008
@@ -188,7 +188,6 @@
JavaConstantPool::JavaConstantPool(Class* cl, Reader& reader) {
ctpSize = reader.readU2();
classDef = cl;
- JInfo = 0;
ctpRes = new void*[ctpSize];
ctpDef = new sint32[ctpSize];
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.h?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.h Fri Oct 10 07:51:51 2008
@@ -258,7 +258,6 @@
ctpRes = 0;
ctpType = 0;
ctpDef = 0;
- JInfo = 0;
}
/// JavaConstantPool - Reads the bytecode of the class to get
@@ -272,20 +271,7 @@
delete ctpRes;
delete ctpDef;
delete ctpType;
- }
-
- mvm::JITInfo* JInfo;
- template<typename Ty>
- Ty *getInfo() {
- if (!JInfo) {
- JInfo = new Ty(this);
- }
-
- assert((void*)dynamic_cast<Ty*>(JInfo) == (void*)JInfo &&
- "Invalid concrete type or multiple inheritence for getInfo");
- return static_cast<Ty*>(JInfo);
- }
-
+ }
};
} // end namespace jnjvm
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Fri Oct 10 07:51:51 2008
@@ -74,7 +74,7 @@
JITVerifyNull(args[0]);
- Value* VT = CallInst::Create(JnjvmModule::GetVTFunction, args[0], "",
+ Value* VT = CallInst::Create(module->GetVTFunction, args[0], "",
currentBlock);
std::vector<Value*> indexes2; //[3];
#ifdef ISOLATE_SHARING
@@ -90,11 +90,11 @@
#endif
} else {
- Value* val = getConstantPoolAt(index, JnjvmModule::VirtualLookupFunction,
+ Value* val = getConstantPoolAt(index, module->VirtualLookupFunction,
Type::Int32Ty, args[0], true);
indexes2.push_back(val);
#ifdef ISOLATE_SHARING
- Value* mul = BinaryOperator::createMul(val, mvm::jit::constantMinusOne,
+ Value* mul = BinaryOperator::createMul(val, module->constantMinusOne,
"", currentBlock);
indexesCtp.push_back(mul);
#endif
@@ -112,7 +112,7 @@
currentBlock);
CTP = new LoadInst(CTP, "", currentBlock);
- CTP = new BitCastInst(CTP, JnjvmModule::ConstantPoolType, "", currentBlock);
+ CTP = new BitCastInst(CTP, module->ConstantPoolType, "", currentBlock);
args.push_back(CTP);
#endif
Value* val = invoke(Func, args, "", currentBlock);
@@ -121,7 +121,7 @@
if (retType != Type::VoidTy) {
push(val, retTypedef->isUnsigned());
if (retType == Type::DoubleTy || retType == Type::Int64Ty) {
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
}
}
@@ -147,7 +147,7 @@
Function* func = llvmFunction;
if (jnjvm) {
- mvm::jit::executionEngine->addGlobalMapping(func, natPtr);
+ module->executionEngine->addGlobalMapping(func, natPtr);
return llvmFunction;
}
@@ -186,7 +186,7 @@
std::vector<Value*> Args;
Args.push_back(lastArg);
Args.push_back(isolateLocal);
- CallInst::Create(JnjvmModule::ServiceCallStartFunction, Args.begin(),
+ CallInst::Create(module->ServiceCallStartFunction, Args.begin(),
Args.end(), "", currentBlock);
BranchInst::Create(endBlock, currentBlock);
currentBlock = endBlock;
@@ -195,11 +195,11 @@
#endif
- Value* buf = llvm::CallInst::Create(JnjvmModule::GetSJLJBufferFunction,
+ Value* buf = llvm::CallInst::Create(module->GetSJLJBufferFunction,
"", currentBlock);
- Value* test = llvm::CallInst::Create(mvm::jit::setjmpLLVM, buf, "",
+ Value* test = llvm::CallInst::Create(module->setjmpLLVM, buf, "",
currentBlock);
- test = new ICmpInst(ICmpInst::ICMP_EQ, test, mvm::jit::constantZero, "",
+ test = new ICmpInst(ICmpInst::ICMP_EQ, test, module->constantZero, "",
currentBlock);
llvm::BranchInst::Create(executeBlock, endBlock, test, currentBlock);
@@ -220,19 +220,17 @@
int64_t jniEnv = (int64_t)&(JavaThread::get()->isolate->jniEnv);
nativeArgs.push_back(
ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, jniEnv),
- mvm::jit::ptrType));
+ module->ptrType));
uint32 index = 0;
if (stat) {
#ifdef ISOLATE_SHARING
Value* val = getClassCtp();
- Value* res = CallInst::Create(JnjvmModule::GetClassDelegateeFunction,
+ Value* res = CallInst::Create(module->GetClassDelegateeFunction,
val, "", currentBlock);
nativeArgs.push_back(res);
#else
- LLVMClassInfo* LCI =
- (LLVMClassInfo*)module->getClassInfo(compilingClass);
- nativeArgs.push_back(LCI->getDelegatee(this));
+ nativeArgs.push_back(module->getJavaClass(compilingClass, this));
#endif
index = 2;
} else {
@@ -263,7 +261,7 @@
if (isSynchro(compilingMethod->access))
endSynchronize();
- llvm::CallInst::Create(JnjvmModule::JniProceedPendingExceptionFunction, "",
+ llvm::CallInst::Create(module->JniProceedPendingExceptionFunction, "",
currentBlock);
if (returnType != Type::VoidTy)
@@ -281,23 +279,23 @@
void JavaJIT::monitorEnter(Value* obj) {
std::vector<Value*> gep;
- gep.push_back(mvm::jit::constantZero);
- gep.push_back(JnjvmModule::JavaObjectLockOffsetConstant);
+ gep.push_back(module->constantZero);
+ gep.push_back(module->JavaObjectLockOffsetConstant);
Value* lockPtr = GetElementPtrInst::Create(obj, gep.begin(), gep.end(), "",
currentBlock);
- Value* threadId = CallInst::Create(JnjvmModule::GetThreadIDFunction, "",
+ Value* threadId = CallInst::Create(module->GetThreadIDFunction, "",
currentBlock);
std::vector<Value*> atomicArgs;
atomicArgs.push_back(lockPtr);
- atomicArgs.push_back(mvm::jit::constantZero);
+ atomicArgs.push_back(module->constantZero);
atomicArgs.push_back(threadId);
// Do the atomic compare and swap.
- Value* atomic = CallInst::Create(mvm::jit::llvm_atomic_lcs_i32,
+ Value* atomic = CallInst::Create(module->llvm_atomic_lcs_i32,
atomicArgs.begin(), atomicArgs.end(), "",
currentBlock);
- Value* cmp = new ICmpInst(ICmpInst::ICMP_EQ, atomic, mvm::jit::constantZero,
+ Value* cmp = new ICmpInst(ICmpInst::ICMP_EQ, atomic, module->constantZero,
"", currentBlock);
BasicBlock* OK = createBasicBlock("synchronize passed");
@@ -313,7 +311,7 @@
Value* thinMask = ConstantInt::get(Type::Int32Ty, 0x80000000);
Value* isThin = BinaryOperator::createAnd(atomic, thinMask, "",
currentBlock);
- cmp = new ICmpInst(ICmpInst::ICMP_EQ, isThin, mvm::jit::constantZero, "",
+ cmp = new ICmpInst(ICmpInst::ICMP_EQ, isThin, module->constantZero, "",
currentBlock);
BranchInst::Create(ThinLockBB, FatLockBB, cmp, currentBlock);
@@ -342,7 +340,7 @@
currentBlock = IncCounterBB;
// The counter will not overflow, increment it.
- Value* Add = BinaryOperator::createAdd(mvm::jit::constantOne, atomic, "",
+ Value* Add = BinaryOperator::createAdd(module->constantOne, atomic, "",
currentBlock);
new StoreInst(Add, lockPtr, false, currentBlock);
BranchInst::Create(OK, currentBlock);
@@ -351,26 +349,26 @@
// The counter will overflow, call this function to create a new lock,
// lock it 0x101 times, and pass.
- CallInst::Create(JnjvmModule::OverflowThinLockFunction, obj, "",
+ CallInst::Create(module->OverflowThinLockFunction, obj, "",
currentBlock);
BranchInst::Create(OK, currentBlock);
currentBlock = FatLockBB;
// Either it's a fat lock or there is contention.
- CallInst::Create(JnjvmModule::AquireObjectFunction, obj, "", currentBlock);
+ CallInst::Create(module->AquireObjectFunction, obj, "", currentBlock);
BranchInst::Create(OK, currentBlock);
currentBlock = OK;
}
void JavaJIT::monitorExit(Value* obj) {
std::vector<Value*> gep;
- gep.push_back(mvm::jit::constantZero);
- gep.push_back(JnjvmModule::JavaObjectLockOffsetConstant);
+ gep.push_back(module->constantZero);
+ gep.push_back(module->JavaObjectLockOffsetConstant);
Value* lockPtr = GetElementPtrInst::Create(obj, gep.begin(), gep.end(), "",
currentBlock);
Value* lock = new LoadInst(lockPtr, "", currentBlock);
- Value* threadId = CallInst::Create(JnjvmModule::GetThreadIDFunction, "",
+ Value* threadId = CallInst::Create(module->GetThreadIDFunction, "",
currentBlock);
Value* cmp = new ICmpInst(ICmpInst::ICMP_EQ, lock, threadId, "",
@@ -388,7 +386,7 @@
// Locked once, set zero
currentBlock = LockedOnceBB;
- new StoreInst(mvm::jit::constantZero, lockPtr, false, currentBlock);
+ new StoreInst(module->constantZero, lockPtr, false, currentBlock);
BranchInst::Create(EndUnlock, currentBlock);
currentBlock = NotLockedOnceBB;
@@ -396,7 +394,7 @@
Value* thinMask = ConstantInt::get(Type::Int32Ty, 0x80000000);
Value* isThin = BinaryOperator::createAnd(lock, thinMask, "",
currentBlock);
- cmp = new ICmpInst(ICmpInst::ICMP_EQ, isThin, mvm::jit::constantZero, "",
+ cmp = new ICmpInst(ICmpInst::ICMP_EQ, isThin, module->constantZero, "",
currentBlock);
BranchInst::Create(ThinLockBB, FatLockBB, cmp, currentBlock);
@@ -404,7 +402,7 @@
currentBlock = ThinLockBB;
// Decrement the counter.
- Value* Sub = BinaryOperator::createSub(lock, mvm::jit::constantOne, "",
+ Value* Sub = BinaryOperator::createSub(lock, module->constantOne, "",
currentBlock);
new StoreInst(Sub, lockPtr, false, currentBlock);
BranchInst::Create(EndUnlock, currentBlock);
@@ -412,7 +410,7 @@
currentBlock = FatLockBB;
// Either it's a fat lock or there is contention.
- CallInst::Create(JnjvmModule::ReleaseObjectFunction, obj, "", currentBlock);
+ CallInst::Create(module->ReleaseObjectFunction, obj, "", currentBlock);
BranchInst::Create(EndUnlock, currentBlock);
currentBlock = EndUnlock;
}
@@ -421,8 +419,8 @@
Value* JavaJIT::getStaticInstanceCtp() {
Value* cl = getClassCtp();
std::vector<Value*> indexes; //[3];
- indexes.push_back(mvm::jit::constantZero);
- indexes.push_back(mvm::jit::constantSeven);
+ indexes.push_back(module->constantZero);
+ indexes.push_back(module->constantSeven);
Value* arg1 = GetElementPtrInst::Create(cl, indexes.begin(),
indexes.end(), "", currentBlock);
arg1 = new LoadInst(arg1, "", false, currentBlock);
@@ -432,11 +430,11 @@
Value* JavaJIT::getClassCtp() {
std::vector<Value*> indexes; //[3];
- indexes.push_back(mvm::jit::constantOne);
+ indexes.push_back(module->constantOne);
Value* arg1 = GetElementPtrInst::Create(ctpCache, indexes.begin(),
indexes.end(), "", currentBlock);
arg1 = new LoadInst(arg1, "", false, currentBlock);
- arg1 = new BitCastInst(arg1, JnjvmModule::JavaClassType, "", currentBlock);
+ arg1 = new BitCastInst(arg1, module->JavaClassType, "", currentBlock);
return arg1;
}
#endif
@@ -447,9 +445,7 @@
obj = llvmFunction->arg_begin();
} else {
#ifndef ISOLATE_SHARING
- LLVMClassInfo* LCI =
- (LLVMClassInfo*)module->getClassInfo(compilingClass);
- obj = LCI->getStaticVar(this);
+ obj = module->getStaticInstance(compilingClass, this);
#else
obj = getStaticInstanceCtp();
#endif
@@ -458,10 +454,10 @@
monitorEnter(obj);
#else
if (ServiceDomain::isLockableDomain(compilingClass->isolate)) {
- llvm::CallInst::Create(JnjvmModule::AquireObjectInSharedDomainFunction,
+ llvm::CallInst::Create(module->AquireObjectInSharedDomainFunction,
obj, "", currentBlock);
} else {
- llvm::CallInst::Create(JnjvmModule::AquireObjectFunction,
+ llvm::CallInst::Create(module->AquireObjectFunction,
obj, "", currentBlock);
}
#endif
@@ -473,9 +469,7 @@
obj = llvmFunction->arg_begin();
} else {
#ifndef ISOLATE_SHARING
- LLVMClassInfo* LCI =
- (LLVMClassInfo*)module->getClassInfo(compilingClass);
- obj = LCI->getStaticVar(this);
+ obj = module->getStaticInstance(compilingClass, this);
#else
obj = getStaticInstanceCtp();
#endif
@@ -484,10 +478,10 @@
monitorExit(obj);
#else
if (ServiceDomain::isLockableDomain(compilingClass->isolate)) {
- llvm::CallInst::Create(JnjvmModule::ReleaseObjectInSharedDomainFunction,
+ llvm::CallInst::Create(module->ReleaseObjectInSharedDomainFunction,
argsSync.begin(), argsSync.end(), "", currentBlock);
} else {
- llvm::CallInst::Create(JnjvmModule::ReleaseObjectFunction, argsSync.begin(),
+ llvm::CallInst::Create(module->ReleaseObjectFunction, argsSync.begin(),
argsSync.end(), "", currentBlock);
}
#endif
@@ -541,7 +535,7 @@
doubleLocals.push_back(new AllocaInst(Type::DoubleTy, "", currentBlock));
longLocals.push_back(new AllocaInst(Type::Int64Ty, "", currentBlock));
floatLocals.push_back(new AllocaInst(Type::FloatTy, "", currentBlock));
- objectLocals.push_back(new AllocaInst(JnjvmModule::JavaObjectType, "",
+ objectLocals.push_back(new AllocaInst(module->JavaObjectType, "",
currentBlock));
}
@@ -612,7 +606,7 @@
std::vector<Value*> Args;
Args.push_back(args[args.size()- 2]);
Args.push_back(isolateLocal);
- CallInst::Create(JnjvmModule::ServiceCallStartFunction, Args.begin(),
+ CallInst::Create(module->ServiceCallStartFunction, Args.begin(),
Args.end(), "", currentBlock);
BranchInst::Create(endBlock, currentBlock);
currentBlock = endBlock;
@@ -643,7 +637,7 @@
std::vector<Value*> Args;
Args.push_back(args[args.size() - 1]);
Args.push_back(isolateLocal);
- CallInst::Create(JnjvmModule::ServiceCallStopFunction, Args.begin(),
+ CallInst::Create(module->ServiceCallStopFunction, Args.begin(),
Args.end(), "", currentBlock);
BranchInst::Create(newEndBlock, currentBlock);
currentBlock = newEndBlock;
@@ -697,7 +691,7 @@
{
std::vector<llvm::Value*> args;
args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)compilingMethod));
- llvm::CallInst::Create(JnjvmModule::PrintMethodStartFunction, args.begin(),
+ llvm::CallInst::Create(module->PrintMethodStartFunction, args.begin(),
args.end(), "", currentBlock);
}
#endif
@@ -709,7 +703,7 @@
doubleLocals.push_back(new AllocaInst(Type::DoubleTy, "", currentBlock));
longLocals.push_back(new AllocaInst(Type::Int64Ty, "", currentBlock));
floatLocals.push_back(new AllocaInst(Type::FloatTy, "", currentBlock));
- objectLocals.push_back(new AllocaInst(JnjvmModule::JavaObjectType, "",
+ objectLocals.push_back(new AllocaInst(module->JavaObjectType, "",
currentBlock));
}
@@ -779,7 +773,7 @@
std::vector<Value*> Args;
Args.push_back(i);
Args.push_back(isolateLocal);
- CallInst::Create(JnjvmModule::ServiceCallStartFunction, Args.begin(),
+ CallInst::Create(module->ServiceCallStartFunction, Args.begin(),
Args.end(), "", currentBlock);
BranchInst::Create(endBlock, currentBlock);
currentBlock = endBlock;
@@ -787,7 +781,7 @@
i++;
ctpCache = i;
#endif
- Value* addrCtpCache = new AllocaInst(JnjvmModule::ConstantPoolType, "",
+ Value* addrCtpCache = new AllocaInst(module->ConstantPoolType, "",
currentBlock);
/// make it volatile to be sure it's on the stack
new StoreInst(ctpCache, addrCtpCache, true, currentBlock);
@@ -832,7 +826,7 @@
{
std::vector<llvm::Value*> args;
args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)compilingMethod));
- llvm::CallInst::Create(JnjvmModule::PrintMethodEndFunction, args.begin(),
+ llvm::CallInst::Create(module->PrintMethodEndFunction, args.begin(),
args.end(), "", currentBlock);
}
#endif
@@ -848,7 +842,7 @@
std::vector<Value*> Args;
Args.push_back(i);
Args.push_back(isolateLocal);
- CallInst::Create(JnjvmModule::ServiceCallStopFunction, Args.begin(),
+ CallInst::Create(module->ServiceCallStopFunction, Args.begin(),
Args.end(), "", currentBlock);
BranchInst::Create(newEndBlock, currentBlock);
currentBlock = newEndBlock;
@@ -871,9 +865,9 @@
if (PI == PE) {
endExceptionBlock->eraseFromParent();
} else {
- CallInst* ptr_eh_ptr = CallInst::Create(JnjvmModule::GetExceptionFunction,
+ CallInst* ptr_eh_ptr = CallInst::Create(module->GetExceptionFunction,
"eh_ptr", endExceptionBlock);
- llvm::CallInst::Create(mvm::jit::unwindResume, ptr_eh_ptr, "",
+ llvm::CallInst::Create(module->unwindResume, ptr_eh_ptr, "",
endExceptionBlock);
new UnreachableInst(endExceptionBlock);
}
@@ -905,7 +899,7 @@
unsigned sync = isSynchro(compilingMethod->access) ? 1 : 0;
nbe += sync;
if (nbe) {
- supplLocal = new AllocaInst(JnjvmModule::JavaObjectType, "exceptionVar",
+ supplLocal = new AllocaInst(module->JavaObjectType, "exceptionVar",
currentBlock);
}
@@ -924,29 +918,28 @@
argsSync.push_back(llvmFunction->arg_begin());
} else {
#ifndef ISOLATE_SHARING
- LLVMClassInfo* LCI = (LLVMClassInfo*)module->getClassInfo(compilingClass);
- Value* arg = LCI->getStaticVar(this);
+ Value* arg = module->getStaticInstance(compilingClass, this);
#else
Value* arg = getStaticInstanceCtp();
#endif
argsSync.push_back(arg);
}
- llvm::CallInst::Create(JnjvmModule::ReleaseObjectFunction, argsSync.begin(), argsSync.end(),
+ llvm::CallInst::Create(module->ReleaseObjectFunction, argsSync.begin(), argsSync.end(),
"", synchronizeExceptionBlock);
llvm::BranchInst::Create(endExceptionBlock, synchronizeExceptionBlock);
- const PointerType* PointerTy_0 = mvm::jit::ptrType;
+ const PointerType* PointerTy_0 = module->ptrType;
std::vector<Value*> int32_eh_select_params;
Instruction* ptr_eh_ptr =
- llvm::CallInst::Create(mvm::jit::llvmGetException, "eh_ptr",
+ llvm::CallInst::Create(module->llvmGetException, "eh_ptr",
trySynchronizeExceptionBlock);
int32_eh_select_params.push_back(ptr_eh_ptr);
Constant* C = ConstantExpr::getCast(Instruction::BitCast,
- mvm::jit::personality, PointerTy_0);
+ module->personality, PointerTy_0);
int32_eh_select_params.push_back(C);
- int32_eh_select_params.push_back(mvm::jit::constantPtrNull);
- llvm::CallInst::Create(mvm::jit::exceptionSelector,
+ int32_eh_select_params.push_back(module->constantPtrNull);
+ llvm::CallInst::Create(module->exceptionSelector,
int32_eh_select_params.begin(),
int32_eh_select_params.end(),
"eh_select", trySynchronizeExceptionBlock);
@@ -964,7 +957,7 @@
// We don't need the lock here, and Java requires to load the classes in the
// try clause, which may require compilation. Therefore we release the lock
// and acquire it after the exception table is read.
- mvm::jit::executionEngine->lock.release();
+ module->executionEngine->lock.release();
for (uint16 i = 0; i < nbe - sync; ++i) {
Exception* ex = new Exception();
ex->startpc = reader.readU2();
@@ -1017,7 +1010,7 @@
exceptions.push_back(ex);
}
- mvm::jit::executionEngine->lock.acquire();
+ module->executionEngine->lock.acquire();
bool first = true;
for (std::vector<Exception*>::iterator i = exceptions.begin(),
@@ -1035,7 +1028,7 @@
cur->realTest = cur->test;
}
- cur->exceptionPHI = llvm::PHINode::Create(mvm::jit::ptrType, "",
+ cur->exceptionPHI = llvm::PHINode::Create(module->ptrType, "",
cur->realTest);
if (next && cur->startpc == next->startpc && cur->endpc == next->endpc)
@@ -1067,16 +1060,16 @@
}
if (cur->realTest != cur->test) {
- const PointerType* PointerTy_0 = mvm::jit::ptrType;
+ const PointerType* PointerTy_0 = module->ptrType;
std::vector<Value*> int32_eh_select_params;
Instruction* ptr_eh_ptr =
- llvm::CallInst::Create(mvm::jit::llvmGetException, "eh_ptr", cur->test);
+ llvm::CallInst::Create(module->llvmGetException, "eh_ptr", cur->test);
int32_eh_select_params.push_back(ptr_eh_ptr);
Constant* C = ConstantExpr::getCast(Instruction::BitCast,
- mvm::jit::personality, PointerTy_0);
+ module->personality, PointerTy_0);
int32_eh_select_params.push_back(C);
- int32_eh_select_params.push_back(mvm::jit::constantPtrNull);
- llvm::CallInst::Create(mvm::jit::exceptionSelector,
+ int32_eh_select_params.push_back(module->constantPtrNull);
+ llvm::CallInst::Create(module->exceptionSelector,
int32_eh_select_params.begin(),
int32_eh_select_params.end(), "eh_select",
cur->test);
@@ -1090,31 +1083,30 @@
// We're dealing with exceptions, don't catch the exception if the class can
// not be found.
if (cur->catche) cl = getResolvedClass(cur->catche, false, false);
- else cl = CallInst::Create(JnjvmModule::GetJnjvmExceptionClassFunction,
+ else cl = CallInst::Create(module->GetJnjvmExceptionClassFunction,
isolateLocal, "", currentBlock);
#else
assert(cur->catchClass);
- LLVMClassInfo* LCI = (LLVMClassInfo*)module->getClassInfo(cur->catchClass);
- cl = LCI->getVar(this);
+ cl = module->getNativeClass(cur->catchClass, this);
#endif
- Value* cmp = llvm::CallInst::Create(JnjvmModule::CompareExceptionFunction, cl, "",
+ Value* cmp = llvm::CallInst::Create(module->CompareExceptionFunction, cl, "",
currentBlock);
llvm::BranchInst::Create(cur->handler, bbNext, cmp, currentBlock);
if (nodeNext)
nodeNext->addIncoming(cur->exceptionPHI, currentBlock);
if (cur->handler->empty()) {
- cur->handlerPHI = llvm::PHINode::Create(mvm::jit::ptrType, "",
+ cur->handlerPHI = llvm::PHINode::Create(module->ptrType, "",
cur->handler);
cur->handlerPHI->addIncoming(cur->exceptionPHI, currentBlock);
- Value* exc = llvm::CallInst::Create(JnjvmModule::GetJavaExceptionFunction,
+ Value* exc = llvm::CallInst::Create(module->GetJavaExceptionFunction,
"", cur->handler);
- llvm::CallInst::Create(JnjvmModule::ClearExceptionFunction, "",
+ llvm::CallInst::Create(module->ClearExceptionFunction, "",
cur->handler);
- llvm::CallInst::Create(mvm::jit::exceptionBeginCatch, cur->handlerPHI,
+ llvm::CallInst::Create(module->exceptionBeginCatch, cur->handlerPHI,
"tmp8", cur->handler);
std::vector<Value*> void_28_params;
- llvm::CallInst::Create(mvm::jit::exceptionEndCatch,
+ llvm::CallInst::Create(module->exceptionEndCatch,
void_28_params.begin(), void_28_params.end(), "",
cur->handler);
new StoreInst(exc, supplLocal, false, cur->handler);
@@ -1136,9 +1128,9 @@
}
void JavaJIT::compareFP(Value* val1, Value* val2, const Type* ty, bool l) {
- Value* one = mvm::jit::constantOne;
- Value* zero = mvm::jit::constantZero;
- Value* minus = mvm::jit::constantMinusOne;
+ Value* one = module->constantOne;
+ Value* zero = module->constantZero;
+ Value* minus = module->constantMinusOne;
Value* c = new FCmpInst(FCmpInst::FCMP_UGT, val1, val2, "", currentBlock);
Value* r = llvm::SelectInst::Create(c, one, zero, "", currentBlock);
@@ -1158,14 +1150,13 @@
if (type == JavaConstantPool::ConstantString) {
#if defined(ISOLATE) || defined(ISOLATE_SHARING)
// Lookup the constant pool cache
- Value* val = getConstantPoolAt(index, JnjvmModule::StringLookupFunction,
- JnjvmModule::JavaObjectType, 0, false);
+ Value* val = getConstantPoolAt(index, module->StringLookupFunction,
+ module->JavaObjectType, 0, false);
push(val, false);
#else
const UTF8* utf8 = ctpInfo->UTF8At(ctpInfo->ctpDef[index]);
JavaString* str = JavaThread::get()->isolate->UTF8ToStr(utf8);
- LLVMStringInfo* LSI = module->getStringInfo(str);
- Value* val = LSI->getDelegatee(this);
+ Value* val = module->getString(str, this);
push(val, false);
#endif
@@ -1185,12 +1176,11 @@
#if !defined(ISOLATE)
if (ctpInfo->ctpRes[index]) {
CommonClass* cl = (CommonClass*)(ctpInfo->ctpRes[index]);
- LLVMCommonClassInfo* LCI = module->getClassInfo(cl);
- push(LCI->getDelegatee(this), false);
+ push(module->getJavaClass(cl, this), false);
} else {
#endif
Value* val = getResolvedClass(index, false);
- Value* res = CallInst::Create(JnjvmModule::GetClassDelegateeFunction,
+ Value* res = CallInst::Create(module->GetClassDelegateeFunction,
val, "", currentBlock);
push(res, false);
#if !defined(ISOLATE)
@@ -1204,7 +1194,7 @@
void JavaJIT::JITVerifyNull(Value* obj) {
JavaJIT* jit = this;
- Constant* zero = JnjvmModule::JavaObjectNullConstant;
+ Constant* zero = module->JavaObjectNullConstant;
Value* test = new ICmpInst(ICmpInst::ICMP_EQ, obj, zero, "",
jit->currentBlock);
@@ -1214,12 +1204,12 @@
llvm::BranchInst::Create(exit, cont, test, jit->currentBlock);
std::vector<Value*> args;
if (currentExceptionBlock != endExceptionBlock) {
- llvm::InvokeInst::Create(JnjvmModule::NullPointerExceptionFunction,
+ llvm::InvokeInst::Create(module->NullPointerExceptionFunction,
unifiedUnreachable,
currentExceptionBlock, args.begin(),
args.end(), "", exit);
} else {
- llvm::CallInst::Create(JnjvmModule::NullPointerExceptionFunction,
+ llvm::CallInst::Create(module->NullPointerExceptionFunction,
args.begin(), args.end(), "", exit);
new UnreachableInst(exit);
}
@@ -1252,12 +1242,12 @@
args.push_back(obj);
args.push_back(index);
if (currentExceptionBlock != endExceptionBlock) {
- llvm::InvokeInst::Create(JnjvmModule::IndexOutOfBoundsExceptionFunction,
+ llvm::InvokeInst::Create(module->IndexOutOfBoundsExceptionFunction,
unifiedUnreachable,
currentExceptionBlock, args.begin(),
args.end(), "", ifFalse);
} else {
- llvm::CallInst::Create(JnjvmModule::IndexOutOfBoundsExceptionFunction,
+ llvm::CallInst::Create(module->IndexOutOfBoundsExceptionFunction,
args.begin(), args.end(), "", ifFalse);
new UnreachableInst(ifFalse);
}
@@ -1265,12 +1255,12 @@
currentBlock = ifTrue;
}
- Constant* zero = mvm::jit::constantZero;
+ Constant* zero = module->constantZero;
Value* val = new BitCastInst(obj, arrayType, "", currentBlock);
std::vector<Value*> indexes; //[3];
indexes.push_back(zero);
- indexes.push_back(JnjvmModule::JavaArrayElementsOffsetConstant);
+ indexes.push_back(module->JavaArrayElementsOffsetConstant);
indexes.push_back(index);
Value* ptr = llvm::GetElementPtrInst::Create(val, indexes.begin(),
indexes.end(),
@@ -1287,7 +1277,7 @@
for (BasicBlock::iterator i = newBlock->begin(), e = newBlock->end(); i != e;
++i, ++index) {
// case 2 happens with handlers
- if (!(isa<PHINode>(i)) || i->getType() == mvm::jit::ptrType) {
+ if (!(isa<PHINode>(i)) || i->getType() == module->ptrType) {
break;
} else {
const llvm::Type* type = i->getType();
@@ -1404,8 +1394,8 @@
if (name->equals(Jnjvm::abs)) {
const Type* Ty = args[0]->getType();
if (Ty == Type::Int32Ty) {
- Constant* const_int32_9 = mvm::jit::constantZero;
- ConstantInt* const_int32_10 = mvm::jit::constantMinusOne;
+ Constant* const_int32_9 = module->constantZero;
+ ConstantInt* const_int32_10 = module->constantMinusOne;
BinaryOperator* int32_tmpneg =
BinaryOperator::create(Instruction::Sub, const_int32_9, args[0],
"tmpneg", currentBlock);
@@ -1415,8 +1405,8 @@
return llvm::SelectInst::Create(int1_abscond, args[0], int32_tmpneg,
"abs", currentBlock);
} else if (Ty == Type::Int64Ty) {
- Constant* const_int64_9 = mvm::jit::constantLongZero;
- ConstantInt* const_int64_10 = mvm::jit::constantLongMinusOne;
+ Constant* const_int64_9 = module->constantLongZero;
+ ConstantInt* const_int64_10 = module->constantLongMinusOne;
BinaryOperator* int64_tmpneg =
BinaryOperator::create(Instruction::Sub, const_int64_9, args[0],
@@ -1429,78 +1419,78 @@
return llvm::SelectInst::Create(int1_abscond, args[0], int64_tmpneg,
"abs", currentBlock);
} else if (Ty == Type::FloatTy) {
- return llvm::CallInst::Create(mvm::jit::func_llvm_fabs_f32, args[0],
+ return llvm::CallInst::Create(module->func_llvm_fabs_f32, args[0],
"tmp1", currentBlock);
} else if (Ty == Type::DoubleTy) {
- return llvm::CallInst::Create(mvm::jit::func_llvm_fabs_f64, args[0],
+ return llvm::CallInst::Create(module->func_llvm_fabs_f64, args[0],
"tmp1", currentBlock);
}
} else if (name->equals(Jnjvm::sqrt)) {
- return llvm::CallInst::Create(mvm::jit::func_llvm_sqrt_f64, args[0],
+ return llvm::CallInst::Create(module->func_llvm_sqrt_f64, args[0],
"tmp1", currentBlock);
} else if (name->equals(Jnjvm::sin)) {
- return llvm::CallInst::Create(mvm::jit::func_llvm_sin_f64, args[0],
+ return llvm::CallInst::Create(module->func_llvm_sin_f64, args[0],
"tmp1", currentBlock);
} else if (name->equals(Jnjvm::cos)) {
- return llvm::CallInst::Create(mvm::jit::func_llvm_cos_f64, args[0],
+ return llvm::CallInst::Create(module->func_llvm_cos_f64, args[0],
"tmp1", currentBlock);
} else if (name->equals(Jnjvm::tan)) {
- return llvm::CallInst::Create(mvm::jit::func_llvm_tan_f64, args[0],
+ return llvm::CallInst::Create(module->func_llvm_tan_f64, args[0],
"tmp1", currentBlock);
} else if (name->equals(Jnjvm::asin)) {
- return llvm::CallInst::Create(mvm::jit::func_llvm_asin_f64, args[0],
+ return llvm::CallInst::Create(module->func_llvm_asin_f64, args[0],
"tmp1", currentBlock);
} else if (name->equals(Jnjvm::acos)) {
- return llvm::CallInst::Create(mvm::jit::func_llvm_acos_f64, args[0],
+ return llvm::CallInst::Create(module->func_llvm_acos_f64, args[0],
"tmp1", currentBlock);
} else if (name->equals(Jnjvm::atan)) {
- return llvm::CallInst::Create(mvm::jit::func_llvm_atan_f64, args[0],
+ return llvm::CallInst::Create(module->func_llvm_atan_f64, args[0],
"tmp1", currentBlock);
} else if (name->equals(Jnjvm::atan2)) {
- return llvm::CallInst::Create(mvm::jit::func_llvm_atan2_f64,
+ return llvm::CallInst::Create(module->func_llvm_atan2_f64,
args.begin(), args.end(), "tmp1",
currentBlock);
} else if (name->equals(Jnjvm::exp)) {
- return llvm::CallInst::Create(mvm::jit::func_llvm_exp_f64, args[0],
+ return llvm::CallInst::Create(module->func_llvm_exp_f64, args[0],
"tmp1", currentBlock);
} else if (name->equals(Jnjvm::log)) {
- return llvm::CallInst::Create(mvm::jit::func_llvm_log_f64, args[0],
+ return llvm::CallInst::Create(module->func_llvm_log_f64, args[0],
"tmp1", currentBlock);
} else if (name->equals(Jnjvm::pow)) {
- return llvm::CallInst::Create(mvm::jit::func_llvm_pow_f64, args.begin(),
+ return llvm::CallInst::Create(module->func_llvm_pow_f64, args.begin(),
args.end(), "tmp1", currentBlock);
} else if (name->equals(Jnjvm::ceil)) {
- return llvm::CallInst::Create(mvm::jit::func_llvm_ceil_f64, args[0], "tmp1",
+ return llvm::CallInst::Create(module->func_llvm_ceil_f64, args[0], "tmp1",
currentBlock);
} else if (name->equals(Jnjvm::floor)) {
- return llvm::CallInst::Create(mvm::jit::func_llvm_floor_f64, args[0],
+ return llvm::CallInst::Create(module->func_llvm_floor_f64, args[0],
"tmp1", currentBlock);
} else if (name->equals(Jnjvm::rint)) {
- return llvm::CallInst::Create(mvm::jit::func_llvm_rint_f64, args[0],
+ return llvm::CallInst::Create(module->func_llvm_rint_f64, args[0],
"tmp1", currentBlock);
} else if (name->equals(Jnjvm::cbrt)) {
- return llvm::CallInst::Create(mvm::jit::func_llvm_cbrt_f64, args[0], "tmp1",
+ return llvm::CallInst::Create(module->func_llvm_cbrt_f64, args[0], "tmp1",
currentBlock);
} else if (name->equals(Jnjvm::cosh)) {
- return llvm::CallInst::Create(mvm::jit::func_llvm_cosh_f64, args[0], "tmp1",
+ return llvm::CallInst::Create(module->func_llvm_cosh_f64, args[0], "tmp1",
currentBlock);
} else if (name->equals(Jnjvm::expm1)) {
- return llvm::CallInst::Create(mvm::jit::func_llvm_expm1_f64, args[0],
+ return llvm::CallInst::Create(module->func_llvm_expm1_f64, args[0],
"tmp1", currentBlock);
} else if (name->equals(Jnjvm::hypot)) {
- return llvm::CallInst::Create(mvm::jit::func_llvm_hypot_f64, args[0],
+ return llvm::CallInst::Create(module->func_llvm_hypot_f64, args[0],
"tmp1", currentBlock);
} else if (name->equals(Jnjvm::log10)) {
- return llvm::CallInst::Create(mvm::jit::func_llvm_log10_f64, args[0],
+ return llvm::CallInst::Create(module->func_llvm_log10_f64, args[0],
"tmp1", currentBlock);
} else if (name->equals(Jnjvm::log1p)) {
- return llvm::CallInst::Create(mvm::jit::func_llvm_log1p_f64, args[0],
+ return llvm::CallInst::Create(module->func_llvm_log1p_f64, args[0],
"tmp1", currentBlock);
} else if (name->equals(Jnjvm::sinh)) {
- return llvm::CallInst::Create(mvm::jit::func_llvm_sinh_f64, args[0],
+ return llvm::CallInst::Create(module->func_llvm_sinh_f64, args[0],
"tmp1", currentBlock);
} else if (name->equals(Jnjvm::tanh)) {
- return llvm::CallInst::Create(mvm::jit::func_llvm_tanh_f64, args[0],
+ return llvm::CallInst::Create(module->func_llvm_tanh_f64, args[0],
"tmp1", currentBlock);
}
@@ -1547,7 +1537,7 @@
if (!val) {
#if defined(ISOLATE_SHARING)
- const Type* Ty = JnjvmModule::ConstantPoolType;
+ const Type* Ty = module->ConstantPoolType;
Constant* Nil = Constant::getNullValue(Ty);
GlobalVariable* GV = new GlobalVariable(Ty, false,
GlobalValue::ExternalLinkage, Nil,
@@ -1564,7 +1554,7 @@
Args.push_back(ctpCache);
Args.push_back(ConstantInt::get(Type::Int32Ty, index));
Args.push_back(GV);
- res = CallInst::Create(JnjvmModule::SpecialCtpLookupFunction, Args.begin(),
+ res = CallInst::Create(module->SpecialCtpLookupFunction, Args.begin(),
Args.end(), "", falseCl);
node->addIncoming(res, falseCl);
BranchInst::Create(trueCl, falseCl);
@@ -1588,7 +1578,7 @@
if (retType != Type::VoidTy) {
push(val, signature->ret->isUnsigned());
if (retType == Type::DoubleTy || retType == Type::Int64Ty) {
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
}
}
@@ -1621,8 +1611,8 @@
#if defined(ISOLATE_SHARING)
Value* newCtpCache = getConstantPoolAt(index,
- JnjvmModule::StaticCtpLookupFunction,
- JnjvmModule::ConstantPoolType, 0,
+ module->StaticCtpLookupFunction,
+ module->ConstantPoolType, 0,
false);
args.push_back(newCtpCache);
#endif
@@ -1640,7 +1630,7 @@
if (retType != Type::VoidTy) {
push(val, signature->ret->isUnsigned());
if (retType == Type::DoubleTy || retType == Type::Int64Ty) {
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
}
}
}
@@ -1654,18 +1644,16 @@
std::vector<Value*> Args;
#ifdef ISOLATE_SHARING
Value* CTP = ctpCache;
- Args.push_back(mvm::jit::constantOne);
+ Args.push_back(module->constantOne);
Value* Cl = GetElementPtrInst::Create(CTP, Args.begin(), Args.end(), "",
currentBlock);
Cl = new LoadInst(Cl, "", currentBlock);
- Cl = new BitCastInst(Cl, JnjvmModule::JavaClassType, "", currentBlock);
+ Cl = new BitCastInst(Cl, module->JavaClassType, "", currentBlock);
Args.clear();
#else
JavaConstantPool* ctp = compilingClass->ctpInfo;
- LLVMConstantPoolInfo* LCPI = module->getConstantPoolInfo(ctp);
- Value* CTP = LCPI->getDelegatee(this);
- LLVMClassInfo* LCI = (LLVMClassInfo*)module->getClassInfo(compilingClass);
- Value* Cl = LCI->getVar(this);
+ Value* CTP = module->getConstantPool(ctp, this);
+ Value* Cl = module->getNativeClass(compilingClass, this);
#endif
Args.push_back(resolver);
@@ -1676,15 +1664,15 @@
Value* res = 0;
if (doThrow) {
- res = invoke(JnjvmModule::GetConstantPoolAtFunction, Args, "",
+ res = invoke(module->GetConstantPoolAtFunction, Args, "",
currentBlock);
} else {
- res = CallInst::Create(JnjvmModule::GetConstantPoolAtFunction, Args.begin(),
+ res = CallInst::Create(module->GetConstantPoolAtFunction, Args.begin(),
Args.end(), "", currentBlock);
}
const Type* realType =
- JnjvmModule::GetConstantPoolAtFunction->getReturnType();
+ module->GetConstantPoolAtFunction->getReturnType();
if (returnType == Type::Int32Ty) {
return new PtrToIntInst(res, Type::Int32Ty, "", currentBlock);
} else if (returnType != realType) {
@@ -1696,11 +1684,11 @@
Value* JavaJIT::getResolvedClass(uint16 index, bool clinit, bool doThrow) {
- Value* node = getConstantPoolAt(index, JnjvmModule::ClassLookupFunction,
- JnjvmModule::JavaClassType, 0, doThrow);
+ Value* node = getConstantPoolAt(index, module->ClassLookupFunction,
+ module->JavaClassType, 0, doThrow);
if (clinit)
- return invoke(JnjvmModule::InitialisationCheckFunction, node, "",
+ return invoke(module->InitialisationCheckFunction, node, "",
currentBlock);
else
return node;
@@ -1715,27 +1703,27 @@
Value* Cl = 0;
if (!cl || !cl->isResolved()) {
Cl = getResolvedClass(index, true);
- Size = CallInst::Create(JnjvmModule::GetObjectSizeFromClassFunction, Cl,
+ Size = CallInst::Create(module->GetObjectSizeFromClassFunction, Cl,
"", currentBlock);
- VT = CallInst::Create(JnjvmModule::GetVTFromClassFunction, Cl, "",
+ VT = CallInst::Create(module->GetVTFromClassFunction, Cl, "",
currentBlock);
} else {
- LLVMClassInfo* LCI = (LLVMClassInfo*)module->getClassInfo(cl);
+ LLVMClassInfo* LCI = module->getClassInfo(cl);
Size = LCI->getVirtualSize(this);
#ifndef ISOLATE_SHARING
- VT = LCI->getVirtualTable(this);
- Cl = LCI->getVar(this);
+ VT = module->getVirtualTable(cl, this);
+ Cl = module->getNativeClass(cl, this);
if (!cl->isReady()) {
- Cl = invoke(JnjvmModule::InitialisationCheckFunction, Cl, "",
+ Cl = invoke(module->InitialisationCheckFunction, Cl, "",
currentBlock);
- CallInst::Create(JnjvmModule::ForceInitialisationCheckFunction, Cl, "",
+ CallInst::Create(module->ForceInitialisationCheckFunction, Cl, "",
currentBlock);
}
#else
Cl = getResolvedClass(index, true);
- CallInst::Create(JnjvmModule::ForceInitialisationCheckFunction, Cl, "",
+ CallInst::Create(module->ForceInitialisationCheckFunction, Cl, "",
currentBlock);
- VT = CallInst::Create(JnjvmModule::GetVTFromClassFunction, Cl, "",
+ VT = CallInst::Create(module->GetVTFromClassFunction, Cl, "",
currentBlock);
#endif
}
@@ -1743,17 +1731,17 @@
args.push_back(Size);
args.push_back(VT);
#ifdef MULTIPLE_GC
- args.push_back(CallInst::Create(JnjvmModule::GetCollectorFunction,
+ args.push_back(CallInst::Create(module->GetCollectorFunction,
isolateLocal, "", currentBlock));
#endif
- Value* val = invoke(JnjvmModule::JavaObjectAllocateFunction, args, "",
+ Value* val = invoke(module->JavaObjectAllocateFunction, args, "",
currentBlock);
// Set the class
std::vector<Value*> gep;
- gep.push_back(mvm::jit::constantZero);
- gep.push_back(JnjvmModule::JavaObjectClassOffsetConstant);
+ gep.push_back(module->constantZero);
+ gep.push_back(module->JavaObjectClassOffsetConstant);
Value* GEP = GetElementPtrInst::Create(val, gep.begin(), gep.end(), "",
currentBlock);
new StoreInst(Cl, GEP, currentBlock);
@@ -1763,7 +1751,7 @@
}
Value* JavaJIT::arraySize(Value* val) {
- return llvm::CallInst::Create(JnjvmModule::ArrayLengthFunction, val, "",
+ return llvm::CallInst::Create(module->ArrayLengthFunction, val, "",
currentBlock);
}
@@ -1772,7 +1760,7 @@
llvm::Value* objectConvert = new BitCastInst(object, type, "",
jit->currentBlock);
- Constant* zero = mvm::jit::constantZero;
+ Constant* zero = jit->module->constantZero;
std::vector<Value*> args; // size = 2
args.push_back(zero);
args.push_back(offset);
@@ -1796,7 +1784,7 @@
#ifndef ISOLATE_SHARING
if (field->classDef->isReady()) {
- object = LCI->getStaticVar(this);
+ object = module->getStaticInstance(field->classDef, this);
type = LCI->getStaticType();
return fieldGetter(this, type, object, LFI->getOffset());
}
@@ -1810,15 +1798,15 @@
}
}
- const Type* Pty = mvm::jit::arrayPtrType;
- Constant* zero = mvm::jit::constantZero;
+ const Type* Pty = module->arrayPtrType;
+ Constant* zero = module->constantZero;
- Function* func = stat ? JnjvmModule::StaticFieldLookupFunction :
- JnjvmModule::VirtualFieldLookupFunction;
+ Function* func = stat ? module->StaticFieldLookupFunction :
+ module->VirtualFieldLookupFunction;
const Type* returnType = 0;
if (stat)
- returnType = mvm::jit::ptrType;
+ returnType = module->ptrType;
else
returnType = Type::Int32Ty;
@@ -1892,7 +1880,7 @@
push(new LoadInst(ptr, "", currentBlock), sign->isUnsigned());
if (type == Type::Int64Ty || type == Type::DoubleTy) {
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
}
}
@@ -1929,7 +1917,7 @@
push(new LoadInst(ptr, "", currentBlock), sign->isUnsigned());
if (type == Type::Int64Ty || type == Type::DoubleTy) {
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
}
}
@@ -2025,8 +2013,8 @@
JITVerifyNull(args[0]);
- Value* zero = mvm::jit::constantZero;
- Value* one = mvm::jit::constantOne;
+ Value* zero = module->constantZero;
+ Value* one = module->constantOne;
#ifndef ISOLATE_SHARING
// ok now the cache
@@ -2036,11 +2024,11 @@
Value* llvmEnv =
ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
uint64_t (enveloppe)),
- JnjvmModule::EnveloppeType);
+ module->EnveloppeType);
#else
Value* llvmEnv = getConstantPoolAt(index,
- JnjvmModule::EnveloppeLookupFunction,
- JnjvmModule::EnveloppeType, 0, false);
+ module->EnveloppeLookupFunction,
+ module->EnveloppeType, 0, false);
#endif
std::vector<Value*> args1;
@@ -2050,7 +2038,7 @@
"", currentBlock);
Value* cache = new LoadInst(cachePtr, "", currentBlock);
- Value* cl = CallInst::Create(JnjvmModule::GetClassFunction, args[0], "",
+ Value* cl = CallInst::Create(module->GetClassFunction, args[0], "",
currentBlock);
std::vector<Value*> args3;
args3.push_back(zero);
@@ -2067,13 +2055,13 @@
BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock);
currentBlock = ifFalse;
- Value* _meth = invoke(JnjvmModule::InterfaceLookupFunction, cache, args[0],
+ Value* _meth = invoke(module->InterfaceLookupFunction, cache, args[0],
"", ifFalse);
Value* meth = new BitCastInst(_meth, virtualPtrType, "",
currentBlock);
#ifdef ISOLATE_SHARING
Value* cache2 = new LoadInst(cachePtr, "", currentBlock);
- Value* newCtpCache = CallInst::Create(JnjvmModule::GetCtpCacheNodeFunction,
+ Value* newCtpCache = CallInst::Create(module->GetCtpCacheNodeFunction,
cache2, "", currentBlock);
args.push_back(newCtpCache);
#endif
@@ -2094,7 +2082,7 @@
#ifdef ISOLATE_SHARING
args.pop_back();
cache = new LoadInst(cachePtr, "", currentBlock);
- newCtpCache = CallInst::Create(JnjvmModule::GetCtpCacheNodeFunction,
+ newCtpCache = CallInst::Create(module->GetCtpCacheNodeFunction,
cache, "", currentBlock);
args.push_back(newCtpCache);
#endif
@@ -2109,7 +2097,7 @@
if (node) {
push(node, signature->ret->isUnsigned());
if (retType == Type::DoubleTy || retType == Type::Int64Ty) {
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
}
}
}
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Fri Oct 10 07:51:51 2008
@@ -152,7 +152,7 @@
(int64_t)OpcodeNames[bytecodes[i]]));
args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)i));
args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)compilingMethod));
- CallInst::Create(JnjvmModule::PrintExecutionFunction, args.begin(),
+ CallInst::Create(module->PrintExecutionFunction, args.begin(),
args.end(), "", currentBlock);
}
#endif
@@ -164,67 +164,67 @@
switch (bytecodes[i]) {
case ACONST_NULL :
- push(JnjvmModule::JavaObjectNullConstant, false);
+ push(module->JavaObjectNullConstant, false);
break;
case ICONST_M1 :
- push(mvm::jit::constantMinusOne, false);
+ push(module->constantMinusOne, false);
break;
case ICONST_0 :
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
case ICONST_1 :
- push(mvm::jit::constantOne, false);
+ push(module->constantOne, false);
break;
case ICONST_2 :
- push(mvm::jit::constantTwo, false);
+ push(module->constantTwo, false);
break;
case ICONST_3 :
- push(mvm::jit::constantThree, false);
+ push(module->constantThree, false);
break;
case ICONST_4 :
- push(mvm::jit::constantFour, false);
+ push(module->constantFour, false);
break;
case ICONST_5 :
- push(mvm::jit::constantFive, false);
+ push(module->constantFive, false);
break;
case LCONST_0 :
- push(mvm::jit::constantLongZero, false);
- push(mvm::jit::constantZero, false);
+ push(module->constantLongZero, false);
+ push(module->constantZero, false);
break;
case LCONST_1 :
- push(mvm::jit::constantLongOne, false);
- push(mvm::jit::constantZero, false);
+ push(module->constantLongOne, false);
+ push(module->constantZero, false);
break;
case FCONST_0 :
- push(mvm::jit::constantFloatZero, false);
+ push(module->constantFloatZero, false);
break;
case FCONST_1 :
- push(mvm::jit::constantFloatOne, false);
+ push(module->constantFloatOne, false);
break;
case FCONST_2 :
- push(mvm::jit::constantFloatTwo, false);
+ push(module->constantFloatTwo, false);
break;
case DCONST_0 :
- push(mvm::jit::constantDoubleZero, false);
- push(mvm::jit::constantZero, false);
+ push(module->constantDoubleZero, false);
+ push(module->constantZero, false);
break;
case DCONST_1 :
- push(mvm::jit::constantDoubleOne, false);
- push(mvm::jit::constantZero, false);
+ push(module->constantDoubleOne, false);
+ push(module->constantZero, false);
break;
case BIPUSH :
@@ -249,7 +249,7 @@
case LDC2_W :
_ldc(readS2(bytecodes, i));
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
case ILOAD :
@@ -260,7 +260,7 @@
case LLOAD :
push(new LoadInst(longLocals[WREAD_U1(bytecodes, false, i)], "",
currentBlock), false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
case FLOAD :
@@ -271,7 +271,7 @@
case DLOAD :
push(new LoadInst(doubleLocals[WREAD_U1(bytecodes, false, i)], "",
currentBlock), false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
case ALOAD :
@@ -298,25 +298,25 @@
case LLOAD_0 :
push(new LoadInst(longLocals[0], "", currentBlock),
false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
case LLOAD_1 :
push(new LoadInst(longLocals[1], "", currentBlock),
false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
case LLOAD_2 :
push(new LoadInst(longLocals[2], "", currentBlock),
false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
case LLOAD_3 :
push(new LoadInst(longLocals[3], "", currentBlock),
false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
case FLOAD_0 :
@@ -342,25 +342,25 @@
case DLOAD_0 :
push(new LoadInst(doubleLocals[0], "", currentBlock),
false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
case DLOAD_1 :
push(new LoadInst(doubleLocals[1], "", currentBlock),
false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
case DLOAD_2 :
push(new LoadInst(doubleLocals[2], "", currentBlock),
false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
case DLOAD_3 :
push(new LoadInst(doubleLocals[3], "", currentBlock),
false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
case ALOAD_0 :
@@ -387,7 +387,7 @@
Value* index = pop();
Value* obj = pop();
Value* ptr = verifyAndComputePtr(obj, index,
- JnjvmModule::JavaArraySInt32Type);
+ module->JavaArraySInt32Type);
push(new LoadInst(ptr, "", currentBlock), false);
break;
}
@@ -396,9 +396,9 @@
Value* index = pop();
Value* obj = pop();
Value* ptr = verifyAndComputePtr(obj, index,
- JnjvmModule::JavaArrayLongType);
+ module->JavaArrayLongType);
push(new LoadInst(ptr, "", currentBlock), false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
}
@@ -406,7 +406,7 @@
Value* index = pop();
Value* obj = pop();
Value* ptr = verifyAndComputePtr(obj, index,
- JnjvmModule::JavaArrayFloatType);
+ module->JavaArrayFloatType);
push(new LoadInst(ptr, "", currentBlock), false);
break;
}
@@ -415,9 +415,9 @@
Value* index = pop();
Value* obj = pop();
Value* ptr = verifyAndComputePtr(obj, index,
- JnjvmModule::JavaArrayDoubleType);
+ module->JavaArrayDoubleType);
push(new LoadInst(ptr, "", currentBlock), false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
}
@@ -425,7 +425,7 @@
Value* index = pop();
Value* obj = pop();
Value* ptr = verifyAndComputePtr(obj, index,
- JnjvmModule::JavaArrayObjectType);
+ module->JavaArrayObjectType);
push(new LoadInst(ptr, "", currentBlock), false);
break;
}
@@ -434,7 +434,7 @@
Value* index = pop();
Value* obj = pop();
Value* ptr = verifyAndComputePtr(obj, index,
- JnjvmModule::JavaArraySInt8Type);
+ module->JavaArraySInt8Type);
Value* val = new LoadInst(ptr, "", currentBlock);
push(new SExtInst(val, Type::Int32Ty, "", currentBlock),
false);
@@ -445,7 +445,7 @@
Value* index = pop();
Value* obj = pop();
Value* ptr = verifyAndComputePtr(obj, index,
- JnjvmModule::JavaArrayUInt16Type);
+ module->JavaArrayUInt16Type);
Value* val = new LoadInst(ptr, "", currentBlock);
push(new ZExtInst(val, Type::Int32Ty, "", currentBlock),
false);
@@ -456,7 +456,7 @@
Value* index = pop();
Value* obj = pop();
Value* ptr = verifyAndComputePtr(obj, index,
- JnjvmModule::JavaArraySInt16Type);
+ module->JavaArraySInt16Type);
Value* val = new LoadInst(ptr, "", currentBlock);
push(new SExtInst(val, Type::Int32Ty, "", currentBlock),
false);
@@ -601,7 +601,7 @@
Value* index = popAsInt();
Value* obj = pop();
Value* ptr = verifyAndComputePtr(obj, index,
- JnjvmModule::JavaArraySInt32Type);
+ module->JavaArraySInt32Type);
new StoreInst(val, ptr, false, currentBlock);
break;
}
@@ -612,7 +612,7 @@
Value* index = pop();
Value* obj = pop();
Value* ptr = verifyAndComputePtr(obj, index,
- JnjvmModule::JavaArrayLongType);
+ module->JavaArrayLongType);
new StoreInst(val, ptr, false, currentBlock);
break;
}
@@ -622,7 +622,7 @@
Value* index = pop();
Value* obj = pop();
Value* ptr = verifyAndComputePtr(obj, index,
- JnjvmModule::JavaArrayFloatType);
+ module->JavaArrayFloatType);
new StoreInst(val, ptr, false, currentBlock);
break;
}
@@ -633,7 +633,7 @@
Value* index = pop();
Value* obj = pop();
Value* ptr = verifyAndComputePtr(obj, index,
- JnjvmModule::JavaArrayDoubleType);
+ module->JavaArrayDoubleType);
new StoreInst(val, ptr, false, currentBlock);
break;
}
@@ -643,7 +643,7 @@
Value* index = pop();
Value* obj = pop();
Value* ptr = verifyAndComputePtr(obj, index,
- JnjvmModule::JavaArrayObjectType);
+ module->JavaArrayObjectType);
new StoreInst(val, ptr, false, currentBlock);
break;
}
@@ -656,7 +656,7 @@
Value* index = pop();
Value* obj = pop();
Value* ptr = verifyAndComputePtr(obj, index,
- JnjvmModule::JavaArraySInt8Type);
+ module->JavaArraySInt8Type);
new StoreInst(val, ptr, false, currentBlock);
break;
}
@@ -672,7 +672,7 @@
Value* index = pop();
Value* obj = pop();
Value* ptr = verifyAndComputePtr(obj, index,
- JnjvmModule::JavaArrayUInt16Type);
+ module->JavaArrayUInt16Type);
new StoreInst(val, ptr, false, currentBlock);
break;
}
@@ -688,7 +688,7 @@
Value* index = pop();
Value* obj = pop();
Value* ptr = verifyAndComputePtr(obj, index,
- JnjvmModule::JavaArraySInt16Type);
+ module->JavaArraySInt16Type);
new StoreInst(val, ptr, false, currentBlock);
break;
}
@@ -785,7 +785,7 @@
llvm::Value* val1 = pop();
push(BinaryOperator::createAdd(val1, val2, "", currentBlock),
false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
}
@@ -804,7 +804,7 @@
llvm::Value* val1 = pop();
push(BinaryOperator::createAdd(val1, val2, "", currentBlock),
false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
}
@@ -822,7 +822,7 @@
llvm::Value* val1 = pop();
push(BinaryOperator::createSub(val1, val2, "", currentBlock),
false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
}
@@ -841,7 +841,7 @@
llvm::Value* val1 = pop();
push(BinaryOperator::createSub(val1, val2, "", currentBlock),
false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
}
@@ -860,7 +860,7 @@
llvm::Value* val1 = pop();
push(BinaryOperator::createMul(val1, val2, "", currentBlock),
false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
}
@@ -879,7 +879,7 @@
llvm::Value* val1 = pop();
push(BinaryOperator::createMul(val1, val2, "", currentBlock),
false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
}
@@ -898,7 +898,7 @@
llvm::Value* val1 = pop();
push(BinaryOperator::createSDiv(val1, val2, "", currentBlock),
false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
}
@@ -917,7 +917,7 @@
llvm::Value* val1 = pop();
push(BinaryOperator::createFDiv(val1, val2, "", currentBlock),
false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
}
@@ -936,7 +936,7 @@
llvm::Value* val1 = pop();
push(BinaryOperator::createSRem(val1, val2, "", currentBlock),
false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
}
@@ -955,13 +955,13 @@
llvm::Value* val1 = pop();
push(BinaryOperator::createFRem(val1, val2, "", currentBlock),
false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
}
case INEG :
push(BinaryOperator::createSub(
- mvm::jit::constantZero,
+ module->constantZero,
popAsInt(), "", currentBlock),
false);
break;
@@ -969,24 +969,24 @@
case LNEG : {
pop();
push(BinaryOperator::createSub(
- mvm::jit::constantLongZero,
+ module->constantLongZero,
pop(), "", currentBlock), false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
}
case FNEG :
push(BinaryOperator::createSub(
- mvm::jit::constantFloatMinusZero,
+ module->constantFloatMinusZero,
pop(), "", currentBlock), false);
break;
case DNEG : {
pop();
push(BinaryOperator::createSub(
- mvm::jit::constantDoubleMinusZero,
+ module->constantDoubleMinusZero,
pop(), "", currentBlock), false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
}
@@ -1004,7 +1004,7 @@
Value* val1 = pop();
push(BinaryOperator::createShl(val1, val2, "", currentBlock),
false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
}
@@ -1022,7 +1022,7 @@
Value* val1 = pop();
push(BinaryOperator::createAShr(val1, val2, "", currentBlock),
false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
}
@@ -1044,7 +1044,7 @@
Value* val1 = pop();
push(BinaryOperator::createLShr(val1, val2, "", currentBlock),
false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
}
@@ -1063,7 +1063,7 @@
Value* val1 = pop();
push(BinaryOperator::createAnd(val1, val2, "", currentBlock),
false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
}
@@ -1082,7 +1082,7 @@
Value* val1 = pop();
push(BinaryOperator::createOr(val1, val2, "", currentBlock),
false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
}
@@ -1101,7 +1101,7 @@
Value* val1 = pop();
push(BinaryOperator::createXor(val1, val2, "", currentBlock),
false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
}
@@ -1119,7 +1119,7 @@
case I2L :
push(new SExtInst(pop(), llvm::Type::Int64Ty, "", currentBlock),
false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
case I2F :
@@ -1130,7 +1130,7 @@
case I2D :
push(new SIToFPInst(pop(), llvm::Type::DoubleTy, "", currentBlock),
false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
case L2I :
@@ -1149,7 +1149,7 @@
pop();
push(new SIToFPInst(pop(), llvm::Type::DoubleTy, "", currentBlock),
false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
case F2I : {
@@ -1159,7 +1159,7 @@
BasicBlock* res = createBasicBlock("F2I");
PHINode* node = PHINode::Create(llvm::Type::Int32Ty, "", res);
- node->addIncoming(mvm::jit::constantZero, currentBlock);
+ node->addIncoming(module->constantZero, currentBlock);
BasicBlock* cont = createBasicBlock("F2I");
BranchInst::Create(res, cont, test, currentBlock);
@@ -1167,25 +1167,25 @@
currentBlock = cont;
test = new FCmpInst(FCmpInst::FCMP_OGE, val,
- mvm::jit::constantMaxIntFloat,
+ module->constantMaxIntFloat,
"", currentBlock);
cont = createBasicBlock("F2I");
BranchInst::Create(res, cont, test, currentBlock);
- node->addIncoming(mvm::jit::constantMaxInt,
+ node->addIncoming(module->constantMaxInt,
currentBlock);
currentBlock = cont;
test = new FCmpInst(FCmpInst::FCMP_OLE, val,
- mvm::jit::constantMinIntFloat,
+ module->constantMinIntFloat,
"", currentBlock);
cont = createBasicBlock("F2I");
BranchInst::Create(res, cont, test, currentBlock);
- node->addIncoming(mvm::jit::constantMinInt, currentBlock);
+ node->addIncoming(module->constantMinInt, currentBlock);
currentBlock = cont;
llvm::Value* newVal = new FPToSIInst(val, Type::Int32Ty, "",
@@ -1207,7 +1207,7 @@
BasicBlock* res = createBasicBlock("F2L");
PHINode* node = PHINode::Create(llvm::Type::Int64Ty, "", res);
- node->addIncoming(mvm::jit::constantLongZero, currentBlock);
+ node->addIncoming(module->constantLongZero, currentBlock);
BasicBlock* cont = createBasicBlock("F2L");
BranchInst::Create(res, cont, test, currentBlock);
@@ -1215,23 +1215,23 @@
currentBlock = cont;
test = new FCmpInst(FCmpInst::FCMP_OGE, val,
- mvm::jit::constantMaxLongFloat,
+ module->constantMaxLongFloat,
"", currentBlock);
cont = createBasicBlock("F2L");
BranchInst::Create(res, cont, test, currentBlock);
- node->addIncoming(mvm::jit::constantMaxLong, currentBlock);
+ node->addIncoming(module->constantMaxLong, currentBlock);
currentBlock = cont;
test = new FCmpInst(FCmpInst::FCMP_OLE, val,
- mvm::jit::constantMinLongFloat, "", currentBlock);
+ module->constantMinLongFloat, "", currentBlock);
cont = createBasicBlock("F2L");
BranchInst::Create(res, cont, test, currentBlock);
- node->addIncoming(mvm::jit::constantMinLong, currentBlock);
+ node->addIncoming(module->constantMinLong, currentBlock);
currentBlock = cont;
llvm::Value* newVal = new FPToSIInst(val, Type::Int64Ty, "",
@@ -1243,14 +1243,14 @@
currentBlock = res;
push(node, false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
}
case F2D :
push(new FPExtInst(pop(), llvm::Type::DoubleTy, "", currentBlock),
false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
case D2I : {
@@ -1261,7 +1261,7 @@
BasicBlock* res = createBasicBlock("D2I");
PHINode* node = PHINode::Create(llvm::Type::Int32Ty, "", res);
- node->addIncoming(mvm::jit::constantZero, currentBlock);
+ node->addIncoming(module->constantZero, currentBlock);
BasicBlock* cont = createBasicBlock("D2I");
BranchInst::Create(res, cont, test, currentBlock);
@@ -1269,24 +1269,24 @@
currentBlock = cont;
test = new FCmpInst(FCmpInst::FCMP_OGE, val,
- mvm::jit::constantMaxIntDouble,
+ module->constantMaxIntDouble,
"", currentBlock);
cont = createBasicBlock("D2I");
BranchInst::Create(res, cont, test, currentBlock);
- node->addIncoming(mvm::jit::constantMaxInt, currentBlock);
+ node->addIncoming(module->constantMaxInt, currentBlock);
currentBlock = cont;
test = new FCmpInst(FCmpInst::FCMP_OLE, val,
- mvm::jit::constantMinIntDouble,
+ module->constantMinIntDouble,
"", currentBlock);
cont = createBasicBlock("D2I");
BranchInst::Create(res, cont, test, currentBlock);
- node->addIncoming(mvm::jit::constantMinInt, currentBlock);
+ node->addIncoming(module->constantMinInt, currentBlock);
currentBlock = cont;
llvm::Value* newVal = new FPToSIInst(val, Type::Int32Ty, "",
@@ -1310,7 +1310,7 @@
BasicBlock* res = createBasicBlock("D2L");
PHINode* node = PHINode::Create(llvm::Type::Int64Ty, "", res);
- node->addIncoming(mvm::jit::constantLongZero, currentBlock);
+ node->addIncoming(module->constantLongZero, currentBlock);
BasicBlock* cont = createBasicBlock("D2L");
BranchInst::Create(res, cont, test, currentBlock);
@@ -1318,24 +1318,24 @@
currentBlock = cont;
test = new FCmpInst(FCmpInst::FCMP_OGE, val,
- mvm::jit::constantMaxLongDouble,
+ module->constantMaxLongDouble,
"", currentBlock);
cont = createBasicBlock("D2L");
BranchInst::Create(res, cont, test, currentBlock);
- node->addIncoming(mvm::jit::constantMaxLong, currentBlock);
+ node->addIncoming(module->constantMaxLong, currentBlock);
currentBlock = cont;
test =
- new FCmpInst(FCmpInst::FCMP_OLE, val, mvm::jit::constantMinLongDouble,
+ new FCmpInst(FCmpInst::FCMP_OLE, val, module->constantMinLongDouble,
"", currentBlock);
cont = createBasicBlock("D2L");
BranchInst::Create(res, cont, test, currentBlock);
- node->addIncoming(mvm::jit::constantMinLong, currentBlock);
+ node->addIncoming(module->constantMinLong, currentBlock);
currentBlock = cont;
llvm::Value* newVal = new FPToSIInst(val, Type::Int64Ty, "",
@@ -1347,7 +1347,7 @@
currentBlock = res;
push(node, false);
- push(mvm::jit::constantZero, false);
+ push(module->constantZero, false);
break;
}
@@ -1399,18 +1399,18 @@
BasicBlock* cont = createBasicBlock("LCMP");
BasicBlock* res = createBasicBlock("LCMP");
PHINode* node = PHINode::Create(llvm::Type::Int32Ty, "", res);
- node->addIncoming(mvm::jit::constantZero, currentBlock);
+ node->addIncoming(module->constantZero, currentBlock);
BranchInst::Create(res, cont, test, currentBlock);
currentBlock = cont;
test = new ICmpInst(ICmpInst::ICMP_SLT, val1, val2, "", currentBlock);
- node->addIncoming(mvm::jit::constantMinusOne, currentBlock);
+ node->addIncoming(module->constantMinusOne, currentBlock);
cont = createBasicBlock("LCMP");
BranchInst::Create(res, cont, test, currentBlock);
currentBlock = cont;
- node->addIncoming(mvm::jit::constantOne, currentBlock);
+ node->addIncoming(module->constantOne, currentBlock);
BranchInst::Create(res, currentBlock);
currentBlock = res;
@@ -1654,7 +1654,7 @@
Value* expr = ConstantExpr::getIntToPtr(
ConstantInt::get(Type::Int64Ty,
uint64_t (jsrIndex++)),
- JnjvmModule::JavaObjectType);
+ module->JavaObjectType);
new StoreInst(expr, supplLocal, false, currentBlock);
BranchInst::Create(opcodeInfos[tmp + readS2(bytecodes, i)].newBlock,
@@ -1832,7 +1832,7 @@
UserClassArray* dcl = 0;
#endif
ConstantInt* sizeElement = 0;
- GlobalVariable* TheVT = 0;
+ Value* TheVT = 0;
Value* valCl = 0;
if (bytecodes[i] == NEWARRAY) {
@@ -1844,11 +1844,10 @@
std::vector<Value*> args;
args.push_back(isolateLocal);
args.push_back(ConstantInt::get(Type::Int32Ty, id - 4));
- valCl = CallInst::Create(JnjvmModule::GetJnjvmArrayClassFunction,
+ valCl = CallInst::Create(module->GetJnjvmArrayClassFunction,
args.begin(), args.end(), "", currentBlock);
#endif
- TheVT = JnjvmModule::JavaObjectVirtualTableGV;
LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[charId];
sizeElement = LAI.sizeInBytesConstant;
} else {
@@ -1864,20 +1863,19 @@
#else
valCl = getResolvedClass(index, false);
- valCl = CallInst::Create(JnjvmModule::GetArrayClassFunction, valCl,
+ valCl = CallInst::Create(module->GetArrayClassFunction, valCl,
"", currentBlock);
#endif
- TheVT = JnjvmModule::ArrayObjectVirtualTableGV;
- sizeElement = mvm::jit::constantPtrSize;
+ sizeElement = module->constantPtrSize;
}
#ifndef ISOLATE_SHARING
- LLVMCommonClassInfo* LCI = module->getClassInfo(dcl);
- valCl = LCI->getVar(this);
+ valCl = module->getNativeClass(dcl, this);
+ TheVT = module->getVirtualTable(dcl, this);
#endif
llvm::Value* arg1 = popAsInt();
Value* cmp = new ICmpInst(ICmpInst::ICMP_SLT, arg1,
- mvm::jit::constantZero, "", currentBlock);
+ module->constantZero, "", currentBlock);
BasicBlock* BB1 = createBasicBlock("");
BasicBlock* BB2 = createBasicBlock("");
@@ -1887,19 +1885,19 @@
std::vector<Value*> exArgs;
exArgs.push_back(arg1);
if (currentExceptionBlock != endExceptionBlock) {
- InvokeInst::Create(JnjvmModule::NegativeArraySizeExceptionFunction,
+ InvokeInst::Create(module->NegativeArraySizeExceptionFunction,
unifiedUnreachable,
currentExceptionBlock, exArgs.begin(),
exArgs.end(), "", currentBlock);
} else {
- CallInst::Create(JnjvmModule::NegativeArraySizeExceptionFunction,
+ CallInst::Create(module->NegativeArraySizeExceptionFunction,
exArgs.begin(), exArgs.end(), "", currentBlock);
new UnreachableInst(currentBlock);
}
currentBlock = BB2;
cmp = new ICmpInst(ICmpInst::ICMP_SGT, arg1,
- JnjvmModule::MaxArraySizeConstant,
+ module->MaxArraySizeConstant,
"", currentBlock);
BB1 = createBasicBlock("");
@@ -1908,12 +1906,12 @@
BranchInst::Create(BB1, BB2, cmp, currentBlock);
currentBlock = BB1;
if (currentExceptionBlock != endExceptionBlock) {
- InvokeInst::Create(JnjvmModule::OutOfMemoryErrorFunction,
+ InvokeInst::Create(module->OutOfMemoryErrorFunction,
unifiedUnreachable,
currentExceptionBlock, exArgs.begin(),
exArgs.end(), "", currentBlock);
} else {
- CallInst::Create(JnjvmModule::OutOfMemoryErrorFunction,
+ CallInst::Create(module->OutOfMemoryErrorFunction,
exArgs.begin(), exArgs.end(), "", currentBlock);
new UnreachableInst(currentBlock);
}
@@ -1922,32 +1920,32 @@
Value* mult = BinaryOperator::createMul(arg1, sizeElement, "",
currentBlock);
Value* size =
- BinaryOperator::createAdd(JnjvmModule::JavaObjectSizeConstant, mult,
+ BinaryOperator::createAdd(module->JavaObjectSizeConstant, mult,
"", currentBlock);
std::vector<Value*> args;
args.push_back(size);
- args.push_back(new LoadInst(TheVT, "", currentBlock));
+ args.push_back(TheVT);
#ifdef MULTIPLE_GC
- args.push_back(CallInst::Create(JnjvmModule::GetCollectorFunction,
+ args.push_back(CallInst::Create(module->GetCollectorFunction,
isolateLocal, "", currentBlock));
#endif
- Value* res = invoke(JnjvmModule::JavaObjectAllocateFunction, args, "",
+ Value* res = invoke(module->JavaObjectAllocateFunction, args, "",
currentBlock);
- Value* cast = new BitCastInst(res, JnjvmModule::JavaArrayType, "",
+ Value* cast = new BitCastInst(res, module->JavaArrayType, "",
currentBlock);
// Set the size
std::vector<Value*> gep4;
- gep4.push_back(mvm::jit::constantZero);
- gep4.push_back(JnjvmModule::JavaArraySizeOffsetConstant);
+ gep4.push_back(module->constantZero);
+ gep4.push_back(module->JavaArraySizeOffsetConstant);
Value* GEP = GetElementPtrInst::Create(cast, gep4.begin(), gep4.end(),
"", currentBlock);
new StoreInst(arg1, GEP, currentBlock);
// Set the class
std::vector<Value*> gep;
- gep.push_back(mvm::jit::constantZero);
- gep.push_back(JnjvmModule::JavaObjectClassOffsetConstant);
+ gep.push_back(module->constantZero);
+ gep.push_back(module->JavaObjectClassOffsetConstant);
GEP = GetElementPtrInst::Create(res, gep.begin(), gep.end(), "",
currentBlock);
new StoreInst(valCl, GEP, currentBlock);
@@ -1969,12 +1967,12 @@
std::vector<Value*> args;
args.push_back(arg);
if (currentExceptionBlock != endExceptionBlock) {
- InvokeInst::Create(JnjvmModule::ThrowExceptionFunction,
+ InvokeInst::Create(module->ThrowExceptionFunction,
unifiedUnreachable,
currentExceptionBlock, args.begin(), args.end(),
"", currentBlock);
} else {
- CallInst::Create(JnjvmModule::ThrowExceptionFunction, args.begin(),
+ CallInst::Create(module->ThrowExceptionFunction, args.begin(),
args.end(), "", currentBlock);
new UnreachableInst(currentBlock);
}
@@ -1991,7 +1989,7 @@
Value* obj = top();
Value* cmp = new ICmpInst(ICmpInst::ICMP_EQ, obj,
- JnjvmModule::JavaObjectNullConstant,
+ module->JavaObjectNullConstant,
"", currentBlock);
BasicBlock* ifTrue = createBasicBlock("null checkcast");
@@ -2002,8 +2000,7 @@
Value* clVar = 0;
#ifndef ISOLATE_SHARING
if (dcl) {
- LLVMCommonClassInfo* LCI = module->getClassInfo(dcl);
- clVar = LCI->getVar(this);
+ clVar = module->getNativeClass(dcl, this);
} else
#endif
clVar = getResolvedClass(index, false);
@@ -2011,7 +2008,7 @@
std::vector<Value*> args;
args.push_back(obj);
args.push_back(clVar);
- Value* call = CallInst::Create(JnjvmModule::InstanceOfFunction,
+ Value* call = CallInst::Create(module->InstanceOfFunction,
args.begin(), args.end(),
"", currentBlock);
@@ -2022,12 +2019,12 @@
exArgs.push_back(obj);
exArgs.push_back(clVar);
if (currentExceptionBlock != endExceptionBlock) {
- InvokeInst::Create(JnjvmModule::ClassCastExceptionFunction,
+ InvokeInst::Create(module->ClassCastExceptionFunction,
unifiedUnreachable,
currentExceptionBlock, exArgs.begin(),
exArgs.end(), "", ex);
} else {
- CallInst::Create(JnjvmModule::ClassCastExceptionFunction,
+ CallInst::Create(module->ClassCastExceptionFunction,
exArgs.begin(), exArgs.end(), "", ex);
new UnreachableInst(ex);
}
@@ -2044,8 +2041,7 @@
Value* clVar = 0;
if (dcl) {
- LLVMCommonClassInfo* LCI = module->getClassInfo(dcl);
- clVar = LCI->getVar(this);
+ clVar = module->getNativeClass(dcl, this);
} else {
clVar = getResolvedClass(index, false);
}
@@ -2055,7 +2051,7 @@
std::vector<Value*> args;
args.push_back(pop());
args.push_back(clVar);
- Value* val = CallInst::Create(JnjvmModule::InstanceOfFunction,
+ Value* val = CallInst::Create(module->InstanceOfFunction,
args.begin(), args.end(), "",
currentBlock);
push(new ZExtInst(val, Type::Int32Ty, "", currentBlock),
@@ -2067,10 +2063,10 @@
Value* obj = pop();
#ifdef SERVICE_VM
if (ServiceDomain::isLockableDomain(compilingClass->isolate))
- invoke(JnjvmModule::AquireObjectInSharedDomainFunction, obj, "",
+ invoke(module->AquireObjectInSharedDomainFunction, obj, "",
currentBlock);
else
- invoke(JnjvmModule::AquireObjectFunction, obj, "",
+ invoke(module->AquireObjectFunction, obj, "",
currentBlock);
#else
JITVerifyNull(obj);
@@ -2083,10 +2079,10 @@
Value* obj = pop();
#ifdef SERVICE_VM
if (ServiceDomain::isLockableDomain(compilingClass->isolate))
- invoke(JnjvmModule::ReleaseObjectInSharedDomainFunction, obj, "",
+ invoke(module->ReleaseObjectInSharedDomainFunction, obj, "",
currentBlock);
else
- invoke(JnjvmModule::ReleaseObjectFunction, obj, "",
+ invoke(module->ReleaseObjectFunction, obj, "",
currentBlock);
#else
JITVerifyNull(obj);
@@ -2110,8 +2106,7 @@
UserClassArray* dcl = JCL->constructArray(className);
compilingClass->ctpInfo->loadClass(index);
- LLVMCommonClassInfo* LCI = module->getClassInfo(dcl);
- Value* valCl = LCI->getVar(this);
+ Value* valCl = module->getNativeClass(dcl ,this);
#endif
Value** args = (Value**)alloca(sizeof(Value*) * (dim + 2));
args[0] = valCl;
@@ -2124,7 +2119,7 @@
for (sint32 v = 0; v < dim + 2; ++v) {
Args.push_back(args[v]);
}
- push(invoke(JnjvmModule::MultiCallNewFunction, Args, "", currentBlock),
+ push(invoke(module->MultiCallNewFunction, Args, "", currentBlock),
false);
break;
}
Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp Fri Oct 10 07:51:51 2008
@@ -40,9 +40,9 @@
JnjvmBootstrapLoader* JnjvmBootstrapLoader::createBootstrapLoader() {
JnjvmBootstrapLoader* JCL = gc_new(JnjvmBootstrapLoader)();
+ JnjvmModule::initialise();
JCL->TheModule = new JnjvmModule("Bootstrap JnJVM");
JCL->TheModuleProvider = new JnjvmModuleProvider(JCL->TheModule);
- JCL->TheModule->initialise();
JCL->allocator = new JavaAllocator();
@@ -70,16 +70,16 @@
JnjvmClassLoader::JnjvmClassLoader(JnjvmClassLoader& JCL, JavaObject* loader,
Jnjvm* I) {
- TheModule = JCL.TheModule;
- TheModuleProvider = JCL.TheModuleProvider;
+ TheModule = new JnjvmModule("Applicative loader");
+ TheModuleProvider = new JnjvmModuleProvider(TheModule);
bootstrapLoader = JCL.bootstrapLoader;
allocator = &(isolate->allocator);
- hashUTF8 = JCL.hashUTF8;
+ hashUTF8 = new UTF8Map(allocator, bootstrapLoader->upcalls->ArrayOfChar);
classes = allocator_new(allocator, ClassMap)();
- javaTypes = JCL.javaTypes;
- javaSignatures = JCL.javaSignatures;
+ javaTypes = new TypeMap();
+ javaSignatures = new SignMap();
javaLoader = loader;
isolate = I;
@@ -388,10 +388,10 @@
}
JnjvmClassLoader::~JnjvmClassLoader() {
- /*delete hashUTF8;
+ delete hashUTF8;
delete javaTypes;
delete javaSignatures;
- delete TheModuleProvider;*/
+ delete TheModuleProvider;
}
void JnjvmBootstrapLoader::analyseClasspathEnv(const char* str) {
Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp Fri Oct 10 07:51:51 2008
@@ -52,8 +52,6 @@
llvm::Constant* JnjvmModule::JavaClassNullConstant;
llvm::Constant* JnjvmModule::MaxArraySizeConstant;
llvm::Constant* JnjvmModule::JavaObjectSizeConstant;
-llvm::GlobalVariable* JnjvmModule::JavaObjectVirtualTableGV;
-llvm::GlobalVariable* JnjvmModule::ArrayObjectVirtualTableGV;
llvm::ConstantInt* JnjvmModule::OffsetObjectSizeInClassConstant;
llvm::ConstantInt* JnjvmModule::OffsetVTInClassConstant;
llvm::ConstantInt* JnjvmModule::OffsetDepthInClassConstant;
@@ -67,90 +65,11 @@
llvm::ConstantInt* JnjvmModule::JavaObjectLockOffsetConstant;
llvm::ConstantInt* JnjvmModule::JavaObjectClassOffsetConstant;
-#ifdef WITH_TRACER
-llvm::Function* JnjvmModule::MarkAndTraceFunction = 0;
-llvm::Function* JnjvmModule::JavaObjectTracerFunction = 0;
-#endif
-llvm::Function* JnjvmModule::GetSJLJBufferFunction = 0;
-llvm::Function* JnjvmModule::ThrowExceptionFunction = 0;
-llvm::Function* JnjvmModule::GetExceptionFunction = 0;
-llvm::Function* JnjvmModule::GetJavaExceptionFunction = 0;
-llvm::Function* JnjvmModule::ClearExceptionFunction = 0;
-llvm::Function* JnjvmModule::CompareExceptionFunction = 0;
-llvm::Function* JnjvmModule::NullPointerExceptionFunction = 0;
-llvm::Function* JnjvmModule::ClassCastExceptionFunction = 0;
-llvm::Function* JnjvmModule::IndexOutOfBoundsExceptionFunction = 0;
-llvm::Function* JnjvmModule::NegativeArraySizeExceptionFunction = 0;
-llvm::Function* JnjvmModule::OutOfMemoryErrorFunction = 0;
-llvm::Function* JnjvmModule::JavaObjectAllocateFunction = 0;
-llvm::Function* JnjvmModule::InterfaceLookupFunction = 0;
-llvm::Function* JnjvmModule::StaticFieldLookupFunction = 0;
-llvm::Function* JnjvmModule::VirtualFieldLookupFunction = 0;
-#ifndef WITHOUT_VTABLE
-llvm::Function* JnjvmModule::VirtualLookupFunction = 0;
-#endif
-llvm::Function* JnjvmModule::PrintExecutionFunction = 0;
-llvm::Function* JnjvmModule::PrintMethodStartFunction = 0;
-llvm::Function* JnjvmModule::PrintMethodEndFunction = 0;
-llvm::Function* JnjvmModule::JniProceedPendingExceptionFunction = 0;
-llvm::Function* JnjvmModule::InitialisationCheckFunction = 0;
-llvm::Function* JnjvmModule::ForceInitialisationCheckFunction = 0;
-llvm::Function* JnjvmModule::ClassLookupFunction = 0;
-llvm::Function* JnjvmModule::InstanceOfFunction = 0;
-llvm::Function* JnjvmModule::IsAssignableFromFunction = 0;
-llvm::Function* JnjvmModule::ImplementsFunction = 0;
-llvm::Function* JnjvmModule::InstantiationOfArrayFunction = 0;
-llvm::Function* JnjvmModule::GetDepthFunction = 0;
-llvm::Function* JnjvmModule::GetDisplayFunction = 0;
-llvm::Function* JnjvmModule::GetClassInDisplayFunction = 0;
-llvm::Function* JnjvmModule::AquireObjectFunction = 0;
-llvm::Function* JnjvmModule::ReleaseObjectFunction = 0;
-llvm::Function* JnjvmModule::MultiCallNewFunction = 0;
-llvm::Function* JnjvmModule::GetConstantPoolAtFunction = 0;
-
-#ifdef ISOLATE
-llvm::Function* JnjvmModule::StringLookupFunction = 0;
-
-#ifdef ISOLATE_SHARING
-llvm::Function* JnjvmModule::GetCtpCacheNodeFunction = 0;
-llvm::Function* JnjvmModule::GetCtpClassFunction = 0;
-llvm::Function* JnjvmModule::EnveloppeLookupFunction = 0;
-llvm::Function* JnjvmModule::GetJnjvmExceptionClassFunction = 0;
-llvm::Function* JnjvmModule::GetJnjvmArrayClassFunction = 0;
-llvm::Function* JnjvmModule::StaticCtpLookupFunction = 0;
-llvm::Function* JnjvmModule::GetArrayClassFunction = 0;
-llvm::Function* JnjvmModule::SpecialCtpLookupFunction = 0;
-#endif
-
-#endif
-
-llvm::Function* JnjvmModule::GetClassDelegateeFunction = 0;
-llvm::Function* JnjvmModule::ArrayLengthFunction = 0;
-llvm::Function* JnjvmModule::GetVTFunction = 0;
-llvm::Function* JnjvmModule::GetClassFunction = 0;
-llvm::Function* JnjvmModule::GetVTFromClassFunction = 0;
-llvm::Function* JnjvmModule::GetObjectSizeFromClassFunction = 0;
-
-#ifdef MULTIPLE_GC
-llvm::Function* JnjvmModule::GetCollectorFunction = 0;
-#endif
-
-#ifdef SERVICE_VM
-llvm::Function* JnjvmModule::AquireObjectInSharedDomainFunction = 0;
-llvm::Function* JnjvmModule::ReleaseObjectInSharedDomainFunction = 0;
-llvm::Function* JnjvmModule::ServiceCallStartFunction = 0;
-llvm::Function* JnjvmModule::ServiceCallStopFunction = 0;
-#endif
-
-llvm::Function* JnjvmModule::GetThreadIDFunction = 0;
-llvm::Function* JnjvmModule::GetLockFunction = 0;
-llvm::Function* JnjvmModule::OverflowThinLockFunction = 0;
-
-
-
-Value* LLVMCommonClassInfo::getVar(JavaJIT* jit) {
- if (!varGV) {
-
+Value* JnjvmModule::getNativeClass(CommonClass* classDef, JavaJIT* jit) {
+ llvm::GlobalVariable* varGV = 0;
+ native_class_iterator End = nativeClasses.end();
+ native_class_iterator I = nativeClasses.find(classDef);
+ if (I == End) {
Constant* cons =
ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
uint64_t (classDef)),
@@ -158,43 +77,119 @@
varGV = new GlobalVariable(JnjvmModule::JavaClassType, true,
GlobalValue::ExternalLinkage,
- cons, "",
- classDef->classLoader->TheModule);
- }
+ cons, "", this);
+
+ nativeClasses.insert(std::make_pair(classDef, varGV));
+ } else {
+ varGV = I->second;
+ }
return new LoadInst(varGV, "", jit->currentBlock);
}
-Value* LLVMConstantPoolInfo::getDelegatee(JavaJIT* jit) {
- if (!delegateeGV) {
+Value* JnjvmModule::getConstantPool(JavaConstantPool* ctp, JavaJIT* jit) {
+ llvm::GlobalVariable* varGV = 0;
+ constant_pool_iterator End = constantPools.end();
+ constant_pool_iterator I = constantPools.find(ctp);
+ if (I == End) {
void* ptr = ctp->ctpRes;
Constant* cons =
ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64(ptr)),
- mvm::jit::ptrPtrType);
- delegateeGV = new GlobalVariable(mvm::jit::ptrPtrType, true,
- GlobalValue::ExternalLinkage,
- cons, "",
- ctp->classDef->classLoader->TheModule);
- }
- return new LoadInst(delegateeGV, "", jit->currentBlock);
+ mvm::MvmModule::ptrPtrType);
+ varGV = new GlobalVariable(mvm::MvmModule::ptrPtrType, true,
+ GlobalValue::ExternalLinkage,
+ cons, "", this);
+ constantPools.insert(std::make_pair(ctp, varGV));
+ } else {
+ varGV = I->second;
+ }
+ return new LoadInst(varGV, "", jit->currentBlock);
}
-Value* LLVMCommonClassInfo::getDelegatee(JavaJIT* jit) {
-#ifndef ISOLATE
- if (!delegateeGV) {
- JavaObject* obj = classDef->getClassDelegatee(JavaThread::get()->isolate);
+Value* JnjvmModule::getString(JavaString* str, JavaJIT* jit) {
+ llvm::GlobalVariable* varGV;
+ string_iterator SI = strings.find(str);
+ if (SI != strings.end()) {
+ varGV = SI->second;
+ } else {
+ void* ptr = str;
+ Constant* cons =
+ ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64(ptr)),
+ JnjvmModule::JavaObjectType);
+ varGV = new GlobalVariable(JnjvmModule::JavaObjectType, true,
+ GlobalValue::ExternalLinkage,
+ cons, "", this);
+ strings.insert(std::make_pair(str, varGV));
+ }
+ return new LoadInst(varGV, "", jit->currentBlock);
+}
+
+Value* JnjvmModule::getJavaClass(CommonClass* cl, JavaJIT* jit) {
+ llvm::GlobalVariable* varGV = 0;
+ java_class_iterator End = javaClasses.end();
+ java_class_iterator I = javaClasses.find(cl);
+ if (I == End) {
+
+ JavaObject* obj = cl->getClassDelegatee(JavaThread::get()->isolate);
Constant* cons =
ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64(obj)),
JnjvmModule::JavaObjectType);
- delegateeGV = new GlobalVariable(JnjvmModule::JavaObjectType, true,
- GlobalValue::ExternalLinkage,
- cons, "",
- classDef->classLoader->TheModule);
+ varGV = new GlobalVariable(JnjvmModule::JavaObjectType, true,
+ GlobalValue::ExternalLinkage,
+ cons, "", this);
+
+ javaClasses.insert(std::make_pair(cl, varGV));
+ } else {
+ varGV = I->second;
}
- return new LoadInst(delegateeGV, "", jit->currentBlock);
-#else
- fprintf(stderr, "implement me\n");
- abort();
-#endif
+ return new LoadInst(varGV, "", jit->currentBlock);
+}
+
+Value* JnjvmModule::getStaticInstance(Class* classDef, JavaJIT* jit) {
+ llvm::GlobalVariable* varGV = 0;
+ static_instance_iterator End = staticInstances.end();
+ static_instance_iterator I = staticInstances.find(classDef);
+ if (I == End) {
+ LLVMClassInfo* LCI = getClassInfo(classDef);
+ LCI->getStaticType();
+ JavaObject* obj = ((Class*)classDef)->getStaticInstance();
+ Constant* cons =
+ ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
+ uint64_t (obj)), JnjvmModule::JavaObjectType);
+
+ varGV = new GlobalVariable(JnjvmModule::JavaObjectType, true,
+ GlobalValue::ExternalLinkage,
+ cons, "", this);
+
+ staticInstances.insert(std::make_pair(classDef, varGV));
+ } else {
+ varGV = I->second;
+ }
+
+ return new LoadInst(varGV, "", jit->currentBlock);
+}
+
+Value* JnjvmModule::getVirtualTable(CommonClass* classDef, JavaJIT* jit) {
+ llvm::GlobalVariable* varGV = 0;
+ virtual_table_iterator End = virtualTables.end();
+ virtual_table_iterator I = virtualTables.find(classDef);
+ if (I == End) {
+ if (!classDef->isArray() && !classDef->isPrimitive()) {
+ LLVMClassInfo* LCI = getClassInfo((Class*)classDef);
+ LCI->getVirtualType();
+ }
+ Constant* cons =
+ ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
+ uint64_t(classDef->virtualVT)),
+ JnjvmModule::VTType);
+ varGV = new GlobalVariable(JnjvmModule::VTType, true,
+ GlobalValue::ExternalLinkage,
+ cons, "", this);
+
+ virtualTables.insert(std::make_pair(classDef, varGV));
+ } else {
+ varGV = I->second;
+ }
+ return new LoadInst(varGV, "", jit->currentBlock);
}
#ifndef WITHOUT_VTABLE
@@ -228,7 +223,7 @@
if (isa<ReturnInst>(I)) {
((void**)VT)[0] = 0;
} else {
- ExecutionEngine* EE = mvm::jit::executionEngine;
+ ExecutionEngine* EE = mvm::MvmModule::executionEngine;
// LLVM does not allow recursive compilation. Create the code now.
((void**)VT)[0] = EE->getPointerToFunction(func);
}
@@ -252,7 +247,7 @@
VT = allocateVT(cl, ++meths);
LLVMMethodInfo* LMI = getMethodInfo(meth);
Function* func = LMI->getMethod();
- ExecutionEngine* EE = mvm::jit::executionEngine;
+ ExecutionEngine* EE = mvm::MvmModule::executionEngine;
((void**)VT)[offset] = EE->getPointerToFunctionOrStub(func);
}
@@ -304,9 +299,9 @@
Function* func = Function::Create(JnjvmModule::MarkAndTraceType,
GlobalValue::ExternalLinkage,
"markAndTraceObject",
- cl->classLoader->TheModule);
+ this);
- Constant* zero = mvm::jit::constantZero;
+ Constant* zero = mvm::MvmModule::constantZero;
Argument* arg = func->arg_begin();
BasicBlock* block = BasicBlock::Create("", func);
llvm::Value* realArg = new BitCastInst(arg, type, "", block);
@@ -317,7 +312,7 @@
Args.push_back(arg);
Args.push_back(GC);
if (stat || cl->super == 0) {
- CallInst::Create(JnjvmModule::JavaObjectTracer, Args.begin(), Args.end(),
+ CallInst::Create(JavaObjectTracerFunction, Args.begin(), Args.end(),
"", block);
} else {
CallInst::Create(((Class*)cl->super)->virtualTracer, Args.begin(),
@@ -325,7 +320,7 @@
}
#else
if (stat || cl->super == 0) {
- CallInst::Create(JnjvmModule::JavaObjectTracerFunction, arg, "", block);
+ CallInst::Create(JavaObjectTracerFunction, arg, "", block);
} else {
LLVMClassInfo* LCP = (LLVMClassInfo*)getClassInfo((Class*)(cl->super));
CallInst::Create(LCP->getVirtualTracer(), arg, "", block);
@@ -358,7 +353,7 @@
ReturnInst::Create(block);
- void* codePtr = mvm::jit::executionEngine->getPointerToGlobal(func);
+ void* codePtr = mvm::MvmModule::executionEngine->getPointerToGlobal(func);
((void**)res)[VT_TRACER_OFFSET] = codePtr;
func->deleteBody();
@@ -381,7 +376,7 @@
if (classDef->super) {
LLVMClassInfo* CLI =
- (LLVMClassInfo*)JnjvmModule::getClassInfo(classDef->super);
+ JnjvmModule::getClassInfo((Class*)classDef->super);
fields.push_back(CLI->getVirtualType()->getContainedType(0));
} else {
fields.push_back(JnjvmModule::JavaObjectType->getContainedType(0));
@@ -402,7 +397,7 @@
StructType* structType = StructType::get(fields, false);
virtualType = PointerType::getUnqual(structType);
- const TargetData* targetData = mvm::jit::executionEngine->getTargetData();
+ const TargetData* targetData = mvm::MvmModule::executionEngine->getTargetData();
const StructLayout* sl = targetData->getStructLayout(structType);
for (CommonClass::field_iterator i = classDef->virtualFields.begin(),
@@ -411,9 +406,10 @@
field->ptrOffset = sl->getElementOffset(field->num + 1);
}
- VirtualTable* VT = JnjvmModule::makeVT((Class*)classDef, false);
+ JnjvmModule* Mod = classDef->classLoader->TheModule;
+ VirtualTable* VT = Mod->makeVT((Class*)classDef, false);
- uint64 size = mvm::jit::getTypeSize(structType);
+ uint64 size = mvm::MvmModule::getTypeSize(structType);
classDef->virtualSize = (uint32)size;
classDef->virtualVT = VT;
virtualSizeConstant = ConstantInt::get(Type::Int32Ty, size);
@@ -447,7 +443,7 @@
StructType* structType = StructType::get(fields, false);
staticType = PointerType::getUnqual(structType);
- const TargetData* targetData = mvm::jit::executionEngine->getTargetData();
+ const TargetData* targetData = mvm::MvmModule::executionEngine->getTargetData();
const StructLayout* sl = targetData->getStructLayout(structType);
for (CommonClass::field_iterator i = classDef->staticFields.begin(),
@@ -457,48 +453,16 @@
}
- VirtualTable* VT = JnjvmModule::makeVT((Class*)classDef, true);
+ JnjvmModule* Mod = cl->classLoader->TheModule;
+ VirtualTable* VT = Mod->makeVT((Class*)classDef, true);
- uint64 size = mvm::jit::getTypeSize(structType);
+ uint64 size = mvm::MvmModule::getTypeSize(structType);
cl->staticSize = size;
cl->staticVT = VT;
}
return staticType;
}
-#ifndef ISOLATE
-Value* LLVMClassInfo::getStaticVar(JavaJIT* jit) {
- if (!staticVarGV) {
- getStaticType();
- JavaObject* obj = ((Class*)classDef)->getStaticInstance();
- Constant* cons =
- ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
- uint64_t (obj)), JnjvmModule::JavaObjectType);
-
- staticVarGV = new GlobalVariable(JnjvmModule::JavaObjectType, true,
- GlobalValue::ExternalLinkage,
- cons, "",
- classDef->classLoader->TheModule);
- }
-
- return new LoadInst(staticVarGV, "", jit->currentBlock);
-}
-#endif
-
-Value* LLVMClassInfo::getVirtualTable(JavaJIT* jit) {
- if (!virtualTableGV) {
- getVirtualType();
- Constant* cons =
- ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
- uint64_t(classDef->virtualVT)),
- JnjvmModule::VTType);
- virtualTableGV = new GlobalVariable(JnjvmModule::VTType, true,
- GlobalValue::ExternalLinkage,
- cons, "",
- classDef->classLoader->TheModule);
- }
- return new LoadInst(virtualTableGV, "", jit->currentBlock);
-}
Value* LLVMClassInfo::getVirtualSize(JavaJIT* jit) {
if (!virtualSizeConstant) {
@@ -572,7 +536,7 @@
const llvm::FunctionType* LLVMSignatureInfo::getVirtualType() {
if (!virtualType) {
// Lock here because we are called by arbitrary code
- llvm::MutexGuard locked(mvm::jit::executionEngine->lock);
+ llvm::MutexGuard locked(mvm::MvmModule::executionEngine->lock);
std::vector<const llvm::Type*> llvmArgs;
unsigned int size = signature->args.size();
@@ -598,7 +562,7 @@
const llvm::FunctionType* LLVMSignatureInfo::getStaticType() {
if (!staticType) {
// Lock here because we are called by arbitrary code
- llvm::MutexGuard locked(mvm::jit::executionEngine->lock);
+ llvm::MutexGuard locked(mvm::MvmModule::executionEngine->lock);
std::vector<const llvm::Type*> llvmArgs;
unsigned int size = signature->args.size();
@@ -622,11 +586,11 @@
const llvm::FunctionType* LLVMSignatureInfo::getNativeType() {
if (!nativeType) {
// Lock here because we are called by arbitrary code
- llvm::MutexGuard locked(mvm::jit::executionEngine->lock);
+ llvm::MutexGuard locked(mvm::MvmModule::executionEngine->lock);
std::vector<const llvm::Type*> llvmArgs;
unsigned int size = signature->args.size();
- llvmArgs.push_back(mvm::jit::ptrType); // JNIEnv
+ llvmArgs.push_back(mvm::MvmModule::ptrType); // JNIEnv
llvmArgs.push_back(JnjvmModule::JavaObjectType); // Class
for (uint32 i = 0; i < size; ++i) {
@@ -649,7 +613,7 @@
Function* LLVMSignatureInfo::createFunctionCallBuf(bool virt) {
- ConstantInt* CI = mvm::jit::constantZero;
+ ConstantInt* CI = mvm::MvmModule::constantZero;
std::vector<Value*> Args;
Function* res = Function::Create(virt ? getVirtualBufType() :
@@ -688,9 +652,9 @@
Value* arg = new LoadInst(val, "", currentBlock);
Args.push_back(arg);
if (type == Type::Int64Ty || type == Type::DoubleTy) {
- CI = mvm::jit::constantTwo;
+ CI = mvm::MvmModule::constantTwo;
} else {
- CI = mvm::jit::constantOne;
+ CI = mvm::MvmModule::constantOne;
}
}
@@ -783,7 +747,7 @@
const FunctionType* LLVMSignatureInfo::getVirtualBufType() {
if (!virtualBufType) {
// Lock here because we are called by arbitrary code
- llvm::MutexGuard locked(mvm::jit::executionEngine->lock);
+ llvm::MutexGuard locked(mvm::MvmModule::executionEngine->lock);
std::vector<const llvm::Type*> Args2;
Args2.push_back(JnjvmModule::JnjvmType); // vm
Args2.push_back(JnjvmModule::ConstantPoolType); // ctp
@@ -799,7 +763,7 @@
const FunctionType* LLVMSignatureInfo::getStaticBufType() {
if (!staticBufType) {
// Lock here because we are called by arbitrary code
- llvm::MutexGuard locked(mvm::jit::executionEngine->lock);
+ llvm::MutexGuard locked(mvm::MvmModule::executionEngine->lock);
std::vector<const llvm::Type*> Args;
Args.push_back(JnjvmModule::JnjvmType); // vm
Args.push_back(JnjvmModule::ConstantPoolType); // ctp
@@ -814,10 +778,10 @@
Function* LLVMSignatureInfo::getVirtualBuf() {
if (!virtualBufFunction) {
// Lock here because we are called by arbitrary code
- llvm::MutexGuard locked(mvm::jit::executionEngine->lock);
+ llvm::MutexGuard locked(mvm::MvmModule::executionEngine->lock);
virtualBufFunction = createFunctionCallBuf(true);
signature->setVirtualCallBuf((intptr_t)
- mvm::jit::executionEngine->getPointerToGlobal(virtualBufFunction));
+ mvm::MvmModule::executionEngine->getPointerToGlobal(virtualBufFunction));
virtualBufFunction->deleteBody();
}
return virtualBufFunction;
@@ -826,10 +790,10 @@
Function* LLVMSignatureInfo::getVirtualAP() {
if (!virtualAPFunction) {
// Lock here because we are called by arbitrary code
- llvm::MutexGuard locked(mvm::jit::executionEngine->lock);
+ llvm::MutexGuard locked(mvm::MvmModule::executionEngine->lock);
virtualAPFunction = createFunctionCallAP(true);
signature->setVirtualCallAP((intptr_t)
- mvm::jit::executionEngine->getPointerToGlobal(virtualAPFunction));
+ mvm::MvmModule::executionEngine->getPointerToGlobal(virtualAPFunction));
virtualAPFunction->deleteBody();
}
return virtualAPFunction;
@@ -838,10 +802,10 @@
Function* LLVMSignatureInfo::getStaticBuf() {
if (!staticBufFunction) {
// Lock here because we are called by arbitrary code
- llvm::MutexGuard locked(mvm::jit::executionEngine->lock);
+ llvm::MutexGuard locked(mvm::MvmModule::executionEngine->lock);
staticBufFunction = createFunctionCallBuf(false);
signature->setStaticCallBuf((intptr_t)
- mvm::jit::executionEngine->getPointerToGlobal(staticBufFunction));
+ mvm::MvmModule::executionEngine->getPointerToGlobal(staticBufFunction));
staticBufFunction->deleteBody();
}
return staticBufFunction;
@@ -850,10 +814,10 @@
Function* LLVMSignatureInfo::getStaticAP() {
if (!staticAPFunction) {
// Lock here because we are called by arbitrary code
- llvm::MutexGuard locked(mvm::jit::executionEngine->lock);
+ llvm::MutexGuard locked(mvm::MvmModule::executionEngine->lock);
staticAPFunction = createFunctionCallAP(false);
signature->setStaticCallAP((intptr_t)
- mvm::jit::executionEngine->getPointerToGlobal(staticAPFunction));
+ mvm::MvmModule::executionEngine->getPointerToGlobal(staticAPFunction));
staticAPFunction->deleteBody();
}
return staticAPFunction;
@@ -861,60 +825,18 @@
void JnjvmModule::resolveVirtualClass(Class* cl) {
// Lock here because we may be called by a class resolver
- llvm::MutexGuard locked(mvm::jit::executionEngine->lock);
+ llvm::MutexGuard locked(mvm::MvmModule::executionEngine->lock);
LLVMClassInfo* LCI = (LLVMClassInfo*)getClassInfo(cl);
LCI->getVirtualType();
}
void JnjvmModule::resolveStaticClass(Class* cl) {
// Lock here because we may be called by a class initializer
- llvm::MutexGuard locked(mvm::jit::executionEngine->lock);
+ llvm::MutexGuard locked(mvm::MvmModule::executionEngine->lock);
LLVMClassInfo* LCI = (LLVMClassInfo*)getClassInfo(cl);
LCI->getStaticType();
}
-#ifdef SERVICE_VM
-Value* LLVMServiceInfo::getDelegatee(JavaJIT* jit) {
- if (!delegateeGV) {
- Constant* cons =
- ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64(vm)),
- mvm::jit::ptrType);
- delegateeGV = new GlobalVariable(mvm::jit::ptrType, true,
- GlobalValue::ExternalLinkage,
- cons, "",
- vm->module);
- }
- return new LoadInst(delegateeGV, "", jit->currentBlock);
-}
-
-#endif
-
-
-LLVMStringInfo* JnjvmModule::getStringInfo(JavaString* str) {
- string_iterator SI = stringMap.find(str);
- if (SI != stringMap.end()) {
- return SI->second;
- } else {
- LLVMStringInfo* LSI = new LLVMStringInfo(str);
- stringMap.insert(std::make_pair(str, LSI));
- return LSI;
- }
-}
-
-Value* LLVMStringInfo::getDelegatee(JavaJIT* jit) {
- if (!delegateeGV) {
- void* ptr = str;
- Constant* cons =
- ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64(ptr)),
- JnjvmModule::JavaObjectType);
- delegateeGV = new GlobalVariable(JnjvmModule::JavaObjectType, true,
- GlobalValue::ExternalLinkage,
- cons, "",
- jit->module);
- }
- return new LoadInst(delegateeGV, "", jit->currentBlock);
-}
-
namespace jnjvm {
namespace llvm_runtime {
@@ -922,10 +844,13 @@
}
}
+Module* JnjvmModule::initialModule;
+
void JnjvmModule::initialise() {
- Module* module = this;
- jnjvm::llvm_runtime::makeLLVMModuleContents(module);
-
+ initialModule = new Module("Initial jnjvm module");
+ jnjvm::llvm_runtime::makeLLVMModuleContents(initialModule);
+ Module* module = initialModule;
+
VTType = module->getTypeByName("VT");
JnjvmType =
@@ -969,6 +894,89 @@
EnveloppeType =
PointerType::getUnqual(module->getTypeByName("Enveloppe"));
+#ifdef WITH_TRACER
+ MarkAndTraceType = module->getFunction("MarkAndTrace")->getFunctionType();
+#endif
+
+ UTF8NullConstant = Constant::getNullValue(JavaArrayUInt16Type);
+ JavaClassNullConstant = Constant::getNullValue(JavaClassType);
+ JavaObjectNullConstant = Constant::getNullValue(JnjvmModule::JavaObjectType);
+ MaxArraySizeConstant = ConstantInt::get(Type::Int32Ty,
+ JavaArray::MaxArraySize);
+ JavaObjectSizeConstant = ConstantInt::get(Type::Int32Ty, sizeof(JavaObject));
+
+
+ JavaArrayElementsOffsetConstant = mvm::MvmModule::constantTwo;
+ JavaArraySizeOffsetConstant = mvm::MvmModule::constantOne;
+ JavaObjectLockOffsetConstant = mvm::MvmModule::constantTwo;
+ JavaObjectClassOffsetConstant = mvm::MvmModule::constantOne;
+
+ OffsetObjectSizeInClassConstant = mvm::MvmModule::constantOne;
+ OffsetVTInClassConstant = mvm::MvmModule::constantTwo;
+ OffsetDisplayInClassConstant = mvm::MvmModule::constantThree;
+ OffsetDepthInClassConstant = mvm::MvmModule::constantFour;
+ OffsetStatusInClassConstant = mvm::MvmModule::constantFive;
+ OffsetCtpInClassConstant = mvm::MvmModule::constantSix;
+
+ LLVMAssessorInfo::initialise();
+}
+
+void JnjvmModule::InitField(JavaField* field, JavaObject* obj, uint64 val) {
+
+ Typedef* type = field->getSignature();
+ if (!type->isPrimitive()) {
+ ((sint32*)((uint64)obj + field->ptrOffset))[0] = (sint32)val;
+ return;
+ }
+
+ PrimitiveTypedef* prim = (PrimitiveTypedef*)type;
+ if (prim->isLong()) {
+ ((sint64*)((uint64)obj + field->ptrOffset))[0] = val;
+ } else if (prim->isInt()) {
+ ((sint32*)((uint64)obj + field->ptrOffset))[0] = (sint32)val;
+ } else if (prim->isChar()) {
+ ((uint16*)((uint64)obj + field->ptrOffset))[0] = (uint16)val;
+ } else if (prim->isShort()) {
+ ((sint16*)((uint64)obj + field->ptrOffset))[0] = (sint16)val;
+ } else if (prim->isByte()) {
+ ((sint8*)((uint64)obj + field->ptrOffset))[0] = (sint8)val;
+ } else if (prim->isBool()) {
+ ((uint8*)((uint64)obj + field->ptrOffset))[0] = (uint8)val;
+ } else {
+ // 0 value for everything else
+ ((sint32*)((uint64)obj + field->ptrOffset))[0] = (sint32)val;
+ }
+}
+
+void JnjvmModule::InitField(JavaField* field, JavaObject* obj, JavaObject* val) {
+ ((JavaObject**)((uint64)obj + field->ptrOffset))[0] = val;
+}
+
+void JnjvmModule::InitField(JavaField* field, JavaObject* obj, double val) {
+ ((double*)((uint64)obj + field->ptrOffset))[0] = val;
+}
+
+void JnjvmModule::InitField(JavaField* field, JavaObject* obj, float val) {
+ ((float*)((uint64)obj + field->ptrOffset))[0] = val;
+}
+
+void JnjvmModule::setMethod(JavaMethod* meth, const char* name) {
+ llvm::Function* func = getMethodInfo(meth)->getMethod();
+ func->setName(name);
+ func->setLinkage(llvm::GlobalValue::ExternalLinkage);
+}
+
+void* JnjvmModule::getMethod(JavaMethod* meth) {
+ return getMethodInfo(meth)->getMethod();
+}
+
+JnjvmModule::JnjvmModule(const std::string &ModuleID) : MvmModule(ModuleID) {
+ std::string str =
+ mvm::MvmModule::executionEngine->getTargetData()->getStringRepresentation();
+ setDataLayout(str);
+
+ Module* module = initialModule;
+
InterfaceLookupFunction = module->getFunction("jnjvmVirtualLookup");
MultiCallNewFunction = module->getFunction("multiCallNew");
InitialisationCheckFunction = module->getFunction("initialisationCheck");
@@ -1052,7 +1060,6 @@
#ifdef WITH_TRACER
MarkAndTraceFunction = module->getFunction("MarkAndTrace");
- MarkAndTraceType = MarkAndTraceFunction->getFunctionType();
JavaObjectTracerFunction = module->getFunction("JavaObjectTracer");
#endif
@@ -1066,102 +1073,8 @@
GetThreadIDFunction = module->getFunction("getThreadID");
GetLockFunction = module->getFunction("getLock");
-
- UTF8NullConstant = Constant::getNullValue(JavaArrayUInt16Type);
- JavaClassNullConstant = Constant::getNullValue(JavaClassType);
- JavaObjectNullConstant = Constant::getNullValue(JnjvmModule::JavaObjectType);
- MaxArraySizeConstant = ConstantInt::get(Type::Int32Ty,
- JavaArray::MaxArraySize);
- JavaObjectSizeConstant = ConstantInt::get(Type::Int32Ty, sizeof(JavaObject));
-
-
- Constant* cons =
- ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
- uint64_t (JavaObject::VT)), VTType);
-
- JavaObjectVirtualTableGV = new GlobalVariable(VTType, true,
- GlobalValue::ExternalLinkage,
- cons, "",
- module);
-
- cons =
- ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
- uint64_t (ArrayObject::VT)), VTType);
-
- ArrayObjectVirtualTableGV = new GlobalVariable(VTType, true,
- GlobalValue::ExternalLinkage,
- cons, "",
- module);
-
- JavaArrayElementsOffsetConstant = mvm::jit::constantTwo;
- JavaArraySizeOffsetConstant = mvm::jit::constantOne;
- JavaObjectLockOffsetConstant = mvm::jit::constantTwo;
- JavaObjectClassOffsetConstant = mvm::jit::constantOne;
-
- OffsetObjectSizeInClassConstant = mvm::jit::constantOne;
- OffsetVTInClassConstant = mvm::jit::constantTwo;
- OffsetDisplayInClassConstant = mvm::jit::constantThree;
- OffsetDepthInClassConstant = mvm::jit::constantFour;
- OffsetStatusInClassConstant = mvm::jit::constantFive;
- OffsetCtpInClassConstant = mvm::jit::constantSix;
-
- LLVMAssessorInfo::initialise();
-}
-
-void JnjvmModule::InitField(JavaField* field, JavaObject* obj, uint64 val) {
-
- Typedef* type = field->getSignature();
- if (!type->isPrimitive()) {
- ((sint32*)((uint64)obj + field->ptrOffset))[0] = (sint32)val;
- return;
- }
-
- PrimitiveTypedef* prim = (PrimitiveTypedef*)type;
- if (prim->isLong()) {
- ((sint64*)((uint64)obj + field->ptrOffset))[0] = val;
- } else if (prim->isInt()) {
- ((sint32*)((uint64)obj + field->ptrOffset))[0] = (sint32)val;
- } else if (prim->isChar()) {
- ((uint16*)((uint64)obj + field->ptrOffset))[0] = (uint16)val;
- } else if (prim->isShort()) {
- ((sint16*)((uint64)obj + field->ptrOffset))[0] = (sint16)val;
- } else if (prim->isByte()) {
- ((sint8*)((uint64)obj + field->ptrOffset))[0] = (sint8)val;
- } else if (prim->isBool()) {
- ((uint8*)((uint64)obj + field->ptrOffset))[0] = (uint8)val;
- } else {
- // 0 value for everything else
- ((sint32*)((uint64)obj + field->ptrOffset))[0] = (sint32)val;
- }
-}
-
-void JnjvmModule::InitField(JavaField* field, JavaObject* obj, JavaObject* val) {
- ((JavaObject**)((uint64)obj + field->ptrOffset))[0] = val;
-}
-
-void JnjvmModule::InitField(JavaField* field, JavaObject* obj, double val) {
- ((double*)((uint64)obj + field->ptrOffset))[0] = val;
-}
-
-void JnjvmModule::InitField(JavaField* field, JavaObject* obj, float val) {
- ((float*)((uint64)obj + field->ptrOffset))[0] = val;
}
-void JnjvmModule::setMethod(JavaMethod* meth, const char* name) {
- llvm::Function* func = getMethodInfo(meth)->getMethod();
- func->setName(name);
- func->setLinkage(llvm::GlobalValue::ExternalLinkage);
-}
-
-void* JnjvmModule::getMethod(JavaMethod* meth) {
- return getMethodInfo(meth)->getMethod();
-}
-
-JnjvmModule::JnjvmModule(const std::string &ModuleID) : llvm::Module(ModuleID) {
- std::string str =
- mvm::jit::executionEngine->getTargetData()->getStringRepresentation();
- setDataLayout(str);
-}
void LLVMAssessorInfo::initialise() {
AssessorInfo[I_VOID].llvmType = Type::VoidTy;
AssessorInfo[I_VOID].llvmTypePtr = 0;
@@ -1172,63 +1085,63 @@
AssessorInfo[I_BOOL].llvmTypePtr = PointerType::getUnqual(Type::Int8Ty);
AssessorInfo[I_BOOL].llvmNullConstant =
Constant::getNullValue(Type::Int8Ty);
- AssessorInfo[I_BOOL].sizeInBytesConstant = mvm::jit::constantOne;
+ AssessorInfo[I_BOOL].sizeInBytesConstant = mvm::MvmModule::constantOne;
AssessorInfo[I_BYTE].llvmType = Type::Int8Ty;
AssessorInfo[I_BYTE].llvmTypePtr = PointerType::getUnqual(Type::Int8Ty);
AssessorInfo[I_BYTE].llvmNullConstant =
Constant::getNullValue(Type::Int8Ty);
- AssessorInfo[I_BYTE].sizeInBytesConstant = mvm::jit::constantOne;
+ AssessorInfo[I_BYTE].sizeInBytesConstant = mvm::MvmModule::constantOne;
AssessorInfo[I_SHORT].llvmType = Type::Int16Ty;
AssessorInfo[I_SHORT].llvmTypePtr = PointerType::getUnqual(Type::Int16Ty);
AssessorInfo[I_SHORT].llvmNullConstant =
Constant::getNullValue(Type::Int16Ty);
- AssessorInfo[I_SHORT].sizeInBytesConstant = mvm::jit::constantTwo;
+ AssessorInfo[I_SHORT].sizeInBytesConstant = mvm::MvmModule::constantTwo;
AssessorInfo[I_CHAR].llvmType = Type::Int16Ty;
AssessorInfo[I_CHAR].llvmTypePtr = PointerType::getUnqual(Type::Int16Ty);
AssessorInfo[I_CHAR].llvmNullConstant =
Constant::getNullValue(Type::Int16Ty);
- AssessorInfo[I_CHAR].sizeInBytesConstant = mvm::jit::constantTwo;
+ AssessorInfo[I_CHAR].sizeInBytesConstant = mvm::MvmModule::constantTwo;
AssessorInfo[I_INT].llvmType = Type::Int32Ty;
AssessorInfo[I_INT].llvmTypePtr = PointerType::getUnqual(Type::Int32Ty);
AssessorInfo[I_INT].llvmNullConstant =
Constant::getNullValue(Type::Int32Ty);
- AssessorInfo[I_INT].sizeInBytesConstant = mvm::jit::constantFour;
+ AssessorInfo[I_INT].sizeInBytesConstant = mvm::MvmModule::constantFour;
AssessorInfo[I_FLOAT].llvmType = Type::FloatTy;
AssessorInfo[I_FLOAT].llvmTypePtr = PointerType::getUnqual(Type::FloatTy);
AssessorInfo[I_FLOAT].llvmNullConstant =
Constant::getNullValue(Type::FloatTy);
- AssessorInfo[I_FLOAT].sizeInBytesConstant = mvm::jit::constantFour;
+ AssessorInfo[I_FLOAT].sizeInBytesConstant = mvm::MvmModule::constantFour;
AssessorInfo[I_LONG].llvmType = Type::Int64Ty;
AssessorInfo[I_LONG].llvmTypePtr = PointerType::getUnqual(Type::Int64Ty);
AssessorInfo[I_LONG].llvmNullConstant =
Constant::getNullValue(Type::Int64Ty);
- AssessorInfo[I_LONG].sizeInBytesConstant = mvm::jit::constantEight;
+ AssessorInfo[I_LONG].sizeInBytesConstant = mvm::MvmModule::constantEight;
AssessorInfo[I_DOUBLE].llvmType = Type::DoubleTy;
AssessorInfo[I_DOUBLE].llvmTypePtr = PointerType::getUnqual(Type::DoubleTy);
AssessorInfo[I_DOUBLE].llvmNullConstant =
Constant::getNullValue(Type::DoubleTy);
- AssessorInfo[I_DOUBLE].sizeInBytesConstant = mvm::jit::constantEight;
+ AssessorInfo[I_DOUBLE].sizeInBytesConstant = mvm::MvmModule::constantEight;
AssessorInfo[I_TAB].llvmType = JnjvmModule::JavaObjectType;
AssessorInfo[I_TAB].llvmTypePtr =
PointerType::getUnqual(JnjvmModule::JavaObjectType);
AssessorInfo[I_TAB].llvmNullConstant =
JnjvmModule::JavaObjectNullConstant;
- AssessorInfo[I_TAB].sizeInBytesConstant = mvm::jit::constantPtrSize;
+ AssessorInfo[I_TAB].sizeInBytesConstant = mvm::MvmModule::constantPtrSize;
AssessorInfo[I_REF].llvmType = JnjvmModule::JavaObjectType;
AssessorInfo[I_REF].llvmTypePtr =
PointerType::getUnqual(JnjvmModule::JavaObjectType);
AssessorInfo[I_REF].llvmNullConstant =
JnjvmModule::JavaObjectNullConstant;
- AssessorInfo[I_REF].sizeInBytesConstant = mvm::jit::constantPtrSize;
+ AssessorInfo[I_REF].sizeInBytesConstant = mvm::MvmModule::constantPtrSize;
}
std::map<const char, LLVMAssessorInfo> LLVMAssessorInfo::AssessorInfo;
Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h Fri Oct 10 07:51:51 2008
@@ -50,42 +50,13 @@
};
-class LLVMCommonClassInfo : public mvm::JITInfo {
-
- friend class JnjvmModule;
-
-protected:
- CommonClass* classDef;
-
-private:
- /// varGV - The LLVM global variable representing this class.
- ///
- llvm::GlobalVariable* varGV;
-
- /// delegateeGV - The LLVM global variable representing the
- /// java/lang/Class instance of this class.
- llvm::GlobalVariable* delegateeGV;
-
-
-public:
- llvm::Value* getVar(JavaJIT* jit);
- llvm::Value* getDelegatee(JavaJIT* jit);
-
- LLVMCommonClassInfo(CommonClass* cl) :
- classDef(cl),
- varGV(0),
- delegateeGV(0)
- {}
-};
-
-class LLVMClassInfo : public LLVMCommonClassInfo {
+class LLVMClassInfo : public mvm::JITInfo {
friend class JnjvmModule;
private:
+ CommonClass* classDef;
/// virtualSizeLLVM - The LLVM constant size of instances of this class.
///
llvm::ConstantInt* virtualSizeConstant;
- llvm::GlobalVariable* staticVarGV;
- llvm::GlobalVariable* virtualTableGV;
llvm::Function* virtualTracerFunction;
llvm::Function* staticTracerFunction;
/// virtualType - The LLVM type of instance of this class.
@@ -97,19 +68,15 @@
const llvm::Type * staticType;
public:
- llvm::Value* getStaticVar(JavaJIT* jit);
- llvm::Value* getVirtualTable(JavaJIT* jit);
llvm::Value* getVirtualSize(JavaJIT* jit);
llvm::Function* getStaticTracer();
llvm::Function* getVirtualTracer();
const llvm::Type* getVirtualType();
const llvm::Type* getStaticType();
- LLVMClassInfo(CommonClass* cl) :
- LLVMCommonClassInfo(cl),
+ LLVMClassInfo(CommonClass* cl) :
+ classDef(cl),
virtualSizeConstant(0),
- staticVarGV(0),
- virtualTableGV(0),
virtualTracerFunction(0),
staticTracerFunction(0),
virtualType(0),
@@ -209,74 +176,38 @@
};
-#ifdef SERVICE_VM
-class LLVMServiceInfo : public mvm::JITInfo {
-private:
- ServiceDomain* vm;
- llvm::GlobalVariable* delegateeGV;
-
-public:
- llvm::Value* getDelegatee(JavaJIT* jit);
-};
-#endif
-
-class LLVMConstantPoolInfo : public mvm::JITInfo {
-private:
- JavaConstantPool* ctp;
- llvm::GlobalVariable* delegateeGV;
-
-public:
- llvm::Value* getDelegatee(JavaJIT* jit);
-
- LLVMConstantPoolInfo(JavaConstantPool* c) :
- ctp(c), delegateeGV(0) {}
-};
-
-class LLVMStringInfo : public mvm::JITInfo {
-private:
- JavaString* str;
- llvm::GlobalVariable* delegateeGV;
-
-public:
- llvm::Value* getDelegatee(JavaJIT* jit);
-
- LLVMStringInfo(JavaString* c) :
- str(c), delegateeGV(0) {}
-};
-
-class JnjvmModule : public llvm::Module {
+class JnjvmModule : public mvm::MvmModule {
friend class LLVMClassInfo;
private:
- std::map<const CommonClass*, LLVMCommonClassInfo*> classMap;
- std::map<const Signdef*, LLVMSignatureInfo*> signatureMap;
- std::map<const JavaField*, LLVMFieldInfo*> fieldMap;
- std::map<const JavaMethod*, LLVMMethodInfo*> methodMap;
- std::map<const JavaString*, LLVMStringInfo*> stringMap;
+ std::map<const CommonClass*, llvm::GlobalVariable*> nativeClasses;
+ std::map<const CommonClass*, llvm::GlobalVariable*> javaClasses;
+ std::map<const CommonClass*, llvm::GlobalVariable*> virtualTables;
+ std::map<const Class*, llvm::GlobalVariable*> staticInstances;
+ std::map<const JavaConstantPool*, llvm::GlobalVariable*> constantPools;
+ std::map<const JavaString*, llvm::GlobalVariable*> strings;
-#ifdef SERVICE_VM
- std::map<const ServiceDomain*, LLVMServiceInfo*> serviceMap;
- typedef std::map<const ServiceDomain*, LLVMServiceInfo*>::iterator
- class_iterator;
-#endif
+ typedef std::map<const CommonClass*, llvm::GlobalVariable*>::iterator
+ native_class_iterator;
- typedef std::map<const CommonClass*, LLVMCommonClassInfo*>::iterator
- class_iterator;
+ typedef std::map<const CommonClass*, llvm::GlobalVariable*>::iterator
+ java_class_iterator;
- typedef std::map<const Signdef*, LLVMSignatureInfo*>::iterator
- signature_iterator;
+ typedef std::map<const CommonClass*, llvm::GlobalVariable*>::iterator
+ virtual_table_iterator;
- typedef std::map<const JavaMethod*, LLVMMethodInfo*>::iterator
- method_iterator;
+ typedef std::map<const Class*, llvm::GlobalVariable*>::iterator
+ static_instance_iterator;
- typedef std::map<const JavaField*, LLVMFieldInfo*>::iterator
- field_iterator;
+ typedef std::map<const JavaConstantPool*, llvm::GlobalVariable*>::iterator
+ constant_pool_iterator;
- typedef std::map<const JavaString*, LLVMStringInfo*>::iterator
+ typedef std::map<const JavaString*, llvm::GlobalVariable*>::iterator
string_iterator;
+
- static VirtualTable* makeVT(Class* cl, bool stat);
- static VirtualTable* allocateVT(Class* cl, CommonClass::method_iterator meths);
+ VirtualTable* makeVT(Class* cl, bool stat);
+ VirtualTable* allocateVT(Class* cl, CommonClass::method_iterator meths);
public:
@@ -308,71 +239,71 @@
static const llvm::Type* ConstantPoolType;
#ifdef WITH_TRACER
- static llvm::Function* MarkAndTraceFunction;
+ llvm::Function* MarkAndTraceFunction;
static const llvm::FunctionType* MarkAndTraceType;
- static llvm::Function* JavaObjectTracerFunction;
+ llvm::Function* JavaObjectTracerFunction;
#endif
- static llvm::Function* GetSJLJBufferFunction;
- static llvm::Function* InterfaceLookupFunction;
- static llvm::Function* VirtualFieldLookupFunction;
- static llvm::Function* StaticFieldLookupFunction;
- static llvm::Function* PrintExecutionFunction;
- static llvm::Function* PrintMethodStartFunction;
- static llvm::Function* PrintMethodEndFunction;
- static llvm::Function* JniProceedPendingExceptionFunction;
- static llvm::Function* InitialisationCheckFunction;
- static llvm::Function* ForceInitialisationCheckFunction;
- static llvm::Function* ClassLookupFunction;
+ llvm::Function* GetSJLJBufferFunction;
+ llvm::Function* InterfaceLookupFunction;
+ llvm::Function* VirtualFieldLookupFunction;
+ llvm::Function* StaticFieldLookupFunction;
+ llvm::Function* PrintExecutionFunction;
+ llvm::Function* PrintMethodStartFunction;
+ llvm::Function* PrintMethodEndFunction;
+ llvm::Function* JniProceedPendingExceptionFunction;
+ llvm::Function* InitialisationCheckFunction;
+ llvm::Function* ForceInitialisationCheckFunction;
+ llvm::Function* ClassLookupFunction;
#ifndef WITHOUT_VTABLE
- static llvm::Function* VirtualLookupFunction;
+ llvm::Function* VirtualLookupFunction;
#endif
- static llvm::Function* InstanceOfFunction;
- static llvm::Function* IsAssignableFromFunction;
- static llvm::Function* ImplementsFunction;
- static llvm::Function* InstantiationOfArrayFunction;
- static llvm::Function* GetDepthFunction;
- static llvm::Function* GetClassInDisplayFunction;
- static llvm::Function* GetDisplayFunction;
- static llvm::Function* AquireObjectFunction;
- static llvm::Function* ReleaseObjectFunction;
- static llvm::Function* GetConstantPoolAtFunction;
+ llvm::Function* InstanceOfFunction;
+ llvm::Function* IsAssignableFromFunction;
+ llvm::Function* ImplementsFunction;
+ llvm::Function* InstantiationOfArrayFunction;
+ llvm::Function* GetDepthFunction;
+ llvm::Function* GetClassInDisplayFunction;
+ llvm::Function* GetDisplayFunction;
+ llvm::Function* AquireObjectFunction;
+ llvm::Function* ReleaseObjectFunction;
+ llvm::Function* GetConstantPoolAtFunction;
#ifdef SERVICE_VM
- static llvm::Function* AquireObjectInSharedDomainFunction;
- static llvm::Function* ReleaseObjectInSharedDomainFunction;
- static llvm::Function* ServiceCallStartFunction;
- static llvm::Function* ServiceCallStopFunction;
+ llvm::Function* AquireObjectInSharedDomainFunction;
+ llvm::Function* ReleaseObjectInSharedDomainFunction;
+ llvm::Function* ServiceCallStartFunction;
+ llvm::Function* ServiceCallStopFunction;
#endif
- static llvm::Function* MultiCallNewFunction;
+ llvm::Function* MultiCallNewFunction;
#ifdef ISOLATE
- static llvm::Function* StringLookupFunction;
+ llvm::Function* StringLookupFunction;
#ifdef ISOLATE_SHARING
- static llvm::Function* GetCtpCacheNodeFunction;
- static llvm::Function* GetCtpClassFunction;
- static llvm::Function* EnveloppeLookupFunction;
- static llvm::Function* GetJnjvmExceptionClassFunction;
- static llvm::Function* GetJnjvmArrayClassFunction;
- static llvm::Function* StaticCtpLookupFunction;
- static llvm::Function* SpecialCtpLookupFunction;
- static llvm::Function* GetArrayClassFunction;
+ llvm::Function* GetCtpCacheNodeFunction;
+ llvm::Function* GetCtpClassFunction;
+ llvm::Function* EnveloppeLookupFunction;
+ llvm::Function* GetJnjvmExceptionClassFunction;
+ llvm::Function* GetJnjvmArrayClassFunction;
+ llvm::Function* StaticCtpLookupFunction;
+ llvm::Function* SpecialCtpLookupFunction;
+ llvm::Function* GetArrayClassFunction;
#endif
#endif
- static llvm::Function* GetClassDelegateeFunction;
- static llvm::Function* ArrayLengthFunction;
- static llvm::Function* GetVTFunction;
- static llvm::Function* GetClassFunction;
- static llvm::Function* JavaObjectAllocateFunction;
+ llvm::Function* GetClassDelegateeFunction;
+ llvm::Function* ArrayLengthFunction;
+ llvm::Function* GetVTFunction;
+ llvm::Function* GetClassFunction;
+ llvm::Function* JavaObjectAllocateFunction;
#ifdef MULTIPLE_GC
- static llvm::Function* GetCollectorFunction;
+ llvm::Function* GetCollectorFunction;
#endif
- static llvm::Function* GetVTFromClassFunction;
- static llvm::Function* GetObjectSizeFromClassFunction;
+ llvm::Function* GetVTFromClassFunction;
+ llvm::Function* GetObjectSizeFromClassFunction;
- static llvm::Function* GetLockFunction;
- static llvm::Function* GetThreadIDFunction;
- static llvm::Function* OverflowThinLockFunction;
+ llvm::Function* GetLockFunction;
+ llvm::Function* GetThreadIDFunction;
+ llvm::Function* OverflowThinLockFunction;
static llvm::ConstantInt* OffsetObjectSizeInClassConstant;
static llvm::ConstantInt* OffsetVTInClassConstant;
@@ -388,19 +319,16 @@
static llvm::Constant* MaxArraySizeConstant;
static llvm::Constant* JavaObjectSizeConstant;
- static llvm::GlobalVariable* ArrayObjectVirtualTableGV;
- static llvm::GlobalVariable* JavaObjectVirtualTableGV;
-
- static llvm::Function* GetExceptionFunction;
- static llvm::Function* GetJavaExceptionFunction;
- static llvm::Function* ThrowExceptionFunction;
- static llvm::Function* ClearExceptionFunction;
- static llvm::Function* CompareExceptionFunction;
- static llvm::Function* NullPointerExceptionFunction;
- static llvm::Function* IndexOutOfBoundsExceptionFunction;
- static llvm::Function* ClassCastExceptionFunction;
- static llvm::Function* OutOfMemoryErrorFunction;
- static llvm::Function* NegativeArraySizeExceptionFunction;
+ llvm::Function* GetExceptionFunction;
+ llvm::Function* GetJavaExceptionFunction;
+ llvm::Function* ThrowExceptionFunction;
+ llvm::Function* ClearExceptionFunction;
+ llvm::Function* CompareExceptionFunction;
+ llvm::Function* NullPointerExceptionFunction;
+ llvm::Function* IndexOutOfBoundsExceptionFunction;
+ llvm::Function* ClassCastExceptionFunction;
+ llvm::Function* OutOfMemoryErrorFunction;
+ llvm::Function* NegativeArraySizeExceptionFunction;
static void InitField(JavaField* field);
static void InitField(JavaField* field, JavaObject* obj, uint64 val = 0);
@@ -418,11 +346,7 @@
return sign->getInfo<LLVMSignatureInfo>();
}
- static LLVMCommonClassInfo* getClassInfo(CommonClass* cl) {
- if (cl->isArray() || cl->isPrimitive()) {
- return cl->getInfo<LLVMCommonClassInfo>();
- }
-
+ static LLVMClassInfo* getClassInfo(Class* cl) {
return cl->getInfo<LLVMClassInfo>();
}
@@ -434,22 +358,22 @@
return method->getInfo<LLVMMethodInfo>();
}
- static LLVMConstantPoolInfo* getConstantPoolInfo(JavaConstantPool* ctp) {
- return ctp->getInfo<LLVMConstantPoolInfo>();
- }
-
static LLVMAssessorInfo& getTypedefInfo(Typedef* type);
- LLVMStringInfo* getStringInfo(JavaString* str);
+ explicit JnjvmModule(const std::string &ModuleID);
+ static void initialise();
-#ifdef SERVICE_VM
- static LLVMServiceInfo* getServiceInfo(ServiceDomain* service) {
- return service->getInfo<LLVMServiceInfo>();
- }
-#endif
+ llvm::Value* getNativeClass(CommonClass* cl, JavaJIT* jit);
+ llvm::Value* getJavaClass(CommonClass* cl, JavaJIT* jit);
+ llvm::Value* getStaticInstance(Class* cl, JavaJIT* jit);
+ llvm::Value* getVirtualTable(CommonClass* cl, JavaJIT* jit);
- explicit JnjvmModule(const std::string &ModuleID);
- void initialise();
+ llvm::Value* getString(JavaString* str, JavaJIT* jit);
+ llvm::Value* getConstantPool(JavaConstantPool* ctp, JavaJIT* jit);
+
+private:
+ static llvm::Module* initialModule;
+
};
}
Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp Fri Oct 10 07:51:51 2008
@@ -9,6 +9,7 @@
#include "llvm/LinkAllPasses.h"
#include "llvm/Analysis/LoopPass.h"
+#include "llvm/Analysis/Verifier.h"
#include "llvm/Support/MutexGuard.h"
#include "mvm/JIT.h"
@@ -74,7 +75,7 @@
bool JnjvmModuleProvider::materializeFunction(Function *F,
std::string *ErrInfo) {
- if (mvm::jit::executionEngine->getPointerToGlobalIfAvailable(F))
+ if (mvm::MvmModule::executionEngine->getPointerToGlobalIfAvailable(F))
return false;
if (!(F->hasNotBeenReadFromBitcode()))
@@ -91,7 +92,7 @@
void* val = meth->compiledPtr();
if (F->isDeclaration())
- mvm::jit::executionEngine->updateGlobalMapping(F, val);
+ mvm::MvmModule::executionEngine->updateGlobalMapping(F, val);
if (isVirtual(meth->access)) {
LLVMMethodInfo* LMI = ((JnjvmModule*)TheModule)->getMethodInfo(meth);
@@ -115,8 +116,8 @@
void* JnjvmModuleProvider::materializeFunction(JavaMethod* meth) {
Function* func = parseFunction(meth);
- void* res = mvm::jit::executionEngine->getPointerToGlobal(func);
- mvm::Code* m = mvm::jit::getCodeFromPointer(res);
+ void* res = mvm::MvmModule::executionEngine->getPointerToGlobal(func);
+ mvm::Code* m = mvm::MvmModule::getCodeFromPointer(res);
if (m) m->setMetaInfo(meth);
func->deleteBody();
@@ -128,7 +129,7 @@
Function* func = LMI->getMethod();
if (func->hasNotBeenReadFromBitcode()) {
// We are jitting. Take the lock.
- llvm::MutexGuard locked(mvm::jit::executionEngine->lock);
+ llvm::MutexGuard locked(mvm::MvmModule::executionEngine->lock);
JavaJIT jit;
jit.compilingClass = meth->classDef;
jit.compilingMethod = meth;
@@ -138,7 +139,7 @@
jit.nativeCompile();
} else {
jit.javaCompile();
- mvm::jit::runPasses(func, perFunctionPasses);
+ mvm::MvmModule::runPasses(func, perFunctionPasses);
}
}
return func;
@@ -197,9 +198,15 @@
// -indvars -loop-unroll -instcombine -gvn -sccp -simplifycfg
// -instcombine -condprop -dse -adce -simplifycfg
//
-static void AddStandardCompilePasses(FunctionPassManager *PM) {
- llvm::MutexGuard locked(mvm::jit::executionEngine->lock);
- // LLVM does not allow calling functions from other modules in verifier
+static void AddStandardCompilePasses(JnjvmModule* mod, FunctionPassManager *PM) {
+ llvm::MutexGuard locked(mvm::MvmModule::executionEngine->lock);
+
+ // TODO: enable this when
+ // - we can call multiple times the makeLLVMModuleContents function generated
+ // by llc -march=cpp -cppgen=contents
+ // - intrinsics won't be in the .ll files
+ // - each module will have its declaration of external functions
+ //
//PM->add(llvm::createVerifierPass()); // Verify that input is correct
addPass(PM, llvm::createCFGSimplificationPass()); // Clean up disgusting code
@@ -226,7 +233,7 @@
addPass(PM, createSCCPPass()); // Constant prop with SCCP
addPass(PM, createCFGSimplificationPass()); // Merge & remove BBs
- Function* func = JnjvmModule::JavaObjectAllocateFunction;
+ Function* func = mod->JavaObjectAllocateFunction;
addPass(PM, mvm::createEscapeAnalysisPass(func));
addPass(PM, mvm::createLowerConstantCallsPass());
@@ -245,17 +252,17 @@
JnjvmModuleProvider::JnjvmModuleProvider(JnjvmModule *m) {
TheModule = (Module*)m;
- mvm::jit::protectEngine->lock();
- mvm::jit::executionEngine->addModuleProvider(this);
- mvm::jit::protectEngine->unlock();
+ mvm::MvmModule::protectEngine->lock();
+ mvm::MvmModule::executionEngine->addModuleProvider(this);
+ mvm::MvmModule::protectEngine->unlock();
perFunctionPasses = new llvm::FunctionPassManager(this);
perFunctionPasses->add(new llvm::TargetData(m));
- AddStandardCompilePasses(perFunctionPasses);
+ AddStandardCompilePasses(m, perFunctionPasses);
}
JnjvmModuleProvider::~JnjvmModuleProvider() {
- mvm::jit::protectEngine->lock();
- mvm::jit::executionEngine->removeModuleProvider(this);
- mvm::jit::protectEngine->unlock();
+ mvm::MvmModule::protectEngine->lock();
+ mvm::MvmModule::executionEngine->removeModuleProvider(this);
+ mvm::MvmModule::protectEngine->unlock();
delete TheModule;
}
Modified: vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp Fri Oct 10 07:51:51 2008
@@ -37,6 +37,7 @@
static RegisterPass<LowerConstantCalls> X("LowerConstantCalls",
"Lower Constant calls");
bool LowerConstantCalls::runOnFunction(Function& F) {
+ JnjvmModule* module = (JnjvmModule*)F.getParent();
bool Changed = false;
for (Function::iterator BI = F.begin(), BE = F.end(); BI != BE; BI++) {
BasicBlock *Cur = BI;
@@ -47,87 +48,87 @@
Instruction* CI = Call.getInstruction();
if (CI) {
Value* V = Call.getCalledValue();
- if (V == jnjvm::JnjvmModule::ArrayLengthFunction) {
+ if (V == module->ArrayLengthFunction) {
Changed = true;
Value* val = Call.getArgument(0); // get the array
- Value* array = new BitCastInst(val, jnjvm::JnjvmModule::JavaArrayType,
+ Value* array = new BitCastInst(val, module->JavaArrayType,
"", CI);
std::vector<Value*> args; //size= 2
- args.push_back(mvm::jit::constantZero);
- args.push_back(jnjvm::JnjvmModule::JavaArraySizeOffsetConstant);
+ args.push_back(mvm::MvmModule::constantZero);
+ args.push_back(module->JavaArraySizeOffsetConstant);
Value* ptr = GetElementPtrInst::Create(array, args.begin(), args.end(),
"", CI);
Value* load = new LoadInst(ptr, "", CI);
CI->replaceAllUsesWith(load);
CI->eraseFromParent();
- } else if (V == jnjvm::JnjvmModule::GetVTFunction) {
+ } else if (V == module->GetVTFunction) {
Changed = true;
Value* val = Call.getArgument(0); // get the object
std::vector<Value*> indexes; //[3];
- indexes.push_back(mvm::jit::constantZero);
- indexes.push_back(mvm::jit::constantZero);
+ indexes.push_back(mvm::MvmModule::constantZero);
+ indexes.push_back(mvm::MvmModule::constantZero);
Value* VTPtr = GetElementPtrInst::Create(val, indexes.begin(),
indexes.end(), "", CI);
Value* VT = new LoadInst(VTPtr, "", CI);
CI->replaceAllUsesWith(VT);
CI->eraseFromParent();
- } else if (V == jnjvm::JnjvmModule::GetClassFunction) {
+ } else if (V == module->GetClassFunction) {
Changed = true;
Value* val = Call.getArgument(0); // get the object
std::vector<Value*> args2;
- args2.push_back(mvm::jit::constantZero);
- args2.push_back(jnjvm::JnjvmModule::JavaObjectClassOffsetConstant);
+ args2.push_back(mvm::MvmModule::constantZero);
+ args2.push_back(module->JavaObjectClassOffsetConstant);
Value* classPtr = GetElementPtrInst::Create(val, args2.begin(),
args2.end(), "",
CI);
Value* cl = new LoadInst(classPtr, "", CI);
CI->replaceAllUsesWith(cl);
CI->eraseFromParent();
- } else if (V == jnjvm::JnjvmModule::GetVTFromClassFunction) {
+ } else if (V == module->GetVTFromClassFunction) {
Changed = true;
Value* val = Call.getArgument(0);
std::vector<Value*> indexes;
- indexes.push_back(mvm::jit::constantZero);
- indexes.push_back(jnjvm::JnjvmModule::OffsetVTInClassConstant);
+ indexes.push_back(mvm::MvmModule::constantZero);
+ indexes.push_back(module->OffsetVTInClassConstant);
Value* VTPtr = GetElementPtrInst::Create(val, indexes.begin(),
indexes.end(), "", CI);
Value* VT = new LoadInst(VTPtr, "", CI);
CI->replaceAllUsesWith(VT);
CI->eraseFromParent();
- } else if (V == jnjvm::JnjvmModule::GetObjectSizeFromClassFunction) {
+ } else if (V == module->GetObjectSizeFromClassFunction) {
Changed = true;
Value* val = Call.getArgument(0);
std::vector<Value*> indexes;
- indexes.push_back(mvm::jit::constantZero);
- indexes.push_back(JnjvmModule::OffsetObjectSizeInClassConstant);
+ indexes.push_back(mvm::MvmModule::constantZero);
+ indexes.push_back(module->OffsetObjectSizeInClassConstant);
Value* SizePtr = GetElementPtrInst::Create(val, indexes.begin(),
indexes.end(), "", CI);
Value* Size = new LoadInst(SizePtr, "", CI);
CI->replaceAllUsesWith(Size);
CI->eraseFromParent();
- } else if (V == jnjvm::JnjvmModule::GetDepthFunction) {
+ } else if (V == module->GetDepthFunction) {
Changed = true;
Value* val = Call.getArgument(0);
std::vector<Value*> indexes;
- indexes.push_back(mvm::jit::constantZero);
- indexes.push_back(JnjvmModule::OffsetDepthInClassConstant);
+ indexes.push_back(mvm::MvmModule::constantZero);
+ indexes.push_back(module->OffsetDepthInClassConstant);
Value* DepthPtr = GetElementPtrInst::Create(val, indexes.begin(),
indexes.end(), "", CI);
Value* Depth = new LoadInst(DepthPtr, "", CI);
CI->replaceAllUsesWith(Depth);
CI->eraseFromParent();
- } else if (V == jnjvm::JnjvmModule::GetDisplayFunction) {
+ } else if (V == module->GetDisplayFunction) {
Changed = true;
Value* val = Call.getArgument(0);
std::vector<Value*> indexes;
- indexes.push_back(mvm::jit::constantZero);
- indexes.push_back(JnjvmModule::OffsetDisplayInClassConstant);
+ indexes.push_back(mvm::MvmModule::constantZero);
+ indexes.push_back(module->OffsetDisplayInClassConstant);
Value* DisplayPtr = GetElementPtrInst::Create(val, indexes.begin(),
indexes.end(), "", CI);
Value* Display = new LoadInst(DisplayPtr, "", CI);
CI->replaceAllUsesWith(Display);
CI->eraseFromParent();
- } else if (V == jnjvm::JnjvmModule::GetClassInDisplayFunction) {
+ } else if (V == module->GetClassInDisplayFunction) {
Changed = true;
Value* val = Call.getArgument(0);
Value* depth = Call.getArgument(1);
@@ -135,7 +136,7 @@
Value* Class = new LoadInst(ClassPtr, "", CI);
CI->replaceAllUsesWith(Class);
CI->eraseFromParent();
- } else if (V == jnjvm::JnjvmModule::InstanceOfFunction) {
+ } else if (V == module->InstanceOfFunction) {
ConstantExpr* CE = dyn_cast<ConstantExpr>(Call.getArgument(1));
if (CE) {
ConstantInt* C = (ConstantInt*)CE->getOperand(0);
@@ -145,21 +146,21 @@
I->getParent()->getTerminator()->eraseFromParent();
Value* obj = Call.getArgument(0);
Instruction* cmp = new ICmpInst(ICmpInst::ICMP_EQ, obj,
- JnjvmModule::JavaObjectNullConstant,
+ module->JavaObjectNullConstant,
"", CI);
BasicBlock* ifTrue = BasicBlock::Create("", &F);
BasicBlock* ifFalse = BasicBlock::Create("", &F);
BranchInst::Create(ifTrue, ifFalse, cmp, CI);
PHINode* node = PHINode::Create(Type::Int1Ty, "", ifTrue);
node->addIncoming(ConstantInt::getFalse(), CI->getParent());
- Value* objCl = CallInst::Create(JnjvmModule::GetClassFunction, obj,
+ Value* objCl = CallInst::Create(module->GetClassFunction, obj,
"", ifFalse);
if (isInterface(cl->access)) {
std::vector<Value*> args;
args.push_back(objCl);
args.push_back(CE);
- Value* res = CallInst::Create(JnjvmModule::ImplementsFunction,
+ Value* res = CallInst::Create(module->ImplementsFunction,
args.begin(), args.end(), "",
ifFalse);
node->addIncoming(res, ifFalse);
@@ -174,7 +175,7 @@
std::vector<Value*> args;
args.push_back(objCl);
args.push_back(CE);
- cmp = CallInst::Create(JnjvmModule::IsAssignableFromFunction,
+ cmp = CallInst::Create(module->IsAssignableFromFunction,
args.begin(), args.end(), "", notEquals);
node->addIncoming(cmp, notEquals);
BranchInst::Create(ifTrue, notEquals);
@@ -183,7 +184,7 @@
args.push_back(objCl);
args.push_back(CE);
Value* res =
- CallInst::Create(JnjvmModule::InstantiationOfArrayFunction,
+ CallInst::Create(module->InstantiationOfArrayFunction,
args.begin(), args.end(), "", notEquals);
node->addIncoming(res, notEquals);
BranchInst::Create(ifTrue, notEquals);
@@ -192,10 +193,10 @@
if (cl->isResolved()) {
depthCl = ConstantInt::get(Type::Int32Ty, cl->depth);
} else {
- depthCl = CallInst::Create(JnjvmModule::GetDepthFunction,
+ depthCl = CallInst::Create(module->GetDepthFunction,
CE, "", notEquals);
}
- Value* depthClObj = CallInst::Create(JnjvmModule::GetDepthFunction,
+ Value* depthClObj = CallInst::Create(module->GetDepthFunction,
objCl, "", notEquals);
Value* cmp = new ICmpInst(ICmpInst::ICMP_ULE, depthCl, depthClObj, "",
notEquals);
@@ -206,14 +207,14 @@
node->addIncoming(ConstantInt::getFalse(), notEquals);
Value* inDisplay =
- CallInst::Create(JnjvmModule::GetDisplayFunction, objCl,
+ CallInst::Create(module->GetDisplayFunction, objCl,
"", supDepth);
std::vector<Value*> args;
args.push_back(inDisplay);
args.push_back(depthCl);
Value* clInDisplay =
- CallInst::Create(JnjvmModule::GetClassInDisplayFunction,
+ CallInst::Create(module->GetClassInDisplayFunction,
args.begin(), args.end(), "", supDepth);
cmp = new ICmpInst(ICmpInst::ICMP_EQ, clInDisplay, CE, "",
@@ -229,7 +230,7 @@
}
}
- else if (V == jnjvm::JnjvmModule::GetConstantPoolAtFunction) {
+ else if (V == module->GetConstantPoolAtFunction) {
Function* resolver = dyn_cast<Function>(Call.getArgument(0));
assert(resolver && "Wrong use of GetConstantPoolAt");
const Type* returnType = resolver->getReturnType();
@@ -259,7 +260,7 @@
indexes.end(), "", CI);
arg1 = new LoadInst(arg1, "", false, CI);
Value* test = new ICmpInst(ICmpInst::ICMP_EQ, arg1,
- mvm::jit::constantPtrNull, "", CI);
+ mvm::MvmModule::constantPtrNull, "", CI);
BasicBlock* trueCl = BasicBlock::Create("Ctp OK", &F);
BasicBlock* falseCl = BasicBlock::Create("Ctp Not OK", &F);
@@ -303,12 +304,12 @@
break;
}
#ifdef MULTIPLE_GC
- else if (V == jnjvm::JnjvmModule::GetCollectorFunction) {
+ else if (V == module->GetCollectorFunction) {
Changed = true;
Value* val = Call.getArgument(0);
std::vector<Value*> indexes;
- indexes.push_back(mvm::jit::constantOne);
- val = new BitCastInst(val, mvm::jit::ptrPtrType, "", CI);
+ indexes.push_back(mvm::MvmModule::constantOne);
+ val = new BitCastInst(val, mvm::MvmModule::ptrPtrType, "", CI);
Value* CollectorPtr = GetElementPtrInst::Create(val, indexes.begin(),
indexes.end(), "",
CI);
@@ -319,47 +320,47 @@
#endif
#ifdef ISOLATE_SHARING
- else if (V == jnjvm::JnjvmModule::GetCtpClassFunction) {
+ else if (V == module->GetCtpClassFunction) {
Changed = true;
Value* val = Call.getArgument(0);
std::vector<Value*> indexes;
- indexes.push_back(mvm::jit::constantZero);
- indexes.push_back(jnjvm::JnjvmModule::OffsetCtpInClassConstant);
+ indexes.push_back(mvm::MvmModule::constantZero);
+ indexes.push_back(module->OffsetCtpInClassConstant);
Value* VTPtr = GetElementPtrInst::Create(val, indexes.begin(),
indexes.end(), "", CI);
Value* VT = new LoadInst(VTPtr, "", CI);
CI->replaceAllUsesWith(VT);
CI->eraseFromParent();
- } else if (V == jnjvm::JnjvmModule::GetCtpCacheNodeFunction) {
+ } else if (V == module->GetCtpCacheNodeFunction) {
Changed = true;
Value* val = Call.getArgument(0);
std::vector<Value*> indexes;
- indexes.push_back(mvm::jit::constantZero);
- indexes.push_back(mvm::jit::constantFour);
+ indexes.push_back(mvm::MvmModule::constantZero);
+ indexes.push_back(mvm::MvmModule::constantFour);
Value* VTPtr = GetElementPtrInst::Create(val, indexes.begin(),
indexes.end(), "", CI);
Value* VT = new LoadInst(VTPtr, "", CI);
CI->replaceAllUsesWith(VT);
CI->eraseFromParent();
- } else if (V == jnjvm::JnjvmModule::GetJnjvmArrayClassFunction) {
+ } else if (V == module->GetJnjvmArrayClassFunction) {
Changed = true;
Value* val = Call.getArgument(0);
Value* index = Call.getArgument(1);
std::vector<Value*> indexes;
- indexes.push_back(mvm::jit::constantZero);
- indexes.push_back(mvm::jit::constantTwo);
+ indexes.push_back(mvm::MvmModule::constantZero);
+ indexes.push_back(mvm::MvmModule::constantTwo);
indexes.push_back(index);
Value* VTPtr = GetElementPtrInst::Create(val, indexes.begin(),
indexes.end(), "", CI);
Value* VT = new LoadInst(VTPtr, "", CI);
CI->replaceAllUsesWith(VT);
CI->eraseFromParent();
- } else if (V == jnjvm::JnjvmModule::GetJnjvmExceptionClassFunction) {
+ } else if (V == module->GetJnjvmExceptionClassFunction) {
Changed = true;
Value* val = Call.getArgument(0);
std::vector<Value*> indexes;
- indexes.push_back(mvm::jit::constantZero);
- indexes.push_back(mvm::jit::constantOne);
+ indexes.push_back(mvm::MvmModule::constantZero);
+ indexes.push_back(mvm::MvmModule::constantOne);
Value* VTPtr = GetElementPtrInst::Create(val, indexes.begin(),
indexes.end(), "", CI);
Value* VT = new LoadInst(VTPtr, "", CI);
@@ -391,6 +392,7 @@
"Lower Forced calls");
bool LowerForcedCalls::runOnFunction(Function& F) {
+ JnjvmModule* module = (JnjvmModule*)F.getParent();
bool Changed = false;
for (Function::iterator BI = F.begin(), BE = F.end(); BI != BE; BI++) {
BasicBlock *Cur = BI;
@@ -399,7 +401,7 @@
II++;
if (CallInst *CI = dyn_cast<CallInst>(I)) {
Value* V = CI->getOperand(0);
- if (V == jnjvm::JnjvmModule::ForceInitialisationCheckFunction) {
+ if (V == module->ForceInitialisationCheckFunction) {
Changed = true;
CI->eraseFromParent();
}
Modified: vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp Fri Oct 10 07:51:51 2008
@@ -75,7 +75,7 @@
}
void Class::TRACER {
- CommonClass::PARENT_TRACER;
+ CommonClass::CALL_TRACER;
bytes->MARK_AND_TRACE;
#if !defined(ISOLATE)
_staticInstance->MARK_AND_TRACE;
@@ -83,7 +83,7 @@
}
void ClassArray::TRACER {
- CommonClass::PARENT_TRACER;
+ CommonClass::CALL_TRACER;
}
void JavaObject::TRACER {
@@ -181,7 +181,7 @@
#ifdef SERVICE_VM
void ServiceDomain::TRACER {
- JavaIsolate::PARENT_TRACER;
+ JavaIsolate::CALL_TRACER;
classes->MARK_AND_TRACE;
}
#endif
Modified: vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h Fri Oct 10 07:51:51 2008
@@ -22,11 +22,11 @@
#ifdef MULTIPLE_GC
#define TRACER tracer(void* GC)
-#define PARENT_TRACER tracer(GC)
+#define CALL_TRACER tracer(GC)
#define MARK_AND_TRACE markAndTrace((Collector*)GC)
#else
#define TRACER tracer()
-#define PARENT_TRACER tracer()
+#define CALL_TRACER tracer()
#define MARK_AND_TRACE markAndTrace()
#endif
Modified: vmkit/trunk/lib/Mvm/Runtime/Disassembler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Runtime/Disassembler.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Runtime/Disassembler.cpp (original)
+++ vmkit/trunk/lib/Mvm/Runtime/Disassembler.cpp Fri Oct 10 07:51:51 2008
@@ -25,7 +25,7 @@
// this is the only function exported from this file
-int mvm::jit::disassemble(unsigned int *addr)
+int mvm::MvmModule::disassemble(unsigned int *addr)
{
if (!initialised)
@@ -56,7 +56,7 @@
static int initialised= 0;
-int mvm::jit::disassemble(unsigned int *addr)
+int mvm::MvmModule::disassemble(unsigned int *addr)
{
if (!initialised)
{
@@ -74,7 +74,7 @@
#else
-int mvm::jit::disassemble(unsigned int* addr) {
+int mvm::MvmModule::disassemble(unsigned int* addr) {
return 0;
}
@@ -82,7 +82,7 @@
#else
-int mvm::jit::disassemble(unsigned int* addr) {
+int mvm::MvmModule::disassemble(unsigned int* addr) {
return 0;
}
Modified: vmkit/trunk/lib/Mvm/Runtime/EscapeAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Runtime/EscapeAnalysis.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Runtime/EscapeAnalysis.cpp (original)
+++ vmkit/trunk/lib/Mvm/Runtime/EscapeAnalysis.cpp Fri Oct 10 07:51:51 2008
@@ -112,7 +112,7 @@
if (CE) {
ConstantInt* C = (ConstantInt*)CE->getOperand(0);
VirtualTable* Table = (VirtualTable*)C->getZExtValue();
- // If the class has a finalize method, do not stack allocate the object
+ // If the class has a finalize method, do not stack allocate the object.
if (!((void**)Table)[0]) {
std::map<Instruction*, bool> visited;
if (!(escapes(Alloc, visited))) {
@@ -120,6 +120,10 @@
BitCastInst* BI = new BitCastInst(AI, Alloc->getType(), "", Alloc);
DOUT << "escape" << Alloc->getParent()->getParent()->getName() << "\n";
Alloc->replaceAllUsesWith(BI);
+ // If it's an invoke, replace the invoke with a direct branch.
+ if (InvokeInst *CI = dyn_cast<InvokeInst>(Alloc)) {
+ BranchInst::Create(CI->getNormalDest(), Alloc);
+ }
Alloc->eraseFromParent();
return true;
}
Modified: vmkit/trunk/lib/Mvm/Runtime/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Runtime/JIT.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Runtime/JIT.cpp (original)
+++ vmkit/trunk/lib/Mvm/Runtime/JIT.cpp Fri Oct 10 07:51:51 2008
@@ -24,7 +24,6 @@
#include "mvm/Threads/Thread.h"
using namespace mvm;
-using namespace mvm::jit;
using namespace llvm;
@@ -54,95 +53,38 @@
}
}
-void mvm::jit::initialise() {
+void MvmModule::initialise() {
llvm::NoFramePointerElim = true;
llvm::ExceptionHandling = true;
- llvm::Module *module = globalModule = new Module("microvm");
- jit::globalModuleProvider = new ExistingModuleProvider (globalModule);
- jit::memoryManager = new MvmMemoryManager();
+ globalModule = new llvm::Module("bootstrap module");
+ globalModuleProvider = new ExistingModuleProvider (globalModule);
+ memoryManager = new MvmMemoryManager();
executionEngine = ExecutionEngine::createJIT(globalModuleProvider, 0,
memoryManager);
- std::string str = executionEngine->getTargetData()->getStringRepresentation();
- module->setDataLayout(str);
-
- mvm::llvm_runtime::makeLLVMModuleContents(module);
-
- printFloatLLVM = module->getFunction("printFloat");
- printDoubleLLVM = module->getFunction("printDouble");
- printLongLLVM = module->getFunction("printLong");
- printIntLLVM = module->getFunction("printInt");
- printObjectLLVM = module->getFunction("printObject");
-
- unwindResume = module->getFunction("_Unwind_Resume_or_Rethrow");
-
- llvmGetException = module->getFunction("llvm.eh.exception");
- exceptionSelector = sizeof(void*) == 4 ?
- module->getFunction("llvm.eh.selector.i32") :
- module->getFunction("llvm.eh.selector.i64");
-
- personality = module->getFunction("__gxx_personality_v0");
- exceptionEndCatch = module->getFunction("__cxa_end_catch");
- exceptionBeginCatch = module->getFunction("__cxa_begin_catch");
-
- func_llvm_sqrt_f64 = module->getFunction("llvm.sqrt.f64");
- func_llvm_sin_f64 = module->getFunction("llvm.sin.f64");
- func_llvm_cos_f64 = module->getFunction("llvm.cos.f64");
-
- func_llvm_tan_f64 = module->getFunction("tan");
- func_llvm_asin_f64 = module->getFunction("asin");
- func_llvm_acos_f64 = module->getFunction("acos");
- func_llvm_atan_f64 = module->getFunction("atan");
- func_llvm_exp_f64 = module->getFunction("exp");
- func_llvm_log_f64 = module->getFunction("log");
- func_llvm_ceil_f64 = module->getFunction("ceil");
- func_llvm_floor_f64 = module->getFunction("floor");
- func_llvm_cbrt_f64 = module->getFunction("cbrt");
- func_llvm_cosh_f64 = module->getFunction("cosh");
- func_llvm_expm1_f64 = module->getFunction("expm1");
- func_llvm_log10_f64 = module->getFunction("log10");
- func_llvm_log1p_f64 = module->getFunction("log1p");
- func_llvm_sinh_f64 = module->getFunction("sinh");
- func_llvm_tanh_f64 = module->getFunction("tanh");
- func_llvm_fabs_f64 = module->getFunction("fabs");
- func_llvm_rint_f64 = module->getFunction("rint");
-
- func_llvm_hypot_f64 = module->getFunction("hypot");
- func_llvm_pow_f64 = module->getFunction("pow");
- func_llvm_atan2_f64 = module->getFunction("atan2");
-
- func_llvm_fabs_f32 = module->getFunction("fabsf");
-
- setjmpLLVM = module->getFunction("setjmp");
-
- llvm_memcpy_i32 = module->getFunction("llvm.memcpy.i32");
- llvm_memset_i32 = module->getFunction("llvm.memset.i32");
-
- llvm_atomic_lcs_i8 = module->getFunction("llvm.atomic.cmp.swap.i8.p0i8");
- llvm_atomic_lcs_i16 = module->getFunction("llvm.atomic.cmp.swap.i16.p0i16");
- llvm_atomic_lcs_i32 = module->getFunction("llvm.atomic.cmp.swap.i32.p0i32");
- llvm_atomic_lcs_i64 = module->getFunction("llvm.atomic.cmp.swap.i64.p0i64");
+ Module module("unused");
+ mvm::llvm_runtime::makeLLVMModuleContents(&module);
llvm_atomic_cmp_swap_i8 = (uint8 (*)(uint8*, uint8, uint8))
(uintptr_t)executionEngine->getPointerToFunction(
- module->getFunction("runtime.llvm.atomic.cmp.swap.i8"));
+ module.getFunction("runtime.llvm.atomic.cmp.swap.i8"));
llvm_atomic_cmp_swap_i16 = (uint16 (*)(uint16*, uint16, uint16))
(uintptr_t)executionEngine->getPointerToFunction(
- module->getFunction("runtime.llvm.atomic.cmp.swap.i16"));
+ module.getFunction("runtime.llvm.atomic.cmp.swap.i16"));
llvm_atomic_cmp_swap_i32 = (uint32 (*)(uint32*, uint32, uint32))
(uintptr_t)executionEngine->getPointerToFunction(
- module->getFunction("runtime.llvm.atomic.cmp.swap.i32"));
+ module.getFunction("runtime.llvm.atomic.cmp.swap.i32"));
llvm_atomic_cmp_swap_i64 = (uint64 (*)(uint64*, uint64, uint64))
(uintptr_t)executionEngine->getPointerToFunction(
- module->getFunction("runtime.llvm.atomic.cmp.swap.i64"));
+ module.getFunction("runtime.llvm.atomic.cmp.swap.i64"));
- executionEnvironment = module->getGlobalVariable("executionEnvironment");
+ executionEnvironment = module.getGlobalVariable("executionEnvironment");
getExecutionEnvironment = (mvm::Thread* (*)())
(uintptr_t)executionEngine->getPointerToFunction(
- module->getFunction("getExecutionEnvironment"));
+ module.getFunction("getExecutionEnvironment"));
setExecutionEnvironment = (void (*)(mvm::Thread*))
(uintptr_t)executionEngine->getPointerToFunction(
- module->getFunction("setExecutionEnvironment"));
+ module.getFunction("setExecutionEnvironment"));
// Type declaration
ptrType = PointerType::getUnqual(Type::Int8Ty);
@@ -193,130 +135,145 @@
constantPtrSize = ConstantInt::get(Type::Int32Ty, sizeof(void*));
arrayPtrType = PointerType::getUnqual(ArrayType::get(Type::Int8Ty, 0));
- mvm::jit::protectEngine = mvm::Lock::allocNormal();
+ protectEngine = mvm::Lock::allocNormal();
+}
+
+
+MvmModule::MvmModule(const std::string& ModuleID) : llvm::Module(ModuleID) {
+ Module* module = this;
+ std::string str = executionEngine->getTargetData()->getStringRepresentation();
+ module->setDataLayout(str);
+
+ mvm::llvm_runtime::makeLLVMModuleContents(module);
+
+ printFloatLLVM = module->getFunction("printFloat");
+ printDoubleLLVM = module->getFunction("printDouble");
+ printLongLLVM = module->getFunction("printLong");
+ printIntLLVM = module->getFunction("printInt");
+ printObjectLLVM = module->getFunction("printObject");
+
+ unwindResume = module->getFunction("_Unwind_Resume_or_Rethrow");
+
+ llvmGetException = module->getFunction("llvm.eh.exception");
+ exceptionSelector = sizeof(void*) == 4 ?
+ module->getFunction("llvm.eh.selector.i32") :
+ module->getFunction("llvm.eh.selector.i64");
+
+ personality = module->getFunction("__gxx_personality_v0");
+ exceptionEndCatch = module->getFunction("__cxa_end_catch");
+ exceptionBeginCatch = module->getFunction("__cxa_begin_catch");
+
+ func_llvm_sqrt_f64 = module->getFunction("llvm.sqrt.f64");
+ func_llvm_sin_f64 = module->getFunction("llvm.sin.f64");
+ func_llvm_cos_f64 = module->getFunction("llvm.cos.f64");
+
+ func_llvm_tan_f64 = module->getFunction("tan");
+ func_llvm_asin_f64 = module->getFunction("asin");
+ func_llvm_acos_f64 = module->getFunction("acos");
+ func_llvm_atan_f64 = module->getFunction("atan");
+ func_llvm_exp_f64 = module->getFunction("exp");
+ func_llvm_log_f64 = module->getFunction("log");
+ func_llvm_ceil_f64 = module->getFunction("ceil");
+ func_llvm_floor_f64 = module->getFunction("floor");
+ func_llvm_cbrt_f64 = module->getFunction("cbrt");
+ func_llvm_cosh_f64 = module->getFunction("cosh");
+ func_llvm_expm1_f64 = module->getFunction("expm1");
+ func_llvm_log10_f64 = module->getFunction("log10");
+ func_llvm_log1p_f64 = module->getFunction("log1p");
+ func_llvm_sinh_f64 = module->getFunction("sinh");
+ func_llvm_tanh_f64 = module->getFunction("tanh");
+ func_llvm_fabs_f64 = module->getFunction("fabs");
+ func_llvm_rint_f64 = module->getFunction("rint");
+
+ func_llvm_hypot_f64 = module->getFunction("hypot");
+ func_llvm_pow_f64 = module->getFunction("pow");
+ func_llvm_atan2_f64 = module->getFunction("atan2");
+
+ func_llvm_fabs_f32 = module->getFunction("fabsf");
+ setjmpLLVM = module->getFunction("setjmp");
+
+ llvm_memcpy_i32 = module->getFunction("llvm.memcpy.i32");
+ llvm_memset_i32 = module->getFunction("llvm.memset.i32");
+
+ llvm_atomic_lcs_i8 = module->getFunction("llvm.atomic.cmp.swap.i8.p0i8");
+ llvm_atomic_lcs_i16 = module->getFunction("llvm.atomic.cmp.swap.i16.p0i16");
+ llvm_atomic_lcs_i32 = module->getFunction("llvm.atomic.cmp.swap.i32.p0i32");
+ llvm_atomic_lcs_i64 = module->getFunction("llvm.atomic.cmp.swap.i64.p0i64");
}
-llvm::Function* mvm::jit::llvm_memcpy_i32;
-llvm::Function* mvm::jit::llvm_memset_i32;
+llvm::ExecutionEngine* MvmModule::executionEngine;
+mvm::Lock* MvmModule::protectEngine;
-llvm::Function* mvm::jit::llvm_atomic_lcs_i8;
-llvm::Function* mvm::jit::llvm_atomic_lcs_i16;
-llvm::Function* mvm::jit::llvm_atomic_lcs_i32;
-llvm::Function* mvm::jit::llvm_atomic_lcs_i64;
-
-
-llvm::Function* mvm::jit::exceptionEndCatch;
-llvm::Function* mvm::jit::exceptionBeginCatch;
-llvm::Function* mvm::jit::unwindResume;
-llvm::Function* mvm::jit::exceptionSelector;
-llvm::Function* mvm::jit::personality;
-llvm::Function* mvm::jit::llvmGetException;
-
-llvm::Function* mvm::jit::printFloatLLVM;
-llvm::Function* mvm::jit::printDoubleLLVM;
-llvm::Function* mvm::jit::printLongLLVM;
-llvm::Function* mvm::jit::printIntLLVM;
-llvm::Function* mvm::jit::printObjectLLVM;
-
-llvm::Function* mvm::jit::setjmpLLVM;
-
-llvm::Function* mvm::jit::func_llvm_fabs_f32;
-llvm::Function* mvm::jit::func_llvm_fabs_f64;
-llvm::Function* mvm::jit::func_llvm_sqrt_f64;
-llvm::Function* mvm::jit::func_llvm_sin_f64;
-llvm::Function* mvm::jit::func_llvm_cos_f64;
-llvm::Function* mvm::jit::func_llvm_tan_f64;
-llvm::Function* mvm::jit::func_llvm_asin_f64;
-llvm::Function* mvm::jit::func_llvm_acos_f64;
-llvm::Function* mvm::jit::func_llvm_atan_f64;
-llvm::Function* mvm::jit::func_llvm_atan2_f64;
-llvm::Function* mvm::jit::func_llvm_exp_f64;
-llvm::Function* mvm::jit::func_llvm_log_f64;
-llvm::Function* mvm::jit::func_llvm_pow_f64;
-llvm::Function* mvm::jit::func_llvm_ceil_f64;
-llvm::Function* mvm::jit::func_llvm_floor_f64;
-llvm::Function* mvm::jit::func_llvm_rint_f64;
-llvm::Function* mvm::jit::func_llvm_cbrt_f64;
-llvm::Function* mvm::jit::func_llvm_cosh_f64;
-llvm::Function* mvm::jit::func_llvm_expm1_f64;
-llvm::Function* mvm::jit::func_llvm_hypot_f64;
-llvm::Function* mvm::jit::func_llvm_log10_f64;
-llvm::Function* mvm::jit::func_llvm_log1p_f64;
-llvm::Function* mvm::jit::func_llvm_sinh_f64;
-llvm::Function* mvm::jit::func_llvm_tanh_f64;
-
-llvm::ExecutionEngine* mvm::jit::executionEngine;
-
-mvm::Lock* mvm::jit::protectEngine;
-llvm::ConstantInt* mvm::jit::constantInt8Zero;
-llvm::ConstantInt* mvm::jit::constantZero;
-llvm::ConstantInt* mvm::jit::constantOne;
-llvm::ConstantInt* mvm::jit::constantTwo;
-llvm::ConstantInt* mvm::jit::constantThree;
-llvm::ConstantInt* mvm::jit::constantFour;
-llvm::ConstantInt* mvm::jit::constantFive;
-llvm::ConstantInt* mvm::jit::constantSix;
-llvm::ConstantInt* mvm::jit::constantSeven;
-llvm::ConstantInt* mvm::jit::constantEight;
-llvm::ConstantInt* mvm::jit::constantMinusOne;
-llvm::ConstantInt* mvm::jit::constantLongMinusOne;
-llvm::ConstantInt* mvm::jit::constantLongZero;
-llvm::ConstantInt* mvm::jit::constantLongOne;
-llvm::ConstantInt* mvm::jit::constantMinInt;
-llvm::ConstantInt* mvm::jit::constantMaxInt;
-llvm::ConstantInt* mvm::jit::constantMinLong;
-llvm::ConstantInt* mvm::jit::constantMaxLong;
-llvm::ConstantFP* mvm::jit::constantFloatZero;
-llvm::ConstantFP* mvm::jit::constantFloatOne;
-llvm::ConstantFP* mvm::jit::constantFloatTwo;
-llvm::ConstantFP* mvm::jit::constantDoubleZero;
-llvm::ConstantFP* mvm::jit::constantDoubleOne;
-llvm::ConstantFP* mvm::jit::constantMaxIntFloat;
-llvm::ConstantFP* mvm::jit::constantMinIntFloat;
-llvm::ConstantFP* mvm::jit::constantMinLongFloat;
-llvm::ConstantFP* mvm::jit::constantMinLongDouble;
-llvm::ConstantFP* mvm::jit::constantMaxLongFloat;
-llvm::ConstantFP* mvm::jit::constantMaxIntDouble;
-llvm::ConstantFP* mvm::jit::constantMinIntDouble;
-llvm::ConstantFP* mvm::jit::constantMaxLongDouble;
-llvm::ConstantFP* mvm::jit::constantDoubleInfinity;
-llvm::ConstantFP* mvm::jit::constantDoubleMinusInfinity;
-llvm::ConstantFP* mvm::jit::constantFloatInfinity;
-llvm::ConstantFP* mvm::jit::constantFloatMinusInfinity;
-llvm::ConstantFP* mvm::jit::constantFloatMinusZero;
-llvm::ConstantFP* mvm::jit::constantDoubleMinusZero;
-llvm::Constant* mvm::jit::constantPtrNull;
-llvm::ConstantInt* mvm::jit::constantPtrSize;
-const llvm::PointerType* mvm::jit::ptrType;
-const llvm::PointerType* mvm::jit::ptr32Type;
-const llvm::PointerType* mvm::jit::ptrPtrType;
-const llvm::Type* mvm::jit::arrayPtrType;
-
-llvm::Module *mvm::jit::globalModule;
-llvm::ExistingModuleProvider *mvm::jit::globalModuleProvider;
-mvm::MvmMemoryManager *mvm::jit::memoryManager;
+llvm::ConstantInt* MvmModule::constantInt8Zero;
+llvm::ConstantInt* MvmModule::constantZero;
+llvm::ConstantInt* MvmModule::constantOne;
+llvm::ConstantInt* MvmModule::constantTwo;
+llvm::ConstantInt* MvmModule::constantThree;
+llvm::ConstantInt* MvmModule::constantFour;
+llvm::ConstantInt* MvmModule::constantFive;
+llvm::ConstantInt* MvmModule::constantSix;
+llvm::ConstantInt* MvmModule::constantSeven;
+llvm::ConstantInt* MvmModule::constantEight;
+llvm::ConstantInt* MvmModule::constantMinusOne;
+llvm::ConstantInt* MvmModule::constantLongMinusOne;
+llvm::ConstantInt* MvmModule::constantLongZero;
+llvm::ConstantInt* MvmModule::constantLongOne;
+llvm::ConstantInt* MvmModule::constantMinInt;
+llvm::ConstantInt* MvmModule::constantMaxInt;
+llvm::ConstantInt* MvmModule::constantMinLong;
+llvm::ConstantInt* MvmModule::constantMaxLong;
+llvm::ConstantFP* MvmModule::constantFloatZero;
+llvm::ConstantFP* MvmModule::constantFloatOne;
+llvm::ConstantFP* MvmModule::constantFloatTwo;
+llvm::ConstantFP* MvmModule::constantDoubleZero;
+llvm::ConstantFP* MvmModule::constantDoubleOne;
+llvm::ConstantFP* MvmModule::constantMaxIntFloat;
+llvm::ConstantFP* MvmModule::constantMinIntFloat;
+llvm::ConstantFP* MvmModule::constantMinLongFloat;
+llvm::ConstantFP* MvmModule::constantMinLongDouble;
+llvm::ConstantFP* MvmModule::constantMaxLongFloat;
+llvm::ConstantFP* MvmModule::constantMaxIntDouble;
+llvm::ConstantFP* MvmModule::constantMinIntDouble;
+llvm::ConstantFP* MvmModule::constantMaxLongDouble;
+llvm::ConstantFP* MvmModule::constantDoubleInfinity;
+llvm::ConstantFP* MvmModule::constantDoubleMinusInfinity;
+llvm::ConstantFP* MvmModule::constantFloatInfinity;
+llvm::ConstantFP* MvmModule::constantFloatMinusInfinity;
+llvm::ConstantFP* MvmModule::constantFloatMinusZero;
+llvm::ConstantFP* MvmModule::constantDoubleMinusZero;
+llvm::Constant* MvmModule::constantPtrNull;
+llvm::ConstantInt* MvmModule::constantPtrSize;
+const llvm::PointerType* MvmModule::ptrType;
+const llvm::PointerType* MvmModule::ptr32Type;
+const llvm::PointerType* MvmModule::ptrPtrType;
+const llvm::Type* MvmModule::arrayPtrType;
+
+llvm::Module *MvmModule::globalModule;
+llvm::ExistingModuleProvider *MvmModule::globalModuleProvider;
+mvm::MvmMemoryManager *MvmModule::memoryManager;
-uint8 (*mvm::jit::llvm_atomic_cmp_swap_i8) (uint8* ptr, uint8 cmp,
+uint8 (*MvmModule::llvm_atomic_cmp_swap_i8) (uint8* ptr, uint8 cmp,
uint8 val);
-uint16 (*mvm::jit::llvm_atomic_cmp_swap_i16) (uint16* ptr, uint16 cmp,
+uint16 (*MvmModule::llvm_atomic_cmp_swap_i16) (uint16* ptr, uint16 cmp,
uint16 val);
-uint32 (*mvm::jit::llvm_atomic_cmp_swap_i32) (uint32* ptr, uint32 cmp,
+uint32 (*MvmModule::llvm_atomic_cmp_swap_i32) (uint32* ptr, uint32 cmp,
uint32 val);
-uint64 (*mvm::jit::llvm_atomic_cmp_swap_i64) (uint64* ptr, uint64 cmp,
+uint64 (*MvmModule::llvm_atomic_cmp_swap_i64) (uint64* ptr, uint64 cmp,
uint64 val);
-llvm::GlobalVariable* mvm::jit::executionEnvironment;
-mvm::Thread* (*mvm::jit::getExecutionEnvironment)();
-void (*mvm::jit::setExecutionEnvironment)(mvm::Thread*);
+llvm::GlobalVariable* MvmModule::executionEnvironment;
+mvm::Thread* (*MvmModule::getExecutionEnvironment)();
+void (*MvmModule::setExecutionEnvironment)(mvm::Thread*);
-uint64 mvm::jit::getTypeSize(const llvm::Type* type) {
+uint64 MvmModule::getTypeSize(const llvm::Type* type) {
return executionEngine->getTargetData()->getABITypeSize(type);
}
-void mvm::jit::runPasses(llvm::Function* func, llvm::FunctionPassManager* pm) {
+void MvmModule::runPasses(llvm::Function* func,
+ llvm::FunctionPassManager* pm) {
pm->run(*func);
}
@@ -326,7 +283,7 @@
#define FRAME_IP(fp) (fp[1])
#endif
-int mvm::jit::getBacktrace(void** stack, int size) {
+int MvmModule::getBacktrace(void** stack, int size) {
void** addr = (void**)__builtin_frame_address(0);
int cpt = 0;
void* baseSP = mvm::Thread::get()->baseSP;
@@ -340,7 +297,7 @@
LockNormal lock;
std::map<void*, Code*> pointerMap;
-Code* mvm::jit::getCodeFromPointer(void* Addr) {
+Code* MvmModule::getCodeFromPointer(void* Addr) {
lock.lock();
std::map<void*, Code*>::iterator I =
pointerMap.lower_bound(Addr);
@@ -354,7 +311,7 @@
return 0;
}
-void mvm::jit::addMethodInfo(void* Addr, Code* C) {
+void MvmModule::addMethodInfo(void* Addr, Code* C) {
lock.lock();
pointerMap.insert(std::make_pair(Addr, C));
lock.unlock();
Modified: vmkit/trunk/lib/Mvm/Runtime/LLVMRuntime.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Runtime/LLVMRuntime.ll?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Runtime/LLVMRuntime.ll (original)
+++ vmkit/trunk/lib/Mvm/Runtime/LLVMRuntime.ll Fri Oct 10 07:51:51 2008
@@ -20,9 +20,9 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
declare void @_Unwind_Resume_or_Rethrow(i8*)
-declare i8* @llvm.eh.exception()
-declare i32 @llvm.eh.selector.i32(i8*, i8*, ...)
-declare i64 @llvm.eh.selector.i64(i8*, i8*, ...)
+declare i8* @llvm.eh.exception() nounwind
+declare i32 @llvm.eh.selector.i32(i8*, i8*, ...) nounwind
+declare i64 @llvm.eh.selector.i64(i8*, i8*, ...) nounwind
declare void @__gxx_personality_v0()
declare i8* @__cxa_begin_catch(i8*)
declare void @__cxa_end_catch()
@@ -32,9 +32,9 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Math ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-declare double @llvm.sqrt.f64(double)
-declare double @llvm.sin.f64(double)
-declare double @llvm.cos.f64(double)
+declare double @llvm.sqrt.f64(double) nounwind
+declare double @llvm.sin.f64(double) nounwind
+declare double @llvm.cos.f64(double) nounwind
declare double @tan(double)
declare double @asin(double)
declare double @acos(double)
@@ -61,17 +61,17 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Memory ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-declare void @llvm.memcpy.i32(i8 *, i8 *, i32, i32)
-declare void @llvm.memset.i32(i8 *, i8, i32, i32)
+declare void @llvm.memcpy.i32(i8 *, i8 *, i32, i32) nounwind
+declare void @llvm.memset.i32(i8 *, i8, i32, i32) nounwind
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Atomic ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-declare i8 @llvm.atomic.cmp.swap.i8.p0i8(i8*, i8, i8)
-declare i16 @llvm.atomic.cmp.swap.i16.p0i16(i16*, i16, i16)
-declare i32 @llvm.atomic.cmp.swap.i32.p0i32(i32*, i32, i32)
-declare i64 @llvm.atomic.cmp.swap.i64.p0i64(i64*, i64, i64)
+declare i8 @llvm.atomic.cmp.swap.i8.p0i8(i8*, i8, i8) nounwind
+declare i16 @llvm.atomic.cmp.swap.i16.p0i16(i16*, i16, i16) nounwind
+declare i32 @llvm.atomic.cmp.swap.i32.p0i32(i32*, i32, i32) nounwind
+declare i64 @llvm.atomic.cmp.swap.i64.p0i64(i64*, i64, i64) nounwind
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;Helper functions for gcc < 4.2 ;;;;;;;;;;;;;;;;;;;;;;;;
Modified: vmkit/trunk/lib/Mvm/Runtime/MvmMemoryManager.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Runtime/MvmMemoryManager.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Runtime/MvmMemoryManager.cpp (original)
+++ vmkit/trunk/lib/Mvm/Runtime/MvmMemoryManager.cpp Fri Oct 10 07:51:51 2008
@@ -30,7 +30,7 @@
unsigned Alignment) {
unsigned char* res = realMemoryManager->allocateStub(GV, StubSize, Alignment);
Code* meth = new Code();
- mvm::jit::addMethodInfo((void*)(res + StubSize), meth);
+ MvmModule::addMethodInfo((void*)(res + StubSize), meth);
currentMethod = meth;
meth->FunctionStart = res;
meth->FunctionEnd = res + StubSize;
@@ -42,7 +42,7 @@
void MvmMemoryManager::endFunctionBody(const Function *F,
unsigned char *FunctionStart,
unsigned char *FunctionEnd) {
- mvm::jit::addMethodInfo((void*)FunctionEnd, currentMethod);
+ MvmModule::addMethodInfo((void*)FunctionEnd, currentMethod);
currentMethod->FunctionStart = FunctionStart;
currentMethod->FunctionEnd = FunctionEnd;
realMemoryManager->endFunctionBody(F, FunctionStart, FunctionEnd);
Modified: vmkit/trunk/lib/N3/Mono/MonoMSCorlib.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/Mono/MonoMSCorlib.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/Mono/MonoMSCorlib.cpp (original)
+++ vmkit/trunk/lib/N3/Mono/MonoMSCorlib.cpp Fri Oct 10 07:51:51 2008
@@ -30,7 +30,7 @@
type->resolveType(true, false, NULL);
type->resolveVT();
- uint64 size = mvm::jit::getTypeSize(type->virtualType->getContainedType(0)) + sizeof(const UTF8*) + sizeof(llvm::GlobalVariable*);
+ uint64 size = mvm::MvmModule::getTypeSize(type->virtualType->getContainedType(0)) + sizeof(const UTF8*) + sizeof(llvm::GlobalVariable*);
type->virtualInstance =
(VMObject*)gc::operator new(size, type->virtualInstance->getVirtualTable());
type->virtualInstance->initialise(type);
Modified: vmkit/trunk/lib/N3/Mono/MonoString.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/Mono/MonoString.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/Mono/MonoString.cpp (original)
+++ vmkit/trunk/lib/N3/Mono/MonoString.cpp Fri Oct 10 07:51:51 2008
@@ -48,7 +48,7 @@
if (!str->_llvmVar) {
VirtualMachine* vm = VMThread::get()->vm;
if (!str->_llvmVar) {
- const Type* pty = mvm::jit::ptrType;
+ const Type* pty = mvm::MvmModule::ptrType;
Constant* cons =
ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (this)),
pty);
Modified: vmkit/trunk/lib/N3/PNetLib/PNetMSCorlib.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/PNetLib/PNetMSCorlib.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/PNetLib/PNetMSCorlib.cpp (original)
+++ vmkit/trunk/lib/N3/PNetLib/PNetMSCorlib.cpp Fri Oct 10 07:51:51 2008
@@ -30,7 +30,7 @@
type->resolveType(true, false, NULL);
type->resolveVT();
- uint64 size = mvm::jit::getTypeSize(type->virtualType->getContainedType(0)) + sizeof(const UTF8*) + sizeof(llvm::GlobalVariable*);
+ uint64 size = mvm::MvmModule::getTypeSize(type->virtualType->getContainedType(0)) + sizeof(const UTF8*) + sizeof(llvm::GlobalVariable*);
type->virtualInstance =
(VMObject*)gc::operator new(size, type->virtualInstance->getVirtualTable());
type->virtualInstance->initialise(type);
Modified: vmkit/trunk/lib/N3/PNetLib/PNetString.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/PNetLib/PNetString.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/PNetLib/PNetString.cpp (original)
+++ vmkit/trunk/lib/N3/PNetLib/PNetString.cpp Fri Oct 10 07:51:51 2008
@@ -49,7 +49,7 @@
if (!str->_llvmVar) {
VirtualMachine* vm = VMThread::get()->vm;
if (!str->_llvmVar) {
- const Type* pty = mvm::jit::ptrType;
+ const Type* pty = mvm::MvmModule::ptrType;
Constant* cons =
ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (this)),
pty);
Modified: vmkit/trunk/lib/N3/VMCore/BackTrace.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/BackTrace.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/BackTrace.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/BackTrace.cpp Fri Oct 10 07:51:51 2008
@@ -26,10 +26,10 @@
void CLIJit::printBacktrace() {
int* ips[100];
- int real_size = mvm::jit::getBacktrace((void**)(void*)ips, 100);
+ int real_size = mvm::MvmModule::getBacktrace((void**)(void*)ips, 100);
int n = 0;
while (n < real_size) {
- mvm::Code* code = mvm::jit::getCodeFromPointer(ips[n++]);
+ mvm::Code* code = mvm::MvmModule::getCodeFromPointer(ips[n++]);
if (code) {
VMMethod* meth = (VMMethod*)code->getMetaInfo();
if (meth) {
@@ -53,10 +53,10 @@
Assembly* Assembly::getExecutingAssembly() {
int* ips[5];
- int real_size = mvm::jit::getBacktrace((void**)(void*)ips, 5);
+ int real_size = mvm::MvmModule::getBacktrace((void**)(void*)ips, 5);
int n = 0;
while (n < real_size) {
- mvm::Code* code = mvm::jit::getCodeFromPointer(ips[n++]);
+ mvm::Code* code = mvm::MvmModule::getCodeFromPointer(ips[n++]);
if (code) {
VMMethod* meth = (VMMethod*)code->getMetaInfo();
if (meth) {
@@ -69,11 +69,11 @@
Assembly* Assembly::getCallingAssembly() {
int* ips[5];
- int real_size = mvm::jit::getBacktrace((void**)(void*)ips, 5);
+ int real_size = mvm::MvmModule::getBacktrace((void**)(void*)ips, 5);
int n = 0;
int i = 0;
while (n < real_size) {
- mvm::Code* code = mvm::jit::getCodeFromPointer(ips[n++]);
+ mvm::Code* code = mvm::MvmModule::getCodeFromPointer(ips[n++]);
if (code) {
VMMethod* meth = (VMMethod*)code->getMetaInfo();
if (meth && i >= 1) {
Modified: vmkit/trunk/lib/N3/VMCore/CLIJit.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIJit.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/CLIJit.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/CLIJit.cpp Fri Oct 10 07:51:51 2008
@@ -106,7 +106,7 @@
Value* GC = ++(block->getParent()->arg_begin());
#endif
- Constant* zero = mvm::jit::constantZero;
+ Constant* zero = mvm::MvmModule::constantZero;
for (std::vector<VMField*>::iterator i = fields.begin(),
e = fields.end(); i!= e; ++i) {
VMField* field = *i;
@@ -160,9 +160,9 @@
Argument* GC = ++(func->arg_begin());
#endif
// Constant Definitions
- Constant* const_int32_8 = mvm::jit::constantZero;
- ConstantInt* const_int32_9 = mvm::jit::constantOne;
- ConstantInt* const_int32_10 = mvm::jit::constantTwo;
+ Constant* const_int32_8 = mvm::MvmModule::constantZero;
+ ConstantInt* const_int32_9 = mvm::MvmModule::constantOne;
+ ConstantInt* const_int32_10 = mvm::MvmModule::constantTwo;
// Function Definitions
@@ -238,7 +238,7 @@
}
- void* tracer = mvm::jit::executionEngine->getPointerToGlobal(func);
+ void* tracer = mvm::MvmModule::executionEngine->getPointerToGlobal(func);
((void**)res)[VT_TRACER_OFFSET] = tracer;
cl->virtualTracer = func;
#endif
@@ -286,7 +286,7 @@
traceClass(cl, block, realArg, fields, (cl->super == MSCorlib::pValue && !stat));
ReturnInst::Create(block);
- void* tracer = mvm::jit::executionEngine->getPointerToGlobal(func);
+ void* tracer = mvm::MvmModule::executionEngine->getPointerToGlobal(func);
((void**)res)[VT_TRACER_OFFSET] = tracer;
if (!stat) {
@@ -423,28 +423,28 @@
std::vector<Value*>& args) {
if (meth->name == N3::sqrt) {
- return CallInst::Create(mvm::jit::func_llvm_sqrt_f64, args[0], "tmp1",
+ return CallInst::Create(module->func_llvm_sqrt_f64, args[0], "tmp1",
currentBlock);
} else if (meth->name == N3::sin) {
- return CallInst::Create(mvm::jit::func_llvm_sin_f64, args[0], "tmp1",
+ return CallInst::Create(module->func_llvm_sin_f64, args[0], "tmp1",
currentBlock);
} else if (meth->name == N3::cos) {
- return CallInst::Create(mvm::jit::func_llvm_cos_f64, args[0], "tmp1",
+ return CallInst::Create(module->func_llvm_cos_f64, args[0], "tmp1",
currentBlock);
} else if (meth->name == N3::exp) {
- return CallInst::Create(mvm::jit::func_llvm_exp_f64, args[0], "tmp1",
+ return CallInst::Create(module->func_llvm_exp_f64, args[0], "tmp1",
currentBlock);
} else if (meth->name == N3::log) {
- return CallInst::Create(mvm::jit::func_llvm_log_f64, args[0], "tmp1",
+ return CallInst::Create(module->func_llvm_log_f64, args[0], "tmp1",
currentBlock);
} else if (meth->name == N3::floor) {
- return CallInst::Create(mvm::jit::func_llvm_floor_f64, args[0], "tmp1",
+ return CallInst::Create(module->func_llvm_floor_f64, args[0], "tmp1",
currentBlock);
} else if (meth->name == N3::log10) {
- return CallInst::Create(mvm::jit::func_llvm_log10_f64, args[0], "tmp1",
+ return CallInst::Create(module->func_llvm_log10_f64, args[0], "tmp1",
currentBlock);
} else if (meth->name == N3::pow) {
- Instruction* val = CallInst::Create(mvm::jit::func_llvm_pow_f64,
+ Instruction* val = CallInst::Create(module->func_llvm_pow_f64,
args.begin(), args.end(), "tmp1",
currentBlock);
return val;
@@ -457,6 +457,7 @@
std::vector<Value*>& args, VMGenericClass* genClass, VMGenericMethod* genMethod) {
CLIJit* jit = gc_new(CLIJit)();
+ jit->module = meth->classDef->vm->module;
jit->compilingClass = meth->classDef;
jit->compilingMethod = meth;
@@ -501,8 +502,8 @@
VMClassArray* base = type;
for (uint32 v = 0; v < dims; ++v) {
std::vector<Value*> Args;
- Args.push_back(mvm::jit::constantZero);
- Args.push_back(mvm::jit::constantTwo);
+ Args.push_back(module->constantZero);
+ Args.push_back(module->constantTwo);
Args.push_back(args[v]);
obj = verifyAndComputePtr(obj, args[v], base->naturalType, true);
if (v != dims - 1) {
@@ -536,22 +537,22 @@
meth->classDef->name == N3::doubleName) {
if (meth->name == N3::isNan) {
push(new FCmpInst(FCmpInst::FCMP_UNO, Args[0],
- mvm::jit::constantDoubleZero, "tmp1", currentBlock));
+ module->constantDoubleZero, "tmp1", currentBlock));
return;
} else if (meth->name == N3::testInfinity) {
BasicBlock* endBlock = createBasicBlock("end test infinity");
BasicBlock* minusInfinity = createBasicBlock("- infinity");
BasicBlock* noInfinity = createBasicBlock("no infinity");
PHINode* node = PHINode::Create(Type::Int32Ty, "", endBlock);
- node->addIncoming(mvm::jit::constantOne, currentBlock);
- node->addIncoming(mvm::jit::constantMinusOne, minusInfinity);
- node->addIncoming(mvm::jit::constantZero, noInfinity);
+ node->addIncoming(module->constantOne, currentBlock);
+ node->addIncoming(module->constantMinusOne, minusInfinity);
+ node->addIncoming(module->constantZero, noInfinity);
Value* val1 = new FCmpInst(FCmpInst::FCMP_OEQ, Args[0],
- mvm::jit::constantDoubleInfinity, "tmp1",
+ module->constantDoubleInfinity, "tmp1",
currentBlock);
BranchInst::Create(endBlock, minusInfinity, val1, currentBlock);
Value* val2 = new FCmpInst(FCmpInst::FCMP_OEQ, Args[0],
- mvm::jit::constantDoubleMinusInfinity, "tmp1",
+ module->constantDoubleMinusInfinity, "tmp1",
minusInfinity);
BranchInst::Create(endBlock, noInfinity, val2, minusInfinity);
BranchInst::Create(endBlock, noInfinity);
@@ -563,22 +564,22 @@
meth->classDef->name == N3::floatName) {
if (meth->name == N3::isNan) {
push(new FCmpInst(FCmpInst::FCMP_UNO, Args[0],
- mvm::jit::constantFloatZero, "tmp1", currentBlock));
+ module->constantFloatZero, "tmp1", currentBlock));
return;
} else if (meth->name == N3::testInfinity) {
BasicBlock* endBlock = createBasicBlock("end test infinity");
BasicBlock* minusInfinity = createBasicBlock("- infinity");
BasicBlock* noInfinity = createBasicBlock("no infinity");
PHINode* node = PHINode::Create(Type::Int32Ty, "", endBlock);
- node->addIncoming(mvm::jit::constantOne, currentBlock);
- node->addIncoming(mvm::jit::constantMinusOne, minusInfinity);
- node->addIncoming(mvm::jit::constantZero, noInfinity);
+ node->addIncoming(module->constantOne, currentBlock);
+ node->addIncoming(module->constantMinusOne, minusInfinity);
+ node->addIncoming(module->constantZero, noInfinity);
Value* val1 = new FCmpInst(FCmpInst::FCMP_OEQ, Args[0],
- mvm::jit::constantFloatInfinity, "tmp1",
+ module->constantFloatInfinity, "tmp1",
currentBlock);
BranchInst::Create(endBlock, minusInfinity, val1, currentBlock);
Value* val2 = new FCmpInst(FCmpInst::FCMP_OEQ, Args[0],
- mvm::jit::constantFloatMinusInfinity, "tmp1",
+ module->constantFloatMinusInfinity, "tmp1",
minusInfinity);
BranchInst::Create(endBlock, noInfinity, val2, minusInfinity);
BranchInst::Create(endBlock, noInfinity);
@@ -629,14 +630,14 @@
} else if (type->super == MSCorlib::pValue || type->super == MSCorlib::pEnum) {
obj = new AllocaInst(type->naturalType, "", currentBlock);
- uint64 size = mvm::jit::getTypeSize(type->naturalType);
+ uint64 size = module->getTypeSize(type->naturalType);
std::vector<Value*> params;
- params.push_back(new BitCastInst(obj, mvm::jit::ptrType, "", currentBlock));
- params.push_back(mvm::jit::constantInt8Zero);
+ params.push_back(new BitCastInst(obj, module->ptrType, "", currentBlock));
+ params.push_back(module->constantInt8Zero);
params.push_back(ConstantInt::get(Type::Int32Ty, size));
- params.push_back(mvm::jit::constantZero);
- CallInst::Create(mvm::jit::llvm_memset_i32, params.begin(), params.end(),
+ params.push_back(module->constantZero);
+ CallInst::Create(module->llvm_memset_i32, params.begin(), params.end(),
"", currentBlock);
} else {
Value* var = new LoadInst(type->llvmVar(), "", currentBlock);
@@ -683,7 +684,7 @@
currentBlock);
}
std::vector<Value*> args;
- args.push_back(mvm::jit::constantZero);
+ args.push_back(module->constantZero);
args.push_back(field->offset);
Value* ptr = GetElementPtrInst::Create(obj, args.begin(), args.end(), "",
currentBlock);
@@ -700,7 +701,7 @@
Value* staticCl = new BitCastInst(call, cl->staticType, "", currentBlock);
std::vector<Value*> args;
- args.push_back(mvm::jit::constantZero);
+ args.push_back(module->constantZero);
args.push_back(field->offset);
Value* ptr = GetElementPtrInst::Create(staticCl, args.begin(), args.end(), "",
currentBlock);
@@ -728,7 +729,7 @@
obj = new BitCastInst(obj, field->classDef->naturalType, "", currentBlock);
}
std::vector<Value*> args;
- args.push_back(mvm::jit::constantZero);
+ args.push_back(module->constantZero);
args.push_back(field->offset);
ptr = GetElementPtrInst::Create(obj, args.begin(), args.end(), "",
currentBlock);
@@ -736,14 +737,14 @@
if (field->signature->super == MSCorlib::pValue &&
field->signature->virtualFields.size() > 1) {
- uint64 size = mvm::jit::getTypeSize(field->signature->naturalType);
+ uint64 size = module->getTypeSize(field->signature->naturalType);
std::vector<Value*> params;
params.push_back(new BitCastInst(ptr, PointerType::getUnqual(Type::Int8Ty), "", currentBlock));
params.push_back(new BitCastInst(val, PointerType::getUnqual(Type::Int8Ty), "", currentBlock));
params.push_back(ConstantInt::get(Type::Int32Ty, size));
- params.push_back(mvm::jit::constantZero);
- CallInst::Create(mvm::jit::llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock);
+ params.push_back(module->constantZero);
+ CallInst::Create(module->llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock);
} else {
type = field->signature->naturalType;
@@ -766,7 +767,7 @@
Value* staticCl = new BitCastInst(call, cl->staticType, "", currentBlock);
std::vector<Value*> args;
- args.push_back(mvm::jit::constantZero);
+ args.push_back(module->constantZero);
args.push_back(field->offset);
Value* ptr = GetElementPtrInst::Create(staticCl, args.begin(), args.end(), "",
currentBlock);
@@ -844,7 +845,7 @@
currentBlock = ifTrue;
}
- Constant* zero = mvm::jit::constantZero;
+ Constant* zero = module->constantZero;
Value* val = new BitCastInst(obj, arrayType, "", currentBlock);
std::vector<Value*> indexes; //[3];
@@ -859,11 +860,11 @@
}
ConstantInt* VMArray::sizeOffset() {
- return mvm::jit::constantOne;
+ return mvm::MvmModule::constantOne;
}
ConstantInt* VMArray::elementsOffset() {
- return mvm::jit::constantTwo;
+ return mvm::MvmModule::constantTwo;
}
Value* CLIJit::arraySize(Value* array) {
@@ -873,7 +874,7 @@
return CallInst::Create(arrayLengthLLVM, array, "", currentBlock);
/*
std::vector<Value*> args; //size= 2
- args.push_back(mvm::jit::constantZero);
+ args.push_back(module->constantZero);
args.push_back(VMArray::sizeOffset());
Value* ptr = GetElementPtrInst::Create(array, args.begin(), args.end(),
"", currentBlock);
@@ -891,13 +892,13 @@
BasicBlock* entry = createBasicBlock("entry");
obj = new BitCastInst(obj, MSCorlib::pDelegate->virtualType, "", entry);
std::vector<Value*> elts;
- elts.push_back(mvm::jit::constantZero);
- elts.push_back(mvm::jit::constantOne);
+ elts.push_back(module->constantZero);
+ elts.push_back(module->constantOne);
Value* targetPtr = GetElementPtrInst::Create(obj, elts.begin(), elts.end(),
"", entry);
elts.pop_back();
- elts.push_back(mvm::jit::constantTwo);
+ elts.push_back(module->constantTwo);
Value* handlePtr = GetElementPtrInst::Create(obj, elts.begin(), elts.end(),
"", entry);
@@ -1084,16 +1085,16 @@
}
if (cur->realTest != cur->test) {
- const PointerType* PointerTy_0 = mvm::jit::ptrType;
+ const PointerType* PointerTy_0 = module->ptrType;
std::vector<Value*> int32_eh_select_params;
- Instruction* ptr_eh_ptr = CallInst::Create(mvm::jit::llvmGetException,
+ Instruction* ptr_eh_ptr = CallInst::Create(module->llvmGetException,
"eh_ptr", cur->test);
int32_eh_select_params.push_back(ptr_eh_ptr);
Constant* C = ConstantExpr::getCast(Instruction::BitCast,
- mvm::jit::personality, PointerTy_0);
+ module->personality, PointerTy_0);
int32_eh_select_params.push_back(C);
- int32_eh_select_params.push_back(mvm::jit::constantPtrNull);
- CallInst::Create(mvm::jit::exceptionSelector,
+ int32_eh_select_params.push_back(module->constantPtrNull);
+ CallInst::Create(module->exceptionSelector,
int32_eh_select_params.begin(),
int32_eh_select_params.end(), "eh_select", cur->test);
BranchInst::Create(cur->realTest, cur->test);
@@ -1107,10 +1108,10 @@
Value* cpp = CallInst::Create(getCppExceptionLLVM, "", cur->handler);
Value* exc = CallInst::Create(getCLIExceptionLLVM, "", cur->handler);
CallInst::Create(clearExceptionLLVM, "", cur->handler);
- CallInst::Create(mvm::jit::exceptionBeginCatch, cpp, "tmp8",
+ CallInst::Create(module->exceptionBeginCatch, cpp, "tmp8",
cur->handler);
std::vector<Value*> void_28_params;
- CallInst::Create(mvm::jit::exceptionEndCatch, void_28_params.begin(),
+ CallInst::Create(module->exceptionEndCatch, void_28_params.begin(),
void_28_params.end(), "", cur->handler);
new StoreInst(exc, supplLocal, false, cur->handler);
@@ -1133,17 +1134,17 @@
llvm::Value* arg = *i;
const llvm::Type* type = arg->getType();
if (type == Type::Int8Ty || type == Type::Int16Ty || type == Type::Int1Ty) {
- CallInst::Create(mvm::jit::printIntLLVM, new ZExtInst(arg, Type::Int32Ty, "", insertAt), "", insertAt);
+ CallInst::Create(module->printIntLLVM, new ZExtInst(arg, Type::Int32Ty, "", insertAt), "", insertAt);
} else if (type == Type::Int32Ty) {
- CallInst::Create(mvm::jit::printIntLLVM, arg, "", insertAt);
+ CallInst::Create(module->printIntLLVM, arg, "", insertAt);
} else if (type == Type::Int64Ty) {
- CallInst::Create(mvm::jit::printLongLLVM, arg, "", insertAt);
+ CallInst::Create(module->printLongLLVM, arg, "", insertAt);
} else if (type == Type::FloatTy) {
- CallInst::Create(mvm::jit::printFloatLLVM, arg, "", insertAt);
+ CallInst::Create(module->printFloatLLVM, arg, "", insertAt);
} else if (type == Type::DoubleTy) {
- CallInst::Create(mvm::jit::printDoubleLLVM, arg, "", insertAt);
+ CallInst::Create(module->printDoubleLLVM, arg, "", insertAt);
} else {
- CallInst::Create(mvm::jit::printIntLLVM, new PtrToIntInst(arg, Type::Int32Ty, "", insertAt), "", insertAt);
+ CallInst::Create(module->printIntLLVM, new PtrToIntInst(arg, Type::Int32Ty, "", insertAt), "", insertAt);
}
}
@@ -1231,15 +1232,15 @@
new StoreInst(Constant::getNullValue(cl->naturalType), alloc, false,
currentBlock);
} else {
- uint64 size = mvm::jit::getTypeSize(cl->naturalType);
+ uint64 size = module->getTypeSize(cl->naturalType);
std::vector<Value*> params;
- params.push_back(new BitCastInst(alloc, mvm::jit::ptrType, "",
+ params.push_back(new BitCastInst(alloc, module->ptrType, "",
currentBlock));
- params.push_back(mvm::jit::constantInt8Zero);
+ params.push_back(module->constantInt8Zero);
params.push_back(ConstantInt::get(Type::Int32Ty, size));
- params.push_back(mvm::jit::constantZero);
- CallInst::Create(mvm::jit::llvm_memset_i32, params.begin(),
+ params.push_back(module->constantZero);
+ CallInst::Create(module->llvm_memset_i32, params.begin(),
params.end(), "", currentBlock);
}
@@ -1278,16 +1279,16 @@
} else if (compilingMethod->structReturn) {
const Type* lastType =
funcType->getContainedType(funcType->getNumContainedTypes() - 1);
- uint64 size = mvm::jit::getTypeSize(lastType->getContainedType(0));
+ uint64 size = module->getTypeSize(lastType->getContainedType(0));
Value* obj = --llvmFunction->arg_end();
std::vector<Value*> params;
- params.push_back(new BitCastInst(obj, mvm::jit::ptrType, "",
+ params.push_back(new BitCastInst(obj, module->ptrType, "",
currentBlock));
- params.push_back(new BitCastInst(endNode, mvm::jit::ptrType, "",
+ params.push_back(new BitCastInst(endNode, module->ptrType, "",
currentBlock));
params.push_back(ConstantInt::get(Type::Int32Ty, size));
- params.push_back(mvm::jit::constantFour);
- CallInst::Create(mvm::jit::llvm_memcpy_i32, params.begin(), params.end(),
+ params.push_back(module->constantFour);
+ CallInst::Create(module->llvm_memcpy_i32, params.begin(), params.end(),
"", currentBlock);
ReturnInst::Create(currentBlock);
} else {
@@ -1302,7 +1303,7 @@
} else {
CallInst* ptr_eh_ptr = CallInst::Create(getCppExceptionLLVM, "eh_ptr",
endExceptionBlock);
- CallInst::Create(mvm::jit::unwindResume, ptr_eh_ptr, "", endExceptionBlock);
+ CallInst::Create(module->unwindResume, ptr_eh_ptr, "", endExceptionBlock);
new UnreachableInst(endExceptionBlock);
}
@@ -1314,7 +1315,7 @@
new UnreachableInst(unifiedUnreachable);
}
- mvm::jit::runPasses(llvmFunction, VMThread::get()->perFunctionPasses);
+ module->runPasses(llvmFunction, VMThread::get()->perFunctionPasses);
if (nbe == 0 && codeLen < 50) {
PRINT_DEBUG(N3_COMPILE, 1, COLOR_NORMAL, "%s can be inlined\n",
@@ -1408,15 +1409,15 @@
new StoreInst(Constant::getNullValue(cl->naturalType), alloc, false,
currentBlock);
} else {
- uint64 size = mvm::jit::getTypeSize(cl->naturalType);
+ uint64 size = module->getTypeSize(cl->naturalType);
std::vector<Value*> params;
- params.push_back(new BitCastInst(alloc, mvm::jit::ptrType, "",
+ params.push_back(new BitCastInst(alloc, module->ptrType, "",
currentBlock));
- params.push_back(mvm::jit::constantInt8Zero);
+ params.push_back(module->constantInt8Zero);
params.push_back(ConstantInt::get(Type::Int32Ty, size));
- params.push_back(mvm::jit::constantZero);
- CallInst::Create(mvm::jit::llvm_memset_i32, params.begin(),
+ params.push_back(module->constantZero);
+ CallInst::Create(module->llvm_memset_i32, params.begin(),
params.end(), "", currentBlock);
}
@@ -1453,7 +1454,7 @@
CLIJit* jit = gc_new(CLIJit)();
jit->compilingClass = cl;
jit->compilingMethod = meth;
-
+ jit->module = cl->vm->module;
Function* func;
meth->getSignature(dynamic_cast<VMGenericMethod*>(meth));
@@ -1485,7 +1486,7 @@
void VMField::initField(VMObject* obj) {
VMField* field = this;
ConstantInt* offset = field->offset;
- const TargetData* targetData = mvm::jit::executionEngine->getTargetData();
+ const TargetData* targetData = mvm::MvmModule::executionEngine->getTargetData();
bool stat = isStatic(field->flags);
const Type* clType = stat ? field->classDef->staticType :
field->classDef->virtualType;
@@ -1502,9 +1503,9 @@
}
void CLIJit::initialiseAppDomain(N3* vm) {
- mvm::jit::protectEngine->lock();
- mvm::jit::executionEngine->addModuleProvider(vm->TheModuleProvider);
- mvm::jit::protectEngine->unlock();
+ mvm::MvmModule::protectEngine->lock();
+ mvm::MvmModule::executionEngine->addModuleProvider(vm->TheModuleProvider);
+ mvm::MvmModule::protectEngine->unlock();
}
namespace n3 {
@@ -1515,10 +1516,10 @@
void CLIJit::initialiseBootstrapVM(N3* vm) {
- Module* module = vm->module;
- mvm::jit::protectEngine->lock();
- mvm::jit::executionEngine->addModuleProvider(vm->TheModuleProvider);
- mvm::jit::protectEngine->unlock();
+ mvm::MvmModule* module = vm->module;
+ module->protectEngine->lock();
+ module->executionEngine->addModuleProvider(vm->TheModuleProvider);
+ module->protectEngine->unlock();
n3::llvm_runtime::makeLLVMModuleContents(module);
@@ -1736,7 +1737,7 @@
}
void AddStandardCompilePasses(FunctionPassManager *PM) {
- llvm::MutexGuard locked(mvm::jit::executionEngine->lock);
+ llvm::MutexGuard locked(mvm::MvmModule::executionEngine->lock);
// LLVM does not allow calling functions from other modules in verifier
//PM->add(llvm::createVerifierPass()); // Verify that input is correct
Modified: vmkit/trunk/lib/N3/VMCore/CLIJit.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIJit.h?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/CLIJit.h (original)
+++ vmkit/trunk/lib/N3/VMCore/CLIJit.h Fri Oct 10 07:51:51 2008
@@ -10,6 +10,7 @@
#ifndef N3_CLIJit_H
#define N3_CLIJit_H
+#include "mvm/JIT.h"
#include "mvm/Object.h"
#include "mvm/PrintBuffer.h"
#include "mvm/Threads/Locks.h"
@@ -93,6 +94,7 @@
llvm::Function* llvmFunction;
VMMethod* compilingMethod;
VMClass* compilingClass;
+ mvm::MvmModule* module;
std::vector<llvm::Value*> arguments;
std::vector<llvm::Value*> locals;
Modified: vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp Fri Oct 10 07:51:51 2008
@@ -231,7 +231,7 @@
}
}
- return mvm::jit::executionEngine->runFunction(func, args);
+ return mvm::MvmModule::executionEngine->runFunction(func, args);
}
GenericValue VMMethod::operator()(VMObject* obj, va_list ap) {
@@ -278,7 +278,7 @@
}
}
- return mvm::jit::executionEngine->runFunction(func, args);
+ return mvm::MvmModule::executionEngine->runFunction(func, args);
}
@@ -304,7 +304,7 @@
classDef->resolveType(true, true, NULL);
Function* func = compiledPtr(NULL);
- return mvm::jit::executionEngine->runFunction(func, args);
+ return mvm::MvmModule::executionEngine->runFunction(func, args);
}
GenericValue VMObject::operator()(VMField* field) {
@@ -364,7 +364,7 @@
if (!_llvmVar) {
aquire();
if (!_llvmVar) {
- const Type* pty = mvm::jit::ptrType;
+ const Type* pty = mvm::MvmModule::ptrType;
Constant* cons =
ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (this)),
pty);
@@ -384,7 +384,7 @@
if (!_llvmVar) {
classDef->aquire();
if (!_llvmVar) {
- const Type* pty = mvm::jit::ptrType;
+ const Type* pty = mvm::MvmModule::ptrType;
Constant* cons =
ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (this)),
pty);
@@ -403,7 +403,7 @@
if (!_llvmVar) {
classDef->aquire();
if (!_llvmVar) {
- const Type* pty = mvm::jit::ptrType;
+ const Type* pty = mvm::MvmModule::ptrType;
Constant* cons =
ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (this)),
pty);
@@ -420,5 +420,5 @@
}
ConstantInt* VMObject::classOffset() {
- return mvm::jit::constantOne;
+ return mvm::MvmModule::constantOne;
}
Modified: vmkit/trunk/lib/N3/VMCore/CLIRuntimeJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIRuntimeJIT.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/CLIRuntimeJIT.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/CLIRuntimeJIT.cpp Fri Oct 10 07:51:51 2008
@@ -156,7 +156,7 @@
}
Function* func = dmeth->compiledPtr(NULL);
- rcache->methPtr = mvm::jit::executionEngine->getPointerToGlobal(func);
+ rcache->methPtr = mvm::MvmModule::executionEngine->getPointerToGlobal(func);
rcache->lastCible = (VMClass*)ocl;
rcache->box = (dmeth->classDef->super == MSCorlib::pValue);
}
Modified: vmkit/trunk/lib/N3/VMCore/LowerArrayLength.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/LowerArrayLength.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/LowerArrayLength.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/LowerArrayLength.cpp Fri Oct 10 07:51:51 2008
@@ -46,7 +46,7 @@
Changed = true;
Value* val = CI->getOperand(1); // get the array
std::vector<Value*> args; //size= 2
- args.push_back(mvm::jit::constantZero);
+ args.push_back(mvm::MvmModule::constantZero);
args.push_back(n3::VMArray::sizeOffset());
Value* ptr = GetElementPtrInst::Create(val, args.begin(), args.end(),
"", CI);
Modified: vmkit/trunk/lib/N3/VMCore/N3.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/N3.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/N3.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/N3.cpp Fri Oct 10 07:51:51 2008
@@ -65,9 +65,9 @@
#endif
std::string str =
- mvm::jit::executionEngine->getTargetData()->getStringRepresentation();
+ mvm::MvmModule::executionEngine->getTargetData()->getStringRepresentation();
- vm->module = new llvm::Module("Bootstrap N3");
+ vm->module = new mvm::MvmModule("Bootstrap N3");
vm->module->setDataLayout(str);
vm->protectModule = mvm::Lock::allocNormal();
vm->functions = FunctionMap::allocate();
@@ -78,7 +78,7 @@
vm->bootstrapThread->baseSP = mvm::Thread::get()->baseSP;
#ifdef MULTIPLE_GC
vm->bootstrapThread->GC = GC;
- mvm::jit::memoryManager->addGCForModule(vm->module, GC);
+ mvm::MvmModule::memoryManager->addGCForModule(vm->module, GC);
#endif
VMThread::set(vm->bootstrapThread);
@@ -100,8 +100,8 @@
#endif
std::string str =
- mvm::jit::executionEngine->getTargetData()->getStringRepresentation();
- vm->module = new llvm::Module("App Domain");
+ mvm::MvmModule::executionEngine->getTargetData()->getStringRepresentation();
+ vm->module = new mvm::MvmModule("App Domain");
vm->module->setDataLayout(str);
vm->protectModule = mvm::Lock::allocNormal();
vm->functions = FunctionMap::allocate();
@@ -112,7 +112,7 @@
vm->bootstrapThread->baseSP = mvm::Thread::get()->baseSP;
#ifdef MULTIPLE_GC
vm->bootstrapThread->GC = GC;
- mvm::jit::memoryManager->addGCForModule(vm->module, GC);
+ mvm::MvmModule::memoryManager->addGCForModule(vm->module, GC);
#endif
VMThread::set(vm->bootstrapThread);
Modified: vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp Fri Oct 10 07:51:51 2008
@@ -31,16 +31,16 @@
return false;
} else {
void* res =
- mvm::jit::executionEngine->getPointerToGlobalIfAvailable(meth->methPtr);
+ mvm::MvmModule::executionEngine->getPointerToGlobalIfAvailable(meth->methPtr);
if (res == 0) {
meth->classDef->aquire();
res =
- mvm::jit::executionEngine->getPointerToGlobalIfAvailable(meth->methPtr);
+ mvm::MvmModule::executionEngine->getPointerToGlobalIfAvailable(meth->methPtr);
if (res == 0) {
CLIJit::compile(meth->classDef, meth);
- void* res = mvm::jit::executionEngine->getPointerToGlobal(meth->methPtr);
+ void* res = mvm::MvmModule::executionEngine->getPointerToGlobal(meth->methPtr);
meth->code = res;
- mvm::Code* code = mvm::jit::getCodeFromPointer(res);
+ mvm::Code* code = mvm::MvmModule::getCodeFromPointer(res);
code->setMetaInfo(meth);
}
meth->classDef->release();
Modified: vmkit/trunk/lib/N3/VMCore/Opcodes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/Opcodes.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/Opcodes.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/Opcodes.cpp Fri Oct 10 07:51:51 2008
@@ -162,7 +162,7 @@
}
static void store(Value* val, Value* local, bool vol,
- BasicBlock* currentBlock) {
+ BasicBlock* currentBlock, mvm::MvmModule* module) {
const Type* contained = local->getType()->getContainedType(0);
if (contained->isSingleValueType()) {
if (val->getType() != contained) {
@@ -170,32 +170,32 @@
}
new StoreInst(val, local, vol, currentBlock);
} else if (isa<PointerType>(val->getType())) {
- uint64 size = mvm::jit::getTypeSize(contained);
+ uint64 size = module->getTypeSize(contained);
std::vector<Value*> params;
params.push_back(new BitCastInst(local, PointerType::getUnqual(Type::Int8Ty), "", currentBlock));
params.push_back(new BitCastInst(val, PointerType::getUnqual(Type::Int8Ty), "", currentBlock));
params.push_back(ConstantInt::get(Type::Int32Ty, size));
- params.push_back(mvm::jit::constantZero);
- CallInst::Create(mvm::jit::llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock);
+ params.push_back(module->constantZero);
+ CallInst::Create(module->llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock);
} else {
new StoreInst(val, local, vol, currentBlock);
}
}
-static Value* load(Value* val, const char* name, BasicBlock* currentBlock) {
+static Value* load(Value* val, const char* name, BasicBlock* currentBlock, mvm::MvmModule* module) {
const Type* contained = val->getType()->getContainedType(0);
if (contained->isSingleValueType()) {
return new LoadInst(val, name, currentBlock);
} else {
- uint64 size = mvm::jit::getTypeSize(contained);
+ uint64 size = module->getTypeSize(contained);
Value* ret = new AllocaInst(contained, "", currentBlock);
std::vector<Value*> params;
params.push_back(new BitCastInst(ret, PointerType::getUnqual(Type::Int8Ty), "", currentBlock));
params.push_back(new BitCastInst(val, PointerType::getUnqual(Type::Int8Ty), "", currentBlock));
params.push_back(ConstantInt::get(Type::Int32Ty, size));
- params.push_back(mvm::jit::constantZero);
- CallInst::Create(mvm::jit::llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock);
+ params.push_back(module->constantZero);
+ CallInst::Create(module->llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock);
return ret;
}
}
@@ -247,13 +247,13 @@
case ADD: {
Value* val2 = pop();
- bool isPointer = (val2->getType() == mvm::jit::ptrType);
+ bool isPointer = (val2->getType() == module->ptrType);
Value* val1 = pop();
- isPointer |= (val1->getType() == mvm::jit::ptrType);
+ isPointer |= (val1->getType() == module->ptrType);
verifyType(val1, val2, currentBlock);
Value* res = BinaryOperator::createAdd(val1, val2, "", currentBlock);
if (isPointer) {
- res = new IntToPtrInst(res, mvm::jit::ptrType, "", currentBlock);
+ res = new IntToPtrInst(res, module->ptrType, "", currentBlock);
}
push(res);
break;
@@ -767,52 +767,52 @@
}
case LDC_I4_0 : {
- push(mvm::jit::constantZero);
+ push(module->constantZero);
break;
}
case LDC_I4_1 : {
- push(mvm::jit::constantOne);
+ push(module->constantOne);
break;
}
case LDC_I4_2 : {
- push(mvm::jit::constantTwo);
+ push(module->constantTwo);
break;
}
case LDC_I4_3 : {
- push(mvm::jit::constantThree);
+ push(module->constantThree);
break;
}
case LDC_I4_4 : {
- push(mvm::jit::constantFour);
+ push(module->constantFour);
break;
}
case LDC_I4_5 : {
- push(mvm::jit::constantFive);
+ push(module->constantFive);
break;
}
case LDC_I4_6 : {
- push(mvm::jit::constantSix);
+ push(module->constantSix);
break;
}
case LDC_I4_7 : {
- push(mvm::jit::constantSeven);
+ push(module->constantSeven);
break;
}
case LDC_I4_8 : {
- push(mvm::jit::constantEight);
+ push(module->constantEight);
break;
}
case LDC_I4_M1 : {
- push(mvm::jit::constantMinusOne);
+ push(module->constantMinusOne);
break;
}
@@ -895,31 +895,31 @@
}
case LDLOC_S : {
- Value* val = load(locals[readU1(bytecodes, i)], "", currentBlock);
+ Value* val = load(locals[readU1(bytecodes, i)], "", currentBlock, module);
push(val);
break;
}
case LDLOC_0 : {
- Value* val = load(locals[0], "", currentBlock);
+ Value* val = load(locals[0], "", currentBlock, module);
push(val);
break;
}
case LDLOC_1 : {
- Value* val = load(locals[1], "", currentBlock);
+ Value* val = load(locals[1], "", currentBlock, module);
push(val);
break;
}
case LDLOC_2 : {
- Value* val = load(locals[2], "", currentBlock);
+ Value* val = load(locals[2], "", currentBlock, module);
push(val);
break;
}
case LDLOC_3 : {
- Value* val = load(locals[3], "", currentBlock);
+ Value* val = load(locals[3], "", currentBlock, module);
push(val);
break;
}
@@ -1199,35 +1199,35 @@
case STLOC_S : {
Value* val = pop();
Value* local = locals[readU1(bytecodes, i)];
- store(val, local, false, currentBlock);
+ store(val, local, false, currentBlock, module);
break;
}
case STLOC_0 : {
Value* val = pop();
Value* local = locals[0];
- store(val, local, false, currentBlock);
+ store(val, local, false, currentBlock, module);
break;
}
case STLOC_1 : {
Value* val = pop();
Value* local = locals[1];
- store(val, local, false, currentBlock);
+ store(val, local, false, currentBlock, module);
break;
}
case STLOC_2 : {
Value* val = pop();
Value* local = locals[2];
- store(val, local, false, currentBlock);
+ store(val, local, false, currentBlock, module);
break;
}
case STLOC_3 : {
Value* val = pop();
Value* local = locals[3];
- store(val, local, false, currentBlock);
+ store(val, local, false, currentBlock, module);
break;
}
@@ -1293,8 +1293,8 @@
std::vector<Value*> ptrs;
- ptrs.push_back(mvm::jit::constantZero);
- ptrs.push_back(mvm::jit::constantOne);
+ ptrs.push_back(module->constantZero);
+ ptrs.push_back(module->constantOne);
Value* ptr = GetElementPtrInst::Create(obj, ptrs.begin(), ptrs.end(), "",
currentBlock);
@@ -1306,14 +1306,14 @@
}
- uint64 size = mvm::jit::getTypeSize(type->naturalType);
+ uint64 size = module->getTypeSize(type->naturalType);
std::vector<Value*> params;
params.push_back(new BitCastInst(ptr, PointerType::getUnqual(Type::Int8Ty), "", currentBlock));
params.push_back(new BitCastInst(val, PointerType::getUnqual(Type::Int8Ty), "", currentBlock));
params.push_back(ConstantInt::get(Type::Int32Ty, size));
- params.push_back(mvm::jit::constantZero);
- CallInst::Create(mvm::jit::llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock);
+ params.push_back(module->constantZero);
+ CallInst::Create(module->llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock);
push(obj);
@@ -1351,7 +1351,7 @@
"", ifFalse);
cmp = new ICmpInst(ICmpInst::ICMP_EQ, call,
- mvm::jit::constantZero, "", ifFalse);
+ module->constantZero, "", ifFalse);
BasicBlock* ex = createBasicBlock("false checkcast");
branch(cmp, ex, ifTrue, ifFalse);
@@ -1408,7 +1408,7 @@
"", ifFalse);
cmp = new ICmpInst(ICmpInst::ICMP_EQ, call,
- mvm::jit::constantZero, "", ifFalse);
+ module->constantZero, "", ifFalse);
BasicBlock* falseInst = createBasicBlock("false isinst");
BasicBlock* trueInst = createBasicBlock("true isinst");
@@ -1581,7 +1581,7 @@
uint32 index = value & 0xfffffff;
const UTF8* utf8 = compilingClass->assembly->readUserString(index);
Value* val = ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, (int64_t)utf8),
- mvm::jit::ptrType);
+ module->ptrType);
Value* res = CallInst::Create(newStringLLVM, val, "", currentBlock);
/*CLIString * str =
(CLIString*)(((N3*)VMThread::get()->vm)->UTF8ToStr(utf8));
@@ -1802,19 +1802,19 @@
}
std::vector<Value*> ptrs;
- ptrs.push_back(mvm::jit::constantZero);
- ptrs.push_back(mvm::jit::constantOne);
+ ptrs.push_back(module->constantZero);
+ ptrs.push_back(module->constantOne);
Value* ptr = GetElementPtrInst::Create(obj, ptrs.begin(), ptrs.end(), "",
currentBlock);
- uint64 size = mvm::jit::getTypeSize(type->naturalType);
+ uint64 size = module->getTypeSize(type->naturalType);
std::vector<Value*> params;
params.push_back(new BitCastInst(val, PointerType::getUnqual(Type::Int8Ty), "", currentBlock));
params.push_back(new BitCastInst(ptr, PointerType::getUnqual(Type::Int8Ty), "", currentBlock));
params.push_back(ConstantInt::get(Type::Int32Ty, size));
- params.push_back(mvm::jit::constantZero);
- CallInst::Create(mvm::jit::llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock);
+ params.push_back(module->constantZero);
+ CallInst::Create(module->llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock);
push(val);
@@ -1865,7 +1865,7 @@
args.push_back(one);
args.push_back(two);
args.push_back(three);
- CallInst::Create(mvm::jit::llvm_memcpy_i32,
+ CallInst::Create(module->llvm_memcpy_i32,
args.begin(), args.end(), "", currentBlock);
isVolatile = false;
break;
@@ -1912,7 +1912,7 @@
args.push_back(one);
args.push_back(two);
args.push_back(three);
- CallInst::Create(mvm::jit::llvm_memset_i32,
+ CallInst::Create(module->llvm_memset_i32,
args.begin(), args.end(), "", currentBlock);
isVolatile = false;
break;
@@ -1936,7 +1936,7 @@
case STLOC : {
Value* val = pop();
Value* local = locals[readU2(bytecodes, i)];
- store(val, local, false, currentBlock);
+ store(val, local, false, currentBlock, module);
break;
}
@@ -1957,15 +1957,15 @@
VMCommonClass* type = assembly->loadType(vm, token, true, false, false,
true, genClass, genMethod);
if (type->super == MSCorlib::pValue) {
- uint64 size = mvm::jit::getTypeSize(type->naturalType);
+ uint64 size = module->getTypeSize(type->naturalType);
std::vector<Value*> params;
- params.push_back(new BitCastInst(pop(), mvm::jit::ptrType, "",
+ params.push_back(new BitCastInst(pop(), module->ptrType, "",
currentBlock));
- params.push_back(mvm::jit::constantInt8Zero);
+ params.push_back(module->constantInt8Zero);
params.push_back(ConstantInt::get(Type::Int32Ty, size));
- params.push_back(mvm::jit::constantZero);
- CallInst::Create(mvm::jit::llvm_memset_i32, params.begin(),
+ params.push_back(module->constantZero);
+ CallInst::Create(module->llvm_memset_i32, params.begin(),
params.end(), "", currentBlock);
}
Modified: vmkit/trunk/lib/N3/VMCore/VMCache.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMCache.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMCache.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/VMCache.cpp Fri Oct 10 07:51:51 2008
@@ -87,10 +87,10 @@
Enveloppe* enveloppe = Enveloppe::allocate(origMeth);
compilingMethod->caches.push_back(enveloppe);
- Value* zero = mvm::jit::constantZero;
- Value* one = mvm::jit::constantOne;
- Value* two = mvm::jit::constantTwo;
- Value* five = mvm::jit::constantFive;
+ Value* zero = module->constantZero;
+ Value* one = module->constantOne;
+ Value* two = module->constantTwo;
+ Value* five = module->constantFive;
Value* llvmEnv =
ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (enveloppe)),
Modified: vmkit/trunk/lib/N3/VMCore/VMClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMClass.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMClass.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/VMClass.cpp Fri Oct 10 07:51:51 2008
@@ -251,7 +251,7 @@
if (meth) {
llvm::Function* pred = meth->compiledPtr(genMethod);
clinit_t res = (clinit_t)
- (intptr_t)mvm::jit::executionEngine->getPointerToGlobal(pred);
+ (intptr_t)mvm::MvmModule::executionEngine->getPointerToGlobal(pred);
res();
}
@@ -291,7 +291,7 @@
VirtualTable* VT = CLIJit::makeVT(cl, true);
- uint64 size = mvm::jit::getTypeSize(cl->staticType->getContainedType(0));
+ uint64 size = mvm::MvmModule::getTypeSize(cl->staticType->getContainedType(0));
cl->staticInstance = (VMObject*)gc::operator new(size, VT);
cl->staticInstance->initialise(cl);
@@ -320,7 +320,7 @@
if (super == MSCorlib::pValue) {
uint32 size = virtualFields.size();
if (size == 1) {
- virtualFields[0]->offset = mvm::jit::constantZero;
+ virtualFields[0]->offset = mvm::MvmModule::constantZero;
ResultTy = virtualFields[0]->signature->naturalType;
} else if (size == 0) {
ResultTy = Type::VoidTy;
@@ -460,7 +460,7 @@
if (super != MSCorlib::pEnum && !cl->virtualInstance) {
VirtualTable* VT = CLIJit::makeVT(cl, false);
- uint64 size = mvm::jit::getTypeSize(cl->virtualType->getContainedType(0));
+ uint64 size = mvm::MvmModule::getTypeSize(cl->virtualType->getContainedType(0));
cl->virtualInstance = (VMObject*)gc::operator new(size, VT);
cl->virtualInstance->initialise(cl);
@@ -614,14 +614,14 @@
}
VMObject* VMClass::initialiseObject(VMObject* obj) {
- uint64 size = mvm::jit::getTypeSize(virtualType->getContainedType(0));
+ uint64 size = mvm::MvmModule::getTypeSize(virtualType->getContainedType(0));
memcpy(obj, virtualInstance, size);
return obj;
}
VMObject* VMClass::doNew() {
if (status < inClinit) resolveType(true, true, NULL);
- uint64 size = mvm::jit::getTypeSize(virtualType->getContainedType(0));
+ uint64 size = mvm::MvmModule::getTypeSize(virtualType->getContainedType(0));
VMObject* res = (VMObject*)
gc::operator new(size, virtualInstance->getVirtualTable());
memcpy(res, virtualInstance, size);
@@ -630,7 +630,7 @@
VMObject* VMClassArray::doNew(uint32 nb) {
if (status < inClinit) resolveType(true, true, NULL);
- uint64 size = mvm::jit::getTypeSize(baseClass->naturalType);
+ uint64 size = mvm::MvmModule::getTypeSize(baseClass->naturalType);
VMArray* res = (VMArray*)
gc::operator new(size * nb + sizeof(VMObject) + sizeof(sint32), arrayVT);
memset(res->elements, 0, size * nb);
Modified: vmkit/trunk/lib/N3/VMCore/VirtualMachine.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VirtualMachine.h?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VirtualMachine.h (original)
+++ vmkit/trunk/lib/N3/VMCore/VirtualMachine.h Fri Oct 10 07:51:51 2008
@@ -14,6 +14,7 @@
#include "llvm/Function.h"
+#include "mvm/JIT.h"
#include "mvm/Object.h"
#include "mvm/PrintBuffer.h"
#include "mvm/VirtualMachine.h"
@@ -121,7 +122,7 @@
mvm::Lock* protectModule;
FunctionMap* functions;
- llvm::Module* module;
+ mvm::MvmModule* module;
N3ModuleProvider* TheModuleProvider;
VMThread* bootstrapThread;
Modified: vmkit/trunk/lib/N3/VMCore/VirtualTables.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VirtualTables.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VirtualTables.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/VirtualTables.cpp Fri Oct 10 07:51:51 2008
@@ -109,11 +109,11 @@
}
void VMArray::TRACER {
- VMObject::PARENT_TRACER;
+ VMObject::CALL_TRACER;
}
void ArrayObject::TRACER {
- VMObject::PARENT_TRACER;
+ VMObject::CALL_TRACER;
for (sint32 i = 0; i < size; i++) {
elements[i]->MARK_AND_TRACE;
}
@@ -121,7 +121,7 @@
#define ARRAYTRACER(name) \
void name::TRACER { \
- VMObject::PARENT_TRACER; \
+ VMObject::CALL_TRACER; \
}
@@ -164,7 +164,7 @@
}
void VMClass::TRACER {
- VMCommonClass::PARENT_TRACER;
+ VMCommonClass::CALL_TRACER;
staticInstance->MARK_AND_TRACE;
virtualInstance->MARK_AND_TRACE;
TRACE_VECTOR(VMClass*, innerClasses, std::allocator);
@@ -173,17 +173,17 @@
}
void VMGenericClass::TRACER {
- VMClass::PARENT_TRACER;
+ VMClass::CALL_TRACER;
TRACE_VECTOR(VMCommonClass*, genericParams, std::allocator);
}
void VMClassArray::TRACER {
- VMCommonClass::PARENT_TRACER;
+ VMCommonClass::CALL_TRACER;
baseClass->MARK_AND_TRACE;
}
void VMClassPointer::TRACER {
- VMCommonClass::PARENT_TRACER;
+ VMCommonClass::CALL_TRACER;
baseClass->MARK_AND_TRACE;
}
@@ -198,7 +198,7 @@
}
void VMGenericMethod::TRACER {
- VMMethod::PARENT_TRACER;
+ VMMethod::CALL_TRACER;
TRACE_VECTOR(VMCommonClass*, genericParams, std::allocator);
}
@@ -269,7 +269,7 @@
}
void N3::TRACER {
- VirtualMachine::PARENT_TRACER;
+ VirtualMachine::CALL_TRACER;
hashUTF8->MARK_AND_TRACE;
hashStr->MARK_AND_TRACE;
loadedAssemblies->MARK_AND_TRACE;
Modified: vmkit/trunk/tools/jnjvm/Main.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/jnjvm/Main.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/tools/jnjvm/Main.cpp (original)
+++ vmkit/trunk/tools/jnjvm/Main.cpp Fri Oct 10 07:51:51 2008
@@ -21,7 +21,7 @@
llvm::llvm_shutdown_obj X;
int base;
- jit::initialise();
+ MvmModule::initialise();
Object::initialise();
Thread::initialise();
Collector::initialise(0, &base);
Modified: vmkit/trunk/tools/n3-mono/Main.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/n3-mono/Main.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/tools/n3-mono/Main.cpp (original)
+++ vmkit/trunk/tools/n3-mono/Main.cpp Fri Oct 10 07:51:51 2008
@@ -21,7 +21,7 @@
llvm::llvm_shutdown_obj X;
int base;
- jit::initialise();
+ MvmModule::initialise();
Object::initialise();
Thread::initialise();
Collector::initialise(0, &base);
Modified: vmkit/trunk/tools/n3-pnetlib/Main.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/n3-pnetlib/Main.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/tools/n3-pnetlib/Main.cpp (original)
+++ vmkit/trunk/tools/n3-pnetlib/Main.cpp Fri Oct 10 07:51:51 2008
@@ -21,7 +21,7 @@
llvm::llvm_shutdown_obj X;
int base;
- jit::initialise();
+ MvmModule::initialise();
Object::initialise();
Thread::initialise();
Collector::initialise(0, &base);
Modified: vmkit/trunk/tools/vmkit/Launcher.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmkit/Launcher.cpp?rev=57349&r1=57348&r2=57349&view=diff
==============================================================================
--- vmkit/trunk/tools/vmkit/Launcher.cpp (original)
+++ vmkit/trunk/tools/vmkit/Launcher.cpp Fri Oct 10 07:51:51 2008
@@ -44,7 +44,7 @@
llvm::llvm_shutdown_obj X;
int base;
- mvm::jit::initialise();
+ mvm::MvmModule::initialise();
mvm::Object::initialise();
mvm::Thread::initialise();
Collector::initialise(0, &base);
More information about the vmkit-commits
mailing list