[pypy-svn] r31702 - in pypy/dist/pypy/jit: codegen/i386 codegen/i386/test timeshifter timeshifter/test

arigo at codespeak.net arigo at codespeak.net
Sun Aug 27 11:27:38 CEST 2006


Author: arigo
Date: Sun Aug 27 11:27:33 2006
New Revision: 31702

Modified:
   pypy/dist/pypy/jit/codegen/i386/codebuf.py
   pypy/dist/pypy/jit/codegen/i386/ri386genop.py
   pypy/dist/pypy/jit/codegen/i386/test/test_genc_ts.py
   pypy/dist/pypy/jit/codegen/i386/test/test_interp_ts.py
   pypy/dist/pypy/jit/timeshifter/test/test_timeshift.py
   pypy/dist/pypy/jit/timeshifter/timeshift.py
Log:
- do a single annhelper.finish() again.  Helps avoid obscure
  re-annotation problems for now.
- fix argument decoding for test_timeshift.
- make test_interp_ts pass some tests (it's only checking that
  code generation doesn't explode).
- started AddrConst for struct tests.


Modified: pypy/dist/pypy/jit/codegen/i386/codebuf.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/i386/codebuf.py	(original)
+++ pypy/dist/pypy/jit/codegen/i386/codebuf.py	Sun Aug 27 11:27:33 2006
@@ -50,11 +50,19 @@
 BUF = lltype.GcArray(lltype.Char)
 
 class LLTypeMachineCodeBlock(AbstractCodeBuilder):
+    # for testing only
+
+    class State:
+        pass
+    state = State()
+    state.base = 1
 
     def __init__(self, map_size):
         self._size = map_size
         self._pos = 0
         self._data = lltype.malloc(BUF, map_size)
+        self._base = LLTypeMachineCodeBlock.state.base
+        LLTypeMachineCodeBlock.state.base += 2 * map_size
 
     def write(self, data):
         p = self._pos
@@ -66,4 +74,4 @@
         self._pos = p
 
     def tell(self):
-        return self._pos
+        return self._base + 2 * self._pos

Modified: pypy/dist/pypy/jit/codegen/i386/ri386genop.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/i386/ri386genop.py	(original)
+++ pypy/dist/pypy/jit/codegen/i386/ri386genop.py	Sun Aug 27 11:27:33 2006
@@ -80,6 +80,24 @@
         self.mc = mc    # to keep it alive
 
 
+class AddrConst(GenConst):
+
+    def __init__(self, addr):
+        self.addr = addr
+
+    def operand(self, block):
+        return imm(llmemory.cast_adr_to_int(self.addr))
+
+    def revealconst(self, T):
+        if T is llmemory.Address:
+            return self.addr
+        elif isinstance(T, lltype.Ptr):
+            return llmemory.cast_adr_to_ptr(self.addr, T)
+        else:
+            assert 0, "XXX not implemented"
+    revealconst._annspecialcase_ = 'specialize:arg(1)'
+
+
 class Block(CodeGenBlock):
     def __init__(self, rgenop, mc):
         self.rgenop = rgenop
@@ -340,8 +358,14 @@
 
     def genconst(llvalue):
         T = lltype.typeOf(llvalue)
-        assert isinstance(T, lltype.Primitive)
-        return IntConst(lltype.cast_primitive(lltype.Signed, llvalue))
+        if isinstance(T, lltype.Primitive):
+            return IntConst(lltype.cast_primitive(lltype.Signed, llvalue))
+        elif T is llmemory.Address:
+            return AddrConst(llvalue)
+        elif isinstance(T, lltype.Ptr):
+            return AddrConst(llmemory.cast_ptr_to_adr(llvalue))
+        else:
+            assert 0, "XXX not implemented"
     genconst._annspecialcase_ = 'specialize:genconst(0)'
     genconst = staticmethod(genconst)
 

Modified: pypy/dist/pypy/jit/codegen/i386/test/test_genc_ts.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/i386/test/test_genc_ts.py	(original)
+++ pypy/dist/pypy/jit/codegen/i386/test/test_genc_ts.py	Sun Aug 27 11:27:33 2006
@@ -81,15 +81,15 @@
         self.timeshift_cached(ll_function, values, *args, **kwds)
 
         mainargs = []
-        for i, (color, llvalue) in enumerate(zip(self.argcolors, values)):
+        for i, (color, strvalue) in enumerate(zip(self.argcolors, values)):
             if color == "green":
-                mainargs.append(llvalue)
+                mainargs.append(strvalue)
             else:
                 if i in opt_consts:
                     mainargs.append('-const')
                 else:
                     mainargs.append('-var')
-                mainargs.append(llvalue)
+                mainargs.append(strvalue)
 
         mainargs = ' '.join([str(arg) for arg in mainargs])
 

Modified: pypy/dist/pypy/jit/codegen/i386/test/test_interp_ts.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/i386/test/test_interp_ts.py	(original)
+++ pypy/dist/pypy/jit/codegen/i386/test/test_interp_ts.py	Sun Aug 27 11:27:33 2006
@@ -1,17 +1,27 @@
 import os
 from pypy.annotation import model as annmodel
 from pypy.jit.timeshifter.test import test_timeshift
-from pypy.jit.codegen.i386.ri386genop import RI386GenOp
+from pypy.jit.codegen.i386.ri386genop import RI386GenOp, IntConst
 
 import py; py.test.skip("in-progress")
 
 
+class Whatever(object):
+    def __eq__(self, other):
+        return True
+
+
 class TestTimeshiftI386LLInterp(test_timeshift.TestTimeshift):
     class RGenOp(RI386GenOp):
         from pypy.jit.codegen.i386.codebuf import LLTypeMachineCodeBlock as MachineCodeBlock
-    
+
+        def constFieldName(T, name):
+            return IntConst(list(T._names).index(name))
+        constFieldName._annspecialcase_ = 'specialize:memo'
+        constFieldName = staticmethod(constFieldName)
+
     def timeshift(self, ll_function, values, opt_consts=[], *args, **kwds):
-        self.timeshift_cached(ll_function, values, *args, **kwds)
+        values = self.timeshift_cached(ll_function, values, *args, **kwds)
 
         mainargs = []
         residualargs = []
@@ -30,6 +40,11 @@
 
         # XXX test more
 
+        return Whatever()
+
+    def check_insns(self, expected=None, **counts):
+        pass
+
 
     # for the individual tests see
     # ====> ../../../timeshifter/test/test_timeshift.py

Modified: pypy/dist/pypy/jit/timeshifter/test/test_timeshift.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/test/test_timeshift.py	(original)
+++ pypy/dist/pypy/jit/timeshifter/test/test_timeshift.py	Sun Aug 27 11:27:33 2006
@@ -72,7 +72,7 @@
         else:
             self.__dict__.update(cache)
             assert argtypes == getargtypes(self.rtyper.annotator, values)
-            return
+            return values
 
         if len(self._cache_order) >= 3:
             del self._cache[self._cache_order.pop(0)]
@@ -203,6 +203,7 @@
         cache = self.__dict__.copy()
         self._cache[key] = cache, getargtypes(rtyper.annotator, values)
         self._cache_order.append(key)
+        return values
 
     def annotate_interface_functions(self):
         annhelper = self.htshift.annhelper
@@ -229,7 +230,7 @@
         annhelper.finish()
 
     def timeshift(self, ll_function, values, opt_consts=[], *args, **kwds):
-        self.timeshift_cached(ll_function, values, *args, **kwds)
+        values = self.timeshift_cached(ll_function, values, *args, **kwds)
 
         mainargs = []
         residualargs = []

Modified: pypy/dist/pypy/jit/timeshifter/timeshift.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/timeshift.py	(original)
+++ pypy/dist/pypy/jit/timeshifter/timeshift.py	Sun Aug 27 11:27:33 2006
@@ -51,49 +51,49 @@
         self.r_box_accum = getrepr(self.s_box_accum)
         self.r_box_accum.setup()
 
-        def ll_make_builder():
-            rgenop = RGenOp()
-            return rtimeshift.make_builder(rgenop)
-
-        # XXX find a different way to enforce the interface types
-        self.ll_make_builder_graph = self.annhelper.getgraph(
-            ll_make_builder,
-            [], self.s_ResidualGraphBuilder)
-        self.ll_int_box_graph = self.annhelper.getgraph(
-            rtimeshift.ll_int_box,
-            [self.s_ConstOrVar, self.s_ConstOrVar],
-            self.s_RedBox)
-        self.ll_addr_box_graph = self.annhelper.getgraph(
-            rtimeshift.ll_addr_box,
-            [self.s_ConstOrVar, self.s_ConstOrVar],
-            self.s_RedBox)
-        self.ll_double_box_graph = self.annhelper.getgraph(
-            rtimeshift.ll_int_box,
-            [self.s_ConstOrVar, self.s_ConstOrVar],
-            self.s_RedBox)
-        self.ll_geninputarg_graph = self.annhelper.getgraph(
-            rtimeshift.ll_geninputarg,
-            [self.s_ResidualGraphBuilder, self.s_ConstOrVar],
-            self.s_ConstOrVar)
-        self.ll_end_setup_builder_graph = self.annhelper.getgraph(
-            rtimeshift.ll_end_setup_builder,
-            [self.s_ResidualGraphBuilder],
-            self.s_Block)
-
-##         self.ll_close_jitstate_graph = self.annhelper.getgraph(
-##             rtimeshift.ll_close_jitstate,
-##             [self.s_JITState],
-##             annmodel.s_None)
-
-        self.ll_close_builder_graph = self.annhelper.getgraph(
-            rtimeshift.ll_close_builder,
-            [self.s_ResidualGraphBuilder],
-            annmodel.s_None)
-        self.annhelper.getgraph(
-            rtimeshift.ll_gencallableconst,
-            [self.s_ResidualGraphBuilder, annmodel.SomeString(),
-             self.s_Block, self.s_ConstOrVar],
-            self.s_ConstOrVar)
+##        def ll_make_builder():
+##            rgenop = RGenOp()
+##            return rtimeshift.make_builder(rgenop)
+
+##        # XXX find a different way to enforce the interface types
+##        self.ll_make_builder_graph = self.annhelper.getgraph(
+##            ll_make_builder,
+##            [], self.s_ResidualGraphBuilder)
+##        self.ll_int_box_graph = self.annhelper.getgraph(
+##            rtimeshift.ll_int_box,
+##            [self.s_ConstOrVar, self.s_ConstOrVar],
+##            self.s_RedBox)
+##        self.ll_addr_box_graph = self.annhelper.getgraph(
+##            rtimeshift.ll_addr_box,
+##            [self.s_ConstOrVar, self.s_ConstOrVar],
+##            self.s_RedBox)
+##        self.ll_double_box_graph = self.annhelper.getgraph(
+##            rtimeshift.ll_int_box,
+##            [self.s_ConstOrVar, self.s_ConstOrVar],
+##            self.s_RedBox)
+##        self.ll_geninputarg_graph = self.annhelper.getgraph(
+##            rtimeshift.ll_geninputarg,
+##            [self.s_ResidualGraphBuilder, self.s_ConstOrVar],
+##            self.s_ConstOrVar)
+##        self.ll_end_setup_builder_graph = self.annhelper.getgraph(
+##            rtimeshift.ll_end_setup_builder,
+##            [self.s_ResidualGraphBuilder],
+##            self.s_Block)
+
+####         self.ll_close_jitstate_graph = self.annhelper.getgraph(
+####             rtimeshift.ll_close_jitstate,
+####             [self.s_JITState],
+####             annmodel.s_None)
+
+##        self.ll_close_builder_graph = self.annhelper.getgraph(
+##            rtimeshift.ll_close_builder,
+##            [self.s_ResidualGraphBuilder],
+##            annmodel.s_None)
+##        self.annhelper.getgraph(
+##            rtimeshift.ll_gencallableconst,
+##            [self.s_ResidualGraphBuilder, annmodel.SomeString(),
+##             self.s_Block, self.s_ConstOrVar],
+##            self.s_ConstOrVar)
 
     def s_r_instanceof(self, cls, can_be_None=True):
         # Return a SomeInstance / InstanceRepr pair correspnding to the specified class.
@@ -167,7 +167,7 @@
             self.timeshift_graph(graph)
         
         # Annotate and rtype the helpers found during timeshifting
-        self.annhelper.finish()
+        # XXX XXX XXX -- self.annhelper.finish() -- XXX XXX XXX
 
     def timeshift_graph(self, graph):
         #print 'timeshift_graph START', graph



More information about the Pypy-commit mailing list