ytljit 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/extconf.rb +1 -1
- data/ext/memory.c +3 -3
- data/ext/ytljit.c +87 -48
- data/ext/ytljit.h +2 -0
- data/lib/ytljit/asm.rb +44 -8
- data/lib/ytljit/asmext.rb +1 -1
- data/lib/ytljit/asmext_x64.rb +18 -34
- data/lib/ytljit/asmext_x86.rb +15 -13
- data/lib/ytljit/asmutil.rb +4 -0
- data/lib/ytljit/instruction.rb +8 -1
- data/lib/ytljit/instruction_ia.rb +27 -16
- data/lib/ytljit/instruction_x64.rb +1 -3
- data/lib/ytljit/util.rb +29 -0
- data/lib/ytljit/vm.rb +464 -135
- data/lib/ytljit/vm_codegen.rb +111 -30
- data/lib/ytljit/vm_cruby_obj.rb +12 -10
- data/lib/ytljit/vm_inline_method.rb +32 -4
- data/lib/ytljit/vm_sendnode.rb +292 -38
- data/lib/ytljit/vm_trans.rb +221 -25
- data/lib/ytljit/vm_type.rb +6 -1
- data/lib/ytljit/vm_type_gen.rb +102 -20
- data/test/test_assemble2.rb +11 -8
- metadata +3 -3
data/lib/ytljit/vm_sendnode.rb
CHANGED
@@ -47,11 +47,16 @@ module YTLJit
|
|
47
47
|
|
48
48
|
@@current_node = nil
|
49
49
|
@@special_node_tab = {}
|
50
|
+
@@macro_tab = {}
|
50
51
|
|
51
52
|
def self.node
|
52
53
|
@@current_node
|
53
54
|
end
|
54
55
|
|
56
|
+
def self.get_macro_tab
|
57
|
+
@@macro_tab
|
58
|
+
end
|
59
|
+
|
55
60
|
def self.add_special_send_node(name)
|
56
61
|
oldcls = @@special_node_tab[name]
|
57
62
|
if oldcls == nil or self < oldcls then
|
@@ -63,6 +68,15 @@ module YTLJit
|
|
63
68
|
end
|
64
69
|
|
65
70
|
def self.make_send_node(parent, func, arguments, op_flag, seqno)
|
71
|
+
if mproc = @@macro_tab[func.name] then
|
72
|
+
args = []
|
73
|
+
arguments[3..-1].each do |ele|
|
74
|
+
args.push eval(ele.to_ruby(ToRubyContext.new).ret_code.last)
|
75
|
+
end
|
76
|
+
res = mproc.call(*args)
|
77
|
+
return res
|
78
|
+
end
|
79
|
+
|
66
80
|
spcl = @@special_node_tab[func.name]
|
67
81
|
newobj = nil
|
68
82
|
if spcl then
|
@@ -84,7 +98,6 @@ module YTLJit
|
|
84
98
|
@arguments = arguments
|
85
99
|
@opt_flag = op_flag
|
86
100
|
@seq_no = seqno
|
87
|
-
@var_return_address = nil
|
88
101
|
@next_node = @@current_node
|
89
102
|
@@current_node = self
|
90
103
|
|
@@ -101,7 +114,6 @@ module YTLJit
|
|
101
114
|
attr_accessor :func
|
102
115
|
attr_accessor :arguments
|
103
116
|
attr :opt_flag
|
104
|
-
attr :var_return_address
|
105
117
|
attr :next_node
|
106
118
|
attr :class_top
|
107
119
|
attr :frame_info
|
@@ -271,7 +283,7 @@ module YTLJit
|
|
271
283
|
context = super(context)
|
272
284
|
|
273
285
|
context.start_using_reg(TMPR2)
|
274
|
-
context.start_using_reg(
|
286
|
+
context.start_using_reg(PTMPR)
|
275
287
|
callconv = @func.calling_convention(context)
|
276
288
|
|
277
289
|
case callconv
|
@@ -281,8 +293,14 @@ module YTLJit
|
|
281
293
|
when :c_fixarg
|
282
294
|
context = compile_c_fixarg(context)
|
283
295
|
|
296
|
+
when :c_fixarg_raw
|
297
|
+
context = compile_c_fixarg_raw(context)
|
298
|
+
|
284
299
|
when :ytl
|
285
300
|
context = compile_ytl(context)
|
301
|
+
|
302
|
+
else
|
303
|
+
raise "Unsupported calling conversion #{callconv}"
|
286
304
|
end
|
287
305
|
|
288
306
|
decide_type_once(context.to_signature)
|
@@ -293,7 +311,7 @@ module YTLJit
|
|
293
311
|
context.ret_reg = RETR
|
294
312
|
end
|
295
313
|
context.ret_node = self
|
296
|
-
context.end_using_reg(
|
314
|
+
context.end_using_reg(PTMPR)
|
297
315
|
context.end_using_reg(TMPR2)
|
298
316
|
|
299
317
|
context = @body.compile(context)
|
@@ -382,12 +400,11 @@ module YTLJit
|
|
382
400
|
# type inference of @new method execute when "send" instruction.
|
383
401
|
context = @arguments[3].collect_candidate_type(context)
|
384
402
|
@arguments[3].decide_type_once(context.to_signature)
|
385
|
-
rrtype =
|
403
|
+
rrtype = ClassClassWrapper.instance(@arguments[3].type.ruby_type)
|
386
404
|
clsnode = ClassTopNode.get_class_top_node(rrtype)
|
387
405
|
clsnode.get_method_tab[@new_method.name] = @new_method
|
388
406
|
|
389
407
|
@body.collect_candidate_type(context)
|
390
|
-
context
|
391
408
|
end
|
392
409
|
|
393
410
|
def compile(context)
|
@@ -397,9 +414,16 @@ module YTLJit
|
|
397
414
|
context = @new_method.compile(context)
|
398
415
|
context.set_code_space(ocs)
|
399
416
|
|
417
|
+
context.ret_reg = 4 # nil
|
418
|
+
context.ret_node = self
|
419
|
+
|
400
420
|
context
|
401
421
|
end
|
402
422
|
end
|
423
|
+
|
424
|
+
class SendEvalNode<SendNode
|
425
|
+
add_special_send_node :eval
|
426
|
+
end
|
403
427
|
|
404
428
|
class SendAllocateNode<SendNode
|
405
429
|
add_special_send_node :allocate
|
@@ -434,7 +458,7 @@ module YTLJit
|
|
434
458
|
|
435
459
|
def compile(context)
|
436
460
|
context.start_using_reg(TMPR2)
|
437
|
-
context.start_using_reg(
|
461
|
+
context.start_using_reg(PTMPR)
|
438
462
|
callconv = @func.calling_convention(context)
|
439
463
|
|
440
464
|
case callconv
|
@@ -446,11 +470,19 @@ module YTLJit
|
|
446
470
|
|
447
471
|
when :ytl
|
448
472
|
context = compile_ytl(context)
|
473
|
+
|
474
|
+
else
|
475
|
+
raise "Unsupported calling conversion #{callconv}"
|
476
|
+
end
|
477
|
+
|
478
|
+
asm = context.assembler
|
479
|
+
asm.with_retry do
|
480
|
+
asm.mov(RETR, PTMPR)
|
449
481
|
end
|
450
482
|
|
451
|
-
context.ret_reg = RETR
|
483
|
+
context.ret_reg = RETR
|
452
484
|
context.ret_node = self
|
453
|
-
context.end_using_reg(
|
485
|
+
context.end_using_reg(PTMPR)
|
454
486
|
context.end_using_reg(TMPR2)
|
455
487
|
|
456
488
|
context = @body.compile(context)
|
@@ -475,6 +507,13 @@ module YTLJit
|
|
475
507
|
initfunc.set_reciever(init)
|
476
508
|
alloc.parent = init
|
477
509
|
@initmethod = init
|
510
|
+
@allocmethod = alloc
|
511
|
+
end
|
512
|
+
|
513
|
+
def debug_info=(val)
|
514
|
+
@initmethod.debug_info = val
|
515
|
+
@allocmethod.debug_info = val
|
516
|
+
@debug_info = val
|
478
517
|
end
|
479
518
|
|
480
519
|
def traverse_childlen
|
@@ -494,19 +533,32 @@ module YTLJit
|
|
494
533
|
when ConstantRefNode
|
495
534
|
context = @initmethod.collect_candidate_type(context)
|
496
535
|
clstop = slfnode.value_node
|
536
|
+
tt = nil
|
537
|
+
sig = context.to_signature
|
497
538
|
case clstop
|
498
539
|
when ClassTopNode
|
499
540
|
tt = RubyType::BaseType.from_ruby_class(clstop.klass_object)
|
500
|
-
add_type(
|
541
|
+
add_type(sig, tt)
|
501
542
|
|
502
543
|
when LiteralNode
|
503
544
|
tt = RubyType::BaseType.from_ruby_class(clstop.value)
|
504
|
-
add_type(
|
545
|
+
add_type(sig, tt)
|
505
546
|
|
506
547
|
else
|
507
548
|
raise "Unkown node type in constant #{slfnode.value_node.class}"
|
508
549
|
end
|
509
550
|
|
551
|
+
# set element type
|
552
|
+
if tt.ruby_type == Range then
|
553
|
+
tt.args = @arguments[3..-1]
|
554
|
+
add_element_node(sig, @arguments[3], [0], context)
|
555
|
+
end
|
556
|
+
|
557
|
+
if tt.ruby_type == Array then
|
558
|
+
@arguments[3..-1].each_with_index do |anode, idx|
|
559
|
+
add_element_node(sig, anode, [idx - 3], context)
|
560
|
+
end
|
561
|
+
end
|
510
562
|
else
|
511
563
|
raise "Unkonwn node type #{@arguments[2].class} "
|
512
564
|
end
|
@@ -519,7 +571,37 @@ module YTLJit
|
|
519
571
|
rtype = @arguments[2].type
|
520
572
|
rrtype = rtype.ruby_type
|
521
573
|
if rrtype.is_a?(Class) then
|
522
|
-
|
574
|
+
if !@is_escape and rrtype.to_s == '#<Class:Range>' then
|
575
|
+
context = gen_alloca(context, 3)
|
576
|
+
asm = context.assembler
|
577
|
+
breg = context.ret_reg
|
578
|
+
|
579
|
+
off = 0
|
580
|
+
[3, 4, 5].each do |no|
|
581
|
+
context = @arguments[no].compile(context)
|
582
|
+
dst = OpIndirect.new(breg, off)
|
583
|
+
asm.with_retry do
|
584
|
+
if context.ret_reg.is_a?(OpRegistor) then
|
585
|
+
asm.mov(dst, context.ret_reg)
|
586
|
+
else
|
587
|
+
asm.mov(TMPR, context.ret_reg)
|
588
|
+
asm.mov(dst, TMPR)
|
589
|
+
end
|
590
|
+
end
|
591
|
+
off = off + AsmType::MACHINE_WORD.size
|
592
|
+
end
|
593
|
+
|
594
|
+
context.ret_reg = breg
|
595
|
+
context.ret_node = self
|
596
|
+
context
|
597
|
+
|
598
|
+
elsif @initmethod.func.calling_convention(context) then
|
599
|
+
context = @initmethod.compile(context)
|
600
|
+
|
601
|
+
else
|
602
|
+
# initialize method not defined
|
603
|
+
context = @allocmethod.compile(context)
|
604
|
+
end
|
523
605
|
@body.compile(context)
|
524
606
|
else
|
525
607
|
super
|
@@ -536,8 +618,6 @@ module YTLJit
|
|
536
618
|
case [slf.ruby_type]
|
537
619
|
when [Fixnum], [Float], [String], [Array]
|
538
620
|
cursig = context.to_signature
|
539
|
-
same_type(@arguments[3], @arguments[2], cursig, cursig, context)
|
540
|
-
same_type(@arguments[2], @arguments[3], cursig, cursig, context)
|
541
621
|
same_type(self, @arguments[2], cursig, cursig, context)
|
542
622
|
same_type(@arguments[2], self, cursig, cursig, context)
|
543
623
|
end
|
@@ -577,8 +657,6 @@ module YTLJit
|
|
577
657
|
case [slf.ruby_type]
|
578
658
|
when [Fixnum], [Float], [Array]
|
579
659
|
cursig = context.to_signature
|
580
|
-
same_type(@arguments[3], @arguments[2], cursig, cursig, context)
|
581
|
-
same_type(@arguments[2], @arguments[3], cursig, cursig, context)
|
582
660
|
same_type(self, @arguments[2], cursig, cursig, context)
|
583
661
|
same_type(@arguments[2], self, cursig, cursig, context)
|
584
662
|
end
|
@@ -600,6 +678,7 @@ module YTLJit
|
|
600
678
|
elsif rrtype == Float then
|
601
679
|
context = gen_arithmetic_operation(context, :subsd, XMM4, XMM0)
|
602
680
|
else
|
681
|
+
p debug_info
|
603
682
|
raise "Unkown method #{rtype.ruby_type}##{@func.name}"
|
604
683
|
end
|
605
684
|
|
@@ -616,8 +695,6 @@ module YTLJit
|
|
616
695
|
cursig = context.to_signature
|
617
696
|
case [slf.ruby_type]
|
618
697
|
when [Fixnum], [Float]
|
619
|
-
same_type(@arguments[3], @arguments[2], cursig, cursig, context)
|
620
|
-
same_type(@arguments[2], @arguments[3], cursig, cursig, context)
|
621
698
|
same_type(self, @arguments[2], cursig, cursig, context)
|
622
699
|
same_type(@arguments[2], self, cursig, cursig, context)
|
623
700
|
|
@@ -651,6 +728,14 @@ module YTLJit
|
|
651
728
|
asm.imul(INDIRECT_SPR)
|
652
729
|
asm.add(SPR, AsmType::MACHINE_WORD.size)
|
653
730
|
end
|
731
|
+
elsif context.ret_reg.is_a?(OpImmidiateMachineWord) then
|
732
|
+
asm.with_retry do
|
733
|
+
asm.mov(TMPR, context.ret_reg)
|
734
|
+
asm.push(TMPR)
|
735
|
+
asm.mov(DBLLOR, TMPR2)
|
736
|
+
asm.imul(INDIRECT_SPR)
|
737
|
+
asm.add(SPR, AsmType::MACHINE_WORD.size)
|
738
|
+
end
|
654
739
|
else
|
655
740
|
asm.with_retry do
|
656
741
|
asm.mov(DBLLOR, TMPR2)
|
@@ -679,8 +764,6 @@ module YTLJit
|
|
679
764
|
case [slf.ruby_type]
|
680
765
|
when [Fixnum], [Float]
|
681
766
|
cursig = context.to_signature
|
682
|
-
same_type(@arguments[3], @arguments[2], cursig, cursig, context)
|
683
|
-
same_type(@arguments[2], @arguments[3], cursig, cursig, context)
|
684
767
|
same_type(self, @arguments[2], cursig, cursig, context)
|
685
768
|
same_type(@arguments[2], self, cursig, cursig, context)
|
686
769
|
end
|
@@ -709,6 +792,13 @@ module YTLJit
|
|
709
792
|
asm.cdq
|
710
793
|
asm.idiv(INDIRECT_SPR)
|
711
794
|
asm.add(SPR, AsmType::MACHINE_WORD.size)
|
795
|
+
elsif context.ret_reg.is_a?(OpImmidiateMachineWord) then
|
796
|
+
asm.mov(TMPR, context.ret_reg)
|
797
|
+
asm.push(TMPR)
|
798
|
+
asm.mov(DBLLOR, TMPR2)
|
799
|
+
asm.cdq
|
800
|
+
asm.idiv(INDIRECT_SPR)
|
801
|
+
asm.add(SPR, AsmType::MACHINE_WORD.size)
|
712
802
|
else
|
713
803
|
asm.mov(DBLLOR, TMPR2)
|
714
804
|
asm.cdq
|
@@ -823,28 +913,32 @@ module YTLJit
|
|
823
913
|
include SendUtil
|
824
914
|
add_special_send_node :[]
|
825
915
|
def collect_candidate_type_regident(context, slf)
|
916
|
+
sig = context.to_signature
|
826
917
|
case [slf.ruby_type]
|
827
918
|
when [Array]
|
828
919
|
fixtype = RubyType::BaseType.from_ruby_class(Fixnum)
|
829
|
-
sig = context.to_signature
|
830
920
|
@arguments[3].add_type(sig, fixtype)
|
831
|
-
@arguments[
|
921
|
+
cidx = @arguments[3].get_constant_value
|
922
|
+
@arguments[2].add_element_node(sig, self, cidx, context)
|
832
923
|
decide_type_once(sig)
|
833
924
|
@arguments[2].type = nil
|
834
925
|
@arguments[2].decide_type_once(sig)
|
835
926
|
epare = @arguments[2].element_node_list[0]
|
927
|
+
@arguments[2].element_node_list.each do |ele|
|
928
|
+
if ele[2] == cidx and ele[1] != self then
|
929
|
+
epare = ele
|
930
|
+
break
|
931
|
+
end
|
932
|
+
end
|
836
933
|
esig = epare[0]
|
837
934
|
enode = epare[1]
|
838
935
|
if enode != self then
|
839
936
|
same_type(self, enode, sig, esig, context)
|
840
|
-
same_type(enode, self, esig, sig, context)
|
841
937
|
end
|
842
938
|
|
843
939
|
when [Hash]
|
844
|
-
@arguments[
|
845
|
-
|
846
|
-
else
|
847
|
-
raise "Unkown type #{slf.ruby_type} in :[]"
|
940
|
+
cidx = @arguments[3].get_constant_value
|
941
|
+
@arguments[2].add_element_node(sig, self, cidx, context)
|
848
942
|
end
|
849
943
|
|
850
944
|
context
|
@@ -855,13 +949,14 @@ module YTLJit
|
|
855
949
|
include SendUtil
|
856
950
|
add_special_send_node :[]=
|
857
951
|
def collect_candidate_type_regident(context, slf)
|
952
|
+
sig = context.to_signature
|
858
953
|
case [slf.ruby_type]
|
859
954
|
when [Array]
|
860
955
|
fixtype = RubyType::BaseType.from_ruby_class(Fixnum)
|
861
|
-
sig = context.to_signature
|
862
956
|
val = @arguments[4]
|
863
957
|
@arguments[3].add_type(sig, fixtype)
|
864
|
-
@arguments[
|
958
|
+
cidx = @arguments[3].get_constant_value
|
959
|
+
@arguments[2].add_element_node(sig, val, cidx, context)
|
865
960
|
decide_type_once(sig)
|
866
961
|
@arguments[2].type = nil
|
867
962
|
@arguments[2].decide_type_once(sig)
|
@@ -874,7 +969,8 @@ module YTLJit
|
|
874
969
|
end
|
875
970
|
|
876
971
|
when [Hash]
|
877
|
-
@arguments[
|
972
|
+
cidx = @arguments[3].get_constant_value
|
973
|
+
@arguments[2].add_element_node(sig, self, cidx, context)
|
878
974
|
end
|
879
975
|
|
880
976
|
context
|
@@ -886,7 +982,6 @@ module YTLJit
|
|
886
982
|
def collect_candidate_type_regident(context, slf)
|
887
983
|
sig = context.to_signature
|
888
984
|
floattype = RubyType::BaseType.from_ruby_class(Float)
|
889
|
-
floattype = floattype.to_box
|
890
985
|
add_type(sig, floattype)
|
891
986
|
context
|
892
987
|
end
|
@@ -897,7 +992,6 @@ module YTLJit
|
|
897
992
|
def collect_candidate_type_regident(context, slf)
|
898
993
|
sig = context.to_signature
|
899
994
|
fixnumtype = RubyType::BaseType.from_ruby_class(Fixnum)
|
900
|
-
fixnumtype = fixnumtype.to_box
|
901
995
|
add_type(sig, fixnumtype)
|
902
996
|
context
|
903
997
|
end
|
@@ -910,6 +1004,39 @@ module YTLJit
|
|
910
1004
|
same_type(self, @arguments[2], sig, sig, context)
|
911
1005
|
context
|
912
1006
|
end
|
1007
|
+
|
1008
|
+
def compile(context)
|
1009
|
+
@arguments[2].decide_type_once(context.to_signature)
|
1010
|
+
rtype = @arguments[2].type
|
1011
|
+
rrtype = rtype.ruby_type
|
1012
|
+
if rtype.is_a?(RubyType::DefaultType0) or
|
1013
|
+
@class_top.search_method_with_super(@func.name, rrtype)[0] then
|
1014
|
+
return super(context)
|
1015
|
+
end
|
1016
|
+
|
1017
|
+
context = gen_eval_self(context)
|
1018
|
+
context = rtype.gen_unboxing(context)
|
1019
|
+
asm = context.assembler
|
1020
|
+
if rrtype == Fixnum then
|
1021
|
+
asm.with_retry do
|
1022
|
+
asm.mov(RETR, context.ret_reg)
|
1023
|
+
asm.neg(RETR)
|
1024
|
+
end
|
1025
|
+
context.ret_reg = RETR
|
1026
|
+
elsif rrtype == Float then
|
1027
|
+
context.start_using_reg(XMM4)
|
1028
|
+
asm.with_retry do
|
1029
|
+
asm.mov(XMM4, context.ret_reg)
|
1030
|
+
asm.subsd(XMM0, XMM0)
|
1031
|
+
asm.subsd(XMM0, XMM4)
|
1032
|
+
end
|
1033
|
+
context.ret_reg = XMM0
|
1034
|
+
context.end_using_reg(XMM4)
|
1035
|
+
end
|
1036
|
+
context.ret_node = self
|
1037
|
+
|
1038
|
+
@body.compile(context)
|
1039
|
+
end
|
913
1040
|
end
|
914
1041
|
|
915
1042
|
class SendRandNode<SendNode
|
@@ -922,6 +1049,91 @@ module YTLJit
|
|
922
1049
|
end
|
923
1050
|
end
|
924
1051
|
|
1052
|
+
class SendRangeAccessNode<SendNode
|
1053
|
+
include AbsArch
|
1054
|
+
|
1055
|
+
def collect_candidate_type_regident(context, slf)
|
1056
|
+
cursig = context.to_signature
|
1057
|
+
if slf.ruby_type == Range then
|
1058
|
+
epare = @arguments[2].element_node_list[0]
|
1059
|
+
esig = epare[0]
|
1060
|
+
enode = epare[1]
|
1061
|
+
tt = enode.decide_type_once(esig)
|
1062
|
+
add_type(cursig, tt)
|
1063
|
+
else
|
1064
|
+
super
|
1065
|
+
end
|
1066
|
+
|
1067
|
+
context
|
1068
|
+
end
|
1069
|
+
|
1070
|
+
def compile(context)
|
1071
|
+
rtype = @arguments[2].decide_type_once(context.to_signature)
|
1072
|
+
rrtype = rtype.ruby_type
|
1073
|
+
if rrtype == Range and !rtype.boxed then
|
1074
|
+
context = @arguments[2].compile(context)
|
1075
|
+
slotoff = OpIndirect.new(TMPR, arg_offset)
|
1076
|
+
asm = context.assembler
|
1077
|
+
asm.with_retry do
|
1078
|
+
asm.mov(TMPR, context.ret_reg)
|
1079
|
+
asm.mov(RETR, slotoff)
|
1080
|
+
end
|
1081
|
+
|
1082
|
+
context.ret_reg = RETR
|
1083
|
+
context.ret_node = self
|
1084
|
+
|
1085
|
+
context
|
1086
|
+
else
|
1087
|
+
super(context)
|
1088
|
+
end
|
1089
|
+
end
|
1090
|
+
end
|
1091
|
+
|
1092
|
+
class SendFirstNode<SendRangeAccessNode
|
1093
|
+
add_special_send_node :first
|
1094
|
+
def arg_offset
|
1095
|
+
0
|
1096
|
+
end
|
1097
|
+
end
|
1098
|
+
|
1099
|
+
class SendLastNode<SendRangeAccessNode
|
1100
|
+
add_special_send_node :last
|
1101
|
+
def arg_offset
|
1102
|
+
AsmType::MACHINE_WORD.size
|
1103
|
+
end
|
1104
|
+
end
|
1105
|
+
|
1106
|
+
class SendExcludeEndNode<SendRangeAccessNode
|
1107
|
+
add_special_send_node :exclude_end?
|
1108
|
+
def collect_candidate_type_regident(context, slf)
|
1109
|
+
cursig = context.to_signature
|
1110
|
+
if slf.ruby_type == Range then
|
1111
|
+
tt = RubyType::BaseType.from_ruby_class(TrueClass)
|
1112
|
+
add_type(cursig, tt)
|
1113
|
+
tt = RubyType::BaseType.from_ruby_class(FalseClass)
|
1114
|
+
add_type(cursig, tt)
|
1115
|
+
else
|
1116
|
+
super
|
1117
|
+
end
|
1118
|
+
|
1119
|
+
context
|
1120
|
+
end
|
1121
|
+
|
1122
|
+
def arg_offset
|
1123
|
+
AsmType::MACHINE_WORD.size * 2
|
1124
|
+
end
|
1125
|
+
end
|
1126
|
+
|
1127
|
+
class SendSizeNode<SendNode
|
1128
|
+
add_special_send_node :size
|
1129
|
+
def collect_candidate_type_regident(context, slf)
|
1130
|
+
cursig = context.to_signature
|
1131
|
+
tt = RubyType::BaseType.from_ruby_class(Fixnum)
|
1132
|
+
add_type(cursig, tt)
|
1133
|
+
context
|
1134
|
+
end
|
1135
|
+
end
|
1136
|
+
|
925
1137
|
class SendSameArgTypeNode<SendNode
|
926
1138
|
def collect_candidate_type_regident(context, slf)
|
927
1139
|
sig = context.to_signature
|
@@ -945,16 +1157,22 @@ module YTLJit
|
|
945
1157
|
|
946
1158
|
def compile_call_func(context, fname)
|
947
1159
|
fadd = OpMemAddress.new(address_of(fname))
|
948
|
-
context.
|
1160
|
+
context.start_arg_reg(FUNC_FLOAT_ARG)
|
1161
|
+
context.start_arg_reg
|
949
1162
|
asm = context.assembler
|
950
1163
|
asm.with_retry do
|
951
1164
|
asm.mov(FUNC_FLOAT_ARG[0], context.ret_reg)
|
1165
|
+
end
|
1166
|
+
context.set_reg_content(FUNC_FLOAT_ARG[0].dst_opecode,
|
1167
|
+
context.ret_node)
|
1168
|
+
asm.with_retry do
|
952
1169
|
asm.call_with_arg(fadd, 1)
|
953
1170
|
asm.sub(SPR, 8)
|
954
1171
|
asm.fstpl(INDIRECT_SPR)
|
955
1172
|
asm.pop(XMM0)
|
956
1173
|
end
|
957
|
-
context.
|
1174
|
+
context.end_arg_reg
|
1175
|
+
context.end_arg_reg(FUNC_FLOAT_ARG)
|
958
1176
|
context
|
959
1177
|
end
|
960
1178
|
|
@@ -976,7 +1194,7 @@ module YTLJit
|
|
976
1194
|
end
|
977
1195
|
end
|
978
1196
|
|
979
|
-
class SendSqrtNode
|
1197
|
+
class SendSqrtNode<SendMathFuncNode
|
980
1198
|
add_special_send_node :sqrt
|
981
1199
|
def compile_main(context)
|
982
1200
|
context = compile_call_func(context, "sqrt")
|
@@ -986,7 +1204,7 @@ module YTLJit
|
|
986
1204
|
end
|
987
1205
|
end
|
988
1206
|
|
989
|
-
class SendSinNode
|
1207
|
+
class SendSinNode<SendMathFuncNode
|
990
1208
|
add_special_send_node :sin
|
991
1209
|
def compile_main(context)
|
992
1210
|
context = compile_call_func(context, "sin")
|
@@ -996,7 +1214,7 @@ module YTLJit
|
|
996
1214
|
end
|
997
1215
|
end
|
998
1216
|
|
999
|
-
class SendCosNode
|
1217
|
+
class SendCosNode<SendMathFuncNode
|
1000
1218
|
add_special_send_node :cos
|
1001
1219
|
def compile_main(context)
|
1002
1220
|
context = compile_call_func(context, "cos")
|
@@ -1006,7 +1224,7 @@ module YTLJit
|
|
1006
1224
|
end
|
1007
1225
|
end
|
1008
1226
|
|
1009
|
-
class SendTanNode
|
1227
|
+
class SendTanNode<SendMathFuncNode
|
1010
1228
|
add_special_send_node :tan
|
1011
1229
|
def compile_main(context)
|
1012
1230
|
context = compile_call_func(context, "tan")
|
@@ -1015,6 +1233,42 @@ module YTLJit
|
|
1015
1233
|
context
|
1016
1234
|
end
|
1017
1235
|
end
|
1236
|
+
|
1237
|
+
class RawSendNode<SendNode
|
1238
|
+
def collect_candidate_type(context)
|
1239
|
+
@arguments.each do |arg|
|
1240
|
+
context = arg.collect_candidate_type(context)
|
1241
|
+
end
|
1242
|
+
|
1243
|
+
context = collect_candidate_type_body(context)
|
1244
|
+
|
1245
|
+
@body.collect_candidate_type(context)
|
1246
|
+
end
|
1247
|
+
end
|
1248
|
+
|
1249
|
+
class RetStringSendNode<RawSendNode
|
1250
|
+
def collect_candidate_type_body(context)
|
1251
|
+
sig = context.to_signature
|
1252
|
+
tt = RubyType::BaseType.from_ruby_class(String)
|
1253
|
+
add_type(sig, tt)
|
1254
|
+
|
1255
|
+
context
|
1256
|
+
end
|
1257
|
+
end
|
1258
|
+
|
1259
|
+
class RetArraySendNode<RawSendNode
|
1260
|
+
def collect_candidate_type_body(context)
|
1261
|
+
sig = context.to_signature
|
1262
|
+
tt = RubyType::BaseType.from_ruby_class(Array)
|
1263
|
+
add_type(sig, tt)
|
1264
|
+
|
1265
|
+
@arguments[1..-1].each_with_index do |anode, idx|
|
1266
|
+
add_element_node(sig, anode, [idx], context)
|
1267
|
+
end
|
1268
|
+
|
1269
|
+
context
|
1270
|
+
end
|
1271
|
+
end
|
1018
1272
|
end
|
1019
1273
|
end
|
1020
1274
|
end
|