Return-Path: Delivered-To: apmail-incubator-harmony-dev-archive@www.apache.org Received: (qmail 65032 invoked from network); 1 Sep 2006 12:09:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 1 Sep 2006 12:09:45 -0000 Received: (qmail 64029 invoked by uid 500); 1 Sep 2006 12:09:41 -0000 Delivered-To: apmail-incubator-harmony-dev-archive@incubator.apache.org Received: (qmail 63991 invoked by uid 500); 1 Sep 2006 12:09:41 -0000 Mailing-List: contact harmony-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-dev@incubator.apache.org Received: (qmail 63980 invoked by uid 99); 1 Sep 2006 12:09:41 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Sep 2006 05:09:41 -0700 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=DNS_FROM_RFC_ABUSE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of artem.aliev@gmail.com designates 64.233.162.192 as permitted sender) Received: from [64.233.162.192] (HELO nz-out-0102.google.com) (64.233.162.192) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Sep 2006 05:09:40 -0700 Received: by nz-out-0102.google.com with SMTP id v1so624993nzb for ; Fri, 01 Sep 2006 05:09:20 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=sZqxyV/sdLQZWS/7UyfP20UywGogTeOWDMpNuYIP2tdZge92/pLOScN11T0Q21LFS2fL3OSpn4EBwLEXOD2z+yJbnAYhiW09cr6wZISnvrgrcbcKjAYPpgsfCf2XOTDiMQSvLCv7xhCovpIc8or2PZKb8wyGYG1rIw4J4gapPOk= Received: by 10.64.184.14 with SMTP id h14mr274183qbf; Fri, 01 Sep 2006 05:09:20 -0700 (PDT) Received: by 10.64.96.9 with HTTP; Fri, 1 Sep 2006 05:09:19 -0700 (PDT) Message-ID: <187bb05d0609010509l766e4308rf6054982343d7332@mail.gmail.com> Date: Fri, 1 Sep 2006 16:09:19 +0400 From: "Artem Aliev" To: harmony-dev@incubator.apache.org Subject: Re: [DRLVM][VM] set_hash_bits() in vmcore/src/thread/mon_enter_exit.cpp -- is it a bug or a feature? In-Reply-To: <12385bbd0608290152y12daa52eo2f1f4959186c9465@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <4dd1f3f00608280832k9d62f20l803fdf10a0810d24@mail.gmail.com> <12385bbd0608290152y12daa52eo2f1f4959186c9465@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Guys, The problem looks much broader then just a hash code placing. There is no common place that describe object header format and object header sharing protocol. There are 3 components that use object header together. VMcore -- store VT pointer and hashcode ThreadManager -- update lockword GC -- tries to find unused bits for its own purpose Different GC algorithms use different unused bits: 2-bits from aligned VT pointer, move hashcode to the synthetic field and use last byte truncate hashcode So by moving hash_code() handling to GC and drop VT bit usage scenario, you simplify the problem to GC- TM interaction but not solve it. We still need the protocol. The other problem is the 64bit platforms.(for example EM64T). It looks natural to have 64bit VT and lockword on such platforms So we need not only sharing protocol bu also a more flexible object layout. Thanks Artem PS: At this time we have following 64bit object header fromat | ------------------ 32 bit -------------------| Virtual Method Table pointer |------------- 22bit -------|------10bit-----| Monitor lockword bits ^unused/hashcode/gc_bits On 8/29/06, Ivan Volosyuk wrote: > This is the GC_V4 specifics. It uses two bits of least significant > byte of the status word during GC, but it always return zeros to this > bits after GC. > > Here is the atomic way to do the changes: > do { > unsigned char lsb = *P_HASH_CONTENTION(p_obj); > unsigned char new_lsb = lsb | hb; > unsigned char uptodate_lsb = > port_atomic_cas8(P_HASH_CONTENTION(p_obj), new_lsb, lsb); > while (lsb != uptodate_lsb); > > BTW, atomic operations is only needed if GC wants to update those two > bits during mutator work. Otherwise, non-atomic operations is ok, as > the same value can be safely written to the same address by multiple > threads. This is one pros for moving this code to GC. > > -- > Ivan > > On 8/28/06, Weldon Washburn wrote: > > While porting MMTk to harmony/drlvm, I hit an integration problem. It > > could even be a bug. set_hash_bits() assumes the least significant > > bit is zero. Assuming that the LSB can be "owned" by the garbage > > collector for its purposes, set_hash_bits() will fail if the GC sets > > this bit to one. Somehow I think the code should read the target > > location, create the intended bit pattern before attempting to do the > > atomic compare and swap. Currently the code assume the target CAS > > location holds zero. > > > > SInce I am working only in single thread right now, I hacked around > > the problem with the below. Thoughts? > > > > > > C:\t_harmony\drlvm\trunk\vm\vmcore\src\thread>svn diff mon_enter_exit.cpp > > Index: mon_enter_exit.cpp > > =================================================================== > > --- mon_enter_exit.cpp (revision 425482) > > +++ mon_enter_exit.cpp (working copy) > > @@ -368,7 +368,12 @@ > > hb = (23 & HASH_MASK); // NO hash = zero allowed, thus hard map hb = 0 > > to a fixed prime number > > > > // don't care if the cmpxchg fails -- just means someone else already set t > > he hash > > - port_atomic_cas8(P_HASH_CONTENTION(p_obj),hb, 0); > > + //port_atomic_cas8(P_HASH_CONTENTION(p_obj),hb, 0); > > + unsigned char lsb = *P_HASH_CONTENTION(p_obj); > > + lsb = lsb & 0x01; //wjw need to keep the LSB, its used by MMTk Garbage Col > > lector > > + hb = hb | lsb; > > + if ( (*P_HASH_CONTENTION(p_obj) & HASH_MASK) == 0 ) // wjw non-atomic hack > > for now > > + *P_HASH_CONTENTION(p_obj) = hb; > > } > > > > --------------------------------------------------------------------- > Terms of use : http://incubator.apache.org/harmony/mailing.html > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org > For additional commands, e-mail: harmony-dev-help@incubator.apache.org > > --------------------------------------------------------------------- Terms of use : http://incubator.apache.org/harmony/mailing.html To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org For additional commands, e-mail: harmony-dev-help@incubator.apache.org