Author: Carl Friedrich Bolz-Tereick <cfb...@gmx.de> Branch: py3.6 Changeset: r97584:eb8c500a7667 Date: 2019-09-21 21:23 +0200 http://bitbucket.org/pypy/pypy/changeset/eb8c500a7667/
Log: merge default diff --git a/pypy/tool/pypyjit.py b/pypy/tool/pypyjit.py deleted file mode 100644 --- a/pypy/tool/pypyjit.py +++ /dev/null @@ -1,118 +0,0 @@ -""" -A file that invokes translation of PyPy with the JIT enabled. - -Run it with py.test -s --pdb pypyjit.py - -""" - -import py, os - -try: - py.test.config.option.runappdirect -except AttributeError: - import sys - print >> sys.stderr, __doc__ - sys.exit(2) - -import sys -sys.setrecursionlimit(100000000) - -from pypy.objspace.std import Space -from rpython.config.translationoption import set_opt_level -from pypy.config.pypyoption import get_pypy_config, set_pypy_opt_level -from rpython.rtyper.annlowlevel import llhelper, llstr, hlstr -from rpython.rtyper.lltypesystem.rstr import STR -from rpython.rtyper.lltypesystem import lltype -from pypy.interpreter.pycode import PyCode -from rpython.translator.goal import unixcheckpoint -import pypy.module.pypyjit.interp_jit - -config = get_pypy_config(translating=True) -config.translation.backendopt.inline_threshold = 0.1 -config.translation.gc = 'boehm' -config.translating = True -config.translation.rweakref = False -set_opt_level(config, level='jit') -config.objspace.allworkingmodules = False -config.objspace.usemodules.pypyjit = True -config.objspace.usemodules.array = False -config.objspace.usemodules._weakref = False -config.objspace.usemodules.struct = True -config.objspace.usemodules.time = True -config.objspace.usemodules._sre = False -config.objspace.usemodules._lsprof = False -# -config.objspace.usemodules._rawffi = False -config.objspace.usemodules.micronumpy = False -# -set_pypy_opt_level(config, level='jit') - -print config - -import sys, pdb - -space = Space(config) -w_dict = space.newdict(module=True) - - -def readfile(filename): - fd = os.open(filename, os.O_RDONLY, 0) - blocks = [] - while True: - data = os.read(fd, 4096) - if not data: - break - blocks.append(data) - os.close(fd) - return ''.join(blocks) - -def read_code(): - from pypy.module.marshal.interp_marshal import dumps - - filename = 'pypyjit_demo.py' - source = readfile(filename) - ec = space.getexecutioncontext() - code = ec.compiler.compile(source, filename, 'exec', 0) - return llstr(space.str_w(dumps(space, code, space.wrap(2)))) - -FPTR = lltype.Ptr(lltype.FuncType([], lltype.Ptr(STR))) -read_code_ptr = llhelper(FPTR, read_code) - -def entry_point(): - space.startup() - from pypy.module.marshal.interp_marshal import loads - code = loads(space, space.wrap(hlstr(read_code_ptr()))) - assert isinstance(code, PyCode) - code.exec_code(space, w_dict, w_dict) - -def test_run_translation(): - from pypy.tool.ann_override import PyPyAnnotatorPolicy - from rpython.rtyper.test.test_llinterp import get_interpreter - - # first annotate and rtype - try: - interp, graph = get_interpreter(entry_point, [], backendopt=False, - config=config, - policy=PyPyAnnotatorPolicy(space)) - except Exception as e: - print '%s: %s' % (e.__class__, e) - pdb.post_mortem(sys.exc_info()[2]) - raise - - # parent process loop: spawn a child, wait for the child to finish, - # print a message, and restart - unixcheckpoint.restartable_point(auto='run') - - from rpython.jit.codewriter.codewriter import CodeWriter - CodeWriter.debug = True - from pypy.tool.pypyjit_child import run_child - run_child(globals(), locals()) - - -if __name__ == '__main__': - import sys - if len(sys.argv) > 1: - # debugging: run the code directly - entry_point() - else: - test_run_translation() diff --git a/pypy/tool/pypyjit_child.py b/pypy/tool/pypyjit_child.py deleted file mode 100644 --- a/pypy/tool/pypyjit_child.py +++ /dev/null @@ -1,25 +0,0 @@ -from pypy.conftest import option -from rpython.rtyper.lltypesystem import lltype -from rpython.jit.metainterp import warmspot -from pypy.module.pypyjit.policy import PyPyJitPolicy - - -def run_child(glob, loc): - import sys, pdb - interp = loc['interp'] - graph = loc['graph'] - interp.malloc_check = False - - from rpython.jit.backend.llgraph.runner import LLGraphCPU - #LLtypeCPU.supports_floats = False # for now - apply_jit(interp, graph, LLGraphCPU) - - -def apply_jit(interp, graph, CPUClass): - print 'warmspot.jittify_and_run() started...' - policy = PyPyJitPolicy() - option.view = True - warmspot.jittify_and_run(interp, graph, [], policy=policy, - listops=True, CPUClass=CPUClass, - backendopt=True, inline=True) - diff --git a/pypy/tool/pypyjit_demo.py b/pypy/tool/pypyjit_demo.py deleted file mode 100644 --- a/pypy/tool/pypyjit_demo.py +++ /dev/null @@ -1,31 +0,0 @@ - -import time -l = [] - -for i in range(100): - print i - t0 = time.time() - exec """ -def k(a, b, c): - pass - -def g(a, b, c): - k(a, b + 1, c + 2) - k(a, b + 1, c + 2) - k(a, b + 1, c + 2) - k(a, b + 1, c + 2) - k(a, b + 1, c + 2) - -def f(i): - g(i, i + 1, i + 2) - g(i, i + 1, i + 2) - g(i, i + 1, i + 2) - g(i, i + 1, i + 2) - g(i, i + 1, i + 2) - g(i, i + 1, i + 2) -for i in range(1000): - f(i) -""" - l.append(time.time() - t0) - -print l diff --git a/pypy/tool/unicodefuzzer.py b/pypy/tool/unicodefuzzer.py deleted file mode 100644 --- a/pypy/tool/unicodefuzzer.py +++ /dev/null @@ -1,63 +0,0 @@ -import random, sys -random.seed(42) - -def make_random_encoded_string(length=10, variance=1): - s = [] - s.append(random.choice(["\xff\xfe", "\xfe\xff", ""])) # BOM - for i in range(length + random.randrange(-variance, variance)): - s.append(chr(random.randrange(256))) - return "".join(s) - -def make_random_unicode(length=10, variance=1): - s = [] - for i in range(length + random.randrange(-variance, variance)): - s.append(unichr(random.randrange(sys.maxunicode))) - return "".join(s) - -def check_encode(encoding, s): - try: - s.encode(encoding) - except UnicodeError: - pass - s.encode(encoding, "ignore") - s.encode(encoding, "replace") - -def check_decode(encoding, s): - try: - s.decode(encoding) - except UnicodeError: - pass - s.decode(encoding, "ignore") - s.decode(encoding, "replace") - -def check_with_length(length): - try: - s = make_random_encoded_string(length, 10) - for encoding in all_encodings: - check_decode(encoding, s) - except Exception as e: - print "decoding:", encoding, repr(s) - try: - s = make_random_unicode(length, 10) - for encoding in all_encodings: - check_encode(encoding, s) - except Exception as e: - print "encoding:", encoding, repr(s) - - -def main(): - for length in range(0, 1000, 10): - print length - for i in range(100): - check_with_length(length) - length = 1000 - for length in range(1000, 1000000, 1000): - print length - for i in range(100): - check_with_length(length) - -all_encodings = "utf-8 latin1 ascii utf-16 utf-16-be utf-16-le utf-7".split() - -if __name__ == '__main__': - main() - _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit