ytljit 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/ytljit/vm.rb CHANGED
@@ -131,16 +131,16 @@ LocalVarNode
131
131
  attr_accessor :type
132
132
  attr_accessor :element_node_list
133
133
 
134
- def add_type(key, type)
135
- @type_list.add_type(key, type)
134
+ def add_type(sig, type)
135
+ @type_list.add_type(sig, type)
136
136
  end
137
137
 
138
- def type_list(key)
139
- @type_list.type_list(key).value
138
+ def type_list(sig)
139
+ @type_list.type_list(sig).value
140
140
  end
141
141
 
142
- def set_type_list(key, val)
143
- @type_list.type_list(key).value = val
142
+ def set_type_list(sig, val)
143
+ @type_list.type_list(sig).value = val
144
144
  end
145
145
 
146
146
  def collect_info(context)
@@ -153,22 +153,22 @@ LocalVarNode
153
153
  context
154
154
  end
155
155
 
156
- def ti_add_observer(dst, dkey, skey, context)
156
+ def ti_add_observer(dst, dsig, ssig, context)
157
157
  if @ti_observer[dst] == nil then
158
158
  @ti_observer[dst] = []
159
159
  end
160
160
 
161
- if @ti_observer[dst].all? {|edkey, eskey, eprc|
162
- (edkey != dkey) or (eskey != skey)
161
+ if @ti_observer[dst].all? {|edsig, essig, eprc|
162
+ (edsig != dsig) or (essig != ssig)
163
163
  } then
164
- prc = lambda { send(:ti_update, dst, self, dkey, skey, context) }
165
- @ti_observer[dst].push [dkey, skey, prc]
164
+ prc = lambda { send(:ti_update, dst, self, dsig, ssig, context) }
165
+ @ti_observer[dst].push [dsig, ssig, prc]
166
166
  end
167
167
  end
168
168
 
169
169
  def ti_changed
170
170
  @ti_observer.each do |rec, lst|
171
- lst.each do |dkey, skey, prc|
171
+ lst.each do |dsig, ssig, prc|
172
172
  prc.call
173
173
  end
174
174
  end
@@ -185,17 +185,17 @@ LocalVarNode
185
185
  res
186
186
  end
187
187
 
188
- def ti_update(dst, src, dkey, skey, context)
189
- dtlist = dst.type_list(dkey)
190
- stlist = src.type_list(skey)
188
+ def ti_update(dst, src, dsig, ssig, context)
189
+ dtlist = dst.type_list(dsig)
190
+ stlist = src.type_list(ssig)
191
191
  =begin
192
- print dkey.map(&:ruby_type), "\n"
192
+ print dsig.map(&:ruby_type), "\n"
193
193
  print dtlist.map(&:ruby_type), "\n"
194
194
  print stlist.map(&:ruby_type), "\n"
195
195
  =end
196
196
  orgsize = dtlist.size
197
197
  # p "#{dst.class} #{src.class} #{dtlist} #{stlist}"
198
- dst.set_type_list(dkey, merge_type(dtlist, stlist))
198
+ dst.set_type_list(dsig, merge_type(dtlist, stlist))
199
199
 
200
200
  if orgsize != dtlist.size then
201
201
  dst.type = nil
@@ -213,7 +213,7 @@ LocalVarNode
213
213
  end
214
214
  end
215
215
 
216
- def same_type(dst, src, dkey, skey, context)
216
+ def same_type(dst, src, dsig, ssig, context)
217
217
  =begin
218
218
  print "#{src.class} -> #{dst.class} \n"
219
219
  if dst.is_a?(LocalVarNode) then
@@ -225,20 +225,20 @@ LocalVarNode
225
225
  =end
226
226
 
227
227
  if dst.is_a?(BaseNode) then
228
- src.ti_add_observer(dst, dkey, skey, context)
228
+ src.ti_add_observer(dst, dsig, ssig, context)
229
229
  end
230
230
 
231
- ti_update(dst, src, dkey, skey, context)
231
+ ti_update(dst, src, dsig, ssig, context)
232
232
  end
233
233
 
234
- def add_element_node(key, type, context)
234
+ def add_element_node(sig, enode, context)
235
235
  slfetnode = @element_node_list
236
- unless slfetnode.include?(type)
237
- @element_node_list.push [key, type]
238
- orgkey = @element_node_list[0][0]
239
- orgtype = @element_node_list[0][1]
240
- if orgtype != type then
241
- same_type(orgtype, type, orgkey, key, context)
236
+ unless slfetnode.include?(enode)
237
+ @element_node_list.push [sig, enode]
238
+ orgsig = @element_node_list[0][0]
239
+ orgnode = @element_node_list[0][1]
240
+ if orgnode != enode then
241
+ same_type(orgnode, enode, orgsig, sig, context)
242
242
  end
243
243
  ti_changed
244
244
  # context.convergent = false
@@ -258,9 +258,9 @@ LocalVarNode
258
258
 
259
259
  when 1
260
260
  if tlist[0].have_element? then
261
- key = @element_node_list[0][0]
261
+ sig = @element_node_list[0][0]
262
262
  node = @element_node_list[0][1]
263
- node.decide_type_once(key)
263
+ node.decide_type_once(sig)
264
264
  tlist[0].element_type = node.type
265
265
  end
266
266
  tlist[0]
@@ -271,19 +271,19 @@ LocalVarNode
271
271
  end
272
272
  end
273
273
 
274
- def decide_type_once(key)
274
+ def decide_type_once(sig)
275
275
  if @type.equal?(nil) # or @type.is_a?(RubyType::DefaultType0) then
276
- tlist = @type_list.type_list(key).value
276
+ tlist = @type_list.type_list(sig).value
277
277
  @type = decide_type_core(tlist)
278
278
  end
279
279
  end
280
280
 
281
- def decide_type(key)
282
- decide_type_once(key)
281
+ def decide_type(sig)
282
+ decide_type_once(sig)
283
283
 
284
284
  if is_a?(HaveChildlenMixin) then
285
285
  traverse_childlen {|rec|
286
- rec.decide_type(key)
286
+ rec.decide_type(sig)
287
287
  }
288
288
  end
289
289
  end
@@ -362,11 +362,14 @@ LocalVarNode
362
362
  end
363
363
 
364
364
  module SendUtil
365
+ include AbsArch
366
+
365
367
  def gen_eval_self(context)
366
368
  # eval 1st arg(self)
367
369
  slfnode = @arguments[2]
368
370
  context = slfnode.compile(context)
369
371
 
372
+ context.ret_node.decide_type_once(context.to_signature)
370
373
  rtype = context.ret_node.type
371
374
  rtype.gen_unboxing(context)
372
375
  end
@@ -374,12 +377,175 @@ LocalVarNode
374
377
  def signature(context)
375
378
  res = []
376
379
  @arguments.each do |ele|
377
- ele.decide_type_once(context.to_key)
380
+ ele.decide_type_once(context.to_signature)
378
381
  res.push ele.type
379
382
  end
380
383
 
381
384
  res
382
385
  end
386
+
387
+ def compile_c_vararg(context)
388
+ fnc = nil
389
+ context.start_using_reg(TMPR2)
390
+
391
+ context = gen_make_argv(context) do |context, rarg|
392
+ context.start_using_reg(FUNC_ARG[0])
393
+ context.start_using_reg(FUNC_ARG[1])
394
+ context.start_using_reg(FUNC_ARG[2])
395
+
396
+ context.cpustack_pushn(3 * AsmType::MACHINE_WORD.size)
397
+ casm = context.assembler
398
+ # Method Select
399
+ # it is legal. use TMPR2 for method select
400
+ # use TMPR3 for store self
401
+ context = @func.compile(context)
402
+ fnc = context.ret_reg
403
+ casm.with_retry do
404
+ casm.mov(FUNC_ARG[0], rarg.size) # argc
405
+ casm.mov(FUNC_ARG[1], TMPR2) # argv
406
+ casm.mov(FUNC_ARG[2], TMPR3) # self
407
+ end
408
+ context.set_reg_content(FUNC_ARG[0], nil)
409
+ context.set_reg_content(FUNC_ARG[1], TMPR2)
410
+ context.set_reg_content(FUNC_ARG[2], context.ret_node)
411
+
412
+ context = gen_call(context, fnc, 3)
413
+ context.cpustack_popn(3 * AsmType::MACHINE_WORD.size)
414
+
415
+ context.end_using_reg(FUNC_ARG[2])
416
+ context.end_using_reg(FUNC_ARG[1])
417
+ context.end_using_reg(FUNC_ARG[0])
418
+ context.end_using_reg(TMPR2)
419
+ context.ret_reg = RETR
420
+ context.ret_node = self
421
+
422
+ decide_type_once(context.to_signature)
423
+ context = @type.to_box.gen_unboxing(context)
424
+
425
+ context
426
+ end
427
+ end
428
+
429
+ def compile_c_fixarg(context)
430
+ fnc = nil
431
+ numarg = @arguments.size - 2
432
+
433
+ numarg.times do |i|
434
+ context.start_using_reg(FUNC_ARG[i])
435
+ end
436
+ context.cpustack_pushn(numarg * AsmType::MACHINE_WORD.size)
437
+
438
+ argpos = 0
439
+ cursrc = 0
440
+ @arguments.each do |arg|
441
+ # skip prevenv and block_argument
442
+ if cursrc < 2 then
443
+ cursrc = cursrc + 1
444
+ next
445
+ end
446
+
447
+ if cursrc == 2 then
448
+ # Self
449
+ # Method Select
450
+ # it is legal. use TMPR2 for method select
451
+ # use TMPR3 for store self
452
+ context = @func.compile(context)
453
+ fnc = context.ret_reg
454
+ casm = context.assembler
455
+ casm.with_retry do
456
+ casm.mov(FUNC_ARG[0], TMPR3)
457
+ end
458
+ context.set_reg_content(FUNC_ARG[0], context.ret_node)
459
+ else
460
+ # other arg.
461
+ context = arg.compile(context)
462
+ context.ret_node.decide_type_once(context.to_signature)
463
+ rtype = context.ret_node.type
464
+ context = rtype.gen_boxing(context)
465
+ casm = context.assembler
466
+ casm.with_retry do
467
+ casm.mov(FUNC_ARG[argpos], context.ret_reg)
468
+ end
469
+ context.set_reg_content(FUNC_ARG[argpos], context.ret_node)
470
+ end
471
+ argpos = argpos + 1
472
+ cursrc = cursrc + 1
473
+ end
474
+
475
+ context = gen_call(context, fnc, numarg)
476
+
477
+ context.cpustack_popn(numarg * AsmType::MACHINE_WORD.size)
478
+ numarg.times do |i|
479
+ context.end_using_reg(FUNC_ARG[numarg - i - 1])
480
+ end
481
+ context.end_using_reg(fnc)
482
+
483
+ decide_type_once(context.to_signature)
484
+ @type.to_box.gen_unboxing(context)
485
+ end
486
+
487
+ def compile_ytl(context)
488
+ fnc = nil
489
+ numarg = @arguments.size
490
+
491
+ numarg.times do |i|
492
+ context.start_using_reg(FUNC_ARG_YTL[i])
493
+ end
494
+ context.cpustack_pushn(numarg * 8)
495
+
496
+ # push prev env
497
+ casm = context.assembler
498
+ casm.with_retry do
499
+ casm.mov(FUNC_ARG_YTL[0], BPR)
500
+ end
501
+ context.set_reg_content(FUNC_ARG_YTL[0], BPR)
502
+
503
+ # block
504
+ # eval block
505
+ # local block
506
+
507
+ # compile block with other code space and context
508
+ tcontext = context.dup
509
+ @arguments[1].compile(tcontext)
510
+
511
+ casm = context.assembler
512
+ casm.with_retry do
513
+ entry = @arguments[1].code_space.var_base_immidiate_address
514
+ casm.mov(FUNC_ARG_YTL[1], entry)
515
+ end
516
+ context.set_reg_content(FUNC_ARG_YTL[1], nil)
517
+
518
+ # other arguments
519
+ @arguments[3..-1].each_with_index do |arg, i|
520
+ context = arg.compile(context)
521
+ casm = context.assembler
522
+ casm.with_retry do
523
+ casm.mov(FUNC_ARG_YTL[i + 3], context.ret_reg)
524
+ end
525
+ context.set_reg_content(FUNC_ARG_YTL[i + 3], context.ret_node)
526
+ end
527
+
528
+ # self
529
+ # Method Select
530
+ # it is legal. use TMPR2 for method select
531
+ # use TMPR3 for store self
532
+ context = @func.compile(context)
533
+ fnc = context.ret_reg
534
+ casm = context.assembler
535
+ casm.with_retry do
536
+ casm.mov(FUNC_ARG_YTL[2], TMPR3)
537
+ end
538
+ context.set_reg_content(FUNC_ARG_YTL[2], @arguments[2])
539
+
540
+ context = gen_call(context, fnc, numarg)
541
+
542
+ context.cpustack_popn(numarg * 8)
543
+ numarg.size.times do |i|
544
+ context.end_using_reg(FUNC_ARG_YTL[numarg - i])
545
+ end
546
+ context.end_using_reg(fnc)
547
+ context
548
+ end
383
549
  end
384
550
 
385
551
  class DummyNode
@@ -427,8 +593,8 @@ LocalVarNode
427
593
  end
428
594
 
429
595
  def find_cs_by_signature(sig)
430
- @code_spaces.each do |key, val|
431
- if key == sig then
596
+ @code_spaces.each do |csig, val|
597
+ if csig == sig then
432
598
  return val
433
599
  end
434
600
  end
@@ -490,8 +656,6 @@ LocalVarNode
490
656
  end
491
657
 
492
658
  def collect_info(context)
493
- context.modified_local_var.push Hash.new
494
- context.modified_instance_var = {}
495
659
  context.yield_node.push []
496
660
  @body.collect_info(context)
497
661
  @yield_node = context.yield_node.pop
@@ -509,8 +673,10 @@ LocalVarNode
509
673
  context.current_method_signature_node.push signode
510
674
  context = @body.collect_candidate_type(context)
511
675
  @end_nodes.each do |enode|
512
- same_type(self, enode, context.to_key, context.to_key, context)
513
- same_type(enode, self, context.to_key, context.to_key, context)
676
+ same_type(self, enode,
677
+ context.to_signature, context.to_signature, context)
678
+ same_type(enode, self,
679
+ context.to_signature, context.to_signature, context)
514
680
  end
515
681
  context.current_method_signature_node.pop
516
682
  context
@@ -545,6 +711,8 @@ LocalVarNode
545
711
  if context.options[:disp_signature] then
546
712
  disp_signature
547
713
  end
714
+
715
+ context.ret_node = self
548
716
  context
549
717
  end
550
718
  end
@@ -553,6 +721,13 @@ LocalVarNode
553
721
  class MethodTopNode<TopNode
554
722
  include MethodTopCodeGen
555
723
 
724
+ def collect_info(context)
725
+ context.modified_local_var.push [{}]
726
+ context = super
727
+ context.modified_local_var.pop
728
+ context
729
+ end
730
+
556
731
  def construct_frame_info(locals, argnum)
557
732
  locals.unshift :_self
558
733
  locals.unshift :_block
@@ -563,6 +738,13 @@ LocalVarNode
563
738
  end
564
739
 
565
740
  class BlockTopNode<MethodTopNode
741
+ def collect_info(context)
742
+ context.modified_local_var.last.push Hash.new
743
+ context = super
744
+ context.modified_local_var.last.pop
745
+ context
746
+ end
747
+
566
748
  include MethodTopCodeGen
567
749
  end
568
750
 
@@ -570,11 +752,25 @@ LocalVarNode
570
752
  include MethodTopCodeGen
571
753
  @@class_top_tab = {}
572
754
 
755
+ def self.get_class_top_node(klass)
756
+ @@class_top_tab[klass]
757
+ end
758
+
759
+ def collect_info(context)
760
+ context.modified_local_var.push [{}]
761
+ context.modified_instance_var = {}
762
+ context = super
763
+ context.modified_local_var.pop
764
+ context
765
+ end
766
+
573
767
  def initialize(parent, klassobj, name = nil)
574
768
  super(parent, name)
575
- @nested_class_tab = {}
769
+ @constant_tab = {}
576
770
  @method_tab = {}
577
771
  @klass_object = klassobj
772
+ @klassclass = class << @klass_object; self; end
773
+ RubyType::define_wraped_class(@klassclass, RubyType::RubyTypeBoxed)
578
774
  unless @@class_top_tab[klassobj]
579
775
  @@class_top_tab[klassobj] = self
580
776
  end
@@ -593,7 +789,21 @@ LocalVarNode
593
789
  end
594
790
  end
595
791
 
596
- attr :nested_class_tab
792
+ def search_method_with_super(name, klassobj = @klass_object)
793
+ clsnode = @@class_top_tab[klassobj]
794
+ if clsnode then
795
+ mtab = clsnode.method_tab
796
+ if val = mtab[name] then
797
+ return [val, clsnode]
798
+ end
799
+
800
+ return search_method_with_super(name, klassobj.superclass)
801
+ end
802
+
803
+ [nil, nil]
804
+ end
805
+
806
+ attr :constant_tab
597
807
  attr :klass_object
598
808
 
599
809
  def construct_frame_info(locals, argnum)
@@ -603,6 +813,23 @@ LocalVarNode
603
813
  argnum += 3
604
814
  super(locals, argnum)
605
815
  end
816
+
817
+ def collect_candidate_type(context, signode, sig)
818
+ @type = RubyType::BaseType.from_ruby_class(@klassclass)
819
+ @type_list.add_type(sig, @type)
820
+
821
+ if add_cs_for_signature(sig) == nil and
822
+ context.visited_top_node[self] then
823
+ return context
824
+ end
825
+
826
+ context.visited_top_node[self] = true
827
+
828
+ context.current_method_signature_node.push signode
829
+ context = @body.collect_candidate_type(context)
830
+ context.current_method_signature_node.pop
831
+ context
832
+ end
606
833
  end
607
834
 
608
835
  class TopTopNode<ClassTopNode
@@ -762,9 +989,11 @@ LocalVarNode
762
989
  tobj = context.current_method_signature_node.last[argoff]
763
990
  if tobj then
764
991
  same_type(self, tobj,
765
- context.to_key, context.to_key(-2), context)
992
+ context.to_signature, context.to_signature(-2),
993
+ context)
766
994
  same_type(tobj, self,
767
- context.to_key(-2), context.to_key, context)
995
+ context.to_signature(-2), context.to_signature,
996
+ context)
768
997
  end
769
998
  end
770
999
  context
@@ -816,14 +1045,15 @@ LocalVarNode
816
1045
  attr :modified_instance_var
817
1046
 
818
1047
  def collect_info(context)
819
- context.modified_local_var.pop
820
1048
  @modified_instance_var = context.modified_instance_var
821
1049
  context
822
1050
  end
823
1051
 
824
1052
  def collect_candidate_type(context)
825
- same_type(self, @parent, context.to_key, context.to_key, context)
826
- same_type(@parent, self, context.to_key, context.to_key, context)
1053
+ same_type(self, @parent,
1054
+ context.to_signature, context.to_signature, context)
1055
+ same_type(@parent, self,
1056
+ context.to_signature, context.to_signature, context)
827
1057
  context
828
1058
  end
829
1059
 
@@ -863,9 +1093,9 @@ LocalVarNode
863
1093
  def collect_candidate_type(context)
864
1094
  context = @value_node.collect_candidate_type(context)
865
1095
  same_type(self, @value_node,
866
- context.to_key, context.to_key, context)
1096
+ context.to_signature, context.to_signature, context)
867
1097
  same_type(@value_node, self,
868
- context.to_key, context.to_key, context)
1098
+ context.to_signature, context.to_signature, context)
869
1099
  context = @body.collect_candidate_type(context)
870
1100
  context
871
1101
  end
@@ -875,6 +1105,7 @@ LocalVarNode
875
1105
  context = @value_node.compile(context)
876
1106
  if context.ret_reg != RETR then
877
1107
  if context.ret_reg.is_a?(OpRegXMM) then
1108
+ decide_type_once(context.to_signature)
878
1109
  context = @type.gen_boxing(context)
879
1110
  if context.ret_reg != RETR then
880
1111
  curas = context.assembler
@@ -910,9 +1141,9 @@ LocalVarNode
910
1141
  @local_label.come_from.values.each do |vnode|
911
1142
  if vnode then
912
1143
  same_type(self, vnode,
913
- context.to_key, context.to_key, context)
1144
+ context.to_signature, context.to_signature, context)
914
1145
  same_type(vnode, self,
915
- context.to_key, context.to_key, context)
1146
+ context.to_signature, context.to_signature, context)
916
1147
  end
917
1148
  end
918
1149
  context
@@ -950,7 +1181,7 @@ LocalVarNode
950
1181
  end
951
1182
 
952
1183
  def collect_info(context)
953
- modlocvar = context.modified_local_var.map {|ele| ele.dup}
1184
+ modlocvar = context.modified_local_var.last.map {|ele| ele.dup}
954
1185
  @modified_local_var_list.push modlocvar
955
1186
  modinsvar = context.modified_instance_var.dup
956
1187
  @modified_instance_var_list.push modinsvar
@@ -1136,19 +1367,20 @@ LocalVarNode
1136
1367
  super(parent)
1137
1368
  @value = val
1138
1369
  @type = RubyType::BaseType.from_object(val)
1370
+ @my_element_node = BaseNode.new(self)
1139
1371
  end
1140
1372
 
1141
1373
  attr :value
1142
1374
 
1143
1375
  def collect_candidate_type(context)
1144
- @type_list.add_type(context.to_key, @type)
1376
+ @type_list.add_type(context.to_signature, @type)
1145
1377
  case @value
1146
1378
  when Array
1147
- key = context.to_key
1148
- @element_node_list = [[key, BaseNode.new(self)]]
1379
+ sig = context.to_signature
1380
+ @element_node_list = [[sig, @my_element_node]]
1149
1381
  @value.each do |ele|
1150
1382
  etype = RubyType::BaseType.from_object(ele)
1151
- @element_node_list[0][1].add_type(key, etype)
1383
+ @element_node_list[0][1].add_type(sig, etype)
1152
1384
  end
1153
1385
  end
1154
1386
  context
@@ -1157,7 +1389,7 @@ LocalVarNode
1157
1389
  def compile(context)
1158
1390
  context = super(context)
1159
1391
 
1160
- decide_type_once(context.to_key)
1392
+ decide_type_once(context.to_signature)
1161
1393
  case @value
1162
1394
  when Fixnum
1163
1395
  val = @value
@@ -1198,11 +1430,42 @@ LocalVarNode
1198
1430
  end
1199
1431
  end
1200
1432
 
1433
+ class ClassValueNode<BaseNode
1434
+ include HaveChildlenMixin
1435
+
1436
+ def initialize(parent, define)
1437
+ super(parent)
1438
+ @define = define
1439
+ end
1440
+
1441
+ def traverse_childlen
1442
+ yield @define
1443
+ yield @body
1444
+ end
1445
+
1446
+ attr_accessor :define
1447
+
1448
+ def collect_candidate_type(context)
1449
+ context = @define.collect_candidate_type(context,[], [])
1450
+ context = @body.collect_candidate_type(context)
1451
+ context
1452
+ end
1453
+
1454
+ def compile(context)
1455
+ # raise "Can't compile"
1456
+ context = super(context)
1457
+ context = @define.compile(context)
1458
+ context = @body.compile(context)
1459
+ context
1460
+ end
1461
+ end
1462
+
1201
1463
  class SpecialObjectNode<BaseNode
1202
1464
  def initialize(parent, kind)
1203
1465
  super(parent)
1204
1466
  @kind = kind
1205
1467
  end
1468
+
1206
1469
 
1207
1470
  attr :kind
1208
1471
 
@@ -1291,15 +1554,15 @@ LocalVarNode
1291
1554
 
1292
1555
  def method_top_node(ctop, slf)
1293
1556
  if slf then
1294
- ctop.method_tab(slf.ruby_type)[@name]
1557
+ ctop.search_method_with_super(@name, slf.ruby_type)[0]
1295
1558
  else
1296
- ctop.method_tab[@name]
1559
+ ctop.search_method_with_super(@name)[0]
1297
1560
  end
1298
1561
  end
1299
1562
 
1300
1563
  def calling_convention(context)
1301
1564
  if @send_node.is_fcall or @send_node.is_vcall then
1302
- mtop = @reciever.method_tab[@name]
1565
+ mtop = @reciever.search_method_with_super(@name)[0]
1303
1566
  if mtop then
1304
1567
  @calling_convention = :ytl
1305
1568
  else
@@ -1307,7 +1570,8 @@ LocalVarNode
1307
1570
  if @reciever.klass_object then
1308
1571
  addr = @reciever.klass_object.method_address_of(@name)
1309
1572
  if addr then
1310
- if variable_argument?(@eciever.method(@name).parameters) then
1573
+ recobj = @reciever.klass_object
1574
+ if variable_argument?(recobj.method(@name).parameters) then
1311
1575
  @calling_convention = :c_vararg
1312
1576
  else
1313
1577
  @calling_convention = :c_fixarg
@@ -1321,15 +1585,19 @@ LocalVarNode
1321
1585
  end
1322
1586
  end
1323
1587
  else
1324
- context = @reciever.compile(context)
1325
- context.ret_node.decide_type_once(context.to_key)
1326
- rtype = context.ret_node.type
1588
+ @reciever.decide_type_once(context.to_signature)
1589
+ rtype = @reciever.type
1327
1590
  rklass = rtype.ruby_type
1328
- mth = rklass.instance_method(@name)
1329
- if variable_argument?(mth.parameters) then
1330
- @calling_convention = :c_vararg
1591
+ knode = ClassTopNode.get_class_top_node(rklass)
1592
+ if knode and knode.search_method_with_super(@name)[0] then
1593
+ @calling_convention = :ytl
1331
1594
  else
1332
- @calling_convention = :c_fixarg
1595
+ mth = rklass.instance_method(@name)
1596
+ if variable_argument?(mth.parameters) then
1597
+ @calling_convention = :c_vararg
1598
+ else
1599
+ @calling_convention = :c_fixarg
1600
+ end
1333
1601
  end
1334
1602
  end
1335
1603
 
@@ -1343,7 +1611,7 @@ LocalVarNode
1343
1611
  asm.with_retry do
1344
1612
  asm.mov(TMPR3, 4)
1345
1613
  end
1346
- mtop = @reciever.method_tab[@name]
1614
+ mtop = @reciever.search_method_with_super(@name)[0]
1347
1615
  if mtop then
1348
1616
  sig = @parent.signature(context)
1349
1617
  cs = mtop.find_cs_by_signature(sig)
@@ -1368,10 +1636,12 @@ LocalVarNode
1368
1636
  end
1369
1637
  else
1370
1638
  context = @reciever.compile(context)
1371
- context.ret_node.decide_type_once(context.to_key)
1639
+ context.ret_node.decide_type_once(context.to_signature)
1372
1640
  rtype = context.ret_node.type
1373
1641
  context = rtype.gen_boxing(context)
1374
1642
  recval = context.ret_reg
1643
+ knode = ClassTopNode.get_class_top_node(rtype.ruby_type)
1644
+ mtop = nil
1375
1645
 
1376
1646
  if rtype.is_a?(RubyType::DefaultType0) then
1377
1647
  # Can't type inference. Dynamic method search
@@ -1404,7 +1674,20 @@ LocalVarNode
1404
1674
  context.set_reg_content(TMPR2, self)
1405
1675
  context.set_reg_content(TMPR3, @reciever)
1406
1676
  context.ret_reg = TMPR2
1677
+
1678
+ elsif knode and mtop = knode.search_method_with_super(@name)[0] then
1679
+ asm = context.assembler
1680
+ asm.with_retry do
1681
+ asm.mov(TMPR3, recval)
1682
+ end
1683
+
1684
+ sig = @parent.signature(context)
1685
+ cs = mtop.find_cs_by_signature(sig)
1686
+ context.ret_reg = cs.var_base_address
1687
+
1407
1688
  else
1689
+ # regident type
1690
+
1408
1691
  asm = context.assembler
1409
1692
  asm.with_retry do
1410
1693
  asm.mov(TMPR3, recval)
@@ -1461,7 +1744,11 @@ LocalVarNode
1461
1744
  end
1462
1745
 
1463
1746
  def collect_info(context)
1464
- vti = context.modified_local_var[@depth][@offset]
1747
+ vti = nil
1748
+ if context.modified_local_var.last[@depth] then
1749
+ vti = context.modified_local_var.last[@depth][@offset]
1750
+ end
1751
+
1465
1752
  if vti then
1466
1753
  @var_type_info = vti.dup
1467
1754
  else
@@ -1475,7 +1762,7 @@ LocalVarNode
1475
1762
  def collect_candidate_type(context)
1476
1763
  @var_type_info.each do |src|
1477
1764
  same_type(self, src,
1478
- context.to_key, context.to_key, context)
1765
+ context.to_signature, context.to_signature, context)
1479
1766
  end
1480
1767
  context
1481
1768
  end
@@ -1501,17 +1788,18 @@ LocalVarNode
1501
1788
  offarg = @current_frame_info.offset_arg(@offset, BPR)
1502
1789
  context.ret_node = self
1503
1790
  context.ret_reg = offarg
1791
+ context
1504
1792
  end
1505
1793
 
1506
1794
  def collect_candidate_type(context)
1507
1795
  @type = RubyType::BaseType.from_ruby_class(@classtop.klass_object)
1508
- @type_list.add_type(context.to_key, @type)
1796
+ @type_list.add_type(context.to_signature, @type)
1509
1797
  context
1510
1798
  end
1511
1799
 
1512
1800
  def compile(context)
1513
1801
  context = super(context)
1514
- comile_main(context)
1802
+ compile_main(context)
1515
1803
  end
1516
1804
  end
1517
1805
 
@@ -1530,14 +1818,14 @@ LocalVarNode
1530
1818
 
1531
1819
  def collect_info(context)
1532
1820
  context = @val.collect_info(context)
1533
- context.modified_local_var[@depth][@offset] = [self]
1821
+ context.modified_local_var.last[@depth][@offset] = [self]
1534
1822
  @body.collect_info(context)
1535
1823
  end
1536
1824
 
1537
1825
  def collect_candidate_type(context)
1538
1826
  context = @val.collect_candidate_type(context)
1539
1827
  same_type(self, @val,
1540
- context.to_key, context.to_key, context)
1828
+ context.to_signature, context.to_signature, context)
1541
1829
  @body.collect_candidate_type(context)
1542
1830
  end
1543
1831
 
@@ -1545,9 +1833,9 @@ LocalVarNode
1545
1833
  context = super(context)
1546
1834
  context = @val.compile(context)
1547
1835
 
1548
- decide_type_once(context.to_key)
1836
+ decide_type_once(context.to_signature)
1549
1837
  if @type.boxed then
1550
- @val.decide_type_once(context.to_key)
1838
+ @val.decide_type_once(context.to_signature)
1551
1839
  rtype = @val.type
1552
1840
  context = rtype.gen_boxing(context)
1553
1841
  end
@@ -1558,7 +1846,8 @@ LocalVarNode
1558
1846
  offarg = @current_frame_info.offset_arg(@offset, base)
1559
1847
 
1560
1848
  asm = context.assembler
1561
- if valr.is_a?(OpRegistor) or valr.is_a?(OpImmidiate) then
1849
+ if valr.is_a?(OpRegistor) or
1850
+ (valr.is_a?(OpImmidiate) and !valr.is_a?(OpImmidiate64)) then
1562
1851
  asm.with_retry do
1563
1852
  asm.mov(offarg, valr)
1564
1853
  end
@@ -1610,7 +1899,7 @@ LocalVarNode
1610
1899
  def collect_candidate_type(context)
1611
1900
  @var_type_info.each do |src|
1612
1901
  same_type(self, src,
1613
- context.to_key, context.to_key, context)
1902
+ context.to_signature, context.to_signature, context)
1614
1903
  end
1615
1904
  context
1616
1905
  end
@@ -1647,7 +1936,7 @@ LocalVarNode
1647
1936
  def collect_candidate_type(context)
1648
1937
  context = @val.collect_candidate_type(context)
1649
1938
  same_type(self, @val,
1650
- context.to_key, context.to_key, context)
1939
+ context.to_signature, context.to_signature, context)
1651
1940
  @body.collect_candidate_type(context)
1652
1941
  end
1653
1942
 
@@ -1661,6 +1950,40 @@ LocalVarNode
1661
1950
  end
1662
1951
  end
1663
1952
 
1953
+ class ConstantRefNode<VariableRefCommonNode
1954
+ include NodeUtil
1955
+
1956
+ def initialize(parent, klass, name)
1957
+ super(parent)
1958
+ @name = name
1959
+ @class_top = klass # .search_class_top
1960
+ @value_node = klass.constant_tab[@name]
1961
+ end
1962
+
1963
+ attr :value_node
1964
+
1965
+ def collect_candidate_type(context)
1966
+ same_type(self, @value_node,
1967
+ context.to_signature, context.to_signature, context)
1968
+ context
1969
+ end
1970
+
1971
+ def compile(context)
1972
+ case @value_node
1973
+ when ClassTopNode
1974
+ obj = @value_node.klass_object
1975
+ objadd = lambda { obj.address }
1976
+ context.ret_reg = OpVarImmidiateAddress.new(objadd)
1977
+
1978
+ else
1979
+ context = @value_node.compile(context)
1980
+ end
1981
+
1982
+ context.ret_node = self
1983
+ context
1984
+ end
1985
+ end
1986
+
1664
1987
  # Reference Register
1665
1988
  class RefRegister
1666
1989
  end