Class: YTLJit::VM::Node::LocalFrameInfoNode

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

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

Attributes included from HaveChildlenMixin

#body

Attributes inherited from BaseNode

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

Instance Method Summary collapse

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

#inspect_by_graph

Constructor Details

#initialize(parent) ⇒ LocalFrameInfoNode

Returns a new instance of LocalFrameInfoNode.



1145
1146
1147
1148
1149
1150
1151
1152
# File 'lib/ytljit/vm.rb', line 1145

def initialize(parent)
  super(parent)
  @frame_layout = []
  @argument_num = nil
  @system_num = nil
  @previous_frame = search_previous_frame(parent)
  @offset_cache = {}
end

Instance Attribute Details

#argument_numObject

Returns the value of attribute argument_num.



1172
1173
1174
# File 'lib/ytljit/vm.rb', line 1172

def argument_num
  @argument_num
end

#frame_layoutObject

Returns the value of attribute frame_layout.



1171
1172
1173
# File 'lib/ytljit/vm.rb', line 1171

def frame_layout
  @frame_layout
end

#previous_frameObject (readonly)

Returns the value of attribute previous_frame.



1174
1175
1176
# File 'lib/ytljit/vm.rb', line 1174

def previous_frame
  @previous_frame
end

#system_numObject

Returns the value of attribute system_num.



1173
1174
1175
# File 'lib/ytljit/vm.rb', line 1173

def system_num
  @system_num
end

Instance Method Details

#collect_candidate_type(context) ⇒ Object



1229
1230
1231
1232
1233
# File 'lib/ytljit/vm.rb', line 1229

def collect_candidate_type(context)
  traverse_childlen {|rec|
    context = rec.collect_candidate_type(context)
  }
end

#compile(context) ⇒ Object



1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
# File 'lib/ytljit/vm.rb', line 1235

def compile(context)
  context = super(context)
  siz = local_area_size
  if  siz != 0 then
    asm = context.assembler
    asm.with_retry do
      asm.sub(SPR, siz)
    end
    context.cpustack_pushn(siz)
  end
  @body.compile(context)
end

#copy_frame_layoutObject



1167
1168
1169
# File 'lib/ytljit/vm.rb', line 1167

def copy_frame_layout
  @frame_layout.each { |ele| ele.dup }
end

#frame_sizeObject



1183
1184
1185
# File 'lib/ytljit/vm.rb', line 1183

def frame_size
  @frame_layout.inject(0) {|sum, slot| sum += slot.size}
end

#local_area_sizeObject



1187
1188
1189
1190
# File 'lib/ytljit/vm.rb', line 1187

def local_area_size
  localnum = @frame_layout.size - @argument_num - @system_num
  @frame_layout[0, localnum].inject(0) {|sum, slot| sum += slot.size}
end

#offset_arg(n, basereg) ⇒ Object



1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
# File 'lib/ytljit/vm.rb', line 1213

def offset_arg(n, basereg)
  rc = nil
  if basereg == BPR then
    rc = @offset_cache[n]
    unless rc
      off = offset_by_byte(n)
      rc = @offset_cache[n] = OpIndirect.new(basereg, off)
    end
  else
    off = offset_by_byte(n)
    rc = OpIndirect.new(basereg, off)
  end

  rc
end

#offset_by_byte(off) ⇒ Object



1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
# File 'lib/ytljit/vm.rb', line 1202

def offset_by_byte(off)
  off = real_offset(off)

  obyte = 0
  off.times do |i|
    obyte += @frame_layout[i].size
  end
  
  obyte - local_area_size
end

#real_offset(off) ⇒ Object



1192
1193
1194
1195
1196
1197
1198
1199
1200
# File 'lib/ytljit/vm.rb', line 1192

def real_offset(off)
  if off >=  @argument_num then
    off = off - @argument_num
  else
    off = off + (@frame_layout.size - @argument_num)
  end

  off
end

#search_previous_frame(mtop) ⇒ Object



1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
# File 'lib/ytljit/vm.rb', line 1154

def search_previous_frame(mtop)
  cnode = mtop.parent
  while !cnode.is_a?(TopNode)
    if cnode then
      cnode = cnode.parent
    else
      return nil
    end
  end

  return cnode.body
end

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

Yields:



1176
1177
1178
1179
1180
1181
# File 'lib/ytljit/vm.rb', line 1176

def traverse_childlen
  @frame_layout.each do |vinf|
    yield vinf
  end
  yield @body
end