diff --git a/jerry-core/lit/lit-literal-storage.cpp b/jerry-core/lit/lit-literal-storage.cpp index 4608c9e7ef..86c10b6db0 100644 --- a/jerry-core/lit/lit-literal-storage.cpp +++ b/jerry-core/lit/lit-literal-storage.cpp @@ -344,8 +344,12 @@ lit_literal_storage_t::dump () } else { - lit_utf8_byte_t buff[ECMA_MAX_CHARS_IN_STRINGIFIED_NUMBER]; - ecma_number_to_utf8_string (lit_p->get_number (), buff, sizeof (buff)); + lit_utf8_byte_t buff[ECMA_MAX_CHARS_IN_STRINGIFIED_NUMBER + 1u]; + memset (buff, 0, sizeof (buff)); + + lit_utf8_size_t sz = ecma_number_to_utf8_string (lit_p->get_number (), buff, sizeof (buff)); + JERRY_ASSERT (sz <= ECMA_MAX_CHARS_IN_STRINGIFIED_NUMBER); + printf ("%s : NUMBER", buff); } diff --git a/jerry-core/lit/lit-literal.h b/jerry-core/lit/lit-literal.h index 3cd9802172..a52060d89d 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 67087cb129..4a45b5ac79 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 321a3bbf43..996b11e33d 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/jsp-early-error.cpp b/jerry-core/parser/js/jsp-early-error.cpp index aaf9a7d761..8667b44b1c 100644 --- a/jerry-core/parser/js/jsp-early-error.cpp +++ b/jerry-core/parser/js/jsp-early-error.cpp @@ -114,10 +114,10 @@ jsp_early_error_start_checking_of_prop_names (void) } void -jsp_early_error_add_prop_name (operand op, prop_type pt) +jsp_early_error_add_prop_name (jsp_operand_t op, prop_type pt) { - JERRY_ASSERT (op.type == OPERAND_LITERAL); - STACK_PUSH (props, create_prop_literal (lit_get_literal_by_cp (op.data.lit_id), pt)); + JERRY_ASSERT (op.is_literal_operand ()); + STACK_PUSH (props, create_prop_literal (lit_get_literal_by_cp (op.get_literal ()), pt)); } void @@ -199,21 +199,21 @@ jsp_early_error_start_checking_of_vargs (void) STACK_PUSH (size_t_stack, STACK_SIZE (props)); } -void jsp_early_error_add_varg (operand op) +void jsp_early_error_add_varg (jsp_operand_t op) { - JERRY_ASSERT (op.type == OPERAND_LITERAL); - STACK_PUSH (props, create_prop_literal (lit_get_literal_by_cp (op.data.lit_id), VARG)); + JERRY_ASSERT (op.is_literal_operand ()); + STACK_PUSH (props, create_prop_literal (lit_get_literal_by_cp (op.get_literal ()), VARG)); } static void -emit_error_on_eval_and_arguments (operand op, locus loc __attr_unused___) +emit_error_on_eval_and_arguments (jsp_operand_t op, locus loc __attr_unused___) { - if (op.type == OPERAND_LITERAL) + if (op.is_literal_operand ()) { - if (lit_literal_equal_type_utf8 (lit_get_literal_by_cp (op.data.lit_id), + if (lit_literal_equal_type_utf8 (lit_get_literal_by_cp (op.get_literal ()), lit_get_magic_string_utf8 (LIT_MAGIC_STRING_ARGUMENTS), lit_get_magic_string_size (LIT_MAGIC_STRING_ARGUMENTS)) - || lit_literal_equal_type_utf8 (lit_get_literal_by_cp (op.data.lit_id), + || lit_literal_equal_type_utf8 (lit_get_literal_by_cp (op.get_literal ()), lit_get_magic_string_utf8 (LIT_MAGIC_STRING_EVAL), lit_get_magic_string_size (LIT_MAGIC_STRING_EVAL))) { @@ -223,7 +223,7 @@ emit_error_on_eval_and_arguments (operand op, locus loc __attr_unused___) } void -jsp_early_error_check_for_eval_and_arguments_in_strict_mode (operand op, bool is_strict, locus loc) +jsp_early_error_check_for_eval_and_arguments_in_strict_mode (jsp_operand_t op, bool is_strict, locus loc) { if (is_strict) { diff --git a/jerry-core/parser/js/jsp-early-error.h b/jerry-core/parser/js/jsp-early-error.h index 0897121ff8..318afff1fa 100644 --- a/jerry-core/parser/js/jsp-early-error.h +++ b/jerry-core/parser/js/jsp-early-error.h @@ -76,12 +76,12 @@ void jsp_early_error_init (void); void jsp_early_error_free (void); void jsp_early_error_start_checking_of_prop_names (void); -void jsp_early_error_add_prop_name (operand, prop_type); +void jsp_early_error_add_prop_name (jsp_operand_t, prop_type); void jsp_early_error_check_for_duplication_of_prop_names (bool, locus); void jsp_early_error_start_checking_of_vargs (void); -void jsp_early_error_add_varg (operand); -void jsp_early_error_check_for_eval_and_arguments_in_strict_mode (operand, bool, locus); +void jsp_early_error_add_varg (jsp_operand_t); +void jsp_early_error_check_for_eval_and_arguments_in_strict_mode (jsp_operand_t, bool, locus); void jsp_early_error_check_for_syntax_errors_in_formal_param_list (bool, locus); void jsp_early_error_check_delete (bool, locus); diff --git a/jerry-core/parser/js/lexer.h b/jerry-core/parser/js/lexer.h index 34c4341740..0f04f69edc 100644 --- a/jerry-core/parser/js/lexer.h +++ b/jerry-core/parser/js/lexer.h @@ -19,8 +19,6 @@ #include "lit-literal.h" #include "lit-strings.h" -#define INVALID_VALUE 255 -#define EVAL_RET_VALUE 128 #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 9e2da73e60..0f0ee948b6 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]; @@ -311,9 +311,8 @@ 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); - raw_p->uids[arg_index + 1] = reg; + JERRY_ASSERT (om.op.data.raw_args[arg_index] == VM_IDX_REWRITE_LITERAL_UID); + om.op.data.raw_args[arg_index] = reg; } } @@ -324,196 +323,166 @@ dumper_try_replace_var_with_reg (scopes_tree tree, /**< a function scope, create } /* dumper_try_replace_var_with_reg */ #endif /* CONFIG_PARSER_ENABLE_PARSE_TIME_BYTE_CODE_OPTIMIZER */ -static op_meta -create_op_meta (vm_instr_t op, lit_cpointer_t lit_id1, lit_cpointer_t lit_id2, lit_cpointer_t lit_id3) +/** + * Generate instruction with specified opcode and operands + * + * @return VM instruction + */ +static vm_instr_t +jsp_dmp_gen_instr (vm_op_t opcode, /**< operation code */ + jsp_operand_t ops[], /**< operands */ + size_t ops_num) /**< operands number */ { - op_meta ret; + vm_instr_t instr; - ret.op = op; - ret.lit_id[0] = lit_id1; - ret.lit_id[1] = lit_id2; - ret.lit_id[2] = lit_id3; + instr.op_idx = opcode; - return ret; -} + for (size_t i = 0; i < ops_num; i++) + { + if (ops[i].is_empty_operand ()) + { + instr.data.raw_args[i] = VM_IDX_EMPTY; + } + else if (ops[i].is_unknown_operand ()) + { + instr.data.raw_args[i] = VM_IDX_REWRITE_GENERAL_CASE; + } + else if (ops[i].is_idx_const_operand ()) + { + instr.data.raw_args[i] = ops[i].get_idx_const (); + } + else if (ops[i].is_register_operand ()) + { + instr.data.raw_args[i] = ops[i].get_idx (); + } + else + { + JERRY_ASSERT (ops[i].is_literal_operand ()); -static op_meta -create_op_meta_000 (vm_instr_t op) -{ - return create_op_meta (op, NOT_A_LITERAL, NOT_A_LITERAL, NOT_A_LITERAL); -} + instr.data.raw_args[i] = VM_IDX_REWRITE_LITERAL_UID; + } + } -static op_meta -create_op_meta_001 (vm_instr_t op, lit_cpointer_t lit_id) -{ - return create_op_meta (op, NOT_A_LITERAL, NOT_A_LITERAL, lit_id); -} + for (size_t i = ops_num; i < 3; i++) + { + instr.data.raw_args[i] = VM_IDX_EMPTY; + } -static op_meta -create_op_meta_010 (vm_instr_t op, lit_cpointer_t lit_id) -{ - return create_op_meta (op, NOT_A_LITERAL, lit_id, NOT_A_LITERAL); -} + return instr; +} /* jsp_dmp_gen_instr */ +/** + * Create intermediate instruction description, containing pointers to literals, + * associated with the instruction's arguments, if there are any. + * + * @return intermediate operation description + */ static op_meta -create_op_meta_011 (vm_instr_t op, lit_cpointer_t lit_id2, lit_cpointer_t lit_id3) +jsp_dmp_create_op_meta (vm_op_t opcode, /**< opcode */ + jsp_operand_t ops[], /**< operands */ + size_t ops_num) /**< operands number */ { - return create_op_meta (op, NOT_A_LITERAL, lit_id2, lit_id3); -} + op_meta ret; -static op_meta -create_op_meta_100 (vm_instr_t op, lit_cpointer_t lit_id) -{ - return create_op_meta (op, lit_id, NOT_A_LITERAL, NOT_A_LITERAL); -} + ret.op = jsp_dmp_gen_instr (opcode, ops, ops_num); -static op_meta -create_op_meta_101 (vm_instr_t op, lit_cpointer_t lit_id1, lit_cpointer_t lit_id3) -{ - return create_op_meta (op, lit_id1, NOT_A_LITERAL, lit_id3); -} + for (size_t i = 0; i < ops_num; i++) + { + if (ops[i].is_literal_operand ()) + { + ret.lit_id[i] = ops[i].get_literal (); + } + else + { + ret.lit_id[i] = NOT_A_LITERAL; + } + } -static op_meta -create_op_meta_110 (vm_instr_t op, lit_cpointer_t lit_id1, lit_cpointer_t lit_id2) -{ - return create_op_meta (op, lit_id1, lit_id2, NOT_A_LITERAL); -} + for (size_t i = ops_num; i < 3; i++) + { + ret.lit_id[i] = NOT_A_LITERAL; + } + + return ret; +} /* jsp_dmp_create_op_meta */ +/** + * Create intermediate instruction description (for instructions without arguments) + * + * See also: + * jsp_dmp_create_op_meta + * + * @return intermediate instruction description + */ static op_meta -create_op_meta_111 (vm_instr_t op, lit_cpointer_t lit_id1, lit_cpointer_t lit_id2, lit_cpointer_t lit_id3) +jsp_dmp_create_op_meta_0 (vm_op_t opcode) /**< opcode */ { - return create_op_meta (op, lit_id1, lit_id2, lit_id3); -} + return jsp_dmp_create_op_meta (opcode, NULL, 0); +} /* jsp_dmp_create_op_meta_0 */ -static operand -tmp_operand (void) +/** + * Create intermediate instruction description (for instructions with 1 argument) + * + * See also: + * jsp_dmp_create_op_meta + * + * @return intermediate instruction description + */ +static op_meta +jsp_dmp_create_op_meta_1 (vm_op_t opcode, /**< opcode */ + jsp_operand_t operand1) /**< first operand */ { - operand ret; - - ret.type = OPERAND_TMP; - ret.data.uid = jsp_alloc_reg_for_temp (); - - return ret; -} + return jsp_dmp_create_op_meta (opcode, &operand1, 1); +} /* jsp_dmp_create_op_meta_1 */ +/** + * Create intermediate instruction description (for instructions with 2 arguments) + * + * See also: + * jsp_dmp_create_op_meta + * + * @return intermediate instruction description + */ static op_meta -create_op_meta_for_res_and_obj (vm_instr_t (*getop) (idx_t, idx_t, idx_t), operand *res, operand *obj) +jsp_dmp_create_op_meta_2 (vm_op_t opcode, /**< opcode */ + jsp_operand_t operand1, /**< first operand */ + jsp_operand_t operand2) /**< second operand */ { - JERRY_ASSERT (obj != NULL); - JERRY_ASSERT (res != NULL); - op_meta ret; - switch (obj->type) - { - case OPERAND_TMP: - { - switch (res->type) - { - case OPERAND_TMP: - { - const vm_instr_t instr = getop (res->data.uid, obj->data.uid, INVALID_VALUE); - ret = create_op_meta_000 (instr); - break; - } - case OPERAND_LITERAL: - { - const vm_instr_t instr = getop (LITERAL_TO_REWRITE, obj->data.uid, INVALID_VALUE); - ret = create_op_meta_100 (instr, res->data.lit_id); - break; - } - } - break; - } - case OPERAND_LITERAL: - { - switch (res->type) - { - case OPERAND_TMP: - { - const vm_instr_t instr = getop (res->data.uid, LITERAL_TO_REWRITE, INVALID_VALUE); - ret = create_op_meta_010 (instr, obj->data.lit_id); - break; - } - case OPERAND_LITERAL: - { - const vm_instr_t instr = getop (LITERAL_TO_REWRITE, LITERAL_TO_REWRITE, INVALID_VALUE); - ret = create_op_meta_110 (instr, res->data.lit_id, obj->data.lit_id); - break; - } - } - break; - } - } - return ret; -} + jsp_operand_t ops[] = { operand1, operand2 }; + return jsp_dmp_create_op_meta (opcode, ops, 2); +} /* jsp_dmp_create_op_meta_2 */ +/** + * Create intermediate instruction description (for instructions with 3 arguments) + * + * See also: + * jsp_dmp_create_op_meta + * + * @return intermediate instruction description + */ static op_meta -create_op_meta_for_obj (vm_instr_t (*getop) (idx_t, idx_t), operand *obj) +jsp_dmp_create_op_meta_3 (vm_op_t opcode, /**< opcode */ + jsp_operand_t operand1, /**< first operand */ + jsp_operand_t operand2, /**< second operand */ + jsp_operand_t operand3) /**< third operand */ { - JERRY_ASSERT (obj != NULL); - op_meta res; - switch (obj->type) - { - case OPERAND_TMP: - { - const vm_instr_t instr = getop (obj->data.uid, INVALID_VALUE); - res = create_op_meta_000 (instr); - break; - } - case OPERAND_LITERAL: - { - const vm_instr_t instr = getop (LITERAL_TO_REWRITE, INVALID_VALUE); - res = create_op_meta_100 (instr, obj->data.lit_id); - break; - } - } - return res; -} + jsp_operand_t ops[] = { operand1, operand2, operand3 }; + return jsp_dmp_create_op_meta (opcode, ops, 3); +} /* jsp_dmp_create_op_meta_3 */ -static op_meta -create_op_meta_for_vlt (varg_list_type vlt, operand *res, operand *obj) +static jsp_operand_t +tmp_operand (void) { - op_meta ret; - switch (vlt) - { - case VARG_FUNC_EXPR: ret = create_op_meta_for_res_and_obj (getop_func_expr_n, res, obj); break; - case VARG_CONSTRUCT_EXPR: ret = create_op_meta_for_res_and_obj (getop_construct_n, res, obj); break; - case VARG_CALL_EXPR: - { - JERRY_ASSERT (obj != NULL); - ret = create_op_meta_for_res_and_obj (getop_call_n, res, obj); - break; - } - case VARG_FUNC_DECL: - { - JERRY_ASSERT (res == NULL); - ret = create_op_meta_for_obj (getop_func_decl_n, obj); - break; - } - case VARG_ARRAY_DECL: - { - JERRY_ASSERT (obj == NULL); - operand empty = empty_operand (); - ret = create_op_meta_for_res_and_obj (getop_array_decl, res, &empty); - break; - } - case VARG_OBJ_DECL: - { - JERRY_ASSERT (obj == NULL); - operand empty = empty_operand (); - ret = create_op_meta_for_res_and_obj (getop_obj_decl, res, &empty); - break; - } - } - return ret; + return jsp_operand_t::make_reg_operand (jsp_alloc_reg_for_temp ()); } 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)); } @@ -524,246 +493,92 @@ last_dumped_op_meta (void) } static void -dump_single_address (vm_instr_t (*getop) (idx_t), operand op) +dump_single_address (vm_op_t opcode, + jsp_operand_t op) { - switch (op.type) - { - case OPERAND_LITERAL: - { - const vm_instr_t instr = getop (LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_100 (instr, op.data.lit_id)); - break; - } - case OPERAND_TMP: - { - const vm_instr_t instr = getop (op.data.uid); - serializer_dump_op_meta (create_op_meta_000 (instr)); - break; - } - } + serializer_dump_op_meta (jsp_dmp_create_op_meta_1 (opcode, op)); } static void -dump_double_address (vm_instr_t (*getop) (idx_t, idx_t), operand res, operand obj) +dump_double_address (vm_op_t opcode, + jsp_operand_t res, + jsp_operand_t obj) { - switch (res.type) - { - case OPERAND_LITERAL: - { - switch (obj.type) - { - case OPERAND_LITERAL: - { - const vm_instr_t instr = getop (LITERAL_TO_REWRITE, LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_110 (instr, res.data.lit_id, obj.data.lit_id)); - break; - } - case OPERAND_TMP: - { - const vm_instr_t instr = getop (LITERAL_TO_REWRITE, obj.data.uid); - serializer_dump_op_meta (create_op_meta_100 (instr, res.data.lit_id)); - break; - } - } - break; - } - case OPERAND_TMP: - { - switch (obj.type) - { - case OPERAND_LITERAL: - { - const vm_instr_t instr = getop (res.data.uid, LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_010 (instr, obj.data.lit_id)); - break; - } - case OPERAND_TMP: - { - const vm_instr_t instr = getop (res.data.uid, obj.data.uid); - serializer_dump_op_meta (create_op_meta_000 (instr)); - break; - } - } - break; - } - } -} - -static void -dump_triple_address (vm_instr_t (*getop) (idx_t, idx_t, idx_t), operand res, operand lhs, operand rhs) -{ - switch (res.type) - { - case OPERAND_LITERAL: - { - switch (lhs.type) - { - case OPERAND_LITERAL: - { - switch (rhs.type) - { - case OPERAND_LITERAL: - { - const vm_instr_t instr = getop (LITERAL_TO_REWRITE, LITERAL_TO_REWRITE, LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_111 (instr, res.data.lit_id, lhs.data.lit_id, rhs.data.lit_id)); - break; - } - case OPERAND_TMP: - { - const vm_instr_t instr = getop (LITERAL_TO_REWRITE, LITERAL_TO_REWRITE, rhs.data.uid); - serializer_dump_op_meta (create_op_meta_110 (instr, res.data.lit_id, lhs.data.lit_id)); - break; - } - } - break; - } - case OPERAND_TMP: - { - switch (rhs.type) - { - case OPERAND_LITERAL: - { - const vm_instr_t instr = getop (LITERAL_TO_REWRITE, lhs.data.uid, LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_101 (instr, res.data.lit_id, rhs.data.lit_id)); - break; - } - case OPERAND_TMP: - { - const vm_instr_t instr = getop (LITERAL_TO_REWRITE, lhs.data.uid, rhs.data.uid); - serializer_dump_op_meta (create_op_meta_100 (instr, res.data.lit_id)); - break; - } - } - break; - } - } - break; - } - case OPERAND_TMP: - { - switch (lhs.type) - { - case OPERAND_LITERAL: - { - switch (rhs.type) - { - case OPERAND_LITERAL: - { - const vm_instr_t instr = getop (res.data.uid, LITERAL_TO_REWRITE, LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_011 (instr, lhs.data.lit_id, rhs.data.lit_id)); - break; - } - case OPERAND_TMP: - { - const vm_instr_t instr = getop (res.data.uid, LITERAL_TO_REWRITE, rhs.data.uid); - serializer_dump_op_meta (create_op_meta_010 (instr, lhs.data.lit_id)); - break; - } - } - break; - } - case OPERAND_TMP: - { - switch (rhs.type) - { - case OPERAND_LITERAL: - { - const vm_instr_t instr = getop (res.data.uid, lhs.data.uid, LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_001 (instr, rhs.data.lit_id)); - break; - } - case OPERAND_TMP: - { - const vm_instr_t instr = getop (res.data.uid, lhs.data.uid, rhs.data.uid); - serializer_dump_op_meta (create_op_meta_000 (instr)); - break; - } - } - break; - } - } - break; - } - } + serializer_dump_op_meta (jsp_dmp_create_op_meta_2 (opcode, res, obj)); } static void -dump_prop_setter_op_meta (op_meta last, operand op) +dump_triple_address (vm_op_t opcode, + jsp_operand_t res, + jsp_operand_t lhs, + jsp_operand_t rhs) { - JERRY_ASSERT (last.op.op_idx == VM_OP_PROP_GETTER); - switch (op.type) - { - case OPERAND_LITERAL: - { - const vm_instr_t instr = getop_prop_setter (last.op.data.prop_getter.obj, - last.op.data.prop_getter.prop, - LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_111 (instr, last.lit_id[1], last.lit_id[2], op.data.lit_id)); - break; - } - case OPERAND_TMP: - { - const vm_instr_t instr = getop_prop_setter (last.op.data.prop_getter.obj, - last.op.data.prop_getter.prop, - op.data.uid); - serializer_dump_op_meta (create_op_meta_110 (instr, last.lit_id[1], last.lit_id[2])); - break; - } - } + serializer_dump_op_meta (jsp_dmp_create_op_meta_3 (opcode, res, lhs, rhs)); } -static operand -create_operand_from_tmp_and_lit (idx_t tmp, lit_cpointer_t lit_id) +static jsp_operand_t +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); - operand ret; - - ret.type = OPERAND_TMP; - ret.data.uid = tmp; - - return ret; + return jsp_operand_t::make_reg_operand (tmp); } else { JERRY_ASSERT (lit_id.packed_value != MEM_CP_NULL); - operand ret; + return jsp_operand_t::make_lit_operand (lit_id); + } +} - ret.type = OPERAND_LITERAL; - ret.data.lit_id = lit_id; +static void +dump_prop_setter_op_meta (op_meta last, jsp_operand_t op) +{ + JERRY_ASSERT (last.op.op_idx == VM_OP_PROP_GETTER); - return ret; - } + dump_triple_address (VM_OP_PROP_SETTER, + create_operand_from_tmp_and_lit (last.op.data.prop_getter.obj, + last.lit_id[1]), + create_operand_from_tmp_and_lit (last.op.data.prop_getter.prop, + last.lit_id[2]), + op); } -static operand -dump_triple_address_and_prop_setter_res (void (*dumper) (operand, operand, operand), - op_meta last, operand op) + +static jsp_operand_t +dump_triple_address_and_prop_setter_res (vm_op_t opcode, /**< opcode of triple address operation */ + op_meta last, + jsp_operand_t op) { JERRY_ASSERT (last.op.op_idx == VM_OP_PROP_GETTER); - const operand obj = create_operand_from_tmp_and_lit (last.op.data.prop_getter.obj, last.lit_id[1]); - const operand prop = create_operand_from_tmp_and_lit (last.op.data.prop_getter.prop, last.lit_id[2]); - const operand tmp = dump_prop_getter_res (obj, prop); - dumper (tmp, tmp, op); + + const jsp_operand_t obj = create_operand_from_tmp_and_lit (last.op.data.prop_getter.obj, last.lit_id[1]); + const jsp_operand_t prop = create_operand_from_tmp_and_lit (last.op.data.prop_getter.prop, last.lit_id[2]); + + const jsp_operand_t tmp = dump_prop_getter_res (obj, prop); + + dump_triple_address (opcode, tmp, tmp, op); + dump_prop_setter (obj, prop, tmp); + return tmp; } -static operand -dump_prop_setter_or_triple_address_res (void (*dumper) (operand, operand, operand), - operand res, operand op) +static jsp_operand_t +dump_prop_setter_or_triple_address_res (vm_op_t opcode, + jsp_operand_t res, + jsp_operand_t op) { const op_meta last = STACK_TOP (prop_getters); if (last.op.op_idx == VM_OP_PROP_GETTER) { - res = dump_triple_address_and_prop_setter_res (dumper, last, op); + res = dump_triple_address_and_prop_setter_res (opcode, last, op); } else { - if (res.type == OPERAND_TMP) + if (res.is_register_operand ()) { /* * FIXME: @@ -772,7 +587,7 @@ dump_prop_setter_or_triple_address_res (void (*dumper) (operand, operand, operan PARSE_ERROR (JSP_EARLY_ERROR_REFERENCE, "Invalid left-hand-side expression", LIT_ITERATOR_POS_ZERO); } - dumper (res, res, op); + dump_triple_address (opcode, res, res, op); } STACK_DROP (prop_getters, 1); return res; @@ -784,26 +599,16 @@ get_diff_from (vm_instr_counter_t oc) return (vm_instr_counter_t) (serializer_get_current_instr_counter () - oc); } -operand +jsp_operand_t empty_operand (void) { - operand ret; - - ret.type = OPERAND_TMP; - ret.data.uid = INVALID_VALUE; - - return ret; + return jsp_operand_t::make_empty_operand (); } -operand +jsp_operand_t literal_operand (lit_cpointer_t lit_cp) { - operand ret; - - ret.type = OPERAND_LITERAL; - ret.data.lit_id = lit_cp; - - return ret; + return jsp_operand_t::make_lit_operand (lit_cp); } /** @@ -811,15 +616,10 @@ literal_operand (lit_cpointer_t lit_cp) * * @return constructed operand */ -operand +jsp_operand_t eval_ret_operand (void) { - operand ret; - - ret.type = OPERAND_TMP; - ret.data.uid = EVAL_RET_VALUE; - - return ret; + return jsp_operand_t::make_reg_operand (VM_REG_SPECIAL_EVAL_RET); } /* eval_ret_operand */ /** @@ -828,45 +628,40 @@ eval_ret_operand (void) * * @return constructed operand */ -operand +jsp_operand_t jsp_create_operand_for_in_special_reg (void) { - operand ret; - - ret.type = OPERAND_TMP; - ret.data.uid = OPCODE_REG_SPECIAL_FOR_IN_PROPERTY_NAME; - - return ret; + return jsp_operand_t::make_reg_operand (VM_REG_SPECIAL_FOR_IN_PROPERTY_NAME); } /* jsp_create_operand_for_in_special_reg */ bool -operand_is_empty (operand op) +operand_is_empty (jsp_operand_t op) { - return op.type == OPERAND_TMP && op.data.uid == INVALID_VALUE; + return op.is_empty_operand (); } 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); @@ -917,13 +712,13 @@ dumper_finish_varg_code_sequence (void) * false - otherwise. */ bool -dumper_is_eval_literal (operand obj) /**< byte-code operand */ +dumper_is_eval_literal (jsp_operand_t obj) /**< byte-code operand */ { /* * FIXME: Switch to corresponding magic string */ - bool is_eval_lit = (obj.type == OPERAND_LITERAL - && lit_literal_equal_type_cstr (lit_get_literal_by_cp (obj.data.lit_id), "eval")); + bool is_eval_lit = (obj.is_literal_operand () + && lit_literal_equal_type_cstr (lit_get_literal_by_cp (obj.get_literal ()), "eval")); return is_eval_lit; } /* dumper_is_eval_literal */ @@ -933,320 +728,227 @@ dumper_is_eval_literal (operand obj) /**< byte-code operand */ * * @return register number, to which the value vas assigned */ -operand +jsp_operand_t dump_array_hole_assignment_res (void) { - operand op = tmp_operand (); + jsp_operand_t op, type_operand, value_operand; + + op = tmp_operand (); - const vm_instr_t instr = getop_assignment (op.data.uid, - OPCODE_ARG_TYPE_SIMPLE, - ECMA_SIMPLE_VALUE_ARRAY_HOLE); - const op_meta om = create_op_meta_000 (instr); - serializer_dump_op_meta (om); + type_operand = jsp_operand_t::make_idx_const_operand (OPCODE_ARG_TYPE_SIMPLE); + value_operand = jsp_operand_t::make_idx_const_operand (ECMA_SIMPLE_VALUE_ARRAY_HOLE); + + dump_triple_address (VM_OP_ASSIGNMENT, op, type_operand, value_operand); return op; } /* dump_array_hole_assignment_res */ void -dump_boolean_assignment (operand op, bool is_true) +dump_boolean_assignment (jsp_operand_t op, bool is_true) { - switch (op.type) - { - case OPERAND_LITERAL: - { - const vm_instr_t instr = getop_assignment (LITERAL_TO_REWRITE, - OPCODE_ARG_TYPE_SIMPLE, - is_true ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE); - const op_meta om = create_op_meta_100 (instr, op.data.lit_id); - serializer_dump_op_meta (om); - break; - } - case OPERAND_TMP: - { - const vm_instr_t instr = getop_assignment (op.data.uid, - OPCODE_ARG_TYPE_SIMPLE, - is_true ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE); - const op_meta om = create_op_meta_000 (instr); - serializer_dump_op_meta (om); - break; - } - } + jsp_operand_t type_operand, value_operand; + + type_operand = jsp_operand_t::make_idx_const_operand (OPCODE_ARG_TYPE_SIMPLE); + value_operand = jsp_operand_t::make_idx_const_operand (is_true ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE); + + dump_triple_address (VM_OP_ASSIGNMENT, op, type_operand, value_operand); } -operand +jsp_operand_t dump_boolean_assignment_res (bool is_true) { - operand op = tmp_operand (); + jsp_operand_t op = tmp_operand (); dump_boolean_assignment (op, is_true); return op; } void -dump_string_assignment (operand op, lit_cpointer_t lit_id) +dump_string_assignment (jsp_operand_t op, lit_cpointer_t lit_id) { - switch (op.type) - { - case OPERAND_LITERAL: - { - const vm_instr_t instr = getop_assignment (LITERAL_TO_REWRITE, OPCODE_ARG_TYPE_STRING, LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_101 (instr, op.data.lit_id, lit_id)); - break; - } - case OPERAND_TMP: - { - const vm_instr_t instr = getop_assignment (op.data.uid, OPCODE_ARG_TYPE_STRING, LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_001 (instr, lit_id)); - break; - } - } + jsp_operand_t type_operand, value_operand; + + type_operand = jsp_operand_t::make_idx_const_operand (OPCODE_ARG_TYPE_STRING); + value_operand = jsp_operand_t::make_lit_operand (lit_id); + + dump_triple_address (VM_OP_ASSIGNMENT, op, type_operand, value_operand); } -operand +jsp_operand_t dump_string_assignment_res (lit_cpointer_t lit_id) { - operand op = tmp_operand (); + jsp_operand_t op = tmp_operand (); dump_string_assignment (op, lit_id); return op; } void -dump_number_assignment (operand op, lit_cpointer_t lit_id) +dump_number_assignment (jsp_operand_t op, lit_cpointer_t lit_id) { - switch (op.type) - { - case OPERAND_LITERAL: - { - const vm_instr_t instr = getop_assignment (LITERAL_TO_REWRITE, OPCODE_ARG_TYPE_NUMBER, LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_101 (instr, op.data.lit_id, lit_id)); - break; - } - case OPERAND_TMP: - { - const vm_instr_t instr = getop_assignment (op.data.uid, OPCODE_ARG_TYPE_NUMBER, LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_001 (instr, lit_id)); - break; - } - } + jsp_operand_t type_operand, value_operand; + + type_operand = jsp_operand_t::make_idx_const_operand (OPCODE_ARG_TYPE_NUMBER); + value_operand = jsp_operand_t::make_lit_operand (lit_id); + + dump_triple_address (VM_OP_ASSIGNMENT, op, type_operand, value_operand); } -operand +jsp_operand_t dump_number_assignment_res (lit_cpointer_t lit_id) { - operand op = tmp_operand (); + jsp_operand_t op = tmp_operand (); dump_number_assignment (op, lit_id); return op; } void -dump_regexp_assignment (operand op, lit_cpointer_t lit_id) +dump_regexp_assignment (jsp_operand_t op, lit_cpointer_t lit_id) { - switch (op.type) - { - case OPERAND_LITERAL: - { - const vm_instr_t instr = getop_assignment (LITERAL_TO_REWRITE, OPCODE_ARG_TYPE_REGEXP, LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_101 (instr, op.data.lit_id, lit_id)); - break; - } - case OPERAND_TMP: - { - const vm_instr_t instr = getop_assignment (op.data.uid, OPCODE_ARG_TYPE_REGEXP, LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_001 (instr, lit_id)); - break; - } - } + jsp_operand_t type_operand, value_operand; + + type_operand = jsp_operand_t::make_idx_const_operand (OPCODE_ARG_TYPE_REGEXP); + value_operand = jsp_operand_t::make_lit_operand (lit_id); + + dump_triple_address (VM_OP_ASSIGNMENT, op, type_operand, value_operand); } -operand +jsp_operand_t dump_regexp_assignment_res (lit_cpointer_t lit_id) { - operand op = tmp_operand (); + jsp_operand_t op = tmp_operand (); dump_regexp_assignment (op, lit_id); return op; } void -dump_smallint_assignment (operand op, idx_t uid) +dump_smallint_assignment (jsp_operand_t op, vm_idx_t uid) { - switch (op.type) - { - case OPERAND_LITERAL: - { - const vm_instr_t instr = getop_assignment (LITERAL_TO_REWRITE, OPCODE_ARG_TYPE_SMALLINT, uid); - serializer_dump_op_meta (create_op_meta_100 (instr, op.data.lit_id)); - break; - } - case OPERAND_TMP: - { - const vm_instr_t instr = getop_assignment (op.data.uid, OPCODE_ARG_TYPE_SMALLINT, uid); - serializer_dump_op_meta (create_op_meta_000 (instr)); - break; - } - } + jsp_operand_t type_operand, value_operand; + + type_operand = jsp_operand_t::make_idx_const_operand (OPCODE_ARG_TYPE_SMALLINT); + value_operand = jsp_operand_t::make_idx_const_operand (uid); + + dump_triple_address (VM_OP_ASSIGNMENT, op, type_operand, value_operand); } -operand -dump_smallint_assignment_res (idx_t uid) +jsp_operand_t +dump_smallint_assignment_res (vm_idx_t uid) { - operand op = tmp_operand (); + jsp_operand_t op = tmp_operand (); dump_smallint_assignment (op, uid); return op; } void -dump_undefined_assignment (operand op) +dump_undefined_assignment (jsp_operand_t op) { - switch (op.type) - { - case OPERAND_LITERAL: - { - const vm_instr_t instr = getop_assignment (LITERAL_TO_REWRITE, - OPCODE_ARG_TYPE_SIMPLE, - ECMA_SIMPLE_VALUE_UNDEFINED); - serializer_dump_op_meta (create_op_meta_100 (instr, op.data.lit_id)); - break; - } - case OPERAND_TMP: - { - const vm_instr_t instr = getop_assignment (op.data.uid, OPCODE_ARG_TYPE_SIMPLE, ECMA_SIMPLE_VALUE_UNDEFINED); - serializer_dump_op_meta (create_op_meta_000 (instr)); - break; - } - } + jsp_operand_t type_operand, value_operand; + + type_operand = jsp_operand_t::make_idx_const_operand (OPCODE_ARG_TYPE_SIMPLE); + value_operand = jsp_operand_t::make_idx_const_operand (ECMA_SIMPLE_VALUE_UNDEFINED); + + dump_triple_address (VM_OP_ASSIGNMENT, op, type_operand, value_operand); } -operand +jsp_operand_t dump_undefined_assignment_res (void) { - operand op = tmp_operand (); + jsp_operand_t op = tmp_operand (); dump_undefined_assignment (op); return op; } void -dump_null_assignment (operand op) +dump_null_assignment (jsp_operand_t op) { - switch (op.type) - { - case OPERAND_LITERAL: - { - const vm_instr_t instr = getop_assignment (LITERAL_TO_REWRITE, - OPCODE_ARG_TYPE_SIMPLE, - ECMA_SIMPLE_VALUE_NULL); - serializer_dump_op_meta (create_op_meta_100 (instr, op.data.lit_id)); - break; - } - case OPERAND_TMP: - { - const vm_instr_t instr = getop_assignment (op.data.uid, - OPCODE_ARG_TYPE_SIMPLE, - ECMA_SIMPLE_VALUE_NULL); - serializer_dump_op_meta (create_op_meta_000 (instr)); - break; - } - } + jsp_operand_t type_operand, value_operand; + + type_operand = jsp_operand_t::make_idx_const_operand (OPCODE_ARG_TYPE_SIMPLE); + value_operand = jsp_operand_t::make_idx_const_operand (ECMA_SIMPLE_VALUE_NULL); + + dump_triple_address (VM_OP_ASSIGNMENT, op, type_operand, value_operand); } -operand +jsp_operand_t dump_null_assignment_res (void) { - operand op = tmp_operand (); + jsp_operand_t op = tmp_operand (); dump_null_assignment (op); return op; } void -dump_variable_assignment (operand res, operand var) +dump_variable_assignment (jsp_operand_t res, jsp_operand_t var) { - switch (res.type) - { - case OPERAND_LITERAL: - { - switch (var.type) - { - case OPERAND_LITERAL: - { - const vm_instr_t instr = getop_assignment (LITERAL_TO_REWRITE, - OPCODE_ARG_TYPE_VARIABLE, - LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_101 (instr, res.data.lit_id, var.data.lit_id)); - break; - } - case OPERAND_TMP: - { - const vm_instr_t instr = getop_assignment (LITERAL_TO_REWRITE, - OPCODE_ARG_TYPE_VARIABLE, - var.data.uid); - serializer_dump_op_meta (create_op_meta_100 (instr, res.data.lit_id)); - break; - } - } - break; - } - case OPERAND_TMP: - { - switch (var.type) - { - case OPERAND_LITERAL: - { - const vm_instr_t instr = getop_assignment (res.data.uid, - OPCODE_ARG_TYPE_VARIABLE, - LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_001 (instr, var.data.lit_id)); - break; - } - case OPERAND_TMP: - { - const vm_instr_t instr = getop_assignment (res.data.uid, - OPCODE_ARG_TYPE_VARIABLE, - var.data.uid); - serializer_dump_op_meta (create_op_meta_000 (instr)); - break; - } - } - break; - } - } + jsp_operand_t type_operand; + + type_operand = jsp_operand_t::make_idx_const_operand (OPCODE_ARG_TYPE_VARIABLE); + + dump_triple_address (VM_OP_ASSIGNMENT, res, type_operand, var); } -operand -dump_variable_assignment_res (operand var) +jsp_operand_t +dump_variable_assignment_res (jsp_operand_t var) { - operand op = tmp_operand (); + jsp_operand_t op = tmp_operand (); dump_variable_assignment (op, var); return op; } void -dump_varg_header_for_rewrite (varg_list_type vlt, operand obj) +dump_varg_header_for_rewrite (varg_list_type vlt, jsp_operand_t obj) { STACK_PUSH (varg_headers, serializer_get_current_instr_counter ()); switch (vlt) { case VARG_FUNC_EXPR: + { + dump_triple_address (VM_OP_FUNC_EXPR_N, + jsp_operand_t::make_unknown_operand (), + obj, + jsp_operand_t::make_unknown_operand ()); + break; + } case VARG_CONSTRUCT_EXPR: + { + dump_triple_address (VM_OP_CONSTRUCT_N, + jsp_operand_t::make_unknown_operand (), + obj, + jsp_operand_t::make_unknown_operand ()); + break; + } case VARG_CALL_EXPR: { - operand res = empty_operand (); - serializer_dump_op_meta (create_op_meta_for_vlt (vlt, &res, &obj)); + dump_triple_address (VM_OP_CALL_N, + jsp_operand_t::make_unknown_operand (), + obj, + jsp_operand_t::make_unknown_operand ()); break; } case VARG_FUNC_DECL: { - serializer_dump_op_meta (create_op_meta_for_vlt (vlt, NULL, &obj)); + dump_double_address (VM_OP_FUNC_DECL_N, + obj, + jsp_operand_t::make_unknown_operand ()); break; } case VARG_ARRAY_DECL: + { + dump_double_address (VM_OP_ARRAY_DECL, + jsp_operand_t::make_unknown_operand (), + jsp_operand_t::make_unknown_operand ()); + break; + } case VARG_OBJ_DECL: { - operand res = empty_operand (); - serializer_dump_op_meta (create_op_meta_for_vlt (vlt, &res, NULL)); + dump_double_address (VM_OP_OBJ_DECL, + jsp_operand_t::make_unknown_operand (), + jsp_operand_t::make_unknown_operand ()); break; } } } -operand +jsp_operand_t rewrite_varg_header_set_args_count (size_t args_count) { /* @@ -1264,15 +966,15 @@ rewrite_varg_header_set_args_count (size_t args_count) case VM_OP_CONSTRUCT_N: case VM_OP_CALL_N: { - const operand res = tmp_operand (); if (args_count > 255) { PARSE_ERROR (JSP_EARLY_ERROR_SYNTAX, "No more than 255 formal parameters / arguments are currently supported", LIT_ITERATOR_POS_ZERO); } - om.op.data.func_expr_n.arg_list = (idx_t) args_count; - om.op.data.func_expr_n.lhs = res.data.uid; + const jsp_operand_t res = tmp_operand (); + 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); return res; @@ -1285,7 +987,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 (); @@ -1299,10 +1001,10 @@ rewrite_varg_header_set_args_count (size_t args_count) "No more than 65535 formal parameters are currently supported", LIT_ITERATOR_POS_ZERO); } - const operand 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.lhs = res.data.uid; + const jsp_operand_t res = tmp_operand (); + 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); return res; @@ -1320,12 +1022,13 @@ rewrite_varg_header_set_args_count (size_t args_count) */ void dump_call_additional_info (opcode_call_flags_t flags, /**< call flags */ - operand this_arg) /**< 'this' argument - if flags include OPCODE_CALL_FLAGS_HAVE_THIS_ARG, - * or empty operand - otherwise */ + jsp_operand_t this_arg) /**< 'this' argument - if flags + * include OPCODE_CALL_FLAGS_HAVE_THIS_ARG, + * or empty operand - otherwise */ { if (flags & OPCODE_CALL_FLAGS_HAVE_THIS_ARG) { - JERRY_ASSERT (this_arg.type == OPERAND_TMP); + JERRY_ASSERT (this_arg.is_register_operand ()); JERRY_ASSERT (!operand_is_empty (this_arg)); } else @@ -1333,139 +1036,124 @@ 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.data.uid - : INVALID_VALUE)); - - serializer_dump_op_meta (create_op_meta_000 (instr)); + dump_triple_address (VM_OP_META, + jsp_operand_t::make_idx_const_operand (OPCODE_META_TYPE_CALL_SITE_INFO), + jsp_operand_t::make_idx_const_operand (flags), + this_arg); } /* dump_call_additional_info */ void -dump_varg (operand op) +dump_varg (jsp_operand_t op) { - switch (op.type) - { - case OPERAND_TMP: - { - const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_VARG, op.data.uid, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_000 (instr)); - return; - } - case OPERAND_LITERAL: - { - const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_VARG, LITERAL_TO_REWRITE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_010 (instr, op.data.lit_id)); - return; - } - } + dump_triple_address (VM_OP_META, + jsp_operand_t::make_idx_const_operand (OPCODE_META_TYPE_VARG), + op, + jsp_operand_t::make_empty_operand ()); } void -dump_prop_name_and_value (operand name, operand value) +dump_prop_name_and_value (jsp_operand_t name, jsp_operand_t value) { - JERRY_ASSERT (name.type == OPERAND_LITERAL); - literal_t lit = lit_get_literal_by_cp (name.data.lit_id); - operand tmp; + JERRY_ASSERT (name.is_literal_operand ()); + literal_t lit = lit_get_literal_by_cp (name.get_literal ()); + jsp_operand_t tmp; if (lit->get_type () == LIT_STR_T || lit->get_type () == LIT_MAGIC_STR_T || lit->get_type () == LIT_MAGIC_STR_EX_T) { - tmp = dump_string_assignment_res (name.data.lit_id); + tmp = dump_string_assignment_res (name.get_literal ()); } else { JERRY_ASSERT (lit->get_type () == LIT_NUMBER_T); - tmp = dump_number_assignment_res (name.data.lit_id); - } - switch (value.type) - { - case OPERAND_LITERAL: - { - const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_VARG_PROP_DATA, tmp.data.uid, LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_001 (instr, value.data.lit_id)); - break; - } - case OPERAND_TMP: - { - const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_VARG_PROP_DATA, tmp.data.uid, value.data.uid); - serializer_dump_op_meta (create_op_meta_000 (instr)); - break; - } + tmp = dump_number_assignment_res (name.get_literal ()); } + + dump_triple_address (VM_OP_META, + jsp_operand_t::make_idx_const_operand (OPCODE_META_TYPE_VARG_PROP_DATA), + tmp, + value); } void -dump_prop_getter_decl (operand name, operand func) +dump_prop_getter_decl (jsp_operand_t name, jsp_operand_t func) { - JERRY_ASSERT (name.type == OPERAND_LITERAL); - JERRY_ASSERT (func.type == OPERAND_TMP); - literal_t lit = lit_get_literal_by_cp (name.data.lit_id); - operand tmp; + JERRY_ASSERT (name.is_literal_operand ()); + JERRY_ASSERT (func.is_register_operand ()); + literal_t lit = lit_get_literal_by_cp (name.get_literal ()); + jsp_operand_t tmp; if (lit->get_type () == LIT_STR_T || lit->get_type () == LIT_MAGIC_STR_T || lit->get_type () == LIT_MAGIC_STR_EX_T) { - tmp = dump_string_assignment_res (name.data.lit_id); + tmp = dump_string_assignment_res (name.get_literal ()); } else { JERRY_ASSERT (lit->get_type () == LIT_NUMBER_T); - tmp = dump_number_assignment_res (name.data.lit_id); + tmp = dump_number_assignment_res (name.get_literal ()); } - const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_VARG_PROP_GETTER, tmp.data.uid, func.data.uid); - serializer_dump_op_meta (create_op_meta_000 (instr)); + + dump_triple_address (VM_OP_META, + jsp_operand_t::make_idx_const_operand (OPCODE_META_TYPE_VARG_PROP_GETTER), + tmp, + func); } void -dump_prop_setter_decl (operand name, operand func) +dump_prop_setter_decl (jsp_operand_t name, jsp_operand_t func) { - JERRY_ASSERT (name.type == OPERAND_LITERAL); - JERRY_ASSERT (func.type == OPERAND_TMP); - literal_t lit = lit_get_literal_by_cp (name.data.lit_id); - operand tmp; + JERRY_ASSERT (name.is_literal_operand ()); + JERRY_ASSERT (func.is_register_operand ()); + literal_t lit = lit_get_literal_by_cp (name.get_literal ()); + jsp_operand_t tmp; if (lit->get_type () == LIT_STR_T || lit->get_type () == LIT_MAGIC_STR_T || lit->get_type () == LIT_MAGIC_STR_EX_T) { - tmp = dump_string_assignment_res (name.data.lit_id); + tmp = dump_string_assignment_res (name.get_literal ()); } else { JERRY_ASSERT (lit->get_type () == LIT_NUMBER_T); - tmp = dump_number_assignment_res (name.data.lit_id); + tmp = dump_number_assignment_res (name.get_literal ()); } - const vm_instr_t instr = getop_meta (OPCODE_META_TYPE_VARG_PROP_SETTER, tmp.data.uid, func.data.uid); - serializer_dump_op_meta (create_op_meta_000 (instr)); + + dump_triple_address (VM_OP_META, + jsp_operand_t::make_idx_const_operand (OPCODE_META_TYPE_VARG_PROP_SETTER), + tmp, + func); } void -dump_prop_getter (operand res, operand obj, operand prop) +dump_prop_getter (jsp_operand_t res, jsp_operand_t obj, jsp_operand_t prop) { - dump_triple_address (getop_prop_getter, res, obj, prop); + dump_triple_address (VM_OP_PROP_GETTER, res, obj, prop); } -operand -dump_prop_getter_res (operand obj, operand prop) +jsp_operand_t +dump_prop_getter_res (jsp_operand_t obj, jsp_operand_t prop) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_prop_getter (res, obj, prop); return res; } void -dump_prop_setter (operand res, operand obj, operand prop) +dump_prop_setter (jsp_operand_t res, jsp_operand_t obj, jsp_operand_t prop) { - dump_triple_address (getop_prop_setter, res, obj, prop); + dump_triple_address (VM_OP_PROP_SETTER, res, obj, prop); } 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); - serializer_dump_op_meta (create_op_meta_000 (instr)); + + dump_triple_address (VM_OP_META, + jsp_operand_t::make_idx_const_operand (OPCODE_META_TYPE_FUNCTION_END), + jsp_operand_t::make_unknown_operand (), + jsp_operand_t::make_unknown_operand ()); } void @@ -1477,51 +1165,61 @@ 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)); + + op_meta function_end_op_meta = serializer_get_op_meta (STACK_TOP (function_ends)); + JERRY_ASSERT (function_end_op_meta.op.op_idx == VM_OP_META); + JERRY_ASSERT (function_end_op_meta.op.data.meta.type == OPCODE_META_TYPE_FUNCTION_END); + JERRY_ASSERT (function_end_op_meta.op.data.meta.data_1 == VM_IDX_REWRITE_GENERAL_CASE); + JERRY_ASSERT (function_end_op_meta.op.data.meta.data_2 == VM_IDX_REWRITE_GENERAL_CASE); + + function_end_op_meta.op.data.meta.data_1 = id1; + function_end_op_meta.op.data.meta.data_2 = id2; + + serializer_rewrite_op_meta (STACK_TOP (function_ends), function_end_op_meta); + STACK_DROP (function_ends, 1); } void -dump_this (operand op) +dump_this (jsp_operand_t op) { - dump_single_address (getop_this_binding, op); + dump_single_address (VM_OP_THIS_BINDING, op); } -operand +jsp_operand_t dump_this_res (void) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_this (res); return res; } void -dump_post_increment (operand res, operand obj) +dump_post_increment (jsp_operand_t res, jsp_operand_t obj) { - dump_double_address (getop_post_incr, res, obj); + dump_double_address (VM_OP_POST_INCR, res, obj); } -operand -dump_post_increment_res (operand op) +jsp_operand_t +dump_post_increment_res (jsp_operand_t op) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_post_increment (res, op); return res; } void -dump_post_decrement (operand res, operand obj) +dump_post_decrement (jsp_operand_t res, jsp_operand_t obj) { - dump_double_address (getop_post_decr, res, obj); + dump_double_address (VM_OP_POST_DECR, res, obj); } -operand -dump_post_decrement_res (operand op) +jsp_operand_t +dump_post_decrement_res (jsp_operand_t op) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_post_decrement (res, op); return res; } @@ -1530,12 +1228,12 @@ dump_post_decrement_res (operand op) * Check if operand of prefix operation is correct */ static void -check_operand_in_prefix_operation (operand obj) /**< operand, which type should be Reference */ +check_operand_in_prefix_operation (jsp_operand_t obj) /**< operand, which type should be Reference */ { const op_meta last = last_dumped_op_meta (); if (last.op.op_idx != VM_OP_PROP_GETTER) { - if (obj.type == OPERAND_TMP) + if (obj.is_empty_operand ()) { /* * FIXME: @@ -1549,544 +1247,449 @@ check_operand_in_prefix_operation (operand obj) /**< operand, which type should } /* check_operand_in_prefix_operation */ void -dump_pre_increment (operand res, operand obj) +dump_pre_increment (jsp_operand_t res, jsp_operand_t obj) { check_operand_in_prefix_operation (obj); - dump_double_address (getop_pre_incr, res, obj); + dump_double_address (VM_OP_PRE_INCR, res, obj); } -operand -dump_pre_increment_res (operand op) +jsp_operand_t +dump_pre_increment_res (jsp_operand_t op) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_pre_increment (res, op); return res; } void -dump_pre_decrement (operand res, operand obj) +dump_pre_decrement (jsp_operand_t res, jsp_operand_t obj) { check_operand_in_prefix_operation (obj); - dump_double_address (getop_pre_decr, res, obj); + dump_double_address (VM_OP_PRE_DECR, res, obj); } -operand -dump_pre_decrement_res (operand op) +jsp_operand_t +dump_pre_decrement_res (jsp_operand_t op) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_pre_decrement (res, op); return res; } void -dump_unary_plus (operand res, operand obj) +dump_unary_plus (jsp_operand_t res, jsp_operand_t obj) { - dump_double_address (getop_unary_plus, res, obj); + dump_double_address (VM_OP_UNARY_PLUS, res, obj); } -operand -dump_unary_plus_res (operand op) +jsp_operand_t +dump_unary_plus_res (jsp_operand_t op) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_unary_plus (res, op); return res; } void -dump_unary_minus (operand res, operand obj) +dump_unary_minus (jsp_operand_t res, jsp_operand_t obj) { - dump_double_address (getop_unary_minus, res, obj); + dump_double_address (VM_OP_UNARY_MINUS, res, obj); } -operand -dump_unary_minus_res (operand op) +jsp_operand_t +dump_unary_minus_res (jsp_operand_t op) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_unary_minus (res, op); return res; } void -dump_bitwise_not (operand res, operand obj) +dump_bitwise_not (jsp_operand_t res, jsp_operand_t obj) { - dump_double_address (getop_b_not, res, obj); + dump_double_address (VM_OP_B_NOT, res, obj); } -operand -dump_bitwise_not_res (operand op) +jsp_operand_t +dump_bitwise_not_res (jsp_operand_t op) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_bitwise_not (res, op); return res; } void -dump_logical_not (operand res, operand obj) +dump_logical_not (jsp_operand_t res, jsp_operand_t obj) { - dump_double_address (getop_logical_not, res, obj); + dump_double_address (VM_OP_LOGICAL_NOT, res, obj); } -operand -dump_logical_not_res (operand op) +jsp_operand_t +dump_logical_not_res (jsp_operand_t op) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_logical_not (res, op); return res; } void -dump_delete (operand res, operand op, bool is_strict, locus loc) +dump_delete (jsp_operand_t res, jsp_operand_t op, bool is_strict, locus loc) { - switch (op.type) + if (op.is_literal_operand ()) + { + literal_t lit = lit_get_literal_by_cp (op.get_literal ()); + if (lit->get_type () == LIT_STR_T + || lit->get_type () == LIT_MAGIC_STR_T + || lit->get_type () == LIT_MAGIC_STR_EX_T) + { + jsp_early_error_check_delete (is_strict, loc); + + dump_double_address (VM_OP_DELETE_VAR, res, op); + } + else if (lit->get_type () == LIT_NUMBER_T) + { + dump_boolean_assignment (res, true); + } + } + else { - case OPERAND_LITERAL: + JERRY_ASSERT (op.is_register_operand ()); + + const op_meta last_op_meta = last_dumped_op_meta (); + switch (last_op_meta.op.op_idx) { - literal_t lit = lit_get_literal_by_cp (op.data.lit_id); - if (lit->get_type () == LIT_STR_T - || lit->get_type () == LIT_MAGIC_STR_T - || lit->get_type () == LIT_MAGIC_STR_EX_T) + case VM_OP_PROP_GETTER: { - jsp_early_error_check_delete (is_strict, loc); - switch (res.type) - { - case OPERAND_LITERAL: - { - const vm_instr_t instr = getop_delete_var (LITERAL_TO_REWRITE, LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_110 (instr, res.data.lit_id, op.data.lit_id)); - break; - } - case OPERAND_TMP: - { - const vm_instr_t instr = getop_delete_var (res.data.uid, LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_010 (instr, op.data.lit_id)); - break; - } - } + const vm_instr_counter_t oc = (vm_instr_counter_t) (serializer_get_current_instr_counter () - 1); + serializer_set_writing_position (oc); + dump_triple_address (VM_OP_DELETE_PROP, + res, + create_operand_from_tmp_and_lit (last_op_meta.op.data.prop_getter.obj, + last_op_meta.lit_id[1]), + create_operand_from_tmp_and_lit (last_op_meta.op.data.prop_getter.prop, + last_op_meta.lit_id[2])); break; } - else if (lit->get_type () == LIT_NUMBER_T) + default: { dump_boolean_assignment (res, true); } - break; - } - case OPERAND_TMP: - { - const op_meta last_op_meta = last_dumped_op_meta (); - switch (last_op_meta.op.op_idx) - { - case VM_OP_PROP_GETTER: - { - const vm_instr_counter_t oc = (vm_instr_counter_t) (serializer_get_current_instr_counter () - 1); - serializer_set_writing_position (oc); - switch (res.type) - { - case OPERAND_LITERAL: - { - if (last_op_meta.op.data.prop_getter.obj == LITERAL_TO_REWRITE) - { - if (last_op_meta.op.data.prop_getter.prop == LITERAL_TO_REWRITE) - { - const vm_instr_t instr = getop_delete_prop (LITERAL_TO_REWRITE, - LITERAL_TO_REWRITE, - LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_111 (instr, res.data.lit_id, - last_op_meta.lit_id[1], - last_op_meta.lit_id[2])); - } - else - { - const vm_instr_t instr = getop_delete_prop (LITERAL_TO_REWRITE, - LITERAL_TO_REWRITE, - last_op_meta.op.data.prop_getter.prop); - serializer_dump_op_meta (create_op_meta_110 (instr, res.data.lit_id, - last_op_meta.lit_id[1])); - } - } - else - { - if (last_op_meta.op.data.prop_getter.prop == LITERAL_TO_REWRITE) - { - const vm_instr_t instr = getop_delete_prop (LITERAL_TO_REWRITE, - last_op_meta.op.data.prop_getter.obj, - LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_101 (instr, res.data.lit_id, - last_op_meta.lit_id[2])); - } - else - { - const vm_instr_t instr = getop_delete_prop (LITERAL_TO_REWRITE, - last_op_meta.op.data.prop_getter.obj, - last_op_meta.op.data.prop_getter.prop); - serializer_dump_op_meta (create_op_meta_100 (instr, res.data.lit_id)); - } - } - break; - } - case OPERAND_TMP: - { - if (last_op_meta.op.data.prop_getter.obj == LITERAL_TO_REWRITE) - { - if (last_op_meta.op.data.prop_getter.prop == LITERAL_TO_REWRITE) - { - const vm_instr_t instr = getop_delete_prop (res.data.uid, - LITERAL_TO_REWRITE, - LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_011 (instr, last_op_meta.lit_id[1], - last_op_meta.lit_id[2])); - } - else - { - const vm_instr_t instr = getop_delete_prop (res.data.uid, - LITERAL_TO_REWRITE, - last_op_meta.op.data.prop_getter.prop); - serializer_dump_op_meta (create_op_meta_010 (instr, last_op_meta.lit_id[1])); - } - } - else - { - if (last_op_meta.op.data.prop_getter.prop == LITERAL_TO_REWRITE) - { - const vm_instr_t instr = getop_delete_prop (res.data.uid, - last_op_meta.op.data.prop_getter.obj, - LITERAL_TO_REWRITE); - serializer_dump_op_meta (create_op_meta_001 (instr, last_op_meta.lit_id[2])); - } - else - { - const vm_instr_t instr = getop_delete_prop (res.data.uid, - last_op_meta.op.data.prop_getter.obj, - last_op_meta.op.data.prop_getter.prop); - serializer_dump_op_meta (create_op_meta_000 (instr)); - } - } - break; - } - } - break; - } - default: - { - dump_boolean_assignment (res, true); - } - } - break; } } } -operand -dump_delete_res (operand op, bool is_strict, locus loc) +jsp_operand_t +dump_delete_res (jsp_operand_t op, bool is_strict, locus loc) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_delete (res, op, is_strict, loc); return res; } void -dump_typeof (operand res, operand op) +dump_typeof (jsp_operand_t res, jsp_operand_t op) { - dump_double_address (getop_typeof, res, op); + dump_double_address (VM_OP_TYPEOF, res, op); } -operand -dump_typeof_res (operand op) +jsp_operand_t +dump_typeof_res (jsp_operand_t op) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_typeof (res, op); return res; } void -dump_multiplication (operand res, operand lhs, operand rhs) +dump_multiplication (jsp_operand_t res, jsp_operand_t lhs, jsp_operand_t rhs) { - dump_triple_address (getop_multiplication, res, lhs, rhs); + dump_triple_address (VM_OP_MULTIPLICATION, res, lhs, rhs); } -operand -dump_multiplication_res (operand lhs, operand rhs) +jsp_operand_t +dump_multiplication_res (jsp_operand_t lhs, jsp_operand_t rhs) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_multiplication (res, lhs, rhs); return res; } void -dump_division (operand res, operand lhs, operand rhs) +dump_division (jsp_operand_t res, jsp_operand_t lhs, jsp_operand_t rhs) { - dump_triple_address (getop_division, res, lhs, rhs); + dump_triple_address (VM_OP_DIVISION, res, lhs, rhs); } -operand -dump_division_res (operand lhs, operand rhs) +jsp_operand_t +dump_division_res (jsp_operand_t lhs, jsp_operand_t rhs) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_division (res, lhs, rhs); return res; } void -dump_remainder (operand res, operand lhs, operand rhs) +dump_remainder (jsp_operand_t res, jsp_operand_t lhs, jsp_operand_t rhs) { - dump_triple_address (getop_remainder, res, lhs, rhs); + dump_triple_address (VM_OP_REMAINDER, res, lhs, rhs); } -operand -dump_remainder_res (operand lhs, operand rhs) +jsp_operand_t +dump_remainder_res (jsp_operand_t lhs, jsp_operand_t rhs) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_remainder (res, lhs, rhs); return res; } void -dump_addition (operand res, operand lhs, operand rhs) +dump_addition (jsp_operand_t res, jsp_operand_t lhs, jsp_operand_t rhs) { - dump_triple_address (getop_addition, res, lhs, rhs); + dump_triple_address (VM_OP_ADDITION, res, lhs, rhs); } -operand -dump_addition_res (operand lhs, operand rhs) +jsp_operand_t +dump_addition_res (jsp_operand_t lhs, jsp_operand_t rhs) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_addition (res, lhs, rhs); return res; } void -dump_substraction (operand res, operand lhs, operand rhs) +dump_substraction (jsp_operand_t res, jsp_operand_t lhs, jsp_operand_t rhs) { - dump_triple_address (getop_substraction, res, lhs, rhs); + dump_triple_address (VM_OP_SUBSTRACTION, res, lhs, rhs); } -operand -dump_substraction_res (operand lhs, operand rhs) +jsp_operand_t +dump_substraction_res (jsp_operand_t lhs, jsp_operand_t rhs) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_substraction (res, lhs, rhs); return res; } void -dump_left_shift (operand res, operand lhs, operand rhs) +dump_left_shift (jsp_operand_t res, jsp_operand_t lhs, jsp_operand_t rhs) { - dump_triple_address (getop_b_shift_left, res, lhs, rhs); + dump_triple_address (VM_OP_B_SHIFT_LEFT, res, lhs, rhs); } -operand -dump_left_shift_res (operand lhs, operand rhs) +jsp_operand_t +dump_left_shift_res (jsp_operand_t lhs, jsp_operand_t rhs) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_left_shift (res, lhs, rhs); return res; } void -dump_right_shift (operand res, operand lhs, operand rhs) +dump_right_shift (jsp_operand_t res, jsp_operand_t lhs, jsp_operand_t rhs) { - dump_triple_address (getop_b_shift_right, res, lhs, rhs); + dump_triple_address (VM_OP_B_SHIFT_RIGHT, res, lhs, rhs); } -operand -dump_right_shift_res (operand lhs, operand rhs) +jsp_operand_t +dump_right_shift_res (jsp_operand_t lhs, jsp_operand_t rhs) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_right_shift (res, lhs, rhs); return res; } void -dump_right_shift_ex (operand res, operand lhs, operand rhs) +dump_right_shift_ex (jsp_operand_t res, jsp_operand_t lhs, jsp_operand_t rhs) { - dump_triple_address (getop_b_shift_uright, res, lhs, rhs); + dump_triple_address (VM_OP_B_SHIFT_URIGHT, res, lhs, rhs); } -operand -dump_right_shift_ex_res (operand lhs, operand rhs) +jsp_operand_t +dump_right_shift_ex_res (jsp_operand_t lhs, jsp_operand_t rhs) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_right_shift_ex (res, lhs, rhs); return res; } void -dump_less_than (operand res, operand lhs, operand rhs) +dump_less_than (jsp_operand_t res, jsp_operand_t lhs, jsp_operand_t rhs) { - dump_triple_address (getop_less_than, res, lhs, rhs); + dump_triple_address (VM_OP_LESS_THAN, res, lhs, rhs); } -operand -dump_less_than_res (operand lhs, operand rhs) +jsp_operand_t +dump_less_than_res (jsp_operand_t lhs, jsp_operand_t rhs) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_less_than (res, lhs, rhs); return res; } void -dump_greater_than (operand res, operand lhs, operand rhs) +dump_greater_than (jsp_operand_t res, jsp_operand_t lhs, jsp_operand_t rhs) { - dump_triple_address (getop_greater_than, res, lhs, rhs); + dump_triple_address (VM_OP_GREATER_THAN, res, lhs, rhs); } -operand -dump_greater_than_res (operand lhs, operand rhs) +jsp_operand_t +dump_greater_than_res (jsp_operand_t lhs, jsp_operand_t rhs) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_greater_than (res, lhs, rhs); return res; } void -dump_less_or_equal_than (operand res, operand lhs, operand rhs) +dump_less_or_equal_than (jsp_operand_t res, jsp_operand_t lhs, jsp_operand_t rhs) { - dump_triple_address (getop_less_or_equal_than, res, lhs, rhs); + dump_triple_address (VM_OP_LESS_OR_EQUAL_THAN, res, lhs, rhs); } -operand -dump_less_or_equal_than_res (operand lhs, operand rhs) +jsp_operand_t +dump_less_or_equal_than_res (jsp_operand_t lhs, jsp_operand_t rhs) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_less_or_equal_than (res, lhs, rhs); return res; } void -dump_greater_or_equal_than (operand res, operand lhs, operand rhs) +dump_greater_or_equal_than (jsp_operand_t res, jsp_operand_t lhs, jsp_operand_t rhs) { - dump_triple_address (getop_greater_or_equal_than, res, lhs, rhs); + dump_triple_address (VM_OP_GREATER_OR_EQUAL_THAN, res, lhs, rhs); } -operand -dump_greater_or_equal_than_res (operand lhs, operand rhs) +jsp_operand_t +dump_greater_or_equal_than_res (jsp_operand_t lhs, jsp_operand_t rhs) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_greater_or_equal_than (res, lhs, rhs); return res; } void -dump_instanceof (operand res, operand lhs, operand rhs) +dump_instanceof (jsp_operand_t res, jsp_operand_t lhs, jsp_operand_t rhs) { - dump_triple_address (getop_instanceof, res, lhs, rhs); + dump_triple_address (VM_OP_INSTANCEOF, res, lhs, rhs); } -operand -dump_instanceof_res (operand lhs, operand rhs) +jsp_operand_t +dump_instanceof_res (jsp_operand_t lhs, jsp_operand_t rhs) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_instanceof (res, lhs, rhs); return res; } void -dump_in (operand res, operand lhs, operand rhs) +dump_in (jsp_operand_t res, jsp_operand_t lhs, jsp_operand_t rhs) { - dump_triple_address (getop_in, res, lhs, rhs); + dump_triple_address (VM_OP_IN, res, lhs, rhs); } -operand -dump_in_res (operand lhs, operand rhs) +jsp_operand_t +dump_in_res (jsp_operand_t lhs, jsp_operand_t rhs) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_in (res, lhs, rhs); return res; } void -dump_equal_value (operand res, operand lhs, operand rhs) +dump_equal_value (jsp_operand_t res, jsp_operand_t lhs, jsp_operand_t rhs) { - dump_triple_address (getop_equal_value, res, lhs, rhs); + dump_triple_address (VM_OP_EQUAL_VALUE, res, lhs, rhs); } -operand -dump_equal_value_res (operand lhs, operand rhs) +jsp_operand_t +dump_equal_value_res (jsp_operand_t lhs, jsp_operand_t rhs) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_equal_value (res, lhs, rhs); return res; } void -dump_not_equal_value (operand res, operand lhs, operand rhs) +dump_not_equal_value (jsp_operand_t res, jsp_operand_t lhs, jsp_operand_t rhs) { - dump_triple_address (getop_not_equal_value, res, lhs, rhs); + dump_triple_address (VM_OP_NOT_EQUAL_VALUE, res, lhs, rhs); } -operand -dump_not_equal_value_res (operand lhs, operand rhs) +jsp_operand_t +dump_not_equal_value_res (jsp_operand_t lhs, jsp_operand_t rhs) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_not_equal_value (res, lhs, rhs); return res; } void -dump_equal_value_type (operand res, operand lhs, operand rhs) +dump_equal_value_type (jsp_operand_t res, jsp_operand_t lhs, jsp_operand_t rhs) { - dump_triple_address (getop_equal_value_type, res, lhs, rhs); + dump_triple_address (VM_OP_EQUAL_VALUE_TYPE, res, lhs, rhs); } -operand -dump_equal_value_type_res (operand lhs, operand rhs) +jsp_operand_t +dump_equal_value_type_res (jsp_operand_t lhs, jsp_operand_t rhs) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_equal_value_type (res, lhs, rhs); return res; } void -dump_not_equal_value_type (operand res, operand lhs, operand rhs) +dump_not_equal_value_type (jsp_operand_t res, jsp_operand_t lhs, jsp_operand_t rhs) { - dump_triple_address (getop_not_equal_value_type, res, lhs, rhs); + dump_triple_address (VM_OP_NOT_EQUAL_VALUE_TYPE, res, lhs, rhs); } -operand -dump_not_equal_value_type_res (operand lhs, operand rhs) +jsp_operand_t +dump_not_equal_value_type_res (jsp_operand_t lhs, jsp_operand_t rhs) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_not_equal_value_type (res, lhs, rhs); return res; } void -dump_bitwise_and (operand res, operand lhs, operand rhs) +dump_bitwise_and (jsp_operand_t res, jsp_operand_t lhs, jsp_operand_t rhs) { - dump_triple_address (getop_b_and, res, lhs, rhs); + dump_triple_address (VM_OP_B_AND, res, lhs, rhs); } -operand -dump_bitwise_and_res (operand lhs, operand rhs) +jsp_operand_t +dump_bitwise_and_res (jsp_operand_t lhs, jsp_operand_t rhs) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_bitwise_and (res, lhs, rhs); return res; } void -dump_bitwise_xor (operand res, operand lhs, operand rhs) +dump_bitwise_xor (jsp_operand_t res, jsp_operand_t lhs, jsp_operand_t rhs) { - dump_triple_address (getop_b_xor, res, lhs, rhs); + dump_triple_address (VM_OP_B_XOR, res, lhs, rhs); } -operand -dump_bitwise_xor_res (operand lhs, operand rhs) +jsp_operand_t +dump_bitwise_xor_res (jsp_operand_t lhs, jsp_operand_t rhs) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_bitwise_xor (res, lhs, rhs); return res; } void -dump_bitwise_or (operand res, operand lhs, operand rhs) +dump_bitwise_or (jsp_operand_t res, jsp_operand_t lhs, jsp_operand_t rhs) { - dump_triple_address (getop_b_or, res, lhs, rhs); + dump_triple_address (VM_OP_B_OR, res, lhs, rhs); } -operand -dump_bitwise_or_res (operand lhs, operand rhs) +jsp_operand_t +dump_bitwise_or_res (jsp_operand_t lhs, jsp_operand_t rhs) { - const operand res = tmp_operand (); + const jsp_operand_t res = tmp_operand (); dump_bitwise_or (res, lhs, rhs); return res; } @@ -2098,24 +1701,14 @@ start_dumping_logical_and_checks (void) } void -dump_logical_and_check_for_rewrite (operand op) +dump_logical_and_check_for_rewrite (jsp_operand_t op) { STACK_PUSH (logical_and_checks, serializer_get_current_instr_counter ()); - switch (op.type) - { - case OPERAND_LITERAL: - { - const vm_instr_t instr = getop_is_false_jmp_down (LITERAL_TO_REWRITE, INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_100 (instr, op.data.lit_id)); - break; - } - case OPERAND_TMP: - { - const vm_instr_t instr = getop_is_false_jmp_down (op.data.uid, INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_000 (instr)); - break; - } - } + + dump_triple_address (VM_OP_IS_FALSE_JMP_DOWN, + op, + jsp_operand_t::make_unknown_operand (), + jsp_operand_t::make_unknown_operand ()); } void @@ -2123,12 +1716,15 @@ rewrite_logical_and_checks (void) { for (uint8_t i = STACK_TOP (U8); i < STACK_SIZE (logical_and_checks); i++) { + vm_idx_t id1, id2; + split_instr_counter (get_diff_from (STACK_ELEMENT (logical_and_checks, i)), &id1, &id2); + op_meta jmp_op_meta = serializer_get_op_meta (STACK_ELEMENT (logical_and_checks, i)); JERRY_ASSERT (jmp_op_meta.op.op_idx == VM_OP_IS_FALSE_JMP_DOWN); - idx_t id1, id2; - split_instr_counter (get_diff_from (STACK_ELEMENT (logical_and_checks, i)), &id1, &id2); + jmp_op_meta.op.data.is_false_jmp_down.oc_idx_1 = id1; jmp_op_meta.op.data.is_false_jmp_down.oc_idx_2 = id2; + serializer_rewrite_op_meta (STACK_ELEMENT (logical_and_checks, i), jmp_op_meta); } STACK_DROP (logical_and_checks, STACK_SIZE (logical_and_checks) - STACK_TOP (U8)); @@ -2142,24 +1738,14 @@ start_dumping_logical_or_checks (void) } void -dump_logical_or_check_for_rewrite (operand op) +dump_logical_or_check_for_rewrite (jsp_operand_t op) { STACK_PUSH (logical_or_checks, serializer_get_current_instr_counter ()); - switch (op.type) - { - case OPERAND_LITERAL: - { - const vm_instr_t instr = getop_is_true_jmp_down (LITERAL_TO_REWRITE, INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_100 (instr, op.data.lit_id)); - break; - } - case OPERAND_TMP: - { - const vm_instr_t instr = getop_is_true_jmp_down (op.data.uid, INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_000 (instr)); - break; - } - } + + dump_triple_address (VM_OP_IS_TRUE_JMP_DOWN, + op, + jsp_operand_t::make_unknown_operand (), + jsp_operand_t::make_unknown_operand ()); } void @@ -2167,12 +1753,15 @@ rewrite_logical_or_checks (void) { for (uint8_t i = STACK_TOP (U8); i < STACK_SIZE (logical_or_checks); i++) { + vm_idx_t id1, id2; + split_instr_counter (get_diff_from (STACK_ELEMENT (logical_or_checks, i)), &id1, &id2); + op_meta jmp_op_meta = serializer_get_op_meta (STACK_ELEMENT (logical_or_checks, i)); JERRY_ASSERT (jmp_op_meta.op.op_idx == VM_OP_IS_TRUE_JMP_DOWN); - idx_t id1, id2; - split_instr_counter (get_diff_from (STACK_ELEMENT (logical_or_checks, i)), &id1, &id2); + jmp_op_meta.op.data.is_true_jmp_down.oc_idx_1 = id1; jmp_op_meta.op.data.is_true_jmp_down.oc_idx_2 = id2; + serializer_rewrite_op_meta (STACK_ELEMENT (logical_or_checks, i), jmp_op_meta); } STACK_DROP (logical_or_checks, STACK_SIZE (logical_or_checks) - STACK_TOP (U8)); @@ -2180,36 +1769,30 @@ rewrite_logical_or_checks (void) } void -dump_conditional_check_for_rewrite (operand op) +dump_conditional_check_for_rewrite (jsp_operand_t op) { STACK_PUSH (conditional_checks, serializer_get_current_instr_counter ()); - switch (op.type) - { - case OPERAND_LITERAL: - { - const vm_instr_t instr = getop_is_false_jmp_down (LITERAL_TO_REWRITE, INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_100 (instr, op.data.lit_id)); - break; - } - case OPERAND_TMP: - { - const vm_instr_t instr = getop_is_false_jmp_down (op.data.uid, INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_000 (instr)); - break; - } - } + + dump_triple_address (VM_OP_IS_FALSE_JMP_DOWN, + op, + jsp_operand_t::make_unknown_operand (), + jsp_operand_t::make_unknown_operand ()); } void rewrite_conditional_check (void) { + vm_idx_t id1, id2; + split_instr_counter (get_diff_from (STACK_TOP (conditional_checks)), &id1, &id2); + op_meta jmp_op_meta = serializer_get_op_meta (STACK_TOP (conditional_checks)); JERRY_ASSERT (jmp_op_meta.op.op_idx == VM_OP_IS_FALSE_JMP_DOWN); - idx_t id1, id2; - split_instr_counter (get_diff_from (STACK_TOP (conditional_checks)), &id1, &id2); + jmp_op_meta.op.data.is_false_jmp_down.oc_idx_1 = id1; jmp_op_meta.op.data.is_false_jmp_down.oc_idx_2 = id2; + serializer_rewrite_op_meta (STACK_TOP (conditional_checks), jmp_op_meta); + STACK_DROP (conditional_checks, 1); } @@ -2217,20 +1800,26 @@ 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); - serializer_dump_op_meta (create_op_meta_000 (instr)); + + dump_double_address (VM_OP_JMP_DOWN, + jsp_operand_t::make_unknown_operand (), + jsp_operand_t::make_unknown_operand ()); } void rewrite_jump_to_end (void) { + vm_idx_t id1, id2; + split_instr_counter (get_diff_from (STACK_TOP (jumps_to_end)), &id1, &id2); + op_meta jmp_op_meta = serializer_get_op_meta (STACK_TOP (jumps_to_end)); JERRY_ASSERT (jmp_op_meta.op.op_idx == VM_OP_JMP_DOWN); - idx_t id1, id2; - split_instr_counter (get_diff_from (STACK_TOP (jumps_to_end)), &id1, &id2); + jmp_op_meta.op.data.jmp_down.oc_idx_1 = id1; jmp_op_meta.op.data.jmp_down.oc_idx_2 = id2; + serializer_rewrite_op_meta (STACK_TOP (jumps_to_end), jmp_op_meta); + STACK_DROP (jumps_to_end, 1); } @@ -2245,8 +1834,8 @@ start_dumping_assignment_expression (void) STACK_PUSH (prop_getters, last); } -operand -dump_prop_setter_or_variable_assignment_res (operand res, operand op) +jsp_operand_t +dump_prop_setter_or_variable_assignment_res (jsp_operand_t res, jsp_operand_t op) { const op_meta last = STACK_TOP (prop_getters); if (last.op.op_idx == VM_OP_PROP_GETTER) @@ -2255,7 +1844,7 @@ dump_prop_setter_or_variable_assignment_res (operand res, operand op) } else { - if (res.type == OPERAND_TMP) + if (res.is_register_operand ()) { /* * FIXME: @@ -2269,70 +1858,70 @@ dump_prop_setter_or_variable_assignment_res (operand res, operand op) return op; } -operand -dump_prop_setter_or_addition_res (operand res, operand op) +jsp_operand_t +dump_prop_setter_or_addition_res (jsp_operand_t res, jsp_operand_t op) { - return dump_prop_setter_or_triple_address_res (dump_addition, res, op); + return dump_prop_setter_or_triple_address_res (VM_OP_ADDITION, res, op); } -operand -dump_prop_setter_or_multiplication_res (operand res, operand op) +jsp_operand_t +dump_prop_setter_or_multiplication_res (jsp_operand_t res, jsp_operand_t op) { - return dump_prop_setter_or_triple_address_res (dump_multiplication, res, op); + return dump_prop_setter_or_triple_address_res (VM_OP_MULTIPLICATION, res, op); } -operand -dump_prop_setter_or_division_res (operand res, operand op) +jsp_operand_t +dump_prop_setter_or_division_res (jsp_operand_t res, jsp_operand_t op) { - return dump_prop_setter_or_triple_address_res (dump_division, res, op); + return dump_prop_setter_or_triple_address_res (VM_OP_DIVISION, res, op); } -operand -dump_prop_setter_or_remainder_res (operand res, operand op) +jsp_operand_t +dump_prop_setter_or_remainder_res (jsp_operand_t res, jsp_operand_t op) { - return dump_prop_setter_or_triple_address_res (dump_remainder, res, op); + return dump_prop_setter_or_triple_address_res (VM_OP_REMAINDER, res, op); } -operand -dump_prop_setter_or_substraction_res (operand res, operand op) +jsp_operand_t +dump_prop_setter_or_substraction_res (jsp_operand_t res, jsp_operand_t op) { - return dump_prop_setter_or_triple_address_res (dump_substraction, res, op); + return dump_prop_setter_or_triple_address_res (VM_OP_SUBSTRACTION, res, op); } -operand -dump_prop_setter_or_left_shift_res (operand res, operand op) +jsp_operand_t +dump_prop_setter_or_left_shift_res (jsp_operand_t res, jsp_operand_t op) { - return dump_prop_setter_or_triple_address_res (dump_left_shift, res, op); + return dump_prop_setter_or_triple_address_res (VM_OP_B_SHIFT_LEFT, res, op); } -operand -dump_prop_setter_or_right_shift_res (operand res, operand op) +jsp_operand_t +dump_prop_setter_or_right_shift_res (jsp_operand_t res, jsp_operand_t op) { - return dump_prop_setter_or_triple_address_res (dump_right_shift, res, op); + return dump_prop_setter_or_triple_address_res (VM_OP_B_SHIFT_RIGHT, res, op); } -operand -dump_prop_setter_or_right_shift_ex_res (operand res, operand op) +jsp_operand_t +dump_prop_setter_or_right_shift_ex_res (jsp_operand_t res, jsp_operand_t op) { - return dump_prop_setter_or_triple_address_res (dump_right_shift_ex, res, op); + return dump_prop_setter_or_triple_address_res (VM_OP_B_SHIFT_URIGHT, res, op); } -operand -dump_prop_setter_or_bitwise_and_res (operand res, operand op) +jsp_operand_t +dump_prop_setter_or_bitwise_and_res (jsp_operand_t res, jsp_operand_t op) { - return dump_prop_setter_or_triple_address_res (dump_bitwise_and, res, op); + return dump_prop_setter_or_triple_address_res (VM_OP_B_AND, res, op); } -operand -dump_prop_setter_or_bitwise_xor_res (operand res, operand op) +jsp_operand_t +dump_prop_setter_or_bitwise_xor_res (jsp_operand_t res, jsp_operand_t op) { - return dump_prop_setter_or_triple_address_res (dump_bitwise_xor, res, op); + return dump_prop_setter_or_triple_address_res (VM_OP_B_XOR, res, op); } -operand -dump_prop_setter_or_bitwise_or_res (operand res, operand op) +jsp_operand_t +dump_prop_setter_or_bitwise_or_res (jsp_operand_t res, jsp_operand_t op) { - return dump_prop_setter_or_triple_address_res (dump_bitwise_or, res, op); + return dump_prop_setter_or_triple_address_res (VM_OP_B_OR, res, op); } void @@ -2342,34 +1931,25 @@ dumper_set_next_interation_target (void) } void -dump_continue_iterations_check (operand op) +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)) { - const vm_instr_t instr = getop_jmp_up (id1, id2); - serializer_dump_op_meta (create_op_meta_000 (instr)); + dump_double_address (VM_OP_JMP_UP, + jsp_operand_t::make_idx_const_operand (id1), + jsp_operand_t::make_idx_const_operand (id2)); } else { - switch (op.type) - { - case OPERAND_LITERAL: - { - const vm_instr_t instr = getop_is_true_jmp_up (LITERAL_TO_REWRITE, id1, id2); - serializer_dump_op_meta (create_op_meta_100 (instr, op.data.lit_id)); - break; - } - case OPERAND_TMP: - { - const vm_instr_t instr = getop_is_true_jmp_up (op.data.uid, id1, id2); - serializer_dump_op_meta (create_op_meta_000 (instr)); - break; - } - } + dump_triple_address (VM_OP_IS_TRUE_JMP_UP, + op, + jsp_operand_t::make_idx_const_operand (id1), + jsp_operand_t::make_idx_const_operand (id2)); } STACK_DROP (next_iterations, 1); } @@ -2390,23 +1970,24 @@ 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; + vm_instr_counter_t ret = serializer_get_current_instr_counter (); + if (is_simple_jump) { - instr = getop_jmp_down (id1, id2); + dump_double_address (VM_OP_JMP_DOWN, + jsp_operand_t::make_idx_const_operand (id1), + jsp_operand_t::make_idx_const_operand (id2)); } else { - instr = getop_jmp_break_continue (id1, id2); + dump_double_address (VM_OP_JMP_BREAK_CONTINUE, + jsp_operand_t::make_idx_const_operand (id1), + jsp_operand_t::make_idx_const_operand (id2)); } - vm_instr_counter_t ret = serializer_get_current_instr_counter (); - - serializer_dump_op_meta (create_op_meta_000 (instr)); - return ret; } /* dump_simple_or_nested_jump_for_rewrite */ @@ -2426,7 +2007,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) @@ -2461,34 +2042,42 @@ start_dumping_case_clauses (void) } void -dump_case_clause_check_for_rewrite (operand switch_expr, operand case_expr) +dump_case_clause_check_for_rewrite (jsp_operand_t switch_expr, jsp_operand_t case_expr) { - const operand res = tmp_operand (); - dump_triple_address (getop_equal_value_type, res, switch_expr, case_expr); + const jsp_operand_t res = tmp_operand (); + dump_triple_address (VM_OP_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.data.uid, INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_000 (instr)); + dump_triple_address (VM_OP_IS_TRUE_JMP_DOWN, + res, + jsp_operand_t::make_unknown_operand (), + jsp_operand_t::make_unknown_operand ()); } 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); - serializer_dump_op_meta (create_op_meta_000 (instr)); + + dump_double_address (VM_OP_JMP_DOWN, + jsp_operand_t::make_unknown_operand (), + jsp_operand_t::make_unknown_operand ()); } 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); + jmp_op_meta.op.data.is_true_jmp_down.oc_idx_1 = id1; jmp_op_meta.op.data.is_true_jmp_down.oc_idx_2 = id2; + serializer_rewrite_op_meta (jmp_oc, jmp_op_meta); + STACK_INCR_HEAD (U8, 2); } @@ -2496,12 +2085,16 @@ 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); + jmp_op_meta.op.data.jmp_down.oc_idx_1 = id1; jmp_op_meta.op.data.jmp_down.oc_idx_2 = id2; + serializer_rewrite_op_meta (jmp_oc, jmp_op_meta); } @@ -2522,23 +2115,15 @@ finish_dumping_case_clauses (void) * @return position of dumped instruction */ vm_instr_counter_t -dump_with_for_rewrite (operand op) /**< operand - result of evaluating Expression - * in WithStatement */ +dump_with_for_rewrite (jsp_operand_t op) /**< jsp_operand_t - result of evaluating Expression + * in WithStatement */ { vm_instr_counter_t oc = serializer_get_current_instr_counter (); - if (op.type == OPERAND_LITERAL) - { - const vm_instr_t instr = getop_with (LITERAL_TO_REWRITE, INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_100 (instr, op.data.lit_id)); - } - else - { - JERRY_ASSERT (op.type == OPERAND_TMP); - - const vm_instr_t instr = getop_with (op.data.uid, INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_000 (instr)); - } + dump_triple_address (VM_OP_WITH, + op, + jsp_operand_t::make_unknown_operand (), + jsp_operand_t::make_unknown_operand ()); return oc; } /* dump_with_for_rewrite */ @@ -2550,12 +2135,14 @@ dump_with_for_rewrite (operand op) /**< operand - result of evaluating Expressio void rewrite_with (vm_instr_counter_t oc) /**< instr counter of the instruction template */ { + vm_idx_t id1, id2; + split_instr_counter (get_diff_from (oc), &id1, &id2); + op_meta with_op_meta = serializer_get_op_meta (oc); - 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; + serializer_rewrite_op_meta (oc, with_op_meta); } /* rewrite_with */ @@ -2565,8 +2152,10 @@ 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); - serializer_dump_op_meta (create_op_meta_000 (instr)); + dump_triple_address (VM_OP_META, + jsp_operand_t::make_idx_const_operand (OPCODE_META_TYPE_END_WITH), + jsp_operand_t::make_empty_operand (), + jsp_operand_t::make_empty_operand ()); } /* dump_with_end */ /** @@ -2578,23 +2167,15 @@ dump_with_end (void) * @return position of dumped instruction */ vm_instr_counter_t -dump_for_in_for_rewrite (operand op) /**< operand - result of evaluating Expression - * in for-in statement */ +dump_for_in_for_rewrite (jsp_operand_t op) /**< jsp_operand_t - result of evaluating Expression + * in for-in statement */ { vm_instr_counter_t oc = serializer_get_current_instr_counter (); - if (op.type == OPERAND_LITERAL) - { - const vm_instr_t instr = getop_for_in (LITERAL_TO_REWRITE, INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_100 (instr, op.data.lit_id)); - } - else - { - JERRY_ASSERT (op.type == OPERAND_TMP); - - const vm_instr_t instr = getop_for_in (op.data.uid, INVALID_VALUE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_000 (instr)); - } + dump_triple_address (VM_OP_FOR_IN, + op, + jsp_operand_t::make_unknown_operand (), + jsp_operand_t::make_unknown_operand ()); return oc; } /* dump_for_in_for_rewrite */ @@ -2606,12 +2187,14 @@ dump_for_in_for_rewrite (operand op) /**< operand - result of evaluating Express void rewrite_for_in (vm_instr_counter_t oc) /**< instr counter of the instruction template */ { + vm_idx_t id1, id2; + split_instr_counter (get_diff_from (oc), &id1, &id2); + op_meta for_in_op_meta = serializer_get_op_meta (oc); - 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; + serializer_rewrite_op_meta (oc, for_in_op_meta); } /* rewrite_for_in */ @@ -2621,53 +2204,71 @@ 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); - serializer_dump_op_meta (create_op_meta_000 (instr)); + dump_triple_address (VM_OP_META, + jsp_operand_t::make_idx_const_operand (OPCODE_META_TYPE_END_FOR_IN), + jsp_operand_t::make_empty_operand (), + jsp_operand_t::make_empty_operand ()); } /* dump_for_in_end */ 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); - serializer_dump_op_meta (create_op_meta_000 (instr)); + + dump_double_address (VM_OP_TRY_BLOCK, + jsp_operand_t::make_unknown_operand (), + jsp_operand_t::make_unknown_operand ()); } void rewrite_try (void) { + vm_idx_t id1, id2; + split_instr_counter (get_diff_from (STACK_TOP (tries)), &id1, &id2); + op_meta try_op_meta = serializer_get_op_meta (STACK_TOP (tries)); JERRY_ASSERT (try_op_meta.op.op_idx == VM_OP_TRY_BLOCK); - idx_t id1, id2; - split_instr_counter (get_diff_from (STACK_TOP (tries)), &id1, &id2); + try_op_meta.op.data.try_block.oc_idx_1 = id1; try_op_meta.op.data.try_block.oc_idx_2 = id2; + serializer_rewrite_op_meta (STACK_TOP (tries), try_op_meta); + STACK_DROP (tries, 1); } void -dump_catch_for_rewrite (operand op) +dump_catch_for_rewrite (jsp_operand_t op) { - JERRY_ASSERT (op.type == OPERAND_LITERAL); + 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); - serializer_dump_op_meta (create_op_meta_000 (instr)); - instr = getop_meta (OPCODE_META_TYPE_CATCH_EXCEPTION_IDENTIFIER, LITERAL_TO_REWRITE, INVALID_VALUE); - serializer_dump_op_meta (create_op_meta_010 (instr, op.data.lit_id)); + + dump_triple_address (VM_OP_META, + jsp_operand_t::make_idx_const_operand (OPCODE_META_TYPE_CATCH), + jsp_operand_t::make_unknown_operand (), + jsp_operand_t::make_unknown_operand ()); + + dump_triple_address (VM_OP_META, + jsp_operand_t::make_idx_const_operand (OPCODE_META_TYPE_CATCH_EXCEPTION_IDENTIFIER), + op, + jsp_operand_t::make_empty_operand ()); } void rewrite_catch (void) { + vm_idx_t id1, id2; + split_instr_counter (get_diff_from (STACK_TOP (catches)), &id1, &id2); + 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; - split_instr_counter (get_diff_from (STACK_TOP (catches)), &id1, &id2); + catch_op_meta.op.data.meta.data_1 = id1; catch_op_meta.op.data.meta.data_2 = id2; + serializer_rewrite_op_meta (STACK_TOP (catches), catch_op_meta); + STACK_DROP (catches, 1); } @@ -2675,36 +2276,44 @@ 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); - serializer_dump_op_meta (create_op_meta_000 (instr)); + + dump_triple_address (VM_OP_META, + jsp_operand_t::make_idx_const_operand (OPCODE_META_TYPE_FINALLY), + jsp_operand_t::make_unknown_operand (), + jsp_operand_t::make_unknown_operand ()); } void rewrite_finally (void) { + vm_idx_t id1, id2; + split_instr_counter (get_diff_from (STACK_TOP (finallies)), &id1, &id2); + 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; - split_instr_counter (get_diff_from (STACK_TOP (finallies)), &id1, &id2); + finally_op_meta.op.data.meta.data_1 = id1; finally_op_meta.op.data.meta.data_2 = id2; + serializer_rewrite_op_meta (STACK_TOP (finallies), finally_op_meta); + STACK_DROP (finallies, 1); } 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); - serializer_dump_op_meta (create_op_meta_000 (instr)); + dump_triple_address (VM_OP_META, + jsp_operand_t::make_idx_const_operand (OPCODE_META_TYPE_END_TRY_CATCH_FINALLY), + jsp_operand_t::make_empty_operand (), + jsp_operand_t::make_empty_operand ()); } void -dump_throw (operand op) +dump_throw (jsp_operand_t op) { - dump_single_address (getop_throw_value, op); + dump_single_address (VM_OP_THROW_VALUE, op); } /** @@ -2734,8 +2343,8 @@ 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); - serializer_dump_var_decl (create_op_meta_100 (instr, lit_id)); + jsp_operand_t op_var_name = jsp_operand_t::make_lit_operand (lit_id); + serializer_dump_var_decl (jsp_dmp_create_op_meta (VM_OP_VAR_DECL, &op_var_name, 1)); } /* dump_variable_declaration */ /** @@ -2751,8 +2360,10 @@ 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); - serializer_dump_op_meta (create_op_meta_000 (instr)); + dump_triple_address (VM_OP_META, + jsp_operand_t::make_idx_const_operand (OPCODE_META_TYPE_SCOPE_CODE_FLAGS), + jsp_operand_t::make_unknown_operand (), + jsp_operand_t::make_empty_operand ()); return oc; } /* dump_scope_code_flags_for_rewrite */ @@ -2765,67 +2376,73 @@ 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 */ void dump_ret (void) { - serializer_dump_op_meta (create_op_meta_000 (getop_ret ())); + serializer_dump_op_meta (jsp_dmp_create_op_meta_0 (VM_OP_RET)); } 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))); + dump_triple_address (VM_OP_REG_VAR_DECL, + jsp_operand_t::make_idx_const_operand (VM_REG_FIRST), + jsp_operand_t::make_unknown_operand (), + jsp_operand_t::make_unknown_operand ()); } void rewrite_reg_var_decl (void) { vm_instr_counter_t reg_var_decl_oc = STACK_TOP (reg_var_decls); + op_meta opm = serializer_get_op_meta (reg_var_decl_oc); JERRY_ASSERT (opm.op.op_idx == VM_OP_REG_VAR_DECL); - 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 { opm.op.data.reg_var_decl.max = jsp_reg_max_for_temps; opm.op.data.reg_var_decl.local_var_regs_num = 0; } + serializer_rewrite_op_meta (reg_var_decl_oc, opm); + STACK_DROP (reg_var_decls, 1); } void -dump_retval (operand op) +dump_retval (jsp_operand_t op) { - dump_single_address (getop_retval, op); + dump_single_address (VM_OP_RETVAL, 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 15e9b9717b..574ca28f61 100644 --- a/jerry-core/parser/js/opcodes-dumper.h +++ b/jerry-core/parser/js/opcodes-dumper.h @@ -16,26 +16,275 @@ #ifndef OPCODES_DUMPER_H #define OPCODES_DUMPER_H -#include "opcodes.h" #include "ecma-globals.h" #include "lexer.h" +#include "opcodes.h" #include "scopes-tree.h" +#include "serializer.h" -typedef enum __attr_packed___ +/** + * Operand (descriptor of value or reference in context of parser) + */ +class jsp_operand_t { - OPERAND_LITERAL, - OPERAND_TMP -} operand_type; +public: + enum type_t : uint8_t + { + EMPTY, /**< empty operand */ + LITERAL, /**< operand contains literal value */ + TMP, /**< operand contains byte-code register index */ + IDX_CONST, /**< operand contains an integer constant that fits vm_idx_t */ + UNKNOWN, /**< operand, representing unknown value that would be rewritten later */ + UNINITIALIZED /**< uninitialized operand + * + * Note: + * For use only in assertions to check that operands + * are initialized before actual usage */ + }; -typedef struct -{ - operand_type type; + /** + * Construct operand template + */ + jsp_operand_t (void) + { +#ifndef JERRY_NDEBUG + _type = jsp_operand_t::UNINITIALIZED; +#endif /* !JERRY_NDEBUG */ + } /* jsp_operand_t */ + + /** + * Construct empty operand + * + * @return constructed operand + */ + static jsp_operand_t + make_empty_operand (void) + { + jsp_operand_t ret; + + ret._type = jsp_operand_t::EMPTY; + + return ret; + } /* make_empty_operand */ + + /** + * Construct unknown operand + * + * @return constructed operand + */ + static jsp_operand_t + make_unknown_operand (void) + { + jsp_operand_t ret; + + ret._type = jsp_operand_t::UNKNOWN; + + return ret; + } /* make_unknown_operand */ + + /** + * Construct idx-constant operand + * + * @return constructed operand + */ + static jsp_operand_t + make_idx_const_operand (vm_idx_t cnst) /**< integer in vm_idx_t range */ + { + jsp_operand_t ret; + + ret._type = jsp_operand_t::IDX_CONST; + ret._data.idx_const = cnst; + + return ret; + } /* make_idx_const_operand */ + + /** + * Construct literal operand + * + * @return constructed operand + */ + static jsp_operand_t + make_lit_operand (lit_cpointer_t lit_id) /**< literal identifier */ + { + JERRY_ASSERT (lit_id.packed_value != NOT_A_LITERAL.packed_value); + + jsp_operand_t ret; + + ret._type = jsp_operand_t::LITERAL; + ret._data.lit_id = lit_id; + + return ret; + } /* make_lit_operand */ + + /** + * Construct register operand + * + * @return constructed operand + */ + static jsp_operand_t + make_reg_operand (vm_idx_t reg_index) /**< register index */ + { + /* + * 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; + + ret._type = jsp_operand_t::TMP; + ret._data.uid = reg_index; + + return ret; + } /* make_reg_operand */ + + /** + * Is it empty operand? + * + * @return true / false + */ + bool + is_empty_operand (void) const + { + JERRY_ASSERT (_type != jsp_operand_t::UNINITIALIZED); + + return (_type == jsp_operand_t::EMPTY); + } /* is_empty_operand */ + + /** + * Is it unknown operand? + * + * @return true / false + */ + bool + is_unknown_operand (void) const + { + JERRY_ASSERT (_type != jsp_operand_t::UNINITIALIZED); + + return (_type == jsp_operand_t::UNKNOWN); + } /* is_unknown_operand */ + + /** + * Is it idx-constant operand? + * + * @return true / false + */ + bool + is_idx_const_operand (void) const + { + JERRY_ASSERT (_type != jsp_operand_t::UNINITIALIZED); + + return (_type == jsp_operand_t::IDX_CONST); + } /* is_idx_const_operand */ + + /** + * Is it byte-code register operand? + * + * @return true / false + */ + bool + is_register_operand (void) const + { + JERRY_ASSERT (_type != jsp_operand_t::UNINITIALIZED); + + return (_type == jsp_operand_t::TMP); + } /* is_register_operand */ + + /** + * Is it literal operand? + * + * @return true / false + */ + bool + is_literal_operand (void) const + { + JERRY_ASSERT (_type != jsp_operand_t::UNINITIALIZED); + + return (_type == jsp_operand_t::LITERAL); + } /* is_literal_operand */ + + /** + * Get idx for operand + * + * @return VM_IDX_REWRITE_LITERAL_UID (for jsp_operand_t::LITERAL), + * or register index (for jsp_operand_t::TMP). + */ + vm_idx_t + get_idx (void) const + { + JERRY_ASSERT (_type != jsp_operand_t::UNINITIALIZED); + + if (_type == jsp_operand_t::TMP) + { + return _data.uid; + } + else if (_type == jsp_operand_t::LITERAL) + { + return VM_IDX_REWRITE_LITERAL_UID; + } + else + { + JERRY_ASSERT (_type == jsp_operand_t::EMPTY); + + return VM_IDX_EMPTY; + } + } /* get_idx */ + + /** + * Get literal from operand + * + * @return literal identifier (for jsp_operand_t::LITERAL), + * or NOT_A_LITERAL (for jsp_operand_t::TMP). + */ + lit_cpointer_t + get_literal (void) const + { + JERRY_ASSERT (_type != jsp_operand_t::UNINITIALIZED); + + if (_type == jsp_operand_t::TMP) + { + return NOT_A_LITERAL; + } + else if (_type == jsp_operand_t::LITERAL) + { + return _data.lit_id; + } + else + { + JERRY_ASSERT (_type == jsp_operand_t::EMPTY); + + return NOT_A_LITERAL; + } + } /* get_literal */ + + /** + * Get constant from idx-constant operand + * + * @return an integer + */ + vm_idx_t + get_idx_const (void) const + { + JERRY_ASSERT (is_idx_const_operand ()); + + return _data.idx_const; + } /* get_idx_const */ +private: union { - idx_t uid; - lit_cpointer_t lit_id; - } data; -} operand; + vm_idx_t idx_const; /**< idx constant value (for jsp_operand_t::IDX_CONST) */ + 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; + + type_t _type; /**< type of operand */ +}; typedef enum __attr_packed___ { @@ -47,11 +296,11 @@ typedef enum __attr_packed___ VARG_CALL_EXPR } varg_list_type; -operand empty_operand (void); -operand literal_operand (lit_cpointer_t); -operand eval_ret_operand (void); -operand jsp_create_operand_for_in_special_reg (void); -bool operand_is_empty (operand); +jsp_operand_t empty_operand (void); +jsp_operand_t literal_operand (lit_cpointer_t); +jsp_operand_t eval_ret_operand (void); +jsp_operand_t jsp_create_operand_for_in_special_reg (void); +bool operand_is_empty (jsp_operand_t); void dumper_init (void); void dumper_free (void); @@ -64,128 +313,128 @@ void dumper_finish_scope (void); void dumper_start_varg_code_sequence (void); void dumper_finish_varg_code_sequence (void); -extern bool dumper_is_eval_literal (operand); - -operand dump_array_hole_assignment_res (void); -void dump_boolean_assignment (operand, bool); -operand dump_boolean_assignment_res (bool); -void dump_string_assignment (operand, lit_cpointer_t); -operand dump_string_assignment_res (lit_cpointer_t); -void dump_number_assignment (operand, lit_cpointer_t); -operand dump_number_assignment_res (lit_cpointer_t); -void dump_regexp_assignment (operand, lit_cpointer_t); -operand dump_regexp_assignment_res (lit_cpointer_t); -void dump_smallint_assignment (operand, idx_t); -operand dump_smallint_assignment_res (idx_t); -void dump_undefined_assignment (operand); -operand dump_undefined_assignment_res (void); -void dump_null_assignment (operand); -operand dump_null_assignment_res (void); -void dump_variable_assignment (operand, operand); -operand dump_variable_assignment_res (operand); - -void dump_varg_header_for_rewrite (varg_list_type, operand); -operand rewrite_varg_header_set_args_count (size_t); -void dump_call_additional_info (opcode_call_flags_t, operand); -void dump_varg (operand); - -void dump_prop_name_and_value (operand, operand); -void dump_prop_getter_decl (operand, operand); -void dump_prop_setter_decl (operand, operand); -void dump_prop_getter (operand, operand, operand); -operand dump_prop_getter_res (operand, operand); -void dump_prop_setter (operand, operand, operand); +extern bool dumper_is_eval_literal (jsp_operand_t); + +jsp_operand_t dump_array_hole_assignment_res (void); +void dump_boolean_assignment (jsp_operand_t, bool); +jsp_operand_t dump_boolean_assignment_res (bool); +void dump_string_assignment (jsp_operand_t, lit_cpointer_t); +jsp_operand_t dump_string_assignment_res (lit_cpointer_t); +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, 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); +jsp_operand_t dump_null_assignment_res (void); +void dump_variable_assignment (jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_variable_assignment_res (jsp_operand_t); + +void dump_varg_header_for_rewrite (varg_list_type, jsp_operand_t); +jsp_operand_t rewrite_varg_header_set_args_count (size_t); +void dump_call_additional_info (opcode_call_flags_t, jsp_operand_t); +void dump_varg (jsp_operand_t); + +void dump_prop_name_and_value (jsp_operand_t, jsp_operand_t); +void dump_prop_getter_decl (jsp_operand_t, jsp_operand_t); +void dump_prop_setter_decl (jsp_operand_t, jsp_operand_t); +void dump_prop_getter (jsp_operand_t, jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_prop_getter_res (jsp_operand_t, jsp_operand_t); +void dump_prop_setter (jsp_operand_t, jsp_operand_t, jsp_operand_t); void dump_function_end_for_rewrite (void); void rewrite_function_end (); -void dump_this (operand); -operand dump_this_res (void); - -void dump_post_increment (operand, operand); -operand dump_post_increment_res (operand); -void dump_post_decrement (operand, operand); -operand dump_post_decrement_res (operand); -void dump_pre_increment (operand, operand); -operand dump_pre_increment_res (operand); -void dump_pre_decrement (operand, operand); -operand dump_pre_decrement_res (operand); -void dump_unary_plus (operand, operand); -operand dump_unary_plus_res (operand); -void dump_unary_minus (operand, operand); -operand dump_unary_minus_res (operand); -void dump_bitwise_not (operand, operand); -operand dump_bitwise_not_res (operand); -void dump_logical_not (operand, operand); -operand dump_logical_not_res (operand); - -void dump_multiplication (operand, operand, operand); -operand dump_multiplication_res (operand, operand); -void dump_division (operand, operand, operand); -operand dump_division_res (operand, operand); -void dump_remainder (operand, operand, operand); -operand dump_remainder_res (operand, operand); -void dump_addition (operand, operand, operand); -operand dump_addition_res (operand, operand); -void dump_substraction (operand, operand, operand); -operand dump_substraction_res (operand, operand); -void dump_left_shift (operand, operand, operand); -operand dump_left_shift_res (operand, operand); -void dump_right_shift (operand, operand, operand); -operand dump_right_shift_res (operand, operand); -void dump_right_shift_ex (operand, operand, operand); -operand dump_right_shift_ex_res (operand, operand); -void dump_less_than (operand, operand, operand); -operand dump_less_than_res (operand, operand); -void dump_greater_than (operand, operand, operand); -operand dump_greater_than_res (operand, operand); -void dump_less_or_equal_than (operand, operand, operand); -operand dump_less_or_equal_than_res (operand, operand); -void dump_greater_or_equal_than (operand, operand, operand); -operand dump_greater_or_equal_than_res (operand, operand); -void dump_instanceof (operand, operand, operand); -operand dump_instanceof_res (operand, operand); -void dump_in (operand, operand, operand); -operand dump_in_res (operand, operand); -void dump_equal_value (operand, operand, operand); -operand dump_equal_value_res (operand, operand); -void dump_not_equal_value (operand, operand, operand); -operand dump_not_equal_value_res (operand, operand); -void dump_equal_value_type (operand, operand, operand); -operand dump_equal_value_type_res (operand, operand); -void dump_not_equal_value_type (operand, operand, operand); -operand dump_not_equal_value_type_res (operand, operand); -void dump_bitwise_and (operand, operand, operand); -operand dump_bitwise_and_res (operand, operand); -void dump_bitwise_xor (operand, operand, operand); -operand dump_bitwise_xor_res (operand, operand); -void dump_bitwise_or (operand, operand, operand); -operand dump_bitwise_or_res (operand, operand); +void dump_this (jsp_operand_t); +jsp_operand_t dump_this_res (void); + +void dump_post_increment (jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_post_increment_res (jsp_operand_t); +void dump_post_decrement (jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_post_decrement_res (jsp_operand_t); +void dump_pre_increment (jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_pre_increment_res (jsp_operand_t); +void dump_pre_decrement (jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_pre_decrement_res (jsp_operand_t); +void dump_unary_plus (jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_unary_plus_res (jsp_operand_t); +void dump_unary_minus (jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_unary_minus_res (jsp_operand_t); +void dump_bitwise_not (jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_bitwise_not_res (jsp_operand_t); +void dump_logical_not (jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_logical_not_res (jsp_operand_t); + +void dump_multiplication (jsp_operand_t, jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_multiplication_res (jsp_operand_t, jsp_operand_t); +void dump_division (jsp_operand_t, jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_division_res (jsp_operand_t, jsp_operand_t); +void dump_remainder (jsp_operand_t, jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_remainder_res (jsp_operand_t, jsp_operand_t); +void dump_addition (jsp_operand_t, jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_addition_res (jsp_operand_t, jsp_operand_t); +void dump_substraction (jsp_operand_t, jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_substraction_res (jsp_operand_t, jsp_operand_t); +void dump_left_shift (jsp_operand_t, jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_left_shift_res (jsp_operand_t, jsp_operand_t); +void dump_right_shift (jsp_operand_t, jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_right_shift_res (jsp_operand_t, jsp_operand_t); +void dump_right_shift_ex (jsp_operand_t, jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_right_shift_ex_res (jsp_operand_t, jsp_operand_t); +void dump_less_than (jsp_operand_t, jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_less_than_res (jsp_operand_t, jsp_operand_t); +void dump_greater_than (jsp_operand_t, jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_greater_than_res (jsp_operand_t, jsp_operand_t); +void dump_less_or_equal_than (jsp_operand_t, jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_less_or_equal_than_res (jsp_operand_t, jsp_operand_t); +void dump_greater_or_equal_than (jsp_operand_t, jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_greater_or_equal_than_res (jsp_operand_t, jsp_operand_t); +void dump_instanceof (jsp_operand_t, jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_instanceof_res (jsp_operand_t, jsp_operand_t); +void dump_in (jsp_operand_t, jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_in_res (jsp_operand_t, jsp_operand_t); +void dump_equal_value (jsp_operand_t, jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_equal_value_res (jsp_operand_t, jsp_operand_t); +void dump_not_equal_value (jsp_operand_t, jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_not_equal_value_res (jsp_operand_t, jsp_operand_t); +void dump_equal_value_type (jsp_operand_t, jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_equal_value_type_res (jsp_operand_t, jsp_operand_t); +void dump_not_equal_value_type (jsp_operand_t, jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_not_equal_value_type_res (jsp_operand_t, jsp_operand_t); +void dump_bitwise_and (jsp_operand_t, jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_bitwise_and_res (jsp_operand_t, jsp_operand_t); +void dump_bitwise_xor (jsp_operand_t, jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_bitwise_xor_res (jsp_operand_t, jsp_operand_t); +void dump_bitwise_or (jsp_operand_t, jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_bitwise_or_res (jsp_operand_t, jsp_operand_t); void start_dumping_logical_and_checks (void); -void dump_logical_and_check_for_rewrite (operand); +void dump_logical_and_check_for_rewrite (jsp_operand_t); void rewrite_logical_and_checks (void); void start_dumping_logical_or_checks (void); -void dump_logical_or_check_for_rewrite (operand); +void dump_logical_or_check_for_rewrite (jsp_operand_t); void rewrite_logical_or_checks (void); -void dump_conditional_check_for_rewrite (operand); +void dump_conditional_check_for_rewrite (jsp_operand_t); void rewrite_conditional_check (void); void dump_jump_to_end_for_rewrite (void); void rewrite_jump_to_end (void); void start_dumping_assignment_expression (void); -operand dump_prop_setter_or_variable_assignment_res (operand, operand); -operand dump_prop_setter_or_addition_res (operand, operand); -operand dump_prop_setter_or_multiplication_res (operand, operand); -operand dump_prop_setter_or_division_res (operand, operand); -operand dump_prop_setter_or_remainder_res (operand, operand); -operand dump_prop_setter_or_substraction_res (operand, operand); -operand dump_prop_setter_or_left_shift_res (operand, operand); -operand dump_prop_setter_or_right_shift_res (operand, operand); -operand dump_prop_setter_or_right_shift_ex_res (operand, operand); -operand dump_prop_setter_or_bitwise_and_res (operand, operand); -operand dump_prop_setter_or_bitwise_xor_res (operand, operand); -operand dump_prop_setter_or_bitwise_or_res (operand, operand); +jsp_operand_t dump_prop_setter_or_variable_assignment_res (jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_prop_setter_or_addition_res (jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_prop_setter_or_multiplication_res (jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_prop_setter_or_division_res (jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_prop_setter_or_remainder_res (jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_prop_setter_or_substraction_res (jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_prop_setter_or_left_shift_res (jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_prop_setter_or_right_shift_res (jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_prop_setter_or_right_shift_ex_res (jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_prop_setter_or_bitwise_and_res (jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_prop_setter_or_bitwise_xor_res (jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_prop_setter_or_bitwise_or_res (jsp_operand_t, jsp_operand_t); void dumper_set_break_target (void); void dumper_set_continue_target (void); @@ -196,37 +445,37 @@ dump_simple_or_nested_jump_for_rewrite (bool is_simple_jump, vm_instr_counter_t rewrite_simple_or_nested_jump_and_get_next (vm_instr_counter_t jump_oc, vm_instr_counter_t target_oc); -void dump_continue_iterations_check (operand); +void dump_continue_iterations_check (jsp_operand_t); void start_dumping_case_clauses (void); -void dump_case_clause_check_for_rewrite (operand, operand); +void dump_case_clause_check_for_rewrite (jsp_operand_t, jsp_operand_t); void dump_default_clause_check_for_rewrite (void); void rewrite_case_clause (void); void rewrite_default_clause (void); void finish_dumping_case_clauses (void); -void dump_delete (operand, operand, bool, locus); -operand dump_delete_res (operand, bool, locus); +void dump_delete (jsp_operand_t, jsp_operand_t, bool, locus); +jsp_operand_t dump_delete_res (jsp_operand_t, bool, locus); -void dump_typeof (operand, operand); -operand dump_typeof_res (operand); +void dump_typeof (jsp_operand_t, jsp_operand_t); +jsp_operand_t dump_typeof_res (jsp_operand_t); -vm_instr_counter_t dump_with_for_rewrite (operand); +vm_instr_counter_t dump_with_for_rewrite (jsp_operand_t); void rewrite_with (vm_instr_counter_t); void dump_with_end (void); -vm_instr_counter_t dump_for_in_for_rewrite (operand); +vm_instr_counter_t dump_for_in_for_rewrite (jsp_operand_t); void rewrite_for_in (vm_instr_counter_t); void dump_for_in_end (void); void dump_try_for_rewrite (void); void rewrite_try (void); -void dump_catch_for_rewrite (operand); +void dump_catch_for_rewrite (jsp_operand_t); void rewrite_catch (void); void dump_finally_for_rewrite (void); void rewrite_finally (void); void dump_end_try_catch_finally (void); -void dump_throw (operand); +void dump_throw (jsp_operand_t); bool dumper_variable_declaration_exists (lit_cpointer_t); void dump_variable_declaration (lit_cpointer_t); @@ -239,6 +488,6 @@ void dump_reg_var_decl_for_rewrite (void); void rewrite_reg_var_decl (void); void dump_ret (void); -void dump_retval (operand op); +void dump_retval (jsp_operand_t op); #endif /* OPCODES_DUMPER_H */ diff --git a/jerry-core/parser/js/parser.cpp b/jerry-core/parser/js/parser.cpp index aa90ec718d..ac1f6e07b0 100644 --- a/jerry-core/parser/js/parser.cpp +++ b/jerry-core/parser/js/parser.cpp @@ -60,11 +60,11 @@ STATIC_STACK (scopes, scopes_tree) #define EMIT_ERROR(type, MESSAGE) PARSE_ERROR(type, MESSAGE, tok.loc) #define EMIT_ERROR_VARG(type, MESSAGE, ...) PARSE_ERROR_VARG(type, MESSAGE, tok.loc, __VA_ARGS__) -static operand parse_expression (bool, jsp_eval_ret_store_t); +static jsp_operand_t parse_expression (bool, jsp_eval_ret_store_t); static void parse_statement (jsp_label_t *outermost_stmt_label_p); -static operand parse_assignment_expression (bool); +static jsp_operand_t parse_assignment_expression (bool); static void parse_source_element_list (bool, bool); -static operand parse_argument_list (varg_list_type, operand, operand *); +static jsp_operand_t parse_argument_list (varg_list_type, jsp_operand_t, jsp_operand_t *); static bool token_is (token_type tt) @@ -286,7 +286,7 @@ jsp_find_next_token_before_the_locus (token_type token_to_find, /**< token to se | NumericLiteral ; */ -static operand +static jsp_operand_t parse_property_name (void) { switch (tok.type) @@ -332,10 +332,10 @@ parse_property_name (void) static void parse_property_name_and_value (void) { - const operand name = parse_property_name (); + const jsp_operand_t name = parse_property_name (); token_after_newlines_must_be (TOK_COLON); skip_newlines (); - const operand value = parse_assignment_expression (true); + const jsp_operand_t value = parse_assignment_expression (true); dump_prop_name_and_value (name, value); jsp_early_error_add_prop_name (name, PROP_DATA); } @@ -381,7 +381,7 @@ parse_property_assignment (void) STACK_DECLARE_USAGE (scopes); - const operand name = parse_property_name (); + const jsp_operand_t name = parse_property_name (); jsp_early_error_add_prop_name (name, is_setter ? PROP_SET : PROP_GET); scopes_tree_set_contains_functions (STACK_TOP (scopes)); @@ -392,7 +392,7 @@ parse_property_assignment (void) lexer_set_strict_mode (scopes_tree_strict_mode (STACK_TOP (scopes))); skip_newlines (); - const operand func = parse_argument_list (VARG_FUNC_EXPR, empty_operand (), NULL); + const jsp_operand_t func = parse_argument_list (VARG_FUNC_EXPR, empty_operand (), NULL); dump_function_end_for_rewrite (); @@ -444,8 +444,8 @@ parse_property_assignment (void) /** Parse list of identifiers, assigment expressions or properties, splitted by comma. For each ALT dumps appropriate bytecode. Uses OBJ during dump if neccesary. Result tmp. */ -static operand -parse_argument_list (varg_list_type vlt, operand obj, operand *this_arg_p) +static jsp_operand_t +parse_argument_list (varg_list_type vlt, jsp_operand_t obj, jsp_operand_t *this_arg_p) { token_type close_tt = TOK_CLOSE_PAREN; size_t args_num = 0; @@ -468,13 +468,13 @@ parse_argument_list (varg_list_type vlt, operand obj, operand *this_arg_p) opcode_call_flags_t call_flags = OPCODE_CALL_FLAGS__EMPTY; - operand this_arg = empty_operand (); + jsp_operand_t this_arg = empty_operand (); if (this_arg_p != NULL && !operand_is_empty (*this_arg_p)) { call_flags = (opcode_call_flags_t) (call_flags | OPCODE_CALL_FLAGS_HAVE_THIS_ARG); - if (this_arg_p->type == OPERAND_LITERAL) + if (this_arg_p->is_literal_operand ()) { /* * FIXME: @@ -554,7 +554,7 @@ parse_argument_list (varg_list_type vlt, operand obj, operand *this_arg_p) { dumper_start_varg_code_sequence (); - operand op; + jsp_operand_t op; if (vlt == VARG_FUNC_DECL || vlt == VARG_FUNC_EXPR) @@ -609,7 +609,7 @@ parse_argument_list (varg_list_type vlt, operand obj, operand *this_arg_p) dumper_finish_varg_code_sequence (); } - operand res; + jsp_operand_t res; switch (vlt) { case VARG_FUNC_DECL: @@ -653,7 +653,7 @@ parse_function_declaration (void) jsp_label_t *masked_label_set_p = jsp_label_mask_set (); token_after_newlines_must_be (TOK_NAME); - const operand name = literal_operand (token_data_as_lit_cp ()); + const jsp_operand_t name = literal_operand (token_data_as_lit_cp ()); jsp_early_error_check_for_eval_and_arguments_in_strict_mode (name, is_strict_mode (), tok.loc); @@ -700,13 +700,13 @@ parse_function_declaration (void) /* function_expression : 'function' LT!* Identifier? LT!* '(' formal_parameter_list? LT!* ')' LT!* function_body ; */ -static operand +static jsp_operand_t parse_function_expression (void) { STACK_DECLARE_USAGE (scopes); assert_keyword (KW_FUNCTION); - operand res; + jsp_operand_t res; jsp_early_error_start_checking_of_vargs (); @@ -720,7 +720,7 @@ parse_function_expression (void) skip_newlines (); if (token_is (TOK_NAME)) { - const operand name = literal_operand (token_data_as_lit_cp ()); + const jsp_operand_t name = literal_operand (token_data_as_lit_cp ()); jsp_early_error_check_for_eval_and_arguments_in_strict_mode (name, is_strict_mode (), tok.loc); skip_newlines (); @@ -770,7 +770,7 @@ parse_function_expression (void) /* array_literal : '[' LT!* assignment_expression? (LT!* ',' (LT!* assignment_expression)?)* LT!* ']' LT!* ; */ -static operand +static jsp_operand_t parse_array_literal (void) { return parse_argument_list (VARG_ARRAY_DECL, empty_operand (), NULL); @@ -779,7 +779,7 @@ parse_array_literal (void) /* object_literal : '{' LT!* property_assignment (LT!* ',' LT!* property_assignment)* LT!* '}' ; */ -static operand +static jsp_operand_t parse_object_literal (void) { return parse_argument_list (VARG_OBJ_DECL, empty_operand (), NULL); @@ -793,7 +793,7 @@ parse_object_literal (void) | string_literal | regexp_literal ; */ -static operand +static jsp_operand_t parse_literal (void) { switch (tok.type) @@ -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"); @@ -820,7 +820,7 @@ parse_literal (void) | '{' LT!* object_literal LT!* '}' | '(' LT!* expression LT!* ')' ; */ -static operand +static jsp_operand_t parse_primary_expression (void) { if (is_keyword (KW_THIS)) @@ -855,7 +855,7 @@ parse_primary_expression (void) skip_newlines (); if (!token_is (TOK_CLOSE_PAREN)) { - operand res = parse_expression (true, JSP_EVAL_RET_STORE_NOT_DUMP); + jsp_operand_t res = parse_expression (true, JSP_EVAL_RET_STORE_NOT_DUMP); token_after_newlines_must_be (TOK_CLOSE_PAREN); return res; } @@ -889,10 +889,10 @@ parse_primary_expression (void) property_reference_suffix : '.' LT!* Identifier ; */ -static operand -parse_member_expression (operand *this_arg, operand *prop_gl) +static jsp_operand_t +parse_member_expression (jsp_operand_t *this_arg, jsp_operand_t *prop_gl) { - operand expr; + jsp_operand_t expr; if (is_keyword (KW_FUNCTION)) { expr = parse_function_expression (); @@ -922,7 +922,7 @@ parse_member_expression (operand *this_arg, operand *prop_gl) skip_newlines (); while (token_is (TOK_OPEN_SQUARE) || token_is (TOK_DOT)) { - operand prop = empty_operand (); + jsp_operand_t prop = empty_operand (); if (token_is (TOK_OPEN_SQUARE)) { @@ -992,12 +992,12 @@ parse_member_expression (operand *this_arg, operand *prop_gl) arguments : '(' LT!* assignment_expression LT!* (',' LT!* assignment_expression * LT!*)* ')' ; */ -static operand -parse_call_expression (operand *this_arg_gl, operand *prop_gl) +static jsp_operand_t +parse_call_expression (jsp_operand_t *this_arg_gl, jsp_operand_t *prop_gl) { - operand this_arg = empty_operand (); - operand expr = parse_member_expression (&this_arg, prop_gl); - operand prop; + jsp_operand_t this_arg = empty_operand (); + jsp_operand_t expr = parse_member_expression (&this_arg, prop_gl); + jsp_operand_t prop; skip_newlines (); if (!token_is (TOK_OPEN_PAREN)) @@ -1056,8 +1056,8 @@ parse_call_expression (operand *this_arg_gl, operand *prop_gl) : call_expression | new_expression ; */ -static operand -parse_left_hand_side_expression (operand *this_arg, operand *prop) +static jsp_operand_t +parse_left_hand_side_expression (jsp_operand_t *this_arg, jsp_operand_t *prop) { return parse_call_expression (this_arg, prop); } @@ -1065,16 +1065,16 @@ parse_left_hand_side_expression (operand *this_arg, operand *prop) /* postfix_expression : left_hand_side_expression ('++' | '--')? ; */ -static operand -parse_postfix_expression (operand *out_this_arg_gl_p, /**< out: if expression evaluates to object-based +static jsp_operand_t +parse_postfix_expression (jsp_operand_t *out_this_arg_gl_p, /**< out: if expression evaluates to object-based * reference - the reference's base; - * otherwise - empty operand */ - operand *out_prop_gl_p) /**< out: if expression evaluates to object-based + * otherwise - empty jsp_operand_t */ + jsp_operand_t *out_prop_gl_p) /**< out: if expression evaluates to object-based * reference - the reference's name; - * otherwise - empty operand */ + * otherwise - empty jsp_operand_t */ { - operand this_arg = empty_operand (), prop = empty_operand (); - operand expr = parse_left_hand_side_expression (&this_arg, &prop); + jsp_operand_t this_arg = empty_operand (), prop = empty_operand (); + jsp_operand_t expr = parse_left_hand_side_expression (&this_arg, &prop); if (lexer_prev_token ().type == TOK_NEWLINE) { @@ -1086,7 +1086,7 @@ parse_postfix_expression (operand *out_this_arg_gl_p, /**< out: if expression ev { jsp_early_error_check_for_eval_and_arguments_in_strict_mode (expr, is_strict_mode (), tok.loc); - const operand res = dump_post_increment_res (expr); + const jsp_operand_t res = dump_post_increment_res (expr); if (!operand_is_empty (this_arg) && !operand_is_empty (prop)) { dump_prop_setter (this_arg, prop, expr); @@ -1097,7 +1097,7 @@ parse_postfix_expression (operand *out_this_arg_gl_p, /**< out: if expression ev { jsp_early_error_check_for_eval_and_arguments_in_strict_mode (expr, is_strict_mode (), tok.loc); - const operand res = dump_post_decrement_res (expr); + const jsp_operand_t res = dump_post_decrement_res (expr); if (!operand_is_empty (this_arg) && !operand_is_empty (prop)) { dump_prop_setter (this_arg, prop, expr); @@ -1126,10 +1126,10 @@ parse_postfix_expression (operand *out_this_arg_gl_p, /**< out: if expression ev : postfix_expression | ('delete' | 'void' | 'typeof' | '++' | '--' | '+' | '-' | '~' | '!') unary_expression ; */ -static operand -parse_unary_expression (operand *this_arg_gl, operand *prop_gl) +static jsp_operand_t +parse_unary_expression (jsp_operand_t *this_arg_gl, jsp_operand_t *prop_gl) { - operand expr, this_arg = empty_operand (), prop = empty_operand (); + jsp_operand_t expr, this_arg = empty_operand (), prop = empty_operand (); switch (tok.type) { case TOK_DOUBLE_PLUS: @@ -1230,10 +1230,10 @@ parse_unary_expression (operand *this_arg_gl, operand *prop_gl) return expr; } -static operand -dump_assignment_of_lhs_if_literal (operand lhs) +static jsp_operand_t +dump_assignment_of_lhs_if_literal (jsp_operand_t lhs) { - if (lhs.type == OPERAND_LITERAL) + if (lhs.is_literal_operand ()) { lhs = dump_variable_assignment_res (lhs); } @@ -1243,10 +1243,10 @@ dump_assignment_of_lhs_if_literal (operand lhs) /* multiplicative_expression : unary_expression (LT!* ('*' | '/' | '%') LT!* unary_expression)* ; */ -static operand +static jsp_operand_t parse_multiplicative_expression (void) { - operand expr = parse_unary_expression (NULL, NULL); + jsp_operand_t expr = parse_unary_expression (NULL, NULL); skip_newlines (); while (true) @@ -1289,10 +1289,10 @@ parse_multiplicative_expression (void) /* additive_expression : multiplicative_expression (LT!* ('+' | '-') LT!* multiplicative_expression)* ; */ -static operand +static jsp_operand_t parse_additive_expression (void) { - operand expr = parse_multiplicative_expression (); + jsp_operand_t expr = parse_multiplicative_expression (); skip_newlines (); while (true) @@ -1328,10 +1328,10 @@ parse_additive_expression (void) /* shift_expression : additive_expression (LT!* ('<<' | '>>' | '>>>') LT!* additive_expression)* ; */ -static operand +static jsp_operand_t parse_shift_expression (void) { - operand expr = parse_additive_expression (); + jsp_operand_t expr = parse_additive_expression (); skip_newlines (); while (true) @@ -1374,10 +1374,10 @@ parse_shift_expression (void) /* relational_expression : shift_expression (LT!* ('<' | '>' | '<=' | '>=' | 'instanceof' | 'in') LT!* shift_expression)* ; */ -static operand +static jsp_operand_t parse_relational_expression (bool in_allowed) { - operand expr = parse_shift_expression (); + jsp_operand_t expr = parse_shift_expression (); skip_newlines (); while (true) @@ -1448,10 +1448,10 @@ parse_relational_expression (bool in_allowed) /* equality_expression : relational_expression (LT!* ('==' | '!=' | '===' | '!==') LT!* relational_expression)* ; */ -static operand +static jsp_operand_t parse_equality_expression (bool in_allowed) { - operand expr = parse_relational_expression (in_allowed); + jsp_operand_t expr = parse_relational_expression (in_allowed); skip_newlines (); while (true) @@ -1501,10 +1501,10 @@ parse_equality_expression (bool in_allowed) /* bitwise_and_expression : equality_expression (LT!* '&' LT!* equality_expression)* ; */ -static operand +static jsp_operand_t parse_bitwise_and_expression (bool in_allowed) { - operand expr = parse_equality_expression (in_allowed); + jsp_operand_t expr = parse_equality_expression (in_allowed); skip_newlines (); while (true) { @@ -1528,10 +1528,10 @@ parse_bitwise_and_expression (bool in_allowed) /* bitwise_xor_expression : bitwise_and_expression (LT!* '^' LT!* bitwise_and_expression)* ; */ -static operand +static jsp_operand_t parse_bitwise_xor_expression (bool in_allowed) { - operand expr = parse_bitwise_and_expression (in_allowed); + jsp_operand_t expr = parse_bitwise_and_expression (in_allowed); skip_newlines (); while (true) { @@ -1555,10 +1555,10 @@ parse_bitwise_xor_expression (bool in_allowed) /* bitwise_or_expression : bitwise_xor_expression (LT!* '|' LT!* bitwise_xor_expression)* ; */ -static operand +static jsp_operand_t parse_bitwise_or_expression (bool in_allowed) { - operand expr = parse_bitwise_xor_expression (in_allowed); + jsp_operand_t expr = parse_bitwise_xor_expression (in_allowed); skip_newlines (); while (true) { @@ -1582,10 +1582,10 @@ parse_bitwise_or_expression (bool in_allowed) /* logical_and_expression : bitwise_or_expression (LT!* '&&' LT!* bitwise_or_expression)* ; */ -static operand +static jsp_operand_t parse_logical_and_expression (bool in_allowed) { - operand expr = parse_bitwise_or_expression (in_allowed), tmp; + jsp_operand_t expr = parse_bitwise_or_expression (in_allowed), tmp; skip_newlines (); if (token_is (TOK_DOUBLE_AND)) { @@ -1617,10 +1617,10 @@ parse_logical_and_expression (bool in_allowed) /* logical_or_expression : logical_and_expression (LT!* '||' LT!* logical_and_expression)* ; */ -static operand +static jsp_operand_t parse_logical_or_expression (bool in_allowed) { - operand expr = parse_logical_and_expression (in_allowed), tmp; + jsp_operand_t expr = parse_logical_and_expression (in_allowed), tmp; skip_newlines (); if (token_is (TOK_DOUBLE_OR)) { @@ -1652,17 +1652,17 @@ parse_logical_or_expression (bool in_allowed) /* conditional_expression : logical_or_expression (LT!* '?' LT!* assignment_expression LT!* ':' LT!* assignment_expression)? ; */ -static operand +static jsp_operand_t parse_conditional_expression (bool in_allowed, bool *is_conditional) { - operand expr = parse_logical_or_expression (in_allowed); + jsp_operand_t expr = parse_logical_or_expression (in_allowed); skip_newlines (); if (token_is (TOK_QUERY)) { dump_conditional_check_for_rewrite (expr); skip_newlines (); expr = parse_assignment_expression (in_allowed); - operand tmp = dump_variable_assignment_res (expr); + jsp_operand_t tmp = dump_variable_assignment_res (expr); token_after_newlines_must_be (TOK_COLON); dump_jump_to_end_for_rewrite (); rewrite_conditional_check (); @@ -1687,11 +1687,11 @@ parse_conditional_expression (bool in_allowed, bool *is_conditional) : conditional_expression | left_hand_side_expression LT!* assignment_operator LT!* assignment_expression ; */ -static operand +static jsp_operand_t parse_assignment_expression (bool in_allowed) { bool is_conditional = false; - operand expr = parse_conditional_expression (in_allowed, &is_conditional); + jsp_operand_t expr = parse_conditional_expression (in_allowed, &is_conditional); if (is_conditional) { return expr; @@ -1717,7 +1717,7 @@ parse_assignment_expression (bool in_allowed) jsp_early_error_check_for_eval_and_arguments_in_strict_mode (expr, is_strict_mode (), tok.loc); skip_newlines (); start_dumping_assignment_expression (); - const operand assign_expr = parse_assignment_expression (in_allowed); + const jsp_operand_t assign_expr = parse_assignment_expression (in_allowed); if (tt == TOK_EQ) { @@ -1784,14 +1784,14 @@ parse_assignment_expression (bool in_allowed) * : assignment_expression (LT!* ',' LT!* assignment_expression)* * ; * - * @return operand which holds result of expression + * @return jsp_operand_t which holds result of expression */ -static operand +static jsp_operand_t parse_expression (bool in_allowed, /**< flag indicating if 'in' is allowed inside expression to parse */ jsp_eval_ret_store_t dump_eval_ret_store) /**< flag indicating if 'eval' * result code store should be dumped */ { - operand expr = parse_assignment_expression (in_allowed); + jsp_operand_t expr = parse_assignment_expression (in_allowed); while (true) { @@ -1826,11 +1826,11 @@ parse_expression (bool in_allowed, /**< flag indicating if 'in' is allowed insid initialiser : '=' LT!* assignment_expression ; */ -static operand +static jsp_operand_t parse_variable_declaration (void) { current_token_must_be (TOK_NAME); - const operand name = literal_operand (token_data_as_lit_cp ()); + const jsp_operand_t name = literal_operand (token_data_as_lit_cp ()); if (!dumper_variable_declaration_exists (token_data_as_lit_cp ())) { @@ -1845,7 +1845,7 @@ parse_variable_declaration (void) if (token_is (TOK_EQ)) { skip_newlines (); - const operand expr = parse_assignment_expression (true); + const jsp_operand_t expr = parse_assignment_expression (true); dump_variable_assignment (name, expr); } else @@ -1990,7 +1990,7 @@ jsp_parse_for_statement (jsp_label_t *outermost_stmt_label_p, /**< outermost (fi } else { - operand cond = parse_expression (true, JSP_EVAL_RET_STORE_NOT_DUMP); + jsp_operand_t cond = parse_expression (true, JSP_EVAL_RET_STORE_NOT_DUMP); dump_continue_iterations_check (cond); } @@ -2012,9 +2012,9 @@ jsp_parse_for_statement (jsp_label_t *outermost_stmt_label_p, /**< outermost (fi * false - otherwise, iterator consists of an identifier name (without base). */ static bool -jsp_parse_for_in_statement_iterator (operand *base_p, /**< out: base value of member expression, if any, - * empty operand - otherwise */ - operand *identifier_p) /**< out: property name (if base value is not empty), +jsp_parse_for_in_statement_iterator (jsp_operand_t *base_p, /**< out: base value of member expression, if any, + * empty jsp_operand_t - otherwise */ + jsp_operand_t *identifier_p) /**< out: property name (if base value is not empty), * identifier - otherwise */ { JERRY_ASSERT (base_p != NULL); @@ -2031,13 +2031,13 @@ jsp_parse_for_in_statement_iterator (operand *base_p, /**< out: base value of me } else { - operand base, identifier; + jsp_operand_t base, identifier; /* * FIXME: * Remove evaluation of last part of identifier chain */ - operand i = parse_left_hand_side_expression (&base, &identifier); + jsp_operand_t i = parse_left_hand_side_expression (&base, &identifier); if (operand_is_empty (base)) { @@ -2073,7 +2073,7 @@ jsp_parse_for_in_statement_iterator (operand *base_p, /**< out: base value of me * 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) @@ -2120,18 +2120,18 @@ jsp_parse_for_in_statement (jsp_label_t *outermost_stmt_label_p, /**< outermost skip_newlines (); // Collection - operand collection = parse_expression (true, JSP_EVAL_RET_STORE_NOT_DUMP); + jsp_operand_t collection = parse_expression (true, JSP_EVAL_RET_STORE_NOT_DUMP); current_token_must_be (TOK_CLOSE_PAREN); skip_token (); // 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 (); - operand iterator_base, iterator_identifier, for_in_special_reg; + jsp_operand_t iterator_base, iterator_identifier, for_in_special_reg; for_in_special_reg = jsp_create_operand_for_in_special_reg (); if (jsp_parse_for_in_statement_iterator (&iterator_base, &iterator_identifier)) @@ -2219,12 +2219,12 @@ jsp_parse_for_or_for_in_statement (jsp_label_t *outermost_stmt_label_p) /**< out } } /* jsp_parse_for_or_for_in_statement */ -static operand +static jsp_operand_t parse_expression_inside_parens (void) { token_after_newlines_must_be (TOK_OPEN_PAREN); skip_newlines (); - const operand res = parse_expression (true, JSP_EVAL_RET_STORE_NOT_DUMP); + const jsp_operand_t res = parse_expression (true, JSP_EVAL_RET_STORE_NOT_DUMP); token_after_newlines_must_be (TOK_CLOSE_PAREN); return res; } @@ -2265,7 +2265,7 @@ parse_if_statement (void) { assert_keyword (KW_IF); - const operand cond = parse_expression_inside_parens (); + const jsp_operand_t cond = parse_expression_inside_parens (); dump_conditional_check_for_rewrite (cond); skip_newlines (); @@ -2308,7 +2308,7 @@ parse_do_while_statement (jsp_label_t *outermost_stmt_label_p) /**< outermost (f serializer_get_current_instr_counter ()); token_after_newlines_must_be_keyword (KW_WHILE); - const operand cond = parse_expression_inside_parens (); + const jsp_operand_t cond = parse_expression_inside_parens (); dump_continue_iterations_check (cond); } @@ -2340,7 +2340,7 @@ parse_while_statement (jsp_label_t *outermost_stmt_label_p) /**< outermost (firs const locus end_loc = tok.loc; lexer_seek (cond_loc); - const operand cond = parse_expression_inside_parens (); + const jsp_operand_t cond = parse_expression_inside_parens (); dump_continue_iterations_check (cond); lexer_seek (end_loc); @@ -2358,7 +2358,7 @@ parse_with_statement (void) { EMIT_ERROR (JSP_EARLY_ERROR_SYNTAX, "'with' expression is not allowed in strict mode."); } - const operand expr = parse_expression_inside_parens (); + const jsp_operand_t expr = parse_expression_inside_parens (); scopes_tree_set_contains_with (STACK_TOP (scopes)); @@ -2406,7 +2406,7 @@ parse_switch_statement (void) { assert_keyword (KW_SWITCH); - const operand switch_expr = parse_expression_inside_parens (); + const jsp_operand_t switch_expr = parse_expression_inside_parens (); token_after_newlines_must_be (TOK_OPEN_BRACE); start_dumping_case_clauses (); @@ -2419,7 +2419,7 @@ parse_switch_statement (void) if (is_keyword (KW_CASE)) { skip_newlines (); - const operand case_expr = parse_expression (true, JSP_EVAL_RET_STORE_NOT_DUMP); + const jsp_operand_t case_expr = parse_expression (true, JSP_EVAL_RET_STORE_NOT_DUMP); next_token_must_be (TOK_COLON); dump_case_clause_check_for_rewrite (switch_expr, case_expr); skip_newlines (); @@ -2503,7 +2503,7 @@ parse_catch_clause (void) token_after_newlines_must_be (TOK_OPEN_PAREN); token_after_newlines_must_be (TOK_NAME); - const operand exception = literal_operand (token_data_as_lit_cp ()); + const jsp_operand_t exception = literal_operand (token_data_as_lit_cp ()); jsp_early_error_check_for_eval_and_arguments_in_strict_mode (exception, is_strict_mode (), tok.loc); token_after_newlines_must_be (TOK_CLOSE_PAREN); @@ -2829,7 +2829,7 @@ parse_statement (jsp_label_t *outermost_stmt_label_p) /**< outermost (first) lab skip_token (); if (!token_is (TOK_SEMICOLON) && !token_is (TOK_NEWLINE)) { - const operand op = parse_expression (true, JSP_EVAL_RET_STORE_NOT_DUMP); + const jsp_operand_t op = parse_expression (true, JSP_EVAL_RET_STORE_NOT_DUMP); dump_retval (op); insert_semicolon (); return; @@ -2853,7 +2853,7 @@ parse_statement (jsp_label_t *outermost_stmt_label_p) /**< outermost (first) lab if (is_keyword (KW_THROW)) { skip_token (); - const operand op = parse_expression (true, JSP_EVAL_RET_STORE_NOT_DUMP); + const jsp_operand_t op = parse_expression (true, JSP_EVAL_RET_STORE_NOT_DUMP); insert_semicolon (); dump_throw (op); return; @@ -2889,7 +2889,7 @@ parse_statement (jsp_label_t *outermost_stmt_label_p) /**< outermost (first) lab { lexer_save_token (tok); tok = temp; - operand expr = parse_expression (true, JSP_EVAL_RET_STORE_DUMP); + jsp_operand_t expr = parse_expression (true, JSP_EVAL_RET_STORE_DUMP); dump_assignment_of_lhs_if_literal (expr); insert_semicolon (); } diff --git a/jerry-core/parser/js/scopes-tree.cpp b/jerry-core/parser/js/scopes-tree.cpp index 8035ed2acc..2f14d495ff 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,20 +29,18 @@ assert_tree (scopes_tree t) JERRY_ASSERT (t != NULL); } -static idx_t -get_uid (op_meta *op, uint8_t i) +static vm_idx_t +get_uid (op_meta *op, size_t i) { - JERRY_ASSERT (i < 4); - raw_instr *raw = (raw_instr *) &op->op; - return raw->uids[i + 1]; + JERRY_ASSERT (i < 3); + return op->op.data.raw_args[i]; } static void -set_uid (op_meta *op, uint8_t i, idx_t uid) +set_uid (op_meta *op, size_t i, vm_idx_t uid) { - JERRY_ASSERT (i < 4); - raw_instr *raw = (raw_instr *) &op->op; - raw->uids[i + 1] = uid; + JERRY_ASSERT (i < 3); + op->op.data.raw_args[i] = uid; } vm_instr_counter_t @@ -151,7 +149,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 +186,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 +221,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 +414,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 +547,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/parser/js/scopes-tree.h b/jerry-core/parser/js/scopes-tree.h index 21842e35cc..8337d269ee 100644 --- a/jerry-core/parser/js/scopes-tree.h +++ b/jerry-core/parser/js/scopes-tree.h @@ -24,12 +24,17 @@ #include "lit-id-hash-table.h" #include "lit-literal.h" -#define NOT_A_LITERAL (lit_cpointer_t::null_cp ()) - +/** + * Intermediate instruction descriptor that additionally to byte-code instruction + * holds information about literals, associated with corresponding arguments + * of the instruction. + */ typedef struct { - lit_cpointer_t lit_id[3]; - vm_instr_t op; + lit_cpointer_t lit_id[3]; /**< literals, corresponding to arguments + * (NOT_A_LITERAL - if not literal is associated + * with corresponding argument) */ + vm_instr_t op; /**< byte-code instruction */ } op_meta; typedef struct tree_header diff --git a/jerry-core/parser/js/serializer.h b/jerry-core/parser/js/serializer.h index f4067c130c..1f2e398357 100644 --- a/jerry-core/parser/js/serializer.h +++ b/jerry-core/parser/js/serializer.h @@ -22,6 +22,8 @@ #include "vm.h" #include "scopes-tree.h" +#define NOT_A_LITERAL (lit_cpointer_t::null_cp ()) + void serializer_init (); void serializer_set_show_instrs (bool show_instrs); op_meta serializer_get_op_meta (vm_instr_counter_t); diff --git a/jerry-core/vm/opcodes-agnostic.cpp b/jerry-core/vm/opcodes-agnostic.cpp index b601e630f6..9b49291864 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 0e1c12fd5a..7dfdaa2bf4 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 fa06c4c814..15d6a35076 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 24795e6418..3f9caaac98 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 371580bfa1..243bfbb3b3 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 cc988cca54..80f6dd0883 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 270f94a447..d066a2ca58 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 0a36588504..2be929fc51 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 c2d6e51d17..3a648eba22 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 05df618358..d0ba20e8ce 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 9af0bd99d7..7aa9d360ab 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,48 +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 */ - -#define VM_OP_0(opcode_name, opcode_name_uppercase) \ - vm_instr_t getop_##opcode_name (void) \ - { \ - vm_instr_t instr; \ - memset (&instr, 0, sizeof(instr)); \ - instr.op_idx = VM_OP_##opcode_name_uppercase; \ - 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 instr; \ - memset (&instr, 0, sizeof(instr)); \ - instr.op_idx = VM_OP_##opcode_name_uppercase; \ - instr.data.opcode_name.arg1 = arg1_v; \ - return instr; \ - } -#define VM_OP_2(opcode_name, opcode_name_uppercase, arg1, arg1_type, arg2, arg2_type) \ - vm_instr_t getop_##opcode_name (idx_t arg1_v, idx_t arg2_v) \ - { \ - vm_instr_t instr; \ - memset (&instr, 0, sizeof(instr)); \ - instr.op_idx = VM_OP_##opcode_name_uppercase; \ - instr.data.opcode_name.arg1 = arg1_v; \ - instr.data.opcode_name.arg2 = arg2_v; \ - return instr; \ - } -#define VM_OP_3(opcode_name, opcode_name_uppercase, arg1, arg1_type, arg2, arg2_type, arg3, arg3_type) \ - vm_instr_t getop_##opcode_name (idx_t arg1_v, idx_t arg2_v, idx_t arg3_v) \ - { \ - vm_instr_t instr; \ - instr.op_idx = VM_OP_##opcode_name_uppercase; \ - instr.data.opcode_name.arg1 = arg1_v; \ - instr.data.opcode_name.arg2 = arg2_v; \ - instr.data.opcode_name.arg3 = arg3_v; \ - return instr; \ - } - -#include "vm-opcodes.inc.h" diff --git a/jerry-core/vm/opcodes.h b/jerry-core/vm/opcodes.h index cee54a7a11..42fc918262 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,35 +228,43 @@ 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" + + /** + * Opcode-independent arguments accessor + * + * Note: + * If opcode is statically known, opcode-specific way of accessing arguments should be used. + */ + vm_idx_t raw_args[3]; } data; } vm_instr_t; @@ -256,21 +297,4 @@ typedef enum 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); -#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); -#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); - -#include "vm-opcodes.inc.h" - - -typedef struct -{ - uint8_t uids[4]; -} raw_instr; - #endif /* OPCODES_H */ diff --git a/jerry-core/vm/pretty-printer.cpp b/jerry-core/vm/pretty-printer.cpp index 9ab95269b2..54b67d1d88 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); @@ -95,23 +95,22 @@ tmp_id_to_str (idx_t id) 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) + JERRY_ASSERT (current_arg >= 1 && current_arg <= 3); + + if (instr.data.raw_args[current_arg - 1] == VM_IDX_REWRITE_LITERAL_UID) { - if (lit_ids == NULL) - { - return "hz"; - } + JERRY_ASSERT (lit_ids != NULL); JERRY_ASSERT (lit_ids[current_arg - 1].packed_value != MEM_CP_NULL); + return lit_cp_to_str (lit_ids[current_arg - 1]); } - else if (raw.uids[current_arg] >= 128) + else if (instr.data.raw_args[current_arg - 1] >= 128) { - return tmp_id_to_str (raw.uids[current_arg]); + return tmp_id_to_str (instr.data.raw_args[current_arg - 1]); } else { - return lit_cp_to_str (serializer_get_literal_cp_by_uid (raw.uids[current_arg], NULL, oc)); + return lit_cp_to_str (serializer_get_literal_cp_by_uid (instr.data.raw_args[current_arg - 1], NULL, oc)); } } @@ -134,14 +133,12 @@ pp_printf (const char *format, vm_instr_t instr, lit_cpointer_t lit_ids[], vm_in { case 'd': { - JERRY_ASSERT (current_arg <= 3); - raw_instr raw = *(raw_instr*) &instr; - printf ("%d", raw.uids[current_arg]); + JERRY_ASSERT (current_arg >= 1 && current_arg <= 3); + printf ("%d", instr.data.raw_args[current_arg - 1]); break; } case 's': { - JERRY_ASSERT (current_arg <= 3); printf ("%s", var_to_str (instr, lit_ids, oc, current_arg)); break; } @@ -159,8 +156,8 @@ pp_printf (const char *format, vm_instr_t instr, lit_cpointer_t lit_ids[], vm_in #define PP_OP(op_name, format) \ case op_name: pp_printf (format, opm.op, opm.lit_id, oc, 1); break; #define VAR(i) var_to_str (opm.op, opm.lit_id, oc, i) -#define OC(i, j) __extension__({ raw_instr* raw = (raw_instr *) &opm.op; \ - vm_calc_instr_counter_from_idx_idx (raw->uids[i], raw->uids[j]); }) +#define OC(i, j) __extension__({ vm_calc_instr_counter_from_idx_idx (opm.op.data.raw_args[i - 1], \ + opm.op.data.raw_args[j - 1]); }) static int vargs_num = 0; static int seen_vargs = 0; @@ -174,7 +171,7 @@ dump_asm (vm_instr_counter_t oc, vm_instr_t instr) for (i = 1; i <= opcode_sizes[opcode_id]; i++) { - printf ("%4d ", ((raw_instr *) &instr)->uids[i]); + printf ("%4d ", instr.data.raw_args[i - 1]); } for (; i < 4; i++) @@ -309,7 +306,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 +413,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 +553,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 8ce18c0b64..9d3bb270b1 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 73ca21e023..d666348402 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; } @@ -49,6 +49,49 @@ instrs_equal (const vm_instr_t *instrs1, vm_instr_t *instrs2, uint16_t size) return true; } +#define VM_OP_0(opcode_name, opcode_name_uppercase) \ + static vm_instr_t __attr_unused___ getop_##opcode_name (void) \ + { \ + vm_instr_t instr; \ + instr.op_idx = VM_OP_##opcode_name_uppercase; \ + instr.data.raw_args[0] = VM_IDX_EMPTY; \ + instr.data.raw_args[1] = VM_IDX_EMPTY; \ + instr.data.raw_args[2] = VM_IDX_EMPTY; \ + return instr; \ + } +#define VM_OP_1(opcode_name, opcode_name_uppercase, arg_1, arg1_type) \ + static vm_instr_t __attr_unused___ getop_##opcode_name (vm_idx_t arg1_v) \ + { \ + vm_instr_t instr; \ + instr.op_idx = VM_OP_##opcode_name_uppercase; \ + instr.data.raw_args[0] = arg1_v; \ + instr.data.raw_args[1] = VM_IDX_EMPTY; \ + instr.data.raw_args[2] = VM_IDX_EMPTY; \ + return instr; \ + } +#define VM_OP_2(opcode_name, opcode_name_uppercase, arg_1, arg1_type, arg_2, arg2_type) \ + static vm_instr_t __attr_unused___ getop_##opcode_name (vm_idx_t arg1_v, vm_idx_t arg2_v) \ + { \ + vm_instr_t instr; \ + instr.op_idx = VM_OP_##opcode_name_uppercase; \ + instr.data.raw_args[0] = arg1_v; \ + instr.data.raw_args[1] = arg2_v; \ + instr.data.raw_args[2] = VM_IDX_EMPTY; \ + return instr; \ + } +#define VM_OP_3(opcode_name, opcode_name_uppercase, arg_1, arg1_type, arg_2, arg2_type, arg3_name, arg3_type) \ + static vm_instr_t __attr_unused___ 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; \ + instr.data.raw_args[0] = arg1_v; \ + instr.data.raw_args[1] = arg2_v; \ + instr.data.raw_args[2] = arg3_v; \ + return instr; \ + } + +#include "vm-opcodes.inc.h" + /** * Unit test's main function. */ @@ -77,8 +120,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;