[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] pkl: fix `get_time'
From: |
Jose E. Marchesi |
Subject: |
Re: [PATCH] pkl: fix `get_time' |
Date: |
Mon, 23 Jan 2023 23:35:50 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Hi Mohammad.
OK for master.
Thaks1
> 2023-01-23 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
>
> * libpoke/pvm.jitter (time): Change the instruction to push
> SEC and NSEC to the stack (instead of creating an array and
> pushing the array to the stack).
> * libpoke/pkl-rt.pk (get_time): Adapt.
> * testsuite/poke.pkl/get-time-1.pk: New test.
> * testsuite/Makefile.am (EXTRA_DIST): Add new test.
> ---
> ChangeLog | 9 +++++++++
> libpoke/pkl-rt.pk | 5 ++++-
> libpoke/pvm.jitter | 15 ++++-----------
> testsuite/Makefile.am | 1 +
> testsuite/poke.pkl/get-time-1.pk | 7 +++++++
> 5 files changed, 25 insertions(+), 12 deletions(-)
> create mode 100644 testsuite/poke.pkl/get-time-1.pk
>
> diff --git a/ChangeLog b/ChangeLog
> index 65cff30d..d40ffc62 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,12 @@
> +2023-01-23 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
> +
> + * libpoke/pvm.jitter (time): Change the instruction to push
> + SEC and NSEC to the stack (instead of creating an array and
> + pushing the array to the stack).
> + * libpoke/pkl-rt.pk (get_time): Adapt.
> + * testsuite/poke.pkl/get-time-1.pk: New test.
> + * testsuite/Makefile.am (EXTRA_DIST): Add new test.
> +
> 2023-01-23 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
>
> * libpoke/pkl-typify.c (pkl_typify1_ps_type_integral): Reject
> diff --git a/libpoke/pkl-rt.pk b/libpoke/pkl-rt.pk
> index 7cb81ec7..151e3ce4 100644
> --- a/libpoke/pkl-rt.pk
> +++ b/libpoke/pkl-rt.pk
> @@ -178,7 +178,10 @@ immutable fun flush = (int<32> ios, offset<uint<64>,1>
> offset) void:
>
> immutable fun get_time = int<64>[2]:
> {
> - return asm int<64>[2]: ("time");
> + var t = int<64>[2] ();
> +
> + asm ("time" : t[0], t[1]);
> + return t;
> }
>
> immutable fun strace = void:
> diff --git a/libpoke/pvm.jitter b/libpoke/pvm.jitter
> index 757915ef..1f266683 100644
> --- a/libpoke/pvm.jitter
> +++ b/libpoke/pvm.jitter
> @@ -6819,25 +6819,18 @@ end
> # Instruction: time
> #
> # Push the current system time to the stack in the form of
> -# an array of two long elements containing the number of seconds
> +# two long elements containing the number of seconds
> # and nanoseconds since the epoch.
> #
> -# Stack: ( -- ARR )
> +# Stack: ( -- LONG(sec) LONG(nsec) )
>
> instruction time ()
> code
> struct timespec ts;
> - pvm_val arr = pvm_make_array (
> - PVM_MAKE_ULONG (2, 64),
> - pvm_make_integral_type (PVM_MAKE_ULONG (64, 64), PVM_MAKE_INT (1,
> 32)));
>
> pvm_gettime (&ts);
> - (void) pvm_array_insert (arr, PVM_MAKE_LONG (0, 64),
> - PVM_MAKE_LONG (ts.tv_sec, 64));
> - (void) pvm_array_insert (arr, PVM_MAKE_LONG (1, 64),
> - PVM_MAKE_LONG (ts.tv_nsec, 64));
> -
> - JITTER_PUSH_STACK (arr);
> + JITTER_PUSH_STACK (PVM_MAKE_LONG (ts.tv_sec, 64));
> + JITTER_PUSH_STACK (PVM_MAKE_LONG (ts.tv_nsec, 64));
> end
> end
>
> diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
> index cff03d63..35ab2bd4 100644
> --- a/testsuite/Makefile.am
> +++ b/testsuite/Makefile.am
> @@ -1522,6 +1522,7 @@ EXTRA_DIST = \
> poke.pkl/get-endian-1.pk \
> poke.pkl/get-ios-1.pk \
> poke.pkl/get-ios-2.pk \
> + poke.pkl/get-time-1.pk \
> poke.pkl/getenv-1.pk \
> poke.pkl/getenv-2.pk \
> poke.pkl/gt-arrays-diag-1.pk \
> diff --git a/testsuite/poke.pkl/get-time-1.pk
> b/testsuite/poke.pkl/get-time-1.pk
> new file mode 100644
> index 00000000..2a794d98
> --- /dev/null
> +++ b/testsuite/poke.pkl/get-time-1.pk
> @@ -0,0 +1,7 @@
> +/* { dg-do run } */
> +
> +var t = get_time;
> +
> +/* { dg-command {.set obase 10} } */
> +/* { dg-command {t isa int<64>[2]} } */
> +/* { dg-output "1" } */