mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Mark generator as running during yield* (#5014)
Fixes #5013 JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
parent
3360e352bf
commit
368641043f
@ -677,7 +677,9 @@ ecma_gc_mark_executable_object (ecma_object_t *object_p) /**< object */
|
||||
ecma_gc_set_object_visited (executable_object_p->frame_ctx.lex_env_p);
|
||||
ecma_gc_set_object_visited (executable_object_p->shared.function_object_p);
|
||||
|
||||
if (!ECMA_EXECUTABLE_OBJECT_IS_SUSPENDED (executable_object_p))
|
||||
if (!ECMA_EXECUTABLE_OBJECT_IS_SUSPENDED (executable_object_p)
|
||||
&& !(executable_object_p->extended_object.u.cls.u2.executable_obj_flags
|
||||
& ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD))
|
||||
{
|
||||
/* All objects referenced by running executable objects are strong roots,
|
||||
* and a finished executable object cannot refer to other values. */
|
||||
|
||||
@ -91,12 +91,20 @@ ecma_builtin_generator_prototype_object_do (vm_executable_object_t *generator_ob
|
||||
{
|
||||
if (generator_object_p->extended_object.u.cls.u2.executable_obj_flags & ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD)
|
||||
{
|
||||
if (generator_object_p->extended_object.u.cls.u2.executable_obj_flags & ECMA_EXECUTABLE_OBJECT_RUNNING)
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_GENERATOR_IS_CURRENTLY_UNDER_EXECUTION);
|
||||
}
|
||||
|
||||
ecma_value_t iterator = generator_object_p->iterator;
|
||||
ecma_value_t next_method = generator_object_p->frame_ctx.stack_top_p[-1];
|
||||
|
||||
bool done = false;
|
||||
|
||||
generator_object_p->extended_object.u.cls.u2.executable_obj_flags |= ECMA_EXECUTABLE_OBJECT_RUNNING;
|
||||
ecma_value_t result = ecma_op_iterator_do (resume_mode, iterator, next_method, arg, &done);
|
||||
ecma_free_value (arg);
|
||||
generator_object_p->extended_object.u.cls.u2.executable_obj_flags &= (uint8_t) ~ECMA_EXECUTABLE_OBJECT_RUNNING;
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (result))
|
||||
{
|
||||
|
||||
30
tests/jerry/regression-test-issue-5013.js
Normal file
30
tests/jerry/regression-test-issue-5013.js
Normal file
@ -0,0 +1,30 @@
|
||||
// Copyright JS Foundation and other contributors, http://js.foundation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
function foo() {
|
||||
var a;
|
||||
function* bar() {
|
||||
try {
|
||||
yield* b;
|
||||
} catch (e) {
|
||||
a = e;
|
||||
}
|
||||
}
|
||||
var b = bar();
|
||||
b.next();
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
foo();
|
||||
Loading…
x
Reference in New Issue
Block a user