[vmkit-commits] [vmkit] r198342 - Implement JVM_clone()
Gael Thomas
gael.thomas at lip6.fr
Thu Jan 2 11:40:47 PST 2014
Author: gthomas
Date: Thu Jan 2 13:40:47 2014
New Revision: 198342
URL: http://llvm.org/viewvc/llvm-project?rev=198342&view=rev
Log:
Implement JVM_clone()
Modified:
vmkit/branches/mcjit/include/j3/j3class.h
vmkit/branches/mcjit/include/j3/j3object.h
vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc
vmkit/branches/mcjit/lib/j3/vm/j3class.cc
vmkit/branches/mcjit/lib/j3/vm/j3object.cc
vmkit/branches/mcjit/lib/j3/vm/j3options.cc
Modified: vmkit/branches/mcjit/include/j3/j3class.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3class.h?rev=198342&r1=198341&r2=198342&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3class.h (original)
+++ vmkit/branches/mcjit/include/j3/j3class.h Thu Jan 2 13:40:47 2014
@@ -132,6 +132,8 @@ namespace j3 {
static J3ObjectType* nativeClass(J3ObjectHandle* handle);
void dumpInterfaceSlotDescriptors();
+
+ virtual J3ObjectHandle* clone(J3ObjectHandle* obj);
};
class J3Layout : public J3ObjectType {
@@ -217,6 +219,8 @@ namespace j3 {
public:
J3Class(J3ClassLoader* loader, const vmkit::Name* name, J3ClassBytes* bytes);
+ J3ObjectHandle* clone(J3ObjectHandle* obj);
+
size_t nbConstructors() { return _nbConstructors; }
size_t nbPublicConstructors() { return _nbPublicConstructors; }
@@ -268,6 +272,8 @@ namespace j3 {
public:
J3ArrayClass(J3ClassLoader* loader, J3Type* component, const vmkit::Name* name);
+ J3ObjectHandle* clone(J3ObjectHandle* obj);
+
J3Type* component() { return _component; }
bool isArrayClass() { return 1; }
Modified: vmkit/branches/mcjit/include/j3/j3object.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3object.h?rev=198342&r1=198341&r2=198342&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3object.h (original)
+++ vmkit/branches/mcjit/include/j3/j3object.h Thu Jan 2 13:40:47 2014
@@ -165,6 +165,7 @@ namespace j3 {
uint32_t hashCode();
+ void rawObjectCopyTo(uint32_t fromOffset, J3ObjectHandle* to, uint32_t toOffset, uint32_t nbb);
void rawArrayCopyTo(uint32_t fromOffset, J3ObjectHandle* to, uint32_t toOffset, uint32_t nbb);
J3ObjectHandle* rawCASObject(uintptr_t offset, J3ObjectHandle* orig, J3ObjectHandle* value);
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=198342&r1=198341&r2=198342&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc (original)
+++ vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc Thu Jan 2 13:40:47 2014
@@ -43,7 +43,13 @@ void JNICALL JVM_MonitorWait(JNIEnv* env
void JNICALL JVM_MonitorNotify(JNIEnv* env, jobject obj) { enterJVM(); NYI(); leaveJVM(); }
void JNICALL JVM_MonitorNotifyAll(JNIEnv* env, jobject obj) { enterJVM(); NYI(); leaveJVM(); }
-jobject JNICALL JVM_Clone(JNIEnv* env, jobject obj) { enterJVM(); NYI(); leaveJVM(); }
+jobject JNICALL JVM_Clone(JNIEnv* env, jobject obj) {
+ jobject res;
+ enterJVM();
+ res = obj->vt()->type()->asObjectType()->clone(obj);
+ leaveJVM();
+ return res;
+}
/*
* java.lang.String
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=198342&r1=198341&r2=198342&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3class.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3class.cc Thu Jan 2 13:40:47 2014
@@ -180,6 +180,10 @@ J3ObjectType* J3ObjectType::nativeClass(
return (J3ObjectType*)(uintptr_t)handle->getLong(J3Thread::get()->vm()->classClassVMData);
}
+J3ObjectHandle* J3ObjectType::clone(J3ObjectHandle* obj) {
+ J3::internalError("should not happen");
+}
+
void J3ObjectType::prepareInterfaceTable() {
//fprintf(stderr, "prepare interface table of %s\n", name()->cStr());
@@ -296,6 +300,12 @@ J3Class::J3Class(J3ClassLoader* loader,
status = LOADED;
}
+J3ObjectHandle* J3Class::clone(J3ObjectHandle* obj) {
+ J3ObjectHandle* res = J3ObjectHandle::doNewObject(this);
+ obj->rawObjectCopyTo(0, res, 0, structSize());
+ return res;
+}
+
J3ObjectHandle* J3Class::extractAttribute(J3Attribute* attr) {
if(attr)
J3::internalError("extract attribute");
@@ -860,6 +870,13 @@ J3ArrayClass::J3ArrayClass(J3ClassLoader
}
}
+J3ObjectHandle* J3ArrayClass::clone(J3ObjectHandle* obj) {
+ size_t n = obj->arrayLength();
+ J3ObjectHandle* res = J3ObjectHandle::doNewArray(this, n);
+ obj->rawArrayCopyTo(0, res, 0, n<<component()->logSize());
+ return res;
+}
+
J3Method* J3ArrayClass::findVirtualMethod(const vmkit::Name* name, const vmkit::Name* sign, bool error) {
return loader()->vm()->objectClass->findVirtualMethod(name, sign, error);
}
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=198342&r1=198341&r2=198342&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3object.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3object.cc Thu Jan 2 13:40:47 2014
@@ -497,6 +497,13 @@ J3ObjectHandle* J3ObjectHandle::getObjec
return rawGetObject(sizeof(J3ArrayObject) + idx*sizeof(J3Object*));
}
+void J3ObjectHandle::rawObjectCopyTo(uint32_t fromOffset, J3ObjectHandle* to, uint32_t toOffset, uint32_t nbb) {
+ if(isSame(to))
+ memmove((uint8_t*)(to->obj()+1) + toOffset, (uint8_t*)(array()+1) + fromOffset, nbb);
+ else
+ memcpy((uint8_t*)(to->obj()+1) + toOffset, (uint8_t*)(array()+1) + fromOffset, nbb);
+}
+
void J3ObjectHandle::rawArrayCopyTo(uint32_t fromOffset, J3ObjectHandle* to, uint32_t toOffset, uint32_t nbb) {
if(isSame(to))
memmove((uint8_t*)(to->array()+1) + toOffset, (uint8_t*)(array()+1) + fromOffset, nbb);
Modified: vmkit/branches/mcjit/lib/j3/vm/j3options.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3options.cc?rev=198342&r1=198341&r2=198342&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3options.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3options.cc Thu Jan 2 13:40:47 2014
@@ -15,7 +15,7 @@ J3Options::J3Options() {
debugEnterIndent = 1;
- debugExecute = 0;
+ debugExecute = 2;
debugLoad = 0;
debugResolve = 0;
debugIniting = 0;
More information about the vmkit-commits
mailing list