Replacing 'varg' opcode with 'meta' opcode with corresponding type.
This commit is contained in:
@@ -68,7 +68,7 @@ run_int (void)
|
|||||||
switch ((ecma_completion_type_t) completion.type)
|
switch ((ecma_completion_type_t) completion.type)
|
||||||
{
|
{
|
||||||
case ECMA_COMPLETION_TYPE_NORMAL:
|
case ECMA_COMPLETION_TYPE_NORMAL:
|
||||||
case ECMA_COMPLETION_TYPE_VARG:
|
case ECMA_COMPLETION_TYPE_META:
|
||||||
{
|
{
|
||||||
JERRY_UNREACHABLE ();
|
JERRY_UNREACHABLE ();
|
||||||
}
|
}
|
||||||
@@ -170,8 +170,6 @@ run_int_from_pos (opcode_counter_t start_pos,
|
|||||||
|
|
||||||
completion = run_int_loop (&int_data);
|
completion = run_int_loop (&int_data);
|
||||||
|
|
||||||
JERRY_ASSERT (completion.type != ECMA_COMPLETION_TYPE_VARG);
|
|
||||||
|
|
||||||
for (uint32_t reg_index = 0;
|
for (uint32_t reg_index = 0;
|
||||||
reg_index < regs_num;
|
reg_index < regs_num;
|
||||||
reg_index++)
|
reg_index++)
|
||||||
|
|||||||
@@ -37,4 +37,7 @@ ecma_completion_value_t fill_varg_list (int_data_t *int_data,
|
|||||||
ecma_length_t args_number,
|
ecma_length_t args_number,
|
||||||
ecma_value_t args_values[],
|
ecma_value_t args_values[],
|
||||||
ecma_length_t *out_arg_number_p);
|
ecma_length_t *out_arg_number_p);
|
||||||
|
void fill_params_list (int_data_t *int_data,
|
||||||
|
ecma_length_t params_number,
|
||||||
|
ecma_string_t* params_names[]);
|
||||||
#endif /* OPCODES_ECMA_SUPPORT_H */
|
#endif /* OPCODES_ECMA_SUPPORT_H */
|
||||||
|
|||||||
@@ -33,39 +33,42 @@ fill_varg_list (int_data_t *int_data, /**< interpreter context */
|
|||||||
ecma_length_t *out_arg_number_p) /**< out: number of arguments
|
ecma_length_t *out_arg_number_p) /**< out: number of arguments
|
||||||
successfully read */
|
successfully read */
|
||||||
{
|
{
|
||||||
ecma_completion_value_t get_arg_completion = ecma_make_empty_completion_value ();
|
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
|
||||||
|
|
||||||
ecma_length_t arg_index;
|
ecma_length_t arg_index;
|
||||||
for (arg_index = 0;
|
for (arg_index = 0;
|
||||||
arg_index < args_number;
|
arg_index < args_number;
|
||||||
arg_index++)
|
arg_index++)
|
||||||
{
|
{
|
||||||
opcode_t next_opcode = read_opcode (int_data->pos);
|
ecma_completion_value_t evaluate_arg_completion = run_int_loop (int_data);
|
||||||
if (next_opcode.op_idx == __op__idx_varg)
|
|
||||||
|
if (evaluate_arg_completion.type == ECMA_COMPLETION_TYPE_META)
|
||||||
{
|
{
|
||||||
get_arg_completion = get_variable_value (int_data, next_opcode.data.varg.arg_lit_idx, false);
|
opcode_t next_opcode = read_opcode (int_data->pos);
|
||||||
if (unlikely (ecma_is_completion_value_throw (get_arg_completion)))
|
JERRY_ASSERT (next_opcode.op_idx == __op__idx_meta);
|
||||||
|
JERRY_ASSERT (next_opcode.data.meta.type == OPCODE_META_TYPE_VARG);
|
||||||
|
|
||||||
|
const idx_t varg_var_idx = next_opcode.data.meta.data_1;
|
||||||
|
|
||||||
|
ecma_completion_value_t get_arg_completion = get_variable_value (int_data, varg_var_idx, false);
|
||||||
|
|
||||||
|
if (ecma_is_completion_value_normal (get_arg_completion))
|
||||||
{
|
{
|
||||||
break;
|
arg_values[arg_index] = get_arg_completion.value;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
JERRY_ASSERT (ecma_is_completion_value_normal (get_arg_completion));
|
ret_value = get_arg_completion;
|
||||||
arg_values[arg_index] = get_arg_completion.value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
get_arg_completion = run_int_loop (int_data);
|
ret_value = evaluate_arg_completion;
|
||||||
|
}
|
||||||
|
|
||||||
if (get_arg_completion.type == ECMA_COMPLETION_TYPE_VARG)
|
if (!ecma_is_empty_completion_value (ret_value))
|
||||||
{
|
{
|
||||||
arg_values[arg_index] = get_arg_completion.value;
|
break;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int_data->pos++;
|
int_data->pos++;
|
||||||
@@ -73,38 +76,32 @@ fill_varg_list (int_data_t *int_data, /**< interpreter context */
|
|||||||
|
|
||||||
*out_arg_number_p = arg_index;
|
*out_arg_number_p = arg_index;
|
||||||
|
|
||||||
if (get_arg_completion.type == ECMA_COMPLETION_TYPE_NORMAL
|
return ret_value;
|
||||||
|| get_arg_completion.type == ECMA_COMPLETION_TYPE_VARG)
|
|
||||||
{
|
|
||||||
/* values are copied to arg_values */
|
|
||||||
return ecma_make_empty_completion_value ();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return get_arg_completion;
|
|
||||||
}
|
|
||||||
} /* fill_varg_list */
|
} /* fill_varg_list */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 'varg' opcode handler
|
* Fill parameters' list
|
||||||
*
|
|
||||||
* @return completion value
|
|
||||||
* Returned value must be freed with ecma_free_completion_value.
|
|
||||||
*/
|
*/
|
||||||
ecma_completion_value_t
|
void
|
||||||
opfunc_varg (opcode_t opdata, /**< operation data */
|
fill_params_list (int_data_t *int_data, /**< interpreter context */
|
||||||
int_data_t *int_data) /**< interpreter context */
|
ecma_length_t params_number, /**< number of parameters */
|
||||||
|
ecma_string_t* params_names[]) /**< out: parameters' names */
|
||||||
{
|
{
|
||||||
const idx_t arg_lit_idx = opdata.data.varg.arg_lit_idx;
|
uint32_t param_index;
|
||||||
|
for (param_index = 0;
|
||||||
ecma_completion_value_t completion = get_variable_value (int_data,
|
param_index < params_number;
|
||||||
arg_lit_idx,
|
param_index++)
|
||||||
false);
|
|
||||||
|
|
||||||
if (ecma_is_completion_value_normal (completion))
|
|
||||||
{
|
{
|
||||||
completion.type = ECMA_COMPLETION_TYPE_VARG;
|
opcode_t next_opcode = read_opcode (int_data->pos);
|
||||||
|
JERRY_ASSERT (next_opcode.op_idx == __op__idx_meta);
|
||||||
|
JERRY_ASSERT (next_opcode.data.meta.type == OPCODE_META_TYPE_VARG);
|
||||||
|
|
||||||
|
const idx_t param_name_lit_idx = next_opcode.data.meta.data_1;
|
||||||
|
|
||||||
|
params_names [param_index] = ecma_new_ecma_string_from_lit_index (param_name_lit_idx);
|
||||||
|
|
||||||
|
int_data->pos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return completion;
|
JERRY_ASSERT (param_index == params_number);
|
||||||
} /* opfunc_varg */
|
} /* fill_params_list */
|
||||||
|
|||||||
+36
-45
@@ -578,34 +578,21 @@ opfunc_func_decl_n (opcode_t opdata, /**< operation data */
|
|||||||
int_data->pos++;
|
int_data->pos++;
|
||||||
|
|
||||||
const idx_t function_name_idx = opdata.data.func_decl_n.name_lit_idx;
|
const idx_t function_name_idx = opdata.data.func_decl_n.name_lit_idx;
|
||||||
const ecma_length_t args_number = opdata.data.func_decl_n.arg_list;
|
const ecma_length_t params_number = opdata.data.func_decl_n.arg_list;
|
||||||
|
|
||||||
ecma_string_t *args_names[args_number + 1 /* length of array should not be zero */];
|
ecma_string_t *params_names[params_number + 1 /* length of array should not be zero */];
|
||||||
|
fill_params_list (int_data, params_number, params_names);
|
||||||
ecma_length_t arg_index = 0;
|
|
||||||
opcode_t next_opcode = read_opcode (int_data->pos);
|
|
||||||
while (next_opcode.op_idx == __op__idx_varg)
|
|
||||||
{
|
|
||||||
const idx_t arg_lit_idx = next_opcode.data.varg.arg_lit_idx;
|
|
||||||
args_names[arg_index++] = ecma_new_ecma_string_from_lit_index (arg_lit_idx);
|
|
||||||
|
|
||||||
JERRY_ASSERT (arg_index <= args_number);
|
|
||||||
|
|
||||||
int_data->pos++;
|
|
||||||
next_opcode = read_opcode (int_data->pos);
|
|
||||||
}
|
|
||||||
JERRY_ASSERT (arg_index == args_number);
|
|
||||||
|
|
||||||
ecma_completion_value_t ret_value = function_declaration (int_data,
|
ecma_completion_value_t ret_value = function_declaration (int_data,
|
||||||
function_name_idx,
|
function_name_idx,
|
||||||
args_names,
|
params_names,
|
||||||
args_number);
|
params_number);
|
||||||
|
|
||||||
for (arg_index = 0;
|
for (uint32_t param_index = 0;
|
||||||
arg_index < args_number;
|
param_index < params_number;
|
||||||
arg_index++)
|
param_index++)
|
||||||
{
|
{
|
||||||
ecma_deref_ecma_string (args_names[arg_index]);
|
ecma_deref_ecma_string (params_names[param_index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret_value;
|
return ret_value;
|
||||||
@@ -625,7 +612,7 @@ opfunc_func_expr_n (opcode_t opdata, /**< operation data */
|
|||||||
|
|
||||||
const idx_t dst_var_idx = opdata.data.func_expr_n.lhs;
|
const idx_t dst_var_idx = opdata.data.func_expr_n.lhs;
|
||||||
const idx_t function_name_lit_idx = opdata.data.func_expr_n.name_lit_idx;
|
const idx_t function_name_lit_idx = opdata.data.func_expr_n.name_lit_idx;
|
||||||
const ecma_length_t args_number = opdata.data.func_expr_n.arg_list;
|
const ecma_length_t params_number = opdata.data.func_expr_n.arg_list;
|
||||||
|
|
||||||
const bool is_named_func_expr = (!is_reg_variable (int_data, function_name_lit_idx));
|
const bool is_named_func_expr = (!is_reg_variable (int_data, function_name_lit_idx));
|
||||||
|
|
||||||
@@ -633,21 +620,9 @@ opfunc_func_expr_n (opcode_t opdata, /**< operation data */
|
|||||||
|
|
||||||
const bool is_strict = int_data->is_strict;
|
const bool is_strict = int_data->is_strict;
|
||||||
|
|
||||||
ecma_string_t *args_names[args_number + 1 /* length of array should not be zero */];
|
ecma_string_t *params_names[params_number + 1 /* length of array should not be zero */];
|
||||||
|
|
||||||
ecma_length_t arg_index = 0;
|
fill_params_list (int_data, params_number, params_names);
|
||||||
opcode_t next_opcode = read_opcode (int_data->pos);
|
|
||||||
while (next_opcode.op_idx == __op__idx_varg)
|
|
||||||
{
|
|
||||||
const idx_t arg_lit_idx = next_opcode.data.varg.arg_lit_idx;
|
|
||||||
args_names[arg_index++] = ecma_new_ecma_string_from_lit_index (arg_lit_idx);
|
|
||||||
|
|
||||||
JERRY_ASSERT (arg_index <= args_number);
|
|
||||||
|
|
||||||
int_data->pos++;
|
|
||||||
next_opcode = read_opcode (int_data->pos);
|
|
||||||
}
|
|
||||||
JERRY_ASSERT (arg_index == args_number);
|
|
||||||
|
|
||||||
const opcode_counter_t jmp_down_opcode_idx = (opcode_counter_t) (int_data->pos);
|
const opcode_counter_t jmp_down_opcode_idx = (opcode_counter_t) (int_data->pos);
|
||||||
opcode_t jmp_down_opcode = read_opcode (jmp_down_opcode_idx);
|
opcode_t jmp_down_opcode = read_opcode (jmp_down_opcode_idx);
|
||||||
@@ -671,8 +646,8 @@ opfunc_func_expr_n (opcode_t opdata, /**< operation data */
|
|||||||
ecma_ref_object (scope_p);
|
ecma_ref_object (scope_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
ecma_object_t *func_obj_p = ecma_op_create_function_object (args_names,
|
ecma_object_t *func_obj_p = ecma_op_create_function_object (params_names,
|
||||||
args_number,
|
params_number,
|
||||||
scope_p,
|
scope_p,
|
||||||
is_strict,
|
is_strict,
|
||||||
function_code_opcode_idx);
|
function_code_opcode_idx);
|
||||||
@@ -692,11 +667,11 @@ opfunc_func_expr_n (opcode_t opdata, /**< operation data */
|
|||||||
ecma_deref_object (func_obj_p);
|
ecma_deref_object (func_obj_p);
|
||||||
ecma_deref_object (scope_p);
|
ecma_deref_object (scope_p);
|
||||||
|
|
||||||
for (arg_index = 0;
|
for (uint32_t param_index = 0;
|
||||||
arg_index < args_number;
|
param_index < params_number;
|
||||||
arg_index++)
|
param_index++)
|
||||||
{
|
{
|
||||||
ecma_deref_ecma_string (args_names[arg_index]);
|
ecma_deref_ecma_string (params_names[param_index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret_value;
|
return ret_value;
|
||||||
@@ -1549,12 +1524,28 @@ opfunc_delete_prop (opcode_t opdata, /**< operation data */
|
|||||||
/**
|
/**
|
||||||
* 'meta' opcode handler.
|
* 'meta' opcode handler.
|
||||||
*
|
*
|
||||||
* The opcode is meta-opcode that is not supposed to be executed.
|
* @return implementation-defined meta completion value
|
||||||
*/
|
*/
|
||||||
ecma_completion_value_t
|
ecma_completion_value_t
|
||||||
opfunc_meta (opcode_t opdata __unused, /**< operation data */
|
opfunc_meta (opcode_t opdata, /**< operation data */
|
||||||
int_data_t *int_data __unused) /**< interpreter context */
|
int_data_t *int_data __unused) /**< interpreter context */
|
||||||
{
|
{
|
||||||
|
const opcode_meta_type type = opdata.data.meta.type;
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case OPCODE_META_TYPE_VARG:
|
||||||
|
{
|
||||||
|
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_META,
|
||||||
|
ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY),
|
||||||
|
ECMA_TARGET_ID_RESERVED);
|
||||||
|
}
|
||||||
|
case OPCODE_META_TYPE_THIS_ARG:
|
||||||
|
{
|
||||||
|
JERRY_UNREACHABLE ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
JERRY_UNREACHABLE ();
|
JERRY_UNREACHABLE ();
|
||||||
} /* opfunc_meta */
|
} /* opfunc_meta */
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,8 @@ typedef enum
|
|||||||
*/
|
*/
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
OPCODE_META_TYPE_THIS_ARG /**< value of this used during call */
|
OPCODE_META_TYPE_THIS_ARG, /**< value of this used during call */
|
||||||
|
OPCODE_META_TYPE_VARG /**< element of arguments' list */
|
||||||
} opcode_meta_type;
|
} opcode_meta_type;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@@ -78,7 +79,6 @@ typedef struct
|
|||||||
p##_3 (a, func_decl_2, name_lit_idx, arg1_lit_idx, arg2_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##_2 (a, func_decl_n, name_lit_idx, arg_list) \
|
||||||
p##_3 (a, func_expr_n, lhs, name_lit_idx, arg_list) \
|
p##_3 (a, func_expr_n, lhs, name_lit_idx, arg_list) \
|
||||||
p##_1 (a, varg, arg_lit_idx) \
|
|
||||||
p##_1 (a, exitval, status_code) \
|
p##_1 (a, exitval, status_code) \
|
||||||
p##_1 (a, retval, ret_value) \
|
p##_1 (a, retval, ret_value) \
|
||||||
p##_0 (a, ret)
|
p##_0 (a, ret)
|
||||||
|
|||||||
@@ -106,8 +106,8 @@ typedef enum
|
|||||||
ECMA_COMPLETION_TYPE_THROW, /**< block completed with throw */
|
ECMA_COMPLETION_TYPE_THROW, /**< block completed with throw */
|
||||||
ECMA_COMPLETION_TYPE_EXIT, /**< implementation-defined completion type
|
ECMA_COMPLETION_TYPE_EXIT, /**< implementation-defined completion type
|
||||||
for finishing script execution */
|
for finishing script execution */
|
||||||
ECMA_COMPLETION_TYPE_VARG /**< implementation-defined completion type
|
ECMA_COMPLETION_TYPE_META /**< implementation-defined completion type
|
||||||
for varg (argument value specifier opcode) */
|
for meta opcode */
|
||||||
} ecma_completion_type_t;
|
} ecma_completion_type_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -365,12 +365,11 @@ ecma_copy_completion_value (ecma_completion_value_t value) /**< completion value
|
|||||||
void
|
void
|
||||||
ecma_free_completion_value (ecma_completion_value_t completion_value) /**< completion value */
|
ecma_free_completion_value (ecma_completion_value_t completion_value) /**< completion value */
|
||||||
{
|
{
|
||||||
switch (completion_value.type)
|
switch ((ecma_completion_type_t)completion_value.type)
|
||||||
{
|
{
|
||||||
case ECMA_COMPLETION_TYPE_NORMAL:
|
case ECMA_COMPLETION_TYPE_NORMAL:
|
||||||
case ECMA_COMPLETION_TYPE_THROW:
|
case ECMA_COMPLETION_TYPE_THROW:
|
||||||
case ECMA_COMPLETION_TYPE_RETURN:
|
case ECMA_COMPLETION_TYPE_RETURN:
|
||||||
case ECMA_COMPLETION_TYPE_VARG:
|
|
||||||
{
|
{
|
||||||
ecma_free_value (completion_value.value, true);
|
ecma_free_value (completion_value.value, true);
|
||||||
break;
|
break;
|
||||||
@@ -382,6 +381,10 @@ ecma_free_completion_value (ecma_completion_value_t completion_value) /**< compl
|
|||||||
JERRY_ASSERT(completion_value.value.value_type == ECMA_TYPE_SIMPLE);
|
JERRY_ASSERT(completion_value.value.value_type == ECMA_TYPE_SIMPLE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case ECMA_COMPLETION_TYPE_META:
|
||||||
|
{
|
||||||
|
JERRY_UNREACHABLE ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} /* ecma_free_completion_value */
|
} /* ecma_free_completion_value */
|
||||||
|
|
||||||
|
|||||||
@@ -412,7 +412,6 @@ pp_opcode (opcode_counter_t oc, opcode_t opcode, bool is_rewrite)
|
|||||||
CASE_VARG_1_NAME (func_decl_1, "function", name_lit_idx, "(", arg1_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_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_VARG_N_NAME (func_decl_n, "function", name_lit_idx, arg_list)
|
||||||
CASE_VARG_1 (varg, arg_lit_idx);
|
|
||||||
CASE_EXIT (exitval, "exit", status_code)
|
CASE_EXIT (exitval, "exit", status_code)
|
||||||
CASE_SINGLE_ADDRESS (retval, "return", ret_value)
|
CASE_SINGLE_ADDRESS (retval, "return", ret_value)
|
||||||
CASE_ZERO_ADDRESS (ret, "return")
|
CASE_ZERO_ADDRESS (ret, "return")
|
||||||
|
|||||||
Reference in New Issue
Block a user