Skip to content

Eliminate code duplication in memory statistics printing #841

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

akosthekiss
Copy link
Member

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu

@akosthekiss akosthekiss added enhancement An improvement memory management Related to memory management or garbage collection labels Feb 4, 2016
stats.peak_pools_count,
stats.peak_allocated_chunks);
#endif /* MEM_STATS */
mem_stats_print ();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akiss77, for me it seems better to put mem_stats_print under #ifdef MEM_STATS, as without the define the call is no-op.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ruben-ayrapetyan I've been considering that as well. The reason why I proposed the above is that it remained semantically equivalent with the original version, which also left the call to mem_heap_print unguarded. Even in mem_heap_print, there are quite some code lines which are always compiled, and only a final portion is ifdef'd by MEM_STATS. If we choose to ifdef the call here, then maybe we should consider putting much more code under ifdef guards,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akiss77, I see. Thank you for your explanation.
The part of mem_heap_print that is not currently guarded by MEM_STATS, is not executed during the call, because the corresponding arguments are set to false, and only dump_stats argument is set to true.
So, maybe, its better to extract part of mem_heap_print that outputs statistics to another routine like mem_heap_print_stats, guard it with MEM_STATS, and call it from mem_heap_print and mem_stats_print. In the case, mem_stats_print could be guarded by #ifdef around the function, not inside.
What do you think about this?

@akosthekiss
Copy link
Member Author

@ruben-ayrapetyan I've updated the patch. I guess I got it according to your feedback. The only change I made is that I used the name mem_heap_stats_print for the new function as it seemed to align better with the existing names.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
@zherczeg
Copy link
Member

zherczeg commented Feb 8, 2016

LGTM

@LaszloLango
Copy link
Contributor

Landed (196e819)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement memory management Related to memory management or garbage collection
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants