From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Untagging by subtraction instead of masking on USE_LSB_TAG Date: Mon, 28 Jan 2008 10:07:42 -0500 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1201532880 17463 80.91.229.12 (28 Jan 2008 15:08:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 28 Jan 2008 15:08:00 +0000 (UTC) Cc: emacs-devel@gnu.org To: YAMAMOTO Mitsuharu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 28 16:08:20 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JJVas-0006Be-5b for ged-emacs-devel@m.gmane.org; Mon, 28 Jan 2008 16:08:18 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JJVaR-0007vM-D5 for ged-emacs-devel@m.gmane.org; Mon, 28 Jan 2008 10:07:51 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JJVaM-0007v0-Vi for emacs-devel@gnu.org; Mon, 28 Jan 2008 10:07:47 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JJVaL-0007uF-Hq for emacs-devel@gnu.org; Mon, 28 Jan 2008 10:07:46 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JJVaL-0007uC-8j for emacs-devel@gnu.org; Mon, 28 Jan 2008 10:07:45 -0500 Original-Received: from ironport2-out.pppoe.ca ([206.248.154.182]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JJVaL-0003IK-C5 for emacs-devel@gnu.org; Mon, 28 Jan 2008 10:07:45 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao8CAGN+nUfO+J95dGdsb2JhbACQKQEwmkqBAA X-IronPort-AV: E=Sophos;i="4.25,260,1199682000"; d="scan'208";a="13294632" Original-Received: from smtp.pppoe.ca ([65.39.196.238]) by ironport2-out.pppoe.ca with ESMTP; 28 Jan 2008 10:07:44 -0500 Original-Received: from pastel.home ([206.248.159.121]) by smtp.pppoe.ca (Internet Mail Server v1.0) with ESMTP id IQJ64843; Mon, 28 Jan 2008 10:07:43 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id BDF8285C3; Mon, 28 Jan 2008 10:07:42 -0500 (EST) In-Reply-To: (YAMAMOTO Mitsuharu's message of "Mon, 28 Jan 2008 11:07:28 +0900") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:87709 Archived-At: > This would make sense if the latency of load/store does not depend on > its displacement (I'm not sure if that is the case in general). > Comments? Yes, all RISC processors I can think of (other than ADM29K, maybe) provide a "small" offset for free: a 0 offset is no faster than a -5 offset. Additionally, masking the lower 3 bits may sometimes be surprisingly costly (the obvious solution of ANDing with ~7 requires a 32bit constant, which tends to be more costly than a smaller constant, and the rsh+lsh can be even worse). So, yes, your patch looks like a very good idea in general. It's also what is typically used in Lisp/Smalltalk/younameit compilers. Stefan PS: This trick has another advantage: on some hardware (e.g. SPARC) if after adding/subtracting the offset, the resulting address is not aligned, you can get an exception, which means you get tag-checking for free. This is no coincidence, since the SPARC architecture benefitted from the experience of the SOAR (Smalltalk On A RISC) project.