poke-devel
[Top][All Lists]
Advanced

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

[PATCH 2/4] pkl: Use accessor macros to access state fields


From: Mohammad-Reza Nabipoor
Subject: [PATCH 2/4] pkl: Use accessor macros to access state fields
Date: Thu, 27 Jan 2022 04:10:08 +0330

2022-01-27  Mohammad-Reza Nabipoor  <mnabipoor@gnu.org>

        * libpoke/pvm.jitter (PVM_RAISE_DIRECT): Use
        `PVM_STATE_RUNTIME_FIELD` accessor.
        (PVM_CALL): Likewise.
        (return): Likewise.
        (pushf): Likewise.
        (popf): Likewise.
        (pushvar): Likewise.
        (pushtopvar): Likewise.
        (popvar): Likewise.
        (regvar): Likewise.
        (pec): Likewise.
        (pushhi): Likewise.
        (pushlo): Likewise.
        (write): Likewise.
        (peekdi): Likewise.
        (peekdiu): Likewise.
        (peekdl): Likewise.
        (peekdlu): Likewise.
        (pokedi): Likewise.
        (pokediu): Likewise.
        (pokedl): Likewise.
        (pokedlu): Likewise.
        (pushe): Likewise.
---
 ChangeLog          | 26 +++++++++++++++++++
 libpoke/pvm.jitter | 64 +++++++++++++++++++++++++++-------------------
 2 files changed, 63 insertions(+), 27 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index afd88876..08028c51 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2022-01-27  Mohammad-Reza Nabipoor  <mnabipoor@gnu.org>
+
+       * libpoke/pvm.jitter (PVM_RAISE_DIRECT): Use
+       `PVM_STATE_RUNTIME_FIELD` accessor.
+       (PVM_CALL): Likewise.
+       (return): Likewise.
+       (pushf): Likewise.
+       (popf): Likewise.
+       (pushvar): Likewise.
+       (pushtopvar): Likewise.
+       (popvar): Likewise.
+       (regvar): Likewise.
+       (pec): Likewise.
+       (pushhi): Likewise.
+       (pushlo): Likewise.
+       (write): Likewise.
+       (peekdi): Likewise.
+       (peekdiu): Likewise.
+       (peekdl): Likewise.
+       (peekdlu): Likewise.
+       (pokedi): Likewise.
+       (pokediu): Likewise.
+       (pokedl): Likewise.
+       (pokedlu): Likewise.
+       (pushe): Likewise.
+
 2022-01-27  Mohammad-Reza Nabipoor  <mnabipoor@gnu.org>
 
        * libpoke/pvm.jitter (wrapped-globals): Add pvm_literal_*.
diff --git a/libpoke/pvm.jitter b/libpoke/pvm.jitter
index dab3a257..c824a93e 100644
--- a/libpoke/pvm.jitter
+++ b/libpoke/pvm.jitter
@@ -241,7 +241,7 @@ late-header-c
                                                                       \
        JITTER_PUSH_STACK ((EXCEPTION));                               \
                                                                       \
-       jitter_state_runtime.env = ehandler.env;                       \
+       PVM_STATE_RUNTIME_FIELD (env) = ehandler.env;                  \
        JITTER_BRANCH (ehandler.code);                                 \
        break;                                                         \
      }                                                                \
@@ -597,11 +597,12 @@ late-header-c
        /* actual value will be written by the callee. */                     \
        JITTER_PUSH_UNSPECIFIED_RETURNSTACK();                                \
                                                                              \
-       /* Save the current environment and use the callee's environment. */    
 \
-       JITTER_PUSH_RETURNSTACK ((jitter_uint) (uintptr_t) 
jitter_state_runtime.env); \
-       jitter_state_runtime.env = PVM_VAL_CLS_ENV ((CLS));                   \
+       /* Save the current environment and use the callee's environment. */  \
+       JITTER_PUSH_RETURNSTACK (                                             \
+         (jitter_uint) (uintptr_t) PVM_STATE_RUNTIME_FIELD (env));           \
+       PVM_STATE_RUNTIME_FIELD (env) = PVM_VAL_CLS_ENV ((CLS));              \
                                                                              \
-       /* Branch-and-link to the native code, whose first instruction will */ \
+       /* Branch-and-link to the native code, whose first instruction will */\
        /*  be a prolog. */                                                   \
        JITTER_BRANCH_AND_LINK (PVM_VAL_CLS_ENTRY_POINT ((CLS)));           \
     } while (0)
@@ -1814,7 +1815,8 @@ instruction return ()
 
     /* Restore the environment of the caller.  Note the cast to
        jitter_uint is to avoid a warning in 32-bit.  */
-    jitter_state_runtime.env = (pvm_env) (jitter_uint) JITTER_TOP_RETURNSTACK 
();
+    PVM_STATE_RUNTIME_FIELD (env)
+      = (pvm_env) (jitter_uint) JITTER_TOP_RETURNSTACK ();
     JITTER_DROP_RETURNSTACK();
 
     return_address = JITTER_TOP_RETURNSTACK();
@@ -1837,8 +1839,8 @@ end
 
 instruction pushf (?n popf_printer)
   code
-    jitter_state_runtime.env
-       = pvm_env_push_frame (jitter_state_runtime.env,
+    PVM_STATE_RUNTIME_FIELD (env)
+       = pvm_env_push_frame (PVM_STATE_RUNTIME_FIELD (env),
                              JITTER_ARGN0);
   end
 end
@@ -1854,8 +1856,8 @@ instruction popf (?n popf_printer)
     jitter_uint i;
 
     for (i = 0; i < JITTER_ARGU0; ++i)
-        jitter_state_runtime.env
-           = pvm_env_pop_frame (jitter_state_runtime.env);
+        PVM_STATE_RUNTIME_FIELD (env)
+           = pvm_env_pop_frame (PVM_STATE_RUNTIME_FIELD (env));
   end
 end
 
@@ -1869,7 +1871,7 @@ end
 
 instruction pushvar (?n 0, ?n 0 1 2 3 4 5)
   code
-    JITTER_PUSH_STACK (pvm_env_lookup (jitter_state_runtime.env,
+    JITTER_PUSH_STACK (pvm_env_lookup (PVM_STATE_RUNTIME_FIELD (env),
                                        (int) JITTER_ARGN0,
                                        (int) JITTER_ARGN1));
   end
@@ -1889,7 +1891,7 @@ end
 instruction pushtopvar (?n)
   branching # because of PVM_RAISE_DIRECT
   code
-    pvm_env topenv = pvm_env_toplevel (jitter_state_runtime.env);
+    pvm_env topenv = pvm_env_toplevel (PVM_STATE_RUNTIME_FIELD (env));
     pvm_val val = pvm_env_lookup (topenv, 0 /* back */,
                                   (int) JITTER_ARGN0 /* over */);
 
@@ -1911,7 +1913,7 @@ end
 
 instruction popvar (?n, ?n)
   code
-    pvm_env_set_var (jitter_state_runtime.env,
+    pvm_env_set_var (PVM_STATE_RUNTIME_FIELD (env),
                      (int) JITTER_ARGN0,
                      (int) JITTER_ARGN1,
                      JITTER_TOP_STACK ());
@@ -1928,7 +1930,7 @@ end
 
 instruction regvar ()
   code
-    pvm_env_register (jitter_state_runtime.env,
+    pvm_env_register (PVM_STATE_RUNTIME_FIELD (env),
                       JITTER_TOP_STACK ());
     JITTER_DROP_STACK ();
   end
@@ -1961,7 +1963,7 @@ end
 instruction pec ()
   code
     pvm_val cls = JITTER_TOP_STACK ();
-    PVM_VAL_CLS_ENV (cls) = jitter_state_runtime.env;
+    PVM_VAL_CLS_ENV (cls) = PVM_STATE_RUNTIME_FIELD (env);
   end
 end
 
@@ -2439,7 +2441,7 @@ end
 
 instruction pushhi (?nl pvm_literal_printer_hi)
   code
-     jitter_state_runtime.push_hi
+     PVM_STATE_RUNTIME_FIELD (push_hi)
        = JITTER_ARGN0;
   end
 end
@@ -2456,7 +2458,7 @@ end
 instruction pushlo (?nl pvm_literal_printer_lo)
   code
      pvm_val k
-       = ((pvm_val) jitter_state_runtime.push_hi << 32)
+       = ((pvm_val) PVM_STATE_RUNTIME_FIELD (push_hi) << 32)
          | JITTER_ARGN0;
      JITTER_PUSH_STACK (k);
   end
@@ -5749,7 +5751,7 @@ end
 
 instruction write ()
   caller
-  branching # because of PVM_RAISE_DIRECT
+  branching # because of PVM_CALL
   code
      pvm_val val = JITTER_TOP_STACK ();
      pvm_val writer = pvm_val_writer (val);
@@ -5837,7 +5839,8 @@ end
 instruction peekdi (?n bits_printer)
   branching # because of PVM_RAISE_DIRECT
   code
-    PVM_PEEK (int, int, jitter_state_runtime.nenc, jitter_state_runtime.endian,
+    PVM_PEEK (int, int, PVM_STATE_RUNTIME_FIELD (nenc),
+              PVM_STATE_RUNTIME_FIELD (endian),
               JITTER_ARGN0, PVM_IOS_ARGS_INT);
   end
 end
@@ -5852,7 +5855,8 @@ end
 instruction peekdiu (?n bits_printer)
   branching # because of PVM_RAISE_DIRECT
   code
-    PVM_PEEK (uint, uint, jitter_state_runtime.nenc, 
jitter_state_runtime.endian,
+    PVM_PEEK (uint, uint, PVM_STATE_RUNTIME_FIELD (nenc),
+              PVM_STATE_RUNTIME_FIELD (endian),
               JITTER_ARGN0, PVM_IOS_ARGS_UINT);
   end
 end
@@ -5867,7 +5871,8 @@ end
 instruction peekdl (?n bits_printer)
   branching # because of PVM_RAISE_DIRECT
   code
-    PVM_PEEK (long, int, jitter_state_runtime.nenc, 
jitter_state_runtime.endian,
+    PVM_PEEK (long, int, PVM_STATE_RUNTIME_FIELD (nenc),
+              PVM_STATE_RUNTIME_FIELD (endian),
               JITTER_ARGN0, PVM_IOS_ARGS_INT);
   end
 end
@@ -5882,7 +5887,8 @@ end
 instruction peekdlu (?n bits_printer)
   branching # because of PVM_RAISE_DIRECT
   code
-    PVM_PEEK (ulong, uint, jitter_state_runtime.nenc, 
jitter_state_runtime.endian,
+    PVM_PEEK (ulong, uint, PVM_STATE_RUNTIME_FIELD (nenc),
+              PVM_STATE_RUNTIME_FIELD (endian),
               JITTER_ARGN0, PVM_IOS_ARGS_UINT);
   end
 end
@@ -5961,7 +5967,8 @@ end
 instruction pokedi (?n bits_printer)
   branching # because of PVM_RAISE_DIRECT
   code
-    PVM_POKE (INT, int, jitter_state_runtime.nenc, jitter_state_runtime.endian,
+    PVM_POKE (INT, int, PVM_STATE_RUNTIME_FIELD (nenc),
+              PVM_STATE_RUNTIME_FIELD (endian),
               JITTER_ARGN0, PVM_IOS_ARGS_WRITE_INT);
   end
 end
@@ -5976,7 +5983,8 @@ end
 instruction pokediu (?n bits_printer)
   branching # because of PVM_RAISE_DIRECT
   code
-    PVM_POKE (UINT, uint, jitter_state_runtime.nenc, 
jitter_state_runtime.endian,
+    PVM_POKE (UINT, uint, PVM_STATE_RUNTIME_FIELD (nenc),
+              PVM_STATE_RUNTIME_FIELD (endian),
               JITTER_ARGN0, PVM_IOS_ARGS_WRITE_UINT);
   end
 end
@@ -5991,7 +5999,8 @@ end
 instruction pokedl (?n bits_printer)
   branching # because of PVM_RAISE_DIRECT
   code
-    PVM_POKE (LONG, int, jitter_state_runtime.nenc, 
jitter_state_runtime.endian,
+    PVM_POKE (LONG, int, PVM_STATE_RUNTIME_FIELD (nenc),
+              PVM_STATE_RUNTIME_FIELD (endian),
               JITTER_ARGN0, PVM_IOS_ARGS_WRITE_INT);
   end
 end
@@ -6006,7 +6015,8 @@ end
 instruction pokedlu (?n bits_printer)
   branching # because of PVM_RAISE_DIRECT
   code
-    PVM_POKE (ULONG, uint, jitter_state_runtime.nenc, 
jitter_state_runtime.endian,
+    PVM_POKE (ULONG, uint, PVM_STATE_RUNTIME_FIELD (nenc),
+              PVM_STATE_RUNTIME_FIELD (endian),
               JITTER_ARGN0, PVM_IOS_ARGS_WRITE_UINT);
   end
 end
@@ -6108,7 +6118,7 @@ instruction pushe (?l)
    ehandler.main_stack_height = JITTER_HEIGHT_STACK ();
    ehandler.return_stack_height = JITTER_HEIGHT_RETURNSTACK ();
    ehandler.code = JITTER_ARGP0;
-   ehandler.env = jitter_state_runtime.env;
+   ehandler.env = PVM_STATE_RUNTIME_FIELD (env);
 
    JITTER_PUSH_EXCEPTIONSTACK (ehandler);
   end
-- 
2.34.1




reply via email to

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