[vmkit-commits] [vmkit] r199692 - J3Globalreference is now a template class.
Gael Thomas
gael.thomas at lip6.fr
Mon Jan 20 14:45:40 PST 2014
Author: gthomas
Date: Mon Jan 20 16:45:39 2014
New Revision: 199692
URL: http://llvm.org/viewvc/llvm-project?rev=199692&view=rev
Log:
J3Globalreference is now a template class.
Modified:
vmkit/branches/mcjit/Makefile
vmkit/branches/mcjit/include/j3/j3class.h
vmkit/branches/mcjit/include/j3/j3classloader.h
vmkit/branches/mcjit/include/j3/j3object.h
vmkit/branches/mcjit/lib/j3/vm/j3object.cc
Modified: vmkit/branches/mcjit/Makefile
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/Makefile?rev=199692&r1=199691&r2=199692&view=diff
==============================================================================
--- vmkit/branches/mcjit/Makefile (original)
+++ vmkit/branches/mcjit/Makefile Mon Jan 20 16:45:39 2014
@@ -5,6 +5,6 @@
LEVEL := .
-DIRS := tools/vmkit-extract lib tools/j3 lib/mmtk/
+DIRS := tools/vmkit-extract lib tools/j3 # lib/mmtk/
include $(LEVEL)/Makefile.rules
Modified: vmkit/branches/mcjit/include/j3/j3class.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3class.h?rev=199692&r1=199691&r2=199692&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3class.h (original)
+++ vmkit/branches/mcjit/include/j3/j3class.h Mon Jan 20 16:45:39 2014
@@ -40,7 +40,6 @@ namespace j3 {
J3Method** methods;
};
-
class J3Type : public vmkit::Symbol {
pthread_mutex_t _mutex;
J3ClassLoader* _loader;
@@ -52,7 +51,7 @@ namespace j3 {
const vmkit::Name* _name;
char* _nativeName;
uint32_t _nativeNameLength;
- J3VirtualTable* _vt;
+ J3VirtualTable* _vt;
J3ObjectHandle* volatile _javaClass;
volatile int status;
Modified: vmkit/branches/mcjit/include/j3/j3classloader.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3classloader.h?rev=199692&r1=199691&r2=199692&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3classloader.h (original)
+++ vmkit/branches/mcjit/include/j3/j3classloader.h Mon Jan 20 16:45:39 2014
@@ -41,7 +41,7 @@ namespace j3 {
uint32_t _compilationMode;
J3ObjectHandle* _javaClassLoader;
- J3GlobalReferences _globalReferences;
+ J3GlobalReferences<J3ObjectHandle> _globalReferences;
pthread_mutex_t _mutexClasses;
vmkit::NameMap<J3Class*>::map classes; /* classes managed by this class loader */
@@ -77,7 +77,7 @@ namespace j3 {
uint32_t interfaceIndex(J3Method* signature);
- J3GlobalReferences* globalReferences() { return &_globalReferences; }
+ J3GlobalReferences<J3ObjectHandle>* globalReferences() { return &_globalReferences; }
static J3ClassLoader* nativeClassLoader(J3ObjectHandle* jloader);
J3ObjectHandle* javaClassLoader(bool doPush=1);
Modified: vmkit/branches/mcjit/include/j3/j3object.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3object.h?rev=199692&r1=199691&r2=199692&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3object.h (original)
+++ vmkit/branches/mcjit/include/j3/j3object.h Mon Jan 20 16:45:39 2014
@@ -144,7 +144,6 @@ namespace j3 {
class J3ObjectHandle {
friend class J3LocalReferences;
- friend class J3GlobalReferences;
friend class J3Method;
public:
@@ -200,25 +199,6 @@ namespace j3 {
#undef defAccessor
};
- class J3LocalReferences : public vmkit::Stack<J3ObjectHandle> {
- public:
- J3LocalReferences(vmkit::BumpAllocator* _allocator) : vmkit::Stack<J3ObjectHandle>(_allocator) {}
-
- J3ObjectHandle* push(J3ObjectHandle* handle) { return handle ? push(handle->obj()) : 0; }
- J3ObjectHandle* push(J3Object* obj);
- };
-
- class J3GlobalReferences {
- pthread_mutex_t mutex;
- vmkit::Stack<J3ObjectHandle> references;
- vmkit::Stack<J3ObjectHandle*> emptySlots;
- public:
- J3GlobalReferences(vmkit::BumpAllocator* _allocator);
-
- J3ObjectHandle* add(J3ObjectHandle* handle);
- void del(J3ObjectHandle* handle);
- };
-
class J3Value {
public:
union {
@@ -235,6 +215,48 @@ namespace j3 {
J3Value() {}
};
+
+ class J3LocalReferences : public vmkit::Stack<J3ObjectHandle> {
+ public:
+ J3LocalReferences(vmkit::BumpAllocator* _allocator) : vmkit::Stack<J3ObjectHandle>(_allocator) {}
+
+ J3ObjectHandle* push(J3ObjectHandle* handle) { return handle ? push(handle->obj()) : 0; }
+ J3ObjectHandle* push(J3Object* obj);
+ };
+
+ template <class T>
+ class J3GlobalReferences {
+ pthread_mutex_t mutex;
+ vmkit::Stack<T> references;
+ vmkit::Stack<T*> emptySlots;
+
+ public:
+ J3GlobalReferences(vmkit::BumpAllocator* _allocator) :
+ references(_allocator),
+ emptySlots(_allocator) {
+ pthread_mutex_init(&mutex, 0);
+ }
+
+ T* add(T* handle) {
+ if(handle) {
+ pthread_mutex_lock(&mutex);
+ T* res = emptySlots.isEmpty() ? references.push() : *emptySlots.pop();
+ *res = *handle;
+ pthread_mutex_unlock(&mutex);
+ return res;
+ } else
+ return 0;
+ }
+
+ void del(T* handle) {
+ if(handle) {
+ handle->harakiri();
+ pthread_mutex_lock(&mutex);
+ *emptySlots.push() = handle;
+ pthread_mutex_unlock(&mutex);
+ }
+ }
+ };
}
#endif
Modified: vmkit/branches/mcjit/lib/j3/vm/j3object.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3object.cc?rev=199692&r1=199691&r2=199692&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3object.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3object.cc Mon Jan 20 16:45:39 2014
@@ -544,32 +544,4 @@ J3ObjectHandle* J3LocalReferences::push(
return 0;
}
-/*
- * J3GlobalReferences
- */
-J3GlobalReferences::J3GlobalReferences(vmkit::BumpAllocator* _allocator) :
- references(_allocator),
- emptySlots(_allocator) {
- pthread_mutex_init(&mutex, 0);
-}
-
-J3ObjectHandle* J3GlobalReferences::add(J3ObjectHandle* handle) {
- if(handle) {
- pthread_mutex_lock(&mutex);
- J3ObjectHandle* res = emptySlots.isEmpty() ? references.push() : *emptySlots.pop();
- res->_obj = handle->_obj;
- pthread_mutex_unlock(&mutex);
- return res;
- } else
- return 0;
-}
-
-void J3GlobalReferences::del(J3ObjectHandle* handle) {
- if(handle) {
- handle->harakiri();
- pthread_mutex_lock(&mutex);
- *emptySlots.push() = handle;
- pthread_mutex_unlock(&mutex);
- }
-}
More information about the vmkit-commits
mailing list