[vmkit-commits] [vmkit] r84097 - in /vmkit/trunk: include/mvm/Object.h lib/N3/VMCore/CLIJit.cpp lib/N3/VMCore/CLIString.h lib/N3/VMCore/N3Initialise.cpp lib/N3/VMCore/VMObject.cpp lib/N3/VMCore/VMObject.h lib/N3/VMCore/VirtualTables.cpp
Gael Thomas
gael.thomas at lip6.fr
Wed Oct 14 07:33:21 PDT 2009
Author: gthomas
Date: Wed Oct 14 09:33:20 2009
New Revision: 84097
URL: http://llvm.org/viewvc/llvm-project?rev=84097&view=rev
Log:
The vt of N3Object is dynamically built in makeVT. Remove the last vts (except LockObj).
Modified:
vmkit/trunk/include/mvm/Object.h
vmkit/trunk/lib/N3/VMCore/CLIJit.cpp
vmkit/trunk/lib/N3/VMCore/CLIString.h
vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp
vmkit/trunk/lib/N3/VMCore/VMObject.cpp
vmkit/trunk/lib/N3/VMCore/VMObject.h
vmkit/trunk/lib/N3/VMCore/VirtualTables.cpp
Modified: vmkit/trunk/include/mvm/Object.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Object.h?rev=84097&r1=84096&r2=84097&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/Object.h (original)
+++ vmkit/trunk/include/mvm/Object.h Wed Oct 14 09:33:20 2009
@@ -33,7 +33,7 @@
class Object : public gc {
public:
static void default_tracer(gc *o) {}
- static intptr_t default_hashcode(gc *o) { return (intptr_t)o; }
+ static intptr_t default_hashCode(const gc *o) { return (intptr_t)o; }
static void default_print(const gc *o, PrintBuffer *buf);
/// tracer - Default implementation of tracer. Does nothing.
@@ -47,7 +47,7 @@
/// hashCode - Default implementation of hashCode. Returns the address
/// of this object.
///
- virtual intptr_t hashCode(){ return default_hashcode(this);}
+ virtual intptr_t hashCode() const { return default_hashCode(this);}
};
Modified: vmkit/trunk/lib/N3/VMCore/CLIJit.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIJit.cpp?rev=84097&r1=84096&r2=84097&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/CLIJit.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/CLIJit.cpp Wed Oct 14 09:33:20 2009
@@ -240,11 +240,11 @@
#endif
#define CASE_ARRAY(name, elmt, nbb, printer, pre, sep, post) \
- else if(cl->baseClass == MSCorlib::p##name) { \
+ if(cl->baseClass == MSCorlib::p##name) { \
((void**)res)[VT_PRINT_OFFSET] = ((void **)(unsigned int)Array##name::do_print); \
- }
+ } else
- if(0) {} ON_ARRAY_CLASSES(CASE_ARRAY)
+ ON_ARRAY_CLASSES(CASE_ARRAY) {}
#undef CASE_ARRAY
@@ -254,9 +254,19 @@
N3VirtualTable* CLIJit::makeVT(VMClass* cl, bool stat) {
int n = N3VirtualTable::baseVtSize();
N3VirtualTable * res =
- stat || !cl->super ?
- new(cl->assembly->allocator, n) N3VirtualTable(VMObject::VT, n) :
- new(cl->assembly->allocator, cl->vtSize) N3VirtualTable(((VMClass *)cl->super)->virtualInstance->getN3VirtualTable(), n, cl->vtSize);
+ stat ? new(cl->assembly->allocator, n) N3VirtualTable((uintptr_t)0,
+ (uintptr_t)0,
+ (uintptr_t)VMObject::_trace,
+ (uintptr_t)VMObject::_print,
+ (uintptr_t)mvm::Object::default_hashCode) : (
+ cl->super ? new(cl->assembly->allocator, cl->vtSize) N3VirtualTable(((VMClass *)cl->super)->virtualInstance->getN3VirtualTable(),
+ n,
+ cl->vtSize) :
+ new(cl->assembly->allocator, cl->vtSize) N3VirtualTable((uintptr_t)0,
+ (uintptr_t)0,
+ (uintptr_t)VMObject::_trace,
+ (uintptr_t)VMObject::_print,
+ (uintptr_t)mvm::Object::default_hashCode));
#ifdef WITH_TRACER
Modified: vmkit/trunk/lib/N3/VMCore/CLIString.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIString.h?rev=84097&r1=84096&r2=84097&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/CLIString.h (original)
+++ vmkit/trunk/lib/N3/VMCore/CLIString.h Wed Oct 14 09:33:20 2009
@@ -25,7 +25,6 @@
class CLIString : public VMObject {
CLIString() {}
public:
- static N3VirtualTable* VT;
virtual void print(mvm::PrintBuffer* buf) const {
buf->write("CLI string");
}
Modified: vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp?rev=84097&r1=84096&r2=84097&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp Wed Oct 14 09:33:20 2009
@@ -154,24 +154,6 @@
#undef DEFINE_ARRAY_LLVM_TYPE
static void initialiseVT() {
-
-#if defined(WITHOUT_FINALIZER)
-# define INIT(X) { \
- X fake; \
- X::VT = ((N3VirtualTable**)(void*)(&fake))[0]; \
- }
-#else
-# define INIT(X) { \
- X fake; \
- X::VT = ((N3VirtualTable**)(void*)(&fake))[0]; \
- ((void**)X::VT)[0] = 0; \
- }
-#endif
-
- INIT(VMObject);
-
-#undef INIT
-
}
VMThread* VMThread::TheThread = 0;
Modified: vmkit/trunk/lib/N3/VMCore/VMObject.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMObject.cpp?rev=84097&r1=84096&r2=84097&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMObject.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/VMObject.cpp Wed Oct 14 09:33:20 2009
@@ -22,8 +22,7 @@
(uintptr_t)0,
(uintptr_t)mvm::Object::default_tracer,
(uintptr_t)LockObj::_print,
- (uintptr_t)mvm::Object::default_hashcode);
-N3VirtualTable *LockObj::VT = &_VT;
+ (uintptr_t)mvm::Object::default_hashCode);
void *N3VirtualTable::operator new(size_t size, mvm::BumpPtrAllocator &allocator, size_t totalVtSize) {
//printf("Allocate N3VirtualTable with %d elements\n", totalVtSize);
@@ -39,7 +38,7 @@
N3VirtualTable::N3VirtualTable(uintptr_t d, uintptr_t o, uintptr_t t, uintptr_t p, uintptr_t h) : VirtualTable(d, o, t) {
print = p;
- hashcode = h;
+ hashCode = h;
}
uint32 N3VirtualTable::baseVtSize() {
@@ -53,7 +52,7 @@
LockObj* LockObj::allocate() {
- LockObj* res = gc_new(LockObj)();
+ LockObj* res = new(&_VT) LockObj();
return res;
}
@@ -125,18 +124,15 @@
return lock.selfOwner();
}
-void VMObject::print(mvm::PrintBuffer* buf) const {
+void VMObject::_print(const VMObject *self, mvm::PrintBuffer* buf) {
+ llvm_gcroot(self, 0);
buf->write("VMObject<");
- classOf->print(buf);
+ self->classOf->print(buf);
+ buf->write("@0x");
+ buf->writePtr((void*)self->hashCode());
buf->write(">");
}
-VMObject* VMObject::allocate(VMCommonClass* cl) {
- VMObject* res = gc_new(VMObject)();
- res->classOf = cl;
- return res;
-}
-
static LockObj* myLock(VMObject* obj) {
verifyNull(obj);
if (obj->lockObj == 0) {
Modified: vmkit/trunk/lib/N3/VMCore/VMObject.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMObject.h?rev=84097&r1=84096&r2=84097&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMObject.h (original)
+++ vmkit/trunk/lib/N3/VMCore/VMObject.h Wed Oct 14 09:33:20 2009
@@ -32,7 +32,7 @@
struct N3VirtualTable : VirtualTable {
uintptr_t print;
- uintptr_t hashcode;
+ uintptr_t hashCode;
void *operator new(size_t size, mvm::BumpPtrAllocator &allocator, size_t totalVtSize);
@@ -46,7 +46,6 @@
class LockObj : public mvm::Object {
public:
static N3VirtualTable _VT;
- static N3VirtualTable* VT;
mvm::LockRecursive lock;
std::vector<VMThread*> threads;
@@ -69,17 +68,15 @@
class VMObject : public mvm::Object {
public:
- static N3VirtualTable* VT;
VMCommonClass* classOf;
LockObj* lockObj;
static mvm::Lock* globalLock;
static const llvm::Type* llvmType;
+
+ static void _print(const VMObject *, mvm::PrintBuffer *);
+ static void _trace(VMObject *);
- virtual void print(mvm::PrintBuffer* buf) const;
- virtual void TRACER;
-
- static VMObject* allocate(VMCommonClass* cl);
void aquire();
void unlock();
void waitIntern(struct timeval *info, bool timed);
Modified: vmkit/trunk/lib/N3/VMCore/VirtualTables.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VirtualTables.cpp?rev=84097&r1=84096&r2=84097&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VirtualTables.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/VirtualTables.cpp Wed Oct 14 09:33:20 2009
@@ -23,24 +23,14 @@
using namespace n3;
-#define INIT(X) N3VirtualTable* X::VT = 0
-
-INIT(VMObject);
-INIT(CLIString);
-
-#undef INIT
-
-#ifdef MULTIPLE_GC
-extern "C" void CLIObjectTracer(VMObject* obj, Collector* GC) {
-#else
extern "C" void CLIObjectTracer(VMObject* obj) {
-#endif
- obj->lockObj->MARK_AND_TRACE;
+ VMObject::_trace(obj);
}
// N3 Objects
-void VMObject::TRACER {
- lockObj->MARK_AND_TRACE;
+void VMObject::_trace(VMObject *self) {
+ llvm_gcroot(self, 0);
+ self->lockObj->MARK_AND_TRACE;
}
#define TRACE_VECTOR(type, name, alloc) { \
More information about the vmkit-commits
mailing list