how about moving the computation of refOffsets to dvmLinkClass, after the
precacheReferenceOffsets is done?
I have made one improvement for current code which avoid one problem on x86,
and I have passed verification in kvm.
diff --git a/vm/oo/Class.c b/vm/oo/Class.c
index 3b11724..85fa5a3 100644
--- a/vm/oo/Class.c
+++ b/vm/oo/Class.c
@@ -4252,28 +4252,29 @@ noverify:
if (clazz->refOffsets != CLASS_WALK_SUPER) {
InstField *f;
int i;
+ int cnt= clazz->ifieldRefCount;
/* All of the fields that contain object references
* are guaranteed to be at the beginning of the ifields list.
*/
- f = clazz->ifields;
- for (i = 0; i < clazz->ifieldRefCount; i++) {
- /*
- * Note that, per the comment on struct InstField,
- * f->byteOffset is the offset from the beginning of
- * obj, not the offset into obj->instanceData.
- */
- assert(f->byteOffset >= CLASS_SMALLEST_OFFSET);
- assert((f->byteOffset & (CLASS_OFFSET_ALIGNMENT - 1)) == 0);
- u4 newBit = CLASS_BIT_FROM_OFFSET(f->byteOffset);
- if (newBit != 0) {
- clazz->refOffsets |= newBit;
- } else {
+ if(cnt>0) {
+#define CLASS_BIT_SHIFT_COUNT(byteOffset) (((unsigned int)(byteOffset) -
CLASS_SMALLEST_OFFSET) / CLASS_OFFSET_ALIGNMENT)
+ f = clazz->ifields;
+ if( CLASS_BIT_SHIFT_COUNT(f[cnt-1].byteOffset) >= CLASS_BITS_PER_WORD)
clazz->refOffsets = CLASS_WALK_SUPER;
- break;
+ else for (i = 0; i < cnt; i++) {
+ /*
+ * Note that, per the comment on struct InstField,
+ * f->byteOffset is the offset from the beginning of
+ * obj, not the offset into obj->instanceData.
+ */
+ assert(f->byteOffset >= CLASS_SMALLEST_OFFSET);
+ assert((f->byteOffset & (CLASS_OFFSET_ALIGNMENT - 1)) ==
0);
+ u4 newBit = CLASS_BIT_FROM_OFFSET(f->byteOffset);
+ clazz->refOffsets |= newBit;
+ f++;
}
- f++;
- }
+ }
}
if (dvmCheckException(self)) {
On Fri, Jul 10, 2009 at 5:41 AM, fadden <[email protected]> wrote:
>
> On Jul 9, 1:13 am, Chen Yang <[email protected]> wrote:
> > Any explanation on why it doesn't show on ARM platform?
>
> It does -- it comes down to timing and luck. If you have a class that
> creates an instance of itself during class initialization, and a GC
> happens before class init completes, you will likely have some trouble
> later on.
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
unsubscribe: [email protected]
website: http://groups.google.com/group/android-porting
-~----------~----~----~----~------~----~------~--~---