[pypy-commit] pypy py3.5: Try to re-add some JIT-friendliness

arigo pypy.commits at gmail.com
Wed Nov 30 13:06:32 EST 2016


Author: Armin Rigo <arigo at tunes.org>
Branch: py3.5
Changeset: r88781:4622e566448f
Date: 2016-11-30 18:20 +0100
http://bitbucket.org/pypy/pypy/changeset/4622e566448f/

Log:	Try to re-add some JIT-friendliness

diff --git a/pypy/module/__builtin__/descriptor.py b/pypy/module/__builtin__/descriptor.py
--- a/pypy/module/__builtin__/descriptor.py
+++ b/pypy/module/__builtin__/descriptor.py
@@ -1,3 +1,4 @@
+from rpython.rlib import jit
 from pypy.interpreter.baseobjspace import W_Root
 from pypy.interpreter.error import OperationError, oefmt
 from pypy.interpreter.gateway import WrappedDefault, interp2app, unwrap_spec
@@ -67,35 +68,43 @@
         # fallback to object.__getattribute__()
         return space.call_function(object_getattribute(space), self, w_name)
 
-def _super_from_frame(space, frame):
-    """super() without args -- fill in from __class__ and first local
-    variable on the stack.
-    """
-    code = frame.pycode
-    if not code:
-        raise oefmt(space.w_RuntimeError, "super(): no code object")
+ at jit.elidable
+def _get_self_location(space, code):
     if code.co_argcount == 0:
         raise oefmt(space.w_RuntimeError, "super(): no arguments")
     args_to_copy = code._args_as_cellvars
     for i in range(len(args_to_copy)):
         if args_to_copy[i] == 0:
-            w_obj = frame._getcell(i).w_value
+            self_cell = i
             break
     else:
-        w_obj = frame.locals_cells_stack_w[0]
-    if not w_obj:
-        raise oefmt(space.w_RuntimeError, "super(): arg[0] deleted")
+        self_cell = -1
 
     for index, name in enumerate(code.co_freevars):
         if name == '__class__':
             break
     else:
         raise oefmt(space.w_RuntimeError, "super(): __class__ cell not found")
+    class_cell = len(code.co_cellvars) + index
+    return self_cell, class_cell
+
+def _super_from_frame(space, frame):
+    """super() without args -- fill in from __class__ and first local
+    variable on the stack.
+    """
+    if frame is None:
+        raise oefmt(space.w_RuntimeError, "super(): no frame object")
+    self_cell, class_cell = _get_self_location(space, frame.getcode())
+    if self_cell < 0:
+        w_obj = frame.locals_cells_stack_w[0]
+    else:
+        w_obj = frame._getcell(self_cell).w_value
+    if not w_obj:
+        raise oefmt(space.w_RuntimeError, "super(): arg[0] deleted")
+
     # a kind of LOAD_DEREF
-    cell = frame._getcell(len(code.co_cellvars) + index)
-    try:
-        w_starttype = cell.get()
-    except ValueError:
+    w_starttype = frame._getcell(class_cell).w_value
+    if w_starttype is None:
         raise oefmt(space.w_RuntimeError, "super(): empty __class__ cell")
     return w_starttype, w_obj
 


More information about the pypy-commit mailing list