예제 #1
0
def parse_bound(ss, n):
    addr = syntax.parse_int(ss[n])
    bound = ss[n + 1]
    if bound == "None":
        bound = None
        return (n + 3, (addr, None))
    else:
        bound = syntax.parse_int(bound)
        kind = ss[n + 2]
        return (n + 3, (addr, (bound, kind)))
예제 #2
0
def parse_bound(ss, n):
    addr = syntax.parse_int(ss[n])
    bound = ss[n + 1]
    if bound == 'None':
        bound = None
        return (n + 3, (addr, None))
    else:
        bound = syntax.parse_int(bound)
        kind = ss[n + 2]
        return (n + 3, (addr, (bound, kind)))
예제 #3
0
def parse_ctxt_id(bits, n):
    return (n + 1, syntax.parse_int(bits[n]))
예제 #4
0
def load_bounds():
    try:
        f = open("%s/LoopBounds.txt" % target_objects.target_dir)
        ls = list(f)
        f.close()
    except IOError, e:
        ls = []
    from syntax import parse_int, parse_list

    for l in ls:
        bits = l.split()
        if bits[:1] not in [["LoopBound"], ["GlobalLoopBound"]]:
            continue
        (n, (addr, bound)) = parse_bound(bits, 1)
        (n, ctxt) = parse_ctxt(bits, n)
        prob_hash = parse_int(bits[n])
        n += 1
        if bits[0] == "LoopBound":
            (n, prev_bounds) = parse_list(parse_bound, bits, n)
            assert n == len(bits), bits
            known = known_bounds.setdefault(addr, [])
            known.append((ctxt, prob_hash, prev_bounds, bound))
        else:
            assert n == len(bits), bits
            known = known_bounds.setdefault((addr, "Global"), [])
            known.append((ctxt, prob_hash, bound))
    known_bounds["Loaded"] = True


def get_bound_ctxt(split, call_ctxt):
    trace("Getting bound for 0x%x in context %s." % (split, call_ctxt))
예제 #5
0
def parse_ctxt_id(bits, n):
    return (n + 1, syntax.parse_int(bits[n]))
예제 #6
0
def load_bounds():
    try:
        f = open('%s/LoopBounds.txt' % target_objects.target_dir)
        ls = list(f)
        f.close()
    except IOError, e:
        ls = []
    from syntax import parse_int, parse_list
    for l in ls:
        bits = l.split()
        if bits[:1] not in [['LoopBound'], ['GlobalLoopBound']]:
            continue
        (n, (addr, bound)) = parse_bound(bits, 1)
        (n, ctxt) = parse_ctxt(bits, n)
        prob_hash = parse_int(bits[n])
        n += 1
        if bits[0] == 'LoopBound':
            (n, prev_bounds) = parse_list(parse_bound, bits, n)
            assert n == len(bits), bits
            known = known_bounds.setdefault(addr, [])
            known.append((ctxt, prob_hash, prev_bounds, bound))
        else:
            assert n == len(bits), bits
            known = known_bounds.setdefault((addr, 'Global'), [])
            known.append((ctxt, prob_hash, bound))
    known_bounds['Loaded'] = True


def get_bound_ctxt(split, call_ctxt, use_cache=True):
    trace('Getting bound for 0x%x in context %s.' % (split, call_ctxt))