def test_set_pypy_opt_level(): conf = get_pypy_config() set_pypy_opt_level(conf, '2') assert conf.objspace.std.withmultidict conf = get_pypy_config() set_pypy_opt_level(conf, '0') assert not conf.objspace.std.withmultidict
def main(argv): config = get_combined_translation_config(pypy_optiondescription, overrides=OVERRIDES, translating=True) config.objspace.nofaking = True config.objspace.compiler = "ast" config.translating = True set_opt_level(config, '1') set_pypy_opt_level(config, '1') enable_allworkingmodules(config) space = make_objspace(config) ctx = JavaScriptContext(space) policy = PyPyAnnotatorPolicy(single_space = space) policy.allow_someobjects = False def interpret(source, context): source = charp2str(source) w_dict = space.newdict() ctx._ctx = context glob = ctx.globals() lst = ctx.propertylist(glob.js_val) for elem in lst: w_val = space.wrap(JSObject(ctx, ctx.get(glob.js_val, elem))) space.setitem(w_dict, space.wrap(elem), w_val) try: ec = space.getexecutioncontext() pycode = ec.compiler.compile(source, 'source', 'exec', 0) pycode.exec_code(space, w_dict, w_dict) except OperationError, e: print "OperationError:" print " operror-type: " + e.w_type.getname(space, '?') print " operror-value: " + space.str_w(space.str(e.w_value)) return 1 return 0
def main(argv): config = get_combined_translation_config(pypy_optiondescription, overrides=OVERRIDES, translating=True) config.objspace.nofaking = True config.objspace.compiler = "ast" config.translating = True set_opt_level(config, '1') set_pypy_opt_level(config, '1') enable_allworkingmodules(config) space = make_objspace(config) ctx = JavaScriptContext(space) policy = PyPyAnnotatorPolicy(single_space=space) policy.allow_someobjects = False def interpret(source, context): source = charp2str(source) w_dict = space.newdict() ctx._ctx = context glob = ctx.globals() lst = ctx.propertylist(glob.js_val) for elem in lst: w_val = space.wrap(JSObject(ctx, ctx.get(glob.js_val, elem))) space.setitem(w_dict, space.wrap(elem), w_val) try: ec = space.getexecutioncontext() pycode = ec.compiler.compile(source, 'source', 'exec', 0) pycode.exec_code(space, w_dict, w_dict) except OperationError, e: print "OperationError:" print " operror-type: " + e.w_type.getname(space, '?') print " operror-value: " + space.str_w(space.str(e.w_value)) return 1 return 0
def handle_config(self, config, translateconfig): if (not translateconfig.help and translateconfig._cfgimpl_value_owners['opt'] == 'default'): raise Exception("You have to specify the --opt level.\n" "Try --opt=2 or --opt=jit, or equivalently -O2 or -Ojit .") self.translateconfig = translateconfig # set up the objspace optimizations based on the --opt argument from pypy.config.pypyoption import set_pypy_opt_level set_pypy_opt_level(config, translateconfig.opt) # as of revision 27081, multimethod.py uses the InstallerVersion1 by default # because it is much faster both to initialize and run on top of CPython. # The InstallerVersion2 is optimized for making a translator-friendly # structure for low level backends. However, InstallerVersion1 is still # preferable for high level backends, so we patch here. from pypy.objspace.std import multimethod if config.objspace.std.multimethods == 'mrd': assert multimethod.InstallerVersion1.instance_counter == 0,\ 'The wrong Installer version has already been instatiated' multimethod.Installer = multimethod.InstallerVersion2 elif config.objspace.std.multimethods == 'doubledispatch': # don't rely on the default, set again here assert multimethod.InstallerVersion2.instance_counter == 0,\ 'The wrong Installer version has already been instatiated' multimethod.Installer = multimethod.InstallerVersion1
def test_rweakref_required(): conf = get_pypy_config() conf.translation.rweakref = False set_pypy_opt_level(conf, '3') assert not conf.objspace.std.withtypeversion assert not conf.objspace.std.withmethodcache
def handle_config(self, config, translateconfig): if (not translateconfig.help and translateconfig._cfgimpl_value_owners['opt'] == 'default'): raise Exception( "You have to specify the --opt level.\n" "Try --opt=2 or --opt=jit, or equivalently -O2 or -Ojit .") self.translateconfig = translateconfig # set up the objspace optimizations based on the --opt argument from pypy.config.pypyoption import set_pypy_opt_level set_pypy_opt_level(config, translateconfig.opt) # as of revision 27081, multimethod.py uses the InstallerVersion1 by default # because it is much faster both to initialize and run on top of CPython. # The InstallerVersion2 is optimized for making a translator-friendly # structure for low level backends. However, InstallerVersion1 is still # preferable for high level backends, so we patch here. from pypy.objspace.std import multimethod if config.objspace.std.multimethods == 'mrd': assert multimethod.InstallerVersion1.instance_counter == 0,\ 'The wrong Installer version has already been instatiated' multimethod.Installer = multimethod.InstallerVersion2 elif config.objspace.std.multimethods == 'doubledispatch': # don't rely on the default, set again here assert multimethod.InstallerVersion2.instance_counter == 0,\ 'The wrong Installer version has already been instatiated' multimethod.Installer = multimethod.InstallerVersion1
def main(argv): config = get_combined_translation_config(pypy_optiondescription, overrides=OVERRIDES, translating=True) config.objspace.nofaking = True config.objspace.compiler = "ast" config.translating = True set_opt_level(config, '1') set_pypy_opt_level(config, '1') enable_allworkingmodules(config) space = make_objspace(config) policy = PyPyAnnotatorPolicy(single_space = space) policy.allow_someobjects = False def interpret(source, context): source = charp2str(source) w_dict = space.newdict() try: ec = space.getexecutioncontext() pycode = ec.compiler.compile(source, 'source', 'exec', 0) pycode.exec_code(space, w_dict, w_dict) except OperationError, e: print "OperationError:" print " operror-type: " + e.w_type.getname(space) print " operror-value: " + space.str_w(space.str(e.get_w_value(space))) return 1 return 0
def test_set_pypy_opt_level(): conf = get_pypy_config() set_pypy_opt_level(conf, '2') assert conf.objspace.std.getattributeshortcut conf = get_pypy_config() set_pypy_opt_level(conf, '0') assert not conf.objspace.std.getattributeshortcut
def main(argv): config = get_combined_translation_config(pypy_optiondescription, overrides=OVERRIDES, translating=True) config.objspace.nofaking = True config.objspace.compiler = "ast" config.translating = True set_opt_level(config, '1') set_pypy_opt_level(config, '1') enable_allworkingmodules(config) space = make_objspace(config) policy = PyPyAnnotatorPolicy(single_space=space) policy.allow_someobjects = False def interpret(source, context): source = charp2str(source) w_dict = space.newdict() try: ec = space.getexecutioncontext() pycode = ec.compiler.compile(source, 'source', 'exec', 0) pycode.exec_code(space, w_dict, w_dict) except OperationError, e: print "OperationError:" print " operror-type: " + e.w_type.getname(space, '?') print " operror-value: " + space.str_w( space.str(e.get_w_value(space))) return 1 return 0
def test_set_pypy_opt_level(): conf = get_pypy_config() set_pypy_opt_level(conf, '2') assert conf.objspace.std.withshadowtracking conf = get_pypy_config() set_pypy_opt_level(conf, '0') assert not conf.objspace.std.newshortcut
def test_set_pypy_opt_level(): conf = get_pypy_config() set_pypy_opt_level(conf, '2') assert conf.objspace.std.intshortcut conf = get_pypy_config() set_pypy_opt_level(conf, '0') assert not conf.objspace.std.intshortcut
def handle_config(self, config, translateconfig): if (not translateconfig.help and translateconfig._cfgimpl_value_owners['opt'] == 'default'): raise Exception("You have to specify the --opt level.\n" "Try --opt=2 or --opt=jit, or equivalently -O2 or -Ojit .") self.translateconfig = translateconfig # set up the objspace optimizations based on the --opt argument from pypy.config.pypyoption import set_pypy_opt_level set_pypy_opt_level(config, translateconfig.opt)
def new_pypy_objspace(): # This module is reloaded, but pypy_getudir has already been deleted from pypy.module import sys as pypy_sys reload(pypy_sys) # if 'pypy_getudir' not in Module.interpleveldefs: # Module.interpleveldefs['pypy_getudir'] = 'foo' from pypy.config.pypyoption import get_pypy_config, set_pypy_opt_level translating = sys.argv[0] == '.build/build.py' # make better pypy_config = get_pypy_config(translating=translating) # disable dispensable modules (to save compile time) pypy_config.objspace.usemodules.micronumpy = False pypy_config.objspace.usemodules._cppyy = False pypy_config.objspace.usemodules._vmprof = False # cpyext causes a lot of 'Undefined symbols for architecture x86_64' errors pypy_config.objspace.usemodules.cpyext = False # disabling cffi backend for now, it also causes an undefined symbol error pypy_config.objspace.usemodules._cffi_backend = False # disable to save compile time from pypy.config.pypyoption import enable_allworkingmodules enable_allworkingmodules(pypy_config) from pypy.config.pypyoption import enable_translationmodules enable_translationmodules(pypy_config) # pypy_config.translation.check_str_without_nul = True # ensures pypy_hooks has a .space pypy_config.objspace.usemodules.pypyjit = True # rstacklets are required pypy_config.translation.continuation = True pypy_config.objspace.usemodules._continuation = True pypy_config.objspace.usemodules.thread = True # Enable more optimizations for PyPy's jit set_pypy_opt_level(pypy_config, 'jit') # Copy over some options that should be the same in both configs pypy_config.translation.make_jobs = system.translationconfig.make_jobs if system.translationconfig.output is not None: pypy_config.translation.output = system.translationconfig.output # merge_configs(config, pypy_config, 'RSqueak', 'PyPy') # PyPy needs threads pypy_config.translation.thread = True # Python objectspace ctor is not Rpython so create it here and # encapsulate it inside the entry point with a closure. from pypy.objspace.std import StdObjSpace as PyStdObjSpace return PyStdObjSpace(pypy_config)
def handle_config(self, config, translateconfig): if (not translateconfig.help and translateconfig._cfgimpl_value_owners['opt'] == 'default'): raise Exception( "You have to specify the --opt level.\n" "Try --opt=2 or --opt=jit, or equivalently -O2 or -Ojit .") self.translateconfig = translateconfig # change the default for this option # XXX disabled until we fix the real problem: a per-translation # seed for siphash is bad #config.translation.suggest(hash="siphash24") # set up the objspace optimizations based on the --opt argument from pypy.config.pypyoption import set_pypy_opt_level set_pypy_opt_level(config, translateconfig.opt)
def handle_config(self, config, translateconfig): self.translateconfig = translateconfig # set up the objspace optimizations based on the --opt argument from pypy.config.pypyoption import set_pypy_opt_level set_pypy_opt_level(config, translateconfig.opt) # as of revision 27081, multimethod.py uses the InstallerVersion1 by default # because it is much faster both to initialize and run on top of CPython. # The InstallerVersion2 is optimized for making a translator-friendly # structure for low level backends. However, InstallerVersion1 is still # preferable for high level backends, so we patch here. from pypy.objspace.std import multimethod if config.objspace.std.multimethods == 'mrd': assert multimethod.InstallerVersion1.instance_counter == 0,\ 'The wrong Installer version has already been instatiated' multimethod.Installer = multimethod.InstallerVersion2 elif config.objspace.std.multimethods == 'doubledispatch': # don't rely on the default, set again here assert multimethod.InstallerVersion2.instance_counter == 0,\ 'The wrong Installer version has already been instatiated' multimethod.Installer = multimethod.InstallerVersion1
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._sre = False config.objspace.usemodules._lsprof = False # config.objspace.usemodules._rawffi = False config.objspace.usemodules.micronumpy = False # set_pypy_opt_level(config, level="jit") config.objspace.std.multimethods = "mrd" multimethod.Installer = multimethod.InstallerVersion2 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:
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:
config.translation.backendopt.inline_threshold = 0.1 config.translation.gc = 'boehm' config.objspace.nofaking = True config.translating = True set_opt_level(config, level='jit') config.objspace.allworkingmodules = False config.objspace.usemodules.pypyjit = True config.objspace.usemodules.array = False config.objspace.usemodules._weakref = True config.objspace.usemodules._sre = False config.objspace.usemodules._lsprof = False # config.objspace.usemodules._ffi = True config.objspace.usemodules.micronumpy = False # set_pypy_opt_level(config, level='jit') if BACKEND == 'c': config.objspace.std.multimethods = 'mrd' multimethod.Installer = multimethod.InstallerVersion2 elif BACKEND == 'cli': config.objspace.std.multimethods = 'doubledispatch' multimethod.Installer = multimethod.InstallerVersion1 config.translation.backend = 'cli' else: assert False print config import sys, pdb space = Space(config)
def set_family_of_options(option, opt, value, parser): from pypy.config.pypyoption import set_pypy_opt_level set_pypy_opt_level(config, value)