[pypy-svn] r60515 - pypy/branch/oo-jit/pypy/jit/tl

antocuni at codespeak.net antocuni at codespeak.net
Tue Dec 16 17:47:03 CET 2008


Author: antocuni
Date: Tue Dec 16 17:47:02 2008
New Revision: 60515

Modified:
   pypy/branch/oo-jit/pypy/jit/tl/tlc.py
   pypy/branch/oo-jit/pypy/jit/tl/tlopcode.py
Log:
two new opcodes, useful for debugging



Modified: pypy/branch/oo-jit/pypy/jit/tl/tlc.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/tl/tlc.py	(original)
+++ pypy/branch/oo-jit/pypy/jit/tl/tlc.py	Tue Dec 16 17:47:02 2008
@@ -2,7 +2,7 @@
 
 import autopath
 import py
-from pypy.rlib.objectmodel import specialize
+from pypy.rlib.objectmodel import specialize, we_are_translated
 from pypy.jit.tl.tlopcode import *
 from pypy.jit.tl import tlopcode
 from pypy.rlib.jit import hint
@@ -12,6 +12,7 @@
     def t(self): raise TypeError
 
     def int_o(self): raise TypeError
+    def to_string(self): raise TypeError
     
     def add(self, other): raise TypeError
     def sub(self, other): raise TypeError
@@ -102,6 +103,9 @@
         cls = hint(self.cls, promote=True)
         return hint(cls, deepfreeze=True)
 
+    def to_string(self):
+        return '<Object>'
+
     def t(self):
         return True
 
@@ -132,6 +136,9 @@
     def int_o(self):
         return self.value
 
+    def to_string(self):
+        return str(self.value)
+
     def add(self, other): return IntObj(self.value + other.int_o())
     def sub(self, other): return IntObj(self.value - other.int_o())
     def mul(self, other): return IntObj(self.value * other.int_o())
@@ -159,6 +166,9 @@
 
 class NilObj(LispObj):
 
+    def to_string(self):
+        return 'nil'
+
     def t(self):
         return False
 
@@ -178,6 +188,9 @@
         self._car = car
         self._cdr = cdr
 
+    def to_string(self):
+        return '<ConsObj>'
+
     def t(self):
         return True
 
@@ -454,6 +467,19 @@
                 args = meth_args
                 stack = []
 
+            elif opcode == PRINT:
+                if not we_are_translated():
+                    a = stack.pop()
+                    hint(a, promote_class=True)
+
+            elif opcode == DUMP:
+                if not we_are_translated():
+                    parts = []
+                    for obj in stack:
+                        hint(obj, promote_class=True)
+                        parts.append(obj.to_string())
+                    print '[%s]' % ', '.join(parts)
+
             else:
                 raise RuntimeError("unknown opcode: " + str(opcode))
 

Modified: pypy/branch/oo-jit/pypy/jit/tl/tlopcode.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/tl/tlopcode.py	(original)
+++ pypy/branch/oo-jit/pypy/jit/tl/tlopcode.py	Tue Dec 16 17:47:02 2008
@@ -51,6 +51,9 @@
 opcode(31, "SEND")
 opcode(32, "PUSHARGN")
 
+opcode(33, "PRINT")
+opcode(34, "DUMP")
+
 del opcode
 
 



More information about the Pypy-commit mailing list