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, AbsArch::INDIRECT_TMPR3
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, #debug_info, #element_node_list, #id, #is_escape, #parent, #ti_observee, #ti_observer, #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, #collect_info, #decide_type, #decide_type_core, #decide_type_once, #gen_type_inference_proc, #get_constant_value, #inference_type, #merge_type, #same_type, #ti_add_observer, #ti_changed, #ti_del_link, #ti_reset, #ti_update
Methods included from TypeListWithSignature
#add_type, #set_type_list, #type_list, #type_list_initvar
Methods included from Inspect
Constructor Details
#initialize(parent, val) ⇒ MethodSelectNode
Returns a new instance of MethodSelectNode.
2156 2157 2158 2159 2160 2161 2162 2163 |
# File 'lib/ytljit/vm.rb', line 2156 def initialize(parent, val) super(parent) @name = val @calling_convention = :unkown @reciever = nil @send_node = nil @ruby_reciever = nil end |
Instance Attribute Details
#calling_convention(context) ⇒ Object (readonly)
Returns the value of attribute calling_convention.
2180 2181 2182 |
# File 'lib/ytljit/vm.rb', line 2180 def calling_convention @calling_convention end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
2179 2180 2181 |
# File 'lib/ytljit/vm.rb', line 2179 def name @name end |
#reciever ⇒ Object
Returns the value of attribute reciever.
2181 2182 2183 |
# File 'lib/ytljit/vm.rb', line 2181 def reciever @reciever end |
Instance Method Details
#collect_candidate_type(context) ⇒ Object
2183 2184 2185 |
# File 'lib/ytljit/vm.rb', line 2183 def collect_candidate_type(context) context end |
#compile(context) ⇒ Object
2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 |
# File 'lib/ytljit/vm.rb', line 2273 def compile(context) context = super(context) if @send_node.is_fcall or @send_node.is_vcall then slfop = @parent.frame_info.offset_arg(2, BPR) asm = context.assembler asm.with_retry do asm.mov(PTMPR, slfop) end context.ret_reg2 = PTMPR mtop = @reciever.search_method_with_super(@name)[0] if mtop then sig = @parent.signature(context) cs = mtop.find_cs_by_signature(sig) context.ret_reg = cs.var_base_address else recobj = @reciever.klass_object if recobj.is_a?(ClassClassWrapper) then recobj = recobj.value end if recobj then addr = lambda { recobj.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) rtype = context.ret_node.decide_type_once(context.to_signature) if @calling_convention != :ytl then context = rtype.gen_boxing(context) rtype = rtype.to_box elsif !rtype.boxed then context = rtype.gen_unboxing(context) end recval = context.ret_reg rrtype = rtype.ruby_type_raw knode = ClassTopNode.get_class_top_node(rrtype) mtop = nil 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_arg_reg 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(PTMPR) end context.set_reg_content(FUNC_ARG_YTL[0].dst_opecode, nil) context.set_reg_content(FUNC_ARG_YTL[1].dst_opecode, self) context.ret_reg2 = PTMPR context.end_arg_reg context.ret_node = self context.set_reg_content(RETR, self) context.set_reg_content(TMPR2, self) context.set_reg_content(PTMPR, @reciever) context.ret_reg = TMPR2 elsif knode and mtop = knode.search_method_with_super(@name)[0] then asm = context.assembler if !rtype.boxed and rtype.ruby_type == Float then if recval != XMM0 then asm.with_retry do asm.mov(XMM0, recval) end end context.ret_reg2 = XMM0 else asm.with_retry do asm.mov(PTMPR, recval) end context.ret_reg2 = PTMPR end sig = @parent.signature(context) cs = mtop.find_cs_by_signature(sig) context.ret_reg = cs.var_base_address else # regident type asm = context.assembler if !rtype.boxed and rtype.ruby_type == Float then if recval != XMM0 then asm.with_retry do asm.mov(XMM0, recval) end end context.ret_reg2 = XMM0 else asm.with_retry do asm.mov(PTMPR, recval) end context.ret_reg2 = PTMPR end addr = lambda { rrec = @ruby_reciever if rrec.is_a?(ClassClassWrapper) then rrec = rrec.value end if rrec.class == Module then name = @name rrec.send(:method_address_of, name) else rrec.method_address_of(@name) end } 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
2187 2188 2189 2190 2191 2192 2193 |
# File 'lib/ytljit/vm.rb', line 2187 def method_top_node(ctop, slf) if slf then ctop.search_method_with_super(@name, slf.ruby_type_raw)[0] else ctop.search_method_with_super(@name)[0] end end |
#set_reciever(sendnode) ⇒ Object
2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 |
# File 'lib/ytljit/vm.rb', line 2165 def set_reciever(sendnode) @send_node = sendnode if sendnode.is_fcall or sendnode.is_vcall then @reciever = @parent.class_top if @reciever == @parent.search_top and !@reciever.is_a?(TopTopNode) then @reciever.make_klassclass_node @reciever = @reciever.klassclass_node end else @reciever = sendnode.arguments[2] end end |