ruby-changes:39288
From: ko1 <ko1@a...>
Date: Sat, 25 Jul 2015 06:44:38 +0900 (JST)
Subject: [ruby-changes:39288] ko1:r51369 (trunk): * vm_core.h: size should be unsigned.
ko1 2015-07-25 06:44:14 +0900 (Sat, 25 Jul 2015) New Revision: 51369 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51369 Log: * 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. Modified files: trunk/ChangeLog trunk/compile.c trunk/iseq.c trunk/iseq.h trunk/proc.c trunk/vm.c trunk/vm_args.c trunk/vm_core.h trunk/vm_eval.c trunk/vm_insnhelper.c Index: ChangeLog =================================================================== --- ChangeLog (revision 51368) +++ ChangeLog (revision 51369) @@ -1,3 +1,30 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Jul 25 06:38:36 2015 Koichi Sasada <ko1@a...> + + * 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@a...> * vm_core.h: constify rb_iseq_constant_body::line_info_table. Index: vm_core.h =================================================================== --- vm_core.h (revision 51368) +++ vm_core.h (revision 51369) @@ -213,7 +213,7 @@ typedef struct rb_call_info_struct { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L213 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 { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L250 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 { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L293 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 { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L345 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; }; Index: iseq.c =================================================================== --- iseq.c (revision 51368) +++ iseq.c (revision 51369) @@ -70,14 +70,13 @@ rb_iseq_free(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/iseq.c#L70 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) https://github.com/ruby/ruby/blob/trunk/iseq.c#L1363 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) https://github.com/ruby/ruby/blob/trunk/iseq.c#L1386 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) https://github.com/ruby/ruby/blob/trunk/iseq.c#L1421 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) https://github.com/ruby/ruby/blob/trunk/iseq.c#L1430 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; Index: iseq.h =================================================================== --- iseq.h (revision 51368) +++ iseq.h (revision 51369) @@ -80,7 +80,7 @@ struct iseq_catch_table_entry { https://github.com/ruby/ruby/blob/trunk/iseq.h#L80 }; PACKED_STRUCT_UNALIGNED(struct iseq_catch_table { - int size; + unsigned int size; struct iseq_catch_table_entry entries[1]; /* flexible array */ }); Index: compile.c =================================================================== --- compile.c (revision 51368) +++ compile.c (revision 51369) @@ -1080,11 +1080,11 @@ get_lvar_level(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/compile.c#L1080 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_ https://github.com/ruby/ruby/blob/trunk/compile.c#L1587 } 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 https://github.com/ruby/ruby/blob/trunk/compile.c#L1719 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 https://github.com/ruby/ruby/blob/trunk/compile.c#L6013 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) https://github.com/ruby/ruby/blob/trunk/compile.c#L6274 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) https://github.com/ruby/ruby/blob/trunk/compile.c#L6294 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++) { Index: vm_eval.c =================================================================== --- vm_eval.c (revision 51368) +++ vm_eval.c (revision 51369) @@ -2043,7 +2043,7 @@ rb_f_local_variables(void) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L2043 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) { Index: proc.c =================================================================== --- proc.c (revision 51368) +++ proc.c (revision 51369) @@ -363,7 +363,7 @@ get_local_variable_ptr(VALUE envval, ID https://github.com/ruby/ruby/blob/trunk/proc.c#L363 do { const rb_iseq_t *iseq; - int i; + unsigned int i; GetEnvPtr(envval, env); iseq = env->block.iseq; Index: vm.c =================================================================== --- vm.c (revision 51368) +++ vm.c (revision 51369) @@ -629,7 +629,7 @@ rb_vm_env_prev_envval(const rb_env_t *en https://github.com/ruby/ruby/blob/trunk/vm.c#L629 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) https://github.com/ruby/ruby/blob/trunk/vm.c#L1477 } } 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; Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 51368) +++ vm_insnhelper.c (revision 51369) @@ -713,7 +713,7 @@ vm_getivar(VALUE obj, ID id, IC ic, rb_c https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L713 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 *t https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1383 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); Index: vm_args.c =================================================================== --- vm_args.c (revision 51368) +++ vm_args.c (revision 51369) @@ -509,7 +509,7 @@ setup_parameters_complex(rb_thread_t * c https://github.com/ruby/ruby/blob/trunk/vm_args.c#L509 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. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/