Commit Graph

18360 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto 653bf360bc mruby-socket: ROM method tables for Socket classes
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-19 09:39:30 +09:00
Yukihiro "Matz" Matsumoto 067f123193 mruby-method: ROM method tables for Method/UnboundMethod classes
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-19 09:39:28 +09:00
Yukihiro "Matz" Matsumoto 08e800e43e mruby-metaprog: ROM method tables for metaprogramming extensions
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-19 09:39:26 +09:00
Yukihiro "Matz" Matsumoto ba0f450fb4 mruby-io: ROM method tables for IO and File classes
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-19 09:39:24 +09:00
Yukihiro "Matz" Matsumoto ae41bb332a mruby-set: ROM method table for Set class (43 methods)
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-19 09:39:23 +09:00
Yukihiro "Matz" Matsumoto f46d77dcf0 mruby-time: ROM method table for Time class
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-19 09:39:19 +09:00
Yukihiro "Matz" Matsumoto f0a4820d44 mruby-symbol-ext: ROM method table for Symbol extensions (2 methods)
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-18 16:44:30 +09:00
Yukihiro "Matz" Matsumoto 4f167f55f7 mruby-range-ext: ROM method table for Range extensions (3 methods)
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-18 16:44:29 +09:00
Yukihiro "Matz" Matsumoto 63df017ff6 mruby-object-ext: ROM method tables for NilClass/Kernel/BasicObject extensions (5 methods)
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-18 16:44:27 +09:00
Yukihiro "Matz" Matsumoto b52d3936e6 mruby-numeric-ext: ROM method table for Integer extensions (9 methods)
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-18 16:44:25 +09:00
Yukihiro "Matz" Matsumoto 0ac01f23ba mruby-hash-ext: ROM method table for Hash extensions (6 methods)
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-18 16:44:23 +09:00
Yukihiro "Matz" Matsumoto 532ab1a74a mruby-proc-ext: ROM method tables for Proc/Kernel extensions (6 methods)
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-18 16:41:20 +09:00
Yukihiro "Matz" Matsumoto 51d0bfa1fc mruby-class-ext: ROM method tables for Module/Class extensions (11 methods)
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-18 16:41:18 +09:00
Yukihiro "Matz" Matsumoto 6b66f99c6b mruby-array-ext: ROM method table for Array extensions (29 methods)
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-18 16:41:10 +09:00
Yukihiro "Matz" Matsumoto d95d71fb8b mruby-string-ext: ROM method table for String/Integer extensions (54 methods)
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-18 16:38:51 +09:00
Yukihiro "Matz" Matsumoto 2c2e38cceb proc.c: ROM method table for Proc class (5 methods)
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-18 16:30:53 +09:00
Yukihiro "Matz" Matsumoto 6cf02c26b9 error.c: ROM method table for Exception class (7 methods)
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-18 16:30:51 +09:00
Yukihiro "Matz" Matsumoto c679c2762d symbol.c: ROM method table for Symbol class (6 methods)
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-18 16:30:49 +09:00
Yukihiro "Matz" Matsumoto c5470958c7 range.c: ROM method table for Range class (15 methods)
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-18 16:30:47 +09:00
Yukihiro "Matz" Matsumoto 1b20096c31 object.c: ROM method tables for NilClass/TrueClass/FalseClass (16 methods)
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-18 16:30:45 +09:00
Yukihiro "Matz" Matsumoto 8fdd5757e3 class.c: ROM method tables for BasicObject/Module/Class (49 methods)
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-18 16:30:43 +09:00
Yukihiro "Matz" Matsumoto cdbc18cf76 kernel.c: ROM method table for Kernel module (27 methods)
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-18 16:30:41 +09:00
Yukihiro "Matz" Matsumoto 63f462ef1f numeric.c: ROM method tables for Numeric/Integer/Float (63 methods)
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-18 16:30:38 +09:00
Yukihiro "Matz" Matsumoto 7f74ba248f hash.c: ROM method table for Hash class (36 methods)
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-18 16:30:37 +09:00
Yukihiro "Matz" Matsumoto 3b44a7001b array.c: ROM method table for Array class (36 methods)
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-18 16:30:35 +09:00
Yukihiro "Matz" Matsumoto 96da40605f class.c, string.c: ROM method table for String class
Move String's 46 method definitions from runtime
mrb_define_method_id() calls to a static ROM method table
sorted at init time. mrb_mt_init_rom() sorts the parallel
vals/keys arrays by presym ID and sets the readonly flag.

Expose mt_tbl and related types in internal.h so ROM tables
can be defined in individual source files.

When MRB_NO_PRESYM is defined, falls back to traditional
runtime method registration.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-18 16:12:56 +09:00
Yukihiro "Matz" Matsumoto 1e0f9b76c3 class.c: add chained method table infrastructure for ROM support
Add next pointer and readonly flag to mt_tbl struct to support
chained ROM method table layers. mt_get() walks the chain,
mt_copy() shares ROM layers, mt_free() and mrb_gc_mark_mt() skip
readonly layers. COW in mrb_define_method_raw() creates a mutable
top layer when the existing table is readonly. mt_flatten() merges
all layers for the rare remove_method case.

No ROM tables exist yet -- all tables have next==NULL and no
readonly flag, so behavior is identical to the previous code.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-18 15:53:18 +09:00
Yukihiro "Matz" Matsumoto e49479feaa mlc_config.json: ignore iso.org links in markdown-link-check
iso.org blocks automated HTTP requests with 403 Forbidden.
Also update the ISO 30170 URLs to current format in README.md
and CONTRIBUTING.md.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-18 15:41:55 +09:00
Yukihiro "Matz" Matsumoto 9910444212 etc.c: inline special float values in word boxing rotation encoding
Encode 0.0, -0.0, +Inf, -Inf, and NaN as small sentinel constants
with the float tag pattern, avoiding heap allocation for these common
special values.  All NaN bit patterns are normalized to a single
canonical NaN.  The 5 obscure floats near 2^(-255) whose rotation
encoding would collide with a sentinel are heap-allocated instead.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-18 15:41:55 +09:00
Yukihiro "Matz" Matsumoto b6148c893f boxing_word.h: lossless float encoding using rotation
Replace lossy 2-bit truncation with rotation-based encoding for
64-bit word boxing with float64. The new scheme uses
rotl64(float_bits - ADDEND, 3) to embed floats inline with full
52-bit mantissa precision. Floats with exponents outside [-255,+256]
(0.0, NaN, Inf, very small/large values) fall back to heap-allocated
RFloat.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-18 15:41:55 +09:00
Yukihiro "Matz" Matsumoto 4e63489d1a hash.c: add __pat_values() for pattern matching optimization
Add Hash#__pat_values(keys) that returns an array of values if all
keys exist, or false if any key is missing. This replaces per-key
key?() + []() calls (2N hash lookups) with a single method call
(N hash lookups). The compiler generates __pat_values() followed by
array indexing to extract each value for pattern matching.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-18 15:41:55 +09:00
Yukihiro "Matz" Matsumoto 5f429e151a mruby-compiler: extract gen_pat_keys_ary() helper for hash pattern codegen
Extract the keys-to-array loop (load keys + OP_ARRAY) into
gen_pat_keys_ary() helper. The pattern appeared in both
deconstruct_keys argument and __except argument generation.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-18 15:41:55 +09:00
Yukihiro "Matz" Matsumoto 8b080a53cd mruby-compiler: extract gen_pat_key() helper for hash pattern codegen
Reduce code duplication by extracting the key-loading pattern
(NODE_SYM check + OP_LOADSYM/codegen) into gen_pat_key() helper.
The pattern appeared 4 times in NODE_PAT_HASH codegen.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-18 15:41:55 +09:00
Yukihiro "Matz" Matsumoto a60ee2164e mruby-compiler: refactor deconstruct_keys argument in hash pattern
Simplify deconstruct_keys argument logic from 3 branches to 2:
- pass nil when rest pattern is present or no keys (all keys needed)
- pass keys array only for partial match without rest
This avoids building keys array twice when **rest is present.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-18 15:41:55 +09:00
Yukihiro "Matz" Matsumoto d98d62ee35 hash.c: change __except to take array argument
mrb_get_args(mrb, "*", ...) internally allocates an array when
arguments are on the stack, so passing keys as direct arguments
did not actually avoid allocation. Change __except to take a
single array argument instead, which is simpler and GC-safe.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-18 15:41:54 +09:00
Yukihiro "Matz" Matsumoto 0209e8d6fd Merge pull request #6719 from mruby/dependabot/github_actions/super-linter/super-linter-8.5.0
build(deps): bump super-linter/super-linter from 8.4.0 to 8.5.0
2026-02-17 16:04:01 +09:00
dependabot[bot] f88d8e3edf build(deps): bump super-linter/super-linter from 8.4.0 to 8.5.0
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 8.4.0 to 8.5.0.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/CHANGELOG.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v8.4.0...v8.5.0)

---
updated-dependencies:
- dependency-name: super-linter/super-linter
  dependency-version: 8.5.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-16 15:58:59 +00:00
Yukihiro "Matz" Matsumoto 488aa8630b mruby-compiler: handle __except with CALL_MAXARGS fallback
When a hash pattern has 15 or more keys, pack them into an array
before calling __except via OP_SEND with CALL_MAXARGS, since the
OP_SEND instruction can only encode up to 14 direct arguments.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-16 18:42:49 +09:00
Yukihiro "Matz" Matsumoto 1b14a3f72a hash.c: add __except method for pattern matching **rest
Add Hash#__except that returns a new hash excluding specified keys,
used by the compiler for **rest capture in hash patterns. Takes keys
as direct arguments to avoid array allocation. The compiler passes
matched key symbols directly on the stack via OP_SEND.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-16 18:16:27 +09:00
Yukihiro "Matz" Matsumoto 9b66ec82c4 mruby-compiler: fix hash pattern matching for CRuby compatibility
Add key existence check using key?() before value access, so that
missing keys correctly fail to match (e.g. {b: 1} no longer matches
{a: nil} pattern). Implement **nil and empty {} exact match via
hash.size == num_keys check. Fix **rest to properly exclude matched
keys using dup + __delete instead of copying the entire hash.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-16 17:33:41 +09:00
Yukihiro "Matz" Matsumoto 34b94129d2 mruby-hash-ext: remove non-compatible Hash#deconstruct_keys
CRuby's Hash#deconstruct_keys simply returns self regardless of
arguments. The mruby-hash-ext version filtered keys, which was
unnecessary since the compiler accesses individual keys via []
after calling deconstruct_keys. The Ruby implementation in
mrblib/hash.rb (returning self) is sufficient and CRuby-compatible.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-16 16:57:21 +09:00
Yukihiro "Matz" Matsumoto 75738a350a mruby-bigint: fix memory leak in mrb_bint_lcm()
mpz_abs() internally allocates via mpz_init_heap(), so
pre-allocating abs_x/abs_y with mpz_init_temp() leaked the
original allocations. let mpz_abs() handle allocation directly.

also use divide-first formula (abs_x/gcd)*abs_y to reduce
intermediate product size, and add bint_norm() for the result.

reported by OSS-Fuzz (clusterfuzz-testcase-6501272051318784).

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-16 16:34:21 +09:00
Yukihiro "Matz" Matsumoto 070bef24ab mruby-numeric-ext: fix integer overflow in Integer#lcm
check for overflow using mrb_int_mul_overflow() in the LCM
computation to avoid undefined behavior when the result exceeds
mrb_int range. raises RangeError instead.

reported by OSS-Fuzz (clusterfuzz-testcase-6501272051318784).

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-16 16:34:20 +09:00
Yukihiro "Matz" Matsumoto 7f6f2a85fc Merge pull request #6718 from eunos-1128/readme/homebrew-conda-installation
Add installation instructions for conda and Homebrew
2026-02-16 16:15:58 +09:00
UENO, M. c9295c4dae Update README.md 2026-02-14 12:44:58 +09:00
UENO, M. ce348d3bd5 Improve mruby installation instructions
Updated installation instructions for mruby to include compilation options.
2026-02-14 12:36:51 +09:00
UENO, M. 6da887a99a Update README.md
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2026-02-14 12:12:54 +09:00
UENO, M. 9ab05a9f3b Update mruby installation instructions in README
Added installation options for Homebrew and Conda.
2026-02-14 12:05:53 +09:00
Yukihiro "Matz" Matsumoto 12bc2cfaa1 mruby-io: reorder struct mrb_io to keep fd at offset 0
move fd, fd2, pid fields before the bitfield flags while keeping
the pointer field last. this preserves the 24-byte struct size
(same as 3.4.0) while restoring fd to offset 0 (same as 3.3.0).

some external gems (e.g. mruby-polarssl) pass struct mrb_io
pointers directly to libraries like mbedtls that expect an int fd
at offset 0. the 3.4.0 reorder moved bitfield flags to offset 0,
causing these gems to read garbage instead of the file descriptor.

fixes #6713

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-14 12:05:20 +09:00
Yukihiro "Matz" Matsumoto cac1c99c6c pre-commit.yml: remove duplicate --color=always argument
The prek-action already passes --color=always internally,
so passing it again via extra-args causes a CLI error.

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-14 10:23:34 +09:00