зеркало из https://github.com/github/ruby.git
c5fc1ce975
This commit introduces a new instruction `opt_newarray_send` which is used when there is an array literal followed by either the `hash`, `min`, or `max` method. ``` [a, b, c].hash ``` Will emit an `opt_newarray_send` instruction. This instruction falls back to a method call if the "interested" method has been monkey patched. Here are some examples of the instructions generated: ``` $ ./miniruby --dump=insns -e '[@a, @b].max' == disasm: #<ISeq:<main>@-e:1 (1,0)-(1,12)> (catch: FALSE) 0000 getinstancevariable :@a, <is:0> ( 1)[Li] 0003 getinstancevariable :@b, <is:1> 0006 opt_newarray_send 2, :max 0009 leave $ ./miniruby --dump=insns -e '[@a, @b].min' == disasm: #<ISeq:<main>@-e:1 (1,0)-(1,12)> (catch: FALSE) 0000 getinstancevariable :@a, <is:0> ( 1)[Li] 0003 getinstancevariable :@b, <is:1> 0006 opt_newarray_send 2, :min 0009 leave $ ./miniruby --dump=insns -e '[@a, @b].hash' == disasm: #<ISeq:<main>@-e:1 (1,0)-(1,13)> (catch: FALSE) 0000 getinstancevariable :@a, <is:0> ( 1)[Li] 0003 getinstancevariable :@b, <is:1> 0006 opt_newarray_send 2, :hash 0009 leave ``` [Feature #18897] [ruby-core:109147] Co-authored-by: John Hawthorn <jhawthorn@github.com> |
||
---|---|---|
.. | ||
array.h | ||
basic_operators.h | ||
bignum.h | ||
bits.h | ||
class.h | ||
cmdlineopt.h | ||
compar.h | ||
compile.h | ||
compilers.h | ||
complex.h | ||
cont.h | ||
dir.h | ||
enc.h | ||
encoding.h | ||
enum.h | ||
enumerator.h | ||
error.h | ||
eval.h | ||
file.h | ||
fixnum.h | ||
gc.h | ||
hash.h | ||
imemo.h | ||
inits.h | ||
io.h | ||
load.h | ||
loadpath.h | ||
math.h | ||
missing.h | ||
numeric.h | ||
object.h | ||
parse.h | ||
proc.h | ||
process.h | ||
ractor.h | ||
random.h | ||
range.h | ||
rational.h | ||
re.h | ||
sanitizers.h | ||
serial.h | ||
signal.h | ||
static_assert.h | ||
string.h | ||
struct.h | ||
symbol.h | ||
thread.h | ||
time.h | ||
transcode.h | ||
util.h | ||
variable.h | ||
vm.h | ||
warnings.h |