ruby-changes:45045
From: rhe <ko1@a...>
Date: Tue, 20 Dec 2016 14:26:11 +0900 (JST)
Subject: [ruby-changes:45045] rhe:r57118 (trunk): proc.c: assume rb_iseq_location_t::first_lineno is always a Fixnum
rhe 2016-12-20 14:26:07 +0900 (Tue, 20 Dec 2016) New Revision: 57118 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57118 Log: proc.c: assume rb_iseq_location_t::first_lineno is always a Fixnum Do not check for the value of rb_iseq_constant_body::line_info_table as it is no longer related. The checks seem to be the remains from the day before the dedicated 'first_lineno' field was introduced. Remove them. Note, rb_iseq_constant_body::line_info_table can be NULL only when the iseq does not contain any instructions that originate from Ruby code, for example, an iseq created with 'proc {}' under a non-default compile options where trace instructions are disabled. Modified files: trunk/proc.c trunk/thread.c trunk/vm_method.c Index: proc.c =================================================================== --- proc.c (revision 57117) +++ proc.c (revision 57118) @@ -1076,12 +1076,8 @@ iseq_location(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/proc.c#L1076 if (!iseq) return Qnil; rb_iseq_check(iseq); loc[0] = iseq->body->location.path; - if (iseq->body->line_info_table) { - loc[1] = rb_iseq_first_lineno(iseq); - } - else { - loc[1] = Qnil; - } + loc[1] = iseq->body->location.first_lineno; + return rb_ary_new4(2, loc); } @@ -1234,12 +1230,9 @@ proc_to_s_(VALUE self, const rb_proc_t * https://github.com/ruby/ruby/blob/trunk/proc.c#L1230 case block_type_iseq: { const rb_iseq_t *iseq = rb_iseq_check(block->as.captured.code.iseq); - int first_lineno = 0; - if (iseq->body->line_info_table) { - first_lineno = FIX2INT(rb_iseq_first_lineno(iseq)); - } str = rb_sprintf("#<%s:%p@%"PRIsVALUE":%d%s>", cname, (void *)self, - iseq->body->location.path, first_lineno, is_lambda); + iseq->body->location.path, + FIX2INT(iseq->body->location.first_lineno), is_lambda); } break; case block_type_symbol: Index: thread.c =================================================================== --- thread.c (revision 57117) +++ thread.c (revision 57118) @@ -788,19 +788,13 @@ thread_initialize(VALUE thread, VALUE ar https://github.com/ruby/ruby/blob/trunk/thread.c#L788 } GetThreadPtr(thread, th); if (th->first_args) { - VALUE proc = th->first_proc, line, loc; - VALUE file; + VALUE proc = th->first_proc, loc; if (!proc || !RTEST(loc = rb_proc_location(proc))) { rb_raise(rb_eThreadError, "already initialized thread"); } - file = RARRAY_AREF(loc, 0); - if (NIL_P(line = RARRAY_AREF(loc, 1))) { - rb_raise(rb_eThreadError, - "already initialized thread - %"PRIsVALUE, file); - } rb_raise(rb_eThreadError, "already initialized thread - %"PRIsVALUE":%"PRIsVALUE, - file, line); + RARRAY_AREF(loc, 0), RARRAY_AREF(loc, 1)); } return thread_create_core(thread, args, 0); } Index: vm_method.c =================================================================== --- vm_method.c (revision 57117) +++ vm_method.c (revision 57118) @@ -563,9 +563,9 @@ rb_method_entry_make(VALUE klass, ID mid https://github.com/ruby/ruby/blob/trunk/vm_method.c#L563 default: break; } - if (iseq && !NIL_P(iseq->body->location.path)) { - int line = iseq->body->line_info_table ? FIX2INT(rb_iseq_first_lineno(iseq)) : 0; - rb_compile_warning(RSTRING_PTR(iseq->body->location.path), line, + if (iseq) { + rb_compile_warning(RSTRING_PTR(iseq->body->location.path), + FIX2INT(iseq->body->location.first_lineno), "previous definition of %"PRIsVALUE" was here", rb_id2str(old_def->original_id)); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/