From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.lisp.guile.devel Subject: Using labels-as-values on MacOS X Date: Fri, 25 May 2012 17:31:11 +0200 Message-ID: <87fwao6zwg.fsf@gnu.org> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1337959918 17245 80.91.229.3 (25 May 2012 15:31:58 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 25 May 2012 15:31:58 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri May 25 17:31:55 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SXwUU-0007EN-GC for guile-devel@m.gmane.org; Fri, 25 May 2012 17:31:46 +0200 Original-Received: from localhost ([::1]:46118 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXwUU-0006Bw-4m for guile-devel@m.gmane.org; Fri, 25 May 2012 11:31:46 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:45887) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXwUM-0006Af-5n for guile-devel@gnu.org; Fri, 25 May 2012 11:31:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SXwUH-0007Ic-DR for guile-devel@gnu.org; Fri, 25 May 2012 11:31:37 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:51732) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXwUG-0007I1-W8 for guile-devel@gnu.org; Fri, 25 May 2012 11:31:33 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1SXwU6-00069W-BL for guile-devel@gnu.org; Fri, 25 May 2012 17:31:22 +0200 Original-Received: from 193.50.110.130 ([193.50.110.130]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 25 May 2012 17:31:22 +0200 Original-Received: from ludo by 193.50.110.130 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 25 May 2012 17:31:22 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 110 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 193.50.110.130 X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 7 Prairial an 220 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu User-Agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.93 (gnu/linux) Cancel-Lock: sha1:iXyYNDIcnb/c3muhEwJbr4BtnJE= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:14513 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Hi, Ken Raeburn skribis: > * Don't use addresses of code labels with LLVM, even if the compiler > supports them. At least with the version of LLVM GCC on my Mac ("gcc > version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build > 2336.1.00)"), Damn, what compiler is this? It’s not the old GCC 4.2 fork? Is it Clang? GCC with DragonEgg? > the performance seems to be quite poor; "guild compile" was showing > about a 4x penalty in CPU time. (For psyntax-pp.go, it was 10 minutes > of CPU time vs 46 minutes.) Weird, would be good to see what happens. The two options for VM dispatching are: --=-=-= Content-Type: text/x-csrc Content-Disposition: inline; filename=vm.c Content-Description: VMs #include int vm_jt (const unsigned int *code) { static const void *jump_table[] = { &&op0, &&op1, &&op2 }; register const unsigned int *ip = code; #define NEXT goto *jump_table[*ip++] NEXT; op0: puts ("op0"); return 0; op1: puts ("op1"); NEXT; op2: puts ("op2"); NEXT; } int vm_switch (const unsigned int *code) { register const unsigned int *ip = code; while (1) switch (*ip++) { case 0: puts ("op0"); return 0; case 1: puts ("op1"); break; case 2: puts ("op2"); break; } } --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Could you look at the code generated by that compiler for this file? With GCC 4.6.2 at -O2, the dispatch with labels-as-values looks like this: mov -4(%rbx), %eax movq jump_table.2080(,%rax,8), %rax addq $4, %rbx jmp *%rax In the other case it’s a series of comparisons like this: cmpl $2, %eax jne .L14 movl $.LC2, %edi call puts movl (%rbx), %eax addq $4, %rbx cmpl $1, %eax jne .L16 movl $.LC1, %edi call puts jmp .L14 > Later/future versions may do better, so we can update it with > version-number checks, unless we want to build performance tests into > the configure script, which doesn't sound like a great idea to me. Agreed, but OTOH #ifdef __LLVM__ isn’t future-proof. Thanks, Ludo’. --=-=-=--