diff --git a/jerry-core/parser/js/js-parser-statm.c b/jerry-core/parser/js/js-parser-statm.c index 28b978f45..81e33dcb2 100644 --- a/jerry-core/parser/js/js-parser-statm.c +++ b/jerry-core/parser/js/js-parser-statm.c @@ -1670,9 +1670,6 @@ parser_parse_statements (parser_context_t *context_p) /**< context */ { lexer_lit_location_t lit_location; uint32_t status_flags = context_p->status_flags; -#ifdef PARSER_DUMP_BYTE_CODE - bool switch_to_strict_mode = false; -#endif /* PARSER_DUMP_BYTE_CODE */ JERRY_ASSERT (context_p->stack_depth == 0); @@ -1683,10 +1680,6 @@ parser_parse_statements (parser_context_t *context_p) /**< context */ && memcmp (PARSER_USE_STRICT_LITERAL, lit_location.char_p, PARSER_USE_STRICT_LENGTH) == 0) { context_p->status_flags |= PARSER_IS_STRICT; - -#ifdef PARSER_DUMP_BYTE_CODE - switch_to_strict_mode = true; -#endif /* PARSER_DUMP_BYTE_CODE */ } lexer_next_token (context_p); @@ -1731,7 +1724,8 @@ parser_parse_statements (parser_context_t *context_p) /**< context */ #ifdef PARSER_DUMP_BYTE_CODE if (context_p->is_show_opcodes - && switch_to_strict_mode) + && !(status_flags & PARSER_IS_STRICT) + && (context_p->status_flags & PARSER_IS_STRICT)) { JERRY_DEBUG_MSG (" Note: switch to strict mode\n\n"); } diff --git a/jerry-core/parser/js/js-parser-util.c b/jerry-core/parser/js/js-parser-util.c index e3c25b545..1394d9db4 100644 --- a/jerry-core/parser/js/js-parser-util.c +++ b/jerry-core/parser/js/js-parser-util.c @@ -86,17 +86,18 @@ void parser_flush_cbc (parser_context_t *context_p) /**< context */ { uint8_t flags; + uint16_t last_opcode = context_p->last_cbc_opcode; - if (context_p->last_cbc_opcode == PARSER_CBC_UNAVAILABLE) + if (last_opcode == PARSER_CBC_UNAVAILABLE) { return; } context_p->status_flags |= PARSER_NO_END_LABEL; - if (PARSER_IS_BASIC_OPCODE (context_p->last_cbc_opcode)) + if (PARSER_IS_BASIC_OPCODE (last_opcode)) { - cbc_opcode_t opcode = (cbc_opcode_t) context_p->last_cbc_opcode; + cbc_opcode_t opcode = (cbc_opcode_t) last_opcode; JERRY_ASSERT (opcode < CBC_END); flags = cbc_flags[opcode]; @@ -106,7 +107,7 @@ parser_flush_cbc (parser_context_t *context_p) /**< context */ } else { - cbc_ext_opcode_t opcode = (cbc_ext_opcode_t) PARSER_GET_EXT_OPCODE (context_p->last_cbc_opcode); + cbc_ext_opcode_t opcode = (cbc_ext_opcode_t) PARSER_GET_EXT_OPCODE (last_opcode); JERRY_ASSERT (opcode < CBC_EXT_END); flags = cbc_ext_flags[opcode]; @@ -167,18 +168,10 @@ parser_flush_cbc (parser_context_t *context_p) /**< context */ #ifdef PARSER_DUMP_BYTE_CODE if (context_p->is_show_opcodes) { - const char *name_p; - - if (PARSER_IS_BASIC_OPCODE (context_p->last_cbc_opcode)) - { - name_p = cbc_names[context_p->last_cbc_opcode]; - } - else - { - name_p = cbc_ext_names[PARSER_GET_EXT_OPCODE (context_p->last_cbc_opcode)]; - } - - JERRY_DEBUG_MSG (" [%3d] %s", (int) context_p->stack_depth, name_p); + JERRY_DEBUG_MSG (" [%3d] %s", + (int) context_p->stack_depth, + PARSER_IS_BASIC_OPCODE (last_opcode) ? cbc_names[last_opcode] + : cbc_ext_names[PARSER_GET_EXT_OPCODE (last_opcode)]); if (flags & (CBC_HAS_LITERAL_ARG | CBC_HAS_LITERAL_ARG2)) { @@ -328,17 +321,10 @@ parser_emit_cbc_push_number (parser_context_t *context_p, /**< context */ #ifdef PARSER_DUMP_BYTE_CODE if (context_p->is_show_opcodes) { - int real_value = value; - - if (is_negative_number) - { - real_value = -real_value; - } - JERRY_DEBUG_MSG (" [%3d] %s number:%d\n", (int) context_p->stack_depth, cbc_names[opcode], - real_value); + is_negative_number ? -(int) value : (int) value); } #endif /* PARSER_DUMP_BYTE_CODE */ @@ -453,14 +439,9 @@ parser_emit_cbc_forward_branch (parser_context_t *context_p, /**< context */ #ifdef PARSER_DUMP_BYTE_CODE if (context_p->is_show_opcodes) { - if (extra_byte_code_increase == 0) - { - JERRY_DEBUG_MSG (" [%3d] %s\n", (int) context_p->stack_depth, cbc_names[opcode]); - } - else - { - JERRY_DEBUG_MSG (" [%3d] %s\n", (int) context_p->stack_depth, cbc_ext_names[opcode]); - } + JERRY_DEBUG_MSG (" [%3d] %s\n", + (int) context_p->stack_depth, + extra_byte_code_increase == 0 ? cbc_names[opcode] : cbc_ext_names[opcode]); } #endif /* PARSER_DUMP_BYTE_CODE */ diff --git a/jerry-core/parser/js/js-parser.c b/jerry-core/parser/js/js-parser.c index d09520d33..ea92e16bd 100644 --- a/jerry-core/parser/js/js-parser.c +++ b/jerry-core/parser/js/js-parser.c @@ -1238,13 +1238,9 @@ parse_print_final_cbc (ecma_compiled_code_t *compiled_code_p, /**< compiled code while (byte_code_p < byte_code_end_p) { - cbc_opcode_t opcode; - cbc_ext_opcode_t ext_opcode; - size_t cbc_offset; - - opcode = (cbc_opcode_t) *byte_code_p; - ext_opcode = CBC_EXT_NOP; - cbc_offset = (size_t) (byte_code_p - byte_code_start_p); + cbc_opcode_t opcode = (cbc_opcode_t) *byte_code_p; + cbc_ext_opcode_t ext_opcode = CBC_EXT_NOP; + size_t cbc_offset = (size_t) (byte_code_p - byte_code_start_p); if (opcode != CBC_EXT_OPCODE) { @@ -1274,15 +1270,15 @@ parse_print_final_cbc (ecma_compiled_code_t *compiled_code_p, /**< compiled code if (opcode == CBC_PUSH_NUMBER_POS_BYTE) { - int value = *byte_code_p++; - JERRY_DEBUG_MSG (" number:%d\n", value + 1); + JERRY_DEBUG_MSG (" number:%d\n", *byte_code_p + 1); + byte_code_p++; continue; } if (opcode == CBC_PUSH_NUMBER_NEG_BYTE) { - int value = *byte_code_p++; - JERRY_DEBUG_MSG (" number:%d\n", -(value + 1)); + JERRY_DEBUG_MSG (" number:%d\n", -(*byte_code_p + 1)); + byte_code_p++; continue; } } @@ -1342,28 +1338,19 @@ parse_print_final_cbc (ecma_compiled_code_t *compiled_code_p, /**< compiled code if (flags & CBC_HAS_BRANCH_ARG) { - size_t branch_offset_length = CBC_BRANCH_OFFSET_LENGTH (opcode); + size_t branch_offset_length = (opcode != CBC_EXT_OPCODE ? CBC_BRANCH_OFFSET_LENGTH (opcode) + : CBC_BRANCH_OFFSET_LENGTH (ext_opcode)); size_t offset = 0; - if (opcode == CBC_EXT_OPCODE) - { - branch_offset_length = CBC_BRANCH_OFFSET_LENGTH (ext_opcode); - } - do { offset = (offset << 8) | *byte_code_p++; } while (--branch_offset_length > 0); - if (CBC_BRANCH_IS_FORWARD (flags)) - { - JERRY_DEBUG_MSG (" offset:%d(->%d)", (int) offset, (int) (cbc_offset + offset)); - } - else - { - JERRY_DEBUG_MSG (" offset:%d(->%d)", (int) offset, (int) (cbc_offset - offset)); - } + JERRY_DEBUG_MSG (" offset:%d(->%d)", + (int) offset, + (int) (cbc_offset + (CBC_BRANCH_IS_FORWARD (flags) ? offset : -offset))); } JERRY_DEBUG_MSG ("\n");