[llvm-commits] [vmkit] r50415 - in /vmkit/trunk/lib/JnJVM/VMCore: JavaIsolate.cpp JavaJIT.cpp JavaJIT.h JavaJITInitialise.cpp JavaJITOpcodes.cpp JavaObject.cpp JavaRuntimeJIT.cpp ServiceDomain.cpp ServiceDomain.h
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Tue Apr 29 02:51:47 PDT 2008
Author: geoffray
Date: Tue Apr 29 04:51:46 2008
New Revision: 50415
URL: http://llvm.org/viewvc/llvm-project?rev=50415&view=rev
Log:
In a service environments, locking and unlocking Java objects
is allowed when:
- the object has been allocated by the current domain
- or the method doing the lock is the shared domain, or the
framework domain (appClassLoader).
Modified:
vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h
vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp
vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp
vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp?rev=50415&r1=50414&r2=50415&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp Tue Apr 29 04:51:46 2008
@@ -385,6 +385,7 @@
loadBootstrap();
#ifdef SERVICE_VM
(*Classpath::vmdataClassLoader)(appClassLoader, (JavaObject*)this);
+ Jnjvm::bootstrapVM->appClassLoader = appClassLoader;
#endif
if (info.agents.size()) {
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=50415&r1=50414&r2=50415&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Tue Apr 29 04:51:46 2008
@@ -340,6 +340,12 @@
Value* arg = compilingClass->staticVar(this);
argsSync.push_back(arg);
}
+#ifdef SERVICE_VM
+ if (ServiceDomain::isLockableDomain(compilingClass->isolate))
+ llvm::CallInst::Create(aquireObjectInSharedDomainLLVM, argsSync.begin(),
+ argsSync.end(), "", currentBlock);
+ else
+#endif
llvm::CallInst::Create(aquireObjectLLVM, argsSync.begin(), argsSync.end(),
"", currentBlock);
}
@@ -352,6 +358,12 @@
Value* arg = compilingClass->staticVar(this);
argsSync.push_back(arg);
}
+#ifdef SERVICE_VM
+ if (ServiceDomain::isLockableDomain(compilingClass->isolate))
+ llvm::CallInst::Create(releaseObjectInSharedDomainLLVM, argsSync.begin(),
+ argsSync.end(), "", currentBlock);
+ else
+#endif
llvm::CallInst::Create(releaseObjectLLVM, argsSync.begin(), argsSync.end(), "",
currentBlock);
}
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h?rev=50415&r1=50414&r2=50415&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h Tue Apr 29 04:51:46 2008
@@ -261,6 +261,10 @@
static llvm::Function* instanceOfLLVM;
static llvm::Function* aquireObjectLLVM;
static llvm::Function* releaseObjectLLVM;
+#ifdef SERVICE_VM
+ static llvm::Function* aquireObjectInSharedDomainLLVM;
+ static llvm::Function* releaseObjectInSharedDomainLLVM;
+#endif
static llvm::Function* multiCallNewLLVM;
static llvm::Function* runtimeUTF8ToStrLLVM;
static llvm::Function* getStaticInstanceLLVM;
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp?rev=50415&r1=50414&r2=50415&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp Tue Apr 29 04:51:46 2008
@@ -546,6 +546,11 @@
aquireObjectLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
"_ZN5jnjvm10JavaObject6aquireEv",
module);
+#ifdef SERVICE_VM
+ aquireObjectInSharedDomainLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
+ "aquireObjectInSharedDomain",
+ module);
+#endif
}
// Create releaseObjectLLVM
@@ -557,6 +562,11 @@
releaseObjectLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
"_ZN5jnjvm10JavaObject6unlockEv",
module);
+#ifdef SERVICE_VM
+ releaseObjectInSharedDomainLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
+ "releaseObjectInSharedDomain",
+ module);
+#endif
}
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp?rev=50415&r1=50414&r2=50415&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Tue Apr 29 04:51:46 2008
@@ -36,9 +36,9 @@
#include "OpcodeNames.def"
-#include <iostream>
-
-
+#ifdef SERVICE_VM
+#include "ServiceDomain.h"
+#endif
using namespace jnjvm;
using namespace llvm;
@@ -1893,12 +1893,22 @@
case MONITORENTER : {
Value* obj = pop();
+#ifdef SERVICE_VM
+ if (ServiceDomain::isLockableDomain(compilingClass->isolate))
+ invoke(aquireObjectInSharedDomainLLVM, obj, "", currentBlock);
+ else
+#endif
invoke(aquireObjectLLVM, obj, "", currentBlock);
break;
}
case MONITOREXIT : {
Value* obj = pop();
+#ifdef SERVICE_VM
+ if (ServiceDomain::isLockableDomain(compilingClass->isolate))
+ invoke(releaseObjectInSharedDomainLLVM, obj, "", currentBlock);
+ else
+#endif
invoke(releaseObjectLLVM, obj, "", currentBlock);
break;
}
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp?rev=50415&r1=50414&r2=50415&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp Tue Apr 29 04:51:46 2008
@@ -16,6 +16,10 @@
#include "JavaThread.h"
#include "Jnjvm.h"
+#ifdef SERVICE_VM
+#include "ServiceDomain.h"
+#endif
+
using namespace jnjvm;
mvm::Lock* JavaObject::globalLock = 0;
@@ -113,14 +117,38 @@
}
void JavaObject::aquire() {
+#ifdef SERVICE_VM
+ ServiceDomain* vm = (ServiceDomain*)JavaThread::get()->isolate;
+ if (!(vm->GC->isMyObject(this))) {
+ vm->serviceError("I'm locking an object I don't own");
+ }
+#endif
myLock(this)->aquire();
}
+
void JavaObject::unlock() {
verifyNull(this);
+#ifdef SERVICE_VM
+ ServiceDomain* vm = (ServiceDomain*)JavaThread::get()->isolate;
+ if (!(vm->GC->isMyObject(this))) {
+ vm->serviceError("I'm unlocking an object I don't own");
+ }
+#endif
lockObj->release();
}
+#ifdef SERVICE_VM
+extern "C" void aquireObjectInSharedDomain(JavaObject* obj) {
+ myLock(obj)->aquire();
+}
+
+extern "C" void releaseObjectInSharedDomain(JavaObject* obj) {
+ verifyNull(obj);
+ obj->lockObj->release();
+}
+#endif
+
void JavaObject::waitIntern(struct timeval* info, bool timed) {
LockObj * l = myLock(this);
bool owner = l->owner();
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp?rev=50415&r1=50414&r2=50415&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp Tue Apr 29 04:51:46 2008
@@ -72,6 +72,11 @@
llvm::Function* JavaJIT::getClassDelegateeLLVM = 0;
llvm::Function* JavaJIT::arrayLengthLLVM = 0;
+#ifdef SERVICE_VM
+llvm::Function* JavaJIT::aquireObjectInSharedDomainLLVM = 0;
+llvm::Function* JavaJIT::releaseObjectInSharedDomainLLVM = 0;
+#endif
+
extern "C" JavaString* runtimeUTF8ToStr(const UTF8* val) {
Jnjvm* vm = JavaThread::get()->isolate;
return vm->UTF8ToStr(val);
Modified: vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp?rev=50415&r1=50414&r2=50415&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp Tue Apr 29 04:51:46 2008
@@ -70,6 +70,7 @@
service->GC = Collector::allocate();
#endif
+
service->classpath = callingVM->classpath;
service->bootClasspathEnv = callingVM->bootClasspathEnv;
service->libClasspathEnv = callingVM->libClasspathEnv;
@@ -81,6 +82,7 @@
service->TheModuleProvider = new JnjvmModuleProvider(service->module,
service->functions,
service->functionDefs);
+
#ifdef MULTIPLE_GC
mvm::jit::memoryManager->addGCForModule(service->module, service->GC);
@@ -111,8 +113,6 @@
service->classes = vm_new(service, ClassMap)();
service->executionTime = 0;
- service->memoryUsed = 0;
- service->gcTriggered = 0;
service->numThreads = 0;
service->lock = mvm::Lock::allocNormal();
@@ -121,6 +121,7 @@
void ServiceDomain::serviceError(const char* str) {
fprintf(stderr, str);
+ JavaJIT::printBacktrace();
abort();
}
Modified: vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h?rev=50415&r1=50414&r2=50415&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h Tue Apr 29 04:51:46 2008
@@ -46,14 +46,17 @@
mvm::Lock* lock;
ClassMap* classes;
uint64 executionTime;
- uint64 memoryUsed;
- uint64 gcTriggered;
uint64 numThreads;
std::map<ServiceDomain*, uint64> interactions;
static ServiceDomain* getDomainFromLoader(JavaObject* loader);
static llvm::Function* serviceCallStartLLVM;
static llvm::Function* serviceCallStopLLVM;
+
+ static bool isLockableDomain(Jnjvm* vm) {
+ return (vm == Jnjvm::bootstrapVM ||
+ vm == getDomainFromLoader(Jnjvm::bootstrapVM->appClassLoader));
+ }
};
} // end namespace jnjvm
More information about the llvm-commits
mailing list