Fix the order of the function arguments for spread operation (#3369)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
committed by
Dániel Bátyai
parent
aeb8431aff
commit
12211d8aaa
@@ -385,15 +385,14 @@ opfunc_append_to_spread_array (ecma_value_t *stack_top_p, /**< current stack top
|
||||
* pointer to the ecma-collection with the spreaded arguments, otherwise
|
||||
*/
|
||||
JERRY_ATTR_NOINLINE ecma_collection_t *
|
||||
opfunc_spread_arguments (ecma_value_t **stack_top_p, /**< [out] pointer to the current stack top */
|
||||
opfunc_spread_arguments (ecma_value_t *stack_top_p, /**< pointer to the current stack top */
|
||||
uint8_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
ecma_value_t *curr_stack_top_p = *stack_top_p;
|
||||
ecma_collection_t *buff_p = ecma_new_collection ();
|
||||
|
||||
for (uint32_t i = 0; i < arguments_list_len; i++)
|
||||
{
|
||||
ecma_value_t arg = *(--curr_stack_top_p);
|
||||
ecma_value_t arg = *stack_top_p++;
|
||||
|
||||
if (arg != ECMA_VALUE_SPREAD_ELEMENT)
|
||||
{
|
||||
@@ -402,7 +401,8 @@ opfunc_spread_arguments (ecma_value_t **stack_top_p, /**< [out] pointer to the c
|
||||
}
|
||||
|
||||
ecma_value_t ret_value = ECMA_VALUE_ERROR;
|
||||
ecma_value_t spread_value = *(--curr_stack_top_p);
|
||||
ecma_value_t spread_value = *stack_top_p++;
|
||||
i++;
|
||||
|
||||
ecma_value_t iterator = ecma_op_get_iterator (spread_value, ECMA_VALUE_EMPTY);
|
||||
|
||||
@@ -443,7 +443,7 @@ opfunc_spread_arguments (ecma_value_t **stack_top_p, /**< [out] pointer to the c
|
||||
{
|
||||
for (uint32_t k = i + 1; k < arguments_list_len; k++)
|
||||
{
|
||||
ecma_free_value (*(--curr_stack_top_p));
|
||||
ecma_free_value (*(++stack_top_p));
|
||||
}
|
||||
|
||||
ecma_collection_free (buff_p);
|
||||
@@ -452,7 +452,6 @@ opfunc_spread_arguments (ecma_value_t **stack_top_p, /**< [out] pointer to the c
|
||||
}
|
||||
}
|
||||
|
||||
*stack_top_p = curr_stack_top_p;
|
||||
return buff_p;
|
||||
} /* opfunc_spread_arguments */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
@@ -106,7 +106,7 @@ opfunc_append_array (ecma_value_t *stack_top_p, uint16_t values_length);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
ecma_collection_t *
|
||||
opfunc_spread_arguments (ecma_value_t **stack_top_p, uint8_t argument_list_len);
|
||||
opfunc_spread_arguments (ecma_value_t *stack_top_p, uint8_t argument_list_len);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
/**
|
||||
|
||||
+4
-2
@@ -1585,7 +1585,8 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
|
||||
if (opcode >= CBC_EXT_SPREAD_SUPER_CALL)
|
||||
{
|
||||
ecma_collection_t *arguments_p = opfunc_spread_arguments (&stack_top_p, arguments_list_len);
|
||||
stack_top_p -= arguments_list_len;
|
||||
ecma_collection_t *arguments_p = opfunc_spread_arguments (stack_top_p, arguments_list_len);
|
||||
|
||||
if (JERRY_UNLIKELY (arguments_p == NULL))
|
||||
{
|
||||
@@ -2043,8 +2044,9 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
case VM_OC_SPREAD_ARGUMENTS:
|
||||
{
|
||||
uint8_t arguments_list_len = *byte_code_p++;
|
||||
stack_top_p -= arguments_list_len;
|
||||
|
||||
ecma_collection_t *arguments_p = opfunc_spread_arguments (&stack_top_p, arguments_list_len);
|
||||
ecma_collection_t *arguments_p = opfunc_spread_arguments (stack_top_p, arguments_list_len);
|
||||
|
||||
if (JERRY_UNLIKELY (arguments_p == NULL))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user