Commit Graph

6164 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto ff2464e879 string.c: make String#initialize_copy private 2025-06-15 14:11:54 +09:00
Yukihiro "Matz" Matsumoto 35d073a986 vm.c: fix unintended argument renaming by Google Jules; #6533 2025-06-06 11:53:14 +09:00
Yukihiro "Matz" Matsumoto 2b75da7335 Merge pull request #6553 from mruby/add-vm-comments 2025-06-06 08:15:41 +09:00
google-labs-jules[bot] da9365f98e Add descriptive comments for MRB_API functions in src/vm.c
This commit adds Doxygen-style comments to several MRB_API functions
in src/vm.c to improve code readability and documentation.

The following functions were commented:
- mrb_stack_extend
- mrb_protect_error
- mrb_funcall
- mrb_funcall_id
- mrb_funcall_with_block
- mrb_funcall_argv
- mrb_yield_with_class
- mrb_yield_argv
- mrb_yield
- mrb_vm_run
- mrb_vm_exec
- mrb_top_run

Additionally, the parameter name 'self' in mrb_yield_with_class was
renamed to 'self_obj' for better clarity and consistency with the new comment.
2025-06-05 23:14:43 +00:00
Yukihiro "Matz" Matsumoto e55b3f0c55 Merge pull request #6552 from mruby/fix-comments-variable-c 2025-06-06 08:14:17 +09:00
google-labs-jules[bot] b4826fdbcf Fix: Correct placement of comments in src/variable.c
This commit corrects the placement of C-style block comments
for MRB_API functions in src/variable.c. Comments are now
placed directly before each function definition as per standard
documentation practices.
2025-06-05 23:13:42 +00:00
Yukihiro "Matz" Matsumoto 2f19fe1e36 Merge pull request #6551 from mruby/add-comments-state 2025-06-06 08:13:11 +09:00
google-labs-jules[bot] 19ddbdcf4b Add descriptive comments for MRB_API functions in src/state.c
This commit adds descriptive comments to the following MRB_API functions in src/state.c, clarifying their purpose and functionality:

- mrb_open_core
- mrb_open
- mrb_free_context
- mrb_close
- mrb_add_irep
- mrb_top_self
- mrb_state_atexit
2025-06-05 23:12:50 +00:00
Yukihiro "Matz" Matsumoto bdd379bc8c Merge pull request #6550 from mruby/add-comments-to-proc-c 2025-06-06 08:12:32 +09:00
google-labs-jules[bot] ddbbf3bd82 Add descriptive comments for MRB_API functions in src/proc.c
This commit adds Doxygen-style comments to the following MRB_API functions in src/proc.c:
- mrb_proc_new_cfunc
- mrb_proc_new_cfunc_with_env
- mrb_closure_new_cfunc
- mrb_proc_cfunc_env_get

The comments describe the purpose, parameters, and return value of each function.
2025-06-05 23:12:02 +00:00
Yukihiro "Matz" Matsumoto 64d390b9e0 numeric.c : add descriptive comments for public functions
- mrb_int_overflow
- mrb_int_zerodiv
- mrb_int_pow
- mrb_div_int
- mrb_div_int_value
- mrb_float_to_str
- mrb_check_num_exact
- mrb_int_mul
- mrb_num_shift
- mrb_float_to_integer
- mrb_int_add
- mrb_int_sub
- mrb_int_to_cstr
- mrb_integer_to_str
- mrb_cmp

The comments were written by Google Jules.
2025-06-06 08:11:37 +09:00
Yukihiro "Matz" Matsumoto d3f339062b Merge pull request #6549 from mruby/add-kernel-comments 2025-06-05 10:36:52 +09:00
google-labs-jules[bot] 1e3295d93e Add descriptive comments to kernel functions
This commit adds descriptive C-style comments to the following functions
in `src/kernel.c`:

- `mrb_func_basic_p`: Explains that the function checks if an object's method is implemented by a specific C function.
- `mrb_obj_freeze`: Explains that the function freezes an object, preventing further modifications.
- `mrb_obj_is_instance_of`: Explains that the function checks if an object is an instance of a given class.
2025-06-05 01:35:27 +00:00
Yukihiro "Matz" Matsumoto 24a84a5a37 Merge pull request #6548 from mruby/add-comments-etc 2025-06-05 10:34:17 +09:00
google-labs-jules[bot] 52d56fe443 Add descriptive comments to MRB_API functions in src/etc.c
This commit adds Doxygen-style comments to several MRB_API functions
in the `src/etc.c` file. These comments explain the purpose,
parameters, and return values of these functions, improving code
readability and maintainability.

The following functions were commented:
- mrb_data_object_alloc
- mrb_data_check_type
- mrb_data_check_get_ptr
- mrb_data_get_ptr
- mrb_obj_to_sym
- mrb_obj_id
- mrb_word_boxing_float_value
- mrb_word_boxing_value_float
- mrb_word_boxing_cptr_value
- mrb_boxing_int_value
2025-06-05 01:33:38 +00:00
Yukihiro "Matz" Matsumoto a3e72804cd range.c: add descriptive comments to MRB_API functions in src/range.c
This commit adds descriptive comments to the following functions:

- mrb_range_ptr
- mrb_range_new
- mrb_range_beg_len

The comments were written by Google Jules.
2025-06-04 11:03:35 +09:00
google-labs-jules[bot] e68eafd511 Add descriptive comments for MRB_API functions in src/class.c
This commit adds C-style block comments to all MRB_API functions
defined in the src/class.c file. The comments explain the purpose
of each function, its parameters, and its return value, aiming to
improve code readability and maintainability.
2025-06-04 01:59:44 +00:00
Yukihiro "Matz" Matsumoto 8e0081923f Merge pull request #6543 from mruby/add-comments-dump-c-partial 2025-06-03 09:01:56 +09:00
google-labs-jules[bot] c837d386de Add descriptive comments to several functions in src/dump.c
This commit adds Doxygen-style comments to the following functions
in src/dump.c, ensuring "@brief" is not used:

Non-static functions (comments reviewed/updated):
- mrb_dump_irep
- mrb_dump_irep_binary
- mrb_dump_irep_cfunc

Static functions (new comments added):
- write_irep_header
- write_iseq_block
- dump_float (if compiled)
- get_pool_block_size
- write_pool_block
- get_syms_block_size
- write_syms_block
- get_irep_record_size

This work is part of a larger effort to document all non-trivial
functions in this file as per your feedback. The remaining functions
will be documented in subsequent commits.
2025-06-03 00:01:24 +00:00
Yukihiro "Matz" Matsumoto c3d2b903c6 error.c: add descriptive comments
The comments are written by Google Jules.
2025-06-03 08:53:06 +09:00
Yukihiro "Matz" Matsumoto 83b21e8fd6 Merge pull request #6542 from mruby/add-symbol-comments 2025-06-03 08:43:23 +09:00
google-labs-jules[bot] e8458f9c22 Add descriptive comments to MRB_API functions in src/symbol.c
This commit adds descriptive comments to all functions marked with MRB_API
in the `src/symbol.c` file. The comments explain the purpose, parameters,
and return values of these functions, improving code readability and
maintainability.

The following functions were commented:
- mrb_intern
- mrb_intern_static
- mrb_intern_cstr
- mrb_intern_str
- mrb_intern_check
- mrb_check_intern
- mrb_intern_check_cstr
- mrb_check_intern_cstr
- mrb_intern_check_str
- mrb_check_intern_str
- mrb_sym_name_len
- mrb_sym_str
- mrb_sym_name
- mrb_sym_dump
2025-06-02 23:42:40 +00: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
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 ec68497a39 Merge pull request #6540 from mruby/add-comments-object-c 2025-05-31 22:48:02 +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
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
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
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
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 77d08772a5 error.c (mrb_vformat): prevent SEGV from %s with NULL 2025-05-21 09:52:10 +09:00