[llvm-commits] [vmkit] r50188 - in /vmkit/trunk/lib/JnJVM/VMCore: JavaInitialise.cpp JavaMetaJIT.cpp JavaObject.h
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Wed Apr 23 15:24:08 PDT 2008
Author: geoffray
Date: Wed Apr 23 17:24:08 2008
New Revision: 50188
URL: http://llvm.org/viewvc/llvm-project?rev=50188&view=rev
Log:
Don't count on C++ to fake Java virtual table. Just use a custom allocated one.
Modified:
vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaObject.h
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp?rev=50188&r1=50187&r2=50188&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp Wed Apr 23 17:24:08 2008
@@ -39,17 +39,6 @@
X::VT = ((void**)(void*)(&fake))[0]; }
INIT(JavaArray);
- INIT(ArrayUInt8);
- INIT(ArraySInt8);
- INIT(ArrayUInt16);
- INIT(ArraySInt16);
- INIT(ArrayUInt32);
- INIT(ArraySInt32);
- INIT(ArrayLong);
- INIT(ArrayFloat);
- INIT(ArrayDouble);
- INIT(ArrayObject);
- INIT(UTF8);
INIT(Attribut);
INIT(CommonClass);
INIT(Class);
@@ -82,6 +71,24 @@
INIT(Enveloppe);
#undef INIT
+#define INIT(X) { \
+ X fake; \
+ void* V = ((void**)(void*)(&fake))[0]; \
+ X::VT = (VirtualTable*)malloc(12 * sizeof(void*) + VT_SIZE); \
+ memcpy(X::VT, V, VT_SIZE); }
+
+ INIT(ArrayUInt8);
+ INIT(ArraySInt8);
+ INIT(ArrayUInt16);
+ INIT(ArraySInt16);
+ INIT(ArrayUInt32);
+ INIT(ArraySInt32);
+ INIT(ArrayLong);
+ INIT(ArrayFloat);
+ INIT(ArrayDouble);
+ INIT(ArrayObject);
+ INIT(UTF8);
+#undef INIT
}
static void initialiseStatics() {
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp?rev=50188&r1=50187&r2=50188&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp Wed Apr 23 17:24:08 2008
@@ -219,28 +219,28 @@
#ifndef WITHOUT_VTABLE
} else {
res = allocateVT(cl, cl->virtualMethods.begin());
- }
-
- if (!(cl->super)) {
- // 12 = number of virtual methods in java/lang/Object (!!!)
- uint32 size = 12 * sizeof(void*);
+
+ if (!(cl->super)) {
+ // 12 = number of virtual methods in java/lang/Object (!!!)
+ uint32 size = 12 * sizeof(void*);
#define COPY(CLASS) \
- memcpy((void*)((unsigned)res + VT_SIZE), \
- (void*)((unsigned)CLASS::VT + VT_SIZE), size);
+ memcpy((void*)((unsigned)CLASS::VT + VT_SIZE), \
+ (void*)((unsigned)res + VT_SIZE), size);
- COPY(ArrayUInt8)
- COPY(ArraySInt8)
- COPY(ArrayUInt16)
- COPY(ArraySInt16)
- COPY(ArrayUInt32)
- COPY(ArraySInt32)
- COPY(ArrayLong)
- COPY(ArrayFloat)
- COPY(ArrayDouble)
- COPY(UTF8)
- COPY(ArrayObject)
+ COPY(ArrayUInt8)
+ COPY(ArraySInt8)
+ COPY(ArrayUInt16)
+ COPY(ArraySInt16)
+ COPY(ArrayUInt32)
+ COPY(ArraySInt32)
+ COPY(ArrayLong)
+ COPY(ArrayFloat)
+ COPY(ArrayDouble)
+ COPY(UTF8)
+ COPY(ArrayObject)
#undef COPY
+ }
}
#endif
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaObject.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaObject.h?rev=50188&r1=50187&r2=50188&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaObject.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaObject.h Wed Apr 23 17:24:08 2008
@@ -104,21 +104,6 @@
void operator()(JavaField* field, uint32 val);
void operator()(JavaField* field, JavaObject* val);
-#ifndef WITHOUT_VTABLE
- // Some of these are final. I could probably remove them from the list.
- virtual void JavaInit() {}
- virtual void JavaEquals() {}
- virtual void JavaHashCode() {}
- virtual void JavaToString() {}
- virtual void JavaFinalize() {}
- virtual void JavaClone() {}
- virtual void JavaGetClass() {}
- virtual void JavaNotify() {}
- virtual void JavaNotifyAll() {}
- virtual void JavaWait() {}
- virtual void JavaWait(sint64) {}
- virtual void JavaWait(sint64, sint32) {}
-#endif
};
More information about the llvm-commits
mailing list