[pypy-svn] r67240 - in pypy/branch/pyjitpl5-less-is_oo/pypy/jit: backend/cli backend/llgraph backend/llvm backend/x86 metainterp metainterp/test tl/spli/test

antocuni at codespeak.net antocuni at codespeak.net
Thu Aug 27 15:23:03 CEST 2009


Author: antocuni
Date: Thu Aug 27 15:23:01 2009
New Revision: 67240

Modified:
   pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/cli/runner.py
   pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/llgraph/runner.py
   pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/llvm/runner.py
   pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/x86/runner.py
   pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/codewriter.py
   pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/pyjitpl.py
   pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/test/test_basic.py
   pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/virtualizable.py
   pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/warmspot.py
   pypy/branch/pyjitpl5-less-is_oo/pypy/jit/tl/spli/test/test_jit.py
Log:
attach the ts helper to the cpu instead of to the staticdata. This already
simplifies things a bit, and moreover assure that ts will be available
wherever is_oo is tested




Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/cli/runner.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/cli/runner.py	(original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/cli/runner.py	Thu Aug 27 15:23:01 2009
@@ -11,6 +11,7 @@
 from pypy.jit.backend.llgraph.runner import KeyManager
 from pypy.translator.cli import dotnet
 from pypy.translator.cli.dotnet import CLR
+from pypy.jit.metainterp.typesystem import oohelper
 
 System = CLR.System
 OpCodes = System.Reflection.Emit.OpCodes
@@ -29,7 +30,8 @@
 
 
 class CliCPU(model.AbstractCPU):
-
+    
+    ts = oohelper
     is_oo = True
 
     def __init__(self, rtyper, stats, translate_support_code=False,

Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/llgraph/runner.py	(original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/llgraph/runner.py	Thu Aug 27 15:23:01 2009
@@ -12,7 +12,7 @@
 from pypy.jit.metainterp.resoperation import ResOperation, rop
 from pypy.jit.backend import model
 from pypy.jit.backend.llgraph import llimpl, symbolic
-
+from pypy.jit.metainterp.typesystem import llhelper, oohelper
 
 class MiniStats:
     pass
@@ -242,6 +242,7 @@
 
 class LLtypeCPU(BaseCPU):
     is_oo = False
+    ts = llhelper
 
     def __init__(self, *args, **kwds):
         BaseCPU.__init__(self, *args, **kwds)
@@ -443,6 +444,7 @@
 
 class OOtypeCPU(BaseCPU):
     is_oo = True
+    ts = oohelper
 
     @staticmethod
     def fielddescrof(T, fieldname):

Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/llvm/runner.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/llvm/runner.py	(original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/backend/llvm/runner.py	Thu Aug 27 15:23:01 2009
@@ -10,11 +10,13 @@
 from pypy.jit.metainterp import history
 from pypy.jit.metainterp.resoperation import rop, ResOperation
 from pypy.jit.backend.x86 import symbolic     # xxx
+from pypy.jit.metainterp.typesystem import llhelper
 
 history.TreeLoop._llvm_compiled_index = -1
 
 
 class LLVMCPU(object):
+    ts = llhelper
     is_oo = False
     logger_cls = None
     RAW_VALUE = rffi.CFixedArray(rffi.ULONGLONG, 1)

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 15:23:01 2009
@@ -16,6 +16,7 @@
 from pypy.jit.backend.x86 import symbolic
 from pypy.jit.metainterp.resoperation import rop, opname
 from pypy.rlib.objectmodel import r_dict
+from pypy.jit.metainterp.typesystem import llhelper
 
 history.TreeLoop._x86_compiled = 0
 history.TreeLoop._x86_bootstrap_code = 0
@@ -49,6 +50,7 @@
 class CPU386(object):
     debug = True
     is_oo = False
+    ts = llhelper
     logger_cls = x86Logger
 
     BOOTSTRAP_TP = lltype.FuncType([], lltype.Signed)

Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/codewriter.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/codewriter.py	(original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/codewriter.py	Thu Aug 27 15:23:01 2009
@@ -48,7 +48,7 @@
         self.values = []
         for graph in graphs:
             fnptr = codewriter.rtyper.getcallable(graph)
-            fnaddress = codewriter.ts.cast_fnptr_to_root(fnptr)
+            fnaddress = codewriter.cpu.ts.cast_fnptr_to_root(fnptr)
             self.keys.append(fnaddress)
             self.values.append(codewriter.get_jitcode(graph))
         self.dict = None
@@ -80,7 +80,7 @@
 class CodeWriter(object):
     portal_graph = None
 
-    def __init__(self, metainterp_sd, policy, ts):
+    def __init__(self, metainterp_sd, policy):
         self.all_prebuilt_values = dict_equal_consts()
         self.all_graphs = {}
         self.all_indirectcallsets = {}
@@ -91,7 +91,6 @@
         self.rtyper = metainterp_sd.cpu.rtyper
         self.cpu = metainterp_sd.cpu
         self.policy = policy
-        self.ts = ts
         self.counter = 0
         self.raise_analyzer = RaiseAnalyzer(self.rtyper.annotator.translator)
         self.class_sizes = []

Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/pyjitpl.py	(original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/pyjitpl.py	Thu Aug 27 15:23:01 2009
@@ -9,7 +9,6 @@
 from pypy.jit.metainterp.history import Const, ConstInt, Box
 from pypy.jit.metainterp.resoperation import rop
 from pypy.jit.metainterp import codewriter, executor
-from pypy.jit.metainterp import typesystem
 from pypy.rlib.rarithmetic import intmask
 from pypy.rlib.objectmodel import specialize
 
@@ -845,7 +844,7 @@
         greenkey = self.env[:num_green_args]
         sd = self.metainterp.staticdata
         loc = sd.state.get_location_str(greenkey)
-        constloc = sd.ts.conststr(loc)
+        constloc = self.metainterp.cpu.ts.conststr(loc)
         self.metainterp.history.record(rop.DEBUG_MERGE_POINT,
                                        [constloc], None)
 
@@ -861,7 +860,7 @@
     def opimpl_goto_if_exception_mismatch(self, vtableref, next_exc_target):
         assert isinstance(self.exception_box, Const)    # XXX
         cpu = self.metainterp.cpu
-        ts = self.metainterp.staticdata.ts
+        ts = self.metainterp.cpu.ts
         if not ts.subclassOf(cpu, self.exception_box, vtableref):
             self.pc = next_exc_target
 
@@ -966,7 +965,7 @@
             return box     # no promotion needed, already a Const
 
     def cls_of_box(self, box):
-        return self.metainterp.staticdata.ts.cls_of_box(self.metainterp.cpu, box)
+        return self.metainterp.cpu.ts.cls_of_box(self.metainterp.cpu, box)
 
     @specialize.arg(1)
     def execute(self, opnum, argboxes, descr=None):
@@ -1007,11 +1006,6 @@
         self.optimize_loop = optimizer.optimize_loop
         self.optimize_bridge = optimizer.optimize_bridge
 
-        if self.cpu.is_oo:
-            self.ts = typesystem.oohelper
-        else:
-            self.ts = typesystem.llhelper
-
         if profile is not None:
             self.profiler = profile()
         else:
@@ -1065,8 +1059,8 @@
             class_sizes[vtable] = sizedescr
         self.cpu.set_class_sizes(class_sizes)
 
-    def generate_bytecode(self, policy, ts):
-        self._codewriter = codewriter.CodeWriter(self, policy, ts)
+    def generate_bytecode(self, policy):
+        self._codewriter = codewriter.CodeWriter(self, policy)
         self.portal_code = self._codewriter.make_portal_bytecode(
             self.portal_graph)
         self._class_sizes = self._codewriter.class_sizes
@@ -1158,7 +1152,7 @@
         #  - all subclasses of JitException
         if we_are_translated():
             from pypy.jit.metainterp.warmspot import JitException
-            e = self.staticdata.ts.get_exception_obj(excvaluebox)
+            e = self.cpu.ts.get_exception_obj(excvaluebox)
             if isinstance(e, JitException) or isinstance(e, AssertionError):
                 raise Exception, e
         #
@@ -1183,14 +1177,14 @@
     def raise_overflow_error(self):
         etype, evalue = self.cpu.get_overflow_error()
         return self.finishframe_exception(
-            self.staticdata.ts.get_exception_box(etype),
-            self.staticdata.ts.get_exc_value_box(evalue))
+            self.cpu.ts.get_exception_box(etype),
+            self.cpu.ts.get_exc_value_box(evalue))
 
     def raise_zero_division_error(self):
         etype, evalue = self.cpu.get_zero_division_error()
         return self.finishframe_exception(
-            self.staticdata.ts.get_exception_box(etype),
-            self.staticdata.ts.get_exc_value_box(evalue))
+            self.cpu.ts.get_exception_box(etype),
+            self.cpu.ts.get_exc_value_box(evalue))
 
     def create_empty_history(self):
         self.history = history.History(self.cpu)
@@ -1392,20 +1386,20 @@
         # save and restore all the boxes that are also used by callers.
         if self.history.inputargs is not None:
             for box in self.history.inputargs:
-                self.staticdata.ts.clean_box(box)
+                self.cpu.ts.clean_box(box)
         lists = [self.history.operations]
         while lists:
             for op in lists.pop():
                 if op is None:
                     continue
                 if op.result is not None:
-                    self.staticdata.ts.clean_box(op.result)
+                    self.cpu.ts.clean_box(op.result)
                 if op.suboperations is not None:
                     lists.append(op.suboperations)
                 if op.optimized is not None:
                     lists.append(op.optimized.suboperations)
                     if op.optimized.result is not None:
-                        self.staticdata.ts.clean_box(op.optimized.result)
+                        self.cpu.ts.clean_box(op.optimized.result)
 
     def prepare_resume_from_failure(self, opnum):
         if opnum == rop.GUARD_TRUE:     # a goto_if_not that jumps only now
@@ -1600,8 +1594,8 @@
         self.cpu.clear_exception()
         frame = self.framestack[-1]
         if etype:
-            exception_box = self.staticdata.ts.get_exception_box(etype)
-            exc_value_box = self.staticdata.ts.get_exc_value_box(evalue)
+            exception_box = self.cpu.ts.get_exception_box(etype)
+            exc_value_box = self.cpu.ts.get_exc_value_box(evalue)
             op = frame.generate_guard(frame.pc, rop.GUARD_EXCEPTION,
                                       None, [exception_box])
             if op:

Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/test/test_basic.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/test/test_basic.py	(original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/test/test_basic.py	Thu Aug 27 15:23:01 2009
@@ -73,7 +73,7 @@
                                             self.type_system, policy=policy,
                                             optimizer=simple_optimize,
                                             **kwds)
-        cw = codewriter.CodeWriter(metainterp.staticdata, policy, self.ts)
+        cw = codewriter.CodeWriter(metainterp.staticdata, policy)
         graph = rtyper.annotator.translator.graphs[0]
         graph_key = (graph, None)
         maingraph = cw.make_one_bytecode(graph_key, False)
@@ -103,7 +103,6 @@
 class LLJitMixin(JitMixin):
     type_system = 'lltype'
     CPUClass = runner.LLtypeCPU
-    ts = LLTypeHelper()
 
     @staticmethod
     def Ptr(T):
@@ -130,7 +129,6 @@
 class OOJitMixin(JitMixin):
     type_system = 'ootype'
     CPUClass = runner.OOtypeCPU
-    ts = OOTypeHelper()
 
     @staticmethod
     def Ptr(T):

Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/virtualizable.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/virtualizable.py	(original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/virtualizable.py	Thu Aug 27 15:23:01 2009
@@ -93,9 +93,9 @@
         self.array_field_descrs = [cpu.fielddescrof(VTYPE, name)
                                    for name in array_fields]
         #
-        getlength = warmrunnerdesc.ts.getlength
-        getarrayitem = warmrunnerdesc.ts.getarrayitem
-        setarrayitem = warmrunnerdesc.ts.setarrayitem
+        getlength = cpu.ts.getlength
+        getarrayitem = cpu.ts.getarrayitem
+        setarrayitem = cpu.ts.setarrayitem
         #
         def read_boxes(cpu, virtualizable):
             boxes = []
@@ -178,7 +178,7 @@
         force_if_necessary._always_inline_ = True
         #
         all_graphs = self.warmrunnerdesc.translator.graphs
-        ts = self.warmrunnerdesc.ts
+        ts = self.warmrunnerdesc.cpu.ts
         (_, FUNCPTR) = ts.get_FuncType([self.VTYPEPTR], lltype.Void)
         funcptr = self.warmrunnerdesc.helper_func(FUNCPTR, force_if_necessary)
         rvirtualizable2.replace_promote_virtualizable_with_call(

Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/warmspot.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/warmspot.py	(original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/metainterp/warmspot.py	Thu Aug 27 15:23:01 2009
@@ -145,7 +145,7 @@
         if self.jitdriver.virtualizables:
             from pypy.jit.metainterp.virtualizable import VirtualizableInfo
             self.metainterp_sd.virtualizable_info = VirtualizableInfo(self)
-        self.metainterp_sd.generate_bytecode(policy, self.ts)
+        self.metainterp_sd.generate_bytecode(policy)
         self.make_enter_function()
         self.rewrite_can_enter_jit()
         self.rewrite_set_param()
@@ -164,11 +164,6 @@
 
     def set_translator(self, translator):
         self.translator = translator
-        if translator.rtyper.type_system.name == 'lltypesystem':
-            self.ts = LLTypeHelper()
-        else:
-            assert translator.rtyper.type_system.name == 'ootypesystem'
-            self.ts = OOTypeHelper()
         self.gcdescr = gc.get_description(translator.config)
 
     def find_portal(self):
@@ -277,7 +272,7 @@
         annhelper = MixLevelHelperAnnotator(self.translator.rtyper)
         s_result = annotationoftype(rettype)
         RETTYPE = annhelper.rtyper.getrepr(s_result).lowleveltype
-        FUNC, PTR = self.ts.get_FuncType(self.green_args_spec, RETTYPE)
+        FUNC, PTR = self.cpu.ts.get_FuncType(self.green_args_spec, RETTYPE)
         args_s = [annmodel.lltype_to_annotation(ARG) for ARG in FUNC.ARGS]
         graph = annhelper.getgraph(func, args_s, s_result)
         funcptr = annhelper.graph2delayed(graph, FUNC)
@@ -300,9 +295,9 @@
                 self.red_args_types.append(history.getkind(TYPE))
         RESTYPE = graph.getreturnvar().concretetype
         (self.JIT_ENTER_FUNCTYPE,
-         self.PTR_JIT_ENTER_FUNCTYPE) = self.ts.get_FuncType(ALLARGS, lltype.Void)
+         self.PTR_JIT_ENTER_FUNCTYPE) = self.cpu.ts.get_FuncType(ALLARGS, lltype.Void)
         (self.PORTAL_FUNCTYPE,
-         self.PTR_PORTAL_FUNCTYPE) = self.ts.get_FuncType(ALLARGS, RESTYPE)
+         self.PTR_PORTAL_FUNCTYPE) = self.cpu.ts.get_FuncType(ALLARGS, RESTYPE)
         
 
     def rewrite_can_enter_jit(self):
@@ -374,7 +369,7 @@
         # ____________________________________________________________
         # Prepare the portal_runner() helper
         #
-        portal_ptr = self.ts.functionptr(PORTALFUNC, 'portal',
+        portal_ptr = self.cpu.ts.functionptr(PORTALFUNC, 'portal',
                                          graph = portalgraph)
         portalfunc_ARGS = unrolling_iterable(
             [(i, 'arg%d' % i, ARG) for i, ARG in enumerate(PORTALFUNC.ARGS)])
@@ -526,8 +521,8 @@
     def rewrite_set_param(self):
         closures = {}
         graphs = self.translator.graphs
-        _, PTR_SET_PARAM_FUNCTYPE = self.ts.get_FuncType([lltype.Signed],
-                                                         lltype.Void)
+        _, PTR_SET_PARAM_FUNCTYPE = self.cpu.ts.get_FuncType([lltype.Signed],
+                                                             lltype.Void)
         def make_closure(fullfuncname):
             state = self.state
             def closure(i):
@@ -666,9 +661,9 @@
         MAX_HASH_TABLE_BITS = 1
     THRESHOLD_LIMIT = sys.maxint // 2
     #
-    getlength = warmrunnerdesc.ts.getlength
-    getarrayitem = warmrunnerdesc.ts.getarrayitem
-    setarrayitem = warmrunnerdesc.ts.setarrayitem
+    getlength = warmrunnerdesc.cpu.ts.getlength
+    getarrayitem = warmrunnerdesc.cpu.ts.getarrayitem
+    setarrayitem = warmrunnerdesc.cpu.ts.setarrayitem
     #
     rtyper = warmrunnerdesc.translator.rtyper
     can_inline_ptr = warmrunnerdesc.can_inline_ptr

Modified: pypy/branch/pyjitpl5-less-is_oo/pypy/jit/tl/spli/test/test_jit.py
==============================================================================
--- pypy/branch/pyjitpl5-less-is_oo/pypy/jit/tl/spli/test/test_jit.py	(original)
+++ pypy/branch/pyjitpl5-less-is_oo/pypy/jit/tl/spli/test/test_jit.py	Thu Aug 27 15:23:01 2009
@@ -9,7 +9,6 @@
 class TestSPLIJit(JitMixin):
     type_system = 'lltype'
     CPUClass = runner.LLtypeCPU
-    ts = LLTypeHelper()
     
     def interpret(self, f, args):
         coderepr = serializer.serialize(f.func_code)



More information about the Pypy-commit mailing list