[pypy-svn] r65331 - in pypy/branch/pyjitpl5/pypy/jit/backend/cli: . test

antocuni at codespeak.net antocuni at codespeak.net
Wed May 20 16:21:29 CEST 2009


Author: antocuni
Date: Wed May 20 16:21:28 2009
New Revision: 65331

Modified:
   pypy/branch/pyjitpl5/pypy/jit/backend/cli/method.py
   pypy/branch/pyjitpl5/pypy/jit/backend/cli/methodfactory.py
   pypy/branch/pyjitpl5/pypy/jit/backend/cli/runner.py
   pypy/branch/pyjitpl5/pypy/jit/backend/cli/test/test_basic.py
Log:
the code to implement bridges was broken, fix it:

  - don't put a 'ret' in emit_store_opargs, else the jump is never taken

  - put the array of failing ops on the cpu, not on the method, else the
    "failed_op" index stored in inputargs is meaningless

  - add a bunch of debugging stuff



Modified: pypy/branch/pyjitpl5/pypy/jit/backend/cli/method.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/cli/method.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/cli/method.py	Wed May 20 16:21:28 2009
@@ -124,7 +124,6 @@
         self.name = name
         self.loop = loop
         self.boxes = {}       # box --> local var
-        self.failing_ops = [] # index --> op
         self.branches = []
         self.branchlabels = []
         self.consts = {}      # object --> index
@@ -183,10 +182,10 @@
 
     def get_index_for_failing_op(self, op):
         try:
-            return self.failing_ops.index(op)
+            return self.cpu.failing_ops.index(op)
         except ValueError:
-            self.failing_ops.append(op)
-            return len(self.failing_ops)-1
+            self.cpu.failing_ops.append(op)
+            return len(self.cpu.failing_ops)-1
 
     def get_index_for_constant(self, obj):
         try:
@@ -231,6 +230,7 @@
         self.il.Emit(OpCodes.Stelem, clitype)
 
     def emit_load_inputargs(self):
+        self.emit_debug("executing: " + self.name)
         i = 0
         for box in self.loop.inputargs:
             self.load_inputarg(i, box.type, box.getCliType())
@@ -243,8 +243,7 @@
 
     def emit_operations(self, operations):
         for op in operations:
-            if self.debug:
-                self.il.EmitWriteLine(op.repr())
+            self.emit_debug(op.repr())
             func = self.operations[op.opnum]
             assert func is not None
             func(self, op)
@@ -278,6 +277,10 @@
     def store_result(self, op):
         op.result.store(self)
 
+    def emit_debug(self, msg):
+        if self.debug:
+            self.il.EmitWriteLine(msg)
+
     def emit_clear_exception(self):
         self.av_inputargs.load(self)
         self.il.Emit(OpCodes.Ldnull)
@@ -315,6 +318,7 @@
         field = dotnet.typeof(InputArgs).GetField('failed_op')
         self.il.Emit(OpCodes.Stfld, field)
         self.emit_store_opargs(op)
+        self.il.Emit(OpCodes.Ret)
 
     def emit_store_opargs(self, op):
         # store the latest values
@@ -322,7 +326,6 @@
         for box in op.args:
             self.store_inputarg(i, box.type, box.getCliType(), box)
             i+=1
-        self.il.Emit(OpCodes.Ret)
 
     def emit_guard_bool(self, op, opcode):
         assert op.suboperations
@@ -388,9 +391,10 @@
             self.il.Emit(OpCodes.Br, self.il_loop_start)
         else:
             # it's a real bridge
+            self.emit_debug('jumping to ' + target.name)
             self.emit_store_opargs(op)
+            target._cli_funcbox.load(self)
             self.av_inputargs.load(self)
-            self.loop._cli_funcbox.load(self)
             methinfo = dotnet.typeof(LoopDelegate).GetMethod('Invoke')
             if self.tailcall:
                 self.il.Emit(OpCodes.Tailcall)

Modified: pypy/branch/pyjitpl5/pypy/jit/backend/cli/methodfactory.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/cli/methodfactory.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/cli/methodfactory.py	Wed May 20 16:21:28 2009
@@ -71,7 +71,7 @@
     def create_delegate(self, delegatetype, consts):
         t = self.typeBuilder.CreateType()
         methinfo = t.GetMethod("invoke")
-##         if self.name == 'generated_case_1':
+##         if self.name == 'Loop #0(r1)_2':
 ##             assemblyData.auto_save_assembly.Save()
         return System.Delegate.CreateDelegate(delegatetype,
                                               consts,

Modified: pypy/branch/pyjitpl5/pypy/jit/backend/cli/runner.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/cli/runner.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/cli/runner.py	Wed May 20 16:21:28 2009
@@ -20,6 +20,10 @@
 
     _cli_funcbox = None
     _cli_meth = None
+    _cli_count = 0
+
+    def _get_cli_name(self):
+        return '%s(r%d)' % (self.name, self._cli_count)
 
 
 class CliCPU(model.AbstractCPU):
@@ -34,6 +38,7 @@
         self.stats = stats
         self.translate_support_code = translate_support_code
         self.inputargs = None
+        self.failing_ops = [] # index --> op
         self.ll_ovf_exc = self._get_prebuilt_exc(OverflowError)
         self.ll_zero_exc = self._get_prebuilt_exc(ZeroDivisionError)
 
@@ -82,13 +87,13 @@
         else:
             # discard previously compiled loop
             loop._cli_funcbox.holder.SetFunc(None)
-        loop._cli_meth = Method(self, loop.name, loop)
+        loop._cli_meth = Method(self, loop._get_cli_name(), loop)
+        loop._cli_count += 1
 
     def execute_operations(self, loop):
-        meth = loop._cli_meth
         func = loop._cli_funcbox.holder.GetFunc()
         func(self.get_inputargs())
-        return meth.failing_ops[self.inputargs.get_failed_op()]
+        return self.failing_ops[self.inputargs.get_failed_op()]
 
     def set_future_value_int(self, index, intvalue):
         self.get_inputargs().set_int(index, intvalue)

Modified: pypy/branch/pyjitpl5/pypy/jit/backend/cli/test/test_basic.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/cli/test/test_basic.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/cli/test/test_basic.py	Wed May 20 16:21:28 2009
@@ -38,6 +38,3 @@
     test_long_long = skip
     test_free_object = skip
     test_stopatxpolicy = skip
-    
-    test_bridge_from_interpreter = _skip
-



More information about the Pypy-commit mailing list