Module: YTLJit::VM::UnboxedArrayUtil

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 Method Summary collapse

Methods included from UnboxedObjectUtil

#compile_object_unboxed

Instance Method Details

#compile_array_unboxed(context) ⇒ Object



212
213
214
215
216
# File 'lib/ytljit/vm_inline_method.rb', line 212

def compile_array_unboxed(context)
  sizent = @element_node_list[1..-1].max_by {|a| a[3] ? a[3][0] : -1}
  siz = sizent[3][0] + 1
  compile_object_unboxed(context, siz)
end

#gen_ref_element(context, slf, idx) ⇒ Object



218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# File 'lib/ytljit/vm_inline_method.rb', line 218

def gen_ref_element(context, slf, idx)
  context.start_using_reg(TMPR2)
  asm = context.assembler
  if slf then
    context = slf.compile(context)
    asm.with_retry do
      asm.mov(TMPR2, context.ret_reg)
    end
  end
  context.set_reg_content(TMPR2, context.ret_node)

  if idx.is_a?(Fixnum) then
    idxval = idx
  else
    context = idx.compile(context)
    itype = idx.decide_type_once(context.to_signature)
    if itype.boxed then
      context = itype.gen_unboxing(context)
    end
    idxval = context.ret_reg
  end
  asm.with_retry do
    if idxval.is_a?(Fixnum) then
      asm.mov(TMPR, idxval * 8)
    elsif idxval.is_a?(OpImmidiate)
      asm.mov(TMPR, idxval.value * 8)
    else
      if idxval != TMPR then
        asm.mov(TMPR, idxval)
      end
      asm.add(TMPR, TMPR) # * 2
      asm.add(TMPR, TMPR) # * 4
      asm.add(TMPR, TMPR) # * 8
    end
    asm.add(TMPR, TMPR2)
  end

  context.end_using_reg(TMPR2)
  context.ret_reg = INDIRECT_TMPR
  context.ret_node = self

  context
end

#gen_set_element(context, slf, idx, val) ⇒ Object



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

def gen_set_element(context, slf, idx, val)
  context.start_using_reg(TMPR2)
  asm = context.assembler
  if slf then
    context = slf.compile(context)
    asm.with_retry do
      asm.mov(TMPR2, context.ret_reg)
    end
  end
  idxval = nil
  if idx.is_a?(Fixnum) then
    idxval = idx
  else
    context = idx.compile(context)
    itype = idx.decide_type_once(context.to_signature)
    if itype.boxed then
      context = itype.gen_unboxing(context)
    end
    idxval = context.ret_reg
  end

  asm.with_retry do
    if idxval.is_a?(Fixnum) then
      asm.mov(TMPR, idxval * 8)
    elsif idxval.is_a?(OpImmidiate)
      asm.mov(TMPR, idxval.value * 8)
    else
      if idxval != TMPR then
        asm.mov(TMPR, idxval)
      end
      asm.add(TMPR, TMPR) # * 2
      asm.add(TMPR, TMPR) # * 4
      asm.add(TMPR, TMPR) # * 8
    end
    asm.add(TMPR2, TMPR)
    asm.push(TMPR2)
  end
  context.set_reg_content(TMPR2, :refer_of_static_heap)
  context = val.compile(context)

  valreg = context.ret_reg
  asm.with_retry do
    asm.pop(TMPR2)
    if !valreg.is_a?(OpRegistor) then
      asm.mov(RETR, valreg)
      valreg = RETR
    end

    asm.mov(INDIRECT_TMPR2, valreg)
  end

  context.end_using_reg(TMPR2)
  context.ret_reg = valreg
  context.ret_node = self
  context
end