diff options
author | Robert Fancsik <frobert@inf.u-szeged.hu> | 2018-07-31 20:15:27 +0200 |
---|---|---|
committer | Dániel Bátyai <dbatyai@inf.u-szeged.hu> | 2018-07-31 20:15:27 +0200 |
commit | 1f20bb3fe59e28803a2c71fe2edef580ada0b0f6 (patch) | |
tree | e7ee0243ca15d522dcef5a3acb5ecc6612214dcc /jerry-core | |
parent | ba76b506f52e2dfa28cd9aa2b5d0aa729caa94a9 (diff) |
Remove unnecessary cbc_code_flag (#2443)
The removed flag can be substituted with the combination of two existing ones.
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
Diffstat (limited to 'jerry-core')
-rw-r--r-- | jerry-core/api/jerry-snapshot.c | 12 | ||||
-rw-r--r-- | jerry-core/api/jerry-snapshot.h | 2 | ||||
-rw-r--r-- | jerry-core/ecma/base/ecma-literal-storage.c | 4 | ||||
-rw-r--r-- | jerry-core/parser/js/byte-code.h | 18 | ||||
-rw-r--r-- | jerry-core/parser/js/js-parser.c | 5 | ||||
-rw-r--r-- | jerry-core/vm/vm.c | 2 |
6 files changed, 22 insertions, 21 deletions
diff --git a/jerry-core/api/jerry-snapshot.c b/jerry-core/api/jerry-snapshot.c index ec5531ab..583685c7 100644 --- a/jerry-core/api/jerry-snapshot.c +++ b/jerry-core/api/jerry-snapshot.c @@ -420,7 +420,7 @@ static_snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< c } } - if (compiled_code_p->status_flags & CBC_CODE_FLAGS_NON_STRICT_ARGUMENTS_NEEDED) + if (CBC_NON_STRICT_ARGUMENTS_NEEDED (compiled_code_p)) { buffer_p += ((size_t) compiled_code_p->size) << JMEM_ALIGNMENT_LOG; literal_start_p = ((ecma_value_t *) buffer_p) - argument_end; @@ -492,7 +492,7 @@ jerry_snapshot_set_offsets (uint32_t *buffer_p, /**< buffer */ } } - if (bytecode_p->status_flags & CBC_CODE_FLAGS_NON_STRICT_ARGUMENTS_NEEDED) + if (CBC_NON_STRICT_ARGUMENTS_NEEDED (bytecode_p)) { uint8_t *byte_p = (uint8_t *) bytecode_p; byte_p += ((size_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG; @@ -585,7 +585,7 @@ snapshot_load_compiled_code (const uint8_t *base_addr_p, /**< base address of th uint8_t *byte_p = (uint8_t *) bytecode_p; cbc_uint16_arguments_t *args_p = (cbc_uint16_arguments_t *) byte_p; - if (bytecode_p->status_flags & CBC_CODE_FLAGS_NON_STRICT_ARGUMENTS_NEEDED) + if (CBC_NON_STRICT_ARGUMENTS_NEEDED (bytecode_p)) { argument_end = args_p->argument_end; } @@ -599,7 +599,7 @@ snapshot_load_compiled_code (const uint8_t *base_addr_p, /**< base address of th uint8_t *byte_p = (uint8_t *) bytecode_p; cbc_uint8_arguments_t *args_p = (cbc_uint8_arguments_t *) byte_p; - if (bytecode_p->status_flags & CBC_CODE_FLAGS_NON_STRICT_ARGUMENTS_NEEDED) + if (CBC_NON_STRICT_ARGUMENTS_NEEDED (bytecode_p)) { argument_end = args_p->argument_end; } @@ -1092,7 +1092,7 @@ scan_snapshot_functions (const uint8_t *buffer_p, /**< snapshot buffer start */ } } - if (bytecode_p->status_flags & CBC_CODE_FLAGS_NON_STRICT_ARGUMENTS_NEEDED) + if (CBC_NON_STRICT_ARGUMENTS_NEEDED (bytecode_p)) { uint8_t *byte_p = (uint8_t *) bytecode_p; byte_p += ((size_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG; @@ -1170,7 +1170,7 @@ update_literal_offsets (uint8_t *buffer_p, /**< snapshot buffer start */ } } - if (bytecode_p->status_flags & CBC_CODE_FLAGS_NON_STRICT_ARGUMENTS_NEEDED) + if (CBC_NON_STRICT_ARGUMENTS_NEEDED (bytecode_p)) { uint8_t *byte_p = (uint8_t *) bytecode_p; byte_p += ((size_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG; diff --git a/jerry-core/api/jerry-snapshot.h b/jerry-core/api/jerry-snapshot.h index 4f420ff0..f8a4140c 100644 --- a/jerry-core/api/jerry-snapshot.h +++ b/jerry-core/api/jerry-snapshot.h @@ -41,7 +41,7 @@ typedef struct /** * Jerry snapshot format version. */ -#define JERRY_SNAPSHOT_VERSION (15u) +#define JERRY_SNAPSHOT_VERSION (16u) /** * Snapshot configuration flags. diff --git a/jerry-core/ecma/base/ecma-literal-storage.c b/jerry-core/ecma/base/ecma-literal-storage.c index b93bd77b..95971135 100644 --- a/jerry-core/ecma/base/ecma-literal-storage.c +++ b/jerry-core/ecma/base/ecma-literal-storage.c @@ -286,7 +286,7 @@ ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_ const_literal_end = args_p->const_literal_end - register_end; literal_end = args_p->literal_end - register_end; - if (compiled_code_p->status_flags & CBC_CODE_FLAGS_NON_STRICT_ARGUMENTS_NEEDED) + if (CBC_NON_STRICT_ARGUMENTS_NEEDED (compiled_code_p)) { argument_end = args_p->argument_end; } @@ -301,7 +301,7 @@ ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_ const_literal_end = args_p->const_literal_end - register_end; literal_end = args_p->literal_end - register_end; - if (compiled_code_p->status_flags & CBC_CODE_FLAGS_NON_STRICT_ARGUMENTS_NEEDED) + if (CBC_NON_STRICT_ARGUMENTS_NEEDED (compiled_code_p)) { argument_end = args_p->argument_end; } diff --git a/jerry-core/parser/js/byte-code.h b/jerry-core/parser/js/byte-code.h index e3a68485..8be5015a 100644 --- a/jerry-core/parser/js/byte-code.h +++ b/jerry-core/parser/js/byte-code.h @@ -668,14 +668,20 @@ typedef enum CBC_CODE_FLAGS_UINT16_ARGUMENTS = (1u << 2), /**< compiled code data is cbc_uint16_arguments_t */ CBC_CODE_FLAGS_STRICT_MODE = (1u << 3), /**< strict mode is enabled */ CBC_CODE_FLAGS_ARGUMENTS_NEEDED = (1u << 4), /**< arguments object must be constructed */ - CBC_CODE_FLAGS_NON_STRICT_ARGUMENTS_NEEDED = (1u << 5), /**< non-strict arguments object must be constructed */ - CBC_CODE_FLAGS_LEXICAL_ENV_NOT_NEEDED = (1u << 6), /**< no need to create a lexical environment */ - CBC_CODE_FLAGS_ARROW_FUNCTION = (1u << 7), /**< this function is an arrow function */ - CBC_CODE_FLAGS_STATIC_FUNCTION = (1u << 8), /**< this function is a static snapshot function */ - CBC_CODE_FLAGS_DEBUGGER_IGNORE = (1u << 9), /**< this function should be ignored by debugger */ - CBC_CODE_FLAGS_CONSTRUCTOR = (1u << 10), /**< this function is a constructor */ + CBC_CODE_FLAGS_LEXICAL_ENV_NOT_NEEDED = (1u << 5), /**< no need to create a lexical environment */ + CBC_CODE_FLAGS_ARROW_FUNCTION = (1u << 6), /**< this function is an arrow function */ + CBC_CODE_FLAGS_STATIC_FUNCTION = (1u << 7), /**< this function is a static snapshot function */ + CBC_CODE_FLAGS_DEBUGGER_IGNORE = (1u << 8), /**< this function should be ignored by debugger */ + CBC_CODE_FLAGS_CONSTRUCTOR = (1u << 9), /**< this function is a constructor */ } cbc_code_flags; +/** + * Non-strict arguments object must be constructed + */ +#define CBC_NON_STRICT_ARGUMENTS_NEEDED(compiled_code_p) \ + (((compiled_code_p)->status_flags & CBC_CODE_FLAGS_ARGUMENTS_NEEDED) \ + && !((compiled_code_p)->status_flags & CBC_CODE_FLAGS_STRICT_MODE)) + #define CBC_OPCODE(arg1, arg2, arg3, arg4) arg1, /** diff --git a/jerry-core/parser/js/js-parser.c b/jerry-core/parser/js/js-parser.c index 128edab9..6771e6a3 100644 --- a/jerry-core/parser/js/js-parser.c +++ b/jerry-core/parser/js/js-parser.c @@ -1742,11 +1742,6 @@ parser_post_processing (parser_context_t *context_p) /**< context */ { compiled_code_p->status_flags |= CBC_CODE_FLAGS_ARGUMENTS_NEEDED; - if (!(context_p->status_flags & PARSER_IS_STRICT)) - { - compiled_code_p->status_flags |= CBC_CODE_FLAGS_NON_STRICT_ARGUMENTS_NEEDED; - } - /* Arguments is stored in the lexical environment. */ context_p->status_flags |= PARSER_LEXICAL_ENV_NEEDED; } diff --git a/jerry-core/vm/vm.c b/jerry-core/vm/vm.c index 0919cb88..eeb2ff3a 100644 --- a/jerry-core/vm/vm.c +++ b/jerry-core/vm/vm.c @@ -2642,7 +2642,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */ { ecma_length_t formal_params_number = 0; - if (bytecode_header_p->status_flags & CBC_CODE_FLAGS_NON_STRICT_ARGUMENTS_NEEDED) + if (CBC_NON_STRICT_ARGUMENTS_NEEDED (bytecode_header_p)) { if (bytecode_header_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS) { |