[pypy-commit] pypy py3.6: make BUILD_CONST_KEY_MAP JIT-friendly

cfbolz pypy.commits at gmail.com
Mon Feb 18 05:59:43 EST 2019


Author: Carl Friedrich Bolz-Tereick <cfbolz at gmx.de>
Branch: py3.6
Changeset: r96053:2e21aa817a15
Date: 2019-02-18 11:58 +0100
http://bitbucket.org/pypy/pypy/changeset/2e21aa817a15/

Log:	make BUILD_CONST_KEY_MAP JIT-friendly

diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -1442,11 +1442,15 @@
 
     @jit.unroll_safe
     def BUILD_CONST_KEY_MAP(self, itemcount, next_instr):
-        keys_w = self.space.fixedview(self.popvalue())
+        from pypy.objspace.std.tupleobject import W_AbstractTupleObject
+        # the reason why we don't use space.fixedview here is that then the
+        # immutability of the tuple would not propagate into the loop below in
+        # the JIT
+        w_keys = self.space.interp_w(W_AbstractTupleObject, self.popvalue())
         w_dict = self.space.newdict()
         for i in range(itemcount):
             w_value = self.peekvalue(itemcount - 1 - i)
-            w_key = keys_w[i]
+            w_key = w_keys.getitem(self.space, i)
             self.space.setitem(w_dict, w_key, w_value)
         self.dropvalues(itemcount)
         self.pushvalue(w_dict)


More information about the pypy-commit mailing list