[vmkit-commits] [vmkit] r83956 - in /vmkit/trunk: include/jnjvm/JnjvmModule.h lib/JnJVM/Compiler/ExceptionsCheck.inc lib/JnJVM/Compiler/ExceptionsDwarf.inc lib/JnJVM/Compiler/JavaJIT.cpp lib/JnJVM/Compiler/JavaJIT.h lib/JnJVM/Compiler/JnjvmModule.cpp lib/JnJVM/LLVMRuntime/Makefile lib/JnJVM/LLVMRuntime/runtime-default-thread.ll lib/JnJVM/LLVMRuntime/runtime-default.ll lib/JnJVM/LLVMRuntime/runtime-mmtk-thread.ll

Nicolas Geoffray nicolas.geoffray at lip6.fr
Tue Oct 13 00:11:08 PDT 2009


Author: geoffray
Date: Tue Oct 13 02:11:07 2009
New Revision: 83956

URL: http://llvm.org/viewvc/llvm-project?rev=83956&view=rev
Log:
The Thread layout is different whether we are building with MMTk
or not.


Added:
    vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default-thread.ll
    vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-mmtk-thread.ll
Modified:
    vmkit/trunk/include/jnjvm/JnjvmModule.h
    vmkit/trunk/lib/JnJVM/Compiler/ExceptionsCheck.inc
    vmkit/trunk/lib/JnJVM/Compiler/ExceptionsDwarf.inc
    vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp
    vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.h
    vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp
    vmkit/trunk/lib/JnJVM/LLVMRuntime/Makefile
    vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll

Modified: vmkit/trunk/include/jnjvm/JnjvmModule.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/jnjvm/JnjvmModule.h?rev=83956&r1=83955&r2=83956&view=diff

==============================================================================
--- vmkit/trunk/include/jnjvm/JnjvmModule.h (original)
+++ vmkit/trunk/include/jnjvm/JnjvmModule.h Tue Oct 13 02:11:07 2009
@@ -239,6 +239,7 @@
   static const llvm::Type* JavaFieldType;
   static const llvm::Type* AttributType;
   static const llvm::Type* JavaThreadType;
+  static const llvm::Type* MutatorThreadType;
   
 #ifdef ISOLATE_SHARING
   static const llvm::Type* JnjvmType;

Modified: vmkit/trunk/lib/JnJVM/Compiler/ExceptionsCheck.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/ExceptionsCheck.inc?rev=83956&r1=83955&r2=83956&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/ExceptionsCheck.inc (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/ExceptionsCheck.inc Tue Oct 13 02:11:07 2009
@@ -6,7 +6,7 @@
                                       InsertAtEnd);
   
   if (TheCompiler->hasExceptionsEnabled()) {
-    Value* threadId = getCurrentThread();
+    Value* threadId = getCurrentThread(module->JavaThreadType);
     Value* geps[2] = { module->constantZero,
                        module->OffsetJavaExceptionInThreadConstant };
 
@@ -63,7 +63,7 @@
   Instruction* res = CallInst::Create(F, arg1, Name, InsertAtEnd);
   
   if (TheCompiler->hasExceptionsEnabled()) {
-    Value* threadId = getCurrentThread();
+    Value* threadId = getCurrentThread(module->JavaThreadType);
     Value* geps[2] = { module->constantZero,
                        module->OffsetJavaExceptionInThreadConstant };
 
@@ -114,7 +114,7 @@
   Instruction* res = CallInst::Create(F, args, args + 2, Name, InsertAtEnd);
   
   if (TheCompiler->hasExceptionsEnabled()) {
-    Value* threadId = getCurrentThread();
+    Value* threadId = getCurrentThread(module->JavaThreadType);
     Value* geps[2] = { module->constantZero,
                        module->OffsetJavaExceptionInThreadConstant };
 
@@ -162,7 +162,7 @@
   Instruction* res = llvm::CallInst::Create(F, Name, InsertAtEnd);
   
   if (TheCompiler->hasExceptionsEnabled()) {
-    Value* threadId = getCurrentThread();
+    Value* threadId = getCurrentThread(module->JavaThreadType);
     Value* geps[2] = { module->constantZero,
                        module->OffsetJavaExceptionInThreadConstant };
 
@@ -222,7 +222,7 @@
 }
 
 void JavaJIT::throwException(Value* obj) {
-  Value* threadId = getCurrentThread();
+  Value* threadId = getCurrentThread(module->JavaThreadType);
   Value* geps[2] = { module->constantZero,
                      module->OffsetJavaExceptionInThreadConstant };
 
@@ -400,7 +400,7 @@
     // catch the exception but resume unwinding.
     JnjvmClassLoader* loader = compilingClass->classLoader;;
     if (loader != loader->bootstrapLoader) {
-      Value* threadId = getCurrentThread();
+      Value* threadId = getCurrentThread(module->MutatorThreadType);
       Value* Isolate = GetElementPtrInst::Create(threadId,
                                                  module->constantFour, "",
                                                  currentBlock);
@@ -475,7 +475,7 @@
     // First thing in the handler: clear the exception.
     Value* geps[2] = { module->constantZero,
                        module->OffsetJavaExceptionInThreadConstant };
-    Value* threadId = getCurrentThread();
+    Value* threadId = getCurrentThread(module->JavaThreadType);
     Value* javaExceptionPtr = GetElementPtrInst::Create(threadId, geps,
                                                         geps + 2, "",
                                                         currentBlock);
@@ -496,7 +496,7 @@
     Value* IsolatePtr = 0;
     currentBlock = cur->javaHandler;
     if (loader != loader->bootstrapLoader) {
-      threadId = getCurrentThread();
+      threadId = getCurrentThread(module->MutatorThreadType);
      
       IsolateIDPtr = GetElementPtrInst::Create(threadId, module->constantThree,
                                                "", cur->javaHandler);

Modified: vmkit/trunk/lib/JnJVM/Compiler/ExceptionsDwarf.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/ExceptionsDwarf.inc?rev=83956&r1=83955&r2=83956&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/ExceptionsDwarf.inc (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/ExceptionsDwarf.inc Tue Oct 13 02:11:07 2009
@@ -388,7 +388,7 @@
     // catch the exception but resume unwinding.
     JnjvmClassLoader* loader = compilingClass->classLoader;;
     if (loader != loader->bootstrapLoader) {
-      Value* threadId = getCurrentThread();
+      Value* threadId = getCurrentThread(module->MutatorThreadType);
       Value* Isolate = GetElementPtrInst::Create(threadId,
                                                  module->constantFour, "",
                                                  currentBlock);
@@ -413,7 +413,7 @@
     }
 #endif
    
-    Value* threadId = getCurrentThread();
+    Value* threadId = getCurrentThread(module->JavaThreadType);
     Value* geps[2] = { module->constantZero,
                        module->OffsetJavaExceptionInThreadConstant };
 
@@ -465,7 +465,7 @@
     
     currentBlock = cur->nativeHandler;
  
-    threadId = getCurrentThread();
+    threadId = getCurrentThread(module->JavaThreadType);
     javaExceptionPtr = GetElementPtrInst::Create(threadId, geps, geps + 2, "",
                                                  currentBlock);
     
@@ -521,7 +521,7 @@
     Value* IsolatePtr = 0;
     currentBlock = cur->javaHandler;
     if (loader != loader->bootstrapLoader) {
-      threadId = getCurrentThread();
+      threadId = getCurrentThread(module->MutatorThreadType);
      
       IsolateIDPtr = GetElementPtrInst::Create(threadId, module->constantThree,
                                                "", cur->javaHandler);
@@ -558,7 +558,7 @@
   if (PI == PE) {
     endExceptionBlock->eraseFromParent();
   } else {
-    Value* threadId = getCurrentThread();
+    Value* threadId = getCurrentThread(module->JavaThreadType);
     Value* geps2[2] = { module->constantZero,
                         module->OffsetCXXExceptionInThreadConstant };
     

Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp?rev=83956&r1=83955&r2=83956&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp Tue Oct 13 02:11:07 2009
@@ -209,15 +209,14 @@
 #endif
 }
 
-llvm::Value* JavaJIT::getCurrentThread() {
+llvm::Value* JavaJIT::getCurrentThread(const llvm::Type* Ty) {
   Value* FrameAddr = CallInst::Create(module->llvm_frameaddress,
                                      	module->constantZero, "", currentBlock);
   Value* threadId = new PtrToIntInst(FrameAddr, module->pointerSizeType, "",
                               			 currentBlock);
   threadId = BinaryOperator::CreateAnd(threadId, module->constantThreadIDMask,
                                        "", currentBlock);
-  threadId = new IntToPtrInst(threadId, module->JavaThreadType, "",
-                              currentBlock);
+  threadId = new IntToPtrInst(threadId, Ty, "", currentBlock);
 
   return threadId;
 }
@@ -315,9 +314,10 @@
   std::vector<Value*> nativeArgs;
   
   
-  Value* threadId = getCurrentThread();
+  Value* threadId = getCurrentThread(module->JavaThreadType);
 
-  Value* geps[2] = { module->constantZero, module->OffsetJNIInThreadConstant };
+  Value* geps[2] = { module->constantZero,
+                     module->OffsetJNIInThreadConstant };
 
   Value* jniEnv = GetElementPtrInst::Create(threadId, geps, geps + 2, "",
                                             currentBlock);
@@ -499,7 +499,7 @@
   lockPtr = new BitCastInst(lockPtr, 
                             PointerType::getUnqual(module->pointerSizeType),
                             "", currentBlock);
-  Value* threadId = getCurrentThread();
+  Value* threadId = getCurrentThread(module->MutatorThreadType);
   threadId = new PtrToIntInst(threadId, module->pointerSizeType, "",
                               currentBlock);
 
@@ -589,7 +589,7 @@
                             "", currentBlock);
   Value* lock = new LoadInst(lockPtr, "", currentBlock);
   
-  Value* threadId = getCurrentThread();
+  Value* threadId = getCurrentThread(module->MutatorThreadType);
   threadId = new PtrToIntInst(threadId, module->pointerSizeType, "",
                               currentBlock);
   
@@ -1036,7 +1036,7 @@
   Value* NewIsolate = 0;
   Value* IsolatePtr = 0;
   if (loader != loader->bootstrapLoader && isPublic(compilingMethod->access)) {
-    threadId = getCurrentThread();
+    threadId = getCurrentThread(module->MutatorThreadType);
      
     IsolateIDPtr = GetElementPtrInst::Create(threadId, module->constantThree,
                                              "", currentBlock);
@@ -1117,7 +1117,7 @@
   }
   
   if (TheCompiler->useCooperativeGC()) {
-    Value* threadId = getCurrentThread();
+    Value* threadId = getCurrentThread(module->MutatorThreadType);
     
     Value* GEP[2] = { module->constantZero, 
                       module->OffsetDoYieldInThreadConstant };

Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.h?rev=83956&r1=83955&r2=83956&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.h (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.h Tue Oct 13 02:11:07 2009
@@ -126,7 +126,7 @@
                     llvm::BasicBlock* currentBlock, bool usign);
  
   /// getCurrentThread - Emit code to get the current thread.
-  llvm::Value* getCurrentThread();
+  llvm::Value* getCurrentThread(const llvm::Type* Ty);
 
 //===--------------------------- Inline support ---------------------------===//
 

Modified: vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp?rev=83956&r1=83955&r2=83956&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp Tue Oct 13 02:11:07 2009
@@ -50,6 +50,7 @@
 const llvm::Type* JnjvmModule::JavaMethodType = 0;
 const llvm::Type* JnjvmModule::AttributType = 0;
 const llvm::Type* JnjvmModule::JavaThreadType = 0;
+const llvm::Type* JnjvmModule::MutatorThreadType = 0;
 
 #ifdef ISOLATE_SHARING
 const llvm::Type* JnjvmModule::JnjvmType = 0;
@@ -161,6 +162,8 @@
     PointerType::getUnqual(module->getTypeByName("Attribut"));
   JavaThreadType =
     PointerType::getUnqual(module->getTypeByName("JavaThread"));
+  MutatorThreadType =
+    PointerType::getUnqual(module->getTypeByName("MutatorThread"));
  
   LLVMAssessorInfo::initialise();
 }
@@ -208,11 +211,11 @@
   OffsetDoYieldInThreadConstant =
     ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 6);
   OffsetJNIInThreadConstant =
-    ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 13);
+    ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 1);
   OffsetJavaExceptionInThreadConstant =
-    ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 14);
+    ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 2);
   OffsetCXXExceptionInThreadConstant =
-    ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 15);
+    ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 3);
   
   ClassReadyConstant =
     ConstantInt::get(Type::getInt8Ty(getGlobalContext()), ready);

Modified: vmkit/trunk/lib/JnJVM/LLVMRuntime/Makefile
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/LLVMRuntime/Makefile?rev=83956&r1=83955&r2=83956&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/LLVMRuntime/Makefile (original)
+++ vmkit/trunk/lib/JnJVM/LLVMRuntime/Makefile Tue Oct 13 02:11:07 2009
@@ -12,6 +12,12 @@
 
 VMKIT_RUNTIME = $(PROJ_SRC_DIR)/runtime-default.ll
 
+ifeq ($(GC_MMTK), 1)
+VMKIT_RUNTIME += $(PROJ_SRC_DIR)/runtime-mmtk-thread.ll
+else
+VMKIT_RUNTIME += $(PROJ_SRC_DIR)/runtime-default-thread.ll
+endif
+
 ifeq ($(ISOLATE_BUILD), 1)
 VMKIT_RUNTIME += $(PROJ_SRC_DIR)/runtime-isolate.ll
 endif

Added: vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default-thread.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default-thread.ll?rev=83956&view=auto

==============================================================================
--- vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default-thread.ll (added)
+++ vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default-thread.ll Tue Oct 13 02:11:07 2009
@@ -0,0 +1,17 @@
+%Vector = type {i32, i8*, i8*}
+
+;;; Field 0: the VT of threads
+;;; Field 1: next
+;;; Field 2: prev
+;;; Field 3: IsolateID
+;;; Field 4: MyVM
+;;; Field 5: baseSP
+;;; Field 6: doYield
+;;; Field 7: inGC
+;;; Field 8: stackScanned
+;;; Field 9: lastSP
+;;; Field 10: internalThreadID
+;;; field 11: routine
+;;; field 12: addresses
+%MutatorThread = type { %VT*, %JavaThread*, %JavaThread*, i8*, i8*, i8*, i1, i1,
+                        i1, i8*, i8*, i8*, %Vector}

Modified: vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll?rev=83956&r1=83955&r2=83956&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll (original)
+++ vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll Tue Oct 13 02:11:07 2009
@@ -34,26 +34,7 @@
 ;;; Field 3: The static instance
 %TaskClassMirror = type { i8, i1, i8* }
 
-%Vector = type {i32, i8*, i8*}
-
-;;; Field 0: the VT of threads
-;;; Field 1: next
-;;; Field 2: prev
-;;; Field 3: IsolateID
-;;; Field 4: MyVM
-;;; Field 5: baseSP
-;;; Field 6: doYield
-;;; Field 7: inGC
-;;; Field 8: stackScanned
-;;; Field 9: lastSP
-;;; Field 10: internalThreadID
-;;; field 11: routine
-;;; field 12: addresses
-;;; field 13: jnienv
-;;; field 14: Java pendingException
-;;; field 15: CXX pendingException
-%JavaThread = type { %VT*, %JavaThread*, %JavaThread*, i8*, i8*, i8*, i1, i1,
-                     i1, i8*, i8*, i8*, %Vector, i8*, %JavaObject*, i8* }
+%JavaThread = type { %MutatorThread, i8*, %JavaObject*, i8* }
 
 
 %Attribut = type { %UTF8*, i32, i32 }

Added: vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-mmtk-thread.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-mmtk-thread.ll?rev=83956&view=auto

==============================================================================
--- vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-mmtk-thread.ll (added)
+++ vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-mmtk-thread.ll Tue Oct 13 02:11:07 2009
@@ -0,0 +1,21 @@
+%Vector = type {i32, i8*, i8*}
+%BumpPtrAllocator = type { i32, i32, i8*, i8*, i8*, i8*, i32 }
+
+;;; Field 0: the VT of threads
+;;; Field 1: next
+;;; Field 2: prev
+;;; Field 3: IsolateID
+;;; Field 4: MyVM
+;;; Field 5: baseSP
+;;; Field 6: doYield
+;;; Field 7: inGC
+;;; Field 8: stackScanned
+;;; Field 9: lastSP
+;;; Field 10: internalThreadID
+;;; field 11: routine
+;;; field 12: addresses
+;;; field 13: allocator
+;;; field 14: MutatorContext
+;;; field 15: CollectorContext
+%MutatorThread = type { %VT*, %JavaThread*, %JavaThread*, i8*, i8*, i8*, i1, i1,
+                        i1, i8*, i8*, i8*, %Vector, %BumpPtrAllocator, i8*, i8* }





More information about the vmkit-commits mailing list