Module: YTLJit::VM::CommonCodeGen

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

Instance Method Details

#dump_context(context) ⇒ Object



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
# File 'lib/ytljit/vm_codegen.rb', line 695

def dump_context(context)
  print "---- Reg map ----\n"
  context.reg_content.each do |key, value|
    print "#{key}   #{value.class} \n"
  end

  print "---- Stack map ----\n"
#=begin
  if @frame_info then
    start = @frame_info.argument_num + 1
    ll = @frame_info.frame_layout.reverse[start..-1]
    ll.each_with_index do |vinf, i|
      ro = @frame_info.real_offset(i)
      print "    #{vinf.name}:#{vinf.size}\n"
=begin
         if mlv = @modified_local_var.last[0][ro] then
           print "    #{mlv.class} \n"
         else
           print "    #{vinf.class} \n"
         end
=end
    end
  end
#=end
  p "---"
  context.stack_content.each do |value|
    if value.is_a?(Symbol) then
      print "    #{value} \n"
    else
      print "    #{value.class} \n"
    end
  end
end

#gen_alloca(context, siz) ⇒ Object



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
# File 'lib/ytljit/vm_codegen.rb', line 632

def gen_alloca(context, siz)
  asm = context.assembler
  case siz
  when Integer
    add = lambda { 
      a = address_of("ytl_arena_alloca")
      $symbol_table[a] = "ytl_arena_alloca"
      a
    }
    alloca = OpVarMemAddress.new(add)
    asm.with_retry do
      asm.mov(FUNC_ARG[0], THEPR)
      asm.mov(TMPR, siz)
      asm.mov(FUNC_ARG[1], TMPR)
    end
    context = gen_save_thepr(context)
    context = gen_call(context, alloca, 2)
    asm.with_retry do
      asm.mov(THEPR, RETR)
    end
  else
    raise "Not implemented yet variable alloca"
  end
  context.ret_reg = THEPR
  context
end

#gen_call(context, fnc, numarg, slf = nil) ⇒ Object



669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
# File 'lib/ytljit/vm_codegen.rb', line 669

def gen_call(context, fnc, numarg, slf = nil)
  casm = context.assembler

  callpos = nil
  casm.with_retry do 
    dmy, callpos = casm.call_with_arg(fnc, numarg)
  end
  context.end_using_reg(fnc)
  vretadd = casm.output_stream.var_base_address(callpos)
  cpuinfo = []
  if slf then
    cpuinfo.push slf
  else
    cpuinfo.push self
  end
  cpuinfo.push context.reg_content.dup
  cpuinfo.push context.stack_content.dup
  cpuinfo.push context.to_signature
  context.top_node.frame_struct_array.push [vretadd, cpuinfo]
  
  if context.options[:dump_context] then
    dump_context(context)
  end
  context
end

#gen_save_thepr(context) ⇒ Object



659
660
661
662
663
664
665
666
667
# File 'lib/ytljit/vm_codegen.rb', line 659

def gen_save_thepr(context)
  casm = context.assembler
  arenaaddr = context.top_node.get_local_arena_address
  casm.with_retry do
    casm.mov(TMPR, arenaaddr)
    casm.mov(INDIRECT_TMPR, THEPR)
  end
  context
end