mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
e7cbd8cc28
Implements dual-mechanism GC protection and optimizes task lookup using pointer arithmetic based on PicoRuby reference implementation. GC Protection: - Add mrb_gc_register/unregister to protect Task objects - Implement mrb_task_mark_all() to mark task contexts during GC - Store proc reference in mrb_task to prevent premature collection - Integrate marking into gc.c root_scan_phase Performance Optimizations: - Add MRB2TASK macro for O(1) context-to-task conversion - Optimize Task.current: O(n) queue search -> O(1) pointer arithmetic - Optimize Task.pass: simplify to root context check - Optimize Task.join: use MRB2TASK for current task lookup Bug Fixes: - Fix MRB_TASK_CREATED/STOPPED to use MRB_FIBER_TERMINATED - Add safety check to prevent execution of terminated tasks - Initialize callinfo PC to bytecode start in task_init_context Co-authored-by: Claude <noreply@anthropic.com>