I have two concerns for this problem. 1. I think what Chen mentioned above is also a problem. Gcc's implementation for ">>" is different from the code's intention here.
2. Does JVM specification allows an instance is created before finishing its class initialization? Thanks. On Fri, Jul 10, 2009 at 10:26 PM, Barry Hayes <bha...@gmail.com> wrote: > > I have submitted a new version of this code: > https://review.source.android.com/#change,10635 > > Please feel free to review and comment. Thanks all for your patience, > sorry about introducing a defect in the first place. > > On Fri, Jul 10, 2009 at 5:22 AM, Chen Yang<sunsety...@gmail.com> wrote: > > 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 <fad...@android.com> wrote: > >> > >> On Jul 9, 1:13 am, Chen Yang <sunsety...@gmail.com> 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. > >> >> > > > > > > -- > bhayes yat cs dot stanford dot edu is what you should put in your > contact files -- it'll forward to me no matter where I move > > > > --~--~---------~--~----~------------~-------~--~----~ unsubscribe: android-porting+unsubscr...@googlegroups.com website: http://groups.google.com/group/android-porting -~----------~----~----~----~------~----~------~--~---