summaryrefslogtreecommitdiff
path: root/enumerator.c
AgeCommit message (Collapse)Author
2023-12-24Fix Enumerator#with_index for GC compactionPeter Zhu
enumerator_block_call was not safe for compaction because the Array backing the argv was not pinned, so it could get moved during compaction which would make argv point to somewhere else. The test crashes when RGENGC_CHECK_MODE is turned on: TestEnumerator#test_with_index_under_gc_compact_stress check_rvalue_consistency: 0x55db0b399450 is not a Ruby object. test/ruby/test_enumerator.rb:133: [BUG] check_rvalue_consistency_force: there is 1 errors. ruby 3.3.0dev (2023-12-23T23:00:27Z master 50bf437341) [x86_64-linux] -- Control frame information ----------------------------------------------- c:0034 p:---- s:0192 e:000187 CFUNC :with_index c:0033 p:---- s:0185 e:000184 CFUNC :each c:0032 p:---- s:0182 e:000181 CFUNC :to_a c:0031 p:0055 s:0178 e:000175 BLOCK test/ruby/test_enumerator.rb:133 c:0030 p:0024 s:0172 e:000171 METHOD tool/lib/envutil.rb:242 c:0029 p:0024 s:0167 e:000166 METHOD tool/lib/envutil.rb:251 c:0028 p:0005 s:0160 e:000159 METHOD test/ruby/test_enumerator.rb:131 ... -- C level backtrace information ------------------------------------------- build/ruby(rb_print_backtrace+0x14) [0x55db0b1deb21] vm_dump.c:820 build/ruby(rb_vm_bugreport) vm_dump.c:1151 build/ruby(bug_report_end+0x0) [0x55db0b3a53a6] error.c:1042 build/ruby(rb_bug_without_die) error.c:1042 build/ruby(die+0x0) [0x55db0afc77c2] error.c:1050 build/ruby(rb_bug) error.c:1052 build/ruby(gc_move+0x0) [0x55db0afbada0] gc.c:1714 build/ruby(check_rvalue_consistency+0xa) [0x55db0afef0c3] gc.c:1729 build/ruby(is_markable_object) gc.c:4769 build/ruby(gc_mark_stack_values) gc.c:6595 build/ruby(rb_gc_mark_vm_stack_values) gc.c:6605 build/ruby(rb_execution_context_mark+0x39) [0x55db0b1d8589] vm.c:3309 build/ruby(thread_mark+0x15) [0x55db0b1a9805] vm.c:3381 build/ruby(gc_mark_stacked_objects+0x6d) [0x55db0aff2c3d] gc.c:7564 build/ruby(gc_mark_stacked_objects_all) gc.c:7602 build/ruby(gc_marks_rest) gc.c:8797 build/ruby(gc_marks+0xd) [0x55db0aff43d5] gc.c:8855 build/ruby(gc_start) gc.c:9608 build/ruby(rb_multi_ractor_p+0x0) [0x55db0aff5463] gc.c:9489 build/ruby(rb_vm_lock_leave) vm_sync.h:92 build/ruby(garbage_collect) gc.c:9491 build/ruby(newobj_slowpath+0xcb) [0x55db0aff57ab] gc.c:2871 build/ruby(newobj_slowpath_wb_protected) gc.c:2895 build/ruby(newobj_of0+0x24) [0x55db0aff59e4] gc.c:2937 build/ruby(newobj_of) gc.c:2947 build/ruby(rb_wb_protected_newobj_of) gc.c:2962 build/ruby(ary_alloc_embed+0x10) [0x55db0b2f3e40] array.c:668 build/ruby(ary_new) array.c:709 build/ruby(rb_ary_tmp_new_from_values) array.c:759 build/ruby(rb_ary_new_from_values) array.c:771 build/ruby(args_copy+0x18) [0x55db0b1bbb88] vm_args.c:158
2023-11-30Add `RUBY_REFERENCES`Nobuyoshi Nakada
Instead of `RUBY_REFERENCES_START` and `RUBY_REFERENCES_END`, so that auto-indent works well.
2023-11-30Prefix `REF_EDGE` and `REFS_LIST_PTR` with `RUBY_`Nobuyoshi Nakada
Also move `struct` so that `typedef`-ed names can be used.
2023-11-29Implement proc_entry on VWAPeter Zhu
2023-11-29Implement Write Barriers on proc_entryPeter Zhu
2023-11-29Add RUBY_TYPED_FREE_IMMEDIATELY flag to proc_entryPeter Zhu
2023-11-27Implement Write Barriers on Enumerator::ProducerPeter Zhu
2023-11-27Implement Write Barriers on Enumerator::GeneratorPeter Zhu
2023-11-27Implement Write Barriers on Enumerator::YielderPeter Zhu
2023-11-23Implement Write Barriers on EnumeratorPeter Zhu
2023-11-22Remove unneccesary defines in enumeratorMatt Valentine-House
2023-11-22Remove unneccesary memsize functions in enumeratorMatt Valentine-House
2023-11-22VWA Embed the rest of the data objects in EnumeratorMatt Valentine-House
2023-11-20Implement Enumerator objects on VWAPeter Zhu
This commit implements Enumerator objects on VWA. This speeds allocations and decreases memory usage. ``` require "benchmark" ary = [] puts(Benchmark.measure do 10_000_000.times do u = ary.to_enum end end) puts `ps -o rss= -p #{$$}` ``` Before: ``` 1.500774 0.002717 1.503491 ( 1.506791) 18512 ``` After: ``` 0.892580 0.002539 0.895119 ( 0.897642) 16480 ```
2023-10-25Fix [Bug #19632]: Disable external iterator for frozen enumerator (#7791)Hiroya Fujinami
* Fix [Bug #19632]: Disable external iterator for frozen enumerator Currently, methods to manipulate an external iterator like `#next` and `#feed` can be called even if a receiver of an enumerator is frozen. However, these methods change the state of an external iterator in an enumerator. Therefore, it seems a BUG to me, and these methods should raise FrozenError if the receiver is frozen. This fixed the following methods to raise FrozenError if the receiver is frozen. - `Enumerator#next` - `Enumerator#next_values` - `Enumerator#peek` - `Enumerator#peek_values` - `Enumerator#feed` - `Enumerator#rewind` * Fix a typo in the document Thanks @Maumagnaguagno.
2023-07-15Fix stack trace for rescued StopIterationMarcelo Pereira
Notes: Merged: https://github.com/ruby/ruby/pull/6201
2023-06-24Do not have Enumeratory::Lazy#zip mark result as packedJeremy Evans
Fixes [Bug #19569] Notes: Merged: https://github.com/ruby/ruby/pull/7967
2023-03-17Implement declarative references for enumeratorMatt Valentine-House
Notes: Merged: https://github.com/ruby/ruby/pull/7153
2022-12-26Try to fix RDoc markup for EnumeratorBenoit Daloze
2022-12-21Make Enumerartor.product return nil when called with a blockAkinori MUSHA
2022-12-21Make product consistently yield an array of N elements instead of N argumentsAkinori MUSHA
Inconsistency pointed out by @mame: ``` >> Enumerator.product([1], [2], [3]).to_a => [[1, 2, 3]] >> Enumerator.product([1], [2]).to_a => [[1, 2]] >> Enumerator.product([1]).to_a => [1] >> Enumerator.product().to_a => [nil] ``` Got fixed as follows: ``` >> Enumerator.product([1], [2], [3]).to_a => [[1, 2, 3]] >> Enumerator.product([1], [2]).to_a => [[1, 2]] >> Enumerator.product([1]).to_a => [[1]] >> Enumerator.product().to_a => [[]] ``` This was due to the nature of the N-argument funcall in Ruby.
2022-12-20Use "Fiber storage variables" consistentlyBenoit Daloze
Notes: Merged: https://github.com/ruby/ruby/pull/6974
2022-12-20Improve documentation for fiber-scoped variablesBenoit Daloze
* Especially around Enumerator. Notes: Merged: https://github.com/ruby/ruby/pull/6974
2022-12-20Never use the storage of another Fiber, that violates the whole designBenoit Daloze
* See https://bugs.ruby-lang.org/issues/19078#note-30 Notes: Merged: https://github.com/ruby/ruby/pull/6972
2022-12-16Reject keyword arguments given to Enumerator::Product.newAkinori MUSHA
The use of keyword arguments should be reserved for future extension.
2022-12-01Introduce `Fiber#storage` for inheritable fiber-scoped variables. (#6612)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-11-25`remain` no longer starts with 0Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6809
2022-11-25[Bug #18971] Add precheck to enumeratorNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6809
2022-11-16Using UNDEF_P macroS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/6721
2022-08-11Fix Array#[] with ArithmeticSequence with negative steps (#5739)Jeremy Evans
* Fix Array#[] with ArithmeticSequence with negative steps Previously, Array#[] when called with an ArithmeticSequence with a negative step did not handle all cases correctly, especially cases involving infinite ranges, inverted ranges, and/or exclusive ends. Fixes [Bug #18247] * Add Array#slice tests for ArithmeticSequence with negative step to test_array Add tests of rb_arithmetic_sequence_beg_len_step C-API function. * Fix ext/-test-/arith_seq/beg_len_step/depend * Rename local variables * Fix a variable name Co-authored-by: Kenta Murata <3959+mrkn@users.noreply.github.com> Notes: Merged-By: mrkn <mrkn@ruby-lang.org>
2022-08-06Adjust styles [ci skip]Nobuyoshi Nakada
2022-07-30Implement Enumerator::Product and Enumerator.product [Feature #18685]Akinori MUSHA
Notes: Merged: https://github.com/ruby/ruby/pull/6197
2022-07-21Expand tabs [ci skip]Takashi Kokubun
[Misc #18891] Notes: Merged: https://github.com/ruby/ruby/pull/6094
2021-09-27Introduce `RBIMPL_NONNULL_ARG` macroNobuyoshi Nakada
Runtime assertion for the argument declared as non-null. This macro does nothing if `RBIMPL_ATTR_NONNULL` is effective, otherwise asserts that the argument is non-null. Notes: Merged: https://github.com/ruby/ruby/pull/4898 Merged-By: nobu <nobu@ruby-lang.org>
2021-09-23Comparing nonnull argument to NULL is uselessNobuyoshi Nakada
2021-09-12Using RB_FLOAT_TYPE_P macroS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/4821
2021-09-05Replace RBOOL macroS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/4791
2021-06-17Adjust styles [ci skip]Nobuyoshi Nakada
* --braces-after-func-def-line * --dont-cuddle-else * --procnames-start-lines * --space-after-for * --space-after-if * --space-after-while
2021-05-27Fix lazy enumerator with index sizeJeremy Evans
Fixes [Bug #17889] Notes: Merged: https://github.com/ruby/ruby/pull/4534
2021-04-09Fix documentation for Enumerator::Lazy#with_indexJeremy Evans
If a block is given, it returns a lazy enumerator that will iterate over the block, it doesn't iterate over the block immediately. Fixes [Bug #17789]
2021-03-06Undef Enumerator::Chain#{feed,next,next_values,peek,peek_values}Jeremy Evans
Previously these methods were defined but raised TypeError, which seems worse. Notes: Merged: https://github.com/ruby/ruby/pull/3811
2021-03-06Make Enumerator#{+,chain} create lazy chain if any included enumerator is lazyJeremy Evans
Implements [Feature #17347] Notes: Merged: https://github.com/ruby/ruby/pull/3811
2021-03-06Fix calling enumerator methods such as with_index on Enumerator::ChainJeremy Evans
This previously raised a TypeError. Wrap the Enumerator::Chain in an Enumerator to work around the problem. Fixes [Bug #17216] Notes: Merged: https://github.com/ruby/ruby/pull/3811
2021-01-08Replace `Kernel.#open` with `URI.open` in docMasataka Pocke Kuwabara
Because `Kernel.#open` no longer opens URI since Ruby 3.0. Notes: Merged: https://github.com/ruby/ruby/pull/4039
2021-01-02Add Enumerable#compact and Enumerator::Lazy#compactzverok
Notes: Merged: https://github.com/ruby/ruby/pull/3851
2020-12-22Enumerator.new: raise unless block given卜部昌平
Has been deprecated since c73b6bd7ebd01133538c645566944132dbde4d13. [Feature #17116] [ruby-dev:50945] Notes: Merged: https://github.com/ruby/ruby/pull/3968
2020-12-21Document usage of ArithmeticSequence in Array#slice, and add to NEWS (#3952)Victor Shepelev
Notes: Merged-By: mrkn <mrkn@ruby-lang.org>
2020-12-09Fix ArithmeticSequence#last and ArithmeticSequence#each for non-integer ↵Kenta Murata
sequences (#3870) [Bug #17218] [ruby-core:100312] Notes: Merged-By: mrkn <mrkn@ruby-lang.org>
2020-10-21Removed more unnecessary ID cachesNobuyoshi Nakada
``` find . -name \*.o -exec nm {} + |& grep -e 'InitVM_.*\.rbimpl_id' -e 'Init_.*\.rbimpl_id' | sed 's/^.* b //;s/\.[1-9][0-9]*$//;s/\.rbimpl_id$//' | uniq ``` should be empty.
2020-10-21Feature #16812: Allow slicing arrays with ArithmeticSequence (#3241)Kenta Murata
* Support ArithmeticSequence in Array#slice * Extract rb_range_component_beg_len * Use rb_range_values to check Range object * Fix ary_make_partial_step * Fix for negative step cases * range.c: Describe the role of err argument in rb_range_component_beg_len * Raise a RangeError when an arithmetic sequence refers the outside of an array [Feature #16812] Notes: Merged-By: mrkn <mrkn@ruby-lang.org>