Author: wenzhuman <[email protected]>
Branch: gc-pinning
Changeset: r71801:1e82e87cb90a
Date: 2014-05-29 14:21 -0400
http://bitbucket.org/pypy/pypy/changeset/1e82e87cb90a/

Log:    merge default

diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py
--- a/rpython/annotator/bookkeeper.py
+++ b/rpython/annotator/bookkeeper.py
@@ -160,8 +160,6 @@
     def consider_call_site_for_pbc(self, s_callable, args, s_result,
                                    call_op):
         descs = list(s_callable.descriptions)
-        if not descs:
-            return
         family = descs[0].getcallfamily()
         s_callable.getKind().consider_call_site(self, family, descs, args,
                                                 s_result, call_op)
diff --git a/rpython/jit/codewriter/jtransform.py 
b/rpython/jit/codewriter/jtransform.py
--- a/rpython/jit/codewriter/jtransform.py
+++ b/rpython/jit/codewriter/jtransform.py
@@ -561,8 +561,10 @@
             return [SpaceOperation('-live-', [], None), op1, None]
         if hints.get('force_virtualizable'):
             return SpaceOperation('hint_force_virtualizable', [op.args[0]], 
None)
-        else:
-            log.WARNING('ignoring hint %r at %r' % (hints, self.graph))
+        if hints.get('force_no_const'):   # for tests only
+            assert getkind(op.args[0].concretetype) == 'int'
+            return SpaceOperation('int_same_as', [op.args[0]], op.result)
+        log.WARNING('ignoring hint %r at %r' % (hints, self.graph))
 
     def _rewrite_raw_malloc(self, op, name, args):
         d = op.args[1].value.copy()
diff --git a/rpython/jit/metainterp/blackhole.py 
b/rpython/jit/metainterp/blackhole.py
--- a/rpython/jit/metainterp/blackhole.py
+++ b/rpython/jit/metainterp/blackhole.py
@@ -380,6 +380,10 @@
 
     # ----------
 
+    @arguments("i", returns="i")
+    def bhimpl_int_same_as(a):
+        return a
+
     @arguments("i", "i", returns="i")
     def bhimpl_int_add(a, b):
         return intmask(a + b)
diff --git a/rpython/jit/metainterp/pyjitpl.py 
b/rpython/jit/metainterp/pyjitpl.py
--- a/rpython/jit/metainterp/pyjitpl.py
+++ b/rpython/jit/metainterp/pyjitpl.py
@@ -231,6 +231,14 @@
         ''' % (_opimpl, _opimpl.upper())).compile()
 
     @arguments("box")
+    def opimpl_int_same_as(self, box):
+        # for tests only: emits a same_as, forcing the result to be in a Box
+        resbox = history.BoxInt(box.getint())
+        self.metainterp._record_helper_nonpure_varargs(
+            rop.SAME_AS, resbox, None, [box])
+        return resbox
+
+    @arguments("box")
     def opimpl_ptr_nonzero(self, box):
         return self.execute(rop.PTR_NE, box, history.CONST_NULL)
 
diff --git a/rpython/jit/metainterp/test/support.py 
b/rpython/jit/metainterp/test/support.py
--- a/rpython/jit/metainterp/test/support.py
+++ b/rpython/jit/metainterp/test/support.py
@@ -273,6 +273,5 @@
 def noConst(x):
     """Helper function for tests, returning 'x' as a BoxInt/BoxPtr
     even if it is a ConstInt/ConstPtr."""
-    f1 = _Foo(); f2 = _Foo()
-    f1.x = x; f2.x = 0
-    return f1.x
+    from rpython.rlib import jit
+    return jit.hint(x, force_no_const=True)
diff --git a/rpython/rtyper/annlowlevel.py b/rpython/rtyper/annlowlevel.py
--- a/rpython/rtyper/annlowlevel.py
+++ b/rpython/rtyper/annlowlevel.py
@@ -486,7 +486,7 @@
             assert False
 
     def specialize_call(self, hop):
-        from rpython.rtyper import rpbc
+        from rpython.rtyper.rnone import NoneRepr
         PTR = hop.r_result.lowleveltype
         if isinstance(PTR, lltype.Ptr):
             T = lltype.Ptr
@@ -496,7 +496,7 @@
             assert False
 
         hop.exception_cannot_occur()
-        if isinstance(hop.args_r[1], rpbc.NoneFrozenPBCRepr):
+        if isinstance(hop.args_r[1], NoneRepr):
             return hop.inputconst(PTR, null)
         v_arg = hop.inputarg(hop.args_r[1], arg=1)
         assert isinstance(v_arg.concretetype, T)
diff --git a/rpython/rtyper/lltypesystem/rpbc.py 
b/rpython/rtyper/lltypesystem/rpbc.py
--- a/rpython/rtyper/lltypesystem/rpbc.py
+++ b/rpython/rtyper/lltypesystem/rpbc.py
@@ -7,39 +7,15 @@
 from rpython.rtyper.lltypesystem import rclass, llmemory
 from rpython.rtyper.lltypesystem.lltype import (typeOf, Void, ForwardReference,
     Struct, Bool, Char, Ptr, malloc, nullptr, Array, Signed)
-from rpython.rtyper.rmodel import Repr, TyperError, inputconst
+from rpython.rtyper.rmodel import Repr, inputconst
 from rpython.rtyper.rpbc import (AbstractClassesPBCRepr, 
AbstractMethodsPBCRepr,
     OverriddenFunctionPBCRepr, AbstractMultipleFrozenPBCRepr,
     AbstractFunctionsPBCRepr, AbstractMultipleUnrelatedFrozenPBCRepr,
-    SingleFrozenPBCRepr, MethodOfFrozenPBCRepr, none_frozen_pbc_repr,
-    get_concrete_calltable)
+    SingleFrozenPBCRepr, get_concrete_calltable)
 from rpython.rtyper.typesystem import getfunctionptr
 from rpython.tool.pairtype import pairtype
 
 
-def rtype_is_None(robj1, rnone2, hop, pos=0):
-    if isinstance(robj1.lowleveltype, Ptr):
-        v1 = hop.inputarg(robj1, pos)
-        return hop.genop('ptr_iszero', [v1], resulttype=Bool)
-    elif robj1.lowleveltype == llmemory.Address:
-        v1 = hop.inputarg(robj1, pos)
-        cnull = hop.inputconst(llmemory.Address, robj1.null_instance())
-        return hop.genop('adr_eq', [v1, cnull], resulttype=Bool)
-    elif robj1 == none_frozen_pbc_repr:
-        return hop.inputconst(Bool, True)
-    elif isinstance(robj1, SmallFunctionSetPBCRepr):
-        if robj1.s_pbc.can_be_None:
-            v1 = hop.inputarg(robj1, pos)
-            return hop.genop('char_eq', [v1, inputconst(Char, '\000')],
-                             resulttype=Bool)
-        else:
-            return inputconst(Bool, False)
-    else:
-        raise TyperError('rtype_is_None of %r' % (robj1))
-
-
-# ____________________________________________________________
-
 class MultipleFrozenPBCRepr(AbstractMultipleFrozenPBCRepr):
     """Representation selected for multiple non-callable pre-built 
constants."""
     def __init__(self, rtyper, access_set):
diff --git a/rpython/rtyper/rnone.py b/rpython/rtyper/rnone.py
new file mode 100644
--- /dev/null
+++ b/rpython/rtyper/rnone.py
@@ -0,0 +1,82 @@
+from rpython.flowspace.model import Constant
+from rpython.annotator.model import SomeNone
+from rpython.rtyper.rmodel import Repr, TyperError, inputconst
+from rpython.rtyper.lltypesystem.lltype import Void, Bool, Ptr, Char
+from rpython.rtyper.lltypesystem.llmemory import Address
+from rpython.rtyper.lltypesystem.rpbc import SmallFunctionSetPBCRepr
+from rpython.rtyper.annlowlevel import llstr
+from rpython.tool.pairtype import pairtype
+
+class NoneRepr(Repr):
+    lowleveltype = Void
+
+    def rtype_bool(self, hop):
+        return Constant(False, Bool)
+
+    def none_call(self, hop):
+        raise TyperError("attempt to call constant None")
+
+    def ll_str(self, none):
+        return llstr("None")
+
+    def get_ll_eq_function(self):
+        return None
+
+    def get_ll_hash_function(self):
+        return ll_none_hash
+
+    rtype_simple_call = none_call
+    rtype_call_args = none_call
+
+none_repr = NoneRepr()
+
+class __extend__(SomeNone):
+    def rtyper_makerepr(self, rtyper):
+        return none_repr
+
+    def rtyper_makekey(self):
+        return self.__class__,
+
+def ll_none_hash(_):
+    return 0
+
+
+class __extend__(pairtype(Repr, NoneRepr)):
+
+    def convert_from_to((r_from, _), v, llops):
+        return inputconst(Void, None)
+
+    def rtype_is_((robj1, rnone2), hop):
+        if hop.s_result.is_constant():
+            return hop.inputconst(Bool, hop.s_result.const)
+        return rtype_is_None(robj1, rnone2, hop)
+
+class __extend__(pairtype(NoneRepr, Repr)):
+
+    def convert_from_to((_, r_to), v, llops):
+        return inputconst(r_to, None)
+
+    def rtype_is_((rnone1, robj2), hop):
+        if hop.s_result.is_constant():
+            return hop.inputconst(Bool, hop.s_result.const)
+        return rtype_is_None(robj2, rnone1, hop, pos=1)
+
+def rtype_is_None(robj1, rnone2, hop, pos=0):
+    if isinstance(robj1.lowleveltype, Ptr):
+        v1 = hop.inputarg(robj1, pos)
+        return hop.genop('ptr_iszero', [v1], resulttype=Bool)
+    elif robj1.lowleveltype == Address:
+        v1 = hop.inputarg(robj1, pos)
+        cnull = hop.inputconst(Address, robj1.null_instance())
+        return hop.genop('adr_eq', [v1, cnull], resulttype=Bool)
+    elif robj1 == none_repr:
+        return hop.inputconst(Bool, True)
+    elif isinstance(robj1, SmallFunctionSetPBCRepr):
+        if robj1.s_pbc.can_be_None:
+            v1 = hop.inputarg(robj1, pos)
+            return hop.genop('char_eq', [v1, inputconst(Char, '\000')],
+                             resulttype=Bool)
+        else:
+            return inputconst(Bool, False)
+    else:
+        raise TyperError('rtype_is_None of %r' % (robj1))
diff --git a/rpython/rtyper/rpbc.py b/rpython/rtyper/rpbc.py
--- a/rpython/rtyper/rpbc.py
+++ b/rpython/rtyper/rpbc.py
@@ -4,9 +4,8 @@
 from rpython.flowspace.model import Constant
 from rpython.annotator.argument import simple_args
 from rpython.rtyper import rclass, callparse
-from rpython.rtyper.annlowlevel import llstr
 from rpython.rtyper.error import TyperError
-from rpython.rtyper.lltypesystem.lltype import typeOf, Void, Bool
+from rpython.rtyper.lltypesystem.lltype import typeOf, Void
 from rpython.rtyper.rmodel import (Repr, inputconst, CanBeNull, mangle,
     inputdesc, warning, impossible_repr)
 from rpython.tool.pairtype import pair, pairtype
@@ -23,8 +22,7 @@
 class __extend__(annmodel.SomePBC):
     def rtyper_makerepr(self, rtyper):
         from rpython.rtyper.lltypesystem.rpbc import (FunctionsPBCRepr,
-            SmallFunctionSetPBCRepr, ClassesPBCRepr, MethodsPBCRepr,
-            MethodOfFrozenPBCRepr)
+            SmallFunctionSetPBCRepr, ClassesPBCRepr, MethodsPBCRepr)
         kind = self.getKind()
         if issubclass(kind, description.FunctionDesc):
             sample = self.any_description()
@@ -61,13 +59,6 @@
             t = ()
         return tuple([self.__class__, self.can_be_None]+lst)+t
 
-class __extend__(annmodel.SomeNone):
-    def rtyper_makerepr(self, rtyper):
-        return none_frozen_pbc_repr
-
-    def rtyper_makekey(self):
-        return self.__class__,
-
 # ____________________________________________________________
 
 class ConcreteCallTableRow(dict):
@@ -589,56 +580,6 @@
     def convert_from_to((r_from, r_to), v, llops):
         return pair(r_from.r_im_self, r_to.r_im_self).convert_from_to(v, llops)
 
-# __ None ____________________________________________________
-class NoneFrozenPBCRepr(Repr):
-    lowleveltype = Void
-
-    def rtype_bool(self, hop):
-        return Constant(False, Bool)
-
-    def none_call(self, hop):
-        raise TyperError("attempt to call constant None")
-
-    def ll_str(self, none):
-        return llstr("None")
-
-    def get_ll_eq_function(self):
-        return None
-
-    def get_ll_hash_function(self):
-        return ll_none_hash
-
-    rtype_simple_call = none_call
-    rtype_call_args = none_call
-
-none_frozen_pbc_repr = NoneFrozenPBCRepr()
-
-def ll_none_hash(_):
-    return 0
-
-
-class __extend__(pairtype(Repr, NoneFrozenPBCRepr)):
-
-    def convert_from_to((r_from, _), v, llops):
-        return inputconst(Void, None)
-
-    def rtype_is_((robj1, rnone2), hop):
-        from rpython.rtyper.lltypesystem.rpbc import rtype_is_None
-        if hop.s_result.is_constant():
-            return hop.inputconst(Bool, hop.s_result.const)
-        return rtype_is_None(robj1, rnone2, hop)
-
-class __extend__(pairtype(NoneFrozenPBCRepr, Repr)):
-
-    def convert_from_to((_, r_to), v, llops):
-        return inputconst(r_to, None)
-
-    def rtype_is_((rnone1, robj2), hop):
-        from rpython.rtyper.lltypesystem.rpbc import rtype_is_None
-        if hop.s_result.is_constant():
-            return hop.inputconst(Bool, hop.s_result.const)
-        return rtype_is_None(robj2, rnone1, hop, pos=1)
-
 # ____________________________________________________________
 
 class AbstractClassesPBCRepr(Repr):
diff --git a/rpython/rtyper/rtyper.py b/rpython/rtyper/rtyper.py
--- a/rpython/rtyper/rtyper.py
+++ b/rpython/rtyper/rtyper.py
@@ -936,7 +936,7 @@
 # _______________________________________________________________________
 # this has the side-effect of registering the unary and binary operations
 # and the rtyper_chooserepr() methods
-from rpython.rtyper import rint, rbool, rfloat
+from rpython.rtyper import rint, rbool, rfloat, rnone
 from rpython.rtyper import rrange
 from rpython.rtyper import rstr, rdict, rlist, rbytearray
 from rpython.rtyper import rclass, rbuiltin, rpbc
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to