18465 Commits

Author SHA1 Message Date
mimaki 1d34c3bed5 Update version to 4.0.0RC. 4.0.0-rc 2026-03-05 11:58:41 +09:00
mimaki 18a1c33fd4 Merge remote-tracking branch 'origin' into stable 2026-03-05 11:14:03 +09:00
Yukihiro "Matz" Matsumoto 64263ebcea Merge pull request #6727 from leviongit/lims/ovld 2026-03-05 08:49:54 +09:00
leviongit 87f88a1ce8 fix grammar
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2026-03-03 13:58:23 +01:00
leviongit ab06ed825a change wording of the "overloading" section
the previous wording may have been taken as mruby not permitting the
overloading of operators on any class
2026-03-03 13:49:03 +01:00
Yukihiro "Matz" Matsumoto 736ec46ba0 version.h: bump version to mruby 4.0.0
update MRUBY_RUBY_VERSION to "4.0", MRUBY_RELEASE_MAJOR to 4,
MRUBY_RELEASE_MINOR to 0. update README.md references accordingly.

Co-authored-by: Claude <noreply@anthropic.com>
2026-03-03 11:10:18 +09:00
Yukihiro "Matz" Matsumoto a3861dcb53 vm.c: scope down tc variable from function to block scope
Inline L_DEF_METHOD body into OP_TDEF and OP_SDEF, making `tc`
(target class) a block-local variable in each case. This eliminates
the cross-case goto and frees one register at function scope.

`ch` (catch handler) cannot be scoped down because UNWIND_ENSURE
sets it before goto L_CATCH_TAGGED_BREAK where ch->target is
consumed (cross-goto flow requires function-scope visibility).

Co-authored-by: Claude <noreply@anthropic.com>
2026-03-02 12:04:48 +09:00
Yukihiro "Matz" Matsumoto e94adf1d57 AUTHORS: update entries [ci skip] 2026-03-02 11:50:38 +09:00
Yukihiro "Matz" Matsumoto 02877f043a amalgamation.md: document platform dependency of HAL gems
Amalgamated files include HAL gem source code selected at build time,
making them platform-specific. Document this as expected behavior.

Ref #6726.

Co-authored-by: Claude <noreply@anthropic.com>
2026-03-02 10:34:55 +09:00
Yukihiro "Matz" Matsumoto b9a1a1fb23 presym.rake: add presym dependencies for all builds, not just internal
Previously, explicit .o => presym.list_path dependencies were only
added for internal builds (mrbc sub-builds). When only a CrossBuild
is configured without an explicit Build.new, the implicit host build
is not internal, so its .o files had no ordering against presym header
generation. This caused "mruby/presym/id.h not found" errors when the
cross build's presym scanning triggered host compilation.

Fixes #6725.

Co-authored-by: Claude <noreply@anthropic.com>
2026-03-02 10:23:35 +09:00
Yukihiro "Matz" Matsumoto 74267ce91e error.h: fix RBreak size overflow on 32-bit platforms with MRB_NO_BOXING
On 32-bit platforms where alignof(int64_t) == 8 (ARM, MIPS, PowerPC,
RISC-V, MinGW), struct RBreak with MRB_USE_RBREAK_VALUE_UNION was 24
bytes (6 words) due to alignment padding before the union
mrb_value_union field. This exceeds the 5-word RVALUE limit, causing
a static assertion failure.

Replace union mrb_value_union with uint32_t[] storage (alignof == 4)
and use memcpy for value access. This gives exactly 20 bytes on all
32-bit platforms. Ref #6722

Co-authored-by: Claude <noreply@anthropic.com>
2026-03-02 09:56:25 +09:00
Yukihiro "Matz" Matsumoto 98bc495fd2 getting-started.md: add links to language and C API guides
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-28 11:35:28 +09:00
Yukihiro "Matz" Matsumoto 0313800b10 doc: add README.md as documentation index
Organizes 22 doc files by audience (getting started, embedders,
contributors) so visitors can find the right document quickly.
Rendered automatically by GitHub when browsing the doc/ directory.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-28 10:42:54 +09:00
Yukihiro "Matz" Matsumoto 438a3bdffc docs: fix version labels, add navigation aids
limitations.md: use consistent CRuby/mruby labels for remaining
entries that still had specific version strings.

language.md: add upfront summary of major CRuby differences so
porting developers see the key gotchas before reading the full doc.

capi.md: add table of contents for navigating the 800+ line
reference.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-27 22:03:39 +09:00
Yukihiro "Matz" Matsumoto 3ce3453e9c docs: improve usability of new documentation
language.md: reorganize stdlib tables by class name instead of gem
name so users can quickly find "does mruby have Time/File/Set?"

capi.md: fix mrb_protect example (mrb->exc is cleared after protect,
so mrb_print_error does not work; show mrb_inspect instead); fix
fiber yield example to show correct usage as return value.

gc.md, compiler.md, vm.md: add "read this if" guidance paragraphs
to help developers decide whether they need each document.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-27 19:03:29 +09:00
Yukihiro "Matz" Matsumoto 1c7b9b1f26 architecture.md: add cross-references to standalone internal docs
Replace duplicated GC, compiler, and VM details with concise
summaries linking to gc.md, compiler.md, and vm.md.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-27 18:36:09 +09:00
Yukihiro "Matz" Matsumoto c561b21d43 vm.md: add VM internals documentation
Covers execution context, call frames, stack layout, argument
encoding, dispatch loop, method lookup with cache, exception
handling, closure environments, and fiber switching.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-27 18:36:04 +09:00
Yukihiro "Matz" Matsumoto 95954d3905 compiler.md: add compiler pipeline documentation
Covers parser/lexer, code generator, IRep structure, operand
encoding with OP_EXT1/2/3, OP_ENTER aspec format, presym system,
and RITE binary format.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-27 18:35:58 +09:00
Yukihiro "Matz" Matsumoto 985b5108d5 gc.md: add GC internals documentation
Covers heap structure, tri-color marking, incremental phases, gray
stack, write barriers, arena management, generational mode, and
tuning parameters.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-27 18:35:52 +09:00
Yukihiro "Matz" Matsumoto 366d9be721 limitations.md: update version references and add missing limitations
Update CRuby/mruby version labels to generic names. Add sections for
refinements, Encoding, integer precision by boxing mode, and
ObjectSpace limitations.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-27 18:35:47 +09:00
Yukihiro "Matz" Matsumoto 0a5a305a01 capi.md: add error handling, fibers, procs, and compilation context sections
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-27 18:35:42 +09:00
Yukihiro "Matz" Matsumoto aa7556acdb language.md: add Ruby language subset guide
Covers supported syntax, numeric types by boxing mode, core classes,
standard library gemboxes, and key differences from CRuby.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-27 18:35:37 +09:00
Yukihiro "Matz" Matsumoto 449627d085 gc-arena-howto.md: update Array#inspect example to current code
The old inspect_ary() function no longer exists. Replace with the
current mrb_ary_to_s() implementation from src/array.c.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-27 18:04:35 +09:00
Yukihiro "Matz" Matsumoto 301436d400 mrbconf.md: update macro documentation for mruby 4.0
- add MRB_NO_BOXING, MRB_WORDBOX_NO_INLINE_FLOAT documentation
- update MRB_WORD_BOXING description (inline floats on 64-bit)
- add MRB_INT64 restriction note for 32-bit platforms
- fix MRB_MALLOC_TRIM -> MRB_USE_MALLOC_TRIM (renamed)
- fix MRB_ARY_LENGTH_MAX default (131072, not 1MB)
- remove stale MRB_USE_LINK_TIME_RO_DATA_P reference
- add MRB_SYMBOL_LINEAR_THRESHOLD and tuning profiles section
- remove outdated heap page size calculation (referenced mruby 3.1.0)

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-27 18:03:32 +09:00
Yukihiro "Matz" Matsumoto 5c1aaa0259 boxing.md: add inline float details and comparison table
Add sections on 64-bit inline float rotation encoding and 32-bit
RFloat heap allocation with char[] buffer for alignment safety.
Add comparison table of all three boxing modes and ABI note.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-27 17:19:08 +09:00
Yukihiro "Matz" Matsumoto 55348ce0da opcode.md: update instruction table to match current ops.h
Add 13 new opcodes (OP_GETIDX0, OP_MATCHERR, OP_SSEND0,
OP_SEND0, OP_BLKCALL, OP_RETSELF, OP_RETNIL, OP_RETTRUE,
OP_RETFALSE, OP_ADDILV, OP_SUBILV, OP_TDEF, OP_SDEF).
Fix renamed instructions (OP_LOADT -> OP_LOADTRUE, etc.).
Update title and introduction to reflect current state.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-27 17:05:47 +09:00
Yukihiro "Matz" Matsumoto 46b4a0400b gc.c: use renamed MRB_WORDBOX_NO_INLINE_FLOAT macro in RVALUE union
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-27 11:29:10 +09:00
Yukihiro "Matz" Matsumoto 05295bca32 Merge pull request #6723 from dearblue/RVALUE
Add `RInteger` and `RFloat` to `RVALUE`
2026-02-27 11:24:08 +09:00
Yukihiro "Matz" Matsumoto ad46759550 NEWS.md: add notes for macro rename and MRB_INT64 restriction
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-27 11:21:31 +09:00
Yukihiro "Matz" Matsumoto ccb2eb9b74 fmt_fp.c: fix float formatting on 32-bit x87 FPU
The power-of-10 normalization loop can leave f >= 10.0 when x87
extended precision (80-bit) produces different rounding than 64-bit
SSE2. This caused garbled output (e.g. "0.0,6.04*2000001e+19"
instead of "1.0e+20") because negative digit values were added to
'0'. Add a correction step after the loop, and clamp extracted
digits to [0,9] for robustness.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-27 11:16:03 +09:00
Yukihiro "Matz" Matsumoto 07a4b755fb object.h: fix MRB_OBJ_SHAPED_P false positive on 32-bit Hash
MRB_FL_OBJ_SHAPED uses bit 5 of flags, which on 32-bit conflicts
with Hash's ea_n_used field (bits 5-9). A Hash with entries would
falsely match MRB_OBJ_SHAPED_P, causing SEGV when its iv pointer
was misinterpreted as mrb_shaped_iv. Add tt == MRB_TT_OBJECT check
to the predicate.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-27 11:06:04 +09:00
Yukihiro "Matz" Matsumoto 59e1fe29d6 mrbconf.h: rename MRB_WORDBOX_NO_FLOAT_TRUNCATE to MRB_WORDBOX_NO_INLINE_FLOAT
The old name referred to "truncation" of float precision, which no
longer happens with rotation encoding. The new name describes the
actual behavior: disabling inline float encoding in word boxing.
The old name is kept as an obsolete alias for backward compatibility.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-27 10:30:01 +09:00
Yukihiro "Matz" Matsumoto 32f99a622d boxing_word.h: use memcpy-based RFloat access for unaligned 32-bit
On 32-bit with MRB_WORDBOX_NO_FLOAT_TRUNCATE, RFloat stores a double
(8-byte alignment) but GC heap slots only guarantee 4-byte alignment.
Use char array + memcpy accessors to avoid misaligned access (SIGBUS
on MIPS, undefined behavior per C standard).

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-27 10:08:37 +09:00
Yukihiro "Matz" Matsumoto eaaa66b39b mrbconf.h: prohibit MRB_INT64 on 32-bit with word/NaN boxing
Heap-allocated RInteger with int64_t requires 8-byte alignment,
but GC heap slots on 32-bit may not guarantee it, causing SIGBUS
on architectures like MIPS. MRB_NO_BOXING is still allowed since
integers are stored inline in mrb_value (no heap RInteger).

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-27 09:55:21 +09:00
Yukihiro "Matz" Matsumoto 4ed338bdb9 doc: add getting-started guide, C API reference, and architecture overview
Three new documents:
- doc/guides/getting-started.md: building, running, and embedding mruby
- doc/guides/capi.md: C API reference for values, classes, methods, etc.
- doc/internal/architecture.md: internal architecture for developers

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-27 09:18:17 +09:00
Yukihiro "Matz" Matsumoto b76d92db2d NEWS.md: add object shapes entry
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-27 08:40:32 +09:00
Yukihiro "Matz" Matsumoto 8d10056aff variable.c: add object shapes for MRB_TT_OBJECT IV storage
Introduce "object shapes" (hidden classes) that share IV key
layouts across objects with the same instance variable assignment
order. This eliminates per-object key storage overhead.

Memory savings: ~22% heap reduction for object-heavy workloads
(e.g., 150k objects with 2-6 IVs). Per-object: 40->24 bytes
for 2 IVs. Objects exceeding 16 IVs or using
remove_instance_variable fall back to traditional iv_tbl.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-27 08:29:46 +09:00
Yukihiro "Matz" Matsumoto b4d2524fb4 NEWS.md: update for mruby 4.0 release
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-26 11:35:38 +09:00
Yukihiro "Matz" Matsumoto bf376a6160 memory.md: document mrb_gc_add_region() heap region API
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-26 08:56:23 +09:00
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 74fb046544 load.c: consolidate irep allocation for .mrb loading
Pack pool/syms/reps arrays into a single calloc with the irep struct,
reducing 4 allocations per irep to 1. Arrays are ordered by descending
alignment (pool/reps/syms) to eliminate inter-array padding.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-25 15:20:19 +09:00
Yukihiro "Matz" Matsumoto 3c2922a361 rom-method-table.md: fix prettier table formatting
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-25 15:20:03 +09:00
Yukihiro "Matz" Matsumoto 3b9784a263 mlc_config.json: add retry and accept 502 as alive status
GitHub sometimes returns transient 502 errors for valid URLs,
causing false positives in CI markdown link checks.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-25 15:12:57 +09:00
Yukihiro "Matz" Matsumoto 9e0eec3974 mruby-compiler: fix MRB_NO_STDIO build in codegen_pattern()
remove snprintf() call that requires <stdio.h>, which is unavailable
with MRB_NO_STDIO; use a static error message consistent with other
codegen_error() calls.

Fixes #6724.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-25 15:11:27 +09:00
Yukihiro "Matz" Matsumoto 06bce53132 fix build for MRB_NO_BOXING + MRB_INT64 on 32-bit
- array.h: disable embedded arrays when MRB_INT64 makes mrb_value
  too large to embed (fixes MRB_ARY_EMBED_LEN_MAX assertion)
- error.h: enable MRB_USE_RBREAK_VALUE_UNION for all 32-bit
  no-boxing builds (MRB_USE_FLOAT32 is irrelevant without
  word/nan boxing)
- gc.c: restrict RVALUE 8-byte alignment padding to
  MRB_WORD_BOXING builds (fixes RVALUE size assertion)
- vm.c: guard direct ary->as.ary access with MRB_ARY_NO_EMBED

Fixes #6722.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-25 15:10:24 +09:00
Yukihiro "Matz" Matsumoto 8df9a22a85 presym.rake: fix unnecessary full recompilation on single file changes
Restrict .o -> presym.list_path dependency to internal builds only
(mrbc sub-build). Regular host/cross builds don't need this because
:all => :gensym ordering guarantees presym headers exist before .o
compilation, and compiler .d files track header changes.

The broad dependency caused full recompilation because Rake's
all_prerequisite_tasks checks transitive prerequisites: every .o
transitively depended on every .pi file through presym.list_path.

Fixes #6721.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-25 15:10:05 +09:00
Yukihiro "Matz" Matsumoto b9007a8f0a cmdprint.c: extract next_print_no() helper
Consolidate the duplicated print_no increment-and-wrap logic
from dbgcmd_print() and dbgcmd_info_local() into a single
next_print_no() function.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-24 09:05:02 +09:00
Yukihiro "Matz" Matsumoto d3dfe83aa1 apibreak.c: simplify get_break_index()
Return directly from the loop instead of using a hit flag
and separate index variable.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-24 09:04:25 +09:00
Yukihiro "Matz" Matsumoto e35c011537 cmdmisc.c: extract parse_file_line_spec() from parse_listcmd_args()
Flatten 4-level nested parsing of list command arguments into
a separate parse_file_line_spec() function.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-24 09:03:59 +09:00
Yukihiro "Matz" Matsumoto 1d52c7a3dd mrdb.c: extract check_breakpoint_hit() from mrb_code_fetch_hook()
Combine method and line breakpoint checks into a single
check_breakpoint_hit() helper, simplifying the DBG_RUN case.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-24 09:03:28 +09:00