diff --git a/jerry-core/jerry.cpp b/jerry-core/jerry.cpp index 4220bf1c7..8ece823a8 100644 --- a/jerry-core/jerry.cpp +++ b/jerry-core/jerry.cpp @@ -904,7 +904,7 @@ jerry_init (jerry_flag_t flags) /**< combination of Jerry flags */ jerry_flags = flags; #ifndef MEM_STATS - if (flags & JERRY_FLAG_MEM_STATS) + if (flags & (JERRY_FLAG_MEM_STATS_AT_EXIT | JERRY_FLAG_MEM_STATS_PER_OPCODE)) { printf ("Ignoring memory statistics option because of '!MEM_STATS' build configuration.\n"); } @@ -921,7 +921,7 @@ jerry_init (jerry_flag_t flags) /**< combination of Jerry flags */ void jerry_cleanup (void) { - bool is_show_mem_stats = ((jerry_flags & JERRY_FLAG_MEM_STATS) != 0); + bool is_show_mem_stats = ((jerry_flags & JERRY_FLAG_MEM_STATS_AT_EXIT) != 0); ecma_finalize (); serializer_free (); @@ -966,8 +966,9 @@ jerry_parse (const char* source_p, /**< script source */ serializer_print_opcodes (); parser_free (); - bool is_show_mem_stats = ((jerry_flags & JERRY_FLAG_MEM_STATS) != 0); - init_int (opcodes, is_show_mem_stats); + bool is_show_mem_stats_per_opcode = ((jerry_flags & JERRY_FLAG_MEM_STATS_PER_OPCODE) != 0); + + init_int (opcodes, is_show_mem_stats_per_opcode); return true; } /* jerry_parse */ diff --git a/jerry-core/jerry.h b/jerry-core/jerry.h index b373d4f92..7df750a31 100644 --- a/jerry-core/jerry.h +++ b/jerry-core/jerry.h @@ -31,12 +31,13 @@ */ typedef uint32_t jerry_flag_t; -#define JERRY_FLAG_EMPTY (0) /**< empty flag set */ -#define JERRY_FLAG_SHOW_OPCODES (1 << 0) /**< dump opcodes to stdout after parse */ -#define JERRY_FLAG_MEM_STATS (1 << 1) /**< dump per-opcode memory statistics during execution - * (in the mode full GC is performed after each opcode handler) */ -#define JERRY_FLAG_PARSE_ONLY (1 << 2) /**< parse only, prevents script execution (only for testing) - * FIXME: Remove. */ +#define JERRY_FLAG_EMPTY (0) /**< empty flag set */ +#define JERRY_FLAG_SHOW_OPCODES (1 << 0) /**< dump opcodes to stdout after parse */ +#define JERRY_FLAG_MEM_STATS_AT_EXIT (1 << 1) /**< dump per-opcode memory statistics during execution + * (in the mode full GC is performed after each opcode handler) */ +#define JERRY_FLAG_MEM_STATS_PER_OPCODE (1 << 2) /**< dump peak memory statistics before exit */ +#define JERRY_FLAG_PARSE_ONLY (1 << 3) /**< parse only, prevents script execution (only for testing) + * FIXME: Remove. */ /** * Error codes diff --git a/main-linux.cpp b/main-linux.cpp index 8a49cec64..de0a2f478 100644 --- a/main-linux.cpp +++ b/main-linux.cpp @@ -139,9 +139,13 @@ main (int argc, printf ("Branch name:\t%s\n", jerry_branch_name); printf ("\n"); } - else if (!strcmp ("--mem-stats", argv[i])) + else if (!strcmp ("--mem-stats-at-exit", argv[i])) { - flags |= JERRY_FLAG_MEM_STATS; + flags |= JERRY_FLAG_MEM_STATS_AT_EXIT; + } + else if (!strcmp ("--mem-stats-per-opcode", argv[i])) + { + flags |= JERRY_FLAG_MEM_STATS_PER_OPCODE; } else if (!strcmp ("--parse-only", argv[i])) { diff --git a/main-nuttx.cpp b/main-nuttx.cpp index 04fbaf945..9e2dc342a 100644 --- a/main-nuttx.cpp +++ b/main-nuttx.cpp @@ -146,9 +146,13 @@ int jerry_main (int argc, char *argv[]) printf ("Commit hash:\t%s\n", jerry_commit_hash); printf ("Branch name:\t%s\n", jerry_branch_name); } - else if (!strcmp ("--mem-stats", argv[i])) + else if (!strcmp ("--mem-stats-at-exit", argv[i])) { - flags |= JERRY_FLAG_MEM_STATS; + flags |= JERRY_FLAG_MEM_STATS_AT_EXIT; + } + else if (!strcmp ("--mem-stats-per-opcode", argv[i])) + { + flags |= JERRY_FLAG_MEM_STATS_PER_OPCODE; } else if (!strcmp ("--parse-only", argv[i])) {