[pypy-svn] r62312 - in pypy/trunk/pypy: interpreter interpreter/astcompiler objspace/flow/test tool

afa at codespeak.net afa at codespeak.net
Sun Mar 1 22:22:46 CET 2009


Author: afa
Date: Sun Mar  1 22:22:45 2009
New Revision: 62312

Modified:
   pypy/trunk/pypy/interpreter/astcompiler/pyassem.py
   pypy/trunk/pypy/interpreter/pyopcode.py
   pypy/trunk/pypy/objspace/flow/test/test_objspace.py
   pypy/trunk/pypy/tool/stdlib_opcode.py
Log:
Some progress towards supporting CPython2.6 for the pypy toolchain:
the Flow Object Space is allowed to interpret the new 2.6 bytecodes.

I hope I understand the "we_are_translated()" stuff correctly;
and what about applevel code?


Modified: pypy/trunk/pypy/interpreter/astcompiler/pyassem.py
==============================================================================
--- pypy/trunk/pypy/interpreter/astcompiler/pyassem.py	(original)
+++ pypy/trunk/pypy/interpreter/astcompiler/pyassem.py	Sun Mar  1 22:22:45 2009
@@ -535,6 +535,7 @@
         'DELETE_GLOBAL': 0,
         'STORE_DEREF': -1,
         'BUILD_MAP': 1,
+        'STORE_MAP': -2,
         'COMPARE_OP': -1,
         'STORE_FAST': -1,
         'DELETE_FAST': 0,

Modified: pypy/trunk/pypy/interpreter/pyopcode.py
==============================================================================
--- pypy/trunk/pypy/interpreter/pyopcode.py	(original)
+++ pypy/trunk/pypy/interpreter/pyopcode.py	Sun Mar  1 22:22:45 2009
@@ -699,12 +699,26 @@
         w_list = f.space.newlist(items)
         f.pushvalue(w_list)
 
-    def BUILD_MAP(f, zero, *ignored):
-        if zero != 0:
-            raise BytecodeCorruption
+    def BUILD_MAP(f, itemcount, *ignored):
+        if not we_are_translated() and sys.version_info >= (2, 6):
+            # We could pre-allocate a dict here
+            # but for the moment this code is not translated.
+            pass
+        else:
+            if itemcount != 0:
+                raise BytecodeCorruption
         w_dict = f.space.newdict()
         f.pushvalue(w_dict)
 
+    def STORE_MAP(f, zero, *ignored):
+        if not we_are_translated() and sys.version_info >= (2, 6):
+            w_key = f.popvalue()
+            w_value = f.popvalue()
+            w_dict = f.peekvalue()
+            f.space.setitem(w_dict, w_key, w_value)
+        else:
+            raise BytecodeCorruption
+
     def LOAD_ATTR(f, nameindex, *ignored):
         "obj.attributename"
         w_attributename = f.getname_w(nameindex)

Modified: pypy/trunk/pypy/objspace/flow/test/test_objspace.py
==============================================================================
--- pypy/trunk/pypy/objspace/flow/test/test_objspace.py	(original)
+++ pypy/trunk/pypy/objspace/flow/test/test_objspace.py	Sun Mar  1 22:22:45 2009
@@ -469,6 +469,14 @@
         x = self.codetest(self.globalconstdict)
 
     #__________________________________________________________
+    def dictliteral(name):
+        x = {'x': 1}
+        return x
+    
+    def test_dictliteral(self):
+        x = self.codetest(self.dictliteral)
+
+    #__________________________________________________________
     
     def specialcases(x):
         operator.lt(x,3)

Modified: pypy/trunk/pypy/tool/stdlib_opcode.py
==============================================================================
--- pypy/trunk/pypy/tool/stdlib_opcode.py	(original)
+++ pypy/trunk/pypy/tool/stdlib_opcode.py	Sun Mar  1 22:22:45 2009
@@ -74,4 +74,10 @@
 lst.sort()
 unrolling_opcode_descs = unrolling_iterable(lst)
 
+# Allow non-translated code to interpret the new 2.6 bytecodes
+import sys
+if sys.version_info >= (2, 6):
+    import opcode
+    opcode_method_names[opcode.opmap['STORE_MAP']] = 'STORE_MAP'
+
 del name, index, desc, lst



More information about the Pypy-commit mailing list