Lines Matching refs:fiber
94 static void zend_fiber_suspend(zend_fiber *fiber) in zend_fiber_suspend() argument
105 zend_fiber_suspend_context(&fiber->context); in zend_fiber_suspend()
110 static void zend_fiber_switch_to(zend_fiber *fiber) in zend_fiber_switch_to() argument
122 zend_observer_fiber_switch_notify(previous, fiber); in zend_fiber_switch_to()
126 FIBER_G(current_fiber) = fiber; in zend_fiber_switch_to()
128 zend_fiber_switch_context(&fiber->context); in zend_fiber_switch_to()
134 zend_observer_fiber_switch_notify(fiber, previous); in zend_fiber_switch_to()
136 if (UNEXPECTED(fiber->status == ZEND_FIBER_STATUS_BAILOUT)) { in zend_fiber_switch_to()
155 zend_fiber *fiber = FIBER_G(current_fiber); in zend_fiber_execute() local
156 ZEND_ASSERT(fiber); in zend_fiber_execute()
172 fiber->execute_data = (zend_execute_data *) stack->top; in zend_fiber_execute()
173 fiber->stack_bottom = fiber->execute_data; in zend_fiber_execute()
175 memset(fiber->execute_data, 0, sizeof(zend_execute_data)); in zend_fiber_execute()
177 fiber->execute_data->func = &zend_fiber_function; in zend_fiber_execute()
178 fiber->stack_bottom->prev_execute_data = EG(current_execute_data); in zend_fiber_execute()
180 EG(current_execute_data) = fiber->execute_data; in zend_fiber_execute()
184 fiber->fci.retval = &fiber->value; in zend_fiber_execute()
186 fiber->status = ZEND_FIBER_STATUS_RUNNING; in zend_fiber_execute()
188 zend_call_function(&fiber->fci, &fiber->fci_cache); in zend_fiber_execute()
191 zval_ptr_dtor(&fiber->fci.function_name); in zend_fiber_execute()
192 ZVAL_UNDEF(&fiber->fci.function_name); in zend_fiber_execute()
195 if (fiber->status == ZEND_FIBER_STATUS_SHUTDOWN) { in zend_fiber_execute()
200 fiber->status = ZEND_FIBER_STATUS_THREW; in zend_fiber_execute()
203 fiber->status = ZEND_FIBER_STATUS_RETURNED; in zend_fiber_execute()
206 fiber->status = ZEND_FIBER_STATUS_BAILOUT; in zend_fiber_execute()
210 fiber->execute_data = NULL; in zend_fiber_execute()
211 fiber->stack_bottom = NULL; in zend_fiber_execute()
216 zend_fiber *fiber = emalloc(sizeof(zend_fiber)); in zend_fiber_object_create() local
217 memset(fiber, 0, sizeof(zend_fiber)); in zend_fiber_object_create()
219 zend_object_std_init(&fiber->std, ce); in zend_fiber_object_create()
220 fiber->std.handlers = &zend_fiber_handlers; in zend_fiber_object_create()
222 return &fiber->std; in zend_fiber_object_create()
227 zend_fiber *fiber = (zend_fiber *) object; in zend_fiber_object_destroy() local
229 if (fiber->status != ZEND_FIBER_STATUS_SUSPENDED) { in zend_fiber_object_destroy()
236 fiber->status = ZEND_FIBER_STATUS_SHUTDOWN; in zend_fiber_object_destroy()
238 zend_fiber_switch_to(fiber); in zend_fiber_object_destroy()
258 zend_fiber *fiber = (zend_fiber *) object; in zend_fiber_object_free() local
260 zval_ptr_dtor(&fiber->fci.function_name); in zend_fiber_object_free()
261 zval_ptr_dtor(&fiber->value); in zend_fiber_object_free()
263 zend_fiber_destroy_context(&fiber->context); in zend_fiber_object_free()
265 zend_object_std_dtor(&fiber->std); in zend_fiber_object_free()
270 zend_fiber *fiber = (zend_fiber *) object; in zend_fiber_object_gc() local
273 zend_get_gc_buffer_add_zval(buf, &fiber->fci.function_name); in zend_fiber_object_gc()
274 zend_get_gc_buffer_add_zval(buf, &fiber->value); in zend_fiber_object_gc()
312 if (reflection->fiber) { in zend_reflection_fiber_object_free()
313 GC_DELREF(&reflection->fiber->std); in zend_reflection_fiber_object_free()
321 zend_fiber *fiber = (zend_fiber *) Z_OBJ_P(getThis()); in ZEND_METHOD() local
324 Z_PARAM_FUNC(fiber->fci, fiber->fci_cache) in ZEND_METHOD()
328 Z_TRY_ADDREF(fiber->fci.function_name); in ZEND_METHOD()
333 zend_fiber *fiber = (zend_fiber *) Z_OBJ_P(getThis()); in ZEND_METHOD() local
336 Z_PARAM_VARIADIC_WITH_NAMED(fiber->fci.params, fiber->fci.param_count, fiber->fci.named_params); in ZEND_METHOD()
339 if (fiber->status != ZEND_FIBER_STATUS_INIT) { in ZEND_METHOD()
344 if (!zend_fiber_init_context(&fiber->context, zend_fiber_execute, FIBER_G(stack_size))) { in ZEND_METHOD()
349 zend_fiber_switch_to(fiber); in ZEND_METHOD()
351 if (fiber->status & ZEND_FIBER_STATUS_FINISHED) { in ZEND_METHOD()
355 RETVAL_COPY_VALUE(&fiber->value); in ZEND_METHOD()
356 ZVAL_UNDEF(&fiber->value); in ZEND_METHOD()
361 zend_fiber *fiber = FIBER_G(current_fiber); in ZEND_METHOD() local
369 if (UNEXPECTED(!fiber)) { in ZEND_METHOD()
374 if (UNEXPECTED(fiber->status == ZEND_FIBER_STATUS_SHUTDOWN)) { in ZEND_METHOD()
379 ZEND_ASSERT(fiber->status == ZEND_FIBER_STATUS_RUNNING); in ZEND_METHOD()
382 ZVAL_COPY(&fiber->value, value); in ZEND_METHOD()
384 ZVAL_NULL(&fiber->value); in ZEND_METHOD()
387 fiber->execute_data = execute_data; in ZEND_METHOD()
388 fiber->status = ZEND_FIBER_STATUS_SUSPENDED; in ZEND_METHOD()
389 fiber->stack_bottom->prev_execute_data = NULL; in ZEND_METHOD()
391 zend_fiber_suspend(fiber); in ZEND_METHOD()
393 if (fiber->status == ZEND_FIBER_STATUS_SHUTDOWN) { in ZEND_METHOD()
405 fiber->status = ZEND_FIBER_STATUS_RUNNING; in ZEND_METHOD()
407 if (fiber->exception) { in ZEND_METHOD()
408 exception = fiber->exception; in ZEND_METHOD()
409 fiber->exception = NULL; in ZEND_METHOD()
415 RETVAL_COPY_VALUE(&fiber->value); in ZEND_METHOD()
416 ZVAL_UNDEF(&fiber->value); in ZEND_METHOD()
421 zend_fiber *fiber; in ZEND_METHOD() local
429 fiber = (zend_fiber *) Z_OBJ_P(getThis()); in ZEND_METHOD()
431 if (UNEXPECTED(fiber->status != ZEND_FIBER_STATUS_SUSPENDED)) { in ZEND_METHOD()
437 ZVAL_COPY(&fiber->value, value); in ZEND_METHOD()
439 ZVAL_NULL(&fiber->value); in ZEND_METHOD()
442 fiber->status = ZEND_FIBER_STATUS_RUNNING; in ZEND_METHOD()
443 fiber->stack_bottom->prev_execute_data = execute_data; in ZEND_METHOD()
445 zend_fiber_switch_to(fiber); in ZEND_METHOD()
447 if (fiber->status & ZEND_FIBER_STATUS_FINISHED) { in ZEND_METHOD()
451 RETVAL_COPY_VALUE(&fiber->value); in ZEND_METHOD()
452 ZVAL_UNDEF(&fiber->value); in ZEND_METHOD()
457 zend_fiber *fiber; in ZEND_METHOD() local
464 fiber = (zend_fiber *) Z_OBJ_P(getThis()); in ZEND_METHOD()
466 if (UNEXPECTED(fiber->status != ZEND_FIBER_STATUS_SUSPENDED)) { in ZEND_METHOD()
472 fiber->exception = exception; in ZEND_METHOD()
474 fiber->status = ZEND_FIBER_STATUS_RUNNING; in ZEND_METHOD()
475 fiber->stack_bottom->prev_execute_data = execute_data; in ZEND_METHOD()
477 zend_fiber_switch_to(fiber); in ZEND_METHOD()
479 if (fiber->status & ZEND_FIBER_STATUS_FINISHED) { in ZEND_METHOD()
483 RETVAL_COPY_VALUE(&fiber->value); in ZEND_METHOD()
484 ZVAL_UNDEF(&fiber->value); in ZEND_METHOD()
489 zend_fiber *fiber; in ZEND_METHOD() local
493 fiber = (zend_fiber *) Z_OBJ_P(getThis()); in ZEND_METHOD()
495 RETURN_BOOL(fiber->status != ZEND_FIBER_STATUS_INIT); in ZEND_METHOD()
500 zend_fiber *fiber; in ZEND_METHOD() local
504 fiber = (zend_fiber *) Z_OBJ_P(getThis()); in ZEND_METHOD()
506 RETURN_BOOL(fiber->status == ZEND_FIBER_STATUS_SUSPENDED); in ZEND_METHOD()
511 zend_fiber *fiber; in ZEND_METHOD() local
515 fiber = (zend_fiber *) Z_OBJ_P(getThis()); in ZEND_METHOD()
517 RETURN_BOOL(fiber->status == ZEND_FIBER_STATUS_RUNNING); in ZEND_METHOD()
522 zend_fiber *fiber; in ZEND_METHOD() local
526 fiber = (zend_fiber *) Z_OBJ_P(getThis()); in ZEND_METHOD()
528 RETURN_BOOL(fiber->status & ZEND_FIBER_STATUS_FINISHED); in ZEND_METHOD()
533 zend_fiber *fiber; in ZEND_METHOD() local
537 fiber = (zend_fiber *) Z_OBJ_P(getThis()); in ZEND_METHOD()
539 if (fiber->status != ZEND_FIBER_STATUS_RETURNED) { in ZEND_METHOD()
542 if (fiber->status == ZEND_FIBER_STATUS_INIT) { in ZEND_METHOD()
544 } else if (fiber->status == ZEND_FIBER_STATUS_THREW) { in ZEND_METHOD()
554 RETURN_COPY(&fiber->value); in ZEND_METHOD()
559 zend_fiber *fiber; in ZEND_METHOD() local
563 fiber = FIBER_G(current_fiber); in ZEND_METHOD()
565 if (!fiber) { in ZEND_METHOD()
569 RETURN_OBJ_COPY(&fiber->std); in ZEND_METHOD()
604 reflection->fiber = (zend_fiber *) Z_OBJ_P(object); in ZEND_METHOD()
606 GC_ADDREF(&reflection->fiber->std); in ZEND_METHOD()
617 RETURN_OBJ_COPY(&reflection->fiber->std); in ZEND_METHOD()
620 #define REFLECTION_CHECK_VALID_FIBER(fiber) do { \ argument
621 …if (fiber == NULL || fiber->status == ZEND_FIBER_STATUS_INIT || fiber->status & ZEND_FIBER_STATUS_…
640 REFLECTION_CHECK_VALID_FIBER(reflection->fiber); in ZEND_METHOD()
642 prev_execute_data = reflection->fiber->stack_bottom->prev_execute_data; in ZEND_METHOD()
643 reflection->fiber->stack_bottom->prev_execute_data = NULL; in ZEND_METHOD()
645 if (FIBER_G(current_fiber) != reflection->fiber) { in ZEND_METHOD()
647 EG(current_execute_data) = reflection->fiber->execute_data; in ZEND_METHOD()
653 reflection->fiber->stack_bottom->prev_execute_data = prev_execute_data; in ZEND_METHOD()
665 REFLECTION_CHECK_VALID_FIBER(reflection->fiber); in ZEND_METHOD()
667 if (FIBER_G(current_fiber) == reflection->fiber) { in ZEND_METHOD()
670 prev_execute_data = reflection->fiber->execute_data->prev_execute_data; in ZEND_METHOD()
685 REFLECTION_CHECK_VALID_FIBER(reflection->fiber); in ZEND_METHOD()
687 if (FIBER_G(current_fiber) == reflection->fiber) { in ZEND_METHOD()
690 prev_execute_data = reflection->fiber->execute_data->prev_execute_data; in ZEND_METHOD()
699 zend_fiber *fiber; in ZEND_METHOD() local
704 fiber = reflection->fiber; in ZEND_METHOD()
706 if (fiber == NULL || fiber->status & ZEND_FIBER_STATUS_FINISHED) { in ZEND_METHOD()
711 RETURN_COPY(&fiber->fci.function_name); in ZEND_METHOD()