diff options
author | Ole Friis Østergaard <olefriis@gmail.com> | 2023-02-28 13:44:57 +0100 |
---|---|---|
committer | John Hawthorn <john@hawthorn.email> | 2023-03-08 09:34:31 -0800 |
commit | 1a3f8e1c9f6ce4b1cd7236fdcdd17a8719654320 (patch) | |
tree | 1c98ce45d048e918923d7e5267062af5072538cf /insns.def | |
parent | dc1e6573f2a1e3f85dd35c2acc26b647bd44e3b7 (diff) |
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.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/7433
Diffstat (limited to 'insns.def')
-rw-r--r-- | insns.def | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -701,6 +701,20 @@ defined } } +/* defined?(@foo) */ +DEFINE_INSN +defined_ivar +(ID id, IVC ic, VALUE pushval) +() +(VALUE val) +// attr bool leaf = false; +{ + val = Qnil; + if (vm_getivar(GET_SELF(), id, GET_ISEQ(), ic, NULL, FALSE, Qundef) != Qundef) { + val = pushval; + } +} + /* check `target' matches `pattern'. `flag & VM_CHECKMATCH_TYPE_MASK' describe how to check pattern. VM_CHECKMATCH_TYPE_WHEN: ignore target and check pattern is truthy. |