зеркало из https://github.com/github/ruby.git
Remove RARRAY_PTR_USE_TRANSIENT
RARRAY_PTR_USE now does the same things as RARRAY_PTR_USE_TRANSIENT.
This commit is contained in:
Родитель
5ebc133116
Коммит
de327ccb63
34
array.c
34
array.c
|
@ -303,7 +303,7 @@ rb_mem_clear(VALUE *mem, long size)
|
|||
static void
|
||||
ary_mem_clear(VALUE ary, long beg, long size)
|
||||
{
|
||||
RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
|
||||
RARRAY_PTR_USE(ary, ptr, {
|
||||
rb_mem_clear(ptr + beg, size);
|
||||
});
|
||||
}
|
||||
|
@ -319,7 +319,7 @@ memfill(register VALUE *mem, register long size, register VALUE val)
|
|||
static void
|
||||
ary_memfill(VALUE ary, long beg, long size, VALUE val)
|
||||
{
|
||||
RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
|
||||
RARRAY_PTR_USE(ary, ptr, {
|
||||
memfill(ptr + beg, size, val);
|
||||
RB_OBJ_WRITTEN(ary, Qundef, val);
|
||||
});
|
||||
|
@ -332,13 +332,13 @@ ary_memcpy0(VALUE ary, long beg, long argc, const VALUE *argv, VALUE buff_owner_
|
|||
|
||||
if (argc > (int)(128/sizeof(VALUE)) /* is magic number (cache line size) */) {
|
||||
rb_gc_writebarrier_remember(buff_owner_ary);
|
||||
RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
|
||||
RARRAY_PTR_USE(ary, ptr, {
|
||||
MEMCPY(ptr+beg, argv, VALUE, argc);
|
||||
});
|
||||
}
|
||||
else {
|
||||
int i;
|
||||
RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
|
||||
RARRAY_PTR_USE(ary, ptr, {
|
||||
for (i=0; i<argc; i++) {
|
||||
RB_OBJ_WRITE(buff_owner_ary, &ptr[i+beg], argv[i]);
|
||||
}
|
||||
|
@ -552,7 +552,7 @@ rb_ary_cancel_sharing(VALUE ary)
|
|||
FL_UNSET_SHARED(ary);
|
||||
ARY_SET_PTR(ary, RARRAY_CONST_PTR_TRANSIENT(shared_root));
|
||||
ARY_SET_CAPA(ary, shared_len);
|
||||
RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
|
||||
RARRAY_PTR_USE(ary, ptr, {
|
||||
MEMMOVE(ptr, ptr+shift, VALUE, len);
|
||||
});
|
||||
FL_SET_EMBED(shared_root);
|
||||
|
@ -1266,7 +1266,7 @@ ary_make_partial_step(VALUE ary, VALUE klass, long offset, long len, long step)
|
|||
ARY_SET_EMBED_LEN(result, len);
|
||||
}
|
||||
else {
|
||||
RARRAY_PTR_USE_TRANSIENT(result, ptr, {
|
||||
RARRAY_PTR_USE(result, ptr, {
|
||||
for (i = 0; i < len; ++i) {
|
||||
RB_OBJ_WRITE(result, ptr+i, values[j]);
|
||||
j += step;
|
||||
|
@ -1341,7 +1341,7 @@ rb_ary_push(VALUE ary, VALUE item)
|
|||
{
|
||||
long idx = RARRAY_LEN((ary_verify(ary), ary));
|
||||
VALUE target_ary = ary_ensure_room_for_push(ary, 1);
|
||||
RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
|
||||
RARRAY_PTR_USE(ary, ptr, {
|
||||
RB_OBJ_WRITE(target_ary, &ptr[idx], item);
|
||||
});
|
||||
ARY_SET_LEN(ary, idx + 1);
|
||||
|
@ -1531,7 +1531,7 @@ rb_ary_behead(VALUE ary, long n)
|
|||
|
||||
if (!ARY_SHARED_P(ary)) {
|
||||
if (ARY_EMBED_P(ary) || RARRAY_LEN(ary) < ARY_DEFAULT_SIZE) {
|
||||
RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
|
||||
RARRAY_PTR_USE(ary, ptr, {
|
||||
MEMMOVE(ptr, ptr + n, VALUE, RARRAY_LEN(ary) - n);
|
||||
}); /* WB: no new reference */
|
||||
ARY_INCREASE_LEN(ary, -n);
|
||||
|
@ -1597,7 +1597,7 @@ ary_modify_for_unshift(VALUE ary, int argc)
|
|||
}
|
||||
else {
|
||||
/* sliding items */
|
||||
RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
|
||||
RARRAY_PTR_USE(ary, ptr, {
|
||||
MEMMOVE(ptr + argc, ptr, VALUE, len);
|
||||
});
|
||||
|
||||
|
@ -2178,7 +2178,7 @@ rb_ary_splice(VALUE ary, long beg, long len, const VALUE *rptr, long rlen)
|
|||
}
|
||||
|
||||
if (len != rlen) {
|
||||
RARRAY_PTR_USE_TRANSIENT(ary, ptr,
|
||||
RARRAY_PTR_USE(ary, ptr,
|
||||
MEMMOVE(ptr + beg + rlen, ptr + beg + len,
|
||||
VALUE, olen - (beg + len)));
|
||||
ARY_SET_LEN(ary, alen);
|
||||
|
@ -2191,7 +2191,7 @@ rb_ary_splice(VALUE ary, long beg, long len, const VALUE *rptr, long rlen)
|
|||
/* do not use RARRAY_PTR() because it can causes GC.
|
||||
* ary can contain T_NONE object because it is not cleared.
|
||||
*/
|
||||
RARRAY_PTR_USE_TRANSIENT(ary, ptr,
|
||||
RARRAY_PTR_USE(ary, ptr,
|
||||
MEMMOVE(ptr + beg, rptr, VALUE, rlen));
|
||||
}
|
||||
}
|
||||
|
@ -3036,7 +3036,7 @@ rb_ary_reverse(VALUE ary)
|
|||
|
||||
rb_ary_modify(ary);
|
||||
if (len > 1) {
|
||||
RARRAY_PTR_USE_TRANSIENT(ary, p1, {
|
||||
RARRAY_PTR_USE(ary, p1, {
|
||||
p2 = p1 + len - 1; /* points last item */
|
||||
ary_reverse(p1, p2);
|
||||
}); /* WB: no new reference */
|
||||
|
@ -3123,7 +3123,7 @@ rb_ary_rotate(VALUE ary, long cnt)
|
|||
if (cnt != 0) {
|
||||
long len = RARRAY_LEN(ary);
|
||||
if (len > 1 && (cnt = rotate_count(cnt, len)) > 0) {
|
||||
RARRAY_PTR_USE_TRANSIENT(ary, ptr, ary_rotate_ptr(ptr, len, cnt));
|
||||
RARRAY_PTR_USE(ary, ptr, ary_rotate_ptr(ptr, len, cnt));
|
||||
return ary;
|
||||
}
|
||||
}
|
||||
|
@ -3844,7 +3844,7 @@ select_bang_ensure(VALUE a)
|
|||
rb_ary_modify(ary);
|
||||
if (i1 < len) {
|
||||
tail = len - i1;
|
||||
RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
|
||||
RARRAY_PTR_USE(ary, ptr, {
|
||||
MEMMOVE(ptr + i2, ptr + i1, VALUE, tail);
|
||||
});
|
||||
}
|
||||
|
@ -4031,7 +4031,7 @@ rb_ary_delete_at(VALUE ary, long pos)
|
|||
|
||||
rb_ary_modify(ary);
|
||||
del = RARRAY_AREF(ary, pos);
|
||||
RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
|
||||
RARRAY_PTR_USE(ary, ptr, {
|
||||
MEMMOVE(ptr+pos, ptr+pos+1, VALUE, len-pos-1);
|
||||
});
|
||||
ARY_INCREASE_LEN(ary, -1);
|
||||
|
@ -6601,7 +6601,7 @@ ary_sample(rb_execution_context_t *ec, VALUE ary, VALUE randgen, VALUE nv, VALUE
|
|||
sorted[j] = idx[i] = k;
|
||||
}
|
||||
result = rb_ary_new_capa(n);
|
||||
RARRAY_PTR_USE_TRANSIENT(result, ptr_result, {
|
||||
RARRAY_PTR_USE(result, ptr_result, {
|
||||
for (i=0; i<n; i++) {
|
||||
ptr_result[i] = RARRAY_AREF(ary, idx[i]);
|
||||
}
|
||||
|
@ -6624,7 +6624,7 @@ ary_sample(rb_execution_context_t *ec, VALUE ary, VALUE randgen, VALUE nv, VALUE
|
|||
len = RARRAY_LEN(ary);
|
||||
if (len <= max_idx) n = 0;
|
||||
else if (n > len) n = len;
|
||||
RARRAY_PTR_USE_TRANSIENT(ary, ptr_ary, {
|
||||
RARRAY_PTR_USE(ary, ptr_ary, {
|
||||
for (i=0; i<n; i++) {
|
||||
long j2 = j = ptr_result[i];
|
||||
long i2 = i;
|
||||
|
|
6
hash.c
6
hash.c
|
@ -3501,7 +3501,7 @@ rb_hash_keys(VALUE hash)
|
|||
if (size == 0) return keys;
|
||||
|
||||
if (ST_DATA_COMPATIBLE_P(VALUE)) {
|
||||
RARRAY_PTR_USE_TRANSIENT(keys, ptr, {
|
||||
RARRAY_PTR_USE(keys, ptr, {
|
||||
if (RHASH_AR_TABLE_P(hash)) {
|
||||
size = ar_keys(hash, ptr, size);
|
||||
}
|
||||
|
@ -3548,14 +3548,14 @@ rb_hash_values(VALUE hash)
|
|||
if (ST_DATA_COMPATIBLE_P(VALUE)) {
|
||||
if (RHASH_AR_TABLE_P(hash)) {
|
||||
rb_gc_writebarrier_remember(values);
|
||||
RARRAY_PTR_USE_TRANSIENT(values, ptr, {
|
||||
RARRAY_PTR_USE(values, ptr, {
|
||||
size = ar_values(hash, ptr, size);
|
||||
});
|
||||
}
|
||||
else if (RHASH_ST_TABLE_P(hash)) {
|
||||
st_table *table = RHASH_ST_TABLE(hash);
|
||||
rb_gc_writebarrier_remember(values);
|
||||
RARRAY_PTR_USE_TRANSIENT(values, ptr, {
|
||||
RARRAY_PTR_USE(values, ptr, {
|
||||
size = st_values(table, ptr, size);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -368,19 +368,9 @@ rb_array_const_ptr(VALUE a)
|
|||
#define RARRAY_PTR_USE(ary, ptr_name, expr) \
|
||||
RBIMPL_RARRAY_STMT(ary, ptr_name, expr)
|
||||
|
||||
/**
|
||||
* Identical to #RARRAY_PTR_USE, except the pointer can be a transient one.
|
||||
*
|
||||
* @param ary An object of ::RArray.
|
||||
* @param ptr_name A variable name which points the C array in `expr`.
|
||||
* @param expr The expression that touches `ptr_name`.
|
||||
*/
|
||||
#define RARRAY_PTR_USE_TRANSIENT(ary, ptr_name, expr) \
|
||||
RBIMPL_RARRAY_STMT(ary, ptr_name, expr)
|
||||
|
||||
/**
|
||||
* Wild use of a C pointer. This function accesses the backend storage
|
||||
* directly. This is slower than #RARRAY_PTR_USE_TRANSIENT. It exercises
|
||||
* directly. This is slower than #RARRAY_PTR_USE. It exercises
|
||||
* extra manoeuvres to protect our generational GC. Use of this function is
|
||||
* considered archaic. Use a modern way instead.
|
||||
*
|
||||
|
@ -415,7 +405,7 @@ RARRAY_PTR(VALUE ary)
|
|||
static inline void
|
||||
RARRAY_ASET(VALUE ary, long i, VALUE v)
|
||||
{
|
||||
RARRAY_PTR_USE_TRANSIENT(ary, ptr,
|
||||
RARRAY_PTR_USE(ary, ptr,
|
||||
RB_OBJ_WRITE(ary, &ptr[i], v));
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче