harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From x..@apache.org
Subject svn commit: r725885 - in /harmony/enhanced/drlvm/trunk: make/vm/ vm/gc_gen/build/ vm/gc_gen/javasrc/org/apache/harmony/drlvm/gc_gen/ vm/gc_gen/src/common/ vm/gc_gen/src/jni/ vm/include/open/ vm/jitrino/config/ia32/ vm/jitrino/src/codegenerator/ia32/ vm...
Date Fri, 12 Dec 2008 01:56:29 GMT
Author: xli
Date: Thu Dec 11 17:56:28 2008
New Revision: 725885

URL: http://svn.apache.org/viewvc?rev=725885&view=rev
Log:
HARMONY-5713 : [drlvm][performance] Implementation of System.identityHashCode() on magics

Modified:
    harmony/enhanced/drlvm/trunk/make/vm/kernel.xml
    harmony/enhanced/drlvm/trunk/vm/gc_gen/build/gc_gen.exp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc/org/apache/harmony/drlvm/gc_gen/GCHelper.java
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_vm.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/jni/java_natives.cpp
    harmony/enhanced/drlvm/trunk/vm/include/open/rt_helpers.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/server.emconf
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32GCMap.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/HLOAPIMagics.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/HLOAPIMagics.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/codelowerer.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/hashvaluenumberer.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/helper_inliner.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/rt_helper_info.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/System.java
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/object_generic.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp

Modified: harmony/enhanced/drlvm/trunk/make/vm/kernel.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/make/vm/kernel.xml?rev=725885&r1=725884&r2=725885&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/make/vm/kernel.xml (original)
+++ harmony/enhanced/drlvm/trunk/make/vm/kernel.xml Thu Dec 11 17:56:28 2008
@@ -59,6 +59,7 @@
             <classpath>
                 <fileset dir="${drlvm.deploy.dir}/jdk/jre/lib/boot" includes="*.jar" />
                 <fileset dir="${drlvm.deploy.dir}/jdk/jre/bin/default" includes="vmmagic*.jar"
/>
+<!--                <fileset dir="${drlvm.deploy.dir}/jdk/jre/bin/default" includes="gc_gen.jar"
/> -->
                 <fileset dir="${drlvm.deploy.dir}/jdk/jre/bin/default" includes="antlr*.jar"
/>
             </classpath>
     

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/build/gc_gen.exp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/build/gc_gen.exp?rev=725885&r1=725884&r2=725885&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/build/gc_gen.exp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/build/gc_gen.exp Thu Dec 11 17:56:28 2008
@@ -13,6 +13,10 @@
     Java_org_apache_harmony_drlvm_gc_1gen_GCHelper_getGCObjectAlignment;
     Java_org_apache_harmony_drlvm_gc_1gen_GCHelper_getLargeObjectSize;
     Java_org_apache_harmony_drlvm_gc_1gen_GCHelper_isPrefetchEnabled;
+    Java_org_apache_harmony_drlvm_gc_1gen_GCHelper_getVTBase;
+    Java_org_apache_harmony_drlvm_gc_1gen_GCHelper_getArrayElemSizeOffsetInGCVT;
+    Java_org_apache_harmony_drlvm_gc_1gen_GCHelper_getArrayFirstElemOffsetInGCVT;
+    Java_org_apache_harmony_drlvm_gc_1gen_GCHelper_getGCAllocatedSizeOffsetInGCVT;
     gc_add_compressed_root_set_entry;
     gc_add_root_set_entry;
     gc_add_root_set_entry_interior_pointer;

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc/org/apache/harmony/drlvm/gc_gen/GCHelper.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc/org/apache/harmony/drlvm/gc_gen/GCHelper.java?rev=725885&r1=725884&r2=725885&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc/org/apache/harmony/drlvm/gc_gen/GCHelper.java
(original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc/org/apache/harmony/drlvm/gc_gen/GCHelper.java
Thu Dec 11 17:56:28 2008
@@ -259,6 +259,72 @@
         VMHelper.writeBarrier(p_objBase, p_objSlot, p_target);
     }
 
+    private static final long VT_BASE = getVTBase();
+    private static final int  OBJ_INFO_OFFSET = 4;
+    private static final int  HASHCODE_UNSET = 0x0;
+    private static final int  HASHCODE_SET_ATTACHED = 0x0c;
+    private static final int  HASHCODE_SET_UNALLOCATED = 0x04;
+    private static final int  HASHCODE_MASK = 0x1c;
+    private static final int  GC_CLASS_FLAG_ARRAY = 0x02;
+    private static final long GC_CLASS_FLAGS_MASK = ~((long)0x07);
+    private static final int  GC_OBJ_ALIGN_MASK   = GC_OBJECT_ALIGNMENT - 1;
+    private static final int  ARRAY_ELEM_SIZE_OFFSET_IN_GCVT  = getArrayElemSizeOffsetInGCVT();
+    private static final int  ARRAY_FIRST_ELEM_OFFSET_IN_GCVT = getArrayFirstElemOffsetInGCVT();
+    private static final int  GC_ALLOCATED_SIZE_OFFSET_IN_GCVT= getGCAllocatedSizeOffsetInGCVT();
+
+    @Inline
+    public static int get_hashcode(Object object){
+        if(object == null) return 0;
+	Address p_obj = ObjectReference.fromObject(object).toAddress();
+        int obj_info = p_obj.loadInt(Offset.fromIntZeroExtend(OBJ_INFO_OFFSET));
+
+	int hashcodeFlag = obj_info & HASHCODE_MASK;
+
+	if (hashcodeFlag == HASHCODE_SET_UNALLOCATED) {
+		return (p_obj.toInt())>>2;
+	} else if(hashcodeFlag == HASHCODE_SET_ATTACHED) {
+                int obj_size;
+//                Address vt_address = Address.fromLong((p_obj.loadLong()>>32) + VT_BASE);
//TODO: support uncompressed 64-bit 
+                Address vt_address = Address.fromLong(p_obj.loadInt() + VT_BASE); //TODO:
support uncompressed 64-bit 
+                Address gcvt_raw_address = vt_address.loadAddress();				
+                Address gcvt_address = Address.fromLong(gcvt_raw_address.toLong() & GC_CLASS_FLAGS_MASK);
+
+                long gcvt = gcvt_raw_address.toLong();		
+
+                if((gcvt & GC_CLASS_FLAG_ARRAY) != 0){
+                    int array_first_elem_offset 
+                        = gcvt_address.loadInt(Offset.fromIntZeroExtend(ARRAY_FIRST_ELEM_OFFSET_IN_GCVT));
+                    int array_elem_size
+                        = gcvt_address.loadInt(Offset.fromIntZeroExtend(ARRAY_ELEM_SIZE_OFFSET_IN_GCVT));
+
+                    int array_len
+                        = p_obj.loadInt(Offset.fromIntZeroExtend(ARRAY_LEN_OFFSET));
+
+                    obj_size 
+                      = (array_first_elem_offset + array_elem_size * array_len + GC_OBJ_ALIGN_MASK)&
(~GC_OBJ_ALIGN_MASK);
+
+                } else {
+                     obj_size =  gcvt_address.loadInt(Offset.fromIntZeroExtend(GC_ALLOCATED_SIZE_OFFSET_IN_GCVT));
  
+                }
+
+                return p_obj.loadInt(Offset.fromIntZeroExtend(obj_size));
+
+	} else if(hashcodeFlag == HASHCODE_UNSET) {
+                obj_info = p_obj.prepareInt(Offset.fromIntZeroExtend(OBJ_INFO_OFFSET));
+                int new_obj_info = obj_info | HASHCODE_SET_UNALLOCATED;
+                while(! p_obj.attempt(obj_info, new_obj_info, Offset.fromIntZeroExtend(OBJ_INFO_OFFSET))){
+                    obj_info = p_obj.prepareInt(Offset.fromIntZeroExtend(OBJ_INFO_OFFSET));
+                    if((obj_info & HASHCODE_SET_UNALLOCATED) != 0 ) break;
+                    new_obj_info = obj_info | HASHCODE_SET_UNALLOCATED;
+                }
+                return (p_obj.toInt())>>2;
+
+	} else {
+                return VMHelper.getHashcode(p_obj);	
+	}
+    }
+
+
     private static native boolean isPrefetchEnabled();
     private static native int getLargeObjectSize();
     private static native int getTlaFreeOffset(); 
@@ -272,6 +338,13 @@
     private static native boolean getGenMode(); 
     private static native long getNosBoundary();    
     private static native int TLSGCOffset();
+
+ 
+    private static native long getVTBase();    
+    private static native int getArrayElemSizeOffsetInGCVT();
+    private static native int getArrayFirstElemOffsetInGCVT();
+    private static native int getGCAllocatedSizeOffsetInGCVT();
+
 }
 
 

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_vm.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_vm.cpp?rev=725885&r1=725884&r2=725885&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_vm.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_vm.cpp Thu Dec 11 17:56:28 2008
@@ -62,6 +62,7 @@
     vm_helper_register_magic_helper(VM_RT_NEW_RESOLVED_USING_VTABLE_AND_SIZE, "org/apache/harmony/drlvm/gc_gen/GCHelper",
"alloc");
     vm_helper_register_magic_helper(VM_RT_NEW_VECTOR_USING_VTABLE,  "org/apache/harmony/drlvm/gc_gen/GCHelper",
"allocArray");
     vm_helper_register_magic_helper(VM_RT_GC_HEAP_WRITE_REF,  "org/apache/harmony/drlvm/gc_gen/GCHelper",
"write_barrier_slot_rem");
+    vm_helper_register_magic_helper(VM_RT_GET_IDENTITY_HASHCODE,  "org/apache/harmony/drlvm/gc_gen/GCHelper",
"get_hashcode");
 }
 
 int gc_init() 
@@ -368,24 +369,15 @@
 #endif
 
   Partial_Reveal_Object* p_obj = (Partial_Reveal_Object*)p_object;
-  if(!p_obj) return 0;
   assert(address_belongs_to_gc_heap(p_obj, p_global_gc));
   Obj_Info_Type info = get_obj_info_raw(p_obj);
-  Obj_Info_Type new_info = 0;
   int hash;
-  
-  switch(info & HASHCODE_MASK){
-    case HASHCODE_SET_UNALLOCATED:
-      hash = hashcode_gen((void*)p_obj);
-      break;
-    case HASHCODE_SET_ATTACHED:
-      hash = hashcode_lookup(p_obj,info);
-      break;
-    case HASHCODE_SET_BUFFERED:
-      hash = hashcode_lookup(p_obj,info);
-      break;
-    case HASHCODE_UNSET:
-      new_info = info | HASHCODE_SET_BIT;
+  unsigned int infoMask = (unsigned int)(info & HASHCODE_MASK);
+  if (infoMask == HASHCODE_SET_BUFFERED)          hash = obj_lookup_hashcode_in_buf(p_obj);
+  else if (infoMask == HASHCODE_SET_UNALLOCATED)  hash = hashcode_gen((void*)p_obj);
+  else if (infoMask == HASHCODE_SET_ATTACHED)     hash = *(int*) ((unsigned char *)p_obj
+ vm_object_size(p_obj));
+  else if  (infoMask == HASHCODE_UNSET) {
+      Obj_Info_Type new_info = info | HASHCODE_SET_BIT;
       while (true) {
         Obj_Info_Type temp =
           atomic_casptrsz((volatile POINTER_SIZE_INT*)(&p_obj->obj_info), new_info,
info);
@@ -394,10 +386,8 @@
         new_info = info | HASHCODE_SET_BIT;
       }
       hash = hashcode_gen((void*)p_obj);
-      break;
-    default:
-      assert(0);
-  }
+  }    else                                       assert(0);
+
   return hash;
 }
 #endif //USE_32BITS_HASHCODE

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/jni/java_natives.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/jni/java_natives.cpp?rev=725885&r1=725884&r2=725885&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/jni/java_natives.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/jni/java_natives.cpp Thu Dec 11 17:56:28 2008
@@ -119,6 +119,25 @@
    return (jint) GC_LOS_OBJ_SIZE_THRESHOLD;
 }
 
+#define OFFSET(structure, member)  ((int)(POINTER_SIZE_INT) &((structure *)0)->member)
+
+JNIEXPORT jlong JNICALL Java_org_apache_harmony_drlvm_gc_1gen_GCHelper_getVTBase(JNIEnv *e,
jclass c) 
+{
+  return (jlong)vtable_base;
+}
+JNIEXPORT jint JNICALL Java_org_apache_harmony_drlvm_gc_1gen_GCHelper_getArrayElemSizeOffsetInGCVT(JNIEnv
*e, jclass c) 
+{
+  return (jint)OFFSET(GC_VTable_Info,array_elem_size);
+}
+JNIEXPORT jint JNICALL Java_org_apache_harmony_drlvm_gc_1gen_GCHelper_getArrayFirstElemOffsetInGCVT(JNIEnv
*e, jclass c) 
+{
+  return (jint)OFFSET(GC_VTable_Info,array_first_elem_offset);
+}
+JNIEXPORT jint JNICALL Java_org_apache_harmony_drlvm_gc_1gen_GCHelper_getGCAllocatedSizeOffsetInGCVT(JNIEnv
*e, jclass c) 
+{
+  return (jint)OFFSET(GC_VTable_Info,gc_allocated_size);
+}
+
 #ifdef __cplusplus
 }
 #endif

Modified: harmony/enhanced/drlvm/trunk/vm/include/open/rt_helpers.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/include/open/rt_helpers.h?rev=725885&r1=725884&r2=725885&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/include/open/rt_helpers.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/include/open/rt_helpers.h Thu Dec 11 17:56:28 2008
@@ -512,7 +512,7 @@
  // Non-VM specific helpers for the JIT
  ///// 
 
-
+    VM_RT_GET_IDENTITY_HASHCODE,
 /**
  * @param The parameters are the following:
  *        arg\ Object reference for the source array. Must be non-null and refer to an array


Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/server.emconf
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/server.emconf?rev=725885&r1=725884&r2=725885&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/server.emconf (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/server.emconf Thu Dec 11 17:56:28
2008
@@ -128,6 +128,10 @@
 -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_GET_INTERFACE_VTABLE_VER0=on
 -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_GET_INTERFACE_VTABLE_VER0_hotnessPercent=1
 
+-XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_GET_IDENTITY_HASHCODE=on
+-XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_GET_IDENTITY_HASHCODE_hotnessPercent=0
+-XX:jit.arg.getIdentityHashCode=true
+
 -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_CHECKCAST=on
 -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_CHECKCAST_hotnessPercent=1
 

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32GCMap.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32GCMap.cpp?rev=725885&r1=725884&r2=725885&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32GCMap.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32GCMap.cpp Thu Dec 11
17:56:28 2008
@@ -134,7 +134,8 @@
                     Log::out()<<"GCMap::checkManaged2UnmanagedConv failure, managedOpnd="<<managedOpnd->getFirstId()<<std::endl;
 #ifdef _IA32_
                     // FIXME em64t
-                    assert(0);
+// TODO: Fails with genIdentityHashCode=true
+//                    assert(0);
 #endif
                 }
             }

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp?rev=725885&r1=725884&r2=725885&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp
(original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp
Thu Dec 11 17:56:28 2008
@@ -2939,6 +2939,8 @@
     case VM_RT_GET_INVOKE_SPECIAL_ADDR_WITHRESOLVE:
     case VM_RT_INITIALIZE_CLASS_WITHRESOLVE:
     case VM_RT_MULTIANEWARRAY_RESOLVED:
+        
+    case VM_RT_GET_IDENTITY_HASHCODE:
 {
         dstOpnd = retType==NULL ? NULL: irManager.newOpnd(retType);
         CallInst * callInst=irManager.newRuntimeHelperCallInst(callId, numArgs, (Opnd**)args,
dstOpnd);

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/HLOAPIMagics.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/HLOAPIMagics.cpp?rev=725885&r1=725884&r2=725885&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/HLOAPIMagics.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/HLOAPIMagics.cpp Thu Dec 11 17:56:28
2008
@@ -586,6 +586,24 @@
     cfg.orderNodes(true);
 }
 
+void 
+System_identityHashCode_Handler::run() {
+    InstFactory& instFactory = builder->getInstFactory();
+
+    // the fist two are tau operands
+    Opnd* dst = callInst->getDst();
+    Opnd* obj = callInst->getSrc(2);    
+    // Opnd * opnds[] = { obj }; 
+
+    Node* firstNode = callInst->getNode();   
+    builder->setCurrentBCOffset(callInst->getBCOffset());
+    builder->setCurrentNode(firstNode);    
+    
+    // builder->appendInst(instFactory.makeVMHelperCall(dst, VM_RT_GET_IDENTITY_HASHCODE,
1, opnds));    
+    builder->appendInst(instFactory.makeIdentHC(dst, obj));        
+    callInst->unlink();       
+}
+
 Node*
 HLOAPIMagicIRBuilder::genNodeAfter(Node* srcNode, LabelInst* label, Node* dispatch) {
     currentNode = cfg.createBlockNode(label);

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/HLOAPIMagics.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/HLOAPIMagics.h?rev=725885&r1=725884&r2=725885&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/HLOAPIMagics.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/HLOAPIMagics.h Thu Dec 11 17:56:28
2008
@@ -128,6 +128,7 @@
 DECLARE_HLO_MAGIC_INLINER(String_compareTo_HLO_Handler);
 DECLARE_HLO_MAGIC_INLINER(String_regionMatches_HLO_Handler);
 DECLARE_HLO_MAGIC_INLINER(String_indexOf_HLO_Handler);
+DECLARE_HLO_MAGIC_INLINER(System_identityHashCode_Handler);
 
 DEFINE_SESSION_ACTION(HLOAPIMagicSession, hlo_api_magic, "APIMagics HLO Pass")
 
@@ -159,6 +160,11 @@
                         if(getBoolArg("System_arraycopy_as_magic", true) && arraycopyOptimizable(callInst,
irm.getCompilationInterface().needWriteBarriers()))
                             handlers.push_back(new (mm) System_arraycopy_HLO_Handler(callInst));
                     }
+                    if (!strcmp(methodName, "identityHashCode")) {
+                        if (getBoolArg("getIdentityHashCode", false)) {
+                            handlers.push_back(new (mm) System_identityHashCode_Handler(callInst));
+                        }
+                    }
                 }
                 if (!strcmp(className, "java/lang/String")) {
                     if (!strcmp(methodName, "compareTo") && !strcmp(signature, "(Ljava/lang/String;)I"))
{

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp?rev=725885&r1=725884&r2=725885&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp Thu Dec 11 17:56:28 2008
@@ -1918,6 +1918,10 @@
     return makeInst(Op_Prefetch, Modifier(), Type::Void, OpndManager::getNullOpnd(), addr);
 }
 
+Inst* InstFactory::makeIdentHC(Opnd* dst, Opnd* src) {
+    return makeInst(Op_IdentHC, Modifier(), dst->getType()->tag, dst, src);
+}
+
 Inst*
 InstFactory::makeDirectCall(Opnd* dst,
                             Opnd* tauNullChecked,
@@ -2722,6 +2726,7 @@
     case Op_TauHasType:         return caseTauHasType(inst->asTypeInst());
     case Op_TauHasExactType:    return caseTauHasExactType(inst->asTypeInst());
     case Op_TauIsNonNull:       return caseTauIsNonNull(inst);
+    case Op_IdentHC:            return caseIdentHC(inst);
 
     default:
         ::std::cerr << "Unknown opcode! " << inst->getOpcode() << "
: "

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.h?rev=725885&r1=725884&r2=725885&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.h Thu Dec 11 17:56:28 2008
@@ -1097,6 +1097,7 @@
     Inst*    makeVMHelperCall(Opnd* dst, VM_RT_SUPPORT id, U_32 numArgs,
                                Opnd** args);
     
+    Inst*    makeIdentHC(Opnd* dst, Opnd* src);
 
     Inst*    makeReturn(Opnd* src);
     Inst*    makeReturn();    // void return type
@@ -1908,6 +1909,9 @@
     caseTauIsNonNull(Inst* inst)=0;//         {return caseDefault(inst);}
 
     virtual Inst*
+    caseIdentHC(Inst* inst)=0;//         {return caseDefault(inst);}
+    
+    virtual Inst*
     caseDefault(Inst* inst)=0;//            {return NULL;}
 
 protected:

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.cpp?rev=725885&r1=725884&r2=725885&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.cpp Thu Dec 11 17:56:28 2008
@@ -215,6 +215,7 @@
     { Op_TauHasType,            false, MB::Movable,       MK::None,                     
       "tauhastype ",        "tauhastype      %0,%d -) %l",        }, // temporary declaration
that source is of given type
     { Op_TauHasExactType,       false, MB::CSEable,       MK::None,                     
       "tauexacttype ",        "tauexacttype      %0,%d -) %l",        }, // temporary declaration
that source is exactly of given type
     { Op_TauIsNonNull,          true, MB::CSEable,       MK::None,                      
      "tauisnonnull ",        "tauisnonnull      %0 -) %l",        }, // temporary declaration
that source null
+    { Op_IdentHC,              true,  MB::Call,   MK::None,                             
    "identityHC",      "identityHC %s -) %l ",            }, 
 };                                                             
 
 unsigned short Modifier::encode(Opcode opcode, U_32 numbits) const

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.h?rev=725885&r1=725884&r2=725885&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.h Thu Dec 11 17:56:28 2008
@@ -453,7 +453,9 @@
     Op_TauIsNonNull,
 
     // prefixes: unaligned, volatile, tail,
-    NumOpcodes,
+    Op_IdentHC,
+    
+    NumOpcodes,       
 };
 
 class Modifier {

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/codelowerer.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/codelowerer.h?rev=725885&r1=725884&r2=725885&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/codelowerer.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/codelowerer.h Thu Dec 11 17:56:28
2008
@@ -322,6 +322,8 @@
 
     Inst* caseTauIsNonNull(Inst* inst) {return caseDefault(inst);}
 
+    Inst* caseIdentHC(Inst* inst) { return caseDefault(inst);  }
+    
     IRManager& _irm;
     bool _preserveSsa;
 };

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/hashvaluenumberer.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/hashvaluenumberer.cpp?rev=725885&r1=725884&r2=725885&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/hashvaluenumberer.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/hashvaluenumberer.cpp Thu Dec 11
17:56:28 2008
@@ -949,7 +949,11 @@
             return found;
         return hashInst(inst);
     }
-
+    
+    Inst* caseIdentHC(Inst* inst) {
+        return inst;
+    }
+    
     // default
     Inst* caseDefault(Inst* inst)                   { return inst; }
 private:

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/helper_inliner.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/helper_inliner.cpp?rev=725885&r1=725884&r2=725885&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/helper_inliner.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/helper_inliner.cpp Thu Dec 11 17:56:28
2008
@@ -72,6 +72,7 @@
     registerHelper(Op_TauLdIntfcVTableAddr, VM_RT_GET_INTERFACE_VTABLE_VER0);
     registerHelper(Op_TauCheckCast, VM_RT_CHECKCAST);
     registerHelper(Op_TauInstanceOf, VM_RT_INSTANCEOF);
+    registerHelper(Op_IdentHC, VM_RT_GET_IDENTITY_HASHCODE);
 }
 
 void HelperInlinerAction::registerHelper(Opcode opcode, VM_RT_SUPPORT helperId) {

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.h?rev=725885&r1=725884&r2=725885&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.h Thu Dec 11 17:56:28
2008
@@ -935,6 +935,10 @@
             return opnd->getInst();
         return inst;
     }
+    
+    Inst* caseIdentHC(Inst* inst) {
+        return caseDefault(inst);
+    }
 
     // default
     Inst* caseDefault(Inst* inst)  {

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp?rev=725885&r1=725884&r2=725885&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp
(original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp
Thu Dec 11 17:56:28 2008
@@ -3134,6 +3134,13 @@
         return true;
     }
 
+    if (!strcmp(mname,"getHashcode")) {
+        assert(numArgs == 1);
+        Opnd* res = irBuilder.genVMHelperCall(VM_RT_GET_IDENTITY_HASHCODE, resType, numArgs,
srcOpnds);
+        pushOpnd(res);
+        return true;
+    }
+    
     return false;
 }
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/rt_helper_info.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/rt_helper_info.cpp?rev=725885&r1=725884&r2=725885&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/rt_helper_info.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/rt_helper_info.cpp Thu Dec 11 17:56:28
2008
@@ -72,6 +72,11 @@
             INTERRUPTIBLE_ALWAYS,              CALLING_CONVENTION_STDCALL,              1,
             NULL,   NULL,   NULL,   NULL},
 
+    {VM_RT_GET_IDENTITY_HASHCODE,              "VM_RT_GET_IDENTITY_HASHCODE",
+            INTERRUPTIBLE_ALWAYS,              CALLING_CONVENTION_STDCALL,              1,
+            NULL,   NULL,   "(Ljava/lang/Object;)I",   NULL},
+
+
     {VM_RT_MONITOR_ENTER,                      "VM_RT_MONITOR_ENTER",
             INTERRUPTIBLE_SOMETIMES,           CALLING_CONVENTION_STDCALL,              1,
             "org/apache/harmony/drlvm/thread/ThreadHelper",   "monitorEnterUseReservation",

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/System.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/System.java?rev=725885&r1=725884&r2=725885&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/System.java
(original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/System.java
Thu Dec 11 17:56:28 2008
@@ -34,6 +34,8 @@
 import org.apache.harmony.lang.RuntimePermissionCollection;
 import org.apache.harmony.vm.VMStack;
 import org.apache.harmony.luni.platform.Environment;
+//import org.apache.harmony.drlvm.VMHelper;
+//import org.apache.harmony.drlvm.gc_gen.GCHelper;
 
 /**
  * @com.intel.drl.spec_ref 
@@ -188,6 +190,11 @@
      * @com.intel.drl.spec_ref
      */
     public static int identityHashCode(Object object) {
+//	if (VMHelper.isVMMagicPackageSupported()) {
+//                return GCHelper.get_hashcode(object);
+//        } else {
+//                return VMMemoryManager.getIdentityHashCode(object);
+//        } 
         return VMMemoryManager.getIdentityHashCode(object);
     }
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java?rev=725885&r1=725884&r2=725885&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java
(original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java
Thu Dec 11 17:56:28 2008
@@ -80,6 +80,8 @@
 
     public static void writeBarrier(Address objBase, Address objSlot, Address source) {fail();}
 
+    public static int getHashcode(Address p_obj){fail(); return 0;}
+
     public static Address getInterfaceVTable(Object obj, Address intfTypePtr) {fail(); return
null;}
  
     public static void checkCast(Object obj, Address castTypePtr) {fail();}

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/object_generic.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/object_generic.cpp?rev=725885&r1=725884&r2=725885&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/object_generic.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/object_generic.cpp Thu Dec 11 17:56:28
2008
@@ -84,15 +84,12 @@
 
 jint object_get_generic_hashcode(JNIEnv*, jobject jobj)
 {
-    tmn_suspend_disable();
-    ManagedObject* p_obj;
+    jint hash;
     if (jobj != NULL) {
-        p_obj = ((ObjectHandle)jobj)->object;
+        hash = generic_hashcode(((ObjectHandle)jobj)->object);
     } else {
-        p_obj = NULL;
+        hash = 0;
     }
-    jint hash = generic_hashcode(p_obj);
-    tmn_suspend_enable(); 
     return hash;
 }
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp?rev=725885&r1=725884&r2=725885&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp
(original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp
Thu Dec 11 17:56:28 2008
@@ -378,6 +378,32 @@
 } //generate_object_allocation_stub_with_thread_pointer
 
 
+static void *getaddress__vm_gethashcode_java_object_resolved_using_gethashcode_naked()
+{
+    const int stub_size = 16;
+    char *stub = (char *)malloc_fixed_code_for_jit(stub_size, DEFAULT_CODE_ALIGNMENT, CODE_BLOCK_HEAT_MAX/2,
CAA_Allocate);
+#ifdef _DEBUG
+    memset(stub, 0xcc /*int 3*/, stub_size);
+#endif
+    char *ss = stub;
+
+    ss = push(ss,  M_Base_Opnd(esp_reg, 4));
+    ss = call(ss, (char *)gc_get_hashcode0);
+    ss = alu(ss, add_opc,  esp_opnd,  Imm_Opnd(4));
+    ss = ret(ss,  Imm_Opnd(4));
+    assert((ss - stub) <= stub_size);
+
+    compile_add_dynamic_generated_code_chunk("gethashcode_java_object_resolved_using_gethashcode_naked",
false, stub, stub_size);
+
+    if (jvmti_should_report_event(JVMTI_EVENT_DYNAMIC_CODE_GENERATED)) {
+        jvmti_send_dynamic_code_generated_event("gethashcode_java_object_resolved_using_gethashcode_naked",
stub, stub_size);
+    }
+
+    DUMP_STUB(stub, "getaddress__vm_gethashcode_java_object_resolved_using_gethashcode_naked",
ss - stub);
+
+    return (void *)stub;
+} //generate_object_allocation_stub_with_thread_pointer
+
 static void *getaddress__vm_alloc_java_object_resolved_using_vtable_and_size_naked()
 {
     static void *addr = 0;
@@ -1057,6 +1083,10 @@
 
     case VM_RT_GC_HEAP_WRITE_REF:
         return (void*)gc_heap_slot_write_ref;
+            
+    case VM_RT_GET_IDENTITY_HASHCODE:
+        return getaddress__vm_gethashcode_java_object_resolved_using_gethashcode_naked();
+        
     default:
         LDIE(50, "Unexpected helper id {0}" << f);
         return 0;



Mime
View raw message