Author: Ronan Lamy <ronan.l...@gmail.com> Branch: py3.5 Changeset: r89004:0b53fb03a003 Date: 2016-12-10 17:56 +0000 http://bitbucket.org/pypy/pypy/changeset/0b53fb03a003/
Log: hg merge default diff --git a/pypy/module/cpyext/pyobject.py b/pypy/module/cpyext/pyobject.py --- a/pypy/module/cpyext/pyobject.py +++ b/pypy/module/cpyext/pyobject.py @@ -25,11 +25,9 @@ basestruct = PyObject.TO W_BaseObject = W_ObjectObject - def get_dealloc(self, space): + def get_dealloc(self): from pypy.module.cpyext.typeobject import subtype_dealloc - return llhelper( - subtype_dealloc.api_func.functype, - subtype_dealloc.api_func.get_wrapper(space)) + return subtype_dealloc def allocate(self, space, w_type, itemcount=0): # similar to PyType_GenericAlloc? @@ -109,10 +107,8 @@ return tp_alloc(space, w_type, itemcount) if tp_dealloc: - def get_dealloc(self, space): - return llhelper( - tp_dealloc.api_func.functype, - tp_dealloc.api_func.get_wrapper(space)) + def get_dealloc(self): + return tp_dealloc if tp_attach: def attach(self, space, pyobj, w_obj): diff --git a/pypy/module/cpyext/slotdefs.py b/pypy/module/cpyext/slotdefs.py --- a/pypy/module/cpyext/slotdefs.py +++ b/pypy/module/cpyext/slotdefs.py @@ -59,6 +59,9 @@ "expected %d-%d arguments, got %d", low, high, space.len_w(w_ob)) +def llslot(space, func): + return llhelper(func.api_func.functype, func.api_func.get_wrapper(space)) + def wrap_init(space, w_self, w_args, func, w_kwargs): func_init = rffi.cast(initproc, func) res = generic_cpy_call(space, func_init, w_self, w_args, w_kwargs) @@ -446,7 +449,6 @@ @func_renamer("cpyext_%s_%s" % (name.replace('.', '_'), typedef.name)) def slot_func(space, w_self): return space.call_function(slot_fn, w_self) - api_func = slot_func.api_func handled = True # binary functions @@ -473,7 +475,6 @@ @func_renamer("cpyext_%s_%s" % (name.replace('.', '_'), typedef.name)) def slot_func(space, w_self, w_arg): return space.call_function(slot_fn, w_self, w_arg) - api_func = slot_func.api_func handled = True # binary-with-Py_ssize_t-type @@ -491,7 +492,6 @@ @func_renamer("cpyext_%s_%s" % (name.replace('.', '_'), typedef.name)) def slot_func(space, w_self, arg): return space.call_function(slot_fn, w_self, space.wrap(arg)) - api_func = slot_func.api_func handled = True # ternary functions @@ -506,7 +506,6 @@ @func_renamer("cpyext_%s_%s" % (name.replace('.', '_'), typedef.name)) def slot_func(space, w_self, w_arg1, w_arg2): return space.call_function(slot_fn, w_self, w_arg1, w_arg2) - api_func = slot_func.api_func handled = True if handled: @@ -526,7 +525,7 @@ else: space.call_function(delattr_fn, w_self, w_name) return 0 - api_func = slot_tp_setattro.api_func + slot_func = slot_tp_setattro elif name == 'tp_getattro': getattr_fn = w_type.getdictvalue(space, '__getattribute__') if getattr_fn is None: @@ -536,7 +535,7 @@ @func_renamer("cpyext_tp_getattro_%s" % (typedef.name,)) def slot_tp_getattro(space, w_self, w_name): return space.call_function(getattr_fn, w_self, w_name) - api_func = slot_tp_getattro.api_func + slot_func = slot_tp_getattro elif name == 'tp_call': call_fn = w_type.getdictvalue(space, '__call__') @@ -549,7 +548,7 @@ args = Arguments(space, [w_self], w_stararg=w_args, w_starstararg=w_kwds) return space.call_args(call_fn, args) - api_func = slot_tp_call.api_func + slot_func = slot_tp_call elif name == 'tp_iternext': iternext_fn = w_type.getdictvalue(space, '__next__') @@ -565,7 +564,7 @@ if not e.match(space, space.w_StopIteration): raise return None - api_func = slot_tp_iternext.api_func + slot_func = slot_tp_iternext elif name == 'tp_init': init_fn = w_type.getdictvalue(space, '__init__') @@ -580,7 +579,7 @@ w_stararg=w_args, w_starstararg=w_kwds) space.call_args(init_fn, args) return 0 - api_func = slot_tp_init.api_func + slot_func = slot_tp_init elif name == 'tp_new': new_fn = w_type.getdictvalue(space, '__new__') if new_fn is None: @@ -592,7 +591,7 @@ args = Arguments(space, [w_self], w_stararg=w_args, w_starstararg=w_kwds) return space.call_args(space.get(new_fn, w_self), args) - api_func = slot_tp_new.api_func + slot_func = slot_tp_new elif name == 'tp_as_buffer.c_bf_getbuffer': buff_fn = w_type.getdictvalue(space, '__buffer__') if buff_fn is None: @@ -621,14 +620,14 @@ return 0 # XXX remove this when it no longer crashes a translated PyPy return - api_func = buff_w.api_func + slot_func = buff_w else: # missing: tp_as_number.nb_nonzero, tp_as_number.nb_coerce # tp_as_sequence.c_sq_contains, tp_as_sequence.c_sq_length # richcmpfunc(s) return - return lambda: llhelper(api_func.functype, api_func.get_wrapper(space)) + return slot_func PyWrapperFlag_KEYWORDS = 1 diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py --- a/pypy/module/cpyext/typeobject.py +++ b/pypy/module/cpyext/typeobject.py @@ -3,7 +3,6 @@ from rpython.rlib import jit from rpython.rlib.objectmodel import specialize from rpython.rlib.rstring import rsplit -from rpython.rtyper.annlowlevel import llhelper from rpython.rtyper.lltypesystem import rffi, lltype from pypy.interpreter.baseobjspace import W_Root, DescrMismatch @@ -27,7 +26,8 @@ PyObject, make_ref, create_ref, from_ref, get_typedescr, make_typedescr, track_reference, Py_DecRef, as_pyobj) from pypy.module.cpyext.slotdefs import ( - slotdefs_for_tp_slots, slotdefs_for_wrappers, get_slot_tp_function) + slotdefs_for_tp_slots, slotdefs_for_wrappers, get_slot_tp_function, + llslot) from pypy.module.cpyext.state import State from pypy.module.cpyext.structmember import PyMember_GetOne, PyMember_SetOne from pypy.module.cpyext.typeobjectdefs import ( @@ -252,21 +252,14 @@ # XXX special case iternext continue - slot_func_helper = None - if slot_func is None and typedef is not None: - get_slot = get_slot_tp_function(space, typedef, slot_name) - if get_slot: - slot_func_helper = get_slot() - elif slot_func: - slot_func_helper = llhelper(slot_func.api_func.functype, - slot_func.api_func.get_wrapper(space)) - - if slot_func_helper is None: + slot_func = get_slot_tp_function(space, typedef, slot_name) + if not slot_func: if WARN_ABOUT_MISSING_SLOT_FUNCTIONS: os.write(2, "%s defined by %s but no slot function defined!\n" % ( method_name, w_type.getname(space))) continue + slot_func_helper = llslot(space, slot_func) # XXX special case wrapper-functions and use a "specific" slot func @@ -372,9 +365,8 @@ def setup_new_method_def(space): ptr = get_new_method_def(space) - ptr.c_ml_meth = rffi.cast(PyCFunction_typedef, - llhelper(tp_new_wrapper.api_func.functype, - tp_new_wrapper.api_func.get_wrapper(space))) + ptr.c_ml_meth = rffi.cast( + PyCFunction_typedef, llslot(space, tp_new_wrapper)) def add_tp_new_wrapper(space, dict_w, pto): if "__new__" in dict_w: @@ -495,8 +487,7 @@ def subtype_dealloc(space, obj): pto = obj.c_ob_type base = pto - this_func_ptr = llhelper(subtype_dealloc.api_func.functype, - subtype_dealloc.api_func.get_wrapper(space)) + this_func_ptr = llslot(space, subtype_dealloc) while base.c_tp_dealloc == this_func_ptr: base = base.c_tp_base assert base @@ -519,9 +510,7 @@ def setup_bytes_buffer_procs(space, pto): c_buf = lltype.malloc(PyBufferProcs, flavor='raw', zero=True) lltype.render_immortal(c_buf) - c_buf.c_bf_getbuffer = llhelper( - bytes_getbuffer.api_func.functype, - bytes_getbuffer.api_func.get_wrapper(space)) + c_buf.c_bf_getbuffer = llslot(space, bytes_getbuffer) pto.c_tp_as_buffer = c_buf pto.c_tp_flags |= Py_TPFLAGS_HAVE_GETCHARBUFFER @@ -581,12 +570,10 @@ # dealloc if space.gettypeobject(w_type.layout.typedef) is w_type: # only for the exact type, like 'space.w_tuple' or 'space.w_list' - pto.c_tp_dealloc = typedescr.get_dealloc(space) + pto.c_tp_dealloc = llslot(space, typedescr.get_dealloc()) else: # for all subtypes, use subtype_dealloc() - pto.c_tp_dealloc = llhelper( - subtype_dealloc.api_func.functype, - subtype_dealloc.api_func.get_wrapper(space)) + pto.c_tp_dealloc = llslot(space, subtype_dealloc) if space.is_w(w_type, space.w_str): pto.c_tp_itemsize = 1 elif space.is_w(w_type, space.w_tuple): @@ -595,10 +582,8 @@ if space.is_w(w_type, space.w_str): setup_bytes_buffer_procs(space, pto) - pto.c_tp_free = llhelper(PyObject_Free.api_func.functype, - PyObject_Free.api_func.get_wrapper(space)) - pto.c_tp_alloc = llhelper(PyType_GenericAlloc.api_func.functype, - PyType_GenericAlloc.api_func.get_wrapper(space)) + pto.c_tp_free = llslot(space, PyObject_Free) + pto.c_tp_alloc = llslot(space, PyType_GenericAlloc) builder = space.fromcache(StaticObjectBuilder) if ((pto.c_tp_flags & Py_TPFLAGS_HEAPTYPE) != 0 and builder.cpyext_type_init is None): @@ -780,15 +765,11 @@ if not pto.c_tp_setattro: from pypy.module.cpyext.object import PyObject_GenericSetAttr - pto.c_tp_setattro = llhelper( - PyObject_GenericSetAttr.api_func.functype, - PyObject_GenericSetAttr.api_func.get_wrapper(space)) + pto.c_tp_setattro = llslot(space, PyObject_GenericSetAttr) if not pto.c_tp_getattro: from pypy.module.cpyext.object import PyObject_GenericGetAttr - pto.c_tp_getattro = llhelper( - PyObject_GenericGetAttr.api_func.functype, - PyObject_GenericGetAttr.api_func.get_wrapper(space)) + pto.c_tp_getattro = llslot(space, PyObject_GenericGetAttr) if w_obj.is_cpytype(): Py_DecRef(space, pto.c_tp_dict) diff --git a/rpython/jit/backend/ppc/regalloc.py b/rpython/jit/backend/ppc/regalloc.py --- a/rpython/jit/backend/ppc/regalloc.py +++ b/rpython/jit/backend/ppc/regalloc.py @@ -1066,7 +1066,6 @@ prepare_cond_call_value_r = prepare_cond_call_value_i - def notimplemented(self, op): msg = '[PPC/regalloc] %s not implemented\n' % op.getopname() if we_are_translated(): diff --git a/rpython/jit/backend/zarch/opassembler.py b/rpython/jit/backend/zarch/opassembler.py --- a/rpython/jit/backend/zarch/opassembler.py +++ b/rpython/jit/backend/zarch/opassembler.py @@ -374,10 +374,11 @@ _COND_CALL_SAVE_REGS = [r.r11, r.r2, r.r3, r.r4, r.r5] def emit_cond_call(self, op, arglocs, regalloc): + resloc = arglocs[0] + arglocs = arglocs[1:] fcond = self.guard_success_cc self.guard_success_cc = c.cond_none assert fcond.value != c.cond_none.value - fcond = c.negate(fcond) jmp_adr = self.mc.get_relative_pos() self.mc.reserve_cond_jump() # patched later to a relative branch @@ -411,6 +412,8 @@ self.mc.BASR(r.r14, r.r14) # restoring the registers saved above, and doing pop_gcmap(), is left # to the cond_call_slowpath helper. We never have any result value. + if resloc is not None: + self.mc.LGR(resloc, r.RES) relative_target = self.mc.currpos() - jmp_adr pmc = OverwritingBuilder(self.mc, jmp_adr, 1) pmc.BRCL(fcond, l.imm(relative_target)) @@ -419,6 +422,9 @@ # guard_no_exception too self.previous_cond_call_jcond = jmp_adr, fcond + emit_cond_call_value_i = emit_cond_call + emit_cond_call_value_r = emit_cond_call + class AllocOpAssembler(object): _mixin_ = True diff --git a/rpython/jit/backend/zarch/regalloc.py b/rpython/jit/backend/zarch/regalloc.py --- a/rpython/jit/backend/zarch/regalloc.py +++ b/rpython/jit/backend/zarch/regalloc.py @@ -1107,7 +1107,7 @@ def prepare_cond_call(self, op): self.load_condition_into_cc(op.getarg(0)) - locs = [] + locs = [None] # support between 0 and 4 integer arguments assert 2 <= op.numargs() <= 2 + 4 for i in range(1, op.numargs()): @@ -1116,6 +1116,22 @@ locs.append(loc) return locs + def prepare_cond_call_value_i(self, op): + x = self.ensure_reg(op.getarg(0)) + self.load_condition_into_cc(op.getarg(0)) + self.rm.force_allocate_reg(op, selected_reg=x) # spilled if survives + # ^^^ if arg0!=0, we jump over the next block of code (the call) + locs = [x] + # support between 0 and 4 integer arguments + assert 2 <= op.numargs() <= 2 + 4 + for i in range(1, op.numargs()): + loc = self.loc(op.getarg(i)) + assert loc.type != FLOAT + locs.append(loc) + return locs # [res, function, args...] + + prepare_cond_call_value_r = prepare_cond_call_value_i + def prepare_cond_call_gc_wb(self, op): arglocs = [self.ensure_reg(op.getarg(0))] return arglocs _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit