Module: YTLJit::VM::SendNodeCodeGen

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



734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
# File 'lib/ytljit/vm_codegen.rb', line 734

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)
      rtype = context.ret_node.decide_type_once(cursig)
    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