Author: Antonio Cuni <anto.c...@gmail.com> Branch: Changeset: r44813:23df97c1753c Date: 2011-06-07 17:05 +0200 http://bitbucket.org/pypy/pypy/changeset/23df97c1753c/
Log: merge heads diff --git a/pypy/annotation/test/test_annrpython.py b/pypy/annotation/test/test_annrpython.py --- a/pypy/annotation/test/test_annrpython.py +++ b/pypy/annotation/test/test_annrpython.py @@ -3483,6 +3483,17 @@ a = self.RPythonAnnotator() raises(Exception, a.build_types, f, [int]) + def test_range_variable_step(self): + def g(n): + return range(0, 10, n) + def f(n): + r = g(1) # constant step, at first + s = g(n) # but it becomes a variable step + return r + a = self.RPythonAnnotator() + s = a.build_types(f, [int]) + assert s.listdef.listitem.range_step == 0 + def g(n): return [0,1,2,n] diff --git a/pypy/jit/metainterp/logger.py b/pypy/jit/metainterp/logger.py --- a/pypy/jit/metainterp/logger.py +++ b/pypy/jit/metainterp/logger.py @@ -102,8 +102,8 @@ def repr_of_resop(self, op, ops_offset=None): if op.getopnum() == rop.DEBUG_MERGE_POINT: jd_sd = self.metainterp_sd.jitdrivers_sd[op.getarg(0).getint()] - s = jd_sd.warmstate.get_location_str(op.getarglist()[1:]) - return "debug_merge_point('%s')" % (s,) + s = jd_sd.warmstate.get_location_str(op.getarglist()[2:]) + return "debug_merge_point(%d, '%s')" % (op.getarg(1).getint(), s) if ops_offset is None: offset = -1 else: diff --git a/pypy/jit/metainterp/pyjitpl.py b/pypy/jit/metainterp/pyjitpl.py --- a/pypy/jit/metainterp/pyjitpl.py +++ b/pypy/jit/metainterp/pyjitpl.py @@ -916,8 +916,8 @@ def debug_merge_point(self, jd_index, in_recursion, greenkey): # debugging: produce a DEBUG_MERGE_POINT operation - self.metainterp.history.record(rop.DEBUG_MERGE_POINT, - [ConstInt(jd_index)] + greenkey, None) + args = [ConstInt(jd_index), ConstInt(in_recursion)] + greenkey + self.metainterp.history.record(rop.DEBUG_MERGE_POINT, args, None) @arguments("box", "label") def opimpl_goto_if_exception_mismatch(self, vtablebox, next_exc_target): diff --git a/pypy/jit/metainterp/test/test_logger.py b/pypy/jit/metainterp/test/test_logger.py --- a/pypy/jit/metainterp/test/test_logger.py +++ b/pypy/jit/metainterp/test/test_logger.py @@ -116,11 +116,11 @@ def test_debug_merge_point(self): inp = ''' [] - debug_merge_point(0, "dupa") + debug_merge_point(0, 0, "dupa") ''' _, loop, oloop = self.reparse(inp, check_equal=False) - assert loop.operations[0].getarg(1)._get_str() == "dupa" - assert oloop.operations[0].getarg(0)._get_str() == "dupa" + assert loop.operations[0].getarg(2)._get_str() == "dupa" + assert oloop.operations[0].getarg(1)._get_str() == "dupa" def test_floats(self): inp = ''' diff --git a/pypy/jit/metainterp/test/test_warmspot.py b/pypy/jit/metainterp/test/test_warmspot.py --- a/pypy/jit/metainterp/test/test_warmspot.py +++ b/pypy/jit/metainterp/test/test_warmspot.py @@ -80,7 +80,7 @@ self.meta_interp(f, [123, 10]) assert len(get_stats().locations) >= 4 for loc in get_stats().locations: - assert loc == (123,) + assert loc == (0, 123) def test_set_param_enable_opts(self): from pypy.rpython.annlowlevel import llstr, hlstr diff --git a/pypy/jit/tool/oparser.py b/pypy/jit/tool/oparser.py --- a/pypy/jit/tool/oparser.py +++ b/pypy/jit/tool/oparser.py @@ -212,7 +212,7 @@ descr = None if argspec.strip(): if opname == 'debug_merge_point': - allargs = argspec.split(', ', 1) + allargs = argspec.split(',', 2) else: allargs = [arg for arg in argspec.split(",") if arg != ''] diff --git a/pypy/jit/tool/test/test_oparser.py b/pypy/jit/tool/test/test_oparser.py --- a/pypy/jit/tool/test/test_oparser.py +++ b/pypy/jit/tool/test/test_oparser.py @@ -142,9 +142,9 @@ x = ''' [] debug_merge_point(0, "info") - debug_merge_point(1, 'info') + debug_merge_point(0, 'info') debug_merge_point(1, '<some ('other,')> info') - debug_merge_point(1, '(stuff) #1') + debug_merge_point(0, '(stuff) #1') ''' loop = parse(x) assert loop.operations[0].getarg(1)._get_str() == 'info' diff --git a/pypy/module/pypyjit/interp_jit.py b/pypy/module/pypyjit/interp_jit.py --- a/pypy/module/pypyjit/interp_jit.py +++ b/pypy/module/pypyjit/interp_jit.py @@ -57,11 +57,14 @@ space = self.space cache = space.fromcache(Cache) + if cache.in_recursion: + return if space.is_true(cache.w_compile_hook): logops = logger._make_log_operations() list_w = [space.wrap(logops.repr_of_resop(op)) for op in operations] pycode = cast_base_ptr_to_instance(PyCode, ll_pycode) + cache.in_recursion = True try: space.call_function(cache.w_compile_hook, space.wrap('main'), @@ -72,14 +75,18 @@ space.newlist(list_w)) except OperationError, e: e.write_unraisable(space, "jit hook ", cache.w_compile_hook) + cache.in_recursion = False def on_compile_bridge(self, logger, orig_looptoken, operations, n): space = self.space cache = space.fromcache(Cache) + if cache.in_recursion: + return if space.is_true(cache.w_compile_hook): logops = logger._make_log_operations() list_w = [space.wrap(logops.repr_of_resop(op)) for op in operations] + cache.in_recursion = True try: space.call_function(cache.w_compile_hook, space.wrap('main'), @@ -88,6 +95,7 @@ space.newlist(list_w)) except OperationError, e: e.write_unraisable(space, "jit hook ", cache.w_compile_hook) + cache.in_recursion = False pypyjitdriver = PyPyJitDriver(get_printable_location = get_printable_location, get_jitcell_at = get_jitcell_at, @@ -193,6 +201,7 @@ class Cache(object): def __init__(self, space): self.w_compile_hook = space.w_None + self.in_recursion = False @unwrap_spec(ObjSpace, W_Root) def set_compile_hook(space, w_hook): @@ -209,6 +218,10 @@ for jit merge point. in case it's `main` it'll be a tuple (code, offset, is_being_profiled) + Note that jit hook is not reentrant. It means that if the code + inside the jit hook is itself jitted, it will get compiled, but the + jit hook won't be called for that. + XXX write down what else """ cache = space.fromcache(Cache) diff --git a/pypy/module/pypyjit/test/test_jit_hook.py b/pypy/module/pypyjit/test/test_jit_hook.py --- a/pypy/module/pypyjit/test/test_jit_hook.py +++ b/pypy/module/pypyjit/test/test_jit_hook.py @@ -87,3 +87,19 @@ sys.stderr = prev assert 'jit hook' in s.getvalue() assert 'ZeroDivisionError' in s.getvalue() + + def test_non_reentrant(self): + import pypyjit + l = [] + + def hook(*args): + l.append(None) + self.on_compile() + self.on_compile_bridge() + + pypyjit.set_compile_hook(hook) + self.on_compile() + assert len(l) == 1 # and did not crash + self.on_compile_bridge() + assert len(l) == 2 # and did not crash + diff --git a/pypy/rlib/longlong2float.py b/pypy/rlib/longlong2float.py --- a/pypy/rlib/longlong2float.py +++ b/pypy/rlib/longlong2float.py @@ -30,15 +30,17 @@ return llval from pypy.translator.tool.cbuild import ExternalCompilationInfo -eci = ExternalCompilationInfo(includes=['string.h'], +eci = ExternalCompilationInfo(includes=['string.h', 'assert.h'], post_include_bits=[""" static double pypy__longlong2float(long long x) { double dd; + assert(sizeof(double) == 8 && sizeof(long long) == 8); memcpy(&dd, &x, 8); return dd; } static long long pypy__float2longlong(double x) { long long ll; + assert(sizeof(double) == 8 && sizeof(long long) == 8); memcpy(&ll, &x, 8); return ll; } diff --git a/pypy/tool/jitlogparser/parser.py b/pypy/tool/jitlogparser/parser.py --- a/pypy/tool/jitlogparser/parser.py +++ b/pypy/tool/jitlogparser/parser.py @@ -95,12 +95,12 @@ def __init__(self, operations, storage): if operations[0].name == 'debug_merge_point': - self.inline_level = int(operations[0].args[1]) + self.inline_level = int(operations[0].args[0]) m = re.search('<code object ([<>\w]+), file \'(.+?)\', line (\d+)> #(\d+) (\w+)', - operations[0].getarg(0)) + operations[0].getarg(1)) if m is None: # a non-code loop, like StrLiteralSearch or something - self.bytecode_name = operations[0].args[0].split(" ")[0][1:] + self.bytecode_name = operations[0].args[1].split(" ")[0][1:] else: self.name, self.filename, lineno, bytecode_no, self.bytecode_name = m.groups() self.startlineno = int(lineno) _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit