Change fill_varg_list to append arguments values to ecma-values collection, instead of array; rename it to vm_fill_varg_list.
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
@@ -37,10 +37,9 @@
|
|||||||
bool is_reg_variable (vm_frame_ctx_t *frame_ctx_p, idx_t var_idx);
|
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 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);
|
ecma_completion_value_t set_variable_value (vm_frame_ctx_t *, vm_instr_counter_t, idx_t, ecma_value_t);
|
||||||
ecma_completion_value_t fill_varg_list (vm_frame_ctx_t *frame_ctx_p,
|
ecma_completion_value_t vm_fill_varg_list (vm_frame_ctx_t *frame_ctx_p,
|
||||||
ecma_length_t args_number,
|
ecma_length_t args_number,
|
||||||
ecma_value_t args_values[],
|
ecma_collection_header_t *args_values_p);
|
||||||
ecma_length_t *out_arg_number_p);
|
|
||||||
void fill_params_list (vm_frame_ctx_t *frame_ctx_p,
|
void fill_params_list (vm_frame_ctx_t *frame_ctx_p,
|
||||||
ecma_length_t params_number,
|
ecma_length_t params_number,
|
||||||
ecma_string_t* params_names[]);
|
ecma_string_t* params_names[]);
|
||||||
|
|||||||
@@ -27,56 +27,44 @@
|
|||||||
* of last expression evaluated
|
* of last expression evaluated
|
||||||
*/
|
*/
|
||||||
ecma_completion_value_t
|
ecma_completion_value_t
|
||||||
fill_varg_list (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */
|
vm_fill_varg_list (vm_frame_ctx_t *frame_ctx_p, /**< interpreter context */
|
||||||
ecma_length_t args_number, /**< number of arguments */
|
ecma_length_t args_number, /**< number of arguments */
|
||||||
ecma_value_t arg_values[], /**< out: arguments' values */
|
ecma_collection_header_t *arg_collection_p) /** collection to fill with argument values */
|
||||||
ecma_length_t *out_arg_number_p) /**< out: number of arguments
|
|
||||||
successfully read */
|
|
||||||
{
|
{
|
||||||
ecma_completion_value_t ret_value = 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 && ecma_is_completion_value_empty (ret_value);
|
arg_index < args_number && ecma_is_completion_value_empty (ret_value);
|
||||||
)
|
arg_index++)
|
||||||
{
|
{
|
||||||
ecma_completion_value_t evaluate_arg_completion = vm_loop (frame_ctx_p, NULL);
|
ECMA_TRY_CATCH (evaluate_arg,
|
||||||
|
vm_loop (frame_ctx_p, NULL),
|
||||||
|
ret_value);
|
||||||
|
|
||||||
if (ecma_is_completion_value_empty (evaluate_arg_completion))
|
vm_instr_t next_instr = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos);
|
||||||
{
|
JERRY_ASSERT (next_instr.op_idx == VM_OP_META);
|
||||||
vm_instr_t next_instr = vm_get_instr (frame_ctx_p->instrs_p, frame_ctx_p->pos);
|
JERRY_ASSERT (next_instr.data.meta.type == OPCODE_META_TYPE_VARG);
|
||||||
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 idx_t varg_var_idx = next_instr.data.meta.data_1;
|
||||||
|
|
||||||
ecma_completion_value_t get_arg_completion = get_variable_value (frame_ctx_p, varg_var_idx, false);
|
ECMA_TRY_CATCH (get_arg,
|
||||||
|
get_variable_value (frame_ctx_p, varg_var_idx, false),
|
||||||
|
ret_value);
|
||||||
|
|
||||||
if (ecma_is_completion_value_normal (get_arg_completion))
|
ecma_append_to_values_collection (arg_collection_p,
|
||||||
{
|
ecma_get_completion_value_value (get_arg_completion),
|
||||||
arg_values[arg_index++] = ecma_get_completion_value_value (get_arg_completion);
|
true);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
JERRY_ASSERT (ecma_is_completion_value_throw (get_arg_completion));
|
|
||||||
|
|
||||||
ret_value = get_arg_completion;
|
ECMA_FINALIZE (get_arg);
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
JERRY_ASSERT (ecma_is_completion_value_throw (evaluate_arg_completion));
|
|
||||||
|
|
||||||
ret_value = evaluate_arg_completion;
|
|
||||||
}
|
|
||||||
|
|
||||||
frame_ctx_p->pos++;
|
frame_ctx_p->pos++;
|
||||||
|
|
||||||
|
ECMA_FINALIZE (evaluate_arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
*out_arg_number_p = arg_index;
|
|
||||||
|
|
||||||
return ret_value;
|
return ret_value;
|
||||||
} /* fill_varg_list */
|
} /* vm_fill_varg_list */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fill parameters' list
|
* Fill parameters' list
|
||||||
|
|||||||
+65
-45
@@ -814,13 +814,12 @@ opfunc_call_n (vm_instr_t instr, /**< instruction */
|
|||||||
function_var_idx,
|
function_var_idx,
|
||||||
&call_flags);
|
&call_flags);
|
||||||
|
|
||||||
MEM_DEFINE_LOCAL_ARRAY (arg_values, args_number_idx, ecma_value_t);
|
ecma_collection_header_t *arg_collection_p = ecma_new_values_collection (NULL, 0, true);
|
||||||
|
|
||||||
ecma_length_t args_read;
|
ecma_completion_value_t get_arg_completion = vm_fill_varg_list (frame_ctx_p,
|
||||||
ecma_completion_value_t get_arg_completion = fill_varg_list (frame_ctx_p,
|
args_number_idx,
|
||||||
args_number_idx,
|
arg_collection_p);
|
||||||
arg_values,
|
ecma_length_t args_read = arg_collection_p->unit_number;
|
||||||
&args_read);
|
|
||||||
|
|
||||||
if (ecma_is_completion_value_empty (get_arg_completion))
|
if (ecma_is_completion_value_empty (get_arg_completion))
|
||||||
{
|
{
|
||||||
@@ -839,11 +838,24 @@ opfunc_call_n (vm_instr_t instr, /**< instruction */
|
|||||||
|
|
||||||
ecma_object_t *func_obj_p = ecma_get_object_from_value (func_value);
|
ecma_object_t *func_obj_p = ecma_get_object_from_value (func_value);
|
||||||
|
|
||||||
|
MEM_DEFINE_LOCAL_ARRAY (arg_values, args_read, ecma_value_t);
|
||||||
|
|
||||||
|
ecma_collection_iterator_t arg_collection_iter;
|
||||||
|
ecma_collection_iterator_init (&arg_collection_iter,
|
||||||
|
arg_collection_p);
|
||||||
|
|
||||||
|
for (ecma_length_t arg_index = 0;
|
||||||
|
ecma_collection_iterator_next (&arg_collection_iter);
|
||||||
|
arg_index++)
|
||||||
|
{
|
||||||
|
arg_values[arg_index] = *arg_collection_iter.current_value_p;
|
||||||
|
}
|
||||||
|
|
||||||
ECMA_TRY_CATCH (call_ret_value,
|
ECMA_TRY_CATCH (call_ret_value,
|
||||||
ecma_op_function_call (func_obj_p,
|
ecma_op_function_call (func_obj_p,
|
||||||
this_value,
|
this_value,
|
||||||
arg_values,
|
arg_values,
|
||||||
args_number_idx),
|
args_read),
|
||||||
ret_value);
|
ret_value);
|
||||||
|
|
||||||
ret_value = set_variable_value (frame_ctx_p, lit_oc,
|
ret_value = set_variable_value (frame_ctx_p, lit_oc,
|
||||||
@@ -852,6 +864,8 @@ opfunc_call_n (vm_instr_t instr, /**< instruction */
|
|||||||
|
|
||||||
ECMA_FINALIZE (call_ret_value);
|
ECMA_FINALIZE (call_ret_value);
|
||||||
|
|
||||||
|
MEM_FINALIZE_LOCAL_ARRAY (arg_values);
|
||||||
|
|
||||||
if (call_flags & OPCODE_CALL_FLAGS_DIRECT_CALL_TO_EVAL_FORM)
|
if (call_flags & OPCODE_CALL_FLAGS_DIRECT_CALL_TO_EVAL_FORM)
|
||||||
{
|
{
|
||||||
JERRY_ASSERT (frame_ctx_p->is_call_in_direct_eval_form);
|
JERRY_ASSERT (frame_ctx_p->is_call_in_direct_eval_form);
|
||||||
@@ -870,15 +884,7 @@ opfunc_call_n (vm_instr_t instr, /**< instruction */
|
|||||||
ret_value = get_arg_completion;
|
ret_value = get_arg_completion;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ecma_length_t arg_index = 0;
|
ecma_free_values_collection (arg_collection_p, true);
|
||||||
arg_index < args_read;
|
|
||||||
arg_index++)
|
|
||||||
{
|
|
||||||
ecma_free_value (arg_values[arg_index], true);
|
|
||||||
}
|
|
||||||
|
|
||||||
MEM_FINALIZE_LOCAL_ARRAY (arg_values);
|
|
||||||
|
|
||||||
ecma_free_value (this_value, true);
|
ecma_free_value (this_value, true);
|
||||||
|
|
||||||
ECMA_FINALIZE (func_value);
|
ECMA_FINALIZE (func_value);
|
||||||
@@ -908,15 +914,14 @@ opfunc_construct_n (vm_instr_t instr, /**< instruction */
|
|||||||
get_variable_value (frame_ctx_p, constructor_name_lit_idx, false),
|
get_variable_value (frame_ctx_p, constructor_name_lit_idx, false),
|
||||||
ret_value);
|
ret_value);
|
||||||
|
|
||||||
MEM_DEFINE_LOCAL_ARRAY (arg_values, args_number, ecma_value_t);
|
|
||||||
|
|
||||||
frame_ctx_p->pos++;
|
frame_ctx_p->pos++;
|
||||||
|
|
||||||
ecma_length_t args_read;
|
ecma_collection_header_t *arg_collection_p = ecma_new_values_collection (NULL, 0, true);
|
||||||
ecma_completion_value_t get_arg_completion = fill_varg_list (frame_ctx_p,
|
|
||||||
args_number,
|
ecma_completion_value_t get_arg_completion = vm_fill_varg_list (frame_ctx_p,
|
||||||
arg_values,
|
args_number,
|
||||||
&args_read);
|
arg_collection_p);
|
||||||
|
ecma_length_t args_read = arg_collection_p->unit_number;
|
||||||
|
|
||||||
if (ecma_is_completion_value_empty (get_arg_completion))
|
if (ecma_is_completion_value_empty (get_arg_completion))
|
||||||
{
|
{
|
||||||
@@ -930,6 +935,19 @@ opfunc_construct_n (vm_instr_t instr, /**< instruction */
|
|||||||
{
|
{
|
||||||
ecma_object_t *constructor_obj_p = ecma_get_object_from_value (constructor_value);
|
ecma_object_t *constructor_obj_p = ecma_get_object_from_value (constructor_value);
|
||||||
|
|
||||||
|
MEM_DEFINE_LOCAL_ARRAY (arg_values, args_read, ecma_value_t);
|
||||||
|
|
||||||
|
ecma_collection_iterator_t arg_collection_iter;
|
||||||
|
ecma_collection_iterator_init (&arg_collection_iter,
|
||||||
|
arg_collection_p);
|
||||||
|
|
||||||
|
for (ecma_length_t arg_index = 0;
|
||||||
|
ecma_collection_iterator_next (&arg_collection_iter);
|
||||||
|
arg_index++)
|
||||||
|
{
|
||||||
|
arg_values[arg_index] = *arg_collection_iter.current_value_p;
|
||||||
|
}
|
||||||
|
|
||||||
ECMA_TRY_CATCH (construction_ret_value,
|
ECMA_TRY_CATCH (construction_ret_value,
|
||||||
ecma_op_function_construct (constructor_obj_p,
|
ecma_op_function_construct (constructor_obj_p,
|
||||||
arg_values,
|
arg_values,
|
||||||
@@ -940,6 +958,8 @@ opfunc_construct_n (vm_instr_t instr, /**< instruction */
|
|||||||
construction_ret_value);
|
construction_ret_value);
|
||||||
|
|
||||||
ECMA_FINALIZE (construction_ret_value);
|
ECMA_FINALIZE (construction_ret_value);
|
||||||
|
|
||||||
|
MEM_FINALIZE_LOCAL_ARRAY (arg_values);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -949,14 +969,7 @@ opfunc_construct_n (vm_instr_t instr, /**< instruction */
|
|||||||
ret_value = get_arg_completion;
|
ret_value = get_arg_completion;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ecma_length_t arg_index = 0;
|
ecma_free_values_collection (arg_collection_p, true);
|
||||||
arg_index < args_read;
|
|
||||||
arg_index++)
|
|
||||||
{
|
|
||||||
ecma_free_value (arg_values[arg_index], true);
|
|
||||||
}
|
|
||||||
|
|
||||||
MEM_FINALIZE_LOCAL_ARRAY (arg_values);
|
|
||||||
|
|
||||||
ECMA_FINALIZE (constructor_value);
|
ECMA_FINALIZE (constructor_value);
|
||||||
|
|
||||||
@@ -987,18 +1000,30 @@ opfunc_array_decl (vm_instr_t instr, /**< instruction */
|
|||||||
|
|
||||||
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
|
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
|
||||||
|
|
||||||
MEM_DEFINE_LOCAL_ARRAY (arg_values, args_number, ecma_value_t);
|
ecma_collection_header_t *arg_collection_p = ecma_new_values_collection (NULL, 0, true);
|
||||||
|
|
||||||
ecma_length_t args_read;
|
ecma_completion_value_t get_arg_completion = vm_fill_varg_list (frame_ctx_p,
|
||||||
ecma_completion_value_t get_arg_completion = fill_varg_list (frame_ctx_p,
|
args_number,
|
||||||
args_number,
|
arg_collection_p);
|
||||||
arg_values,
|
ecma_length_t args_read = arg_collection_p->unit_number;
|
||||||
&args_read);
|
|
||||||
|
|
||||||
if (ecma_is_completion_value_empty (get_arg_completion))
|
if (ecma_is_completion_value_empty (get_arg_completion))
|
||||||
{
|
{
|
||||||
JERRY_ASSERT (args_read == args_number);
|
JERRY_ASSERT (args_read == args_number);
|
||||||
|
|
||||||
|
MEM_DEFINE_LOCAL_ARRAY (arg_values, args_read, ecma_value_t);
|
||||||
|
|
||||||
|
ecma_collection_iterator_t arg_collection_iter;
|
||||||
|
ecma_collection_iterator_init (&arg_collection_iter,
|
||||||
|
arg_collection_p);
|
||||||
|
|
||||||
|
for (ecma_length_t arg_index = 0;
|
||||||
|
ecma_collection_iterator_next (&arg_collection_iter);
|
||||||
|
arg_index++)
|
||||||
|
{
|
||||||
|
arg_values[arg_index] = *arg_collection_iter.current_value_p;
|
||||||
|
}
|
||||||
|
|
||||||
ECMA_TRY_CATCH (array_obj_value,
|
ECMA_TRY_CATCH (array_obj_value,
|
||||||
ecma_op_create_array_object (arg_values,
|
ecma_op_create_array_object (arg_values,
|
||||||
args_number,
|
args_number,
|
||||||
@@ -1010,6 +1035,8 @@ opfunc_array_decl (vm_instr_t instr, /**< instruction */
|
|||||||
array_obj_value);
|
array_obj_value);
|
||||||
|
|
||||||
ECMA_FINALIZE (array_obj_value);
|
ECMA_FINALIZE (array_obj_value);
|
||||||
|
|
||||||
|
MEM_FINALIZE_LOCAL_ARRAY (arg_values);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1018,14 +1045,7 @@ opfunc_array_decl (vm_instr_t instr, /**< instruction */
|
|||||||
ret_value = get_arg_completion;
|
ret_value = get_arg_completion;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ecma_length_t arg_index = 0;
|
ecma_free_values_collection (arg_collection_p, true);
|
||||||
arg_index < args_read;
|
|
||||||
arg_index++)
|
|
||||||
{
|
|
||||||
ecma_free_value (arg_values[arg_index], true);
|
|
||||||
}
|
|
||||||
|
|
||||||
MEM_FINALIZE_LOCAL_ARRAY (arg_values);
|
|
||||||
|
|
||||||
return ret_value;
|
return ret_value;
|
||||||
} /* opfunc_array_decl */
|
} /* opfunc_array_decl */
|
||||||
|
|||||||
Reference in New Issue
Block a user