37 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto 072855a242 gc.c: add contiguous heap region support (mrb_gc_add_region)
Allow users to provide contiguous memory buffers for GC heap pages
via mrb_gc_add_region(). Region pages are carved from user-owned
buffers and never freed by the GC. This is the foundation for
bitmap GC on embedded targets with fragmented RAM.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-26 08:54:01 +09:00
Yukihiro "Matz" Matsumoto 31fea1709f gc.c: replace gcnext gray linked list with fixed-size gray stack
remove per-object gcnext pointer from MRB_OBJECT_HEADER, saving one
word (8 bytes on 64-bit) per object slot. the gray list for tri-color
marking is replaced by a fixed-size stack (MRB_GRAY_STACK_SIZE=1024)
in mrb_gc. when the stack overflows, a linear heap rescan recovers
gray objects.

object slot size: 48 -> 40 bytes (16.7% reduction on 64-bit).
benchmarks show up to 12% RSS reduction on object-heavy workloads
with neutral performance impact.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-12 13:38:21 +09:00
dearblue 8b495cdfda Cancel the warning disablement
Suppress warnings for 0-length sequences is not required.

By commit f1a02dff58, it was introduced.
By commit 24939723d7, pseudo-variable length arrays are now used and the warning suppression is no longer needed.
By commit e8841fbf58, moved the intervening code.
2024-09-10 21:07:43 +09:00
Yukihiro "Matz" Matsumoto d708931b10 gc.c: revert 38b9a25e83
Fix #6041
2023-09-09 14:31:13 +09:00
Yukihiro "Matz" Matsumoto e8841fbf58 gc.h: move mrb_heap_page definition to gc.c 2023-09-05 23:29:24 +09:00
Yukihiro "Matz" Matsumoto 38b9a25e83 gc.c (mrb_obj_alloc): remove free_next,free_prev from heap pages
It used to be maintain heap pages with allocatable objects (free_heaps)
but we can save two words (16 bytes) per page by scanning live heap pages.
2023-06-27 15:48:25 +09:00
Yukihiro "Matz" Matsumoto b6181ae58a mruby/gc.h: reorder mrb_gc members to reduce alignment gaps 2023-06-09 17:19:09 +09:00
Yukihiro "Matz" Matsumoto 8b8e186688 gc.h: rename majorgc_old_threashold to oldgen_threashold
This field means that if you have more old generation objects than
this value, major GC mode will be turned on.
2023-06-06 11:26:35 +09:00
Yukihiro "Matz" Matsumoto eaa89fbe2a Merge branch 'get-args-array' of https://github.com/sasq64/mruby into sasq64-get-args-array 2022-08-24 16:46:00 +09:00
Yukihiro "Matz" Matsumoto b99c389ec3 internal.h: aggregate internal functions.
Internal functions can only be called from within the library.
Functions listed in `mruby/internal.h` can be called from:

* core (src/*.c)
* gems (mrbgems/**/*.c)

But not from the application linked with `libmruby`.
2022-04-02 18:25:13 +09:00
Jonas Minnberg c6f0452d13 Added comments about removal of objects[]
Made mrb_get_args_v() static
2021-12-12 16:14:53 +01:00
Jonas Minnberg 24939723d7 Remove zero length array since it is not C++ compatible 2021-12-11 14:23:59 +01:00
dearblue 94c5c8f44c Introduce MRB_GC_RED
Replaces the magic number `7` except in `src/gc.c`.
2021-04-24 10:31:21 +09:00
Yukihiro "Matz" Matsumoto 5e55b61c44 Fix mrb_int and size_t combination warnings. 2020-08-11 15:06:51 +09:00
dearblue ccd5f203bf Improve prototype for mrb_objspace_page_slot_size(); ref #5032
If it qualify a return type that is not a pointer with `const`, the
compiler ignores it.
2020-07-24 11:48:09 +09:00
Rory OConnell 41e3220539 All values use page slot size in calculation 2020-07-13 15:56:27 -07:00
David Siaw b5299b1c58 fix up documentation for values 2019-08-18 20:12:44 +09:00
Tomasz Dąbrowski f1a02dff58 fix: include\mruby/gc.h(43): warning C4200: nonstandard extension used: zero-sized array in struct/union 2017-09-27 14:42:27 +02:00
Yukihiro "Matz" Matsumoto aa8e490fd5 Prevent GC during each_object; fix #3616 2017-04-25 17:25:48 +09:00
Yukihiro "Matz" Matsumoto 62dae09bf6 Allow mrb_objspace_each_objects() to break iteration; ref #3359 2017-04-20 15:44:56 +09:00
Yukihiro "Matz" Matsumoto 065966dae4 common.h are supposed to be included from other header, so call it with quotes; ref #3032 2015-11-28 00:10:38 +09:00
Yukihiro "Matz" Matsumoto 5c405dea3d include changed from by quotes ("") to by brackets (<>); close #3032 2015-11-27 17:48:23 +09:00
furunkel 1c6b1d0155 Prefix mrb_gc_state enum members, make color defines private 2015-10-20 10:54:47 +02:00
furunkel 2b39d87fe8 Remove gc_ prefix of mrb_gc fields 2015-10-19 23:00:07 +02:00
furunkel 2f8b0f66bc Move MRB_GC_ARENA_SIZE to gc.h and fix compiler warnings 2015-10-19 22:43:09 +02:00
furunkel 3ab2f9371e Clean up GC code 2015-10-19 22:29:43 +02:00
Seba Gamboa a0fe0c40b1 Remove old doxygen tags 2015-10-08 12:29:10 -03:00
Seba Gamboa 40bf7bde78 Sorting documentation grouping 2015-09-21 01:48:42 -03:00
Seba Gamboa c127614638 Setting up doxygen groups 2015-09-20 21:14:07 -03:00
Tatsuhiko Kubo 3b904e9408 Unify include guard styles and header comments. 2014-08-21 13:27:37 +09:00
Yukihiro "Matz" Matsumoto 206f89e209 add MRB_API modifiers to mruby API functions 2014-08-04 00:47:08 +09:00
cremno a2cfc9a9af rework mruby-objectspace and gc.[ch]
- functions should have C linkage (for C++ code)
- add prefix to each_object_callback
- use more appropriate variable types / initialization
- ObjectSpace::count_objects has 1 opt. arg.
- prefer mrb_intern_lit to mrb_intern_cstr for str. lit.
- mruby/value.h is included by mruby.h
- adjust coding style
2014-01-31 17:42:05 +01:00
Yukihiro "Matz" Matsumoto 5c0b9b703c primary mruby fiber implementation 2013-05-20 17:54:07 +09:00
Ryan Scott 4acfadfee1 Fixed the each object callback to be more consistent with other callbacks. 2013-05-18 10:55:41 +10:00
Ryan Scott 40d63f7740 Changed the each_object callback so that a pointer is passed for the object, instead of the struct. 2013-05-17 08:02:24 +10:00
Ryan Scott f62cc5b1ee Changed the object_count so that it only iterates over the RBasic object, not the full RVALUE known by the GC 2013-05-17 07:41:13 +10:00
Ryan Scott 222918deae First implementation of ObjectSpace moved outside of gc.c 2013-05-17 07:21:33 +10:00