poke-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] pkl: Re-implement `strace` instruction


From: Jose E. Marchesi
Subject: Re: [PATCH] pkl: Re-implement `strace` instruction
Date: Wed, 01 Dec 2021 21:17:42 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Hi Mohammad.

What is the purpose of this rewrite?

> 2021-12-01  Mohammad-Reza Nabipoor  <mnabipoor@gnu.org>
>
>       * libpoke/pvm.jitter (strace): Re-implement using
>       `JITTER_AT_DEPTH_STACK`.
> ---
>
> Hi, Jose.
>
> The following expression will be soon replaced by
> `JITTER_NUMBER_OF_ELEMENTS_STACK ()` (when Luca implements it):

Isn't that the depth at the top?

>
>
>  (pvm_val*)JITTER_HEIGHT_STACK () - (pvm_val*)PVM_STATE_BACKING_FIELD (canary)
>
>
>
> Regards,
> Mohammad-Reza
>
>
>  ChangeLog          |  5 +++++
>  libpoke/pvm.jitter | 49 +++++++++++++++++++++++-----------------------
>  2 files changed, 29 insertions(+), 25 deletions(-)
>
> diff --git a/ChangeLog b/ChangeLog
> index d0384f03..9d24b65e 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,8 @@
> +2021-12-01  Mohammad-Reza Nabipoor  <mnabipoor@gnu.org>
> +
> +     * libpoke/pvm.jitter (strace): Re-implement using
> +     `JITTER_AT_DEPTH_STACK`.
> +
>  2021-12-01  Jose E. Marchesi  <jemarch@gnu.org>
>  
>       * etc/poke.rec (1.1): Add release.
> diff --git a/libpoke/pvm.jitter b/libpoke/pvm.jitter
> index 6c3a1690..8c943f14 100644
> --- a/libpoke/pvm.jitter
> +++ b/libpoke/pvm.jitter
> @@ -6087,31 +6087,30 @@ end
>  instruction strace (?n)
>    non-relocatable
>    code
> -     pvm_val tmp[1024];
> -     int i = 0, j;
> -     int num_elems = (int) JITTER_ARGN0;
> -
> -     while (((num_elems == 0 || i < num_elems)
> -             && (JITTER_HEIGHT_STACK () !=
> -                 PVM_STATE_BACKING_FIELD (canary))))
> -        {
> -          assert (i < 1024);
> -          pvm_print_val_with_params (PVM_STATE_BACKING_FIELD (vm),
> -                                     JITTER_TOP_STACK (),
> -                                     0 /* depth */,
> -                                     PVM_PRINT_FLAT,
> -                                     16 /* base */,
> -                                     2 /* indent */,
> -                                     0 /* acutoff */,
> -                                     PVM_PRINT_F_MAPS);
> -          pk_puts ("\n");
> -          tmp[i++] = JITTER_TOP_STACK ();
> -          JITTER_DROP_STACK ();
> -        }
> -
> -     /* Restore the stack.  */
> -     for (j = (i - 1); j >= 0; j--)
> -        JITTER_PUSH_STACK (tmp[j]);
> +    int i = 0;
> +    int num_elems_max =
> +      PVM_STATE_BACKING_FIELD (canary) == NULL
> +        ? 1024
> +        :  (pvm_val*)JITTER_HEIGHT_STACK () -
> +           (pvm_val*)PVM_STATE_BACKING_FIELD (canary);
> +    int num_elems = (int) JITTER_ARGN0;
> +
> +    if (num_elems == 0 || num_elems > num_elems_max)
> +      num_elems = num_elems_max;
> +
> +    while (i < num_elems)
> +      {
> +        pvm_print_val_with_params (PVM_STATE_BACKING_FIELD (vm),
> +                                   JITTER_AT_DEPTH_STACK (i),
> +                                   0 /* depth */,
> +                                   PVM_PRINT_FLAT,
> +                                   16 /* base */,
> +                                   2 /* indent */,
> +                                   0 /* acutoff */,
> +                                   PVM_PRINT_F_MAPS);
> +        pk_puts ("\n");
> +        i++;
> +      }
>    end
>  end



reply via email to

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