Follow-up refactoring of logging-related parts

This patch:
* Ensures that all calls to `jerry_port_log` in jerry-core happen
  via macros defined in jrt.h. Also, it unifies the names of those
  macros: as `JERRY_ERROR_MSG` and `JERRY_WARNING_MSG` gave a good
  pattern that was well aligned with the naming scheme of the log
  level enum, `JERRY_DLOG` and `JERRY_DDLOG` were rewritten to
  `JERRY_DEBUG_MSG` and `JERRY_TRACE_MSG`.
* Ensures that all debug logging code parts of jerry-core (i.e.,
  memory statistics, JS byte-code dumps, and RegExp byte-code
  dumps) are guarded by macros: `JMEM_STATS`,
  `PARSER_DUMP_BYTE_CODE`, and `REGEXP_DUMP_BYTE_CODE`, which in
  turn are controled by cmake build system feature flags
  `FEATURE_MEM_STATS`, `FEATURE_PARSER_DUMP`, and
  `FEATURE_REGEXP_DUMP`.
* Ensures that all debug logging functionalities can be controled
  during run time (provided that they were enabled during build
  time): the engine has `JERRY_INIT_MEM_STATS[_SEPARATE]`,
  `JERRY_INIT_SHOW_OPCODES`, `JERRY_INIT_SHOW_REGEXP_OPCODES` init
  flags, and the default unix/linux command line app has
  corresponding command line switches.`
* Drops `FEATURE_LOG`, `JERRY_ENABLE_LOG`, and
  `JERRY_INIT_ENABLE_LOG`, as their name was misleadingly general,
  even though they mostly controled the regexp engine only. The
  above-mentioned `*REGEXP*` things mostly act as their
  replacements.
* Updates build, test, and measurement tool scripts, and
  documentation.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This commit is contained in:
Akos Kiss
2016-08-05 21:46:41 +02:00
parent 1b996a9a56
commit a2d5acb43c
30 changed files with 333 additions and 362 deletions
+4 -4
View File
@@ -5,8 +5,8 @@
Enum that contains the following elements: Enum that contains the following elements:
- JERRY_INIT_EMPTY - empty flag set - JERRY_INIT_EMPTY - empty flag set
- JERRY_INIT_ENABLE_LOG - enable logging - JERRY_INIT_SHOW_OPCODES - dump byte-code to log after parse
- JERRY_INIT_SHOW_OPCODES - dump byte-code to stdout after parse - JERRY_INIT_SHOW_REGEXP_OPCODES - dump regexp byte-code to log after compilation
- JERRY_INIT_MEM_STATS - dump memory statistics - JERRY_INIT_MEM_STATS - dump memory statistics
- JERRY_INIT_MEM_STATS_SEPARATE - dump memory statistics and reset peak values after parse - JERRY_INIT_MEM_STATS_SEPARATE - dump memory statistics and reset peak values after parse
@@ -181,8 +181,8 @@ jerry_init (jerry_init_flag_t flags)
`flags` - combination of various engine configuration flags: `flags` - combination of various engine configuration flags:
- `JERRY_INIT_EMPTY` - no flags, just initialize in default configuration. - `JERRY_INIT_EMPTY` - no flags, just initialize in default configuration.
- `JERRY_INIT_ENABLE_LOG` - enable logging.
- `JERRY_INIT_SHOW_OPCODES` - print compiled byte-code. - `JERRY_INIT_SHOW_OPCODES` - print compiled byte-code.
- `JERRY_INIT_SHOW_REGEXP_OPCODES` - print compiled regexp byte-code.
- `JERRY_INIT_MEM_STATS` - dump memory statistics. - `JERRY_INIT_MEM_STATS` - dump memory statistics.
- `JERRY_INIT_MEM_STATS_SEPARATE` - dump memory statistics and reset peak values after parse. - `JERRY_INIT_MEM_STATS_SEPARATE` - dump memory statistics and reset peak values after parse.
@@ -190,7 +190,7 @@ jerry_init (jerry_init_flag_t flags)
```c ```c
{ {
jerry_init (JERRY_INIT_SHOW_OPCODES | JERRY_INIT_ENABLE_LOG); jerry_init (JERRY_INIT_SHOW_OPCODES | JERRY_INIT_SHOW_REGEXP_OPCODES);
// ... // ...
+15 -8
View File
@@ -20,11 +20,12 @@ project (${JERRY_CORE_NAME} C)
# Optional features # Optional features
set(FEATURE_PROFILE "full" CACHE STRING "Profile types: full, minimal") set(FEATURE_PROFILE "full" CACHE STRING "Profile types: full, minimal")
set(FEATURE_ERROR_MESSAGES OFF CACHE BOOL "Enable error messages?") set(FEATURE_ERROR_MESSAGES OFF CACHE BOOL "Enable error messages?")
set(FEATURE_LOG OFF CACHE BOOL "Enable logging?")
set(FEATURE_VALGRIND OFF CACHE BOOL "Enable Valgrind support?") set(FEATURE_VALGRIND OFF CACHE BOOL "Enable Valgrind support?")
set(FEATURE_VALGRIND_FREYA OFF CACHE BOOL "Enable Valgrind-Freya support?") set(FEATURE_VALGRIND_FREYA OFF CACHE BOOL "Enable Valgrind-Freya support?")
set(FEATURE_MEM_STRESS_TEST OFF CACHE BOOL "Enable mem-stress test?") set(FEATURE_MEM_STRESS_TEST OFF CACHE BOOL "Enable mem-stress test?")
set(FEATURE_MEM_STATS OFF CACHE BOOL "Enable memory-statistics?") set(FEATURE_MEM_STATS OFF CACHE BOOL "Enable memory statistics?")
set(FEATURE_PARSER_DUMP OFF CACHE BOOL "Enable parser byte-code dumps?")
set(FEATURE_REGEXP_DUMP OFF CACHE BOOL "Enable regexp byte-code dumps?")
set(FEATURE_SNAPSHOT_SAVE OFF CACHE BOOL "Allow to save snapshot files?") set(FEATURE_SNAPSHOT_SAVE OFF CACHE BOOL "Allow to save snapshot files?")
set(FEATURE_SNAPSHOT_EXEC OFF CACHE BOOL "Allow to execute snapshot files?") set(FEATURE_SNAPSHOT_EXEC OFF CACHE BOOL "Allow to execute snapshot files?")
set(MEM_HEAP_SIZE_KB "512" CACHE STRING "Size of memory heap, in kilobytes") set(MEM_HEAP_SIZE_KB "512" CACHE STRING "Size of memory heap, in kilobytes")
@@ -32,11 +33,12 @@ set(MEM_HEAP_SIZE_KB "512" CACHE STRING "Size of memory heap, in kilobyt
# Status messages # Status messages
message(STATUS "FEATURE_PROFILE " ${FEATURE_PROFILE}) message(STATUS "FEATURE_PROFILE " ${FEATURE_PROFILE})
message(STATUS "FEATURE_ERROR_MESSAGES " ${FEATURE_ERROR_MESSAGES}) message(STATUS "FEATURE_ERROR_MESSAGES " ${FEATURE_ERROR_MESSAGES})
message(STATUS "FEATURE_LOG " ${FEATURE_LOG})
message(STATUS "FEATURE_VALGRIND " ${FEATURE_VALGRIND}) message(STATUS "FEATURE_VALGRIND " ${FEATURE_VALGRIND})
message(STATUS "FEATURE_VALGRIND_FREYA " ${FEATURE_VALGRIND_FREYA}) message(STATUS "FEATURE_VALGRIND_FREYA " ${FEATURE_VALGRIND_FREYA})
message(STATUS "FEATURE_MEM_STRESS_TEST " ${FEATURE_MEM_STRESS_TEST}) message(STATUS "FEATURE_MEM_STRESS_TEST " ${FEATURE_MEM_STRESS_TEST})
message(STATUS "FEATURE_MEM_STATS " ${FEATURE_MEM_STATS}) message(STATUS "FEATURE_MEM_STATS " ${FEATURE_MEM_STATS})
message(STATUS "FEATURE_PARSER_DUMP " ${FEATURE_PARSER_DUMP})
message(STATUS "FEATURE_REGEXP_DUMP " ${FEATURE_REGEXP_DUMP})
message(STATUS "FEATURE_SNAPSHOT_SAVE " ${FEATURE_SNAPSHOT_SAVE}) message(STATUS "FEATURE_SNAPSHOT_SAVE " ${FEATURE_SNAPSHOT_SAVE})
message(STATUS "FEATURE_SNAPSHOT_EXEC " ${FEATURE_SNAPSHOT_EXEC}) message(STATUS "FEATURE_SNAPSHOT_EXEC " ${FEATURE_SNAPSHOT_EXEC})
message(STATUS "MEM_HEAP_SIZE_KB " ${MEM_HEAP_SIZE_KB}) message(STATUS "MEM_HEAP_SIZE_KB " ${MEM_HEAP_SIZE_KB})
@@ -170,11 +172,6 @@ if(FEATURE_ERROR_MESSAGES)
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_ENABLE_ERROR_MESSAGES) set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_ENABLE_ERROR_MESSAGES)
endif() endif()
# Log
if(FEATURE_LOG)
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_ENABLE_LOG)
endif()
# Valgrind # Valgrind
if(FEATURE_VALGRIND) if(FEATURE_VALGRIND)
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_VALGRIND) set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_VALGRIND)
@@ -197,6 +194,16 @@ if(FEATURE_MEM_STATS)
set(DEFINES_JERRY ${DEFINES_JERRY} JMEM_STATS) set(DEFINES_JERRY ${DEFINES_JERRY} JMEM_STATS)
endif() endif()
# Parser byte-code dumps
if(FEATURE_PARSER_DUMP)
set(DEFINES_JERRY ${DEFINES_JERRY} PARSER_DUMP_BYTE_CODE)
endif()
# RegExp byte-code dumps
if(FEATURE_REGEXP_DUMP)
set(DEFINES_JERRY ${DEFINES_JERRY} REGEXP_DUMP_BYTE_CODE)
endif()
# Snapshot save # Snapshot save
if(FEATURE_SNAPSHOT_SAVE) if(FEATURE_SNAPSHOT_SAVE)
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_ENABLE_SNAPSHOT_SAVE) set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_ENABLE_SNAPSHOT_SAVE)
+51 -51
View File
@@ -385,7 +385,7 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
{ {
case RE_OP_MATCH: case RE_OP_MATCH:
{ {
JERRY_DDLOG ("Execute RE_OP_MATCH: match\n"); JERRY_TRACE_MSG ("Execute RE_OP_MATCH: match\n");
*out_str_p = str_curr_p; *out_str_p = str_curr_p;
ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_TRUE); ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_TRUE);
return ret_value; /* match */ return ret_value; /* match */
@@ -400,15 +400,15 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
bool is_ignorecase = re_ctx_p->flags & RE_FLAG_IGNORE_CASE; bool is_ignorecase = re_ctx_p->flags & RE_FLAG_IGNORE_CASE;
ecma_char_t ch1 = (ecma_char_t) re_get_char (&bc_p); /* Already canonicalized. */ ecma_char_t ch1 = (ecma_char_t) re_get_char (&bc_p); /* Already canonicalized. */
ecma_char_t ch2 = re_canonicalize (lit_utf8_read_next (&str_curr_p), is_ignorecase); ecma_char_t ch2 = re_canonicalize (lit_utf8_read_next (&str_curr_p), is_ignorecase);
JERRY_DDLOG ("Character matching %d to %d: ", ch1, ch2); JERRY_TRACE_MSG ("Character matching %d to %d: ", ch1, ch2);
if (ch1 != ch2) if (ch1 != ch2)
{ {
JERRY_DDLOG ("fail\n"); JERRY_TRACE_MSG ("fail\n");
return ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */ return ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
} }
JERRY_DDLOG ("match\n"); JERRY_TRACE_MSG ("match\n");
break; /* tail merge */ break; /* tail merge */
} }
@@ -420,65 +420,65 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
} }
ecma_char_t ch = lit_utf8_read_next (&str_curr_p); ecma_char_t ch = lit_utf8_read_next (&str_curr_p);
JERRY_DDLOG ("Period matching '.' to %d: ", (uint32_t) ch); JERRY_TRACE_MSG ("Period matching '.' to %d: ", (uint32_t) ch);
if (lit_char_is_line_terminator (ch)) if (lit_char_is_line_terminator (ch))
{ {
JERRY_DDLOG ("fail\n"); JERRY_TRACE_MSG ("fail\n");
return ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */ return ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
} }
JERRY_DDLOG ("match\n"); JERRY_TRACE_MSG ("match\n");
break; /* tail merge */ break; /* tail merge */
} }
case RE_OP_ASSERT_START: case RE_OP_ASSERT_START:
{ {
JERRY_DDLOG ("Execute RE_OP_ASSERT_START: "); JERRY_TRACE_MSG ("Execute RE_OP_ASSERT_START: ");
if (str_curr_p <= re_ctx_p->input_start_p) if (str_curr_p <= re_ctx_p->input_start_p)
{ {
JERRY_DDLOG ("match\n"); JERRY_TRACE_MSG ("match\n");
break; /* tail merge */ break; /* tail merge */
} }
if (!(re_ctx_p->flags & RE_FLAG_MULTILINE)) if (!(re_ctx_p->flags & RE_FLAG_MULTILINE))
{ {
JERRY_DDLOG ("fail\n"); JERRY_TRACE_MSG ("fail\n");
return ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */ return ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
} }
if (lit_char_is_line_terminator (lit_utf8_peek_prev (str_curr_p))) if (lit_char_is_line_terminator (lit_utf8_peek_prev (str_curr_p)))
{ {
JERRY_DDLOG ("match\n"); JERRY_TRACE_MSG ("match\n");
break; /* tail merge */ break; /* tail merge */
} }
JERRY_DDLOG ("fail\n"); JERRY_TRACE_MSG ("fail\n");
return ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */ return ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
} }
case RE_OP_ASSERT_END: case RE_OP_ASSERT_END:
{ {
JERRY_DDLOG ("Execute RE_OP_ASSERT_END: "); JERRY_TRACE_MSG ("Execute RE_OP_ASSERT_END: ");
if (str_curr_p >= re_ctx_p->input_end_p) if (str_curr_p >= re_ctx_p->input_end_p)
{ {
JERRY_DDLOG ("match\n"); JERRY_TRACE_MSG ("match\n");
break; /* tail merge */ break; /* tail merge */
} }
if (!(re_ctx_p->flags & RE_FLAG_MULTILINE)) if (!(re_ctx_p->flags & RE_FLAG_MULTILINE))
{ {
JERRY_DDLOG ("fail\n"); JERRY_TRACE_MSG ("fail\n");
return ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */ return ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
} }
if (lit_char_is_line_terminator (lit_utf8_peek_next (str_curr_p))) if (lit_char_is_line_terminator (lit_utf8_peek_next (str_curr_p)))
{ {
JERRY_DDLOG ("match\n"); JERRY_TRACE_MSG ("match\n");
break; /* tail merge */ break; /* tail merge */
} }
JERRY_DDLOG ("fail\n"); JERRY_TRACE_MSG ("fail\n");
return ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */ return ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
} }
case RE_OP_ASSERT_WORD_BOUNDARY: case RE_OP_ASSERT_WORD_BOUNDARY:
@@ -506,26 +506,26 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
if (op == RE_OP_ASSERT_WORD_BOUNDARY) if (op == RE_OP_ASSERT_WORD_BOUNDARY)
{ {
JERRY_DDLOG ("Execute RE_OP_ASSERT_WORD_BOUNDARY: "); JERRY_TRACE_MSG ("Execute RE_OP_ASSERT_WORD_BOUNDARY: ");
if (is_wordchar_left == is_wordchar_right) if (is_wordchar_left == is_wordchar_right)
{ {
JERRY_DDLOG ("fail\n"); JERRY_TRACE_MSG ("fail\n");
return ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */ return ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
} }
} }
else else
{ {
JERRY_ASSERT (op == RE_OP_ASSERT_NOT_WORD_BOUNDARY); JERRY_ASSERT (op == RE_OP_ASSERT_NOT_WORD_BOUNDARY);
JERRY_DDLOG ("Execute RE_OP_ASSERT_NOT_WORD_BOUNDARY: "); JERRY_TRACE_MSG ("Execute RE_OP_ASSERT_NOT_WORD_BOUNDARY: ");
if (is_wordchar_left != is_wordchar_right) if (is_wordchar_left != is_wordchar_right)
{ {
JERRY_DDLOG ("fail\n"); JERRY_TRACE_MSG ("fail\n");
return ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */ return ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
} }
} }
JERRY_DDLOG ("match\n"); JERRY_TRACE_MSG ("match\n");
break; /* tail merge */ break; /* tail merge */
} }
case RE_OP_LOOKAHEAD_POS: case RE_OP_LOOKAHEAD_POS:
@@ -558,17 +558,17 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
if (!ECMA_IS_VALUE_ERROR (match_value)) if (!ECMA_IS_VALUE_ERROR (match_value))
{ {
JERRY_DDLOG ("Execute RE_OP_LOOKAHEAD_POS/NEG: "); JERRY_TRACE_MSG ("Execute RE_OP_LOOKAHEAD_POS/NEG: ");
ecma_free_value (match_value); ecma_free_value (match_value);
if ((op == RE_OP_LOOKAHEAD_POS && sub_str_p) if ((op == RE_OP_LOOKAHEAD_POS && sub_str_p)
|| (op == RE_OP_LOOKAHEAD_NEG && !sub_str_p)) || (op == RE_OP_LOOKAHEAD_NEG && !sub_str_p))
{ {
JERRY_DDLOG ("match\n"); JERRY_TRACE_MSG ("match\n");
match_value = re_match_regexp (re_ctx_p, bc_p, str_curr_p, &sub_str_p); match_value = re_match_regexp (re_ctx_p, bc_p, str_curr_p, &sub_str_p);
} }
else else
{ {
JERRY_DDLOG ("fail\n"); JERRY_TRACE_MSG ("fail\n");
match_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */ match_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
} }
} }
@@ -596,10 +596,10 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
uint32_t num_of_ranges; uint32_t num_of_ranges;
bool is_match; bool is_match;
JERRY_DDLOG ("Execute RE_OP_CHAR_CLASS/RE_OP_INV_CHAR_CLASS, "); JERRY_TRACE_MSG ("Execute RE_OP_CHAR_CLASS/RE_OP_INV_CHAR_CLASS, ");
if (str_curr_p >= re_ctx_p->input_end_p) if (str_curr_p >= re_ctx_p->input_end_p)
{ {
JERRY_DDLOG ("fail\n"); JERRY_TRACE_MSG ("fail\n");
return ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */ return ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
} }
@@ -613,8 +613,8 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
{ {
ecma_char_t ch1 = re_canonicalize (re_get_char (&bc_p), is_ignorecase); ecma_char_t ch1 = re_canonicalize (re_get_char (&bc_p), is_ignorecase);
ecma_char_t ch2 = re_canonicalize (re_get_char (&bc_p), is_ignorecase); ecma_char_t ch2 = re_canonicalize (re_get_char (&bc_p), is_ignorecase);
JERRY_DDLOG ("num_of_ranges=%d, ch1=%d, ch2=%d, curr_ch=%d; ", JERRY_TRACE_MSG ("num_of_ranges=%d, ch1=%d, ch2=%d, curr_ch=%d; ",
num_of_ranges, ch1, ch2, curr_ch); num_of_ranges, ch1, ch2, curr_ch);
if (curr_ch >= ch1 && curr_ch <= ch2) if (curr_ch >= ch1 && curr_ch <= ch2)
{ {
@@ -628,7 +628,7 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
{ {
if (!is_match) if (!is_match)
{ {
JERRY_DDLOG ("fail\n"); JERRY_TRACE_MSG ("fail\n");
return ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */ return ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
} }
} }
@@ -637,11 +637,11 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
JERRY_ASSERT (op == RE_OP_INV_CHAR_CLASS); JERRY_ASSERT (op == RE_OP_INV_CHAR_CLASS);
if (is_match) if (is_match)
{ {
JERRY_DDLOG ("fail\n"); JERRY_TRACE_MSG ("fail\n");
return ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */ return ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
} }
} }
JERRY_DDLOG ("match\n"); JERRY_TRACE_MSG ("match\n");
break; /* tail merge */ break; /* tail merge */
} }
case RE_OP_BACKREFERENCE: case RE_OP_BACKREFERENCE:
@@ -649,13 +649,13 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
uint32_t backref_idx; uint32_t backref_idx;
backref_idx = re_get_value (&bc_p); backref_idx = re_get_value (&bc_p);
JERRY_DDLOG ("Execute RE_OP_BACKREFERENCE (idx: %d): ", backref_idx); JERRY_TRACE_MSG ("Execute RE_OP_BACKREFERENCE (idx: %d): ", backref_idx);
backref_idx *= 2; /* backref n -> saved indices [n*2, n*2+1] */ backref_idx *= 2; /* backref n -> saved indices [n*2, n*2+1] */
JERRY_ASSERT (backref_idx >= 2 && backref_idx + 1 < re_ctx_p->num_of_captures); JERRY_ASSERT (backref_idx >= 2 && backref_idx + 1 < re_ctx_p->num_of_captures);
if (!re_ctx_p->saved_p[backref_idx] || !re_ctx_p->saved_p[backref_idx + 1]) if (!re_ctx_p->saved_p[backref_idx] || !re_ctx_p->saved_p[backref_idx + 1])
{ {
JERRY_DDLOG ("match\n"); JERRY_TRACE_MSG ("match\n");
break; /* capture is 'undefined', always matches! */ break; /* capture is 'undefined', always matches! */
} }
@@ -667,7 +667,7 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
if (str_curr_p >= re_ctx_p->input_end_p) if (str_curr_p >= re_ctx_p->input_end_p)
{ {
JERRY_DDLOG ("fail\n"); JERRY_TRACE_MSG ("fail\n");
return ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */ return ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
} }
@@ -676,18 +676,18 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
if (ch1 != ch2) if (ch1 != ch2)
{ {
JERRY_DDLOG ("fail\n"); JERRY_TRACE_MSG ("fail\n");
return ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */ return ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
} }
} }
JERRY_DDLOG ("match\n"); JERRY_TRACE_MSG ("match\n");
break; /* tail merge */ break; /* tail merge */
} }
case RE_OP_SAVE_AT_START: case RE_OP_SAVE_AT_START:
{ {
uint8_t *old_bc_p; uint8_t *old_bc_p;
JERRY_DDLOG ("Execute RE_OP_SAVE_AT_START\n"); JERRY_TRACE_MSG ("Execute RE_OP_SAVE_AT_START\n");
const lit_utf8_byte_t *old_start_p = re_ctx_p->saved_p[RE_GLOBAL_START_IDX]; const lit_utf8_byte_t *old_start_p = re_ctx_p->saved_p[RE_GLOBAL_START_IDX];
re_ctx_p->saved_p[RE_GLOBAL_START_IDX] = str_curr_p; re_ctx_p->saved_p[RE_GLOBAL_START_IDX] = str_curr_p;
@@ -718,7 +718,7 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
} }
case RE_OP_SAVE_AND_MATCH: case RE_OP_SAVE_AND_MATCH:
{ {
JERRY_DDLOG ("End of pattern is reached: match\n"); JERRY_TRACE_MSG ("End of pattern is reached: match\n");
re_ctx_p->saved_p[RE_GLOBAL_END_IDX] = str_curr_p; re_ctx_p->saved_p[RE_GLOBAL_END_IDX] = str_curr_p;
*out_str_p = str_curr_p; *out_str_p = str_curr_p;
return ecma_make_simple_value (ECMA_SIMPLE_VALUE_TRUE); /* match */ return ecma_make_simple_value (ECMA_SIMPLE_VALUE_TRUE); /* match */
@@ -729,18 +729,18 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
* Alternatives should be jump over, when alternative opcode appears. * Alternatives should be jump over, when alternative opcode appears.
*/ */
uint32_t offset = re_get_value (&bc_p); uint32_t offset = re_get_value (&bc_p);
JERRY_DDLOG ("Execute RE_OP_ALTERNATIVE"); JERRY_TRACE_MSG ("Execute RE_OP_ALTERNATIVE");
bc_p += offset; bc_p += offset;
while (*bc_p == RE_OP_ALTERNATIVE) while (*bc_p == RE_OP_ALTERNATIVE)
{ {
JERRY_DDLOG (", jump: %d"); JERRY_TRACE_MSG (", jump: %d");
bc_p++; bc_p++;
offset = re_get_value (&bc_p); offset = re_get_value (&bc_p);
bc_p += offset; bc_p += offset;
} }
JERRY_DDLOG ("\n"); JERRY_TRACE_MSG ("\n");
break; /* tail merge */ break; /* tail merge */
} }
case RE_OP_CAPTURE_NON_GREEDY_ZERO_GROUP_START: case RE_OP_CAPTURE_NON_GREEDY_ZERO_GROUP_START:
@@ -1057,8 +1057,8 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
max = re_get_value (&bc_p); max = re_get_value (&bc_p);
offset = re_get_value (&bc_p); offset = re_get_value (&bc_p);
JERRY_DDLOG ("Non-greedy iterator, min=%lu, max=%lu, offset=%ld\n", JERRY_TRACE_MSG ("Non-greedy iterator, min=%lu, max=%lu, offset=%ld\n",
(unsigned long) min, (unsigned long) max, (long) offset); (unsigned long) min, (unsigned long) max, (long) offset);
num_of_iter = 0; num_of_iter = 0;
while (num_of_iter <= max) while (num_of_iter <= max)
@@ -1104,8 +1104,8 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
max = re_get_value (&bc_p); max = re_get_value (&bc_p);
offset = re_get_value (&bc_p); offset = re_get_value (&bc_p);
JERRY_DDLOG ("Greedy iterator, min=%lu, max=%lu, offset=%ld\n", JERRY_TRACE_MSG ("Greedy iterator, min=%lu, max=%lu, offset=%ld\n",
(unsigned long) min, (unsigned long) max, (long) offset); (unsigned long) min, (unsigned long) max, (long) offset);
num_of_iter = 0; num_of_iter = 0;
@@ -1153,7 +1153,7 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
} }
default: default:
{ {
JERRY_DDLOG ("UNKNOWN opcode (%d)!\n", (uint32_t) op); JERRY_TRACE_MSG ("UNKNOWN opcode (%d)!\n", (uint32_t) op);
return ecma_raise_common_error (ECMA_ERR_MSG ("")); return ecma_raise_common_error (ECMA_ERR_MSG (""));
} }
} }
@@ -1278,10 +1278,10 @@ ecma_regexp_exec_helper (ecma_value_t regexp_value, /**< RegExp object */
re_ctx.flags &= (uint16_t) ~RE_FLAG_GLOBAL; re_ctx.flags &= (uint16_t) ~RE_FLAG_GLOBAL;
} }
JERRY_DDLOG ("Exec with flags [global: %d, ignoreCase: %d, multiline: %d]\n", JERRY_TRACE_MSG ("Exec with flags [global: %d, ignoreCase: %d, multiline: %d]\n",
re_ctx.flags & RE_FLAG_GLOBAL, re_ctx.flags & RE_FLAG_GLOBAL,
re_ctx.flags & RE_FLAG_IGNORE_CASE, re_ctx.flags & RE_FLAG_IGNORE_CASE,
re_ctx.flags & RE_FLAG_MULTILINE); re_ctx.flags & RE_FLAG_MULTILINE);
re_ctx.num_of_captures = bc_p->num_of_captures; re_ctx.num_of_captures = bc_p->num_of_captures;
JERRY_ASSERT (re_ctx.num_of_captures % 2 == 0); JERRY_ASSERT (re_ctx.num_of_captures % 2 == 0);
+5 -5
View File
@@ -47,11 +47,11 @@ extern "C"
*/ */
typedef enum typedef enum
{ {
JERRY_INIT_EMPTY = (0u), /**< empty flag set */ JERRY_INIT_EMPTY = (0u), /**< empty flag set */
JERRY_INIT_ENABLE_LOG = (1u << 0), /**< enable logging */ JERRY_INIT_SHOW_OPCODES = (1u << 0), /**< dump byte-code to log after parse */
JERRY_INIT_SHOW_OPCODES = (1u << 1), /**< dump byte-code to stdout after parse */ JERRY_INIT_SHOW_REGEXP_OPCODES = (1u << 1), /**< dump regexp byte-code to log after compilation */
JERRY_INIT_MEM_STATS = (1u << 2), /**< dump memory statistics */ JERRY_INIT_MEM_STATS = (1u << 2), /**< dump memory statistics */
JERRY_INIT_MEM_STATS_SEPARATE = (1u << 3), /**< dump memory statistics and reset peak values after parse */ JERRY_INIT_MEM_STATS_SEPARATE = (1u << 3), /**< dump memory statistics and reset peak values after parse */
} jerry_init_flag_t; } jerry_init_flag_t;
/** /**
+22 -15
View File
@@ -143,27 +143,36 @@ jerry_init (jerry_init_flag_t flags) /**< combination of Jerry flags */
/* Zero out all members. */ /* Zero out all members. */
memset (&JERRY_CONTEXT (JERRY_CONTEXT_FIRST_MEMBER), 0, sizeof (jerry_context_t)); memset (&JERRY_CONTEXT (JERRY_CONTEXT_FIRST_MEMBER), 0, sizeof (jerry_context_t));
if (flags & (JERRY_INIT_ENABLE_LOG))
{
#ifndef JERRY_ENABLE_LOG
JERRY_WARNING_MSG ("Ignoring log options because of '!JERRY_ENABLE_LOG' build configuration.\n");
#endif /* !JERRY_ENABLE_LOG */
}
if (flags & (JERRY_INIT_MEM_STATS | JERRY_INIT_MEM_STATS_SEPARATE)) if (flags & (JERRY_INIT_MEM_STATS | JERRY_INIT_MEM_STATS_SEPARATE))
{ {
#ifndef JMEM_STATS #ifndef JMEM_STATS
flags &= (jerry_init_flag_t) ~(JERRY_INIT_MEM_STATS | JERRY_INIT_MEM_STATS_SEPARATE); flags &= (jerry_init_flag_t) ~(JERRY_INIT_MEM_STATS | JERRY_INIT_MEM_STATS_SEPARATE);
JERRY_WARNING_MSG ("Ignoring memory statistics option because of '!JMEM_STATS' build configuration.\n"); JERRY_WARNING_MSG ("Ignoring JERRY_INIT_MEM_STATS flag because of !JMEM_STATS configuration.\n");
#else /* JMEM_STATS */ #else /* JMEM_STATS */
if (flags & JERRY_INIT_MEM_STATS_SEPARATE) flags |= JERRY_INIT_MEM_STATS;
{
flags |= JERRY_INIT_MEM_STATS;
}
#endif /* !JMEM_STATS */ #endif /* !JMEM_STATS */
} }
if (flags & JERRY_INIT_SHOW_OPCODES)
{
#ifndef PARSER_DUMP_BYTE_CODE
flags &= (jerry_init_flag_t) ~JERRY_INIT_SHOW_OPCODES;
JERRY_WARNING_MSG ("Ignoring JERRY_INIT_SHOW_OPCODES flag because of !PARSER_DUMP_BYTE_CODE configuration.\n");
#endif /* !PARSER_DUMP_BYTE_CODE */
}
if (flags & JERRY_INIT_SHOW_REGEXP_OPCODES)
{
#ifndef REGEXP_DUMP_BYTE_CODE
flags &= (jerry_init_flag_t) ~JERRY_INIT_SHOW_REGEXP_OPCODES;
JERRY_WARNING_MSG ("Ignoring JERRY_INIT_SHOW_REGEXP_OPCODES flag "
"because of !REGEXP_DUMP_BYTE_CODE configuration.\n");
#endif /* !REGEXP_DUMP_BYTE_CODE */
}
JERRY_CONTEXT (jerry_init_flags) = flags; JERRY_CONTEXT (jerry_init_flags) = flags;
jerry_make_api_available (); jerry_make_api_available ();
@@ -182,7 +191,7 @@ jerry_cleanup (void)
jerry_make_api_unavailable (); jerry_make_api_unavailable ();
ecma_finalize (); ecma_finalize ();
jmem_finalize ((JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_MEM_STATS) != 0); jmem_finalize ();
} /* jerry_cleanup */ } /* jerry_cleanup */
/** /**
@@ -271,8 +280,6 @@ jerry_parse (const jerry_char_t *source_p, /**< script source */
{ {
jerry_assert_api_available (); jerry_assert_api_available ();
parser_set_show_instrs ((JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_SHOW_OPCODES));
ecma_compiled_code_t *bytecode_data_p; ecma_compiled_code_t *bytecode_data_p;
ecma_value_t parse_status; ecma_value_t parse_status;
+2 -5
View File
@@ -40,18 +40,15 @@ jmem_init (void)
* Finalize memory allocators. * Finalize memory allocators.
*/ */
void void
jmem_finalize (bool is_show_mem_stats) /**< show heap memory stats jmem_finalize ()
before finalization? */
{ {
jmem_pools_finalize (); jmem_pools_finalize ();
#ifdef JMEM_STATS #ifdef JMEM_STATS
if (is_show_mem_stats) if (JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_MEM_STATS)
{ {
jmem_stats_print (); jmem_stats_print ();
} }
#else /* !JMEM_STATS */
JERRY_UNUSED (is_show_mem_stats);
#endif /* JMEM_STATS */ #endif /* JMEM_STATS */
jmem_heap_finalize (); jmem_heap_finalize ();
+1 -1
View File
@@ -129,7 +129,7 @@ typedef void (*jmem_free_unused_memory_callback_t) (jmem_free_unused_memory_seve
} while (false); } while (false);
extern void jmem_init (void); extern void jmem_init (void);
extern void jmem_finalize (bool); extern void jmem_finalize (void);
extern uintptr_t jmem_compress_pointer (const void *); extern uintptr_t jmem_compress_pointer (const void *);
extern void *jmem_decompress_pointer (uintptr_t); extern void *jmem_decompress_pointer (uintptr_t);
+21 -22
View File
@@ -645,28 +645,27 @@ jmem_heap_stats_print (void)
{ {
jmem_heap_stats_t *heap_stats = &JERRY_CONTEXT (jmem_heap_stats); jmem_heap_stats_t *heap_stats = &JERRY_CONTEXT (jmem_heap_stats);
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, JERRY_DEBUG_MSG ("Heap stats:\n"
"Heap stats:\n" " Heap size = %zu bytes\n"
" Heap size = %zu bytes\n" " Allocated = %zu bytes\n"
" Allocated = %zu bytes\n" " Waste = %zu bytes\n"
" Waste = %zu bytes\n" " Peak allocated = %zu bytes\n"
" Peak allocated = %zu bytes\n" " Peak waste = %zu bytes\n"
" Peak waste = %zu bytes\n" " Skip-ahead ratio = %zu.%04zu\n"
" Skip-ahead ratio = %zu.%04zu\n" " Average alloc iteration = %zu.%04zu\n"
" Average alloc iteration = %zu.%04zu\n" " Average free iteration = %zu.%04zu\n"
" Average free iteration = %zu.%04zu\n" "\n",
"\n", heap_stats->size,
heap_stats->size, heap_stats->allocated_bytes,
heap_stats->allocated_bytes, heap_stats->waste_bytes,
heap_stats->waste_bytes, heap_stats->peak_allocated_bytes,
heap_stats->peak_allocated_bytes, heap_stats->peak_waste_bytes,
heap_stats->peak_waste_bytes, heap_stats->skip_count / heap_stats->nonskip_count,
heap_stats->skip_count / heap_stats->nonskip_count, heap_stats->skip_count % heap_stats->nonskip_count * 10000 / heap_stats->nonskip_count,
heap_stats->skip_count % heap_stats->nonskip_count * 10000 / heap_stats->nonskip_count, heap_stats->alloc_iter_count / heap_stats->alloc_count,
heap_stats->alloc_iter_count / heap_stats->alloc_count, heap_stats->alloc_iter_count % heap_stats->alloc_count * 10000 / heap_stats->alloc_count,
heap_stats->alloc_iter_count % heap_stats->alloc_count * 10000 / heap_stats->alloc_count, heap_stats->free_iter_count / heap_stats->free_count,
heap_stats->free_iter_count / heap_stats->free_count, heap_stats->free_iter_count % heap_stats->free_count * 10000 / heap_stats->free_count);
heap_stats->free_iter_count % heap_stats->free_count * 10000 / heap_stats->free_count);
} /* jmem_heap_stats_print */ } /* jmem_heap_stats_print */
/** /**
+12 -13
View File
@@ -190,19 +190,18 @@ jmem_pools_stats_print (void)
{ {
jmem_pools_stats_t *pools_stats = &JERRY_CONTEXT (jmem_pools_stats); jmem_pools_stats_t *pools_stats = &JERRY_CONTEXT (jmem_pools_stats);
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, JERRY_DEBUG_MSG ("Pools stats:\n"
"Pools stats:\n" " Chunk size: %zu\n"
" Chunk size: %zu\n" " Pool chunks: %zu\n"
" Pool chunks: %zu\n" " Peak pool chunks: %zu\n"
" Peak pool chunks: %zu\n" " Free chunks: %zu\n"
" Free chunks: %zu\n" " Pool reuse ratio: %zu.%04zu\n",
" Pool reuse ratio: %zu.%04zu\n", JMEM_POOL_CHUNK_SIZE,
JMEM_POOL_CHUNK_SIZE, pools_stats->pools_count,
pools_stats->pools_count, pools_stats->peak_pools_count,
pools_stats->peak_pools_count, pools_stats->free_chunks,
pools_stats->free_chunks, pools_stats->reused_count / pools_stats->new_alloc_count,
pools_stats->reused_count / pools_stats->new_alloc_count, pools_stats->reused_count % pools_stats->new_alloc_count * 10000 / pools_stats->new_alloc_count);
pools_stats->reused_count % pools_stats->new_alloc_count * 10000 / pools_stats->new_alloc_count);
} /* jmem_pools_stats_print */ } /* jmem_pools_stats_print */
/** /**
+12 -14
View File
@@ -38,7 +38,7 @@ jerry_fatal (jerry_fatal_code_t code) /**< status code */
{ {
case ERR_OUT_OF_MEMORY: case ERR_OUT_OF_MEMORY:
{ {
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Error: ERR_OUT_OF_MEMORY\n"); JERRY_ERROR_MSG ("Error: ERR_OUT_OF_MEMORY\n");
break; break;
} }
case ERR_SYSCALL: case ERR_SYSCALL:
@@ -48,12 +48,12 @@ jerry_fatal (jerry_fatal_code_t code) /**< status code */
} }
case ERR_REF_COUNT_LIMIT: case ERR_REF_COUNT_LIMIT:
{ {
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Error: ERR_REF_COUNT_LIMIT\n"); JERRY_ERROR_MSG ("Error: ERR_REF_COUNT_LIMIT\n");
break; break;
} }
case ERR_FAILED_INTERNAL_ASSERTION: case ERR_FAILED_INTERNAL_ASSERTION:
{ {
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Error: ERR_FAILED_INTERNAL_ASSERTION\n"); JERRY_ERROR_MSG ("Error: ERR_FAILED_INTERNAL_ASSERTION\n");
break; break;
} }
} }
@@ -77,12 +77,11 @@ jerry_assert_fail (const char *assertion, /**< assertion condition string */
const char *function, /**< function name */ const char *function, /**< function name */
const uint32_t line) /**< line */ const uint32_t line) /**< line */
{ {
jerry_port_log (JERRY_LOG_LEVEL_ERROR, JERRY_ERROR_MSG ("ICE: Assertion '%s' failed at %s(%s):%lu.\n",
"ICE: Assertion '%s' failed at %s(%s):%lu.\n", assertion,
assertion, file,
file, function,
function, (unsigned long) line);
(unsigned long) line);
jerry_fatal (ERR_FAILED_INTERNAL_ASSERTION); jerry_fatal (ERR_FAILED_INTERNAL_ASSERTION);
} /* jerry_assert_fail */ } /* jerry_assert_fail */
@@ -95,11 +94,10 @@ jerry_unreachable (const char *file, /**< file name */
const char *function, /**< function name */ const char *function, /**< function name */
const uint32_t line) /**< line */ const uint32_t line) /**< line */
{ {
jerry_port_log (JERRY_LOG_LEVEL_ERROR, JERRY_ERROR_MSG ("ICE: Unreachable control path at %s(%s):%lu was executed.\n",
"ICE: Unreachable control path at %s(%s):%lu was executed.\n", file,
file, function,
function, (unsigned long) line);
(unsigned long) line);
jerry_fatal (ERR_FAILED_INTERNAL_ASSERTION); jerry_fatal (ERR_FAILED_INTERNAL_ASSERTION);
} /* jerry_unreachable */ } /* jerry_unreachable */
+2 -20
View File
@@ -119,28 +119,10 @@ extern void __noreturn jerry_fatal (jerry_fatal_code_t);
/* /*
* Logging * Logging
*/ */
#ifdef JERRY_ENABLE_LOG
#define JERRY_DLOG(...) jerry_port_log (JERRY_LOG_LEVEL_DEBUG, __VA_ARGS__)
#define JERRY_DDLOG(...) jerry_port_log (JERRY_LOG_LEVEL_TRACE, __VA_ARGS__)
#else /* !JERRY_ENABLE_LOG */
/**
* Mark for unreachable points and unimplemented cases
*/
extern void jerry_ref_unused_variables (void *, ...);
#define JERRY_DLOG(...) \
do \
{ \
if (false) \
{ \
jerry_ref_unused_variables (0, __VA_ARGS__); \
} \
} while (0)
#define JERRY_DDLOG(...) JERRY_DLOG (__VA_ARGS__)
#endif /* JERRY_ENABLE_LOG */
#define JERRY_ERROR_MSG(...) jerry_port_log (JERRY_LOG_LEVEL_ERROR, __VA_ARGS__) #define JERRY_ERROR_MSG(...) jerry_port_log (JERRY_LOG_LEVEL_ERROR, __VA_ARGS__)
#define JERRY_WARNING_MSG(...) jerry_port_log (JERRY_LOG_LEVEL_WARNING, __VA_ARGS__) #define JERRY_WARNING_MSG(...) jerry_port_log (JERRY_LOG_LEVEL_WARNING, __VA_ARGS__)
#define JERRY_DEBUG_MSG(...) jerry_port_log (JERRY_LOG_LEVEL_DEBUG, __VA_ARGS__)
#define JERRY_TRACE_MSG(...) jerry_port_log (JERRY_LOG_LEVEL_TRACE, __VA_ARGS__)
/** /**
* Size of struct member * Size of struct member
+10 -10
View File
@@ -59,7 +59,7 @@ util_print_chars (const uint8_t *char_p, /**< character pointer */
{ {
while (size > 0) while (size > 0)
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "%c", *char_p++); JERRY_DEBUG_MSG ("%c", *char_p++);
size--; size--;
} }
} /* util_print_chars */ } /* util_print_chars */
@@ -73,7 +73,7 @@ util_print_number (ecma_number_t num_p) /**< number to print */
lit_utf8_byte_t str_buf[ECMA_MAX_CHARS_IN_STRINGIFIED_NUMBER]; lit_utf8_byte_t str_buf[ECMA_MAX_CHARS_IN_STRINGIFIED_NUMBER];
lit_utf8_size_t str_size = ecma_number_to_utf8_string (num_p, str_buf, sizeof (str_buf)); lit_utf8_size_t str_size = ecma_number_to_utf8_string (num_p, str_buf, sizeof (str_buf));
str_buf[str_size] = 0; str_buf[str_size] = 0;
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "%s", str_buf); JERRY_DEBUG_MSG ("%s", str_buf);
} /* util_print_number */ } /* util_print_number */
/** /**
@@ -86,22 +86,22 @@ util_print_literal (lexer_literal_t *literal_p) /**< literal */
{ {
if (literal_p->status_flags & LEXER_FLAG_VAR) if (literal_p->status_flags & LEXER_FLAG_VAR)
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "var_ident("); JERRY_DEBUG_MSG ("var_ident(");
} }
else else
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "ident("); JERRY_DEBUG_MSG ("ident(");
} }
util_print_chars (literal_p->u.char_p, literal_p->prop.length); util_print_chars (literal_p->u.char_p, literal_p->prop.length);
} }
else if (literal_p->type == LEXER_FUNCTION_LITERAL) else if (literal_p->type == LEXER_FUNCTION_LITERAL)
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "function"); JERRY_DEBUG_MSG ("function");
return; return;
} }
else if (literal_p->type == LEXER_STRING_LITERAL) else if (literal_p->type == LEXER_STRING_LITERAL)
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "string("); JERRY_DEBUG_MSG ("string(");
util_print_chars (literal_p->u.char_p, literal_p->prop.length); util_print_chars (literal_p->u.char_p, literal_p->prop.length);
} }
else if (literal_p->type == LEXER_NUMBER_LITERAL) else if (literal_p->type == LEXER_NUMBER_LITERAL)
@@ -110,21 +110,21 @@ util_print_literal (lexer_literal_t *literal_p) /**< literal */
JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (value_p) == ECMA_STRING_LITERAL_NUMBER); JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (value_p) == ECMA_STRING_LITERAL_NUMBER);
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "number("); JERRY_DEBUG_MSG ("number(");
util_print_number (ecma_get_number_from_value (value_p->u.lit_number)); util_print_number (ecma_get_number_from_value (value_p->u.lit_number));
} }
else if (literal_p->type == LEXER_REGEXP_LITERAL) else if (literal_p->type == LEXER_REGEXP_LITERAL)
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "regexp"); JERRY_DEBUG_MSG ("regexp");
return; return;
} }
else else
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "unknown"); JERRY_DEBUG_MSG ("unknown");
return; return;
} }
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, ")"); JERRY_DEBUG_MSG (")");
} /* util_print_literal */ } /* util_print_literal */
#endif /* PARSER_DUMP_BYTE_CODE */ #endif /* PARSER_DUMP_BYTE_CODE */
-5
View File
@@ -33,11 +33,6 @@
* @{ * @{
*/ */
#ifndef JERRY_NDEBUG
/* Note: This flag is independent from debug mode. */
#define PARSER_DUMP_BYTE_CODE
#endif /* !JERRY_NDEBUG */
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-regexp-object.h" #include "ecma-regexp-object.h"
#include "jmem-heap.h" #include "jmem-heap.h"
+1 -1
View File
@@ -1609,7 +1609,7 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
if (context_p->is_show_opcodes if (context_p->is_show_opcodes
&& switch_to_strict_mode) && switch_to_strict_mode)
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " Note: switch to strict mode\n\n"); JERRY_DEBUG_MSG (" Note: switch to strict mode\n\n");
} }
#endif /* PARSER_DUMP_BYTE_CODE */ #endif /* PARSER_DUMP_BYTE_CODE */
+13 -14
View File
@@ -170,13 +170,13 @@ parser_flush_cbc (parser_context_t *context_p) /**< context */
name_p = cbc_ext_names[PARSER_GET_EXT_OPCODE (context_p->last_cbc_opcode)]; name_p = cbc_ext_names[PARSER_GET_EXT_OPCODE (context_p->last_cbc_opcode)];
} }
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " [%3d] %s", (int) context_p->stack_depth, name_p); JERRY_DEBUG_MSG (" [%3d] %s", (int) context_p->stack_depth, name_p);
if (flags & (CBC_HAS_LITERAL_ARG | CBC_HAS_LITERAL_ARG2)) if (flags & (CBC_HAS_LITERAL_ARG | CBC_HAS_LITERAL_ARG2))
{ {
uint16_t literal_index = context_p->last_cbc.literal_index; uint16_t literal_index = context_p->last_cbc.literal_index;
lexer_literal_t *literal_p = PARSER_GET_LITERAL (literal_index); lexer_literal_t *literal_p = PARSER_GET_LITERAL (literal_index);
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " idx:%d->", literal_index); JERRY_DEBUG_MSG (" idx:%d->", literal_index);
util_print_literal (literal_p); util_print_literal (literal_p);
} }
@@ -184,7 +184,7 @@ parser_flush_cbc (parser_context_t *context_p) /**< context */
{ {
uint16_t literal_index = context_p->last_cbc.value; uint16_t literal_index = context_p->last_cbc.value;
lexer_literal_t *literal_p = PARSER_GET_LITERAL (literal_index); lexer_literal_t *literal_p = PARSER_GET_LITERAL (literal_index);
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " idx:%d->", literal_index); JERRY_DEBUG_MSG (" idx:%d->", literal_index);
util_print_literal (literal_p); util_print_literal (literal_p);
if (!(flags & CBC_HAS_LITERAL_ARG)) if (!(flags & CBC_HAS_LITERAL_ARG))
@@ -192,17 +192,17 @@ parser_flush_cbc (parser_context_t *context_p) /**< context */
literal_index = context_p->last_cbc.third_literal_index; literal_index = context_p->last_cbc.third_literal_index;
lexer_literal_t *literal_p = PARSER_GET_LITERAL (literal_index); lexer_literal_t *literal_p = PARSER_GET_LITERAL (literal_index);
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " idx:%d->", literal_index); JERRY_DEBUG_MSG (" idx:%d->", literal_index);
util_print_literal (literal_p); util_print_literal (literal_p);
} }
} }
if (flags & CBC_HAS_BYTE_ARG) if (flags & CBC_HAS_BYTE_ARG)
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " byte_arg:%d", (int) context_p->last_cbc.value); JERRY_DEBUG_MSG (" byte_arg:%d", (int) context_p->last_cbc.value);
} }
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "\n"); JERRY_DEBUG_MSG ("\n");
} }
#endif /* PARSER_DUMP_BYTE_CODE */ #endif /* PARSER_DUMP_BYTE_CODE */
@@ -327,11 +327,10 @@ parser_emit_cbc_push_number (parser_context_t *context_p, /**< context */
real_value = -real_value; real_value = -real_value;
} }
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, JERRY_DEBUG_MSG (" [%3d] %s number:%d\n",
" [%3d] %s number:%d\n", (int) context_p->stack_depth,
(int) context_p->stack_depth, cbc_names[opcode],
cbc_names[opcode], real_value);
real_value);
} }
#endif /* PARSER_DUMP_BYTE_CODE */ #endif /* PARSER_DUMP_BYTE_CODE */
@@ -395,11 +394,11 @@ parser_emit_cbc_forward_branch (parser_context_t *context_p, /**< context */
{ {
if (extra_byte_code_increase == 0) if (extra_byte_code_increase == 0)
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " [%3d] %s\n", (int) context_p->stack_depth, cbc_names[opcode]); JERRY_DEBUG_MSG (" [%3d] %s\n", (int) context_p->stack_depth, cbc_names[opcode]);
} }
else else
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " [%3d] %s\n", (int) context_p->stack_depth, cbc_ext_names[opcode]); JERRY_DEBUG_MSG (" [%3d] %s\n", (int) context_p->stack_depth, cbc_ext_names[opcode]);
} }
} }
#endif /* PARSER_DUMP_BYTE_CODE */ #endif /* PARSER_DUMP_BYTE_CODE */
@@ -510,7 +509,7 @@ parser_emit_cbc_backward_branch (parser_context_t *context_p, /**< context */
#ifdef PARSER_DUMP_BYTE_CODE #ifdef PARSER_DUMP_BYTE_CODE
if (context_p->is_show_opcodes) if (context_p->is_show_opcodes)
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " [%3d] %s\n", (int) context_p->stack_depth, name); JERRY_DEBUG_MSG (" [%3d] %s\n", (int) context_p->stack_depth, name);
} }
#endif /* PARSER_DUMP_BYTE_CODE */ #endif /* PARSER_DUMP_BYTE_CODE */
+46 -64
View File
@@ -17,12 +17,9 @@
#include "ecma-exceptions.h" #include "ecma-exceptions.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-literal-storage.h" #include "ecma-literal-storage.h"
#include "jcontext.h"
#include "js-parser-internal.h" #include "js-parser-internal.h"
#ifdef PARSER_DUMP_BYTE_CODE
static bool parser_show_instrs = false;
#endif /* PARSER_DUMP_BYTE_CODE */
/** \addtogroup parser Parser /** \addtogroup parser Parser
* @{ * @{
* *
@@ -873,35 +870,35 @@ parse_print_literal (ecma_compiled_code_t *compiled_code_p, /**< compiled code *
if (literal_index == const_literal_end) if (literal_index == const_literal_end)
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " idx:%d(self)->function", literal_index); JERRY_DEBUG_MSG (" idx:%d(self)->function", literal_index);
break; break;
} }
JERRY_ASSERT (literal_index < argument_end); JERRY_ASSERT (literal_index < argument_end);
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " idx:%d(arg)->undefined", literal_index); JERRY_DEBUG_MSG (" idx:%d(arg)->undefined", literal_index);
break; break;
} }
if (literal_p->prop.index == literal_index if (literal_p->prop.index == literal_index
&& literal_p->type != LEXER_UNUSED_LITERAL) && literal_p->type != LEXER_UNUSED_LITERAL)
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " idx:%d", literal_index); JERRY_DEBUG_MSG (" idx:%d", literal_index);
if (literal_index < argument_end) if (literal_index < argument_end)
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "(arg)->"); JERRY_DEBUG_MSG ("(arg)->");
} }
else if (literal_index < register_end) else if (literal_index < register_end)
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "(reg)->"); JERRY_DEBUG_MSG ("(reg)->");
} }
else if (literal_index < ident_end) else if (literal_index < ident_end)
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "(ident)->"); JERRY_DEBUG_MSG ("(ident)->");
} }
else else
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "(lit)->"); JERRY_DEBUG_MSG ("(lit)->");
} }
util_print_literal (literal_p); util_print_literal (literal_p);
@@ -946,14 +943,14 @@ parse_print_define_vars (ecma_compiled_code_t *compiled_code_p, /**< compiled co
PARSER_READ_IDENTIFIER_INDEX (identifier_end); PARSER_READ_IDENTIFIER_INDEX (identifier_end);
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " from: %d to: %d\n", identifier_index, identifier_end); JERRY_DEBUG_MSG (" from: %d to: %d\n", identifier_index, identifier_end);
while (identifier_index <= identifier_end) while (identifier_index <= identifier_end)
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " "); JERRY_DEBUG_MSG (" ");
parse_print_literal (compiled_code_p, identifier_index, literal_pool_p); parse_print_literal (compiled_code_p, identifier_index, literal_pool_p);
identifier_index++; identifier_index++;
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "\n"); JERRY_DEBUG_MSG ("\n");
} }
return byte_code_p; return byte_code_p;
@@ -977,21 +974,21 @@ parse_print_initialize_vars (ecma_compiled_code_t *compiled_code_p, /**< compile
PARSER_READ_IDENTIFIER_INDEX (identifier_index); PARSER_READ_IDENTIFIER_INDEX (identifier_index);
PARSER_READ_IDENTIFIER_INDEX (identifier_end); PARSER_READ_IDENTIFIER_INDEX (identifier_end);
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " from: %d to: %d\n", identifier_index, identifier_end); JERRY_DEBUG_MSG (" from: %d to: %d\n", identifier_index, identifier_end);
while (identifier_index <= identifier_end) while (identifier_index <= identifier_end)
{ {
uint16_t literal_index; uint16_t literal_index;
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " "); JERRY_DEBUG_MSG (" ");
parse_print_literal (compiled_code_p, identifier_index, literal_pool_p); parse_print_literal (compiled_code_p, identifier_index, literal_pool_p);
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " ="); JERRY_DEBUG_MSG (" =");
PARSER_READ_IDENTIFIER_INDEX (literal_index); PARSER_READ_IDENTIFIER_INDEX (literal_index);
parse_print_literal (compiled_code_p, literal_index, literal_pool_p); parse_print_literal (compiled_code_p, literal_index, literal_pool_p);
identifier_index++; identifier_index++;
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "\n"); JERRY_DEBUG_MSG ("\n");
} }
return byte_code_p; return byte_code_p;
@@ -1039,50 +1036,49 @@ parse_print_final_cbc (ecma_compiled_code_t *compiled_code_p, /**< compiled code
literal_end = args->literal_end; literal_end = args->literal_end;
} }
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, JERRY_DEBUG_MSG ("\nFinal byte code dump:\n\n Maximum stack depth: %d\n Flags: [",
"\nFinal byte code dump:\n\n Maximum stack depth: %d\n Flags: [", (int) stack_limit);
(int) stack_limit);
if (!(compiled_code_p->status_flags & CBC_CODE_FLAGS_FULL_LITERAL_ENCODING)) if (!(compiled_code_p->status_flags & CBC_CODE_FLAGS_FULL_LITERAL_ENCODING))
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "small_lit_enc"); JERRY_DEBUG_MSG ("small_lit_enc");
encoding_limit = 255; encoding_limit = 255;
encoding_delta = 0xfe01; encoding_delta = 0xfe01;
} }
else else
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "full_lit_enc"); JERRY_DEBUG_MSG ("full_lit_enc");
encoding_limit = 128; encoding_limit = 128;
encoding_delta = 0x8000; encoding_delta = 0x8000;
} }
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS) if (compiled_code_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS)
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, ",uint16_arguments"); JERRY_DEBUG_MSG (",uint16_arguments");
} }
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_STRICT_MODE) if (compiled_code_p->status_flags & CBC_CODE_FLAGS_STRICT_MODE)
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, ",strict_mode"); JERRY_DEBUG_MSG (",strict_mode");
} }
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_ARGUMENTS_NEEDED) if (compiled_code_p->status_flags & CBC_CODE_FLAGS_ARGUMENTS_NEEDED)
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, ",arguments_needed"); JERRY_DEBUG_MSG (",arguments_needed");
} }
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_LEXICAL_ENV_NOT_NEEDED) if (compiled_code_p->status_flags & CBC_CODE_FLAGS_LEXICAL_ENV_NOT_NEEDED)
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, ",no_lexical_env"); JERRY_DEBUG_MSG (",no_lexical_env");
} }
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "]\n"); JERRY_DEBUG_MSG ("]\n");
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " Argument range end: %d\n", (int) argument_end); JERRY_DEBUG_MSG (" Argument range end: %d\n", (int) argument_end);
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " Register range end: %d\n", (int) register_end); JERRY_DEBUG_MSG (" Register range end: %d\n", (int) register_end);
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " Identifier range end: %d\n", (int) ident_end); JERRY_DEBUG_MSG (" Identifier range end: %d\n", (int) ident_end);
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " Const literal range end: %d\n", (int) const_literal_end); JERRY_DEBUG_MSG (" Const literal range end: %d\n", (int) const_literal_end);
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " Literal range end: %d\n\n", (int) literal_end); JERRY_DEBUG_MSG (" Literal range end: %d\n\n", (int) literal_end);
byte_code_start_p = (uint8_t *) compiled_code_p; byte_code_start_p = (uint8_t *) compiled_code_p;
@@ -1112,7 +1108,7 @@ parse_print_final_cbc (ecma_compiled_code_t *compiled_code_p, /**< compiled code
if (opcode != CBC_EXT_OPCODE) if (opcode != CBC_EXT_OPCODE)
{ {
flags = cbc_flags[opcode]; flags = cbc_flags[opcode];
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " %3d : %s", (int) cbc_offset, cbc_names[opcode]); JERRY_DEBUG_MSG (" %3d : %s", (int) cbc_offset, cbc_names[opcode]);
byte_code_p++; byte_code_p++;
if (opcode == CBC_INITIALIZE_VARS) if (opcode == CBC_INITIALIZE_VARS)
@@ -1138,14 +1134,14 @@ parse_print_final_cbc (ecma_compiled_code_t *compiled_code_p, /**< compiled code
if (opcode == CBC_PUSH_NUMBER_POS_BYTE) if (opcode == CBC_PUSH_NUMBER_POS_BYTE)
{ {
int value = *byte_code_p++; int value = *byte_code_p++;
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " number:%d\n", value + 1); JERRY_DEBUG_MSG (" number:%d\n", value + 1);
continue; continue;
} }
if (opcode == CBC_PUSH_NUMBER_NEG_BYTE) if (opcode == CBC_PUSH_NUMBER_NEG_BYTE)
{ {
int value = *byte_code_p++; int value = *byte_code_p++;
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " number:%d\n", -(value + 1)); JERRY_DEBUG_MSG (" number:%d\n", -(value + 1));
continue; continue;
} }
} }
@@ -1153,7 +1149,7 @@ parse_print_final_cbc (ecma_compiled_code_t *compiled_code_p, /**< compiled code
{ {
ext_opcode = (cbc_ext_opcode_t) byte_code_p[1]; ext_opcode = (cbc_ext_opcode_t) byte_code_p[1];
flags = cbc_ext_flags[ext_opcode]; flags = cbc_ext_flags[ext_opcode];
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " %3d : %s", (int) cbc_offset, cbc_ext_names[ext_opcode]); JERRY_DEBUG_MSG (" %3d : %s", (int) cbc_offset, cbc_ext_names[ext_opcode]);
byte_code_p += 2; byte_code_p += 2;
} }
@@ -1181,7 +1177,7 @@ parse_print_final_cbc (ecma_compiled_code_t *compiled_code_p, /**< compiled code
if (flags & CBC_HAS_BYTE_ARG) if (flags & CBC_HAS_BYTE_ARG)
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " byte_arg:%d", *byte_code_p); JERRY_DEBUG_MSG (" byte_arg:%d", *byte_code_p);
byte_code_p++; byte_code_p++;
} }
@@ -1203,15 +1199,15 @@ parse_print_final_cbc (ecma_compiled_code_t *compiled_code_p, /**< compiled code
if (CBC_BRANCH_IS_FORWARD (flags)) if (CBC_BRANCH_IS_FORWARD (flags))
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " offset:%d(->%d)", (int) offset, (int) (cbc_offset + offset)); JERRY_DEBUG_MSG (" offset:%d(->%d)", (int) offset, (int) (cbc_offset + offset));
} }
else else
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " offset:%d(->%d)", (int) offset, (int) (cbc_offset - offset)); JERRY_DEBUG_MSG (" offset:%d(->%d)", (int) offset, (int) (cbc_offset - offset));
} }
} }
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "\n"); JERRY_DEBUG_MSG ("\n");
} }
} /* parse_print_final_cbc */ } /* parse_print_final_cbc */
@@ -1688,7 +1684,7 @@ parser_post_processing (parser_context_t *context_p) /**< context */
lexer_literal_t *literal_p; lexer_literal_t *literal_p;
parse_print_final_cbc (compiled_code_p, &context_p->literal_pool, length); parse_print_final_cbc (compiled_code_p, &context_p->literal_pool, length);
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "\nByte code size: %d bytes\n", (int) length); JERRY_DEBUG_MSG ("\nByte code size: %d bytes\n", (int) length);
context_p->total_byte_code_size += (uint32_t) length; context_p->total_byte_code_size += (uint32_t) length;
parser_list_iterator_init (&context_p->literal_pool, &literal_iterator); parser_list_iterator_init (&context_p->literal_pool, &literal_iterator);
@@ -1854,12 +1850,12 @@ parser_parse_source (const uint8_t *source_p, /**< valid UTF-8 source code */
#endif /* !JERRY_NDEBUG */ #endif /* !JERRY_NDEBUG */
#ifdef PARSER_DUMP_BYTE_CODE #ifdef PARSER_DUMP_BYTE_CODE
context.is_show_opcodes = parser_show_instrs; context.is_show_opcodes = (JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_SHOW_OPCODES);
context.total_byte_code_size = 0; context.total_byte_code_size = 0;
if (context.is_show_opcodes) if (context.is_show_opcodes)
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "\n--- Script parsing start ---\n\n"); JERRY_DEBUG_MSG ("\n--- Script parsing start ---\n\n");
} }
#endif /* PARSER_DUMP_BYTE_CODE */ #endif /* PARSER_DUMP_BYTE_CODE */
@@ -1893,9 +1889,8 @@ parser_parse_source (const uint8_t *source_p, /**< valid UTF-8 source code */
#ifdef PARSER_DUMP_BYTE_CODE #ifdef PARSER_DUMP_BYTE_CODE
if (context.is_show_opcodes) if (context.is_show_opcodes)
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, JERRY_DEBUG_MSG ("\nScript parsing successfully completed. Total byte code size: %d bytes\n",
"\nScript parsing successfully completed. Total byte code size: %d bytes\n", (int) context.total_byte_code_size);
(int) context.total_byte_code_size);
} }
#endif /* PARSER_DUMP_BYTE_CODE */ #endif /* PARSER_DUMP_BYTE_CODE */
} }
@@ -1928,7 +1923,7 @@ parser_parse_source (const uint8_t *source_p, /**< valid UTF-8 source code */
#ifdef PARSER_DUMP_BYTE_CODE #ifdef PARSER_DUMP_BYTE_CODE
if (context.is_show_opcodes) if (context.is_show_opcodes)
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "\n--- Script parsing end ---\n\n"); JERRY_DEBUG_MSG ("\n--- Script parsing end ---\n\n");
} }
#endif /* PARSER_DUMP_BYTE_CODE */ #endif /* PARSER_DUMP_BYTE_CODE */
@@ -1997,7 +1992,7 @@ parser_parse_function (parser_context_t *context_p, /**< context */
#ifdef PARSER_DUMP_BYTE_CODE #ifdef PARSER_DUMP_BYTE_CODE
if (context_p->is_show_opcodes) if (context_p->is_show_opcodes)
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "\n--- Function parsing start ---\n\n"); JERRY_DEBUG_MSG ("\n--- Function parsing start ---\n\n");
} }
#endif /* PARSER_DUMP_BYTE_CODE */ #endif /* PARSER_DUMP_BYTE_CODE */
@@ -2144,7 +2139,7 @@ parser_parse_function (parser_context_t *context_p, /**< context */
if (context_p->is_show_opcodes if (context_p->is_show_opcodes
&& (context_p->status_flags & PARSER_HAS_NON_STRICT_ARG)) && (context_p->status_flags & PARSER_HAS_NON_STRICT_ARG))
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " Note: legacy (non-strict) argument definition\n\n"); JERRY_DEBUG_MSG (" Note: legacy (non-strict) argument definition\n\n");
} }
#endif /* PARSER_DUMP_BYTE_CODE */ #endif /* PARSER_DUMP_BYTE_CODE */
@@ -2160,7 +2155,7 @@ parser_parse_function (parser_context_t *context_p, /**< context */
#ifdef PARSER_DUMP_BYTE_CODE #ifdef PARSER_DUMP_BYTE_CODE
if (context_p->is_show_opcodes) if (context_p->is_show_opcodes)
{ {
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "\n--- Function parsing end ---\n\n"); JERRY_DEBUG_MSG ("\n--- Function parsing end ---\n\n");
} }
#endif /* PARSER_DUMP_BYTE_CODE */ #endif /* PARSER_DUMP_BYTE_CODE */
@@ -2226,19 +2221,6 @@ parser_raise_error (parser_context_t *context_p, /**< context */
JERRY_ASSERT (0); JERRY_ASSERT (0);
} /* parser_raise_error */ } /* parser_raise_error */
/**
* Tell parser whether to dump bytecode
*/
void
parser_set_show_instrs (int show_instrs) /**< flag indicating whether to dump bytecode */
{
#ifdef PARSER_DUMP_BYTE_CODE
parser_show_instrs = show_instrs;
#else /* !PARSER_DUMP_BYTE_CODE */
JERRY_UNUSED (show_instrs);
#endif /* PARSER_DUMP_BYTE_CODE */
} /* parser_set_show_instrs */
/** /**
* Parse EcamScript source code * Parse EcamScript source code
* *
-2
View File
@@ -133,8 +133,6 @@ extern ecma_value_t parser_parse_script (const uint8_t *, size_t, bool, ecma_com
const char *parser_error_to_string (parser_error_t); const char *parser_error_to_string (parser_error_t);
extern void parser_set_show_instrs (int);
/** /**
* @} * @}
* @} * @}
+68 -68
View File
@@ -232,7 +232,7 @@ re_insert_u32 (re_bytecode_ctx_t *bc_ctx_p, /**< RegExp bytecode context */
re_bytecode_list_insert (bc_ctx_p, offset, (uint8_t *) &value, sizeof (uint32_t)); re_bytecode_list_insert (bc_ctx_p, offset, (uint8_t *) &value, sizeof (uint32_t));
} /* re_insert_u32 */ } /* re_insert_u32 */
#ifdef JERRY_ENABLE_LOG #ifdef REGEXP_DUMP_BYTE_CODE
/** /**
* RegExp bytecode dumper * RegExp bytecode dumper
*/ */
@@ -240,9 +240,9 @@ void
re_dump_bytecode (re_bytecode_ctx_t *bc_ctx_p) /**< RegExp bytecode context */ re_dump_bytecode (re_bytecode_ctx_t *bc_ctx_p) /**< RegExp bytecode context */
{ {
re_compiled_code_t *compiled_code_p = (re_compiled_code_t *) bc_ctx_p->block_start_p; re_compiled_code_t *compiled_code_p = (re_compiled_code_t *) bc_ctx_p->block_start_p;
JERRY_DLOG ("%d ", compiled_code_p->header.status_flags); JERRY_DEBUG_MSG ("%d ", compiled_code_p->header.status_flags);
JERRY_DLOG ("%d ", compiled_code_p->num_of_captures); JERRY_DEBUG_MSG ("%d ", compiled_code_p->num_of_captures);
JERRY_DLOG ("%d | ", compiled_code_p->num_of_non_captures); JERRY_DEBUG_MSG ("%d | ", compiled_code_p->num_of_non_captures);
uint8_t *bytecode_p = (uint8_t *) (compiled_code_p + 1); uint8_t *bytecode_p = (uint8_t *) (compiled_code_p + 1);
@@ -253,188 +253,188 @@ re_dump_bytecode (re_bytecode_ctx_t *bc_ctx_p) /**< RegExp bytecode context */
{ {
case RE_OP_MATCH: case RE_OP_MATCH:
{ {
JERRY_DLOG ("MATCH, "); JERRY_DEBUG_MSG ("MATCH, ");
break; break;
} }
case RE_OP_CHAR: case RE_OP_CHAR:
{ {
JERRY_DLOG ("CHAR "); JERRY_DEBUG_MSG ("CHAR ");
JERRY_DLOG ("%c, ", (char) re_get_char (&bytecode_p)); JERRY_DEBUG_MSG ("%c, ", (char) re_get_char (&bytecode_p));
break; break;
} }
case RE_OP_CAPTURE_NON_GREEDY_ZERO_GROUP_START: case RE_OP_CAPTURE_NON_GREEDY_ZERO_GROUP_START:
{ {
JERRY_DLOG ("N"); JERRY_DEBUG_MSG ("N");
/* FALLTHRU */ /* FALLTHRU */
} }
case RE_OP_CAPTURE_GREEDY_ZERO_GROUP_START: case RE_OP_CAPTURE_GREEDY_ZERO_GROUP_START:
{ {
JERRY_DLOG ("GZ_START "); JERRY_DEBUG_MSG ("GZ_START ");
JERRY_DLOG ("%d ", re_get_value (&bytecode_p)); JERRY_DEBUG_MSG ("%d ", re_get_value (&bytecode_p));
JERRY_DLOG ("%d ", re_get_value (&bytecode_p)); JERRY_DEBUG_MSG ("%d ", re_get_value (&bytecode_p));
JERRY_DLOG ("%d, ", re_get_value (&bytecode_p)); JERRY_DEBUG_MSG ("%d, ", re_get_value (&bytecode_p));
break; break;
} }
case RE_OP_CAPTURE_GROUP_START: case RE_OP_CAPTURE_GROUP_START:
{ {
JERRY_DLOG ("START "); JERRY_DEBUG_MSG ("START ");
JERRY_DLOG ("%d ", re_get_value (&bytecode_p)); JERRY_DEBUG_MSG ("%d ", re_get_value (&bytecode_p));
JERRY_DLOG ("%d, ", re_get_value (&bytecode_p)); JERRY_DEBUG_MSG ("%d, ", re_get_value (&bytecode_p));
break; break;
} }
case RE_OP_CAPTURE_NON_GREEDY_GROUP_END: case RE_OP_CAPTURE_NON_GREEDY_GROUP_END:
{ {
JERRY_DLOG ("N"); JERRY_DEBUG_MSG ("N");
/* FALLTHRU */ /* FALLTHRU */
} }
case RE_OP_CAPTURE_GREEDY_GROUP_END: case RE_OP_CAPTURE_GREEDY_GROUP_END:
{ {
JERRY_DLOG ("G_END "); JERRY_DEBUG_MSG ("G_END ");
JERRY_DLOG ("%d ", re_get_value (&bytecode_p)); JERRY_DEBUG_MSG ("%d ", re_get_value (&bytecode_p));
JERRY_DLOG ("%d ", re_get_value (&bytecode_p)); JERRY_DEBUG_MSG ("%d ", re_get_value (&bytecode_p));
JERRY_DLOG ("%d ", re_get_value (&bytecode_p)); JERRY_DEBUG_MSG ("%d ", re_get_value (&bytecode_p));
JERRY_DLOG ("%d, ", re_get_value (&bytecode_p)); JERRY_DEBUG_MSG ("%d, ", re_get_value (&bytecode_p));
break; break;
} }
case RE_OP_NON_CAPTURE_NON_GREEDY_ZERO_GROUP_START: case RE_OP_NON_CAPTURE_NON_GREEDY_ZERO_GROUP_START:
{ {
JERRY_DLOG ("N"); JERRY_DEBUG_MSG ("N");
/* FALLTHRU */ /* FALLTHRU */
} }
case RE_OP_NON_CAPTURE_GREEDY_ZERO_GROUP_START: case RE_OP_NON_CAPTURE_GREEDY_ZERO_GROUP_START:
{ {
JERRY_DLOG ("GZ_NC_START "); JERRY_DEBUG_MSG ("GZ_NC_START ");
JERRY_DLOG ("%d ", re_get_value (&bytecode_p)); JERRY_DEBUG_MSG ("%d ", re_get_value (&bytecode_p));
JERRY_DLOG ("%d ", re_get_value (&bytecode_p)); JERRY_DEBUG_MSG ("%d ", re_get_value (&bytecode_p));
JERRY_DLOG ("%d, ", re_get_value (&bytecode_p)); JERRY_DEBUG_MSG ("%d, ", re_get_value (&bytecode_p));
break; break;
} }
case RE_OP_NON_CAPTURE_GROUP_START: case RE_OP_NON_CAPTURE_GROUP_START:
{ {
JERRY_DLOG ("NC_START "); JERRY_DEBUG_MSG ("NC_START ");
JERRY_DLOG ("%d ", re_get_value (&bytecode_p)); JERRY_DEBUG_MSG ("%d ", re_get_value (&bytecode_p));
JERRY_DLOG ("%d, ", re_get_value (&bytecode_p)); JERRY_DEBUG_MSG ("%d, ", re_get_value (&bytecode_p));
break; break;
} }
case RE_OP_NON_CAPTURE_NON_GREEDY_GROUP_END: case RE_OP_NON_CAPTURE_NON_GREEDY_GROUP_END:
{ {
JERRY_DLOG ("N"); JERRY_DEBUG_MSG ("N");
/* FALLTHRU */ /* FALLTHRU */
} }
case RE_OP_NON_CAPTURE_GREEDY_GROUP_END: case RE_OP_NON_CAPTURE_GREEDY_GROUP_END:
{ {
JERRY_DLOG ("G_NC_END "); JERRY_DEBUG_MSG ("G_NC_END ");
JERRY_DLOG ("%d ", re_get_value (&bytecode_p)); JERRY_DEBUG_MSG ("%d ", re_get_value (&bytecode_p));
JERRY_DLOG ("%d ", re_get_value (&bytecode_p)); JERRY_DEBUG_MSG ("%d ", re_get_value (&bytecode_p));
JERRY_DLOG ("%d ", re_get_value (&bytecode_p)); JERRY_DEBUG_MSG ("%d ", re_get_value (&bytecode_p));
JERRY_DLOG ("%d, ", re_get_value (&bytecode_p)); JERRY_DEBUG_MSG ("%d, ", re_get_value (&bytecode_p));
break; break;
} }
case RE_OP_SAVE_AT_START: case RE_OP_SAVE_AT_START:
{ {
JERRY_DLOG ("RE_START "); JERRY_DEBUG_MSG ("RE_START ");
JERRY_DLOG ("%d, ", re_get_value (&bytecode_p)); JERRY_DEBUG_MSG ("%d, ", re_get_value (&bytecode_p));
break; break;
} }
case RE_OP_SAVE_AND_MATCH: case RE_OP_SAVE_AND_MATCH:
{ {
JERRY_DLOG ("RE_END, "); JERRY_DEBUG_MSG ("RE_END, ");
break; break;
} }
case RE_OP_GREEDY_ITERATOR: case RE_OP_GREEDY_ITERATOR:
{ {
JERRY_DLOG ("GREEDY_ITERATOR "); JERRY_DEBUG_MSG ("GREEDY_ITERATOR ");
JERRY_DLOG ("%d ", re_get_value (&bytecode_p)); JERRY_DEBUG_MSG ("%d ", re_get_value (&bytecode_p));
JERRY_DLOG ("%d ", re_get_value (&bytecode_p)); JERRY_DEBUG_MSG ("%d ", re_get_value (&bytecode_p));
JERRY_DLOG ("%d, ", re_get_value (&bytecode_p)); JERRY_DEBUG_MSG ("%d, ", re_get_value (&bytecode_p));
break; break;
} }
case RE_OP_NON_GREEDY_ITERATOR: case RE_OP_NON_GREEDY_ITERATOR:
{ {
JERRY_DLOG ("NON_GREEDY_ITERATOR "); JERRY_DEBUG_MSG ("NON_GREEDY_ITERATOR ");
JERRY_DLOG ("%d, ", re_get_value (&bytecode_p)); JERRY_DEBUG_MSG ("%d, ", re_get_value (&bytecode_p));
JERRY_DLOG ("%d, ", re_get_value (&bytecode_p)); JERRY_DEBUG_MSG ("%d, ", re_get_value (&bytecode_p));
JERRY_DLOG ("%d, ", re_get_value (&bytecode_p)); JERRY_DEBUG_MSG ("%d, ", re_get_value (&bytecode_p));
break; break;
} }
case RE_OP_PERIOD: case RE_OP_PERIOD:
{ {
JERRY_DLOG ("PERIOD "); JERRY_DEBUG_MSG ("PERIOD ");
break; break;
} }
case RE_OP_ALTERNATIVE: case RE_OP_ALTERNATIVE:
{ {
JERRY_DLOG ("ALTERNATIVE "); JERRY_DEBUG_MSG ("ALTERNATIVE ");
JERRY_DLOG ("%d, ", re_get_value (&bytecode_p)); JERRY_DEBUG_MSG ("%d, ", re_get_value (&bytecode_p));
break; break;
} }
case RE_OP_ASSERT_START: case RE_OP_ASSERT_START:
{ {
JERRY_DLOG ("ASSERT_START "); JERRY_DEBUG_MSG ("ASSERT_START ");
break; break;
} }
case RE_OP_ASSERT_END: case RE_OP_ASSERT_END:
{ {
JERRY_DLOG ("ASSERT_END "); JERRY_DEBUG_MSG ("ASSERT_END ");
break; break;
} }
case RE_OP_ASSERT_WORD_BOUNDARY: case RE_OP_ASSERT_WORD_BOUNDARY:
{ {
JERRY_DLOG ("ASSERT_WORD_BOUNDARY "); JERRY_DEBUG_MSG ("ASSERT_WORD_BOUNDARY ");
break; break;
} }
case RE_OP_ASSERT_NOT_WORD_BOUNDARY: case RE_OP_ASSERT_NOT_WORD_BOUNDARY:
{ {
JERRY_DLOG ("ASSERT_NOT_WORD_BOUNDARY "); JERRY_DEBUG_MSG ("ASSERT_NOT_WORD_BOUNDARY ");
break; break;
} }
case RE_OP_LOOKAHEAD_POS: case RE_OP_LOOKAHEAD_POS:
{ {
JERRY_DLOG ("LOOKAHEAD_POS "); JERRY_DEBUG_MSG ("LOOKAHEAD_POS ");
JERRY_DLOG ("%d, ", re_get_value (&bytecode_p)); JERRY_DEBUG_MSG ("%d, ", re_get_value (&bytecode_p));
break; break;
} }
case RE_OP_LOOKAHEAD_NEG: case RE_OP_LOOKAHEAD_NEG:
{ {
JERRY_DLOG ("LOOKAHEAD_NEG "); JERRY_DEBUG_MSG ("LOOKAHEAD_NEG ");
JERRY_DLOG ("%d, ", re_get_value (&bytecode_p)); JERRY_DEBUG_MSG ("%d, ", re_get_value (&bytecode_p));
break; break;
} }
case RE_OP_BACKREFERENCE: case RE_OP_BACKREFERENCE:
{ {
JERRY_DLOG ("BACKREFERENCE "); JERRY_DEBUG_MSG ("BACKREFERENCE ");
JERRY_DLOG ("%d, ", re_get_value (&bytecode_p)); JERRY_DEBUG_MSG ("%d, ", re_get_value (&bytecode_p));
break; break;
} }
case RE_OP_INV_CHAR_CLASS: case RE_OP_INV_CHAR_CLASS:
{ {
JERRY_DLOG ("INV_"); JERRY_DEBUG_MSG ("INV_");
/* FALLTHRU */ /* FALLTHRU */
} }
case RE_OP_CHAR_CLASS: case RE_OP_CHAR_CLASS:
{ {
JERRY_DLOG ("CHAR_CLASS "); JERRY_DEBUG_MSG ("CHAR_CLASS ");
uint32_t num_of_class = re_get_value (&bytecode_p); uint32_t num_of_class = re_get_value (&bytecode_p);
JERRY_DLOG ("%d", num_of_class); JERRY_DEBUG_MSG ("%d", num_of_class);
while (num_of_class) while (num_of_class)
{ {
JERRY_DLOG (" %d", re_get_char (&bytecode_p)); JERRY_DEBUG_MSG (" %d", re_get_char (&bytecode_p));
JERRY_DLOG ("-%d", re_get_char (&bytecode_p)); JERRY_DEBUG_MSG ("-%d", re_get_char (&bytecode_p));
num_of_class--; num_of_class--;
} }
JERRY_DLOG (", "); JERRY_DEBUG_MSG (", ");
break; break;
} }
default: default:
{ {
JERRY_DLOG ("UNKNOWN(%d), ", (uint32_t) op); JERRY_DEBUG_MSG ("UNKNOWN(%d), ", (uint32_t) op);
break; break;
} }
} }
} }
JERRY_DLOG ("EOF\n"); JERRY_DEBUG_MSG ("EOF\n");
} /* re_dump_bytecode */ } /* re_dump_bytecode */
#endif /* JERRY_ENABLE_LOG */ #endif /* REGEXP_DUMP_BYTE_CODE */
/** /**
* @} * @}
+2 -2
View File
@@ -115,9 +115,9 @@ void re_insert_opcode (re_bytecode_ctx_t *, uint32_t, re_opcode_t);
void re_insert_u32 (re_bytecode_ctx_t *, uint32_t, uint32_t); void re_insert_u32 (re_bytecode_ctx_t *, uint32_t, uint32_t);
void re_bytecode_list_insert (re_bytecode_ctx_t *, size_t, uint8_t *, size_t); void re_bytecode_list_insert (re_bytecode_ctx_t *, size_t, uint8_t *, size_t);
#ifdef JERRY_ENABLE_LOG #ifdef REGEXP_DUMP_BYTE_CODE
void re_dump_bytecode (re_bytecode_ctx_t *bc_ctx); void re_dump_bytecode (re_bytecode_ctx_t *bc_ctx);
#endif /* JERRY_ENABLE_LOG */ #endif /* REGEXP_DUMP_BYTE_CODE */
/** /**
* @} * @}
+26 -23
View File
@@ -237,7 +237,7 @@ re_parse_alternative (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context
case RE_TOK_START_CAPTURE_GROUP: case RE_TOK_START_CAPTURE_GROUP:
{ {
idx = re_ctx_p->num_of_captures++; idx = re_ctx_p->num_of_captures++;
JERRY_DDLOG ("Compile a capture group start (idx: %d)\n", idx); JERRY_TRACE_MSG ("Compile a capture group start (idx: %d)\n", idx);
ret_value = re_parse_alternative (re_ctx_p, false); ret_value = re_parse_alternative (re_ctx_p, false);
@@ -251,7 +251,7 @@ re_parse_alternative (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context
case RE_TOK_START_NON_CAPTURE_GROUP: case RE_TOK_START_NON_CAPTURE_GROUP:
{ {
idx = re_ctx_p->num_of_non_captures++; idx = re_ctx_p->num_of_non_captures++;
JERRY_DDLOG ("Compile a non-capture group start (idx: %d)\n", idx); JERRY_TRACE_MSG ("Compile a non-capture group start (idx: %d)\n", idx);
ret_value = re_parse_alternative (re_ctx_p, false); ret_value = re_parse_alternative (re_ctx_p, false);
@@ -264,8 +264,8 @@ re_parse_alternative (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context
} }
case RE_TOK_CHAR: case RE_TOK_CHAR:
{ {
JERRY_DDLOG ("Compile character token: %c, qmin: %d, qmax: %d\n", JERRY_TRACE_MSG ("Compile character token: %c, qmin: %d, qmax: %d\n",
re_ctx_p->current_token.value, re_ctx_p->current_token.qmin, re_ctx_p->current_token.qmax); re_ctx_p->current_token.value, re_ctx_p->current_token.qmin, re_ctx_p->current_token.qmax);
re_append_opcode (bc_ctx_p, RE_OP_CHAR); re_append_opcode (bc_ctx_p, RE_OP_CHAR);
re_append_char (bc_ctx_p, re_canonicalize ((ecma_char_t) re_ctx_p->current_token.value, re_append_char (bc_ctx_p, re_canonicalize ((ecma_char_t) re_ctx_p->current_token.value,
@@ -279,7 +279,7 @@ re_parse_alternative (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context
} }
case RE_TOK_PERIOD: case RE_TOK_PERIOD:
{ {
JERRY_DDLOG ("Compile a period\n"); JERRY_TRACE_MSG ("Compile a period\n");
re_append_opcode (bc_ctx_p, RE_OP_PERIOD); re_append_opcode (bc_ctx_p, RE_OP_PERIOD);
if ((re_ctx_p->current_token.qmin != 1) || (re_ctx_p->current_token.qmax != 1)) if ((re_ctx_p->current_token.qmin != 1) || (re_ctx_p->current_token.qmax != 1))
@@ -290,7 +290,7 @@ re_parse_alternative (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context
} }
case RE_TOK_ALTERNATIVE: case RE_TOK_ALTERNATIVE:
{ {
JERRY_DDLOG ("Compile an alternative\n"); JERRY_TRACE_MSG ("Compile an alternative\n");
re_insert_u32 (bc_ctx_p, alterantive_offset, re_get_bytecode_length (bc_ctx_p) - alterantive_offset); re_insert_u32 (bc_ctx_p, alterantive_offset, re_get_bytecode_length (bc_ctx_p) - alterantive_offset);
re_append_opcode (bc_ctx_p, RE_OP_ALTERNATIVE); re_append_opcode (bc_ctx_p, RE_OP_ALTERNATIVE);
alterantive_offset = re_get_bytecode_length (re_ctx_p->bytecode_ctx_p); alterantive_offset = re_get_bytecode_length (re_ctx_p->bytecode_ctx_p);
@@ -298,31 +298,31 @@ re_parse_alternative (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context
} }
case RE_TOK_ASSERT_START: case RE_TOK_ASSERT_START:
{ {
JERRY_DDLOG ("Compile a start assertion\n"); JERRY_TRACE_MSG ("Compile a start assertion\n");
re_append_opcode (bc_ctx_p, RE_OP_ASSERT_START); re_append_opcode (bc_ctx_p, RE_OP_ASSERT_START);
break; break;
} }
case RE_TOK_ASSERT_END: case RE_TOK_ASSERT_END:
{ {
JERRY_DDLOG ("Compile an end assertion\n"); JERRY_TRACE_MSG ("Compile an end assertion\n");
re_append_opcode (bc_ctx_p, RE_OP_ASSERT_END); re_append_opcode (bc_ctx_p, RE_OP_ASSERT_END);
break; break;
} }
case RE_TOK_ASSERT_WORD_BOUNDARY: case RE_TOK_ASSERT_WORD_BOUNDARY:
{ {
JERRY_DDLOG ("Compile a word boundary assertion\n"); JERRY_TRACE_MSG ("Compile a word boundary assertion\n");
re_append_opcode (bc_ctx_p, RE_OP_ASSERT_WORD_BOUNDARY); re_append_opcode (bc_ctx_p, RE_OP_ASSERT_WORD_BOUNDARY);
break; break;
} }
case RE_TOK_ASSERT_NOT_WORD_BOUNDARY: case RE_TOK_ASSERT_NOT_WORD_BOUNDARY:
{ {
JERRY_DDLOG ("Compile a not word boundary assertion\n"); JERRY_TRACE_MSG ("Compile a not word boundary assertion\n");
re_append_opcode (bc_ctx_p, RE_OP_ASSERT_NOT_WORD_BOUNDARY); re_append_opcode (bc_ctx_p, RE_OP_ASSERT_NOT_WORD_BOUNDARY);
break; break;
} }
case RE_TOK_ASSERT_START_POS_LOOKAHEAD: case RE_TOK_ASSERT_START_POS_LOOKAHEAD:
{ {
JERRY_DDLOG ("Compile a positive lookahead assertion\n"); JERRY_TRACE_MSG ("Compile a positive lookahead assertion\n");
idx = re_ctx_p->num_of_non_captures++; idx = re_ctx_p->num_of_non_captures++;
re_append_opcode (bc_ctx_p, RE_OP_LOOKAHEAD_POS); re_append_opcode (bc_ctx_p, RE_OP_LOOKAHEAD_POS);
@@ -339,7 +339,7 @@ re_parse_alternative (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context
} }
case RE_TOK_ASSERT_START_NEG_LOOKAHEAD: case RE_TOK_ASSERT_START_NEG_LOOKAHEAD:
{ {
JERRY_DDLOG ("Compile a negative lookahead assertion\n"); JERRY_TRACE_MSG ("Compile a negative lookahead assertion\n");
idx = re_ctx_p->num_of_non_captures++; idx = re_ctx_p->num_of_non_captures++;
re_append_opcode (bc_ctx_p, RE_OP_LOOKAHEAD_NEG); re_append_opcode (bc_ctx_p, RE_OP_LOOKAHEAD_NEG);
@@ -364,7 +364,7 @@ re_parse_alternative (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context
re_ctx_p->highest_backref = backref; re_ctx_p->highest_backref = backref;
} }
JERRY_DDLOG ("Compile a backreference: %d\n", backref); JERRY_TRACE_MSG ("Compile a backreference: %d\n", backref);
re_append_opcode (bc_ctx_p, RE_OP_BACKREFERENCE); re_append_opcode (bc_ctx_p, RE_OP_BACKREFERENCE);
re_append_u32 (bc_ctx_p, backref); re_append_u32 (bc_ctx_p, backref);
@@ -380,7 +380,7 @@ re_parse_alternative (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context
case RE_TOK_START_CHAR_CLASS: case RE_TOK_START_CHAR_CLASS:
case RE_TOK_START_INV_CHAR_CLASS: case RE_TOK_START_INV_CHAR_CLASS:
{ {
JERRY_DDLOG ("Compile a character class\n"); JERRY_TRACE_MSG ("Compile a character class\n");
re_append_opcode (bc_ctx_p, re_append_opcode (bc_ctx_p,
re_ctx_p->current_token.type == RE_TOK_START_INV_CHAR_CLASS re_ctx_p->current_token.type == RE_TOK_START_INV_CHAR_CLASS
? RE_OP_INV_CHAR_CLASS ? RE_OP_INV_CHAR_CLASS
@@ -406,7 +406,7 @@ re_parse_alternative (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context
} }
case RE_TOK_END_GROUP: case RE_TOK_END_GROUP:
{ {
JERRY_DDLOG ("Compile a group end\n"); JERRY_TRACE_MSG ("Compile a group end\n");
if (expect_eof) if (expect_eof)
{ {
@@ -469,7 +469,7 @@ re_find_bytecode_in_cache (ecma_string_t *pattern_str_p, /**< pattern string */
if ((cached_bytecode_p->header.status_flags & RE_FLAGS_MASK) == flags if ((cached_bytecode_p->header.status_flags & RE_FLAGS_MASK) == flags
&& ecma_compare_ecma_strings (cached_pattern_str_p, pattern_str_p)) && ecma_compare_ecma_strings (cached_pattern_str_p, pattern_str_p))
{ {
JERRY_DDLOG ("RegExp is found in cache\n"); JERRY_TRACE_MSG ("RegExp is found in cache\n");
return idx; return idx;
} }
} }
@@ -480,7 +480,7 @@ re_find_bytecode_in_cache (ecma_string_t *pattern_str_p, /**< pattern string */
} }
} }
JERRY_DDLOG ("RegExp is NOT found in cache\n"); JERRY_TRACE_MSG ("RegExp is NOT found in cache\n");
return free_idx; return free_idx;
} /* re_find_bytecode_in_cache */ } /* re_find_bytecode_in_cache */
@@ -594,15 +594,18 @@ re_compile_bytecode (const re_compiled_code_t **out_bytecode_p, /**< [out] point
if (!ecma_is_value_empty (ret_value)) if (!ecma_is_value_empty (ret_value))
{ {
/* Compilation failed, free bytecode. */ /* Compilation failed, free bytecode. */
JERRY_DDLOG ("RegExp compilation failed!\n"); JERRY_TRACE_MSG ("RegExp compilation failed!\n");
jmem_heap_free_block (bc_ctx.block_start_p, byte_code_size); jmem_heap_free_block (bc_ctx.block_start_p, byte_code_size);
*out_bytecode_p = NULL; *out_bytecode_p = NULL;
} }
else else
{ {
#ifdef JERRY_ENABLE_LOG #ifdef REGEXP_DUMP_BYTE_CODE
re_dump_bytecode (&bc_ctx); if (JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_SHOW_REGEXP_OPCODES)
#endif /* JERRY_ENABLE_LOG */ {
re_dump_bytecode (&bc_ctx);
}
#endif /* REGEXP_DUMP_BYTE_CODE */
/* The RegExp bytecode contains at least a RE_OP_SAVE_AT_START opdoce, so it cannot be NULL. */ /* The RegExp bytecode contains at least a RE_OP_SAVE_AT_START opdoce, so it cannot be NULL. */
JERRY_ASSERT (bc_ctx.block_start_p != NULL); JERRY_ASSERT (bc_ctx.block_start_p != NULL);
@@ -617,7 +620,7 @@ re_compile_bytecode (const re_compiled_code_t **out_bytecode_p, /**< [out] point
JERRY_CONTEXT (re_cache_idx) = 0; JERRY_CONTEXT (re_cache_idx) = 0;
} }
JERRY_DDLOG ("RegExp cache is full! Remove the element on idx: %d\n", JERRY_CONTEXT (re_cache_idx)); JERRY_TRACE_MSG ("RegExp cache is full! Remove the element on idx: %d\n", JERRY_CONTEXT (re_cache_idx));
cache_idx = JERRY_CONTEXT (re_cache_idx)++; cache_idx = JERRY_CONTEXT (re_cache_idx)++;
@@ -629,7 +632,7 @@ re_compile_bytecode (const re_compiled_code_t **out_bytecode_p, /**< [out] point
} }
} }
JERRY_DDLOG ("Insert bytecode into RegExp cache (idx: %d).\n", cache_idx); JERRY_TRACE_MSG ("Insert bytecode into RegExp cache (idx: %d).\n", cache_idx);
ecma_bytecode_ref ((ecma_compiled_code_t *) *out_bytecode_p); ecma_bytecode_ref ((ecma_compiled_code_t *) *out_bytecode_p);
JERRY_CONTEXT (re_cache)[cache_idx] = *out_bytecode_p; JERRY_CONTEXT (re_cache)[cache_idx] = *out_bytecode_p;
} }
+6 -3
View File
@@ -111,6 +111,7 @@ print_help (char *name)
" --mem-stats-separate\n" " --mem-stats-separate\n"
" --parse-only\n" " --parse-only\n"
" --show-opcodes\n" " --show-opcodes\n"
" --show-regexp-opcodes\n"
" --save-snapshot-for-global FILE\n" " --save-snapshot-for-global FILE\n"
" --save-snapshot-for-eval FILE\n" " --save-snapshot-for-eval FILE\n"
" --exec-snapshot FILE\n" " --exec-snapshot FILE\n"
@@ -187,6 +188,11 @@ main (int argc,
flags |= JERRY_INIT_SHOW_OPCODES; flags |= JERRY_INIT_SHOW_OPCODES;
jerry_port_default_set_log_level (JERRY_LOG_LEVEL_DEBUG); jerry_port_default_set_log_level (JERRY_LOG_LEVEL_DEBUG);
} }
else if (!strcmp ("--show-regexp-opcodes", argv[i]))
{
flags |= JERRY_INIT_SHOW_REGEXP_OPCODES;
jerry_port_default_set_log_level (JERRY_LOG_LEVEL_DEBUG);
}
else if (!strcmp ("--save-snapshot-for-global", argv[i]) else if (!strcmp ("--save-snapshot-for-global", argv[i])
|| !strcmp ("--save-snapshot-for-eval", argv[i])) || !strcmp ("--save-snapshot-for-eval", argv[i]))
{ {
@@ -237,10 +243,7 @@ main (int argc,
return JERRY_STANDALONE_EXIT_CODE_FAIL; return JERRY_STANDALONE_EXIT_CODE_FAIL;
} }
#ifdef JERRY_ENABLE_LOG
flags |= JERRY_INIT_ENABLE_LOG;
jerry_port_default_set_log_level (argv[i][0] - '0'); jerry_port_default_set_log_level (argv[i][0] - '0');
#endif /* JERRY_ENABLE_LOG */
} }
else if (!strcmp ("--abort-on-fail", argv[i])) else if (!strcmp ("--abort-on-fail", argv[i]))
{ {
-2
View File
@@ -209,9 +209,7 @@ int jerryscript_entry (int argc, char *argv[])
flags |= JERRY_FLAG_ENABLE_LOG; flags |= JERRY_FLAG_ENABLE_LOG;
if (++i < argc && strlen (argv[i]) == 1 && argv[i][0] >='0' && argv[i][0] <= '3') if (++i < argc && strlen (argv[i]) == 1 && argv[i][0] >='0' && argv[i][0] <= '3')
{ {
#ifdef JERRY_ENABLE_LOG
jerry_debug_level = argv[i][0] - '0'; jerry_debug_level = argv[i][0] - '0';
#endif /* JERRY_ENABLE_LOG */
} }
else else
{ {
+1 -1
View File
@@ -74,7 +74,7 @@ main ()
TEST_ASSERT (length == 3); TEST_ASSERT (length == 3);
ecma_finalize (); ecma_finalize ();
jmem_finalize (true); jmem_finalize ();
return 0; return 0;
} /* main */ } /* main */
+1 -1
View File
@@ -129,6 +129,6 @@ main ()
} }
ecma_finalize_lit_storage (); ecma_finalize_lit_storage ();
jmem_finalize (true); jmem_finalize ();
return 0; return 0;
} /* main */ } /* main */
+1 -1
View File
@@ -82,7 +82,7 @@ main ()
jmem_pools_stats_print (); jmem_pools_stats_print ();
#endif /* JMEM_STATS */ #endif /* JMEM_STATS */
jmem_finalize (false); jmem_finalize ();
return 0; return 0;
} /* main */ } /* main */
+1 -1
View File
@@ -217,7 +217,7 @@ main ()
TEST_ASSERT (res_buf[2] == 0xBF); TEST_ASSERT (res_buf[2] == 0xBF);
ecma_finalize (); ecma_finalize ();
jmem_finalize (true); jmem_finalize ();
return 0; return 0;
} /* main */ } /* main */
+5 -3
View File
@@ -40,10 +40,11 @@ def add_build_args(parser):
parser.add_argument('--lto', choices=['on', 'off'], default='on', help='Enable link-time optimizations (default: %(default)s)') parser.add_argument('--lto', choices=['on', 'off'], default='on', help='Enable link-time optimizations (default: %(default)s)')
parser.add_argument('--profile', choices=['full', 'minimal'], default='full', help='Specify the profile (default: %(default)s)') parser.add_argument('--profile', choices=['full', 'minimal'], default='full', help='Specify the profile (default: %(default)s)')
parser.add_argument('--error-messages', choices=['on', 'off'], default='off', help='Enable error messages (default: %(default)s)') parser.add_argument('--error-messages', choices=['on', 'off'], default='off', help='Enable error messages (default: %(default)s)')
parser.add_argument('--log', choices=['on', 'off'], default='off', help='Enable logging (default: %(default)s)')
parser.add_argument('--valgrind', choices=['on', 'off'], default='off', help='Enable Valgrind support (default: %(default)s)') parser.add_argument('--valgrind', choices=['on', 'off'], default='off', help='Enable Valgrind support (default: %(default)s)')
parser.add_argument('--valgrind-freya', choices=['on', 'off'], default='off', help='Enable Valgrind-Freya support (default: %(default)s)') parser.add_argument('--valgrind-freya', choices=['on', 'off'], default='off', help='Enable Valgrind-Freya support (default: %(default)s)')
parser.add_argument('--mem-stats', choices=['on', 'off'], default='off', help='Enable memory-statistics (default: %(default)s)') parser.add_argument('--show-opcodes', choices=['on', 'off'], default='off', help='Enable parser byte-code dumps (default: %(default)s)')
parser.add_argument('--show-regexp-opcodes', choices=['on', 'off'], default='off', help='Enable regexp byte-code dumps (default: %(default)s)')
parser.add_argument('--mem-stats', choices=['on', 'off'], default='off', help='Enable memory statistics (default: %(default)s)')
parser.add_argument('--mem-stress-test', choices=['on', 'off'], default='off', help='Enable mem-stress test (default: %(default)s)') parser.add_argument('--mem-stress-test', choices=['on', 'off'], default='off', help='Enable mem-stress test (default: %(default)s)')
parser.add_argument('--snapshot-save', choices=['on', 'off'], default='on', help='Allow to save snapshot files (default: %(default)s)') parser.add_argument('--snapshot-save', choices=['on', 'off'], default='on', help='Allow to save snapshot files (default: %(default)s)')
parser.add_argument('--snapshot-exec', choices=['on', 'off'], default='on', help='Allow to execute snapshot files (default: %(default)s)') parser.add_argument('--snapshot-exec', choices=['on', 'off'], default='on', help='Allow to execute snapshot files (default: %(default)s)')
@@ -75,9 +76,10 @@ def generate_build_options(arguments):
build_options.append('-DCMAKE_BUILD_TYPE=%s' % arguments.build_type) build_options.append('-DCMAKE_BUILD_TYPE=%s' % arguments.build_type)
build_options.append('-DFEATURE_PROFILE=%s' % arguments.profile) build_options.append('-DFEATURE_PROFILE=%s' % arguments.profile)
build_options.append('-DFEATURE_ERROR_MESSAGES=%s' % arguments.error_messages.upper()) build_options.append('-DFEATURE_ERROR_MESSAGES=%s' % arguments.error_messages.upper())
build_options.append('-DFEATURE_LOG=%s' % arguments.log.upper())
build_options.append('-DFEATURE_VALGRIND=%s' % arguments.valgrind.upper()) build_options.append('-DFEATURE_VALGRIND=%s' % arguments.valgrind.upper())
build_options.append('-DFEATURE_VALGRIND_FREYA=%s' % arguments.valgrind_freya.upper()) build_options.append('-DFEATURE_VALGRIND_FREYA=%s' % arguments.valgrind_freya.upper())
build_options.append('-DFEATURE_PARSER_DUMP=%s' % arguments.show_opcodes.upper())
build_options.append('-DFEATURE_REGEXP_DUMP=%s' % arguments.show_regexp_opcodes.upper())
build_options.append('-DFEATURE_MEM_STATS=%s' % arguments.mem_stats.upper()) build_options.append('-DFEATURE_MEM_STATS=%s' % arguments.mem_stats.upper())
build_options.append('-DFEATURE_MEM_STRESS_TEST=%s' % arguments.mem_stress_test.upper()) build_options.append('-DFEATURE_MEM_STRESS_TEST=%s' % arguments.mem_stress_test.upper())
build_options.append('-DFEATURE_SNAPSHOT_SAVE=%s' % arguments.snapshot_save.upper()) build_options.append('-DFEATURE_SNAPSHOT_SAVE=%s' % arguments.snapshot_save.upper())
+1 -1
View File
@@ -43,7 +43,7 @@ function is_mem_stats_build
[ -x "$1" ] || fail_msg "Engine '$1' is not executable" [ -x "$1" ] || fail_msg "Engine '$1' is not executable"
tmpfile=`mktemp` tmpfile=`mktemp`
"$1" --mem-stats $tmpfile 2>&1 | grep -- "Ignoring memory statistics option because of '!JMEM_STATS' build configuration." 2>&1 > /dev/null "$1" --mem-stats $tmpfile 2>&1 | grep -- "Ignoring JERRY_INIT_MEM_STATS flag because of !JMEM_STATS configuration." 2>&1 > /dev/null
code=$? code=$?
rm $tmpfile rm $tmpfile
+1 -1
View File
@@ -32,7 +32,7 @@ function is_mem_stats_build() {
[ -x "$1" ] || fail_msg "Engine '$1' is not executable" [ -x "$1" ] || fail_msg "Engine '$1' is not executable"
tmpfile=`mktemp` tmpfile=`mktemp`
"$1" --mem-stats $tmpfile 2>&1 | grep -- "Ignoring memory statistics option because of '!JMEM_STATS' build configuration." 2>&1 > /dev/null "$1" --mem-stats $tmpfile 2>&1 | grep -- "Ignoring JERRY_INIT_MEM_STATS flag because of !JMEM_STATS configuration." 2>&1 > /dev/null
code=$? code=$?
rm $tmpfile rm $tmpfile
+3 -1
View File
@@ -80,11 +80,13 @@ jerry_test_suite_options.append(Options('jerry_test_suite-minimal-debug-snapshot
# Test options for buildoption-test # Test options for buildoption-test
jerry_buildoptions = [ jerry_buildoptions = [
Options('buildoption_test-lto', ['--lto=on']), Options('buildoption_test-lto', ['--lto=on']),
Options('buildoption_test-log', ['--log=on']),
Options('buildoption_test-error_messages', ['--error-messages=on']), Options('buildoption_test-error_messages', ['--error-messages=on']),
Options('buildoption_test-all_in_one', ['--all-in-one=on']), Options('buildoption_test-all_in_one', ['--all-in-one=on']),
Options('buildoption_test-valgrind', ['--valgrind=on']), Options('buildoption_test-valgrind', ['--valgrind=on']),
Options('buildoption_test-valgrind_freya', ['--valgrind-freya=on']), Options('buildoption_test-valgrind_freya', ['--valgrind-freya=on']),
Options('buildoption_test-mem_stats', ['--mem-stats=on']),
Options('buildoption_test-show_opcodes', ['--show-opcodes=on']),
Options('buildoption_test-show_regexp_opcodes', ['--show-regexp-opcodes=on']),
Options('buildoption_test-jerry_libc', ['--jerry-libc=on', '--compiler-default-libc=off']), Options('buildoption_test-jerry_libc', ['--jerry-libc=on', '--compiler-default-libc=off']),
Options('buildoption_test-compiler_default_libc', ['--compiler-default-libc=on', '--jerry-libc=off']), Options('buildoption_test-compiler_default_libc', ['--compiler-default-libc=on', '--jerry-libc=off']),
] ]