[pypy-svn] r74154 - in pypy/branch/blackhole-improvement/pypy/jit: backend backend/llgraph codewriter metainterp

arigo at codespeak.net arigo at codespeak.net
Wed Apr 28 11:54:50 CEST 2010


Author: arigo
Date: Wed Apr 28 11:54:48 2010
New Revision: 74154

Removed:
   pypy/branch/blackhole-improvement/pypy/jit/metainterp/heaptracker.py
Modified:
   pypy/branch/blackhole-improvement/pypy/jit/backend/llgraph/llimpl.py
   pypy/branch/blackhole-improvement/pypy/jit/backend/llgraph/runner.py
   pypy/branch/blackhole-improvement/pypy/jit/backend/model.py
   pypy/branch/blackhole-improvement/pypy/jit/codewriter/jitter.py
   pypy/branch/blackhole-improvement/pypy/jit/metainterp/blackhole.py
Log:
Enough to pass test_isinstance.


Modified: pypy/branch/blackhole-improvement/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/backend/llgraph/llimpl.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/backend/llgraph/llimpl.py	Wed Apr 28 11:54:48 2010
@@ -1151,16 +1151,6 @@
 def get_frame_forced_token(opaque_frame):
     return llmemory.cast_ptr_to_adr(opaque_frame)
 
-class MemoCast(object):
-    def __init__(self):
-        self.addresses = [llmemory.NULL]
-        self.rev_cache = {}
-        self.vtable_to_size = {}
-
-def new_memo_cast():
-    memocast = MemoCast()
-    return _to_opaque(memocast)
-
 ##def cast_adr_to_int(memocast, adr):
 ##    # xxx slow
 ##    assert lltype.typeOf(adr) == llmemory.Address
@@ -1280,11 +1270,11 @@
     newvalue = cast_from_ptr(ITEMTYPE, newvalue)
     array.setitem(index, newvalue)
 
-def do_setfield_gc_int(struct, fieldnum, newvalue, memocast):
+def do_setfield_gc_int(struct, fieldnum, newvalue):
     STRUCT, fieldname = symbolic.TokenToField[fieldnum]
     ptr = lltype.cast_opaque_ptr(lltype.Ptr(STRUCT), struct)
     FIELDTYPE = getattr(STRUCT, fieldname)
-    newvalue = cast_from_int(FIELDTYPE, newvalue, memocast)
+    newvalue = cast_from_int(FIELDTYPE, newvalue)
     setattr(ptr, fieldname, newvalue)
 
 def do_setfield_gc_float(struct, fieldnum, newvalue):
@@ -1480,16 +1470,13 @@
 COMPILEDLOOP = lltype.Ptr(lltype.OpaqueType("CompiledLoop"))
 FRAME = lltype.Ptr(lltype.OpaqueType("Frame"))
 OOFRAME = lltype.Ptr(lltype.OpaqueType("OOFrame"))
-MEMOCAST = lltype.Ptr(lltype.OpaqueType("MemoCast"))
 
 _TO_OPAQUE[CompiledLoop] = COMPILEDLOOP.TO
 _TO_OPAQUE[Frame] = FRAME.TO
 _TO_OPAQUE[OOFrame] = OOFRAME.TO
-_TO_OPAQUE[MemoCast] = MEMOCAST.TO
 
 s_CompiledLoop = annmodel.SomePtr(COMPILEDLOOP)
 s_Frame = annmodel.SomePtr(FRAME)
-s_MemoCast = annmodel.SomePtr(MEMOCAST)
 
 setannotation(compile_start, s_CompiledLoop)
 setannotation(compile_start_int_var, annmodel.SomeInteger())
@@ -1530,11 +1517,6 @@
 setannotation(get_forced_token_frame, s_Frame)
 setannotation(get_frame_forced_token, annmodel.SomeAddress())
 
-setannotation(new_memo_cast, s_MemoCast)
-##setannotation(cast_adr_to_int, annmodel.SomeInteger())
-##setannotation(cast_int_to_adr, annmodel.SomeAddress())
-setannotation(set_class_size, annmodel.s_None)
-
 setannotation(do_arraylen_gc, annmodel.SomeInteger())
 setannotation(do_strlen, annmodel.SomeInteger())
 setannotation(do_strgetitem, annmodel.SomeInteger())

Modified: pypy/branch/blackhole-improvement/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/backend/llgraph/runner.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/backend/llgraph/runner.py	Wed Apr 28 11:54:48 2010
@@ -86,11 +86,11 @@
         self.stats.exec_counters = {}
         self.stats.exec_jumps = 0
         self.stats.exec_conditional_jumps = 0
-        self.memo_cast = llimpl.new_memo_cast()
         llimpl._stats = self.stats
         llimpl._llinterp = LLInterpreter(self.rtyper)
         self._future_values = []
         self._descrs = {}
+        self.class_vtables_as_int = {}
 
     def _freeze_(self):
         assert self.translate_support_code
@@ -105,13 +105,6 @@
             self._descrs[key] = descr
             return descr
 
-    def set_class_sizes(self, class_sizes):
-        self.class_sizes = class_sizes
-        for vtable, size in class_sizes.items():
-            if not self.is_oo:
-                size = size.ofs
-            llimpl.set_class_size(self.memo_cast, vtable, size)
-
     def compile_bridge(self, faildescr, inputargs, operations):
         c = llimpl.compile_start()
         self._compile_loop_or_bridge(c, inputargs, operations)
@@ -285,6 +278,14 @@
         assert not isinstance(S, lltype.Ptr)
         return self.getdescr(symbolic.get_size(S))
 
+    def sizevtableof(self, S, vtable):
+        assert isinstance(S, lltype.GcStruct)
+        descr = self.getdescr(symbolic.get_size(S))
+        vtable_adr = llmemory.cast_ptr_to_adr(vtable)
+        vtable_int = llmemory.cast_adr_to_int(vtable_adr)
+        self.class_vtables_as_int[descr] = vtable_int
+        return descr
+
     def cast_adr_to_int(self, adr):
         return llimpl.cast_adr_to_int(self.memo_cast, adr)
 
@@ -427,13 +428,11 @@
         assert isinstance(size, Descr)
         return history.BoxPtr(llimpl.do_new(size.ofs))
 
-    def do_new_with_vtable(self, vtablebox):
-        vtable = vtablebox.getint()
-        size = self.class_sizes[vtable]
-        result = llimpl.do_new(size.ofs)
+    def bh_new_with_vtable(self, sizevtabledescr):
+        result = llimpl.do_new(sizevtabledescr.ofs)
         llimpl.do_setfield_gc_int(result, self.fielddescrof_vtable.ofs,
-                                  vtable, self.memo_cast)
-        return history.BoxPtr(result)
+                                  self.class_vtables_as_int[sizevtabledescr])
+        return result
 
     def do_new_array(self, countbox, size):
         assert isinstance(size, Descr)

Modified: pypy/branch/blackhole-improvement/pypy/jit/backend/model.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/backend/model.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/backend/model.py	Wed Apr 28 11:54:48 2010
@@ -24,9 +24,6 @@
     def get_fail_descr_from_number(self, n):
         return self.fail_descr_list[n]
 
-    def set_class_sizes(self, class_sizes):
-        self.class_sizes = class_sizes
-
     def setup_once(self):
         """Called once by the front-end when the program starts."""
         pass
@@ -118,7 +115,7 @@
         raise NotImplementedError
 
     @staticmethod
-    def numof(S):
+    def sizevtableof(S, vtable):
         raise NotImplementedError
 
     @staticmethod
@@ -215,6 +212,9 @@
     def do_new_with_vtable(self, classbox):
         raise NotImplementedError
 
+    def bh_new_with_vtable(self, sizevtabledescr):
+        raise NotImplementedError
+
     def do_new_array(self, lengthbox, arraydescr):
         raise NotImplementedError
 

Modified: pypy/branch/blackhole-improvement/pypy/jit/codewriter/jitter.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/codewriter/jitter.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/codewriter/jitter.py	Wed Apr 28 11:54:48 2010
@@ -239,9 +239,8 @@
         return ARRAY.OF == lltype.Void
 
     def rewrite_op_getfield(self, op):
-        #if self.is_typeptr_getset(op):
-        #    self.handle_getfield_typeptr(op)
-        #    return
+        if self.is_typeptr_getset(op):
+            XXX
         # turn the flow graph 'getfield' operation into our own version
         [v_inst, c_fieldname] = op.args
         RESULT = op.result.concretetype
@@ -284,6 +283,16 @@
         return SpaceOperation('getfield_%s_%s%s' % (argname, kind, pure),
                               [v_inst, descr], op.result)
 
+    def rewrite_op_setfield(self, op):
+        if self.is_typeptr_getset(op):
+            # ignore the operation completely -- instead, it's done by 'new'
+            raise NoOp
+        XXX
+
+    def is_typeptr_getset(self, op):
+        return (op.args[1].value == 'typeptr' and
+                op.args[0].concretetype.TO._hints.get('typeptr'))
+
     def rewrite_op_malloc(self, op):
         assert op.args[1].value == {'flavor': 'gc'}
         STRUCT = op.args[0].value

Modified: pypy/branch/blackhole-improvement/pypy/jit/metainterp/blackhole.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/metainterp/blackhole.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/metainterp/blackhole.py	Wed Apr 28 11:54:48 2010
@@ -504,3 +504,7 @@
     opimpl_getfield_raw_u_pure = opimpl_getfield_raw_u
     opimpl_getfield_raw_r_pure = opimpl_getfield_raw_r
     opimpl_getfield_raw_f_pure = opimpl_getfield_raw_f
+
+    @arguments("d", returns="r")
+    def opimpl_new_with_vtable(self, descr):
+        return self.cpu.bh_new_with_vtable(descr)



More information about the Pypy-commit mailing list