Class: YTLJit::VM::Node::LocalLabel

Inherits:
BaseNode show all
Includes:
HaveChildlenMixin, MultipleCodeSpaceUtil, NodeUtil
Defined in:
lib/ytljit/vm.rb

Constant Summary

Constants inherited from BaseNode

BaseNode::ESCAPE_LEVEL

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

Attributes included from HaveChildlenMixin

#body

Attributes inherited from BaseNode

#code_space, #debug_info, #element_node_list, #id, #is_escape, #parent, #ti_observee, #ti_observer, #type

Instance Method Summary collapse

Methods included from MultipleCodeSpaceUtil

#add_cs_for_signature, #find_cs_by_signature, #get_code_space

Methods included from NodeUtil

#search_class_top, #search_end, #search_frame_info, #search_top

Methods inherited from BaseNode

#add_element_node, #add_element_node_backward, #add_element_node_backward_aux, #decide_type, #decide_type_core, #decide_type_once, #gen_type_inference_proc, #get_constant_value, #inference_type, #marge_element_node, #marge_type, #same_type, #search_valid_signature, #set_escape_node, #set_escape_node_backward, #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

#inspect_by_graph

Constructor Details

#initialize(parent, name) ⇒ LocalLabel

Returns a new instance of LocalLabel.



2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
# File 'lib/ytljit/vm.rb', line 2264

def initialize(parent, name)
  super(parent)
  @name = name
  @come_from = {}
  @come_from_val = []
  @current_signature = nil
  @code_spaces = []
  @value_node = nil
  @modified_local_var_list = []
  @res_area = nil
end

Instance Attribute Details

#come_fromObject (readonly)

Returns the value of attribute come_from.



2277
2278
2279
# File 'lib/ytljit/vm.rb', line 2277

def come_from
  @come_from
end

#nameObject (readonly)

Returns the value of attribute name.



2276
2277
2278
# File 'lib/ytljit/vm.rb', line 2276

def name
  @name
end

#res_areaObject (readonly)

Returns the value of attribute res_area.



2279
2280
2281
# File 'lib/ytljit/vm.rb', line 2279

def res_area
  @res_area
end

#value_nodeObject

Returns the value of attribute value_node.



2278
2279
2280
# File 'lib/ytljit/vm.rb', line 2278

def value_node
  @value_node
end

Instance Method Details

#collect_candidate_type(context, sender = nil) ⇒ Object



2359
2360
2361
2362
2363
2364
2365
# File 'lib/ytljit/vm.rb', line 2359

def collect_candidate_type(context, sender = nil)
    if @come_from.keys[0] == sender then
      @body.collect_candidate_type(context)
   else
     context
   end
end

#collect_info(context) ⇒ Object



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
# File 'lib/ytljit/vm.rb', line 2302

def collect_info(context)
  if @modified_local_var_list.size == 0 then
    # first visit
    delnode = []
    fornode = []
    @come_from.keys.each do |ele|
      if lonly_node(ele) then
        delnode.push ele
      end
    end
    delnode.each do |ele|
      @come_from.delete(ele)
    end
  end
    
  modlocvar = context.modified_local_var.last.map {|ele| ele.dup}
  @modified_local_var_list.push modlocvar
  if @modified_local_var_list.size == 1 then
    tnode = search_frame_info
    offset = tnode.static_alloca(8)
    @res_area = OpIndirect.new(BPR, offset)
    @body.collect_info(context)
  elsif @modified_local_var_list.size == @come_from.size then
    context.marge_local_var(@modified_local_var_list)
    @body.collect_info(context)
  else
    context
  end
end

#compile(context) ⇒ Object



2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
# File 'lib/ytljit/vm.rb', line 2367

def compile(context)
  context = super(context)
  if @current_signature == nil or
      @current_signature != context.to_signature then
    @come_from_val = []
    @current_signature = context.to_signature
  end

  @come_from_val.push context.ret_reg
  
  if @come_from_val.size == 1 then
    @body.compile(context)
  else
    context
  end
end

#compile_block_value(context, comefrom) ⇒ Object



2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
# File 'lib/ytljit/vm.rb', line 2332

def compile_block_value(context, comefrom)
  valnode = @come_from[comefrom]
  if valnode then
    context = valnode.compile(context)
    asm = context.assembler
    if !context.ret_reg.is_a?(OpRegXMM) then
      asm.with_retry do
        asm.mov(TMPR, context.ret_reg)
        asm.mov(@res_area, TMPR)
      end
      context.ret_reg = TMPR
    end
  end

  context.set_reg_content(context.ret_reg, self)
  context
end

#lonly_node(node) ⇒ Object



2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
# File 'lib/ytljit/vm.rb', line 2286

def lonly_node(node)
  while !node.is_a?(TopNode) 
    if node.is_a?(LocalLabel) then
      if node.come_from.size == 0 then
        return true
      else
        return false
      end
    end

    node = node.parent
  end

  return false
end

#traverse_block_value(comefrom, &block) ⇒ Object



2350
2351
2352
2353
2354
2355
2356
2357
# File 'lib/ytljit/vm.rb', line 2350

def traverse_block_value(comefrom, &block)
  valnode = @come_from[comefrom]
  if valnode then
    yield valnode
  else
    nil
  end
end

#traverse_childlen {|@value_node| ... } ⇒ Object

Yields:



2281
2282
2283
2284
# File 'lib/ytljit/vm.rb', line 2281

def traverse_childlen
  yield @value_node
  yield @body
end