[vmkit-commits] [vmkit] r59364 - in /vmkit/trunk: include/mvm/Threads/Thread.h lib/JnJVM/VMCore/JavaJIT.cpp lib/Mvm/CommonThread/ctthread.cpp lib/Mvm/GCMmap2/gcthread.h
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Sat Nov 15 08:08:15 PST 2008
Author: geoffray
Date: Sat Nov 15 10:08:15 2008
New Revision: 59364
URL: http://llvm.org/viewvc/llvm-project?rev=59364&view=rev
Log:
Better support for ISOLATE and SERVICE.
Modified:
vmkit/trunk/include/mvm/Threads/Thread.h
vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp
vmkit/trunk/lib/Mvm/GCMmap2/gcthread.h
Modified: vmkit/trunk/include/mvm/Threads/Thread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Threads/Thread.h?rev=59364&r1=59363&r2=59364&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/Threads/Thread.h (original)
+++ vmkit/trunk/include/mvm/Threads/Thread.h Sat Nov 15 10:08:15 2008
@@ -53,26 +53,10 @@
};
-#ifdef ISOLATE
-/// ThreadIsolate - Threads implement this class in an isolate environment
-/// so that the ID can be loaded easely in LLVM compiled code.
-class ThreadIsolate {
-public:
-
- /// IsolateID - The IsolateID of the virtual machine, put here for fast
- /// access.
- uint32 IsolateID;
-};
-#endif
-
/// Thread - This class is the base of custom virtual machines' Thread classes.
/// It provides static functions to manage threads. An instance of this class
/// contains all thread-specific informations.
-class Thread :
-#ifdef ISOLATE
- public ThreadIsolate,
-#endif
- public CircularBase {
+class Thread : public CircularBase {
public:
/// yield - Yield the processor to another thread.
@@ -105,7 +89,13 @@
}
public:
-
+
+#ifdef ISOLATE
+ /// IsolateID - The Isolate ID of the thread's VM.
+ uint32 IsolateID;
+#endif
+
+ /// MyVM - The VM attached to this Thread.
VirtualMachine* MyVM;
/// baseSP - The base stack pointer.
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=59364&r1=59363&r2=59364&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Sat Nov 15 10:08:15 2008
@@ -198,44 +198,6 @@
endBlock = createBasicBlock("end block");
returnType = funcType->getReturnType();
-#if defined(ISOLATE_SHARING)
- Value* lastArg = 0;
- for (Function::arg_iterator i = func->arg_begin(), e = func->arg_end();
- i != e; ++i) {
- lastArg = i;
- }
-#if !defined(SERVICE_VM)
- ctpCache = lastArg;
- lastArg--;
- isolateLocal = lastArg;
-#else
- ctpCache = lastArg;
- lastArg--;
- if (compilingClass->isolate == Jnjvm::bootstrapVM) {
- isolateLocal = lastArg;
- } else {
- JavaObject* loader = compilingClass->classLoader;
- ServiceDomain* vm = ServiceDomain::getDomainFromLoader(loader);
- LLVMServiceInfo* LSI = module->getServiceInfo(vm);
- isolateLocal = LSI->getDelegatee(this);
- Value* cmp = new ICmpInst(ICmpInst::ICMP_NE, lastArg,
- isolateLocal, "", currentBlock);
- BasicBlock* ifTrue = createBasicBlock("true service call");
- BasicBlock* endBlock = createBasicBlock("end check service call");
- BranchInst::Create(ifTrue, endBlock, cmp, currentBlock);
- currentBlock = ifTrue;
- std::vector<Value*> Args;
- Args.push_back(lastArg);
- Args.push_back(isolateLocal);
- CallInst::Create(module->ServiceCallStartFunction, Args.begin(),
- Args.end(), "", currentBlock);
- BranchInst::Create(endBlock, currentBlock);
- currentBlock = endBlock;
- }
-#endif
-#endif
-
-
Value* buf = llvm::CallInst::Create(module->GetSJLJBufferFunction,
"", currentBlock);
Value* test = llvm::CallInst::Create(module->setjmpLLVM, buf, "",
@@ -546,36 +508,6 @@
}
}
-#if defined(ISOLATE_SHARING)
-#if !defined(SERVICE_VM)
- isolateLocal = args[args.size() - 2];
- ctpCache = args[args.size() - 1];
-#else
- ctpCache = args[args.size() - 1];
- if (compilingClass->isolate == Jnjvm::bootstrapVM) {
- isolateLocal = args[args.size() - 2];
- } else {
- JavaObject* loader = compilingClass->classLoader;
- ServiceDomain* vm = ServiceDomain::getDomainFromLoader(loader);
- LLVMServiceInfo* LSI = module->getServiceInfo(vm);
- isolateLocal = LSI->getDelegatee(this);
- Value* cmp = new ICmpInst(ICmpInst::ICMP_NE, args[args.size() - 1],
- isolateLocal, "", currentBlock);
- BasicBlock* ifTrue = createBasicBlock("true service call");
- BasicBlock* endBlock = createBasicBlock("end check service call");
- BranchInst::Create(ifTrue, endBlock, cmp, currentBlock);
- currentBlock = ifTrue;
- std::vector<Value*> Args;
- Args.push_back(args[args.size()- 2]);
- Args.push_back(isolateLocal);
- CallInst::Create(module->ServiceCallStartFunction, Args.begin(),
- Args.end(), "", currentBlock);
- BranchInst::Create(endBlock, currentBlock);
- currentBlock = endBlock;
- }
-#endif
-#endif
-
exploreOpcodes(&compilingClass->bytes->elements[start], codeLen);
nbEnveloppes = 0;
@@ -588,25 +520,6 @@
PRINT_DEBUG(JNJVM_COMPILE, 1, COLOR_NORMAL, "--> end inline compiling %s\n",
compilingMethod->printString());
-#if defined(SERVICE_VM)
- if (compilingClass->isolate != Jnjvm::bootstrapVM) {
- Value* cmp = new ICmpInst(ICmpInst::ICMP_NE, args[args.size() - 1],
- isolateLocal, "", currentBlock);
- BasicBlock* ifTrue = createBasicBlock("true service call");
- BasicBlock* newEndBlock = createBasicBlock("end check service call");
- BranchInst::Create(ifTrue, newEndBlock, cmp, currentBlock);
- currentBlock = ifTrue;
- std::vector<Value*> Args;
- Args.push_back(args[args.size() - 1]);
- Args.push_back(isolateLocal);
- CallInst::Create(module->ServiceCallStopFunction, Args.begin(),
- Args.end(), "", currentBlock);
- BranchInst::Create(newEndBlock, currentBlock);
- currentBlock = newEndBlock;
- endBlock = currentBlock;
- }
-#endif
-
curBB = endBlock;
return endNode;
@@ -717,41 +630,45 @@
}
#if defined(ISOLATE_SHARING)
-#if !defined(SERVICE_VM)
- isolateLocal = i;
- i++;
- ctpCache = i;
-#else
- if (compilingClass->isolate == Jnjvm::bootstrapVM) {
- isolateLocal = i;
- } else {
- JavaObject* loader = compilingClass->classLoader;
- ServiceDomain* vm = ServiceDomain::getDomainFromLoader(loader);
- LLVMServiceInfo* LSI = module->getServiceInfo(vm);
- isolateLocal = LSI->getDelegatee(this);
- Value* cmp = new ICmpInst(ICmpInst::ICMP_NE, i, isolateLocal, "",
- currentBlock);
- BasicBlock* ifTrue = createBasicBlock("true service call");
- BasicBlock* endBlock = createBasicBlock("end check service call");
- BranchInst::Create(ifTrue, endBlock, cmp, currentBlock);
- currentBlock = ifTrue;
- std::vector<Value*> Args;
- Args.push_back(i);
- Args.push_back(isolateLocal);
- CallInst::Create(module->ServiceCallStartFunction, Args.begin(),
- Args.end(), "", currentBlock);
- BranchInst::Create(endBlock, currentBlock);
- currentBlock = endBlock;
- }
- i++;
ctpCache = i;
-#endif
Value* addrCtpCache = new AllocaInst(module->ConstantPoolType, "",
currentBlock);
/// make it volatile to be sure it's on the stack
new StoreInst(ctpCache, addrCtpCache, true, currentBlock);
#endif
+
+
+#if defined(SERVICE)
+ JnjvmClassLoader* loader = compilingClass->classLoader;
+ Value* cmp = 0;
+ if (loader != loader->bootstrapLoader && isPublic(compilingMethod->access)) {
+ Value* threadId = CallInst::Create(module->llvm_frameaddress,
+ module->constantZero, "", currentBlock);
+ threadId = new PtrToIntInst(threadId, module->pointerSizeType, "",
+ currentBlock);
+ threadId = BinaryOperator::CreateAnd(threadId, module->constantThreadIDMask,
+ "", currentBlock);
+ threadId = new IntToPtrInst(threadId, module->ptr32Type, "", currentBlock);
+
+ GEP.clear();
+ GEP.push_back(module->constantThree);
+ Value* IsolateID = GetElementPtrInst::Create(threadId, GEP.begin(),
+ GEP.end(), "", currentBlock);
+ IsolateID = new LoadInst(IsolateID, "", currentBlock);
+
+ Value* MyID = ConstantInt::get(Type::Int32Ty, loader->isolate->IsolateID);
+ Cmp = new ICmpInst(ICmpInst::ICMP_EQ, IsolateID, MyID, "", currentBlock);
+
+ BasicBlock* EndBB = createBasicBlock("After service check");
+ BasicBlock* ServiceBB = createBasicBlock("Service call");
+
+ BranchInst::Create(EndBB, ServiceBB, Cmp, currentBlock);
+
+ currentBlock = ServiceBB;
+ }
+#endif
+
unsigned nbe = readExceptionTable(reader);
exploreOpcodes(&compilingClass->bytes->elements[start], codeLen);
Modified: vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp?rev=59364&r1=59363&r2=59364&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp (original)
+++ vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp Sat Nov 15 10:08:15 2008
@@ -7,11 +7,12 @@
//
//===----------------------------------------------------------------------===//
+#include "mvm/VirtualMachine.h"
#include "mvm/Threads/Thread.h"
+#include <csignal>
+#include <ctime>
#include <pthread.h>
-#include <signal.h>
-#include <time.h>
#include <sys/mman.h>
using namespace mvm;
@@ -133,7 +134,7 @@
void Thread::internalThreadStart(mvm::Thread* th) {
th->baseSP = (void*)&th;
#ifdef ISOLATE
- th->IsolateID = th->vm->IsolateID;
+ th->IsolateID = th->MyVM->IsolateID;
#endif
Collector::inject_my_thread(th);
th->routine(th);
Modified: vmkit/trunk/lib/Mvm/GCMmap2/gcthread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gcthread.h?rev=59364&r1=59363&r2=59364&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gcthread.h (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gcthread.h Sat Nov 15 10:08:15 2008
@@ -115,7 +115,7 @@
_nb_threads--;
if (!_nb_threads) base = 0;
#ifdef SERVICE
- th->theVM->numThreads--;
+ th->MyVM->numThreads--;
#endif
unlock();
}
@@ -128,7 +128,7 @@
base = th;
_nb_threads++;
#ifdef SERVICE
- th->theVM->numThreads++;
+ th->MyVM->numThreads++;
#endif
unlock();
}
More information about the vmkit-commits
mailing list