Module: YTLJit::VM::TypeCodeGen::ArrayTypeUnboxedCodeGen

Includes:
SendNodeCodeGen, ArrayTypeCommonCodeGen
Defined in:
lib/ytljit/vm_type_gen.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

Attributes included from ArrayTypeCommonCodeGen

#element_type

Instance Method Summary collapse

Methods included from SendNodeCodeGen

#gen_make_argv

Methods included from CommonCodeGen

#dump_context, #gen_alloca, #gen_call, #gen_save_thepr

Methods included from ArrayTypeCommonCodeGen

#==, #have_element?, #init, #inspect

Instance Method Details

#copy_typeObject



321
322
323
324
325
326
# File 'lib/ytljit/vm_type_gen.rb', line 321

def copy_type
  dao = self.class.from_ruby_class(@ruby_type)
  dao = dao.to_unbox
  dao.element_type = @element_type
  dao
end

#gen_boxing(context) ⇒ Object



260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# File 'lib/ytljit/vm_type_gen.rb', line 260

def gen_boxing(context)
#          raise "foo"
#          return context
  cursig = context.to_signature
  asm = context.assembler
  val = context.ret_reg
  vnode = context.ret_node
  etypel = []
  vnode.element_node_list[1..-1].each do |a|
    if a[3] then
      curidx = a[3][0]
      if etypel[curidx] == nil then
        etypel[curidx] = a[2].decide_type_once(a[1])
      end
    end
  end
  siz = etypel.size

  context.start_using_reg(TMPR3)
  context.start_using_reg(TMPR2)
  asm.with_retry do
    asm.mov(TMPR3, val)
  end

  argcomp = lambda {|context, arg, idx|
    eleacc = OpIndirect.new(TMPR3, idx * AsmType::MACHINE_WORD.size)
    asm.with_retry do
      asm.mov(TMPR2, eleacc)
    end
    context.ret_reg = TMPR2
    arg
  }

  context = gen_make_argv(context, etypel, argcomp) do |context, rarg|
    context.start_arg_reg
    context.cpustack_pushn(2 * AsmType::MACHINE_WORD.size)

    addr = lambda {
      address_of("rb_ary_new4")
    }
    rbarynew = OpVarMemAddress.new(addr)
    asm.with_retry do
      asm.mov(FUNC_ARG[0], siz)
      asm.mov(FUNC_ARG[1], TMPR2)
    end

    context = gen_save_thepr(context)
    context = gen_call(context, rbarynew, 2, vnode)
    context.cpustack_popn(2 * AsmType::MACHINE_WORD.size)
    context.end_arg_reg
    context.ret_reg = RETR
    context.set_reg_content(context.ret_reg, vnode)
    context
  end

  context.end_using_reg(TMPR2)
  context.end_using_reg(TMPR3)
  context
end

#instanceObject



253
254
255
256
257
258
# File 'lib/ytljit/vm_type_gen.rb', line 253

def instance
  ni = self.dup
  ni.instance_eval { extend ArrayTypeUnboxedCodeGen }
  ni.init
  ni
end