Module: YTLJit::VM::SendNodeCodeGen

Includes:
AbsArch, CommonCodeGen
Included in:
Node::ClassTopNode, Node::SendNode, TypeCodeGen::ArrayTypeUnboxedCodeGen
Defined in:
lib/ytljit/vm_codegen.rb

Constant Summary

Constants included from AbsArch

AbsArch::AL, AbsArch::BL, AbsArch::CL, AbsArch::DL, AbsArch::FUNC_ARG, AbsArch::FUNC_ARG_YTL, AbsArch::FUNC_FLOAT_ARG, AbsArch::FUNC_FLOAT_ARG_YTL, AbsArch::INDIRECT_BPR, AbsArch::INDIRECT_RETR, AbsArch::INDIRECT_SPR, AbsArch::INDIRECT_TMPR, AbsArch::INDIRECT_TMPR2, AbsArch::INDIRECT_TMPR3

Constants included from SSE

SSE::XMM0, SSE::XMM1, SSE::XMM2, SSE::XMM3, SSE::XMM4, SSE::XMM5, SSE::XMM6, SSE::XMM7

Instance Method Summary collapse

Methods included from CommonCodeGen

#dump_context, #gen_alloca, #gen_call, #gen_save_thepr

Instance Method Details

#gen_make_argv(context, rarg = nil, argcomphook = nil) ⇒ Object



684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
# File 'lib/ytljit/vm_codegen.rb', line 684

def gen_make_argv(context, rarg = nil, argcomphook = nil)
  casm = context.assembler
  if rarg == nil then
    rarg = @arguments[3..-1]
  end
  cursig = context.to_signature

  # make argv
  argbyte = rarg.size * AsmType::MACHINE_WORD.size
  casm.with_retry do
    casm.sub(SPR, argbyte)
  end
  context.cpustack_pushn(argbyte)

  rarg.each_with_index do |arg, i|
    rtype = nil
    if argcomphook then
      rtype = argcomphook.call(context, arg, i)
    else
      context = arg.compile(context)
      context.ret_node.decide_type_once(cursig)
      rtype = context.ret_node.type
    end
    context = rtype.gen_boxing(context)
    dst = OpIndirect.new(SPR, i * AsmType::MACHINE_WORD.size)
    if context.ret_reg.is_a?(OpRegistor) or 
        context.ret_reg.is_a?(OpImmidiate32) or 
        context.ret_reg.is_a?(OpImmidiate8) then
      casm.with_retry do
        casm.mov(dst, context.ret_reg)
      end

    else
      casm.with_retry do
        casm.mov(TMPR, context.ret_reg)
        casm.mov(dst, TMPR)
      end
    end
    context.cpustack_setn(i, context.ret_node)
  end

  # Copy Stack Pointer
  # TMPR2 doesnt need save. Because already saved in outside
  # of send node
  casm.with_retry do
    casm.mov(TMPR2, SPR)
  end
  context.set_reg_content(TMPR2, SPR)

  # stack, generate call ...
  context = yield(context, rarg)

  # adjust stack
  casm.with_retry do
    casm.add(SPR, argbyte)
  end
  context.cpustack_popn(argbyte)

  context
end