aboutsummaryrefslogtreecommitdiffstats
path: root/array.c
Commit message (Collapse)AuthorAgeFilesLines
* Add missing RB_GC_GUARDs related to DATA_PTRKJ Tsanaktsidis2024-03-311-0/+1
| | | | | | | | | I discovered the problem in `compile.c` from a failing TestIseqLoad#test_stressful_roundtrip test with ASAN enabled. The other two changes in array.c and string.c I found by auditing similar usages of DATA_PTR in the codebase. [Bug #20402]
* [DOC] Array doc (#10199)Burdette Lamar2024-03-131-0/+25
|
* Add 'In brief' for Array#[]BurdetteLamar2024-03-061-0/+10
|
* Remove unneeded RUBY_FUNC_EXPORTEDPeter Zhu2024-02-231-1/+1
|
* [DOC] Doc compliance (#9955)Burdette Lamar2024-02-141-1/+1
|
* Comply with doc guideBurdetteLamar2024-02-121-101/+101
|
* Replace assert with RUBY_ASSERT in array.cPeter Zhu2024-02-121-62/+62
| | | | | | assert does not print the bug report, only the file and line number of the assertion that failed. RUBY_ASSERT prints the full bug report, which makes it much easier to debug.
* Rewrite Array#each in Ruby using Primitive (#9533)Takashi Kokubun2024-01-231-45/+14
|
* [DOC] correct doc comment for rb_ary_asetEdwing1232024-01-181-2/+3
| | | Signed-off-by: Edwin Garcia <egarciavalle2014@gmail.com>
* [DOC] Enhance documentation for `Array#zip`Akshay Birajdar2024-01-091-0/+7
|
* [DOC] Add parentheses to Array#eql?Peter Zhu2023-12-271-2/+2
| | | | Makes the call-seq and code more consistent in format.
* [DOC] Link to Array#eql? from Array#hashPeter Zhu2023-12-251-1/+1
|
* Remove useless `#if 1` in array.cPeter Zhu2023-12-231-2/+0
|
* Fix ary_make_partial_step for compactionPeter Zhu2023-12-211-1/+6
| | | | | | | | | | ary could change embeddedness due to compaction, so we should only get the pointer after allocations. The included test was crashing with: TestArray#test_slice_gc_compact_stress ruby/lib/pp.rb:192: [BUG] Segmentation fault at 0x0000000000000038
* [DOC] No document for internal or debug methodsNobuyoshi Nakada2023-12-181-0/+1
|
* Array#rassoc should try to convert to array implicitly. Fixes #20003Tema Bolshakov2023-11-291-1/+1
|
* Fix compaction during ary_make_partialPeter Zhu2023-11-271-1/+4
| | | | | | The ary_make_shared call may allocate, which can trigger a GC compaction. This can cause the array to be embedded because it has a length of 0.
* Get rid of flatten_memo_data_typeJean Boussier2023-11-221-23/+12
| | | | | We can use an hidden Hash instead, it's simpler, triggers write barriers, handle compaction, etc.
* Keep write-barrier status after splicing arrayPeter Zhu2023-09-041-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We don't need to remove the write-barrier protected status after splicing an array. We can simply add it to the rememberset for marking during the next GC. The benchmark illustrates the performance impact on minor GC: ``` require "benchmark" arys = 1_000_000.times.map do ary = Array.new(50) ary.insert(1, 3) ary end 4.times { GC.start } puts(Benchmark.measure do 1000.times do GC.start(full_mark: false) end end) ``` This branch: ``` 1.309910 0.004342 1.314252 ( 1.314580) ``` Master branch: ``` 54.376091 0.219037 54.595128 ( 54.742996) ```
* [DOC] Remove typoNobuyoshi Nakada2023-08-291-1/+1
|
* Fix Array#bsearch when block returns a non-integer numeric valueKouhei Yanagita2023-08-291-2/+2
|
* Refactor ary_make_partialPeter Zhu2023-08-181-3/+3
|
* [DOC] Don't suppress autolinks (#8207)Burdette Lamar2023-08-111-65/+65
|
* No computing embed_capa_max in ary_make_partialKunshan Wang2023-08-031-5/+4
| | | | | ary_make_partial now uses the actual embed_capa of an allocated heap array to guide whether make an embedded copy or a slice view.
* Don't pass array into ary_heap_allocPeter Zhu2023-07-131-13/+9
| | | | | We no longer need a reference to the array when allocating the buffer because we no longer allocate through the transient heap.
* Remove unused references to the transient heapPeter Zhu2023-07-131-3/+0
|
* Remove RARRAY_CONST_PTR_TRANSIENTPeter Zhu2023-07-131-37/+37
| | | | RARRAY_CONST_PTR now does the same things as RARRAY_CONST_PTR_TRANSIENT.
* Remove RARRAY_PTR_USE_TRANSIENTPeter Zhu2023-07-131-17/+17
| | | | RARRAY_PTR_USE now does the same things as RARRAY_PTR_USE_TRANSIENT.
* [Feature #19730] Remove transient heapPeter Zhu2023-07-131-127/+9
|
* [DOC] Mention the edge case of `any?`/`all?`Nobuyoshi Nakada2023-06-011-0/+6
|
* Implement Hash ST tables on VWAPeter Zhu2023-05-171-3/+7
|
* [DOC] Move docs of `Array#first` and `Array#last` to array.rbNobuyoshi Nakada2023-05-101-67/+0
|
* Document that Array#{&,intersection,intersect?} use hash method [ci skip]Jeremy Evans2023-05-091-2/+6
| | | | Fixes [Bug #19622]
* * expand tabs. [ci skip]git2023-04-191-2/+2
| | | | Please consider using misc/expand_tabs.rb as a pre-commit hook.
* Emit special instruction for array literal + .(hash|min|max)Aaron Patterson2023-04-181-12/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit introduces a new instruction `opt_newarray_send` which is used when there is an array literal followed by either the `hash`, `min`, or `max` method. ``` [a, b, c].hash ``` Will emit an `opt_newarray_send` instruction. This instruction falls back to a method call if the "interested" method has been monkey patched. Here are some examples of the instructions generated: ``` $ ./miniruby --dump=insns -e '[@a, @b].max' == disasm: #<ISeq:<main>@-e:1 (1,0)-(1,12)> (catch: FALSE) 0000 getinstancevariable :@a, <is:0> ( 1)[Li] 0003 getinstancevariable :@b, <is:1> 0006 opt_newarray_send 2, :max 0009 leave $ ./miniruby --dump=insns -e '[@a, @b].min' == disasm: #<ISeq:<main>@-e:1 (1,0)-(1,12)> (catch: FALSE) 0000 getinstancevariable :@a, <is:0> ( 1)[Li] 0003 getinstancevariable :@b, <is:1> 0006 opt_newarray_send 2, :min 0009 leave $ ./miniruby --dump=insns -e '[@a, @b].hash' == disasm: #<ISeq:<main>@-e:1 (1,0)-(1,13)> (catch: FALSE) 0000 getinstancevariable :@a, <is:0> ( 1)[Li] 0003 getinstancevariable :@b, <is:1> 0006 opt_newarray_send 2, :hash 0009 leave ``` [Feature #18897] [ruby-core:109147] Co-authored-by: John Hawthorn <jhawthorn@github.com>
* [Feature #19474] Refactor NEWOBJ macrosMatt Valentine-House2023-04-061-10/+10
| | | | NEWOBJ_OF is now our canonical newobj macro. It takes an optional ec
* [Feature #19579] Remove !USE_RVARGC code (#7655)Peter Zhu2023-04-041-22/+0
| | | | | | | | | | | Remove !USE_RVARGC code [Feature #19579] The Variable Width Allocation feature was turned on by default in Ruby 3.2. Since then, we haven't received bug reports or backports to the non-Variable Width Allocation code paths, so we assume that nobody is using it. We also don't plan on maintaining the non-Variable Width Allocation code, so we are going to remove it.
* Remove an unneeded function copyTakashi Kokubun2023-04-011-9/+2
|
* `Array#first` and `Array#last` in RubyKoichi Sasada2023-03-231-17/+30
|
* rb_ary_sum: don't enter fast path if initial isn't a native numeric type.Jean Boussier2023-03-151-0/+7
| | | | | | | [Bug #19530] If the initial value isn't one of the special cased types, we directly jump to the slow path.
* Adjust styles [ci skip]Nobuyoshi Nakada2023-03-081-1/+2
|
* YJIT: Handle splat+rest for args pass greater than required (#7468)Jimmy Miller2023-03-071-0/+6
| | | | | | | | | | | For example: ```ruby def my_func(x, y, *rest) p [x, y, rest] end my_func(1, 2, 3, *[4, 5]) ```
* Stop exporting symbols for MJITTakashi Kokubun2023-03-061-4/+4
|
* Remove (newly unneeded) remarks about aliasesBurdetteLamar2023-02-191-12/+0
|
* Keep shared arrays WB protectedPeter Zhu2023-02-021-2/+2
| | | | | | | | | | | | | | Sharing an array will cause it to be WB unprotected due to the use of `RARRAY_PTR`. We don't need to WB unprotect the array because we're not writing to the buffer of the array. The following script demonstrates this issue: ``` ary = [1] * 1000 shared = ary[10..20] puts ObjectSpace.dump(ary) ```
* Remove function ary_recycle_hashPeter Zhu2023-01-241-28/+7
| | | | | | Freeing the memory of a Hash should be done by the garbage collector and not by array functions. This could potentially leak memory if ary_recycle_hash was not implemented properly.
* Remove ARY_SET_SHAREDPeter Zhu2023-01-101-15/+7
| | | | We don't need ARY_SET_SHARED since we already have rb_ary_set_shared.
* Don't allow re-embedding frozen arraysPeter Zhu2022-12-231-2/+9
| | | | | | | | Frozen arrays should not move from heap allocated to embedded because frozen arrays could be shared roots for other (shared) arrays. If the frozen array moves from heap allocated to embedded it would cause issues since the shared array would no longer know where to set the pointer in the shared root.
* Fix typo in array.cPeter Zhu2022-12-221-1/+1
| | | | We should be using the size of RArray and not RString for arrays.
* [DOC] Correct Array#compact! descriptionJonathan Lim2022-12-111-1/+1
|