From 0a4616b65fd1ff591ae7968b4d9f445f7cdd7cb8 Mon Sep 17 00:00:00 2001 From: Ilmir Usmanov Date: Wed, 24 Sep 2014 16:33:06 +0400 Subject: [PATCH] Remove call_0, call_1, func_decl_0, func_decl_1, func_decl_2 opcodes. --- src/libcoreint/opcodes.c | 155 ------------------------------ src/libcoreint/opcodes.h | 5 - src/liboptimizer/pretty-printer.c | 7 -- 3 files changed, 167 deletions(-) diff --git a/src/libcoreint/opcodes.c b/src/libcoreint/opcodes.c index 53581eeb0..3752eeb28 100644 --- a/src/libcoreint/opcodes.c +++ b/src/libcoreint/opcodes.c @@ -66,45 +66,6 @@ opfunc_nop (opcode_t opdata __unused, /**< operation data */ return ecma_make_empty_completion_value (); } /* opfunc_nop */ -ecma_completion_value_t -opfunc_call_1 (opcode_t opdata __unused, int_data_t *int_data) -{ - const idx_t func_name_lit_idx = opdata.data.call_1.name_lit_idx; - const idx_t lhs_var_idx = opdata.data.call_1.lhs; - - int_data->pos++; - - ecma_completion_value_t ret_value; - ret_value = ecma_make_empty_completion_value (); - - ECMA_TRY_CATCH (func_value, get_variable_value (int_data, func_name_lit_idx, false), ret_value); - ECMA_TRY_CATCH (arg_value, get_variable_value (int_data, opdata.data.call_1.arg1_lit_idx, false), ret_value); - - if (!ecma_op_is_callable (func_value.u.value)) - { - ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); - } - else - { - ecma_object_t *func_obj_p = ECMA_GET_POINTER (func_value.u.value.value); - - ECMA_TRY_CATCH (this_value, ecma_op_implicit_this_value (int_data->lex_env_p), ret_value); - ECMA_TRY_CATCH (call_completion, - ecma_op_function_call (func_obj_p, this_value.u.value, &arg_value.u.value, 1), - ret_value); - - ret_value = set_variable_value (int_data, lhs_var_idx, call_completion.u.value); - - ECMA_FINALIZE (call_completion); - ECMA_FINALIZE (this_value); - } - - ECMA_FINALIZE (arg_value); - ECMA_FINALIZE (func_value); - - return ret_value; -} - /** * 'Assignment' opcode handler. * @@ -481,77 +442,6 @@ function_declaration (int_data_t *int_data, /**< interpreter context */ return ret_value; } /* function_declaration */ -/** - * 'Function declaration with no parameters' opcode handler. - * - * @return completion value - * returned value must be freed with ecma_free_completion_value. - */ -ecma_completion_value_t -opfunc_func_decl_0 (opcode_t opdata, /**< operation data */ - int_data_t *int_data) /**< interpreter context */ -{ - int_data->pos++; - - return function_declaration (int_data, - opdata.data.func_decl_0.name_lit_idx, - NULL, - 0); -} /* opfunc_func_decl_0 */ - -/** - * 'Function declaration with one parameter' opcode handler. - * - * @return completion value - * returned value must be freed with ecma_free_completion_value. - */ -ecma_completion_value_t -opfunc_func_decl_1 (opcode_t opdata, /**< operation data */ - int_data_t *int_data) /**< interpreter context */ -{ - int_data->pos++; - - ecma_string_t *arg_name_string_p = ecma_new_ecma_string_from_lit_index (opdata.data.func_decl_1.arg1_lit_idx); - - ecma_completion_value_t ret_value = function_declaration (int_data, - opdata.data.func_decl_1.name_lit_idx, - &arg_name_string_p, - 1); - - ecma_deref_ecma_string (arg_name_string_p); - - return ret_value; -} /* opfunc_func_decl_1 */ - -/** - * 'Function declaration with two parameters' opcode handler. - * - * @return completion value - * returned value must be freed with ecma_free_completion_value. - */ -ecma_completion_value_t -opfunc_func_decl_2 (opcode_t opdata, /**< operation data */ - int_data_t *int_data) /**< interpreter context */ -{ - int_data->pos++; - - ecma_string_t* arg_names_strings[2] = - { - ecma_new_ecma_string_from_lit_index (opdata.data.func_decl_2.arg1_lit_idx), - ecma_new_ecma_string_from_lit_index (opdata.data.func_decl_2.arg2_lit_idx) - }; - - ecma_completion_value_t ret_value = function_declaration (int_data, - opdata.data.func_decl_1.name_lit_idx, - arg_names_strings, - 2); - - ecma_deref_ecma_string (arg_names_strings[0]); - ecma_deref_ecma_string (arg_names_strings[1]); - - return ret_value; -} /* opfunc_func_decl_2 */ - /** * 'Function declaration' opcode handler. * @@ -667,51 +557,6 @@ opfunc_func_expr_n (opcode_t opdata, /**< operation data */ return ret_value; } /* opfunc_func_expr_n */ -/** - * Function call with no arguments' opcode handler. - * - * See also: ECMA-262 v5, 11.2.3 - * - * @return completion value - * Returned value must be freed with ecma_free_completion_value. - */ -ecma_completion_value_t -opfunc_call_0 (opcode_t opdata, /**< operation data */ - int_data_t *int_data) /**< interpreter context */ -{ - const idx_t func_name_lit_idx = opdata.data.call_0.name_lit_idx; - const idx_t lhs_var_idx = opdata.data.call_0.lhs; - - int_data->pos++; - - ecma_completion_value_t ret_value; - - ECMA_TRY_CATCH (func_value, get_variable_value (int_data, func_name_lit_idx, false), ret_value); - - if (!ecma_op_is_callable (func_value.u.value)) - { - ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); - } - else - { - ecma_object_t *func_obj_p = ECMA_GET_POINTER (func_value.u.value.value); - - ECMA_TRY_CATCH (this_value, ecma_op_implicit_this_value (int_data->lex_env_p), ret_value); - ECMA_TRY_CATCH (call_completion, - ecma_op_function_call (func_obj_p, this_value.u.value, NULL, 0), - ret_value); - - ret_value = set_variable_value (int_data, lhs_var_idx, call_completion.u.value); - - ECMA_FINALIZE (call_completion); - ECMA_FINALIZE (this_value); - } - - ECMA_FINALIZE (func_value); - - return ret_value; -} /* opfunc_call_0 */ - /** * 'Function call' opcode handler. * diff --git a/src/libcoreint/opcodes.h b/src/libcoreint/opcodes.h index e81dc982e..98e6ea1a4 100644 --- a/src/libcoreint/opcodes.h +++ b/src/libcoreint/opcodes.h @@ -96,14 +96,9 @@ opcode_counter_t calc_opcode_counter_from_idx_idx (const idx_t oc_idx_1, const i opcode_counter_t read_meta_opcode_counter (opcode_meta_type expected_type, int_data_t *int_data); #define OP_CALLS_AND_ARGS(p, a) \ - p##_2 (a, call_0, lhs, name_lit_idx) \ - p##_3 (a, call_1, lhs, name_lit_idx, arg1_lit_idx) \ p##_3 (a, call_n, lhs, name_lit_idx, arg_list) \ p##_3 (a, native_call, lhs, name, arg_list) \ p##_3 (a, construct_n, lhs, name_lit_idx, arg_list) \ - p##_1 (a, func_decl_0, name_lit_idx) \ - p##_2 (a, func_decl_1, name_lit_idx, arg1_lit_idx) \ - p##_3 (a, func_decl_2, name_lit_idx, arg1_lit_idx, arg2_lit_idx) \ p##_2 (a, func_decl_n, name_lit_idx, arg_list) \ p##_3 (a, func_expr_n, lhs, name_lit_idx, arg_list) \ p##_1 (a, exitval, status_code) \ diff --git a/src/liboptimizer/pretty-printer.c b/src/liboptimizer/pretty-printer.c index 52742f757..4258d5d5f 100644 --- a/src/liboptimizer/pretty-printer.c +++ b/src/liboptimizer/pretty-printer.c @@ -371,8 +371,6 @@ pp_opcode (opcode_counter_t oc, opcode_t opcode, bool is_rewrite) __printf (" // "); - TODO (Pretty print for prop_setter); - switch (opcode_num) { CASE_CONDITIONAL_JUMP (is_true_jmp_up, "if (", value, ") goto", oc, -, opcode_1, opcode_2) @@ -413,13 +411,8 @@ pp_opcode (opcode_counter_t oc, opcode_t opcode, bool is_rewrite) CASE_DOUBLE_ADDRESS (pre_incr, dst, "=", "++", var_right) CASE_DOUBLE_ADDRESS (pre_decr, dst, "=", "--", var_right) CASE_ASSIGNMENT (assignment, var_left, "=", value_right) - CASE_VARG_0_NAME_LHS (call_0, lhs, "=", "", name_lit_idx, "(", ")") - CASE_VARG_1_NAME_LHS (call_1, lhs, "=", "", name_lit_idx, "(", arg1_lit_idx, ")") CASE_VARG_N_NAME_LHS (call_n, lhs, "=", "", name_lit_idx, arg_list) CASE_VARG_N_NAME_LHS (construct_n, lhs, "=", "new", name_lit_idx, arg_list) - CASE_VARG_0_NAME (func_decl_0, "function", name_lit_idx, "(", ")") - CASE_VARG_1_NAME (func_decl_1, "function", name_lit_idx, "(", arg1_lit_idx, ")") - CASE_VARG_2_NAME (func_decl_2, "function", name_lit_idx, "(", arg1_lit_idx, arg2_lit_idx, ")") CASE_VARG_N_NAME (func_decl_n, "function", name_lit_idx, arg_list) CASE_EXIT (exitval, "exit", status_code) CASE_SINGLE_ADDRESS (retval, "return", ret_value)