Author: Richard Plangger <planri...@gmail.com> Branch: new-jit-log Changeset: r82584:ed87960a6c98 Date: 2016-02-26 19:13 +0100 http://bitbucket.org/pypy/pypy/changeset/ed87960a6c98/
Log: finished a first (not yet compiling) version that both writes loops and bridges in a more condensed format 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 @@ -532,8 +532,8 @@ looptoken._x86_ops_offset = ops_offset looptoken._ll_function_addr = rawstart if logger: - logger.log_loop(inputargs, operations, 0, "rewritten", - name=loopname, ops_offset=ops_offset) + logger.log_trace(logger.MARK_ASM, inputargs, operations, + ops_offset=ops_offset) self.fixup_target_tokens(rawstart) self.teardown() @@ -587,8 +587,8 @@ frame_depth = max(self.current_clt.frame_info.jfi_frame_depth, frame_depth_no_fixed_size + JITFRAME_FIXED_SIZE) if logger: - logger.log_bridge(inputargs, operations, "rewritten", faildescr, - ops_offset=ops_offset) + logger.log_trace(logger.MARK_ASM, inputargs, operations, + faildescr=faildescr, ops_offset=ops_offset) self.fixup_target_tokens(rawstart) self.update_frame_depth(frame_depth) self.teardown() diff --git a/rpython/jit/metainterp/jitlog.py b/rpython/jit/metainterp/jitlog.py --- a/rpython/jit/metainterp/jitlog.py +++ b/rpython/jit/metainterp/jitlog.py @@ -1,22 +1,46 @@ from rpython.rlib.rvmprof.rvmprof import cintf class VMProfJitLogger(object): + + MARK_BLOCK_ASM = 0x10 + + MARK_INPUT_ARGS = 0x11 + MARK_RESOP = 0x12 + + MARK_RESOP_META = 0x13 + def __init__(self): self.cintf = cintf.setup() - def _ensure_init(self): + def setup_once(self): self.cintf.jitlog_try_init_using_env() + if self.cintf.jitlog_filter(0x0): + return + self.cintf.jitlog_write_marker(MARK_RESOP_META); + count = len(resoperation.opname) + self.cintf.jitlog_write_int(count) + for opnum, opname in resoperation.opname.items(): + self.cintf.write_marker(opnum) + self.cintf.write_string(opname) - self.cintf.write_marker(BinaryJitLogger.JIT_META_MARKER) - count = len(resoperation.opname) - assert count < 256 - self.cintf.write_marker(count) - for opnum, opname in resoperation.opname.items(): - self.cintf.write_byte(opnum) - self.cintf.write_string(opnum) + def log_trace(self, tag, args, ops, + faildescr=None, ops_offset={}): + if self.cintf.jitlog_filter(tag): + return + assert isinstance(tag, int) + self.cintf.jitlog_write_marker(tag); - def log_loop(self, operations): - pass + # input args + self.cintf.jitlog_write_marker(MARK_INPUT_ARGS); + str_args = [arg.repr_short(arg._repr_memo) for arg in args] + self.cintf.jitlog_write_string(','.join(str_args)) - def _log_resoperation(self, op): - pass + self.cintf.jitlog_write_int(len(ops)) + for i,op in enumerate(ops): + self.cintf.jitlog_write_marker(MARK_RESOP) + self.cintf.jitlog_write_marker(op.getopnum()) + str_args = [arg.repr_short(arg._repr_memo) for arg in op.getarglist()] + descr = op.getdescr() + if descr: + str_args += ['descr='+descr] + self.cintf.jitlog_write_string(','.join(str_args)) diff --git a/rpython/jit/metainterp/optimizeopt/__init__.py b/rpython/jit/metainterp/optimizeopt/__init__.py --- a/rpython/jit/metainterp/optimizeopt/__init__.py +++ b/rpython/jit/metainterp/optimizeopt/__init__.py @@ -54,7 +54,6 @@ debug_start("jit-optimize") inputargs = compile_data.start_label.getarglist() try: - metainterp.jitlog.log_loop(inputargs, compile_data.operations, memo) metainterp_sd.logger_noopt.log_loop(inputargs, compile_data.operations, memo=memo) diff --git a/rpython/rlib/rvmprof/cintf.py b/rpython/rlib/rvmprof/cintf.py --- a/rpython/rlib/rvmprof/cintf.py +++ b/rpython/rlib/rvmprof/cintf.py @@ -55,6 +55,9 @@ jitlog_init = rffi.llexternal("jitlog_init", [rffi.INT, rffi.CHARP], rffi.CHARP, compilation_info=eci, save_err=rffi.RFFI_SAVE_ERRNO) + jitlog_init = rffi.llexternal("jitlog_write_marker", [rffi.INT, rffi.CHARP], + rffi.CHARP, compilation_info=eci, + save_err=rffi.RFFI_SAVE_ERRNO) return CInterface(locals()) diff --git a/rpython/rlib/rvmprof/src/jitlog_main.h b/rpython/rlib/rvmprof/src/jitlog_main.h --- a/rpython/rlib/rvmprof/src/jitlog_main.h +++ b/rpython/rlib/rvmprof/src/jitlog_main.h @@ -5,6 +5,12 @@ static int jitlog_ready = 0; RPY_EXTERN +int jitlog_filter(int tag) +{ + return 0; // TODO +} + +RPY_EXTERN void jitlog_try_init_using_env(void) { if (jitlog_ready) { return; } diff --git a/rpython/rlib/rvmprof/src/rvmprof.h b/rpython/rlib/rvmprof/src/rvmprof.h --- a/rpython/rlib/rvmprof/src/rvmprof.h +++ b/rpython/rlib/rvmprof/src/rvmprof.h @@ -11,3 +11,4 @@ RPY_EXTERN char * jitlog_init(int, char*); RPY_EXTERN void jitlog_try_init_using_env(void); +RPY_EXTERN int jitlog_filter(int tag); _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit