guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] 01/01: Fix shuffling of unboxed stack elements on 32-bit


From: Andy Wingo
Subject: [Guile-commits] 01/01: Fix shuffling of unboxed stack elements on 32-bit systems
Date: Sat, 11 Jun 2016 12:46:55 +0000 (UTC)

wingo pushed a commit to branch master
in repository guile.

commit be6194e32a642bbb62ad11cef02b9e34bf648ac3
Author: Andy Wingo <address@hidden>
Date:   Sat Jun 11 14:44:59 2016 +0200

    Fix shuffling of unboxed stack elements on 32-bit systems
    
    * libguile/vm-engine.c (SP_REF_SLOT, SP_SET_SLOT): New defines.
      (push, pop, mov, long-mov): Move full slots.  Fixes 32-bit with
      unboxed 64-bit stack values; before when shuffling these values
      around, we were only shuffling the lower 32 bits on 32-bit platforms.
---
 libguile/vm-engine.c |   35 +++++++++++++++++++++++++++--------
 1 file changed, 27 insertions(+), 8 deletions(-)

diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c
index dfdf0a1..0978636 100644
--- a/libguile/vm-engine.c
+++ b/libguile/vm-engine.c
@@ -248,6 +248,9 @@
 #define FP_REF(i)              SCM_FRAME_LOCAL (vp->fp, i)
 #define FP_SET(i,o)            SCM_FRAME_LOCAL (vp->fp, i) = o
 
+#define SP_REF_SLOT(i)         (sp[i])
+#define SP_SET_SLOT(i,o)       (sp[i] = o)
+
 #define SP_REF(i)              (sp[i].as_scm)
 #define SP_SET(i,o)            (sp[i].as_scm = o)
 
@@ -1142,12 +1145,16 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
   VM_DEFINE_OP (26, push, "push", OP1 (X8_S24))
     {
       scm_t_uint32 src;
-      SCM val;
+      union scm_vm_stack_element val;
 
+      /* FIXME: The compiler currently emits "push" for SCM, F64, U64,
+         and S64 variables.  However SCM values are the usual case, and
+         on a 32-bit machine it might be cheaper to move a SCM than to
+         move a 64-bit number.  */
       UNPACK_24 (op, src);
-      val = SP_REF (src);
+      val = SP_REF_SLOT (src);
       ALLOC_FRAME (FRAME_LOCALS_COUNT () + 1);
-      SP_SET (0, val);
+      SP_SET_SLOT (0, val);
       NEXT (1);
     }
 
@@ -1158,12 +1165,16 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
   VM_DEFINE_OP (27, pop, "pop", OP1 (X8_S24) | OP_DST)
     {
       scm_t_uint32 dst;
-      SCM val;
+      union scm_vm_stack_element val;
 
+      /* FIXME: The compiler currently emits "pop" for SCM, F64, U64,
+         and S64 variables.  However SCM values are the usual case, and
+         on a 32-bit machine it might be cheaper to move a SCM than to
+         move a 64-bit number.  */
       UNPACK_24 (op, dst);
-      val = SP_REF (0);
+      val = SP_REF_SLOT (0);
       vp->sp = sp = sp + 1;
-      SP_SET (dst, val);
+      SP_SET_SLOT (dst, val);
       NEXT (1);
     }
 
@@ -1548,7 +1559,11 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
       scm_t_uint16 src;
 
       UNPACK_12_12 (op, dst, src);
-      SP_SET (dst, SP_REF (src));
+      /* FIXME: The compiler currently emits "mov" for SCM, F64, U64,
+         and S64 variables.  However SCM values are the usual case, and
+         on a 32-bit machine it might be cheaper to move a SCM than to
+         move a 64-bit number.  */
+      SP_SET_SLOT (dst, SP_REF_SLOT (src));
 
       NEXT (1);
     }
@@ -1564,7 +1579,11 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
 
       UNPACK_24 (op, dst);
       UNPACK_24 (ip[1], src);
-      SP_SET (dst, SP_REF (src));
+      /* FIXME: The compiler currently emits "long-mov" for SCM, F64,
+         U64, and S64 variables.  However SCM values are the usual case,
+         and on a 32-bit machine it might be cheaper to move a SCM than
+         to move a 64-bit number.  */
+      SP_SET_SLOT (dst, SP_REF_SLOT (src));
 
       NEXT (2);
     }



reply via email to

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