guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] GNU Guile branch, master, updated. v2.1.0-110-ge7f6497


From: Mark H Weaver
Subject: [Guile-commits] GNU Guile branch, master, updated. v2.1.0-110-ge7f6497
Date: Tue, 06 Aug 2013 21:37:13 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=e7f64971ed62a6b58f86b5d90a15b24733e36a8d

The branch, master has been updated
       via  e7f64971ed62a6b58f86b5d90a15b24733e36a8d (commit)
       via  d2295ba5716b60a5f0b28b1b91fd2ed3cf1192f5 (commit)
       via  0bd659658ba2a2b6dab9cb75f693818e5ce8241b (commit)
      from  78ff784784a001c775b790dffe948b56c50bd153 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit e7f64971ed62a6b58f86b5d90a15b24733e36a8d
Author: Mark H Weaver <address@hidden>
Date:   Tue Aug 6 17:03:56 2013 -0400

    RTL VM: Avoid untagging inums in 'logand' and 'logior'.
    
    * libguile/vm-engine.c (logand, logior): Avoid untagging.

commit d2295ba5716b60a5f0b28b1b91fd2ed3cf1192f5
Author: Mark H Weaver <address@hidden>
Date:   Tue Aug 6 17:00:23 2013 -0400

    RTL VM: Avoid signed overflows in 'add1' and 'sub1'.
    
    * libguile/vm-engine.c (INUM_MIN, INUM_MAX): Redefine without making
      assumptions about the representation.
      (INUM_STEP): New macro.
      (add1, sub1): Avoid signed overflows, and use INUM_STEP.

commit 0bd659658ba2a2b6dab9cb75f693818e5ce8241b
Author: Mark H Weaver <address@hidden>
Date:   Tue Aug 6 16:51:41 2013 -0400

    RTL VM: ash: Use SCM_SRS and fix large right shifts in fast path.
    
    * libguile/vm-engine.c (ash): Use SCM_SRS, and handle large right
      shifts properly.

-----------------------------------------------------------------------

Summary of changes:
 libguile/vm-engine.c |   43 ++++++++++++++++++++++++++-----------------
 1 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c
index 1300a1e..613c638 100644
--- a/libguile/vm-engine.c
+++ b/libguile/vm-engine.c
@@ -490,6 +490,7 @@ VM_NAME (SCM vm, SCM program, SCM *argv, int nargs)
 #undef INIT
 #undef INUM_MAX
 #undef INUM_MIN
+#undef INUM_STEP
 #undef jump_table
 #undef LOCAL_REF
 #undef LOCAL_SET
@@ -754,8 +755,13 @@ VM_NAME (SCM vm, SCM program, SCM *argv, int nargs)
   do { LOCAL_SET (dst, x); NEXT (1); } while (0)
 
 /* The maximum/minimum tagged integers.  */
-#define INUM_MAX (INTPTR_MAX - 1)
-#define INUM_MIN (INTPTR_MIN + scm_tc2_int)
+#define INUM_MAX  \
+  ((scm_t_signed_bits) SCM_UNPACK (SCM_I_MAKINUM (SCM_MOST_POSITIVE_FIXNUM)))
+#define INUM_MIN  \
+  ((scm_t_signed_bits) SCM_UNPACK (SCM_I_MAKINUM (SCM_MOST_NEGATIVE_FIXNUM)))
+#define INUM_STEP                                \
+  ((scm_t_signed_bits) SCM_UNPACK (SCM_INUM1)    \
+   - (scm_t_signed_bits) SCM_UNPACK (SCM_INUM0))
 
 #define BINARY_INTEGER_OP(CFUNC,SFUNC)                                      \
   {                                                             \
@@ -2807,15 +2813,14 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
     {
       ARGS1 (x);
 
-      /* Check for overflow.  */
-      if (SCM_LIKELY ((scm_t_intptr) SCM_UNPACK (x) < INUM_MAX))
+      /* Check for overflow.  We must avoid overflow in the signed
+         addition below, even if X is not an inum.  */
+      if (SCM_LIKELY ((scm_t_signed_bits) SCM_UNPACK (x) <= INUM_MAX - 
INUM_STEP))
         {
           SCM result;
 
-          /* Add the integers without untagging.  */
-          result = SCM_PACK ((scm_t_intptr) SCM_UNPACK (x)
-                             + (scm_t_intptr) SCM_UNPACK (SCM_I_MAKINUM (1))
-                             - scm_tc2_int);
+          /* Add 1 to the integer without untagging.  */
+          result = SCM_PACK ((scm_t_signed_bits) SCM_UNPACK (x) + INUM_STEP);
 
           if (SCM_LIKELY (SCM_I_INUMP (result)))
             RETURN (result);
@@ -2842,15 +2847,14 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
     {
       ARGS1 (x);
 
-      /* Check for underflow.  */
-      if (SCM_LIKELY ((scm_t_intptr) SCM_UNPACK (x) > INUM_MIN))
+      /* Check for overflow.  We must avoid overflow in the signed
+         subtraction below, even if X is not an inum.  */
+      if (SCM_LIKELY ((scm_t_signed_bits) SCM_UNPACK (x) >= INUM_MIN + 
INUM_STEP))
         {
           SCM result;
 
-          /* Substract the integers without untagging.  */
-          result = SCM_PACK ((scm_t_intptr) SCM_UNPACK (x)
-                             - (scm_t_intptr) SCM_UNPACK (SCM_I_MAKINUM (1))
-                             + scm_tc2_int);
+          /* Substract 1 from the integer without untagging.  */
+          result = SCM_PACK ((scm_t_signed_bits) SCM_UNPACK (x) - INUM_STEP);
 
           if (SCM_LIKELY (SCM_I_INUMP (result)))
             RETURN (result);
@@ -2926,7 +2930,10 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
         {
           if (SCM_I_INUM (y) < 0)
             /* Right shift, will be a fixnum. */
-            RETURN (SCM_I_MAKINUM (SCM_I_INUM (x) >> -SCM_I_INUM (y)));
+            RETURN (SCM_I_MAKINUM
+                    (SCM_SRS (SCM_I_INUM (x),
+                              (-SCM_I_INUM (y) <= SCM_I_FIXNUM_BIT-1)
+                              ? -SCM_I_INUM (y) : SCM_I_FIXNUM_BIT-1)));
           else
             /* Left shift. See comments in scm_ash. */
             {
@@ -2956,7 +2963,8 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
     {
       ARGS2 (x, y);
       if (SCM_I_INUMP (x) && SCM_I_INUMP (y))
-        RETURN (SCM_I_MAKINUM (SCM_I_INUM (x) & SCM_I_INUM (y)));
+        /* Compute bitwise AND without untagging */
+        RETURN (SCM_PACK (SCM_UNPACK (x) & SCM_UNPACK (y)));
       SYNC_IP ();
       RETURN (scm_logand (x, y));
     }
@@ -2969,7 +2977,8 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
     {
       ARGS2 (x, y);
       if (SCM_I_INUMP (x) && SCM_I_INUMP (y))
-        RETURN (SCM_I_MAKINUM (SCM_I_INUM (x) | SCM_I_INUM (y)));
+        /* Compute bitwise OR without untagging */
+        RETURN (SCM_PACK (SCM_UNPACK (x) | SCM_UNPACK (y)));
       SYNC_IP ();
       RETURN (scm_logior (x, y));
     }


hooks/post-receive
-- 
GNU Guile



reply via email to

[Prev in Thread] Current Thread [Next in Thread]