Author: Richard Plangger <planri...@gmail.com> Branch: new-jit-log Changeset: r83773:37892687f8b9 Date: 2016-04-19 15:27 +0200 http://bitbucket.org/pypy/pypy/changeset/37892687f8b9/
Log: refactoring simplifies the logging of a trace. now (just for the purpose of the jitlog) there is a unique id for each traces which makes parsing also easier 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 @@ -544,7 +544,7 @@ looptoken._ll_function_addr = rawstart + functionpos if logger: log = logger.log_trace(MARK_TRACE_ASM, None, self.mc) - log.write(inputargs, operations, None, ops_offset=ops_offset, unique_id=rawstart) + log.write(inputargs, operations, ops_offset=ops_offset) self.fixup_target_tokens(rawstart) self.teardown() @@ -611,7 +611,7 @@ frame_depth_no_fixed_size + JITFRAME_FIXED_SIZE) if logger: log = logger.log_trace(MARK_TRACE_ASM, None, self.mc) - log.write(inputargs, operations, faildescr, ops_offset, unique_id=rawstart) + log.write(inputargs, operations, ops_offset) self.fixup_target_tokens(rawstart) self.update_frame_depth(frame_depth) self.teardown() 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 @@ -478,10 +478,7 @@ def do_compile_loop(jd_id, unique_id, metainterp_sd, inputargs, operations, looptoken, log=True, name='', memo=None): _log = metainterp_sd.jitlog.log_trace(MARK_TRACE_OPT, metainterp_sd, None) - _log.write(inputargs, operations, None, name=name, unique_id=unique_id) - # TODO remove old - metainterp_sd.logger_ops.log_loop(inputargs, operations, -2, - 'compiling', None, name, memo) + _log.write(inputargs, operations) return metainterp_sd.cpu.compile_loop(inputargs, operations, looptoken, jd_id=jd_id, unique_id=unique_id, @@ -491,10 +488,7 @@ def do_compile_bridge(metainterp_sd, faildescr, inputargs, operations, original_loop_token, log=True, memo=None): _log = metainterp_sd.jitlog.log_trace(MARK_TRACE_OPT, metainterp_sd, None) - _log.write(inputargs, operations, faildescr) - # TODO remove old - metainterp_sd.logger_ops.log_bridge(inputargs, operations, "compiling", - memo=memo) + _log.write(inputargs, operations) assert isinstance(faildescr, AbstractFailDescr) return metainterp_sd.cpu.compile_bridge(faildescr, inputargs, operations, original_loop_token, log=log, @@ -510,6 +504,7 @@ def send_loop_to_backend(greenkey, jitdriver_sd, metainterp_sd, loop, type, orig_inpargs, memo): + metainterp_sd.jitlog.start_new_trace(None, type == "entry bridge") forget_optimization_info(loop.operations) forget_optimization_info(loop.inputargs) vinfo = jitdriver_sd.virtualizable_info @@ -571,6 +566,7 @@ def send_bridge_to_backend(jitdriver_sd, metainterp_sd, faildescr, inputargs, operations, original_loop_token, memo): + metainterp_sd.jitlog.start_new_trace(faildescr) forget_optimization_info(operations) forget_optimization_info(inputargs) if not we_are_translated(): 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 @@ -31,6 +31,7 @@ MARK_STITCH_BRIDGE = 0x19 MARK_JITLOG_COUNTER = 0x20 +MARK_START_TRACE = 0x21 MARK_JITLOG_HEADER = 0x23 MARK_JITLOG_DEBUG_MERGE_POINT = 0x24 @@ -84,6 +85,7 @@ def __init__(self): self.cintf = cintf.setup() self.memo = {} + self.trace_id = 0 def setup_once(self): if self.cintf.jitlog_enabled(): @@ -97,6 +99,20 @@ def finish(self): self.cintf.jitlog_teardown() + def start_new_trace(self, faildescr=None, entry_bridge=False): + if not self.cintf.jitlog_enabled(): + return + content = [encode_le_addr(self.trace_id)] + if faildescr: + content.append(encode_str('bridge')) + descrnmr = compute_unique_id(faildescr) + content.append(encode_le_addr(descrnmr)) + else: + content.append(encode_str('loop')) + content.append(encode_le_addr(int(entry_bridge))) + self.cintf._write_marked(MARK_START_TRACE, ''.join(content)) + self.trace_id += 1 + def _write_marked(self, mark, line): if not we_are_translated(): assert self.cintf.jitlog_enabled() @@ -127,7 +143,10 @@ self._write_marked(MARK_STITCH_BRIDGE, ''.join(lst)) class BaseLogTrace(object): - def write(self, args, ops, faildescr=None, ops_offset={}, name=None, unique_id=0): + def write_trace(self, trace): + return None + + def write(self, args, ops, ops_offset={}): return None EMPTY_TRACE_LOG = BaseLogTrace() @@ -143,25 +162,16 @@ self.mc = mc self.logger = logger - def write(self, args, ops, faildescr=None, ops_offset={}, - name=None, unique_id=0): + def write_trace(self, trace): + ops = [] + i = trace.get_iter() + while not i.done(): + ops.append(i.next()) + self.write(i.inputargs, ops) + + def write(self, args, ops, faildescr=None, ops_offset={}): log = self.logger - - if name is None: - name = '' - # write the initial tag - if faildescr is None: - string = encode_str('loop') + \ - encode_le_addr(unique_id) + \ - encode_str(name or '') - log._write_marked(self.tag, string) - else: - descr_number = compute_unique_id(faildescr) - string = encode_str('bridge') + \ - encode_le_addr(descr_number) + \ - encode_le_addr(unique_id) + \ - encode_str(name or '') - log._write_marked(self.tag, string) + log._write_marked(self.tag, encode_le_addr(self.trace_id)) # input args str_args = [self.var_to_str(arg) for arg in args] @@ -191,11 +201,11 @@ jd_sd = self.metainterp_sd.jitdrivers_sd[op.getarg(0).getint()] filename, lineno, enclosed, index, opname = jd_sd.warmstate.get_location(op.getarglist()[3:]) line = [] - line.append(encode_str(filename)) + line.append(encode_str(filename or "")) line.append(encode_le_16bit(lineno)) - line.append(encode_str(enclosed)) + line.append(encode_str(enclosed or "")) line.append(encode_le_64bit(index)) - line.append(encode_str(opname)) + line.append(encode_str(opname or "")) log._write_marked(MARK_JITLOG_DEBUG_MERGE_POINT, ''.join(line)) 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,9 +54,9 @@ """ debug_start("jit-optimize") try: - # TODO missing the unique id - # TODO log = metainterp_sd.jitlog.log_trace(MARK_TRACE, metainterp_sd, None) - # TODO log.write(inputargs, compile_data.operations) + # mark that a new trace has been started + log = metainterp_sd.jitlog.log_trace(MARK_TRACE, metainterp_sd, None) + log.write_trace(compile_data.trace) if compile_data.log_noopt: metainterp_sd.logger_noopt.log_loop_from_trace(compile_data.trace, memo=memo) if memo is None: diff --git a/rpython/jit/metainterp/warmspot.py b/rpython/jit/metainterp/warmspot.py --- a/rpython/jit/metainterp/warmspot.py +++ b/rpython/jit/metainterp/warmspot.py @@ -564,6 +564,7 @@ def make_driverhook_graphs(self): s_Str = annmodel.SomeString() + s_Str_None = annmodel.SomeString(can_be_None=True) s_Int = annmodel.SomeInteger() # annhelper = MixLevelHelperAnnotator(self.translator.rtyper) @@ -580,7 +581,7 @@ jd._should_unroll_one_iteration_ptr = self._make_hook_graph(jd, annhelper, jd.jitdriver.should_unroll_one_iteration, annmodel.s_Bool) - s_Tuple = annmodel.SomeTuple([s_Str, s_Int, s_Str, s_Int, s_Str]) + s_Tuple = annmodel.SomeTuple([s_Str_None, s_Int, s_Str_None, s_Int, s_Str_None]) jd._get_location_ptr = self._make_hook_graph(jd, annhelper, jd.jitdriver.get_location, s_Tuple) annhelper.finish() _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit