| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
| |
My previous attempt to correct #2068 apparently failed and the confusing
wording ("instances") was merged into trunk instead.
This should address any potential confusion.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
rb_str_buf_new always allocates at least 127 bytes of capacity, even
when less is requested.
> ObjectSpace.dump(%w[a b c].join)
{"address":"0x7f935f06ebf0", "type":"STRING", "class":"0x7f935d8b7bb0", "bytesize":3, "capacity":127, "value":"abc", "encoding":"UTF-8", "memsize":168, "flags":{"wb_protected":true}}
Instead, by using rb_str_new and then setting the length to 0, we can
allocate the exact amount of memory needed, without extra capacity.
> ObjectSpace.dump(%w[a b c].join)
{"address":"0x7f903fcab530", "type":"STRING", "class":"0x7f903f8b7988", "embedded":true, "bytesize":3, "value":"abc", "encoding":"UTF-8", "memsize":40, "flags":{"wb_protected":true}}
|
| |
|
|
|
|
| |
Closes: https://github.com/ruby/ruby/pull/2254
|
|
|
|
| |
Closes: https://github.com/ruby/ruby/pull/2255
|
|
|
|
|
|
|
|
|
|
|
| |
ARY_SHARED_P and ARY_EMBED_P included:
assert(!FL_TEST((ary), ELTS_SHARED) || !FL_TEST((ary), RARRAY_EMBED_FLAG)),
The two predicate macros are used in many other assert conditions,
which caused memory bloat during C compilation.
This change factors out the assertion above to a function.
Now gcc consumes 160 MB instead of 250 MB to compile array.c.
|
|
|
|
|
| |
The old code lost information of lineno. Now, an assertion error will
output a correct lineno (but now gcc 8 requires 250 MB, unfortunately).
|
|
|
|
|
|
|
| |
The assertion blows up gcc 8 by consuming approx. 1.8 GB memory.
This change reduces the amount of memory required to about 200 MB.
A follow-up of ae750799c1b28b06d02e50cd26450b9903516526.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
FL_TEST() uses FL_ABLE() which test data types. However,
in array.c we don't need to check it (all of them should be
T_ARRAY), so I changed from FL_TEST() to FL_TEST_RAW() which
does not check FL_ABLE(). Instead of FL_ABLE(), add assertion
to check given object is a T_ARRAY object.
For example, rb_ary_free() becomes slim:
with FL_TEST():
0000000000006a30 <rb_ary_free>:
6a30: 40 f6 c7 07 test $0x7,%dil
6a34: 48 8b 07 mov (%rdi),%rax
6a37: 75 09 jne 6a42 <rb_ary_free+0x12>
6a39: 48 f7 c7 f7 ff ff ff test $0xfffffffffffffff7,%rdi
6a40: 75 1e jne 6a60 <rb_ary_free+0x30>
6a42: a9 00 00 00 02 test $0x2000000,%eax
6a47: 74 07 je 6a50 <rb_ary_free+0x20>
6a49: f3 c3 repz retq
6a4b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1)
6a50: 48 8b 7f 20 mov 0x20(%rdi),%rdi
6a54: e9 00 00 00 00 jmpq 6a59 <rb_ary_free+0x29>
6a59: 0f 1f 80 00 00 00 00 nopl 0x0(%rax)
6a60: 89 c2 mov %eax,%edx
6a62: 83 e2 1f and $0x1f,%edx
6a65: 83 fa 1b cmp $0x1b,%edx
6a68: 74 d8 je 6a42 <rb_ary_free+0x12>
6a6a: f6 c4 60 test $0x60,%ah
6a6d: 74 d3 je 6a42 <rb_ary_free+0x12>
6a6f: eb d8 jmp 6a49 <rb_ary_free+0x19>```
with FL_TEST_RAW():
0000000000006a30 <rb_ary_free>:
6a30: 48 f7 07 00 60 00 02 testq $0x2006000,(%rdi)
6a37: 74 07 je 6a40 <rb_ary_free+0x10>
6a39: f3 c3 repz retq
6a3b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1)
6a40: 48 8b 7f 20 mov 0x20(%rdi),%rdi
6a44: e9 00 00 00 00 jmpq 6a49 <rb_ary_free+0x19>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Shared arrays created by Array#dup and so on points
a shared_root object to manage lifetime of Array buffer.
However, sometimes shared_root is called only shared so
it is confusing. So I fixed these wording "shared" to "shared_root".
* RArray::heap::aux::shared -> RArray::heap::aux::shared_root
* ARY_SHARED() -> ARY_SHARED_ROOT()
* ARY_SHARED_NUM() -> ARY_SHARED_ROOT_REFCNT()
Also, add some debug_counters to count shared array objects.
* ary_shared_create: shared ary by Array#dup and so on.
* ary_shared: finished in shard.
* ary_shared_root_occupied: shared_root but has only 1 refcnt.
The number (ary_shared - ary_shared_root_occupied) is meaningful.
|
|
|
|
|
| |
RUBY_ASSERT_ALWAYS(expr) ignores NDEBUG (we cannot remove this
assertion).
|
|
|
|
|
|
|
|
|
| |
Array#minmax was previous not implemented, so calling #minmax on
array was actually calling Enumerable#minmax. This is a simple
implementation of #minmax by just calling rb_ary_min and
rb_ary_max, which improves performance significantly.
Fixes [Bug #15929]
|
|
|
|
|
|
| |
Fixes [Bug #15953]
Closes: https://github.com/ruby/ruby/pull/2253
|
|
|
|
|
|
|
| |
Bug fix in commit ec8e5f5aa64e2a [Bug #15952] disabled an
optimization in this function.
Closes: https://github.com/ruby/ruby/pull/2252
|
|
|
|
| |
Closes: https://github.com/ruby/ruby/pull/2251
|
|
|
|
|
|
| |
Fixes [Bug #15951]
Closes: https://github.com/ruby/ruby/pull/2250
|
|
|
|
|
|
| |
For array.c (Array#sort) and enum.c (Enumerable#sort_by),
add comments mentioning that sort.reverse! / sort_by { ... }.reverse!
can/should be used to reverse the result. [ci skip]
|
| |
|
|
|
|
| |
* Mostly to try the new git repository.
|
|\
| |
| |
| | |
[Fix GH-2084]
|
| |
| |
| | |
Throughout the docs, `new_ary` is used to indicate a new array, whereas `ary` refers to the receiver.
|
| |
| |
| |
| |
| |
| |
| |
| | |
* array.c (rb_ary_join_m): warn use of non-nil $,.
* io.c (rb_output_fs_setter): warn when set to non-nil value.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67606 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
| |
| |
| |
| |
| |
| | |
[ruby-core:87945] [Feature #14912]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
| |
| |
| |
| | |
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
| |
| |
| |
| |
| |
| |
| |
| | |
Because hard to specify commits related to r67479 only.
So please commit again.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
| |
| |
| |
| | |
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
| |
| |
| |
| | |
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|/
|
|
| |
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67331 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently we are not explicit enough regarding the potentially confusing
behavior of `Array#-` and `Array#difference` when it comes to duplicate items
within receiver arrays.
Although the original documentation for these methods does use an array with
multiple instance of the same integers, the explanation for the behavior is
actually imprecise.
> removing any items that also appear in +other_ary+
Not only does `Array#-` remove any items that also appear in `other_ary` but
it also remove any instance of any item in `other_ary`.
One may expect `Array#-` to behave like mathematical subtraction or difference
when it doesn't. One could be forgiven to expect the following behavior:
```ruby
[1,1,2,2,3,3,4,4] - [1,2,3,4]
=> [1,2,3,4]
```
In reality this is the result:
```ruby
[1,1,2,2,3,3,4,4] - [1,2,3,4]
=> []
```
I hope that I've prevented this potential confusion with the clarifications
in this change. I can offer this as evidence of likeliness for confusion:
https://twitter.com/olivierlacan/status/1084930269533085696
I'll freely admit I was surprised by this behavior myself since I needed to
obtain an Array with only one instance of each item in the argument array
removed.
[Fix GH-2068] [ci skip]
From: Olivier Lacan <hi@olivierlacan.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
|
|
| |
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
|
|
|
|
|
|
|
|
|
| |
Before this patch, if `reject!` is called on a shared array it can
mutate the shared array rather than a copy. This patch marks the array
as "going to be modified" so that the shared source array isn't
mutated.
[Bug #15479] [ruby-core:90781]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
|
|
|
|
|
|
|
|
|
| |
* array.c (rb_ary_splice): do not use RARRAY_PTR() here because it can cause
GC because of rb_ary_detransient(). Here ary can contain T_NONE object
because of increasing capacity and not initialized yet.
error log: http://ci.rvm.jp/results/trunk-test@ruby-sky1/1557174
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* internal.h: rename the following names:
* li_table -> ar_table. "li" means linear (from linear search),
but we use the word "array" (from data layout).
* RHASH_ARRAY -> RHASH_AR_TABLE. AR_TABLE is more clear.
* rb_hash_array_* -> rb_hash_ar_table_*.
* RHASH_TABLE_P() -> RHASH_ST_TABLE_P(). more clear.
* RHASH_CLEAR() -> RHASH_ST_CLEAR().
* hash.c: rename "linear_" prefix functions to "ar_" prefix.
* hash.c (linear_init_table): rename to ar_alloc_table.
* debug_counter.h: rename obj_hash_array to obj_hash_ar.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before this patch Array#all? was not implemented in Array class
and alternatively Enumerable#all? was used, while #any? has its
own method entry in Array class. Similarly, Array#none? and #one?
also lacks its own implementation.
This patch provides Array-specific implementations for above three
methods to enable faster method lookup.
[Fix GH-2041]
From: Koji Onishi <fursich0@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
|
|
| |
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
|
|
|
|
| |
* array.c (ary_take_first_or_last): expected optional argument.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
|
|
| |
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66179 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
|
|
| |
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66166 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* include/ruby/ruby.h: de-transient at
`RARRAY_PTR_USE` and `RARRAY_PTR_USE_START`.
Introduce `RARRAY_PTR_USE_TRANSIENT` and
`RARRAY_PTR_USE_START_TRANSIENT` if you don't want to
de-transient an array. Generally, it is difficult
so C-extension writers should not use them.
* array.c: use `RARRAY_PTR_USE_TRANSIENT` if possible.
* hash.c: ditto.
* enum.c (enum_sort_by): remove `rb_ary_transient_heap_evacuate()`
because `RARRAY_PTR_USE` do de-transient.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In this example code:
```ruby
def foo
[1, 2, 3, 4]
end
```
The array literal uses a `duparray` instruction. Before this patch,
`rb_ary_resurrect` would malloc and memcpy a new array buffer. This
patch changes `rb_ary_resurrect` to use `ary_make_partial` so that the
new array object shares the underlying buffer with the array stored in
the instruction sequences.
Before this patch, the new array object is not shared:
```
$ ruby -r objspace -e'p ObjectSpace.dump([1, 2, 3, 4])'
"{\"address\":\"0x7fa2718372d0\", \"type\":\"ARRAY\", \"class\":\"0x7fa26f8b0010\", \"length\":4, \"memsize\":72, \"flags\":{\"wb_protected\":true}}\n"
```
After this patch:
```
$ ./ruby -r objspace -e'p ObjectSpace.dump([1, 2, 3, 4])'
"{\"address\":\"0x7f9a76883638\", \"type\":\"ARRAY\", \"class\":\"0x7f9a758af900\", \"length\":4, \"shared\":true, \"references\":[\"0x7f9a768837c8\"], \"memsize\":40, \"flags\":{\"wb_protected\":true}}\n"
```
[Feature #15289] [ruby-core:90097]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
|
|
| |
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65924 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
|
|
|
|
|
| |
* array.c (rb_ary_collect): no longer splat sole array for lambda.
[ruby-core:89734] [Bug #15285]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65923 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
|
|
|
|
|
|
|
|
| |
This args[1]-- overflows when it is zero. Should do that only
when we can say it is nonzero.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
|
|
| |
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
|
|
| |
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
|
|
|
|
|
|
| |
* include/ruby/ruby.h: intrdocue `USE_TRANSIENT_HEAP` macro
to enable/disable transient heap.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
|
|
| |
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* hash.c, internal.h: support theap for small Hash.
Introduce RHASH_ARRAY (li_table) besides st_table and small Hash
(<=8 entries) are managed by an array data structure.
This array data can be managed by theap.
If st_table is needed, then converting array data to st_table data.
For st_table using code, we prepare "stlike" APIs which accepts hash value
and are very similar to st_ APIs.
This work is based on the GSoC achievement
by tacinight <tacingiht@gmail.com> and refined by ko1.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
|
|
| |
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|