summaryrefslogtreecommitdiff
path: root/hash.c
AgeCommit message (Collapse)Author
2025-12-19[DOC] Harmonize <= methodsBurdetteLamar
2025-12-18[DOC] Harmonize lt methodsBurdette Lamar
2025-12-03Rename `rb_obj_exivar_p` -> `rb_obj_gen_fields_p`Jean Boussier
The "EXIVAR" terminology has been replaced by "gen fields" AKA "generic fields". Exivar implies variable, but generic fields include more than just variables, e.g. `object_id`.
2025-11-27Reorganize page documentations (#15154)Stan Lo
Re-organize page docs
2025-11-05Remove dead rb_hash_dumpPeter Zhu
2025-11-01[DOC] Fix typo in `Hash#compare_by_identity` docsSam Westerman
2025-10-23use `SET_SHAREABLE`Koichi Sasada
to adopt strict shareable rule. * (basically) shareable objects only refer shareable objects * (exception) shareable objects can refere unshareable objects but should not leak reference to unshareable objects to Ruby world
2025-10-03[DOC] hash.c - fix 3 class doc typosMSP-Greg
2025-08-24[DOC] Fix outdated `ENV::clone` method descriptionYaroslav
It does raise an exception rather than just issuing a warning: ```shell $ docker run -e ALL_RUBY_SINCE=2.7 --rm rubylang/all-ruby ./all-ruby -We 'ENV.clone' ruby-2.7.0 ... ruby-3.0.7 ruby-3.1.0-preview1 -e:1: warning: ENV.clone is deprecated; use ENV.to_h instead ... ruby-3.2.0-preview1 -e:1: warning: ENV.clone is deprecated; use ENV.to_h instead ruby-3.2.0-preview2 -e:1:in `clone': Cannot clone ENV, use ENV.to_h to get a copy of ENV as a hash (TypeError) from -e:1:in `<main>' exit 1 ... ruby-3.3.9 -e:1:in `clone': Cannot clone ENV, use ENV.to_h to get a copy of ENV as a hash (TypeError) from -e:1:in `<main>' exit 1 ruby-3.4.0-preview1 -e:1:in 'clone': Cannot clone ENV, use ENV.to_h to get a copy of ENV as a hash (TypeError) from -e:1:in '<main>' exit 1 ... ruby-3.5.0-preview1 -e:1:in 'clone': Cannot clone ENV, use ENV.to_h to get a copy of ENV as a hash (TypeError) from -e:1:in '<main>' exit 1 ```
2025-08-19[DOC] Tweaks for Object#hashBurdette Lamar
2025-08-12Allow encodings to be autoloaded through transcoding functionsLuke Gruber
Make sure VM lock is not held when calling `load_transcoder_entry`, as that causes deadlock inside ractors. `String#encode` now works inside ractors, among others. Atomic load the rb_encoding_list Without this, wbcheck would sometimes hit a missing write barrier. Co-authored-by: John Hawthorn <john.hawthorn@shopify.com> Hold VM lock when iterating over global_enc_table.names This st_table can be inserted into at runtime when autoloading encodings. minor optimization when calling Encoding.list
2025-07-30[DOC] Mention that Hash#replace also replaces defaultsJean Boussier
2025-07-28Remove unnecessary internal/gc.h include in hash.cPeter Zhu
hash.c compiles just fine on HASH_DEBUG without including internal/gc.h.
2025-07-26Adjust indents [ci skip]Nobuyoshi Nakada
2025-07-21Remove dsymbol_fstr_hashPeter Zhu
We don't need to delay the freeing of the fstr for the symbol if we store the hash of the fstr in the dynamic symbol and we use compare-by-identity for removing the dynamic symbol from the sym_set.
2025-07-18Remove dead post-hoc rehash checkAlan Wu
Hash#rehash checks whether the hash is iterating, and with VWA, RHASH_ST_TABLE() always returns the same thing for the same hash. RHASH_ST_TABLE(VALUE h) { return (st_table *)((uintptr_t)h + sizeof(struct RHash)); } So this check can never fail and raise an exception. Remove it.
2025-07-18Remove rehash checking TODO (GH-13919)Erik Berlin
Hash#rehash checks for rehash during iteration, and there seems to be no efficient way to check for it after the fact, so remove the TODO.
2025-07-16Avoid second RHASH_AR_TABLE_REF lookupErik Berlin
2025-06-24Fix write barriers in rb_hash_add_new_elementJohn Hawthorn
The write barriers must be run after the st_update callback returns, as the objects are not on the object until then and there may be allocation when there is a new object inserted. This is hard to reproduce, and I haven't seen an actual crash due to it, but it is detected by wbcheck RUBY_GC_LIBRARY=wbcheck WBCHECK_VERIFY_AFTER_WB=1 ./miniruby -e '("a".."zz").uniq.to_a' WBCHECK ERROR: Missed write barrier detected! Parent object: 0x720db01f99c0 (wb_protected: true) rb_obj_info_dump: 0x0000720db01f99c0 T_HASH/[S] 18 Reference counts - snapshot: 32, writebarrier: 2, current: 36, missed: 2 Missing reference to: 0x716db02e3450 rb_obj_info_dump: 0x0000716db02e3450 T_STRING/String len: 1, capa: 15 "q" Missing reference to: 0x716db02e3450 rb_obj_info_dump: 0x0000716db02e3450 T_STRING/String len: 1, capa: 15 "q" A part of why this is hard to reproduce and it's unlikely to crash is that the insertion only rarely allocates. Co-authored-by: Luke Gruber <luke.gruber@shopify.com>
2025-06-17* adjust indentNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/13634
2025-06-13Use the `shape_id` rather than `FL_EXIVAR`Jean Boussier
We still keep setting `FL_EXIVAR` so that `rb_shape_verify_consistency` can detect discrepancies. Notes: Merged: https://github.com/ruby/ruby/pull/13612
2025-05-25Use RB_VM_LOCKINGNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/13439
2025-05-22[Bug #21357] Fix crash in Hash#merge with blockDaniel Colson
Prior to https://github.com/ruby/ruby/commit/49b306ecb9e2e9e06e0b1590bacc5f4b38169c3c the `optional_arg` passed from `rb_hash_update_block_i` to `tbl_update` was a hash value (i.e. a VALUE). After that commit it changed to an `update_call_args`. If the block sets or changes the value, `tbl_update_modify` will set the `arg.value` back to an actual value and we won't crash. But in the case where the block returns the original value we end up calling `RB_OBJ_WRITTEN` with the `update_call_args` which is not expected and may crash. `arg.value` appears to only be used to pass to `RB_OBJ_WRITTEN` (others who need the `update_call_args` get it from `arg.arg`), so I don't think it needs to be set to anything upfront. And `tbl_update_modify` will set the `arg.value` in the cases we need the write barrier. Notes: Merged: https://github.com/ruby/ruby/pull/13404
2025-05-15[Bug #21333] Prohibit hash modification inside Hash#update blockNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/13344
2025-05-14[Bug #21331] Prohibit hash modification during stlike loopNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/13329
2025-05-14Remove unused retval assignmentsNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/13329
2025-05-14Revert "[Bug #21331] Prohibit modification during stlike loop"Nobuyoshi Nakada
This reverts commit bb180b87b43c45e17ff49735a26d7a188d5c8396, which caused "malloc during GC" error on wasm. Notes: Merged: https://github.com/ruby/ruby/pull/13329
2025-05-13[Bug #21331] Prohibit modification during stlike loopNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/13317
2025-04-28Support Marshal.{dump,load} for core SetJeremy Evans
This was missed when adding core Set, because it's handled implicitly for T_OBJECT. Keep marshal compatibility between core Set and stdlib Set, so you can unmarshal core Set with stdlib Set and vice versa. Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> Notes: Merged: https://github.com/ruby/ruby/pull/13185 Merged-By: jeremyevans <code@jeremyevans.net>
2025-04-02[DOC] Tweaks for Hash docBurdetteLamar
Notes: Merged: https://github.com/ruby/ruby/pull/13029
2025-03-31[DOC] Tweaks for Hash docBurdetteLamar
Notes: Merged: https://github.com/ruby/ruby/pull/13020
2025-03-31[DOC] Tweaks for Hash#updateBurdette Lamar
Notes: Merged: https://github.com/ruby/ruby/pull/12985 Merged-By: peterzhu2118 <peter@peterzhu.ca>
2025-03-29[DOC] Tweaks for Hash#values_atBurdetteLamar
Notes: Merged: https://github.com/ruby/ruby/pull/12989
2025-03-29[DOC] Tweaks for Hash#valuesBurdetteLamar
Notes: Merged: https://github.com/ruby/ruby/pull/12988
2025-03-29[DOC] Tweaks for Hash#has_value?BurdetteLamar
Notes: Merged: https://github.com/ruby/ruby/pull/12986
2025-03-25[DOC] Doc for Hash#transform_keys! (#12942)Burdette Lamar
Notes: Merged-By: peterzhu2118 <peter@peterzhu.ca>
2025-03-23[DOC] Doc for Hash#transform_values!Burdette Lamar
Notes: Merged: https://github.com/ruby/ruby/pull/12944 Merged-By: peterzhu2118 <peter@peterzhu.ca>
2025-03-23[DOC] Doc for Hash#transform_valuesBurdetteLamar
Notes: Merged: https://github.com/ruby/ruby/pull/12943
2025-03-17[DOC] Fix indentation for documentation of Hash#compactPeter Zhu
2025-03-16[DOC] Doc for Hash#transform_keysBurdetteLamar
Notes: Merged: https://github.com/ruby/ruby/pull/12935
2025-03-14[DOC] Tweaks for Hash#to_h (#12918)Burdette Lamar
Notes: Merged-By: peterzhu2118 <peter@peterzhu.ca>
2025-03-13[DOC] Tweaks for Hash#to_hashBurdetteLamar
Notes: Merged: https://github.com/ruby/ruby/pull/12920
2025-03-13[DOC] Tweaks for Hash#to_procBurdetteLamar
Notes: Merged: https://github.com/ruby/ruby/pull/12919
2025-03-11[DOC] Tweaks for Hash#sliceBurdette Lamar
Notes: Merged: https://github.com/ruby/ruby/pull/12907 Merged-By: peterzhu2118 <peter@peterzhu.ca>
2025-03-11[DOC] Tweaks for Hash#to_aBurdetteLamar
Notes: Merged: https://github.com/ruby/ruby/pull/12908
2025-03-11[DOC] Tweaks for Hash#shiftBurdetteLamar
Notes: Merged: https://github.com/ruby/ruby/pull/12906
2025-03-11[DOC] Tweaks for Hash#select! (#12904)Burdette Lamar
Notes: Merged-By: peterzhu2118 <peter@peterzhu.ca>
2025-03-11[DOC] Tweaks for Hash#select (#12903)Burdette Lamar
Notes: Merged-By: peterzhu2118 <peter@peterzhu.ca>
2025-03-11[DOC] Tweaks for Hash#reject!Burdette Lamar
Notes: Merged: https://github.com/ruby/ruby/pull/12902 Merged-By: peterzhu2118 <peter@peterzhu.ca>
2025-03-11[DOC] Tweaks for Hash#reject (#12876)Burdette Lamar
Notes: Merged-By: peterzhu2118 <peter@peterzhu.ca>