diff --git a/jerry-core/config.h b/jerry-core/config.h index 5fd33efa2..103672737 100644 --- a/jerry-core/config.h +++ b/jerry-core/config.h @@ -163,7 +163,7 @@ #define CONFIG_VM_STACK_FRAME_INLINED_VALUES_NUMBER (16) /** - * Run GC after execution of each opcode + * Run GC after execution of each byte-code instruction */ // #define CONFIG_VM_RUN_GC_AFTER_EACH_OPCODE diff --git a/jerry-core/ecma/base/ecma-globals.h b/jerry-core/ecma/base/ecma-globals.h index 8661ce08f..56dffcd7d 100644 --- a/jerry-core/ecma/base/ecma-globals.h +++ b/jerry-core/ecma/base/ecma-globals.h @@ -174,7 +174,7 @@ typedef uint32_t ecma_completion_value_t; * Break / continue jump target */ #define ECMA_COMPLETION_VALUE_TARGET_POS (0) -#define ECMA_COMPLETION_VALUE_TARGET_WIDTH ((uint32_t) sizeof (opcode_counter_t) * JERRY_BITSINBYTE) +#define ECMA_COMPLETION_VALUE_TARGET_WIDTH ((uint32_t) sizeof (vm_instr_counter_t) * JERRY_BITSINBYTE) /** * Type (ecma_completion_type_t) diff --git a/jerry-core/ecma/base/ecma-helpers-value.cpp b/jerry-core/ecma/base/ecma-helpers-value.cpp index 14dcb70b5..9c9bc5afc 100644 --- a/jerry-core/ecma/base/ecma-helpers-value.cpp +++ b/jerry-core/ecma/base/ecma-helpers-value.cpp @@ -464,14 +464,14 @@ ecma_get_completion_value_value_field (ecma_completion_value_t completion_value) /** * Get target of break / continue completion value * - * @return opcode counter + * @return instruction counter */ -static opcode_counter_t +static vm_instr_counter_t ecma_get_completion_value_target (ecma_completion_value_t completion_value) /**< completion value */ { - return (opcode_counter_t) jrt_extract_bit_field (completion_value, - ECMA_COMPLETION_VALUE_TARGET_POS, - ECMA_COMPLETION_VALUE_TARGET_WIDTH); + return (vm_instr_counter_t) jrt_extract_bit_field (completion_value, + ECMA_COMPLETION_VALUE_TARGET_POS, + ECMA_COMPLETION_VALUE_TARGET_WIDTH); } /* ecma_get_completion_value_target */ /** @@ -514,7 +514,7 @@ ecma_set_completion_value_value_field (ecma_completion_value_t completion_value, static ecma_completion_value_t __attr_const___ ecma_set_completion_value_target (ecma_completion_value_t completion_value, /**< completion value * to set field in */ - opcode_counter_t target) /**< break / continue target */ + vm_instr_counter_t target) /**< break / continue target */ { return (ecma_completion_value_t) jrt_set_bit_field_value (completion_value, target, @@ -645,7 +645,7 @@ ecma_make_meta_completion_value (void) * @return completion value */ ecma_completion_value_t __attr_const___ -ecma_make_jump_completion_value (opcode_counter_t target) /**< target break / continue */ +ecma_make_jump_completion_value (vm_instr_counter_t target) /**< target break / continue */ { ecma_completion_value_t completion_value = 0; @@ -712,9 +712,9 @@ ecma_get_object_from_completion_value (ecma_completion_value_t completion_value) /** * Get break / continue target from completion value * - * @return opcode counter + * @return instruction counter */ -opcode_counter_t +vm_instr_counter_t ecma_get_jump_target_from_completion_value (ecma_completion_value_t completion_value) /**< completion * value */ { diff --git a/jerry-core/ecma/base/ecma-helpers.h b/jerry-core/ecma/base/ecma-helpers.h index 78107d7d6..253f0deaf 100644 --- a/jerry-core/ecma/base/ecma-helpers.h +++ b/jerry-core/ecma/base/ecma-helpers.h @@ -84,7 +84,7 @@ extern ecma_completion_value_t ecma_make_throw_obj_completion_value (ecma_object extern ecma_completion_value_t ecma_make_empty_completion_value (void); extern ecma_completion_value_t ecma_make_return_completion_value (ecma_value_t value); extern ecma_completion_value_t ecma_make_meta_completion_value (void); -extern ecma_completion_value_t ecma_make_jump_completion_value (opcode_counter_t target); +extern ecma_completion_value_t ecma_make_jump_completion_value (vm_instr_counter_t target); extern ecma_value_t ecma_get_completion_value_value (ecma_completion_value_t completion_value); extern ecma_number_t* __attr_const___ ecma_get_number_from_completion_value (ecma_completion_value_t completion_value); @@ -92,7 +92,7 @@ extern ecma_string_t* __attr_const___ ecma_get_string_from_completion_value (ecma_completion_value_t completion_value); extern ecma_object_t* __attr_const___ ecma_get_object_from_completion_value (ecma_completion_value_t completion_value); -extern opcode_counter_t +extern vm_instr_counter_t ecma_get_jump_target_from_completion_value (ecma_completion_value_t completion_value); extern ecma_completion_value_t ecma_copy_completion_value (ecma_completion_value_t value); extern void ecma_free_completion_value (ecma_completion_value_t completion_value); diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-function.cpp b/jerry-core/ecma/builtin-objects/ecma-builtin-function.cpp index 56e6ee84c..b071fc7b7 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-function.cpp +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-function.cpp @@ -255,13 +255,13 @@ ecma_builtin_function_dispatch_construct (const ecma_value_t *arguments_list_p, utf8_string_buffer_pos += sz; } - const opcode_t* opcodes_p; + const vm_instr_t* instrs_p; jsp_status_t parse_status; parse_status = parser_parse_new_function ((const jerry_api_char_t **) utf8_string_params_p, utf8_string_params_size, params_count, - &opcodes_p); + &instrs_p); if (parse_status == JSP_STATUS_SYNTAX_ERROR) { @@ -277,7 +277,7 @@ ecma_builtin_function_dispatch_construct (const ecma_value_t *arguments_list_p, bool is_strict = false; bool do_instantiate_arguments_object = true; - opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (opcodes_p, + opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (instrs_p, 0); if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_STRICT) @@ -302,7 +302,7 @@ ecma_builtin_function_dispatch_construct (const ecma_value_t *arguments_list_p, glob_lex_env_p, is_strict, do_instantiate_arguments_object, - opcodes_p, + instrs_p, 1); ecma_deref_object (glob_lex_env_p); diff --git a/jerry-core/ecma/operations/ecma-eval.cpp b/jerry-core/ecma/operations/ecma-eval.cpp index 1e2ba3fa4..51d8b3a82 100644 --- a/jerry-core/ecma/operations/ecma-eval.cpp +++ b/jerry-core/ecma/operations/ecma-eval.cpp @@ -86,7 +86,7 @@ ecma_op_eval_chars_buffer (const jerry_api_char_t *code_p, /**< code characters ecma_completion_value_t completion; - const opcode_t *opcodes_p; + const vm_instr_t *instrs_p; jsp_status_t parse_status; bool is_strict_call = (is_direct && is_called_from_strict_mode_code); @@ -94,7 +94,7 @@ ecma_op_eval_chars_buffer (const jerry_api_char_t *code_p, /**< code characters parse_status = parser_parse_eval (code_p, code_buffer_size, is_strict_call, - &opcodes_p); + &instrs_p); if (parse_status == JSP_STATUS_SYNTAX_ERROR) { @@ -108,10 +108,10 @@ ecma_op_eval_chars_buffer (const jerry_api_char_t *code_p, /**< code characters { JERRY_ASSERT (parse_status == JSP_STATUS_OK); - opcode_counter_t first_opcode_index = 0u; + vm_instr_counter_t first_instr_index = 0u; bool is_strict_prologue = false; - opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (opcodes_p, - first_opcode_index++); + opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (instrs_p, + first_instr_index++); if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_STRICT) { is_strict_prologue = true; @@ -142,8 +142,8 @@ ecma_op_eval_chars_buffer (const jerry_api_char_t *code_p, /**< code characters lex_env_p = strict_lex_env_p; } - completion = vm_run_from_pos (opcodes_p, - first_opcode_index, + completion = vm_run_from_pos (instrs_p, + first_instr_index, this_binding, lex_env_p, is_strict, diff --git a/jerry-core/ecma/operations/ecma-function-object.cpp b/jerry-core/ecma/operations/ecma-function-object.cpp index 53d536b95..fea564eb7 100644 --- a/jerry-core/ecma/operations/ecma-function-object.cpp +++ b/jerry-core/ecma/operations/ecma-function-object.cpp @@ -36,7 +36,7 @@ */ /** - * Pack 'is_strict', 'do_instantiate_arguments_object' flags and opcode index to value + * Pack 'is_strict', 'do_instantiate_arguments_object' flags and instruction position to value * that can be stored in an [[Code]] internal property. * * @return packed value @@ -45,9 +45,9 @@ static uint32_t ecma_pack_code_internal_property_value (bool is_strict, /**< is code strict? */ bool do_instantiate_args_obj, /**< should an Arguments object be * instantiated for the code */ - opcode_counter_t opcode_idx) /**< index of first opcode */ + vm_instr_counter_t instr_oc) /**< position of first instruction */ { - uint32_t value = opcode_idx; + uint32_t value = instr_oc; const uint32_t is_strict_bit_offset = (uint32_t) (sizeof (value) * JERRY_BITSINBYTE - 1); const uint32_t do_instantiate_arguments_object_bit_offset = (uint32_t) (sizeof (value) * JERRY_BITSINBYTE - 2); @@ -68,12 +68,12 @@ ecma_pack_code_internal_property_value (bool is_strict, /**< is code strict? */ } /* ecma_pack_code_internal_property_value */ /** - * Unpack 'is_strict', 'do_instantiate_arguments_object' flags and opcode index from value + * Unpack 'is_strict', 'do_instantiate_arguments_object' flags and instruction position from value * that can be stored in an [[Code]] internal property. * - * @return opcode index + * @return instruction position */ -static opcode_counter_t +static vm_instr_counter_t ecma_unpack_code_internal_property_value (uint32_t value, /**< packed value */ bool* out_is_strict_p, /**< out: is code strict? */ bool* out_do_instantiate_args_obj_p) /**< should an Arguments object be @@ -89,7 +89,7 @@ ecma_unpack_code_internal_property_value (uint32_t value, /**< packed value */ *out_do_instantiate_args_obj_p = ((value & (1u << do_instantiate_arguments_object_bit_offset)) != 0); value &= ~((1u << is_strict_bit_offset) | (1u << do_instantiate_arguments_object_bit_offset)); - return (opcode_counter_t) value; + return (vm_instr_counter_t) value; } /* ecma_unpack_code_internal_property_value */ /** @@ -221,8 +221,9 @@ ecma_op_create_function_object (ecma_string_t* formal_parameter_list_p[], /**< f bool is_strict, /**< 'strict' flag */ bool do_instantiate_arguments_object, /**< should an Arguments object be instantiated * for the function object upon call */ - const opcode_t *opcodes_p, /**< byte-code array */ - opcode_counter_t first_opcode_index) /**< index of first opcode of function's body */ + const vm_instr_t *instrs_p, /**< byte-code array */ + vm_instr_counter_t first_instr_pos) /**< position of first instruction + * of function's body */ { // 1., 4., 13. ecma_object_t *prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE); @@ -274,13 +275,13 @@ ecma_op_create_function_object (ecma_string_t* formal_parameter_list_p[], /**< f } // 12. - ecma_property_t *opcodes_prop_p = ecma_create_internal_property (f, ECMA_INTERNAL_PROPERTY_CODE_BYTECODE); - MEM_CP_SET_NON_NULL_POINTER (opcodes_prop_p->u.internal_property.value, opcodes_p); + ecma_property_t *bytecode_prop_p = ecma_create_internal_property (f, ECMA_INTERNAL_PROPERTY_CODE_BYTECODE); + MEM_CP_SET_NON_NULL_POINTER (bytecode_prop_p->u.internal_property.value, instrs_p); ecma_property_t *code_prop_p = ecma_create_internal_property (f, ECMA_INTERNAL_PROPERTY_CODE_FLAGS_AND_OFFSET); code_prop_p->u.internal_property.value = ecma_pack_code_internal_property_value (is_strict, do_instantiate_arguments_object, - first_opcode_index); + first_instr_pos); // 14. ecma_number_t* len_p = ecma_alloc_number (); @@ -707,7 +708,7 @@ ecma_op_function_call (ecma_object_t *func_obj_p, /**< Function object */ { /* Entering Function Code (ECMA-262 v5, 10.4.3) */ ecma_property_t *scope_prop_p = ecma_get_internal_property (func_obj_p, ECMA_INTERNAL_PROPERTY_SCOPE); - ecma_property_t *opcodes_prop_p = ecma_get_internal_property (func_obj_p, ECMA_INTERNAL_PROPERTY_CODE_BYTECODE); + ecma_property_t *bytecode_prop_p = ecma_get_internal_property (func_obj_p, ECMA_INTERNAL_PROPERTY_CODE_BYTECODE); ecma_property_t *code_prop_p = ecma_get_internal_property (func_obj_p, ECMA_INTERNAL_PROPERTY_CODE_FLAGS_AND_OFFSET); @@ -718,10 +719,10 @@ ecma_op_function_call (ecma_object_t *func_obj_p, /**< Function object */ // 8. bool is_strict; bool do_instantiate_args_obj; - const opcode_t *opcodes_p = MEM_CP_GET_POINTER (const opcode_t, opcodes_prop_p->u.internal_property.value); - opcode_counter_t code_first_opcode_idx = ecma_unpack_code_internal_property_value (code_prop_value, - &is_strict, - &do_instantiate_args_obj); + const vm_instr_t *instrs_p = MEM_CP_GET_POINTER (const vm_instr_t, bytecode_prop_p->u.internal_property.value); + vm_instr_counter_t code_first_instr_pos = ecma_unpack_code_internal_property_value (code_prop_value, + &is_strict, + &do_instantiate_args_obj); ecma_value_t this_binding; // 1. @@ -757,8 +758,8 @@ ecma_op_function_call (ecma_object_t *func_obj_p, /**< Function object */ do_instantiate_args_obj), ret_value); - ecma_completion_value_t completion = vm_run_from_pos (opcodes_p, - code_first_opcode_idx, + ecma_completion_value_t completion = vm_run_from_pos (instrs_p, + code_first_instr_pos, this_binding, local_env_p, is_strict, @@ -1019,8 +1020,9 @@ ecma_op_function_construct (ecma_object_t *func_obj_p, /**< Function object */ ecma_completion_value_t ecma_op_function_declaration (ecma_object_t *lex_env_p, /**< lexical environment */ ecma_string_t *function_name_p, /**< function name */ - const opcode_t *opcodes_p, /**< byte-code array */ - opcode_counter_t function_code_opcode_idx, /**< index of first opcode of function code */ + const vm_instr_t *instrs_p, /**< byte-code array */ + vm_instr_counter_t function_first_instr_pos, /**< position of first instruction + * of function code */ ecma_string_t* formal_parameter_list_p[], /**< formal parameters list */ ecma_length_t formal_parameter_list_length, /**< length of formal parameters list */ bool is_strict, /**< flag indicating if function is declared in strict mode code */ @@ -1036,8 +1038,8 @@ ecma_op_function_declaration (ecma_object_t *lex_env_p, /**< lexical environment lex_env_p, is_strict, do_instantiate_arguments_object, - opcodes_p, - function_code_opcode_idx); + instrs_p, + function_first_instr_pos); // c. bool func_already_declared = ecma_op_has_binding (lex_env_p, function_name_p); diff --git a/jerry-core/ecma/operations/ecma-function-object.h b/jerry-core/ecma/operations/ecma-function-object.h index 726c705fd..533f97f75 100644 --- a/jerry-core/ecma/operations/ecma-function-object.h +++ b/jerry-core/ecma/operations/ecma-function-object.h @@ -35,8 +35,8 @@ ecma_op_create_function_object (ecma_string_t* formal_parameter_list_p[], ecma_object_t *scope_p, bool is_strict, bool do_instantiate_arguments_object, - const opcode_t *opcodes_p, - opcode_counter_t first_opcode_idx); + const vm_instr_t *instrs_p, + vm_instr_counter_t first_opcode_idx); extern ecma_object_t* ecma_op_create_external_function_object (ecma_external_pointer_t code_p); @@ -58,8 +58,8 @@ ecma_op_function_has_instance (ecma_object_t *func_obj_p, extern ecma_completion_value_t ecma_op_function_declaration (ecma_object_t *lex_env_p, ecma_string_t *function_name_p, - const opcode_t *opcodes_p, - opcode_counter_t function_code_opcode_idx, + const vm_instr_t *instrs_p, + vm_instr_counter_t function_code_opcode_idx, ecma_string_t* formal_parameter_list_p[], ecma_length_t formal_parameter_list_length, bool is_strict, diff --git a/jerry-core/jerry.cpp b/jerry-core/jerry.cpp index ee9a76fcd..41e245547 100644 --- a/jerry-core/jerry.cpp +++ b/jerry-core/jerry.cpp @@ -1329,16 +1329,16 @@ jerry_parse (const jerry_api_char_t* source_p, /**< script source */ { jerry_assert_api_available (); - bool is_show_opcodes = ((jerry_flags & JERRY_FLAG_SHOW_OPCODES) != 0); + bool is_show_instructions = ((jerry_flags & JERRY_FLAG_SHOW_OPCODES) != 0); - parser_set_show_opcodes (is_show_opcodes); + parser_set_show_instrs (is_show_instructions); - const opcode_t *opcodes_p; + const vm_instr_t *instrs_p; jsp_status_t parse_status; parse_status = parser_parse_script (source_p, source_size, - &opcodes_p); + &instrs_p); if (parse_status != JSP_STATUS_OK) { @@ -1355,9 +1355,9 @@ jerry_parse (const jerry_api_char_t* source_p, /**< script source */ } #endif /* MEM_STATS */ - bool is_show_mem_stats_per_opcode = ((jerry_flags & JERRY_FLAG_MEM_STATS_PER_OPCODE) != 0); + bool is_show_mem_stats_per_instruction = ((jerry_flags & JERRY_FLAG_MEM_STATS_PER_OPCODE) != 0); - vm_init (opcodes_p, is_show_mem_stats_per_opcode); + vm_init (instrs_p, is_show_mem_stats_per_instruction); return true; } /* jerry_parse */ diff --git a/jerry-core/jerry.h b/jerry-core/jerry.h index 951b2e0a8..b1898fa15 100644 --- a/jerry-core/jerry.h +++ b/jerry-core/jerry.h @@ -31,10 +31,11 @@ typedef uint32_t jerry_flag_t; #define JERRY_FLAG_EMPTY (0u) /**< empty flag set */ -#define JERRY_FLAG_SHOW_OPCODES (1u << 0) /**< dump opcodes to stdout after parse */ +#define JERRY_FLAG_SHOW_OPCODES (1u << 0) /**< dump byte-code to stdout after parse */ #define JERRY_FLAG_MEM_STATS (1u << 1) /**< dump memory statistics */ -#define JERRY_FLAG_MEM_STATS_PER_OPCODE (1u << 2) /**< dump per-opcode memory statistics during execution - * (in the mode full GC is performed after each opcode handler) */ +#define JERRY_FLAG_MEM_STATS_PER_OPCODE (1u << 2) /**< dump per-instruction memory statistics during execution + * (in the mode full GC is performed after execution of each + * opcode handler) */ #define JERRY_FLAG_MEM_STATS_SEPARATE (1u << 3) /**< dump memory statistics and reset peak values after parse */ #define JERRY_FLAG_PARSE_ONLY (1u << 4) /**< parse only, prevents script execution (only for testing) * FIXME: Remove. */ diff --git a/jerry-core/parser/js/bytecode-data.h b/jerry-core/parser/js/bytecode-data.h index 9696af434..f641155a2 100644 --- a/jerry-core/parser/js/bytecode-data.h +++ b/jerry-core/parser/js/bytecode-data.h @@ -27,7 +27,7 @@ * * Literal id is its index in 'literals' array of bytecode_data_t structure. * - * Bytecode, which is kept in the 'opcodes' field, is divided into blocks + * Bytecode, which is kept in the 'instrs' field, is divided into blocks * of 'BLOCK_SIZE' operands. Every block has its own numbering of literals. * Literal uid could be in range [0, 127] in every block. * @@ -42,27 +42,27 @@ typedef struct __attribute__ ((aligned (MEM_ALIGNMENT))) { mem_cpointer_t lit_id_hash_cp; /**< pointer to literal identifiers hash table * See also: lit_id_hash_table_init */ - mem_cpointer_t next_opcodes_cp; /**< pointer to next byte-code memory region */ - opcode_counter_t instructions_number; /**< number of instructions in the byte-code array */ -} opcodes_header_t; + mem_cpointer_t next_instrs_cp; /**< pointer to next byte-code memory region */ + vm_instr_counter_t instructions_number; /**< number of instructions in the byte-code array */ +} insts_data_header_t; typedef struct { const ecma_char_t *strings_buffer; - const opcode_t *opcodes; - opcode_counter_t opcodes_count; + const vm_instr_t *instrs_p; + vm_instr_counter_t instrs_count; } bytecode_data_t; /** - * Macros to get a pointer to bytecode header by pointer to opcodes start + * Macros to get a pointer to bytecode header by pointer to instructions array start */ -#define GET_BYTECODE_HEADER(opcodes) ((opcodes_header_t *) (((uint8_t *) (opcodes)) - sizeof (opcodes_header_t))) +#define GET_BYTECODE_HEADER(instrs) ((insts_data_header_t *) (((uint8_t *) (instrs)) - sizeof (insts_data_header_t))) /** * Macros to get a hash table corresponding to a bytecode region */ -#define GET_HASH_TABLE_FOR_BYTECODE(opcodes) (MEM_CP_GET_POINTER (lit_id_hash_table, \ - GET_BYTECODE_HEADER (opcodes)->lit_id_hash_cp)) +#define GET_HASH_TABLE_FOR_BYTECODE(instrs) (MEM_CP_GET_POINTER (lit_id_hash_table, \ + GET_BYTECODE_HEADER (instrs)->lit_id_hash_cp)) #endif // BYTECODE_DATA_H diff --git a/jerry-core/parser/js/collections/lit-id-hash-table.cpp b/jerry-core/parser/js/collections/lit-id-hash-table.cpp index 8da6188e1..67087cb12 100644 --- a/jerry-core/parser/js/collections/lit-id-hash-table.cpp +++ b/jerry-core/parser/js/collections/lit-id-hash-table.cpp @@ -23,7 +23,7 @@ * @{ * * \addtogroup lit_id_hash_table Literal identifiers hash table - * The hash table connects pairs (opcode block, idx_t value) with literal identifiers. + * The hash table connects pairs (instruction block, idx_t value) with literal identifiers. * @{ */ @@ -36,7 +36,7 @@ lit_id_hash_table * lit_id_hash_table_init (uint8_t *table_buffer_p, /**< buffer to initialize hash table in */ size_t buffer_size, /**< size of the buffer */ size_t buckets_count, /**< number of pairs */ - size_t blocks_count) /**< number of opcode blocks */ + size_t blocks_count) /**< number of instruction blocks */ { const size_t header_size = JERRY_ALIGNUP (sizeof (lit_id_hash_table), MEM_ALIGNMENT); const size_t raw_buckets_size = JERRY_ALIGNUP (sizeof (lit_cpointer_t) * buckets_count, MEM_ALIGNMENT); @@ -62,7 +62,7 @@ lit_id_hash_table_init (uint8_t *table_buffer_p, /**< buffer to initialize hash */ size_t lit_id_hash_table_get_size_for_table (size_t buckets_count, /**< number of pairs */ - size_t blocks_count) /**< number of opcode blocks */ + size_t blocks_count) /**< number of instructions blocks */ { const size_t header_size = JERRY_ALIGNUP (sizeof (lit_id_hash_table), MEM_ALIGNMENT); const size_t raw_buckets_size = JERRY_ALIGNUP (sizeof (lit_cpointer_t) * buckets_count, MEM_ALIGNMENT); @@ -88,7 +88,7 @@ lit_id_hash_table_free (lit_id_hash_table *table_p) /**< table's header */ void lit_id_hash_table_insert (lit_id_hash_table *table_p, /**< table's header */ idx_t uid, /**< value of byte-code instruction's argument */ - opcode_counter_t oc, /**< opcode counter of the instruction */ + vm_instr_counter_t oc, /**< instruction counter of the instruction */ lit_cpointer_t lit_cp) /**< literal identifier */ { JERRY_ASSERT (table_p != NULL); @@ -112,7 +112,7 @@ lit_id_hash_table_insert (lit_id_hash_table *table_p, /**< table's header */ lit_cpointer_t lit_id_hash_table_lookup (lit_id_hash_table *table_p, /**< table's header */ idx_t uid, /**< value of byte-code instruction's argument */ - opcode_counter_t oc) /**< opcode counter of the instruction */ + vm_instr_counter_t oc) /**< instruction counter of the instruction */ { JERRY_ASSERT (table_p != NULL); diff --git a/jerry-core/parser/js/collections/lit-id-hash-table.h b/jerry-core/parser/js/collections/lit-id-hash-table.h index 6905652e5..321a3bbf4 100644 --- a/jerry-core/parser/js/collections/lit-id-hash-table.h +++ b/jerry-core/parser/js/collections/lit-id-hash-table.h @@ -31,7 +31,7 @@ typedef struct lit_id_hash_table *lit_id_hash_table_init (uint8_t*, size_t, size_t, size_t); size_t lit_id_hash_table_get_size_for_table (size_t, size_t); void lit_id_hash_table_free (lit_id_hash_table *); -void lit_id_hash_table_insert (lit_id_hash_table *, idx_t, opcode_counter_t, lit_cpointer_t); -lit_cpointer_t lit_id_hash_table_lookup (lit_id_hash_table *, idx_t, opcode_counter_t); +void lit_id_hash_table_insert (lit_id_hash_table *, idx_t, vm_instr_counter_t, lit_cpointer_t); +lit_cpointer_t lit_id_hash_table_lookup (lit_id_hash_table *, idx_t, vm_instr_counter_t); #endif /* LIT_ID_HASH_TABLE */ diff --git a/jerry-core/parser/js/jsp-label.cpp b/jerry-core/parser/js/jsp-label.cpp index 4b8d2fffb..751510719 100644 --- a/jerry-core/parser/js/jsp-label.cpp +++ b/jerry-core/parser/js/jsp-label.cpp @@ -105,8 +105,8 @@ jsp_label_push (jsp_label_t *out_label_p, /**< out: place where label structure */ void jsp_label_rewrite_jumps_and_pop (jsp_label_t *label_p, /**< label to remove (should be on top of stack) */ - opcode_counter_t break_tgt_oc) /**< target opcode counter - * for breaks on the label */ + vm_instr_counter_t break_tgt_oc) /**< target instruction counter + * for breaks on the label */ { JERRY_ASSERT (label_p != NULL); JERRY_ASSERT (break_tgt_oc != MAX_OPCODES); @@ -228,7 +228,7 @@ jsp_label_add_jump (jsp_label_t *label_p, /**< label to register jump for */ */ void jsp_label_setup_continue_target (jsp_label_t *outermost_label_p, /**< the outermost label to setup target for */ - opcode_counter_t tgt_oc) /**< target */ + vm_instr_counter_t tgt_oc) /**< target */ { /* There are no labels that could not be targeted with 'break' jumps */ JERRY_ASSERT (tgt_oc != MAX_OPCODES); diff --git a/jerry-core/parser/js/jsp-label.h b/jerry-core/parser/js/jsp-label.h index 503902dc8..ae8685d65 100644 --- a/jerry-core/parser/js/jsp-label.h +++ b/jerry-core/parser/js/jsp-label.h @@ -43,7 +43,7 @@ typedef enum * Jump instructions with target identified by some specific label, * are linked into singly-linked list. * - * Pointer to a next element of the list is represented with opcode counter. + * Pointer to a next element of the list is represented with instruction counter. * stored in instructions linked into the list. * */ @@ -51,13 +51,13 @@ typedef struct jsp_label_t { jsp_label_type_flag_t type_mask; /**< label type mask */ token id; /**< label name (TOK_NAME), if type is LABEL_NAMED */ - opcode_counter_t continue_tgt_oc; /**< target opcode counter for continues on the label */ - opcode_counter_t breaks_list_oc; /**< opcode counter of first 'break' instruction in the list - * of instructions with the target identified by the label */ - opcode_counter_t breaks_number; /**< number of 'break' instructions in the list */ - opcode_counter_t continues_list_oc; /**< opcode counter of first 'continue' instruction in the list - * of instructions with the target identified by the label */ - opcode_counter_t continues_number; /**< number of 'continue' instructions in the list */ + vm_instr_counter_t continue_tgt_oc; /**< target instruction counter for continues on the label */ + vm_instr_counter_t breaks_list_oc; /**< instruction counter of first 'break' instruction in the list + * of instructions with the target identified by the label */ + vm_instr_counter_t breaks_number; /**< number of 'break' instructions in the list */ + vm_instr_counter_t continues_list_oc; /**< instruction counter of first 'continue' instruction in the list + * of instructions with the target identified by the label */ + vm_instr_counter_t continues_number; /**< number of 'continue' instructions in the list */ jsp_label_t *next_label_p; /**< next label in current label set stack */ bool is_nested_jumpable_border : 1; /**< flag, indicating that this and outer labels * are not currently accessible with simple jumps, @@ -70,12 +70,12 @@ extern void jsp_label_finalize (void); extern void jsp_label_remove_all_labels (void); extern void jsp_label_push (jsp_label_t *out_label_p, jsp_label_type_flag_t type_mask, token id); -extern void jsp_label_rewrite_jumps_and_pop (jsp_label_t *label_p, opcode_counter_t break_tgt_oc); +extern void jsp_label_rewrite_jumps_and_pop (jsp_label_t *label_p, vm_instr_counter_t break_tgt_oc); extern jsp_label_t *jsp_label_find (jsp_label_type_flag_t type_mask, token id, bool *out_is_simply_jumpable_p); extern void jsp_label_add_jump (jsp_label_t *label_p, bool is_simply_jumpable, bool is_break); -extern void jsp_label_setup_continue_target (jsp_label_t *outermost_label_p, opcode_counter_t tgt_oc); +extern void jsp_label_setup_continue_target (jsp_label_t *outermost_label_p, vm_instr_counter_t tgt_oc); extern bool jsp_label_raise_nested_jumpable_border (void); extern void jsp_label_remove_nested_jumpable_border (void); diff --git a/jerry-core/parser/js/lexer.cpp b/jerry-core/parser/js/lexer.cpp index 74a5a5192..04f6e6e13 100644 --- a/jerry-core/parser/js/lexer.cpp +++ b/jerry-core/parser/js/lexer.cpp @@ -1826,7 +1826,8 @@ lexer_is_no_escape_sequences_in_token_string (token tok) /**< token of type TOK_ void lexer_init (const jerry_api_char_t *source, /**< script source */ size_t source_size, /**< script source size in bytes */ - bool show_opcodes) /**< flag indicating if to dump opcodes */ + bool is_print_source_code) /**< flag indicating whether to dump + * processed source code */ { empty_token.type = TOK_EMPTY; empty_token.uid = 0; @@ -1848,9 +1849,9 @@ lexer_init (const jerry_api_char_t *source, /**< script source */ lexer_set_strict_mode (false); #ifndef JERRY_NDEBUG - allow_dump_lines = show_opcodes; + allow_dump_lines = is_print_source_code; #else /* JERRY_NDEBUG */ - (void) show_opcodes; + (void) is_print_source_code; allow_dump_lines = false; #endif /* JERRY_NDEBUG */ } /* lexer_init */ diff --git a/jerry-core/parser/js/opcodes-dumper.cpp b/jerry-core/parser/js/opcodes-dumper.cpp index f8932444d..699739b51 100644 --- a/jerry-core/parser/js/opcodes-dumper.cpp +++ b/jerry-core/parser/js/opcodes-dumper.cpp @@ -32,37 +32,37 @@ enum { varg_headers_global_size }; -STATIC_STACK (varg_headers, opcode_counter_t) +STATIC_STACK (varg_headers, vm_instr_counter_t) enum { function_ends_global_size }; -STATIC_STACK (function_ends, opcode_counter_t) +STATIC_STACK (function_ends, vm_instr_counter_t) enum { logical_and_checks_global_size }; -STATIC_STACK (logical_and_checks, opcode_counter_t) +STATIC_STACK (logical_and_checks, vm_instr_counter_t) enum { logical_or_checks_global_size }; -STATIC_STACK (logical_or_checks, opcode_counter_t) +STATIC_STACK (logical_or_checks, vm_instr_counter_t) enum { conditional_checks_global_size }; -STATIC_STACK (conditional_checks, opcode_counter_t) +STATIC_STACK (conditional_checks, vm_instr_counter_t) enum { jumps_to_end_global_size }; -STATIC_STACK (jumps_to_end, opcode_counter_t) +STATIC_STACK (jumps_to_end, vm_instr_counter_t) enum { @@ -74,31 +74,31 @@ enum { next_iterations_global_size }; -STATIC_STACK (next_iterations, opcode_counter_t) +STATIC_STACK (next_iterations, vm_instr_counter_t) enum { case_clauses_global_size }; -STATIC_STACK (case_clauses, opcode_counter_t) +STATIC_STACK (case_clauses, vm_instr_counter_t) enum { tries_global_size }; -STATIC_STACK (tries, opcode_counter_t) +STATIC_STACK (tries, vm_instr_counter_t) enum { catches_global_size }; -STATIC_STACK (catches, opcode_counter_t) +STATIC_STACK (catches, vm_instr_counter_t) enum { finallies_global_size }; -STATIC_STACK (finallies, opcode_counter_t) +STATIC_STACK (finallies, vm_instr_counter_t) enum { @@ -110,7 +110,7 @@ enum { reg_var_decls_global_size }; -STATIC_STACK (reg_var_decls, opcode_counter_t) +STATIC_STACK (reg_var_decls, vm_instr_counter_t) /** * Reset counter of register variables allocator @@ -150,7 +150,7 @@ next_temp_name (void) } /* next_temp_name */ static op_meta -create_op_meta (opcode_t op, lit_cpointer_t lit_id1, lit_cpointer_t lit_id2, lit_cpointer_t lit_id3) +create_op_meta (vm_instr_t op, lit_cpointer_t lit_id1, lit_cpointer_t lit_id2, lit_cpointer_t lit_id3) { op_meta ret; @@ -163,49 +163,49 @@ create_op_meta (opcode_t op, lit_cpointer_t lit_id1, lit_cpointer_t lit_id2, lit } static op_meta -create_op_meta_000 (opcode_t op) +create_op_meta_000 (vm_instr_t op) { return create_op_meta (op, NOT_A_LITERAL, NOT_A_LITERAL, NOT_A_LITERAL); } static op_meta -create_op_meta_001 (opcode_t op, lit_cpointer_t lit_id) +create_op_meta_001 (vm_instr_t op, lit_cpointer_t lit_id) { return create_op_meta (op, NOT_A_LITERAL, NOT_A_LITERAL, lit_id); } static op_meta -create_op_meta_010 (opcode_t op, lit_cpointer_t lit_id) +create_op_meta_010 (vm_instr_t op, lit_cpointer_t lit_id) { return create_op_meta (op, NOT_A_LITERAL, lit_id, NOT_A_LITERAL); } static op_meta -create_op_meta_011 (opcode_t op, lit_cpointer_t lit_id2, lit_cpointer_t lit_id3) +create_op_meta_011 (vm_instr_t op, lit_cpointer_t lit_id2, lit_cpointer_t lit_id3) { return create_op_meta (op, NOT_A_LITERAL, lit_id2, lit_id3); } static op_meta -create_op_meta_100 (opcode_t op, lit_cpointer_t lit_id) +create_op_meta_100 (vm_instr_t op, lit_cpointer_t lit_id) { return create_op_meta (op, lit_id, NOT_A_LITERAL, NOT_A_LITERAL); } static op_meta -create_op_meta_101 (opcode_t op, lit_cpointer_t lit_id1, lit_cpointer_t lit_id3) +create_op_meta_101 (vm_instr_t op, lit_cpointer_t lit_id1, lit_cpointer_t lit_id3) { return create_op_meta (op, lit_id1, NOT_A_LITERAL, lit_id3); } static op_meta -create_op_meta_110 (opcode_t op, lit_cpointer_t lit_id1, lit_cpointer_t lit_id2) +create_op_meta_110 (vm_instr_t op, lit_cpointer_t lit_id1, lit_cpointer_t lit_id2) { return create_op_meta (op, lit_id1, lit_id2, NOT_A_LITERAL); } static op_meta -create_op_meta_111 (opcode_t op, lit_cpointer_t lit_id1, lit_cpointer_t lit_id2, lit_cpointer_t lit_id3) +create_op_meta_111 (vm_instr_t op, lit_cpointer_t lit_id1, lit_cpointer_t lit_id2, lit_cpointer_t lit_id3) { return create_op_meta (op, lit_id1, lit_id2, lit_id3); } @@ -262,7 +262,7 @@ is_native_call (operand obj) } static op_meta -create_op_meta_for_res_and_obj (opcode_t (*getop) (idx_t, idx_t, idx_t), operand *res, operand *obj) +create_op_meta_for_res_and_obj (vm_instr_t (*getop) (idx_t, idx_t, idx_t), operand *res, operand *obj) { JERRY_ASSERT (obj != NULL); JERRY_ASSERT (res != NULL); @@ -275,14 +275,14 @@ create_op_meta_for_res_and_obj (opcode_t (*getop) (idx_t, idx_t, idx_t), operand { case OPERAND_TMP: { - const opcode_t opcode = getop (res->data.uid, obj->data.uid, INVALID_VALUE); - ret = create_op_meta_000 (opcode); + const vm_instr_t instr = getop (res->data.uid, obj->data.uid, INVALID_VALUE); + ret = create_op_meta_000 (instr); break; } case OPERAND_LITERAL: { - const opcode_t opcode = getop (LITERAL_TO_REWRITE, obj->data.uid, INVALID_VALUE); - ret = create_op_meta_100 (opcode, res->data.lit_id); + const vm_instr_t instr = getop (LITERAL_TO_REWRITE, obj->data.uid, INVALID_VALUE); + ret = create_op_meta_100 (instr, res->data.lit_id); break; } } @@ -294,14 +294,14 @@ create_op_meta_for_res_and_obj (opcode_t (*getop) (idx_t, idx_t, idx_t), operand { case OPERAND_TMP: { - const opcode_t opcode = getop (res->data.uid, LITERAL_TO_REWRITE, INVALID_VALUE); - ret = create_op_meta_010 (opcode, obj->data.lit_id); + const vm_instr_t instr = getop (res->data.uid, LITERAL_TO_REWRITE, INVALID_VALUE); + ret = create_op_meta_010 (instr, obj->data.lit_id); break; } case OPERAND_LITERAL: { - const opcode_t opcode = getop (LITERAL_TO_REWRITE, LITERAL_TO_REWRITE, INVALID_VALUE); - ret = create_op_meta_110 (opcode, res->data.lit_id, obj->data.lit_id); + const vm_instr_t instr = getop (LITERAL_TO_REWRITE, LITERAL_TO_REWRITE, INVALID_VALUE); + ret = create_op_meta_110 (instr, res->data.lit_id, obj->data.lit_id); break; } } @@ -312,7 +312,7 @@ create_op_meta_for_res_and_obj (opcode_t (*getop) (idx_t, idx_t, idx_t), operand } static op_meta -create_op_meta_for_obj (opcode_t (*getop) (idx_t, idx_t), operand *obj) +create_op_meta_for_obj (vm_instr_t (*getop) (idx_t, idx_t), operand *obj) { JERRY_ASSERT (obj != NULL); op_meta res; @@ -320,14 +320,14 @@ create_op_meta_for_obj (opcode_t (*getop) (idx_t, idx_t), operand *obj) { case OPERAND_TMP: { - const opcode_t opcode = getop (obj->data.uid, INVALID_VALUE); - res = create_op_meta_000 (opcode); + const vm_instr_t instr = getop (obj->data.uid, INVALID_VALUE); + res = create_op_meta_000 (instr); break; } case OPERAND_LITERAL: { - const opcode_t opcode = getop (LITERAL_TO_REWRITE, INVALID_VALUE); - res = create_op_meta_100 (opcode, obj->data.lit_id); + const vm_instr_t instr = getop (LITERAL_TO_REWRITE, INVALID_VALUE); + res = create_op_meta_100 (instr, obj->data.lit_id); break; } } @@ -343,14 +343,14 @@ create_op_meta_for_native_call (operand res, operand obj) { case OPERAND_TMP: { - const opcode_t opcode = getop_native_call (res.data.uid, name_to_native_call_id (obj), INVALID_VALUE); - ret = create_op_meta_000 (opcode); + const vm_instr_t instr = getop_native_call (res.data.uid, name_to_native_call_id (obj), INVALID_VALUE); + ret = create_op_meta_000 (instr); break; } case OPERAND_LITERAL: { - const opcode_t opcode = getop_native_call (LITERAL_TO_REWRITE, name_to_native_call_id (obj), INVALID_VALUE); - ret = create_op_meta_100 (opcode, res.data.lit_id); + const vm_instr_t instr = getop_native_call (LITERAL_TO_REWRITE, name_to_native_call_id (obj), INVALID_VALUE); + ret = create_op_meta_100 (instr, res.data.lit_id); break; } } @@ -401,43 +401,43 @@ create_op_meta_for_vlt (varg_list_type vlt, operand *res, operand *obj) } static void -split_opcode_counter (opcode_counter_t oc, idx_t *id1, idx_t *id2) +split_instr_counter (vm_instr_counter_t oc, idx_t *id1, idx_t *id2) { JERRY_ASSERT (id1 != NULL); JERRY_ASSERT (id2 != NULL); *id1 = (idx_t) (oc >> JERRY_BITSINBYTE); *id2 = (idx_t) (oc & ((1 << JERRY_BITSINBYTE) - 1)); - JERRY_ASSERT (oc == calc_opcode_counter_from_idx_idx (*id1, *id2)); + JERRY_ASSERT (oc == vm_calc_instr_counter_from_idx_idx (*id1, *id2)); } static op_meta last_dumped_op_meta (void) { - return serializer_get_op_meta ((opcode_counter_t) (serializer_get_current_opcode_counter () - 1)); + return serializer_get_op_meta ((vm_instr_counter_t) (serializer_get_current_instr_counter () - 1)); } static void -dump_single_address (opcode_t (*getop) (idx_t), operand op) +dump_single_address (vm_instr_t (*getop) (idx_t), operand op) { switch (op.type) { case OPERAND_LITERAL: { - const opcode_t opcode = getop (LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_100 (opcode, op.data.lit_id)); + const vm_instr_t instr = getop (LITERAL_TO_REWRITE); + serializer_dump_op_meta (create_op_meta_100 (instr, op.data.lit_id)); break; } case OPERAND_TMP: { - const opcode_t opcode = getop (op.data.uid); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + const vm_instr_t instr = getop (op.data.uid); + serializer_dump_op_meta (create_op_meta_000 (instr)); break; } } } static void -dump_double_address (opcode_t (*getop) (idx_t, idx_t), operand res, operand obj) +dump_double_address (vm_instr_t (*getop) (idx_t, idx_t), operand res, operand obj) { switch (res.type) { @@ -447,14 +447,14 @@ dump_double_address (opcode_t (*getop) (idx_t, idx_t), operand res, operand obj) { case OPERAND_LITERAL: { - const opcode_t opcode = getop (LITERAL_TO_REWRITE, LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_110 (opcode, res.data.lit_id, obj.data.lit_id)); + const vm_instr_t instr = getop (LITERAL_TO_REWRITE, LITERAL_TO_REWRITE); + serializer_dump_op_meta (create_op_meta_110 (instr, res.data.lit_id, obj.data.lit_id)); break; } case OPERAND_TMP: { - const opcode_t opcode = getop (LITERAL_TO_REWRITE, obj.data.uid); - serializer_dump_op_meta (create_op_meta_100 (opcode, res.data.lit_id)); + const vm_instr_t instr = getop (LITERAL_TO_REWRITE, obj.data.uid); + serializer_dump_op_meta (create_op_meta_100 (instr, res.data.lit_id)); break; } } @@ -466,14 +466,14 @@ dump_double_address (opcode_t (*getop) (idx_t, idx_t), operand res, operand obj) { case OPERAND_LITERAL: { - const opcode_t opcode = getop (res.data.uid, LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_010 (opcode, obj.data.lit_id)); + const vm_instr_t instr = getop (res.data.uid, LITERAL_TO_REWRITE); + serializer_dump_op_meta (create_op_meta_010 (instr, obj.data.lit_id)); break; } case OPERAND_TMP: { - const opcode_t opcode = getop (res.data.uid, obj.data.uid); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + const vm_instr_t instr = getop (res.data.uid, obj.data.uid); + serializer_dump_op_meta (create_op_meta_000 (instr)); break; } } @@ -483,7 +483,7 @@ dump_double_address (opcode_t (*getop) (idx_t, idx_t), operand res, operand obj) } static void -dump_triple_address (opcode_t (*getop) (idx_t, idx_t, idx_t), operand res, operand lhs, operand rhs) +dump_triple_address (vm_instr_t (*getop) (idx_t, idx_t, idx_t), operand res, operand lhs, operand rhs) { switch (res.type) { @@ -497,14 +497,14 @@ dump_triple_address (opcode_t (*getop) (idx_t, idx_t, idx_t), operand res, opera { case OPERAND_LITERAL: { - const opcode_t opcode = getop (LITERAL_TO_REWRITE, LITERAL_TO_REWRITE, LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_111 (opcode, res.data.lit_id, lhs.data.lit_id, rhs.data.lit_id)); + const vm_instr_t instr = getop (LITERAL_TO_REWRITE, LITERAL_TO_REWRITE, LITERAL_TO_REWRITE); + serializer_dump_op_meta (create_op_meta_111 (instr, res.data.lit_id, lhs.data.lit_id, rhs.data.lit_id)); break; } case OPERAND_TMP: { - const opcode_t opcode = getop (LITERAL_TO_REWRITE, LITERAL_TO_REWRITE, rhs.data.uid); - serializer_dump_op_meta (create_op_meta_110 (opcode, res.data.lit_id, lhs.data.lit_id)); + const vm_instr_t instr = getop (LITERAL_TO_REWRITE, LITERAL_TO_REWRITE, rhs.data.uid); + serializer_dump_op_meta (create_op_meta_110 (instr, res.data.lit_id, lhs.data.lit_id)); break; } } @@ -516,14 +516,14 @@ dump_triple_address (opcode_t (*getop) (idx_t, idx_t, idx_t), operand res, opera { case OPERAND_LITERAL: { - const opcode_t opcode = getop (LITERAL_TO_REWRITE, lhs.data.uid, LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_101 (opcode, res.data.lit_id, rhs.data.lit_id)); + const vm_instr_t instr = getop (LITERAL_TO_REWRITE, lhs.data.uid, LITERAL_TO_REWRITE); + serializer_dump_op_meta (create_op_meta_101 (instr, res.data.lit_id, rhs.data.lit_id)); break; } case OPERAND_TMP: { - const opcode_t opcode = getop (LITERAL_TO_REWRITE, lhs.data.uid, rhs.data.uid); - serializer_dump_op_meta (create_op_meta_100 (opcode, res.data.lit_id)); + const vm_instr_t instr = getop (LITERAL_TO_REWRITE, lhs.data.uid, rhs.data.uid); + serializer_dump_op_meta (create_op_meta_100 (instr, res.data.lit_id)); break; } } @@ -542,14 +542,14 @@ dump_triple_address (opcode_t (*getop) (idx_t, idx_t, idx_t), operand res, opera { case OPERAND_LITERAL: { - const opcode_t opcode = getop (res.data.uid, LITERAL_TO_REWRITE, LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_011 (opcode, lhs.data.lit_id, rhs.data.lit_id)); + const vm_instr_t instr = getop (res.data.uid, LITERAL_TO_REWRITE, LITERAL_TO_REWRITE); + serializer_dump_op_meta (create_op_meta_011 (instr, lhs.data.lit_id, rhs.data.lit_id)); break; } case OPERAND_TMP: { - const opcode_t opcode = getop (res.data.uid, LITERAL_TO_REWRITE, rhs.data.uid); - serializer_dump_op_meta (create_op_meta_010 (opcode, lhs.data.lit_id)); + const vm_instr_t instr = getop (res.data.uid, LITERAL_TO_REWRITE, rhs.data.uid); + serializer_dump_op_meta (create_op_meta_010 (instr, lhs.data.lit_id)); break; } } @@ -561,14 +561,14 @@ dump_triple_address (opcode_t (*getop) (idx_t, idx_t, idx_t), operand res, opera { case OPERAND_LITERAL: { - const opcode_t opcode = getop (res.data.uid, lhs.data.uid, LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_001 (opcode, rhs.data.lit_id)); + const vm_instr_t instr = getop (res.data.uid, lhs.data.uid, LITERAL_TO_REWRITE); + serializer_dump_op_meta (create_op_meta_001 (instr, rhs.data.lit_id)); break; } case OPERAND_TMP: { - const opcode_t opcode = getop (res.data.uid, lhs.data.uid, rhs.data.uid); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + const vm_instr_t instr = getop (res.data.uid, lhs.data.uid, rhs.data.uid); + serializer_dump_op_meta (create_op_meta_000 (instr)); break; } } @@ -588,18 +588,18 @@ dump_prop_setter_op_meta (op_meta last, operand op) { case OPERAND_LITERAL: { - const opcode_t opcode = getop_prop_setter (last.op.data.prop_getter.obj, - last.op.data.prop_getter.prop, - LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_111 (opcode, last.lit_id[1], last.lit_id[2], op.data.lit_id)); + const vm_instr_t instr = getop_prop_setter (last.op.data.prop_getter.obj, + last.op.data.prop_getter.prop, + LITERAL_TO_REWRITE); + serializer_dump_op_meta (create_op_meta_111 (instr, last.lit_id[1], last.lit_id[2], op.data.lit_id)); break; } case OPERAND_TMP: { - const opcode_t opcode = getop_prop_setter (last.op.data.prop_getter.obj, - last.op.data.prop_getter.prop, - op.data.uid); - serializer_dump_op_meta (create_op_meta_110 (opcode, last.lit_id[1], last.lit_id[2])); + const vm_instr_t instr = getop_prop_setter (last.op.data.prop_getter.obj, + last.op.data.prop_getter.prop, + op.data.uid); + serializer_dump_op_meta (create_op_meta_110 (instr, last.lit_id[1], last.lit_id[2])); break; } } @@ -671,10 +671,10 @@ dump_prop_setter_or_triple_address_res (void (*dumper) (operand, operand, operan return res; } -static opcode_counter_t -get_diff_from (opcode_counter_t oc) +static vm_instr_counter_t +get_diff_from (vm_instr_counter_t oc) { - return (opcode_counter_t) (serializer_get_current_opcode_counter () - oc); + return (vm_instr_counter_t) (serializer_get_current_instr_counter () - oc); } operand @@ -717,7 +717,7 @@ eval_ret_operand (void) /** * Creates operand for taking iterator value (next property name) - * from for-in opcode handler. + * from for-in instr handler. * * @return constructed operand */ @@ -823,19 +823,19 @@ dump_boolean_assignment (operand op, bool is_true) { case OPERAND_LITERAL: { - const opcode_t opcode = getop_assignment (LITERAL_TO_REWRITE, - OPCODE_ARG_TYPE_SIMPLE, - is_true ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE); - const op_meta om = create_op_meta_100 (opcode, op.data.lit_id); + const vm_instr_t instr = getop_assignment (LITERAL_TO_REWRITE, + OPCODE_ARG_TYPE_SIMPLE, + is_true ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE); + const op_meta om = create_op_meta_100 (instr, op.data.lit_id); serializer_dump_op_meta (om); break; } case OPERAND_TMP: { - const opcode_t opcode = getop_assignment (op.data.uid, - OPCODE_ARG_TYPE_SIMPLE, - is_true ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE); - const op_meta om = create_op_meta_000 (opcode); + const vm_instr_t instr = getop_assignment (op.data.uid, + OPCODE_ARG_TYPE_SIMPLE, + is_true ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE); + const op_meta om = create_op_meta_000 (instr); serializer_dump_op_meta (om); break; } @@ -857,14 +857,14 @@ dump_string_assignment (operand op, lit_cpointer_t lit_id) { case OPERAND_LITERAL: { - const opcode_t opcode = getop_assignment (LITERAL_TO_REWRITE, OPCODE_ARG_TYPE_STRING, LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_101 (opcode, op.data.lit_id, lit_id)); + const vm_instr_t instr = getop_assignment (LITERAL_TO_REWRITE, OPCODE_ARG_TYPE_STRING, LITERAL_TO_REWRITE); + serializer_dump_op_meta (create_op_meta_101 (instr, op.data.lit_id, lit_id)); break; } case OPERAND_TMP: { - const opcode_t opcode = getop_assignment (op.data.uid, OPCODE_ARG_TYPE_STRING, LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_001 (opcode, lit_id)); + const vm_instr_t instr = getop_assignment (op.data.uid, OPCODE_ARG_TYPE_STRING, LITERAL_TO_REWRITE); + serializer_dump_op_meta (create_op_meta_001 (instr, lit_id)); break; } } @@ -885,14 +885,14 @@ dump_number_assignment (operand op, lit_cpointer_t lit_id) { case OPERAND_LITERAL: { - const opcode_t opcode = getop_assignment (LITERAL_TO_REWRITE, OPCODE_ARG_TYPE_NUMBER, LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_101 (opcode, op.data.lit_id, lit_id)); + const vm_instr_t instr = getop_assignment (LITERAL_TO_REWRITE, OPCODE_ARG_TYPE_NUMBER, LITERAL_TO_REWRITE); + serializer_dump_op_meta (create_op_meta_101 (instr, op.data.lit_id, lit_id)); break; } case OPERAND_TMP: { - const opcode_t opcode = getop_assignment (op.data.uid, OPCODE_ARG_TYPE_NUMBER, LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_001 (opcode, lit_id)); + const vm_instr_t instr = getop_assignment (op.data.uid, OPCODE_ARG_TYPE_NUMBER, LITERAL_TO_REWRITE); + serializer_dump_op_meta (create_op_meta_001 (instr, lit_id)); break; } } @@ -913,14 +913,14 @@ dump_regexp_assignment (operand op, lit_cpointer_t lit_id) { case OPERAND_LITERAL: { - const opcode_t opcode = getop_assignment (LITERAL_TO_REWRITE, OPCODE_ARG_TYPE_REGEXP, LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_101 (opcode, op.data.lit_id, lit_id)); + const vm_instr_t instr = getop_assignment (LITERAL_TO_REWRITE, OPCODE_ARG_TYPE_REGEXP, LITERAL_TO_REWRITE); + serializer_dump_op_meta (create_op_meta_101 (instr, op.data.lit_id, lit_id)); break; } case OPERAND_TMP: { - const opcode_t opcode = getop_assignment (op.data.uid, OPCODE_ARG_TYPE_REGEXP, LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_001 (opcode, lit_id)); + const vm_instr_t instr = getop_assignment (op.data.uid, OPCODE_ARG_TYPE_REGEXP, LITERAL_TO_REWRITE); + serializer_dump_op_meta (create_op_meta_001 (instr, lit_id)); break; } } @@ -941,14 +941,14 @@ dump_smallint_assignment (operand op, idx_t uid) { case OPERAND_LITERAL: { - const opcode_t opcode = getop_assignment (LITERAL_TO_REWRITE, OPCODE_ARG_TYPE_SMALLINT, uid); - serializer_dump_op_meta (create_op_meta_100 (opcode, op.data.lit_id)); + const vm_instr_t instr = getop_assignment (LITERAL_TO_REWRITE, OPCODE_ARG_TYPE_SMALLINT, uid); + serializer_dump_op_meta (create_op_meta_100 (instr, op.data.lit_id)); break; } case OPERAND_TMP: { - const opcode_t opcode = getop_assignment (op.data.uid, OPCODE_ARG_TYPE_SMALLINT, uid); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + const vm_instr_t instr = getop_assignment (op.data.uid, OPCODE_ARG_TYPE_SMALLINT, uid); + serializer_dump_op_meta (create_op_meta_000 (instr)); break; } } @@ -969,16 +969,16 @@ dump_undefined_assignment (operand op) { case OPERAND_LITERAL: { - const opcode_t opcode = getop_assignment (LITERAL_TO_REWRITE, - OPCODE_ARG_TYPE_SIMPLE, - ECMA_SIMPLE_VALUE_UNDEFINED); - serializer_dump_op_meta (create_op_meta_100 (opcode, op.data.lit_id)); + const vm_instr_t instr = getop_assignment (LITERAL_TO_REWRITE, + OPCODE_ARG_TYPE_SIMPLE, + ECMA_SIMPLE_VALUE_UNDEFINED); + serializer_dump_op_meta (create_op_meta_100 (instr, op.data.lit_id)); break; } case OPERAND_TMP: { - const opcode_t opcode = getop_assignment (op.data.uid, OPCODE_ARG_TYPE_SIMPLE, ECMA_SIMPLE_VALUE_UNDEFINED); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + const vm_instr_t instr = getop_assignment (op.data.uid, OPCODE_ARG_TYPE_SIMPLE, ECMA_SIMPLE_VALUE_UNDEFINED); + serializer_dump_op_meta (create_op_meta_000 (instr)); break; } } @@ -999,18 +999,18 @@ dump_null_assignment (operand op) { case OPERAND_LITERAL: { - const opcode_t opcode = getop_assignment (LITERAL_TO_REWRITE, - OPCODE_ARG_TYPE_SIMPLE, - ECMA_SIMPLE_VALUE_NULL); - serializer_dump_op_meta (create_op_meta_100 (opcode, op.data.lit_id)); + const vm_instr_t instr = getop_assignment (LITERAL_TO_REWRITE, + OPCODE_ARG_TYPE_SIMPLE, + ECMA_SIMPLE_VALUE_NULL); + serializer_dump_op_meta (create_op_meta_100 (instr, op.data.lit_id)); break; } case OPERAND_TMP: { - const opcode_t opcode = getop_assignment (op.data.uid, - OPCODE_ARG_TYPE_SIMPLE, - ECMA_SIMPLE_VALUE_NULL); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + const vm_instr_t instr = getop_assignment (op.data.uid, + OPCODE_ARG_TYPE_SIMPLE, + ECMA_SIMPLE_VALUE_NULL); + serializer_dump_op_meta (create_op_meta_000 (instr)); break; } } @@ -1035,18 +1035,18 @@ dump_variable_assignment (operand res, operand var) { case OPERAND_LITERAL: { - const opcode_t opcode = getop_assignment (LITERAL_TO_REWRITE, - OPCODE_ARG_TYPE_VARIABLE, - LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_101 (opcode, res.data.lit_id, var.data.lit_id)); + const vm_instr_t instr = getop_assignment (LITERAL_TO_REWRITE, + OPCODE_ARG_TYPE_VARIABLE, + LITERAL_TO_REWRITE); + serializer_dump_op_meta (create_op_meta_101 (instr, res.data.lit_id, var.data.lit_id)); break; } case OPERAND_TMP: { - const opcode_t opcode = getop_assignment (LITERAL_TO_REWRITE, - OPCODE_ARG_TYPE_VARIABLE, - var.data.uid); - serializer_dump_op_meta (create_op_meta_100 (opcode, res.data.lit_id)); + const vm_instr_t instr = getop_assignment (LITERAL_TO_REWRITE, + OPCODE_ARG_TYPE_VARIABLE, + var.data.uid); + serializer_dump_op_meta (create_op_meta_100 (instr, res.data.lit_id)); break; } } @@ -1058,18 +1058,18 @@ dump_variable_assignment (operand res, operand var) { case OPERAND_LITERAL: { - const opcode_t opcode = getop_assignment (res.data.uid, - OPCODE_ARG_TYPE_VARIABLE, - LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_001 (opcode, var.data.lit_id)); + const vm_instr_t instr = getop_assignment (res.data.uid, + OPCODE_ARG_TYPE_VARIABLE, + LITERAL_TO_REWRITE); + serializer_dump_op_meta (create_op_meta_001 (instr, var.data.lit_id)); break; } case OPERAND_TMP: { - const opcode_t opcode = getop_assignment (res.data.uid, - OPCODE_ARG_TYPE_VARIABLE, - var.data.uid); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + const vm_instr_t instr = getop_assignment (res.data.uid, + OPCODE_ARG_TYPE_VARIABLE, + var.data.uid); + serializer_dump_op_meta (create_op_meta_000 (instr)); break; } } @@ -1089,7 +1089,7 @@ dump_variable_assignment_res (operand var) void dump_varg_header_for_rewrite (varg_list_type vlt, operand obj) { - STACK_PUSH (varg_headers, serializer_get_current_opcode_counter ()); + STACK_PUSH (varg_headers, serializer_get_current_instr_counter ()); switch (vlt) { case VARG_FUNC_EXPR: @@ -1176,13 +1176,13 @@ dump_call_additional_info (opcode_call_flags_t flags, /**< call flags */ JERRY_ASSERT (operand_is_empty (this_arg)); } - const opcode_t opcode = getop_meta (OPCODE_META_TYPE_CALL_SITE_INFO, - flags, - (idx_t) (flags & OPCODE_CALL_FLAGS_HAVE_THIS_ARG - ? this_arg.data.uid - : INVALID_VALUE)); + const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_CALL_SITE_INFO, + flags, + (idx_t) (flags & OPCODE_CALL_FLAGS_HAVE_THIS_ARG + ? this_arg.data.uid + : INVALID_VALUE)); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + serializer_dump_op_meta (create_op_meta_000 (instr)); } /* dump_call_additional_info */ void @@ -1192,14 +1192,14 @@ dump_varg (operand op) { case OPERAND_TMP: { - const opcode_t opcode = getop_meta (OPCODE_META_TYPE_VARG, op.data.uid, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_VARG, op.data.uid, INVALID_VALUE); + serializer_dump_op_meta (create_op_meta_000 (instr)); return; } case OPERAND_LITERAL: { - const opcode_t opcode = getop_meta (OPCODE_META_TYPE_VARG, LITERAL_TO_REWRITE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_010 (opcode, op.data.lit_id)); + const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_VARG, LITERAL_TO_REWRITE, INVALID_VALUE); + serializer_dump_op_meta (create_op_meta_010 (instr, op.data.lit_id)); return; } } @@ -1226,14 +1226,14 @@ dump_prop_name_and_value (operand name, operand value) { case OPERAND_LITERAL: { - const opcode_t opcode = getop_meta (OPCODE_META_TYPE_VARG_PROP_DATA, tmp.data.uid, LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_001 (opcode, value.data.lit_id)); + const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_VARG_PROP_DATA, tmp.data.uid, LITERAL_TO_REWRITE); + serializer_dump_op_meta (create_op_meta_001 (instr, value.data.lit_id)); break; } case OPERAND_TMP: { - const opcode_t opcode = getop_meta (OPCODE_META_TYPE_VARG_PROP_DATA, tmp.data.uid, value.data.uid); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_VARG_PROP_DATA, tmp.data.uid, value.data.uid); + serializer_dump_op_meta (create_op_meta_000 (instr)); break; } } @@ -1257,8 +1257,8 @@ dump_prop_getter_decl (operand name, operand func) JERRY_ASSERT (lit->get_type () == LIT_NUMBER_T); tmp = dump_number_assignment_res (name.data.lit_id); } - const opcode_t opcode = getop_meta (OPCODE_META_TYPE_VARG_PROP_GETTER, tmp.data.uid, func.data.uid); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_VARG_PROP_GETTER, tmp.data.uid, func.data.uid); + serializer_dump_op_meta (create_op_meta_000 (instr)); } void @@ -1279,8 +1279,8 @@ dump_prop_setter_decl (operand name, operand func) JERRY_ASSERT (lit->get_type () == LIT_NUMBER_T); tmp = dump_number_assignment_res (name.data.lit_id); } - const opcode_t opcode = getop_meta (OPCODE_META_TYPE_VARG_PROP_SETTER, tmp.data.uid, func.data.uid); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_VARG_PROP_SETTER, tmp.data.uid, func.data.uid); + serializer_dump_op_meta (create_op_meta_000 (instr)); } void @@ -1306,29 +1306,29 @@ dump_prop_setter (operand res, operand obj, operand prop) void dump_function_end_for_rewrite (void) { - STACK_PUSH (function_ends, serializer_get_current_opcode_counter ()); - const opcode_t opcode = getop_meta (OPCODE_META_TYPE_FUNCTION_END, INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + STACK_PUSH (function_ends, serializer_get_current_instr_counter ()); + const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_FUNCTION_END, INVALID_VALUE, INVALID_VALUE); + serializer_dump_op_meta (create_op_meta_000 (instr)); } void rewrite_function_end (varg_list_type vlt) { - opcode_counter_t oc; + vm_instr_counter_t oc; if (vlt == VARG_FUNC_DECL) { - oc = (opcode_counter_t) (get_diff_from (STACK_TOP (function_ends)) - + serializer_count_opcodes_in_subscopes ()); + oc = (vm_instr_counter_t) (get_diff_from (STACK_TOP (function_ends)) + + serializer_count_instrs_in_subscopes ()); } else { JERRY_ASSERT (vlt == VARG_FUNC_EXPR); - oc = (opcode_counter_t) (get_diff_from (STACK_TOP (function_ends))); + oc = (vm_instr_counter_t) (get_diff_from (STACK_TOP (function_ends))); } idx_t id1, id2; - split_opcode_counter (oc, &id1, &id2); - const opcode_t opcode = getop_meta (OPCODE_META_TYPE_FUNCTION_END, id1, id2); - serializer_rewrite_op_meta (STACK_TOP (function_ends), create_op_meta_000 (opcode)); + split_instr_counter (oc, &id1, &id2); + const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_FUNCTION_END, id1, id2); + serializer_rewrite_op_meta (STACK_TOP (function_ends), create_op_meta_000 (instr)); STACK_DROP (function_ends, 1); } @@ -1475,14 +1475,14 @@ dump_delete (operand res, operand op, bool is_strict, locus loc) { case OPERAND_LITERAL: { - const opcode_t opcode = getop_delete_var (LITERAL_TO_REWRITE, LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_110 (opcode, res.data.lit_id, op.data.lit_id)); + const vm_instr_t instr = getop_delete_var (LITERAL_TO_REWRITE, LITERAL_TO_REWRITE); + serializer_dump_op_meta (create_op_meta_110 (instr, res.data.lit_id, op.data.lit_id)); break; } case OPERAND_TMP: { - const opcode_t opcode = getop_delete_var (res.data.uid, LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_010 (opcode, op.data.lit_id)); + const vm_instr_t instr = getop_delete_var (res.data.uid, LITERAL_TO_REWRITE); + serializer_dump_op_meta (create_op_meta_010 (instr, op.data.lit_id)); break; } } @@ -1501,7 +1501,7 @@ dump_delete (operand res, operand op, bool is_strict, locus loc) { case VM_OP_PROP_GETTER: { - const opcode_counter_t oc = (opcode_counter_t) (serializer_get_current_opcode_counter () - 1); + const vm_instr_counter_t oc = (vm_instr_counter_t) (serializer_get_current_instr_counter () - 1); serializer_set_writing_position (oc); switch (res.type) { @@ -1511,19 +1511,19 @@ dump_delete (operand res, operand op, bool is_strict, locus loc) { if (last_op_meta.op.data.prop_getter.prop == LITERAL_TO_REWRITE) { - const opcode_t opcode = getop_delete_prop (LITERAL_TO_REWRITE, - LITERAL_TO_REWRITE, - LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_111 (opcode, res.data.lit_id, + const vm_instr_t instr = getop_delete_prop (LITERAL_TO_REWRITE, + LITERAL_TO_REWRITE, + LITERAL_TO_REWRITE); + serializer_dump_op_meta (create_op_meta_111 (instr, res.data.lit_id, last_op_meta.lit_id[1], last_op_meta.lit_id[2])); } else { - const opcode_t opcode = getop_delete_prop (LITERAL_TO_REWRITE, - LITERAL_TO_REWRITE, - last_op_meta.op.data.prop_getter.prop); - serializer_dump_op_meta (create_op_meta_110 (opcode, res.data.lit_id, + const vm_instr_t instr = getop_delete_prop (LITERAL_TO_REWRITE, + LITERAL_TO_REWRITE, + last_op_meta.op.data.prop_getter.prop); + serializer_dump_op_meta (create_op_meta_110 (instr, res.data.lit_id, last_op_meta.lit_id[1])); } } @@ -1531,18 +1531,18 @@ dump_delete (operand res, operand op, bool is_strict, locus loc) { if (last_op_meta.op.data.prop_getter.prop == LITERAL_TO_REWRITE) { - const opcode_t opcode = getop_delete_prop (LITERAL_TO_REWRITE, - last_op_meta.op.data.prop_getter.obj, - LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_101 (opcode, res.data.lit_id, + const vm_instr_t instr = getop_delete_prop (LITERAL_TO_REWRITE, + last_op_meta.op.data.prop_getter.obj, + LITERAL_TO_REWRITE); + serializer_dump_op_meta (create_op_meta_101 (instr, res.data.lit_id, last_op_meta.lit_id[2])); } else { - const opcode_t opcode = getop_delete_prop (LITERAL_TO_REWRITE, - last_op_meta.op.data.prop_getter.obj, - last_op_meta.op.data.prop_getter.prop); - serializer_dump_op_meta (create_op_meta_100 (opcode, res.data.lit_id)); + const vm_instr_t instr = getop_delete_prop (LITERAL_TO_REWRITE, + last_op_meta.op.data.prop_getter.obj, + last_op_meta.op.data.prop_getter.prop); + serializer_dump_op_meta (create_op_meta_100 (instr, res.data.lit_id)); } } break; @@ -1553,35 +1553,35 @@ dump_delete (operand res, operand op, bool is_strict, locus loc) { if (last_op_meta.op.data.prop_getter.prop == LITERAL_TO_REWRITE) { - const opcode_t opcode = getop_delete_prop (res.data.uid, - LITERAL_TO_REWRITE, - LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_011 (opcode, last_op_meta.lit_id[1], + const vm_instr_t instr = getop_delete_prop (res.data.uid, + LITERAL_TO_REWRITE, + LITERAL_TO_REWRITE); + serializer_dump_op_meta (create_op_meta_011 (instr, last_op_meta.lit_id[1], last_op_meta.lit_id[2])); } else { - const opcode_t opcode = getop_delete_prop (res.data.uid, - LITERAL_TO_REWRITE, - last_op_meta.op.data.prop_getter.prop); - serializer_dump_op_meta (create_op_meta_010 (opcode, last_op_meta.lit_id[1])); + const vm_instr_t instr = getop_delete_prop (res.data.uid, + LITERAL_TO_REWRITE, + last_op_meta.op.data.prop_getter.prop); + serializer_dump_op_meta (create_op_meta_010 (instr, last_op_meta.lit_id[1])); } } else { if (last_op_meta.op.data.prop_getter.prop == LITERAL_TO_REWRITE) { - const opcode_t opcode = getop_delete_prop (res.data.uid, - last_op_meta.op.data.prop_getter.obj, - LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_001 (opcode, last_op_meta.lit_id[2])); + const vm_instr_t instr = getop_delete_prop (res.data.uid, + last_op_meta.op.data.prop_getter.obj, + LITERAL_TO_REWRITE); + serializer_dump_op_meta (create_op_meta_001 (instr, last_op_meta.lit_id[2])); } else { - const opcode_t opcode = getop_delete_prop (res.data.uid, - last_op_meta.op.data.prop_getter.obj, - last_op_meta.op.data.prop_getter.prop); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + const vm_instr_t instr = getop_delete_prop (res.data.uid, + last_op_meta.op.data.prop_getter.obj, + last_op_meta.op.data.prop_getter.prop); + serializer_dump_op_meta (create_op_meta_000 (instr)); } } break; @@ -1924,19 +1924,19 @@ start_dumping_logical_and_checks (void) void dump_logical_and_check_for_rewrite (operand op) { - STACK_PUSH (logical_and_checks, serializer_get_current_opcode_counter ()); + STACK_PUSH (logical_and_checks, serializer_get_current_instr_counter ()); switch (op.type) { case OPERAND_LITERAL: { - const opcode_t opcode = getop_is_false_jmp_down (LITERAL_TO_REWRITE, INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_100 (opcode, op.data.lit_id)); + const vm_instr_t instr = getop_is_false_jmp_down (LITERAL_TO_REWRITE, INVALID_VALUE, INVALID_VALUE); + serializer_dump_op_meta (create_op_meta_100 (instr, op.data.lit_id)); break; } case OPERAND_TMP: { - const opcode_t opcode = getop_is_false_jmp_down (op.data.uid, INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + const vm_instr_t instr = getop_is_false_jmp_down (op.data.uid, INVALID_VALUE, INVALID_VALUE); + serializer_dump_op_meta (create_op_meta_000 (instr)); break; } } @@ -1950,9 +1950,9 @@ rewrite_logical_and_checks (void) op_meta jmp_op_meta = serializer_get_op_meta (STACK_ELEMENT (logical_and_checks, i)); JERRY_ASSERT (jmp_op_meta.op.op_idx == VM_OP_IS_FALSE_JMP_DOWN); idx_t id1, id2; - split_opcode_counter (get_diff_from (STACK_ELEMENT (logical_and_checks, i)), &id1, &id2); - jmp_op_meta.op.data.is_false_jmp_down.opcode_1 = id1; - jmp_op_meta.op.data.is_false_jmp_down.opcode_2 = id2; + split_instr_counter (get_diff_from (STACK_ELEMENT (logical_and_checks, i)), &id1, &id2); + jmp_op_meta.op.data.is_false_jmp_down.oc_idx_1 = id1; + jmp_op_meta.op.data.is_false_jmp_down.oc_idx_2 = id2; serializer_rewrite_op_meta (STACK_ELEMENT (logical_and_checks, i), jmp_op_meta); } STACK_DROP (logical_and_checks, STACK_SIZE (logical_and_checks) - STACK_TOP (U8)); @@ -1968,19 +1968,19 @@ start_dumping_logical_or_checks (void) void dump_logical_or_check_for_rewrite (operand op) { - STACK_PUSH (logical_or_checks, serializer_get_current_opcode_counter ()); + STACK_PUSH (logical_or_checks, serializer_get_current_instr_counter ()); switch (op.type) { case OPERAND_LITERAL: { - const opcode_t opcode = getop_is_true_jmp_down (LITERAL_TO_REWRITE, INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_100 (opcode, op.data.lit_id)); + const vm_instr_t instr = getop_is_true_jmp_down (LITERAL_TO_REWRITE, INVALID_VALUE, INVALID_VALUE); + serializer_dump_op_meta (create_op_meta_100 (instr, op.data.lit_id)); break; } case OPERAND_TMP: { - const opcode_t opcode = getop_is_true_jmp_down (op.data.uid, INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + const vm_instr_t instr = getop_is_true_jmp_down (op.data.uid, INVALID_VALUE, INVALID_VALUE); + serializer_dump_op_meta (create_op_meta_000 (instr)); break; } } @@ -1994,9 +1994,9 @@ rewrite_logical_or_checks (void) op_meta jmp_op_meta = serializer_get_op_meta (STACK_ELEMENT (logical_or_checks, i)); JERRY_ASSERT (jmp_op_meta.op.op_idx == VM_OP_IS_TRUE_JMP_DOWN); idx_t id1, id2; - split_opcode_counter (get_diff_from (STACK_ELEMENT (logical_or_checks, i)), &id1, &id2); - jmp_op_meta.op.data.is_true_jmp_down.opcode_1 = id1; - jmp_op_meta.op.data.is_true_jmp_down.opcode_2 = id2; + split_instr_counter (get_diff_from (STACK_ELEMENT (logical_or_checks, i)), &id1, &id2); + jmp_op_meta.op.data.is_true_jmp_down.oc_idx_1 = id1; + jmp_op_meta.op.data.is_true_jmp_down.oc_idx_2 = id2; serializer_rewrite_op_meta (STACK_ELEMENT (logical_or_checks, i), jmp_op_meta); } STACK_DROP (logical_or_checks, STACK_SIZE (logical_or_checks) - STACK_TOP (U8)); @@ -2006,19 +2006,19 @@ rewrite_logical_or_checks (void) void dump_conditional_check_for_rewrite (operand op) { - STACK_PUSH (conditional_checks, serializer_get_current_opcode_counter ()); + STACK_PUSH (conditional_checks, serializer_get_current_instr_counter ()); switch (op.type) { case OPERAND_LITERAL: { - const opcode_t opcode = getop_is_false_jmp_down (LITERAL_TO_REWRITE, INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_100 (opcode, op.data.lit_id)); + const vm_instr_t instr = getop_is_false_jmp_down (LITERAL_TO_REWRITE, INVALID_VALUE, INVALID_VALUE); + serializer_dump_op_meta (create_op_meta_100 (instr, op.data.lit_id)); break; } case OPERAND_TMP: { - const opcode_t opcode = getop_is_false_jmp_down (op.data.uid, INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + const vm_instr_t instr = getop_is_false_jmp_down (op.data.uid, INVALID_VALUE, INVALID_VALUE); + serializer_dump_op_meta (create_op_meta_000 (instr)); break; } } @@ -2030,9 +2030,9 @@ rewrite_conditional_check (void) op_meta jmp_op_meta = serializer_get_op_meta (STACK_TOP (conditional_checks)); JERRY_ASSERT (jmp_op_meta.op.op_idx == VM_OP_IS_FALSE_JMP_DOWN); idx_t id1, id2; - split_opcode_counter (get_diff_from (STACK_TOP (conditional_checks)), &id1, &id2); - jmp_op_meta.op.data.is_false_jmp_down.opcode_1 = id1; - jmp_op_meta.op.data.is_false_jmp_down.opcode_2 = id2; + split_instr_counter (get_diff_from (STACK_TOP (conditional_checks)), &id1, &id2); + jmp_op_meta.op.data.is_false_jmp_down.oc_idx_1 = id1; + jmp_op_meta.op.data.is_false_jmp_down.oc_idx_2 = id2; serializer_rewrite_op_meta (STACK_TOP (conditional_checks), jmp_op_meta); STACK_DROP (conditional_checks, 1); } @@ -2040,9 +2040,9 @@ rewrite_conditional_check (void) void dump_jump_to_end_for_rewrite (void) { - STACK_PUSH (jumps_to_end, serializer_get_current_opcode_counter ()); - const opcode_t opcode = getop_jmp_down (INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + STACK_PUSH (jumps_to_end, serializer_get_current_instr_counter ()); + const vm_instr_t instr = getop_jmp_down (INVALID_VALUE, INVALID_VALUE); + serializer_dump_op_meta (create_op_meta_000 (instr)); } void @@ -2051,9 +2051,9 @@ rewrite_jump_to_end (void) op_meta jmp_op_meta = serializer_get_op_meta (STACK_TOP (jumps_to_end)); JERRY_ASSERT (jmp_op_meta.op.op_idx == VM_OP_JMP_DOWN); idx_t id1, id2; - split_opcode_counter (get_diff_from (STACK_TOP (jumps_to_end)), &id1, &id2); - jmp_op_meta.op.data.jmp_down.opcode_1 = id1; - jmp_op_meta.op.data.jmp_down.opcode_2 = id2; + split_instr_counter (get_diff_from (STACK_TOP (jumps_to_end)), &id1, &id2); + jmp_op_meta.op.data.jmp_down.oc_idx_1 = id1; + jmp_op_meta.op.data.jmp_down.oc_idx_2 = id2; serializer_rewrite_op_meta (STACK_TOP (jumps_to_end), jmp_op_meta); STACK_DROP (jumps_to_end, 1); } @@ -2064,7 +2064,7 @@ start_dumping_assignment_expression (void) const op_meta last = last_dumped_op_meta (); if (last.op.op_idx == VM_OP_PROP_GETTER) { - serializer_set_writing_position ((opcode_counter_t) (serializer_get_current_opcode_counter () - 1)); + serializer_set_writing_position ((vm_instr_counter_t) (serializer_get_current_instr_counter () - 1)); } STACK_PUSH (prop_getters, last); } @@ -2162,20 +2162,20 @@ dump_prop_setter_or_bitwise_or_res (operand res, operand op) void dumper_set_next_interation_target (void) { - STACK_PUSH (next_iterations, serializer_get_current_opcode_counter ()); + STACK_PUSH (next_iterations, serializer_get_current_instr_counter ()); } void dump_continue_iterations_check (operand op) { - const opcode_counter_t next_iteration_target_diff = (opcode_counter_t) (serializer_get_current_opcode_counter () + const vm_instr_counter_t next_iteration_target_diff = (vm_instr_counter_t) (serializer_get_current_instr_counter () - STACK_TOP (next_iterations)); idx_t id1, id2; - split_opcode_counter (next_iteration_target_diff, &id1, &id2); + split_instr_counter (next_iteration_target_diff, &id1, &id2); if (operand_is_empty (op)) { - const opcode_t opcode = getop_jmp_up (id1, id2); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + const vm_instr_t instr = getop_jmp_up (id1, id2); + serializer_dump_op_meta (create_op_meta_000 (instr)); } else { @@ -2183,14 +2183,14 @@ dump_continue_iterations_check (operand op) { case OPERAND_LITERAL: { - const opcode_t opcode = getop_is_true_jmp_up (LITERAL_TO_REWRITE, id1, id2); - serializer_dump_op_meta (create_op_meta_100 (opcode, op.data.lit_id)); + const vm_instr_t instr = getop_is_true_jmp_up (LITERAL_TO_REWRITE, id1, id2); + serializer_dump_op_meta (create_op_meta_100 (instr, op.data.lit_id)); break; } case OPERAND_TMP: { - const opcode_t opcode = getop_is_true_jmp_up (op.data.uid, id1, id2); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + const vm_instr_t instr = getop_is_true_jmp_up (op.data.uid, id1, id2); + serializer_dump_op_meta (create_op_meta_000 (instr)); break; } } @@ -2206,30 +2206,30 @@ dump_continue_iterations_check (operand op) * * @return position of dumped instruction */ -opcode_counter_t +vm_instr_counter_t dump_simple_or_nested_jump_for_rewrite (bool is_simple_jump, /**< flag indicating, whether simple jump * or 'jmp_break_continue' template should be dumped */ - opcode_counter_t next_jump_for_tgt_oc) /**< opcode counter of next - * template targetted to - * the same target - if any, - * or MAX_OPCODES - otherwise */ + vm_instr_counter_t next_jump_for_tgt_oc) /**< instr counter of next + * template targetted to + * the same target - if any, + * or MAX_OPCODES - otherwise */ { idx_t id1, id2; - split_opcode_counter (next_jump_for_tgt_oc, &id1, &id2); + split_instr_counter (next_jump_for_tgt_oc, &id1, &id2); - opcode_t opcode; + vm_instr_t instr; if (is_simple_jump) { - opcode = getop_jmp_down (id1, id2); + instr = getop_jmp_down (id1, id2); } else { - opcode = getop_jmp_break_continue (id1, id2); + instr = getop_jmp_break_continue (id1, id2); } - opcode_counter_t ret = serializer_get_current_opcode_counter (); + vm_instr_counter_t ret = serializer_get_current_instr_counter (); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + serializer_dump_op_meta (create_op_meta_000 (instr)); return ret; } /* dump_simple_or_nested_jump_for_rewrite */ @@ -2237,11 +2237,11 @@ dump_simple_or_nested_jump_for_rewrite (bool is_simple_jump, /**< flag indicatin /** * Write jump target position into previously dumped template of jump (simple or nested) instruction * - * @return opcode counter value that was encoded in the jump before rewrite + * @return instr counter value that was encoded in the jump before rewrite */ -opcode_counter_t -rewrite_simple_or_nested_jump_and_get_next (opcode_counter_t jump_oc, /**< position of jump to rewrite */ - opcode_counter_t target_oc) /**< the jump's target */ +vm_instr_counter_t +rewrite_simple_or_nested_jump_and_get_next (vm_instr_counter_t jump_oc, /**< position of jump to rewrite */ + vm_instr_counter_t target_oc) /**< the jump's target */ { op_meta jump_op_meta = serializer_get_op_meta (jump_oc); @@ -2251,30 +2251,30 @@ rewrite_simple_or_nested_jump_and_get_next (opcode_counter_t jump_oc, /**< posit || (jump_op_meta.op.op_idx == VM_OP_JMP_BREAK_CONTINUE)); idx_t id1, id2, id1_prev, id2_prev; - split_opcode_counter ((opcode_counter_t) (target_oc - jump_oc), &id1, &id2); + split_instr_counter ((vm_instr_counter_t) (target_oc - jump_oc), &id1, &id2); if (is_simple_jump) { - id1_prev = jump_op_meta.op.data.jmp_down.opcode_1; - id2_prev = jump_op_meta.op.data.jmp_down.opcode_2; + id1_prev = jump_op_meta.op.data.jmp_down.oc_idx_1; + id2_prev = jump_op_meta.op.data.jmp_down.oc_idx_2; - jump_op_meta.op.data.jmp_down.opcode_1 = id1; - jump_op_meta.op.data.jmp_down.opcode_2 = id2; + jump_op_meta.op.data.jmp_down.oc_idx_1 = id1; + jump_op_meta.op.data.jmp_down.oc_idx_2 = id2; } else { JERRY_ASSERT (jump_op_meta.op.op_idx == VM_OP_JMP_BREAK_CONTINUE); - id1_prev = jump_op_meta.op.data.jmp_break_continue.opcode_1; - id2_prev = jump_op_meta.op.data.jmp_break_continue.opcode_2; + id1_prev = jump_op_meta.op.data.jmp_break_continue.oc_idx_1; + id2_prev = jump_op_meta.op.data.jmp_break_continue.oc_idx_2; - jump_op_meta.op.data.jmp_break_continue.opcode_1 = id1; - jump_op_meta.op.data.jmp_break_continue.opcode_2 = id2; + jump_op_meta.op.data.jmp_break_continue.oc_idx_1 = id1; + jump_op_meta.op.data.jmp_break_continue.oc_idx_2 = id2; } serializer_rewrite_op_meta (jump_oc, jump_op_meta); - return calc_opcode_counter_from_idx_idx (id1_prev, id2_prev); + return vm_calc_instr_counter_from_idx_idx (id1_prev, id2_prev); } /* rewrite_simple_or_nested_jump_get_next */ void @@ -2289,29 +2289,29 @@ dump_case_clause_check_for_rewrite (operand switch_expr, operand case_expr) { const operand res = tmp_operand (); dump_triple_address (getop_equal_value_type, res, switch_expr, case_expr); - STACK_PUSH (case_clauses, serializer_get_current_opcode_counter ()); - const opcode_t opcode = getop_is_true_jmp_down (res.data.uid, INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + STACK_PUSH (case_clauses, serializer_get_current_instr_counter ()); + const vm_instr_t instr = getop_is_true_jmp_down (res.data.uid, INVALID_VALUE, INVALID_VALUE); + serializer_dump_op_meta (create_op_meta_000 (instr)); } void dump_default_clause_check_for_rewrite (void) { - STACK_PUSH (case_clauses, serializer_get_current_opcode_counter ()); - const opcode_t opcode = getop_jmp_down (INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + STACK_PUSH (case_clauses, serializer_get_current_instr_counter ()); + const vm_instr_t instr = getop_jmp_down (INVALID_VALUE, INVALID_VALUE); + serializer_dump_op_meta (create_op_meta_000 (instr)); } void rewrite_case_clause (void) { - const opcode_counter_t jmp_oc = STACK_ELEMENT (case_clauses, STACK_HEAD (U8, 2)); + const vm_instr_counter_t jmp_oc = STACK_ELEMENT (case_clauses, STACK_HEAD (U8, 2)); idx_t id1, id2; - split_opcode_counter (get_diff_from (jmp_oc), &id1, &id2); + split_instr_counter (get_diff_from (jmp_oc), &id1, &id2); op_meta jmp_op_meta = serializer_get_op_meta (jmp_oc); JERRY_ASSERT (jmp_op_meta.op.op_idx == VM_OP_IS_TRUE_JMP_DOWN); - jmp_op_meta.op.data.is_true_jmp_down.opcode_1 = id1; - jmp_op_meta.op.data.is_true_jmp_down.opcode_2 = id2; + jmp_op_meta.op.data.is_true_jmp_down.oc_idx_1 = id1; + jmp_op_meta.op.data.is_true_jmp_down.oc_idx_2 = id2; serializer_rewrite_op_meta (jmp_oc, jmp_op_meta); STACK_INCR_HEAD (U8, 2); } @@ -2319,13 +2319,13 @@ rewrite_case_clause (void) void rewrite_default_clause (void) { - const opcode_counter_t jmp_oc = STACK_TOP (case_clauses); + const vm_instr_counter_t jmp_oc = STACK_TOP (case_clauses); idx_t id1, id2; - split_opcode_counter (get_diff_from (jmp_oc), &id1, &id2); + split_instr_counter (get_diff_from (jmp_oc), &id1, &id2); op_meta jmp_op_meta = serializer_get_op_meta (jmp_oc); JERRY_ASSERT (jmp_op_meta.op.op_idx == VM_OP_JMP_DOWN); - jmp_op_meta.op.data.jmp_down.opcode_1 = id1; - jmp_op_meta.op.data.jmp_down.opcode_2 = id2; + jmp_op_meta.op.data.jmp_down.oc_idx_1 = id1; + jmp_op_meta.op.data.jmp_down.oc_idx_2 = id2; serializer_rewrite_op_meta (jmp_oc, jmp_op_meta); } @@ -2345,23 +2345,23 @@ finish_dumping_case_clauses (void) * * @return position of dumped instruction */ -opcode_counter_t +vm_instr_counter_t dump_with_for_rewrite (operand op) /**< operand - result of evaluating Expression * in WithStatement */ { - opcode_counter_t oc = serializer_get_current_opcode_counter (); + vm_instr_counter_t oc = serializer_get_current_instr_counter (); if (op.type == OPERAND_LITERAL) { - const opcode_t opcode = getop_with (LITERAL_TO_REWRITE, INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_100 (opcode, op.data.lit_id)); + const vm_instr_t instr = getop_with (LITERAL_TO_REWRITE, INVALID_VALUE, INVALID_VALUE); + serializer_dump_op_meta (create_op_meta_100 (instr, op.data.lit_id)); } else { JERRY_ASSERT (op.type == OPERAND_TMP); - const opcode_t opcode = getop_with (op.data.uid, INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + const vm_instr_t instr = getop_with (op.data.uid, INVALID_VALUE, INVALID_VALUE); + serializer_dump_op_meta (create_op_meta_000 (instr)); } return oc; @@ -2372,12 +2372,12 @@ dump_with_for_rewrite (operand op) /**< operand - result of evaluating Expressio * dumped earlier (see also: dump_with_for_rewrite). */ void -rewrite_with (opcode_counter_t oc) /**< opcode counter of the instruction template */ +rewrite_with (vm_instr_counter_t oc) /**< instr counter of the instruction template */ { op_meta with_op_meta = serializer_get_op_meta (oc); idx_t id1, id2; - split_opcode_counter (get_diff_from (oc), &id1, &id2); + split_instr_counter (get_diff_from (oc), &id1, &id2); with_op_meta.op.data.with.oc_idx_1 = id1; with_op_meta.op.data.with.oc_idx_2 = id2; serializer_rewrite_op_meta (oc, with_op_meta); @@ -2389,8 +2389,8 @@ rewrite_with (opcode_counter_t oc) /**< opcode counter of the instruction templa void dump_with_end (void) { - const opcode_t opcode = getop_meta (OPCODE_META_TYPE_END_WITH, INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_END_WITH, INVALID_VALUE, INVALID_VALUE); + serializer_dump_op_meta (create_op_meta_000 (instr)); } /* dump_with_end */ /** @@ -2401,23 +2401,23 @@ dump_with_end (void) * * @return position of dumped instruction */ -opcode_counter_t +vm_instr_counter_t dump_for_in_for_rewrite (operand op) /**< operand - result of evaluating Expression * in for-in statement */ { - opcode_counter_t oc = serializer_get_current_opcode_counter (); + vm_instr_counter_t oc = serializer_get_current_instr_counter (); if (op.type == OPERAND_LITERAL) { - const opcode_t opcode = getop_for_in (LITERAL_TO_REWRITE, INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_100 (opcode, op.data.lit_id)); + const vm_instr_t instr = getop_for_in (LITERAL_TO_REWRITE, INVALID_VALUE, INVALID_VALUE); + serializer_dump_op_meta (create_op_meta_100 (instr, op.data.lit_id)); } else { JERRY_ASSERT (op.type == OPERAND_TMP); - const opcode_t opcode = getop_for_in (op.data.uid, INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + const vm_instr_t instr = getop_for_in (op.data.uid, INVALID_VALUE, INVALID_VALUE); + serializer_dump_op_meta (create_op_meta_000 (instr)); } return oc; @@ -2428,12 +2428,12 @@ dump_for_in_for_rewrite (operand op) /**< operand - result of evaluating Express * dumped earlier (see also: dump_for_in_for_rewrite). */ void -rewrite_for_in (opcode_counter_t oc) /**< opcode counter of the instruction template */ +rewrite_for_in (vm_instr_counter_t oc) /**< instr counter of the instruction template */ { op_meta for_in_op_meta = serializer_get_op_meta (oc); idx_t id1, id2; - split_opcode_counter (get_diff_from (oc), &id1, &id2); + split_instr_counter (get_diff_from (oc), &id1, &id2); for_in_op_meta.op.data.for_in.oc_idx_1 = id1; for_in_op_meta.op.data.for_in.oc_idx_2 = id2; serializer_rewrite_op_meta (oc, for_in_op_meta); @@ -2445,16 +2445,16 @@ rewrite_for_in (opcode_counter_t oc) /**< opcode counter of the instruction temp void dump_for_in_end (void) { - const opcode_t opcode = getop_meta (OPCODE_META_TYPE_END_FOR_IN, INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_END_FOR_IN, INVALID_VALUE, INVALID_VALUE); + serializer_dump_op_meta (create_op_meta_000 (instr)); } /* dump_for_in_end */ void dump_try_for_rewrite (void) { - STACK_PUSH (tries, serializer_get_current_opcode_counter ()); - const opcode_t opcode = getop_try_block (INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + STACK_PUSH (tries, serializer_get_current_instr_counter ()); + const vm_instr_t instr = getop_try_block (INVALID_VALUE, INVALID_VALUE); + serializer_dump_op_meta (create_op_meta_000 (instr)); } void @@ -2463,7 +2463,7 @@ rewrite_try (void) op_meta try_op_meta = serializer_get_op_meta (STACK_TOP (tries)); JERRY_ASSERT (try_op_meta.op.op_idx == VM_OP_TRY_BLOCK); idx_t id1, id2; - split_opcode_counter (get_diff_from (STACK_TOP (tries)), &id1, &id2); + split_instr_counter (get_diff_from (STACK_TOP (tries)), &id1, &id2); try_op_meta.op.data.try_block.oc_idx_1 = id1; try_op_meta.op.data.try_block.oc_idx_2 = id2; serializer_rewrite_op_meta (STACK_TOP (tries), try_op_meta); @@ -2474,11 +2474,11 @@ void dump_catch_for_rewrite (operand op) { JERRY_ASSERT (op.type == OPERAND_LITERAL); - STACK_PUSH (catches, serializer_get_current_opcode_counter ()); - opcode_t opcode = getop_meta (OPCODE_META_TYPE_CATCH, INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_000 (opcode)); - opcode = getop_meta (OPCODE_META_TYPE_CATCH_EXCEPTION_IDENTIFIER, LITERAL_TO_REWRITE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_010 (opcode, op.data.lit_id)); + STACK_PUSH (catches, serializer_get_current_instr_counter ()); + vm_instr_t instr = getop_meta (OPCODE_META_TYPE_CATCH, INVALID_VALUE, INVALID_VALUE); + serializer_dump_op_meta (create_op_meta_000 (instr)); + instr = getop_meta (OPCODE_META_TYPE_CATCH_EXCEPTION_IDENTIFIER, LITERAL_TO_REWRITE, INVALID_VALUE); + serializer_dump_op_meta (create_op_meta_010 (instr, op.data.lit_id)); } void @@ -2488,7 +2488,7 @@ rewrite_catch (void) JERRY_ASSERT (catch_op_meta.op.op_idx == VM_OP_META && catch_op_meta.op.data.meta.type == OPCODE_META_TYPE_CATCH); idx_t id1, id2; - split_opcode_counter (get_diff_from (STACK_TOP (catches)), &id1, &id2); + split_instr_counter (get_diff_from (STACK_TOP (catches)), &id1, &id2); catch_op_meta.op.data.meta.data_1 = id1; catch_op_meta.op.data.meta.data_2 = id2; serializer_rewrite_op_meta (STACK_TOP (catches), catch_op_meta); @@ -2498,9 +2498,9 @@ rewrite_catch (void) void dump_finally_for_rewrite (void) { - STACK_PUSH (finallies, serializer_get_current_opcode_counter ()); - const opcode_t opcode = getop_meta (OPCODE_META_TYPE_FINALLY, INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + STACK_PUSH (finallies, serializer_get_current_instr_counter ()); + const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_FINALLY, INVALID_VALUE, INVALID_VALUE); + serializer_dump_op_meta (create_op_meta_000 (instr)); } void @@ -2510,7 +2510,7 @@ rewrite_finally (void) JERRY_ASSERT (finally_op_meta.op.op_idx == VM_OP_META && finally_op_meta.op.data.meta.type == OPCODE_META_TYPE_FINALLY); idx_t id1, id2; - split_opcode_counter (get_diff_from (STACK_TOP (finallies)), &id1, &id2); + split_instr_counter (get_diff_from (STACK_TOP (finallies)), &id1, &id2); finally_op_meta.op.data.meta.data_1 = id1; finally_op_meta.op.data.meta.data_2 = id2; serializer_rewrite_op_meta (STACK_TOP (finallies), finally_op_meta); @@ -2520,9 +2520,9 @@ rewrite_finally (void) void dump_end_try_catch_finally (void) { - const opcode_t opcode = getop_meta (OPCODE_META_TYPE_END_TRY_CATCH_FINALLY, - INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_END_TRY_CATCH_FINALLY, + INVALID_VALUE, INVALID_VALUE); + serializer_dump_op_meta (create_op_meta_000 (instr)); } void @@ -2534,7 +2534,7 @@ dump_throw (operand op) bool dumper_variable_declaration_exists (lit_cpointer_t lit_id) { - for (opcode_counter_t oc = (opcode_counter_t) (serializer_get_current_opcode_counter () - 1); + for (vm_instr_counter_t oc = (vm_instr_counter_t) (serializer_get_current_instr_counter () - 1); oc > 0; oc--) { const op_meta var_decl_op_meta = serializer_get_op_meta (oc); @@ -2553,8 +2553,8 @@ dumper_variable_declaration_exists (lit_cpointer_t lit_id) void dump_variable_declaration (lit_cpointer_t lit_id) { - const opcode_t opcode = getop_var_decl (LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_100 (opcode, lit_id)); + const vm_instr_t instr = getop_var_decl (LITERAL_TO_REWRITE); + serializer_dump_op_meta (create_op_meta_100 (instr, lit_id)); } /** @@ -2565,13 +2565,13 @@ dump_variable_declaration (lit_cpointer_t lit_id) * * @return position of dumped instruction */ -opcode_counter_t +vm_instr_counter_t dump_scope_code_flags_for_rewrite (void) { - opcode_counter_t oc = serializer_get_current_opcode_counter (); + vm_instr_counter_t oc = serializer_get_current_instr_counter (); - const opcode_t opcode = getop_meta (OPCODE_META_TYPE_SCOPE_CODE_FLAGS, INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_000 (opcode)); + const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_SCOPE_CODE_FLAGS, INVALID_VALUE, INVALID_VALUE); + serializer_dump_op_meta (create_op_meta_000 (instr)); return oc; } /* dump_scope_code_flags_for_rewrite */ @@ -2581,7 +2581,7 @@ dump_scope_code_flags_for_rewrite (void) * dumped earlier (see also: dump_scope_code_flags_for_rewrite). */ void -rewrite_scope_code_flags (opcode_counter_t scope_code_flags_oc, /**< position of instruction to rewrite */ +rewrite_scope_code_flags (vm_instr_counter_t scope_code_flags_oc, /**< position of instruction to rewrite */ opcode_scope_code_flags_t scope_flags) /**< scope's code properties flags set */ { JERRY_ASSERT ((idx_t) scope_flags == scope_flags); @@ -2605,14 +2605,14 @@ dump_ret (void) void dump_reg_var_decl_for_rewrite (void) { - STACK_PUSH (reg_var_decls, serializer_get_current_opcode_counter ()); + STACK_PUSH (reg_var_decls, serializer_get_current_instr_counter ()); serializer_dump_op_meta (create_op_meta_000 (getop_reg_var_decl (OPCODE_REG_FIRST, INVALID_VALUE))); } void rewrite_reg_var_decl (void) { - opcode_counter_t reg_var_decl_oc = STACK_TOP (reg_var_decls); + vm_instr_counter_t reg_var_decl_oc = STACK_TOP (reg_var_decls); op_meta opm = serializer_get_op_meta (reg_var_decl_oc); JERRY_ASSERT (opm.op.op_idx == VM_OP_REG_VAR_DECL); opm.op.data.reg_var_decl.max = max_temp_name; diff --git a/jerry-core/parser/js/opcodes-dumper.h b/jerry-core/parser/js/opcodes-dumper.h index 12058fc80..e80402cef 100644 --- a/jerry-core/parser/js/opcodes-dumper.h +++ b/jerry-core/parser/js/opcodes-dumper.h @@ -186,12 +186,12 @@ operand dump_prop_setter_or_bitwise_or_res (operand, operand); void dumper_set_break_target (void); void dumper_set_continue_target (void); void dumper_set_next_interation_target (void); -opcode_counter_t +vm_instr_counter_t dump_simple_or_nested_jump_for_rewrite (bool is_simple_jump, - opcode_counter_t next_jump_for_tg_oc); -opcode_counter_t -rewrite_simple_or_nested_jump_and_get_next (opcode_counter_t jump_oc, - opcode_counter_t target_oc); + vm_instr_counter_t next_jump_for_tg_oc); +vm_instr_counter_t +rewrite_simple_or_nested_jump_and_get_next (vm_instr_counter_t jump_oc, + vm_instr_counter_t target_oc); void dump_continue_iterations_check (operand); void start_dumping_case_clauses (void); @@ -207,12 +207,12 @@ operand dump_delete_res (operand, bool, locus); void dump_typeof (operand, operand); operand dump_typeof_res (operand); -opcode_counter_t dump_with_for_rewrite (operand); -void rewrite_with (opcode_counter_t); +vm_instr_counter_t dump_with_for_rewrite (operand); +void rewrite_with (vm_instr_counter_t); void dump_with_end (void); -opcode_counter_t dump_for_in_for_rewrite (operand); -void rewrite_for_in (opcode_counter_t); +vm_instr_counter_t dump_for_in_for_rewrite (operand); +void rewrite_for_in (vm_instr_counter_t); void dump_for_in_end (void); void dump_try_for_rewrite (void); @@ -227,8 +227,8 @@ void dump_throw (operand); bool dumper_variable_declaration_exists (lit_cpointer_t); void dump_variable_declaration (lit_cpointer_t); -opcode_counter_t dump_scope_code_flags_for_rewrite (void); -void rewrite_scope_code_flags (opcode_counter_t scope_code_flags_oc, +vm_instr_counter_t dump_scope_code_flags_for_rewrite (void); +void rewrite_scope_code_flags (vm_instr_counter_t scope_code_flags_oc, opcode_scope_code_flags_t scope_flags); void dump_reg_var_decl_for_rewrite (void); diff --git a/jerry-core/parser/js/parser.cpp b/jerry-core/parser/js/parser.cpp index 993c0dd0d..b815956d0 100644 --- a/jerry-core/parser/js/parser.cpp +++ b/jerry-core/parser/js/parser.cpp @@ -50,7 +50,7 @@ typedef enum static token tok; static bool inside_eval = false; static bool inside_function = false; -static bool parser_show_opcodes = false; +static bool parser_show_instrs = false; enum { @@ -1920,7 +1920,7 @@ jsp_parse_for_statement (jsp_label_t *outermost_stmt_label_p, /**< outermost (fi // Setup ContinueTarget jsp_label_setup_continue_target (outermost_stmt_label_p, - serializer_get_current_opcode_counter ()); + serializer_get_current_instr_counter ()); // Increment lexer_seek (increment_loc); @@ -2027,7 +2027,7 @@ jsp_parse_for_in_statement_iterator (operand *base_p, /**< out: base value of me * Note: * Layout of generate byte-code is the following: * tmp <- Collection (Expression) - * for_in instruction (tmp, opcode counter of for-in end mark) + * for_in instruction (tmp, instruction counter of for-in end mark) * { * Assignment of OPCODE_REG_SPECIAL_FOR_IN_PROPERTY_NAME to * Iterator (VariableDeclarationNoIn / LeftHandSideExpression) @@ -2081,7 +2081,7 @@ jsp_parse_for_in_statement (jsp_label_t *outermost_stmt_label_p, /**< outermost skip_token (); // Dump for-in instruction - opcode_counter_t for_in_oc = dump_for_in_for_rewrite (collection); + vm_instr_counter_t for_in_oc = dump_for_in_for_rewrite (collection); // Dump assignment VariableDeclarationNoIn / LeftHandSideExpression <- OPCODE_REG_SPECIAL_FOR_IN_PROPERTY_NAME lexer_seek (iterator_loc); @@ -2111,7 +2111,7 @@ jsp_parse_for_in_statement (jsp_label_t *outermost_stmt_label_p, /**< outermost // Setup ContinueTarget jsp_label_setup_continue_target (outermost_stmt_label_p, - serializer_get_current_opcode_counter ()); + serializer_get_current_instr_counter ()); // Write position of for-in end to for_in instruction rewrite_for_in (for_in_oc); @@ -2261,7 +2261,7 @@ parse_do_while_statement (jsp_label_t *outermost_stmt_label_p) /**< outermost (f parse_statement (NULL); jsp_label_setup_continue_target (outermost_stmt_label_p, - serializer_get_current_opcode_counter ()); + serializer_get_current_instr_counter ()); token_after_newlines_must_be_keyword (KW_WHILE); const operand cond = parse_expression_inside_parens (); @@ -2290,7 +2290,7 @@ parse_while_statement (jsp_label_t *outermost_stmt_label_p) /**< outermost (firs parse_statement (NULL); jsp_label_setup_continue_target (outermost_stmt_label_p, - serializer_get_current_opcode_counter ()); + serializer_get_current_instr_counter ()); rewrite_jump_to_end (); @@ -2318,7 +2318,7 @@ parse_with_statement (void) bool is_raised = jsp_label_raise_nested_jumpable_border (); - opcode_counter_t with_begin_oc = dump_with_for_rewrite (expr); + vm_instr_counter_t with_begin_oc = dump_with_for_rewrite (expr); skip_newlines (); parse_statement (NULL); rewrite_with (with_begin_oc); @@ -2442,7 +2442,7 @@ parse_switch_statement (void) skip_token (); jsp_label_rewrite_jumps_and_pop (&label, - serializer_get_current_opcode_counter ()); + serializer_get_current_instr_counter ()); finish_dumping_case_clauses (); } @@ -2595,7 +2595,7 @@ parse_iterational_statement (jsp_label_t *outermost_named_stmt_label_p) /**< out } jsp_label_rewrite_jumps_and_pop (&label, - serializer_get_current_opcode_counter ()); + serializer_get_current_instr_counter ()); } /* parse_iterational_statement */ /* statement @@ -2831,7 +2831,7 @@ parse_statement (jsp_label_t *outermost_stmt_label_p) /**< outermost (first) lab parse_statement (outermost_stmt_label_p != NULL ? outermost_stmt_label_p : &label); jsp_label_rewrite_jumps_and_pop (&label, - serializer_get_current_opcode_counter ()); + serializer_get_current_instr_counter ()); } else { @@ -2921,7 +2921,7 @@ preparse_scope (bool is_global) const locus start_loc = tok.loc; const token_type end_tt = is_global ? TOK_EOF : TOK_CLOSE_BRACE; - opcode_counter_t scope_code_flags_oc = dump_scope_code_flags_for_rewrite (); + vm_instr_counter_t scope_code_flags_oc = dump_scope_code_flags_for_rewrite (); bool is_use_strict = false; bool is_ref_arguments_identifier = false; @@ -3169,10 +3169,10 @@ parser_parse_program (const jerry_api_char_t *source_p, /**< source code buffer bool in_eval, /**< flag indicating if we are parsing body of eval code */ bool is_strict, /**< flag, indicating whether current code * inherited strict mode from code of an outer scope */ - const opcode_t **out_opcodes_p) /**< out: generated byte-code array - * (in case there were no syntax errors) */ + const vm_instr_t **out_instrs_p) /**< out: generated byte-code array + * (in case there were no syntax errors) */ { - JERRY_ASSERT (out_opcodes_p != NULL); + JERRY_ASSERT (out_instrs_p != NULL); inside_function = in_function; inside_eval = in_eval; @@ -3186,7 +3186,7 @@ parser_parse_program (const jerry_api_char_t *source_p, /**< source code buffer jsp_mm_init (); jsp_label_init (); - serializer_set_show_opcodes (parser_show_opcodes); + serializer_set_show_instrs (parser_show_instrs); dumper_init (); jsp_early_error_init (); @@ -3205,7 +3205,7 @@ parser_parse_program (const jerry_api_char_t *source_p, /**< source code buffer * Operations that could raise an early error can be performed only during execution of the block. */ - lexer_init (source_p, source_size, parser_show_opcodes); + lexer_init (source_p, source_size, parser_show_instrs); lexer_set_strict_mode (scopes_tree_strict_mode (STACK_TOP (scopes))); skip_newlines (); @@ -3233,7 +3233,7 @@ parser_parse_program (const jerry_api_char_t *source_p, /**< source code buffer jsp_early_error_free (); - *out_opcodes_p = serializer_merge_scopes_into_bytecode (); + *out_instrs_p = serializer_merge_scopes_into_bytecode (); dumper_free (); @@ -3252,7 +3252,7 @@ parser_parse_program (const jerry_api_char_t *source_p, /**< source code buffer JERRY_ASSERT (!is_parse_finished); #endif /* !JERRY_NDEBUG */ - *out_opcodes_p = NULL; + *out_instrs_p = NULL; jsp_label_remove_all_labels (); jsp_mm_free_all (); @@ -3286,10 +3286,10 @@ parser_parse_program (const jerry_api_char_t *source_p, /**< source code buffer jsp_status_t parser_parse_script (const jerry_api_char_t *source, /**< source script */ size_t source_size, /**< source script size it bytes */ - const opcode_t **opcodes_p) /**< out: generated byte-code array - * (in case there were no syntax errors) */ + const vm_instr_t **out_instrs_p) /**< out: generated byte-code array + * (in case there were no syntax errors) */ { - return parser_parse_program (source, source_size, false, false, false, opcodes_p); + return parser_parse_program (source, source_size, false, false, false, out_instrs_p); } /* parser_parse_script */ /** @@ -3303,10 +3303,10 @@ parser_parse_eval (const jerry_api_char_t *source, /**< string passed to eval() size_t source_size, /**< string size in bytes */ bool is_strict, /**< flag, indicating whether eval is called * from strict code in direct mode */ - const opcode_t **opcodes_p) /**< out: generated byte-code array - * (in case there were no syntax errors) */ + const vm_instr_t **out_instrs_p) /**< out: generated byte-code array + * (in case there were no syntax errors) */ { - return parser_parse_program (source, source_size, false, true, is_strict, opcodes_p); + return parser_parse_program (source, source_size, false, true, is_strict, out_instrs_p); } /* parser_parse_eval */ /** @@ -3324,8 +3324,8 @@ parser_parse_new_function (const jerry_api_char_t **params, /**< array of argume * body) call */ const size_t *params_size, /**< sizes of arguments strings */ size_t params_count, /**< total number of arguments passed to new Function (...) */ - const opcode_t **out_opcodes_p) /**< out: generated byte-code array - * (in case there were no syntax errors) */ + const vm_instr_t **out_instrs_p) /**< out: generated byte-code array + * (in case there were no syntax errors) */ { // Process arguments JERRY_ASSERT (params_count > 0); @@ -3339,14 +3339,14 @@ parser_parse_new_function (const jerry_api_char_t **params, /**< array of argume true, false, false, - out_opcodes_p); + out_instrs_p); } /* parser_parse_new_function */ /** - * Tell parser to dump bytecode + * Tell parser whether to dump bytecode */ void -parser_set_show_opcodes (bool show_opcodes) /**< flag indicating if to dump bytecode */ +parser_set_show_instrs (bool show_instrs) /**< flag indicating whether to dump bytecode */ { - parser_show_opcodes = show_opcodes; -} /* parser_set_show_opcodes */ + parser_show_instrs = show_instrs; +} /* parser_set_show_instrs */ diff --git a/jerry-core/parser/js/parser.h b/jerry-core/parser/js/parser.h index b5e4e1121..339c8d346 100644 --- a/jerry-core/parser/js/parser.h +++ b/jerry-core/parser/js/parser.h @@ -28,9 +28,9 @@ typedef enum JSP_STATUS_REFERENCE_ERROR /**< ReferenceError early error occured */ } jsp_status_t; -void parser_set_show_opcodes (bool); -jsp_status_t parser_parse_script (const jerry_api_char_t *, size_t, const opcode_t **); -jsp_status_t parser_parse_eval (const jerry_api_char_t *, size_t, bool, const opcode_t **); -jsp_status_t parser_parse_new_function (const jerry_api_char_t **, const size_t *, size_t, const opcode_t **); +void parser_set_show_instrs (bool); +jsp_status_t parser_parse_script (const jerry_api_char_t *, size_t, const vm_instr_t **); +jsp_status_t parser_parse_eval (const jerry_api_char_t *, size_t, bool, const vm_instr_t **); +jsp_status_t parser_parse_new_function (const jerry_api_char_t **, const size_t *, size_t, const vm_instr_t **); #endif /* PARSER_H */ diff --git a/jerry-core/parser/js/scopes-tree.cpp b/jerry-core/parser/js/scopes-tree.cpp index 66b1b0cf7..e89880a38 100644 --- a/jerry-core/parser/js/scopes-tree.cpp +++ b/jerry-core/parser/js/scopes-tree.cpp @@ -20,7 +20,7 @@ #define HASH_SIZE 128 static hash_table lit_id_to_uid = null_hash; -static opcode_counter_t global_oc; +static vm_instr_counter_t global_oc; static idx_t next_uid; static void @@ -33,7 +33,7 @@ static idx_t get_uid (op_meta *op, uint8_t i) { JERRY_ASSERT (i < 4); - raw_opcode *raw = (raw_opcode *) &op->op; + raw_instr *raw = (raw_instr *) &op->op; return raw->uids[i + 1]; } @@ -41,57 +41,57 @@ static void set_uid (op_meta *op, uint8_t i, idx_t uid) { JERRY_ASSERT (i < 4); - raw_opcode *raw = (raw_opcode *) &op->op; + raw_instr *raw = (raw_instr *) &op->op; raw->uids[i + 1] = uid; } -opcode_counter_t -scopes_tree_opcodes_num (scopes_tree t) +vm_instr_counter_t +scopes_tree_instrs_num (scopes_tree t) { assert_tree (t); - return t->opcodes_num; + return t->instrs_num; } void scopes_tree_add_op_meta (scopes_tree tree, op_meta op) { assert_tree (tree); - linked_list_set_element (tree->opcodes, tree->opcodes_num++, &op); + linked_list_set_element (tree->instrs, tree->instrs_num++, &op); } void -scopes_tree_set_op_meta (scopes_tree tree, opcode_counter_t oc, op_meta op) +scopes_tree_set_op_meta (scopes_tree tree, vm_instr_counter_t oc, op_meta op) { assert_tree (tree); - JERRY_ASSERT (oc < tree->opcodes_num); - linked_list_set_element (tree->opcodes, oc, &op); + JERRY_ASSERT (oc < tree->instrs_num); + linked_list_set_element (tree->instrs, oc, &op); } void -scopes_tree_set_opcodes_num (scopes_tree tree, opcode_counter_t oc) +scopes_tree_set_instrs_num (scopes_tree tree, vm_instr_counter_t oc) { assert_tree (tree); - JERRY_ASSERT (oc < tree->opcodes_num); - tree->opcodes_num = oc; + JERRY_ASSERT (oc < tree->instrs_num); + tree->instrs_num = oc; } op_meta -scopes_tree_op_meta (scopes_tree tree, opcode_counter_t oc) +scopes_tree_op_meta (scopes_tree tree, vm_instr_counter_t oc) { assert_tree (tree); - JERRY_ASSERT (oc < tree->opcodes_num); - return *(op_meta *) linked_list_element (tree->opcodes, oc); + JERRY_ASSERT (oc < tree->instrs_num); + return *(op_meta *) linked_list_element (tree->instrs, oc); } -opcode_counter_t -scopes_tree_count_opcodes (scopes_tree t) +vm_instr_counter_t +scopes_tree_count_instructions (scopes_tree t) { assert_tree (t); - opcode_counter_t res = t->opcodes_num; + vm_instr_counter_t res = t->instrs_num; for (uint8_t i = 0; i < t->t.children_num; i++) { - res = (opcode_counter_t) ( - res + scopes_tree_count_opcodes ( + res = (vm_instr_counter_t) ( + res + scopes_tree_count_instructions ( *(scopes_tree *) linked_list_element (t->t.children, i))); } return res; @@ -213,18 +213,18 @@ insert_uids_to_lit_id_map (op_meta *om, uint16_t mask) } static op_meta * -extract_op_meta (scopes_tree tree, opcode_counter_t opc_index) +extract_op_meta (scopes_tree tree, vm_instr_counter_t instr_pos) { - return (op_meta *) linked_list_element (tree->opcodes, opc_index); + return (op_meta *) linked_list_element (tree->instrs, instr_pos); } -static opcode_t -generate_opcode (scopes_tree tree, opcode_counter_t opc_index, lit_id_hash_table *lit_ids) +static vm_instr_t +generate_instr (scopes_tree tree, vm_instr_counter_t instr_pos, lit_id_hash_table *lit_ids) { start_new_block_if_necessary (); - op_meta *om = extract_op_meta (tree, opc_index); - /* Now we should change uids of opcodes. - Since different opcodes has different literals/tmps in different places, + op_meta *om = extract_op_meta (tree, instr_pos); + /* Now we should change uids of instructions. + Since different instructions has different literals/tmps in different places, we should change only them. For each case possible literal positions are shown as 0xYYY literal, where Y is set to '1' when there is a possible literal in this position, @@ -363,11 +363,11 @@ generate_opcode (scopes_tree tree, opcode_counter_t opc_index, lit_id_hash_table } static idx_t -count_new_literals_in_opcode (scopes_tree tree, opcode_counter_t opc_index) +count_new_literals_in_instr (scopes_tree tree, vm_instr_counter_t instr_pos) { start_new_block_if_necessary (); idx_t current_uid = next_uid; - op_meta *om = extract_op_meta (tree, opc_index); + op_meta *om = extract_op_meta (tree, instr_pos); switch (om->op.op_idx) { case VM_OP_PROP_GETTER: @@ -517,11 +517,11 @@ scopes_tree_count_literals_in_blocks (scopes_tree tree) global_oc = 0; assert_tree (tree); - opcode_counter_t opc_index; + vm_instr_counter_t instr_pos; bool header = true; - for (opc_index = 0; opc_index < tree->opcodes_num; opc_index++) + for (instr_pos = 0; instr_pos < tree->instrs_num; instr_pos++) { - op_meta *om = extract_op_meta (tree, opc_index); + op_meta *om = extract_op_meta (tree, instr_pos); if (om->op.op_idx != VM_OP_VAR_DECL && om->op.op_idx != VM_OP_META && !header) { @@ -531,15 +531,15 @@ scopes_tree_count_literals_in_blocks (scopes_tree tree) { header = false; } - result += count_new_literals_in_opcode (tree, opc_index); + result += count_new_literals_in_instr (tree, instr_pos); } for (uint8_t child_id = 0; child_id < tree->t.children_num; child_id++) { result += scopes_tree_count_literals_in_blocks (*(scopes_tree *) linked_list_element (tree->t.children, child_id)); } - for (; opc_index < tree->opcodes_num; opc_index++) + for (; instr_pos < tree->instrs_num; instr_pos++) { - result += count_new_literals_in_opcode (tree, opc_index); + result += count_new_literals_in_instr (tree, instr_pos); } return result; @@ -555,20 +555,20 @@ scopes_tree_count_literals_in_blocks (scopes_tree tree) Header and var_decls are dumped first, then we shall recursively dump function declaration, - and finally, other opcodes. + and finally, other instructions. - For each opcodes block (size of block is defined in bytecode-data.h) + For each instructions block (size of block is defined in bytecode-data.h) literal indexes 'hash' table is filled. */ static void -merge_subscopes (scopes_tree tree, opcode_t *data, lit_id_hash_table *lit_ids) +merge_subscopes (scopes_tree tree, vm_instr_t *data, lit_id_hash_table *lit_ids) { assert_tree (tree); JERRY_ASSERT (data); - opcode_counter_t opc_index; + vm_instr_counter_t instr_pos; bool header = true; - for (opc_index = 0; opc_index < tree->opcodes_num; opc_index++) + for (instr_pos = 0; instr_pos < tree->instrs_num; instr_pos++) { - op_meta *om = extract_op_meta (tree, opc_index); + op_meta *om = extract_op_meta (tree, instr_pos); if (om->op.op_idx != VM_OP_VAR_DECL && om->op.op_idx != VM_OP_META && !header) { @@ -578,7 +578,7 @@ merge_subscopes (scopes_tree tree, opcode_t *data, lit_id_hash_table *lit_ids) { header = false; } - data[global_oc] = generate_opcode (tree, opc_index, lit_ids); + data[global_oc] = generate_instr (tree, instr_pos, lit_ids); global_oc++; } for (uint8_t child_id = 0; child_id < tree->t.children_num; child_id++) @@ -586,9 +586,9 @@ merge_subscopes (scopes_tree tree, opcode_t *data, lit_id_hash_table *lit_ids) merge_subscopes (*(scopes_tree *) linked_list_element (tree->t.children, child_id), data, lit_ids); } - for (; opc_index < tree->opcodes_num; opc_index++) + for (; instr_pos < tree->instrs_num; instr_pos++) { - data[global_oc] = generate_opcode (tree, opc_index, lit_ids); + data[global_oc] = generate_instr (tree, instr_pos, lit_ids); global_oc++; } } @@ -596,11 +596,11 @@ merge_subscopes (scopes_tree tree, opcode_t *data, lit_id_hash_table *lit_ids) /* Postparser. Init literal indexes 'hash' table. Reorder function declarations. - Rewrite opcodes' temporary uids with their keys in literal indexes 'hash' table. */ -opcode_t * + Rewrite instructions' temporary uids with their keys in literal indexes 'hash' table. */ +vm_instr_t * scopes_tree_raw_data (scopes_tree tree, /**< scopes tree to convert to byte-code array */ uint8_t *buffer_p, /**< buffer for byte-code array and literal identifiers hash table */ - size_t opcodes_array_size, /**< size of space for byte-code array */ + size_t instructions_array_size, /**< size of space for byte-code array */ lit_id_hash_table *lit_ids) /**< literal identifiers hash table */ { JERRY_ASSERT (lit_ids); @@ -614,14 +614,14 @@ scopes_tree_raw_data (scopes_tree tree, /**< scopes tree to convert to byte-code global_oc = 0; /* Dump bytecode and fill literal indexes 'hash' table. */ - JERRY_ASSERT (opcodes_array_size >= - sizeof (opcodes_header_t) + (size_t) (scopes_tree_count_opcodes (tree)) * sizeof (opcode_t)); + JERRY_ASSERT (instructions_array_size >= + sizeof (insts_data_header_t) + (size_t) (scopes_tree_count_instructions (tree)) * sizeof (vm_instr_t)); - opcodes_header_t *opcodes_data = (opcodes_header_t *) buffer_p; - memset (opcodes_data, 0, opcodes_array_size); + insts_data_header_t *opcodes_data = (insts_data_header_t *) buffer_p; + memset (opcodes_data, 0, instructions_array_size); - opcode_t *opcodes = (opcode_t *)(((uint8_t*) opcodes_data) + sizeof (opcodes_header_t)); - merge_subscopes (tree, opcodes, lit_ids); + vm_instr_t *instrs = (vm_instr_t *)(((uint8_t*) opcodes_data) + sizeof (insts_data_header_t)); + merge_subscopes (tree, instrs, lit_ids); if (lit_id_to_uid != null_hash) { hash_table_free (lit_id_to_uid); @@ -630,7 +630,7 @@ scopes_tree_raw_data (scopes_tree tree, /**< scopes tree to convert to byte-code MEM_CP_SET_POINTER (opcodes_data->lit_id_hash_cp, lit_ids); - return opcodes; + return instrs; } /* scopes_tree_raw_data */ void @@ -666,9 +666,9 @@ scopes_tree_init (scopes_tree parent) JERRY_ASSERT (*(scopes_tree *) added == tree); parent->t.children_num++; } - tree->opcodes_num = 0; + tree->instrs_num = 0; tree->strict_mode = 0; - tree->opcodes = linked_list_init (sizeof (op_meta)); + tree->instrs = linked_list_init (sizeof (op_meta)); return tree; } @@ -684,6 +684,6 @@ scopes_tree_free (scopes_tree tree) } linked_list_free (tree->t.children); } - linked_list_free (tree->opcodes); + linked_list_free (tree->instrs); jsp_mm_free (tree); } diff --git a/jerry-core/parser/js/scopes-tree.h b/jerry-core/parser/js/scopes-tree.h index 7b7956027..11e3ec729 100644 --- a/jerry-core/parser/js/scopes-tree.h +++ b/jerry-core/parser/js/scopes-tree.h @@ -29,7 +29,7 @@ typedef struct { lit_cpointer_t lit_id[3]; - opcode_t op; + vm_instr_t op; } op_meta; typedef struct tree_header @@ -42,8 +42,8 @@ typedef struct tree_header typedef struct { tree_header t; - linked_list opcodes; - opcode_counter_t opcodes_num; + linked_list instrs; + vm_instr_counter_t instrs_num; unsigned strict_mode:1; } scopes_tree_int; @@ -51,14 +51,14 @@ typedef scopes_tree_int * scopes_tree; scopes_tree scopes_tree_init (scopes_tree); void scopes_tree_free (scopes_tree); -opcode_counter_t scopes_tree_opcodes_num (scopes_tree); +vm_instr_counter_t scopes_tree_instrs_num (scopes_tree); void scopes_tree_add_op_meta (scopes_tree, op_meta); -void scopes_tree_set_op_meta (scopes_tree, opcode_counter_t, op_meta); -void scopes_tree_set_opcodes_num (scopes_tree, opcode_counter_t); -op_meta scopes_tree_op_meta (scopes_tree, opcode_counter_t); +void scopes_tree_set_op_meta (scopes_tree, vm_instr_counter_t, op_meta); +void scopes_tree_set_instrs_num (scopes_tree, vm_instr_counter_t); +op_meta scopes_tree_op_meta (scopes_tree, vm_instr_counter_t); size_t scopes_tree_count_literals_in_blocks (scopes_tree); -opcode_counter_t scopes_tree_count_opcodes (scopes_tree); -opcode_t *scopes_tree_raw_data (scopes_tree, uint8_t *, size_t, lit_id_hash_table *); +vm_instr_counter_t scopes_tree_count_instructions (scopes_tree); +vm_instr_t *scopes_tree_raw_data (scopes_tree, uint8_t *, size_t, lit_id_hash_table *); void scopes_tree_set_strict_mode (scopes_tree, bool); bool scopes_tree_strict_mode (scopes_tree); diff --git a/jerry-core/parser/js/serializer.cpp b/jerry-core/parser/js/serializer.cpp index a40a30aa3..19482ea88 100644 --- a/jerry-core/parser/js/serializer.cpp +++ b/jerry-core/parser/js/serializer.cpp @@ -20,14 +20,14 @@ static bytecode_data_t bytecode_data; static scopes_tree current_scope; -static bool print_opcodes; +static bool print_instrs; static void -serializer_print_opcodes (const opcode_t *opcodes_p, - size_t opcodes_count); +serializer_print_instrs (const vm_instr_t *instrs_p, + size_t instrs_count); op_meta -serializer_get_op_meta (opcode_counter_t oc) +serializer_get_op_meta (vm_instr_counter_t oc) { JERRY_ASSERT (current_scope); return scopes_tree_op_meta (current_scope, oc); @@ -38,22 +38,22 @@ serializer_get_op_meta (opcode_counter_t oc) * * @return byte-code instruction */ -opcode_t -serializer_get_opcode (const opcode_t *opcodes_p, /**< pointer to byte-code array (or NULL, +vm_instr_t +serializer_get_instr (const vm_instr_t *instrs_p, /**< pointer to byte-code array (or NULL, * if instruction should be taken from * instruction list of current scope) */ - opcode_counter_t oc) /**< opcode counter of the intruction */ + vm_instr_counter_t oc) /**< position of the intruction */ { - if (opcodes_p == NULL) + if (instrs_p == NULL) { return serializer_get_op_meta (oc).op; } else { - JERRY_ASSERT (oc < GET_BYTECODE_HEADER (opcodes_p)->instructions_number); - return opcodes_p[oc]; + JERRY_ASSERT (oc < GET_BYTECODE_HEADER (instrs_p)->instructions_number); + return instrs_p[oc]; } -} /* serializer_get_opcode */ +} /* serializer_get_instr */ /** * Convert literal id (operand value of instruction) to compressed pointer to literal @@ -66,10 +66,10 @@ serializer_get_opcode (const opcode_t *opcodes_p, /**< pointer to byte-code arra */ lit_cpointer_t serializer_get_literal_cp_by_uid (uint8_t id, /**< literal idx */ - const opcode_t *opcodes_p, /**< pointer to bytecode */ - opcode_counter_t oc) /**< position in the bytecode */ + const vm_instr_t *instrs_p, /**< pointer to bytecode */ + vm_instr_counter_t oc) /**< position in the bytecode */ { - lit_id_hash_table *lit_id_hash = GET_HASH_TABLE_FOR_BYTECODE (opcodes_p == NULL ? bytecode_data.opcodes : opcodes_p); + lit_id_hash_table *lit_id_hash = GET_HASH_TABLE_FOR_BYTECODE (instrs_p == NULL ? bytecode_data.instrs_p : instrs_p); if (lit_id_hash == null_hash) { return INVALID_LITERAL; @@ -89,84 +89,84 @@ serializer_set_scope (scopes_tree new_scope) current_scope = new_scope; } -const opcode_t * +const vm_instr_t * serializer_merge_scopes_into_bytecode (void) { - bytecode_data.opcodes_count = scopes_tree_count_opcodes (current_scope); + bytecode_data.instrs_count = scopes_tree_count_instructions (current_scope); const size_t buckets_count = scopes_tree_count_literals_in_blocks (current_scope); - const size_t blocks_count = (size_t) bytecode_data.opcodes_count / BLOCK_SIZE + 1; - const opcode_counter_t opcodes_count = scopes_tree_count_opcodes (current_scope); + const size_t blocks_count = (size_t) bytecode_data.instrs_count / BLOCK_SIZE + 1; + const vm_instr_counter_t instrs_count = scopes_tree_count_instructions (current_scope); - const size_t opcodes_array_size = JERRY_ALIGNUP (sizeof (opcodes_header_t) + opcodes_count * sizeof (opcode_t), - MEM_ALIGNMENT); + const size_t bytecode_array_size = JERRY_ALIGNUP (sizeof (insts_data_header_t) + instrs_count * sizeof (vm_instr_t), + MEM_ALIGNMENT); const size_t lit_id_hash_table_size = JERRY_ALIGNUP (lit_id_hash_table_get_size_for_table (buckets_count, blocks_count), MEM_ALIGNMENT); - uint8_t *buffer_p = (uint8_t*) mem_heap_alloc_block (opcodes_array_size + lit_id_hash_table_size, + uint8_t *buffer_p = (uint8_t*) mem_heap_alloc_block (bytecode_array_size + lit_id_hash_table_size, MEM_HEAP_ALLOC_LONG_TERM); - lit_id_hash_table *lit_id_hash = lit_id_hash_table_init (buffer_p + opcodes_array_size, + lit_id_hash_table *lit_id_hash = lit_id_hash_table_init (buffer_p + bytecode_array_size, lit_id_hash_table_size, buckets_count, blocks_count); - const opcode_t *opcodes_p = scopes_tree_raw_data (current_scope, buffer_p, opcodes_array_size, lit_id_hash); + const vm_instr_t *instrs_p = scopes_tree_raw_data (current_scope, buffer_p, bytecode_array_size, lit_id_hash); - opcodes_header_t *header_p = (opcodes_header_t*) buffer_p; - MEM_CP_SET_POINTER (header_p->next_opcodes_cp, bytecode_data.opcodes); - header_p->instructions_number = opcodes_count; - bytecode_data.opcodes = opcodes_p; + insts_data_header_t *header_p = (insts_data_header_t*) buffer_p; + MEM_CP_SET_POINTER (header_p->next_instrs_cp, bytecode_data.instrs_p); + header_p->instructions_number = instrs_count; + bytecode_data.instrs_p = instrs_p; - if (print_opcodes) + if (print_instrs) { lit_dump_literals (); - serializer_print_opcodes (opcodes_p, bytecode_data.opcodes_count); + serializer_print_instrs (instrs_p, bytecode_data.instrs_count); } - return opcodes_p; + return instrs_p; } void serializer_dump_op_meta (op_meta op) { - JERRY_ASSERT (scopes_tree_opcodes_num (current_scope) < MAX_OPCODES); + JERRY_ASSERT (scopes_tree_instrs_num (current_scope) < MAX_OPCODES); scopes_tree_add_op_meta (current_scope, op); #ifdef JERRY_ENABLE_PRETTY_PRINTER - if (print_opcodes) + if (print_instrs) { - pp_op_meta (NULL, (opcode_counter_t) (scopes_tree_opcodes_num (current_scope) - 1), op, false); + pp_op_meta (NULL, (vm_instr_counter_t) (scopes_tree_instrs_num (current_scope) - 1), op, false); } #endif } -opcode_counter_t -serializer_get_current_opcode_counter (void) +vm_instr_counter_t +serializer_get_current_instr_counter (void) { - return scopes_tree_opcodes_num (current_scope); + return scopes_tree_instrs_num (current_scope); } -opcode_counter_t -serializer_count_opcodes_in_subscopes (void) +vm_instr_counter_t +serializer_count_instrs_in_subscopes (void) { - return (opcode_counter_t) (scopes_tree_count_opcodes (current_scope) - scopes_tree_opcodes_num (current_scope)); + return (vm_instr_counter_t) (scopes_tree_count_instructions (current_scope) - scopes_tree_instrs_num (current_scope)); } void -serializer_set_writing_position (opcode_counter_t oc) +serializer_set_writing_position (vm_instr_counter_t oc) { - scopes_tree_set_opcodes_num (current_scope, oc); + scopes_tree_set_instrs_num (current_scope, oc); } void -serializer_rewrite_op_meta (const opcode_counter_t loc, op_meta op) +serializer_rewrite_op_meta (const vm_instr_counter_t loc, op_meta op) { scopes_tree_set_op_meta (current_scope, loc, op); #ifdef JERRY_ENABLE_PRETTY_PRINTER - if (print_opcodes) + if (print_instrs) { pp_op_meta (NULL, loc, op, true); } @@ -174,25 +174,25 @@ serializer_rewrite_op_meta (const opcode_counter_t loc, op_meta op) } static void -serializer_print_opcodes (const opcode_t *opcodes_p, - size_t opcodes_count) +serializer_print_instrs (const vm_instr_t *instrs_p, + size_t instrs_count) { #ifdef JERRY_ENABLE_PRETTY_PRINTER - for (opcode_counter_t loc = 0; loc < opcodes_count; loc++) + for (vm_instr_counter_t loc = 0; loc < instrs_count; loc++) { op_meta opm; - opm.op = opcodes_p[loc]; + opm.op = instrs_p[loc]; for (int i = 0; i < 3; i++) { opm.lit_id[i] = NOT_A_LITERAL; } - pp_op_meta (opcodes_p, loc, opm, false); + pp_op_meta (instrs_p, loc, opm, false); } #else - (void) opcodes_p; - (void) opcodes_count; + (void) instrs_p; + (void) instrs_count; #endif } @@ -200,17 +200,17 @@ void serializer_init () { current_scope = NULL; - print_opcodes = false; + print_instrs = false; bytecode_data.strings_buffer = NULL; - bytecode_data.opcodes = NULL; + bytecode_data.instrs_p = NULL; lit_init (); } -void serializer_set_show_opcodes (bool show_opcodes) +void serializer_set_show_instrs (bool show_instrs) { - print_opcodes = show_opcodes; + print_instrs = show_instrs; } void @@ -223,10 +223,10 @@ serializer_free (void) lit_finalize (); - while (bytecode_data.opcodes != NULL) + while (bytecode_data.instrs_p != NULL) { - opcodes_header_t *header_p = GET_BYTECODE_HEADER (bytecode_data.opcodes); - bytecode_data.opcodes = MEM_CP_GET_POINTER (opcode_t, header_p->next_opcodes_cp); + insts_data_header_t *header_p = GET_BYTECODE_HEADER (bytecode_data.instrs_p); + bytecode_data.instrs_p = MEM_CP_GET_POINTER (vm_instr_t, header_p->next_instrs_cp); mem_heap_free_block (header_p); } diff --git a/jerry-core/parser/js/serializer.h b/jerry-core/parser/js/serializer.h index cc7f34694..fed71d025 100644 --- a/jerry-core/parser/js/serializer.h +++ b/jerry-core/parser/js/serializer.h @@ -23,18 +23,18 @@ #include "scopes-tree.h" void serializer_init (); -void serializer_set_show_opcodes (bool show_opcodes); -op_meta serializer_get_op_meta (opcode_counter_t); -opcode_t serializer_get_opcode (const opcode_t*, opcode_counter_t); -lit_cpointer_t serializer_get_literal_cp_by_uid (uint8_t, const opcode_t*, opcode_counter_t); +void serializer_set_show_instrs (bool show_instrs); +op_meta serializer_get_op_meta (vm_instr_counter_t); +vm_instr_t serializer_get_instr (const vm_instr_t*, vm_instr_counter_t); +lit_cpointer_t serializer_get_literal_cp_by_uid (uint8_t, const vm_instr_t*, vm_instr_counter_t); void serializer_set_strings_buffer (const ecma_char_t *); void serializer_set_scope (scopes_tree); -const opcode_t *serializer_merge_scopes_into_bytecode (void); +const vm_instr_t *serializer_merge_scopes_into_bytecode (void); void serializer_dump_op_meta (op_meta); -opcode_counter_t serializer_get_current_opcode_counter (void); -opcode_counter_t serializer_count_opcodes_in_subscopes (void); -void serializer_set_writing_position (opcode_counter_t); -void serializer_rewrite_op_meta (opcode_counter_t, op_meta); +vm_instr_counter_t serializer_get_current_instr_counter (void); +vm_instr_counter_t serializer_count_instrs_in_subscopes (void); +void serializer_set_writing_position (vm_instr_counter_t); +void serializer_rewrite_op_meta (vm_instr_counter_t, op_meta); void serializer_free (void); #endif // SERIALIZER_H diff --git a/jerry-core/vm/opcodes-agnostic.cpp b/jerry-core/vm/opcodes-agnostic.cpp index 51ee60ede..b601e630f 100644 --- a/jerry-core/vm/opcodes-agnostic.cpp +++ b/jerry-core/vm/opcodes-agnostic.cpp @@ -20,16 +20,16 @@ * 'Jump down if true' opcode handler. * * Note: - * current opcode's position changes by adding specified offset + * current instruction's position changes by adding specified offset * if argument evaluates to true. */ ecma_completion_value_t -opfunc_is_true_jmp_down (opcode_t opdata, /**< operation data */ +opfunc_is_true_jmp_down (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t cond_var_idx = opdata.data.is_true_jmp_down.value; - const opcode_counter_t offset = calc_opcode_counter_from_idx_idx (opdata.data.is_true_jmp_down.opcode_1, - opdata.data.is_true_jmp_down.opcode_2); + const idx_t cond_var_idx = instr.data.is_true_jmp_down.value; + const vm_instr_counter_t offset = vm_calc_instr_counter_from_idx_idx (instr.data.is_true_jmp_down.oc_idx_1, + instr.data.is_true_jmp_down.oc_idx_2); ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -41,7 +41,7 @@ opfunc_is_true_jmp_down (opcode_t opdata, /**< operation data */ if (ecma_is_completion_value_normal_true (to_bool_completion)) { JERRY_ASSERT ((uint32_t) frame_ctx_p->pos + offset < MAX_OPCODES); - frame_ctx_p->pos = (opcode_counter_t) (frame_ctx_p->pos + offset); + frame_ctx_p->pos = (vm_instr_counter_t) (frame_ctx_p->pos + offset); } else { @@ -57,12 +57,12 @@ opfunc_is_true_jmp_down (opcode_t opdata, /**< operation data */ /* Likewise to opfunc_is_true_jmp_down, but jumps up. */ ecma_completion_value_t -opfunc_is_true_jmp_up (opcode_t opdata, /**< operation data */ +opfunc_is_true_jmp_up (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t cond_var_idx = opdata.data.is_true_jmp_up.value; - const opcode_counter_t offset = calc_opcode_counter_from_idx_idx (opdata.data.is_true_jmp_up.opcode_1, - opdata.data.is_true_jmp_up.opcode_2); + const idx_t cond_var_idx = instr.data.is_true_jmp_up.value; + const vm_instr_counter_t offset = vm_calc_instr_counter_from_idx_idx (instr.data.is_true_jmp_up.oc_idx_1, + instr.data.is_true_jmp_up.oc_idx_2); ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -74,7 +74,7 @@ opfunc_is_true_jmp_up (opcode_t opdata, /**< operation data */ if (ecma_is_completion_value_normal_true (to_bool_completion)) { JERRY_ASSERT ((uint32_t) frame_ctx_p->pos >= offset); - frame_ctx_p->pos = (opcode_counter_t) (frame_ctx_p->pos - offset); + frame_ctx_p->pos = (vm_instr_counter_t) (frame_ctx_p->pos - offset); } else { @@ -92,16 +92,16 @@ opfunc_is_true_jmp_up (opcode_t opdata, /**< operation data */ * 'Jump down if false' opcode handler. * * Note: - * current opcode's position changes by adding specified offset + * current instruction's position changes by adding specified offset * if argument evaluates to false. */ ecma_completion_value_t -opfunc_is_false_jmp_down (opcode_t opdata, /**< operation data */ +opfunc_is_false_jmp_down (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t cond_var_idx = opdata.data.is_false_jmp_down.value; - const opcode_counter_t offset = calc_opcode_counter_from_idx_idx (opdata.data.is_false_jmp_down.opcode_1, - opdata.data.is_false_jmp_down.opcode_2); + const idx_t cond_var_idx = instr.data.is_false_jmp_down.value; + const vm_instr_counter_t offset = vm_calc_instr_counter_from_idx_idx (instr.data.is_false_jmp_down.oc_idx_1, + instr.data.is_false_jmp_down.oc_idx_2); ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -113,7 +113,7 @@ opfunc_is_false_jmp_down (opcode_t opdata, /**< operation data */ if (!ecma_is_completion_value_normal_true (to_bool_completion)) { JERRY_ASSERT ((uint32_t) frame_ctx_p->pos + offset < MAX_OPCODES); - frame_ctx_p->pos = (opcode_counter_t) (frame_ctx_p->pos + offset); + frame_ctx_p->pos = (vm_instr_counter_t) (frame_ctx_p->pos + offset); } else { @@ -129,12 +129,12 @@ opfunc_is_false_jmp_down (opcode_t opdata, /**< operation data */ /* Likewise to opfunc_is_false_jmp_down, but jumps up. */ ecma_completion_value_t -opfunc_is_false_jmp_up (opcode_t opdata, /**< operation data */ +opfunc_is_false_jmp_up (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t cond_var_idx = opdata.data.is_false_jmp_up.value; - const opcode_counter_t offset = calc_opcode_counter_from_idx_idx (opdata.data.is_false_jmp_up.opcode_1, - opdata.data.is_false_jmp_up.opcode_2); + const idx_t cond_var_idx = instr.data.is_false_jmp_up.value; + const vm_instr_counter_t offset = vm_calc_instr_counter_from_idx_idx (instr.data.is_false_jmp_up.oc_idx_1, + instr.data.is_false_jmp_up.oc_idx_2); ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -146,7 +146,7 @@ opfunc_is_false_jmp_up (opcode_t opdata, /**< operation data */ if (!ecma_is_completion_value_normal_true (to_bool_completion)) { JERRY_ASSERT ((uint32_t) frame_ctx_p->pos >= offset); - frame_ctx_p->pos = (opcode_counter_t) (frame_ctx_p->pos - offset); + frame_ctx_p->pos = (vm_instr_counter_t) (frame_ctx_p->pos - offset); } else { @@ -164,18 +164,18 @@ opfunc_is_false_jmp_up (opcode_t opdata, /**< operation data */ * 'Jump down' opcode handler. * * Note: - * the opcode changes adds specified value to current opcode position + * the opcode changes adds specified value to current instruction position */ ecma_completion_value_t -opfunc_jmp_down (opcode_t opdata, /**< operation data */ +opfunc_jmp_down (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const opcode_counter_t offset = calc_opcode_counter_from_idx_idx (opdata.data.jmp_down.opcode_1, - opdata.data.jmp_down.opcode_2); + const vm_instr_counter_t offset = vm_calc_instr_counter_from_idx_idx (instr.data.jmp_down.oc_idx_1, + instr.data.jmp_down.oc_idx_2); JERRY_ASSERT (((uint32_t) frame_ctx_p->pos + offset < MAX_OPCODES)); - frame_ctx_p->pos = (opcode_counter_t) (frame_ctx_p->pos + offset); + frame_ctx_p->pos = (vm_instr_counter_t) (frame_ctx_p->pos + offset); return ecma_make_empty_completion_value (); } @@ -184,17 +184,17 @@ opfunc_jmp_down (opcode_t opdata, /**< operation data */ * 'Jump up' opcode handler. * * Note: - * the opcode changes substracts specified value from current opcode position + * the opcode changes substracts specified value from current instruction position */ ecma_completion_value_t -opfunc_jmp_up (opcode_t opdata, /**< operation data */ +opfunc_jmp_up (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const opcode_counter_t offset = calc_opcode_counter_from_idx_idx (opdata.data.jmp_up.opcode_1, - opdata.data.jmp_up.opcode_2); + const vm_instr_counter_t offset = vm_calc_instr_counter_from_idx_idx (instr.data.jmp_up.oc_idx_1, + instr.data.jmp_up.oc_idx_2); JERRY_ASSERT ((uint32_t) frame_ctx_p->pos >= offset); - frame_ctx_p->pos = (opcode_counter_t) (frame_ctx_p->pos - offset); + frame_ctx_p->pos = (vm_instr_counter_t) (frame_ctx_p->pos - offset); return ecma_make_empty_completion_value (); } @@ -206,12 +206,12 @@ opfunc_jmp_up (opcode_t opdata, /**< operation data */ * the opcode returns break-continue completion value with jump target */ ecma_completion_value_t -opfunc_jmp_break_continue (opcode_t opdata, /**< operation data */ +opfunc_jmp_break_continue (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - opcode_counter_t target = frame_ctx_p->pos; - target = (opcode_counter_t) (target + calc_opcode_counter_from_idx_idx (opdata.data.jmp_down.opcode_1, - opdata.data.jmp_down.opcode_2)); + vm_instr_counter_t target = frame_ctx_p->pos; + target = (vm_instr_counter_t) (target + vm_calc_instr_counter_from_idx_idx (instr.data.jmp_down.oc_idx_1, + instr.data.jmp_down.oc_idx_2)); return ecma_make_jump_completion_value (target); } /* opfunc_jmp_break_continue */ diff --git a/jerry-core/vm/opcodes-ecma-arithmetics.cpp b/jerry-core/vm/opcodes-ecma-arithmetics.cpp index ae7ea8f85..0e1c12fd5 100644 --- a/jerry-core/vm/opcodes-ecma-arithmetics.cpp +++ b/jerry-core/vm/opcodes-ecma-arithmetics.cpp @@ -103,12 +103,12 @@ do_number_arithmetic (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_addition (opcode_t opdata, /**< operation data */ +opfunc_addition (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.addition.dst; - const idx_t left_var_idx = opdata.data.addition.var_left; - const idx_t right_var_idx = opdata.data.addition.var_right; + const idx_t dst_var_idx = instr.data.addition.dst; + const idx_t left_var_idx = instr.data.addition.var_left; + const idx_t right_var_idx = instr.data.addition.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -169,12 +169,12 @@ opfunc_addition (opcode_t opdata, /**< operation data */ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_substraction (opcode_t opdata, /**< operation data */ +opfunc_substraction (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.substraction.dst; - const idx_t left_var_idx = opdata.data.substraction.var_left; - const idx_t right_var_idx = opdata.data.substraction.var_right; + const idx_t dst_var_idx = instr.data.substraction.dst; + const idx_t left_var_idx = instr.data.substraction.var_left; + const idx_t right_var_idx = instr.data.substraction.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -204,12 +204,12 @@ opfunc_substraction (opcode_t opdata, /**< operation data */ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_multiplication (opcode_t opdata, /**< operation data */ +opfunc_multiplication (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.multiplication.dst; - const idx_t left_var_idx = opdata.data.multiplication.var_left; - const idx_t right_var_idx = opdata.data.multiplication.var_right; + const idx_t dst_var_idx = instr.data.multiplication.dst; + const idx_t left_var_idx = instr.data.multiplication.var_left; + const idx_t right_var_idx = instr.data.multiplication.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -239,12 +239,12 @@ opfunc_multiplication (opcode_t opdata, /**< operation data */ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_division (opcode_t opdata, /**< operation data */ +opfunc_division (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.division.dst; - const idx_t left_var_idx = opdata.data.division.var_left; - const idx_t right_var_idx = opdata.data.division.var_right; + const idx_t dst_var_idx = instr.data.division.dst; + const idx_t left_var_idx = instr.data.division.var_left; + const idx_t right_var_idx = instr.data.division.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -274,12 +274,12 @@ opfunc_division (opcode_t opdata, /**< operation data */ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_remainder (opcode_t opdata, /**< operation data */ +opfunc_remainder (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.remainder.dst; - const idx_t left_var_idx = opdata.data.remainder.var_left; - const idx_t right_var_idx = opdata.data.remainder.var_right; + const idx_t dst_var_idx = instr.data.remainder.dst; + const idx_t left_var_idx = instr.data.remainder.var_left; + const idx_t right_var_idx = instr.data.remainder.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -309,11 +309,11 @@ opfunc_remainder (opcode_t opdata, /**< operation data */ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_unary_plus (opcode_t opdata, /**< operation data */ +opfunc_unary_plus (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.remainder.dst; - const idx_t var_idx = opdata.data.remainder.var_left; + const idx_t dst_var_idx = instr.data.remainder.dst; + const idx_t var_idx = instr.data.remainder.var_left; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -346,11 +346,11 @@ opfunc_unary_plus (opcode_t opdata, /**< operation data */ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_unary_minus (opcode_t opdata, /**< operation data */ +opfunc_unary_minus (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.remainder.dst; - const idx_t var_idx = opdata.data.remainder.var_left; + const idx_t dst_var_idx = instr.data.remainder.dst; + const idx_t var_idx = instr.data.remainder.var_left; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); diff --git a/jerry-core/vm/opcodes-ecma-bitwise.cpp b/jerry-core/vm/opcodes-ecma-bitwise.cpp index 2d3e19426..fa06c4c81 100644 --- a/jerry-core/vm/opcodes-ecma-bitwise.cpp +++ b/jerry-core/vm/opcodes-ecma-bitwise.cpp @@ -119,12 +119,12 @@ do_number_bitwise_logic (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context * * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_b_and (opcode_t opdata, /**< operation data */ +opfunc_b_and (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.b_and.dst; - const idx_t left_var_idx = opdata.data.b_and.var_left; - const idx_t right_var_idx = opdata.data.b_and.var_right; + const idx_t dst_var_idx = instr.data.b_and.dst; + const idx_t left_var_idx = instr.data.b_and.var_left; + const idx_t right_var_idx = instr.data.b_and.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -154,12 +154,12 @@ opfunc_b_and (opcode_t opdata, /**< operation data */ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_b_or (opcode_t opdata, /**< operation data */ +opfunc_b_or (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.b_or.dst; - const idx_t left_var_idx = opdata.data.b_or.var_left; - const idx_t right_var_idx = opdata.data.b_or.var_right; + const idx_t dst_var_idx = instr.data.b_or.dst; + const idx_t left_var_idx = instr.data.b_or.var_left; + const idx_t right_var_idx = instr.data.b_or.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -189,12 +189,12 @@ opfunc_b_or (opcode_t opdata, /**< operation data */ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_b_xor (opcode_t opdata, /**< operation data */ +opfunc_b_xor (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.b_xor.dst; - const idx_t left_var_idx = opdata.data.b_xor.var_left; - const idx_t right_var_idx = opdata.data.b_xor.var_right; + const idx_t dst_var_idx = instr.data.b_xor.dst; + const idx_t left_var_idx = instr.data.b_xor.var_left; + const idx_t right_var_idx = instr.data.b_xor.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -224,12 +224,12 @@ opfunc_b_xor (opcode_t opdata, /**< operation data */ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_b_shift_left (opcode_t opdata, /**< operation data */ +opfunc_b_shift_left (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.b_shift_left.dst; - const idx_t left_var_idx = opdata.data.b_shift_left.var_left; - const idx_t right_var_idx = opdata.data.b_shift_left.var_right; + const idx_t dst_var_idx = instr.data.b_shift_left.dst; + const idx_t left_var_idx = instr.data.b_shift_left.var_left; + const idx_t right_var_idx = instr.data.b_shift_left.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -259,12 +259,12 @@ opfunc_b_shift_left (opcode_t opdata, /**< operation data */ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_b_shift_right (opcode_t opdata, /**< operation data */ +opfunc_b_shift_right (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.b_shift_right.dst; - const idx_t left_var_idx = opdata.data.b_shift_right.var_left; - const idx_t right_var_idx = opdata.data.b_shift_right.var_right; + const idx_t dst_var_idx = instr.data.b_shift_right.dst; + const idx_t left_var_idx = instr.data.b_shift_right.var_left; + const idx_t right_var_idx = instr.data.b_shift_right.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -294,12 +294,12 @@ opfunc_b_shift_right (opcode_t opdata, /**< operation data */ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_b_shift_uright (opcode_t opdata, /**< operation data */ +opfunc_b_shift_uright (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.b_shift_uright.dst; - const idx_t left_var_idx = opdata.data.b_shift_uright.var_left; - const idx_t right_var_idx = opdata.data.b_shift_uright.var_right; + const idx_t dst_var_idx = instr.data.b_shift_uright.dst; + const idx_t left_var_idx = instr.data.b_shift_uright.var_left; + const idx_t right_var_idx = instr.data.b_shift_uright.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -329,11 +329,11 @@ opfunc_b_shift_uright (opcode_t opdata, /**< operation data */ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_b_not (opcode_t opdata, /**< operation data */ +opfunc_b_not (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.b_not.dst; - const idx_t right_var_idx = opdata.data.b_not.var_right; + const idx_t dst_var_idx = instr.data.b_not.dst; + const idx_t right_var_idx = instr.data.b_not.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); diff --git a/jerry-core/vm/opcodes-ecma-equality.cpp b/jerry-core/vm/opcodes-ecma-equality.cpp index 860872556..24795e641 100644 --- a/jerry-core/vm/opcodes-ecma-equality.cpp +++ b/jerry-core/vm/opcodes-ecma-equality.cpp @@ -25,12 +25,12 @@ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_equal_value (opcode_t opdata, /**< operation data */ +opfunc_equal_value (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.equal_value.dst; - const idx_t left_var_idx = opdata.data.equal_value.var_left; - const idx_t right_var_idx = opdata.data.equal_value.var_right; + const idx_t dst_var_idx = instr.data.equal_value.dst; + const idx_t left_var_idx = instr.data.equal_value.var_left; + const idx_t right_var_idx = instr.data.equal_value.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -64,12 +64,12 @@ opfunc_equal_value (opcode_t opdata, /**< operation data */ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_not_equal_value (opcode_t opdata, /**< operation data */ +opfunc_not_equal_value (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.not_equal_value.dst; - const idx_t left_var_idx = opdata.data.not_equal_value.var_left; - const idx_t right_var_idx = opdata.data.not_equal_value.var_right; + const idx_t dst_var_idx = instr.data.not_equal_value.dst; + const idx_t left_var_idx = instr.data.not_equal_value.var_left; + const idx_t right_var_idx = instr.data.not_equal_value.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -105,12 +105,12 @@ opfunc_not_equal_value (opcode_t opdata, /**< operation data */ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_equal_value_type (opcode_t opdata, /**< operation data */ +opfunc_equal_value_type (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.equal_value_type.dst; - const idx_t left_var_idx = opdata.data.equal_value_type.var_left; - const idx_t right_var_idx = opdata.data.equal_value_type.var_right; + const idx_t dst_var_idx = instr.data.equal_value_type.dst; + const idx_t left_var_idx = instr.data.equal_value_type.var_left; + const idx_t right_var_idx = instr.data.equal_value_type.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -140,12 +140,12 @@ opfunc_equal_value_type (opcode_t opdata, /**< operation data */ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_not_equal_value_type (opcode_t opdata, /**< operation data */ +opfunc_not_equal_value_type (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.not_equal_value_type.dst; - const idx_t left_var_idx = opdata.data.not_equal_value_type.var_left; - const idx_t right_var_idx = opdata.data.not_equal_value_type.var_right; + const idx_t dst_var_idx = instr.data.not_equal_value_type.dst; + const idx_t left_var_idx = instr.data.not_equal_value_type.var_left; + const idx_t right_var_idx = instr.data.not_equal_value_type.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); diff --git a/jerry-core/vm/opcodes-ecma-relational.cpp b/jerry-core/vm/opcodes-ecma-relational.cpp index e0862559d..371580bfa 100644 --- a/jerry-core/vm/opcodes-ecma-relational.cpp +++ b/jerry-core/vm/opcodes-ecma-relational.cpp @@ -25,12 +25,12 @@ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_less_than (opcode_t opdata, /**< operation data */ +opfunc_less_than (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.less_than.dst; - const idx_t left_var_idx = opdata.data.less_than.var_left; - const idx_t right_var_idx = opdata.data.less_than.var_right; + const idx_t dst_var_idx = instr.data.less_than.dst; + const idx_t left_var_idx = instr.data.less_than.var_left; + const idx_t right_var_idx = instr.data.less_than.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -73,12 +73,12 @@ opfunc_less_than (opcode_t opdata, /**< operation data */ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_greater_than (opcode_t opdata, /**< operation data */ +opfunc_greater_than (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.greater_than.dst; - const idx_t left_var_idx = opdata.data.greater_than.var_left; - const idx_t right_var_idx = opdata.data.greater_than.var_right; + const idx_t dst_var_idx = instr.data.greater_than.dst; + const idx_t left_var_idx = instr.data.greater_than.var_left; + const idx_t right_var_idx = instr.data.greater_than.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -121,12 +121,12 @@ opfunc_greater_than (opcode_t opdata, /**< operation data */ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_less_or_equal_than (opcode_t opdata, /**< operation data */ +opfunc_less_or_equal_than (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.less_or_equal_than.dst; - const idx_t left_var_idx = opdata.data.less_or_equal_than.var_left; - const idx_t right_var_idx = opdata.data.less_or_equal_than.var_right; + const idx_t dst_var_idx = instr.data.less_or_equal_than.dst; + const idx_t left_var_idx = instr.data.less_or_equal_than.var_left; + const idx_t right_var_idx = instr.data.less_or_equal_than.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -176,12 +176,12 @@ opfunc_less_or_equal_than (opcode_t opdata, /**< operation data */ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_greater_or_equal_than (opcode_t opdata, /**< operation data */ +opfunc_greater_or_equal_than (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.greater_or_equal_than.dst; - const idx_t left_var_idx = opdata.data.greater_or_equal_than.var_left; - const idx_t right_var_idx = opdata.data.greater_or_equal_than.var_right; + const idx_t dst_var_idx = instr.data.greater_or_equal_than.dst; + const idx_t left_var_idx = instr.data.greater_or_equal_than.var_left; + const idx_t right_var_idx = instr.data.greater_or_equal_than.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -231,12 +231,12 @@ opfunc_greater_or_equal_than (opcode_t opdata, /**< operation data */ * returned value must be freed with ecma_free_completion_value. */ ecma_completion_value_t -opfunc_instanceof (opcode_t opdata __attr_unused___, /**< operation data */ +opfunc_instanceof (vm_instr_t instr __attr_unused___, /**< instruction */ vm_frame_ctx_t *frame_ctx_p __attr_unused___) /**< interpreter context */ { - const idx_t dst_idx = opdata.data.instanceof.dst; - const idx_t left_var_idx = opdata.data.instanceof.var_left; - const idx_t right_var_idx = opdata.data.instanceof.var_right; + const idx_t dst_idx = instr.data.instanceof.dst; + const idx_t left_var_idx = instr.data.instanceof.var_left; + const idx_t right_var_idx = instr.data.instanceof.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -277,12 +277,12 @@ opfunc_instanceof (opcode_t opdata __attr_unused___, /**< operation data */ * returned value must be freed with ecma_free_completion_value. */ ecma_completion_value_t -opfunc_in (opcode_t opdata __attr_unused___, /**< operation data */ +opfunc_in (vm_instr_t instr __attr_unused___, /**< instruction */ vm_frame_ctx_t *frame_ctx_p __attr_unused___) /**< interpreter context */ { - const idx_t dst_idx = opdata.data.in.dst; - const idx_t left_var_idx = opdata.data.in.var_left; - const idx_t right_var_idx = opdata.data.in.var_right; + const idx_t dst_idx = instr.data.in.dst; + const idx_t left_var_idx = instr.data.in.var_left; + const idx_t right_var_idx = instr.data.in.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); diff --git a/jerry-core/vm/opcodes-ecma-support.h b/jerry-core/vm/opcodes-ecma-support.h index e0b71e150..357af960b 100644 --- a/jerry-core/vm/opcodes-ecma-support.h +++ b/jerry-core/vm/opcodes-ecma-support.h @@ -18,6 +18,7 @@ #include "ecma-alloc.h" #include "ecma-array-object.h" +#include "ecma-builtins.h" #include "ecma-comparison.h" #include "ecma-conversion.h" #include "ecma-exceptions.h" @@ -35,7 +36,7 @@ bool is_reg_variable (vm_frame_ctx_t *frame_ctx_p, idx_t var_idx); ecma_completion_value_t get_variable_value (vm_frame_ctx_t *, idx_t, bool); -ecma_completion_value_t set_variable_value (vm_frame_ctx_t *, opcode_counter_t, idx_t, ecma_value_t); +ecma_completion_value_t set_variable_value (vm_frame_ctx_t *, vm_instr_counter_t, idx_t, ecma_value_t); ecma_completion_value_t fill_varg_list (vm_frame_ctx_t *frame_ctx_p, ecma_length_t args_number, ecma_value_t args_values[], diff --git a/jerry-core/vm/opcodes-ecma-try-catch-finally.cpp b/jerry-core/vm/opcodes-ecma-try-catch-finally.cpp index e382e5ff6..270f94a44 100644 --- a/jerry-core/vm/opcodes-ecma-try-catch-finally.cpp +++ b/jerry-core/vm/opcodes-ecma-try-catch-finally.cpp @@ -27,13 +27,13 @@ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_try_block (opcode_t opdata, /**< operation data */ +opfunc_try_block (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t block_end_oc_idx_1 = opdata.data.try_block.oc_idx_1; - const idx_t block_end_oc_idx_2 = opdata.data.try_block.oc_idx_2; - const opcode_counter_t try_end_oc = (opcode_counter_t) ( - calc_opcode_counter_from_idx_idx (block_end_oc_idx_1, block_end_oc_idx_2) + frame_ctx_p->pos); + const idx_t block_end_oc_idx_1 = instr.data.try_block.oc_idx_1; + const idx_t block_end_oc_idx_2 = instr.data.try_block.oc_idx_2; + const vm_instr_counter_t try_end_oc = (vm_instr_counter_t) ( + vm_calc_instr_counter_from_idx_idx (block_end_oc_idx_1, block_end_oc_idx_2) + frame_ctx_p->pos); frame_ctx_p->pos++; @@ -43,23 +43,23 @@ opfunc_try_block (opcode_t opdata, /**< operation data */ || (ecma_is_completion_value_empty (try_completion) && frame_ctx_p->pos == try_end_oc)); frame_ctx_p->pos = try_end_oc; - opcode_t next_opcode = vm_get_opcode (frame_ctx_p->opcodes_p, frame_ctx_p->pos); - JERRY_ASSERT (next_opcode.op_idx == VM_OP_META); + vm_instr_t next_instr = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos); + JERRY_ASSERT (next_instr.op_idx == VM_OP_META); - if (next_opcode.data.meta.type == OPCODE_META_TYPE_CATCH) + if (next_instr.data.meta.type == OPCODE_META_TYPE_CATCH) { - const opcode_counter_t catch_end_oc = (opcode_counter_t) ( - read_meta_opcode_counter (OPCODE_META_TYPE_CATCH, frame_ctx_p) + frame_ctx_p->pos); + const vm_instr_counter_t catch_end_oc = (vm_instr_counter_t) ( + vm_read_instr_counter_from_meta (OPCODE_META_TYPE_CATCH, frame_ctx_p) + frame_ctx_p->pos); frame_ctx_p->pos++; if (ecma_is_completion_value_throw (try_completion)) { - next_opcode = vm_get_opcode (frame_ctx_p->opcodes_p, frame_ctx_p->pos); - JERRY_ASSERT (next_opcode.op_idx == VM_OP_META); - JERRY_ASSERT (next_opcode.data.meta.type == OPCODE_META_TYPE_CATCH_EXCEPTION_IDENTIFIER); + next_instr = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos); + JERRY_ASSERT (next_instr.op_idx == VM_OP_META); + JERRY_ASSERT (next_instr.data.meta.type == OPCODE_META_TYPE_CATCH_EXCEPTION_IDENTIFIER); - lit_cpointer_t catch_exc_val_var_name_lit_cp = serializer_get_literal_cp_by_uid (next_opcode.data.meta.data_1, - frame_ctx_p->opcodes_p, + lit_cpointer_t catch_exc_val_var_name_lit_cp = serializer_get_literal_cp_by_uid (next_instr.data.meta.data_1, + frame_ctx_p->instrs_p, frame_ctx_p->pos); frame_ctx_p->pos++; @@ -98,13 +98,13 @@ opfunc_try_block (opcode_t opdata, /**< operation data */ frame_ctx_p->pos = catch_end_oc; } - next_opcode = vm_get_opcode (frame_ctx_p->opcodes_p, frame_ctx_p->pos); - JERRY_ASSERT (next_opcode.op_idx == VM_OP_META); + next_instr = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos); + JERRY_ASSERT (next_instr.op_idx == VM_OP_META); - if (next_opcode.data.meta.type == OPCODE_META_TYPE_FINALLY) + if (next_instr.data.meta.type == OPCODE_META_TYPE_FINALLY) { - const opcode_counter_t finally_end_oc = (opcode_counter_t) ( - read_meta_opcode_counter (OPCODE_META_TYPE_FINALLY, frame_ctx_p) + frame_ctx_p->pos); + const vm_instr_counter_t finally_end_oc = (vm_instr_counter_t) ( + vm_read_instr_counter_from_meta (OPCODE_META_TYPE_FINALLY, frame_ctx_p) + frame_ctx_p->pos); frame_ctx_p->pos++; vm_run_scope_t run_scope_finally = { frame_ctx_p->pos, finally_end_oc }; @@ -121,9 +121,9 @@ opfunc_try_block (opcode_t opdata, /**< operation data */ } } - next_opcode = vm_get_opcode (frame_ctx_p->opcodes_p, frame_ctx_p->pos++); - JERRY_ASSERT (next_opcode.op_idx == VM_OP_META); - JERRY_ASSERT (next_opcode.data.meta.type == OPCODE_META_TYPE_END_TRY_CATCH_FINALLY); + next_instr = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos++); + JERRY_ASSERT (next_instr.op_idx == VM_OP_META); + JERRY_ASSERT (next_instr.data.meta.type == OPCODE_META_TYPE_END_TRY_CATCH_FINALLY); return try_completion; } /* opfunc_try_block */ diff --git a/jerry-core/vm/opcodes-for-in.cpp b/jerry-core/vm/opcodes-for-in.cpp index aba38dbb0..0a3658850 100644 --- a/jerry-core/vm/opcodes-for-in.cpp +++ b/jerry-core/vm/opcodes-for-in.cpp @@ -182,15 +182,15 @@ vm_helper_for_in_enumerate_properties_names (ecma_object_t *obj_p) /**< starting * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_for_in (opcode_t opdata, /**< operation data */ +opfunc_for_in (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *int_data_p) /**< interpreter context */ { - const idx_t expr_idx = opdata.data.for_in.expr; - const idx_t block_end_oc_idx_1 = opdata.data.for_in.oc_idx_1; - const idx_t block_end_oc_idx_2 = opdata.data.for_in.oc_idx_2; - const opcode_counter_t for_in_end_oc = (opcode_counter_t) ( - calc_opcode_counter_from_idx_idx (block_end_oc_idx_1, - block_end_oc_idx_2) + int_data_p->pos); + const idx_t expr_idx = instr.data.for_in.expr; + const idx_t block_end_oc_idx_1 = instr.data.for_in.oc_idx_1; + const idx_t block_end_oc_idx_2 = instr.data.for_in.oc_idx_2; + const vm_instr_counter_t for_in_end_oc = (vm_instr_counter_t) ( + vm_calc_instr_counter_from_idx_idx (block_end_oc_idx_1, + block_end_oc_idx_2) + int_data_p->pos); ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -203,9 +203,9 @@ opfunc_for_in (opcode_t opdata, /**< operation data */ int_data_p->pos++; - opcode_t meta_opcode = vm_get_opcode (int_data_p->opcodes_p, for_in_end_oc); - JERRY_ASSERT (meta_opcode.op_idx == VM_OP_META); - JERRY_ASSERT (meta_opcode.data.meta.type == OPCODE_META_TYPE_END_FOR_IN); + vm_instr_t meta_instr = vm_get_instr (int_data_p->instrs_p, for_in_end_oc); + JERRY_ASSERT (meta_instr.op_idx == VM_OP_META); + JERRY_ASSERT (meta_instr.data.meta.type == OPCODE_META_TYPE_END_FOR_IN); /* 3. */ if (!ecma_is_value_undefined (expr_value) @@ -225,8 +225,8 @@ opfunc_for_in (opcode_t opdata, /**< operation data */ { ecma_collection_iterator_init (&names_iterator, names_p); - const opcode_counter_t for_in_body_begin_oc = int_data_p->pos; - const opcode_counter_t for_in_body_end_oc = for_in_end_oc; + const vm_instr_counter_t for_in_body_begin_oc = int_data_p->pos; + const vm_instr_counter_t for_in_body_end_oc = for_in_end_oc; while (ecma_collection_iterator_next (&names_iterator)) { @@ -270,7 +270,7 @@ opfunc_for_in (opcode_t opdata, /**< operation data */ ECMA_FINALIZE (obj_expr_value); } - int_data_p->pos = (opcode_counter_t) (for_in_end_oc + 1u); + int_data_p->pos = (vm_instr_counter_t) (for_in_end_oc + 1u); ECMA_FINALIZE (expr_value); diff --git a/jerry-core/vm/opcodes-helpers-variables.cpp b/jerry-core/vm/opcodes-helpers-variables.cpp index 46fc698ff..3f79e556b 100644 --- a/jerry-core/vm/opcodes-helpers-variables.cpp +++ b/jerry-core/vm/opcodes-helpers-variables.cpp @@ -91,7 +91,7 @@ get_variable_value (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */ else { ecma_string_t var_name_string; - lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (var_idx, frame_ctx_p->opcodes_p, frame_ctx_p->pos); + lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (var_idx, frame_ctx_p->instrs_p, frame_ctx_p->pos); JERRY_ASSERT (lit_cp.packed_value != MEM_CP_NULL); ecma_new_ecma_string_on_stack_from_lit_cp (&var_name_string, lit_cp); @@ -125,7 +125,7 @@ get_variable_value (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */ */ ecma_completion_value_t set_variable_value (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */ - opcode_counter_t lit_oc, /**< opcode counter for literal */ + vm_instr_counter_t lit_oc, /**< instruction counter for literal */ idx_t var_idx, /**< variable identifier */ ecma_value_t value) /**< value to set */ { @@ -158,7 +158,7 @@ set_variable_value (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */ else { ecma_string_t var_name_string; - lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (var_idx, frame_ctx_p->opcodes_p, lit_oc); + lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (var_idx, frame_ctx_p->instrs_p, lit_oc); JERRY_ASSERT (lit_cp.packed_value != MEM_CP_NULL); ecma_new_ecma_string_on_stack_from_lit_cp (&var_name_string, lit_cp); diff --git a/jerry-core/vm/opcodes-native-call.cpp b/jerry-core/vm/opcodes-native-call.cpp index 4caa6d0f1..e9690cf7f 100644 --- a/jerry-core/vm/opcodes-native-call.cpp +++ b/jerry-core/vm/opcodes-native-call.cpp @@ -28,13 +28,13 @@ * 'Native call' opcode handler. */ ecma_completion_value_t -opfunc_native_call (opcode_t opdata, /**< operation data */ +opfunc_native_call (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.native_call.lhs; - const idx_t native_call_id_idx = opdata.data.native_call.name; - const idx_t args_number = opdata.data.native_call.arg_list; - const opcode_counter_t lit_oc = frame_ctx_p->pos; + const idx_t dst_var_idx = instr.data.native_call.lhs; + const idx_t native_call_id_idx = instr.data.native_call.name; + const idx_t args_number = instr.data.native_call.arg_list; + const vm_instr_counter_t lit_oc = frame_ctx_p->pos; JERRY_ASSERT (native_call_id_idx < OPCODE_NATIVE_CALL__COUNT); diff --git a/jerry-core/vm/opcodes-varg.cpp b/jerry-core/vm/opcodes-varg.cpp index 4bb681398..b43f97c5e 100644 --- a/jerry-core/vm/opcodes-varg.cpp +++ b/jerry-core/vm/opcodes-varg.cpp @@ -44,11 +44,11 @@ fill_varg_list (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */ if (ecma_is_completion_value_empty (evaluate_arg_completion)) { - opcode_t next_opcode = vm_get_opcode (frame_ctx_p->opcodes_p, frame_ctx_p->pos); - JERRY_ASSERT (next_opcode.op_idx == VM_OP_META); - JERRY_ASSERT (next_opcode.data.meta.type == OPCODE_META_TYPE_VARG); + vm_instr_t next_instr = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos); + JERRY_ASSERT (next_instr.op_idx == VM_OP_META); + JERRY_ASSERT (next_instr.data.meta.type == OPCODE_META_TYPE_VARG); - const idx_t varg_var_idx = next_opcode.data.meta.data_1; + const idx_t varg_var_idx = next_instr.data.meta.data_1; ecma_completion_value_t get_arg_completion = get_variable_value (frame_ctx_p, varg_var_idx, false); @@ -91,12 +91,12 @@ fill_params_list (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */ param_index < params_number; param_index++) { - opcode_t next_opcode = vm_get_opcode (frame_ctx_p->opcodes_p, frame_ctx_p->pos); - JERRY_ASSERT (next_opcode.op_idx == VM_OP_META); - JERRY_ASSERT (next_opcode.data.meta.type == OPCODE_META_TYPE_VARG); + vm_instr_t next_instr = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos); + JERRY_ASSERT (next_instr.op_idx == VM_OP_META); + JERRY_ASSERT (next_instr.data.meta.type == OPCODE_META_TYPE_VARG); - const lit_cpointer_t param_name_lit_idx = serializer_get_literal_cp_by_uid (next_opcode.data.meta.data_1, - frame_ctx_p->opcodes_p, + const lit_cpointer_t param_name_lit_idx = serializer_get_literal_cp_by_uid (next_instr.data.meta.data_1, + frame_ctx_p->instrs_p, frame_ctx_p->pos); params_names[param_index] = ecma_new_ecma_string_from_lit_cp (param_name_lit_idx); diff --git a/jerry-core/vm/opcodes.cpp b/jerry-core/vm/opcodes.cpp index 280f08571..4792fad8a 100644 --- a/jerry-core/vm/opcodes.cpp +++ b/jerry-core/vm/opcodes.cpp @@ -59,12 +59,12 @@ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_assignment (opcode_t opdata, /**< operation data */ +opfunc_assignment (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.assignment.var_left; - const opcode_arg_type_operand type_value_right = (opcode_arg_type_operand) opdata.data.assignment.type_value_right; - const idx_t src_val_descr = opdata.data.assignment.value_right; + const idx_t dst_var_idx = instr.data.assignment.var_left; + const opcode_arg_type_operand type_value_right = (opcode_arg_type_operand) instr.data.assignment.type_value_right; + const idx_t src_val_descr = instr.data.assignment.value_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -77,7 +77,7 @@ opfunc_assignment (opcode_t opdata, /**< operation data */ } else if (type_value_right == OPCODE_ARG_TYPE_STRING) { - lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (src_val_descr, frame_ctx_p->opcodes_p, frame_ctx_p->pos); + lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (src_val_descr, frame_ctx_p->instrs_p, frame_ctx_p->pos); ecma_string_t *string_p = ecma_new_ecma_string_from_lit_cp (lit_cp); ret_value = set_variable_value (frame_ctx_p, @@ -106,7 +106,7 @@ opfunc_assignment (opcode_t opdata, /**< operation data */ { ecma_number_t *num_p = frame_ctx_p->tmp_num_p; - lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (src_val_descr, frame_ctx_p->opcodes_p, frame_ctx_p->pos); + lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (src_val_descr, frame_ctx_p->instrs_p, frame_ctx_p->pos); literal_t lit = lit_get_literal_by_cp (lit_cp); JERRY_ASSERT (lit->get_type () == LIT_NUMBER_T); @@ -121,7 +121,7 @@ opfunc_assignment (opcode_t opdata, /**< operation data */ { ecma_number_t *num_p = frame_ctx_p->tmp_num_p; - lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (src_val_descr, frame_ctx_p->opcodes_p, frame_ctx_p->pos); + lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (src_val_descr, frame_ctx_p->instrs_p, frame_ctx_p->pos); literal_t lit = lit_get_literal_by_cp (lit_cp); JERRY_ASSERT (lit->get_type () == LIT_NUMBER_T); @@ -147,7 +147,7 @@ opfunc_assignment (opcode_t opdata, /**< operation data */ { #ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (src_val_descr, - frame_ctx_p->opcodes_p, + frame_ctx_p->instrs_p, frame_ctx_p->pos); ecma_string_t *string_p = ecma_new_ecma_string_from_lit_cp (lit_cp); @@ -230,11 +230,11 @@ opfunc_assignment (opcode_t opdata, /**< operation data */ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_pre_incr (opcode_t opdata, /**< operation data */ +opfunc_pre_incr (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.pre_incr.dst; - const idx_t incr_var_idx = opdata.data.pre_incr.var_right; + const idx_t dst_var_idx = instr.data.pre_incr.dst; + const idx_t incr_var_idx = instr.data.pre_incr.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -277,11 +277,11 @@ opfunc_pre_incr (opcode_t opdata, /**< operation data */ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_pre_decr (opcode_t opdata, /**< operation data */ +opfunc_pre_decr (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.pre_decr.dst; - const idx_t decr_var_idx = opdata.data.pre_decr.var_right; + const idx_t dst_var_idx = instr.data.pre_decr.dst; + const idx_t decr_var_idx = instr.data.pre_decr.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -324,11 +324,11 @@ opfunc_pre_decr (opcode_t opdata, /**< operation data */ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_post_incr (opcode_t opdata, /**< operation data */ +opfunc_post_incr (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.post_incr.dst; - const idx_t incr_var_idx = opdata.data.post_incr.var_right; + const idx_t dst_var_idx = instr.data.post_incr.dst; + const idx_t incr_var_idx = instr.data.post_incr.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -372,11 +372,11 @@ opfunc_post_incr (opcode_t opdata, /**< operation data */ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_post_decr (opcode_t opdata, /**< operation data */ +opfunc_post_decr (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.post_decr.dst; - const idx_t decr_var_idx = opdata.data.post_decr.var_right; + const idx_t dst_var_idx = instr.data.post_decr.dst; + const idx_t decr_var_idx = instr.data.post_decr.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -417,7 +417,7 @@ opfunc_post_decr (opcode_t opdata, /**< operation data */ * The opcode is meta-opcode that is not supposed to be executed. */ ecma_completion_value_t -opfunc_reg_var_decl (opcode_t opdata __attr_unused___, /**< operation data */ +opfunc_reg_var_decl (vm_instr_t instr __attr_unused___, /**< instruction */ vm_frame_ctx_t *frame_ctx_p __attr_unused___) /**< interpreter context */ { JERRY_UNREACHABLE (); @@ -433,11 +433,11 @@ opfunc_reg_var_decl (opcode_t opdata __attr_unused___, /**< operation data */ * However, ecma_free_completion_value may be called for it, but it is a no-op. */ ecma_completion_value_t -opfunc_var_decl (opcode_t opdata, /**< operation data */ +opfunc_var_decl (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (opdata.data.var_decl.variable_name, - frame_ctx_p->opcodes_p, + lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (instr.data.var_decl.variable_name, + frame_ctx_p->instrs_p, frame_ctx_p->pos); JERRY_ASSERT (lit_cp.packed_value != MEM_CP_NULL); @@ -485,11 +485,11 @@ function_declaration (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */ bool do_instantiate_arguments_object = true; const bool is_configurable_bindings = frame_ctx_p->is_eval_code; - const opcode_counter_t function_code_end_oc = (opcode_counter_t) ( - read_meta_opcode_counter (OPCODE_META_TYPE_FUNCTION_END, frame_ctx_p) + frame_ctx_p->pos); + const vm_instr_counter_t function_code_end_oc = (vm_instr_counter_t) ( + vm_read_instr_counter_from_meta (OPCODE_META_TYPE_FUNCTION_END, frame_ctx_p) + frame_ctx_p->pos); frame_ctx_p->pos++; - opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (frame_ctx_p->opcodes_p, frame_ctx_p->pos++); + opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (frame_ctx_p->instrs_p, frame_ctx_p->pos++); if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_STRICT) { @@ -508,7 +508,7 @@ function_declaration (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */ ecma_completion_value_t ret_value = ecma_op_function_declaration (frame_ctx_p->lex_env_p, function_name_string_p, - frame_ctx_p->opcodes_p, + frame_ctx_p->instrs_p, frame_ctx_p->pos, args_names, args_number, @@ -529,14 +529,14 @@ function_declaration (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */ * returned value must be freed with ecma_free_completion_value. */ ecma_completion_value_t -opfunc_func_decl_n (opcode_t opdata, /**< operation data */ +opfunc_func_decl_n (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t function_name_idx = opdata.data.func_decl_n.name_lit_idx; - const ecma_length_t params_number = opdata.data.func_decl_n.arg_list; + const idx_t function_name_idx = instr.data.func_decl_n.name_lit_idx; + const ecma_length_t params_number = instr.data.func_decl_n.arg_list; lit_cpointer_t function_name_lit_cp = serializer_get_literal_cp_by_uid (function_name_idx, - frame_ctx_p->opcodes_p, + frame_ctx_p->instrs_p, frame_ctx_p->pos); frame_ctx_p->pos++; @@ -571,21 +571,21 @@ opfunc_func_decl_n (opcode_t opdata, /**< operation data */ * returned value must be freed with ecma_free_completion_value. */ ecma_completion_value_t -opfunc_func_expr_n (opcode_t opdata, /**< operation data */ +opfunc_func_expr_n (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const opcode_counter_t lit_oc = frame_ctx_p->pos; + const vm_instr_counter_t lit_oc = frame_ctx_p->pos; frame_ctx_p->pos++; - const idx_t dst_var_idx = opdata.data.func_expr_n.lhs; - const idx_t function_name_lit_idx = opdata.data.func_expr_n.name_lit_idx; - const ecma_length_t params_number = opdata.data.func_expr_n.arg_list; + const idx_t dst_var_idx = instr.data.func_expr_n.lhs; + const idx_t function_name_lit_idx = instr.data.func_expr_n.name_lit_idx; + const ecma_length_t params_number = instr.data.func_expr_n.arg_list; const bool is_named_func_expr = (function_name_lit_idx != INVALID_VALUE); ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); - opcode_counter_t function_code_end_oc; + vm_instr_counter_t function_code_end_oc; MEM_DEFINE_LOCAL_ARRAY (params_names, params_number, ecma_string_t*); @@ -594,11 +594,11 @@ opfunc_func_expr_n (opcode_t opdata, /**< operation data */ bool is_strict = frame_ctx_p->is_strict; bool do_instantiate_arguments_object = true; - function_code_end_oc = (opcode_counter_t) (read_meta_opcode_counter (OPCODE_META_TYPE_FUNCTION_END, - frame_ctx_p) + frame_ctx_p->pos); + function_code_end_oc = (vm_instr_counter_t) (vm_read_instr_counter_from_meta (OPCODE_META_TYPE_FUNCTION_END, + frame_ctx_p) + frame_ctx_p->pos); frame_ctx_p->pos++; - opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (frame_ctx_p->opcodes_p, + opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (frame_ctx_p->instrs_p, frame_ctx_p->pos++); if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_STRICT) @@ -621,7 +621,7 @@ opfunc_func_expr_n (opcode_t opdata, /**< operation data */ scope_p = ecma_create_decl_lex_env (frame_ctx_p->lex_env_p); lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (function_name_lit_idx, - frame_ctx_p->opcodes_p, + frame_ctx_p->instrs_p, lit_oc); JERRY_ASSERT (lit_cp.packed_value != MEM_CP_NULL); @@ -639,7 +639,7 @@ opfunc_func_expr_n (opcode_t opdata, /**< operation data */ scope_p, is_strict, do_instantiate_arguments_object, - frame_ctx_p->opcodes_p, + frame_ctx_p->instrs_p, frame_ctx_p->pos); ret_value = set_variable_value (frame_ctx_p, lit_oc, @@ -682,8 +682,8 @@ opfunc_func_expr_n (opcode_t opdata, /**< operation data */ */ static ecma_value_t vm_helper_call_get_call_flags_and_this_arg (vm_frame_ctx_t *int_data_p, /**< interpreter context */ - opcode_counter_t var_idx_lit_oc, /**< opcode counter, corresponding to - * instruction with function_var_idx */ + vm_instr_counter_t var_idx_lit_oc, /**< instruction counter of instruction + with var_idx */ idx_t var_idx, /**< idx, used to retrieve the called function object */ opcode_call_flags_t *out_flags_p) /**< out: call flags */ { @@ -694,7 +694,7 @@ vm_helper_call_get_call_flags_and_this_arg (vm_frame_ctx_t *int_data_p, /**< int opcode_call_flags_t call_flags = OPCODE_CALL_FLAGS__EMPTY; idx_t this_arg_var_idx = INVALID_VALUE; - opcode_t next_opcode = vm_get_opcode (int_data_p->opcodes_p, int_data_p->pos); + vm_instr_t next_opcode = vm_get_instr (int_data_p->instrs_p, int_data_p->pos); if (next_opcode.op_idx == VM_OP_META && next_opcode.data.meta.type == OPCODE_META_TYPE_CALL_SITE_INFO) { @@ -753,7 +753,7 @@ vm_helper_call_get_call_flags_and_this_arg (vm_frame_ctx_t *int_data_p, /**< int /* 6.b.i */ ecma_string_t var_name_string; - lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (var_idx, int_data_p->opcodes_p, var_idx_lit_oc); + lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (var_idx, int_data_p->instrs_p, var_idx_lit_oc); ecma_new_ecma_string_on_stack_from_lit_cp (&var_name_string, lit_cp); ecma_object_t *ref_base_lex_env_p = ecma_op_resolve_reference_base (int_data_p->lex_env_p, @@ -792,13 +792,13 @@ vm_helper_call_get_call_flags_and_this_arg (vm_frame_ctx_t *int_data_p, /**< int * Returned value must be freed with ecma_free_completion_value. */ ecma_completion_value_t -opfunc_call_n (opcode_t opdata, /**< operation data */ +opfunc_call_n (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t lhs_var_idx = opdata.data.call_n.lhs; - const idx_t function_var_idx = opdata.data.call_n.function_var_idx; - const idx_t args_number_idx = opdata.data.call_n.arg_list; - const opcode_counter_t lit_oc = frame_ctx_p->pos; + const idx_t lhs_var_idx = instr.data.call_n.lhs; + const idx_t function_var_idx = instr.data.call_n.function_var_idx; + const idx_t args_number_idx = instr.data.call_n.arg_list; + const vm_instr_counter_t lit_oc = frame_ctx_p->pos; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -895,13 +895,13 @@ opfunc_call_n (opcode_t opdata, /**< operation data */ * Returned value must be freed with ecma_free_completion_value. */ ecma_completion_value_t -opfunc_construct_n (opcode_t opdata, /**< operation data */ +opfunc_construct_n (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t lhs_var_idx = opdata.data.construct_n.lhs; - const idx_t constructor_name_lit_idx = opdata.data.construct_n.name_lit_idx; - const idx_t args_number = opdata.data.construct_n.arg_list; - const opcode_counter_t lit_oc = frame_ctx_p->pos; + const idx_t lhs_var_idx = instr.data.construct_n.lhs; + const idx_t constructor_name_lit_idx = instr.data.construct_n.name_lit_idx; + const idx_t args_number = instr.data.construct_n.arg_list; + const vm_instr_counter_t lit_oc = frame_ctx_p->pos; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); ECMA_TRY_CATCH (constructor_value, @@ -972,12 +972,12 @@ opfunc_construct_n (opcode_t opdata, /**< operation data */ * Returned value must be freed with ecma_free_completion_value. */ ecma_completion_value_t -opfunc_array_decl (opcode_t opdata, /**< operation data */ +opfunc_array_decl (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t lhs_var_idx = opdata.data.array_decl.lhs; - const idx_t args_number = opdata.data.array_decl.list; - const opcode_counter_t lit_oc = frame_ctx_p->pos; + const idx_t lhs_var_idx = instr.data.array_decl.lhs; + const idx_t args_number = instr.data.array_decl.list; + const vm_instr_counter_t lit_oc = frame_ctx_p->pos; frame_ctx_p->pos++; @@ -1035,12 +1035,12 @@ opfunc_array_decl (opcode_t opdata, /**< operation data */ * Returned value must be freed with ecma_free_completion_value. */ ecma_completion_value_t -opfunc_obj_decl (opcode_t opdata, /**< operation data */ +opfunc_obj_decl (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t lhs_var_idx = opdata.data.obj_decl.lhs; - const idx_t args_number = opdata.data.obj_decl.list; - const opcode_counter_t obj_lit_oc = frame_ctx_p->pos; + const idx_t lhs_var_idx = instr.data.obj_decl.lhs; + const idx_t args_number = instr.data.obj_decl.list; + const vm_instr_counter_t obj_lit_oc = frame_ctx_p->pos; frame_ctx_p->pos++; @@ -1056,7 +1056,7 @@ opfunc_obj_decl (opcode_t opdata, /**< operation data */ if (ecma_is_completion_value_empty (evaluate_prop_completion)) { - opcode_t next_opcode = vm_get_opcode (frame_ctx_p->opcodes_p, frame_ctx_p->pos); + vm_instr_t next_opcode = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos); JERRY_ASSERT (next_opcode.op_idx == VM_OP_META); const opcode_meta_type type = (opcode_meta_type) next_opcode.data.meta.type; @@ -1191,7 +1191,7 @@ opfunc_obj_decl (opcode_t opdata, /**< operation data */ * However, ecma_free_completion_value may be called for it, but it is a no-op. */ ecma_completion_value_t -opfunc_ret (opcode_t opdata __attr_unused___, /**< operation data */ +opfunc_ret (vm_instr_t instr __attr_unused___, /**< instruction */ vm_frame_ctx_t *frame_ctx_p __attr_unused___) /**< interpreter context */ { return ecma_make_return_completion_value (ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED)); @@ -1207,12 +1207,12 @@ opfunc_ret (opcode_t opdata __attr_unused___, /**< operation data */ * However, ecma_free_completion_value may be called for it, but it is a no-op. */ ecma_completion_value_t -opfunc_retval (opcode_t opdata __attr_unused___, /**< operation data */ +opfunc_retval (vm_instr_t instr __attr_unused___, /**< instruction */ vm_frame_ctx_t *frame_ctx_p __attr_unused___) /**< interpreter context */ { ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); - ECMA_TRY_CATCH (expr_val, get_variable_value (frame_ctx_p, opdata.data.retval.ret_value, false), ret_value); + ECMA_TRY_CATCH (expr_val, get_variable_value (frame_ctx_p, instr.data.retval.ret_value, false), ret_value); ret_value = ecma_make_return_completion_value (ecma_copy_value (expr_val, true)); @@ -1231,12 +1231,12 @@ opfunc_retval (opcode_t opdata __attr_unused___, /**< operation data */ * returned value must be freed with ecma_free_completion_value. */ ecma_completion_value_t -opfunc_prop_getter (opcode_t opdata __attr_unused___, /**< operation data */ +opfunc_prop_getter (vm_instr_t instr __attr_unused___, /**< instruction */ vm_frame_ctx_t *frame_ctx_p __attr_unused___) /**< interpreter context */ { - const idx_t lhs_var_idx = opdata.data.prop_getter.lhs; - const idx_t base_var_idx = opdata.data.prop_getter.obj; - const idx_t prop_name_var_idx = opdata.data.prop_getter.prop; + const idx_t lhs_var_idx = instr.data.prop_getter.lhs; + const idx_t base_var_idx = instr.data.prop_getter.obj; + const idx_t prop_name_var_idx = instr.data.prop_getter.prop; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -1284,12 +1284,12 @@ opfunc_prop_getter (opcode_t opdata __attr_unused___, /**< operation data */ * returned value must be freed with ecma_free_completion_value. */ ecma_completion_value_t -opfunc_prop_setter (opcode_t opdata __attr_unused___, /**< operation data */ +opfunc_prop_setter (vm_instr_t instr __attr_unused___, /**< instruction */ vm_frame_ctx_t *frame_ctx_p __attr_unused___) /**< interpreter context */ { - const idx_t base_var_idx = opdata.data.prop_setter.obj; - const idx_t prop_name_var_idx = opdata.data.prop_setter.prop; - const idx_t rhs_var_idx = opdata.data.prop_setter.rhs; + const idx_t base_var_idx = instr.data.prop_setter.obj; + const idx_t prop_name_var_idx = instr.data.prop_setter.prop; + const idx_t rhs_var_idx = instr.data.prop_setter.rhs; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -1336,11 +1336,11 @@ opfunc_prop_setter (opcode_t opdata __attr_unused___, /**< operation data */ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_logical_not (opcode_t opdata, /**< operation data */ +opfunc_logical_not (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.logical_not.dst; - const idx_t right_var_idx = opdata.data.logical_not.var_right; + const idx_t dst_var_idx = instr.data.logical_not.dst; + const idx_t right_var_idx = instr.data.logical_not.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -1374,11 +1374,11 @@ opfunc_logical_not (opcode_t opdata, /**< operation data */ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_this_binding (opcode_t opdata, /**< operation data */ +opfunc_this_binding (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.this_binding.lhs; - const opcode_counter_t lit_oc = frame_ctx_p->pos; + const idx_t dst_var_idx = instr.data.this_binding.lhs; + const vm_instr_counter_t lit_oc = frame_ctx_p->pos; frame_ctx_p->pos++; @@ -1400,14 +1400,14 @@ opfunc_this_binding (opcode_t opdata, /**< operation data */ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_with (opcode_t opdata, /**< operation data */ +opfunc_with (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t expr_var_idx = opdata.data.with.expr; - const idx_t block_end_oc_idx_1 = opdata.data.with.oc_idx_1; - const idx_t block_end_oc_idx_2 = opdata.data.with.oc_idx_2; - const opcode_counter_t with_end_oc = (opcode_counter_t) ( - calc_opcode_counter_from_idx_idx (block_end_oc_idx_1, block_end_oc_idx_2) + frame_ctx_p->pos); + const idx_t expr_var_idx = instr.data.with.expr; + const idx_t block_end_oc_idx_1 = instr.data.with.oc_idx_1; + const idx_t block_end_oc_idx_2 = instr.data.with.oc_idx_2; + const vm_instr_counter_t with_end_oc = (vm_instr_counter_t) ( + vm_calc_instr_counter_from_idx_idx (block_end_oc_idx_1, block_end_oc_idx_2) + frame_ctx_p->pos); ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -1431,7 +1431,7 @@ opfunc_with (opcode_t opdata, /**< operation data */ frame_ctx_p->lex_env_p = new_env_p; #ifndef JERRY_NDEBUG - opcode_t meta_opcode = vm_get_opcode (frame_ctx_p->opcodes_p, with_end_oc); + vm_instr_t meta_opcode = vm_get_instr (frame_ctx_p->instrs_p, with_end_oc); JERRY_ASSERT (meta_opcode.op_idx == VM_OP_META); JERRY_ASSERT (meta_opcode.data.meta.type == OPCODE_META_TYPE_END_WITH); #endif /* !JERRY_NDEBUG */ @@ -1474,10 +1474,10 @@ opfunc_with (opcode_t opdata, /**< operation data */ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_throw_value (opcode_t opdata, /**< operation data */ +opfunc_throw_value (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t var_idx = opdata.data.throw_value.var; + const idx_t var_idx = instr.data.throw_value.var; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -1520,7 +1520,7 @@ evaluate_arg_for_typeof (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context * } else { - lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (var_idx, frame_ctx_p->opcodes_p, frame_ctx_p->pos); + lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (var_idx, frame_ctx_p->instrs_p, frame_ctx_p->pos); JERRY_ASSERT (lit_cp.packed_value != MEM_CP_NULL); ecma_string_t *var_name_string_p = ecma_new_ecma_string_from_lit_cp (lit_cp); @@ -1553,11 +1553,11 @@ evaluate_arg_for_typeof (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context * * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_typeof (opcode_t opdata, /**< operation data */ +opfunc_typeof (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.typeof.lhs; - const idx_t obj_var_idx = opdata.data.typeof.obj; + const idx_t dst_var_idx = instr.data.typeof.lhs; + const idx_t obj_var_idx = instr.data.typeof.obj; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -1625,18 +1625,18 @@ opfunc_typeof (opcode_t opdata, /**< operation data */ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_delete_var (opcode_t opdata, /**< operation data */ +opfunc_delete_var (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.delete_var.lhs; - const idx_t name_lit_idx = opdata.data.delete_var.name; - const opcode_counter_t lit_oc = frame_ctx_p->pos; + const idx_t dst_var_idx = instr.data.delete_var.lhs; + const idx_t name_lit_idx = instr.data.delete_var.name; + const vm_instr_counter_t lit_oc = frame_ctx_p->pos; frame_ctx_p->pos++; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); - lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (name_lit_idx, frame_ctx_p->opcodes_p, lit_oc); + lit_cpointer_t lit_cp = serializer_get_literal_cp_by_uid (name_lit_idx, frame_ctx_p->instrs_p, lit_oc); JERRY_ASSERT (lit_cp.packed_value != MEM_CP_NULL); ecma_string_t *name_string_p = ecma_new_ecma_string_from_lit_cp (lit_cp); @@ -1692,12 +1692,12 @@ opfunc_delete_var (opcode_t opdata, /**< operation data */ * Returned value must be freed with ecma_free_completion_value */ ecma_completion_value_t -opfunc_delete_prop (opcode_t opdata, /**< operation data */ +opfunc_delete_prop (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = opdata.data.delete_prop.lhs; - const idx_t base_var_idx = opdata.data.delete_prop.base; - const idx_t name_var_idx = opdata.data.delete_prop.name; + const idx_t dst_var_idx = instr.data.delete_prop.lhs; + const idx_t base_var_idx = instr.data.delete_prop.base; + const idx_t name_var_idx = instr.data.delete_prop.name; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -1763,10 +1763,10 @@ opfunc_delete_prop (opcode_t opdata, /**< operation data */ * @return implementation-defined meta completion value */ ecma_completion_value_t -opfunc_meta (opcode_t opdata, /**< operation data */ +opfunc_meta (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p __attr_unused___) /**< interpreter context */ { - const opcode_meta_type type = (opcode_meta_type) opdata.data.meta.type; + const opcode_meta_type type = (opcode_meta_type) instr.data.meta.type; switch (type) { @@ -1797,73 +1797,73 @@ opfunc_meta (opcode_t opdata, /**< operation data */ } /* opfunc_meta */ /** - * Calculate opcode counter from 'meta' opcode's data arguments. + * Calculate instruction counter from 'meta' instruction's data arguments. * - * @return opcode counter + * @return instruction counter */ -opcode_counter_t -calc_opcode_counter_from_idx_idx (const idx_t oc_idx_1, /**< first idx */ - const idx_t oc_idx_2) /**< second idx */ +vm_instr_counter_t +vm_calc_instr_counter_from_idx_idx (const idx_t oc_idx_1, /**< first idx */ + const idx_t oc_idx_2) /**< second idx */ { - opcode_counter_t counter; + vm_instr_counter_t counter; counter = oc_idx_1; - counter = (opcode_counter_t) (counter << (sizeof (idx_t) * JERRY_BITSINBYTE)); - counter = (opcode_counter_t) (counter | oc_idx_2); + counter = (vm_instr_counter_t) (counter << (sizeof (idx_t) * JERRY_BITSINBYTE)); + counter = (vm_instr_counter_t) (counter | oc_idx_2); return counter; -} /* calc_meta_opcode_counter_from_meta_data */ +} /* vm_calc_instr_counter_from_idx_idx */ /** - * Read opcode counter from current opcode, - * that should be 'meta' opcode of type 'opcode counter'. + * Read instruction counter from current instruction, + * that should be 'meta' instruction of specified type. */ -opcode_counter_t -read_meta_opcode_counter (opcode_meta_type expected_type, /**< expected type of meta opcode */ - vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ +vm_instr_counter_t +vm_read_instr_counter_from_meta (opcode_meta_type expected_type, /**< expected type of meta instruction */ + vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - opcode_t meta_opcode = vm_get_opcode (frame_ctx_p->opcodes_p, frame_ctx_p->pos); + vm_instr_t meta_opcode = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos); JERRY_ASSERT (meta_opcode.data.meta.type == expected_type); const idx_t data_1 = meta_opcode.data.meta.data_1; const idx_t data_2 = meta_opcode.data.meta.data_2; - return calc_opcode_counter_from_idx_idx (data_1, data_2); -} /* read_meta_opcode_counter */ + return vm_calc_instr_counter_from_idx_idx (data_1, data_2); +} /* vm_read_instr_counter_from_meta */ #define VM_OP_0(opcode_name, opcode_name_uppercase) \ - opcode_t getop_##opcode_name (void) \ + vm_instr_t getop_##opcode_name (void) \ { \ - opcode_t opdata; \ - opdata.op_idx = VM_OP_##opcode_name_uppercase; \ - return opdata; \ + vm_instr_t instr; \ + instr.op_idx = VM_OP_##opcode_name_uppercase; \ + return instr; \ } #define VM_OP_1(opcode_name, opcode_name_uppercase, arg1, arg1_type) \ - opcode_t getop_##opcode_name (idx_t arg1_v) \ + vm_instr_t getop_##opcode_name (idx_t arg1_v) \ { \ - opcode_t opdata; \ - opdata.op_idx = VM_OP_##opcode_name_uppercase; \ - opdata.data.opcode_name.arg1 = arg1_v; \ - return opdata; \ + vm_instr_t instr; \ + instr.op_idx = VM_OP_##opcode_name_uppercase; \ + instr.data.opcode_name.arg1 = arg1_v; \ + return instr; \ } #define VM_OP_2(opcode_name, opcode_name_uppercase, arg1, arg1_type, arg2, arg2_type) \ - opcode_t getop_##opcode_name (idx_t arg1_v, idx_t arg2_v) \ + vm_instr_t getop_##opcode_name (idx_t arg1_v, idx_t arg2_v) \ { \ - opcode_t opdata; \ - opdata.op_idx = VM_OP_##opcode_name_uppercase; \ - opdata.data.opcode_name.arg1 = arg1_v; \ - opdata.data.opcode_name.arg2 = arg2_v; \ - return opdata; \ + vm_instr_t instr; \ + instr.op_idx = VM_OP_##opcode_name_uppercase; \ + instr.data.opcode_name.arg1 = arg1_v; \ + instr.data.opcode_name.arg2 = arg2_v; \ + return instr; \ } #define VM_OP_3(opcode_name, opcode_name_uppercase, arg1, arg1_type, arg2, arg2_type, arg3, arg3_type) \ - opcode_t getop_##opcode_name (idx_t arg1_v, idx_t arg2_v, idx_t arg3_v) \ + vm_instr_t getop_##opcode_name (idx_t arg1_v, idx_t arg2_v, idx_t arg3_v) \ { \ - opcode_t opdata; \ - opdata.op_idx = VM_OP_##opcode_name_uppercase; \ - opdata.data.opcode_name.arg1 = arg1_v; \ - opdata.data.opcode_name.arg2 = arg2_v; \ - opdata.data.opcode_name.arg3 = arg3_v; \ - return opdata; \ + vm_instr_t instr; \ + instr.op_idx = VM_OP_##opcode_name_uppercase; \ + instr.data.opcode_name.arg1 = arg1_v; \ + instr.data.opcode_name.arg2 = arg2_v; \ + instr.data.opcode_name.arg3 = arg3_v; \ + return instr; \ } #include "vm-opcodes.inc.h" diff --git a/jerry-core/vm/opcodes.h b/jerry-core/vm/opcodes.h index b3d867c97..7c6906867 100644 --- a/jerry-core/vm/opcodes.h +++ b/jerry-core/vm/opcodes.h @@ -35,8 +35,15 @@ #define OP_3(action, name, field1, field2, field3) \ __##action (name, field1, field2, field3) -typedef uint16_t opcode_counter_t; /** opcode counters */ -typedef uint8_t idx_t; /** index values */ +/** + * Instruction counter / position + */ +typedef uint16_t vm_instr_counter_t; + +/** + * Opcode / argument value in an instruction + */ +typedef uint8_t idx_t; /** * Descriptor of assignment's second argument @@ -139,17 +146,17 @@ typedef enum } vm_op_arg_type_t; /** - * Forward declaration of opcode structure + * Forward declaration of instruction structure */ -struct opcode_t; +struct vm_instr_t; /** * Context of interpreter, related to a JS stack frame */ typedef struct { - const opcode_t *opcodes_p; /**< pointer to array containing currently executed bytecode */ - opcode_counter_t pos; /**< current opcode to execute */ + const vm_instr_t *instrs_p; /**< currently executed byte-code array */ + vm_instr_counter_t pos; /**< current position instruction to execute */ ecma_value_t this_binding; /**< this binding for current context */ ecma_object_t *lex_env_p; /**< current lexical environment */ bool is_strict; /**< is current code execution mode strict? */ @@ -178,20 +185,20 @@ typedef struct * Note: * Run scope represents boundaries of byte-code block to run. * - * Jumps within of the current run scope are performed by just changing opcode counter, + * Jumps within of the current run scope are performed by just changing instruction counter, * and outside of the run scope - by returning corresponding ECMA_COMPLETION_TYPE_BREAK_CONTINUE * completion value. */ typedef struct { - const opcode_counter_t start_oc; /**< opcode counter of the first instruction of the scope */ - const opcode_counter_t end_oc; /**< opcode counter of the last instruction of the scope */ + const vm_instr_counter_t start_oc; /**< instruction counter of the first instruction of the scope */ + const vm_instr_counter_t end_oc; /**< instruction counter of the last instruction of the scope */ } vm_run_scope_t; -opcode_counter_t calc_opcode_counter_from_idx_idx (const idx_t oc_idx_1, const idx_t oc_idx_2); -opcode_counter_t read_meta_opcode_counter (opcode_meta_type expected_type, vm_frame_ctx_t *frame_ctx_p); +vm_instr_counter_t vm_calc_instr_counter_from_idx_idx (const idx_t oc_idx_1, const idx_t oc_idx_2); +vm_instr_counter_t vm_read_instr_counter_from_meta (opcode_meta_type expected_type, vm_frame_ctx_t *int_data); -typedef struct opcode_t +typedef struct vm_instr_t { idx_t op_idx; union @@ -218,9 +225,9 @@ typedef struct opcode_t #include "vm-opcodes.inc.h" } data; -} opcode_t; +} vm_instr_t; -enum __opcode_idx +typedef enum { #define VM_OP_0(opcode_name, opcode_name_uppercase) \ VM_OP_ ## opcode_name_uppercase, @@ -234,29 +241,29 @@ enum __opcode_idx #include "vm-opcodes.inc.h" VM_OP__COUNT /**< number of opcodes */ -}; +} vm_op_t; #define VM_OP_0(opcode_name, opcode_name_uppercase) \ - ecma_completion_value_t opfunc_##opcode_name (opcode_t, vm_frame_ctx_t*); + ecma_completion_value_t opfunc_##opcode_name (vm_instr_t, vm_frame_ctx_t*); #define VM_OP_1(opcode_name, opcode_name_uppercase, arg1, arg1_type) \ - ecma_completion_value_t opfunc_##opcode_name (opcode_t, vm_frame_ctx_t*); + ecma_completion_value_t opfunc_##opcode_name (vm_instr_t, vm_frame_ctx_t*); #define VM_OP_2(opcode_name, opcode_name_uppercase, arg1, arg1_type, arg2, arg2_type) \ - ecma_completion_value_t opfunc_##opcode_name (opcode_t, vm_frame_ctx_t*); + ecma_completion_value_t opfunc_##opcode_name (vm_instr_t, vm_frame_ctx_t*); #define VM_OP_3(opcode_name, opcode_name_uppercase, arg1, arg1_type, arg2, arg2_type, arg3, arg3_type) \ - ecma_completion_value_t opfunc_##opcode_name (opcode_t, vm_frame_ctx_t*); + ecma_completion_value_t opfunc_##opcode_name (vm_instr_t, vm_frame_ctx_t*); #include "vm-opcodes.inc.h" -typedef ecma_completion_value_t (*opfunc) (opcode_t, vm_frame_ctx_t *); +typedef ecma_completion_value_t (*opfunc) (vm_instr_t, vm_frame_ctx_t *); #define VM_OP_0(opcode_name, opcode_name_uppercase) \ - opcode_t getop_##opcode_name (void); + vm_instr_t getop_##opcode_name (void); #define VM_OP_1(opcode_name, opcode_name_uppercase, arg1, arg1_type) \ - opcode_t getop_##opcode_name (idx_t); + vm_instr_t getop_##opcode_name (idx_t); #define VM_OP_2(opcode_name, opcode_name_uppercase, arg1, arg1_type, arg2, arg2_type) \ - opcode_t getop_##opcode_name (idx_t, idx_t); + vm_instr_t getop_##opcode_name (idx_t, idx_t); #define VM_OP_3(opcode_name, opcode_name_uppercase, arg1, arg1_type, arg2, arg2_type, arg3, arg3_type) \ - opcode_t getop_##opcode_name (idx_t, idx_t, idx_t); + vm_instr_t getop_##opcode_name (idx_t, idx_t, idx_t); #include "vm-opcodes.inc.h" @@ -264,6 +271,6 @@ typedef ecma_completion_value_t (*opfunc) (opcode_t, vm_frame_ctx_t *); typedef struct { uint8_t uids[4]; -} raw_opcode; +} raw_instr; #endif /* OPCODES_H */ diff --git a/jerry-core/vm/pretty-printer.cpp b/jerry-core/vm/pretty-printer.cpp index 3bd207b7b..955b1757b 100644 --- a/jerry-core/vm/pretty-printer.cpp +++ b/jerry-core/vm/pretty-printer.cpp @@ -94,9 +94,9 @@ tmp_id_to_str (idx_t id) } static const char * -var_to_str (opcode_t opcode, lit_cpointer_t lit_ids[], opcode_counter_t oc, uint8_t current_arg) +var_to_str (vm_instr_t instr, lit_cpointer_t lit_ids[], vm_instr_counter_t oc, uint8_t current_arg) { - raw_opcode raw = *(raw_opcode*) &opcode; + raw_instr raw = *(raw_instr*) &instr; if (raw.uids[current_arg] == LITERAL_TO_REWRITE) { if (lit_ids == NULL) @@ -117,7 +117,7 @@ var_to_str (opcode_t opcode, lit_cpointer_t lit_ids[], opcode_counter_t oc, uint } static void -pp_printf (const char *format, opcode_t opcode, lit_cpointer_t lit_ids[], opcode_counter_t oc, uint8_t start_arg) +pp_printf (const char *format, vm_instr_t instr, lit_cpointer_t lit_ids[], vm_instr_counter_t oc, uint8_t start_arg) { uint8_t current_arg = start_arg; JERRY_ASSERT (current_arg <= 3); @@ -136,14 +136,14 @@ pp_printf (const char *format, opcode_t opcode, lit_cpointer_t lit_ids[], opcode case 'd': { JERRY_ASSERT (current_arg <= 3); - raw_opcode raw = *(raw_opcode*) &opcode; + raw_instr raw = *(raw_instr*) &instr; printf ("%d", raw.uids[current_arg]); break; } case 's': { JERRY_ASSERT (current_arg <= 3); - printf ("%s", var_to_str (opcode, lit_ids, oc, current_arg)); + printf ("%s", var_to_str (instr, lit_ids, oc, current_arg)); break; } default: @@ -160,22 +160,22 @@ pp_printf (const char *format, opcode_t opcode, lit_cpointer_t lit_ids[], opcode #define PP_OP(op_name, format) \ case op_name: pp_printf (format, opm.op, opm.lit_id, oc, 1); break; #define VAR(i) var_to_str (opm.op, opm.lit_id, oc, i) -#define OC(i, j) __extension__({ raw_opcode* raw = (raw_opcode *) &opm.op; \ - calc_opcode_counter_from_idx_idx (raw->uids[i], raw->uids[j]); }) +#define OC(i, j) __extension__({ raw_instr* raw = (raw_instr *) &opm.op; \ + vm_calc_instr_counter_from_idx_idx (raw->uids[i], raw->uids[j]); }) static int vargs_num = 0; static int seen_vargs = 0; static void -dump_asm (opcode_counter_t oc, opcode_t opcode) +dump_asm (vm_instr_counter_t oc, vm_instr_t instr) { uint8_t i = 0; - uint8_t opcode_id = opcode.op_idx; + uint8_t opcode_id = instr.op_idx; printf ("%3d: %20s ", oc, opcode_names[opcode_id]); for (i = 1; i < opcode_sizes[opcode_id]; i++) { - printf ("%4d ", ((raw_opcode *) &opcode)->uids[i]); + printf ("%4d ", ((raw_instr *) &instr)->uids[i]); } for (; i < 4; i++) @@ -185,8 +185,8 @@ dump_asm (opcode_counter_t oc, opcode_t opcode) } void -pp_op_meta (const opcode_t *opcodes_p, - opcode_counter_t oc, +pp_op_meta (const vm_instr_t *instrs_p, + vm_instr_counter_t oc, op_meta opm, bool rewrite) { @@ -397,11 +397,11 @@ pp_op_meta (const opcode_t *opcodes_p, if (seen_vargs == vargs_num) { bool found = false; - opcode_counter_t start = oc; + vm_instr_counter_t start = oc; while ((int16_t) start >= 0 && !found) { start--; - switch (serializer_get_opcode (opcodes_p, start).op_idx) + switch (serializer_get_instr (instrs_p, start).op_idx) { case VM_OP_CALL_N: case VM_OP_NATIVE_CALL: @@ -416,7 +416,7 @@ pp_op_meta (const opcode_t *opcodes_p, } } } - opcode_t start_op = serializer_get_opcode (opcodes_p, start); + vm_instr_t start_op = serializer_get_instr (instrs_p, start); switch (start_op.op_idx) { case VM_OP_CALL_N: @@ -476,9 +476,9 @@ pp_op_meta (const opcode_t *opcodes_p, JERRY_UNREACHABLE (); } } - for (opcode_counter_t counter = start; counter <= oc; counter++) + for (vm_instr_counter_t counter = start; counter <= oc; counter++) { - opcode_t meta_op = serializer_get_opcode (opcodes_p, counter); + vm_instr_t meta_op = serializer_get_instr (instrs_p, counter); switch (meta_op.op_idx) { diff --git a/jerry-core/vm/pretty-printer.h b/jerry-core/vm/pretty-printer.h index 596fc76e1..c6aa8d15e 100644 --- a/jerry-core/vm/pretty-printer.h +++ b/jerry-core/vm/pretty-printer.h @@ -21,8 +21,7 @@ #include "vm.h" #include "scopes-tree.h" -void pp_opcode (opcode_counter_t, opcode_t, bool); -void pp_op_meta (const opcode_t*, opcode_counter_t, op_meta, bool); +void pp_op_meta (const vm_instr_t*, vm_instr_counter_t, op_meta, bool); #endif // JERRY_ENABLE_PRETTY_PRINTER #endif // PRETTY_PRINTER diff --git a/jerry-core/vm/vm-opcodes.inc.h b/jerry-core/vm/vm-opcodes.inc.h index c087f7bc4..a99be51cf 100644 --- a/jerry-core/vm/vm-opcodes.inc.h +++ b/jerry-core/vm/vm-opcodes.inc.h @@ -264,36 +264,36 @@ VM_OP_2 (unary_plus, UNARY_PLUS, var, VM_OP_ARG_TYPE_VARIABLE) VM_OP_2 (jmp_up, JMP_UP, - opcode_1, VM_OP_ARG_TYPE_INTEGER_CONST, - opcode_2, VM_OP_ARG_TYPE_INTEGER_CONST) + oc_idx_1, VM_OP_ARG_TYPE_INTEGER_CONST, + oc_idx_2, VM_OP_ARG_TYPE_INTEGER_CONST) VM_OP_2 (jmp_down, JMP_DOWN, - opcode_1, VM_OP_ARG_TYPE_INTEGER_CONST, - opcode_2, VM_OP_ARG_TYPE_INTEGER_CONST) + oc_idx_1, VM_OP_ARG_TYPE_INTEGER_CONST, + oc_idx_2, VM_OP_ARG_TYPE_INTEGER_CONST) VM_OP_2 (jmp_break_continue, JMP_BREAK_CONTINUE, - opcode_1, VM_OP_ARG_TYPE_INTEGER_CONST, - opcode_2, VM_OP_ARG_TYPE_INTEGER_CONST) + oc_idx_1, VM_OP_ARG_TYPE_INTEGER_CONST, + oc_idx_2, VM_OP_ARG_TYPE_INTEGER_CONST) VM_OP_3 (is_true_jmp_up, IS_TRUE_JMP_UP, value, VM_OP_ARG_TYPE_VARIABLE, - opcode_1, VM_OP_ARG_TYPE_INTEGER_CONST, - opcode_2, VM_OP_ARG_TYPE_INTEGER_CONST) + oc_idx_1, VM_OP_ARG_TYPE_INTEGER_CONST, + oc_idx_2, VM_OP_ARG_TYPE_INTEGER_CONST) VM_OP_3 (is_true_jmp_down, IS_TRUE_JMP_DOWN, value, VM_OP_ARG_TYPE_VARIABLE, - opcode_1, VM_OP_ARG_TYPE_INTEGER_CONST, - opcode_2, VM_OP_ARG_TYPE_INTEGER_CONST) + oc_idx_1, VM_OP_ARG_TYPE_INTEGER_CONST, + oc_idx_2, VM_OP_ARG_TYPE_INTEGER_CONST) VM_OP_3 (is_false_jmp_up, IS_FALSE_JMP_UP, value, VM_OP_ARG_TYPE_VARIABLE, - opcode_1, VM_OP_ARG_TYPE_INTEGER_CONST, - opcode_2, VM_OP_ARG_TYPE_INTEGER_CONST) + oc_idx_1, VM_OP_ARG_TYPE_INTEGER_CONST, + oc_idx_2, VM_OP_ARG_TYPE_INTEGER_CONST) VM_OP_3 (is_false_jmp_down, IS_FALSE_JMP_DOWN, value, VM_OP_ARG_TYPE_VARIABLE, - opcode_1, VM_OP_ARG_TYPE_INTEGER_CONST, - opcode_2, VM_OP_ARG_TYPE_INTEGER_CONST) + oc_idx_1, VM_OP_ARG_TYPE_INTEGER_CONST, + oc_idx_2, VM_OP_ARG_TYPE_INTEGER_CONST) VM_OP_1 (var_decl, VAR_DECL, variable_name, VM_OP_ARG_TYPE_STRING) diff --git a/jerry-core/vm/vm.cpp b/jerry-core/vm/vm.cpp index 0ee2bc8d6..00683f16e 100644 --- a/jerry-core/vm/vm.cpp +++ b/jerry-core/vm/vm.cpp @@ -44,9 +44,9 @@ static const opfunc __opfuncs[VM_OP__COUNT] = #include "vm-opcodes.inc.h" }; -JERRY_STATIC_ASSERT (sizeof (opcode_t) <= 4); +JERRY_STATIC_ASSERT (sizeof (vm_instr_t) <= 4); -const opcode_t *__program = NULL; +const vm_instr_t *__program = NULL; #ifdef MEM_STATS static const char *__op_names[VM_OP__COUNT] = @@ -120,8 +120,8 @@ interp_mem_get_stats (mem_heap_stats_t *out_heap_stats_p, } static void -interp_mem_stats_context_enter (vm_frame_ctx_t *int_data_p, - opcode_counter_t block_position) +interp_mem_stats_context_enter (vm_frame_ctx_t *frame_ctx_p, + vm_instr_counter_t block_position) { if (likely (!interp_mem_stats_enabled)) { @@ -136,13 +136,13 @@ interp_mem_stats_context_enter (vm_frame_ctx_t *int_data_p, indent_prefix[indentation] = '|'; indent_prefix[indentation + 1] = '\0'; - int_data_p->context_peak_allocated_heap_bytes = 0; - int_data_p->context_peak_waste_heap_bytes = 0; - int_data_p->context_peak_pools_count = 0; - int_data_p->context_peak_allocated_pool_chunks = 0; + frame_ctx_p->context_peak_allocated_heap_bytes = 0; + frame_ctx_p->context_peak_waste_heap_bytes = 0; + frame_ctx_p->context_peak_pools_count = 0; + frame_ctx_p->context_peak_allocated_pool_chunks = 0; - interp_mem_get_stats (&int_data_p->heap_stats_context_enter, - &int_data_p->pools_stats_context_enter, + interp_mem_get_stats (&frame_ctx_p->heap_stats_context_enter, + &frame_ctx_p->pools_stats_context_enter, false, false); printf ("\n%s--- Beginning interpretation of a block at position %u ---\n" @@ -151,15 +151,15 @@ interp_mem_stats_context_enter (vm_frame_ctx_t *int_data_p, "%s Pools: %5u\n" "%s Allocated pool chunks: %5u\n\n", indent_prefix, (uint32_t) block_position, - indent_prefix, (uint32_t) int_data_p->heap_stats_context_enter.allocated_bytes, - indent_prefix, (uint32_t) int_data_p->heap_stats_context_enter.waste_bytes, - indent_prefix, (uint32_t) int_data_p->pools_stats_context_enter.pools_count, - indent_prefix, (uint32_t) int_data_p->pools_stats_context_enter.allocated_chunks); + indent_prefix, (uint32_t) frame_ctx_p->heap_stats_context_enter.allocated_bytes, + indent_prefix, (uint32_t) frame_ctx_p->heap_stats_context_enter.waste_bytes, + indent_prefix, (uint32_t) frame_ctx_p->pools_stats_context_enter.pools_count, + indent_prefix, (uint32_t) frame_ctx_p->pools_stats_context_enter.allocated_chunks); } static void -interp_mem_stats_context_exit (vm_frame_ctx_t *int_data_p, - opcode_counter_t block_position) +interp_mem_stats_context_exit (vm_frame_ctx_t *frame_ctx_p, + vm_instr_counter_t block_position) { if (likely (!interp_mem_stats_enabled)) { @@ -181,46 +181,46 @@ interp_mem_stats_context_exit (vm_frame_ctx_t *int_data_p, &pools_stats_context_exit, false, true); - int_data_p->context_peak_allocated_heap_bytes -= JERRY_MAX (int_data_p->heap_stats_context_enter.allocated_bytes, + frame_ctx_p->context_peak_allocated_heap_bytes -= JERRY_MAX (frame_ctx_p->heap_stats_context_enter.allocated_bytes, heap_stats_context_exit.allocated_bytes); - int_data_p->context_peak_waste_heap_bytes -= JERRY_MAX (int_data_p->heap_stats_context_enter.waste_bytes, + frame_ctx_p->context_peak_waste_heap_bytes -= JERRY_MAX (frame_ctx_p->heap_stats_context_enter.waste_bytes, heap_stats_context_exit.waste_bytes); - int_data_p->context_peak_pools_count -= JERRY_MAX (int_data_p->pools_stats_context_enter.pools_count, + frame_ctx_p->context_peak_pools_count -= JERRY_MAX (frame_ctx_p->pools_stats_context_enter.pools_count, pools_stats_context_exit.pools_count); - int_data_p->context_peak_allocated_pool_chunks -= JERRY_MAX (int_data_p->pools_stats_context_enter.allocated_chunks, + frame_ctx_p->context_peak_allocated_pool_chunks -= JERRY_MAX (frame_ctx_p->pools_stats_context_enter.allocated_chunks, pools_stats_context_exit.allocated_chunks); printf ("%sAllocated heap bytes in the context: %5u -> %5u (%+5d, local %5u, peak %5u)\n", indent_prefix, - (uint32_t) int_data_p->heap_stats_context_enter.allocated_bytes, + (uint32_t) frame_ctx_p->heap_stats_context_enter.allocated_bytes, (uint32_t) heap_stats_context_exit.allocated_bytes, - (uint32_t) (heap_stats_context_exit.allocated_bytes - int_data_p->heap_stats_context_enter.allocated_bytes), - (uint32_t) int_data_p->context_peak_allocated_heap_bytes, + (uint32_t) (heap_stats_context_exit.allocated_bytes - frame_ctx_p->heap_stats_context_enter.allocated_bytes), + (uint32_t) frame_ctx_p->context_peak_allocated_heap_bytes, (uint32_t) heap_stats_context_exit.global_peak_allocated_bytes); printf ("%sWaste heap bytes in the context: %5u -> %5u (%+5d, local %5u, peak %5u)\n", indent_prefix, - (uint32_t) int_data_p->heap_stats_context_enter.waste_bytes, + (uint32_t) frame_ctx_p->heap_stats_context_enter.waste_bytes, (uint32_t) heap_stats_context_exit.waste_bytes, - (uint32_t) (heap_stats_context_exit.waste_bytes - int_data_p->heap_stats_context_enter.waste_bytes), - (uint32_t) int_data_p->context_peak_waste_heap_bytes, + (uint32_t) (heap_stats_context_exit.waste_bytes - frame_ctx_p->heap_stats_context_enter.waste_bytes), + (uint32_t) frame_ctx_p->context_peak_waste_heap_bytes, (uint32_t) heap_stats_context_exit.global_peak_waste_bytes); printf ("%sPools count in the context: %5u -> %5u (%+5d, local %5u, peak %5u)\n", indent_prefix, - (uint32_t) int_data_p->pools_stats_context_enter.pools_count, + (uint32_t) frame_ctx_p->pools_stats_context_enter.pools_count, (uint32_t) pools_stats_context_exit.pools_count, - (uint32_t) (pools_stats_context_exit.pools_count - int_data_p->pools_stats_context_enter.pools_count), - (uint32_t) int_data_p->context_peak_pools_count, + (uint32_t) (pools_stats_context_exit.pools_count - frame_ctx_p->pools_stats_context_enter.pools_count), + (uint32_t) frame_ctx_p->context_peak_pools_count, (uint32_t) pools_stats_context_exit.global_peak_pools_count); printf ("%sAllocated pool chunks in the context: %5u -> %5u (%+5d, local %5u, peak %5u)\n", indent_prefix, - (uint32_t) int_data_p->pools_stats_context_enter.allocated_chunks, + (uint32_t) frame_ctx_p->pools_stats_context_enter.allocated_chunks, (uint32_t) pools_stats_context_exit.allocated_chunks, (uint32_t) (pools_stats_context_exit.allocated_chunks - - int_data_p->pools_stats_context_enter.allocated_chunks), - (uint32_t) int_data_p->context_peak_allocated_pool_chunks, + frame_ctx_p->pools_stats_context_enter.allocated_chunks), + (uint32_t) frame_ctx_p->context_peak_allocated_pool_chunks, (uint32_t) pools_stats_context_exit.global_peak_allocated_chunks); printf ("\n%s--- End of interpretation of a block at position %u ---\n\n", @@ -228,8 +228,8 @@ interp_mem_stats_context_exit (vm_frame_ctx_t *int_data_p, } static void -interp_mem_stats_opcode_enter (const opcode_t *opcodes_p, - opcode_counter_t opcode_position, +interp_mem_stats_opcode_enter (const vm_instr_t *instrs_p, + vm_instr_counter_t instr_position, mem_heap_stats_t *out_heap_stats_p, mem_pools_stats_t *out_pools_stats_p) { @@ -250,17 +250,17 @@ interp_mem_stats_opcode_enter (const opcode_t *opcodes_p, out_pools_stats_p, true, false); - opcode_t opcode = vm_get_opcode (opcodes_p, opcode_position); + vm_instr_t instr = vm_get_instr (instrs_p, instr_position); printf ("%s-- Opcode: %s (position %u) --\n", - indent_prefix, __op_names[opcode.op_idx], (uint32_t) opcode_position); + indent_prefix, __op_names[instr.op_idx], (uint32_t) instr_position); interp_mem_stats_print_indentation += INTERP_MEM_PRINT_INDENTATION_STEP; } static void -interp_mem_stats_opcode_exit (vm_frame_ctx_t *int_data_p, - opcode_counter_t opcode_position, +interp_mem_stats_opcode_exit (vm_frame_ctx_t *frame_ctx_p, + vm_instr_counter_t instr_position, mem_heap_stats_t *heap_stats_before_p, mem_pools_stats_t *pools_stats_before_p) { @@ -286,16 +286,16 @@ interp_mem_stats_opcode_exit (vm_frame_ctx_t *int_data_p, &pools_stats_after, false, true); - int_data_p->context_peak_allocated_heap_bytes = JERRY_MAX (int_data_p->context_peak_allocated_heap_bytes, + frame_ctx_p->context_peak_allocated_heap_bytes = JERRY_MAX (frame_ctx_p->context_peak_allocated_heap_bytes, heap_stats_after.allocated_bytes); - int_data_p->context_peak_waste_heap_bytes = JERRY_MAX (int_data_p->context_peak_waste_heap_bytes, + frame_ctx_p->context_peak_waste_heap_bytes = JERRY_MAX (frame_ctx_p->context_peak_waste_heap_bytes, heap_stats_after.waste_bytes); - int_data_p->context_peak_pools_count = JERRY_MAX (int_data_p->context_peak_pools_count, + frame_ctx_p->context_peak_pools_count = JERRY_MAX (frame_ctx_p->context_peak_pools_count, pools_stats_after.pools_count); - int_data_p->context_peak_allocated_pool_chunks = JERRY_MAX (int_data_p->context_peak_allocated_pool_chunks, + frame_ctx_p->context_peak_allocated_pool_chunks = JERRY_MAX (frame_ctx_p->context_peak_allocated_pool_chunks, pools_stats_after.allocated_chunks); - opcode_t opcode = vm_get_opcode (int_data_p->opcodes_p, opcode_position); + vm_instr_t instr = vm_get_instr (frame_ctx_p->instrs_p, instr_position); printf ("%s Allocated heap bytes: %5u -> %5u (%+5d, local %5u, peak %5u)\n", indent_prefix, @@ -343,7 +343,7 @@ interp_mem_stats_opcode_exit (vm_frame_ctx_t *int_data_p, } printf ("%s-- End of execution of opcode %s (position %u) --\n\n", - indent_prefix, __op_names[opcode.op_idx], opcode_position); + indent_prefix, __op_names[instr.op_idx], instr_position); } #endif /* MEM_STATS */ @@ -351,8 +351,8 @@ interp_mem_stats_opcode_exit (vm_frame_ctx_t *int_data_p, * Initialize interpreter. */ void -vm_init (const opcode_t *program_p, /**< pointer to byte-code program */ - bool dump_mem_stats) /** dump per-opcode memory usage change statistics */ +vm_init (const vm_instr_t *program_p, /**< pointer to byte-code program */ + bool dump_mem_stats) /** dump per-instruction memory usage change statistics */ { #ifdef MEM_STATS interp_mem_stats_enabled = dump_mem_stats; @@ -392,7 +392,7 @@ vm_run_global (void) #endif /* MEM_STATS */ bool is_strict = false; - opcode_counter_t start_pos = 0; + vm_instr_counter_t start_pos = 0; opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (__program, start_pos++); @@ -448,7 +448,7 @@ vm_run_global (void) * Otherwise - the completion value is discarded and normal empty completion value is returned. */ ecma_completion_value_t -vm_loop (vm_frame_ctx_t *int_data_p, /**< interpreter context */ +vm_loop (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */ vm_run_scope_t *run_scope_p) /**< current run scope, * or NULL - if there is no active run scope */ { @@ -467,29 +467,29 @@ vm_loop (vm_frame_ctx_t *int_data_p, /**< interpreter context */ do { JERRY_ASSERT (run_scope_p == NULL - || (run_scope_p->start_oc <= int_data_p->pos - && int_data_p->pos <= run_scope_p->end_oc)); + || (run_scope_p->start_oc <= frame_ctx_p->pos + && frame_ctx_p->pos <= run_scope_p->end_oc)); - const opcode_t *curr = &int_data_p->opcodes_p[int_data_p->pos]; + const vm_instr_t *curr = &frame_ctx_p->instrs_p[frame_ctx_p->pos]; #ifdef MEM_STATS - const opcode_counter_t opcode_pos = int_data_p->pos; + const vm_instr_counter_t instr_pos = frame_ctx_p->pos; - interp_mem_stats_opcode_enter (int_data_p->opcodes_p, - opcode_pos, + interp_mem_stats_opcode_enter (frame_ctx_p->instrs_p, + instr_pos, &heap_stats_before, &pools_stats_before); #endif /* MEM_STATS */ - completion = __opfuncs[curr->op_idx] (*curr, int_data_p); + completion = __opfuncs[curr->op_idx] (*curr, frame_ctx_p); #ifdef CONFIG_VM_RUN_GC_AFTER_EACH_OPCODE ecma_gc_run (); #endif /* CONFIG_VM_RUN_GC_AFTER_EACH_OPCODE */ #ifdef MEM_STATS - interp_mem_stats_opcode_exit (int_data_p, - opcode_pos, + interp_mem_stats_opcode_exit (frame_ctx_p, + instr_pos, &heap_stats_before, &pools_stats_before); #endif /* MEM_STATS */ @@ -501,7 +501,7 @@ vm_loop (vm_frame_ctx_t *int_data_p, /**< interpreter context */ if (ecma_is_completion_value_jump (completion)) { - opcode_counter_t target = ecma_get_jump_target_from_completion_value (completion); + vm_instr_counter_t target = ecma_get_jump_target_from_completion_value (completion); /* * TODO: @@ -512,7 +512,7 @@ vm_loop (vm_frame_ctx_t *int_data_p, /**< interpreter context */ || (target >= run_scope_p->start_oc /* or target is within the current run scope */ && target <= run_scope_p->end_oc)) { - int_data_p->pos = target; + frame_ctx_p->pos = target; continue; } @@ -528,11 +528,11 @@ vm_loop (vm_frame_ctx_t *int_data_p, /**< interpreter context */ } /* vm_loop */ /** - * Run the code, starting from specified opcode + * Run the code, starting from specified instruction position */ ecma_completion_value_t -vm_run_from_pos (const opcode_t *opcodes_p, /**< byte-code array */ - opcode_counter_t start_pos, /**< identifier of starting opcode */ +vm_run_from_pos (const vm_instr_t *instrs_p, /**< byte-code array */ + vm_instr_counter_t start_pos, /**< position of starting instruction */ ecma_value_t this_binding_value, /**< value of 'ThisBinding' */ ecma_object_t *lex_env_p, /**< lexical environment to use */ bool is_strict, /**< is the code is strict mode code (ECMA-262 v5, 10.1.1) */ @@ -540,7 +540,7 @@ vm_run_from_pos (const opcode_t *opcodes_p, /**< byte-code array */ { ecma_completion_value_t completion; - const opcode_t *curr = &opcodes_p[start_pos]; + const vm_instr_t *curr = &instrs_p[start_pos]; JERRY_ASSERT (curr->op_idx == VM_OP_REG_VAR_DECL); const idx_t min_reg_num = curr->data.reg_var_decl.min; @@ -552,8 +552,8 @@ vm_run_from_pos (const opcode_t *opcodes_p, /**< byte-code array */ MEM_DEFINE_LOCAL_ARRAY (regs, regs_num, ecma_value_t); vm_frame_ctx_t frame_ctx; - frame_ctx.opcodes_p = opcodes_p; - frame_ctx.pos = (opcode_counter_t) (start_pos + 1); + frame_ctx.instrs_p = instrs_p; + frame_ctx.pos = (vm_instr_counter_t) (start_pos + 1); frame_ctx.this_binding = this_binding_value; frame_ctx.lex_env_p = lex_env_p; frame_ctx.is_strict = is_strict; @@ -592,28 +592,28 @@ vm_run_from_pos (const opcode_t *opcodes_p, /**< byte-code array */ } /* vm_run_from_pos */ /** - * Get specified opcode from the program. + * Get specified instruction from the program. */ -opcode_t -vm_get_opcode (const opcode_t *opcodes_p, /**< byte-code array */ - opcode_counter_t counter) /**< opcode counter */ +vm_instr_t +vm_get_instr (const vm_instr_t *instrs_p, /**< byte-code array */ + vm_instr_counter_t counter) /**< instruction counter */ { - return opcodes_p[ counter ]; -} /* vm_get_opcode */ + return instrs_p[ counter ]; +} /* vm_get_instr */ /** - * Get scope code flags from opcode specified by opcode counter + * Get scope code flags from instruction at specified position * * @return mask of scope code flags */ opcode_scope_code_flags_t -vm_get_scope_flags (const opcode_t *opcodes_p, /**< byte-code array */ - opcode_counter_t counter) /**< opcode counter */ +vm_get_scope_flags (const vm_instr_t *instrs_p, /**< byte-code array */ + vm_instr_counter_t counter) /**< instruction counter */ { - opcode_t flags_opcode = vm_get_opcode (opcodes_p, counter); - JERRY_ASSERT (flags_opcode.op_idx == VM_OP_META - && flags_opcode.data.meta.type == OPCODE_META_TYPE_SCOPE_CODE_FLAGS); - return (opcode_scope_code_flags_t) flags_opcode.data.meta.data_1; + vm_instr_t flags_instr = vm_get_instr (instrs_p, counter); + JERRY_ASSERT (flags_instr.op_idx == VM_OP_META + && flags_instr.data.meta.type == OPCODE_META_TYPE_SCOPE_CODE_FLAGS); + return (opcode_scope_code_flags_t) flags_instr.data.meta.data_1; } /* vm_get_scope_flags */ /** diff --git a/jerry-core/vm/vm.h b/jerry-core/vm/vm.h index 44cc75dd9..497263b22 100644 --- a/jerry-core/vm/vm.h +++ b/jerry-core/vm/vm.h @@ -20,19 +20,19 @@ #include "jrt.h" #include "opcodes.h" -extern void vm_init (const opcode_t* program_p, bool dump_mem_stats); +extern void vm_init (const vm_instr_t* program_p, bool dump_mem_stats); extern void vm_finalize (void); extern jerry_completion_code_t vm_run_global (void); extern ecma_completion_value_t vm_loop (vm_frame_ctx_t *frame_ctx_p, vm_run_scope_t *run_scope_p); -extern ecma_completion_value_t vm_run_from_pos (const opcode_t *opcodes_p, - opcode_counter_t start_pos, +extern ecma_completion_value_t vm_run_from_pos (const vm_instr_t *instrs_p, + vm_instr_counter_t start_pos, ecma_value_t this_binding_value, ecma_object_t *lex_env_p, bool is_strict, bool is_eval_code); -extern opcode_t vm_get_opcode (const opcode_t*, opcode_counter_t counter); -extern opcode_scope_code_flags_t vm_get_scope_flags (const opcode_t*, opcode_counter_t counter); +extern vm_instr_t vm_get_instr (const vm_instr_t*, vm_instr_counter_t counter); +extern opcode_scope_code_flags_t vm_get_scope_flags (const vm_instr_t*, vm_instr_counter_t counter); extern bool vm_is_strict_mode (void); extern bool vm_is_direct_eval_form_call (void); diff --git a/tests/unit/test-parser.cpp b/tests/unit/test-parser.cpp index d38930df7..6fea79c79 100644 --- a/tests/unit/test-parser.cpp +++ b/tests/unit/test-parser.cpp @@ -21,12 +21,12 @@ #include "test-common.h" static bool -opcodes_equal (const opcode_t *opcodes1, opcode_t *opcodes2, uint16_t size) +instrs_equal (const vm_instr_t *instrs1, vm_instr_t *instrs2, uint16_t size) { uint16_t i; for (i = 0; i < size; i++) { - if (memcmp (&opcodes1[i], &opcodes2[i], sizeof (opcode_t)) != 0) + if (memcmp (&instrs1[i], &instrs2[i], sizeof (vm_instr_t)) != 0) { return false; } @@ -44,7 +44,7 @@ main (int __attr_unused___ argc, { TEST_INIT (); - const opcode_t *opcodes_p; + const vm_instr_t *instrs_p; jsp_status_t parse_status; mem_init (); @@ -53,12 +53,12 @@ main (int __attr_unused___ argc, char program1[] = "a=1;var a;"; serializer_init (); - parser_set_show_opcodes (true); - parse_status = parser_parse_script ((jerry_api_char_t *) program1, strlen (program1), &opcodes_p); + parser_set_show_instrs (true); + parse_status = parser_parse_script ((jerry_api_char_t *) program1, strlen (program1), &instrs_p); - JERRY_ASSERT (parse_status == JSP_STATUS_OK && opcodes_p != NULL); + JERRY_ASSERT (parse_status == JSP_STATUS_OK && instrs_p != NULL); - opcode_t opcodes[] = + vm_instr_t instrs[] = { getop_meta (OPCODE_META_TYPE_SCOPE_CODE_FLAGS, // [ ] OPCODE_SCOPE_CODE_FLAGS_NOT_REF_ARGUMENTS_IDENTIFIER @@ -71,7 +71,7 @@ main (int __attr_unused___ argc, getop_ret () // return; }; - JERRY_ASSERT (opcodes_equal (opcodes_p, opcodes, 5)); + JERRY_ASSERT (instrs_equal (instrs_p, instrs, 5)); serializer_free (); @@ -79,10 +79,10 @@ main (int __attr_unused___ argc, char program2[] = "var var;"; serializer_init (); - parser_set_show_opcodes (true); - parse_status = parser_parse_script ((jerry_api_char_t *) program2, strlen (program2), &opcodes_p); + parser_set_show_instrs (true); + parse_status = parser_parse_script ((jerry_api_char_t *) program2, strlen (program2), &instrs_p); - JERRY_ASSERT (parse_status == JSP_STATUS_SYNTAX_ERROR && opcodes_p == NULL); + JERRY_ASSERT (parse_status == JSP_STATUS_SYNTAX_ERROR && instrs_p == NULL); serializer_free ();