Author: Antonio Cuni <anto.c...@gmail.com> Branch: gc-hooks Changeset: r94194:def5c83256cc Date: 2018-03-31 11:49 +0200 http://bitbucket.org/pypy/pypy/changeset/def5c83256cc/
Log: move the if gc_*_enabled checks inside the fire_* methods diff --git a/rpython/memory/gc/hook.py b/rpython/memory/gc/hook.py --- a/rpython/memory/gc/hook.py +++ b/rpython/memory/gc/hook.py @@ -15,7 +15,6 @@ self.gc_collect_step_enabled = False self.gc_collect_enabled = False - def on_gc_minor(self, total_memory_used, pinned_objects): """ Called after a minor collection @@ -44,16 +43,19 @@ @rgc.no_collect def fire_gc_minor(self, total_memory_used, pinned_objects): - self.on_gc_minor(total_memory_used, pinned_objects) + if self.gc_minor_enabled: + self.on_gc_minor(total_memory_used, pinned_objects) @rgc.no_collect def fire_gc_collect_step(self, oldstate, newstate): - self.on_gc_collect_step(oldstate, newstate) + if self.gc_collect_step_enabled: + self.on_gc_collect_step(oldstate, newstate) @rgc.no_collect def fire_gc_collect(self, count, arenas_count_before, arenas_count_after, arenas_bytes, rawmalloc_bytes_before, rawmalloc_bytes_after): - self.on_gc_collect(count, arenas_count_before, arenas_count_after, - arenas_bytes, rawmalloc_bytes_before, - rawmalloc_bytes_after) + if self.gc_collect_enabled: + self.on_gc_collect(count, arenas_count_before, arenas_count_after, + arenas_bytes, rawmalloc_bytes_before, + rawmalloc_bytes_after) diff --git a/rpython/memory/gc/incminimark.py b/rpython/memory/gc/incminimark.py --- a/rpython/memory/gc/incminimark.py +++ b/rpython/memory/gc/incminimark.py @@ -1838,9 +1838,8 @@ self.root_walker.finished_minor_collection() # debug_stop("gc-minor") - if self.hooks.gc_minor_enabled: - self.hooks.fire_gc_minor(total_memory_used=total_memory_used, - pinned_objects=self.pinned_objects_in_nursery) + self.hooks.fire_gc_minor(total_memory_used=total_memory_used, + pinned_objects=self.pinned_objects_in_nursery) def _reset_flag_old_objects_pointing_to_pinned(self, obj, ignore): ll_assert(self.header(obj).tid & GCFLAG_PINNED_OBJECT_PARENT_KNOWN != 0, @@ -2424,14 +2423,13 @@ self.stat_rawmalloced_total_size, " => ", self.rawmalloced_total_size) debug_stop("gc-collect-done") - if self.hooks.gc_collect_enabled: - self.hooks.fire_gc_collect( - count=self.num_major_collects, - arenas_count_before=self.stat_ac_arenas_count, - arenas_count_after=self.ac.arenas_count, - arenas_bytes=self.ac.total_memory_used, - rawmalloc_bytes_before=self.stat_rawmalloced_total_size, - rawmalloc_bytes_after=self.rawmalloced_total_size) + self.hooks.fire_gc_collect( + count=self.num_major_collects, + arenas_count_before=self.stat_ac_arenas_count, + arenas_count_after=self.ac.arenas_count, + arenas_bytes=self.ac.total_memory_used, + rawmalloc_bytes_before=self.stat_rawmalloced_total_size, + rawmalloc_bytes_after=self.rawmalloced_total_size) # # Set the threshold for the next major collection to be when we # have allocated 'major_collection_threshold' times more than @@ -2483,9 +2481,8 @@ debug_print("stopping, now in gc state: ", GC_STATES[self.gc_state]) debug_stop("gc-collect-step") - if self.hooks.gc_collect_step_enabled: - self.hooks.fire_gc_collect_step(oldstate=oldstate, - newstate=self.gc_state) + self.hooks.fire_gc_collect_step(oldstate=oldstate, + newstate=self.gc_state) def _sweep_old_objects_pointing_to_pinned(self, obj, new_list): if self.header(obj).tid & GCFLAG_VISITED: _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit