def _(bs): "handler(rsp)" bs.code += isa.mov(registers.rdi, registers.rsp) bs.code += isa.mov(registers.r12, registers.rsp) bs.code += isa.and_(registers.rsp, -16) bs.code += isa.mov( registers.rax, ctypes.cast(handler_cfunc, ctypes.c_void_p).value) bs.code += isa.call(registers.rax) bs.code += isa.mov(registers.rsp, registers.r12) for arg in arg_types[::-1]: assert bs.flow.stack.pop() is arg for i in xrange(arg.size): bs.code += isa.pop(registers.rbx) assert bs.flow.stack.pop() is self bs.code += isa.push(registers.rax) def _(value): def _(bs): type = type_impl.id_to_type[value] for i in xrange(type.size): bs.code += isa.push( MemRef( ctypes.cast(self.return_area, ctypes.c_void_p).value + i)) bs.flow.stack.append(type) assert bs.flow.stack[-1].size == 0 return _ util.unlift(bs, _, "PythonFunction.call")
def _(bs): "handler(rsp)" bs.code += isa.mov(registers.rdi, registers.rsp) bs.code += isa.mov(registers.r12, registers.rsp) bs.code += isa.and_(registers.rsp, -16) bs.code += isa.mov(registers.rax, ctypes.cast(handler_cfunc, ctypes.c_void_p).value) bs.code += isa.call(registers.rax) bs.code += isa.mov(registers.rsp, registers.r12) for arg in arg_types[::-1]: assert bs.flow.stack.pop() is arg for i in xrange(arg.size): bs.code += isa.pop(registers.rbx) assert bs.flow.stack.pop() is self bs.code += isa.push(registers.rax) def _(value): def _(bs): type = type_impl.id_to_type[value] for i in xrange(type.size): bs.code += isa.push(MemRef(ctypes.cast(self.return_area, ctypes.c_void_p).value + i)) bs.flow.stack.append(type) assert bs.flow.stack[-1].size == 0 return _ util.unlift(bs, _, "PythonFunction.call")
def _(bs): assert bs.flow.stack.pop() is type_impl.Str assert bs.flow.stack.pop() is self def _(value): s = type_impl.Str.to_python(struct.pack("l", value)) def _(bs): bs.flow.stack.append(CDLLInsts[s]) return _ util.unlift(bs, _, "CDLL")
def _(bs): assert bs.flow.stack.pop() is type_impl.Int bs.code += isa.pop(registers.r13) assert bs.flow.stack.pop() is self bs.code += isa.pop(registers.r12) bs.code += isa.shl(registers.r13, 3) bs.code += isa.add(registers.r12, registers.r13) bs.code += isa.push(MemRef(registers.r12)) def _(value): def _(bs): type = type_impl.id_to_type[value] for i in reversed(xrange(type.size)): bs.code += isa.push(MemRef(registers.r12, i * 8 + 8)) bs.flow.stack.append(type) return _ util.unlift(bs, _, "RawLoadObjectMeth.call")