diff --git a/jerry-core/lit/lit-literal.h b/jerry-core/lit/lit-literal.h index 3cd980217..a52060d89 100644 --- a/jerry-core/lit/lit-literal.h +++ b/jerry-core/lit/lit-literal.h @@ -20,8 +20,6 @@ #include "lit-literal-storage.h" #include "lit-magic-strings.h" -#define LITERAL_TO_REWRITE (INVALID_VALUE - 1) - void lit_init (); void lit_finalize (); void lit_dump_literals (); 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 67087cb12..4a45b5ac7 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 (instruction block, idx_t value) with literal identifiers. + * The hash table connects pairs (instruction block, vm_idx_t value) with literal identifiers. * @{ */ @@ -87,7 +87,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 */ + vm_idx_t uid, /**< value of byte-code instruction's argument */ vm_instr_counter_t oc, /**< instruction counter of the instruction */ lit_cpointer_t lit_cp) /**< literal identifier */ { @@ -111,7 +111,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 */ + vm_idx_t uid, /**< value of byte-code instruction's argument */ 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 321a3bbf4..996b11e33 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, 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); +void lit_id_hash_table_insert (lit_id_hash_table *, vm_idx_t, vm_instr_counter_t, lit_cpointer_t); +lit_cpointer_t lit_id_hash_table_lookup (lit_id_hash_table *, vm_idx_t, vm_instr_counter_t); #endif /* LIT_ID_HASH_TABLE */ diff --git a/jerry-core/parser/js/lexer.h b/jerry-core/parser/js/lexer.h index a2802c6b8..0f04f69ed 100644 --- a/jerry-core/parser/js/lexer.h +++ b/jerry-core/parser/js/lexer.h @@ -19,7 +19,6 @@ #include "lit-literal.h" #include "lit-strings.h" -#define INVALID_VALUE 255 #define INVALID_LITERAL (rcs_cpointer_t::null_cp ()) /* Keywords. */ diff --git a/jerry-core/parser/js/opcodes-dumper.cpp b/jerry-core/parser/js/opcodes-dumper.cpp index 5b37ca6d2..3414747b0 100644 --- a/jerry-core/parser/js/opcodes-dumper.cpp +++ b/jerry-core/parser/js/opcodes-dumper.cpp @@ -22,7 +22,7 @@ /** * Register allocator's counter */ -static idx_t jsp_reg_next; +static vm_idx_t jsp_reg_next; /** * Maximum identifier of a register, allocated for intermediate value storage @@ -30,21 +30,21 @@ static idx_t jsp_reg_next; * See also: * dumper_new_scope, dumper_finish_scope */ -static idx_t jsp_reg_max_for_temps; +static vm_idx_t jsp_reg_max_for_temps; /** * Maximum identifier of a register, allocated for storage of a variable value. * - * The value can be INVALID_VALUE, indicating that no registers were allocated for variable values. + * The value can be VM_IDX_EMPTY, indicating that no registers were allocated for variable values. * * Note: * Registers for variable values are always allocated after registers for temporary values, - * so the value, if not equal to INVALID_VALUE, is always greater than jsp_reg_max_for_temps. + * so the value, if not equal to VM_IDX_EMPTY, is always greater than jsp_reg_max_for_temps. * * See also: * dumper_try_replace_var_with_reg */ -static idx_t jsp_reg_max_for_local_var; +static vm_idx_t jsp_reg_max_for_local_var; enum { @@ -128,7 +128,7 @@ enum { jsp_reg_id_stack_global_size }; -STATIC_STACK (jsp_reg_id_stack, idx_t) +STATIC_STACK (jsp_reg_id_stack, vm_idx_t) enum { @@ -141,14 +141,14 @@ STATIC_STACK (reg_var_decls, vm_instr_counter_t) * * @return identifier of the allocated register */ -static idx_t +static vm_idx_t jsp_alloc_reg_for_temp (void) { - JERRY_ASSERT (jsp_reg_max_for_local_var == INVALID_VALUE); + JERRY_ASSERT (jsp_reg_max_for_local_var == VM_IDX_EMPTY); - idx_t next_reg = jsp_reg_next++; + vm_idx_t next_reg = jsp_reg_next++; - if (next_reg > OPCODE_REG_GENERAL_LAST) + if (next_reg > VM_REG_GENERAL_LAST) { /* * FIXME: @@ -216,7 +216,7 @@ dumper_try_replace_var_with_reg (scopes_tree tree, /**< a function scope, create JERRY_ASSERT (meta_type == OPCODE_META_TYPE_VARG); /* the varg specifies argument name, and so should be a string literal */ - JERRY_ASSERT (meta_opm.op.data.meta.data_1 == LITERAL_TO_REWRITE); + JERRY_ASSERT (meta_opm.op.data.meta.data_1 == VM_IDX_REWRITE_LITERAL_UID); JERRY_ASSERT (meta_opm.lit_id[1].packed_value != NOT_A_LITERAL.packed_value); if (meta_opm.lit_id[1].packed_value == var_decl_om_p->lit_id[0].packed_value) @@ -233,19 +233,19 @@ dumper_try_replace_var_with_reg (scopes_tree tree, /**< a function scope, create } } - if (jsp_reg_max_for_local_var == INVALID_VALUE) + if (jsp_reg_max_for_local_var == VM_IDX_EMPTY) { jsp_reg_max_for_local_var = jsp_reg_max_for_temps; } - if (jsp_reg_max_for_local_var == OPCODE_REG_GENERAL_LAST) + if (jsp_reg_max_for_local_var == VM_REG_GENERAL_LAST) { /* not enough registers */ return false; } - JERRY_ASSERT (jsp_reg_max_for_local_var < OPCODE_REG_GENERAL_LAST); + JERRY_ASSERT (jsp_reg_max_for_local_var < VM_REG_GENERAL_LAST); - idx_t reg = ++jsp_reg_max_for_local_var; + vm_idx_t reg = ++jsp_reg_max_for_local_var; lit_cpointer_t lit_cp = var_decl_om_p->lit_id[0]; @@ -312,7 +312,7 @@ dumper_try_replace_var_with_reg (scopes_tree tree, /**< a function scope, create om.lit_id[arg_index] = NOT_A_LITERAL; raw_instr *raw_p = (raw_instr *) (&om.op); - JERRY_ASSERT (raw_p->uids[arg_index + 1] == LITERAL_TO_REWRITE); + JERRY_ASSERT (raw_p->uids[arg_index + 1] == VM_IDX_REWRITE_LITERAL_UID); raw_p->uids[arg_index + 1] = reg; } } @@ -393,7 +393,9 @@ tmp_operand (void) static op_meta -create_op_meta_for_res_and_obj (vm_instr_t (*getop) (idx_t, idx_t, idx_t), jsp_operand_t *res, jsp_operand_t *obj) +create_op_meta_for_res_and_obj (vm_instr_t (*getop) (vm_idx_t, vm_idx_t, vm_idx_t), + jsp_operand_t *res, + jsp_operand_t *obj) { JERRY_ASSERT (obj != NULL); JERRY_ASSERT (res != NULL); @@ -404,14 +406,14 @@ create_op_meta_for_res_and_obj (vm_instr_t (*getop) (idx_t, idx_t, idx_t), jsp_o if (res->is_register_operand () || res->is_empty_operand ()) { - const vm_instr_t instr = getop (res->get_idx (), obj->get_idx (), INVALID_VALUE); + const vm_instr_t instr = getop (res->get_idx (), obj->get_idx (), VM_IDX_REWRITE_GENERAL_CASE); ret = create_op_meta_000 (instr); } else { JERRY_ASSERT (res->is_literal_operand ()); - const vm_instr_t instr = getop (LITERAL_TO_REWRITE, obj->get_idx (), INVALID_VALUE); + const vm_instr_t instr = getop (VM_IDX_REWRITE_LITERAL_UID, obj->get_idx (), VM_IDX_REWRITE_GENERAL_CASE); ret = create_op_meta_100 (instr, res->get_literal ()); } } @@ -422,14 +424,16 @@ create_op_meta_for_res_and_obj (vm_instr_t (*getop) (idx_t, idx_t, idx_t), jsp_o if (res->is_register_operand () || res->is_empty_operand ()) { - const vm_instr_t instr = getop (res->get_idx (), LITERAL_TO_REWRITE, INVALID_VALUE); + const vm_instr_t instr = getop (res->get_idx (), VM_IDX_REWRITE_LITERAL_UID, VM_IDX_REWRITE_GENERAL_CASE); ret = create_op_meta_010 (instr, obj->get_literal ()); } else { JERRY_ASSERT (res->is_literal_operand ()); - const vm_instr_t instr = getop (LITERAL_TO_REWRITE, LITERAL_TO_REWRITE, INVALID_VALUE); + const vm_instr_t instr = getop (VM_IDX_REWRITE_LITERAL_UID, + VM_IDX_REWRITE_LITERAL_UID, + VM_IDX_REWRITE_GENERAL_CASE); ret = create_op_meta_110 (instr, res->get_literal (), obj->get_literal ()); } } @@ -437,7 +441,7 @@ create_op_meta_for_res_and_obj (vm_instr_t (*getop) (idx_t, idx_t, idx_t), jsp_o } static op_meta -create_op_meta_for_obj (vm_instr_t (*getop) (idx_t, idx_t), jsp_operand_t *obj) +create_op_meta_for_obj (vm_instr_t (*getop) (vm_idx_t, vm_idx_t), jsp_operand_t *obj) { JERRY_ASSERT (obj != NULL); op_meta res; @@ -445,14 +449,14 @@ create_op_meta_for_obj (vm_instr_t (*getop) (idx_t, idx_t), jsp_operand_t *obj) if (obj->is_register_operand () || obj->is_empty_operand ()) { - const vm_instr_t instr = getop (obj->get_idx (), INVALID_VALUE); + const vm_instr_t instr = getop (obj->get_idx (), VM_IDX_REWRITE_GENERAL_CASE); res = create_op_meta_000 (instr); } else { JERRY_ASSERT (obj->is_literal_operand ()); - const vm_instr_t instr = getop (LITERAL_TO_REWRITE, INVALID_VALUE); + const vm_instr_t instr = getop (VM_IDX_REWRITE_LITERAL_UID, VM_IDX_REWRITE_GENERAL_CASE); res = create_op_meta_100 (instr, obj->get_literal ()); } @@ -498,12 +502,12 @@ create_op_meta_for_vlt (varg_list_type vlt, jsp_operand_t *res, jsp_operand_t *o } static void -split_instr_counter (vm_instr_counter_t oc, idx_t *id1, idx_t *id2) +split_instr_counter (vm_instr_counter_t oc, vm_idx_t *id1, vm_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)); + *id1 = (vm_idx_t) (oc >> JERRY_BITSINBYTE); + *id2 = (vm_idx_t) (oc & ((1 << JERRY_BITSINBYTE) - 1)); JERRY_ASSERT (oc == vm_calc_instr_counter_from_idx_idx (*id1, *id2)); } @@ -514,11 +518,11 @@ last_dumped_op_meta (void) } static void -dump_single_address (vm_instr_t (*getop) (idx_t), jsp_operand_t op) +dump_single_address (vm_instr_t (*getop) (vm_idx_t), jsp_operand_t op) { if (op.is_literal_operand ()) { - const vm_instr_t instr = getop (LITERAL_TO_REWRITE); + const vm_instr_t instr = getop (VM_IDX_REWRITE_LITERAL_UID); serializer_dump_op_meta (create_op_meta_100 (instr, op.get_literal ())); } else @@ -531,20 +535,20 @@ dump_single_address (vm_instr_t (*getop) (idx_t), jsp_operand_t op) } static void -dump_double_address (vm_instr_t (*getop) (idx_t, idx_t), jsp_operand_t res, jsp_operand_t obj) +dump_double_address (vm_instr_t (*getop) (vm_idx_t, vm_idx_t), jsp_operand_t res, jsp_operand_t obj) { if (res.is_literal_operand ()) { if (obj.is_literal_operand ()) { - const vm_instr_t instr = getop (LITERAL_TO_REWRITE, LITERAL_TO_REWRITE); + const vm_instr_t instr = getop (VM_IDX_REWRITE_LITERAL_UID, VM_IDX_REWRITE_LITERAL_UID); serializer_dump_op_meta (create_op_meta_110 (instr, res.get_literal (), obj.get_literal ())); } else { JERRY_ASSERT (obj.is_register_operand ()); - const vm_instr_t instr = getop (LITERAL_TO_REWRITE, obj.get_idx ()); + const vm_instr_t instr = getop (VM_IDX_REWRITE_LITERAL_UID, obj.get_idx ()); serializer_dump_op_meta (create_op_meta_100 (instr, res.get_literal ())); } } @@ -554,7 +558,7 @@ dump_double_address (vm_instr_t (*getop) (idx_t, idx_t), jsp_operand_t res, jsp_ if (obj.is_literal_operand ()) { - const vm_instr_t instr = getop (res.get_idx (), LITERAL_TO_REWRITE); + const vm_instr_t instr = getop (res.get_idx (), VM_IDX_REWRITE_LITERAL_UID); serializer_dump_op_meta (create_op_meta_010 (instr, obj.get_literal ())); } else @@ -568,7 +572,10 @@ dump_double_address (vm_instr_t (*getop) (idx_t, idx_t), jsp_operand_t res, jsp_ } static void -dump_triple_address (vm_instr_t (*getop) (idx_t, idx_t, idx_t), jsp_operand_t res, jsp_operand_t lhs, jsp_operand_t rhs) +dump_triple_address (vm_instr_t (*getop) (vm_idx_t, vm_idx_t, vm_idx_t), + jsp_operand_t res, + jsp_operand_t lhs, + jsp_operand_t rhs) { if (res.is_literal_operand ()) { @@ -576,7 +583,9 @@ dump_triple_address (vm_instr_t (*getop) (idx_t, idx_t, idx_t), jsp_operand_t re { if (rhs.is_literal_operand ()) { - const vm_instr_t instr = getop (LITERAL_TO_REWRITE, LITERAL_TO_REWRITE, LITERAL_TO_REWRITE); + const vm_instr_t instr = getop (VM_IDX_REWRITE_LITERAL_UID, + VM_IDX_REWRITE_LITERAL_UID, + VM_IDX_REWRITE_LITERAL_UID); serializer_dump_op_meta (create_op_meta_111 (instr, res.get_literal (), lhs.get_literal (), @@ -586,7 +595,7 @@ dump_triple_address (vm_instr_t (*getop) (idx_t, idx_t, idx_t), jsp_operand_t re { JERRY_ASSERT (rhs.is_register_operand ()); - const vm_instr_t instr = getop (LITERAL_TO_REWRITE, LITERAL_TO_REWRITE, rhs.get_idx ()); + const vm_instr_t instr = getop (VM_IDX_REWRITE_LITERAL_UID, VM_IDX_REWRITE_LITERAL_UID, rhs.get_idx ()); serializer_dump_op_meta (create_op_meta_110 (instr, res.get_literal (), lhs.get_literal ())); } } @@ -596,14 +605,14 @@ dump_triple_address (vm_instr_t (*getop) (idx_t, idx_t, idx_t), jsp_operand_t re if (rhs.is_literal_operand ()) { - const vm_instr_t instr = getop (LITERAL_TO_REWRITE, lhs.get_idx (), LITERAL_TO_REWRITE); + const vm_instr_t instr = getop (VM_IDX_REWRITE_LITERAL_UID, lhs.get_idx (), VM_IDX_REWRITE_LITERAL_UID); serializer_dump_op_meta (create_op_meta_101 (instr, res.get_literal (), rhs.get_literal ())); } else { JERRY_ASSERT (rhs.is_register_operand ()); - const vm_instr_t instr = getop (LITERAL_TO_REWRITE, lhs.get_idx (), rhs.get_idx ()); + const vm_instr_t instr = getop (VM_IDX_REWRITE_LITERAL_UID, lhs.get_idx (), rhs.get_idx ()); serializer_dump_op_meta (create_op_meta_100 (instr, res.get_literal ())); } } @@ -616,14 +625,14 @@ dump_triple_address (vm_instr_t (*getop) (idx_t, idx_t, idx_t), jsp_operand_t re { if (rhs.is_literal_operand ()) { - const vm_instr_t instr = getop (res.get_idx (), LITERAL_TO_REWRITE, LITERAL_TO_REWRITE); + const vm_instr_t instr = getop (res.get_idx (), VM_IDX_REWRITE_LITERAL_UID, VM_IDX_REWRITE_LITERAL_UID); serializer_dump_op_meta (create_op_meta_011 (instr, lhs.get_literal (), rhs.get_literal ())); } else { JERRY_ASSERT (rhs.is_register_operand ()); - const vm_instr_t instr = getop (res.get_idx (), LITERAL_TO_REWRITE, rhs.get_idx ()); + const vm_instr_t instr = getop (res.get_idx (), VM_IDX_REWRITE_LITERAL_UID, rhs.get_idx ()); serializer_dump_op_meta (create_op_meta_010 (instr, lhs.get_literal ())); } } @@ -633,7 +642,7 @@ dump_triple_address (vm_instr_t (*getop) (idx_t, idx_t, idx_t), jsp_operand_t re if (rhs.is_literal_operand ()) { - const vm_instr_t instr = getop (res.get_idx (), lhs.get_idx (), LITERAL_TO_REWRITE); + const vm_instr_t instr = getop (res.get_idx (), lhs.get_idx (), VM_IDX_REWRITE_LITERAL_UID); serializer_dump_op_meta (create_op_meta_001 (instr, rhs.get_literal ())); } else @@ -657,7 +666,7 @@ dump_prop_setter_op_meta (op_meta last, jsp_operand_t op) { const vm_instr_t instr = getop_prop_setter (last.op.data.prop_getter.obj, last.op.data.prop_getter.prop, - LITERAL_TO_REWRITE); + VM_IDX_REWRITE_LITERAL_UID); serializer_dump_op_meta (create_op_meta_111 (instr, last.lit_id[1], last.lit_id[2], op.get_literal ())); } else @@ -672,9 +681,9 @@ dump_prop_setter_op_meta (op_meta last, jsp_operand_t op) } static jsp_operand_t -create_operand_from_tmp_and_lit (idx_t tmp, lit_cpointer_t lit_id) +create_operand_from_tmp_and_lit (vm_idx_t tmp, lit_cpointer_t lit_id) { - if (tmp != LITERAL_TO_REWRITE) + if (tmp != VM_IDX_REWRITE_LITERAL_UID) { JERRY_ASSERT (lit_id.packed_value == MEM_CP_NULL); @@ -753,7 +762,7 @@ literal_operand (lit_cpointer_t lit_cp) jsp_operand_t eval_ret_operand (void) { - return jsp_operand_t::make_reg_operand (OPCODE_REG_SPECIAL_EVAL_RET); + return jsp_operand_t::make_reg_operand (VM_REG_SPECIAL_EVAL_RET); } /* eval_ret_operand */ /** @@ -765,7 +774,7 @@ eval_ret_operand (void) jsp_operand_t jsp_create_operand_for_in_special_reg (void) { - return jsp_operand_t::make_reg_operand (OPCODE_REG_SPECIAL_FOR_IN_PROPERTY_NAME); + return jsp_operand_t::make_reg_operand (VM_REG_SPECIAL_FOR_IN_PROPERTY_NAME); } /* jsp_create_operand_for_in_special_reg */ bool @@ -777,25 +786,25 @@ operand_is_empty (jsp_operand_t op) void dumper_new_statement (void) { - jsp_reg_next = OPCODE_REG_GENERAL_FIRST; + jsp_reg_next = VM_REG_GENERAL_FIRST; } void dumper_new_scope (void) { - JERRY_ASSERT (jsp_reg_max_for_local_var == INVALID_VALUE); + JERRY_ASSERT (jsp_reg_max_for_local_var == VM_IDX_EMPTY); STACK_PUSH (jsp_reg_id_stack, jsp_reg_next); STACK_PUSH (jsp_reg_id_stack, jsp_reg_max_for_temps); - jsp_reg_next = OPCODE_REG_GENERAL_FIRST; + jsp_reg_next = VM_REG_GENERAL_FIRST; jsp_reg_max_for_temps = jsp_reg_next; } void dumper_finish_scope (void) { - JERRY_ASSERT (jsp_reg_max_for_local_var == INVALID_VALUE); + JERRY_ASSERT (jsp_reg_max_for_local_var == VM_IDX_EMPTY); jsp_reg_max_for_temps = STACK_TOP (jsp_reg_id_stack); STACK_DROP (jsp_reg_id_stack, 1); @@ -881,7 +890,7 @@ dump_boolean_assignment (jsp_operand_t op, bool is_true) { if (op.is_literal_operand ()) { - const vm_instr_t instr = getop_assignment (LITERAL_TO_REWRITE, + const vm_instr_t instr = getop_assignment (VM_IDX_REWRITE_LITERAL_UID, OPCODE_ARG_TYPE_SIMPLE, is_true ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE); const op_meta om = create_op_meta_100 (instr, op.get_literal ()); @@ -912,14 +921,16 @@ dump_string_assignment (jsp_operand_t op, lit_cpointer_t lit_id) { if (op.is_literal_operand ()) { - const vm_instr_t instr = getop_assignment (LITERAL_TO_REWRITE, OPCODE_ARG_TYPE_STRING, LITERAL_TO_REWRITE); + const vm_instr_t instr = getop_assignment (VM_IDX_REWRITE_LITERAL_UID, + OPCODE_ARG_TYPE_STRING, + VM_IDX_REWRITE_LITERAL_UID); serializer_dump_op_meta (create_op_meta_101 (instr, op.get_literal (), lit_id)); } else { JERRY_ASSERT (op.is_register_operand ()); - const vm_instr_t instr = getop_assignment (op.get_idx (), OPCODE_ARG_TYPE_STRING, LITERAL_TO_REWRITE); + const vm_instr_t instr = getop_assignment (op.get_idx (), OPCODE_ARG_TYPE_STRING, VM_IDX_REWRITE_LITERAL_UID); serializer_dump_op_meta (create_op_meta_001 (instr, lit_id)); } } @@ -937,14 +948,16 @@ dump_number_assignment (jsp_operand_t op, lit_cpointer_t lit_id) { if (op.is_literal_operand ()) { - const vm_instr_t instr = getop_assignment (LITERAL_TO_REWRITE, OPCODE_ARG_TYPE_NUMBER, LITERAL_TO_REWRITE); + const vm_instr_t instr = getop_assignment (VM_IDX_REWRITE_LITERAL_UID, + OPCODE_ARG_TYPE_NUMBER, + VM_IDX_REWRITE_LITERAL_UID); serializer_dump_op_meta (create_op_meta_101 (instr, op.get_literal (), lit_id)); } else { JERRY_ASSERT (op.is_register_operand ()); - const vm_instr_t instr = getop_assignment (op.get_idx (), OPCODE_ARG_TYPE_NUMBER, LITERAL_TO_REWRITE); + const vm_instr_t instr = getop_assignment (op.get_idx (), OPCODE_ARG_TYPE_NUMBER, VM_IDX_REWRITE_LITERAL_UID); serializer_dump_op_meta (create_op_meta_001 (instr, lit_id)); } } @@ -962,14 +975,16 @@ dump_regexp_assignment (jsp_operand_t op, lit_cpointer_t lit_id) { if (op.is_literal_operand ()) { - const vm_instr_t instr = getop_assignment (LITERAL_TO_REWRITE, OPCODE_ARG_TYPE_REGEXP, LITERAL_TO_REWRITE); + const vm_instr_t instr = getop_assignment (VM_IDX_REWRITE_LITERAL_UID, + OPCODE_ARG_TYPE_REGEXP, + VM_IDX_REWRITE_LITERAL_UID); serializer_dump_op_meta (create_op_meta_101 (instr, op.get_literal (), lit_id)); } else { JERRY_ASSERT (op.is_register_operand ()); - const vm_instr_t instr = getop_assignment (op.get_idx (), OPCODE_ARG_TYPE_REGEXP, LITERAL_TO_REWRITE); + const vm_instr_t instr = getop_assignment (op.get_idx (), OPCODE_ARG_TYPE_REGEXP, VM_IDX_REWRITE_LITERAL_UID); serializer_dump_op_meta (create_op_meta_001 (instr, lit_id)); } } @@ -983,11 +998,11 @@ dump_regexp_assignment_res (lit_cpointer_t lit_id) } void -dump_smallint_assignment (jsp_operand_t op, idx_t uid) +dump_smallint_assignment (jsp_operand_t op, vm_idx_t uid) { if (op.is_literal_operand ()) { - const vm_instr_t instr = getop_assignment (LITERAL_TO_REWRITE, OPCODE_ARG_TYPE_SMALLINT, uid); + const vm_instr_t instr = getop_assignment (VM_IDX_REWRITE_LITERAL_UID, OPCODE_ARG_TYPE_SMALLINT, uid); serializer_dump_op_meta (create_op_meta_100 (instr, op.get_literal ())); } else @@ -1000,7 +1015,7 @@ dump_smallint_assignment (jsp_operand_t op, idx_t uid) } jsp_operand_t -dump_smallint_assignment_res (idx_t uid) +dump_smallint_assignment_res (vm_idx_t uid) { jsp_operand_t op = tmp_operand (); dump_smallint_assignment (op, uid); @@ -1012,7 +1027,7 @@ dump_undefined_assignment (jsp_operand_t op) { if (op.is_literal_operand ()) { - const vm_instr_t instr = getop_assignment (LITERAL_TO_REWRITE, + const vm_instr_t instr = getop_assignment (VM_IDX_REWRITE_LITERAL_UID, OPCODE_ARG_TYPE_SIMPLE, ECMA_SIMPLE_VALUE_UNDEFINED); serializer_dump_op_meta (create_op_meta_100 (instr, op.get_literal ())); @@ -1039,7 +1054,7 @@ dump_null_assignment (jsp_operand_t op) { if (op.is_literal_operand ()) { - const vm_instr_t instr = getop_assignment (LITERAL_TO_REWRITE, + const vm_instr_t instr = getop_assignment (VM_IDX_REWRITE_LITERAL_UID, OPCODE_ARG_TYPE_SIMPLE, ECMA_SIMPLE_VALUE_NULL); serializer_dump_op_meta (create_op_meta_100 (instr, op.get_literal ())); @@ -1070,16 +1085,16 @@ dump_variable_assignment (jsp_operand_t res, jsp_operand_t var) { if (var.is_literal_operand ()) { - const vm_instr_t instr = getop_assignment (LITERAL_TO_REWRITE, + const vm_instr_t instr = getop_assignment (VM_IDX_REWRITE_LITERAL_UID, OPCODE_ARG_TYPE_VARIABLE, - LITERAL_TO_REWRITE); + VM_IDX_REWRITE_LITERAL_UID); serializer_dump_op_meta (create_op_meta_101 (instr, res.get_literal (), var.get_literal ())); } else { JERRY_ASSERT (var.is_register_operand ()); - const vm_instr_t instr = getop_assignment (LITERAL_TO_REWRITE, + const vm_instr_t instr = getop_assignment (VM_IDX_REWRITE_LITERAL_UID, OPCODE_ARG_TYPE_VARIABLE, var.get_idx ()); serializer_dump_op_meta (create_op_meta_100 (instr, res.get_literal ())); @@ -1093,7 +1108,7 @@ dump_variable_assignment (jsp_operand_t res, jsp_operand_t var) { const vm_instr_t instr = getop_assignment (res.get_idx (), OPCODE_ARG_TYPE_VARIABLE, - LITERAL_TO_REWRITE); + VM_IDX_REWRITE_LITERAL_UID); serializer_dump_op_meta (create_op_meta_001 (instr, var.get_literal ())); } else @@ -1170,7 +1185,7 @@ rewrite_varg_header_set_args_count (size_t args_count) LIT_ITERATOR_POS_ZERO); } const jsp_operand_t res = tmp_operand (); - om.op.data.func_expr_n.arg_list = (idx_t) args_count; + om.op.data.func_expr_n.arg_list = (vm_idx_t) args_count; om.op.data.func_expr_n.lhs = res.get_idx (); serializer_rewrite_op_meta (STACK_TOP (varg_headers), om); STACK_DROP (varg_headers, 1); @@ -1184,7 +1199,7 @@ rewrite_varg_header_set_args_count (size_t args_count) "No more than 255 formal parameters are currently supported", LIT_ITERATOR_POS_ZERO); } - om.op.data.func_decl_n.arg_list = (idx_t) args_count; + om.op.data.func_decl_n.arg_list = (vm_idx_t) args_count; serializer_rewrite_op_meta (STACK_TOP (varg_headers), om); STACK_DROP (varg_headers, 1); return empty_operand (); @@ -1199,8 +1214,8 @@ rewrite_varg_header_set_args_count (size_t args_count) LIT_ITERATOR_POS_ZERO); } const jsp_operand_t res = tmp_operand (); - om.op.data.obj_decl.list_1 = (idx_t) (args_count >> 8); - om.op.data.obj_decl.list_2 = (idx_t) (args_count & 0xffu); + om.op.data.obj_decl.list_1 = (vm_idx_t) (args_count >> 8); + om.op.data.obj_decl.list_2 = (vm_idx_t) (args_count & 0xffu); om.op.data.obj_decl.lhs = res.get_idx (); serializer_rewrite_op_meta (STACK_TOP (varg_headers), om); STACK_DROP (varg_headers, 1); @@ -1233,11 +1248,14 @@ dump_call_additional_info (opcode_call_flags_t flags, /**< call flags */ JERRY_ASSERT (operand_is_empty (this_arg)); } - 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.get_idx () - : INVALID_VALUE)); + vm_idx_t this_arg_idx = VM_IDX_EMPTY; + + if (flags & OPCODE_CALL_FLAGS_HAVE_THIS_ARG) + { + this_arg_idx = this_arg.get_idx (); + } + + const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_CALL_SITE_INFO, flags, this_arg_idx); serializer_dump_op_meta (create_op_meta_000 (instr)); } /* dump_call_additional_info */ @@ -1247,14 +1265,14 @@ dump_varg (jsp_operand_t op) { if (op.is_register_operand ()) { - const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_VARG, op.get_idx (), INVALID_VALUE); + const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_VARG, op.get_idx (), VM_IDX_EMPTY); serializer_dump_op_meta (create_op_meta_000 (instr)); } else { JERRY_ASSERT (op.is_literal_operand ()); - const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_VARG, LITERAL_TO_REWRITE, INVALID_VALUE); + const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_VARG, VM_IDX_REWRITE_LITERAL_UID, VM_IDX_EMPTY); serializer_dump_op_meta (create_op_meta_010 (instr, op.get_literal ())); } } @@ -1279,7 +1297,7 @@ dump_prop_name_and_value (jsp_operand_t name, jsp_operand_t value) if (value.is_literal_operand ()) { - const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_VARG_PROP_DATA, tmp.get_idx (), LITERAL_TO_REWRITE); + const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_VARG_PROP_DATA, tmp.get_idx (), VM_IDX_REWRITE_LITERAL_UID); serializer_dump_op_meta (create_op_meta_001 (instr, value.get_literal ())); } else @@ -1359,7 +1377,9 @@ void dump_function_end_for_rewrite (void) { 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); + const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_FUNCTION_END, + VM_IDX_REWRITE_GENERAL_CASE, + VM_IDX_REWRITE_GENERAL_CASE); serializer_dump_op_meta (create_op_meta_000 (instr)); } @@ -1372,7 +1392,7 @@ rewrite_function_end () + serializer_count_instrs_in_subscopes ()); } - idx_t id1, id2; + vm_idx_t id1, id2; 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)); @@ -1543,14 +1563,14 @@ dump_delete (jsp_operand_t res, jsp_operand_t op, bool is_strict, locus loc) if (res.is_literal_operand ()) { - const vm_instr_t instr = getop_delete_var (LITERAL_TO_REWRITE, LITERAL_TO_REWRITE); + const vm_instr_t instr = getop_delete_var (VM_IDX_REWRITE_LITERAL_UID, VM_IDX_REWRITE_LITERAL_UID); serializer_dump_op_meta (create_op_meta_110 (instr, res.get_literal (), op.get_literal ())); } else { JERRY_ASSERT (res.is_register_operand ()); - const vm_instr_t instr = getop_delete_var (res.get_idx (), LITERAL_TO_REWRITE); + const vm_instr_t instr = getop_delete_var (res.get_idx (), VM_IDX_REWRITE_LITERAL_UID); serializer_dump_op_meta (create_op_meta_010 (instr, op.get_literal ())); } } @@ -1572,21 +1592,21 @@ dump_delete (jsp_operand_t res, jsp_operand_t op, bool is_strict, locus loc) serializer_set_writing_position (oc); if (res.is_literal_operand ()) { - if (last_op_meta.op.data.prop_getter.obj == LITERAL_TO_REWRITE) + if (last_op_meta.op.data.prop_getter.obj == VM_IDX_REWRITE_LITERAL_UID) { - if (last_op_meta.op.data.prop_getter.prop == LITERAL_TO_REWRITE) + if (last_op_meta.op.data.prop_getter.prop == VM_IDX_REWRITE_LITERAL_UID) { - const vm_instr_t instr = getop_delete_prop (LITERAL_TO_REWRITE, - LITERAL_TO_REWRITE, - LITERAL_TO_REWRITE); + const vm_instr_t instr = getop_delete_prop (VM_IDX_REWRITE_LITERAL_UID, + VM_IDX_REWRITE_LITERAL_UID, + VM_IDX_REWRITE_LITERAL_UID); serializer_dump_op_meta (create_op_meta_111 (instr, res.get_literal (), last_op_meta.lit_id[1], last_op_meta.lit_id[2])); } else { - const vm_instr_t instr = getop_delete_prop (LITERAL_TO_REWRITE, - LITERAL_TO_REWRITE, + const vm_instr_t instr = getop_delete_prop (VM_IDX_REWRITE_LITERAL_UID, + VM_IDX_REWRITE_LITERAL_UID, last_op_meta.op.data.prop_getter.prop); serializer_dump_op_meta (create_op_meta_110 (instr, res.get_literal (), last_op_meta.lit_id[1])); @@ -1594,17 +1614,17 @@ dump_delete (jsp_operand_t res, jsp_operand_t op, bool is_strict, locus loc) } else { - if (last_op_meta.op.data.prop_getter.prop == LITERAL_TO_REWRITE) + if (last_op_meta.op.data.prop_getter.prop == VM_IDX_REWRITE_LITERAL_UID) { - const vm_instr_t instr = getop_delete_prop (LITERAL_TO_REWRITE, + const vm_instr_t instr = getop_delete_prop (VM_IDX_REWRITE_LITERAL_UID, last_op_meta.op.data.prop_getter.obj, - LITERAL_TO_REWRITE); + VM_IDX_REWRITE_LITERAL_UID); serializer_dump_op_meta (create_op_meta_101 (instr, res.get_literal (), last_op_meta.lit_id[2])); } else { - const vm_instr_t instr = getop_delete_prop (LITERAL_TO_REWRITE, + const vm_instr_t instr = getop_delete_prop (VM_IDX_REWRITE_LITERAL_UID, 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.get_literal ())); @@ -1615,31 +1635,31 @@ dump_delete (jsp_operand_t res, jsp_operand_t op, bool is_strict, locus loc) { JERRY_ASSERT (res.is_register_operand ()); - if (last_op_meta.op.data.prop_getter.obj == LITERAL_TO_REWRITE) + if (last_op_meta.op.data.prop_getter.obj == VM_IDX_REWRITE_LITERAL_UID) { - if (last_op_meta.op.data.prop_getter.prop == LITERAL_TO_REWRITE) + if (last_op_meta.op.data.prop_getter.prop == VM_IDX_REWRITE_LITERAL_UID) { const vm_instr_t instr = getop_delete_prop (res.get_idx (), - LITERAL_TO_REWRITE, - LITERAL_TO_REWRITE); + VM_IDX_REWRITE_LITERAL_UID, + VM_IDX_REWRITE_LITERAL_UID); serializer_dump_op_meta (create_op_meta_011 (instr, last_op_meta.lit_id[1], last_op_meta.lit_id[2])); } else { const vm_instr_t instr = getop_delete_prop (res.get_idx (), - LITERAL_TO_REWRITE, + VM_IDX_REWRITE_LITERAL_UID, 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) + if (last_op_meta.op.data.prop_getter.prop == VM_IDX_REWRITE_LITERAL_UID) { const vm_instr_t instr = getop_delete_prop (res.get_idx (), last_op_meta.op.data.prop_getter.obj, - LITERAL_TO_REWRITE); + VM_IDX_REWRITE_LITERAL_UID); serializer_dump_op_meta (create_op_meta_001 (instr, last_op_meta.lit_id[2])); } else @@ -1990,14 +2010,18 @@ dump_logical_and_check_for_rewrite (jsp_operand_t op) if (op.is_literal_operand ()) { - const vm_instr_t instr = getop_is_false_jmp_down (LITERAL_TO_REWRITE, INVALID_VALUE, INVALID_VALUE); + const vm_instr_t instr = getop_is_false_jmp_down (VM_IDX_REWRITE_LITERAL_UID, + VM_IDX_REWRITE_GENERAL_CASE, + VM_IDX_REWRITE_GENERAL_CASE); serializer_dump_op_meta (create_op_meta_100 (instr, op.get_literal ())); } else { JERRY_ASSERT (op.is_register_operand ()); - const vm_instr_t instr = getop_is_false_jmp_down (op.get_idx (), INVALID_VALUE, INVALID_VALUE); + const vm_instr_t instr = getop_is_false_jmp_down (op.get_idx (), + VM_IDX_REWRITE_GENERAL_CASE, + VM_IDX_REWRITE_GENERAL_CASE); serializer_dump_op_meta (create_op_meta_000 (instr)); } } @@ -2009,7 +2033,7 @@ 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; + vm_idx_t id1, 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; @@ -2032,14 +2056,18 @@ dump_logical_or_check_for_rewrite (jsp_operand_t op) if (op.is_literal_operand ()) { - const vm_instr_t instr = getop_is_true_jmp_down (LITERAL_TO_REWRITE, INVALID_VALUE, INVALID_VALUE); + const vm_instr_t instr = getop_is_true_jmp_down (VM_IDX_REWRITE_LITERAL_UID, + VM_IDX_REWRITE_GENERAL_CASE, + VM_IDX_REWRITE_GENERAL_CASE); serializer_dump_op_meta (create_op_meta_100 (instr, op.get_literal ())); } else { JERRY_ASSERT (op.is_register_operand ()); - const vm_instr_t instr = getop_is_true_jmp_down (op.get_idx (), INVALID_VALUE, INVALID_VALUE); + const vm_instr_t instr = getop_is_true_jmp_down (op.get_idx (), + VM_IDX_REWRITE_GENERAL_CASE, + VM_IDX_REWRITE_GENERAL_CASE); serializer_dump_op_meta (create_op_meta_000 (instr)); } } @@ -2051,7 +2079,7 @@ 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; + vm_idx_t id1, 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; @@ -2067,14 +2095,18 @@ dump_conditional_check_for_rewrite (jsp_operand_t op) STACK_PUSH (conditional_checks, serializer_get_current_instr_counter ()); if (op.is_literal_operand ()) { - const vm_instr_t instr = getop_is_false_jmp_down (LITERAL_TO_REWRITE, INVALID_VALUE, INVALID_VALUE); + const vm_instr_t instr = getop_is_false_jmp_down (VM_IDX_REWRITE_LITERAL_UID, + VM_IDX_REWRITE_GENERAL_CASE, + VM_IDX_REWRITE_GENERAL_CASE); serializer_dump_op_meta (create_op_meta_100 (instr, op.get_literal ())); } else { JERRY_ASSERT (op.is_register_operand ()); - const vm_instr_t instr = getop_is_false_jmp_down (op.get_idx (), INVALID_VALUE, INVALID_VALUE); + const vm_instr_t instr = getop_is_false_jmp_down (op.get_idx (), + VM_IDX_REWRITE_GENERAL_CASE, + VM_IDX_REWRITE_GENERAL_CASE); serializer_dump_op_meta (create_op_meta_000 (instr)); } } @@ -2084,7 +2116,7 @@ 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; + vm_idx_t id1, 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; @@ -2096,7 +2128,7 @@ void dump_jump_to_end_for_rewrite (void) { STACK_PUSH (jumps_to_end, serializer_get_current_instr_counter ()); - const vm_instr_t instr = getop_jmp_down (INVALID_VALUE, INVALID_VALUE); + const vm_instr_t instr = getop_jmp_down (VM_IDX_REWRITE_GENERAL_CASE, VM_IDX_REWRITE_GENERAL_CASE); serializer_dump_op_meta (create_op_meta_000 (instr)); } @@ -2105,7 +2137,7 @@ 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; + vm_idx_t id1, 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; @@ -2225,7 +2257,7 @@ dump_continue_iterations_check (jsp_operand_t op) { 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; + vm_idx_t id1, id2; split_instr_counter (next_iteration_target_diff, &id1, &id2); if (operand_is_empty (op)) { @@ -2236,7 +2268,7 @@ dump_continue_iterations_check (jsp_operand_t op) { if (op.is_literal_operand ()) { - const vm_instr_t instr = getop_is_true_jmp_up (LITERAL_TO_REWRITE, id1, id2); + const vm_instr_t instr = getop_is_true_jmp_up (VM_IDX_REWRITE_LITERAL_UID, id1, id2); serializer_dump_op_meta (create_op_meta_100 (instr, op.get_literal ())); } else @@ -2266,7 +2298,7 @@ dump_simple_or_nested_jump_for_rewrite (bool is_simple_jump, /**< flag indicatin * the same target - if any, * or MAX_OPCODES - otherwise */ { - idx_t id1, id2; + vm_idx_t id1, id2; split_instr_counter (next_jump_for_tgt_oc, &id1, &id2); vm_instr_t instr; @@ -2302,7 +2334,7 @@ rewrite_simple_or_nested_jump_and_get_next (vm_instr_counter_t jump_oc, /**< pos JERRY_ASSERT (is_simple_jump || (jump_op_meta.op.op_idx == VM_OP_JMP_BREAK_CONTINUE)); - idx_t id1, id2, id1_prev, id2_prev; + vm_idx_t id1, id2, id1_prev, id2_prev; split_instr_counter ((vm_instr_counter_t) (target_oc - jump_oc), &id1, &id2); if (is_simple_jump) @@ -2342,7 +2374,9 @@ dump_case_clause_check_for_rewrite (jsp_operand_t switch_expr, jsp_operand_t cas const jsp_operand_t res = tmp_operand (); dump_triple_address (getop_equal_value_type, res, switch_expr, case_expr); STACK_PUSH (case_clauses, serializer_get_current_instr_counter ()); - const vm_instr_t instr = getop_is_true_jmp_down (res.get_idx (), INVALID_VALUE, INVALID_VALUE); + const vm_instr_t instr = getop_is_true_jmp_down (res.get_idx (), + VM_IDX_REWRITE_GENERAL_CASE, + VM_IDX_REWRITE_GENERAL_CASE); serializer_dump_op_meta (create_op_meta_000 (instr)); } @@ -2350,7 +2384,7 @@ void dump_default_clause_check_for_rewrite (void) { STACK_PUSH (case_clauses, serializer_get_current_instr_counter ()); - const vm_instr_t instr = getop_jmp_down (INVALID_VALUE, INVALID_VALUE); + const vm_instr_t instr = getop_jmp_down (VM_IDX_REWRITE_GENERAL_CASE, VM_IDX_REWRITE_GENERAL_CASE); serializer_dump_op_meta (create_op_meta_000 (instr)); } @@ -2358,7 +2392,7 @@ void rewrite_case_clause (void) { const vm_instr_counter_t jmp_oc = STACK_ELEMENT (case_clauses, STACK_HEAD (U8, 2)); - idx_t id1, id2; + vm_idx_t 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); @@ -2372,7 +2406,7 @@ void rewrite_default_clause (void) { const vm_instr_counter_t jmp_oc = STACK_TOP (case_clauses); - idx_t id1, id2; + vm_idx_t 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); @@ -2405,14 +2439,16 @@ dump_with_for_rewrite (jsp_operand_t op) /**< jsp_operand_t - result of evaluati if (op.is_literal_operand ()) { - const vm_instr_t instr = getop_with (LITERAL_TO_REWRITE, INVALID_VALUE, INVALID_VALUE); + const vm_instr_t instr = getop_with (VM_IDX_REWRITE_LITERAL_UID, + VM_IDX_REWRITE_GENERAL_CASE, + VM_IDX_REWRITE_GENERAL_CASE); serializer_dump_op_meta (create_op_meta_100 (instr, op.get_literal ())); } else { JERRY_ASSERT (op.is_register_operand ()); - const vm_instr_t instr = getop_with (op.get_idx (), INVALID_VALUE, INVALID_VALUE); + const vm_instr_t instr = getop_with (op.get_idx (), VM_IDX_REWRITE_GENERAL_CASE, VM_IDX_REWRITE_GENERAL_CASE); serializer_dump_op_meta (create_op_meta_000 (instr)); } @@ -2428,7 +2464,7 @@ rewrite_with (vm_instr_counter_t oc) /**< instr counter of the instruction templ { op_meta with_op_meta = serializer_get_op_meta (oc); - idx_t id1, id2; + vm_idx_t 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; @@ -2441,7 +2477,7 @@ rewrite_with (vm_instr_counter_t oc) /**< instr counter of the instruction templ void dump_with_end (void) { - const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_END_WITH, INVALID_VALUE, INVALID_VALUE); + const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_END_WITH, VM_IDX_EMPTY, VM_IDX_EMPTY); serializer_dump_op_meta (create_op_meta_000 (instr)); } /* dump_with_end */ @@ -2461,14 +2497,16 @@ dump_for_in_for_rewrite (jsp_operand_t op) /**< jsp_operand_t - result of evalua if (op.is_literal_operand ()) { - const vm_instr_t instr = getop_for_in (LITERAL_TO_REWRITE, INVALID_VALUE, INVALID_VALUE); + const vm_instr_t instr = getop_for_in (VM_IDX_REWRITE_LITERAL_UID, + VM_IDX_REWRITE_GENERAL_CASE, + VM_IDX_REWRITE_GENERAL_CASE); serializer_dump_op_meta (create_op_meta_100 (instr, op.get_literal ())); } else { JERRY_ASSERT (op.is_register_operand ()); - const vm_instr_t instr = getop_for_in (op.get_idx (), INVALID_VALUE, INVALID_VALUE); + const vm_instr_t instr = getop_for_in (op.get_idx (), VM_IDX_REWRITE_GENERAL_CASE, VM_IDX_REWRITE_GENERAL_CASE); serializer_dump_op_meta (create_op_meta_000 (instr)); } @@ -2484,7 +2522,7 @@ rewrite_for_in (vm_instr_counter_t oc) /**< instr counter of the instruction tem { op_meta for_in_op_meta = serializer_get_op_meta (oc); - idx_t id1, id2; + vm_idx_t 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; @@ -2497,7 +2535,7 @@ rewrite_for_in (vm_instr_counter_t oc) /**< instr counter of the instruction tem void dump_for_in_end (void) { - const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_END_FOR_IN, INVALID_VALUE, INVALID_VALUE); + const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_END_FOR_IN, VM_IDX_EMPTY, VM_IDX_EMPTY); serializer_dump_op_meta (create_op_meta_000 (instr)); } /* dump_for_in_end */ @@ -2505,7 +2543,7 @@ void dump_try_for_rewrite (void) { STACK_PUSH (tries, serializer_get_current_instr_counter ()); - const vm_instr_t instr = getop_try_block (INVALID_VALUE, INVALID_VALUE); + const vm_instr_t instr = getop_try_block (VM_IDX_REWRITE_GENERAL_CASE, VM_IDX_REWRITE_GENERAL_CASE); serializer_dump_op_meta (create_op_meta_000 (instr)); } @@ -2514,7 +2552,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; + vm_idx_t 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; @@ -2527,9 +2565,9 @@ dump_catch_for_rewrite (jsp_operand_t op) { JERRY_ASSERT (op.is_literal_operand ()); STACK_PUSH (catches, serializer_get_current_instr_counter ()); - vm_instr_t instr = getop_meta (OPCODE_META_TYPE_CATCH, INVALID_VALUE, INVALID_VALUE); + vm_instr_t instr = getop_meta (OPCODE_META_TYPE_CATCH, VM_IDX_REWRITE_GENERAL_CASE, VM_IDX_REWRITE_GENERAL_CASE); serializer_dump_op_meta (create_op_meta_000 (instr)); - instr = getop_meta (OPCODE_META_TYPE_CATCH_EXCEPTION_IDENTIFIER, LITERAL_TO_REWRITE, INVALID_VALUE); + instr = getop_meta (OPCODE_META_TYPE_CATCH_EXCEPTION_IDENTIFIER, VM_IDX_REWRITE_LITERAL_UID, VM_IDX_EMPTY); serializer_dump_op_meta (create_op_meta_010 (instr, op.get_literal ())); } @@ -2539,7 +2577,7 @@ rewrite_catch (void) op_meta catch_op_meta = serializer_get_op_meta (STACK_TOP (catches)); 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; + vm_idx_t 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; @@ -2551,7 +2589,9 @@ void dump_finally_for_rewrite (void) { STACK_PUSH (finallies, serializer_get_current_instr_counter ()); - const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_FINALLY, INVALID_VALUE, INVALID_VALUE); + const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_FINALLY, + VM_IDX_REWRITE_GENERAL_CASE, + VM_IDX_REWRITE_GENERAL_CASE); serializer_dump_op_meta (create_op_meta_000 (instr)); } @@ -2561,7 +2601,7 @@ rewrite_finally (void) op_meta finally_op_meta = serializer_get_op_meta (STACK_TOP (finallies)); 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; + vm_idx_t 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; @@ -2573,7 +2613,7 @@ void dump_end_try_catch_finally (void) { const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_END_TRY_CATCH_FINALLY, - INVALID_VALUE, INVALID_VALUE); + VM_IDX_EMPTY, VM_IDX_EMPTY); serializer_dump_op_meta (create_op_meta_000 (instr)); } @@ -2610,7 +2650,7 @@ dumper_variable_declaration_exists (lit_cpointer_t lit_id) /**< literal which ho void dump_variable_declaration (lit_cpointer_t lit_id) /**< literal which holds variable's name */ { - const vm_instr_t instr = getop_var_decl (LITERAL_TO_REWRITE); + const vm_instr_t instr = getop_var_decl (VM_IDX_REWRITE_LITERAL_UID); serializer_dump_var_decl (create_op_meta_100 (instr, lit_id)); } /* dump_variable_declaration */ @@ -2627,7 +2667,7 @@ dump_scope_code_flags_for_rewrite (void) { vm_instr_counter_t oc = serializer_get_current_instr_counter (); - const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_SCOPE_CODE_FLAGS, INVALID_VALUE, INVALID_VALUE); + const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_SCOPE_CODE_FLAGS, VM_IDX_REWRITE_GENERAL_CASE, VM_IDX_EMPTY); serializer_dump_op_meta (create_op_meta_000 (instr)); return oc; @@ -2641,15 +2681,15 @@ void 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); + JERRY_ASSERT ((vm_idx_t) scope_flags == scope_flags); op_meta opm = serializer_get_op_meta (scope_code_flags_oc); JERRY_ASSERT (opm.op.op_idx == VM_OP_META); JERRY_ASSERT (opm.op.data.meta.type == OPCODE_META_TYPE_SCOPE_CODE_FLAGS); - JERRY_ASSERT (opm.op.data.meta.data_1 == INVALID_VALUE); - JERRY_ASSERT (opm.op.data.meta.data_2 == INVALID_VALUE); + JERRY_ASSERT (opm.op.data.meta.data_1 == VM_IDX_REWRITE_GENERAL_CASE); + JERRY_ASSERT (opm.op.data.meta.data_2 == VM_IDX_EMPTY); - opm.op.data.meta.data_1 = (idx_t) scope_flags; + opm.op.data.meta.data_1 = (vm_idx_t) scope_flags; serializer_rewrite_op_meta (scope_code_flags_oc, opm); } /* rewrite_scope_code_flags */ @@ -2663,7 +2703,9 @@ void dump_reg_var_decl_for_rewrite (void) { 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, INVALID_VALUE))); + serializer_dump_op_meta (create_op_meta_000 (getop_reg_var_decl (VM_REG_FIRST, + VM_IDX_REWRITE_GENERAL_CASE, + VM_IDX_REWRITE_GENERAL_CASE))); } void @@ -2673,13 +2715,13 @@ rewrite_reg_var_decl (void) op_meta opm = serializer_get_op_meta (reg_var_decl_oc); JERRY_ASSERT (opm.op.op_idx == VM_OP_REG_VAR_DECL); - if (jsp_reg_max_for_local_var != INVALID_VALUE) + if (jsp_reg_max_for_local_var != VM_IDX_EMPTY) { JERRY_ASSERT (jsp_reg_max_for_local_var >= jsp_reg_max_for_temps); - opm.op.data.reg_var_decl.local_var_regs_num = (idx_t) (jsp_reg_max_for_local_var - jsp_reg_max_for_temps); + opm.op.data.reg_var_decl.local_var_regs_num = (vm_idx_t) (jsp_reg_max_for_local_var - jsp_reg_max_for_temps); opm.op.data.reg_var_decl.max = jsp_reg_max_for_local_var; - jsp_reg_max_for_local_var = INVALID_VALUE; + jsp_reg_max_for_local_var = VM_IDX_EMPTY; } else { @@ -2699,9 +2741,9 @@ dump_retval (jsp_operand_t op) void dumper_init (void) { - jsp_reg_next = OPCODE_REG_GENERAL_FIRST; - jsp_reg_max_for_temps = OPCODE_REG_GENERAL_FIRST; - jsp_reg_max_for_local_var = INVALID_VALUE; + jsp_reg_next = VM_REG_GENERAL_FIRST; + jsp_reg_max_for_temps = VM_REG_GENERAL_FIRST; + jsp_reg_max_for_local_var = VM_IDX_EMPTY; STACK_INIT (U8); STACK_INIT (varg_headers); diff --git a/jerry-core/parser/js/opcodes-dumper.h b/jerry-core/parser/js/opcodes-dumper.h index d4ab01911..ddb8aa4d9 100644 --- a/jerry-core/parser/js/opcodes-dumper.h +++ b/jerry-core/parser/js/opcodes-dumper.h @@ -89,10 +89,19 @@ public: * @return constructed operand */ static jsp_operand_t - make_reg_operand (idx_t reg_index) /**< register index */ + make_reg_operand (vm_idx_t reg_index) /**< register index */ { - JERRY_ASSERT (reg_index != INVALID_VALUE - && reg_index != LITERAL_TO_REWRITE); + /* + * The following check currently leads to 'comparison is always true + * due to limited range of data type' warning, so it is turned off. + * + * If VM_IDX_GENERAL_VALUE_FIRST is changed to value greater than 0, + * the check should be restored. + */ + // JERRY_ASSERT (reg_index >= VM_IDX_GENERAL_VALUE_FIRST); + static_assert (VM_IDX_GENERAL_VALUE_FIRST == 0, "See comment above"); + + JERRY_ASSERT (reg_index <= VM_IDX_GENERAL_VALUE_LAST); jsp_operand_t ret; @@ -142,12 +151,12 @@ public: } /* is_literal_operand */ /** - * Get idx_t for operand + * Get idx for operand * - * @return LITERAL_TO_REWRITE (for jsp_operand_t::LITERAL), + * @return VM_IDX_REWRITE_LITERAL_UID (for jsp_operand_t::LITERAL), * or register index (for jsp_operand_t::TMP). */ - idx_t + vm_idx_t get_idx (void) const { JERRY_ASSERT (_type != jsp_operand_t::UNINITIALIZED); @@ -158,13 +167,13 @@ public: } else if (_type == jsp_operand_t::LITERAL) { - return LITERAL_TO_REWRITE; + return VM_IDX_REWRITE_LITERAL_UID; } else { JERRY_ASSERT (_type == jsp_operand_t::EMPTY); - return INVALID_VALUE; + return VM_IDX_EMPTY; } } /* get_idx */ @@ -198,7 +207,7 @@ public: private: union { - idx_t uid; /**< byte-code register index (for jsp_operand_t::TMP) */ + vm_idx_t uid; /**< byte-code register index (for jsp_operand_t::TMP) */ lit_cpointer_t lit_id; /**< literal (for jsp_operand_t::LITERAL) */ } _data; @@ -243,8 +252,8 @@ void dump_number_assignment (jsp_operand_t, lit_cpointer_t); jsp_operand_t dump_number_assignment_res (lit_cpointer_t); void dump_regexp_assignment (jsp_operand_t, lit_cpointer_t); jsp_operand_t dump_regexp_assignment_res (lit_cpointer_t); -void dump_smallint_assignment (jsp_operand_t, idx_t); -jsp_operand_t dump_smallint_assignment_res (idx_t); +void dump_smallint_assignment (jsp_operand_t, vm_idx_t); +jsp_operand_t dump_smallint_assignment_res (vm_idx_t); void dump_undefined_assignment (jsp_operand_t); jsp_operand_t dump_undefined_assignment_res (void); void dump_null_assignment (jsp_operand_t); diff --git a/jerry-core/parser/js/parser.cpp b/jerry-core/parser/js/parser.cpp index 21a1fb3ae..ac1f6e07b 100644 --- a/jerry-core/parser/js/parser.cpp +++ b/jerry-core/parser/js/parser.cpp @@ -803,7 +803,7 @@ parse_literal (void) case TOK_REGEXP: return dump_regexp_assignment_res (token_data_as_lit_cp ()); case TOK_NULL: return dump_null_assignment_res (); case TOK_BOOL: return dump_boolean_assignment_res ((bool) token_data ()); - case TOK_SMALL_INT: return dump_smallint_assignment_res ((idx_t) token_data ()); + case TOK_SMALL_INT: return dump_smallint_assignment_res ((vm_idx_t) token_data ()); default: { EMIT_ERROR (JSP_EARLY_ERROR_SYNTAX, "Expected literal"); @@ -2073,7 +2073,7 @@ jsp_parse_for_in_statement_iterator (jsp_operand_t *base_p, /**< out: base value * tmp <- Collection (Expression) * for_in instruction (tmp, instruction counter of for-in end mark) * { - * Assignment of OPCODE_REG_SPECIAL_FOR_IN_PROPERTY_NAME to + * Assignment of VM_REG_SPECIAL_FOR_IN_PROPERTY_NAME to * Iterator (VariableDeclarationNoIn / LeftHandSideExpression) * } * Body (Statement) @@ -2127,7 +2127,7 @@ jsp_parse_for_in_statement (jsp_label_t *outermost_stmt_label_p, /**< outermost // Dump for-in instruction vm_instr_counter_t for_in_oc = dump_for_in_for_rewrite (collection); - // Dump assignment VariableDeclarationNoIn / LeftHandSideExpression <- OPCODE_REG_SPECIAL_FOR_IN_PROPERTY_NAME + // Dump assignment VariableDeclarationNoIn / LeftHandSideExpression <- VM_REG_SPECIAL_FOR_IN_PROPERTY_NAME lexer_seek (iterator_loc); tok = lexer_next_token (); diff --git a/jerry-core/parser/js/scopes-tree.cpp b/jerry-core/parser/js/scopes-tree.cpp index 8035ed2ac..a8120f090 100644 --- a/jerry-core/parser/js/scopes-tree.cpp +++ b/jerry-core/parser/js/scopes-tree.cpp @@ -21,7 +21,7 @@ static hash_table lit_id_to_uid = null_hash; static vm_instr_counter_t global_oc; -static idx_t next_uid; +static vm_idx_t next_uid; static void assert_tree (scopes_tree t) @@ -29,7 +29,7 @@ assert_tree (scopes_tree t) JERRY_ASSERT (t != NULL); } -static idx_t +static vm_idx_t get_uid (op_meta *op, uint8_t i) { JERRY_ASSERT (i < 4); @@ -38,7 +38,7 @@ get_uid (op_meta *op, uint8_t i) } static void -set_uid (op_meta *op, uint8_t i, idx_t uid) +set_uid (op_meta *op, uint8_t i, vm_idx_t uid) { JERRY_ASSERT (i < 4); raw_instr *raw = (raw_instr *) &op->op; @@ -151,7 +151,7 @@ start_new_block_if_necessary (void) hash_table_free (lit_id_to_uid); lit_id_to_uid = null_hash; } - lit_id_to_uid = hash_table_init (sizeof (lit_cpointer_t), sizeof (idx_t), HASH_SIZE, lit_id_hash); + lit_id_to_uid = hash_table_init (sizeof (lit_cpointer_t), sizeof (vm_idx_t), HASH_SIZE, lit_id_hash); } } @@ -188,16 +188,16 @@ change_uid (op_meta *om, lit_id_hash_table *lit_ids, uint16_t mask) { if (is_possible_literal (mask, i)) { - if (get_uid (om, i) == LITERAL_TO_REWRITE) + if (get_uid (om, i) == VM_IDX_REWRITE_LITERAL_UID) { JERRY_ASSERT (om->lit_id[i].packed_value != MEM_CP_NULL); lit_cpointer_t lit_id = om->lit_id[i]; - idx_t *uid = (idx_t *) hash_table_lookup (lit_id_to_uid, &lit_id); + vm_idx_t *uid = (vm_idx_t *) hash_table_lookup (lit_id_to_uid, &lit_id); if (uid == NULL) { hash_table_insert (lit_id_to_uid, &lit_id, &next_uid); lit_id_hash_table_insert (lit_ids, next_uid, global_oc, lit_id); - uid = (idx_t *) hash_table_lookup (lit_id_to_uid, &lit_id); + uid = (vm_idx_t *) hash_table_lookup (lit_id_to_uid, &lit_id); JERRY_ASSERT (uid != NULL); JERRY_ASSERT (*uid == next_uid); next_uid++; @@ -223,15 +223,15 @@ insert_uids_to_lit_id_map (op_meta *om, uint16_t mask) { if (is_possible_literal (mask, i)) { - if (get_uid (om, i) == LITERAL_TO_REWRITE) + if (get_uid (om, i) == VM_IDX_REWRITE_LITERAL_UID) { JERRY_ASSERT (om->lit_id[i].packed_value != MEM_CP_NULL); lit_cpointer_t lit_id = om->lit_id[i]; - idx_t *uid = (idx_t *) hash_table_lookup (lit_id_to_uid, &lit_id); + vm_idx_t *uid = (vm_idx_t *) hash_table_lookup (lit_id_to_uid, &lit_id); if (uid == NULL) { hash_table_insert (lit_id_to_uid, &lit_id, &next_uid); - uid = (idx_t *) hash_table_lookup (lit_id_to_uid, &lit_id); + uid = (vm_idx_t *) hash_table_lookup (lit_id_to_uid, &lit_id); JERRY_ASSERT (uid != NULL); JERRY_ASSERT (*uid == next_uid); next_uid++; @@ -416,11 +416,11 @@ generate_instr (linked_list instr_list, /**< instruction list */ * * @return number of new literals */ -static idx_t +static vm_idx_t count_new_literals_in_instr (op_meta *om_p) /**< instruction */ { start_new_block_if_necessary (); - idx_t current_uid = next_uid; + vm_idx_t current_uid = next_uid; switch (om_p->op.op_idx) { case VM_OP_PROP_GETTER: @@ -549,7 +549,7 @@ count_new_literals_in_instr (op_meta *om_p) /**< instruction */ break; } } - return (idx_t) (next_uid - current_uid); + return (vm_idx_t) (next_uid - current_uid); } /* count_new_literals_in_instr */ /** diff --git a/jerry-core/vm/opcodes-agnostic.cpp b/jerry-core/vm/opcodes-agnostic.cpp index b601e630f..9b4929186 100644 --- a/jerry-core/vm/opcodes-agnostic.cpp +++ b/jerry-core/vm/opcodes-agnostic.cpp @@ -27,7 +27,7 @@ ecma_completion_value_t 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 = instr.data.is_true_jmp_down.value; + const vm_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); @@ -60,7 +60,7 @@ ecma_completion_value_t 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 = instr.data.is_true_jmp_up.value; + const vm_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); @@ -99,7 +99,7 @@ ecma_completion_value_t 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 = instr.data.is_false_jmp_down.value; + const vm_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); @@ -132,7 +132,7 @@ ecma_completion_value_t 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 = instr.data.is_false_jmp_up.value; + const vm_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); diff --git a/jerry-core/vm/opcodes-ecma-arithmetics.cpp b/jerry-core/vm/opcodes-ecma-arithmetics.cpp index 0e1c12fd5..7dfdaa2bf 100644 --- a/jerry-core/vm/opcodes-ecma-arithmetics.cpp +++ b/jerry-core/vm/opcodes-ecma-arithmetics.cpp @@ -43,7 +43,7 @@ typedef enum */ static ecma_completion_value_t do_number_arithmetic (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */ - idx_t dst_var_idx, /**< destination variable identifier */ + vm_idx_t dst_var_idx, /**< destination variable identifier */ number_arithmetic_op op, /**< number arithmetic operation */ ecma_value_t left_value, /**< left value */ ecma_value_t right_value) /** right value */ @@ -106,9 +106,9 @@ ecma_completion_value_t opfunc_addition (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - 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; + const vm_idx_t dst_var_idx = instr.data.addition.dst; + const vm_idx_t left_var_idx = instr.data.addition.var_left; + const vm_idx_t right_var_idx = instr.data.addition.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -172,9 +172,9 @@ ecma_completion_value_t opfunc_substraction (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - 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; + const vm_idx_t dst_var_idx = instr.data.substraction.dst; + const vm_idx_t left_var_idx = instr.data.substraction.var_left; + const vm_idx_t right_var_idx = instr.data.substraction.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -207,9 +207,9 @@ ecma_completion_value_t opfunc_multiplication (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - 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; + const vm_idx_t dst_var_idx = instr.data.multiplication.dst; + const vm_idx_t left_var_idx = instr.data.multiplication.var_left; + const vm_idx_t right_var_idx = instr.data.multiplication.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -242,9 +242,9 @@ ecma_completion_value_t opfunc_division (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - 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; + const vm_idx_t dst_var_idx = instr.data.division.dst; + const vm_idx_t left_var_idx = instr.data.division.var_left; + const vm_idx_t right_var_idx = instr.data.division.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -277,9 +277,9 @@ ecma_completion_value_t opfunc_remainder (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - 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; + const vm_idx_t dst_var_idx = instr.data.remainder.dst; + const vm_idx_t left_var_idx = instr.data.remainder.var_left; + const vm_idx_t right_var_idx = instr.data.remainder.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -312,8 +312,8 @@ ecma_completion_value_t opfunc_unary_plus (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = instr.data.remainder.dst; - const idx_t var_idx = instr.data.remainder.var_left; + const vm_idx_t dst_var_idx = instr.data.remainder.dst; + const vm_idx_t var_idx = instr.data.remainder.var_left; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -349,8 +349,8 @@ ecma_completion_value_t opfunc_unary_minus (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = instr.data.remainder.dst; - const idx_t var_idx = instr.data.remainder.var_left; + const vm_idx_t dst_var_idx = instr.data.remainder.dst; + const vm_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 fa06c4c81..15d6a3507 100644 --- a/jerry-core/vm/opcodes-ecma-bitwise.cpp +++ b/jerry-core/vm/opcodes-ecma-bitwise.cpp @@ -43,7 +43,7 @@ typedef enum */ static ecma_completion_value_t do_number_bitwise_logic (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */ - idx_t dst_var_idx, /**< destination variable identifier */ + vm_idx_t dst_var_idx, /**< destination variable identifier */ number_bitwise_logic_op op, /**< number bitwise logic operation */ ecma_value_t left_value, /**< left value */ ecma_value_t right_value) /** right value */ @@ -122,9 +122,9 @@ ecma_completion_value_t opfunc_b_and (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - 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; + const vm_idx_t dst_var_idx = instr.data.b_and.dst; + const vm_idx_t left_var_idx = instr.data.b_and.var_left; + const vm_idx_t right_var_idx = instr.data.b_and.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -157,9 +157,9 @@ ecma_completion_value_t opfunc_b_or (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - 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; + const vm_idx_t dst_var_idx = instr.data.b_or.dst; + const vm_idx_t left_var_idx = instr.data.b_or.var_left; + const vm_idx_t right_var_idx = instr.data.b_or.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -192,9 +192,9 @@ ecma_completion_value_t opfunc_b_xor (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - 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; + const vm_idx_t dst_var_idx = instr.data.b_xor.dst; + const vm_idx_t left_var_idx = instr.data.b_xor.var_left; + const vm_idx_t right_var_idx = instr.data.b_xor.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -227,9 +227,9 @@ ecma_completion_value_t opfunc_b_shift_left (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - 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; + const vm_idx_t dst_var_idx = instr.data.b_shift_left.dst; + const vm_idx_t left_var_idx = instr.data.b_shift_left.var_left; + const vm_idx_t right_var_idx = instr.data.b_shift_left.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -262,9 +262,9 @@ ecma_completion_value_t opfunc_b_shift_right (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - 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; + const vm_idx_t dst_var_idx = instr.data.b_shift_right.dst; + const vm_idx_t left_var_idx = instr.data.b_shift_right.var_left; + const vm_idx_t right_var_idx = instr.data.b_shift_right.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -297,9 +297,9 @@ ecma_completion_value_t opfunc_b_shift_uright (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - 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; + const vm_idx_t dst_var_idx = instr.data.b_shift_uright.dst; + const vm_idx_t left_var_idx = instr.data.b_shift_uright.var_left; + const vm_idx_t right_var_idx = instr.data.b_shift_uright.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -332,8 +332,8 @@ ecma_completion_value_t opfunc_b_not (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = instr.data.b_not.dst; - const idx_t right_var_idx = instr.data.b_not.var_right; + const vm_idx_t dst_var_idx = instr.data.b_not.dst; + const vm_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 24795e641..3f9caaac9 100644 --- a/jerry-core/vm/opcodes-ecma-equality.cpp +++ b/jerry-core/vm/opcodes-ecma-equality.cpp @@ -28,9 +28,9 @@ ecma_completion_value_t opfunc_equal_value (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - 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; + const vm_idx_t dst_var_idx = instr.data.equal_value.dst; + const vm_idx_t left_var_idx = instr.data.equal_value.var_left; + const vm_idx_t right_var_idx = instr.data.equal_value.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -67,9 +67,9 @@ ecma_completion_value_t opfunc_not_equal_value (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - 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; + const vm_idx_t dst_var_idx = instr.data.not_equal_value.dst; + const vm_idx_t left_var_idx = instr.data.not_equal_value.var_left; + const vm_idx_t right_var_idx = instr.data.not_equal_value.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -108,9 +108,9 @@ ecma_completion_value_t opfunc_equal_value_type (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - 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; + const vm_idx_t dst_var_idx = instr.data.equal_value_type.dst; + const vm_idx_t left_var_idx = instr.data.equal_value_type.var_left; + const vm_idx_t right_var_idx = instr.data.equal_value_type.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -143,9 +143,9 @@ ecma_completion_value_t 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 = 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; + const vm_idx_t dst_var_idx = instr.data.not_equal_value_type.dst; + const vm_idx_t left_var_idx = instr.data.not_equal_value_type.var_left; + const vm_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 371580bfa..243bfbb3b 100644 --- a/jerry-core/vm/opcodes-ecma-relational.cpp +++ b/jerry-core/vm/opcodes-ecma-relational.cpp @@ -28,9 +28,9 @@ ecma_completion_value_t opfunc_less_than (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - 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; + const vm_idx_t dst_var_idx = instr.data.less_than.dst; + const vm_idx_t left_var_idx = instr.data.less_than.var_left; + const vm_idx_t right_var_idx = instr.data.less_than.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -76,9 +76,9 @@ ecma_completion_value_t opfunc_greater_than (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - 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; + const vm_idx_t dst_var_idx = instr.data.greater_than.dst; + const vm_idx_t left_var_idx = instr.data.greater_than.var_left; + const vm_idx_t right_var_idx = instr.data.greater_than.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -124,9 +124,9 @@ ecma_completion_value_t 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 = 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; + const vm_idx_t dst_var_idx = instr.data.less_or_equal_than.dst; + const vm_idx_t left_var_idx = instr.data.less_or_equal_than.var_left; + const vm_idx_t right_var_idx = instr.data.less_or_equal_than.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -179,9 +179,9 @@ ecma_completion_value_t 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 = 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; + const vm_idx_t dst_var_idx = instr.data.greater_or_equal_than.dst; + const vm_idx_t left_var_idx = instr.data.greater_or_equal_than.var_left; + const vm_idx_t right_var_idx = instr.data.greater_or_equal_than.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -234,9 +234,9 @@ ecma_completion_value_t 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 = 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; + const vm_idx_t dst_idx = instr.data.instanceof.dst; + const vm_idx_t left_var_idx = instr.data.instanceof.var_left; + const vm_idx_t right_var_idx = instr.data.instanceof.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -280,9 +280,9 @@ ecma_completion_value_t 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 = 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; + const vm_idx_t dst_idx = instr.data.in.dst; + const vm_idx_t left_var_idx = instr.data.in.var_left; + const vm_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 cc988cca5..80f6dd088 100644 --- a/jerry-core/vm/opcodes-ecma-support.h +++ b/jerry-core/vm/opcodes-ecma-support.h @@ -34,9 +34,9 @@ #include "ecma-try-catch-macro.h" #include "serializer.h" -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 *, vm_instr_counter_t, idx_t, ecma_value_t); +bool is_reg_variable (vm_frame_ctx_t *frame_ctx_p, vm_idx_t var_idx); +ecma_completion_value_t get_variable_value (vm_frame_ctx_t *, vm_idx_t, bool); +ecma_completion_value_t set_variable_value (vm_frame_ctx_t *, vm_instr_counter_t, vm_idx_t, ecma_value_t); ecma_completion_value_t vm_fill_varg_list (vm_frame_ctx_t *frame_ctx_p, ecma_length_t args_number, ecma_collection_header_t *args_values_p); diff --git a/jerry-core/vm/opcodes-ecma-try-catch-finally.cpp b/jerry-core/vm/opcodes-ecma-try-catch-finally.cpp index 270f94a44..d066a2ca5 100644 --- a/jerry-core/vm/opcodes-ecma-try-catch-finally.cpp +++ b/jerry-core/vm/opcodes-ecma-try-catch-finally.cpp @@ -30,8 +30,8 @@ ecma_completion_value_t 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 = instr.data.try_block.oc_idx_1; - const idx_t block_end_oc_idx_2 = instr.data.try_block.oc_idx_2; + const vm_idx_t block_end_oc_idx_1 = instr.data.try_block.oc_idx_1; + const vm_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); diff --git a/jerry-core/vm/opcodes-for-in.cpp b/jerry-core/vm/opcodes-for-in.cpp index 0a3658850..2be929fc5 100644 --- a/jerry-core/vm/opcodes-for-in.cpp +++ b/jerry-core/vm/opcodes-for-in.cpp @@ -185,9 +185,9 @@ ecma_completion_value_t opfunc_for_in (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *int_data_p) /**< interpreter context */ { - 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_idx_t expr_idx = instr.data.for_in.expr; + const vm_idx_t block_end_oc_idx_1 = instr.data.for_in.oc_idx_1; + const vm_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); @@ -238,7 +238,7 @@ opfunc_for_in (vm_instr_t instr, /**< instruction */ { ecma_completion_value_t completion = set_variable_value (int_data_p, int_data_p->pos, - OPCODE_REG_SPECIAL_FOR_IN_PROPERTY_NAME, + VM_REG_SPECIAL_FOR_IN_PROPERTY_NAME, name_value); JERRY_ASSERT (ecma_is_completion_value_empty (completion)); diff --git a/jerry-core/vm/opcodes-helpers-variables.cpp b/jerry-core/vm/opcodes-helpers-variables.cpp index c2d6e51d1..3a648eba2 100644 --- a/jerry-core/vm/opcodes-helpers-variables.cpp +++ b/jerry-core/vm/opcodes-helpers-variables.cpp @@ -60,7 +60,7 @@ do_strict_eval_arguments_check (ecma_object_t *ref_base_lex_env_p, /**< base of */ bool is_reg_variable (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */ - idx_t var_idx) /**< variable identifier */ + vm_idx_t var_idx) /**< variable identifier */ { return (var_idx >= frame_ctx_p->min_reg_idx && var_idx <= frame_ctx_p->max_reg_idx); } /* is_reg_variable */ @@ -73,7 +73,7 @@ is_reg_variable (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */ */ ecma_completion_value_t get_variable_value (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */ - idx_t var_idx, /**< variable identifier */ + vm_idx_t var_idx, /**< variable identifier */ bool do_eval_or_arguments_check) /** run 'strict eval or arguments reference' check See also: do_strict_eval_arguments_check */ { @@ -126,7 +126,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 */ vm_instr_counter_t lit_oc, /**< instruction counter for literal */ - idx_t var_idx, /**< variable identifier */ + vm_idx_t var_idx, /**< variable identifier */ ecma_value_t value) /**< value to set */ { ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); diff --git a/jerry-core/vm/opcodes-varg.cpp b/jerry-core/vm/opcodes-varg.cpp index 05df61835..d0ba20e8c 100644 --- a/jerry-core/vm/opcodes-varg.cpp +++ b/jerry-core/vm/opcodes-varg.cpp @@ -46,7 +46,7 @@ vm_fill_varg_list (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */ 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_instr.data.meta.data_1; + const vm_idx_t varg_var_idx = next_instr.data.meta.data_1; ECMA_TRY_CATCH (get_arg, get_variable_value (frame_ctx_p, varg_var_idx, false), diff --git a/jerry-core/vm/opcodes.cpp b/jerry-core/vm/opcodes.cpp index 9af0bd99d..1a68f3895 100644 --- a/jerry-core/vm/opcodes.cpp +++ b/jerry-core/vm/opcodes.cpp @@ -62,9 +62,9 @@ ecma_completion_value_t opfunc_assignment (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = instr.data.assignment.var_left; + const vm_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; + const vm_idx_t src_val_descr = instr.data.assignment.value_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -233,8 +233,8 @@ ecma_completion_value_t opfunc_pre_incr (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = instr.data.pre_incr.dst; - const idx_t incr_var_idx = instr.data.pre_incr.var_right; + const vm_idx_t dst_var_idx = instr.data.pre_incr.dst; + const vm_idx_t incr_var_idx = instr.data.pre_incr.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -280,8 +280,8 @@ ecma_completion_value_t opfunc_pre_decr (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = instr.data.pre_decr.dst; - const idx_t decr_var_idx = instr.data.pre_decr.var_right; + const vm_idx_t dst_var_idx = instr.data.pre_decr.dst; + const vm_idx_t decr_var_idx = instr.data.pre_decr.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -327,8 +327,8 @@ ecma_completion_value_t opfunc_post_incr (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = instr.data.post_incr.dst; - const idx_t incr_var_idx = instr.data.post_incr.var_right; + const vm_idx_t dst_var_idx = instr.data.post_incr.dst; + const vm_idx_t incr_var_idx = instr.data.post_incr.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -375,8 +375,8 @@ ecma_completion_value_t opfunc_post_decr (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = instr.data.post_decr.dst; - const idx_t decr_var_idx = instr.data.post_decr.var_right; + const vm_idx_t dst_var_idx = instr.data.post_decr.dst; + const vm_idx_t decr_var_idx = instr.data.post_decr.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -530,7 +530,7 @@ ecma_completion_value_t opfunc_func_decl_n (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t function_name_idx = instr.data.func_decl_n.name_lit_idx; + const vm_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, @@ -566,10 +566,10 @@ opfunc_func_expr_n (vm_instr_t instr, /**< instruction */ frame_ctx_p->pos++; - 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 vm_idx_t dst_var_idx = instr.data.func_expr_n.lhs; + const vm_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); + const bool is_named_func_expr = (function_name_lit_idx != VM_IDX_EMPTY); ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -662,7 +662,7 @@ static ecma_value_t vm_helper_call_get_call_flags_and_this_arg (vm_frame_ctx_t *int_data_p, /**< interpreter context */ 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 */ + vm_idx_t var_idx, /**< idx, used to retrieve the called function object */ opcode_call_flags_t *out_flags_p) /**< out: call flags */ { JERRY_ASSERT (out_flags_p != NULL); @@ -670,7 +670,7 @@ vm_helper_call_get_call_flags_and_this_arg (vm_frame_ctx_t *int_data_p, /**< int bool is_increase_instruction_pointer; opcode_call_flags_t call_flags = OPCODE_CALL_FLAGS__EMPTY; - idx_t this_arg_var_idx = INVALID_VALUE; + vm_idx_t this_arg_var_idx = VM_IDX_EMPTY; 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 @@ -773,9 +773,9 @@ ecma_completion_value_t opfunc_call_n (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - 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_idx_t lhs_var_idx = instr.data.call_n.lhs; + const vm_idx_t function_var_idx = instr.data.call_n.function_var_idx; + const vm_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 (); @@ -866,9 +866,9 @@ ecma_completion_value_t opfunc_construct_n (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - 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_idx_t lhs_var_idx = instr.data.construct_n.lhs; + const vm_idx_t constructor_name_lit_idx = instr.data.construct_n.name_lit_idx; + const vm_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 (); @@ -935,9 +935,9 @@ ecma_completion_value_t opfunc_array_decl (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t lhs_var_idx = instr.data.array_decl.lhs; - const idx_t args_number_high_byte = instr.data.array_decl.list_1; - const idx_t args_number_low_byte = instr.data.array_decl.list_2; + const vm_idx_t lhs_var_idx = instr.data.array_decl.lhs; + const vm_idx_t args_number_high_byte = instr.data.array_decl.list_1; + const vm_idx_t args_number_low_byte = instr.data.array_decl.list_2; const vm_instr_counter_t lit_oc = frame_ctx_p->pos; frame_ctx_p->pos++; @@ -1009,9 +1009,9 @@ ecma_completion_value_t opfunc_obj_decl (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t lhs_var_idx = instr.data.obj_decl.lhs; - const idx_t args_number_high_byte = instr.data.obj_decl.list_1; - const idx_t args_number_low_byte = instr.data.obj_decl.list_2; + const vm_idx_t lhs_var_idx = instr.data.obj_decl.lhs; + const vm_idx_t args_number_high_byte = instr.data.obj_decl.list_1; + const vm_idx_t args_number_low_byte = instr.data.obj_decl.list_2; const vm_instr_counter_t obj_lit_oc = frame_ctx_p->pos; frame_ctx_p->pos++; @@ -1039,10 +1039,10 @@ opfunc_obj_decl (vm_instr_t instr, /**< instruction */ || type == OPCODE_META_TYPE_VARG_PROP_GETTER || type == OPCODE_META_TYPE_VARG_PROP_SETTER); - const idx_t prop_name_var_idx = next_opcode.data.meta.data_1; + const vm_idx_t prop_name_var_idx = next_opcode.data.meta.data_1; JERRY_ASSERT (is_reg_variable (frame_ctx_p, prop_name_var_idx)); - const idx_t value_for_prop_desc_var_idx = next_opcode.data.meta.data_2; + const vm_idx_t value_for_prop_desc_var_idx = next_opcode.data.meta.data_2; ECMA_TRY_CATCH (value_for_prop_desc, get_variable_value (frame_ctx_p, @@ -1209,9 +1209,9 @@ ecma_completion_value_t 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 = 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; + const vm_idx_t lhs_var_idx = instr.data.prop_getter.lhs; + const vm_idx_t base_var_idx = instr.data.prop_getter.obj; + const vm_idx_t prop_name_var_idx = instr.data.prop_getter.prop; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -1262,9 +1262,9 @@ ecma_completion_value_t 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 = 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; + const vm_idx_t base_var_idx = instr.data.prop_setter.obj; + const vm_idx_t prop_name_var_idx = instr.data.prop_setter.prop; + const vm_idx_t rhs_var_idx = instr.data.prop_setter.rhs; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -1314,8 +1314,8 @@ ecma_completion_value_t opfunc_logical_not (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = instr.data.logical_not.dst; - const idx_t right_var_idx = instr.data.logical_not.var_right; + const vm_idx_t dst_var_idx = instr.data.logical_not.dst; + const vm_idx_t right_var_idx = instr.data.logical_not.var_right; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -1352,7 +1352,7 @@ ecma_completion_value_t opfunc_this_binding (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = instr.data.this_binding.lhs; + const vm_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++; @@ -1378,9 +1378,9 @@ ecma_completion_value_t opfunc_with (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - 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_idx_t expr_var_idx = instr.data.with.expr; + const vm_idx_t block_end_oc_idx_1 = instr.data.with.oc_idx_1; + const vm_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); @@ -1452,7 +1452,7 @@ ecma_completion_value_t opfunc_throw_value (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t var_idx = instr.data.throw_value.var; + const vm_idx_t var_idx = instr.data.throw_value.var; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -1481,7 +1481,7 @@ opfunc_throw_value (vm_instr_t instr, /**< instruction */ */ static ecma_completion_value_t evaluate_arg_for_typeof (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */ - idx_t var_idx) /**< arg variable identifier */ + vm_idx_t var_idx) /**< arg variable identifier */ { ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -1531,8 +1531,8 @@ ecma_completion_value_t opfunc_typeof (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = instr.data.typeof.lhs; - const idx_t obj_var_idx = instr.data.typeof.obj; + const vm_idx_t dst_var_idx = instr.data.typeof.lhs; + const vm_idx_t obj_var_idx = instr.data.typeof.obj; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -1603,8 +1603,8 @@ ecma_completion_value_t opfunc_delete_var (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - const idx_t dst_var_idx = instr.data.delete_var.lhs; - const idx_t name_lit_idx = instr.data.delete_var.name; + const vm_idx_t dst_var_idx = instr.data.delete_var.lhs; + const vm_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++; @@ -1670,9 +1670,9 @@ ecma_completion_value_t opfunc_delete_prop (vm_instr_t instr, /**< instruction */ vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ { - 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; + const vm_idx_t dst_var_idx = instr.data.delete_prop.lhs; + const vm_idx_t base_var_idx = instr.data.delete_prop.base; + const vm_idx_t name_var_idx = instr.data.delete_prop.name; ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); @@ -1777,13 +1777,13 @@ opfunc_meta (vm_instr_t instr, /**< instruction */ * @return instruction counter */ 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 */ +vm_calc_instr_counter_from_idx_idx (const vm_idx_t oc_idx_1, /**< first idx */ + const vm_idx_t oc_idx_2) /**< second idx */ { vm_instr_counter_t counter; counter = oc_idx_1; - counter = (vm_instr_counter_t) (counter << (sizeof (idx_t) * JERRY_BITSINBYTE)); + counter = (vm_instr_counter_t) (counter << (sizeof (vm_idx_t) * JERRY_BITSINBYTE)); counter = (vm_instr_counter_t) (counter | oc_idx_2); return counter; @@ -1800,8 +1800,8 @@ vm_read_instr_counter_from_meta (opcode_meta_type expected_type, /**< expected t 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; + const vm_idx_t data_1 = meta_opcode.data.meta.data_1; + const vm_idx_t data_2 = meta_opcode.data.meta.data_2; return vm_calc_instr_counter_from_idx_idx (data_1, data_2); } /* vm_read_instr_counter_from_meta */ @@ -1815,7 +1815,7 @@ vm_read_instr_counter_from_meta (opcode_meta_type expected_type, /**< expected t return instr; \ } #define VM_OP_1(opcode_name, opcode_name_uppercase, arg1, arg1_type) \ - vm_instr_t getop_##opcode_name (idx_t arg1_v) \ + vm_instr_t getop_##opcode_name (vm_idx_t arg1_v) \ { \ vm_instr_t instr; \ memset (&instr, 0, sizeof(instr)); \ @@ -1824,7 +1824,7 @@ vm_read_instr_counter_from_meta (opcode_meta_type expected_type, /**< expected t return instr; \ } #define VM_OP_2(opcode_name, opcode_name_uppercase, arg1, arg1_type, arg2, arg2_type) \ - vm_instr_t getop_##opcode_name (idx_t arg1_v, idx_t arg2_v) \ + vm_instr_t getop_##opcode_name (vm_idx_t arg1_v, vm_idx_t arg2_v) \ { \ vm_instr_t instr; \ memset (&instr, 0, sizeof(instr)); \ @@ -1834,7 +1834,7 @@ vm_read_instr_counter_from_meta (opcode_meta_type expected_type, /**< expected t return instr; \ } #define VM_OP_3(opcode_name, opcode_name_uppercase, arg1, arg1_type, arg2, arg2_type, arg3, arg3_type) \ - vm_instr_t getop_##opcode_name (idx_t arg1_v, idx_t arg2_v, idx_t arg3_v) \ + vm_instr_t getop_##opcode_name (vm_idx_t arg1_v, vm_idx_t arg2_v, vm_idx_t arg3_v) \ { \ vm_instr_t instr; \ instr.op_idx = VM_OP_##opcode_name_uppercase; \ diff --git a/jerry-core/vm/opcodes.h b/jerry-core/vm/opcodes.h index cee54a7a1..4f7b1e692 100644 --- a/jerry-core/vm/opcodes.h +++ b/jerry-core/vm/opcodes.h @@ -41,9 +41,56 @@ typedef uint16_t vm_instr_counter_t; /** - * Opcode / argument value in an instruction + * Opcode / argument value in an instruction ("idx") */ -typedef uint8_t idx_t; +typedef uint8_t vm_idx_t; + +/** + * Description of vm_idx_t possible value ranges and special values + */ +enum : vm_idx_t +{ + VM_IDX_GENERAL_VALUE_FIRST = 0, /**< first idx value that can be used for any argument value */ + VM_IDX_GENERAL_VALUE_LAST = 252, /**< last idx value that can be used for any argument value */ + + /* + * Special values + */ + VM_IDX_REWRITE_GENERAL_CASE = 253, /**< intermediate value, used during byte-code generation, + * indicating that the idx would be rewritten with a value + * other than in-block literal identifier */ + VM_IDX_REWRITE_LITERAL_UID = 254, /**< intermediate value, used during byte-code generation, + * indicating that the idx would be rewritten with in-block + * literal identifier */ + VM_IDX_EMPTY = 255, /**< empty idx value, used when corresponding instruction argument is not set */ + + /* + * Literals (variable names / strings / numbers) ranges + */ + VM_IDX_LITERAL_FIRST = VM_IDX_GENERAL_VALUE_FIRST, /**< index of first possible literals-related idx value */ + VM_IDX_LITERAL_LAST = VM_IDX_LITERAL_FIRST + 127, /**< index of last possible literals-related idx value */ + + /* + * Registers (temp variables) ranges + */ + VM_IDX_REG_FIRST = VM_IDX_LITERAL_LAST + 1, /** identifier of first special register */ + VM_IDX_REG_LAST = VM_IDX_GENERAL_VALUE_LAST, /**< identifier of last register */ +}; + +/** + * Ranges of registers (temporary variables) + */ +typedef enum : vm_idx_t +{ + VM_REG_FIRST = VM_IDX_REG_FIRST, /** identifier of first special register */ + VM_REG_LAST = VM_IDX_REG_LAST, /**< identifier of last register */ + + VM_REG_SPECIAL_EVAL_RET = VM_REG_FIRST, /**< eval return value */ + VM_REG_SPECIAL_FOR_IN_PROPERTY_NAME, /**< variable, containing property name, + * at start of for-in loop body */ + VM_REG_GENERAL_FIRST, /** identifier of first non-special register */ + VM_REG_GENERAL_LAST = VM_IDX_REG_LAST /** identifier of last non-special register */ +} vm_reg_t; /** * Descriptor of assignment's second argument @@ -84,7 +131,7 @@ typedef enum OPCODE_META_TYPE_END_FOR_IN /**< end of for-in statement */ } opcode_meta_type; -typedef enum : idx_t +typedef enum : vm_idx_t { OPCODE_CALL_FLAGS__EMPTY = (0u), /**< initializer for empty flag set */ OPCODE_CALL_FLAGS_HAVE_THIS_ARG = (1u << 0), /**< flag, indicating that call is performed @@ -100,7 +147,7 @@ typedef enum : idx_t /** * Flags indicating various properties of a scope's code */ -typedef enum : idx_t +typedef enum : vm_idx_t { OPCODE_SCOPE_CODE_FLAGS__EMPTY = (0u), /**< initializer for empty flag set */ OPCODE_SCOPE_CODE_FLAGS_STRICT = (1u << 0), /**< code is strict mode code */ @@ -110,20 +157,6 @@ typedef enum : idx_t * 'eval' identifier */ } opcode_scope_code_flags_t; -/** - * Enumeration of registers (temp variables) ranges - */ -typedef enum : idx_t -{ - OPCODE_REG_FIRST = 128, /** identifier of first special register */ - OPCODE_REG_SPECIAL_EVAL_RET = OPCODE_REG_FIRST, /**< eval return value */ - OPCODE_REG_SPECIAL_FOR_IN_PROPERTY_NAME, /**< variable, containing property name, - * at start of for-in loop body */ - OPCODE_REG_GENERAL_FIRST, /** identifier of first non-special register */ - OPCODE_REG_GENERAL_LAST = 253, /** identifier of last non-special register */ - OPCODE_REG_LAST = OPCODE_REG_GENERAL_FIRST /**< identifier of last register */ -} opcode_special_reg_t; - /** * Types of byte-code instruction arguments, used for instruction description * @@ -137,7 +170,7 @@ typedef enum VM_OP_ARG_TYPE_IDENTIFIER = (1u << 2), /**< identifier - named variable (string literal) */ VM_OP_ARG_TYPE_STRING = (1u << 3), /**< string constant value (string literal) */ VM_OP_ARG_TYPE_NUMBER = (1u << 4), /**< number constant value (number literal) */ - VM_OP_ARG_TYPE_INTEGER_CONST = (1u << 5), /**< a 8-bit integer constant (any idx_t) */ + VM_OP_ARG_TYPE_INTEGER_CONST = (1u << 5), /**< a 8-bit integer constant (any vm_idx_t) */ VM_OP_ARG_TYPE_TYPE_OF_NEXT = (1u << 6), /**< opcode_arg_type_operand value, * representing type of argument encoded in next idx */ @@ -163,8 +196,8 @@ typedef struct bool is_eval_code; /**< is current code executed with eval */ bool is_call_in_direct_eval_form; /** flag, indicating if there is call of 'Direct call to eval' form in * process (see also: OPCODE_CALL_FLAGS_DIRECT_CALL_TO_EVAL_FORM) */ - idx_t min_reg_idx; /**< minimum idx used for register identification */ - idx_t max_reg_idx; /**< maximum idx used for register identification */ + vm_idx_t min_reg_idx; /**< minimum idx used for register identification */ + vm_idx_t max_reg_idx; /**< maximum idx used for register identification */ ecma_number_t* tmp_num_p; /**< an allocated number (to reduce temporary allocations) */ vm_stack_frame_t stack_frame; /**< stack frame associated with the context */ @@ -195,32 +228,32 @@ typedef struct const vm_instr_counter_t end_oc; /**< instruction counter of the last instruction of the scope */ } vm_run_scope_t; -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_calc_instr_counter_from_idx_idx (const vm_idx_t oc_idx_1, const vm_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 vm_instr_t { - idx_t op_idx; + vm_idx_t op_idx; union { #define VM_OP_1(opcode_name, opcode_name_uppercase, arg1, arg1_type) \ struct \ { \ - idx_t arg1; \ + vm_idx_t arg1; \ } opcode_name; #define VM_OP_2(opcode_name, opcode_name_uppercase, arg1, arg1_type, arg2, arg2_type) \ struct \ { \ - idx_t arg1; \ - idx_t arg2; \ + vm_idx_t arg1; \ + vm_idx_t arg2; \ } opcode_name; #define VM_OP_3(opcode_name, opcode_name_uppercase, arg1, arg1_type, arg2, arg2_type, arg3, arg3_type) \ struct \ { \ - idx_t arg1; \ - idx_t arg2; \ - idx_t arg3; \ + vm_idx_t arg1; \ + vm_idx_t arg2; \ + vm_idx_t arg3; \ } opcode_name; #include "vm-opcodes.inc.h" @@ -259,11 +292,11 @@ typedef ecma_completion_value_t (*opfunc) (vm_instr_t, vm_frame_ctx_t *); #define VM_OP_0(opcode_name, opcode_name_uppercase) \ vm_instr_t getop_##opcode_name (void); #define VM_OP_1(opcode_name, opcode_name_uppercase, arg1, arg1_type) \ - vm_instr_t getop_##opcode_name (idx_t); + vm_instr_t getop_##opcode_name (vm_idx_t); #define VM_OP_2(opcode_name, opcode_name_uppercase, arg1, arg1_type, arg2, arg2_type) \ - vm_instr_t getop_##opcode_name (idx_t, idx_t); + vm_instr_t getop_##opcode_name (vm_idx_t, vm_idx_t); #define VM_OP_3(opcode_name, opcode_name_uppercase, arg1, arg1_type, arg2, arg2_type, arg3, arg3_type) \ - vm_instr_t getop_##opcode_name (idx_t, idx_t, idx_t); + vm_instr_t getop_##opcode_name (vm_idx_t, vm_idx_t, vm_idx_t); #include "vm-opcodes.inc.h" diff --git a/jerry-core/vm/pretty-printer.cpp b/jerry-core/vm/pretty-printer.cpp index 9ab95269b..907539140 100644 --- a/jerry-core/vm/pretty-printer.cpp +++ b/jerry-core/vm/pretty-printer.cpp @@ -68,9 +68,9 @@ lit_cp_to_str (lit_cpointer_t cp) } static const char * -tmp_id_to_str (idx_t id) +tmp_id_to_str (vm_idx_t id) { - JERRY_ASSERT (id != LITERAL_TO_REWRITE); + JERRY_ASSERT (id != VM_IDX_REWRITE_LITERAL_UID); JERRY_ASSERT (id >= 128); clear_temp_buffer (); strncpy (buff, "tmp", 3); @@ -96,7 +96,7 @@ static const char * var_to_str (vm_instr_t instr, lit_cpointer_t lit_ids[], vm_instr_counter_t oc, uint8_t current_arg) { raw_instr raw = *(raw_instr*) &instr; - if (raw.uids[current_arg] == LITERAL_TO_REWRITE) + if (raw.uids[current_arg] == VM_IDX_REWRITE_LITERAL_UID) { if (lit_ids == NULL) { @@ -309,7 +309,7 @@ pp_op_meta (const vm_instr_t *instrs_p, { if (opm.op.data.func_expr_n.arg_list == 0) { - if (opm.op.data.func_expr_n.name_lit_idx == INVALID_VALUE) + if (opm.op.data.func_expr_n.name_lit_idx == VM_IDX_EMPTY) { printf ("%s = function ();", VAR (1)); } @@ -416,7 +416,7 @@ pp_op_meta (const vm_instr_t *instrs_p, } case VM_OP_FUNC_EXPR_N: { - if (start_op.data.func_expr_n.name_lit_idx == INVALID_VALUE) + if (start_op.data.func_expr_n.name_lit_idx == VM_IDX_EMPTY) { pp_printf ("%s = function (", start_op, NULL, start, 1); } @@ -556,24 +556,25 @@ pp_op_meta (const vm_instr_t *instrs_p, } case OPCODE_META_TYPE_SCOPE_CODE_FLAGS: { - if (opm.op.data.meta.data_1 != INVALID_VALUE) + if (opm.op.data.meta.data_1 != VM_IDX_REWRITE_GENERAL_CASE + && opm.op.data.meta.data_1 != VM_IDX_EMPTY) { - idx_t scope_flags = opm.op.data.meta.data_1; + vm_idx_t scope_flags = opm.op.data.meta.data_1; if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_STRICT) { printf ("[use strict] "); - scope_flags &= (idx_t) ~(OPCODE_SCOPE_CODE_FLAGS_STRICT); + scope_flags &= (vm_idx_t) ~(OPCODE_SCOPE_CODE_FLAGS_STRICT); } if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_NOT_REF_ARGUMENTS_IDENTIFIER) { printf ("[no 'arguments'] "); - scope_flags &= (idx_t) ~(OPCODE_SCOPE_CODE_FLAGS_NOT_REF_ARGUMENTS_IDENTIFIER); + scope_flags &= (vm_idx_t) ~(OPCODE_SCOPE_CODE_FLAGS_NOT_REF_ARGUMENTS_IDENTIFIER); } if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_NOT_REF_EVAL_IDENTIFIER) { printf ("[no 'eval'] "); - scope_flags &= (idx_t) ~(OPCODE_SCOPE_CODE_FLAGS_NOT_REF_EVAL_IDENTIFIER); + scope_flags &= (vm_idx_t) ~(OPCODE_SCOPE_CODE_FLAGS_NOT_REF_EVAL_IDENTIFIER); } JERRY_ASSERT (scope_flags == 0); diff --git a/jerry-core/vm/vm.cpp b/jerry-core/vm/vm.cpp index 8ce18c0b6..9d3bb270b 100644 --- a/jerry-core/vm/vm.cpp +++ b/jerry-core/vm/vm.cpp @@ -543,9 +543,9 @@ vm_run_from_pos (const vm_instr_t *instrs_p, /**< byte-code array */ const vm_instr_t *curr = &instrs_p[start_pos]; JERRY_ASSERT (curr->op_idx == VM_OP_REG_VAR_DECL); - const idx_t min_reg_idx = curr->data.reg_var_decl.min; - const idx_t max_reg_idx = curr->data.reg_var_decl.max; - const idx_t local_var_regs_num = curr->data.reg_var_decl.local_var_regs_num; + const vm_idx_t min_reg_idx = curr->data.reg_var_decl.min; + const vm_idx_t max_reg_idx = curr->data.reg_var_decl.max; + const vm_idx_t local_var_regs_num = curr->data.reg_var_decl.local_var_regs_num; JERRY_ASSERT (max_reg_idx >= min_reg_idx); int32_t regs_num = max_reg_idx - min_reg_idx + 1; diff --git a/tests/unit/test-parser.cpp b/tests/unit/test-parser.cpp index 73ca21e02..d33f86508 100644 --- a/tests/unit/test-parser.cpp +++ b/tests/unit/test-parser.cpp @@ -40,7 +40,7 @@ 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 (&instrs1[i], &instrs2[i], instr_fields_num[instrs1[i].op_idx] * sizeof (idx_t)) != 0) + if (memcmp (&instrs1[i], &instrs2[i], instr_fields_num[instrs1[i].op_idx] * sizeof (vm_idx_t)) != 0) { return false; } @@ -77,8 +77,8 @@ main (int __attr_unused___ argc, getop_meta (OPCODE_META_TYPE_SCOPE_CODE_FLAGS, // [ ] OPCODE_SCOPE_CODE_FLAGS_NOT_REF_ARGUMENTS_IDENTIFIER | OPCODE_SCOPE_CODE_FLAGS_NOT_REF_EVAL_IDENTIFIER, - INVALID_VALUE), - getop_reg_var_decl (OPCODE_REG_FIRST, OPCODE_REG_GENERAL_FIRST, 0), + VM_IDX_EMPTY), + getop_reg_var_decl (VM_REG_FIRST, VM_REG_GENERAL_FIRST, 0), getop_var_decl (0), // var a; getop_assignment (130, 1, 1), // $tmp0 = 1; getop_assignment (0, 6, 130), // a = $tmp0;