diff --git a/jerry-core/parser/js/opcodes-dumper.cpp b/jerry-core/parser/js/opcodes-dumper.cpp index 9f8237b2a..60552f82f 100644 --- a/jerry-core/parser/js/opcodes-dumper.cpp +++ b/jerry-core/parser/js/opcodes-dumper.cpp @@ -1182,18 +1182,10 @@ rewrite_function_end () STACK_DROP (function_ends, 1); } -void -dump_this (jsp_operand_t op) -{ - dump_single_address (VM_OP_THIS_BINDING, op); -} - jsp_operand_t dump_this_res (void) { - const jsp_operand_t res = tmp_operand (); - dump_this (res); - return res; + return jsp_operand_t::make_reg_operand (VM_REG_SPECIAL_THIS_BINDING); } void diff --git a/jerry-core/parser/js/opcodes-dumper.h b/jerry-core/parser/js/opcodes-dumper.h index 831720474..7ce0f7a86 100644 --- a/jerry-core/parser/js/opcodes-dumper.h +++ b/jerry-core/parser/js/opcodes-dumper.h @@ -348,7 +348,6 @@ 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 (jsp_operand_t); jsp_operand_t dump_this_res (void); void dump_post_increment (jsp_operand_t, jsp_operand_t); diff --git a/jerry-core/parser/js/scopes-tree.cpp b/jerry-core/parser/js/scopes-tree.cpp index 2bd9f662e..64ce3dcf3 100644 --- a/jerry-core/parser/js/scopes-tree.cpp +++ b/jerry-core/parser/js/scopes-tree.cpp @@ -350,7 +350,6 @@ generate_instr (linked_list instr_list, /**< instruction list */ case VM_OP_FUNC_DECL_N: case VM_OP_ARRAY_DECL: case VM_OP_OBJ_DECL: - case VM_OP_THIS_BINDING: case VM_OP_WITH: case VM_OP_FOR_IN: case VM_OP_THROW_VALUE: @@ -492,7 +491,6 @@ count_new_literals_in_instr (op_meta *om_p) /**< instruction */ case VM_OP_FUNC_DECL_N: case VM_OP_ARRAY_DECL: case VM_OP_OBJ_DECL: - case VM_OP_THIS_BINDING: case VM_OP_WITH: case VM_OP_THROW_VALUE: case VM_OP_IS_TRUE_JMP_UP: diff --git a/jerry-core/vm/opcodes-helpers-variables.cpp b/jerry-core/vm/opcodes-helpers-variables.cpp index acf0166fc..75fe1bae7 100644 --- a/jerry-core/vm/opcodes-helpers-variables.cpp +++ b/jerry-core/vm/opcodes-helpers-variables.cpp @@ -55,7 +55,7 @@ do_strict_eval_arguments_check (ecma_object_t *ref_base_lex_env_p, /**< base of /** * Check if the variable is register variable. * - * @return true - if var_idx is register variable in current interpreter context, + * @return true - if var_idx is a register variable, * false - otherwise. */ bool diff --git a/jerry-core/vm/opcodes.cpp b/jerry-core/vm/opcodes.cpp index eacb66d37..7e0591d8d 100644 --- a/jerry-core/vm/opcodes.cpp +++ b/jerry-core/vm/opcodes.cpp @@ -1350,32 +1350,6 @@ opfunc_logical_not (vm_instr_t instr, /**< instruction */ return ret_value; } /* opfunc_logical_not */ -/** - * 'This' opcode handler. - * - * See also: ECMA-262 v5, 11.1.1 - * - * @return completion value - * Returned value must be freed with ecma_free_completion_value - */ -ecma_completion_value_t -opfunc_this_binding (vm_instr_t instr, /**< instruction */ - vm_frame_ctx_t *frame_ctx_p) /**< interpreter context */ -{ - 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++; - - ecma_completion_value_t ret_value; - - ret_value = set_variable_value (frame_ctx_p, lit_oc, - dst_var_idx, - frame_ctx_p->this_binding); - - return ret_value; -} /* opfunc_this_binding */ - /** * 'With' opcode handler. * diff --git a/jerry-core/vm/opcodes.h b/jerry-core/vm/opcodes.h index 04dd91e11..377f7edf6 100644 --- a/jerry-core/vm/opcodes.h +++ b/jerry-core/vm/opcodes.h @@ -90,8 +90,9 @@ typedef enum : vm_idx_t VM_REG_SPECIAL_EVAL_RET = VM_REG_SPECIAL_FIRST, /**< eval return value */ VM_REG_SPECIAL_FOR_IN_PROPERTY_NAME, /**< variable, containing property name, * at start of for-in loop body */ + VM_REG_SPECIAL_THIS_BINDING, /**< value of ThisBinding */ - VM_REG_SPECIAL_LAST = VM_REG_SPECIAL_FOR_IN_PROPERTY_NAME, /**< last special register */ + VM_REG_SPECIAL_LAST = VM_REG_SPECIAL_THIS_BINDING, /**< last special register */ VM_REG_GENERAL_FIRST, /** first non-special register */ VM_REG_GENERAL_LAST = VM_IDX_REG_LAST /** last non-special register */ @@ -205,7 +206,6 @@ typedef struct { const bytecode_data_header_t *bytecode_header_p; /**< currently executed byte-code data */ vm_instr_counter_t pos; /**< current position instruction to execute */ - ecma_value_t this_binding; /**< this binding for current context */ ecma_object_t *lex_env_p; /**< current lexical environment */ bool is_strict; /**< is current code execution mode strict? */ bool is_eval_code; /**< is current code executed with eval */ diff --git a/jerry-core/vm/pretty-printer.cpp b/jerry-core/vm/pretty-printer.cpp index f0330acf4..254f3620e 100644 --- a/jerry-core/vm/pretty-printer.cpp +++ b/jerry-core/vm/pretty-printer.cpp @@ -227,7 +227,6 @@ pp_op_meta (const bytecode_data_header_t *bytecode_data_p, PP_OP (VM_OP_RET, "ret;"); PP_OP (VM_OP_PROP_GETTER, "%s = %s[%s];"); PP_OP (VM_OP_PROP_SETTER, "%s[%s] = %s;"); - PP_OP (VM_OP_THIS_BINDING, "%s = this;"); PP_OP (VM_OP_DELETE_VAR, "%s = delete %s;"); PP_OP (VM_OP_DELETE_PROP, "%s = delete %s.%s;"); PP_OP (VM_OP_TYPEOF, "%s = typeof %s;"); diff --git a/jerry-core/vm/vm-opcodes.inc.h b/jerry-core/vm/vm-opcodes.inc.h index a2ba40a41..611d2bf17 100644 --- a/jerry-core/vm/vm-opcodes.inc.h +++ b/jerry-core/vm/vm-opcodes.inc.h @@ -78,9 +78,6 @@ VM_OP_3 (prop_setter, PROP_SETTER, prop, VM_OP_ARG_TYPE_VARIABLE, rhs, VM_OP_ARG_TYPE_VARIABLE) -VM_OP_1 (this_binding, THIS_BINDING, - lhs, VM_OP_ARG_TYPE_VARIABLE) - VM_OP_2 (delete_var, DELETE_VAR, lhs, VM_OP_ARG_TYPE_VARIABLE, name, VM_OP_ARG_TYPE_VARIABLE) diff --git a/jerry-core/vm/vm.cpp b/jerry-core/vm/vm.cpp index 9a10706fe..bda12838a 100644 --- a/jerry-core/vm/vm.cpp +++ b/jerry-core/vm/vm.cpp @@ -615,7 +615,6 @@ vm_run_from_pos (const bytecode_data_header_t *header_p, /**< byte-code data hea vm_frame_ctx_t frame_ctx; frame_ctx.bytecode_header_p = header_p; frame_ctx.pos = (vm_instr_counter_t) (start_pos + 1); - frame_ctx.this_binding = this_binding_value; frame_ctx.lex_env_p = lex_env_p; frame_ctx.is_strict = is_strict; frame_ctx.is_eval_code = is_eval_code; @@ -623,6 +622,9 @@ vm_run_from_pos (const bytecode_data_header_t *header_p, /**< byte-code data hea frame_ctx.tmp_num_p = ecma_alloc_number (); vm_stack_add_frame (&frame_ctx.stack_frame, regs, regs_num, local_var_regs_num); + vm_stack_frame_set_reg_value (&frame_ctx.stack_frame, + VM_REG_SPECIAL_THIS_BINDING, + ecma_copy_value (this_binding_value, false)); vm_frame_ctx_t *prev_context_p = vm_top_context_p; vm_top_context_p = &frame_ctx; @@ -729,7 +731,9 @@ vm_get_this_binding (void) { JERRY_ASSERT (vm_top_context_p != NULL); - return ecma_copy_value (vm_top_context_p->this_binding, true); + return ecma_copy_value (vm_stack_frame_get_reg_value (&vm_top_context_p->stack_frame, + VM_REG_SPECIAL_THIS_BINDING), + true); } /* vm_get_this_binding */ /**