[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] pkl: Re-implement `strace` instruction
From: |
Mohammad-Reza Nabipoor |
Subject: |
[PATCH] pkl: Re-implement `strace` instruction |
Date: |
Wed, 1 Dec 2021 22:31:32 +0330 |
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):
(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
--
2.34.1
- [PATCH] pkl: Re-implement `strace` instruction,
Mohammad-Reza Nabipoor <=