[pypy-svn] r78218 - in pypy/trunk/pypy: jit/backend/test jit/backend/x86/test jit/metainterp/test jit/tool module/pypyjit/test

fijal at codespeak.net fijal at codespeak.net
Fri Oct 22 18:19:57 CEST 2010


Author: fijal
Date: Fri Oct 22 18:19:52 2010
New Revision: 78218

Added:
   pypy/trunk/pypy/jit/tool/oparser.py
      - copied, changed from r78182, pypy/trunk/pypy/jit/metainterp/test/oparser.py
Removed:
   pypy/trunk/pypy/jit/metainterp/test/oparser.py
Modified:
   pypy/trunk/pypy/jit/backend/test/runner_test.py
   pypy/trunk/pypy/jit/backend/x86/test/test_gc_integration.py
   pypy/trunk/pypy/jit/backend/x86/test/test_regalloc.py
   pypy/trunk/pypy/jit/backend/x86/test/test_runner.py
   pypy/trunk/pypy/jit/metainterp/test/test_compile.py
   pypy/trunk/pypy/jit/metainterp/test/test_logger.py
   pypy/trunk/pypy/jit/metainterp/test/test_oparser.py
   pypy/trunk/pypy/jit/metainterp/test/test_optimizefindnode.py
   pypy/trunk/pypy/jit/metainterp/test/test_optimizeopt.py
   pypy/trunk/pypy/jit/tool/loopviewer.py
   pypy/trunk/pypy/jit/tool/showstats.py
   pypy/trunk/pypy/module/pypyjit/test/test_pypy_c.py
Log:
Refactor a bit oparser. Also move it to tool instead of metainterp/test
(it's rather widely used by now)


Modified: pypy/trunk/pypy/jit/backend/test/runner_test.py
==============================================================================
--- pypy/trunk/pypy/jit/backend/test/runner_test.py	(original)
+++ pypy/trunk/pypy/jit/backend/test/runner_test.py	Fri Oct 22 18:19:52 2010
@@ -9,7 +9,7 @@
                                          ConstObj, BoxFloat, ConstFloat)
 from pypy.jit.metainterp.resoperation import ResOperation, rop
 from pypy.jit.metainterp.typesystem import deref
-from pypy.jit.metainterp.test.oparser import parse
+from pypy.jit.tool.oparser import parse
 from pypy.rpython.lltypesystem import lltype, llmemory, rstr, rffi, rclass
 from pypy.rpython.ootypesystem import ootype
 from pypy.rpython.annlowlevel import llhelper

Modified: pypy/trunk/pypy/jit/backend/x86/test/test_gc_integration.py
==============================================================================
--- pypy/trunk/pypy/jit/backend/x86/test/test_gc_integration.py	(original)
+++ pypy/trunk/pypy/jit/backend/x86/test/test_gc_integration.py	Fri Oct 22 18:19:52 2010
@@ -12,7 +12,7 @@
 from pypy.jit.backend.detect_cpu import getcpuclass
 from pypy.jit.backend.x86.regalloc import RegAlloc
 from pypy.jit.backend.x86.arch import WORD, FRAME_FIXED_SIZE
-from pypy.jit.metainterp.test.oparser import parse
+from pypy.jit.tool.oparser import parse
 from pypy.rpython.lltypesystem import lltype, llmemory, rffi
 from pypy.rpython.annlowlevel import llhelper
 from pypy.rpython.lltypesystem import rclass, rstr

Modified: pypy/trunk/pypy/jit/backend/x86/test/test_regalloc.py
==============================================================================
--- pypy/trunk/pypy/jit/backend/x86/test/test_regalloc.py	(original)
+++ pypy/trunk/pypy/jit/backend/x86/test/test_regalloc.py	Fri Oct 22 18:19:52 2010
@@ -11,7 +11,7 @@
 from pypy.jit.backend.x86.regalloc import RegAlloc, X86RegisterManager,\
      FloatConstants, is_comparison_or_ovf_op
 from pypy.jit.backend.x86.arch import IS_X86_32, IS_X86_64
-from pypy.jit.metainterp.test.oparser import parse
+from pypy.jit.tool.oparser import parse
 from pypy.rpython.lltypesystem import lltype, llmemory, rffi
 from pypy.rpython.annlowlevel import llhelper
 from pypy.rpython.lltypesystem import rclass, rstr

Modified: pypy/trunk/pypy/jit/backend/x86/test/test_runner.py
==============================================================================
--- pypy/trunk/pypy/jit/backend/x86/test/test_runner.py	(original)
+++ pypy/trunk/pypy/jit/backend/x86/test/test_runner.py	Fri Oct 22 18:19:52 2010
@@ -10,7 +10,7 @@
 from pypy.jit.metainterp.resoperation import rop
 from pypy.jit.metainterp.executor import execute
 from pypy.jit.backend.test.runner_test import LLtypeBackendTest
-from pypy.jit.metainterp.test.oparser import parse
+from pypy.jit.tool.oparser import parse
 from pypy.tool.udir import udir
 import ctypes
 import sys

Modified: pypy/trunk/pypy/jit/metainterp/test/test_compile.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/test/test_compile.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/test/test_compile.py	Fri Oct 22 18:19:52 2010
@@ -6,8 +6,8 @@
 from pypy.jit.metainterp.compile import ResumeGuardCountersInt
 from pypy.jit.metainterp.compile import compile_tmp_callback
 from pypy.jit.metainterp import optimize, jitprof, typesystem, compile
-from pypy.jit.metainterp.test.oparser import parse
 from pypy.jit.metainterp.test.test_optimizefindnode import LLtypeMixin
+from pypy.jit.tool.oparser import parse
 
 
 def test_insert_loop_token():

Modified: pypy/trunk/pypy/jit/metainterp/test/test_logger.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/test/test_logger.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/test/test_logger.py	Fri Oct 22 18:19:52 2010
@@ -1,6 +1,6 @@
 import sys
 from pypy.rlib import debug
-from pypy.jit.metainterp.test.oparser import pure_parse
+from pypy.jit.tool.oparser import pure_parse
 from pypy.jit.metainterp import logger
 from pypy.jit.metainterp.typesystem import llhelper
 from StringIO import StringIO

Modified: pypy/trunk/pypy/jit/metainterp/test/test_oparser.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/test/test_oparser.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/test/test_oparser.py	Fri Oct 22 18:19:52 2010
@@ -1,7 +1,7 @@
 
 from pypy.rpython.lltypesystem import lltype, llmemory
 
-from pypy.jit.metainterp.test.oparser import parse
+from pypy.jit.tool.oparser import parse
 from pypy.jit.metainterp.resoperation import rop
 from pypy.jit.metainterp.history import AbstractDescr, BoxInt, LoopToken,\
      BoxFloat

Modified: pypy/trunk/pypy/jit/metainterp/test/test_optimizefindnode.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/test/test_optimizefindnode.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/test/test_optimizefindnode.py	Fri Oct 22 18:19:52 2010
@@ -18,7 +18,7 @@
 from pypy.jit.metainterp.specnode import ConstantSpecNode
 from pypy.jit.codewriter.effectinfo import EffectInfo
 from pypy.jit.codewriter.heaptracker import register_known_gctype, adr2int
-from pypy.jit.metainterp.test.oparser import parse
+from pypy.jit.tool.oparser import parse
 
 def test_sort_descrs():
     class PseudoDescr(AbstractDescr):

Modified: pypy/trunk/pypy/jit/metainterp/test/test_optimizeopt.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/test/test_optimizeopt.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/test/test_optimizeopt.py	Fri Oct 22 18:19:52 2010
@@ -12,7 +12,7 @@
 from pypy.jit.metainterp.jitprof import EmptyProfiler
 from pypy.jit.metainterp import executor, compile, resume, history
 from pypy.jit.metainterp.resoperation import rop, opname, ResOperation
-from pypy.jit.metainterp.test.oparser import pure_parse
+from pypy.jit.tool.oparser import pure_parse
 
 ##class FakeFrame(object):
 ##    parent_resumedata_snapshot = None

Modified: pypy/trunk/pypy/jit/tool/loopviewer.py
==============================================================================
--- pypy/trunk/pypy/jit/tool/loopviewer.py	(original)
+++ pypy/trunk/pypy/jit/tool/loopviewer.py	Fri Oct 22 18:19:52 2010
@@ -9,7 +9,7 @@
 import optparse
 from pprint import pprint
 from pypy.tool import logparser
-from pypy.jit.metainterp.test.oparser import parse
+from pypy.jit.tool.oparser import parse
 from pypy.jit.metainterp.history import ConstInt
 from pypy.rpython.lltypesystem import llmemory, lltype
 

Copied: pypy/trunk/pypy/jit/tool/oparser.py (from r78182, pypy/trunk/pypy/jit/metainterp/test/oparser.py)
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/test/oparser.py	(original)
+++ pypy/trunk/pypy/jit/tool/oparser.py	Fri Oct 22 18:19:52 2010
@@ -184,24 +184,9 @@
                 self.newvar(arg)
             return self.vars[arg]
 
-    def parse_op(self, line):
-        num = line.find('(')
-        if num == -1:
-            raise ParseError("invalid line: %s" % line)
-        opname = line[:num]
-        try:
-            opnum = getattr(rop, opname.upper())
-        except AttributeError:
-            if opname == 'escape':
-                opnum = ESCAPE_OP.OPNUM
-            else:
-                raise ParseError("unknown op: %s" % opname)
-        endnum = line.rfind(')')
-        if endnum == -1:
-            raise ParseError("invalid line: %s" % line)
+    def parse_args(self, opname, argspec):
         args = []
         descr = None
-        argspec = line[num + 1:endnum]
         if argspec.strip():
             if opname == 'debug_merge_point':
                 allargs = [argspec]
@@ -219,6 +204,24 @@
                     args.append(self.getvar(arg))
                 except KeyError:
                     raise ParseError("Unknown var: %s" % arg)
+        return args, descr
+
+    def parse_op(self, line):
+        num = line.find('(')
+        if num == -1:
+            raise ParseError("invalid line: %s" % line)
+        opname = line[:num]
+        try:
+            opnum = getattr(rop, opname.upper())
+        except AttributeError:
+            if opname == 'escape':
+                opnum = ESCAPE_OP.OPNUM
+            else:
+                raise ParseError("unknown op: %s" % opname)
+        endnum = line.rfind(')')
+        if endnum == -1:
+            raise ParseError("invalid line: %s" % line)
+        args, descr = self.parse_args(opname, line[num + 1:endnum])
         if rop._GUARD_FIRST <= opnum <= rop._GUARD_LAST:
             i = line.find('[', endnum) + 1
             j = line.find(']', i)

Modified: pypy/trunk/pypy/jit/tool/showstats.py
==============================================================================
--- pypy/trunk/pypy/jit/tool/showstats.py	(original)
+++ pypy/trunk/pypy/jit/tool/showstats.py	Fri Oct 22 18:19:52 2010
@@ -4,7 +4,7 @@
 import autopath
 import sys, py
 from pypy.tool import logparser
-from pypy.jit.metainterp.test.oparser import parse
+from pypy.jit.tool.oparser import parse
 from pypy.jit.metainterp.resoperation import rop
 from pypy.rpython.lltypesystem import lltype, llmemory
 

Modified: pypy/trunk/pypy/module/pypyjit/test/test_pypy_c.py
==============================================================================
--- pypy/trunk/pypy/module/pypyjit/test/test_pypy_c.py	(original)
+++ pypy/trunk/pypy/module/pypyjit/test/test_pypy_c.py	Fri Oct 22 18:19:52 2010
@@ -131,7 +131,7 @@
         return result
 
     def parse_loops(self, opslogfile):
-        from pypy.jit.metainterp.test.oparser import parse
+        from pypy.jit.tool.oparser import parse
         from pypy.tool import logparser
         assert opslogfile.check()
         log = logparser.parse_log_file(str(opslogfile))



More information about the Pypy-commit mailing list