[vmkit-commits] [vmkit] r198223 - Don't use the data layout to find the size of the Java types
Gael Thomas
gael.thomas at lip6.fr
Mon Dec 30 09:24:22 PST 2013
Author: gthomas
Date: Mon Dec 30 11:24:21 2013
New Revision: 198223
URL: http://llvm.org/viewvc/llvm-project?rev=198223&view=rev
Log:
Don't use the data layout to find the size of the Java types
Modified:
vmkit/branches/mcjit/include/j3/j3.h
vmkit/branches/mcjit/include/j3/j3class.h
vmkit/branches/mcjit/include/j3/j3object.h
vmkit/branches/mcjit/include/j3/j3typesdef.h
vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc
vmkit/branches/mcjit/lib/j3/openjdk/j3unsafe.cc
vmkit/branches/mcjit/lib/j3/vm/j3.cc
vmkit/branches/mcjit/lib/j3/vm/j3class.cc
vmkit/branches/mcjit/lib/j3/vm/j3object.cc
Modified: vmkit/branches/mcjit/include/j3/j3.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3.h?rev=198223&r1=198222&r2=198223&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3.h (original)
+++ vmkit/branches/mcjit/include/j3/j3.h Mon Dec 30 11:24:21 2013
@@ -45,7 +45,7 @@ namespace j3 {
static J3* create();
-#define defPrimitive(name, ctype, llvmtype) \
+#define defPrimitive(name, ctype, llvmtype, scale) \
J3Primitive* type##name;
onJavaTypes(defPrimitive)
#undef defPrimitive
Modified: vmkit/branches/mcjit/include/j3/j3class.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3class.h?rev=198223&r1=198222&r2=198223&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3class.h (original)
+++ vmkit/branches/mcjit/include/j3/j3class.h Mon Dec 30 11:24:21 2013
@@ -53,7 +53,7 @@ namespace j3 {
public:
J3Type(J3ClassLoader* loader, const vmkit::Name* name);
- uint64_t getLogSize();
+ virtual uint32_t logSize() = 0;
uint64_t getSizeInBits();
void* getSymbolAddress();
@@ -168,6 +168,8 @@ namespace j3 {
public:
J3ObjectType(J3ClassLoader* loader, const vmkit::Name* name);
+ uint32_t logSize() { return sizeof(uintptr_t) == 8 ? 3 : 2; }
+
J3InterfaceSlotDescriptor* slotDescriptorAt(uint32_t index) { return &_interfaceSlotDescriptors[index]; }
void prepareInterfaceTable();
@@ -312,11 +314,13 @@ namespace j3 {
};
class J3Primitive : public J3Type {
+ uint32_t _logSize;
llvm::Type* _llvmType;
public:
- J3Primitive(J3ClassLoader* loader, char id, llvm::Type* type);
+ J3Primitive(J3ClassLoader* loader, char id, llvm::Type* type, uint32_t logSize);
+ uint32_t logSize() { return _logSize; }
bool isPrimitive() { return 1; }
llvm::Type* llvmType() { return _llvmType; }
};
Modified: vmkit/branches/mcjit/include/j3/j3object.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3object.h?rev=198223&r1=198222&r2=198223&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3object.h (original)
+++ vmkit/branches/mcjit/include/j3/j3object.h Mon Dec 30 11:24:21 2013
@@ -174,7 +174,7 @@ namespace j3 {
void setObjectAt(uint32_t idx, J3ObjectHandle* v);
J3ObjectHandle* getObjectAt(uint32_t idx);
-#define defAccessor(name, ctype, llvmtype) \
+#define defAccessor(name, ctype, llvmtype, scale) \
void rawSet##name(uint32_t offset, ctype value); \
ctype rawGet##name(uint32_t offset); \
void set##name(J3Field* f, ctype value); \
@@ -209,13 +209,13 @@ namespace j3 {
class J3Value {
public:
union {
-#define doIt(name, ctype, llvmtype) \
+#define doIt(name, ctype, llvmtype, scale) \
ctype val##name;
onJavaFields(doIt);
#undef doIt
};
-#define doIt(name, ctype, llvmtype) \
+#define doIt(name, ctype, llvmtype, scale) \
J3Value(ctype val) { val##name = val; }
onJavaFields(doIt);
#undef doIt
Modified: vmkit/branches/mcjit/include/j3/j3typesdef.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3typesdef.h?rev=198223&r1=198222&r2=198223&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3typesdef.h (original)
+++ vmkit/branches/mcjit/include/j3/j3typesdef.h Mon Dec 30 11:24:21 2013
@@ -3,21 +3,21 @@
namespace j3 {
-#define onJavaPrimitives(_) \
- _(Boolean, bool, Int1) \
- _(Byte, int8_t, Int8) \
- _(Short, int16_t, Int16) \
- _(Char, uint16_t, Int16) \
- _(Integer, int32_t, Int32) \
- _(Long, int64_t, Int64) \
- _(Float, float, Float) \
- _(Double, double, Double) \
+#define onJavaPrimitives(_) \
+ _(Boolean, bool, Int1, 0) \
+ _(Byte, int8_t, Int8, 0) \
+ _(Short, int16_t, Int16, 1) \
+ _(Char, uint16_t, Int16, 1) \
+ _(Integer, int32_t, Int32, 2) \
+ _(Long, int64_t, Int64, 3) \
+ _(Float, float, Float, 2) \
+ _(Double, double, Double, 3) \
#define onJavaObject(_) \
- _(Object, J3ObjectHandle*, Fatal)
+ _(Object, J3ObjectHandle*, Fatal, 3)
#define onJavaVoid(_) \
- _(Void, void, Void)
+ _(Void, void, Void, 0)
#define onJavaTypes(_) \
onJavaPrimitives(_) \
Modified: vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc?rev=198223&r1=198222&r2=198223&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc (original)
+++ vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc Mon Dec 30 11:24:21 2013
@@ -68,7 +68,7 @@ void JNICALL JVM_ArrayCopy(JNIEnv* env,
(dst_pos + length) > dst->arrayLength())
J3::arrayIndexOutOfBoundsException();
- uint32_t scale = srcType0->asArrayClass()->component()->getLogSize();
+ uint32_t scale = srcType0->asArrayClass()->component()->logSize();
src->rawArrayCopyTo(src_pos << scale, dst, dst_pos << scale, length << scale);
Modified: vmkit/branches/mcjit/lib/j3/openjdk/j3unsafe.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/openjdk/j3unsafe.cc?rev=198223&r1=198222&r2=198223&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/openjdk/j3unsafe.cc (original)
+++ vmkit/branches/mcjit/lib/j3/openjdk/j3unsafe.cc Mon Dec 30 11:24:21 2013
@@ -28,7 +28,7 @@ extern "C" {
/// makes this type of access impossible or unsupported.
///
JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_arrayIndexScale(JNIEnv* env, jobject unsafe, jclass clazz) {
- return J3ObjectType::nativeClass(clazz)->asArrayClass()->component()->getLogSize();
+ return J3ObjectType::nativeClass(clazz)->asArrayClass()->component()->logSize();
}
JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_addressSize(JNIEnv* env, jobject unsafe) {
Modified: vmkit/branches/mcjit/lib/j3/vm/j3.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3.cc?rev=198223&r1=198222&r2=198223&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3.cc Mon Dec 30 11:24:21 2013
@@ -85,8 +85,8 @@ void J3::run() {
vmkit::BumpAllocator* a = initialClassLoader->allocator();
-#define defPrimitive(name, ctype, llvmtype) \
- type##name = new(a) J3Primitive(initialClassLoader, J3Cst::ID_##name, llvm::Type::get##llvmtype##Ty(llvmContext()));
+#define defPrimitive(name, ctype, llvmtype, scale) \
+ type##name = new(a) J3Primitive(initialClassLoader, J3Cst::ID_##name, llvm::Type::get##llvmtype##Ty(llvmContext()), scale);
onJavaTypes(defPrimitive)
#undef defPrimitive
Modified: vmkit/branches/mcjit/lib/j3/vm/j3class.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3class.cc?rev=198223&r1=198222&r2=198223&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3class.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3class.cc Mon Dec 30 11:24:21 2013
@@ -71,22 +71,8 @@ J3ArrayClass* J3Type::getArray(uint32_t
return prof > 1 ? _array->getArray(prof-1) : _array;
}
-uint64_t J3Type::getLogSize() {
- uint32_t res = getSizeInBits();
-
- switch(res) {
- case 1:
- case 8: return 0;
- case 16: return 1;
- case 32: return 2;
- case 64: return 3;
- default:
- J3::internalError(L"unexpected type");
- }
-}
-
uint64_t J3Type::getSizeInBits() {
- return loader()->vm()->dataLayout()->getTypeSizeInBits(llvmType());
+ return 1 << (logSize()+3);
}
bool J3Type::isAssignableTo(J3Type* parent) {
@@ -964,12 +950,14 @@ llvm::Type* J3ArrayClass::llvmType() {
/*
* ------------ J3Primitive ------------
*/
-J3Primitive::J3Primitive(J3ClassLoader* loader, char id, llvm::Type* type) : J3Type(loader, loader->vm()->names()->get(id)) {
+J3Primitive::J3Primitive(J3ClassLoader* loader, char id, llvm::Type* type, uint32_t logSize) :
+ J3Type(loader, loader->vm()->names()->get(id)) {
_llvmType = type;
_nativeName = (char*)loader->allocator()->allocate(2);
_nativeName[0] = id;
_nativeName[1] = 0;
_nativeNameLength = 1;
_vt = J3VirtualTable::create(this);
+ _logSize = logSize;
}
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=198223&r1=198222&r2=198223&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3object.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3object.cc Mon Dec 30 11:24:21 2013
@@ -406,7 +406,7 @@ J3ObjectHandle* J3ObjectHandle::doNewArr
-#define defAccessor(name, ctype, llvmtype) \
+#define defAccessor(name, ctype, llvmtype, scale) \
void J3ObjectHandle::rawSet##name(uint32_t offset, ctype value) { \
*((ctype*)((uintptr_t)obj() + offset)) = value; \
} \
More information about the vmkit-commits
mailing list