Author: Tobias Pape <[email protected]>
Branch:
Changeset: r23:27343cfd74c8
Date: 2013-02-14 14:26 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/27343cfd74c8/
Log: remove autopath
diff --git a/spyvm/autopath1.py b/spyvm/autopath1.py
deleted file mode 100644
--- a/spyvm/autopath1.py
+++ /dev/null
@@ -1,5 +0,0 @@
-import sys, os
-
-spyvm = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
-if spyvm not in sys.path:
- sys.path.insert(0, spyvm)
diff --git a/spyvm/objspace.py b/spyvm/objspace.py
--- a/spyvm/objspace.py
+++ b/spyvm/objspace.py
@@ -172,7 +172,7 @@
return self.wrap_int(intmask(val))
except WrappingError:
pass
- # XXX this is not really working well on 64 bit machines
+ # XXX is math allowed here?
import math
bytes_len = max(4, int(math.log(val, 0xff)) + 1)
w_result =
model.W_BytesObject(self.classtable['w_LargePositiveInteger'], bytes_len)
diff --git a/spyvm/test/jit.py b/spyvm/test/jit.py
new file mode 100755
--- /dev/null
+++ b/spyvm/test/jit.py
@@ -0,0 +1,89 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# view jit.
+#
+
+import sys
+from rpython import conftest
+class o:
+ view = False
+ viewloops = True
+conftest.option = o
+
+from rpython.jit.metainterp.test.test_ajit import LLJitMixin
+
+
+from spyvm import model, interpreter, primitives, shadow
+from spyvm import objspace
+from spyvm.tool.analyseimage import create_squeakimage
+
+
+mockclass = objspace.bootstrap_class
+
+space = objspace.ObjSpace()
+
+# expose the bytecode's values as global constants.
+# Bytecodes that have a whole range are exposed as global functions:
+# call them with an argument 'n' to get the bytecode number 'base + n'.
+# XXX hackish
+def setup():
+ def make_getter(entry):
+ def get_opcode_chr(n):
+ opcode = entry[0] + n
+ assert entry[0] <= opcode <= entry[1]
+ return chr(opcode)
+ return get_opcode_chr
+ for entry in interpreter.BYTECODE_RANGES:
+ name = entry[-1]
+ if len(entry) == 2: # no range
+ globals()[name] = chr(entry[0])
+ else:
+ globals()[name] = make_getter(entry)
+setup()
+
+#
+# Tests
+#
+
+sys.setrecursionlimit(100000)
+
+class TestLLtype(LLJitMixin):
+
+
+ def test_tiny_benchmarks(self):
+
+ def tinyBenchmarks():
+ from spyvm import objspace
+ space = objspace.ObjSpace()
+ image = create_squeakimage(space)
+ interp = interpreter.Interpreter(space)
+
+ w_object = model.W_SmallInteger(0)
+
+ s_class = w_object.shadow_of_my_class(space)
+ w_method = s_class.lookup("tinyBenchmarks")
+
+ assert w_method
+ w_frame = w_method.create_frame(space, w_object, [])
+ interp.store_w_active_context(w_frame)
+
+ counter = 0
+
+ from spyvm.interpreter import BYTECODE_TABLE
+ return interp
+
+ interp = tinyBenchmarks()
+ def interp_w():
+ counter = 0
+ try:
+ while True:
+ counter += 1
+ interp.bytecode_step_translated()
+ if counter == 100000:
+ counter = 0
+ except interpreter.ReturnFromTopLevel, e:
+ w_result = e.object
+
+ self.meta_interp(interp_w, [], listcomp=True, listops=True,
backendopt=True)
+
diff --git a/spyvm/tool/analyseimage.py b/spyvm/tool/analyseimage.py
--- a/spyvm/tool/analyseimage.py
+++ b/spyvm/tool/analyseimage.py
@@ -1,4 +1,3 @@
-import autopath
import py
from spyvm import squeakimage
from spyvm import constants
@@ -6,7 +5,7 @@
from spyvm import interpreter
import sys
-mini_image = py.magic.autopath().dirpath().dirpath().join('mini.image')
+mini_image = py.path.local(__file__).dirpath().dirpath().join('mini.image')
def get_miniimage(space):
return squeakimage.ImageReader(space,
squeakimage.Stream(mini_image.open()))
diff --git a/spyvm/tool/autopath.py b/spyvm/tool/autopath.py
deleted file mode 100644
--- a/spyvm/tool/autopath.py
+++ /dev/null
@@ -1,135 +0,0 @@
-"""
-self cloning, automatic path configuration
-
-copy this into any subdirectory of pypy from which scripts need
-to be run, typically all of the test subdirs.
-The idea is that any such script simply issues
-
- import autopath
-
-and this will make sure that the parent directory containing "pypy"
-is in sys.path.
-
-If you modify the master "autopath.py" version (in pypy/tool/autopath.py)
-you can directly run it which will copy itself on all autopath.py files
-it finds under the pypy root directory.
-
-This module always provides these attributes:
-
- pypydir pypy root directory path
- this_dir directory where this autopath.py resides
-
-"""
-
-def __dirinfo(part):
- """ return (partdir, this_dir) and insert parent of partdir
- into sys.path. If the parent directories don't have the part
- an EnvironmentError is raised."""
-
- import sys, os
- try:
- head = this_dir = os.path.realpath(os.path.dirname(__file__))
- except NameError:
- head = this_dir = os.path.realpath(os.path.dirname(sys.argv[0]))
-
- error = None
- while head:
- partdir = head
- head, tail = os.path.split(head)
- if tail == part:
- # check if "../py/__init__.py" exists
- checkfile = os.path.join(partdir, os.pardir, 'py', '__init__.py')
- if not os.path.exists(checkfile):
- error = "Cannot find %r" % (os.path.normpath(checkfile),)
- break
- else:
- error = "Cannot find the parent directory %r of the path %r" % (
- partdir, this_dir)
- if not error:
- # check for bogus end-of-line style (e.g. files checked out on
- # Windows and moved to Unix)
- f = open(__file__.replace('.pyc', '.py'), 'r')
- data = f.read()
- f.close()
- if data.endswith('\r\n') or data.endswith('\r'):
- error = ("Bad end-of-line style in the .py files. Typically "
- "caused by a zip file or a checkout done on Windows and "
- "moved to Unix or vice-versa.")
- if error:
- raise EnvironmentError("Invalid source tree - bogus checkout! " +
- error)
-
- pypy_root = os.path.join(head, '')
- try:
- sys.path.remove(head)
- except ValueError:
- pass
- sys.path.insert(0, head)
-
- munged = {}
- for name, mod in sys.modules.items():
- if '.' in name:
- continue
- fn = getattr(mod, '__file__', None)
- if not isinstance(fn, str):
- continue
- newname = os.path.splitext(os.path.basename(fn))[0]
- if not newname.startswith(part + '.'):
- continue
- path = os.path.join(os.path.dirname(os.path.realpath(fn)), '')
- if path.startswith(pypy_root) and newname != part:
- modpaths = os.path.normpath(path[len(pypy_root):]).split(os.sep)
- if newname != '__init__':
- modpaths.append(newname)
- modpath = '.'.join(modpaths)
- if modpath not in sys.modules:
- munged[modpath] = mod
-
- for name, mod in munged.iteritems():
- if name not in sys.modules:
- sys.modules[name] = mod
- if '.' in name:
- prename = name[:name.rfind('.')]
- postname = name[len(prename)+1:]
- if prename not in sys.modules:
- __import__(prename)
- if not hasattr(sys.modules[prename], postname):
- setattr(sys.modules[prename], postname, mod)
-
- return partdir, this_dir
-
-def __clone():
- """ clone master version of autopath.py into all subdirs """
- from os.path import join, walk
- if not this_dir.endswith(join('pypy','tool')):
- raise EnvironmentError("can only clone master version "
- "'%s'" % join(pypydir, 'tool',_myname))
-
-
- def sync_walker(arg, dirname, fnames):
- if _myname in fnames:
- fn = join(dirname, _myname)
- f = open(fn, 'rwb+')
- try:
- if f.read() == arg:
- print "checkok", fn
- else:
- print "syncing", fn
- f = open(fn, 'w')
- f.write(arg)
- finally:
- f.close()
- s = open(join(pypydir, 'tool', _myname), 'rb').read()
- walk(pypydir, sync_walker, s)
-
-_myname = 'autopath.py'
-
-# set guaranteed attributes
-
-pypydir, this_dir = __dirinfo('pypy')
-import py
-libpythondir = str(py.path.local(pypydir).dirpath().join('lib-python',
'2.5.2'))
-libpythonmodifieddir =
str(py.path.local(libpythondir).dirpath().join('modified-2.5.2'))
-
-if __name__ == '__main__':
- __clone()
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit