Module: YTLJit::VM::SendNodeCodeGen

Includes:
AbsArch, CommonCodeGen
Included in:
Node::ClassTopNode, Node::SendNode
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

Instance Method Details

#gen_make_argv(context) ⇒ Object



622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
# File 'lib/ytljit/vm_codegen.rb', line 622

def gen_make_argv(context)
  casm = context.assembler
  rarg = @arguments[3..-1]

  # make argv
  casm = context.assembler
  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|
    context = arg.compile(context)
    context.ret_node.decide_type_once(context.to_signature)
    rtype = context.ret_node.type
    context = rtype.gen_boxing(context)
    casm = context.assembler
    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 = context.assembler
  casm.with_retry do
    casm.add(SPR, argbyte)
  end
  context.cpustack_popn(argbyte)

  context
end