Module: YTLJit::VM::ArithmeticOperationUtil

Includes:
AbsArch
Included in:
Node::SendDivNode, Node::SendMinusNode, Node::SendMultNode, Node::SendPlusNode
Defined in:
lib/ytljit/vm_inline_method.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 Method Summary collapse

Instance Method Details

#gen_arithmetic_operation(context, inst, tempreg, resreg) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/ytljit/vm_inline_method.rb', line 5

def gen_arithmetic_operation(context, inst, tempreg, resreg)
  context.start_using_reg(tempreg)
  context = gen_eval_self(context)
  context.ret_node.type = nil
  rtype = context.ret_node.decide_type_once(context.to_signature)
  context = rtype.gen_unboxing(context)
  asm = context.assembler
  if context.ret_reg.using(tempreg) then
    asm.with_retry do
      asm.mov(TMPR, context.ret_reg)
    end
    context.end_using_reg(context.ret_reg)
    asm.with_retry do
      asm.mov(tempreg, TMPR)
    end
  else
    asm.with_retry do
      asm.mov(tempreg, context.ret_reg)
    end
    context.end_using_reg(context.ret_reg)
  end
  context.set_reg_content(tempreg, context.ret_node)
  
  # @argunents[1] is block
  # @argunents[2] is self
  # @arguments[3] is other
  aele = @arguments[3]
  context = aele.compile(context)
  context.ret_node.type = nil
  rtype = context.ret_node.decide_type_once(context.to_signature)
  context = rtype.gen_unboxing(context)
    
  asm = context.assembler
  if block_given? then
    yield(context)
  else
    asm.with_retry do
      # default code
      if context.ret_reg.using(tempreg) then
        asm.mov(TMPR, context.ret_reg)
        context.end_using_reg(context.ret_reg)
        asm.send(inst, tempreg, TMPR)
      else
        asm.send(inst, tempreg, context.ret_reg)
        context.end_using_reg(context.ret_reg)
      end
      asm.mov(resreg, tempreg)
    end
  end

  context.end_using_reg(tempreg)

  context.ret_node = self
  context.ret_reg = resreg
  
  decide_type_once(context.to_signature)

  if @type.boxed then
    context = @type.to_unbox.gen_boxing(context)
  end
  
  context
end