Example #1
0
 def entry_point(argv):
     x = "got:"
     debug_start("mycat")
     if have_debug_prints(): x += "b"
     debug_print("foo", 2, "bar", 3)
     debug_start("cat2")
     if have_debug_prints(): x += "c"
     debug_print("baz")
     debug_stop("cat2")
     if have_debug_prints(): x += "d"
     debug_print("bok")
     debug_stop("mycat")
     if have_debug_prints(): x += "a"
     debug_print("toplevel")
     os.write(1, x + '.\n')
     return 0
Example #2
0
 def entry_point(argv):
     x = "got:"
     debug_start  ("mycat")
     if have_debug_prints(): x += "b"
     debug_print    ("foo", 2, "bar", 3)
     debug_start      ("cat2")
     if have_debug_prints(): x += "c"
     debug_print        ("baz")
     debug_stop       ("cat2")
     if have_debug_prints(): x += "d"
     debug_print    ("bok")
     debug_stop   ("mycat")
     if have_debug_prints(): x += "a"
     debug_print("toplevel")
     os.write(1, x + '.\n')
     return 0
Example #3
0
 def _dump(self, addr, logname, backend=None):
     debug_start(logname)
     if have_debug_prints():
         #
         if backend is not None:
             debug_print('BACKEND', backend)
         #
         from pypy.jit.backend.hlinfo import highleveljitinfo
         if highleveljitinfo.sys_executable:
             debug_print('SYS_EXECUTABLE', highleveljitinfo.sys_executable)
         #
         HEX = '0123456789ABCDEF'
         dump = []
         src = rffi.cast(rffi.CCHARP, addr)
         for p in range(self.get_relative_pos()):
             o = ord(src[p])
             dump.append(HEX[o >> 4])
             dump.append(HEX[o & 15])
         debug_print(
             'CODE_DUMP',
             '@%x' % addr,
             '+0 ',  # backwards compatibility
             ''.join(dump))
         #
     debug_stop(logname)
Example #4
0
def dump_storage(storage, liveboxes):
    "For profiling only."
    from pypy.rlib.objectmodel import compute_unique_id
    debug_start("jit-resume")
    if have_debug_prints():
        debug_print('Log storage', compute_unique_id(storage))
        frameinfo = storage.rd_frame_info_list
        while frameinfo is not None:
            try:
                jitcodename = frameinfo.jitcode.name
            except AttributeError:
                jitcodename = str(compute_unique_id(frameinfo.jitcode))
            debug_print('\tjitcode/pc', jitcodename,
                        frameinfo.pc, frameinfo.exception_target,
                        'at', compute_unique_id(frameinfo))
            frameinfo = frameinfo.prev
        numb = storage.rd_numb
        while numb is not None:
            debug_print('\tnumb', str([untag(i) for i in numb.nums]),
                        'at', compute_unique_id(numb))
            numb = numb.prev
        for const in storage.rd_consts:
            debug_print('\tconst', const.repr_rpython())
        for box in liveboxes:
            if box is None:
                debug_print('\tbox', 'None')
            else:
                debug_print('\tbox', box.repr_rpython())
        if storage.rd_virtuals is not None:
            for virtual in storage.rd_virtuals:
                if virtual is None:
                    debug_print('\t\t', 'None')
                else:
                    virtual.debug_prints()
    debug_stop("jit-resume")
Example #5
0
 def f(x):
     debug_start("mycat")
     debug_print("foo", 2, "bar", x)
     debug_stop("mycat")
     debug_flush() # does nothing
     debug_offset() # should not explode at least
     return have_debug_prints()
Example #6
0
 def _log_operations(self, inputargs, operations):
     if not have_debug_prints():
         return
     memo = {}
     if inputargs is not None:
         args = ", ".join([self.repr_of_arg(memo, arg) for arg in inputargs])
         debug_print('[' + args + ']')
     for i in range(len(operations)):
         op = operations[i]
         if op.opnum == rop.DEBUG_MERGE_POINT:
             loc = op.args[0]._get_str()
             debug_print("debug_merge_point('%s')" % (loc,))
             continue
         args = ", ".join([self.repr_of_arg(memo, arg) for arg in op.args])
         if op.result is not None:
             res = self.repr_of_arg(memo, op.result) + " = "
         else:
             res = ""
         is_guard = op.is_guard()
         if op.descr is not None:
             descr = op.descr
             if is_guard and self.guard_number:
                 index = self.metainterp_sd.cpu.get_fail_descr_number(descr)
                 r = "<Guard%d>" % index
             else:
                 r = self.repr_of_descr(descr)
             args += ', descr=' +  r
         if is_guard and op.fail_args is not None:
             fail_args = ' [' + ", ".join([self.repr_of_arg(memo, arg)
                                           for arg in op.fail_args]) + ']'
         else:
             fail_args = ''
         debug_print(res + op.getopname() +
                     '(' + args + ')' + fail_args)
Example #7
0
 def _dump(self, addr, logname, backend=None):
     debug_start(logname)
     if have_debug_prints():
         #
         if backend is not None:
             debug_print('BACKEND', backend)
         #
         from pypy.jit.backend.hlinfo import highleveljitinfo
         if highleveljitinfo.sys_executable:
             debug_print('SYS_EXECUTABLE', highleveljitinfo.sys_executable)
         else:
             debug_print('SYS_EXECUTABLE', '??')
         #
         HEX = '0123456789ABCDEF'
         dump = []
         src = rffi.cast(rffi.CCHARP, addr)
         for p in range(self.get_relative_pos()):
             o = ord(src[p])
             dump.append(HEX[o >> 4])
             dump.append(HEX[o & 15])
         debug_print('CODE_DUMP',
                     '@%x' % addr,
                     '+0 ',     # backwards compatibility
                     ''.join(dump))
         #
     debug_stop(logname)
Example #8
0
 def _log_operations(self, inputargs, operations):
     if not have_debug_prints():
         return
     memo = {}
     if inputargs is not None:
         args = ", ".join(
             [self.repr_of_arg(memo, arg) for arg in inputargs])
         debug_print('[' + args + ']')
     for i in range(len(operations)):
         op = operations[i]
         if op.opnum == rop.DEBUG_MERGE_POINT:
             loc = op.args[0]._get_str()
             debug_print("debug_merge_point('%s')" % (loc, ))
             continue
         args = ", ".join([self.repr_of_arg(memo, arg) for arg in op.args])
         if op.result is not None:
             res = self.repr_of_arg(memo, op.result) + " = "
         else:
             res = ""
         is_guard = op.is_guard()
         if op.descr is not None:
             descr = op.descr
             if is_guard and self.guard_number:
                 index = self.metainterp_sd.cpu.get_fail_descr_number(descr)
                 r = "<Guard%d>" % index
             else:
                 r = self.repr_of_descr(descr)
             args += ', descr=' + r
         if is_guard and op.fail_args is not None:
             fail_args = ' [' + ", ".join(
                 [self.repr_of_arg(memo, arg)
                  for arg in op.fail_args]) + ']'
         else:
             fail_args = ''
         debug_print(res + op.getopname() + '(' + args + ')' + fail_args)
Example #9
0
 def entry_point(argv):
     x = "got:"
     debug_start  ("mycat")
     if have_debug_prints(): x += "b"
     debug_print    ("foo", r_longlong(2), "bar", 3)
     debug_start      ("cat2")
     if have_debug_prints(): x += "c"
     debug_print        ("baz")
     debug_stop       ("cat2")
     if have_debug_prints(): x += "d"
     debug_print    ("bok")
     debug_stop   ("mycat")
     if have_debug_prints(): x += "a"
     debug_print("toplevel")
     debug_flush()
     os.write(1, x + "." + str(debug_offset()) + '.\n')
     return 0
Example #10
0
 def entry_point(argv):
     x = "got:"
     debug_start  ("mycat")
     if have_debug_prints(): x += "b"
     debug_print    ("foo", r_longlong(2), "bar", 3)
     debug_start      ("cat2")
     if have_debug_prints(): x += "c"
     debug_print        ("baz")
     debug_stop       ("cat2")
     if have_debug_prints(): x += "d"
     debug_print    ("bok")
     debug_stop   ("mycat")
     if have_debug_prints(): x += "a"
     debug_print("toplevel")
     debug_flush()
     os.write(1, x + "." + str(debug_offset()) + '.\n')
     return 0
Example #11
0
    def semispace_collect(self, size_changing=False):
        debug_start("gc-collect")
        debug_print()
        debug_print(".----------- Full collection ------------------")
        start_usage = self.free - self.tospace
        debug_print("| used before collection:          ", start_usage, "bytes")
        # start_time = time.time()
        # llop.debug_print(lltype.Void, 'semispace_collect', int(size_changing))

        # Switch the spaces.  We copy everything over to the empty space
        # (self.fromspace at the beginning of the collection), and clear the old
        # one (self.tospace at the beginning).  Their purposes will be reversed
        # for the next collection.
        tospace = self.fromspace
        fromspace = self.tospace
        self.fromspace = fromspace
        self.tospace = tospace
        self.top_of_space = tospace + self.space_size
        scan = self.free = tospace
        self.starting_full_collect()
        self.collect_roots()
        if self.run_finalizers.non_empty():
            self.update_run_finalizers()
        scan = self.scan_copied(scan)
        if self.objects_with_finalizers.non_empty():
            scan = self.deal_with_objects_with_finalizers(scan)
        if self.objects_with_weakrefs.non_empty():
            self.invalidate_weakrefs()
        self.update_objects_with_id()
        self.finished_full_collect()
        self.debug_check_consistency()
        if not size_changing:
            llarena.arena_reset(fromspace, self.space_size, True)
            self.record_red_zone()
            self.execute_finalizers()
        # llop.debug_print(lltype.Void, 'collected', self.space_size, size_changing, self.top_of_space - self.free)
        if have_debug_prints():
            # end_time = time.time()
            # elapsed_time = end_time - start_time
            # self.total_collection_time += elapsed_time
            self.total_collection_count += 1
            # total_program_time = end_time - self.program_start_time
            end_usage = self.free - self.tospace
            debug_print("| used after collection:           ", end_usage, "bytes")
            debug_print("| freed:                           ", start_usage - end_usage, "bytes")
            debug_print("| size of each semispace:          ", self.space_size, "bytes")
            debug_print("| fraction of semispace now used:  ", end_usage * 100.0 / self.space_size, "%")
            # ct = self.total_collection_time
            cc = self.total_collection_count
            debug_print("| number of semispace_collects:    ", cc)
            # debug_print("|                         i.e.:    ",
            #            cc / total_program_time, "per second")
            # debug_print("| total time in semispace_collect: ",
            #            ct, "seconds")
            # debug_print("|                            i.e.: ",
            #            ct * 100.0 / total_program_time, "%")
            debug_print("`----------------------------------------------")
        debug_stop("gc-collect")
Example #12
0
 def _log_operations(self, inputargs, operations, ops_offset):
     if not have_debug_prints():
         return
     if ops_offset is None:
         ops_offset = {}
     if inputargs is not None:
         args = ", ".join([self.repr_of_arg(arg) for arg in inputargs])
         debug_print('[' + args + ']')
     for i in range(len(operations)):
         op = operations[i]
         debug_print(self.repr_of_resop(operations[i], ops_offset))
     if ops_offset and None in ops_offset:
         offset = ops_offset[None]
         debug_print("+%d: --end of the loop--" % offset)
Example #13
0
 def _log_operations(self, inputargs, operations, ops_offset):
     if not have_debug_prints():
         return
     if ops_offset is None:
         ops_offset = {}
     if inputargs is not None:
         args = ", ".join([self.repr_of_arg(arg) for arg in inputargs])
         debug_print('[' + args + ']')
     for i in range(len(operations)):
         op = operations[i]
         debug_print(self.repr_of_resop(operations[i], ops_offset))
         if op.getopnum() == rop.LABEL:
             self._log_inputarg_setup_ops(op)
     if ops_offset and None in ops_offset:
         offset = ops_offset[None]
         debug_print("+%d: --end of the loop--" % offset)
Example #14
0
def dump_storage(storage, liveboxes):
    "For profiling only."
    from pypy.rlib.objectmodel import compute_unique_id
    debug_start("jit-resume")
    if have_debug_prints():
        debug_print('Log storage', compute_unique_id(storage))
        frameinfo = storage.rd_frame_info_list
        while frameinfo is not None:
            try:
                jitcodename = frameinfo.jitcode.name
            except AttributeError:
                jitcodename = str(compute_unique_id(frameinfo.jitcode))
            debug_print('\tjitcode/pc', jitcodename,
                        frameinfo.pc,
                        'at', compute_unique_id(frameinfo))
            frameinfo = frameinfo.prev
        numb = storage.rd_numb
        while numb:
            debug_print('\tnumb', str([untag(numb.nums[i])
                                       for i in range(len(numb.nums))]),
                        'at', compute_unique_id(numb))
            numb = numb.prev
        for const in storage.rd_consts:
            debug_print('\tconst', const.repr_rpython())
        for box in liveboxes:
            if box is None:
                debug_print('\tbox', 'None')
            else:
                debug_print('\tbox', box.repr_rpython())
        if storage.rd_virtuals is not None:
            for virtual in storage.rd_virtuals:
                if virtual is None:
                    debug_print('\t\t', 'None')
                else:
                    virtual.debug_prints()
    debug_stop("jit-resume")
Example #15
0
 def f(x):
     debug_start("mycat")
     debug_print("foo", 2, "bar", x)
     debug_stop("mycat")
     return have_debug_prints()
Example #16
0
def op_have_debug_prints():
    return debug.have_debug_prints()
Example #17
0
 def _log_operations(self, inputargs, operations, ops_offset):
     if not have_debug_prints():
         return None
     logops = self._make_log_operations()
     logops._log_operations(inputargs, operations, ops_offset)
     return logops
Example #18
0
 def f(x):
     debug_start("mycat")
     debug_print("foo", 2, "bar", x)
     debug_stop("mycat")
     return have_debug_prints()
Example #19
0
 def print_stats(self):
     debug_start("jit-summary")
     if have_debug_prints():
         self._print_stats()
     debug_stop("jit-summary")
Example #20
0
    def semispace_collect(self, size_changing=False):
        debug_start("gc-collect")
        debug_print()
        debug_print(".----------- Full collection ------------------")
        start_usage = self.free - self.tospace
        debug_print("| used before collection:          ", start_usage,
                    "bytes")
        #start_time = time.time()
        #llop.debug_print(lltype.Void, 'semispace_collect', int(size_changing))

        # Switch the spaces.  We copy everything over to the empty space
        # (self.fromspace at the beginning of the collection), and clear the old
        # one (self.tospace at the beginning).  Their purposes will be reversed
        # for the next collection.
        tospace = self.fromspace
        fromspace = self.tospace
        self.fromspace = fromspace
        self.tospace = tospace
        self.top_of_space = tospace + self.space_size
        scan = self.free = tospace
        self.starting_full_collect()
        self.collect_roots()
        if self.run_finalizers.non_empty():
            self.update_run_finalizers()
        scan = self.scan_copied(scan)
        if self.objects_with_light_finalizers.non_empty():
            self.deal_with_objects_with_light_finalizers()
        if self.objects_with_finalizers.non_empty():
            scan = self.deal_with_objects_with_finalizers(scan)
        if self.objects_with_weakrefs.non_empty():
            self.invalidate_weakrefs()
        self.update_objects_with_id()
        self.finished_full_collect()
        self.debug_check_consistency()
        if not size_changing:
            llarena.arena_reset(fromspace, self.space_size, True)
            self.record_red_zone()
            self.execute_finalizers()
        #llop.debug_print(lltype.Void, 'collected', self.space_size, size_changing, self.top_of_space - self.free)
        if have_debug_prints():
            #end_time = time.time()
            #elapsed_time = end_time - start_time
            #self.total_collection_time += elapsed_time
            self.total_collection_count += 1
            #total_program_time = end_time - self.program_start_time
            end_usage = self.free - self.tospace
            debug_print("| used after collection:           ", end_usage,
                        "bytes")
            debug_print("| freed:                           ",
                        start_usage - end_usage, "bytes")
            debug_print("| size of each semispace:          ", self.space_size,
                        "bytes")
            debug_print("| fraction of semispace now used:  ",
                        end_usage * 100.0 / self.space_size, "%")
            #ct = self.total_collection_time
            cc = self.total_collection_count
            debug_print("| number of semispace_collects:    ", cc)
            #debug_print("|                         i.e.:    ",
            #            cc / total_program_time, "per second")
            #debug_print("| total time in semispace_collect: ",
            #            ct, "seconds")
            #debug_print("|                            i.e.: ",
            #            ct * 100.0 / total_program_time, "%")
            debug_print("`----------------------------------------------")
        debug_stop("gc-collect")
Example #21
0
def op_have_debug_prints():
    return debug.have_debug_prints()
Example #22
0
 def print_stats(self):
     debug_start("jit-summary")
     if have_debug_prints():
         self._print_stats()
     debug_stop("jit-summary")
Example #23
0
    def sweep_rawmalloced_objects(self, generation):
        # free all the rawmalloced objects of the specified generation
        # that have not been marked
        if generation == 2:
            objects = self.gen2_rawmalloced_objects
            # generation 2 sweep: if A points to an object object B that
            # moves from gen2 to gen3, it's possible that A no longer points
            # to any gen2 object.  In this case, A remains a bit too long in
            # last_generation_root_objects, but this will be fixed by the
            # next collect_last_generation_roots().
        elif generation == 3:
            objects = self.gen3_rawmalloced_objects
            # generation 3 sweep: remove from last_generation_root_objects
            # all the objects that we are about to free
            gen3roots = self.last_generation_root_objects
            newgen3roots = self.AddressStack()
            while gen3roots.non_empty():
                obj = gen3roots.pop()
                if not (self.header(obj).tid & GCFLAG_UNVISITED):
                    newgen3roots.append(obj)
            gen3roots.delete()
            self.last_generation_root_objects = newgen3roots
        else:
            ll_assert(False, "bogus 'generation'")
            return 0  # to please the flowspace

        surviving_objects = self.AddressStack()
        # Help the flow space
        alive_count = alive_size = dead_count = dead_size = 0
        debug = have_debug_prints()
        while objects.non_empty():
            obj = objects.pop()
            tid = self.header(obj).tid
            if tid & GCFLAG_UNVISITED:
                if debug:
                    dead_count += 1
                    dead_size += raw_malloc_usage(self.get_size_incl_hash(obj))
                addr = obj - self.gcheaderbuilder.size_gc_header
                llmemory.raw_free(addr)
            else:
                if debug:
                    alive_count += 1
                alive_size += raw_malloc_usage(self.get_size_incl_hash(obj))
                if generation == 3:
                    surviving_objects.append(obj)
                elif generation == 2:
                    ll_assert((tid & GCFLAG_AGE_MASK) < GCFLAG_AGE_MAX,
                              "wrong age for generation 2 object")
                    tid += GCFLAG_AGE_ONE
                    if (tid & GCFLAG_AGE_MASK) == GCFLAG_AGE_MAX:
                        # the object becomes part of generation 3
                        self.gen3_rawmalloced_objects.append(obj)
                        # GCFLAG_NO_HEAP_PTRS not set yet, conservatively
                        self.last_generation_root_objects.append(obj)
                    else:
                        # the object stays in generation 2
                        tid |= GCFLAG_UNVISITED
                        surviving_objects.append(obj)
                    self.header(obj).tid = tid
        objects.delete()
        if generation == 2:
            self.gen2_rawmalloced_objects = surviving_objects
        elif generation == 3:
            self.gen3_rawmalloced_objects = surviving_objects
        debug_print("| [hyb] gen", generation, "nonmoving now alive: ",
                    alive_size, "bytes in", alive_count, "objs")
        debug_print("| [hyb] gen", generation, "nonmoving freed:     ",
                    dead_size, "bytes in", dead_count, "objs")
        return alive_size
Example #24
0
File: hybrid.py Project: ieure/pypy
    def sweep_rawmalloced_objects(self, generation):
        # free all the rawmalloced objects of the specified generation
        # that have not been marked
        if generation == 2:
            objects = self.gen2_rawmalloced_objects
            # generation 2 sweep: if A points to an object object B that
            # moves from gen2 to gen3, it's possible that A no longer points
            # to any gen2 object.  In this case, A remains a bit too long in
            # last_generation_root_objects, but this will be fixed by the
            # next collect_last_generation_roots().
        elif generation == 3:
            objects = self.gen3_rawmalloced_objects
            # generation 3 sweep: remove from last_generation_root_objects
            # all the objects that we are about to free
            gen3roots = self.last_generation_root_objects
            newgen3roots = self.AddressStack()
            while gen3roots.non_empty():
                obj = gen3roots.pop()
                if not (self.header(obj).tid & GCFLAG_UNVISITED):
                    newgen3roots.append(obj)
            gen3roots.delete()
            self.last_generation_root_objects = newgen3roots
        else:
            ll_assert(False, "bogus 'generation'")
            return 0 # to please the flowspace

        surviving_objects = self.AddressStack()
        # Help the flow space
        alive_count = alive_size = dead_count = dead_size = 0
        debug = have_debug_prints()
        while objects.non_empty():
            obj = objects.pop()
            tid = self.header(obj).tid
            if tid & GCFLAG_UNVISITED:
                if debug:
                    dead_count+=1
                    dead_size+=raw_malloc_usage(self.get_size_incl_hash(obj))
                addr = obj - self.gcheaderbuilder.size_gc_header
                llmemory.raw_free(addr)
            else:
                if debug:
                    alive_count+=1
                alive_size+=raw_malloc_usage(self.get_size_incl_hash(obj))
                if generation == 3:
                    surviving_objects.append(obj)
                elif generation == 2:
                    ll_assert((tid & GCFLAG_AGE_MASK) < GCFLAG_AGE_MAX,
                              "wrong age for generation 2 object")
                    tid += GCFLAG_AGE_ONE
                    if (tid & GCFLAG_AGE_MASK) == GCFLAG_AGE_MAX:
                        # the object becomes part of generation 3
                        self.gen3_rawmalloced_objects.append(obj)
                        # GCFLAG_NO_HEAP_PTRS not set yet, conservatively
                        self.last_generation_root_objects.append(obj)
                    else:
                        # the object stays in generation 2
                        tid |= GCFLAG_UNVISITED
                        surviving_objects.append(obj)
                    self.header(obj).tid = tid
        objects.delete()
        if generation == 2:
            self.gen2_rawmalloced_objects = surviving_objects
        elif generation == 3:
            self.gen3_rawmalloced_objects = surviving_objects
        debug_print("| [hyb] gen", generation,
                    "nonmoving now alive: ",
                    alive_size, "bytes in",
                    alive_count, "objs")
        debug_print("| [hyb] gen", generation,
                    "nonmoving freed:     ",
                    dead_size, "bytes in",
                    dead_count, "objs")
        return alive_size
Example #25
0
 def _log_operations(self, inputargs, operations, ops_offset):
     if not have_debug_prints():
         return None
     logops = self._make_log_operations()
     logops._log_operations(inputargs, operations, ops_offset)
     return logops