[vmkit-commits] [vmkit] r57172 - in /vmkit/trunk/lib/Mvm/Runtime: JIT.cpp LLVMRuntime.ll
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Mon Oct 6 08:32:29 PDT 2008
Author: geoffray
Date: Mon Oct 6 10:32:28 2008
New Revision: 57172
URL: http://llvm.org/viewvc/llvm-project?rev=57172&view=rev
Log:
New executionEnvironment variable for llvm, to store thread local data.
Modified:
vmkit/trunk/lib/Mvm/Runtime/JIT.cpp
vmkit/trunk/lib/Mvm/Runtime/LLVMRuntime.ll
Modified: vmkit/trunk/lib/Mvm/Runtime/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Runtime/JIT.cpp?rev=57172&r1=57171&r2=57172&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Runtime/JIT.cpp (original)
+++ vmkit/trunk/lib/Mvm/Runtime/JIT.cpp Mon Oct 6 10:32:28 2008
@@ -135,6 +135,14 @@
llvm_atomic_cmp_swap_i64 = (uint64 (*)(uint64*, uint64, uint64))
(uintptr_t)executionEngine->getPointerToFunction(
module->getFunction("runtime.llvm.atomic.cmp.swap.i64"));
+
+ executionEnvironment = module->getGlobalVariable("executionEnvironment");
+ getExecutionEnvironment = (mvm::Thread* (*)())
+ (uintptr_t)executionEngine->getPointerToFunction(
+ module->getFunction("getExecutionEnvironment"));
+ setExecutionEnvironment = (void (*)(mvm::Thread*))
+ (uintptr_t)executionEngine->getPointerToFunction(
+ module->getFunction("setExecutionEnvironment"));
// Type declaration
ptrType = PointerType::getUnqual(Type::Int8Ty);
@@ -300,6 +308,10 @@
uint64 val);
+llvm::GlobalVariable* mvm::jit::executionEnvironment;
+mvm::Thread* (*mvm::jit::getExecutionEnvironment)();
+void (*mvm::jit::setExecutionEnvironment)(mvm::Thread*);
+
uint64 mvm::jit::getTypeSize(const llvm::Type* type) {
return executionEngine->getTargetData()->getABITypeSize(type);
}
Modified: vmkit/trunk/lib/Mvm/Runtime/LLVMRuntime.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Runtime/LLVMRuntime.ll?rev=57172&r1=57171&r2=57172&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Runtime/LLVMRuntime.ll (original)
+++ vmkit/trunk/lib/Mvm/Runtime/LLVMRuntime.ll Mon Oct 6 10:32:28 2008
@@ -1,4 +1,11 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Common types ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;; A virtual table is an array of function pointers.
+%VT = type i32**
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Printing functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -93,3 +100,21 @@
%A = call i64 @llvm.atomic.cmp.swap.i64.p0i64( i64* %ptr, i64 %cmp, i64 %swap)
ret i64 %A
}
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;; TLS for the execution environment ;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+%Thread = type {%VT*, i32}
+
+ at executionEnvironment = thread_local global %Thread* null
+
+define %Thread* @getExecutionEnvironment() nounwind readnone {
+ %E = load %Thread** @executionEnvironment
+ ret %Thread* %E
+}
+
+define void @setExecutionEnvironment(%Thread* %E) nounwind {
+ store %Thread* %E, %Thread** @executionEnvironment
+ ret void
+}
More information about the vmkit-commits
mailing list