Пример #1
0
 def execute_call_release_gil(self, descr, saveerr, func, *args):
     if hasattr(descr, '_original_func_'):
         func = descr._original_func_  # see pyjitpl.py
         # we want to call the function that does the aroundstate
         # manipulation here (as a hack, instead of really doing
         # the aroundstate manipulation ourselves)
         return self.execute_call_may_force(descr, func, *args)
     guard_op = self.lltrace.operations[self.current_index + 1]
     assert guard_op.getopnum() == rop.GUARD_NOT_FORCED
     self.force_guard_op = guard_op
     call_args = support.cast_call_args_in_order(descr.ARGS, args)
     #
     func_adr = llmemory.cast_int_to_adr(func)
     if hasattr(func_adr.ptr._obj, '_callable'):
         # this is needed e.g. by test_fficall.test_guard_not_forced_fails,
         # because to actually force the virtualref we need to llinterp the
         # graph, not to directly execute the python function
         result = self.cpu.maybe_on_top_of_llinterp(func, call_args,
                                                    descr.RESULT)
     else:
         FUNC = lltype.FuncType(descr.ARGS, descr.RESULT, descr.ABI)
         func_to_call = rffi.cast(lltype.Ptr(FUNC), func)
         result = func_to_call(*call_args)
     del self.force_guard_op
     return support.cast_result(descr.RESULT, result)
Пример #2
0
 def maybe_on_top_of_llinterp(self, func, args, RESULT):
     ptr = llmemory.cast_int_to_adr(func).ptr
     if hasattr(ptr._obj, 'graph'):
         res = self.llinterp.eval_graph(ptr._obj.graph, args)
     else:
         res = ptr._obj._callable(*args)
     return support.cast_result(RESULT, res)
Пример #3
0
 def maybe_on_top_of_llinterp(self, func, args, RESULT):
     ptr = llmemory.cast_int_to_adr(func).ptr
     if hasattr(ptr._obj, 'graph'):
         res = self.llinterp.eval_graph(ptr._obj.graph, args)
     else:
         res = ptr._obj._callable(*args)
     if RESULT is lltype.Void:
         return None
     return support.cast_result(RESULT, res)
Пример #4
0
 def execute_call_release_gil(self, descr, saveerr, func, *args):
     if hasattr(descr, '_original_func_'):
         func = descr._original_func_     # see pyjitpl.py
         # we want to call the function that does the aroundstate
         # manipulation here (as a hack, instead of really doing
         # the aroundstate manipulation ourselves)
         return self.execute_call_may_force(descr, func, *args)
     guard_op = self.lltrace.operations[self.current_index + 1]
     assert guard_op.getopnum() == rop.GUARD_NOT_FORCED
     self.force_guard_op = guard_op
     call_args = support.cast_call_args_in_order(descr.ARGS, args)
     #
     func_adr = llmemory.cast_int_to_adr(func)
     if hasattr(func_adr.ptr._obj, '_callable'):
         # this is needed e.g. by test_fficall.test_guard_not_forced_fails,
         # because to actually force the virtualref we need to llinterp the
         # graph, not to directly execute the python function
         result = self.cpu.maybe_on_top_of_llinterp(func, call_args, descr.RESULT)
     else:
         FUNC = lltype.FuncType(descr.ARGS, descr.RESULT, descr.ABI)
         func_to_call = rffi.cast(lltype.Ptr(FUNC), func)
         result = func_to_call(*call_args)
     del self.force_guard_op
     return support.cast_result(descr.RESULT, result)
Пример #5
0
 def bh_raw_load_i(self, struct, offset, descr):
     ll_p = rffi.cast(rffi.CCHARP, struct)
     ll_p = rffi.cast(lltype.Ptr(descr.A), rffi.ptradd(ll_p, offset))
     value = ll_p[0]
     return support.cast_result(descr.A.OF, value)
Пример #6
0
 def bh_getinteriorfield_gc(self, a, index, descr):
     array = a._obj.container
     return support.cast_result(descr.FIELD,
                       getattr(array.getitem(index), descr.fieldname))
Пример #7
0
 def bh_getarrayitem_gc(self, a, index, descr):
     a = support.cast_arg(lltype.Ptr(descr.A), a)
     array = a._obj
     return support.cast_result(descr.A.OF, array.getitem(index))
Пример #8
0
 def bh_getfield_gc(self, p, descr):
     p = support.cast_arg(lltype.Ptr(descr.S), p)
     return support.cast_result(descr.FIELD, getattr(p, descr.fieldname))
Пример #9
0
 def bh_raw_load_i(self, struct, offset, descr):
     ll_p = rffi.cast(rffi.CCHARP, struct)
     ll_p = rffi.cast(lltype.Ptr(descr.A), rffi.ptradd(ll_p, offset))
     value = ll_p[0]
     return support.cast_result(descr.A.OF, value)
Пример #10
0
 def bh_getinteriorfield_gc(self, a, index, descr):
     array = a._obj.container
     return support.cast_result(
         descr.FIELD, getattr(array.getitem(index), descr.fieldname))
Пример #11
0
 def bh_getarrayitem_gc(self, a, index, descr):
     a = support.cast_arg(lltype.Ptr(descr.A), a)
     array = a._obj
     return support.cast_result(descr.A.OF, array.getitem(index))
Пример #12
0
 def bh_getfield_gc(self, p, descr):
     p = support.cast_arg(lltype.Ptr(descr.S), p)
     return support.cast_result(descr.FIELD, getattr(p, descr.fieldname))