Module: YTLJit::VM::Node::SendUtil
- Includes:
- AbsArch
- Included in:
- CApiCommonNode, SendCompareNode, SendDivNode, SendElementAssignNode, SendElementRefNode, SendMathFuncNode, SendMinusNode, SendMultNode, SendNode, SendPlusNode, 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
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
|
# File 'lib/ytljit/vm.rb', line 580
def compile_c_fixarg(context)
fnc = nil
numarg = @arguments.size - 2
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)
context.ret_node.decide_type_once(context.to_signature)
rtype = context.ret_node.type
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_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)
if !@type.boxed then
context = @type.to_box.gen_unboxing(context)
end
context
end
|
#compile_c_fixarg_raw(context) ⇒ Object
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
750
751
752
753
754
755
756
|
# File 'lib/ytljit/vm.rb', line 715
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_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
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
|
# File 'lib/ytljit/vm.rb', line 537
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, nil)
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_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
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
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
677
678
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
|
# File 'lib/ytljit/vm.rb', line 642
def compile_ytl(context)
fnc = nil
numarg = @arguments.size
context.start_arg_reg
context.start_arg_reg(FUNC_ARG_YTL)
context.cpustack_pushn(numarg * 8)
casm = context.assembler
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, nil)
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
495
496
497
498
499
500
501
502
503
504
505
506
|
# File 'lib/ytljit/vm.rb', line 495
def gen_eval_self(context)
slfnode = @arguments[2]
context = slfnode.compile(context)
context.ret_node.decide_type_once(context.to_signature)
rtype = context.ret_node.type
if !rtype.boxed then
context = rtype.gen_unboxing(context)
end
context
end
|
#signature(context, args = @arguments) ⇒ Object
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
|
# File 'lib/ytljit/vm.rb', line 508
def signature(context, args = @arguments)
res = []
cursig = context.to_signature
args[0].decide_type_once(cursig)
res.push args[0].type
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
args[1].decide_type_once(ynode.signature(context))
res.push args[1].type
context.pop_signature
else
args[1].decide_type_once(cursig)
res.push args[1].type
args[2].decide_type_once(cursig)
slf = args[2].type
end
res.push slf
args[3..-1].each do |ele|
ele.decide_type_once(cursig)
res.push ele.type
end
res
end
|