summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@ruby-lang.org>2020-11-02 14:40:29 -0800
committerAaron Patterson <tenderlove@ruby-lang.org>2020-11-02 14:42:48 -0800
commit67b2c21c327c96d80b8a0fe02a96d417e85293e8 (patch)
treec4ea1236016fc2b7e40582a69966d35c5f8c7289 /vm.c
parent79b242260bc0530503dde85eda8e79b1c2aa9a6e (diff)
Add `GC.auto_compact= true/false` and `GC.auto_compact`
* `GC.auto_compact=`, `GC.auto_compact` can be used to control when compaction runs. Setting `auto_compact=` to true will cause compaction to occurr duing major collections. At the moment, compaction adds significant overhead to major collections, so please test first! [Feature #17176]
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/vm.c b/vm.c
index ccb04c7..83911f8 100644
--- a/vm.c
+++ b/vm.c
@@ -2495,6 +2495,36 @@ rb_vm_update_references(void *ptr)
}
void
+rb_vm_each_stack_value(void *ptr, void (*cb)(VALUE, void*), void *ctx)
+{
+ if (ptr) {
+ rb_vm_t *vm = ptr;
+ rb_ractor_t *r = 0;
+ list_for_each(&vm->ractor.set, r, vmlr_node) {
+ VM_ASSERT(rb_ractor_status_p(r, ractor_blocking) ||
+ rb_ractor_status_p(r, ractor_running));
+ if (r->threads.cnt > 0) {
+ rb_thread_t *th = 0;
+ list_for_each(&r->threads.set, th, lt_node) {
+ VM_ASSERT(th != NULL);
+ rb_execution_context_t * ec = th->ec;
+ if (ec->vm_stack) {
+ VALUE *p = ec->vm_stack;
+ VALUE *sp = ec->cfp->sp;
+ while (p <= sp) {
+ if (!rb_special_const_p(*p)) {
+ cb(*p, ctx);
+ }
+ p++;
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+void
rb_vm_mark(void *ptr)
{
RUBY_MARK_ENTER("vm");