lib/tenderjit/iseq_compiler.rb
def handle_expandarray num, flag
      raise NotImplementedError if flag != 0

      # handle_coercearray will try to coerce the stack's top value to an array
      # see vm_expandarray.  If the top of the stack isn't an array, it will
      # *allocate* an array on the machine's stack.  Then push that value on
      # the stack and tag it as an int by setting the lower bit to 1.  This
      # guarantees that the `compile_expandarray` runtime check will only ever
      # see an "int" which is actually a tagged array, or a real array.  If
      # it's tagged we just have to remove the tag and use it as an array.
      # Also if it's tagged we need to unwind rsp.

      handle_coercearray

      #sp_inc = num - 1 + (flag & 1 ? 1 : 0);

      req = CompileExpandArray.new(num, flag, @temp_stack.dup.freeze)
      @compile_requests << Fiddle::Pinned.new(req)

      deferred = @jit.deferred_call(@temp_stack) do |ctx|
        ctx.with_runtime do |rt|
          rt.rb_funcall self, :compile_expandarray, [REG_CFP, req, rt.return_value]

          rt.NUM2INT(rt.return_value)

          rt.jump rt.return_value
        end
      end

      deferred.call
      req.deferred_entry = deferred.entry.to_i

      # attr rb_snum_t sp_inc = (rb_snum_t)num - 1 + (flag & 1 ? 1 : 0);
      @temp_stack.pop
      num.times { @temp_stack.push :unknown }

      with_runtime do |rt|
        rt.patchable_jump req.deferred_entry
      end
    end
# num is the number of elements we need to expand
# flag is special
num is the number of elements we need to expand
flag is special
num is the number of elements we need to expand flag is special
def handle_expandarray num, flag
      raise NotImplementedError if flag != 0
      handle_coercearray
      req = CompileExpandArray.new(num, flag, @temp_stack.dup.freeze)
      @compile_requests << Fiddle::Pinned.new(req)
      deferred = @jit.deferred_call(@temp_stack) do |ctx|
        ctx.with_runtime do |rt|
          rt.rb_funcall self, :compile_expandarray, [REG_CFP, req, rt.return_value]
          rt.NUM2INT(rt.return_value)
          rt.jump rt.return_value
        end
      end
      deferred.call
      req.deferred_entry = deferred.entry.to_i
      @temp_stack.pop
      num.times { @temp_stack.push :unknown }
      with_runtime do |rt|
        rt.patchable_jump req.deferred_entry
      end
    end
def handle_expandarray num , flag raise NotImplementedError if flag != 0 handle_coercearray req = CompileExpandArray . new ( num , flag , @temp_stack . dup . freeze ) @compile_requests << Fiddle :: Pinned . new ( req ) deferred = @jit . deferred_call ( @temp_stack ) do | ctx | ctx . with_runtime do | rt | rt . rb_funcall self , :compile_expandarray , [ REG_CFP , req , rt . return_value ] rt . NUM2INT ( rt . return_value ) rt . jump rt . return_value end end deferred . call req . deferred_entry = deferred . entry . to_i @temp_stack . pop num . times { @temp_stack . push :unknown } with_runtime do | rt | rt . patchable_jump req . deferred_entry end end
num is the number of elements we need to expand
flag is special
num is the number of elements we need to expand flag is special
# handle_coercearray will try to coerce the stack's top value to an array # see vm_expandarray.  If the top of the stack isn't an array, it will # *allocate* an array on the machine's stack.  Then push that value on # the stack and tag it as an int by setting the lower bit to 1.  This # guarantees that the `compile_expandarray` runtime check will only ever # see an "int" which is actually a tagged array, or a real array.  If # it's tagged we just have to remove the tag and use it as an array. # Also if it's tagged we need to unwind rsp. #sp_inc = num - 1 + (flag & 1 ? 1 : 0); # attr rb_snum_t sp_inc = (rb_snum_t)num - 1 + (flag & 1 ? 1 : 0);
num
flag