OSDN Git Service

dalvik: return positive hash code in Dalvik with Houdini jb-x86
authorllin4 <ling.lin@intel.com>
Thu, 29 Mar 2012 06:48:34 +0000 (14:48 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Mon, 16 Dec 2013 17:07:32 +0000 (01:07 +0800)
BZ: 29547

port from OTC https://otc-android.intel.com/gerrit/#/c/13089/

Make x86 version of Dalvik to always return positive hash code
when Houdini is enabled in the platform, to match
the ARM app's assumption on its native platform.
MiTalk fails without this fix.

Change-Id: I417c39cd7a40871078f0597c3beffefcfec49189
Orig-Change-Id: I4ce3436b2d4eb90abdffcdeb0b8a0e7ea96a94db
Signed-off-by: llin4 <ling.lin@intel.com>
Signed-off-by: Qiming Shi <qiming.shi@intel.com>
vm/Dvm.mk
vm/Sync.cpp
vm/oo/Object.h

index 2f53391..e5835ac 100644 (file)
--- a/vm/Dvm.mk
+++ b/vm/Dvm.mk
@@ -32,6 +32,9 @@ LOCAL_CFLAGS += -DARCH_VARIANT=\"$(dvm_arch_variant)\"
 # Optional features.  These may impact the size or performance of the VM.
 #
 
+# Houdini support
+LOCAL_CFLAGS += -DMTERP_NO_UNALIGN_64
+
 # Make a debugging version when building the simulator (if not told
 # otherwise) and when explicitly asked.
 dvm_make_debug_vm := false
index f42004c..2b4c025 100644 (file)
@@ -1218,7 +1218,12 @@ void dvmThreadInterrupt(Thread* thread)
 #ifndef WITH_COPYING_GC
 u4 dvmIdentityHashCode(Object *obj)
 {
-    return (u4)obj;
+    /*
+     * The following assumes that objects are allocated at even boundaries, so
+     * the shift preserves uniqueness of hashCode() while guaranteeing a
+     * non-negative result (for the convenience of some applications,like MiTalk).
+     */
+    return (u4)(((u4)obj)>>1);
 }
 #else
 /*
index dc98d31..67756f6 100644 (file)
@@ -274,6 +274,10 @@ struct ArrayObject : Object {
     /* number of elements; immutable after init */
     u4              length;
 
+#ifdef MTERP_NO_UNALIGN_64
+    u4              dummy;      /* padding to get 'contents' at offset 16 */
+#endif
+
     /*
      * Array contents; actual size is (length * sizeof(type)).  This is
      * declared as u8 so that the compiler inserts any necessary padding