Author: Ronan Lamy <[email protected]>
Branch: kill-ootype
Changeset: r65296:1a1aec304f2e
Date: 2013-07-09 18:47 +0200
http://bitbucket.org/pypy/pypy/changeset/1a1aec304f2e/

Log:    kill ConstObj, BoxObj

diff --git a/rpython/jit/backend/arm/test/test_calling_convention.py 
b/rpython/jit/backend/arm/test/test_calling_convention.py
--- a/rpython/jit/backend/arm/test/test_calling_convention.py
+++ b/rpython/jit/backend/arm/test/test_calling_convention.py
@@ -18,8 +18,7 @@
                                          BoxInt, Box, BoxPtr,
                                          JitCellToken, TargetToken,
                                          ConstInt, ConstPtr,
-                                         BoxObj,
-                                         ConstObj, BoxFloat, ConstFloat)
+                                         BoxFloat, ConstFloat)
 
 skip_unless_run_slow_tests()
 
@@ -64,7 +63,7 @@
             assert self.cpu.get_int_value(deadframe, x) == x
         assert self.cpu.get_int_value(deadframe, 11) == 38
 
-   
+
     def test_float_hf_call_mixed(self):
         if not self.cpu.supports_floats:
             py.test.skip("requires floats")
diff --git a/rpython/jit/backend/arm/test/test_generated.py 
b/rpython/jit/backend/arm/test/test_generated.py
--- a/rpython/jit/backend/arm/test/test_generated.py
+++ b/rpython/jit/backend/arm/test/test_generated.py
@@ -4,8 +4,7 @@
                                          BasicFailDescr,
                                          BoxInt, Box, BoxPtr,
                                          ConstInt, ConstPtr,
-                                         BoxObj, Const,
-                                         ConstObj, BoxFloat, ConstFloat)
+                                         Const, BoxFloat, ConstFloat)
 from rpython.jit.metainterp.history import JitCellToken
 from rpython.jit.metainterp.resoperation import ResOperation, rop
 from rpython.rtyper.test.test_llinterp import interpret
diff --git a/rpython/jit/backend/llgraph/test/test_llgraph.py 
b/rpython/jit/backend/llgraph/test/test_llgraph.py
--- a/rpython/jit/backend/llgraph/test/test_llgraph.py
+++ b/rpython/jit/backend/llgraph/test/test_llgraph.py
@@ -7,7 +7,7 @@
 class TestLLTypeLLGraph(LLtypeBackendTest):
     # for individual tests see:
     # ====> ../../test/runner_test.py
-    
+
 
     def get_cpu(self):
         return LLGraphCPU(None)
@@ -30,18 +30,3 @@
     assert llmemory.cast_adr_to_ptr(a2, lltype.Ptr(X)) == x
     assert heaptracker.adr2int(llmemory.NULL) == 0
     assert heaptracker.int2adr(0) == llmemory.NULL
-
-## these tests never worked
-## class TestOOTypeLLGraph(LLGraphTest):
-##     from rpython.jit.backend.llgraph.runner import OOtypeCPU as cpu_type
-
-def test_fielddescr_ootype():
-    py.test.skip("ootype tests skipped")
-    from rpython.rtyper.ootypesystem import ootype
-    from rpython.jit.backend.llgraph.runner import OOtypeCPU
-    A = ootype.Instance("A", ootype.ROOT, {"foo": ootype.Signed})
-    B = ootype.Instance("B", A)
-    cpu = OOtypeCPU(None)
-    descr1 = cpu.fielddescrof(A, "foo")
-    descr2 = cpu.fielddescrof(B, "foo")
-    assert descr1 is descr2
diff --git a/rpython/jit/backend/test/runner_test.py 
b/rpython/jit/backend/test/runner_test.py
--- a/rpython/jit/backend/test/runner_test.py
+++ b/rpython/jit/backend/test/runner_test.py
@@ -6,8 +6,7 @@
                                          BoxInt, Box, BoxPtr,
                                          JitCellToken, TargetToken,
                                          ConstInt, ConstPtr,
-                                         BoxObj,
-                                         ConstObj, BoxFloat, ConstFloat)
+                                         BoxFloat, ConstFloat)
 from rpython.jit.metainterp.resoperation import ResOperation, rop
 from rpython.jit.metainterp.typesystem import deref
 from rpython.jit.codewriter.effectinfo import EffectInfo
@@ -55,7 +54,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())
diff --git a/rpython/jit/codewriter/effectinfo.py 
b/rpython/jit/codewriter/effectinfo.py
--- a/rpython/jit/codewriter/effectinfo.py
+++ b/rpython/jit/codewriter/effectinfo.py
@@ -1,7 +1,6 @@
 from rpython.jit.metainterp.typesystem import deref, fieldType, arrayItem
 from rpython.rtyper.lltypesystem.rclass import OBJECT
 from rpython.rtyper.lltypesystem import lltype, llmemory
-from rpython.rtyper.ootypesystem import ootype
 from rpython.translator.backendopt.graphanalyze import BoolGraphAnalyzer
 
 
@@ -223,8 +222,6 @@
 def consider_struct(TYPE, fieldname):
     if fieldType(TYPE, fieldname) is lltype.Void:
         return False
-    if isinstance(TYPE, ootype.OOType):
-        return True
     if not isinstance(TYPE, lltype.GcStruct): # can be a non-GC-struct
         return False
     if fieldname == "typeptr" and TYPE is OBJECT:
@@ -237,8 +234,6 @@
 def consider_array(ARRAY):
     if arrayItem(ARRAY) is lltype.Void:
         return False
-    if isinstance(ARRAY, ootype.Array):
-        return True
     if not isinstance(ARRAY, lltype.GcArray): # can be a non-GC-array
         return False
     return True
diff --git a/rpython/jit/codewriter/test/test_effectinfo.py 
b/rpython/jit/codewriter/test/test_effectinfo.py
--- a/rpython/jit/codewriter/test/test_effectinfo.py
+++ b/rpython/jit/codewriter/test/test_effectinfo.py
@@ -1,6 +1,5 @@
 from rpython.rtyper.lltypesystem.rclass import OBJECT
 from rpython.rtyper.lltypesystem import lltype
-from rpython.rtyper.ootypesystem import ootype
 from rpython.jit.codewriter.effectinfo import effectinfo_from_writeanalyze,\
     EffectInfo
 
@@ -91,17 +90,3 @@
     assert not effectinfo.readonly_descrs_fields
     assert not effectinfo.write_descrs_fields
     assert not effectinfo.write_descrs_arrays
-
-def test_filter_out_ooarray_of_void():
-    effects = frozenset([("array", ootype.Array(ootype.Void))])
-    effectinfo = effectinfo_from_writeanalyze(effects, None)
-    assert not effectinfo.readonly_descrs_fields
-    assert not effectinfo.write_descrs_fields
-    assert not effectinfo.write_descrs_arrays
-
-def test_filter_out_instance_with_void():
-    effects = frozenset([("struct", ootype.Instance("x", ootype.ROOT, {"a": 
ootype.Void}), "a")])
-    effectinfo = effectinfo_from_writeanalyze(effects, None)
-    assert not effectinfo.readonly_descrs_fields
-    assert not effectinfo.write_descrs_fields
-    assert not effectinfo.write_descrs_arrays
diff --git a/rpython/jit/metainterp/history.py 
b/rpython/jit/metainterp/history.py
--- a/rpython/jit/metainterp/history.py
+++ b/rpython/jit/metainterp/history.py
@@ -1,6 +1,5 @@
 from rpython.rtyper.extregistry import ExtRegistryEntry
 from rpython.rtyper.lltypesystem import lltype, llmemory, rffi
-from rpython.rtyper.ootypesystem import ootype
 from rpython.rlib.objectmodel import we_are_translated, Symbolic
 from rpython.rlib.objectmodel import compute_unique_id
 from rpython.rlib.rarithmetic import r_int64, is_valid_int
@@ -48,8 +47,6 @@
             return "int"
         else:
             return "ref"
-    elif isinstance(TYPE, ootype.OOType):
-        return "ref"
     else:
         raise NotImplementedError("type %s not supported" % TYPE)
 getkind._annspecialcase_ = 'specialize:memo'
@@ -67,14 +64,7 @@
 def repr_object(box):
     try:
         TYPE = box.value.obj._TYPE
-        if TYPE is ootype.String:
-            return '(%r)' % box.value.obj._str
-        if TYPE is ootype.Class or isinstance(TYPE, ootype.StaticMethod):
-            return '(%r)' % box.value.obj
-        if isinstance(box.value.obj, ootype._view):
-            return repr(box.value.obj._inst._TYPE)
-        else:
-            return repr(TYPE)
+        return repr(TYPE)
     except AttributeError:
         return box.value
 
@@ -359,56 +349,6 @@
 
 CONST_NULL = ConstPtr(ConstPtr.value)
 
-class ConstObj(Const):
-    type = REF
-    value = ootype.NULL
-    _attrs_ = ('value',)
-
-    def __init__(self, value):
-        assert ootype.typeOf(value) is ootype.Object
-        self.value = value
-
-    def clonebox(self):
-        return BoxObj(self.value)
-
-    nonconstbox = clonebox
-
-    def getref_base(self):
-       return self.value
-
-    def getref(self, OBJ):
-        return ootype.cast_from_object(OBJ, self.getref_base())
-    getref._annspecialcase_ = 'specialize:arg(1)'
-
-    def _get_hash_(self):
-        if self.value:
-            return ootype.identityhash(self.value)
-        else:
-            return 0
-
-##    def getaddr(self):
-##        # so far this is used only when calling
-##        # CodeWriter.IndirectCallset.bytecode_for_address.  We don't need a
-##        # real addr, but just a key for the dictionary
-##        return self.value
-
-    def same_constant(self, other):
-        if isinstance(other, ConstObj):
-            return self.value == other.value
-        return False
-
-    def nonnull(self):
-        return bool(self.value)
-
-    _getrepr_ = repr_object
-
-    def repr_rpython(self):
-        return repr_rpython(self, 'co')
-
-    def _get_str(self):    # for debugging only
-        from rpython.rtyper.annlowlevel import hlstr
-        return hlstr(ootype.cast_from_object(ootype.String, self.value))
-
 class Box(AbstractValue):
     __slots__ = ()
     _extended_display = True
@@ -423,7 +363,6 @@
             intval = lltype.cast_primitive(lltype.Signed, x)
             return BoxInt(intval)
         elif kind == "ref":
-            # XXX add ootype support?
             ptrval = lltype.cast_opaque_ptr(llmemory.GCREF, x)
             return BoxPtr(ptrval)
         elif kind == "float":
@@ -575,46 +514,6 @@
 
 NULLBOX = BoxPtr()
 
-
-class BoxObj(Box):
-    type = REF
-    _attrs_ = ('value',)
-
-    def __init__(self, value=ootype.NULL):
-        assert ootype.typeOf(value) is ootype.Object
-        self.value = value
-
-    def forget_value(self):
-        self.value = ootype.NULL
-
-    def clonebox(self):
-        return BoxObj(self.value)
-
-    def constbox(self):
-        return ConstObj(self.value)
-
-    def getref_base(self):
-        return self.value
-
-    def getref(self, OBJ):
-        return ootype.cast_from_object(OBJ, self.getref_base())
-    getref._annspecialcase_ = 'specialize:arg(1)'
-
-    def _get_hash_(self):
-        if self.value:
-            return ootype.identityhash(self.value)
-        else:
-            return 0
-
-    def nonnull(self):
-        return bool(self.value)
-
-    def repr_rpython(self):
-        return repr_rpython(self, 'bo')
-
-    _getrepr_ = repr_object
-
-
 # ____________________________________________________________
 
 
@@ -728,7 +627,7 @@
 
     def repr_of_descr(self):
         return 'TargetToken(%d)' % compute_unique_id(self)
-        
+
 class TreeLoop(object):
     inputargs = None
     operations = None
@@ -825,7 +724,7 @@
                 seen = dict.fromkeys(inputargs)
                 assert len(seen) == len(inputargs), (
                     "duplicate Box in the LABEL arguments")
-                
+
         assert operations[-1].is_final()
         if operations[-1].getopnum() == rop.JUMP:
             target = operations[-1].getdescr()
@@ -834,7 +733,7 @@
 
     def dump(self):
         # RPython-friendly
-        print '%r: inputargs =' % self, self._dump_args(self.inputargs)        
+        print '%r: inputargs =' % self, self._dump_args(self.inputargs)
         for op in self.operations:
             args = op.getarglist()
             print '\t', op.getopname(), self._dump_args(args), \
@@ -950,7 +849,7 @@
     def add_jitcell_token(self, token):
         assert isinstance(token, JitCellToken)
         self.jitcell_token_wrefs.append(weakref.ref(token))
-        
+
     def set_history(self, history):
         self.operations = history.operations
 
@@ -1043,7 +942,7 @@
             opname = op.getopname()
             insns[opname] = insns.get(opname, 0) + 1
         return self._check_insns(insns, expected, check)
-        
+
     def check_loops(self, expected=None, everywhere=False, **check):
         insns = {}
         for loop in self.get_all_loops():
@@ -1066,7 +965,7 @@
             print
             import pdb; pdb.set_trace()
         return
-        
+
         for insn, expected_count in check.items():
             getattr(rop, insn.upper())  # fails if 'rop.INSN' does not exist
             found = insns.get(insn, 0)
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_util.py 
b/rpython/jit/metainterp/optimizeopt/test/test_util.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_util.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_util.py
@@ -7,8 +7,7 @@
 
 from rpython.jit.backend.llgraph import runner
 from rpython.jit.metainterp.history import (BoxInt, BoxPtr, ConstInt, ConstPtr,
-                                         Const, TreeLoop, BoxObj,
-                                         ConstObj, AbstractDescr,
+                                         Const, TreeLoop, AbstractDescr,
                                          JitCellToken, TargetToken)
 from rpython.jit.metainterp.optimizeopt.util import sort_descrs, equaloplists
 from rpython.jit.metainterp.optimize import InvalidLoop
@@ -275,79 +274,9 @@
 
     namespace = locals()
 
-class OOtypeMixin_xxx_disabled(object):
-    type_system = 'ootype'
-
-##    def get_class_of_box(self, box):
-##        root = box.getref(ootype.ROOT)
-##        return ootype.classof(root)
-
-##    cpu = runner.OOtypeCPU(None)
-##    NODE = ootype.Instance('NODE', ootype.ROOT, {})
-##    NODE._add_fields({'value': ootype.Signed,
-##                      'floatval' : ootype.Float,
-##                      'next': NODE})
-##    NODE2 = ootype.Instance('NODE2', NODE, {'other': NODE})
-
-##    node_vtable = ootype.runtimeClass(NODE)
-##    node_vtable_adr = ootype.cast_to_object(node_vtable)
-##    node_vtable2 = ootype.runtimeClass(NODE2)
-##    node_vtable_adr2 = ootype.cast_to_object(node_vtable2)
-
-##    node = ootype.new(NODE)
-##    nodebox = BoxObj(ootype.cast_to_object(node))
-##    myptr = nodebox.value
-##    myptr2 = ootype.cast_to_object(ootype.new(NODE))
-##    nodebox2 = BoxObj(ootype.cast_to_object(node))
-##    valuedescr = cpu.fielddescrof(NODE, 'value')
-##    floatdescr = cpu.fielddescrof(NODE, 'floatval')
-##    nextdescr = cpu.fielddescrof(NODE, 'next')
-##    otherdescr = cpu.fielddescrof(NODE2, 'other')
-##    nodesize = cpu.typedescrof(NODE)
-##    nodesize2 = cpu.typedescrof(NODE2)
-
-##    arraydescr = cpu.arraydescrof(ootype.Array(ootype.Signed))
-##    floatarraydescr = cpu.arraydescrof(ootype.Array(ootype.Float))
-
-##    # a plain Record
-##    S = ootype.Record({'a': ootype.Signed, 'b': NODE})
-##    ssize = cpu.typedescrof(S)
-##    adescr = cpu.fielddescrof(S, 'a')
-##    bdescr = cpu.fielddescrof(S, 'b')
-##    sbox = BoxObj(ootype.cast_to_object(ootype.new(S)))
-##    arraydescr2 = cpu.arraydescrof(ootype.Array(S))
-
-##    T = ootype.Record({'c': ootype.Signed,
-##                       'd': ootype.Array(NODE)})
-##    tsize = cpu.typedescrof(T)
-##    cdescr = cpu.fielddescrof(T, 'c')
-##    ddescr = cpu.fielddescrof(T, 'd')
-##    arraydescr3 = cpu.arraydescrof(ootype.Array(NODE))
-
-##    U = ootype.Instance('U', ootype.ROOT, {'one': ootype.Array(NODE)})
-##    usize = cpu.typedescrof(U)
-##    onedescr = cpu.fielddescrof(U, 'one')
-##    u_vtable = ootype.runtimeClass(U)
-##    u_vtable_adr = ootype.cast_to_object(u_vtable)
-
-##    # force a consistent order
-##    valuedescr.sort_key()
-##    nextdescr.sort_key()
-##    adescr.sort_key()
-##    bdescr.sort_key()
-
-##    FUNC = lltype.FuncType([lltype.Signed], lltype.Signed)
-##    nonwritedescr = cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT) # XXX fix 
ootype
-
-##    cpu.class_sizes = {node_vtable_adr: cpu.typedescrof(NODE),
-##                       node_vtable_adr2: cpu.typedescrof(NODE2),
-##                       u_vtable_adr: cpu.typedescrof(U)}
-##    namespace = locals()
-
 # ____________________________________________________________
 
 
-
 class Fake(object):
     failargs_limit = 1000
     storedebug = None
@@ -447,7 +376,7 @@
         preamble.inputargs = inputargs
         preamble.resume_at_jump_descr = FakeDescrWithSnapshot()
 
-        token = JitCellToken() 
+        token = JitCellToken()
         preamble.operations = [ResOperation(rop.LABEL, inputargs, None, 
descr=TargetToken(token))] + \
                               operations +  \
                               [ResOperation(rop.LABEL, jump_args, None, 
descr=token)]
@@ -460,7 +389,7 @@
         loop.operations = [preamble.operations[-1]] + \
                           [inliner.inline_op(op, clone=False) for op in 
cloned_operations] + \
                           [ResOperation(rop.JUMP, [inliner.inline_arg(a) for a 
in jump_args],
-                                        None, descr=token)] 
+                                        None, descr=token)]
                           #[inliner.inline_op(jumpop)]
         assert loop.operations[-1].getopnum() == rop.JUMP
         assert loop.operations[0].getopnum() == rop.LABEL
@@ -479,7 +408,7 @@
             preamble.operations.insert(-1, op)
 
         return preamble
-        
+
 
 class FakeDescr(compile.ResumeGuardDescr):
     def clone_if_mutable(self):
diff --git a/rpython/jit/metainterp/warmstate.py 
b/rpython/jit/metainterp/warmstate.py
--- a/rpython/jit/metainterp/warmstate.py
+++ b/rpython/jit/metainterp/warmstate.py
@@ -83,12 +83,6 @@
             adr = llmemory.cast_ptr_to_adr(value)
             value = heaptracker.adr2int(adr)
             # fall through to the end of the function
-    elif isinstance(lltype.typeOf(value), ootype.OOType):
-        value = ootype.cast_to_object(value)
-        if in_const_box:
-            return history.ConstObj(value)
-        else:
-            return history.BoxObj(value)
     elif (isinstance(value, float) or
           longlong.is_longlong(lltype.typeOf(value))):
         if isinstance(value, float):
diff --git a/rpython/jit/tool/oparser.py b/rpython/jit/tool/oparser.py
--- a/rpython/jit/tool/oparser.py
+++ b/rpython/jit/tool/oparser.py
@@ -81,18 +81,11 @@
         if self._consts is None:
             return name
         obj = self._consts[name]
-        if self.type_system == 'lltype':
-            if typ == 'ptr':
-                return self.model.ConstPtr(obj)
-            else:
-                assert typ == 'class'
-                return self.model.ConstInt(self.model.ptr_to_int(obj))
+        if typ == 'ptr':
+            return self.model.ConstPtr(obj)
         else:
-            if typ == 'ptr':
-                return self.model.ConstObj(obj)
-            else:
-                assert typ == 'class'
-                return self.model.ConstObj(ootype.cast_to_object(obj))
+            assert typ == 'class'
+            return self.model.ConstInt(self.model.ptr_to_int(obj))
 
     def get_descr(self, poss_descr, allow_invent):
         if poss_descr.startswith('<'):
@@ -180,10 +173,7 @@
             elif arg == 'None':
                 return None
             elif arg == 'NULL':
-                if self.type_system == 'lltype':
-                    return self.model.ConstPtr(self.model.ConstPtr.value)
-                else:
-                    return self.model.ConstObj(self.model.ConstObj.value)
+                return self.model.ConstPtr(self.model.ConstPtr.value)
             elif arg.startswith('ConstPtr('):
                 name = arg[len('ConstPtr('):-1]
                 return self.get_const(name, 'ptr')
diff --git a/rpython/jit/tool/oparser_model.py 
b/rpython/jit/tool/oparser_model.py
--- a/rpython/jit/tool/oparser_model.py
+++ b/rpython/jit/tool/oparser_model.py
@@ -5,7 +5,7 @@
     class LoopModel(object):
         from rpython.jit.metainterp.history import TreeLoop, JitCellToken
         from rpython.jit.metainterp.history import Box, BoxInt, BoxFloat
-        from rpython.jit.metainterp.history import ConstInt, ConstObj, 
ConstPtr, ConstFloat
+        from rpython.jit.metainterp.history import ConstInt, ConstPtr, 
ConstFloat
         from rpython.jit.metainterp.history import BasicFailDescr, 
BasicFinalDescr, TargetToken
         from rpython.jit.metainterp.typesystem import llhelper
 
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to