From 0de562cd943004840b450deb71c5892a50da13d0 Mon Sep 17 00:00:00 2001 From: llin4 Date: Thu, 29 Mar 2012 14:48:34 +0800 Subject: [PATCH] dalvik: return positive hash code in Dalvik with Houdini 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 Signed-off-by: Qiming Shi --- vm/Dvm.mk | 3 +++ vm/Sync.cpp | 7 ++++++- vm/oo/Object.h | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/vm/Dvm.mk b/vm/Dvm.mk index 2f53391b8..e5835acd4 100644 --- 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 diff --git a/vm/Sync.cpp b/vm/Sync.cpp index f42004cd1..2b4c02578 100644 --- a/vm/Sync.cpp +++ b/vm/Sync.cpp @@ -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 /* diff --git a/vm/oo/Object.h b/vm/oo/Object.h index dc98d314c..67756f674 100644 --- a/vm/oo/Object.h +++ b/vm/oo/Object.h @@ -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 -- 2.11.0