[vmkit-commits] [vmkit] r117242 - in /vmkit/branches/precise: include/mvm/JIT.h include/mvm/MethodInfo.h include/mvm/VirtualMachine.h lib/J3/Classpath/ClasspathVMThrowable.inc lib/J3/Compiler/JavaJITCompiler.cpp lib/J3/VMCore/JavaClass.cpp lib/J3/VMCore/JavaClass.h lib/J3/VMCore/JavaRuntimeJIT.cpp lib/J3/VMCore/JavaThread.cpp lib/J3/VMCore/Jnjvm.cpp lib/J3/VMCore/Jnjvm.h lib/J3/VMCore/JnjvmClassLoader.cpp lib/Mvm/Compiler/JIT.cpp lib/Mvm/Runtime/MethodInfo.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Sun Oct 24 10:51:11 PDT 2010
Author: geoffray
Date: Sun Oct 24 12:51:11 2010
New Revision: 117242
URL: http://llvm.org/viewvc/llvm-project?rev=117242&view=rev
Log:
Code cleanup on MethodInfo.
Modified:
vmkit/branches/precise/include/mvm/JIT.h
vmkit/branches/precise/include/mvm/MethodInfo.h
vmkit/branches/precise/include/mvm/VirtualMachine.h
vmkit/branches/precise/lib/J3/Classpath/ClasspathVMThrowable.inc
vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp
vmkit/branches/precise/lib/J3/VMCore/JavaClass.cpp
vmkit/branches/precise/lib/J3/VMCore/JavaClass.h
vmkit/branches/precise/lib/J3/VMCore/JavaRuntimeJIT.cpp
vmkit/branches/precise/lib/J3/VMCore/JavaThread.cpp
vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp
vmkit/branches/precise/lib/J3/VMCore/Jnjvm.h
vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp
vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp
vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp
Modified: vmkit/branches/precise/include/mvm/JIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/mvm/JIT.h?rev=117242&r1=117241&r2=117242&view=diff
==============================================================================
--- vmkit/branches/precise/include/mvm/JIT.h (original)
+++ vmkit/branches/precise/include/mvm/JIT.h Sun Oct 24 12:51:11 2010
@@ -214,10 +214,12 @@
class MvmJITMethodInfo : public JITMethodInfo {
public:
virtual void print(void* ip, void* addr);
- MvmJITMethodInfo(llvm::GCFunctionInfo* GFI, const llvm::Function* F) :
+ MvmJITMethodInfo(llvm::GCFunctionInfo* GFI,
+ const llvm::Function* F,
+ void* owner) :
JITMethodInfo(GFI) {
MetaInfo = const_cast<llvm::Function*>(F);
- MethodType = 0;
+ Owner = owner;
}
};
Modified: vmkit/branches/precise/include/mvm/MethodInfo.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/mvm/MethodInfo.h?rev=117242&r1=117241&r2=117242&view=diff
==============================================================================
--- vmkit/branches/precise/include/mvm/MethodInfo.h (original)
+++ vmkit/branches/precise/include/mvm/MethodInfo.h Sun Oct 24 12:51:11 2010
@@ -19,6 +19,9 @@
public:
virtual void print(void* ip, void* addr) = 0;
virtual void scan(uintptr_t closure, void* ip, void* addr) = 0;
+ virtual bool isHighLevelMethod() {
+ return false;
+ }
static void* isStub(void* ip, void* addr) {
bool isStub = ((unsigned char*)ip)[0] == 0xCE;
@@ -26,10 +29,8 @@
return ip;
}
- void* getMetaInfo() const { return MetaInfo; }
-
- unsigned MethodType;
void* MetaInfo;
+ void* Owner;
};
class CamlFrame {
@@ -44,7 +45,10 @@
public:
CamlFrame* CF;
virtual void scan(uintptr_t closure, void* ip, void* addr);
- CamlMethodInfo(CamlFrame* C) : CF(C) { }
+ CamlMethodInfo(CamlFrame* C) : CF(C) {
+ Owner = NULL;
+ MetaInfo = NULL;
+ }
};
class StaticCamlMethodInfo : public CamlMethodInfo {
@@ -53,8 +57,9 @@
virtual void print(void* ip, void* addr);
StaticCamlMethodInfo(CamlFrame* CF, const char* n) :
CamlMethodInfo(CF) {
+ Owner = NULL;
+ MetaInfo = NULL;
name = n;
- MethodType = 0;
}
};
@@ -65,7 +70,8 @@
static DefaultMethodInfo DM;
DefaultMethodInfo() {
- MethodType = -1;
+ Owner = NULL;
+ MetaInfo = NULL;
}
};
Modified: vmkit/branches/precise/include/mvm/VirtualMachine.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/mvm/VirtualMachine.h?rev=117242&r1=117241&r2=117242&view=diff
==============================================================================
--- vmkit/branches/precise/include/mvm/VirtualMachine.h (original)
+++ vmkit/branches/precise/include/mvm/VirtualMachine.h Sun Oct 24 12:51:11 2010
@@ -42,6 +42,9 @@
///
void addMethodInfo(MethodInfo* meth, void* ip);
+ /// removeMethodInfos - Remove all MethodInfo owned by the given owner.
+ void removeMethodInfos(void* owner);
+
FunctionMap();
};
@@ -171,6 +174,9 @@
MethodInfo* IPToMethodInfo(void* ip) {
return FunctionsCache.IPToMethodInfo(ip);
}
+ void removeMethodInfos(void* owner) {
+ FunctionsCache.removeMethodInfos(owner);
+ }
//===----------------------------------------------------------------------===//
// (4) Launch-related methods.
Modified: vmkit/branches/precise/lib/J3/Classpath/ClasspathVMThrowable.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Classpath/ClasspathVMThrowable.inc?rev=117242&r1=117241&r2=117242&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/Classpath/ClasspathVMThrowable.inc (original)
+++ vmkit/branches/precise/lib/J3/Classpath/ClasspathVMThrowable.inc Sun Oct 24 12:51:11 2010
@@ -144,9 +144,9 @@
sint32 index = 2;;
while (index != JavaArray::getSize(stack)) {
mvm::MethodInfo* MI = vm->IPToMethodInfo(ArrayPtr::getElement((ArrayPtr*)stack, index));
- if (MI->MethodType != 1) ++index;
+ if (!MI->isHighLevelMethod()) ++index;
else {
- JavaMethod* meth = (JavaMethod*)MI->getMetaInfo();
+ JavaMethod* meth = (JavaMethod*)MI->MetaInfo;
assert(meth && "Wrong stack trace");
if (meth->classDef->isAssignableFrom(vm->upcalls->newThrowable)) {
++index;
@@ -159,7 +159,7 @@
while (cur < JavaArray::getSize(stack)) {
mvm::MethodInfo* MI = vm->IPToMethodInfo(ArrayPtr::getElement((ArrayPtr*)stack, cur));
++cur;
- if (MI->MethodType == 1) ++size;
+ if (MI->isHighLevelMethod()) ++size;
}
result = (ArrayObject*)
@@ -168,8 +168,8 @@
cur = 0;
for (sint32 i = index; i < JavaArray::getSize(stack); ++i) {
mvm::MethodInfo* MI = vm->IPToMethodInfo(ArrayPtr::getElement((ArrayPtr*)stack, i));
- if (MI->MethodType == 1) {
- JavaMethod* meth = (JavaMethod*)MI->getMetaInfo();
+ if (MI->isHighLevelMethod()) {
+ JavaMethod* meth = (JavaMethod*)MI->MetaInfo;
ArrayObject::setElement(result, consStackElement(meth, ArrayPtr::getElement((ArrayPtr*)stack, i)), cur);
cur++;
}
Modified: vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp?rev=117242&r1=117241&r2=117242&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp (original)
+++ vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp Sun Oct 24 12:51:11 2010
@@ -40,15 +40,18 @@
using namespace j3;
using namespace llvm;
-
class JavaJITMethodInfo : public mvm::JITMethodInfo {
public:
virtual void print(void* ip, void* addr);
+ virtual bool isHighLevelMethod() {
+ return true;
+ }
- JavaJITMethodInfo(llvm::GCFunctionInfo* GFI, JavaMethod* m) :
- mvm::JITMethodInfo(GFI) {
+ JavaJITMethodInfo(llvm::GCFunctionInfo* GFI,
+ JavaMethod* m) :
+ mvm::JITMethodInfo(GFI) {
MetaInfo = m;
- MethodType = 1;
+ Owner = m->classDef->classLoader->getCompiler();
}
};
@@ -105,7 +108,7 @@
mvm::JITMethodInfo* MI = NULL;
if (meth == NULL) {
// This is a stub.
- MI = new(Alloc, "JITMethodInfo") mvm::MvmJITMethodInfo(GFI, &F);
+ MI = new(Alloc, "JITMethodInfo") mvm::MvmJITMethodInfo(GFI, &F, TheCompiler);
} else {
MI = new(Alloc, "JavaJITMethodInfo") JavaJITMethodInfo(GFI, meth);
}
Modified: vmkit/branches/precise/lib/J3/VMCore/JavaClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JavaClass.cpp?rev=117242&r1=117241&r2=117242&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/VMCore/JavaClass.cpp (original)
+++ vmkit/branches/precise/lib/J3/VMCore/JavaClass.cpp Sun Oct 24 12:51:11 2010
@@ -287,17 +287,6 @@
return code;
}
-void JavaStaticMethodInfo::print(void* ip, void* addr) {
- void* new_ip = NULL;
- if (ip) new_ip = mvm::MethodInfo::isStub(ip, addr);
- JavaMethod* meth = (JavaMethod*)MetaInfo;
- fprintf(stderr, "; %p in %s.%s", new_ip,
- UTF8Buffer(meth->classDef->name).cString(),
- UTF8Buffer(meth->name).cString());
- if (ip != new_ip) fprintf(stderr, " (from stub)");
- fprintf(stderr, "\n");
-}
-
void JavaMethod::setNative() {
access |= ACC_NATIVE;
}
Modified: vmkit/branches/precise/lib/J3/VMCore/JavaClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JavaClass.h?rev=117242&r1=117241&r2=117242&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/VMCore/JavaClass.h (original)
+++ vmkit/branches/precise/lib/J3/VMCore/JavaClass.h Sun Oct 24 12:51:11 2010
@@ -873,18 +873,6 @@
};
-class JavaStaticMethodInfo : public mvm::CamlMethodInfo {
-public:
- virtual void print(void* ip, void* addr);
-
- JavaStaticMethodInfo(mvm::CamlMethodInfo* super, void* ip, JavaMethod* M) :
- mvm::CamlMethodInfo(super->CF) {
- MetaInfo = M;
- MethodType = 1;
- }
-
-};
-
class CodeLineInfo : public mvm::PermanentObject {
public:
uintptr_t address;
Modified: vmkit/branches/precise/lib/J3/VMCore/JavaRuntimeJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JavaRuntimeJIT.cpp?rev=117242&r1=117241&r2=117242&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/VMCore/JavaRuntimeJIT.cpp (original)
+++ vmkit/branches/precise/lib/J3/VMCore/JavaRuntimeJIT.cpp Sun Oct 24 12:51:11 2010
@@ -608,9 +608,10 @@
// Lookup the caller of this class.
mvm::StackWalker Walker(th);
- while (Walker.get()->MethodType != 1) ++Walker;
+ ++Walker; // Remove the stub.
mvm::MethodInfo* MI = Walker.get();
- JavaMethod* meth = (JavaMethod*)MI->getMetaInfo();
+ assert(MI->isHighLevelMethod() && "Wrong stack trace");
+ JavaMethod* meth = (JavaMethod*)MI->MetaInfo;
void* ip = *Walker;
// Lookup the method info in the constant pool of the caller.
@@ -671,10 +672,10 @@
// Lookup the caller of this class.
mvm::StackWalker Walker(th);
- while (Walker.get()->MethodType != 1) ++Walker;
+ ++Walker; // Remove the stub.
mvm::MethodInfo* MI = Walker.get();
- assert(MI->MethodType == 1 && "Wrong call to stub");
- JavaMethod* caller = (JavaMethod*)MI->getMetaInfo();
+ assert(MI->isHighLevelMethod() && "Wrong stack trace");
+ JavaMethod* caller = (JavaMethod*)MI->MetaInfo;
void* ip = *Walker;
// Lookup the method info in the constant pool of the caller.
@@ -709,10 +710,10 @@
// Lookup the caller of this class.
mvm::StackWalker Walker(th);
- while (Walker.get()->MethodType != 1) ++Walker;
+ ++Walker; // Remove the stub.
mvm::MethodInfo* MI = Walker.get();
- assert(MI->MethodType == 1 && "Wrong call to stub");
- JavaMethod* caller = (JavaMethod*)MI->getMetaInfo();
+ assert(MI->isHighLevelMethod() && "Wrong stack trace");
+ JavaMethod* caller = (JavaMethod*)MI->MetaInfo;
void* ip = *Walker;
// Lookup the method info in the constant pool of the caller.
Modified: vmkit/branches/precise/lib/J3/VMCore/JavaThread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JavaThread.cpp?rev=117242&r1=117241&r2=117242&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/VMCore/JavaThread.cpp (original)
+++ vmkit/branches/precise/lib/J3/VMCore/JavaThread.cpp Sun Oct 24 12:51:11 2010
@@ -72,8 +72,8 @@
uint32 i = 0;
while (mvm::MethodInfo* MI = Walker.get()) {
- if (MI->MethodType == 1) {
- JavaMethod* M = (JavaMethod*)MI->getMetaInfo();
+ if (MI->isHighLevelMethod()) {
+ JavaMethod* M = (JavaMethod*)MI->MetaInfo;
buffer[i++] = M;
}
++Walker;
@@ -86,9 +86,9 @@
uint32 index = 0;
while (mvm::MethodInfo* MI = Walker.get()) {
- if (MI->MethodType == 1) {
+ if (MI->isHighLevelMethod()) {
if (index == level) {
- return (JavaMethod*)MI->getMetaInfo();
+ return (JavaMethod*)MI->MetaInfo;
}
++index;
}
@@ -111,8 +111,8 @@
mvm::StackWalker Walker(this);
while (mvm::MethodInfo* MI = Walker.get()) {
- if (MI->MethodType == 1) {
- JavaMethod* meth = (JavaMethod*)MI->getMetaInfo();
+ if (MI->isHighLevelMethod() == 1) {
+ JavaMethod* meth = (JavaMethod*)MI->MetaInfo;
JnjvmClassLoader* loader = meth->classDef->classLoader;
obj = loader->getJavaClassLoader();
if (obj) return obj;
@@ -127,7 +127,7 @@
mvm::StackWalker Walker(this);
while (mvm::MethodInfo* MI = Walker.get()) {
- if (MI->MethodType == 1)
+ if (MI->isHighLevelMethod())
MI->print(Walker.ip, Walker.addr);
++Walker;
}
Modified: vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp?rev=117242&r1=117241&r2=117242&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp (original)
+++ vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp Sun Oct 24 12:51:11 2010
@@ -1383,35 +1383,6 @@
return tmp;
}
-void Jnjvm::internalRemoveMethods(JnjvmClassLoader* loader, mvm::FunctionMap& Map) {
- // Loop over all methods in the map to find which ones belong
- // to this class loader.
- Map.FunctionMapLock.acquire();
- std::map<void*, mvm::MethodInfo*>::iterator temp;
- for (std::map<void*, mvm::MethodInfo*>::iterator i = Map.Functions.begin(),
- e = Map.Functions.end(); i != e;) {
- mvm::MethodInfo* MI = i->second;
- if (MI->MethodType == 1) {
- JavaMethod* meth = (JavaMethod*)i->second->getMetaInfo();
- if (meth->classDef->classLoader == loader) {
- temp = i;
- ++i;
- Map.Functions.erase(temp);
- } else {
- ++i;
- }
- } else {
- ++i;
- }
- }
- Map.FunctionMapLock.release();
-}
-
-void Jnjvm::removeMethodsInFunctionMaps(JnjvmClassLoader* loader) {
- internalRemoveMethods(loader, FunctionsCache);
-}
-
-
void Jnjvm::startCollection() {
finalizerThread->FinalizationQueueLock.acquire();
referenceThread->ToEnqueueLock.acquire();
Modified: vmkit/branches/precise/lib/J3/VMCore/Jnjvm.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/Jnjvm.h?rev=117242&r1=117241&r2=117242&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/VMCore/Jnjvm.h (original)
+++ vmkit/branches/precise/lib/J3/VMCore/Jnjvm.h Sun Oct 24 12:51:11 2010
@@ -351,32 +351,11 @@
///
virtual void waitForExit();
-private:
- /// internalRemoveMethodsInFunctionMap - Removes all methods compiled by this
- /// class loader from the function map.
- ///
- void internalRemoveMethods(JnjvmClassLoader* loader, mvm::FunctionMap& Map);
-
-public:
- /// removeMethodsInFunctionMaps - Removes all methods compiled by this
- /// class loader from the function maps.
- ///
- void removeMethodsInFunctionMaps(JnjvmClassLoader* loader);
-
/// loadBootstrap - Bootstraps the JVM, getting the class loader, initializing
/// bootstrap classes (e.g. java/lang/Class, java/lang/Exception) and
/// mapping the initial thread.
///
void loadBootstrap();
-
-#ifdef ISOLATE
- static Jnjvm* RunningIsolates[NR_ISOLATES];
- static mvm::LockNormal IsolateLock;
-#endif
-
-#ifdef SERVICE
- virtual void stopService();
-#endif
};
} // end namespace j3
Modified: vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp?rev=117242&r1=117241&r2=117242&view=diff
==============================================================================
--- vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp (original)
+++ vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp Sun Oct 24 12:51:11 2010
@@ -912,8 +912,9 @@
JnjvmClassLoader::~JnjvmClassLoader() {
- if (isolate)
- isolate->removeMethodsInFunctionMaps(this);
+ if (isolate) {
+ isolate->removeMethodInfos(TheCompiler);
+ }
if (classes) {
classes->~ClassMap();
@@ -1087,6 +1088,31 @@
return res;
}
+class JavaStaticMethodInfo : public mvm::CamlMethodInfo {
+public:
+ virtual void print(void* ip, void* addr);
+ virtual bool isHighLevelMethod() {
+ return true;
+ }
+
+ JavaStaticMethodInfo(mvm::CamlMethodInfo* super, void* ip, JavaMethod* M) :
+ mvm::CamlMethodInfo(super->CF) {
+ MetaInfo = M;
+ Owner = M->classDef->classLoader->getCompiler();
+ }
+};
+
+void JavaStaticMethodInfo::print(void* ip, void* addr) {
+ void* new_ip = NULL;
+ if (ip) new_ip = mvm::MethodInfo::isStub(ip, addr);
+ JavaMethod* meth = (JavaMethod*)MetaInfo;
+ fprintf(stderr, "; %p in %s.%s", new_ip,
+ UTF8Buffer(meth->classDef->name).cString(),
+ UTF8Buffer(meth->name).cString());
+ if (ip != new_ip) fprintf(stderr, " (from stub)");
+ fprintf(stderr, "\n");
+}
+
void JnjvmClassLoader::insertAllMethodsInVM(Jnjvm* vm) {
for (ClassMap::iterator i = classes->map.begin(), e = classes->map.end();
i != e; ++i) {
Modified: vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp?rev=117242&r1=117241&r2=117242&view=diff
==============================================================================
--- vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp (original)
+++ vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp Sun Oct 24 12:51:11 2010
@@ -104,8 +104,8 @@
assert(&(*I)->getFunction() == &F &&
"GC Info and method do not correspond");
llvm::GCFunctionInfo* GFI = *I;
- JITMethodInfo* MI =
- new(*MvmModule::Allocator, "MvmJITMethodInfo") MvmJITMethodInfo(GFI, &F);
+ JITMethodInfo* MI = new(*MvmModule::Allocator, "MvmJITMethodInfo")
+ MvmJITMethodInfo(GFI, &F, MvmModule::executionEngine);
MI->addToVM(mvm::Thread::get()->MyVM, (JIT*)MvmModule::executionEngine);
}
};
Modified: vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp?rev=117242&r1=117241&r2=117242&view=diff
==============================================================================
--- vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp (original)
+++ vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp Sun Oct 24 12:51:11 2010
@@ -126,3 +126,19 @@
Functions.insert(std::make_pair(ip, meth));
FunctionMapLock.release();
}
+
+
+void FunctionMap::removeMethodInfos(void* owner) {
+ FunctionMapLock.acquire();
+ std::map<void*, mvm::MethodInfo*>::iterator temp;
+ for (std::map<void*, mvm::MethodInfo*>::iterator i = Functions.begin(),
+ e = Functions.end(); i != e;) {
+ mvm::MethodInfo* MI = i->second;
+ if (MI->Owner == owner) {
+ temp = i;
+ i++;
+ Functions.erase(temp);
+ }
+ }
+ FunctionMapLock.release();
+}
More information about the vmkit-commits
mailing list