Return-Path: Delivered-To: apmail-harmony-dev-archive@www.apache.org Received: (qmail 97339 invoked from network); 29 Apr 2008 01:03:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 29 Apr 2008 01:03:40 -0000 Received: (qmail 92595 invoked by uid 500); 29 Apr 2008 01:03:39 -0000 Delivered-To: apmail-harmony-dev-archive@harmony.apache.org Received: (qmail 92565 invoked by uid 500); 29 Apr 2008 01:03:39 -0000 Mailing-List: contact dev-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list dev@harmony.apache.org Received: (qmail 92554 invoked by uid 99); 29 Apr 2008 01:03:39 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Apr 2008 18:03:39 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of xiaofeng.li@gmail.com designates 74.125.46.158 as permitted sender) Received: from [74.125.46.158] (HELO yw-out-1718.google.com) (74.125.46.158) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Apr 2008 01:02:55 +0000 Received: by yw-out-1718.google.com with SMTP id 5so491285ywm.0 for ; Mon, 28 Apr 2008 18:03:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=SN2f3nGoTLuu8/Fxksmtg7untTsRa5D4Pq1KPINOSO0=; b=atmDwWRtqjL4uxOYay8EGLa13GGOqv07KMoQdEbSUDkQdhjp85WUDHrrL9ovo8z23O6mrXThrZjK70VtFO5KRztnBQC7VcpRZTj4x9O7Rnq8yTYyRUCM1CgPvcQWsiB2pz9lJY4usoo+JVeudiO9E1dJEl61HMsBLT9fXNm+Qt0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=YlA+fKkcL9dEHAZerunLh8ZcUUsXr7HkKuzzGnja3SXNYW0P7p287sVYli2foSsOPcLggTGlrKFzkVBwxVCLmjcuSbUZ/C1X8EY6wXRp89cuKz8FA2tvt8TxjciFPPrIVlHzIp6MlFxJ5ArRzA7krZVxzc0275uW6gpUVDooX1o= Received: by 10.150.83.22 with SMTP id g22mr4534135ybb.140.1209430983597; Mon, 28 Apr 2008 18:03:03 -0700 (PDT) Received: by 10.151.13.18 with HTTP; Mon, 28 Apr 2008 18:03:01 -0700 (PDT) Message-ID: <9623c9a50804281803s6ecbe528m46779d6f0cc0414f@mail.gmail.com> Date: Tue, 29 Apr 2008 09:03:01 +0800 From: "Xiao-Feng Li" To: dev@harmony.apache.org Subject: Re: [classlib][performance] @Inline and @NoBoundsCheck annotation support In-Reply-To: <3b3f27c60804281703h73bff889r442c576343b88ee0@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <4bebff790804250403v1c661d6u5d5b32b0f6283cac@mail.gmail.com> <3b3f27c60804281703h73bff889r442c576343b88ee0@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org On Tue, Apr 29, 2008 at 8:03 AM, Nathan Beyer wrote: > I know I can be silly at times, but why not focus on making a better JIT? Good question... :) I think the reason is, it's too hard to get the JIT to do really well all the time. It's not only because the JIT is not smart enough yet, but also because there are tradeoffs between compilation time and execution time. Well, annotation is not the panacea for performance. JIT is still the major labor. Annotation is likes that when you are climbing on crag, and accidentally find a dent to put your foot. :) Thanks, xiaofeng > -Nathan > > > > On Fri, Apr 25, 2008 at 6:03 AM, Aleksey Shipilev < > aleksey.shipilev@gmail.com> wrote: > > > Hi, > > > > I had returned to idea to have @Inline and @NoBoundCheck annotation > > support in classlib and Jitrino. > > I will try to summarize the rationale for both these annotations: > > > > 1. @Inline. There are places where we're creating small methods to > > get more consistent code, while we expect JIT should inline them to > > reduce call penalty. Unfortunately, this is not always the case and > > any JIT can miss the opportunities for inline. As classlib developers > > we can dope our code with the hints saying "this method is really > > should be inlined, as we know it would be the penalty leaving it not > > inlined, just do it even when inline budget is exhausted". Jitrino > > really have @Inline already as the part of vmmagic package, but I want > > to see these annotations visible from the classlib part. > > > > That's the case of new HashMap [1] for example: > > > > /* > > * Contract-related functionality > > */ > > static int computeHashCode(Object key) { > > return key.hashCode(); > > } > > > > static boolean areEqualKeys(Object key1, Object key2) { > > return key1.equals(key2); > > } > > > > static boolean areEqualValues(Object value1, Object value2) { > > return value1.equals(value2); > > } > > > > > > 2. @NoBoundCheck. There are also cases in which we definitely know > > that no bound check need to be performed. This is the case of HashMap > > again: > > > > ... > > int hash = computeHashCode(key); > > index = hash & (elementData.length - 1); > > entry = elementData[index]; > > ... > > > > Of course, good JIT compiler should also resolve such patterns and > > eliminate bounds check here, but we can again hint the compiler they > > are not necessary. There's a complication though that such pragma > > could violate security if used in user code, but we could restrict its > > usage to bootstrap classes only. ABCD gurus (Egor?) could shed more > > light whether it's possible to implement on JIT side. > > > > What do you think? I can elaborate with proof-of-concept patches to > > see what advantage it would bring. > > > > Thanks, > > Aleksey. > > > > [1] https://issues.apache.org/jira/browse/HARMONY-5791 > > > -- http://xiao-feng.blogspot.com