Module: YTLJit::VM::Node::SendUtil
- Includes:
- AbsArch
- Included in:
- CApiCommonNode, DirectBlockNode, SendAndNode, SendCompareNode, SendCountNode, SendDirnameNode, SendDivNode, SendElementAssignNode, SendElementRefNode, SendGtGtNode, SendLengthNode, SendLtLtNode, SendMathFuncNode, SendMinusNode, SendModNode, SendMultNode, SendNode, SendOpenNode, SendOrNode, SendPlusNode, SendReadNode, SendSizeNode, SendStripExNode, SendTrExNode, 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
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
|
# File 'lib/ytljit/vm.rb', line 796
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.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
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
|
# File 'lib/ytljit/vm.rb', line 968
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.ret_reg = RETR
context.set_reg_content(context.ret_reg, self)
decide_type_once(context.to_signature)
context
end
|
#compile_c_vararg(context) ⇒ Object
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
793
794
|
# File 'lib/ytljit/vm.rb', line 751
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, :argc)
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
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
888
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
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
|
# File 'lib/ytljit/vm.rb', line 859
def compile_ytl(context)
fnc = nil
numarg = @arguments.size
cursig = 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(cursig).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, :first_exception_entry)
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)
elsif @func.is_a?(DirectBlockNode) then
context = @arguments[0].compile(context)
casm.with_retry do
casm.mov(FUNC_ARG_YTL[0], context.ret_reg)
end
context.set_reg_content(FUNC_ARG_YTL[0].dst_opecode, context.ret_node)
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
tcontext.stack_content = []
@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
sig = @yield_signature_cache[cursig]
ecs = @arguments[1].code_space_from_signature[sig]
ecs ||= @arguments[1].code_space
entry = ecs.var_base_immidiate_address
casm.with_retry do
casm.mov(FUNC_ARG_YTL[1], entry)
end
context.set_reg_content(FUNC_ARG_YTL[1].dst_opecode, entry)
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_save_thepr(context)
context = gen_call(context, fnc, numarg)
context.cpustack_popn(numarg * 8)
context.end_arg_reg
context.end_arg_reg(FUNC_ARG_YTL)
context
end
|
#gen_eval_self(context) ⇒ Object
700
701
702
703
704
705
706
707
708
709
710
711
712
|
# File 'lib/ytljit/vm.rb', line 700
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
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
744
745
746
747
748
749
|
# File 'lib/ytljit/vm.rb', line 714
def signature(context, args = @arguments)
res = []
cursig = context.to_signature
if args[1].is_a?(BlockTopNode) then
res.push cursig[1]
else
res.push args[0].decide_type_once(cursig)
end
if @func.is_a?(YieldNode) then
res.push cursig[0]
else
res.push args[1].decide_type_once(cursig)
end
mt, slf = get_send_method_node(cursig)
res.push slf
args[3..-1].each do |ele|
if ele.type_list(cursig) == [[], []] then
res.push ele.type
else
ele.type = nil
res.push ele.decide_type_once(cursig)
end
end
if mt and args[1].is_a?(BlockTopNode) then
sig = @yield_signature_cache[cursig]
if sig then
args[1].type = nil
res[1] = args[1].decide_type_once(sig)
end
end
res
end
|