def test_to_json_meta_bridges(): forest = TraceForest(1) forest.resops = {15: 'guard_true'} trunk = forest.add_trace('loop', 0, 0) bridge1 = forest.add_trace('bridge', 1, 0) bridge2 = forest.add_trace('bridge', 2, 0) bridge3 = forest.add_trace('bridge', 3, 0) forest.descr_nmr_to_point_in_trace[10] = PointInTrace(trunk, None) forest.descr_nmr_to_point_in_trace[11] = PointInTrace(trunk, None) forest.descr_nmr_to_point_in_trace[12] = PointInTrace(bridge1, None) forest.descr_nmr_to_point_in_trace[13] = PointInTrace(bridge2, None) # trunk.set_addr_bounds(99, 100) bridge1.set_addr_bounds(100, 101) bridge2.set_addr_bounds(200, 201) bridge3.set_addr_bounds(300, 301) # forest.stitch_bridge(10, 100) forest.stitch_bridge(11, 200) forest.stitch_bridge(12, 300) # stage = trunk.start_mark(const.MARK_TRACE_OPT) j = LogMetaSerializer().to_representation(FakeJitLog(forest)) assert len(j['bridges']) == 4 bridges = j['bridges'] assert bridges[0] == {10: 100, 11: 200} assert bridges[1] == {12: 300} assert bridges[2] == {} assert bridges[3] == {}
def test_to_json_meta_links(): forest = TraceForest(1) forest.resops = { 15: 'guard_true' } trunk = forest.add_trace('loop', 0, 0) bridge1 = forest.add_trace('bridge', 1, 0) bridge2 = forest.add_trace('bridge', 2, 0) bridge3 = forest.add_trace('bridge', 3, 0) op = FlatOp(0,'',[],None,0,0) op.index = 42 forest.descr_nmr_to_point_in_trace[10] = PointInTrace(trunk, op) forest.descr_nmr_to_point_in_trace[11] = PointInTrace(trunk, None) forest.descr_nmr_to_point_in_trace[12] = PointInTrace(bridge1, None) forest.descr_nmr_to_point_in_trace[13] = PointInTrace(bridge2, None) # trunk.set_addr_bounds(99,100) bridge1.set_addr_bounds(100,101) bridge2.set_addr_bounds(200,201) bridge3.set_addr_bounds(300,301) # forest.stitch_bridge(10, 100) forest.stitch_bridge(11, 200) forest.stitch_bridge(12, 300) # stage = trunk.start_mark(const.MARK_TRACE_OPT) j = LogMetaSerializer().to_representation(forest) assert len(j['links']) == 2 links = j['links'] assert links[0] == {42: 1, 0: 2} assert links[1] == {0: 3}
def test_failing_guard(): forest = TraceForest(3) trace = forest.add_trace('loop', 0, 0) trace.start_mark(const.MARK_TRACE_ASM) op = FlatOp(0, 'gurad_true', '', 'i0', 0, 15) trace.add_instr(op) # trace2 = forest.add_trace('bridge', 16, 0) trace2.start_mark(const.MARK_TRACE_OPT) trace2.set_addr_bounds(42,44) # forest.stitch_bridge(15, 42) assert trace2.get_failing_guard() == op
def test_failing_guard(): forest = TraceForest(3) trace = forest.add_trace('loop', 0, 0) trace.start_mark(const.MARK_TRACE_ASM) op = FlatOp(0, 'gurad_true', '', 'i0', 0, 15) trace.add_instr(op) # trace2 = forest.add_trace('bridge', 16, 0) trace2.start_mark(const.MARK_TRACE_OPT) trace2.set_addr_bounds(42, 44) # forest.stitch_bridge(15, 42) assert trace2.get_failing_guard() == op