[pypy-commit] pypy int-tag-untag-as-operations: make tagged instances use the new operations as well

cfbolz noreply at buildbot.pypy.org
Thu Oct 27 17:28:03 CEST 2011


Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: int-tag-untag-as-operations
Changeset: r48509:d3b9577c4c08
Date: 2011-10-27 17:27 +0200
http://bitbucket.org/pypy/pypy/changeset/d3b9577c4c08/

Log:	make tagged instances use the new operations as well

diff --git a/pypy/rpython/lltypesystem/rtagged.py b/pypy/rpython/lltypesystem/rtagged.py
--- a/pypy/rpython/lltypesystem/rtagged.py
+++ b/pypy/rpython/lltypesystem/rtagged.py
@@ -4,6 +4,7 @@
 from pypy.rpython.lltypesystem.rclass import InstanceRepr, CLASSTYPE, ll_inst_type
 from pypy.rpython.lltypesystem.rclass import MissingRTypeAttribute
 from pypy.rpython.lltypesystem.rclass import ll_issubclass_const
+from pypy.rpython.lltypesystem.lloperation import llop
 from pypy.rpython.rmodel import TyperError, inputconst
 
 
@@ -43,18 +44,17 @@
         v_value = hop.inputarg(lltype.Signed, arg=1)
         c_one = hop.inputconst(lltype.Signed, 1)
         hop.exception_is_here()
-        v2 = hop.genop('int_add_ovf', [v_value, v_value],
+        v2 = hop.genop('int_tag_ovf', [v_value],
                        resulttype = lltype.Signed)
-        v2p1 = hop.genop('int_add', [v2, c_one],
-                         resulttype = lltype.Signed)
-        v_instance =  hop.genop('cast_int_to_ptr', [v2p1],
+        v_instance =  hop.genop('cast_int_to_ptr', [v2],
                                 resulttype = self.lowleveltype)
         return v_instance, False   # don't call __init__
 
     def convert_const_exact(self, value):
         self.setup()
         number = value.get_untagged_value()
-        return ll_int_to_unboxed(self.lowleveltype, number)
+        tagged = number * 2 + 1
+        return lltype.cast_int_to_ptr(self.lowleveltype, tagged)
 
     def getvalue_from_unboxed(self, llops, vinst):
         assert not self.is_parent
@@ -142,11 +142,9 @@
                                  minid, maxid, c_answer_if_unboxed)
 
 
-def ll_int_to_unboxed(PTRTYPE, value):
-    return lltype.cast_int_to_ptr(PTRTYPE, value*2+1)
 
 def ll_unboxed_to_int(p):
-    return lltype.cast_ptr_to_int(p) >> 1
+    return llop.int_untag(lltype.Signed, lltype.cast_ptr_to_int(p))
 
 def ll_unboxed_getclass_canbenone(instance, class_if_unboxed):
     if instance:


More information about the pypy-commit mailing list