Esempio n. 1
0
    def test_on_abort(self):
        import pypyjit
        l = []

        def hook(jitdriver_name, greenkey, reason):
            l.append((jitdriver_name, reason))

        pypyjit.set_abort_hook(hook)
        self.on_abort()
        assert l == [('pypyjit', 'ABORT_TOO_LONG')]
Esempio n. 2
0
    def test_on_abort(self):
        import pypyjit
        l = []

        def hook(jitdriver_name, greenkey, reason, operations):
            l.append((jitdriver_name, reason, operations))

        pypyjit.set_abort_hook(hook)
        self.on_abort()
        assert l == [('pypyjit', 'ABORT_TOO_LONG', [])]
Esempio n. 3
0
    def test_on_abort(self):
        import pypyjit
        l = []

        def hook(jitdriver_name, greenkey, reason, operations):
            l.append((jitdriver_name, reason, operations))

        pypyjit.set_abort_hook(hook)
        self.on_abort()
        assert len(l) == 1
        name, reason, ops = l[0]
        assert name == 'pypyjit'
        assert reason == 'ABORT_TOO_LONG'
        assert len(ops) == 4
        assert ops[2].hash == 0
Esempio n. 4
0
    def enable(self, profile):
        pypyjit.set_compile_hook(self.on_compile)
        pypyjit.set_abort_hook(self.on_abort)
        self._backup_stdout = sys.stdout
        self._backup_stderr = sys.stderr
        sys.stdout = RecordingStream(sys.stdout)
        sys.stderr = RecordingStream(sys.stderr)

        self.options["build"]["gc"] = sys.pypy_translation_info["translation.gc"]
        self.options["build"]["gcrootfinder"] = sys.pypy_translation_info["translation.gcrootfinder"]
        self.options["build"]["pypy_version"] = sys._mercurial[2]

        if profile:
            self._profile_mmaps = []
            self._new_mmap()
            sys.setprofile(self.on_profile)

        self._start_time = high_res_time()
Esempio n. 5
0
    def disable(self, profile):
        self._end_time = high_res_time()
        self.runtime = self._end_time - self._start_time
        del self._start_time

        if profile:
            sys.setprofile(None)

        pypyjit.set_compile_hook(None)
        pypyjit.set_abort_hook(None)

        self.stdout = sys.stdout._content.getvalue()
        self.stderr = sys.stderr._content.getvalue()
        sys.stdout = self._backup_stdout
        sys.stderr = self._backup_stderr
        del self._backup_stdout
        del self._backup_stderr

        if profile:
            self._find_calls()
        del self._end_time
Esempio n. 6
0
            print dir(op.pycode)
            print op.pycode.co_code
        print dir(op)


def hook2(*args):
    l2.append(args)


def hook3(*args):
    l3.append(args)


pypyjit.set_compile_hook(hook)
pypyjit.set_optimize_hook(hook2)
pypyjit.set_abort_hook(hook3)
runpy.run_path(sys.argv[1])
pypyjit.set_compile_hook(None)
pypyjit.set_optimize_hook(None)
pypyjit.set_abort_hook(None)

for jitdriver_name, loop_type, greenkey, operations, assembler_addr, assembler_length in l:
    storage = LoopStorage()
    try:
        code = storage.load_code(loop.filename)[(loop.startlineno, loop.name)]
        if code.co_name == "<module>" and code.co_firstlineno == 1:
            with open(code.co_filename) as f:
                source = CodeRepr(f.read(), code, loop)
        else:
            source = CodeRepr(inspect.getsource(code), code, loop)
    except (IOError, OSError):
Esempio n. 7
0
    logging.debug("%d, Elapsed TPS: %d, Elapsed: %f" % (count, int(count/(t1 - tstart)), (t1-tstart)))

import sys

def bork(name, greenkey, reason):
    print "ABORTED: ", name, greenkey,reason
def optimize(name, loop, greenkey, operations):
    print "OPTIMIZE: ", name, loop, greenkey
def chook(jitdriver_name, loop_type, greenkey, operations, assembler_addr, assembler_length):
    if loop_type == 'entry bridge':
        print "COMPILE: ", loop_type, greenkey

if __name__ == '__main__':

    if False:
        import pypyjit
        pypyjit.set_abort_hook(bork)
        pypyjit.set_optimize_hook(optimize)
        pypyjit.set_compile_hook(chook)

    #dumbtest()
    #sys.exit(0)

    logging.basicConfig(level=logging.DEBUG)
    fd = sys.stdin
    outfd = sys.stdout
    byline(fd, outfd)
    #at = SQLexer()
    #for i in range(128):
    #    print i, chr(i), at.map_main_alt[i]