示例#1
0
    def test_new_code_hook(self):
        l = []

        def callable(code):
            l.append(code)

        import __pypy__
        __pypy__.set_code_callback(callable)
        d = {}
        try:
            exec """
def f():
    pass
""" in d
        finally:
            __pypy__.set_code_callback(None)
        assert d['f'].__code__ in l
示例#2
0
    def test_new_code_hook(self):
        l = []

        def callable(code):
            l.append(code)

        import __pypy__
        __pypy__.set_code_callback(callable)
        d = {}
        try:
            exec """
def f():
    pass
""" in d
        finally:
            __pypy__.set_code_callback(None)
        assert d['f'].__code__ in l
示例#3
0
    def test_new_code_hook(self):
        # workaround for running on top of old CPython 2.7 versions
        def exec_(code, d):
            exec(code, d)

        l = []

        def callable(code):
            l.append(code)

        import __pypy__
        __pypy__.set_code_callback(callable)
        d = {}
        try:
            exec_("""
def f():
    pass
""", d)
        finally:
            __pypy__.set_code_callback(None)
        assert d['f'].__code__ in l
示例#4
0
                            if 'guard' in repr(op):
                                pypyjit.trace_next_iteration_hash(op.hash)
                                m = re.search('Guard(0x[0-9a-f]+)', repr(op))
                                self._lookup[int(m.group(1), 16)] = s[i]
                    
            #print self._lookup[loopinfo.bridge_no] in self._trace_bridges
#            self._trace_bridges[(hash(gkey[0]), gkey[1])] = set()
            #import pdb
            #pdb.set_trace()
#        else:
#            print loopinfo.bridge_no

    def finish(self):
        with open("tracedata.py", "w") as f:
            f.write("trace_too_long = set([")
            for k in self._trace_too_long_set:
                f.write(repr(k) + ", ")
            f.write("])\n")
            f.write("trace_immediately = {}\n")
            for k, v in self._trace_immediately.iteritems():
                f.write("trace_immediately[%d] = set([%s])\n" %
                        (k, ", ".join([repr(x) for x in v])))

tracer = Tracer()

pypyjit.set_trace_too_long_hook(tracer.trace_too_long)
pypyjit.set_compile_hook(tracer.on_compile, operations=True)
__pypy__.set_code_callback(tracer.code_callback)

atexit.register(tracer.finish)