[Quipu-dev] quipu/quipu: Small style improvements

Back to archive index

scmno****@osdn***** scmno****@osdn*****
Sun Jun 3 04:06:25 JST 2018


changeset dd1ad9f5c411 in quipu/quipu
details: http://hg.osdn.jp/view/quipu/quipu?cmd=changeset;node=dd1ad9f5c411
user: Agustina Arzille <avarz****@riseu*****>
date: Sat Jun 02 18:55:55 2018 +0000
description: Small style improvements

diffstat:

 array.cpp        |   2 +-
 compiler.cpp     |  22 +++++++++++-----------
 continuation.cpp |   4 ++--
 defs.h           |   8 ++++++--
 floatp.cpp       |   2 +-
 function.cpp     |   4 ++--
 function.h       |   4 ++--
 integer.cpp      |   2 +-
 interp.cpp       |   6 +++---
 interp.h         |   2 +-
 10 files changed, 30 insertions(+), 26 deletions(-)

diffs (247 lines):

diff -r 7294e939ef48 -r dd1ad9f5c411 array.cpp
--- a/array.cpp	Sat Jun 02 18:43:29 2018 +0000
+++ b/array.cpp	Sat Jun 02 18:55:55 2018 +0000
@@ -9,7 +9,7 @@
 
 QP_DECLS_BEGIN
 
-const int array::data_offset = QP_ENTRY_OFF (array, object);
+const int array::data_offset = entry_off<array, object> ();
 
 static array empty_array;
 
diff -r 7294e939ef48 -r dd1ad9f5c411 compiler.cpp
--- a/compiler.cpp	Sat Jun 02 18:43:29 2018 +0000
+++ b/compiler.cpp	Sat Jun 02 18:55:55 2018 +0000
@@ -2092,7 +2092,7 @@
     return (ls.plocals[ls.n - sx - 1][ix]);
 
   uint32_t cf = unwind_n (interp->stack, interp->cur_frame, sx);
-  uint32_t nbp = cf - (interpreter::frame_overhead +
+  uint32_t nbp = cf - (interpreter::frame_size +
     as_int (interp->stack[cf - 3]));
   return (interp->dynframe_captured (cf - 1) ?
     xaref (interp->stack[nbp], ix) : interp->stack[nbp + ix]);
@@ -2128,7 +2128,7 @@
 
       lastf = as_int (interp->stack[lastf - 4]);
       fn = interp->stack[lastf - as_int (interp->stack[lastf - 3]) -
-        (interpreter::frame_overhead + 1)];
+        (interpreter::frame_size + 1)];
     }
 }
 
@@ -2224,7 +2224,7 @@
     { // Restored from a caught exception.
       top_frame = cdp->topf;
       nargs = as_int (stack[interp->cur_frame - 3]);
-      bp = interp->cur_frame - interpreter::frame_overhead - nargs;
+      bp = interp->cur_frame - interpreter::frame_size - nargs;
       fn = stack[bp - 1];
       ip = as_bvector(fct_bcode (fn))->data + cdp->ip_offset;
       set_lastf (interp, fn, lastf);
@@ -2234,7 +2234,7 @@
     { // Continuation-passing style.
       continuation *cnp = as_continuation (cont);
       cnp->push (interp, lstack);
-      bp = interp->cur_frame - interpreter::frame_overhead -
+      bp = interp->cur_frame - interpreter::frame_size -
         as_int (stack[interp->cur_frame - 3]);
       fn = stack[bp - 1];
       set_lastf (interp, fn, lastf);
@@ -2341,7 +2341,7 @@
               NEXT_OP;
             }
 
-          bp = lastf - interpreter::frame_overhead - nargs;
+          bp = lastf - interpreter::frame_size - nargs;
           interp->cur_frame = as_int (stack[lastf - 4]);
           move_objs (&stack[bp - 1], stkend - n - 1, n + 1);
 
@@ -2440,10 +2440,10 @@
       if ((interp->cur_frame = as_int (stack[lastf - 4])) == top_frame)
         return (retval);
 
-      stkend = stack + lastf - (interpreter::frame_overhead +
+      stkend = stack + lastf - (interpreter::frame_size +
         as_int (stack[lastf - 3]));
       nargs = as_int (stack[interp->cur_frame - 3]);
-      bp = interp->cur_frame - (interpreter::frame_overhead + nargs);
+      bp = interp->cur_frame - (interpreter::frame_size + nargs);
       r_stkend(1) = retval;
       fn = stack[bp - 1];
 
@@ -2640,7 +2640,7 @@
         }
 
       sx = as_int (stack[interp->cur_frame - 4]);
-      sx -= interpreter::frame_overhead + as_int (stack[sx - 3]);
+      sx -= interpreter::frame_size + as_int (stack[sx - 3]);
       ix = *ip++;
       U_PUSH (interp->dynframe_captured (
         as_int (stack[interp->cur_frame - 4]) - 1) ?
@@ -2654,12 +2654,12 @@
 
     OP_(LOADB):
     OP_(LOADBL):
-      U_PUSH (stack[bp + nargs + interpreter::frame_overhead + ip_ival (ip)]);
+      U_PUSH (stack[bp + nargs + interpreter::frame_size + ip_ival (ip)]);
       NEXT_OP;
 
     OP_(SETB):
     OP_(SETBL):
-      stack[bp + nargs + interpreter::frame_overhead +
+      stack[bp + nargs + interpreter::frame_size +
         ip_ival (ip)] = r_stkend (1);
       NEXT_OP;
 
@@ -2805,7 +2805,7 @@
       interp->cur_frame = unwind_n (stack, interp->cur_frame, n);
       stkend = stack + as_int (stack[interp->cur_frame - 2]);
       nargs = as_int (stack[interp->cur_frame - 3]);
-      bp = interp->cur_frame - interpreter::frame_overhead - nargs;
+      bp = interp->cur_frame - interpreter::frame_size - nargs;
       lstack.pop (locals = U_PREV_LC ());
       U_PUSH (retval);
       NEXT_OP;
diff -r 7294e939ef48 -r dd1ad9f5c411 continuation.cpp
--- a/continuation.cpp	Sat Jun 02 18:43:29 2018 +0000
+++ b/continuation.cpp	Sat Jun 02 18:55:55 2018 +0000
@@ -13,7 +13,7 @@
 make_argv (interpreter *interp, uint32_t ilastf, int& nframes)
 {
   uint32_t start = ilastf - as_int (interp->stack[ilastf - 3]) -
-    interpreter::frame_overhead - 1;
+    interpreter::frame_size - 1;
 
   uint32_t lastf = as_int (interp->stack[ilastf - 4]), nf = 0;
   uint32_t sp = interp->stkdiff ();
@@ -45,7 +45,7 @@
   uint32_t nsp = interp->stkdiff ();
   for (int i = 0; i < this->nframes; ++i)
     {
-      nsp += as_int (ap->data[i]) + interpreter::frame_overhead + 1;
+      nsp += as_int (ap->data[i]) + interpreter::frame_size + 1;
       interp->stack[nsp - 2] = intobj (nsp);
       interp->stack[nsp - 4] = intobj (interp->cur_frame);
 
diff -r 7294e939ef48 -r dd1ad9f5c411 defs.h
--- a/defs.h	Sat Jun 02 18:43:29 2018 +0000
+++ b/defs.h	Sat Jun 02 18:55:55 2018 +0000
@@ -273,8 +273,12 @@
 #  undef QP_HAS_ALLOCA
 #endif
 
-#define QP_ENTRY_OFF(tp, mem)   (((sizeof (tp) + alignof (mem) - 1) &   \
-                                  ~(alignof (mem) - 1)) - sizeof (tp))
+template <class T1, class T2>
+inline constexpr size_t entry_off ()
+{
+  return (((sizeof (T1) + alignof (T2) - 1) &
+    ~(alignof (T2) - 1)) - sizeof (T1));
+}
 
 inline constexpr uint32_t hash_rotl (uint32_t __code, uint32_t __nb)
 {
diff -r 7294e939ef48 -r dd1ad9f5c411 floatp.cpp
--- a/floatp.cpp	Sat Jun 02 18:43:29 2018 +0000
+++ b/floatp.cpp	Sat Jun 02 18:55:55 2018 +0000
@@ -385,7 +385,7 @@
 
 // Long float implementation.
 
-const int bigfloat::data_offset = QP_ENTRY_OFF (bigfloat, limb_t);
+const int bigfloat::data_offset = entry_off<bigfloat, limb_t> ();
 
 bigfloat* bigfloat::alloc_raw (int len)
 {
diff -r 7294e939ef48 -r dd1ad9f5c411 function.cpp
--- a/function.cpp	Sat Jun 02 18:43:29 2018 +0000
+++ b/function.cpp	Sat Jun 02 18:55:55 2018 +0000
@@ -68,7 +68,7 @@
         ++sp;
       else if (instr->opcode () == OP_MKFRAME ||
           instr->opcode () == OP_MKFRAMEL)
-        sp += interpreter::frame_overhead;
+        sp += interpreter::frame_size;
       else if (instr->branch_p ())
         {
           switch (instr->opcode ())
@@ -98,7 +98,7 @@
       start += instr->argsize () * instr->nops ();
     }
 
-  return (max_sp + interpreter::frame_overhead);
+  return (max_sp + interpreter::frame_size);
 }
 
 int write_x (interpreter *interp, stream *strm, object obj, io_info&)
diff -r 7294e939ef48 -r dd1ad9f5c411 function.h
--- a/function.h	Sat Jun 02 18:43:29 2018 +0000
+++ b/function.h	Sat Jun 02 18:55:55 2018 +0000
@@ -25,9 +25,9 @@
       uint32_t __cf = __interp->cur_frame;
       __interp->push_frame (NIL, __argc, 0);
       this->fct (__interp, __interp->stkend - __argc -
-        interpreter::frame_overhead, __argc);
+        interpreter::frame_size, __argc);
       __interp->cur_frame = __cf;
-      __interp->stkend -= interpreter::frame_overhead;
+      __interp->stkend -= interpreter::frame_size;
       return (__interp->retval);
     }
 
diff -r 7294e939ef48 -r dd1ad9f5c411 integer.cpp
--- a/integer.cpp	Sat Jun 02 18:43:29 2018 +0000
+++ b/integer.cpp	Sat Jun 02 18:55:55 2018 +0000
@@ -121,7 +121,7 @@
 
 // Bigint implementation.
 
-const int bigint::data_offset = QP_ENTRY_OFF (bigint, limb_t);
+const int bigint::data_offset = entry_off<bigint, limb_t> ();
 
 bigint* bigint::alloc_raw (int len)
 {
diff -r 7294e939ef48 -r dd1ad9f5c411 interp.cpp
--- a/interp.cpp	Sat Jun 02 18:43:29 2018 +0000
+++ b/interp.cpp	Sat Jun 02 18:55:55 2018 +0000
@@ -244,7 +244,7 @@
 
   int nargs = as_int (this->stack[this->cur_frame - 3]);
   return (this->stack[this->cur_frame -
-    nargs - interpreter::frame_overhead - 1]);
+    nargs - interpreter::frame_size - 1]);
 }
 
 void interpreter::raise (object exc)
@@ -313,7 +313,7 @@
 
 void interpreter::push_frame (object env, int nargs, int off)
 {
-  this->growstk (frame_overhead);
+  this->growstk (frame_size);
   *this->stkend++ = env;
   *this->stkend++ = intobj (this->cur_frame);
   *this->stkend++ = intobj (nargs);
@@ -469,7 +469,7 @@
   for (; frame > 0; frame = as_int (this->stack[frame - 4]))
     {
       int size = as_int (this->stack[frame - 3]) + 1;
-      int bp = frame - interpreter::frame_overhead - size;
+      int bp = frame - interpreter::frame_size - size;
       object caller = this->stack[bp];
 
       if ((caller & EXTRA_BIT) || (fct_p (caller) &&
diff -r 7294e939ef48 -r dd1ad9f5c411 interp.h
--- a/interp.h	Sat Jun 02 18:43:29 2018 +0000
+++ b/interp.h	Sat Jun 02 18:55:55 2018 +0000
@@ -126,7 +126,7 @@
   // Internal constants.
   enum
     {
-      frame_overhead = 5,
+      frame_size = 5,
       dynframe_size = 3,
       edata_size = 3,
       dbdata_isize = 4




More information about the Quipu-dev mailing list
Back to archive index