[vmkit-commits] [vmkit] r197887 - more jni functions
Gael Thomas
gael.thomas at lip6.fr
Sun Dec 22 12:25:39 PST 2013
Author: gthomas
Date: Sun Dec 22 14:25:38 2013
New Revision: 197887
URL: http://llvm.org/viewvc/llvm-project?rev=197887&view=rev
Log:
more jni functions
Modified:
vmkit/branches/mcjit/include/j3/j3.h
vmkit/branches/mcjit/include/j3/j3object.h
vmkit/branches/mcjit/lib/j3/vm/j3jni.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=197887&r1=197886&r2=197887&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3.h (original)
+++ vmkit/branches/mcjit/include/j3/j3.h Sun Dec 22 14:25:38 2013
@@ -106,6 +106,8 @@ namespace j3 {
static void nullPointerException() __attribute__((noreturn));
static void classCastException() __attribute__((noreturn));
+
+ static void arrayBoundCheckException() __attribute__((noreturn));
};
}
Modified: vmkit/branches/mcjit/include/j3/j3object.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3object.h?rev=197887&r1=197886&r2=197887&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3object.h (original)
+++ vmkit/branches/mcjit/include/j3/j3object.h Sun Dec 22 14:25:38 2013
@@ -106,6 +106,7 @@ namespace j3 {
public:
uint32_t length() { return _length; }
+ void* content() { return this+1; }
};
class J3ObjectHandle {
@@ -142,13 +143,15 @@ namespace j3 {
void setObjectAt(uint32_t idx, J3ObjectHandle* v);
J3ObjectHandle* getObjectAt(uint32_t idx);
-#define defAccessor(name, ctype, llvmtype) \
- void rawSet##name(uint32_t offset, ctype value); \
- ctype rawGet##name(uint32_t offset); \
- void set##name(J3Field* f, ctype value); \
- ctype get##name(J3Field* f); \
- void set##name##At(uint32_t idx, ctype value); \
- ctype get##name##At(uint32_t idx);
+#define defAccessor(name, ctype, llvmtype) \
+ void rawSet##name(uint32_t offset, ctype value); \
+ ctype rawGet##name(uint32_t offset); \
+ void set##name(J3Field* f, ctype value); \
+ ctype get##name(J3Field* f); \
+ void set##name##At(uint32_t idx, ctype value); \
+ ctype get##name##At(uint32_t idx); \
+ void setRegion##name(uint32_t selfIdx, const ctype* buf, uint32_t bufIdx, uint32_t len); \
+ void getRegion##name(uint32_t selfIdx, const ctype* buf, uint32_t bufIdx, uint32_t len);
onJavaPrimitives(defAccessor);
#undef defAccessor
};
Modified: vmkit/branches/mcjit/lib/j3/vm/j3jni.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3jni.cc?rev=197887&r1=197886&r2=197887&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3jni.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3jni.cc Sun Dec 22 14:25:38 2013
@@ -229,6 +229,13 @@ jmethodID JNICALL GetStaticMethodID(JNIE
return res; \
}
+#define defArrayRegion(jtype, id, j3type) \
+ void JNICALL Set##id##ArrayRegion(JNIEnv* env, jtype##Array array, jsize start, jsize len, const jtype* buf) { \
+ enterJVM(); \
+ array->setRegion##j3type(0, buf, start, len); \
+ leaveJVM(); \
+ }
+
#define defJNIObj(jtype, id, j3type) \
defCall(jtype, id, j3type) \
defNonVirtualCall(jtype, id, j3type) \
@@ -236,7 +243,8 @@ jmethodID JNICALL GetStaticMethodID(JNIE
#define defJNI(jtype, id, j3type) \
defJNIObj(jtype, id, j3type) \
- defNewArray(jtype, id, j3type)
+ defNewArray(jtype, id, j3type) \
+ defArrayRegion(jtype, id, j3type)
defJNIObj(jobject, Object, Object);
defJNI (jboolean, Boolean, Boolean);
@@ -427,15 +435,6 @@ void JNICALL GetLongArrayRegion(JNIEnv*
void JNICALL GetFloatArrayRegion(JNIEnv* env, jfloatArray array, jsize start, jsize len, jfloat* buf) { enterJVM(); leaveJVM(); NYI(); }
void JNICALL GetDoubleArrayRegion(JNIEnv* env, jdoubleArray array, jsize start, jsize len, jdouble* buf) { enterJVM(); leaveJVM(); NYI(); }
-void JNICALL SetBooleanArrayRegion(JNIEnv* env, jbooleanArray array, jsize start, jsize l, const jboolean* buf) { enterJVM(); leaveJVM(); NYI(); }
-void JNICALL SetByteArrayRegion(JNIEnv* env, jbyteArray array, jsize start, jsize len, const jbyte* buf) { enterJVM(); leaveJVM(); NYI(); }
-void JNICALL SetCharArrayRegion(JNIEnv* env, jcharArray array, jsize start, jsize len, const jchar* buf) { enterJVM(); leaveJVM(); NYI(); }
-void JNICALL SetShortArrayRegion(JNIEnv* env, jshortArray array, jsize start, jsize len, const jshort* buf) { enterJVM(); leaveJVM(); NYI(); }
-void JNICALL SetIntArrayRegion(JNIEnv* env, jintArray array, jsize start, jsize len, const jint* buf) { enterJVM(); leaveJVM(); NYI(); }
-void JNICALL SetLongArrayRegion(JNIEnv* env, jlongArray array, jsize start, jsize len, const jlong* buf) { enterJVM(); leaveJVM(); NYI(); }
-void JNICALL SetFloatArrayRegion(JNIEnv* env, jfloatArray array, jsize start, jsize len, const jfloat* buf) { enterJVM(); leaveJVM(); NYI(); }
-void JNICALL SetDoubleArrayRegion(JNIEnv* env, jdoubleArray array, jsize start, jsize len, const jdouble* buf) { enterJVM(); leaveJVM(); NYI(); }
-
jint JNICALL RegisterNatives(JNIEnv* env, jclass clazz, const JNINativeMethod* methods, jint nMethods) {
enterJVM();
J3Class* cl = J3Class::nativeClass(clazz)->asClass();
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=197887&r1=197886&r2=197887&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3object.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3object.cc Sun Dec 22 14:25:38 2013
@@ -344,6 +344,22 @@ J3ObjectHandle* J3ObjectHandle::doNewArr
\
ctype J3ObjectHandle::get##name##At(uint32_t idx) { \
return rawGet##name(sizeof(J3ArrayObject) + idx*sizeof(ctype)); \
+ } \
+ \
+ void J3ObjectHandle::setRegion##name(uint32_t selfIdx, const ctype* buf, uint32_t bufIdx, uint32_t len) { \
+ if(selfIdx + len > arrayLength()) \
+ J3::arrayBoundCheckException(); \
+ memcpy((uint8_t*)array() + sizeof(J3ArrayObject) + selfIdx*sizeof(ctype), \
+ (uint8_t*)buf + bufIdx*sizeof(ctype), \
+ len*sizeof(ctype)); \
+ } \
+ \
+ void J3ObjectHandle::getRegion##name(uint32_t selfIdx, const ctype* buf, uint32_t bufIdx, uint32_t len) { \
+ if(selfIdx + len > arrayLength()) \
+ J3::arrayBoundCheckException(); \
+ memcpy((uint8_t*)buf + bufIdx*sizeof(ctype), \
+ (uint8_t*)array() + sizeof(J3ArrayObject) + selfIdx*sizeof(ctype), \
+ len*sizeof(ctype)); \
}
onJavaPrimitives(defAccessor)
More information about the vmkit-commits
mailing list