summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-21 10:52:52 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-21 10:52:52 +0000
commita3fe1034c41008df798be2e7fcf19ff5d977bc56 (patch)
tree1c38fd12acbc0a3cb55bb6d0bc89970c3438d86a
parentc458aeffd1b4339fed8b31c229b0d007c1b9e052 (diff)
insns.def: checktype
* insns.def (checktype): split branchiftype to checktype and branchif, to make branch condition negation possible. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--compile.c4
-rw-r--r--insns.def23
-rw-r--r--iseq.c2
3 files changed, 13 insertions, 16 deletions
diff --git a/compile.c b/compile.c
index 9305d4ff3c..af9e136b8b 100644
--- a/compile.c
+++ b/compile.c
@@ -5622,8 +5622,8 @@ compile_evstr(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
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);
diff --git a/insns.def b/insns.def
index da54e0a4b1..cac337423f 100644
--- a/insns.def
+++ b/insns.def
@@ -655,6 +655,16 @@ checkkeyword
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
@@ -926,19 +936,6 @@ branchnil
}
}
-/* 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);
- }
-}
-
/**********************************************************/
/* for optimize */
/**********************************************************/
diff --git a/iseq.c b/iseq.c
index 96ccb56ecd..5903fddfea 100644
--- a/iseq.c
+++ b/iseq.c
@@ -1666,7 +1666,7 @@ rb_insn_operand_intern(const rb_iseq_t *iseq,
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;