Commit Graph

16944 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto 91c59ced99 mruby-time: replace magic numbers to C macros
The code is written by Google Jules.
2025-06-02 15:55:44 +09:00
Yukihiro "Matz" Matsumoto 46b8e80d9e Merge pull request #6541 from mruby/add-api-comments-array 2025-06-02 08:48:57 +09:00
google-labs-jules[bot] 7f3329e393 Add descriptive comments for MRB_API functions in src/array.c
This change adds C-style multiline comments to all functions
marked with MRB_API in the src/array.c file.

The comments explain each function's purpose, its parameters,
and what it returns, where applicable. This improves the
readability and maintainability of the C API for mruby arrays.

The `@brief` markup was intentionally avoided as per your
requirements.
2025-06-01 23:48:11 +00:00
Yukihiro "Matz" Matsumoto 9c5d1cdaa9 Merge branch 'jules_wip_7626599795303680331' 2025-06-01 17:58:39 +09:00
google-labs-jules[bot] 493cc64902 hash.c: add descriptive comments to C-facing MRB_API hash functions
This commit adds C-style descriptive comments to MRB_API functions
in `src/hash.c` that are intended for use as part of mruby's C API.
The comments are targeted at C developers using these functions directly.

Comments were added or updated for the following functions:
- mrb_hash_new: Added comment.
- mrb_hash_new_capa: Updated existing comment to be more C API user-centric.
- mrb_hash_dup: Added comment.
- mrb_hash_get: Added comment.
- mrb_hash_fetch: Added comment.
- mrb_hash_set: Added comment.
- mrb_hash_delete_key: Added comment.
- mrb_hash_size: Added comment.
- mrb_hash_merge: Added comment.
- mrb_hash_foreach: Comment updated in a previous phase of work.

This work aligns with the guideline to comment C-facing MRB_API functions,
while avoiding adding new C-API comments to those MRB_API functions
that solely implement Ruby methods and already have extensive Ruby
method documentation (call-seq) in the source. The @brief markup
was avoided as per the original issue request.
2025-06-01 17:57:30 +09:00
Yukihiro "Matz" Matsumoto 273e7325c9 Merge pull request #6538 from mruby/dependabot/bundler/rake-13.3.0 2025-05-31 22:48:52 +09:00
Yukihiro "Matz" Matsumoto ec68497a39 Merge pull request #6540 from mruby/add-comments-object-c 2025-05-31 22:48:02 +09:00
Yukihiro "Matz" Matsumoto 05c7aa2fe2 Merge pull request #6539 from mruby/add-string-comments 2025-05-31 22:47:45 +09:00
google-labs-jules[bot] f4b56a5e56 Add descriptive comments to MRB_API functions in object.c
This commit adds and updates C-style block comments for all functions marked with MRB_API in src/object.c.

The comments explain the purpose, parameters, and return values of these functions, adhering to the project's documentation style and avoiding the use of '@brief' markup.

Existing comments were also reviewed and updated for clarity and consistency.
2025-05-31 13:45:31 +00:00
google-labs-jules[bot] 5924a23b8d Here's the rewritten message:
Add descriptive comments for MRB_API functions in src/string.c

This commit adds descriptive comments to various MRB_API functions
within the src/string.c file. These comments aim to improve code
readability and maintainability by explaining the purpose,
parameters, and return values of these functions.
2025-05-31 13:44:19 +00:00
dependabot[bot] bbb5d28530 build(deps): bump rake from 13.2.1 to 13.3.0
Bumps [rake](https://github.com/ruby/rake) from 13.2.1 to 13.3.0.
- [Release notes](https://github.com/ruby/rake/releases)
- [Changelog](https://github.com/ruby/rake/blob/master/History.rdoc)
- [Commits](https://github.com/ruby/rake/compare/v13.2.1...v13.3.0)

---
updated-dependencies:
- dependency-name: rake
  dependency-version: 13.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-30 14:40:20 +00:00
Yukihiro "Matz" Matsumoto df62559ddb Merge pull request #6537 from mruby/add-cdump-comments 2025-05-30 07:24:00 +09:00
Yukihiro "Matz" Matsumoto b925d6fee4 Merge pull request #6536 from mruby/add-debug-comments 2025-05-30 07:23:45 +09:00
google-labs-jules[bot] bee56a8634 The comments in cdump.c have been updated to remove the @brief tag from the Doxygen-style comment for the mrb_dump_irep_cstruct function. This change was made based on your feedback.
The rest of the comment, which details the function's purpose, parameters, return values, and conditional compilation, remains unchanged.
2025-05-29 22:22:07 +00:00
Yukihiro "Matz" Matsumoto 0011ee2267 Merge pull request #6535 from mruby/add-mempool-comments 2025-05-29 10:06:32 +09:00
Yukihiro "Matz" Matsumoto 70614ba82a Merge pull request #6534 from mruby/add-readfloat-comment 2025-05-29 09:25:39 +09:00
google-labs-jules[bot] a668834b2d Add descriptive comments to public functions in src/debug.c
This change adds Doxygen-style comments to the public API functions
in `src/debug.c`, including mrb_packed_int_len, mrb_packed_int_encode,
and mrb_packed_int_decode. The comments explain the purpose of each function,
its parameters, and its return value. This improves the readability
and maintainability of the code.
2025-05-28 22:06:18 +00:00
google-labs-jules[bot] e0d1f99744 I've added descriptive comments for functions/macros in src/mempool.c.
This commit adds Doxygen-style comments to the public functions,
internal static functions, and structs within the `src/mempool.c` file.
These comments clarify the purpose, parameters, and return values (where applicable)
of these code elements, improving code readability and maintainability.

The following elements were commented:
- struct mempool_page
- struct mempool
- ALIGN_PADDING macro
- mempool_open()
- mempool_close()
- page_alloc()
- mempool_alloc()
- mempool_realloc()
2025-05-28 22:02:53 +00:00
google-labs-jules[bot] 224d0c8933 Add descriptive comment to mrb_read_float function
This commit adds a descriptive comment at the beginning of the `mrb_read_float` function in `src/readfloat.c`.

The comment explains the function's purpose, its parameters (`str`, `endp`, `fp`), and its return value (`TRUE` or `FALSE`). This improves code readability and understanding.
2025-05-28 22:01:17 +00:00
Yukihiro "Matz" Matsumoto e5905fe1dc Merge pull request #6533 from katafrakt/fix-extended-callback 2025-05-28 11:13:38 +09:00
Yukihiro "Matz" Matsumoto eb5fbfbb40 class.c: Remove MRB_INLINE_METHOD_CACHE support from mt_tbl
The sorted array binary search implementation no longer uses the inline
cache array, so remove all MRB_INLINE_METHOD_CACHE definitions and
related code.
2025-05-28 08:33:21 +09:00
Yukihiro "Matz" Matsumoto e8ebeb151d class.c: Switch mt_tbl to sorted array binary search for method lookups
By replacing the open‐addressing hash with a sorted array and binary
search, we eliminate tombstone management and improve cache locality of
method entries. This preserves the original contiguous values+keys
layout and peak memory usage, while simplifying growth logic and
delivering lookup performance gains.
2025-05-28 07:54:42 +09:00
Paweł Świątkowski bdcd496bc2 Fix calling extended callback
The callback of extending module should be called, not of a singleton
class of an extended object.
2025-05-27 23:03:10 +02:00
Yukihiro "Matz" Matsumoto bec5dbc4e9 variable.c (iv_copy): just memcpy sorted array; no iv_put 2025-05-27 10:58:41 +09:00
Yukihiro "Matz" Matsumoto 63a09ee336 variable.c (iv_rehash): just memcpy sorted array; no need to call iv_put 2025-05-27 10:53:58 +09:00
Yukihiro "Matz" Matsumoto 9cee6ead4c variable.c: use binary search for iv_tbl lookups
Preserve the original iv_tbl heap layout and allocation pattern, but
switch iv_put to maintain sorted keys and iv_get/iv_del to perform
binary search. This eliminates extra probing overhead, improves
read-heavy lookup performance for small tables, and incurs zero
additional allocations.
2025-05-27 10:33:09 +09:00
Yukihiro "Matz" Matsumoto ca6dc4ec2d variable.c (iv_size): refactor the function
Along with removing an obsolete comment line.
2025-05-27 10:16:12 +09:00
Yukihiro "Matz" Matsumoto 7c02e17e25 variable.c (mrb_mod_cv_get): initialize local variable
To silence compiler warning.
2025-05-26 22:59:04 +09:00
Yukihiro "Matz" Matsumoto 11bf789730 array.c: remove unnecessary blank line 2025-05-26 14:32:19 +09:00
Yukihiro "Matz" Matsumoto 9537d9b75a Merge pull request #6532 from mruby/improve-mt-hash-load-factor 2025-05-25 20:57:36 +09:00
google-labs-jules[bot] e82f49adf7 I've reverted method table optimizations to prioritize memory savings for you.
My previous attempts to improve method table (mt_tbl) performance by introducing a load factor and adjusting the initial allocation size unfortunately led to undesirable increases in memory consumption.

Given that memory usage is a primary concern, I've reverted the following changes:
- Removed the load factor based rehashing logic.
- Removed the related definitions for the load factor.
- Ensured the initial allocation size is 8.

This restores the method table to its original behavior, where it rehashes only when the table is completely full or during initial allocation. This should bring memory usage back to its baseline level prior to these optimization attempts.
2025-05-25 11:40:43 +00:00
Yukihiro "Matz" Matsumoto ed8ec097a2 Merge pull request #6531 from mruby/improve-mt-hash-load-factor 2025-05-25 20:12:46 +09:00
google-labs-jules[bot] 8a91c91a69 Improve method table performance by rehashing at 75% load factor.
The method table (mt_tbl) in src/class.c previously only rehashed when it became completely full. With linear probing, this could lead to significant performance degradation for lookups and insertions as the table approached full capacity.

This change introduces a load factor (MT_LOAD_FACTOR_NUM/MT_LOAD_FACTOR_DEN, set to 3/4 or 0.75). The mt_put function now checks if adding a new element would cause the table's size to meet or exceed this load factor relative to its allocated capacity. If so, it triggers a rehash before inserting the new element.

This helps maintain more empty slots in the hash table, improving the average-case performance of linear probing and reducing the likelihood of worst-case scenarios. The existing initial allocation size and doubling strategy for rehashing are retained.
2025-05-24 22:50:29 +00:00
Yukihiro "Matz" Matsumoto 0c51a72bfe string.c (popcount): support when sizeof(int) == 4
This function is used when the compiler does not support builtin
popcount operation (namely VC++).
2025-05-23 23:10:45 +09:00
Yukihiro "Matz" Matsumoto ca526044d3 vm.c (stack_init): clear initial stack 2025-05-23 23:09:53 +09:00
Yukihiro "Matz" Matsumoto 86ef7a912d mruby-rational (int_lshift): check before actual left bit shift 2025-05-21 13:25:08 +09:00
Yukihiro "Matz" Matsumoto f4b01ed19e mruby-rational (int_lshift): exponential may be bigger than int bits 2025-05-21 10:40:02 +09:00
Yukihiro "Matz" Matsumoto 1fa9eaa2b5 mruby-eval (binding_eval_error_check): re-raise Exception in parsing 2025-05-21 10:25:35 +09:00
Yukihiro "Matz" Matsumoto 77d08772a5 error.c (mrb_vformat): prevent SEGV from %s with NULL 2025-05-21 09:52:10 +09:00
Yukihiro "Matz" Matsumoto 1726b61481 mruby-compiler (gen_move): avoid unnecessary goto's 2025-05-20 18:31:51 +09:00
Yukihiro "Matz" Matsumoto d329d9af79 mruby-compiler (gen_move): avoid optimization of ADDI/SUBI
ADDI/SUBI may fall back to method call that may clear block argument
place holder, which may be a live register. So we cannot directly call
ADDI/SUBI over local variables.
2025-05-20 18:31:21 +09:00
Yukihiro "Matz" Matsumoto d08276a052 codedump.c: remove unnecessary tab character from OP_MOVE 2025-05-19 23:36:16 +09:00
Yukihiro "Matz" Matsumoto 82d03b32f2 codedump.c: skip string body if it's empty 2025-05-19 23:34:02 +09:00
Yukihiro "Matz" Matsumoto f9414456a5 codedump.c: output format for OP_ARRAY has changed 2025-05-19 23:09:03 +09:00
Yukihiro "Matz" Matsumoto 1d426c50bf range.c (range_num_to_a): C++ compiler eagerly warns goto statement 2025-05-19 19:41:01 +09:00
Yukihiro "Matz" Matsumoto 94d9f6cfc7 range.c (range_num_to_a): support big integer beg/end in ranges 2025-05-19 17:36:54 +09:00
Yukihiro "Matz" Matsumoto ff4109735f range.c (range_num_to_a): improved float support 2025-05-19 17:36:45 +09:00
Yukihiro "Matz" Matsumoto 18c43c2a5a mruby-io: provide Kernel#p in this gem
To prevent ordering instability when output from mruby-io and Kernel#p
mixed.
2025-05-19 13:31:01 +09:00
Yukihiro "Matz" Matsumoto 65247613b9 Merge pull request #6530 from dearblue/visibility 2025-05-19 08:11:18 +09:00
Yukihiro "Matz" Matsumoto 31ebcb349e mruby-compiler: add y.tab.c in the repository again; close #6515
Since we have introduced lrama, everyone can generate same `y.tab.c`
on any platform, without installing Bison. That was the reason we have
removed `y.tab.c` from the repository. But this change cause #6515 and
bothered out-of-tree builds. So we (reluctantly) added `y.tab.c` again.
2025-05-19 08:00:37 +09:00