[pypy-svn] r25541 - in pypy/dist/pypy/translator/backendopt: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Sat Apr 8 14:17:15 CEST 2006


Author: cfbolz
Date: Sat Apr  8 14:17:15 2006
New Revision: 25541

Modified:
   pypy/dist/pypy/translator/backendopt/inline.py
   pypy/dist/pypy/translator/backendopt/test/test_inline.py
Log:
improve the weights of some operations. for some definition of improve


Modified: pypy/dist/pypy/translator/backendopt/inline.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/inline.py	(original)
+++ pypy/dist/pypy/translator/backendopt/inline.py	Sat Apr  8 14:17:15 2006
@@ -424,15 +424,17 @@
 OP_WEIGHTS = {'same_as': 0,
               'cast_pointer': 0,
               'keepalive': 0,
-              'direct_call': 2,    # guess
-              'indirect_call': 2,  # guess
-#              'malloc': 2,
+              'malloc': 2,
               'yield_current_frame_to_caller': sys.maxint, # XXX bit extreme
               }
 
 def block_weight(block, weights=OP_WEIGHTS):
     total = 0
     for op in block.operations:
+        if op.opname == "direct_call":
+            total += 1.5 + len(op.args) / 2
+        elif op.opname == "indirect_call":
+            total += 2 + len(op.args) / 2
         total += weights.get(op.opname, 1)
     if block.exitswitch is not None:
         total += 1
@@ -543,7 +545,8 @@
             break   # finished
 
         heappop(fiboheap)
-        log.inlining('%7.2f %50s' % (weight, graph.name))
+        if callers[graph]:
+            log.inlining('%7.2f %50s' % (weight, graph.name))
         for parentgraph in callers[graph]:
             if parentgraph == graph:
                 continue

Modified: pypy/dist/pypy/translator/backendopt/test/test_inline.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/test/test_inline.py	(original)
+++ pypy/dist/pypy/translator/backendopt/test/test_inline.py	Sat Apr  8 14:17:15 2006
@@ -410,7 +410,7 @@
     t = TranslationContext()
     graph = t.buildflowgraph(f)
     res = measure_median_execution_cost(graph)
-    assert res == 19
+    assert round(res, 5) == round(32.333333333, 5)
 
 def test_indirect_call_with_exception():
     class MyExc(Exception):



More information about the Pypy-commit mailing list