summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorOle Friis Østergaard <olefriis@gmail.com>2023-02-28 13:44:57 +0100
committerJohn Hawthorn <john@hawthorn.email>2023-03-08 09:34:31 -0800
commit1a3f8e1c9f6ce4b1cd7236fdcdd17a8719654320 (patch)
tree1c98ce45d048e918923d7e5267062af5072538cf /compile.c
parentdc1e6573f2a1e3f85dd35c2acc26b647bd44e3b7 (diff)
downloadruby-1a3f8e1c9f6ce4b1cd7236fdcdd17a8719654320.tar.gz
Add defined_ivar instruction
This is a variation of the `defined` instruction, for use when we are checking for an instance variable. Splitting this out as a separate instruction lets us skip some checks, and it also allows us to use an instance variable cache, letting shape analysis speed up the operation further.
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/compile.c b/compile.c
index 82a6d0ef4e..f4bb2c9107 100644
--- a/compile.c
+++ b/compile.c
@@ -5460,9 +5460,8 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
#define PUSH_VAL(type) (needstr == Qfalse ? Qtrue : rb_iseq_defined_string(type))
case NODE_IVAR:
- ADD_INSN(ret, line_node, putnil);
- ADD_INSN3(ret, line_node, defined, INT2FIX(DEFINED_IVAR),
- ID2SYM(node->nd_vid), PUSH_VAL(DEFINED_IVAR));
+ ADD_INSN3(ret, line_node, defined_ivar,
+ ID2SYM(node->nd_vid), get_ivar_ic_value(iseq,node->nd_vid), PUSH_VAL(DEFINED_IVAR));
return;
case NODE_GVAR: