Пример #1
0
Файл: gc.py Проект: charred/pypy
 def rewrite_assembler(self, cpu, operations, gcrefs_output_list):
     rewriter = GcRewriterAssembler(self, cpu)
     newops = rewriter.rewrite(operations)
     # record all GCREFs, because the GC (or Boehm) cannot see them and
     # keep them alive if they end up as constants in the assembler
     for op in newops:
         self._record_constptrs(op, gcrefs_output_list)
     return newops
Пример #2
0
    def rewrite_assembler(self, cpu, operations, gcrefs_output_list):
        rewriter = GcRewriterAssembler(self, cpu)
        newops = rewriter.rewrite(operations)

        # the key is an operation that contains a ConstPtr as an argument and
        # this ConstPtrs pointer might change as it points to an object that
        # can't be made non-moving (e.g. the object is pinned).
        ops_with_movable_const_ptr = {}
        #
        # a list of such not really constant ConstPtrs.
        changeable_const_pointers = []
        for op in newops:
            # record all GCREFs, because the GC (or Boehm) cannot see them and
            # keep them alive if they end up as constants in the assembler.
            # If such a GCREF can change and we can't make the object it points
            # to non-movable, we have to handle it seperatly. Such GCREF's are
            # returned as ConstPtrs in 'changeable_const_pointers' and the
            # affected operation is returned in 'op_with_movable_const_ptr'.
            # For this special case see 'rewrite_changeable_constptrs'.
            self._record_constptrs(op, gcrefs_output_list,
                                   ops_with_movable_const_ptr,
                                   changeable_const_pointers)
        #
        # handle pointers that are not guaranteed to stay the same
        if len(ops_with_movable_const_ptr) > 0:
            moving_obj_tracker = MovableObjectTracker(
                cpu, changeable_const_pointers)
            #
            if not we_are_translated():
                # used for testing
                self.last_moving_obj_tracker = moving_obj_tracker
            # make sure the array containing the pointers is not collected by
            # the GC (or Boehm)
            gcrefs_output_list.append(moving_obj_tracker.ptr_array_gcref)
            rgc._make_sure_does_not_move(moving_obj_tracker.ptr_array_gcref)

            ops = newops
            newops = []
            for op in ops:
                if op in ops_with_movable_const_ptr:
                    rewritten_ops = self._rewrite_changeable_constptrs(
                        op, ops_with_movable_const_ptr, moving_obj_tracker)
                    newops.extend(rewritten_ops)
                else:
                    newops.append(op)
        #
        return newops
Пример #3
0
Файл: gc.py Проект: Qointum/pypy
    def rewrite_assembler(self, cpu, operations, gcrefs_output_list):
        rewriter = GcRewriterAssembler(self, cpu)
        newops = rewriter.rewrite(operations)

        # the key is an operation that contains a ConstPtr as an argument and
        # this ConstPtrs pointer might change as it points to an object that
        # can't be made non-moving (e.g. the object is pinned).
        ops_with_movable_const_ptr = {}
        #
        # a list of such not really constant ConstPtrs.
        changeable_const_pointers = []
        for op in newops:
            # record all GCREFs, because the GC (or Boehm) cannot see them and
            # keep them alive if they end up as constants in the assembler.
            # If such a GCREF can change and we can't make the object it points
            # to non-movable, we have to handle it seperatly. Such GCREF's are
            # returned as ConstPtrs in 'changeable_const_pointers' and the
            # affected operation is returned in 'op_with_movable_const_ptr'.
            # For this special case see 'rewrite_changeable_constptrs'.
            self._record_constptrs(op, gcrefs_output_list,
                    ops_with_movable_const_ptr, changeable_const_pointers)
        #
        # handle pointers that are not guaranteed to stay the same
        if len(ops_with_movable_const_ptr) > 0:
            moving_obj_tracker = MovableObjectTracker(cpu, changeable_const_pointers)
            #
            if not we_are_translated():
                # used for testing
                self.last_moving_obj_tracker = moving_obj_tracker
            # make sure the array containing the pointers is not collected by
            # the GC (or Boehm)
            gcrefs_output_list.append(moving_obj_tracker.ptr_array_gcref)
            rgc._make_sure_does_not_move(moving_obj_tracker.ptr_array_gcref)

            ops = newops
            newops = []
            for op in ops:
                if op in ops_with_movable_const_ptr:
                    rewritten_ops = self._rewrite_changeable_constptrs(op,
                            ops_with_movable_const_ptr, moving_obj_tracker)
                    newops.extend(rewritten_ops)
                else:
                    newops.append(op)
        #
        return newops
Пример #4
0
 def rewrite_assembler(self, cpu, operations, gcrefs_output_list):
     rewriter = GcRewriterAssembler(self, cpu)
     newops = rewriter.rewrite(operations, gcrefs_output_list)
     return newops
Пример #5
0
 def rewrite_assembler(self, cpu, operations, gcrefs_output_list):
     rewriter = GcRewriterAssembler(self, cpu)
     newops = rewriter.rewrite(operations, gcrefs_output_list)
     return newops