rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
if w_stararg is not None and space.is_true(w_stararg):
if w_stararg is not None:
def __init__(self, space, args_w, keywords=None, keywords_w=None, w_stararg=None, w_starstararg=None): self.space = space assert isinstance(args_w, list) self.arguments_w = args_w self.keywords = keywords self.keywords_w = keywords_w if keywords is not None: assert keywords_w is not None assert len(keywords_w) == len(k...
if w_starstararg is not None and space.is_true(w_starstararg):
if w_starstararg is not None:
def __init__(self, space, args_w, keywords=None, keywords_w=None, w_stararg=None, w_starstararg=None): self.space = space assert isinstance(args_w, list) self.arguments_w = args_w self.keywords = keywords self.keywords_w = keywords_w if keywords is not None: assert keywords_w is not None assert len(keywords_w) == len(k...
for func in targets: graph = getattr(func._obj, 'graph', None)
for graph in targets:
def generic_call(self, FUNC, fnexpr, args_v, v_result, targets=None): args = [] assert len(args_v) == len(FUNC.TO.ARGS) for v, ARGTYPE in zip(args_v, FUNC.TO.ARGS): if ARGTYPE is Void: continue # skip 'void' argument args.append(self.expr(v)) # special case for rctypes: by-value container args: # XXX is this still n...
op.args[1:], op.result, [fn.value])
op.args[1:], op.result, targets)
def OP_DIRECT_CALL(self, op): fn = op.args[0] return self.generic_call(fn.concretetype, self.expr(fn), op.args[1:], op.result, [fn.value])
elif letter == "d" or letter == "g":
elif letter == "d":
def unwrap_value(space, push_func, add_arg, argdesc, letter, w_arg): w = space.wrap if letter in TYPEMAP_PTR_LETTERS: # check for NULL ptr datainstance = space.interpclass_w(w_arg) if isinstance(datainstance, W_DataInstance): ptr = datainstance.ll_buffer else: ptr = unwrap_truncate_int(rffi.VOIDP, space, w_arg) push_fu...
assert out.getvalue == "None"
assert out.getvalue() == "None\n"
def test_print_function(self): import __builtin__ import sys import StringIO pr = getattr(__builtin__, "print") save = sys.stdout out = sys.stdout = StringIO.StringIO() try: pr("Hello,", "person!") finally: sys.stdout = save assert out.getvalue() == "Hello, person!\n" out = StringIO.StringIO() pr("Hello,", "person!", f...
self.mc.MOV_mi((loc.value, self.cpu.vtable_offset), loc_vtable.value)
self.mc.MOV(mem(loc, self.cpu.vtable_offset), loc_vtable)
def set_vtable(self, loc, loc_vtable): if self.cpu.vtable_offset is not None: assert isinstance(loc, RegLoc) assert isinstance(loc_vtable, ImmedLoc) self.mc.MOV_mi((loc.value, self.cpu.vtable_offset), loc_vtable.value)
optimizer = Optimizer(metainterp_sd, loop, optimizations, not_a_bridge=True)
optimizer = Optimizer(metainterp_sd, loop, optimizations)
def optimize_loop(self, ops, optops): loop = self.parse(ops) # self.loop = loop metainterp_sd = FakeMetaInterpStaticData(self.cpu) if hasattr(self, 'vrefinfo'): metainterp_sd.virtualref_info = self.vrefinfo # # XXX list the exact optimizations that are needed for each test from pypy.jit.metainterp.optimizeopt import (O...
def test_interp2app_unwrap_spec_path(self):
def test_interp2app_unwrap_spec_path(self, monkeypatch):
def test_interp2app_unwrap_spec_path(self): space = self.space def g(space, p): return p
parts = name.split(os.path.sep)
parts_ends = [i for i in range(0, len(name)) if name[i] == os.path.sep or name[i] == ZIPSEP] parts_ends.append(len(name))
def descr_new_zipimporter(space, w_type, name): w = space.wrap w_ZipImportError = space.getattr(space.getbuiltinmodule('zipimport'), w('ZipImportError')) ok = False parts = name.split(os.path.sep) filename = "" # make annotator happy for i in range(1, len(parts) + 1): filename = os.path.sep.join(parts[:i]) if not filen...
for i in range(1, len(parts) + 1): filename = os.path.sep.join(parts[:i])
for i in parts_ends: filename = name[:i]
def descr_new_zipimporter(space, w_type, name): w = space.wrap w_ZipImportError = space.getattr(space.getbuiltinmodule('zipimport'), w('ZipImportError')) ok = False parts = name.split(os.path.sep) filename = "" # make annotator happy for i in range(1, len(parts) + 1): filename = os.path.sep.join(parts[:i]) if not filen...
)
ifdef='AF_PACKET')
'typedef unsigned __int32 uint32_t;',
('ifr_name', rffi.CFixedArray(rffi.CHAR, 8))])
('ifr_name', rffi.CFixedArray(rffi.CHAR, 8))], ifdef='AF_PACKET')
'typedef unsigned __int32 uint32_t;',
ioctl = external('ioctl', [socketfd_type, rffi.INT, lltype.Ptr(ifreq)], rffi.INT)
if ifreq is not None: ioctl = external('ioctl', [socketfd_type, rffi.INT, lltype.Ptr(ifreq)], rffi.INT)
def external_c(name, args, result): return rffi.llexternal(name, args, result, compilation_info=eci, calling_conv='c')
newsize = base.read_from_env('PYPY_GC_NURSERY')
newsize = env.read_from_env('PYPY_GC_NURSERY')
def setup(self): """Called at run-time to initialize the GC.""" # # Hack: MovingGCBase.setup() sets up stuff related to id(), which # we implement differently anyway. So directly call GCBase.setup(). GCBase.setup(self) # # A list of all raw_malloced objects (the objects too large) self.rawmalloced_objects = self.Addre...
major_coll = base.read_float_from_env('PYPY_GC_MAJOR_COLLECT')
major_coll = env.read_float_from_env('PYPY_GC_MAJOR_COLLECT')
def setup(self): """Called at run-time to initialize the GC.""" # # Hack: MovingGCBase.setup() sets up stuff related to id(), which # we implement differently anyway. So directly call GCBase.setup(). GCBase.setup(self) # # A list of all raw_malloced objects (the objects too large) self.rawmalloced_objects = self.Addre...
growth = base.read_float_from_env('PYPY_GC_GROWTH')
growth = env.read_float_from_env('PYPY_GC_GROWTH')
def setup(self): """Called at run-time to initialize the GC.""" # # Hack: MovingGCBase.setup() sets up stuff related to id(), which # we implement differently anyway. So directly call GCBase.setup(). GCBase.setup(self) # # A list of all raw_malloced objects (the objects too large) self.rawmalloced_objects = self.Addre...
min_heap_size = base.read_uint_from_env('PYPY_GC_MIN')
min_heap_size = env.read_uint_from_env('PYPY_GC_MIN')
def setup(self): """Called at run-time to initialize the GC.""" # # Hack: MovingGCBase.setup() sets up stuff related to id(), which # we implement differently anyway. So directly call GCBase.setup(). GCBase.setup(self) # # A list of all raw_malloced objects (the objects too large) self.rawmalloced_objects = self.Addre...
max_heap_size = base.read_uint_from_env('PYPY_GC_MAX')
max_heap_size = env.read_uint_from_env('PYPY_GC_MAX')
def setup(self): """Called at run-time to initialize the GC.""" # # Hack: MovingGCBase.setup() sets up stuff related to id(), which # we implement differently anyway. So directly call GCBase.setup(). GCBase.setup(self) # # A list of all raw_malloced objects (the objects too large) self.rawmalloced_objects = self.Addre...
max_delta = base.read_uint_from_env('PYPY_GC_MAX_DELTA')
max_delta = env.read_uint_from_env('PYPY_GC_MAX_DELTA')
def setup(self): """Called at run-time to initialize the GC.""" # # Hack: MovingGCBase.setup() sets up stuff related to id(), which # we implement differently anyway. So directly call GCBase.setup(). GCBase.setup(self) # # A list of all raw_malloced objects (the objects too large) self.rawmalloced_objects = self.Addre...
if hasattr(op, 'getfailargs'):
if not we_are_translated() and hasattr(op, 'getfailargs'):
def _emit_guard(self, op, regalloc, fcond, save_exc=False): descr = op.getdescr() assert isinstance(descr, AbstractFailDescr) if hasattr(op, 'getfailargs'): print 'Failargs: ', op.getfailargs()
self._emit_guard(op, regalloc, c.NE)
if offset is not None: self.mc.ADD_ri(r.pc.value, r.pc.value, 2*WORD, cond=c.EQ) else: raise NotImplementedError
def emit_op_guard_nonnull_class(self, op, regalloc, fcond): locs = self._prepare_guard_class(op, regalloc, fcond) self.mc.CMP_ri(locs[0].value, 0) self._emit_guard(op, regalloc, c.NE) self._cmp_guard_class(op, locs, regalloc, fcond) return fcond
imm_ofs = self._check_imm_arg(ofs_length)
ofs_box = ConstInt(ofs_length) imm_ofs = self._check_imm_arg(ofs_box)
def emit_op_strlen(self, op, regalloc, fcond): l0, box = self._ensure_value_is_boxed(op.getarg(0), regalloc) boxes = [box]
l1 = regalloc.make_sure_var_in_reg(ConstInt(ofs_length), boxes) else: l1, box1 = self._ensure_value_is_boxed(ConstInt(ofs_length), regalloc, boxes)
l1 = regalloc.make_sure_var_in_reg(ofs_box, boxes) else: l1, box1 = self._ensure_value_is_boxed(ofs_box, regalloc, boxes)
def emit_op_strlen(self, op, regalloc, fcond): l0, box = self._ensure_value_is_boxed(op.getarg(0), regalloc) boxes = [box]
imm_ofs = self._check_imm_arg(ofs_length)
ofs_box = ConstInt(ofs_length) imm_ofs = self._check_imm_arg(ofs_box)
def emit_op_unicodelen(self, op, regalloc, fcond): l0, box = self._ensure_value_is_boxed(op.getarg(0), regalloc) boxes = [box] res = regalloc.force_allocate_reg(op.result, boxes) boxes.append(op.result) basesize, itemsize, ofs_length = symbolic.get_array_token(rstr.UNICODE, self.cpu.translate_support_code) imm_ofs = se...
l1 = regalloc.make_sure_var_in_reg(ConstInt(ofs_length), boxes) else: l1, box1 = self._ensure_value_is_boxed(ConstInt(ofs_length), regalloc, boxes)
l1 = regalloc.make_sure_var_in_reg(ofs_box, boxes) else: l1, box1 = self._ensure_value_is_boxed(ofs_box, regalloc, boxes)
def emit_op_unicodelen(self, op, regalloc, fcond): l0, box = self._ensure_value_is_boxed(op.getarg(0), regalloc) boxes = [box] res = regalloc.force_allocate_reg(op.result, boxes) boxes.append(op.result) basesize, itemsize, ofs_length = symbolic.get_array_token(rstr.UNICODE, self.cpu.translate_support_code) imm_ofs = se...
regalloc.possibly_free_var(v) regalloc.possibly_free_var(tempbox)
def _malloc_varsize(self, ofs_items, ofs_length, scale, v, res_v, regalloc): tempbox = TempBox() size_loc = regalloc.force_allocate_reg(tempbox) self.mc.gen_load_int(size_loc.value, ofs_items + (v.getint() << scale)) self._emit_call(self.malloc_func_addr, [tempbox], regalloc, result=res_v) loc = regalloc.make_sure_var_...
import warnings warnings.simplefilter('error', DeprecationWarning) try: raises(DeprecationWarning, f) finally: warnings.simplefilter('default', DeprecationWarning)
raises(TypeError, f)
def f(): raise "test"
def test_stringexc(self): a = "hello world" try: raise a except a, e: assert e == None try: raise a, "message" except a, e: assert e == "message"
def test_more_precise_instancearg(self): try: raise Exception, SystemError(1, 2) except SystemError, e: assert e.args[0] == 1 assert e.args[1] == 2
setfield_gc(p2, 0, descr=virtualtokendescr)
setfield_gc(p2, -2, descr=virtualtokendescr)
def test_vref_nonvirtual_escape(self): ops = """ [p1] p2 = virtual_ref(p1, 5) escape(p2) virtual_ref_finish(p2, p1) jump(p1) """ expected = """ [p1] i0 = force_token() p2 = new_with_vtable(ConstClass(jit_virtual_ref_vtable)) setfield_gc(p2, i0, descr=virtualtokendescr) setfield_gc(p2, 5, descr=virtualrefindexdescr) esc...
setfield_gc(p2, 0, descr=virtualtokendescr)
setfield_gc(p2, -2, descr=virtualtokendescr)
def test_vref_virtual_1(self): ops = """ [p0, i1] # p1 = new_with_vtable(ConstClass(node_vtable)) p1b = new_with_vtable(ConstClass(node_vtable)) setfield_gc(p1b, 252, descr=valuedescr) setfield_gc(p1, p1b, descr=nextdescr) # p2 = virtual_ref(p1, 3) setfield_gc(p0, p2, descr=nextdescr) call_may_force(i1, descr=mayforcev...
setfield_gc(p2, 0, descr=virtualtokendescr)
setfield_gc(p2, -2, descr=virtualtokendescr)
def test_vref_virtual_2(self): self.make_fail_descr() ops = """ [p0, i1] # p1 = new_with_vtable(ConstClass(node_vtable)) p1b = new_with_vtable(ConstClass(node_vtable)) setfield_gc(p1b, i1, descr=valuedescr) setfield_gc(p1, p1b, descr=nextdescr) # p2 = virtual_ref(p1, 2) setfield_gc(p0, p2, descr=nextdescr) call_may_for...
newdata.extend(c for c in space.str_w(list_w[i]))
newdata.extend([c for c in space.str_w(list_w[i])])
def str_join__Bytearray_ANY(space, w_self, w_list): list_w = space.listview(w_list) if not list_w: return W_BytearrayObject([]) data = w_self.data reslen = 0 for i in range(len(list_w)): w_s = list_w[i] if not (space.is_true(space.isinstance(w_s, space.w_str)) or space.is_true(space.isinstance(w_s, space.w_bytearray)))...
op.getdescr().rd_snapshot = None
orgdescr = op.getdescr() assert isinstance(orgdescr, ResumeGuardDescr) orgdescr.rd_snapshot = None
def inline(self, loop_operations, loop_args, jump_args): self.argmap = argmap = {} assert len(loop_args) == len(jump_args) for i in range(len(loop_args)): argmap[loop_args[i]] = jump_args[i]
op.getdescr().rd_snapshot = None
descr = op.getdescr() assert isinstance(descr, ResumeGuardDescr) descr.rd_snapshot = None
def inline(self, loop_operations, loop_args, jump_args): self.argmap = argmap = {} assert len(loop_args) == len(jump_args) for i in range(len(loop_args)): argmap[loop_args[i]] = jump_args[i]
return Snapshot(self.inline_snapshot(snapshot.prev), boxes)
new_snapshot = Snapshot(self.inline_snapshot(snapshot.prev), boxes[:]) self.snapshot_map[snapshot] = new_snapshot return new_snapshot
def inline_snapshot(self, snapshot): if snapshot in self.snapshot_map: return self.snapshot_map[snapshot] boxes = [] for a in snapshot.boxes: if isinstance(a, Const): boxes.append(a) else: boxes.append(self.inline_arg(a)) return Snapshot(self.inline_snapshot(snapshot.prev), boxes)
out = py.builtin._totext(out, sys.getdefaultencoding()) err = py.builtin._totext(err, sys.getdefaultencoding())
out = py.builtin._totext(out, sys.stdout.encoding) err = py.builtin._totext(err, sys.stderr.encoding)
def cmdexec(cmd): """ return output of executing 'cmd' in a separate process. raise cmdexec.ExecutionFailed exeception if the command failed. the exception will provide an 'err' attribute containing the error-output from the command. """ process = subprocess.Popen(cmd, shell=True, universal_newlines=True, stdout=subpr...
printf("&p = %ld, p.x = %ld, p.y = %ld\\n", &p, p.x, p.y);
def test_byval_argument(self): """ struct Point { long x; long y; };
def fdopenstream(self, stream, fd, mode):
def fdopenstream(self, stream, fd, mode, w_name=None):
def fdopenstream(self, stream, fd, mode): self.fd = fd self.mode = mode self.stream = stream if stream.flushable(): getopenstreams(self.space)[stream] = None
assert fn(sys.maxint) == 4*sys.maxint
assert fn(2147483647) == 4*2147483647
def f(i): return 4*i
assert gn(sys.maxint) == 4*sys.maxint
assert gn(2147483647) == 4*2147483647
def g(i): return 4*i
importlist.append(os.path.join(python_std_lib, 'plat-mac')) importlist.append(os.path.join(python_std_lib, 'plat-mac', 'lib-scriptpackages'))
platmac = os.path.join(python_std_lib, 'plat-mac') importlist.append(platmac) importlist.append(os.path.join(platmac, 'lib-scriptpackages'))
def getinitialpath(prefix): from pypy.module.sys.version import CPYTHON_VERSION dirname = '%d.%d.%d' % (CPYTHON_VERSION[0], CPYTHON_VERSION[1], CPYTHON_VERSION[2]) lib_python = os.path.join(prefix, 'lib-python') python_std_lib = os.path.join(lib_python, dirname) checkdir(python_std_lib) python_std_lib_modified = os.pat...
elif self.find_rewriteable_bool(op, args):
elif self.find_rewritable_bool(op, args):
def optimize_default(self, op): if op.is_always_pure(): for arg in op.args: if self.get_constant_box(arg) is None: break else: # all constant arguments: constant-fold away argboxes = [self.get_constant_box(arg) for arg in op.args] resbox = execute_nonspec(self.cpu, None, op.opnum, argboxes, op.descr) self.make_constant...
def find_rewriteable_bool(self, op, args):
def find_rewritable_bool(self, op, args):
def find_rewriteable_bool(self, op, args): try: oldopnum = opboolinvers[op.opnum] targs = [args[0], args[1], ConstInt(oldopnum)] if self.try_boolinvers(op, targs): return True except KeyError: pass
rstack.resume_point("CALL_METHOD_no_kwargs", f, n_args, returns=w_result)
rstack.resume_point("CALL_METHOD", f, w_self, n_args, returns=w_result)
def CALL_METHOD(f, oparg, *ignored): # opargs contains the arg, and kwarg count, excluding the implicit 'self' n_args = oparg & 0xff n_kwargs = (oparg >> 8) & 0xff w_self = f.peekvalue(n_args + (2 * n_kwargs)) w_callable = f.peekvalue(n_args + (2 * n_kwargs) + 1) n = n_args + (w_self is not None) if not n_kwargs: try:...
rstack.resume_point("CALL_METHOD", f, w_self, returns=w_result)
rstack.resume_point("CALL_METHOD", f, w_self, n_args, returns=w_result)
def CALL_METHOD(f, oparg, *ignored): # opargs contains the arg, and kwarg count, excluding the implicit 'self' n_args = oparg & 0xff n_kwargs = (oparg >> 8) & 0xff w_self = f.peekvalue(n_args + (2 * n_kwargs)) w_callable = f.peekvalue(n_args + (2 * n_kwargs) + 1) n = n_args + (w_self is not None) if not n_kwargs: try:...
if encoding == "ascii": expect = self.lowleveltype
if encoding == "ascii" and self.lowleveltype == UniChar: expect = UniChar
def rtype_method_encode(self, hop): if not hop.args_s[1].is_constant(): raise TyperError("encoding must be constant") encoding = hop.args_s[1].const if encoding == "ascii": expect = self.lowleveltype # can be a UniChar else: expect = self.repr # must be a regular unicode string v_self = hop.inputarg(expect,...
compilation_info=CConfig._compilation_info_)
compilation_info=CConfig._compilation_info_, sandboxsafe=True, threadsafe=True)
def external(name, args, result): return rffi.llexternal(name, args, result, compilation_info=CConfig._compilation_info_)
return rffi.llexternal(name, args, result, compilation_info=CConfig._compilation_info_, calling_conv='win')
return rffi.llexternal(name, args, result, compilation_info=CConfig._compilation_info_, calling_conv='win', sandboxsafe=True, threadsafe=True)
def winexternal(name, args, result): return rffi.llexternal(name, args, result, compilation_info=CConfig._compilation_info_, calling_conv='win')
from pypy.interpreter.gateway import interp2app, Arguments
from pypy.interpreter.gateway import interp2app, Arguments, unwrap_spec
from pypy.interpreter.typedef import TypeDef, interp_attrproperty
descr_new.unwrap_spec = [ObjSpace, W_Root, Arguments]
def descr_new(space, w_subtype, __args__): self = space.allocate_instance(W_Type, w_subtype) W_Type.__init__(self, space) return space.wrap(self)
descr_init.unwrap_spec = ['self', ObjSpace, W_Root, W_Root, int]
def descr_init(self, space, w_errno, w_strerror, written=0): W_IOError.descr_init(self, space, [w_errno, w_strerror]) self.written = written
gc_buf = lltype.nullptr(STRTYPE)
gc_buf = rgc.malloc_nonmovable(STRTYPE, count)
def alloc_buffer(count): """ Returns a (raw_buffer, gc_buffer) pair, allocated with count bytes. The raw_buffer can be safely passed to a native function which expects it to not move. Call str_from_buffer with the returned values to get a safe high-level string. When the garbage collector cooperates, this allows for th...
def optimize_loop(self, ops, spectext, optops, checkspecnodes=True, expected_preamble=None):
def optimize_loop(self, ops, spectext, optops, expected_preamble=None):
def optimize_loop(self, ops, spectext, optops, checkspecnodes=True, expected_preamble=None): loop = self.parse(ops) # if checkspecnodes: # verify that 'spectext' is indeed what optimizefindnode would # compute for this loop cpu = self.cpu perfect_specialization_finder = PerfectSpecializationFinder(cpu) perfect_speciali...
if checkspecnodes: cpu = self.cpu perfect_specialization_finder = PerfectSpecializationFinder(cpu) perfect_specialization_finder.find_nodes_loop(loop) self.check_specnodes(loop.token.specnodes, spectext) else: loop.token.specnodes = self.unpack_specnodes(spectext)
loop.token.specnodes = self.unpack_specnodes(spectext)
def optimize_loop(self, ops, spectext, optops, checkspecnodes=True, expected_preamble=None): loop = self.parse(ops) # if checkspecnodes: # verify that 'spectext' is indeed what optimizefindnode would # compute for this loop cpu = self.cpu perfect_specialization_finder = PerfectSpecializationFinder(cpu) perfect_speciali...
print "Ops: "
print loop.preamble.inputargs print '\n'.join([str(o) for o in loop.preamble.operations]) print print loop.inputargs
def optimize_loop(self, ops, spectext, optops, checkspecnodes=True, expected_preamble=None): loop = self.parse(ops) # if checkspecnodes: # verify that 'spectext' is indeed what optimizefindnode would # compute for this loop cpu = self.cpu perfect_specialization_finder = PerfectSpecializationFinder(cpu) perfect_speciali...
expected = """
preamble = """
def test_constant_boolrewrite_lt(self): ops = """ [i0] i1 = int_lt(i0, 0) guard_true(i1) [] i2 = int_ge(i0, 0) guard_false(i2) [] jump(i0) """ expected = """ [i0] i1 = int_lt(i0, 0) guard_true(i1) [] jump(i0) """ self.optimize_loop(ops, 'Not', expected)
self.optimize_loop(ops, 'Not', expected)
expected = """ [i0] jump(i0) """ self.optimize_loop(ops, 'Not', expected, expected_preamble=preamble)
def test_constant_boolrewrite_lt(self): ops = """ [i0] i1 = int_lt(i0, 0) guard_true(i1) [] i2 = int_ge(i0, 0) guard_false(i2) [] jump(i0) """ expected = """ [i0] i1 = int_lt(i0, 0) guard_true(i1) [] jump(i0) """ self.optimize_loop(ops, 'Not', expected)
expected = """
preamble = """
def test_constant_boolrewrite_gt(self): ops = """ [i0] i1 = int_gt(i0, 0) guard_true(i1) [] i2 = int_le(i0, 0) guard_false(i2) [] jump(i0) """ expected = """ [i0] i1 = int_gt(i0, 0) guard_true(i1) [] jump(i0) """ self.optimize_loop(ops, 'Not', expected)
self.optimize_loop(ops, 'Not', expected)
expected = """ [i0] jump(i0) """ self.optimize_loop(ops, 'Not', expected, expected_preamble=preamble)
def test_constant_boolrewrite_gt(self): ops = """ [i0] i1 = int_gt(i0, 0) guard_true(i1) [] i2 = int_le(i0, 0) guard_false(i2) [] jump(i0) """ expected = """ [i0] i1 = int_gt(i0, 0) guard_true(i1) [] jump(i0) """ self.optimize_loop(ops, 'Not', expected)
expected = """
preamble = """
def test_constant_boolrewrite_reflex(self): ops = """ [i0] i1 = int_gt(i0, 0) guard_true(i1) [] i2 = int_lt(0, i0) guard_true(i2) [] jump(i0) """ expected = """ [i0] i1 = int_gt(i0, 0) guard_true(i1) [] jump(i0) """ self.optimize_loop(ops, 'Not', expected)
self.optimize_loop(ops, 'Not', expected)
expected = """ [i0] jump(i0) """ self.optimize_loop(ops, 'Not', expected, expected_preamble=preamble)
def test_constant_boolrewrite_reflex(self): ops = """ [i0] i1 = int_gt(i0, 0) guard_true(i1) [] i2 = int_lt(0, i0) guard_true(i2) [] jump(i0) """ expected = """ [i0] i1 = int_gt(i0, 0) guard_true(i1) [] jump(i0) """ self.optimize_loop(ops, 'Not', expected)
expected = """
preamble = """
def test_constant_boolrewrite_reflex_invers(self): ops = """ [i0] i1 = int_gt(i0, 0) guard_true(i1) [] i2 = int_ge(0, i0) guard_false(i2) [] jump(i0) """ expected = """ [i0] i1 = int_gt(i0, 0) guard_true(i1) [] jump(i0) """ self.optimize_loop(ops, 'Not', expected)
self.optimize_loop(ops, 'Not', expected)
expected = """ [i0] jump(i0) """ self.optimize_loop(ops, 'Not', expected, expected_preamble=preamble)
def test_constant_boolrewrite_reflex_invers(self): ops = """ [i0] i1 = int_gt(i0, 0) guard_true(i1) [] i2 = int_ge(0, i0) guard_false(i2) [] jump(i0) """ expected = """ [i0] i1 = int_gt(i0, 0) guard_true(i1) [] jump(i0) """ self.optimize_loop(ops, 'Not', expected)
jump(ConstPtr(myptr))
jump(p1)
def test_remove_guard_value_if_constant(self): ops = """ [p1] guard_value(p1, ConstPtr(myptr)) [] jump(ConstPtr(myptr)) """ expected = """ [] jump() """ self.optimize_loop(ops, 'Constant(myptr)', expected)
self.optimize_loop(ops, 'Constant(myptr)', expected)
self.optimize_loop(ops, 'Not', expected)
def test_remove_guard_value_if_constant(self): ops = """ [p1] guard_value(p1, ConstPtr(myptr)) [] jump(ConstPtr(myptr)) """ expected = """ [] jump() """ self.optimize_loop(ops, 'Constant(myptr)', expected)
expected = """
preamble = """
def test_ooisnull_oononnull_1(self): ops = """ [p0] guard_class(p0, ConstClass(node_vtable)) [] guard_nonnull(p0) [] jump(p0) """ expected = """ [p0] guard_class(p0, ConstClass(node_vtable)) [] jump(p0) """ self.optimize_loop(ops, 'Not', expected)
self.optimize_loop(ops, 'Not', expected)
expected = """ [p0] jump(p0) """ self.optimize_loop(ops, 'Not', expected, preamble)
def test_ooisnull_oononnull_1(self): ops = """ [p0] guard_class(p0, ConstClass(node_vtable)) [] guard_nonnull(p0) [] jump(p0) """ expected = """ [p0] guard_class(p0, ConstClass(node_vtable)) [] jump(p0) """ self.optimize_loop(ops, 'Not', expected)
expected = """
preamble = """
def test_int_is_true_1(self): ops = """ [i0] i1 = int_is_true(i0) guard_true(i1) [] i2 = int_is_true(i0) guard_true(i2) [] jump(i0) """ expected = """ [i0] i1 = int_is_true(i0) guard_true(i1) [] jump(i0) """ self.optimize_loop(ops, 'Not', expected)
self.optimize_loop(ops, 'Not', expected)
expected = """ [i0] jump(i0) """ self.optimize_loop(ops, 'Not', expected, preamble)
def test_int_is_true_1(self): ops = """ [i0] i1 = int_is_true(i0) guard_true(i1) [] i2 = int_is_true(i0) guard_true(i2) [] jump(i0) """ expected = """ [i0] i1 = int_is_true(i0) guard_true(i1) [] jump(i0) """ self.optimize_loop(ops, 'Not', expected)
expected = """
preamble = """
def test_ooisnull_oononnull_2(self): ops = """ [p0] guard_nonnull(p0) [] guard_nonnull(p0) [] jump(p0) """ expected = """ [p0] guard_nonnull(p0) [] jump(p0) """ self.optimize_loop(ops, 'Not', expected)
self.optimize_loop(ops, 'Not', expected)
expected = """ [p0] jump(p0) """ self.optimize_loop(ops, 'Not', expected, preamble)
def test_ooisnull_oononnull_2(self): ops = """ [p0] guard_nonnull(p0) [] guard_nonnull(p0) [] jump(p0) """ expected = """ [p0] guard_nonnull(p0) [] jump(p0) """ self.optimize_loop(ops, 'Not', expected)
expected = """
preamble = """
def test_ooisnull_oononnull_via_virtual(self): ops = """ [p0] pv = new_with_vtable(ConstClass(node_vtable)) setfield_gc(pv, p0, descr=valuedescr) guard_nonnull(p0) [] p1 = getfield_gc(pv, descr=valuedescr) guard_nonnull(p1) [] jump(p0) """ expected = """ [p0] guard_nonnull(p0) [] jump(p0) """ self.optimize_loop(ops, 'N...
self.optimize_loop(ops, 'Not', expected)
expected = """ [p0] jump(p0) """ self.optimize_loop(ops, 'Not', expected, preamble)
def test_ooisnull_oononnull_via_virtual(self): ops = """ [p0] pv = new_with_vtable(ConstClass(node_vtable)) setfield_gc(pv, p0, descr=valuedescr) guard_nonnull(p0) [] p1 = getfield_gc(pv, descr=valuedescr) guard_nonnull(p1) [] jump(p0) """ expected = """ [p0] guard_nonnull(p0) [] jump(p0) """ self.optimize_loop(ops, 'N...
expected = """
preamble = """
def test_oois_1(self): ops = """ [p0] guard_class(p0, ConstClass(node_vtable)) [] i0 = ptr_ne(p0, NULL) guard_true(i0) [] i1 = ptr_eq(p0, NULL) guard_false(i1) [] i2 = ptr_ne(NULL, p0) guard_true(i0) [] i3 = ptr_eq(NULL, p0) guard_false(i1) [] jump(p0) """ expected = """ [p0] guard_class(p0, ConstClass(node_vtable)) []...
self.optimize_loop(ops, 'Not', expected)
expected = """ [p0] jump(p0) """ self.optimize_loop(ops, 'Not', expected, preamble)
def test_oois_1(self): ops = """ [p0] guard_class(p0, ConstClass(node_vtable)) [] i0 = ptr_ne(p0, NULL) guard_true(i0) [] i1 = ptr_eq(p0, NULL) guard_false(i1) [] i2 = ptr_ne(NULL, p0) guard_true(i0) [] i3 = ptr_eq(NULL, p0) guard_false(i1) [] jump(p0) """ expected = """ [p0] guard_class(p0, ConstClass(node_vtable)) []...
expected = """
preamble = """
def test_guard_value_to_guard_true(self): ops = """ [i] i1 = int_lt(i, 3) guard_value(i1, 1) [i] jump(i) """ expected = """ [i] i1 = int_lt(i, 3) guard_true(i1) [i] jump(i) """ self.optimize_loop(ops, 'Not', expected)
self.optimize_loop(ops, 'Not', expected)
expected = """ [i] jump(i) """ self.optimize_loop(ops, 'Not', expected, preamble)
def test_guard_value_to_guard_true(self): ops = """ [i] i1 = int_lt(i, 3) guard_value(i1, 1) [i] jump(i) """ expected = """ [i] i1 = int_lt(i, 3) guard_true(i1) [i] jump(i) """ self.optimize_loop(ops, 'Not', expected)
expected = """
preamble = """
def test_guard_value_to_guard_false(self): ops = """ [i] i1 = int_is_true(i) guard_value(i1, 0) [i] jump(i) """ expected = """ [i] i1 = int_is_true(i) guard_false(i1) [i] jump(i) """ self.optimize_loop(ops, 'Not', expected)
self.optimize_loop(ops, 'Not', expected)
expected = """ [i] jump(i) """ self.optimize_loop(ops, 'Not', expected, preamble)
def test_guard_value_to_guard_false(self): ops = """ [i] i1 = int_is_true(i) guard_value(i1, 0) [i] jump(i) """ expected = """ [i] i1 = int_is_true(i) guard_false(i1) [i] jump(i) """ self.optimize_loop(ops, 'Not', expected)
expected = """
preamble = """
def test_guard_value_on_nonbool(self): ops = """ [i] i1 = int_add(i, 3) guard_value(i1, 0) [i] jump(i) """ expected = """ [i] i1 = int_add(i, 3) guard_value(i1, 0) [i] jump(-3) """ self.optimize_loop(ops, 'Not', expected)
jump(-3) """ self.optimize_loop(ops, 'Not', expected)
jump() """ expected = """ [] jump() """ self.optimize_loop(ops, 'Not', expected, preamble)
def test_guard_value_on_nonbool(self): ops = """ [i] i1 = int_add(i, 3) guard_value(i1, 0) [i] jump(i) """ expected = """ [i] i1 = int_add(i, 3) guard_value(i1, 0) [i] jump(-3) """ self.optimize_loop(ops, 'Not', expected)
expected = """
preamble = """
def test_int_is_true_of_bool(self): ops = """ [i0, i1] i2 = int_gt(i0, i1) i3 = int_is_true(i2) i4 = int_is_true(i3) guard_value(i4, 0) [i0, i1] jump(i0, i1) """ expected = """ [i0, i1] i2 = int_gt(i0, i1) guard_false(i2) [i0, i1] jump(i0, i1) """ self.optimize_loop(ops, 'Not, Not', expected)
self.optimize_loop(ops, 'Not, Not', expected)
expected = """ [i0, i1] jump(i0, i1) """ self.optimize_loop(ops, 'Not, Not', expected, preamble)
def test_int_is_true_of_bool(self): ops = """ [i0, i1] i2 = int_gt(i0, i1) i3 = int_is_true(i2) i4 = int_is_true(i3) guard_value(i4, 0) [i0, i1] jump(i0, i1) """ expected = """ [i0, i1] i2 = int_gt(i0, i1) guard_false(i2) [i0, i1] jump(i0, i1) """ self.optimize_loop(ops, 'Not, Not', expected)
self.optimize_loop(ops, 'Not, Not, Not', ops)
self.optimize_loop(ops, 'Not, Not, Not', expected, preamble)
def test_p123_simple(self): ops = """ [i1, p2, p3] i3 = getfield_gc(p3, descr=valuedescr) escape(i3) p1 = new_with_vtable(ConstClass(node_vtable)) setfield_gc(p1, i1, descr=valuedescr) jump(i1, p1, p2) """ # We cannot track virtuals that survive for more than two iterations. self.optimize_loop(ops, 'Not, Not, Not', ops...
self.optimize_loop(ops, 'Not, Not, Not', ops)
preamble = """ [i1, p2, p3] i3 = getfield_gc(p3, descr=valuedescr) escape(i3) jump(i1, p2) """ expected = """ [i1, p2] i3 = getfield_gc(p2, descr=valuedescr) escape(i3) p4 = new_with_vtable(ConstClass(node_vtable)) setfield_gc(p4, i1, descr=valuedescr) p1sub = new_with_vtable(ConstClass(node_vtable2)) setfield_gc(p1sub...
def test_p123_nested(self): ops = """ [i1, p2, p3] i3 = getfield_gc(p3, descr=valuedescr) escape(i3) p1 = new_with_vtable(ConstClass(node_vtable)) setfield_gc(p1, i1, descr=valuedescr) p1sub = new_with_vtable(ConstClass(node_vtable2)) setfield_gc(p1sub, i1, descr=valuedescr) setfield_gc(p1, p1sub, descr=nextdescr) jump...
self.optimize_loop(ops, 'Not, Not, Not', ops)
preamble = """ [i1, p2, p3] p3sub = getfield_gc(p3, descr=nextdescr) i3 = getfield_gc(p3sub, descr=valuedescr) escape(i3) jump(i1, p2) """ expected = """ [i1, p3] p2sub = new_with_vtable(ConstClass(node_vtable2)) setfield_gc(p2sub, i1, descr=valuedescr) setfield_gc(p3, p2sub, descr=nextdescr) escape(i1) p4 = new_with_v...
def test_p123_anti_nested(self): ops = """ [i1, p2, p3] p3sub = getfield_gc(p3, descr=nextdescr) i3 = getfield_gc(p3sub, descr=valuedescr) escape(i3) p1 = new_with_vtable(ConstClass(node_vtable)) p2sub = new_with_vtable(ConstClass(node_vtable2)) setfield_gc(p2sub, i1, descr=valuedescr) setfield_gc(p2, p2sub, descr=next...
" really return an PyObject?"
" really return a PyObject?"
def cfunction_descr_call(space, w_self, __args__): self = space.interp_w(W_PyCFunctionObject, w_self) args_w, kw_w = __args__.unpack() null = lltype.nullptr(PyObject.TO) # XXX for the moment # Call the C function result = self.ml.c_ml_meth(null, null) try: ret = from_ref(space, result) except RuntimeError: if not we_a...
if isinstance(self.buf, buffer.SubBuffer): offset = self.buf.offset elif isinstance(self.buf, buffer.RWSubBuffer): offset = self.buf.offset
buf = self.buf if isinstance(buf, buffer.SubBuffer): offset = buf.offset elif isinstance(buf, buffer.RWSubBuffer): offset = buf.offset
def w_get_suboffsets(space, self): if isinstance(self.buf, buffer.SubBuffer): offset = self.buf.offset elif isinstance(self.buf, buffer.RWSubBuffer): offset = self.buf.offset else: offset = 0 return space.newtuple([space.wrap(offset)])
if opcode == opcodedesc.RETURN_VALUE.index: w_returnvalue = self.popvalue() block = self.unrollstack(SReturnValue.kind) if block is None: self.pushvalue(w_returnvalue) raise Return else: unroller = SReturnValue(w_returnvalue) next_instr = block.handle(self, unroller) return next_instr if opcode == opcodedesc.YIELD_VAL...
def dispatch_bytecode(self, co_code, next_instr, ec): space = self.space while True: self.last_instr = intmask(next_instr) if not jit.we_are_jitted(): ec.bytecode_trace(self) next_instr = r_uint(self.last_instr) opcode = ord(co_code[next_instr]) next_instr += 1 if space.config.objspace.logbytecodes: space.bytecodecount...
def JUMP_ABSOLUTE(f, jumpto, next_instr, *ignored): return jumpto
def JUMP_IF_TRUE(f, stepby, next_instr, *ignored): w_cond = f.peekvalue() if f.space.is_true(w_cond): next_instr += stepby return next_instr
def YIELD_VALUE(f, oparg, next_instr): raise Yield def RETURN_VALUE(self, oparg, next_instr): w_returnvalue = self.popvalue() block = self.unrollstack(SReturnValue.kind) if block is None: self.pushvalue(w_returnvalue) raise Return unroller = SReturnValue(w_returnvalue) next_instr = block.handle(self, unroller) return ...
def WITH_CLEANUP(f, *ignored): # see comment in END_FINALLY for stack state w_exitfunc = f.popvalue() w_unroller = f.peekvalue(2) unroller = f.space.interpclass_w(w_unroller) if isinstance(unroller, SApplicationException): operr = unroller.operr w_result = f.space.call_function(w_exitfunc, operr.w_type, operr.get_w_val...
w_stacklevel = space.wrap(stacklevel)
w_stacklevel = space.wrap(rffi.cast(lltype.Signed, stacklevel))
def PyErr_WarnEx(space, w_category, message_ptr, stacklevel): """Issue a warning message. The category argument is a warning category (see below) or NULL; the message argument is a message string. stacklevel is a positive number giving a number of stack frames; the warning will be issued from the currently executing...
warmrunnerdesc.state.set_param_threshold(3) warmrunnerdesc.state.set_param_trace_eagerness(2) warmrunnerdesc.state.set_param_trace_limit(trace_limit) warmrunnerdesc.state.set_param_inlining(inline) warmrunnerdesc.state.set_param_optimizer(OPTIMIZER_FULL)
for jd in warmrunnerdesc.jitdrivers_sd: jd.warmstate.set_param_threshold(3) jd.warmstate.set_param_trace_eagerness(2) jd.warmstate.set_param_trace_limit(trace_limit) jd.warmstate.set_param_inlining(inline) jd.warmstate.set_param_optimizer(OPTIMIZER_FULL)
def entry_point(argv): args = %s res = function(*args) print res return 0
pass
self.w_newlines_dict = { SEEN_CR: space.wrap("\r"), SEEN_LF: space.wrap("\n"), SEEN_CRLF: space.wrap("\r\n"), SEEN_CR | SEEN_LF: space.newtuple( [space.wrap("\r"), space.wrap("\n")]), SEEN_CR | SEEN_CRLF: space.newtuple( [space.wrap("\r"), space.wrap("\r\n")]), SEEN_LF | SEEN_CRLF: space.newtuple( [space.wrap("\n"), sp...
def __init__(self, space): pass
return { SEEN_CR: space.wrap("\r"), SEEN_LF: space.wrap("\n"), SEEN_CRLF: space.wrap("\r\n"), SEEN_CR | SEEN_LF: space.wrap(("\r", "\n")), SEEN_CR | SEEN_CRLF: space.wrap(("\r", "\r\n")), SEEN_LF | SEEN_CRLF: space.wrap(("\n", "\r\n")), SEEN_CR | SEEN_LF | SEEN_CRLF: space.wrap(("\r", "\n", "\r\n")), }.get(self.seennl)
return self.w_newlines_dict.get(self.seennl, space.w_None)
def newlines_get_w(space, self): return { SEEN_CR: space.wrap("\r"), SEEN_LF: space.wrap("\n"), SEEN_CRLF: space.wrap("\r\n"), SEEN_CR | SEEN_LF: space.wrap(("\r", "\n")), SEEN_CR | SEEN_CRLF: space.wrap(("\r", "\r\n")), SEEN_LF | SEEN_CRLF: space.wrap(("\n", "\r\n")), SEEN_CR | SEEN_LF | SEEN_CRLF: space.wrap(("\r", "...
if not space.match(space, space.w_ImportError):
if not e.match(space, space.w_ImportError):
def descr_init(self, space, w_buffer, w_encoding=None, w_errors=None, w_newline=None, line_buffering=0): self.state = STATE_ZERO
table = space.str_w(w_table) if len(table) != 256: raise OperationError( space.w_ValueError, space.wrap("translation table must be 256 characters long"))
if space.is_w(w_table, space.w_None): table = DEFAULT_NOOP_TABLE else: table = space.str_w(w_table) if len(table) != 256: raise OperationError( space.w_ValueError, space.wrap("translation table must be 256 characters long"))
def str_translate__Rope_ANY_ANY(space, w_string, w_table, w_deletechars=''): """charfilter - unicode handling is not implemented Return a copy of the string where all characters occurring in the optional argument deletechars are removed, and the remaining characters have been mapped through the given translation table...
block.exits[0].args[0] is block.operations[-1].result)):
block.exits[0].args[0] is block.operations[-1].result) and block.operations[-1].opname not in ('malloc', 'malloc_nonmovable')):
def transform_block(self, graph, block): need_exc_matching = False n_gen_exc_checks = 0 if block is graph.exceptblock: return need_exc_matching, n_gen_exc_checks elif block is graph.returnblock: return need_exc_matching, n_gen_exc_checks last_operation = len(block.operations) - 1 if block.exitswitch == c_last_exception...
WORD = rffi.sizeof(lltype.Signed) assert descr1.get_base_size(False) == WORD assert descr2.get_base_size(False) == WORD assert descr3.get_base_size(False) == WORD assert descr4.get_base_size(False) == WORD
def get_alignment(code): return struct.calcsize('l' + code) - struct.calcsize(code) assert descr1.get_base_size(False) == get_alignment('c') assert descr2.get_base_size(False) == get_alignment('p') assert descr3.get_base_size(False) == get_alignment('p') assert descr4.get_base_size(False) == get_alignment('d')
def test_get_array_descr(): U = lltype.Struct('U') T = lltype.GcStruct('T') A1 = lltype.GcArray(lltype.Char) A2 = lltype.GcArray(lltype.Ptr(T)) A3 = lltype.GcArray(lltype.Ptr(U)) A4 = lltype.GcArray(lltype.Float) assert getArrayDescrClass(A2) is GcPtrArrayDescr assert getArrayDescrClass(A3) is NonGcPtrArrayDescr cls = ...