1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* include/ruby/ruby.h: rename RARRAY_RAWPTR() to RARRAY_CONST_PTR().

RARRAY_RAWPTR(ary) returns (const VALUE *) type pointer and
  usecase of this macro is not acquire raw pointer, but acquire
  read-only pointer. So we rename to better name.
  RSTRUCT_RAWPTR() is also renamed to RSTRUCT_CONST_PTR()
  (I expect that nobody use it).
* array.c, compile.c, cont.c, enumerator.c, gc.c, proc.c, random.c,
  string.c, struct.c, thread.c, vm_eval.c, vm_insnhelper.c:
  catch up this change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2013-09-25 08:24:34 +00:00
parent d700d34043
commit dc626dbab3
14 changed files with 93 additions and 81 deletions

View file

@ -1,3 +1,16 @@
Wed Sep 25 17:12:08 2013 Koichi Sasada <ko1@atdot.net>
* include/ruby/ruby.h: rename RARRAY_RAWPTR() to RARRAY_CONST_PTR().
RARRAY_RAWPTR(ary) returns (const VALUE *) type pointer and
usecase of this macro is not acquire raw pointer, but acquire
read-only pointer. So we rename to better name.
RSTRUCT_RAWPTR() is also renamed to RSTRUCT_CONST_PTR()
(I expect that nobody use it).
* array.c, compile.c, cont.c, enumerator.c, gc.c, proc.c, random.c,
string.c, struct.c, thread.c, vm_eval.c, vm_insnhelper.c:
catch up this change.
Wed Sep 25 16:58:33 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* internal.h (rb_float_value, rb_float_new): move inline functions

84
array.c
View file

@ -217,7 +217,7 @@ ary_resize_capa(VALUE ary, long capacity)
else {
if (!ARY_EMBED_P(ary)) {
long len = RARRAY_LEN(ary);
const VALUE *ptr = RARRAY_RAWPTR(ary);
const VALUE *ptr = RARRAY_CONST_PTR(ary);
if (len > capacity) len = capacity;
MEMCPY((VALUE *)RARRAY(ary)->as.ary, ptr, VALUE, len);
FL_SET_EMBED(ary);
@ -324,9 +324,9 @@ rb_ary_modify(VALUE ary)
ARY_SET_EMBED_LEN(ary, len);
}
else if (ARY_SHARED_OCCUPIED(shared) && len > (RARRAY_LEN(shared)>>1)) {
long shift = RARRAY_RAWPTR(ary) - RARRAY_RAWPTR(shared);
long shift = RARRAY_CONST_PTR(ary) - RARRAY_CONST_PTR(shared);
FL_UNSET_SHARED(ary);
ARY_SET_PTR(ary, RARRAY_RAWPTR(shared));
ARY_SET_PTR(ary, RARRAY_CONST_PTR(shared));
ARY_SET_CAPA(ary, RARRAY_LEN(shared));
RARRAY_PTR_USE(ary, ptr, {
MEMMOVE(ptr, ptr+shift, VALUE, len);
@ -336,7 +336,7 @@ rb_ary_modify(VALUE ary)
}
else {
VALUE *ptr = ALLOC_N(VALUE, len);
MEMCPY(ptr, RARRAY_RAWPTR(ary), VALUE, len);
MEMCPY(ptr, RARRAY_CONST_PTR(ary), VALUE, len);
rb_ary_unshare(ary);
ARY_SET_CAPA(ary, len);
ARY_SET_PTR(ary, ptr);
@ -354,7 +354,7 @@ ary_ensure_room_for_push(VALUE ary, long add_len)
if (new_len > RARRAY_EMBED_LEN_MAX) {
VALUE shared = ARY_SHARED(ary);
if (ARY_SHARED_OCCUPIED(shared)) {
if (RARRAY_RAWPTR(ary) - RARRAY_RAWPTR(shared) + new_len <= RARRAY_LEN(shared)) {
if (RARRAY_CONST_PTR(ary) - RARRAY_CONST_PTR(shared) + new_len <= RARRAY_LEN(shared)) {
rb_ary_modify_check(ary);
}
else {
@ -577,7 +577,7 @@ ary_make_shared(VALUE ary)
FL_UNSET_EMBED(shared);
ARY_SET_LEN((VALUE)shared, ARY_CAPA(ary));
ARY_SET_PTR((VALUE)shared, RARRAY_RAWPTR(ary));
ARY_SET_PTR((VALUE)shared, RARRAY_CONST_PTR(ary));
ary_mem_clear((VALUE)shared, RARRAY_LEN(ary), ARY_CAPA(ary) - RARRAY_LEN(ary));
FL_SET_SHARED_ROOT(shared);
ARY_SET_SHARED_NUM((VALUE)shared, 1);
@ -595,7 +595,7 @@ ary_make_substitution(VALUE ary)
if (len <= RARRAY_EMBED_LEN_MAX) {
VALUE subst = rb_ary_new2(len);
ary_memcpy(subst, 0, len, RARRAY_RAWPTR(ary));
ary_memcpy(subst, 0, len, RARRAY_CONST_PTR(ary));
ARY_SET_EMBED_LEN(subst, len);
return subst;
}
@ -711,8 +711,8 @@ rb_ary_initialize(int argc, VALUE *argv, VALUE ary)
rb_ary_modify(ary);
if (argc == 0) {
if (ARY_OWNS_HEAP_P(ary) && RARRAY_RAWPTR(ary) != 0) {
xfree((void *)RARRAY_RAWPTR(ary));
if (ARY_OWNS_HEAP_P(ary) && RARRAY_CONST_PTR(ary) != 0) {
xfree((void *)RARRAY_CONST_PTR(ary));
}
rb_ary_unshare_safe(ary);
FL_SET_EMBED(ary);
@ -817,7 +817,7 @@ ary_make_partial(VALUE ary, VALUE klass, long offset, long len)
if (len <= RARRAY_EMBED_LEN_MAX) {
VALUE result = ary_alloc(klass);
ary_memcpy(result, 0, len, RARRAY_RAWPTR(ary) + offset);
ary_memcpy(result, 0, len, RARRAY_CONST_PTR(ary) + offset);
ARY_SET_EMBED_LEN(result, len);
return result;
}
@ -826,7 +826,7 @@ ary_make_partial(VALUE ary, VALUE klass, long offset, long len)
FL_UNSET_EMBED(result);
shared = ary_make_shared(ary);
ARY_SET_PTR(result, RARRAY_RAWPTR(ary));
ARY_SET_PTR(result, RARRAY_CONST_PTR(ary));
ARY_SET_LEN(result, RARRAY_LEN(ary));
rb_ary_set_shared(result, shared);
@ -1081,8 +1081,8 @@ ary_ensure_room_for_unshift(VALUE ary, int argc)
VALUE shared = ARY_SHARED(ary);
capa = RARRAY_LEN(shared);
if (ARY_SHARED_OCCUPIED(shared) && capa > new_len) {
head = RARRAY_RAWPTR(ary);
sharedp = RARRAY_RAWPTR(shared);
head = RARRAY_CONST_PTR(ary);
sharedp = RARRAY_CONST_PTR(shared);
goto makeroom_if_need;
}
}
@ -1099,7 +1099,7 @@ ary_ensure_room_for_unshift(VALUE ary, int argc)
capa = ARY_CAPA(ary);
ary_make_shared(ary);
head = sharedp = RARRAY_RAWPTR(ary);
head = sharedp = RARRAY_CONST_PTR(ary);
goto makeroom;
makeroom_if_need:
if (head - sharedp < argc) {
@ -1432,7 +1432,7 @@ rb_ary_index(int argc, VALUE *argv, VALUE ary)
if (rb_block_given_p())
rb_warn("given block not used");
len = RARRAY_LEN(ary);
ptr = RARRAY_RAWPTR(ary);
ptr = RARRAY_CONST_PTR(ary);
for (i=0; i<len; i++) {
VALUE e = ptr[i];
switch (rb_equal_opt(e, val)) {
@ -1444,7 +1444,7 @@ rb_ary_index(int argc, VALUE *argv, VALUE ary)
continue;
}
len = RARRAY_LEN(ary);
ptr = RARRAY_RAWPTR(ary);
ptr = RARRAY_CONST_PTR(ary);
}
return Qnil;
}
@ -1495,7 +1495,7 @@ rb_ary_rindex(int argc, VALUE *argv, VALUE ary)
val = argv[0];
if (rb_block_given_p())
rb_warn("given block not used");
ptr = RARRAY_RAWPTR(ary);
ptr = RARRAY_CONST_PTR(ary);
while (i--) {
VALUE e = ptr[i];
switch (rb_equal_opt(e, val)) {
@ -1509,7 +1509,7 @@ rb_ary_rindex(int argc, VALUE *argv, VALUE ary)
if (i > (len = RARRAY_LEN(ary))) {
i = len;
}
ptr = RARRAY_RAWPTR(ary);
ptr = RARRAY_CONST_PTR(ary);
}
return Qnil;
}
@ -1555,7 +1555,7 @@ rb_ary_splice(VALUE ary, long beg, long len, VALUE rpl)
len = beg + rlen;
ary_mem_clear(ary, RARRAY_LEN(ary), beg - RARRAY_LEN(ary));
if (rlen > 0) {
ary_memcpy(ary, beg, rlen, RARRAY_RAWPTR(rpl));
ary_memcpy(ary, beg, rlen, RARRAY_CONST_PTR(rpl));
}
ARY_SET_LEN(ary, len);
}
@ -1575,7 +1575,7 @@ rb_ary_splice(VALUE ary, long beg, long len, VALUE rpl)
ARY_SET_LEN(ary, alen);
}
if (rlen > 0) {
MEMMOVE(RARRAY_PTR(ary) + beg, RARRAY_RAWPTR(rpl), VALUE, rlen);
MEMMOVE(RARRAY_PTR(ary) + beg, RARRAY_CONST_PTR(rpl), VALUE, rlen);
}
}
}
@ -1879,7 +1879,7 @@ rb_ary_dup(VALUE ary)
{
long len = RARRAY_LEN(ary);
VALUE dup = rb_ary_new2(len);
ary_memcpy(dup, 0, len, RARRAY_RAWPTR(ary));
ary_memcpy(dup, 0, len, RARRAY_CONST_PTR(ary));
ARY_SET_LEN(dup, len);
return dup;
}
@ -1887,7 +1887,7 @@ rb_ary_dup(VALUE ary)
VALUE
rb_ary_resurrect(VALUE ary)
{
return rb_ary_new4(RARRAY_LEN(ary), RARRAY_RAWPTR(ary));
return rb_ary_new4(RARRAY_LEN(ary), RARRAY_CONST_PTR(ary));
}
extern VALUE rb_output_fs;
@ -2179,8 +2179,8 @@ rb_ary_reverse_m(VALUE ary)
VALUE dup = rb_ary_new2(len);
if (len > 0) {
const VALUE *p1 = RARRAY_RAWPTR(ary);
VALUE *p2 = (VALUE *)RARRAY_RAWPTR(dup) + len - 1;
const VALUE *p1 = RARRAY_CONST_PTR(ary);
VALUE *p2 = (VALUE *)RARRAY_CONST_PTR(dup) + len - 1;
do *p2-- = *p1++; while (--len > 0);
}
ARY_SET_LEN(dup, RARRAY_LEN(ary));
@ -2279,7 +2279,7 @@ rb_ary_rotate_m(int argc, VALUE *argv, VALUE ary)
rotated = rb_ary_new2(len);
if (len > 0) {
cnt = rotate_count(cnt, len);
ptr = RARRAY_RAWPTR(ary);
ptr = RARRAY_CONST_PTR(ary);
len -= cnt;
ary_memcpy(rotated, 0, len, ptr + cnt);
ary_memcpy(rotated, len, cnt, ptr);
@ -2422,7 +2422,7 @@ rb_ary_sort_bang(VALUE ary)
else {
xfree((void *)ARY_HEAP_PTR(ary));
}
ARY_SET_PTR(ary, RARRAY_RAWPTR(tmp));
ARY_SET_PTR(ary, RARRAY_CONST_PTR(tmp));
ARY_SET_HEAP_LEN(ary, len);
ARY_SET_CAPA(ary, RARRAY_LEN(tmp));
}
@ -2986,7 +2986,7 @@ rb_ary_slice_bang(int argc, VALUE *argv, VALUE ary)
len = orig_len - pos;
}
if (len == 0) return rb_ary_new2(0);
arg2 = rb_ary_new4(len, RARRAY_RAWPTR(ary)+pos);
arg2 = rb_ary_new4(len, RARRAY_CONST_PTR(ary)+pos);
RBASIC_SET_CLASS(arg2, rb_obj_class(ary));
rb_ary_splice(ary, pos, len, Qundef);
return arg2;
@ -3290,7 +3290,7 @@ rb_ary_replace(VALUE copy, VALUE orig)
FL_UNSET_SHARED(copy);
}
FL_SET_EMBED(copy);
ary_memcpy(copy, 0, RARRAY_LEN(orig), RARRAY_RAWPTR(orig));
ary_memcpy(copy, 0, RARRAY_LEN(orig), RARRAY_CONST_PTR(orig));
if (shared) {
rb_ary_decrement_share(shared);
}
@ -3305,7 +3305,7 @@ rb_ary_replace(VALUE copy, VALUE orig)
rb_ary_unshare_safe(copy);
}
FL_UNSET_EMBED(copy);
ARY_SET_PTR(copy, RARRAY_RAWPTR(orig));
ARY_SET_PTR(copy, RARRAY_CONST_PTR(orig));
ARY_SET_LEN(copy, RARRAY_LEN(orig));
rb_ary_set_shared(copy, shared);
}
@ -3463,8 +3463,8 @@ rb_ary_plus(VALUE x, VALUE y)
len = xlen + ylen;
z = rb_ary_new2(len);
ary_memcpy(z, 0, xlen, RARRAY_RAWPTR(x));
ary_memcpy(z, xlen, ylen, RARRAY_RAWPTR(y));
ary_memcpy(z, 0, xlen, RARRAY_CONST_PTR(x));
ary_memcpy(z, xlen, ylen, RARRAY_CONST_PTR(y));
ARY_SET_LEN(z, len);
return z;
}
@ -3540,16 +3540,16 @@ rb_ary_times(VALUE ary, VALUE times)
ary2 = ary_new(rb_obj_class(ary), len);
ARY_SET_LEN(ary2, len);
ptr = RARRAY_RAWPTR(ary);
ptr = RARRAY_CONST_PTR(ary);
t = RARRAY_LEN(ary);
if (0 < t) {
ary_memcpy(ary2, 0, t, ptr);
while (t <= len/2) {
ary_memcpy(ary2, t, t, RARRAY_RAWPTR(ary2));
ary_memcpy(ary2, t, t, RARRAY_CONST_PTR(ary2));
t *= 2;
}
if (t < len) {
ary_memcpy(ary2, t, len-t, RARRAY_RAWPTR(ary2));
ary_memcpy(ary2, t, len-t, RARRAY_CONST_PTR(ary2));
}
}
out:
@ -3635,8 +3635,8 @@ recursive_equal(VALUE ary1, VALUE ary2, int recur)
if (recur) return Qtrue; /* Subtle! */
p1 = RARRAY_RAWPTR(ary1);
p2 = RARRAY_RAWPTR(ary2);
p1 = RARRAY_CONST_PTR(ary1);
p2 = RARRAY_CONST_PTR(ary2);
len1 = RARRAY_LEN(ary1);
for (i = 0; i < len1; i++) {
@ -3647,8 +3647,8 @@ recursive_equal(VALUE ary1, VALUE ary2, int recur)
return Qfalse;
if (len1 < i)
return Qtrue;
p1 = RARRAY_RAWPTR(ary1) + i;
p2 = RARRAY_RAWPTR(ary2) + i;
p1 = RARRAY_CONST_PTR(ary1) + i;
p2 = RARRAY_CONST_PTR(ary2) + i;
}
else {
return Qfalse;
@ -3685,7 +3685,7 @@ rb_ary_equal(VALUE ary1, VALUE ary2)
return rb_equal(ary2, ary1);
}
if (RARRAY_LEN(ary1) != RARRAY_LEN(ary2)) return Qfalse;
if (RARRAY_RAWPTR(ary1) == RARRAY_RAWPTR(ary2)) return Qtrue;
if (RARRAY_CONST_PTR(ary1) == RARRAY_CONST_PTR(ary2)) return Qtrue;
return rb_exec_recursive_paired(recursive_equal, ary1, ary2, ary2);
}
@ -3716,7 +3716,7 @@ rb_ary_eql(VALUE ary1, VALUE ary2)
if (ary1 == ary2) return Qtrue;
if (!RB_TYPE_P(ary2, T_ARRAY)) return Qfalse;
if (RARRAY_LEN(ary1) != RARRAY_LEN(ary2)) return Qfalse;
if (RARRAY_RAWPTR(ary1) == RARRAY_RAWPTR(ary2)) return Qtrue;
if (RARRAY_CONST_PTR(ary1) == RARRAY_CONST_PTR(ary2)) return Qtrue;
return rb_exec_recursive_paired(recursive_eql, ary1, ary2, ary2);
}
@ -4160,14 +4160,14 @@ rb_ary_compact_bang(VALUE ary)
long n;
rb_ary_modify(ary);
p = t = (VALUE *)RARRAY_RAWPTR(ary); /* WB: no new reference */
p = t = (VALUE *)RARRAY_CONST_PTR(ary); /* WB: no new reference */
end = p + RARRAY_LEN(ary);
while (t < end) {
if (NIL_P(*t)) t++;
else *p++ = *t++;
}
n = p - RARRAY_RAWPTR(ary);
n = p - RARRAY_CONST_PTR(ary);
if (RARRAY_LEN(ary) == n) {
return Qnil;
}

View file

@ -1174,7 +1174,7 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *optargs, NODE *node_args)
iseq->arg_opts = i;
iseq->arg_opt_table = ALLOC_N(VALUE, i);
MEMCPY(iseq->arg_opt_table, RARRAY_RAWPTR(labels), VALUE, i);
MEMCPY(iseq->arg_opt_table, RARRAY_CONST_PTR(labels), VALUE, i);
for (j = 0; j < i; j++) {
iseq->arg_opt_table[j] &= ~1;
}
@ -1675,13 +1675,13 @@ iseq_set_exception_table(rb_iseq_t *iseq)
struct iseq_catch_table_entry *entry;
tlen = (int)RARRAY_LEN(iseq->compile_data->catch_table_ary);
tptr = RARRAY_RAWPTR(iseq->compile_data->catch_table_ary);
tptr = RARRAY_CONST_PTR(iseq->compile_data->catch_table_ary);
iseq->catch_table = tlen ? ALLOC_N(struct iseq_catch_table_entry, tlen) : 0;
iseq->catch_table_size = tlen;
for (i = 0; i < tlen; i++) {
ptr = RARRAY_RAWPTR(tptr[i]);
ptr = RARRAY_CONST_PTR(tptr[i]);
entry = &iseq->catch_table[i];
entry->type = (enum catch_type)(ptr[0] & 0xffff);
entry->start = label_get_position((LABEL *)(ptr[1] & ~1));

2
cont.c
View file

@ -1151,7 +1151,7 @@ rb_fiber_start(void)
int argc;
const VALUE *argv, args = cont->value;
GetProcPtr(cont->saved_thread.first_proc, proc);
argv = (argc = cont->argc) > 1 ? RARRAY_RAWPTR(args) : &args;
argv = (argc = cont->argc) > 1 ? RARRAY_CONST_PTR(args) : &args;
cont->value = Qnil;
th->errinfo = Qnil;
th->root_lep = rb_vm_ep_local_ep(proc->block.ep);

View file

@ -1044,7 +1044,7 @@ enumerator_size(VALUE obj)
}
if (e->args) {
argc = (int)RARRAY_LEN(e->args);
argv = RARRAY_RAWPTR(e->args);
argv = RARRAY_CONST_PTR(e->args);
}
size = rb_check_funcall(e->size, id_call, argc, argv);
if (size != Qundef) return size;

4
gc.c
View file

@ -3277,7 +3277,7 @@ gc_mark_children(rb_objspace_t *objspace, VALUE ptr)
}
else {
long i, len = RARRAY_LEN(obj);
const VALUE *ptr = RARRAY_RAWPTR(obj);
const VALUE *ptr = RARRAY_CONST_PTR(obj);
for (i=0; i < len; i++) {
gc_mark(objspace, *ptr++);
}
@ -3357,7 +3357,7 @@ gc_mark_children(rb_objspace_t *objspace, VALUE ptr)
case T_STRUCT:
{
long len = RSTRUCT_LEN(obj);
const VALUE *ptr = RSTRUCT_RAWPTR(obj);
const VALUE *ptr = RSTRUCT_CONST_PTR(obj);
while (len--) {
gc_mark(objspace, *ptr++);

View file

@ -881,13 +881,12 @@ struct RArray {
#define RARRAY_LENINT(ary) rb_long2int(RARRAY_LEN(ary))
/* DO NOT USE THIS MACRO DIRECTLY */
#define RARRAY_RAWPTR(a) \
((RBASIC(a)->flags & RARRAY_EMBED_FLAG) ? \
RARRAY(a)->as.ary : \
RARRAY(a)->as.heap.ptr)
#define RARRAY_CONST_PTR(a) \
((const VALUE *)((RBASIC(a)->flags & RARRAY_EMBED_FLAG) ? \
RARRAY(a)->as.ary : \
RARRAY(a)->as.heap.ptr))
#define RARRAY_PTR_USE_START(a) RARRAY_RAWPTR(a)
#define RARRAY_PTR_USE_START(a) ((VALUE *)RARRAY_CONST_PTR(a))
#define RARRAY_PTR_USE_END(a) /* */
#define RARRAY_PTR_USE(ary, ptr_name, expr) do { \
@ -897,13 +896,13 @@ struct RArray {
RARRAY_PTR_USE_END(_ary); \
} while (0)
#define RARRAY_AREF(a, i) (RARRAY_RAWPTR(a)[i])
#define RARRAY_AREF(a, i) (RARRAY_CONST_PTR(a)[i])
#define RARRAY_ASET(a, i, v) do { \
const VALUE _ary_ = (a); \
OBJ_WRITE(_ary_, &RARRAY_RAWPTR(_ary_)[i], (v)); \
OBJ_WRITE(_ary_, &RARRAY_CONST_PTR(_ary_)[i], (v)); \
} while (0)
#define RARRAY_PTR(a) ((VALUE *)RARRAY_RAWPTR(RGENGC_WB_PROTECTED_ARRAY ? OBJ_WB_UNPROTECT((VALUE)a) : ((VALUE)a)))
#define RARRAY_PTR(a) ((VALUE *)RARRAY_CONST_PTR(RGENGC_WB_PROTECTED_ARRAY ? OBJ_WB_UNPROTECT((VALUE)a) : ((VALUE)a)))
struct RRegexp {
struct RBasic basic;
@ -1056,14 +1055,14 @@ struct RStruct {
(RSTRUCT_EMBED_LEN_MASK >> RSTRUCT_EMBED_LEN_SHIFT)) : \
RSTRUCT(st)->as.heap.len)
#define RSTRUCT_LENINT(st) rb_long2int(RSTRUCT_LEN(st))
#define RSTRUCT_RAWPTR(st) \
#define RSTRUCT_CONST_PTR(st) \
((RBASIC(st)->flags & RSTRUCT_EMBED_LEN_MASK) ? \
RSTRUCT(st)->as.ary : \
RSTRUCT(st)->as.heap.ptr)
#define RSTRUCT_PTR(st) ((VALUE *)RSTRUCT_RAWPTR(RGENGC_WB_PROTECTED_STRUCT ? OBJ_WB_UNPROTECT((VALUE)st) : (VALUE)st))
#define RSTRUCT_PTR(st) ((VALUE *)RSTRUCT_CONST_PTR(RGENGC_WB_PROTECTED_STRUCT ? OBJ_WB_UNPROTECT((VALUE)st) : (VALUE)st))
#define RSTRUCT_SET(st, idx, v) OBJ_WRITE(st, &RSTRUCT_RAWPTR(st)[idx], (v))
#define RSTRUCT_GET(st, idx) (RSTRUCT_RAWPTR(st)[idx])
#define RSTRUCT_SET(st, idx, v) OBJ_WRITE(st, &RSTRUCT_CONST_PTR(st)[idx], (v))
#define RSTRUCT_GET(st, idx) (RSTRUCT_CONST_PTR(st)[idx])
#ifndef RBIGNUM_EMBED_LEN_MAX
# define RBIGNUM_EMBED_LEN_MAX ((int)((sizeof(VALUE)*3)/sizeof(BDIGIT)))

4
proc.c
View file

@ -752,7 +752,7 @@ rb_proc_call(VALUE self, VALUE args)
VALUE vret;
rb_proc_t *proc;
GetProcPtr(self, proc);
vret = rb_vm_invoke_proc(GET_THREAD(), proc, check_argc(RARRAY_LEN(args)), RARRAY_RAWPTR(args), 0);
vret = rb_vm_invoke_proc(GET_THREAD(), proc, check_argc(RARRAY_LEN(args)), RARRAY_CONST_PTR(args), 0);
RB_GC_GUARD(self);
RB_GC_GUARD(args);
return vret;
@ -2429,7 +2429,7 @@ curry(VALUE dummy, VALUE args, int argc, VALUE *argv, VALUE passed_proc)
return arity;
}
else {
return rb_proc_call_with_block(proc, check_argc(RARRAY_LEN(passed)), RARRAY_RAWPTR(passed), passed_proc);
return rb_proc_call_with_block(proc, check_argc(RARRAY_LEN(passed)), RARRAY_CONST_PTR(passed), passed_proc);
}
}

View file

@ -632,7 +632,7 @@ random_load(VALUE obj, VALUE dump)
rb_check_copyable(obj, dump);
Check_Type(dump, T_ARRAY);
ary = RARRAY_RAWPTR(dump);
ary = RARRAY_CONST_PTR(dump);
switch (RARRAY_LEN(dump)) {
case 3:
seed = ary[2];

View file

@ -1366,7 +1366,7 @@ rb_str_format_m(VALUE str, VALUE arg)
volatile VALUE tmp = rb_check_array_type(arg);
if (!NIL_P(tmp)) {
return rb_str_format(RARRAY_LENINT(tmp), RARRAY_RAWPTR(tmp), str);
return rb_str_format(RARRAY_LENINT(tmp), RARRAY_CONST_PTR(tmp), str);
}
return rb_str_format(1, &arg, str);
}

View file

@ -207,7 +207,7 @@ setup_struct(VALUE nstr, VALUE members)
rb_define_singleton_method(nstr, "new", rb_class_new_instance, -1);
rb_define_singleton_method(nstr, "[]", rb_class_new_instance, -1);
rb_define_singleton_method(nstr, "members", rb_struct_s_members_m, 0);
ptr_members = RARRAY_RAWPTR(members);
ptr_members = RARRAY_CONST_PTR(members);
len = RARRAY_LEN(members);
for (i=0; i< len; i++) {
ID id = SYM2ID(ptr_members[i]);
@ -448,7 +448,7 @@ rb_struct_initialize_m(int argc, VALUE *argv, VALUE self)
RSTRUCT_SET(self, i, argv[i]);
}
if (n > argc) {
rb_mem_clear((VALUE *)RSTRUCT_RAWPTR(self)+argc, n-argc);
rb_mem_clear((VALUE *)RSTRUCT_CONST_PTR(self)+argc, n-argc);
}
return Qnil;
}
@ -666,7 +666,7 @@ rb_struct_inspect(VALUE s)
static VALUE
rb_struct_to_a(VALUE s)
{
return rb_ary_new4(RSTRUCT_LEN(s), RSTRUCT_RAWPTR(s));
return rb_ary_new4(RSTRUCT_LEN(s), RSTRUCT_CONST_PTR(s));
}
/*
@ -911,8 +911,8 @@ recursive_equal(VALUE s, VALUE s2, int recur)
long i, len;
if (recur) return Qtrue; /* Subtle! */
ptr = RSTRUCT_RAWPTR(s);
ptr2 = RSTRUCT_RAWPTR(s2);
ptr = RSTRUCT_CONST_PTR(s);
ptr2 = RSTRUCT_CONST_PTR(s2);
len = RSTRUCT_LEN(s);
for (i=0; i<len; i++) {
if (!rb_equal(ptr[i], ptr2[i])) return Qfalse;
@ -958,7 +958,7 @@ recursive_hash(VALUE s, VALUE dummy, int recur)
h = rb_hash_start(rb_hash(rb_obj_class(s)));
if (!recur) {
ptr = RSTRUCT_RAWPTR(s);
ptr = RSTRUCT_CONST_PTR(s);
len = RSTRUCT_LEN(s);
for (i = 0; i < len; i++) {
n = rb_hash(ptr[i]);
@ -989,8 +989,8 @@ recursive_eql(VALUE s, VALUE s2, int recur)
long i, len;
if (recur) return Qtrue; /* Subtle! */
ptr = RSTRUCT_RAWPTR(s);
ptr2 = RSTRUCT_RAWPTR(s2);
ptr = RSTRUCT_CONST_PTR(s);
ptr2 = RSTRUCT_CONST_PTR(s2);
len = RSTRUCT_LEN(s);
for (i=0; i<len; i++) {
if (!rb_eql(ptr[i], ptr2[i])) return Qfalse;

View file

@ -528,7 +528,7 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s
th->root_lep = rb_vm_ep_local_ep(proc->block.ep);
th->root_svar = Qnil;
EXEC_EVENT_HOOK(th, RUBY_EVENT_THREAD_BEGIN, th->self, 0, 0, Qundef);
th->value = rb_vm_invoke_proc(th, proc, (int)RARRAY_LEN(args), RARRAY_RAWPTR(args), 0);
th->value = rb_vm_invoke_proc(th, proc, (int)RARRAY_LEN(args), RARRAY_CONST_PTR(args), 0);
EXEC_EVENT_HOOK(th, RUBY_EVENT_THREAD_END, th->self, 0, 0, Qundef);
}
else {
@ -1545,10 +1545,10 @@ rb_threadptr_pending_interrupt_check_mask(rb_thread_t *th, VALUE err)
{
VALUE mask;
long mask_stack_len = RARRAY_LEN(th->pending_interrupt_mask_stack);
const VALUE *mask_stack = RARRAY_RAWPTR(th->pending_interrupt_mask_stack);
const VALUE *mask_stack = RARRAY_CONST_PTR(th->pending_interrupt_mask_stack);
VALUE ancestors = rb_mod_ancestors(err); /* TODO: GC guard */
long ancestors_len = RARRAY_LEN(ancestors);
const VALUE *ancestors_ptr = RARRAY_RAWPTR(ancestors);
const VALUE *ancestors_ptr = RARRAY_CONST_PTR(ancestors);
int i, j;
for (i=0; i<mask_stack_len; i++) {

View file

@ -1510,7 +1510,7 @@ yield_under(VALUE under, VALUE self, VALUE values)
return vm_yield_with_cref(th, 1, &self, cref);
}
else {
return vm_yield_with_cref(th, RARRAY_LENINT(values), RARRAY_RAWPTR(values), cref);
return vm_yield_with_cref(th, RARRAY_LENINT(values), RARRAY_CONST_PTR(values), cref);
}
}

View file

@ -792,7 +792,7 @@ vm_expandarray(rb_control_frame_t *cfp, VALUE ary, rb_num_t num, int flag)
cfp->sp += space_size;
ptr = RARRAY_RAWPTR(ary);
ptr = RARRAY_CONST_PTR(ary);
len = (rb_num_t)RARRAY_LEN(ary);
if (flag & 0x02) {
@ -1068,7 +1068,7 @@ vm_caller_setup_args(const rb_thread_t *th, rb_control_frame_t *cfp, rb_call_inf
}
else {
long len = RARRAY_LEN(tmp);
ptr = RARRAY_RAWPTR(tmp);
ptr = RARRAY_CONST_PTR(tmp);
cfp->sp -= 1;
CHECK_VM_STACK_OVERFLOW(cfp, len);
@ -2244,7 +2244,7 @@ vm_yield_setup_block_args(rb_thread_t *th, const rb_iseq_t * iseq,
CHECK_VM_STACK_OVERFLOW(th->cfp, argc);
MEMCPY(argv, RARRAY_RAWPTR(ary), VALUE, argc);
MEMCPY(argv, RARRAY_CONST_PTR(ary), VALUE, argc);
}
else {
/* vm_push_frame current argv is at the top of sp because vm_invoke_block