[pypy-svn] r67250 - in pypy/branch/pyjitpl5-less-is_oo/pypy/jit: backend/cli backend/x86 metainterp

antocuni at codespeak.net antocuni at codespeak.net
Thu Aug 27 16:38:34 CEST 2009


Author: antocuni
Date: Thu Aug 27 16:38:33 2009
New Revision: 67250

Modified:
   pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/cli/method.py
   pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/x86/assembler.py
   pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/x86/runner.py
   pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/executor.py
   pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/history.py
   pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/optimizeopt.py
   pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/typesystem.py
Log:
unify history.PTR and history.OBJ into history.REF; this let us to remove a
bit of code duplication here and there



Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/cli/method.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/cli/method.py	(original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/cli/method.py	Thu Aug 27 16:38:33 2009
@@ -44,7 +44,7 @@
         
         if self.type == history.INT:
             return dotnet.typeof(System.Int32)
-        elif self.type == history.OBJ:
+        elif self.type == history.REF:
             return dotnet.typeof(System.Object)
         else:
             assert False, 'Unknown type: %s' % self.type
@@ -282,7 +282,7 @@
         t = dotnet.typeof(InputArgs)
         if type == history.INT:
             fieldname = 'ints'
-        elif type == history.OBJ:
+        elif type == history.REF:
             fieldname = 'objs'
         else:
             assert False, 'Unknown type %s' % type

Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/x86/assembler.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/x86/assembler.py	(original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/x86/assembler.py	Thu Aug 27 16:38:33 2009
@@ -1,7 +1,7 @@
 import sys, os
 import ctypes
 from pypy.jit.backend.x86 import symbolic
-from pypy.jit.metainterp.history import Const, Box, BoxPtr, PTR
+from pypy.jit.metainterp.history import Const, Box, BoxPtr, REF
 from pypy.rpython.lltypesystem import lltype, rffi, ll2ctypes, rstr, llmemory
 from pypy.rpython.lltypesystem.rclass import OBJECT
 from pypy.rpython.lltypesystem.lloperation import llop
@@ -240,7 +240,7 @@
         for i in range(len(arglocs)):
             loc = arglocs[i]
             if not isinstance(loc, REG):
-                if args[i].type == PTR:
+                if args[i].type == REF:
                     # This uses XCHG to put zeroes in fail_boxes_ptr after
                     # reading them
                     self.mc.XOR(ecx, ecx)
@@ -253,7 +253,7 @@
         for i in range(len(arglocs)):
             loc = arglocs[i]
             if isinstance(loc, REG):
-                if args[i].type == PTR:
+                if args[i].type == REF:
                     # This uses XCHG to put zeroes in fail_boxes_ptr after
                     # reading them
                     self.mc.XOR(loc, loc)
@@ -718,7 +718,7 @@
         for i in range(len(locs)):
             loc = locs[i]
             if isinstance(loc, REG):
-                if op.args[i].type == PTR:
+                if op.args[i].type == REF:
                     base = self.fail_box_ptr_addr
                 else:
                     base = self.fail_box_int_addr
@@ -726,7 +726,7 @@
         for i in range(len(locs)):
             loc = locs[i]
             if not isinstance(loc, REG):
-                if op.args[i].type == PTR:
+                if op.args[i].type == REF:
                     base = self.fail_box_ptr_addr
                 else:
                     base = self.fail_box_int_addr

Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/x86/runner.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/x86/runner.py	(original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/x86/runner.py	Thu Aug 27 16:38:33 2009
@@ -179,7 +179,7 @@
         if calldescr.call_loop is not None:
             if not we_are_translated():
                 assert (calldescr.shape ==
-                        ([arg.type == history.PTR for arg in args[1:]], ptr))
+                        ([arg.type == history.REF for arg in args[1:]], ptr))
             return calldescr.call_loop
         args = [arg.clonebox() for arg in args]
         result = self._new_box(ptr)

Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/executor.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/executor.py	(original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/executor.py	Thu Aug 27 16:38:33 2009
@@ -7,7 +7,7 @@
 from pypy.rpython.lltypesystem.lloperation import llop
 from pypy.rlib.rarithmetic import ovfcheck, r_uint, intmask
 from pypy.jit.metainterp.history import BoxInt, ConstInt, check_descr
-from pypy.jit.metainterp.history import INT, PTR, OBJ
+from pypy.jit.metainterp.history import INT, REF
 from pypy.jit.metainterp.resoperation import rop
 
 
@@ -106,22 +106,20 @@
     tp = args[0].type
     if tp == INT:
         x = bool(args[0].getint())
-    elif tp == PTR:
+    elif tp == REF:
         x = bool(args[0].getref_base())
     else:
-        assert tp == OBJ
-        x = bool(args[0].getref_base())
+        assert False
     return ConstInt(x)
 
 def do_ooisnull(cpu, args, descr=None):
     tp = args[0].type
     if tp == INT:
         x = bool(args[0].getint())
-    elif tp == PTR:
+    elif tp == REF:
         x = bool(args[0].getref_base())
     else:
-        assert tp == OBJ
-        x = bool(args[0].getref_base())
+        assert False
     return ConstInt(not x)
 
 def do_oois(cpu, args, descr=None):
@@ -129,11 +127,10 @@
     assert tp == args[1].type
     if tp == INT:
         x = args[0].getint() == args[1].getint()
-    elif tp == PTR:
+    elif tp == REF:
         x = args[0].getref_base() == args[1].getref_base()
     else:
-        assert tp == OBJ
-        x = args[0].getref_base() == args[1].getref_base()
+        assert False
     return ConstInt(x)
 
 def do_ooisnot(cpu, args, descr=None):
@@ -141,11 +138,10 @@
     assert tp == args[1].type
     if tp == INT:
         x = args[0].getint() != args[1].getint()
-    elif tp == PTR:
+    elif tp == REF:
         x = args[0].getref_base() != args[1].getref_base()
     else:
-        assert tp == OBJ
-        x = args[0].getref_base() != args[1].getref_base()
+        assert False
     return ConstInt(x)
 
 def do_ooidentityhash(cpu, args, descr=None):

Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/history.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/history.py	(original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/history.py	Thu Aug 27 16:38:33 2009
@@ -17,8 +17,7 @@
 # ____________________________________________________________
 
 INT = 'i'
-PTR = 'p'
-OBJ = 'o'
+REF = 'r'
 
 def getkind(TYPE):
     if TYPE is lltype.Void:
@@ -280,7 +279,7 @@
         return repr_rpython(self, 'ca')
 
 class ConstPtr(Const):
-    type = PTR
+    type = REF
     value = lltype.nullptr(llmemory.GCREF.TO)
     _attrs_ = ('value',)
 
@@ -326,7 +325,7 @@
         return hlstr(lltype.cast_opaque_ptr(lltype.Ptr(rstr.STR), self.value))
 
 class ConstObj(Const):
-    type = OBJ
+    type = REF
     value = ootype.NULL
     _attrs_ = ('value',)
 
@@ -471,7 +470,7 @@
     changevalue_int = __init__
 
 class BoxPtr(Box):
-    type = PTR
+    type = REF
     _attrs_ = ('value',)
 
     def __init__(self, value=lltype.nullptr(llmemory.GCREF.TO)):
@@ -516,7 +515,7 @@
 
 
 class BoxObj(Box):
-    type = OBJ
+    type = REF
     _attrs_ = ('value',)
 
     def __init__(self, value=ootype.NULL):

Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/optimizeopt.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/optimizeopt.py	(original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/optimizeopt.py	Thu Aug 27 16:38:33 2009
@@ -1,5 +1,5 @@
 from pypy.jit.metainterp.history import Box, BoxInt, BoxPtr, BoxObj
-from pypy.jit.metainterp.history import Const, ConstInt, ConstPtr, ConstObj, PTR, OBJ
+from pypy.jit.metainterp.history import Const, ConstInt, ConstPtr, ConstObj, REF
 from pypy.jit.metainterp.resoperation import rop, ResOperation
 from pypy.jit.metainterp.specnode import SpecNode, NotSpecNode, ConstantSpecNode
 from pypy.jit.metainterp.specnode import AbstractVirtualStructSpecNode
@@ -336,26 +336,18 @@
         self.values = {}
         self.values_to_clean = []    # OptValues to clean when we see an
                                      # operation with side-effects
-        self.interned_ptrs = {}
-        self.interned_objs = {}
+        self.interned_refs = {}
 
     def getinterned(self, box):
         if not self.is_constant(box):
             return box
-        if not self.cpu.is_oo and box.type == PTR:
+        if box.type == REF:
             value = box.getref_base()
-            key = lltype.cast_ptr_to_int(value)
+            key = self.cpu.ts.cast_ref_to_hashable(value)
             try:
-                return self.interned_ptrs[key]
+                return self.interned_refs[key]
             except KeyError:
-                self.interned_ptrs[key] = box
-                return box
-        elif self.cpu.is_oo and box.type == OBJ:
-            value = box.getref_base()
-            try:
-                return self.interned_objs[value]
-            except KeyError:
-                self.interned_objs[value] = box
+                self.interned_refs[key] = box
                 return box
         else:
             return box

Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/typesystem.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/typesystem.py	(original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/typesystem.py	Thu Aug 27 16:38:33 2009
@@ -1,10 +1,8 @@
-#from pypy.rpython.annlowlevel import base_ptr_lltype, base_obj_ootype
-#from pypy.rpython.annlowlevel import cast_instance_to_base_ptr
-#from pypy.rpython.annlowlevel import cast_instance_to_base_obj
 from pypy.rpython.lltypesystem import lltype, llmemory, rclass
 from pypy.rpython.ootypesystem import ootype
 from pypy.rpython.annlowlevel import cast_base_ptr_to_instance, llstr, oostr
 from pypy.jit.metainterp import history
+from pypy.jit.metainterp import history
 
 def deref(T):
     if isinstance(T, lltype.Ptr):
@@ -39,10 +37,8 @@
 
     name = 'lltype'
     functionptr = staticmethod(lltype.functionptr)
-    #ROOT_TYPE = llmemory.Address
-    #BASE_OBJ_TYPE = base_ptr_lltype()
-    #NULL_OBJECT = base_ptr_lltype()._defl()
-    #cast_instance_to_base_ptr = staticmethod(cast_instance_to_base_ptr)
+    BoxRef = history.BoxPtr
+    ConstRef = history.ConstPtr
 
     def get_typeptr(self, obj):
         return obj.typeptr
@@ -95,15 +91,15 @@
         ll = llstr(str)
         return history.ConstPtr(lltype.cast_opaque_ptr(llmemory.GCREF, ll))
 
+    def cast_ref_to_hashable(self, ptr):
+        return lltype.cast_ptr_to_int(ptr)
 
 class OOTypeHelper(TypeSystemHelper):
 
     name = 'ootype'
     functionptr = staticmethod(ootype.static_meth)
-    #ROOT_TYPE = ootype.Object
-    #BASE_OBJ_TYPE = base_obj_ootype()
-    #NULL_OBJECT = base_obj_ootype()._defl()
-    #cast_instance_to_base_ptr = staticmethod(cast_instance_to_base_obj)
+    BoxRef = history.BoxObj
+    ConstRef = history.ConstObj
 
     def get_typeptr(self, obj):
         return obj.meta
@@ -153,6 +149,9 @@
         oo = oostr(str)
         return history.ConstObj(ootype.cast_to_object(oo))
 
+    def cast_ref_to_hashable(self, obj):
+        return obj
+
 
 llhelper = LLTypeHelper()
 oohelper = OOTypeHelper()



More information about the Pypy-commit mailing list