[vmkit-commits] [vmkit] r135874 - in /vmkit/trunk: include/mvm/VirtualMachine.h lib/J3/VMCore/Precompiled.cpp lib/Mvm/Runtime/MethodInfo.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Sun Jul 24 08:10:17 PDT 2011
Author: geoffray
Date: Sun Jul 24 10:10:16 2011
New Revision: 135874
URL: http://llvm.org/viewvc/llvm-project?rev=135874&view=rev
Log:
Use a llvm::DenseMap for the function pointers map.
Modified:
vmkit/trunk/include/mvm/VirtualMachine.h
vmkit/trunk/lib/J3/VMCore/Precompiled.cpp
vmkit/trunk/lib/Mvm/Runtime/MethodInfo.cpp
Modified: vmkit/trunk/include/mvm/VirtualMachine.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/VirtualMachine.h?rev=135874&r1=135873&r2=135874&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/VirtualMachine.h (original)
+++ vmkit/trunk/include/mvm/VirtualMachine.h Sun Jul 24 10:10:16 2011
@@ -10,6 +10,8 @@
#ifndef MVM_VIRTUALMACHINE_H
#define MVM_VIRTUALMACHINE_H
+#include "llvm/ADT/DenseMap.h"
+
#include "mvm/Allocator.h"
#include "mvm/Threads/CollectionRV.h"
#include "mvm/Threads/Locks.h"
@@ -29,7 +31,7 @@
/// used when walking the stack so that VMKit knows which applicative method
/// is executing on the stack.
///
- std::map<void*, MethodInfo*> Functions;
+ llvm::DenseMap<void*, MethodInfo*> Functions;
/// FunctionMapLock - Spin lock to protect the Functions map.
///
@@ -42,6 +44,9 @@
/// addMethodInfo - A new instruction pointer in the function map.
///
void addMethodInfo(MethodInfo* meth, void* ip);
+ void addMethodInfoNoLock(MethodInfo* meth, void* ip) {
+ Functions[ip] = meth;
+ }
/// removeMethodInfos - Remove all MethodInfo owned by the given owner.
void removeMethodInfos(void* owner);
Modified: vmkit/trunk/lib/J3/VMCore/Precompiled.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/Precompiled.cpp?rev=135874&r1=135873&r2=135874&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/Precompiled.cpp (original)
+++ vmkit/trunk/lib/J3/VMCore/Precompiled.cpp Sun Jul 24 10:10:16 2011
@@ -340,7 +340,8 @@
while (decoder.hasNext()) {
StaticJ3Frame* frame = decoder.next();
mvm::MethodInfo* MI = new(allocator, "JavaStaticMethodInfo") JavaStaticMethodInfo(frame, meth);
- vm->FunctionsCache.addMethodInfo(MI, frame->ReturnAddress);
+ assert(loader->bootstrapLoader == loader && "Can only add frame without lock for the bootstrap loader");
+ vm->FunctionsCache.addMethodInfoNoLock(MI, frame->ReturnAddress);
meth->codeInfo[codeInfoIndex].address = reinterpret_cast<uintptr_t>(frame->ReturnAddress);
meth->codeInfo[codeInfoIndex++].bytecodeIndex = frame->BytecodeIndex;
}
Modified: vmkit/trunk/lib/Mvm/Runtime/MethodInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Runtime/MethodInfo.cpp?rev=135874&r1=135873&r2=135874&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Runtime/MethodInfo.cpp (original)
+++ vmkit/trunk/lib/Mvm/Runtime/MethodInfo.cpp Sun Jul 24 10:10:16 2011
@@ -7,6 +7,9 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
+
#include "mvm/Allocator.h"
#include "mvm/MethodInfo.h"
#include "mvm/VirtualMachine.h"
@@ -95,14 +98,14 @@
CamlFrame* frame = decoder.next();
CamlMethodInfo* MI =
new(*StaticAllocator, "CamlMethodInfo") CamlMethodInfo(frame);
- addMethodInfo(MI, frame->ReturnAddress);
+ addMethodInfoNoLock(MI, frame->ReturnAddress);
}
}
}
MethodInfo* FunctionMap::IPToMethodInfo(void* ip) {
FunctionMapLock.acquire();
- std::map<void*, MethodInfo*>::iterator I = Functions.find(ip);
+ llvm::DenseMap<void*, MethodInfo*>::iterator I = Functions.find(ip);
MethodInfo* res = NULL;
if (I != Functions.end()) {
res = I->second;
@@ -113,24 +116,29 @@
return res;
}
+
void FunctionMap::addMethodInfo(MethodInfo* meth, void* ip) {
FunctionMapLock.acquire();
- Functions.insert(std::make_pair(ip, meth));
+ addMethodInfoNoLock(meth, ip);
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(),
+ llvm::DenseSet<void*> toRemove;
+ for (llvm::DenseMap<void*, MethodInfo*>::iterator i = Functions.begin(),
e = Functions.end(); i != e;) {
mvm::MethodInfo* MI = i->second;
- temp = i;
- i++;
if (MI->Owner == owner) {
- Functions.erase(temp);
+ toRemove.insert(i->first);
}
}
+
+ for (llvm::DenseSet<void*>::iterator i = toRemove.begin(),
+ e = toRemove.end(); i != e;) {
+ Functions.erase(*i);
+ }
+
FunctionMapLock.release();
}
More information about the vmkit-commits
mailing list