Read function's scope flags only in ecma_op_create_function_object instead of call sites of the routine.
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
@@ -487,30 +487,12 @@ function_declaration (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */
|
||||
lit_cpointer_t function_name_lit_cp, /**< compressed pointer to literal with function name */
|
||||
ecma_collection_header_t *formal_params_collection_p) /** formal parameters collection */
|
||||
{
|
||||
bool is_strict = frame_ctx_p->is_strict;
|
||||
bool do_instantiate_arguments_object = true;
|
||||
const bool is_configurable_bindings = frame_ctx_p->is_eval_code;
|
||||
|
||||
const vm_instr_counter_t function_code_end_oc = (vm_instr_counter_t) (
|
||||
vm_read_instr_counter_from_meta (OPCODE_META_TYPE_FUNCTION_END, frame_ctx_p) + frame_ctx_p->pos);
|
||||
frame_ctx_p->pos++;
|
||||
|
||||
opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (frame_ctx_p->bytecode_header_p->instrs_p,
|
||||
frame_ctx_p->pos++);
|
||||
|
||||
if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_STRICT)
|
||||
{
|
||||
is_strict = true;
|
||||
}
|
||||
if ((scope_flags & OPCODE_SCOPE_CODE_FLAGS_NOT_REF_ARGUMENTS_IDENTIFIER)
|
||||
&& (scope_flags & OPCODE_SCOPE_CODE_FLAGS_NOT_REF_EVAL_IDENTIFIER))
|
||||
{
|
||||
/* the code doesn't use 'arguments' identifier
|
||||
* and doesn't perform direct call to eval,
|
||||
* so Arguments object can't be referenced */
|
||||
do_instantiate_arguments_object = false;
|
||||
}
|
||||
|
||||
ecma_string_t *function_name_string_p = ecma_new_ecma_string_from_lit_cp (function_name_lit_cp);
|
||||
|
||||
ecma_completion_value_t ret_value = ecma_op_function_declaration (frame_ctx_p->lex_env_p,
|
||||
@@ -518,8 +500,7 @@ function_declaration (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */
|
||||
frame_ctx_p->bytecode_header_p,
|
||||
frame_ctx_p->pos,
|
||||
formal_params_collection_p,
|
||||
is_strict,
|
||||
do_instantiate_arguments_object,
|
||||
frame_ctx_p->is_strict,
|
||||
is_configurable_bindings);
|
||||
ecma_deref_ecma_string (function_name_string_p);
|
||||
|
||||
@@ -587,29 +568,10 @@ opfunc_func_expr_n (vm_instr_t instr, /**< instruction */
|
||||
|
||||
vm_fill_params_list (frame_ctx_p, params_number, formal_params_collection_p);
|
||||
|
||||
bool is_strict = frame_ctx_p->is_strict;
|
||||
bool do_instantiate_arguments_object = true;
|
||||
|
||||
function_code_end_oc = (vm_instr_counter_t) (vm_read_instr_counter_from_meta (OPCODE_META_TYPE_FUNCTION_END,
|
||||
frame_ctx_p) + frame_ctx_p->pos);
|
||||
frame_ctx_p->pos++;
|
||||
|
||||
opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (frame_ctx_p->bytecode_header_p->instrs_p,
|
||||
frame_ctx_p->pos++);
|
||||
|
||||
if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_STRICT)
|
||||
{
|
||||
is_strict = true;
|
||||
}
|
||||
if ((scope_flags & OPCODE_SCOPE_CODE_FLAGS_NOT_REF_ARGUMENTS_IDENTIFIER)
|
||||
&& (scope_flags & OPCODE_SCOPE_CODE_FLAGS_NOT_REF_EVAL_IDENTIFIER))
|
||||
{
|
||||
/* the code doesn't use 'arguments' identifier
|
||||
* and doesn't perform direct call to eval,
|
||||
* so Arguments object can't be referenced */
|
||||
do_instantiate_arguments_object = false;
|
||||
}
|
||||
|
||||
ecma_object_t *scope_p;
|
||||
ecma_string_t *function_name_string_p = NULL;
|
||||
if (is_named_func_expr)
|
||||
@@ -632,8 +594,7 @@ opfunc_func_expr_n (vm_instr_t instr, /**< instruction */
|
||||
|
||||
ecma_object_t *func_obj_p = ecma_op_create_function_object (formal_params_collection_p,
|
||||
scope_p,
|
||||
is_strict,
|
||||
do_instantiate_arguments_object,
|
||||
frame_ctx_p->is_strict,
|
||||
frame_ctx_p->bytecode_header_p,
|
||||
frame_ctx_p->pos);
|
||||
|
||||
|
||||
@@ -396,8 +396,7 @@ vm_run_global (void)
|
||||
bool is_strict = false;
|
||||
vm_instr_counter_t start_pos = 0;
|
||||
|
||||
opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (__program->instrs_p,
|
||||
start_pos++);
|
||||
opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (__program, start_pos++);
|
||||
|
||||
if (scope_flags & OPCODE_SCOPE_CODE_FLAGS_STRICT)
|
||||
{
|
||||
@@ -449,8 +448,7 @@ vm_run_eval (const bytecode_data_header_t *bytecode_data_p, /**< byte-code data
|
||||
bool is_direct) /**< is eval called in direct mode? */
|
||||
{
|
||||
vm_instr_counter_t first_instr_index = 0u;
|
||||
opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (bytecode_data_p->instrs_p,
|
||||
first_instr_index++);
|
||||
opcode_scope_code_flags_t scope_flags = vm_get_scope_flags (bytecode_data_p, first_instr_index++);
|
||||
bool is_strict = ((scope_flags & OPCODE_SCOPE_CODE_FLAGS_STRICT) != 0);
|
||||
|
||||
ecma_value_t this_binding;
|
||||
@@ -669,10 +667,10 @@ vm_get_instr (const vm_instr_t *instrs_p, /**< byte-code array */
|
||||
* @return mask of scope code flags
|
||||
*/
|
||||
opcode_scope_code_flags_t
|
||||
vm_get_scope_flags (const vm_instr_t *instrs_p, /**< byte-code array */
|
||||
vm_get_scope_flags (const bytecode_data_header_t *bytecode_header_p, /**< byte-code data */
|
||||
vm_instr_counter_t counter) /**< instruction counter */
|
||||
{
|
||||
vm_instr_t flags_instr = vm_get_instr (instrs_p, counter);
|
||||
vm_instr_t flags_instr = vm_get_instr (bytecode_header_p->instrs_p, counter);
|
||||
JERRY_ASSERT (flags_instr.op_idx == VM_OP_META
|
||||
&& flags_instr.data.meta.type == OPCODE_META_TYPE_SCOPE_CODE_FLAGS);
|
||||
return (opcode_scope_code_flags_t) flags_instr.data.meta.data_1;
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ extern ecma_completion_value_t vm_run_from_pos (const bytecode_data_header_t *,
|
||||
ecma_value_t, ecma_object_t *, bool, bool);
|
||||
|
||||
extern vm_instr_t vm_get_instr (const vm_instr_t *, vm_instr_counter_t);
|
||||
extern opcode_scope_code_flags_t vm_get_scope_flags (const vm_instr_t *, vm_instr_counter_t);
|
||||
extern opcode_scope_code_flags_t vm_get_scope_flags (const bytecode_data_header_t *, vm_instr_counter_t);
|
||||
|
||||
extern bool vm_is_strict_mode (void);
|
||||
extern bool vm_is_direct_eval_form_call (void);
|
||||
|
||||
Reference in New Issue
Block a user