Class: YTLJit::VM::Node::MethodSelectNode
- Defined in:
- lib/ytljit/vm.rb
Overview
Method name
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
Constants included from SSE
SSE::XMM0, SSE::XMM1, SSE::XMM2, SSE::XMM3, SSE::XMM4, SSE::XMM5, SSE::XMM6, SSE::XMM7
Instance Attribute Summary collapse
-
#calling_convention(context) ⇒ Object
readonly
Returns the value of attribute calling_convention.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#reciever ⇒ Object
Returns the value of attribute reciever.
Attributes inherited from BaseNode
#code_space, #element_node_list, #id, #parent, #type
Instance Method Summary collapse
- #collect_candidate_type(context) ⇒ Object
- #compile(context) ⇒ Object
-
#initialize(parent, val) ⇒ MethodSelectNode
constructor
A new instance of MethodSelectNode.
- #method_top_node(ctop, slf) ⇒ Object
- #set_reciever(sendnode) ⇒ Object
Methods inherited from BaseNode
#add_element_node, #add_type, #collect_info, #decide_type, #decide_type_core, #decide_type_once, #gen_type_inference_proc, #inference_type, #merge_type, #same_type, #set_type_list, #ti_add_observer, #ti_changed, #ti_update, #type_list
Methods included from Inspect
Constructor Details
#initialize(parent, val) ⇒ MethodSelectNode
Returns a new instance of MethodSelectNode.
1267 1268 1269 1270 1271 1272 1273 |
# File 'lib/ytljit/vm.rb', line 1267 def initialize(parent, val) super(parent) @name = val @calling_convention = :unkown @reciever = nil @send_node = nil end |
Instance Attribute Details
#calling_convention(context) ⇒ Object (readonly)
Returns the value of attribute calling_convention.
1285 1286 1287 |
# File 'lib/ytljit/vm.rb', line 1285 def calling_convention @calling_convention end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
1284 1285 1286 |
# File 'lib/ytljit/vm.rb', line 1284 def name @name end |
#reciever ⇒ Object
Returns the value of attribute reciever.
1286 1287 1288 |
# File 'lib/ytljit/vm.rb', line 1286 def reciever @reciever end |
Instance Method Details
#collect_candidate_type(context) ⇒ Object
1288 1289 1290 |
# File 'lib/ytljit/vm.rb', line 1288 def collect_candidate_type(context) context end |
#compile(context) ⇒ Object
1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 |
# File 'lib/ytljit/vm.rb', line 1339 def compile(context) context = super(context) if @send_node.is_fcall or @send_node.is_vcall then asm = context.assembler asm.with_retry do asm.mov(TMPR3, 4) end mtop = @reciever.method_tab[@name] if mtop then sig = @parent.signature(context) cs = mtop.find_cs_by_signature(sig) context.ret_reg = cs.var_base_address else if @reciever.klass_object then addr = lambda { @reciever.klass_object.method_address_of(@name) } if addr.call then context.ret_reg = OpVarMemAddress.new(addr) context.code_space.refer_operands.push context.ret_reg context.ret_node = self else raise "Unkown method - #{@name}" context.ret_reg = OpImmidiateAddress.new(0) context.ret_node = self end else raise "foo" end end else context = @reciever.compile(context) context.ret_node.decide_type_once(context.to_key) rtype = context.ret_node.type context = rtype.gen_boxing(context) recval = context.ret_reg if rtype.is_a?(RubyType::DefaultType0) then # Can't type inference. Dynamic method search mnval = @name.address objclass = OpMemAddress.new(address_of("rb_obj_class")) addr = address_of("ytl_method_address_of_raw") meaddrof = OpMemAddress.new(addr) context.start_using_reg(TMPR2) context.start_using_reg(FUNC_ARG[0]) context.start_using_reg(FUNC_ARG[1]) asm = context.assembler asm.with_retry do asm.push(recval) asm.mov(FUNC_ARG[0], recval) asm.call_with_arg(objclass, 1) asm.mov(FUNC_ARG[0], RETR) asm.mov(FUNC_ARG[1], mnval) asm.call_with_arg(meaddrof, 2) asm.mov(TMPR2, RETR) asm.pop(TMPR3) end context.end_using_reg(FUNC_ARG[1]) context.end_using_reg(FUNC_ARG[0]) context.ret_node = self context.set_reg_content(RETR, self) context.set_reg_content(TMPR2, self) context.set_reg_content(TMPR3, @reciever) context.ret_reg = TMPR2 else asm = context.assembler asm.with_retry do asm.mov(TMPR3, recval) end addr = lambda { rtype.ruby_type.method_address_of(@name) } if addr.call then context.ret_reg = OpVarMemAddress.new(addr) context.code_space.refer_operands.push context.ret_reg context.ret_node = self else raise "Unkown method - #{@name}" context.ret_reg = OpImmidiateAddress.new(0) context.ret_node = self end end end context end |
#method_top_node(ctop, slf) ⇒ Object
1292 1293 1294 1295 1296 1297 1298 |
# File 'lib/ytljit/vm.rb', line 1292 def method_top_node(ctop, slf) if slf then ctop.method_tab(slf.ruby_type)[@name] else ctop.method_tab[@name] end end |
#set_reciever(sendnode) ⇒ Object
1275 1276 1277 1278 1279 1280 1281 1282 |
# File 'lib/ytljit/vm.rb', line 1275 def set_reciever(sendnode) @send_node = sendnode if sendnode.is_fcall then @reciever = @parent.class_top else @reciever = sendnode.arguments[2] end end |