Author: Maciej Fijalkowski <[email protected]>
Branch: result-in-resops
Changeset: r57404:6b0a9d86251d
Date: 2012-09-20 15:08 +0200
http://bitbucket.org/pypy/pypy/changeset/6b0a9d86251d/

Log:    hack enough to make test_llgraph pass again

diff --git a/pypy/jit/backend/llgraph/llimpl.py 
b/pypy/jit/backend/llgraph/llimpl.py
--- a/pypy/jit/backend/llgraph/llimpl.py
+++ b/pypy/jit/backend/llgraph/llimpl.py
@@ -7,8 +7,7 @@
 import weakref
 from pypy.objspace.flow.model import Variable, Constant
 from pypy.annotation import model as annmodel
-from pypy.jit.metainterp.history import REF, INT, FLOAT
-from pypy.jit.metainterp import history
+from pypy.jit.metainterp.resoperation import REF, INT, FLOAT
 from pypy.jit.codewriter import heaptracker
 from pypy.rpython.lltypesystem import lltype, llmemory, rclass, rstr, rffi
 from pypy.rpython.ootypesystem import ootype
diff --git a/pypy/jit/backend/llgraph/runner.py 
b/pypy/jit/backend/llgraph/runner.py
--- a/pypy/jit/backend/llgraph/runner.py
+++ b/pypy/jit/backend/llgraph/runner.py
@@ -169,12 +169,12 @@
 
     def _compile_loop_or_bridge(self, c, inputargs, operations, clt):
         for box in inputargs:
-            if isinstance(box, history.BoxInt):
+            if isinstance(box, resoperation.BoxInt):
                 r = llimpl.compile_start_int_var(c)
             elif isinstance(box, self.ts.BoxRef):
                 TYPE = self.ts.BASETYPE
                 r = llimpl.compile_start_ref_var(c, TYPE)
-            elif isinstance(box, history.BoxFloat):
+            elif isinstance(box, resoperation.BoxFloat):
                 r = llimpl.compile_start_float_var(c)
             else:
                 raise Exception("box is: %r" % (box,))
@@ -665,12 +665,6 @@
         assert isinstance(typedescr, TypeDescr)
         return typedescr.create()
 
-    def do_runtimenew(self, classbox):
-        "NOT_RPYTHON"
-        classobj = classbox.getref(ootype.Class)
-        res = ootype.runtimenew(classobj)
-        return history.BoxObj(ootype.cast_to_object(res))
-
     def do_instanceof(self, box1, typedescr):
         assert isinstance(typedescr, TypeDescr)
         return typedescr.instanceof(box1)
@@ -730,12 +724,10 @@
     return getargs
 
 def boxresult(RESULT, result):
-    if isinstance(RESULT, ootype.OOType):
-        return history.BoxObj(ootype.cast_to_object(result))
-    elif RESULT is lltype.Float:
-        return history.BoxFloat(result)
+    if RESULT is lltype.Float:
+        return resoperation.BoxFloat(result)
     else:
-        return history.BoxInt(lltype.cast_primitive(ootype.Signed, result))
+        return resoperation.BoxInt(lltype.cast_primitive(ootype.Signed, 
result))
 boxresult._annspecialcase_ = 'specialize:arg(0)'
 
 
@@ -847,7 +839,7 @@
 
         def instanceof(box):
             obj = box.getref(ootype.ROOT)
-            return history.BoxInt(ootype.instanceof(obj, TYPE))
+            return resoperation.BoxInt(ootype.instanceof(obj, TYPE))
 
         self.create = create
         self.create_array = create_array
diff --git a/pypy/jit/backend/test/runner_test.py 
b/pypy/jit/backend/test/runner_test.py
--- a/pypy/jit/backend/test/runner_test.py
+++ b/pypy/jit/backend/test/runner_test.py
@@ -2,12 +2,10 @@
 from pypy.jit.metainterp.history import (AbstractFailDescr,
                                          AbstractDescr,
                                          BasicFailDescr,
-                                         BoxInt, Box, BoxPtr,
-                                         JitCellToken, TargetToken,
-                                         BoxObj, BoxFloat)
+                                         JitCellToken, TargetToken)
 from pypy.jit.metainterp.resoperation import rop, create_resop_dispatch,\
-     create_resop, ConstInt, ConstPtr, ConstFloat, ConstObj, create_resop_2,\
-     create_resop_1
+     create_resop, ConstInt, ConstPtr, ConstFloat, create_resop_2,\
+     create_resop_1, BoxInt, Box, BoxPtr, BoxFloat
 from pypy.jit.metainterp.typesystem import deref
 from pypy.jit.codewriter.effectinfo import EffectInfo
 from pypy.rpython.lltypesystem import lltype, llmemory, rstr, rffi, rclass
@@ -50,7 +48,7 @@
         for box in inputargs:
             if isinstance(box, BoxInt):
                 args.append(box.getint())
-            elif isinstance(box, (BoxPtr, BoxObj)):
+            elif isinstance(box, BoxPtr):
                 args.append(box.getref_base())
             elif isinstance(box, BoxFloat):
                 args.append(box.getfloatstorage())
@@ -553,7 +551,7 @@
             func_ptr = llhelper(FPTR, f)
             FUNC = deref(FPTR)
             funcconst = self.get_funcbox(self.cpu, func_ptr)
-            funcbox = funcconst.clonebox()
+            funcbox = funcconst.nonconstbox()
             calldescr = self.cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT,
                                         EffectInfo.MOST_GENERAL)
             res = self.execute_operation(rop.CALL_i,
@@ -724,13 +722,16 @@
             assert self.guard_failed
 
     def test_ooops(self):
+        def clone(box):
+            return BoxPtr(box.value)
+        
         u1_box, U_box = self.alloc_instance(self.U)
         u2_box, U_box = self.alloc_instance(self.U)
         r = self.execute_operation(rop.PTR_EQ, [u1_box,
-                                                u1_box.clonebox()], 'int')
+                                                clone(u1_box)], 'int')
         assert r == 1
         r = self.execute_operation(rop.PTR_NE, [u2_box,
-                                                u2_box.clonebox()], 'int')
+                                                clone(u2_box)], 'int')
         assert r == 0
         r = self.execute_operation(rop.PTR_EQ, [u1_box, u2_box], 'int')
         assert r == 0
@@ -739,14 +740,14 @@
         #
         null_box = self.null_instance()
         r = self.execute_operation(rop.PTR_EQ, [null_box,
-                                                null_box.clonebox()], 'int')
+                                                clone(null_box)], 'int')
         assert r == 1
         r = self.execute_operation(rop.PTR_EQ, [u1_box, null_box], 'int')
         assert r == 0
         r = self.execute_operation(rop.PTR_EQ, [null_box, u2_box], 'int')
         assert r == 0
         r = self.execute_operation(rop.PTR_NE, [null_box,
-                                                null_box.clonebox()], 'int')
+                                                clone(null_box)], 'int')
         assert r == 0
         r = self.execute_operation(rop.PTR_NE, [u2_box, null_box], 'int')
         assert r == 1
@@ -3292,45 +3293,3 @@
             result = rawstorage.raw_storage_getitem(T, p, 16)
             assert result == rffi.cast(T, value)
             rawstorage.free_raw_storage(p)
-
-class OOtypeBackendTest(BaseBackendTest):
-
-    type_system = 'ootype'
-    Ptr = staticmethod(lambda x: x)
-    FuncType = ootype.StaticMethod
-    malloc = staticmethod(ootype.new)
-    nullptr = staticmethod(ootype.null)
-
-    def setup_class(cls):
-        py.test.skip("ootype tests skipped")
-
-    @classmethod
-    def get_funcbox(cls, cpu, func_ptr):
-        return BoxObj(ootype.cast_to_object(func_ptr))
-
-    S = ootype.Instance('S', ootype.ROOT, {'value': ootype.Signed,
-                                           'chr1': ootype.Char,
-                                           'chr2': ootype.Char})
-    S._add_fields({'next': S})
-    T = ootype.Instance('T', S)
-    U = ootype.Instance('U', T)
-
-    def alloc_instance(self, T):
-        t = ootype.new(T)
-        cls = ootype.classof(t)
-        t_box = BoxObj(ootype.cast_to_object(t))
-        T_box = ConstObj(ootype.cast_to_object(cls))
-        return t_box, T_box
-
-    def null_instance(self):
-        return BoxObj(ootype.NULL)
-
-    def alloc_array_of(self, ITEM, length):
-        py.test.skip("implement me")
-
-    def alloc_string(self, string):
-        py.test.skip("implement me")
-
-    def alloc_unicode(self, unicode):
-        py.test.skip("implement me")
-
diff --git a/pypy/jit/metainterp/logger.py b/pypy/jit/metainterp/logger.py
--- a/pypy/jit/metainterp/logger.py
+++ b/pypy/jit/metainterp/logger.py
@@ -2,8 +2,8 @@
 from pypy.rlib.debug import debug_start, debug_stop, debug_print
 from pypy.rlib.objectmodel import we_are_translated
 from pypy.rpython.lltypesystem import lltype, llmemory, rffi
-from pypy.jit.metainterp.resoperation import rop, ConstInt
-from pypy.jit.metainterp.history import BoxInt, BoxFloat, TargetToken
+from pypy.jit.metainterp.resoperation import rop, ConstInt, BoxInt, BoxFloat
+from pypy.jit.metainterp.history import TargetToken
 
 class Logger(object):
 
diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py 
b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
@@ -6,9 +6,9 @@
 import pypy.jit.metainterp.optimizeopt.optimizer as optimizeopt
 import pypy.jit.metainterp.optimizeopt.virtualize as virtualize
 from pypy.jit.metainterp.optimize import InvalidLoop
-from pypy.jit.metainterp.history import BoxInt, get_const_ptr_for_string
+from pypy.jit.metainterp.history import get_const_ptr_for_string
 from pypy.jit.metainterp import executor, compile, resume
-from pypy.jit.metainterp.resoperation import rop, opname, ConstInt
+from pypy.jit.metainterp.resoperation import rop, opname, ConstInt, BoxInt
 from pypy.rlib.rarithmetic import LONG_BIT
 
 def test_store_final_boxes_in_guard():
diff --git a/pypy/jit/metainterp/pyjitpl.py b/pypy/jit/metainterp/pyjitpl.py
--- a/pypy/jit/metainterp/pyjitpl.py
+++ b/pypy/jit/metainterp/pyjitpl.py
@@ -9,9 +9,9 @@
 from pypy.jit.metainterp import history, compile, resume
 from pypy.jit.metainterp.resoperation import Const, ConstInt, ConstPtr,\
      ConstFloat
-from pypy.jit.metainterp.history import Box, TargetToken
+from pypy.jit.metainterp.history import TargetToken
 from pypy.jit.metainterp.resoperation import rop, create_resop, 
create_resop_0,\
-     create_resop_1, create_resop_2
+     create_resop_1, create_resop_2, Box
 from pypy.jit.metainterp import resoperation
 from pypy.jit.metainterp import executor
 from pypy.jit.metainterp.logger import Logger
@@ -22,7 +22,6 @@
 from pypy.rlib.objectmodel import specialize
 from pypy.jit.codewriter.jitcode import JitCode, SwitchDictDescr
 from pypy.jit.codewriter import heaptracker
-from pypy.jit.metainterp.optimizeopt.util import args_dict_box
 
 # ____________________________________________________________
 
diff --git a/pypy/jit/metainterp/resoperation.py 
b/pypy/jit/metainterp/resoperation.py
--- a/pypy/jit/metainterp/resoperation.py
+++ b/pypy/jit/metainterp/resoperation.py
@@ -231,6 +231,7 @@
 class Box(AbstractValue):
     __slots__ = ()
     _counter = 0
+    _extended_display = True
 
     def nonconstbox(self):
         return self
diff --git a/pypy/jit/metainterp/test/test_executor.py 
b/pypy/jit/metainterp/test/test_executor.py
--- a/pypy/jit/metainterp/test/test_executor.py
+++ b/pypy/jit/metainterp/test/test_executor.py
@@ -5,8 +5,9 @@
 from pypy.jit.metainterp.executor import execute
 from pypy.jit.metainterp.executor import execute_varargs, execute_nonspec
 from pypy.jit.metainterp.resoperation import rop, opboolinvers, opboolreflex, 
opname
-from pypy.jit.metainterp.history import BoxInt, BoxPtr, BoxFloat, AbstractDescr
-from pypy.jit.metainterp.resoperation import ConstInt, ConstPtr, ConstFloat
+from pypy.jit.metainterp.history import AbstractDescr
+from pypy.jit.metainterp.resoperation import ConstInt, ConstPtr, ConstFloat,\
+     BoxInt, BoxPtr, BoxFloat
 from pypy.jit.metainterp import history
 from pypy.jit.codewriter import longlong
 from pypy.jit.backend.model import AbstractCPU
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to