unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Andy Wingo <wingo@pobox.com>
To: guile-devel@gnu.org
Cc: Andy Wingo <wingo@pobox.com>
Subject: [PATCH 05/10] vm-engine: remove register assignments
Date: Thu, 23 May 2013 15:30:58 +0200	[thread overview]
Message-ID: <1369315863-15879-6-git-send-email-wingo@pobox.com> (raw)
In-Reply-To: <1369315863-15879-1-git-send-email-wingo@pobox.com>

* libguile/vm-engine.c: Remove the register assignments inherited from
  the 1990s.  GCC does seem to allocate reasonably on systems with
  enough registers (e.g. x86-64), and on system with too few (x86-32) we
  disabled manual allocation.  Anyway this code was never tested, so
  it's better to leave the compiler to do its own thing, until proven
  otherwise.  Also in the RTL VM we don't need to allocate a register to
  the SP, because it isn't accessed as much.
---
 libguile/vm-engine.c |   73 +++++++++-----------------------------------------
 1 file changed, 12 insertions(+), 61 deletions(-)

diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c
index 98e9837..b7e355d 100644
--- a/libguile/vm-engine.c
+++ b/libguile/vm-engine.c
@@ -26,80 +26,31 @@
 # error unknown debug engine VM_ENGINE
 #endif
 
-
-/* Register optimization. [ stolen from librep/src/lispmach.h,v 1.3 ]
-
-   Some compilers underestimate the use of the local variables representing
-   the abstract machine registers, and don't put them in hardware registers,
-   which slows down the interpreter considerably.
-   For GCC, I have hand-assigned hardware registers for several architectures.
-*/
-
+/* Assign some registers by hand.  There used to be a bigger list here,
+   but it was never tested, and in the case of x86-32, was a source of
+   compilation failures.  It can be revived if it's useful, but my naive
+   hope is that simply annotating the locals with "register" will be a
+   sufficient hint to the compiler.  */
 #ifdef __GNUC__
-#ifdef __mips__
-#define IP_REG asm("$16")
-#define SP_REG asm("$17")
-#define FP_REG asm("$18")
-#endif
-#ifdef __sparc__
-#define IP_REG asm("%l0")
-#define SP_REG asm("%l1")
-#define FP_REG asm("%l2")
-#endif
-#ifdef __alpha__
-#ifdef __CRAY__
-#define IP_REG asm("r9")
-#define SP_REG asm("r10")
-#define FP_REG asm("r11")
-#else
-#define IP_REG asm("$9")
-#define SP_REG asm("$10")
-#define FP_REG asm("$11")
-#endif
-#endif
-#ifdef __i386__
-/* too few registers! because of register allocation errors with various gcs,
-   just punt on explicit assignments on i386, hoping that the "register"
-   declaration will be sufficient. */
-#elif defined __x86_64__
+# if defined __x86_64__
 /* GCC 4.6 chooses %rbp for IP_REG and %rbx for SP_REG, which works
    well.  Tell it to keep the jump table in a r12, which is
    callee-saved.  */
-#define JT_REG asm ("r12")
-#endif
-#if defined(PPC) || defined(_POWER) || defined(_IBMR2)
-#define IP_REG asm("26")
-#define SP_REG asm("27")
-#define FP_REG asm("28")
-#endif
-#ifdef __hppa__
-#define IP_REG asm("%r18")
-#define SP_REG asm("%r17")
-#define FP_REG asm("%r16")
-#endif
-#ifdef __mc68000__
-#define IP_REG asm("a5")
-#define SP_REG asm("a4")
-#define FP_REG
-#endif
-#ifdef __arm__
-#define IP_REG asm("r9")
-#define SP_REG asm("r8")
-#define FP_REG asm("r7")
-#endif
+#  define JT_REG asm ("r12")
+# endif
 #endif
 
 #ifndef IP_REG
-#define IP_REG
+# define IP_REG
 #endif
 #ifndef SP_REG
-#define SP_REG
+# define SP_REG
 #endif
 #ifndef FP_REG
-#define FP_REG
+# define FP_REG
 #endif
 #ifndef JT_REG
-#define JT_REG
+# define JT_REG
 #endif
 
 #define VM_ASSERT(condition, handler)           \
-- 
1.7.10.4




  parent reply	other threads:[~2013-05-23 13:30 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-23 13:30 Add RTL VM Andy Wingo
2013-05-23 13:30 ` [PATCH 01/10] inline vm-engine.h into vm-engine.c Andy Wingo
2013-05-23 21:28   ` Ludovic Courtès
2013-05-23 13:30 ` [PATCH 02/10] remove CONS macro in VM; use scm_cons instead Andy Wingo
2013-05-23 13:30 ` [PATCH 03/10] minor vm-engine cleanups Andy Wingo
2013-06-06  6:48   ` Marijn
2013-05-23 13:30 ` [PATCH 04/10] remove some configurability in vm-engine Andy Wingo
2013-05-23 13:30 ` Andy Wingo [this message]
2013-05-23 13:30 ` [PATCH 06/10] Allow vm_engine caller to pass arguments on the stack Andy Wingo
2013-05-23 21:37   ` Ludovic Courtès
2013-05-23 13:31 ` [PATCH 07/10] pop-continuation abort-continuation hooks pass return vals directly Andy Wingo
2013-05-23 21:46   ` Ludovic Courtès
2013-05-23 13:31 ` [PATCH 08/10] cpp hygiene in the vm Andy Wingo
2013-05-23 13:31 ` [PATCH 09/10] refactor to resolve_variable Andy Wingo
2013-05-23 21:47   ` Ludovic Courtès
2013-05-23 13:31 ` [PATCH 10/10] add new rtl vm Andy Wingo
2013-05-30 16:06   ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1369315863-15879-6-git-send-email-wingo@pobox.com \
    --to=wingo@pobox.com \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).