Module: YTLJit::VM::Node::SendUtil
- Includes:
- AbsArch
- Included in:
- CApiCommonNode, SendAndNode, SendCompareNode, SendDivNode, SendElementAssignNode, SendElementRefNode, SendGtGtNode, SendLengthNode, SendLtLtNode, SendMathFuncNode, SendMinusNode, SendModNode, SendMultNode, SendNode, SendOrNode, SendPlusNode, SendXorNode, YieldNode
- Defined in:
- lib/ytljit/vm.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
Instance Method Details
#compile_c_fixarg(context) ⇒ Object
724
725
726
727
728
729
730
731
732
733
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
|
# File 'lib/ytljit/vm.rb', line 724
def compile_c_fixarg(context)
fnc = nil
numarg = @arguments.size - 2
sig = context.to_signature
context.start_arg_reg
context.cpustack_pushn(numarg * AsmType::MACHINE_WORD.size)
argpos = 0
cursrc = 0
@arguments.each do |arg|
if cursrc < 2 then
cursrc = cursrc + 1
next
end
if cursrc == 2 then
context = @func.compile(context)
fnc = context.ret_reg
casm = context.assembler
casm.with_retry do
casm.mov(FUNC_ARG[0], context.ret_reg2)
end
context.set_reg_content(FUNC_ARG[0].dst_opecode,
context.ret_node)
else
context = arg.compile(context)
rnode = context.ret_node
rtype = rnode.decide_type_once(sig)
context = rtype.gen_boxing(context)
casm = context.assembler
casm.with_retry do
casm.mov(FUNC_ARG[argpos], context.ret_reg)
end
context.set_reg_content(FUNC_ARG[argpos].dst_opecode,
context.ret_node)
end
argpos = argpos + 1
cursrc = cursrc + 1
end
context = gen_save_thepr(context)
context = gen_call(context, fnc, numarg)
context.cpustack_popn(numarg * AsmType::MACHINE_WORD.size)
context.end_arg_reg
context.end_using_reg(fnc)
context.ret_reg = RETR
context.set_reg_content(context.ret_reg, self)
decide_type_once(sig)
if !@type.boxed then
context = @type.to_box.gen_unboxing(context)
end
context
end
|
#compile_c_fixarg_raw(context) ⇒ Object
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
|
# File 'lib/ytljit/vm.rb', line 889
def compile_c_fixarg_raw(context)
context = @func.compile(context)
fnc = context.ret_reg
numarg = @arguments.size
context.start_arg_reg
context.cpustack_pushn(numarg * AsmType::MACHINE_WORD.size)
@arguments.each_with_index do |arg, argpos|
context = arg.compile(context)
rtype = context.ret_node.decide_type_once(context.to_signature)
atype = @func.arg_type[argpos]
if atype == :"..." or atype == nil then
if @func.arg_type.last == :"..." then
atype = @func.arg_type[-2]
end
end
if atype == :VALUE then
context = rtype.gen_boxing(context)
end
casm = context.assembler
casm.with_retry do
casm.mov(FUNC_ARG[argpos], context.ret_reg)
end
context.set_reg_content(FUNC_ARG[argpos].dst_opecode,
context.ret_node)
end
context = gen_save_thepr(context)
context = gen_call(context, fnc, numarg)
context.cpustack_popn(numarg * AsmType::MACHINE_WORD.size)
context.end_arg_reg
context.end_using_reg(fnc)
context.ret_reg = RETR
context.set_reg_content(context.ret_reg, self)
decide_type_once(context.to_signature)
context
end
|
#compile_c_vararg(context) ⇒ Object
679
680
681
682
683
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
|
# File 'lib/ytljit/vm.rb', line 679
def compile_c_vararg(context)
fnc = nil
context.start_using_reg(TMPR2)
context = gen_make_argv(context) do |context, rarg|
context.start_arg_reg
context.cpustack_pushn(3 * AsmType::MACHINE_WORD.size)
casm = context.assembler
casm.with_retry do
casm.mov(FUNC_ARG[0], rarg.size) casm.mov(FUNC_ARG[1], TMPR2) end
context.set_reg_content(FUNC_ARG[0].dst_opecode, true)
context.set_reg_content(FUNC_ARG[1].dst_opecode, TMPR2)
context = @func.compile(context)
fnc = context.ret_reg
casm.with_retry do
casm.mov(FUNC_ARG[2], context.ret_reg2) end
context.set_reg_content(FUNC_ARG[2].dst_opecode, context.ret_node)
context = gen_save_thepr(context)
context = gen_call(context, fnc, 3)
context.cpustack_popn(3 * AsmType::MACHINE_WORD.size)
context.end_arg_reg
context.end_using_reg(TMPR2)
context.ret_reg = RETR
context.set_reg_content(context.ret_reg, self)
context.ret_node = self
@type = nil
decide_type_once(context.to_signature)
if !@type.boxed then
context = @type.to_box.gen_unboxing(context)
end
context
end
end
|
#compile_ytl(context) ⇒ Object
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
|
# File 'lib/ytljit/vm.rb', line 790
def compile_ytl(context)
fnc = nil
numarg = @arguments.size
sig = context.to_signature
context.start_arg_reg
context.start_arg_reg(FUNC_ARG_YTL)
context.cpustack_pushn(numarg * 8)
casm = context.assembler
fstentry = nil
if @current_exception_table then
[:ensure].each do |kind|
ent = nil
if entbase = @current_exception_table[kind] then
ent = entbase[3]
end
if ent then
csadd = ent.get_code_space(sig).var_base_immidiate_address
else
csadd = TopTopNode.get_nothing_proc.var_base_immidiate_address
end
entry = casm.add_value_entry(csadd)
fstentry ||= entry.to_immidiate
end
handoff = OpIndirect.new(BPR, AsmType::MACHINE_WORD.size * 2)
casm.with_retry do
casm.mov(TMPR, fstentry)
casm.mov(handoff, TMPR)
end
context.set_reg_content(handoff, true)
end
if @func.is_a?(YieldNode) then
prevenv = @frame_info.offset_arg(0, BPR)
casm.with_retry do
casm.mov(TMPR, prevenv)
casm.mov(FUNC_ARG_YTL[0], TMPR)
end
context.set_reg_content(FUNC_ARG_YTL[0].dst_opecode, prevenv)
else
casm.with_retry do
casm.mov(FUNC_ARG_YTL[0], BPR)
end
context.set_reg_content(FUNC_ARG_YTL[0].dst_opecode, BPR)
end
tcontext = context.dup
tcontext.prev_context = context
@arguments[1].compile(tcontext)
casm = context.assembler
@arguments[3..-1].each_with_index do |arg, i|
context = arg.compile(context)
casm = context.assembler
casm.with_retry do
casm.mov(FUNC_ARG_YTL[i + 3], context.ret_reg)
end
context.set_reg_content(FUNC_ARG_YTL[i + 3].dst_opecode,
context.ret_node)
end
casm.with_retry do
entry = @arguments[1].code_space.var_base_immidiate_address
casm.mov(FUNC_ARG_YTL[1], entry)
end
context.set_reg_content(FUNC_ARG_YTL[1].dst_opecode, true)
context = @func.compile(context)
fnc = context.ret_reg
casm = context.assembler
casm.with_retry do
casm.mov(FUNC_ARG_YTL[2], context.ret_reg2)
end
context.set_reg_content(FUNC_ARG_YTL[2].dst_opecode, @arguments[2])
context = gen_call(context, fnc, numarg)
context.cpustack_popn(numarg * 8)
context.end_arg_reg
context.end_arg_reg(FUNC_ARG_YTL)
context.end_using_reg(fnc)
context
end
|
#gen_eval_self(context) ⇒ Object
638
639
640
641
642
643
644
645
646
647
648
649
650
|
# File 'lib/ytljit/vm.rb', line 638
def gen_eval_self(context)
slfnode = @arguments[2]
context = slfnode.compile(context)
rnode = context.ret_node
rtype = rnode.decide_type_once(context.to_signature)
if !rtype.boxed then
context = rtype.gen_unboxing(context)
end
context
end
|
#signature(context, args = @arguments) ⇒ Object
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
677
|
# File 'lib/ytljit/vm.rb', line 652
def signature(context, args = @arguments)
res = []
cursig = context.to_signature
res.push args[0].decide_type_once(cursig)
mt, slf = get_send_method_node(cursig)
if mt and (ynode = mt.yield_node[0]) then
context.push_signature(args, mt)
args[1].type = nil
res.push args[1].decide_type_once(ynode.signature(context))
context.pop_signature
else
res.push args[1].decide_type_once(cursig)
slf = args[2].decide_type_once(cursig)
end
res.push slf
args[3..-1].each do |ele|
res.push ele.decide_type_once(cursig)
end
res
end
|