aboutsummaryrefslogtreecommitdiffstats
path: root/cont.c
Commit message (Collapse)AuthorAgeFilesLines
* Moved Fiber methods into core [Feature #17407]Nobuyoshi Nakada2021-01-131-11/+5
|
* [DOC] Fix grammar: "is same as" -> "is the same as"Marcus Stollsteimer2021-01-051-1/+1
|
* Adjusted styles [ci skip]Nobuyoshi Nakada2020-12-281-2/+4
|
* Language tweaks to Fiber [doc]Marc-Andre Lafortune2020-12-271-56/+49
|
* Fix a typo [ci skip]Kazuhiro NISHIYAMA2020-12-241-1/+1
|
* Redocument non-blocking Fibers and schedulerzverok2020-12-241-1/+339
| | | | | | | | | * Document Fiber's method related to scheduling; * Extend Fiber's class docs with concepts of non-blocking fibers; * Introduce "imaginary" (documentation-only) class Fiber::SchedulerInterface to properly document how scheduler's methods should look.
* Review commentszverok2020-12-241-3/+10
|
* Redocument Fiber#transferzverok2020-12-241-27/+53
|
* Enable `Fiber.current` and `Fiber#alive?` call inside ractorDelton Ding2020-12-231-0/+3
|
* Update Fiber#backtrace doc [See bug #17408]Marc-Andre Lafortune2020-12-211-2/+2
|
* Document Fiber#backtrace and #backtrace_locationszverok2020-12-211-0/+65
|
* Let Fiber#raise work with transferring fibersnicholas a. evans2020-12-121-4/+23
| | | | | | This automatically choosess whether to use transfer on a transferring fiber or resume on a yielding fiber. If the fiber is resuming, it raises a FiberError.
* Remove obsoleted internal/mjit.h inclusionTakashi Kokubun2020-11-221-1/+0
| | | | :bow:
* Make sure all threads are scanned on unload_unitsTakashi Kokubun2020-11-211-3/+6
| | | | | | | | | | | This has been a TODO since 79df14c04b. While adcf0316d1 covered the root_fiber of the initial thread, it didn't cover root_fibers of other threads. Now it's hooked properly in rb_threadptr_root_fiber_setup. With regards to "XXX: Is this mjit_cont `mjit_cont_free`d?", when rb_threadptr_root_fiber_release is called, although I'm not sure when th->root_fiber is truthy, fiber_free seems to call cont_free and mjit_cont_free. So mjit_conts of root_fibers seem to be freed properly.
* fix public interfaceKoichi Sasada2020-11-181-1/+1
| | | | | | | | | | | | | | | | | | To make some kind of Ractor related extensions, some functions should be exposed. * include/ruby/thread_native.h * rb_native_mutex_* * rb_native_cond_* * include/ruby/ractor.h * RB_OBJ_SHAREABLE_P(obj) * rb_ractor_shareable_p(obj) * rb_ractor_std*() * rb_cRactor and rm ractor_pub.h and rename srcdir/ractor.h to srcdir/ractor_core.h (to avoid conflict with include/ruby/ractor.h)
* strip trailing spaces and adjusted indents [ci skip]Nobuyoshi Nakada2020-11-121-13/+13
|
* Rename to `Fiber#set_scheduler`.Samuel Williams2020-11-071-3/+41
|
* Remove duplicated line [ci skip]Kazuhiro NISHIYAMA2020-10-141-1/+0
| | | | ref bf3b2a43741e4f72be21bc6acf24d37e7fcff61c
* relax Fiber#transfer's restrictionKoichi Sasada2020-10-121-35/+67
| | | | | | | | | | | | | | | | | | | | | | | | | Using Fiber#transfer with Fiber#resume for a same Fiber is limited (once Fiber#transfer is called for a fiber, the fiber can not be resumed more). This restriction was introduced to protect the resume/yield chain, but we realized that it is too much to protect the chain. Instead of the current restriction, we introduce some other protections. (1) can not transfer to the resuming fiber. (2) can not transfer to the yielding fiber. (3) can not resume transferred fiber. (4) can not yield from not-resumed fiber. [Bug #17221] Also at the end of a transferred fiber, it had continued on root fiber. However, if the root fiber resumed a fiber (and that fiber can resumed another fiber), this behavior also breaks the resume/yield chain. So at the end of a transferred fiber, switch to the edge of resume chain from root fiber. For example, root fiber resumed f1 and f1 resumed f2, transferred to f3 and f3 terminated, then continue from the fiber f2 (it was continued from root fiber without this patch).
* Fix a use-after-free bug reported by ASANAaron Patterson2020-10-011-3/+1
| | | | | | | If a fiber and thread are collected at the same time, the thread might get collected first and the pointer on the fiber will go bad. I don't think we need to check whether or not this is the main fiber in order to release its stack
* Make Mutex per-Fiber instead of per-ThreadBenoit Daloze2020-09-141-0/+11
| | | | | | | | | * Enables Mutex to be used as synchronization between multiple Fibers of the same Thread. * With a Fiber scheduler we can yield to another Fiber on contended Mutex#lock instead of blocking the entire thread. * This also makes the behavior of Mutex consistent across CRuby, JRuby and TruffleRuby. * [Feature #16792]
* Rename `Fiber{}` to `Fiber.schedule{}`.Samuel Williams2020-09-141-1/+2
|
* Introduce Ractor mechanism for parallel executionKoichi Sasada2020-09-031-7/+11
| | | | | | | | | | | | | | | | This commit introduces Ractor mechanism to run Ruby program in parallel. See doc/ractor.md for more details about Ractor. See ticket [Feature #17100] to see the implementation details and discussions. [Feature #17100] This commit does not complete the implementation. You can find many bugs on using Ractor. Also the specification will be changed so that this feature is experimental. You will see a warning when you make the first Ractor with `Ractor.new`. I hope this feature can help programmers from thread-safety issues.
* Expose ec -> backtrace (internal) and use it to implement fiber backtrace.Samuel Williams2020-08-181-0/+14
| | | | See <https://bugs.ruby-lang.org/issues/16815> for more details.
* Ensure that the head of the vacancy list is correctly inserted into the ↵Samuel Williams2020-06-051-0/+1
| | | | | | linked list. See <https://bugs.ruby-lang.org/issues/16814> for more details.
* Fix documentation for Fiber#raise [ci skip]Jeremy Evans2020-05-251-2/+2
| | | | Fixes [Bug #16912]
* Thread scheduler for light weight concurrency.Samuel Williams2020-05-141-6/+86
|
* sed -i 's|ruby/impl|ruby/internal|'卜部昌平2020-05-111-1/+1
| | | | To fix build failures.
* sed -i s|ruby/3|ruby/impl|g卜部昌平2020-05-111-1/+1
| | | | This shall fix compile errors.
* Added more NORETURN declarationsNobuyoshi Nakada2020-05-111-1/+3
|
* Merge pull request #2991 from shyouhei/ruby.h卜部昌平2020-04-081-1/+1
| | | Split ruby.h
* Prevent unloading methods used in root_fiber while calling another Fiber (#2939)Takashi Kokubun2020-02-281-3/+18
| | | | | | Fixing SEGVs like: http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/2744905 http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/2744420 http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/2741400
* Let execution context local storage be an ID tableLourens Naudé2020-01-111-2/+3
|
* Fully separate positional arguments and keyword argumentsJeremy Evans2020-01-021-8/+4
| | | | | | | | | | | | | | | | | | | | | | | | This removes the warnings added in 2.7, and changes the behavior so that a final positional hash is not treated as keywords or vice-versa. To handle the arg_setup_block splat case correctly with keyword arguments, we need to check if we are taking a keyword hash. That case didn't have a test, but it affects real-world code, so add a test for it. This removes rb_empty_keyword_given_p() and related code, as that is not needed in Ruby 3. The empty keyword case is the same as the no keyword case in Ruby 3. This changes rb_scan_args to implement keyword argument separation for C functions when the : character is used. For backwards compatibility, it returns a duped hash. This is a bad idea for performance, but not duping the hash breaks at least Enumerator::ArithmeticSequence#inspect. Instead of having RB_PASS_CALLED_KEYWORDS be a number, simplify the code by just making it be rb_keyword_given_p().
* decouple internal.h headers卜部昌平2019-12-261-7/+13
| | | | | | | | | | | | | | | | | | Saves comitters' daily life by avoid #include-ing everything from internal.h to make each file do so instead. This would significantly speed up incremental builds. We take the following inclusion order in this changeset: 1. "ruby/config.h", where _GNU_SOURCE is defined (must be the very first thing among everything). 2. RUBY_EXTCONF_H if any. 3. Standard C headers, sorted alphabetically. 4. Other system headers, maybe guarded by #ifdef 5. Everything else, sorted alphabetically. Exceptions are those win32-related headers, which tend not be self- containing (headers have inclusion order dependencies).
* Fixed misspellingsNobuyoshi Nakada2019-12-201-1/+1
| | | | Fixed misspellings reported at [Bug #16437], only in ruby and rubyspec.
* Suppress strict-aliasing warning by x86_64-w64-mingw32-gcc 7.4.0Nobuyoshi Nakada2019-11-281-2/+2
|
* Fix a typo [ci skip]Kazuhiro NISHIYAMA2019-11-041-1/+1
|
* ruby_mimmalloc can return NULL卜部昌平2019-11-011-0/+3
| | | | malloc can fail. Should treat such situations.
* Fix continuation mark / compactAaron Patterson2019-10-281-0/+6
|
* Fix documentation for Fiber#transfer [ci skip]Jeremy Evans2019-10-261-6/+13
| | | | | | | | | | | | | | | | | Fiber#transfer prevents calling Fiber#resume on the receiver of the transfer method, not the fiber calling transfer. Transfering back to a fiber does not allow later calling resume on the fiber. Once transfer has been called on a fiber, you can never call resume on the fiber. Calling resume on a transferred fiber is not a double resume error, it is a different FiberError (cannot resume transferred Fiber). For details on the differences between transferred fibers and regular fibers, see Sasada-san's RubyKaigi 2017 presentation (in short, Fiber#transfer is for coroutine, Fiber#resume is for semi-coroutine).
* show "transferred" attribute on Fiber#to_sKoichi Sasada2019-10-241-4/+10
| | | | | | | If a fiber is invoked with transfer method (such as "f.transfer"), then the invoked fiber ("f") is labeled as "transferred" and this fiber can not be invoked with Fiber#resume. This patch adds transferred attribute for "Fiber#to_s" (and inspect).
* Revert "Fix Fiber#transfer"Koichi Sasada2019-10-241-2/+1
| | | | | | This reverts commit fa8ac91e957a076f6df1adaecad7896817138009. Previous behavior is intentional.
* Fix Fiber#transferJeremy Evans2019-10-211-1/+2
| | | | | | | | | | | | | Fiber#transfer previously made it impossible to resume the fiber if it was transferred to (no resuming the target of Fiber#transfer). However, the documentation specifies that you cannot resume a fiber that has transferred to another fiber (no resuming the source of Fiber#transfer), unless control is transferred back. Fix the code by setting the transferred flag on the current/source fiber, and unsetting the transferred flag on the target fiber. Fixes [Bug #9664] Fixes [Bug #12555]
* Add rb_adjust_argv_kw_splat to internal.hJeremy Evans2019-09-261-1/+0
| | | | | We are calling this in a few other files, it is better to have it in a header than adding prototypes to the other files.
* Fix clang errors when pendantic errors enabledAaron Patterson2019-09-261-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | I've been compiling with: ``` set -lx cflags '-std=c99 -Werror=pedantic -pedantic-errors' ``` But compilation would fail with the following: ``` cont.c:296:90: error: format specifies type 'void *' but the argument has type 'struct fiber_pool_stack *' [-Werror,-Wformat-pedantic] if (DEBUG) fprintf(stderr, "fiber_pool_stack_alloca(%p): %"PRIuSIZE"/%"PRIuSIZE"\n", stack, offset, stack->available); ~~ ^~~~~ cont.c:467:24: error: format specifies type 'void *' but the argument has type 'struct fiber_pool *' [-Werror,-Wformat-pedantic] count, fiber_pool, fiber_pool->used, fiber_pool->count, size, fiber_pool->vm_stack_size); ^~~~~~~~~~ cont.c:588:83: error: format specifies type 'void *' but the argument has type 'struct fiber_pool_vacancy *' [-Werror,-Wformat-pedantic] if (DEBUG) fprintf(stderr, "fiber_pool_stack_acquire: %p used=%"PRIuSIZE"\n", fiber_pool->vacancies, fiber_pool->used); ~~ ^~~~~~~~~~~~~~~~~~~~~ cont.c:736:76: error: format specifies type 'void *' but the argument has type 'rb_fiber_t *' (aka 'struct rb_fiber_struct *') [-Werror,-Wformat-pedantic] if (DEBUG) fprintf(stderr, "fiber_stack_release: %p, stack.base=%p\n", fiber, fiber->stack.base); ``` This commit just fixes the pedantic errors
* Fix keyword argument separation issues in Fiber#resumeJeremy Evans2019-09-261-11/+30
|
* Add VM_NO_KEYWORDSJeremy Evans2019-09-051-1/+1
| | | | | I think this is easier to read than using literal 0 with comments in every case where it is used.
* Propagate kw_splat informationYusuke Endoh2019-09-051-1/+1
| | | | | | | The kw_splat flag is whether the original call passes keyword or not. Some types of methods (e.g., bmethod and sym_proc) drops the information. This change tries to propagate the flag to the final callee, as far as I can.
* rb_proc_new / rb_fiber_new now free from ANYARGS卜部昌平2019-08-271-1/+1
| | | | | | | After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. This commit deletes ANYARGS from rb_proc_new / rb_fiber_new, and applies RB_BLOCK_CALL_FUNC_ARGLIST wherever necessary.