[pypy-svn] r53739 - in pypy/dist/pypy/rpython: lltypesystem ootypesystem

arigo at codespeak.net arigo at codespeak.net
Sun Apr 13 12:24:30 CEST 2008


Author: arigo
Date: Sun Apr 13 12:24:28 2008
New Revision: 53739

Modified:
   pypy/dist/pypy/rpython/lltypesystem/rclass.py
   pypy/dist/pypy/rpython/ootypesystem/rclass.py
Log:
An optimization that I thought was already done - apparently not.
Constant-fold the result of "instance.attr" if the annotator
aready says that the result is constant.


Modified: pypy/dist/pypy/rpython/lltypesystem/rclass.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/rclass.py	(original)
+++ pypy/dist/pypy/rpython/lltypesystem/rclass.py	Sun Apr 13 12:24:28 2008
@@ -520,6 +520,8 @@
             return instance_repr.getfield(vinst, '__class__', hop.llops)
 
     def rtype_getattr(self, hop):
+        if hop.s_result.is_constant():
+            return hop.inputconst(hop.r_result, hop.s_result.const)
         attr = hop.args_s[1].const
         vinst, vattr = hop.inputargs(self, Void)
         if attr == '__class__' and hop.r_result.lowleveltype is Void:

Modified: pypy/dist/pypy/rpython/ootypesystem/rclass.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/rclass.py	(original)
+++ pypy/dist/pypy/rpython/ootypesystem/rclass.py	Sun Apr 13 12:24:28 2008
@@ -380,6 +380,8 @@
         return ll_inst_hash
 
     def rtype_getattr(self, hop):
+        if hop.s_result.is_constant():
+            return hop.inputconst(hop.r_result, hop.s_result.const)
         v_inst, _ = hop.inputargs(self, ootype.Void)
         s_inst = hop.args_s[0]
         attr = hop.args_s[1].const



More information about the Pypy-commit mailing list