mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* vm_core.h: size should be unsigned.
* rb_call_info_t::index * rb_iseq_constant_body::stack_max * rb_iseq_constant_body::local_size * rb_iseq_constant_body::param::size * rb_iseq_constant_body::local_table_size * rb_iseq_constant_body::is_size * rb_iseq_constant_body::callinfo_size * iseq.h: same for iseq_catch_table::size. * compile.c: catch up these fix. * iseq.c: ditto. * proc.c: ditto. * vm.c: ditto. * vm_args.c: ditto. * vm_eval.c: ditto. * vm_insnhelper.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
14428f09b1
commit
22be6d06ab
10 changed files with 68 additions and 39 deletions
27
ChangeLog
27
ChangeLog
|
@ -1,3 +1,30 @@
|
|||
Sat Jul 25 06:38:36 2015 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* vm_core.h: size should be unsigned.
|
||||
* rb_call_info_t::index
|
||||
* rb_iseq_constant_body::stack_max
|
||||
* rb_iseq_constant_body::local_size
|
||||
* rb_iseq_constant_body::param::size
|
||||
* rb_iseq_constant_body::local_table_size
|
||||
* rb_iseq_constant_body::is_size
|
||||
* rb_iseq_constant_body::callinfo_size
|
||||
|
||||
* iseq.h: same for iseq_catch_table::size.
|
||||
|
||||
* compile.c: catch up these fix.
|
||||
|
||||
* iseq.c: ditto.
|
||||
|
||||
* proc.c: ditto.
|
||||
|
||||
* vm.c: ditto.
|
||||
|
||||
* vm_args.c: ditto.
|
||||
|
||||
* vm_eval.c: ditto.
|
||||
|
||||
* vm_insnhelper.c: ditto.
|
||||
|
||||
Sat Jul 25 06:00:09 2015 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* vm_core.h: constify rb_iseq_constant_body::line_info_table.
|
||||
|
|
14
compile.c
14
compile.c
|
@ -1080,11 +1080,11 @@ get_lvar_level(const rb_iseq_t *iseq)
|
|||
static int
|
||||
get_dyna_var_idx_at_raw(const rb_iseq_t *iseq, ID id)
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < iseq->body->local_table_size; i++) {
|
||||
if (iseq->body->local_table[i] == id) {
|
||||
return i;
|
||||
return (int)i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
|
@ -1587,7 +1587,7 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
|
|||
}
|
||||
case TS_IC: /* inline cache */
|
||||
{
|
||||
int ic_index = FIX2INT(operands[j]);
|
||||
unsigned int ic_index = FIX2UINT(operands[j]);
|
||||
IC ic = (IC)&iseq->body->is_entries[ic_index];
|
||||
if (UNLIKELY(ic_index >= iseq->body->is_size)) {
|
||||
rb_bug("iseq_set_sequence: ic_index overflow: index: %d, size: %d", ic_index, iseq->body->is_size);
|
||||
|
@ -1719,7 +1719,7 @@ static int
|
|||
iseq_set_exception_table(rb_iseq_t *iseq)
|
||||
{
|
||||
const VALUE *tptr, *ptr;
|
||||
int tlen, i;
|
||||
unsigned int tlen, i;
|
||||
struct iseq_catch_table_entry *entry;
|
||||
|
||||
tlen = (int)RARRAY_LEN(iseq->compile_data->catch_table_ary);
|
||||
|
@ -6013,7 +6013,7 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *anchor,
|
|||
break;
|
||||
case TS_IC:
|
||||
argv[j] = op;
|
||||
if (NUM2INT(op) >= iseq->body->is_size) {
|
||||
if (NUM2UINT(op) >= iseq->body->is_size) {
|
||||
iseq->body->is_size = NUM2INT(op) + 1;
|
||||
}
|
||||
break;
|
||||
|
@ -6274,7 +6274,7 @@ rb_dvar_defined(ID id)
|
|||
iseq->body->type == ISEQ_TYPE_EVAL ||
|
||||
iseq->body->type == ISEQ_TYPE_MAIN
|
||||
) {
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < iseq->body->local_table_size; i++) {
|
||||
if (iseq->body->local_table[i] == id) {
|
||||
|
@ -6294,7 +6294,7 @@ rb_local_defined(ID id)
|
|||
const rb_iseq_t *iseq;
|
||||
|
||||
if (th->base_block && th->base_block->iseq) {
|
||||
int i;
|
||||
unsigned int i;
|
||||
iseq = th->base_block->iseq->body->local_iseq;
|
||||
|
||||
for (i=0; i<iseq->body->local_table_size; i++) {
|
||||
|
|
36
iseq.c
36
iseq.c
|
@ -70,14 +70,13 @@ rb_iseq_free(const rb_iseq_t *iseq)
|
|||
RUBY_FREE_ENTER("iseq");
|
||||
|
||||
if (iseq) {
|
||||
int i;
|
||||
|
||||
ruby_xfree((void *)iseq->body->iseq_encoded);
|
||||
ruby_xfree((void *)iseq->body->line_info_table);
|
||||
ruby_xfree((void *)iseq->body->local_table);
|
||||
ruby_xfree((void *)iseq->body->is_entries);
|
||||
|
||||
if (iseq->body->callinfo_entries) {
|
||||
unsigned int i;
|
||||
for (i=0; i<iseq->body->callinfo_size; i++) {
|
||||
/* TODO: revisit callinfo data structure */
|
||||
const rb_call_info_kw_arg_t *kw_arg = iseq->body->callinfo_entries[i].kw_arg;
|
||||
|
@ -1364,7 +1363,7 @@ rb_iseq_disasm(const rb_iseq_t *iseq)
|
|||
VALUE str = rb_str_new(0, 0);
|
||||
VALUE child = rb_ary_tmp_new(3);
|
||||
unsigned int size;
|
||||
int i;
|
||||
unsigned int i;
|
||||
long l;
|
||||
const ID *tbl;
|
||||
size_t n;
|
||||
|
@ -1387,14 +1386,16 @@ rb_iseq_disasm(const rb_iseq_t *iseq)
|
|||
if (iseq->body->catch_table) {
|
||||
rb_str_cat2(str, "== catch table\n");
|
||||
}
|
||||
if (iseq->body->catch_table) for (i = 0; i < iseq->body->catch_table->size; i++) {
|
||||
const struct iseq_catch_table_entry *entry = &iseq->body->catch_table->entries[i];
|
||||
rb_str_catf(str,
|
||||
"| catch type: %-6s st: %04d ed: %04d sp: %04d cont: %04d\n",
|
||||
catch_type((int)entry->type), (int)entry->start,
|
||||
(int)entry->end, (int)entry->sp, (int)entry->cont);
|
||||
if (entry->iseq) {
|
||||
rb_str_concat(str, rb_iseq_disasm(entry->iseq));
|
||||
if (iseq->body->catch_table) {
|
||||
for (i = 0; i < iseq->body->catch_table->size; i++) {
|
||||
const struct iseq_catch_table_entry *entry = &iseq->body->catch_table->entries[i];
|
||||
rb_str_catf(str,
|
||||
"| catch type: %-6s st: %04d ed: %04d sp: %04d cont: %04d\n",
|
||||
catch_type((int)entry->type), (int)entry->start,
|
||||
(int)entry->end, (int)entry->sp, (int)entry->cont);
|
||||
if (entry->iseq) {
|
||||
rb_str_concat(str, rb_iseq_disasm(entry->iseq));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (iseq->body->catch_table) {
|
||||
|
@ -1420,6 +1421,7 @@ rb_iseq_disasm(const rb_iseq_t *iseq)
|
|||
iseq->body->param.flags.has_kwrest ? iseq->body->param.keyword->rest_start : -1);
|
||||
|
||||
for (i = 0; i < iseq->body->local_table_size; i++) {
|
||||
int li = (int)i;
|
||||
long width;
|
||||
VALUE name = id_to_name(tbl[i], 0);
|
||||
char argi[0x100] = "";
|
||||
|
@ -1428,18 +1430,18 @@ rb_iseq_disasm(const rb_iseq_t *iseq)
|
|||
if (iseq->body->param.flags.has_opt) {
|
||||
int argc = iseq->body->param.lead_num;
|
||||
int opts = iseq->body->param.opt_num;
|
||||
if (i >= argc && i < argc + opts) {
|
||||
if (li >= argc && li < argc + opts) {
|
||||
snprintf(opti, sizeof(opti), "Opt=%"PRIdVALUE,
|
||||
iseq->body->param.opt_table[i - argc]);
|
||||
iseq->body->param.opt_table[li - argc]);
|
||||
}
|
||||
}
|
||||
|
||||
snprintf(argi, sizeof(argi), "%s%s%s%s%s", /* arg, opts, rest, post block */
|
||||
iseq->body->param.lead_num > i ? "Arg" : "",
|
||||
iseq->body->param.lead_num > li ? "Arg" : "",
|
||||
opti,
|
||||
(iseq->body->param.flags.has_rest && iseq->body->param.rest_start == i) ? "Rest" : "",
|
||||
(iseq->body->param.flags.has_post && iseq->body->param.post_start <= i && i < iseq->body->param.post_start + iseq->body->param.post_num) ? "Post" : "",
|
||||
(iseq->body->param.flags.has_block && iseq->body->param.block_start == i) ? "Block" : "");
|
||||
(iseq->body->param.flags.has_rest && iseq->body->param.rest_start == li) ? "Rest" : "",
|
||||
(iseq->body->param.flags.has_post && iseq->body->param.post_start <= li && li < iseq->body->param.post_start + iseq->body->param.post_num) ? "Post" : "",
|
||||
(iseq->body->param.flags.has_block && iseq->body->param.block_start == li) ? "Block" : "");
|
||||
|
||||
rb_str_catf(str, "[%2d] ", iseq->body->local_size - i);
|
||||
width = RSTRING_LEN(str) + 11;
|
||||
|
|
2
iseq.h
2
iseq.h
|
@ -80,7 +80,7 @@ struct iseq_catch_table_entry {
|
|||
};
|
||||
|
||||
PACKED_STRUCT_UNALIGNED(struct iseq_catch_table {
|
||||
int size;
|
||||
unsigned int size;
|
||||
struct iseq_catch_table_entry entries[1]; /* flexible array */
|
||||
});
|
||||
|
||||
|
|
2
proc.c
2
proc.c
|
@ -363,7 +363,7 @@ get_local_variable_ptr(VALUE envval, ID lid)
|
|||
|
||||
do {
|
||||
const rb_iseq_t *iseq;
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
GetEnvPtr(envval, env);
|
||||
iseq = env->block.iseq;
|
||||
|
|
4
vm.c
4
vm.c
|
@ -629,7 +629,7 @@ rb_vm_env_prev_envval(const rb_env_t *env)
|
|||
static int
|
||||
collect_local_variables_in_iseq(const rb_iseq_t *iseq, const struct local_var_list *vars)
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
if (!iseq) return 0;
|
||||
for (i = 0; i < iseq->body->local_table_size; i++) {
|
||||
local_var_list_add(vars, iseq->body->local_table[i]);
|
||||
|
@ -1477,7 +1477,7 @@ vm_exec(rb_thread_t *th)
|
|||
}
|
||||
}
|
||||
else {
|
||||
int i;
|
||||
unsigned int i;
|
||||
const struct iseq_catch_table_entry *entry;
|
||||
const struct iseq_catch_table *ct;
|
||||
unsigned long epc, cont_pc, cont_sp;
|
||||
|
|
|
@ -509,7 +509,7 @@ setup_parameters_complex(rb_thread_t * const th, const rb_iseq_t * const iseq, r
|
|||
struct args_info args_body, *args;
|
||||
VALUE keyword_hash = Qnil;
|
||||
VALUE * const orig_sp = th->cfp->sp;
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
/*
|
||||
* Extend SP for GC.
|
||||
|
|
14
vm_core.h
14
vm_core.h
|
@ -213,7 +213,7 @@ typedef struct rb_call_info_struct {
|
|||
int argc;
|
||||
union {
|
||||
int opt_pc; /* used by iseq */
|
||||
int index; /* used by ivar */
|
||||
unsigned int index; /* used by ivar */
|
||||
enum method_missing_reason method_missing_reason; /* used by method_missing */
|
||||
int inc_sp; /* used by cfunc */
|
||||
} aux;
|
||||
|
@ -250,9 +250,9 @@ struct rb_iseq_constant_body {
|
|||
ISEQ_TYPE_DEFINED_GUARD
|
||||
} type; /* instruction sequence type */
|
||||
|
||||
int stack_max; /* for stack overflow check */
|
||||
unsigned int stack_max; /* for stack overflow check */
|
||||
/* sizeof(vars) + 1 */
|
||||
int local_size;
|
||||
unsigned int local_size;
|
||||
|
||||
unsigned int iseq_size;
|
||||
const VALUE *iseq_encoded; /* encoded iseq (insn addr and operands) */
|
||||
|
@ -293,7 +293,7 @@ struct rb_iseq_constant_body {
|
|||
unsigned int ambiguous_param0 : 1; /* {|a|} */
|
||||
} flags;
|
||||
|
||||
int size;
|
||||
unsigned int size;
|
||||
|
||||
int lead_num;
|
||||
int opt_num;
|
||||
|
@ -345,9 +345,9 @@ struct rb_iseq_constant_body {
|
|||
rb_call_info_t *callinfo_entries;
|
||||
const VALUE mark_ary; /* Array: includes operands which should be GC marked */
|
||||
|
||||
int local_table_size;
|
||||
int is_size;
|
||||
int callinfo_size;
|
||||
unsigned int local_table_size;
|
||||
unsigned int is_size;
|
||||
unsigned int callinfo_size;
|
||||
unsigned int line_info_size;
|
||||
};
|
||||
|
||||
|
|
|
@ -2043,7 +2043,7 @@ rb_f_local_variables(void)
|
|||
rb_thread_t *th = GET_THREAD();
|
||||
rb_control_frame_t *cfp =
|
||||
vm_get_ruby_level_caller_cfp(th, RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp));
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
local_var_list_init(&vars);
|
||||
while (cfp) {
|
||||
|
|
|
@ -713,7 +713,7 @@ vm_getivar(VALUE obj, ID id, IC ic, rb_call_info_t *ci, int is_attr)
|
|||
const VALUE *const ptr = ROBJECT_IVPTR(obj);
|
||||
|
||||
if (LIKELY(is_attr ? ci->aux.index > 0 : ic->ic_serial == RCLASS_SERIAL(klass))) {
|
||||
int index = !is_attr ? (int)ic->ic_value.index : ci->aux.index - 1;
|
||||
long index = !is_attr ? (long)ic->ic_value.index : (long)(ci->aux.index - 1);
|
||||
|
||||
if (index < len) {
|
||||
val = ptr[index];
|
||||
|
@ -1383,7 +1383,7 @@ vm_call_iseq_setup_normal(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info
|
|||
static inline VALUE
|
||||
vm_call_iseq_setup_tailcall(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci)
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
VALUE *argv = cfp->sp - ci->argc;
|
||||
const rb_callable_method_entry_t *me = ci->me;
|
||||
const rb_iseq_t *iseq = def_iseq_ptr(me->def);
|
||||
|
|
Loading…
Reference in a new issue