Author: Richard Plangger <planri...@gmail.com> Branch: new-jit-log Changeset: r85635:4f7beec17bd8 Date: 2016-07-09 22:41 +0200 http://bitbucket.org/pypy/pypy/changeset/4f7beec17bd8/
Log: change the loop numbering (token.number) to use jitlog's trace id, change test in test_compile, modify the emitted jitlog format when logging jitlog counters diff --git a/pypy/module/_vmprof/interp_vmprof.py b/pypy/module/_vmprof/interp_vmprof.py --- a/pypy/module/_vmprof/interp_vmprof.py +++ b/pypy/module/_vmprof/interp_vmprof.py @@ -3,7 +3,7 @@ from pypy.interpreter.pyframe import PyFrame from pypy.interpreter.pycode import PyCode from pypy.interpreter.baseobjspace import W_Root -from rpython.rlib import rvmprof +from rpython.rlib import rvmprof, jit # ____________________________________________________________ @@ -77,6 +77,7 @@ except rvmprof.VMProfError, e: raise VMProfError(space, e) +@jit.dont_look_inside def disable_jitlog(space): """ Disable PyPy's logging facility. """ rvmprof.disable_jitlog() diff --git a/rpython/jit/backend/llsupport/assembler.py b/rpython/jit/backend/llsupport/assembler.py --- a/rpython/jit/backend/llsupport/assembler.py +++ b/rpython/jit/backend/llsupport/assembler.py @@ -13,6 +13,7 @@ from rpython.rlib.jitlog import _log_jit_counter from rpython.rtyper.annlowlevel import cast_instance_to_gcref, llhelper from rpython.rtyper.lltypesystem import rffi, lltype +from rpython.rlib.rvmprof.rvmprof import _get_vmprof DEBUG_COUNTER = lltype.Struct('DEBUG_COUNTER', # 'b'ridge, 'l'abel or # 'e'ntry point @@ -134,7 +135,9 @@ # if self._debug is already set it means that someone called # set_debug by hand before initializing the assembler. Leave it # as it is - self.set_debug(have_debug_prints_for('jit-backend-counts')) + should_debug = have_debug_prints_for('jit-backend-counts') or \ + _get_vmprof().cintf.jitlog_enabled() + self.set_debug(should_debug) # when finishing, we only have one value at [0], the rest dies self.gcmap_for_finish = lltype.malloc(jitframe.GCMAP, 1, flavor='raw', diff --git a/rpython/jit/backend/llsupport/test/ztranslation_test.py b/rpython/jit/backend/llsupport/test/ztranslation_test.py --- a/rpython/jit/backend/llsupport/test/ztranslation_test.py +++ b/rpython/jit/backend/llsupport/test/ztranslation_test.py @@ -12,6 +12,7 @@ from rpython.config.config import ConfigError from rpython.translator.tool.cbuild import ExternalCompilationInfo from rpython.rtyper.lltypesystem import lltype, rffi +from rpython.rlib import jitlog class TranslationTest(CCompiledMixin): @@ -240,6 +241,23 @@ assert res == 2 # one for loop and one for the prologue, no unrolling + def test_flush_trace_counts(self): + driver = JitDriver(greens = [], reds = ['i']) + + def f(): + i = 0 + while i < 100000: + driver.jit_merge_point(i=i) + i += 1 + + def main(): + jit_hooks.stats_set_debug(None, True) + f() + jitlog.stats_flush_trace_counts(None) + return 0 + + res = self.meta_interp(main, []) + assert res == 0 class TranslationRemoveTypePtrTest(CCompiledMixin): CPUClass = getcpuclass() diff --git a/rpython/jit/backend/x86/assembler.py b/rpython/jit/backend/x86/assembler.py --- a/rpython/jit/backend/x86/assembler.py +++ b/rpython/jit/backend/x86/assembler.py @@ -493,8 +493,9 @@ clt.frame_info.clear() # for now if log: + number = looptoken.number operations = self._inject_debugging_code(looptoken, operations, - 'e', looptoken.number) + 'e', number) regalloc = RegAlloc(self, self.cpu.translate_support_code) # diff --git a/rpython/jit/backend/x86/runner.py b/rpython/jit/backend/x86/runner.py --- a/rpython/jit/backend/x86/runner.py +++ b/rpython/jit/backend/x86/runner.py @@ -2,7 +2,6 @@ from rpython.rtyper.lltypesystem import lltype, llmemory, rffi from rpython.rlib.jit_hooks import LOOP_RUN_CONTAINER from rpython.rlib import rgc -from rpython.jit.metainterp.debug import debug_sd from rpython.jit.backend.x86.assembler import Assembler386 from rpython.jit.backend.x86.regalloc import gpr_reg_mgr_cls, xmm_reg_mgr_cls from rpython.jit.backend.x86.profagent import ProfileAgent @@ -115,9 +114,10 @@ looptoken.compiled_loop_token.invalidate_positions = [] def get_all_loop_runs(self): + asm = self.assembler l = lltype.malloc(LOOP_RUN_CONTAINER, - len(debug_sd.loop_run_counters)) - for i, ll_s in enumerate(debug_sd.loop_run_counters): + len(asm.loop_run_counters)) + for i, ll_s in enumerate(asm.loop_run_counters): l[i].type = ll_s.type l[i].number = ll_s.number l[i].counter = ll_s.i diff --git a/rpython/jit/metainterp/compile.py b/rpython/jit/metainterp/compile.py --- a/rpython/jit/metainterp/compile.py +++ b/rpython/jit/metainterp/compile.py @@ -526,9 +526,7 @@ patch_new_loop_to_load_virtualizable_fields(loop, jitdriver_sd, vable) original_jitcell_token = loop.original_jitcell_token - globaldata = metainterp_sd.globaldata - original_jitcell_token.number = n = globaldata.loopnumbering - globaldata.loopnumbering += 1 + original_jitcell_token.number = n = metainterp_sd.jitlog.trace_id if not we_are_translated(): show_procedures(metainterp_sd, loop) diff --git a/rpython/jit/metainterp/pyjitpl.py b/rpython/jit/metainterp/pyjitpl.py --- a/rpython/jit/metainterp/pyjitpl.py +++ b/rpython/jit/metainterp/pyjitpl.py @@ -1931,7 +1931,6 @@ self.initialized = False self.indirectcall_dict = None self.addr2name = None - self.loopnumbering = 0 # ____________________________________________________________ diff --git a/rpython/jit/metainterp/test/test_compile.py b/rpython/jit/metainterp/test/test_compile.py --- a/rpython/jit/metainterp/test/test_compile.py +++ b/rpython/jit/metainterp/test/test_compile.py @@ -52,7 +52,7 @@ return 'location' class FakeGlobalData(object): - loopnumbering = 0 + pass class FakeMetaInterpStaticData(object): all_descrs = [] @@ -80,8 +80,8 @@ cpu = FakeCPU() staticdata = FakeMetaInterpStaticData() staticdata.cpu = cpu - staticdata.globaldata = FakeGlobalData() - staticdata.globaldata.loopnumbering = 1 + staticdata.jitlog = jl.VMProfJitLogger(cpu) + staticdata.jitlog.trace_id = 1 # loop = parse(''' [p1] @@ -108,8 +108,7 @@ jitcell_token = target_token.targeting_jitcell_token assert jitcell_token == target_token.original_jitcell_token assert jitcell_token.target_tokens == [target_token] - assert jitcell_token.number == 1 - assert staticdata.globaldata.loopnumbering == 2 + assert jitcell_token.number == 2 # assert len(cpu.seen) == 1 assert cpu.seen[0][2] == jitcell_token diff --git a/rpython/rlib/jitlog.py b/rpython/rlib/jitlog.py --- a/rpython/rlib/jitlog.py +++ b/rpython/rlib/jitlog.py @@ -17,9 +17,7 @@ @register_helper(None) def stats_flush_trace_counts(warmrunnerdesc): - print("hello") warmrunnerdesc.metainterp_sd.cpu.assembler.flush_trace_counters() - return True def commonprefix(a,b): "Given a list of pathnames, returns the longest common leading component" @@ -235,11 +233,13 @@ cintf = _get_vmprof().cintf if not cintf.jitlog_enabled(): return - le_addr = encode_le_addr(struct.number) - # not an address (but a number) but it is a machine word - le_count = encode_le_addr(struct.i) - out = le_addr + le_count - cintf.jitlog_write_marked(MARK_JITLOG_COUNTER + out, len(out) + 1) + # addr is either a number (trace_id), or the address + # of the descriptor. for entries it is a the trace_id, + # for any label/bridge entry the addr is the address + list = [MARK_JITLOG_COUNTER, encode_le_addr(struct.number), + struct.type, encode_le_64bit(struct.i)] + content = ''.join(list) + cintf.jitlog_write_marked(content, len(content)) class VMProfJitLogger(object): def __init__(self, cpu=None): @@ -265,10 +265,11 @@ self.cintf.jitlog_teardown() def start_new_trace(self, metainterp_sd, faildescr=None, entry_bridge=False): + # even if the logger is not enabled, increment the trace id + self.trace_id += 1 if not self.cintf.jitlog_enabled(): return self.metainterp_sd = metainterp_sd - self.trace_id += 1 content = [encode_le_addr(self.trace_id)] if faildescr: content.append(encode_str('bridge')) diff --git a/rpython/rlib/rvmprof/rvmprof.py b/rpython/rlib/rvmprof/rvmprof.py --- a/rpython/rlib/rvmprof/rvmprof.py +++ b/rpython/rlib/rvmprof/rvmprof.py @@ -122,6 +122,7 @@ raise VMProfError(os.strerror(rposix.get_saved_errno())) self.is_enabled = True + @jit.dont_look_inside def enable_jitlog(self, fileno): # initialize the jit log from rpython.rlib import jitlog as jl _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit