[pypy-svn] r74293 - in pypy/branch/blackhole-improvement/pypy/jit: codewriter metainterp

arigo at codespeak.net arigo at codespeak.net
Fri Apr 30 17:38:47 CEST 2010


Author: arigo
Date: Fri Apr 30 17:38:46 2010
New Revision: 74293

Modified:
   pypy/branch/blackhole-improvement/pypy/jit/codewriter/assembler.py
   pypy/branch/blackhole-improvement/pypy/jit/metainterp/pyjitpl.py
Log:
In-progress.


Modified: pypy/branch/blackhole-improvement/pypy/jit/codewriter/assembler.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/codewriter/assembler.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/codewriter/assembler.py	Fri Apr 30 17:38:46 2010
@@ -1,6 +1,7 @@
 from pypy.jit.metainterp.history import AbstractValue, AbstractDescr, getkind
 from pypy.jit.codewriter.flatten import Register, Label, TLabel, KINDS
 from pypy.jit.codewriter.flatten import ListOfKind, SwitchDictDescr
+from pypy.jit.codewriter.format import format_assembler
 from pypy.objspace.flow.model import Constant
 from pypy.rpython.lltypesystem import lltype, llmemory
 from pypy.rlib.objectmodel import we_are_translated
@@ -100,6 +101,7 @@
         self.insns = {}
         self.descrs = []
         self._descr_dict = {}
+        self._count_jitcodes = 0
 
     def assemble(self, ssarepr):
         self.setup()
@@ -107,7 +109,7 @@
             self.write_insn(insn)
         self.fix_labels()
         self.check_result()
-        return self.make_jitcode(ssarepr.name)
+        return self.make_jitcode(ssarepr)
 
     def setup(self):
         self.code = []
@@ -248,8 +250,8 @@
         assert self.count_regs['ref'] + len(self.constants_r) <= 256
         assert self.count_regs['float'] + len(self.constants_f) <= 256
 
-    def make_jitcode(self, name):
-        jitcode = JitCode(name, liveness=self.liveness,
+    def make_jitcode(self, ssarepr):
+        jitcode = JitCode(ssarepr.name, liveness=self.liveness,
                           assembler=self)
         jitcode.setup(''.join(self.code),
                       self.constants_i,
@@ -258,4 +260,7 @@
                       self.count_regs['int'],
                       self.count_regs['ref'],
                       self.count_regs['float'])
+        if self._count_jitcodes < 50:    # stop if we have a lot of them
+            jitcode._dump = format_assembler(ssarepr)
+        self._count_jitcodes += 1
         return jitcode

Modified: pypy/branch/blackhole-improvement/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/metainterp/pyjitpl.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/metainterp/pyjitpl.py	Fri Apr 30 17:38:46 2010
@@ -183,27 +183,25 @@
     def opimpl_goto(self, target):
         self.pc = target
 
-    @XXX  #arguments("orgpc", "jumptarget", "box", "varargs")
-    def opimpl_goto_if_not(self, pc, target, box, livelist):
+    @arguments("orgpc", "label", "box")
+    def opimpl_goto_if_not(self, pc, target, box):
         switchcase = box.getint()
         if switchcase:
             opnum = rop.GUARD_TRUE
         else:
             self.pc = target
             opnum = rop.GUARD_FALSE
-        self.env = livelist
         self.generate_guard(pc, opnum, box)
-        # note about handling self.env explicitly here: it is done in
-        # such a way that the 'box' on which we generate the guard is
-        # typically not included in the livelist.
-
-    @arguments("label", "box", "box")
-    def opimpl_goto_if_not_int_lt(self, target, box1, box2):
-        if box1.getint() < box2.getint():
-            pass
-        else:
-            self.pc = target
 
+    for _opimpl in ['int_lt', 'int_le', 'int_eq', 'int_ne', 'int_gt', 'int_ge',
+                    ]:
+        exec py.code.Source('''
+            @arguments("orgpc", "label", "box", "box")
+            def opimpl_goto_if_not_%s(self, pc, target, b1, b2):
+                condbox = self.execute(rop.%s, b1, b2)
+                self.opimpl_goto_if_not(pc, target, condbox)
+        ''' % (_opimpl, _opimpl.upper())).compile()
+    
     def follow_jump(self):
         _op_goto_if_not = self.metainterp.staticdata._op_goto_if_not
         assert ord(self.bytecode[self.pc]) == _op_goto_if_not



More information about the Pypy-commit mailing list