ruby-changes:51018
From: nobu <ko1@a...>
Date: Sat, 21 Apr 2018 19:52:58 +0900 (JST)
Subject: [ruby-changes:51018] nobu:r63225 (trunk): insns.def: checktype
nobu 2018-04-21 19:52:52 +0900 (Sat, 21 Apr 2018) New Revision: 63225 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63225 Log: insns.def: checktype * insns.def (checktype): split branchiftype to checktype and branchif, to make branch condition negation possible. Modified files: trunk/compile.c trunk/insns.def trunk/iseq.c Index: iseq.c =================================================================== --- iseq.c (revision 63224) +++ iseq.c (revision 63225) @@ -1666,7 +1666,7 @@ rb_insn_operand_intern(const rb_iseq_t * https://github.com/ruby/ruby/blob/trunk/iseq.c#L1666 ret = rb_iseq_defined_string(deftype); if (ret) break; } - else if (insn == BIN(branchiftype) && op_no == 0) { + else if (insn == BIN(checktype) && op_no == 0) { const char *type_str = rb_type_str((enum ruby_value_type)op); if (type_str) { ret = rb_str_new_cstr(type_str); break; Index: insns.def =================================================================== --- insns.def (revision 63224) +++ insns.def (revision 63225) @@ -655,6 +655,16 @@ checkkeyword https://github.com/ruby/ruby/blob/trunk/insns.def#L655 ret = vm_check_keyword(kw_bits_index, keyword_index, GET_EP()); } +/* check if val is type. */ +DEFINE_INSN +checktype +(rb_num_t type) +(VALUE val) +(VALUE ret) +{ + ret = (TYPE(val) == (int)type) ? Qtrue : Qfalse; +} + /* fire a coverage event (currently, this is used for line coverage and branch coverage) */ DEFINE_INSN tracecoverage @@ -924,19 +934,6 @@ branchnil https://github.com/ruby/ruby/blob/trunk/insns.def#L934 RUBY_VM_CHECK_INTS(ec); JUMP(dst); } -} - -/* if val is type, set PC to (PC + dst). */ -DEFINE_INSN -branchiftype -(rb_num_t type, OFFSET dst) -(VALUE val) -() -{ - if (TYPE(val) == (int)type) { - RUBY_VM_CHECK_INTS(ec); - JUMP(dst); - } } /**********************************************************/ Index: compile.c =================================================================== --- compile.c (revision 63224) +++ compile.c (revision 63225) @@ -5622,8 +5622,8 @@ compile_evstr(rb_iseq_t *iseq, LINK_ANCH https://github.com/ruby/ruby/blob/trunk/compile.c#L5622 const unsigned int flag = VM_CALL_FCALL; LABEL *isstr = NEW_LABEL(line); ADD_INSN(ret, line, dup); - ADD_INSN2(ret, line, branchiftype, INT2FIX(T_STRING), isstr); - LABEL_REF(isstr); + ADD_INSN1(ret, line, checktype, INT2FIX(T_STRING)); + ADD_INSNL(ret, line, branchif, isstr); ADD_INSN(ret, line, dup); ADD_SEND_R(ret, line, idTo_s, INT2FIX(0), NULL, INT2FIX(flag), NULL); ADD_INSN(ret, line, tostring); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/