Implement yield* operation in generator functions. (#3407)

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2019-12-05 13:50:53 +01:00
committed by Dániel Bátyai
parent 1829d2df55
commit 1a4972fc3f
13 changed files with 476 additions and 143 deletions
+12 -12
View File
@@ -319,23 +319,23 @@ opfunc_append_to_spread_array (ecma_value_t *stack_top_p, /**< current stack top
{
while (true)
{
ecma_value_t next = ecma_op_iterator_step (iterator);
ecma_value_t next_value = ecma_op_iterator_step (iterator);
if (ECMA_IS_VALUE_ERROR (next))
if (ECMA_IS_VALUE_ERROR (next_value))
{
break;
}
if (ecma_is_value_false (next))
if (ecma_is_value_false (next_value))
{
idx--;
ret_value = ECMA_VALUE_EMPTY;
break;
}
ecma_value_t value = ecma_op_iterator_value (next);
ecma_value_t value = ecma_op_iterator_value (next_value);
ecma_free_value (next);
ecma_free_value (next_value);
if (ECMA_IS_VALUE_ERROR (value))
{
@@ -412,22 +412,22 @@ opfunc_spread_arguments (ecma_value_t *stack_top_p, /**< pointer to the current
{
while (true)
{
ecma_value_t next = ecma_op_iterator_step (iterator);
ecma_value_t next_value = ecma_op_iterator_step (iterator);
if (ECMA_IS_VALUE_ERROR (next))
if (ECMA_IS_VALUE_ERROR (next_value))
{
break;
}
if (ecma_is_value_false (next))
if (ecma_is_value_false (next_value))
{
ret_value = ECMA_VALUE_EMPTY;
break;
}
ecma_value_t value = ecma_op_iterator_value (next);
ecma_value_t value = ecma_op_iterator_value (next_value);
ecma_free_value (next);
ecma_free_value (next_value);
if (ECMA_IS_VALUE_ERROR (value))
{
@@ -615,7 +615,7 @@ opfunc_create_executable_object (vm_frame_ctx_t *frame_ctx_p) /**< frame context
*/
ecma_value_t
opfunc_resume_executable_object (vm_executable_object_t *executable_object_p, /**< executable object */
ecma_value_t value) /**< value pushed onto the stack */
ecma_value_t value) /**< value pushed onto the stack (takes the reference) */
{
const ecma_compiled_code_t *bytecode_header_p = executable_object_p->frame_ctx.bytecode_header_p;
ecma_value_t *register_p = VM_GET_REGISTERS (&executable_object_p->frame_ctx);
@@ -654,7 +654,7 @@ opfunc_resume_executable_object (vm_executable_object_t *executable_object_p, /*
ecma_ref_if_object (*register_p++);
}
*register_p++ = ecma_copy_value (value);
*register_p++ = value;
executable_object_p->frame_ctx.stack_top_p = register_p;
JERRY_ASSERT (ECMA_EXECUTABLE_OBJECT_IS_SUSPENDED (executable_object_p->extended_object.u.class_prop.extra_info));
+10 -11
View File
@@ -3423,16 +3423,16 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
goto error;
}
ecma_value_t iterator_step = ecma_op_iterator_step (iterator);
ecma_value_t next_value = ecma_op_iterator_step (iterator);
if (ECMA_IS_VALUE_ERROR (iterator_step))
if (ECMA_IS_VALUE_ERROR (next_value))
{
ecma_free_value (iterator);
result = iterator_step;
result = next_value;
goto error;
}
if (ecma_is_value_false (iterator_step))
if (ecma_is_value_false (next_value))
{
ecma_free_value (iterator);
byte_code_p = byte_code_start_p + branch_offset;
@@ -3444,7 +3444,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
VM_PLUS_EQUAL_U16 (frame_ctx_p->context_depth, PARSER_FOR_OF_CONTEXT_STACK_ALLOCATION);
stack_top_p += PARSER_FOR_OF_CONTEXT_STACK_ALLOCATION;
stack_top_p[-1] = VM_CREATE_CONTEXT (VM_CONTEXT_FOR_OF, branch_offset);
stack_top_p[-2] = iterator_step;
stack_top_p[-2] = next_value;
stack_top_p[-3] = iterator;
if (byte_code_p[0] == CBC_EXT_OPCODE && byte_code_p[1] == CBC_EXT_CLONE_CONTEXT)
@@ -3474,18 +3474,18 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
{
JERRY_ASSERT (VM_GET_REGISTERS (frame_ctx_p) + register_end + frame_ctx_p->context_depth == stack_top_p);
ecma_value_t iterator_step = ecma_op_iterator_step (stack_top_p[-3]);
ecma_value_t next_value = ecma_op_iterator_step (stack_top_p[-3]);
if (ECMA_IS_VALUE_ERROR (iterator_step))
if (ECMA_IS_VALUE_ERROR (next_value))
{
result = iterator_step;
result = next_value;
goto error;
}
if (!ecma_is_value_false (iterator_step))
if (!ecma_is_value_false (next_value))
{
ecma_free_value (stack_top_p[-2]);
stack_top_p[-2] = iterator_step;
stack_top_p[-2] = next_value;
byte_code_p = byte_code_start_p + branch_offset;
continue;
}
@@ -3494,7 +3494,6 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
ecma_free_value (stack_top_p[-3]);
VM_MINUS_EQUAL_U16 (frame_ctx_p->context_depth, PARSER_FOR_OF_CONTEXT_STACK_ALLOCATION);
stack_top_p -= PARSER_FOR_OF_CONTEXT_STACK_ALLOCATION;
continue;
}
#endif /* ENABLED (JERRY_ES2015) */