[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[COMMITTED] pvm: new instruction GC for running the collector
From: |
Jose E. Marchesi |
Subject: |
[COMMITTED] pvm: new instruction GC for running the collector |
Date: |
Thu, 19 Sep 2024 16:18:25 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
This commit adds a new PVM instruction named gc, that calls the PVM
garbage collector.
2024-09-19 Jose E. Marchesi <jemarch@gnu.org>
* libpoke/pvm-alloc.c (pvm_alloc_gc): Define.
* libpoke/pkl-insn.def (PKL_INSN_GC): Define.
* libpoke/pvm.jitter (gc): New instruction.
* testsuite/poke.pvm/pvm-insns-test.pk: Add test for gc instruction.
---
ChangeLog | 7 +++++++
libpoke/pkl-insn.def | 1 +
libpoke/pvm-alloc.c | 6 ++++++
libpoke/pvm.jitter | 13 +++++++++++++
testsuite/poke.pvm/pvm-insns-test.pk | 8 ++++++++
5 files changed, 35 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 06ebd28c..611b7128 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-09-19 Jose E. Marchesi <jemarch@gnu.org>
+
+ * libpoke/pvm-alloc.c (pvm_alloc_gc): Define.
+ * libpoke/pkl-insn.def (PKL_INSN_GC): Define.
+ * libpoke/pvm.jitter (gc): New instruction.
+ * testsuite/poke.pvm/pvm-insns-test.pk: Add test for gc instruction.
+
2024-09-19 Jose E. Marchesi <jemarch@gnu.org>
* poke/pk-cmd-ios.c (PK_FILE_F_RDONLY): Define.
diff --git a/libpoke/pkl-insn.def b/libpoke/pkl-insn.def
index 61bc78da..4f842f3d 100644
--- a/libpoke/pkl-insn.def
+++ b/libpoke/pkl-insn.def
@@ -482,6 +482,7 @@ PKL_DEF_INSN(PKL_INSN_DISAS,"","disas")
PKL_DEF_INSN(PKL_INSN_RAND,"","rand")
PKL_DEF_INSN(PKL_INSN_TIME,"","time")
PKL_DEF_INSN(PKL_INSN_SLEEP,"","sleep")
+PKL_DEF_INSN(PKL_INSN_GC,"","gc")
/* System interaction instructions. */
diff --git a/libpoke/pvm-alloc.c b/libpoke/pvm-alloc.c
index 188300cd..4c8ee84d 100644
--- a/libpoke/pvm-alloc.c
+++ b/libpoke/pvm-alloc.c
@@ -122,3 +122,9 @@ pvm_alloc_unregister_thread ()
{
assert (GC_unregister_my_thread () == GC_SUCCESS);
}
+
+void
+pvm_alloc_gc ()
+{
+ GC_gcollect ();
+}
diff --git a/libpoke/pvm.jitter b/libpoke/pvm.jitter
index bf516efd..f10c30bd 100644
--- a/libpoke/pvm.jitter
+++ b/libpoke/pvm.jitter
@@ -92,6 +92,7 @@ wrapped-functions
pk_upow
pk_format_binary
pvm_alloc
+ pvm_alloc_gc
pvm_allocate_struct_attrs
pvm_make_struct_type
pvm_typeof
@@ -7243,6 +7244,18 @@ instruction sleep ()
end
end
+# Instruction: gc
+#
+# Run the PVM garbage collector.
+#
+# Stack: ( -- )
+
+instruction gc ()
+ code
+ pvm_alloc_gc ();
+ end
+end
+
# Instruction: siz
#
# Given a value, push its size as a bit-offset.
diff --git a/testsuite/poke.pvm/pvm-insns-test.pk
b/testsuite/poke.pvm/pvm-insns-test.pk
index b49d8853..ccaff3f7 100644
--- a/testsuite/poke.pvm/pvm-insns-test.pk
+++ b/testsuite/poke.pvm/pvm-insns-test.pk
@@ -890,6 +890,14 @@ var tests = [
assert (asm int<32>: ("cgetn; nip; nnn; nip" : lambda void: {}));
}
},
+ /* Miscellaneous instructions. */
+ PkTest {
+ name = "gc",
+ func = lambda (string name) void:
+ {
+ asm ("gc");
+ }
+ },
];
var ok = pktest_run (tests);
--
2.30.2
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [COMMITTED] pvm: new instruction GC for running the collector,
Jose E. Marchesi <=