Index: working_vm/vm/vmcore/include/class_member.h
===================================================================
--- working_vm/vm/vmcore/include/class_member.h (revision 647500)
+++ working_vm/vm/vmcore/include/class_member.h (working copy)
@@ -102,6 +102,19 @@
*/
void* Alloc(size_t size);
+ unsigned pad1;
+ unsigned pad2;
+ unsigned pad3;
+ unsigned pad4;
+
+ // offset of class member;
+ // for virtual methods, the method's offset within the vtable
+ // for static methods, not used, always zero
+ // for instance data, offset within the instance's data block
+ // for static data, offset within the class' static data block
+ unsigned _offset;
+
+
protected:
Class_Member()
{
@@ -118,13 +131,6 @@
_signature = NULL;
}
- // offset of class member;
- // for virtual methods, the method's offset within the vtable
- // for static methods, not used, always zero
- // for instance data, offset within the instance's data block
- // for static data, offset within the class' static data block
- unsigned _offset;
-
bool _synthetic;
bool _deprecated;
AnnotationTable* _annotations;
@@ -145,12 +151,16 @@
#endif
}; // Class_Member
+namespace Jitrino {
+ class APIMagicHandler;
+}
///////////////////////////////////////////////////////////////////////////////
// Fields within Class structures.
///////////////////////////////////////////////////////////////////////////////
struct Field : public Class_Member{
+ friend Jitrino::APIMagicHandler;
public:
//-----------------------
Index: working_vm/vm/jitrino/config/ia32/server.emconf
===================================================================
--- working_vm/vm/jitrino/config/ia32/server.emconf (revision 647500)
+++ working_vm/vm/jitrino/config/ia32/server.emconf (working copy)
@@ -67,7 +67,7 @@
-XX:jit.SD1_OPT.path.optimizer=ssa,simplify,dce,uce,vp_instrument,devirt_virtual,edge_instrument,dessa,statprof
-XX:jit.SD1_OPT.path.devirt_virtual=devirt
--XX:jit.SD1_OPT.path.codegen=bbp,btr,gcpoints,cafl,dce1,i8l,api_magic,light_jni-,early_prop,peephole,itrace-,native,constraints,dce2,regalloc,spillgen,copy,i586,layout,rce+,stack,break-,iprof-,peephole,emitter!,si_insts,gcmap,info
+-XX:jit.SD1_OPT.path.codegen=bbp,btr,gcpoints,cafl,dce1,i8l,api_magic-,light_jni-,early_prop,peephole,itrace-,native,constraints,dce2,regalloc,spillgen,copy,i586,layout,rce+,stack,break-,iprof-,peephole,emitter!,si_insts,gcmap,info
-XX:jit.SD1_OPT.path.dce1=cg_dce
-XX:jit.SD1_OPT.path.dce2=cg_dce
Index: working_vm/vm/jitrino/src/codegenerator/ia32/Ia32APIMagics.cpp
===================================================================
--- working_vm/vm/jitrino/src/codegenerator/ia32/Ia32APIMagics.cpp (revision 647500)
+++ working_vm/vm/jitrino/src/codegenerator/ia32/Ia32APIMagics.cpp (working copy)
@@ -20,8 +20,9 @@
#include "Ia32Inst.h"
#include "Ia32IRManager.h"
+#include "class_member.h"
+#include "open/types.h"
-
//#define ENABLE_GC_RT_CHECKS
namespace Jitrino {
@@ -50,7 +51,7 @@
return callInst->getOpnd(idx);
}
-class APIMagicHandler {
+class APIMagicHandler {
public:
APIMagicHandler(IRManager* _irm, CallInst* _inst, MethodDesc* _md)
: irm(_irm), callInst(_inst), md(_md), typeManager(irm->getTypeManager()) {
@@ -107,6 +108,7 @@
DECLARE_HELPER_INLINER(String_compareTo_Handler_x_String_x_I);
DECLARE_HELPER_INLINER(String_regionMatches_Handler_x_I_x_String_x_I_x_I_x_Z);
DECLARE_HELPER_INLINER(String_indexOf_Handler_x_String_x_I_x_I);
+DECLARE_HELPER_INLINER(OAH_Misc_Accessors_ObjectAccessor_GET_Handler);
void APIMagicsHandlerSession::runImpl() {
CompilationContext* cc = getCompilationContext();
@@ -140,7 +142,38 @@
const char* className = md->getParentType()->getName();
const char* methodName = md->getName();
const char* signature = md->getSignatureString();
- if (!strcmp(className, "java/lang/Integer")) {
+ if (!strcmp(className, "org/apache/harmony/misc/accessors/ObjectAccessor")) {
+ if (getBoolArg("genOAmagic", false)) {
+ if (!strcmp(methodName, "getByte")) {
+ handlers.push_back(new (tmpMM) OAH_Misc_Accessors_ObjectAccessor_GET_Handler(irm, callInst, md));
+ }
+ if (!strcmp(methodName, "getChar")) {
+ handlers.push_back(new (tmpMM) OAH_Misc_Accessors_ObjectAccessor_GET_Handler(irm, callInst, md));
+ }
+ if (!strcmp(methodName, "getFloat")) {
+ handlers.push_back(new (tmpMM) OAH_Misc_Accessors_ObjectAccessor_GET_Handler(irm, callInst, md));
+ }
+ if (!strcmp(methodName, "getInt")) {
+ handlers.push_back(new (tmpMM) OAH_Misc_Accessors_ObjectAccessor_GET_Handler(irm, callInst, md));
+ }
+ if (!strcmp(methodName, "getShort")) {
+ handlers.push_back(new (tmpMM) OAH_Misc_Accessors_ObjectAccessor_GET_Handler(irm, callInst, md));
+ }
+ if (!strcmp(methodName, "getBoolean")) {
+ handlers.push_back(new (tmpMM) OAH_Misc_Accessors_ObjectAccessor_GET_Handler(irm, callInst, md));
+ }
+// if (!strcmp(methodName, "getDouble")) {
+// handlers.push_back(new (tmpMM) OAH_Misc_Accessors_ObjectAccessor_GET_Handler(irm, callInst, md));
+// }
+// if (!strcmp(methodName, "getLong")) {
+// handlers.push_back(new (tmpMM) OAH_Misc_Accessors_ObjectAccessor_GET_Handler(irm, callInst, md));
+// }
+ if (!strcmp(methodName, "get")) {
+ handlers.push_back(new (tmpMM) OAH_Misc_Accessors_ObjectAccessor_GET_Handler(irm, callInst, md));
+ }
+ }
+
+ } else if (!strcmp(className, "java/lang/Integer")) {
if (!strcmp(methodName, "numberOfLeadingZeros") && !strcmp(signature, "(I)I")) {
handlers.push_back(new (tmpMM) Integer_numberOfLeadingZeros_Handler_x_I_x_I(irm, callInst, md));
} else if (!strcmp(methodName, "numberOfTrailingZeros") && !strcmp(signature, "(I)I")) {
@@ -230,6 +263,41 @@
}
+void OAH_Misc_Accessors_ObjectAccessor_GET_Handler::run() {
+ Opnd* trgtObj = getCallSrc(callInst, 1);
+ Opnd* fieldID = getCallSrc(callInst, 2);
+ Opnd* dst = getCallDst(callInst);
+
+ Type * i32Type =irm->getTypeFromTag(Type::Int32);
+ Opnd* tmpOpnd = irm->newOpnd(i32Type);
+
+ // get FID
+ int fidOffset = (int)&(((Field_Handle)0)->_offset);
+ Opnd* fieldOffInObj = irm->newOpnd(i32Type);
+ Opnd* deltaA = irm->newImmOpnd(i32Type, fidOffset);
+
+ Opnd * baseOpnd = irm->newOpnd(typeManager.getManagedPtrType(i32Type));
+ irm->newCopyPseudoInst(Mnemonic_MOV, baseOpnd, fieldID)->insertBefore(callInst);
+// irm->newInst(Mnemonic_INT3)->insertBefore(callInst);
+
+ irm->newInst(Mnemonic_MOV, tmpOpnd, baseOpnd)->insertBefore(callInst);
+ irm->newInst(Mnemonic_ADD, tmpOpnd, deltaA)->insertBefore(callInst);
+ Opnd* memOpnd1 = irm->newMemOpnd(i32Type, tmpOpnd, 0, 0, 0);
+
+ irm->newCopyPseudoInst(Mnemonic_MOV, fieldOffInObj, memOpnd1)->insertBefore(callInst);
+// irm->newInst(Mnemonic_INT3)->insertBefore(callInst);
+
+ irm->newInst(Mnemonic_MOV, tmpOpnd, trgtObj)->insertBefore(callInst);
+ irm->newInst(Mnemonic_ADD, tmpOpnd, fieldOffInObj)->insertBefore(callInst);
+
+ Opnd* memOpnd2 = irm->newMemOpnd(i32Type, tmpOpnd, 0, 0, 0);
+ irm->newCopyPseudoInst(Mnemonic_MOV, dst, memOpnd2)->insertBefore(callInst);
+
+// irm->newInst(Mnemonic_INT3)->insertBefore(callInst);
+
+ callInst->unlink();
+}
+
void Integer_numberOfLeadingZeros_Handler_x_I_x_I::run() {
//mov r2,-1
//bsr r1,arg
Index: working_vm/vm/jitrino/src/optimizer/HLOAPIMagics.h
===================================================================
--- working_vm/vm/jitrino/src/optimizer/HLOAPIMagics.h (revision 647500)
+++ working_vm/vm/jitrino/src/optimizer/HLOAPIMagics.h (working copy)
@@ -172,6 +172,7 @@
handlers.push_back(new (mm) String_indexOf_HLO_Handler(callInst));
}
}
+
}
}
}
Index: working_classlib/modules/luni/src/main/java/java/io/ObjectInputStream.java
===================================================================
--- working_classlib/modules/luni/src/main/java/java/io/ObjectInputStream.java (revision 647500)
+++ working_classlib/modules/luni/src/main/java/java/io/ObjectInputStream.java (working copy)
@@ -30,6 +30,9 @@
import java.util.HashMap;
import java.util.Iterator;
+import org.apache.harmony.misc.accessors.ObjectAccessor;
+import org.apache.harmony.misc.accessors.AccessorFactory;
+
import org.apache.harmony.kernel.vm.VM;
import org.apache.harmony.luni.internal.nls.Messages;
import org.apache.harmony.luni.util.Msg;
@@ -119,6 +122,8 @@
PRIMITIVE_CLASSES.put("double", double.class); //$NON-NLS-1$
}
+ private ObjectAccessor accessor = AccessorFactory.getObjectAccessor();
+
// Internal type used to keep track of validators & corresponding priority
static class InputValidationDesc {
ObjectInputValidation validator;
@@ -1124,41 +1129,39 @@
}
for (ObjectStreamField fieldDesc : fields) {
+
+ // get associated Field
+ long fieldID = fieldDesc.getFieldID(accessor, declaringClass);
+
+ if (fieldID == ObjectStreamField.FIELD_IS_ABSENT) continue;
+
// Code duplication starts, just because Java is typed
if (fieldDesc.isPrimitive()) {
try {
switch (fieldDesc.getTypeCode()) {
case 'B':
- setField(obj, declaringClass, fieldDesc.getName(),
- input.readByte());
+ accessor.setByte(obj, fieldID, input.readByte());
break;
case 'C':
- setField(obj, declaringClass, fieldDesc.getName(),
- input.readChar());
+ accessor.setChar(obj, fieldID, input.readChar());
break;
case 'D':
- setField(obj, declaringClass, fieldDesc.getName(),
- input.readDouble());
+ accessor.setDouble(obj, fieldID, input.readDouble());
break;
case 'F':
- setField(obj, declaringClass, fieldDesc.getName(),
- input.readFloat());
+ accessor.setFloat(obj, fieldID, input.readFloat());
break;
case 'I':
- setField(obj, declaringClass, fieldDesc.getName(),
- input.readInt());
+ accessor.setInt(obj, fieldID, input.readInt());
break;
case 'J':
- setField(obj, declaringClass, fieldDesc.getName(),
- input.readLong());
+ accessor.setLong(obj, fieldID, input.readLong());
break;
case 'S':
- setField(obj, declaringClass, fieldDesc.getName(),
- input.readShort());
+ accessor.setShort(obj, fieldID, input.readShort());
break;
case 'Z':
- setField(obj, declaringClass, fieldDesc.getName(),
- input.readBoolean());
+ accessor.setBoolean(obj, fieldID, input.readBoolean());
break;
default:
throw new StreamCorruptedException(Msg.getString(
@@ -1195,8 +1198,7 @@
+ fieldName }));
}
try {
- objSetField(obj, declaringClass, fieldName, fieldDesc
- .getTypeString(), toSet);
+ accessor.setObject(obj, fieldID, toSet);
} catch (NoSuchFieldError e) {
// Ignored
}
@@ -2434,250 +2436,6 @@
}
/**
- * Set a given declared field named fieldName of
- * instance to the new byte value
- * value.
- *
- * This method could be implemented non-natively on top of java.lang.reflect
- * implementations that support the setAccessible API, at the
- * expense of extra object creation (java.lang.reflect.Field). Otherwise
- * Serialization could not set private fields, except by the use of a native
- * method like this one.
- *
- * @param instance
- * Object whose field to set
- * @param declaringClass
- * instance's declaring class
- * @param fieldName
- * Name of the field to set
- * @param value
- * New value for the field
- *
- * @throws NoSuchFieldError
- * If the field does not exist.
- */
- private static native void setField(Object instance,
- Class> declaringClass, String fieldName, byte value)
- throws NoSuchFieldError;
-
- /**
- * Set a given declared field named fieldName of
- * instance to the new char value
- * value.
- *
- * This method could be implemented non-natively on top of java.lang.reflect
- * implementations that support the setAccessible API, at the
- * expense of extra object creation (java.lang.reflect.Field). Otherwise
- * Serialization could not set private fields, except by the use of a native
- * method like this one.
- *
- * @param instance
- * Object whose field to set
- * @param declaringClass
- * instance's declaring class
- * @param fieldName
- * Name of the field to set
- * @param value
- * New value for the field
- *
- * @throws NoSuchFieldError
- * If the field does not exist.
- */
- private static native void setField(Object instance,
- Class> declaringClass, String fieldName, char value)
- throws NoSuchFieldError;
-
- /**
- * Set a given declared field named fieldName of
- * instance to the new double value
- * value.
- *
- * This method could be implemented non-natively on top of java.lang.reflect
- * implementations that support the setAccessible API, at the
- * expense of extra object creation (java.lang.reflect.Field). Otherwise
- * Serialization could not set private fields, except by the use of a native
- * method like this one.
- *
- * @param instance
- * Object whose field to set
- * @param declaringClass
- * instance's declaring class
- * @param fieldName
- * Name of the field to set
- * @param value
- * New value for the field
- *
- * @throws NoSuchFieldError
- * If the field does not exist.
- */
- private static native void setField(Object instance,
- Class> declaringClass, String fieldName, double value)
- throws NoSuchFieldError;
-
- /**
- * Set a given declared field named fieldName of
- * instance to the new float value
- * value.
- *
- * This method could be implemented non-natively on top of java.lang.reflect
- * implementations that support the setAccessible API, at the
- * expense of extra object creation (java.lang.reflect.Field). Otherwise
- * Serialization could not set private fields, except by the use of a native
- * method like this one.
- *
- * @param instance
- * Object whose field to set
- * @param declaringClass
- * instance's declaring class
- * @param fieldName
- * Name of the field to set
- * @param value
- * New value for the field
- *
- * @throws NoSuchFieldError
- * If the field does not exist.
- */
- private static native void setField(Object instance,
- Class> declaringClass, String fieldName, float value)
- throws NoSuchFieldError;
-
- /**
- * Set a given declared field named fieldName of
- * instance to the new int value
- * value.
- *
- * This method could be implemented non-natively on top of java.lang.reflect
- * implementations that support the setAccessible API, at the
- * expense of extra object creation (java.lang.reflect.Field). Otherwise
- * Serialization could not set private fields, except by the use of a native
- * method like this one.
- *
- * @param instance
- * Object whose field to set
- * @param declaringClass
- * instance's declaring class
- * @param fieldName
- * Name of the field to set
- * @param value
- * New value for the field
- *
- * @throws NoSuchFieldError
- * If the field does not exist.
- */
- private static native void setField(Object instance,
- Class> declaringClass, String fieldName, int value)
- throws NoSuchFieldError;
-
- /**
- * Set a given declared field named fieldName of
- * instance to the new long value
- * value.
- *
- * This method could be implemented non-natively on top of java.lang.reflect
- * implementations that support the setAccessible API, at the
- * expense of extra object creation (java.lang.reflect.Field). Otherwise
- * Serialization could not set private fields, except by the use of a native
- * method like this one.
- *
- * @param instance
- * Object whose field to set
- * @param declaringClass
- * instance's declaring class
- * @param fieldName
- * Name of the field to set
- * @param value
- * New value for the field
- *
- * @throws NoSuchFieldError
- * If the field does not exist.
- */
- private static native void setField(Object instance,
- Class> declaringClass, String fieldName, long value)
- throws NoSuchFieldError;
-
- /**
- * Set a given declared field named fieldName of
- * instance to the new value value.
- *
- * This method could be implemented non-natively on top of java.lang.reflect
- * implementations that support the setAccessible API, at the
- * expense of extra object creation (java.lang.reflect.Field). Otherwise
- * Serialization could not set private fields, except by the use of a native
- * method like this one.
- *
- * @param instance
- * Object whose field to set
- * @param declaringClass
- * Class which declares the field
- * @param fieldName
- * Name of the field to set
- * @param fieldTypeName
- * Name of the class defining the type of the field
- * @param value
- * New value for the field
- *
- * @throws NoSuchFieldError
- * If the field does not exist.
- */
- private static native void objSetField(Object instance,
- Class> declaringClass, String fieldName, String fieldTypeName,
- Object value) throws NoSuchFieldError;
-
- /**
- * Set a given declared field named fieldName of
- * instance to the new short value
- * value.
- *
- * This method could be implemented non-natively on top of java.lang.reflect
- * implementations that support the setAccessible API, at the
- * expense of extra object creation (java.lang.reflect.Field). Otherwise
- * Serialization could not set private fields, except by the use of a native
- * method like this one.
- *
- * @param instance
- * Object whose field to set
- * @param declaringClass
- * instance's declaring class
- * @param fieldName
- * Name of the field to set
- * @param value
- * New value for the field
- *
- * @throws NoSuchFieldError
- * If the field does not exist.
- */
- private static native void setField(Object instance,
- Class> declaringClass, String fieldName, short value)
- throws NoSuchFieldError;
-
- /**
- * Set a given declared field named fieldName of
- * instance to the new boolean value
- * value.
- *
- * This method could be implemented non-natively on top of java.lang.reflect
- * implementations that support the setAccessible API, at the
- * expense of extra object creation (java.lang.reflect.Field). Otherwise
- * Serialization could not set private fields, except by the use of a native
- * method like this one.
- *
- * @param instance
- * Object whose field to set
- * @param declaringClass
- * instance's declaring class
- * @param fieldName
- * Name of the field to set
- * @param value
- * New value for the field
- *
- * @throws NoSuchFieldError
- * If the field does not exist.
- */
- private static native void setField(Object instance,
- Class> declaringClass, String fieldName, boolean value)
- throws NoSuchFieldError;
-
- /**
* Skips length bytes of primitive data from the receiver. It
* should not be used to skip bytes at any arbitrary position; just when
* reading primitive data types (ints, chars, etc).
Index: working_classlib/modules/luni/src/main/java/java/io/ObjectStreamField.java
===================================================================
--- working_classlib/modules/luni/src/main/java/java/io/ObjectStreamField.java (revision 647500)
+++ working_classlib/modules/luni/src/main/java/java/io/ObjectStreamField.java (working copy)
@@ -21,6 +21,8 @@
import java.util.Arrays;
import java.util.Comparator;
+import org.apache.harmony.misc.accessors.ObjectAccessor;
+
/**
* This class represents object fields that are saved to the stream, by
* serialization. Classes can define the collection of fields to be dumped,
@@ -31,6 +33,9 @@
*/
public class ObjectStreamField implements Comparable