aboutsummaryrefslogtreecommitdiffstats
path: root/cont.c
Commit message (Collapse)AuthorAgeFilesLines
* use `GET_EC()` directly.ko12017-11-061-4/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* move rb_thread_t::interrupt_flag and maskko12017-11-061-10/+16
| | | | | | | | | | | | | | | | to rb_execution_context_t. * vm_core.h (rb_thread_t): move `rb_thread_t::interrupt_flag` and `rb_thread_t::interrupt_mask` to rb_execution_context_t. RUBY_VM_CHECK_INTS() accepts `ec` instead of `th`. * cont.c (rb_fiber_terminate): to propagate interrupt information, add new parameter `need_interrupt`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* renmae ec::fiber to ec::fiber_ptr.ko12017-11-061-24/+24
| | | | | | | | * vm_core.h (rb_execution_context_t): renmae ec::fiber to ec::fiber_ptr make consistent with ec::thread_ptr. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* EXEC_EVENT_HOOK(ec, ...)ko12017-10-291-2/+2
| | | | | | | * vm_core.h (EXEC_EVENT_HOOK): accepts `ec` instead of `th`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* `ec` has `thread_ptr`.ko12017-10-291-10/+3
| | | | | | | | | | * cont.c (rb_context_struct): move rb_context_t::thread_ptr to rb_execution_context_t::thread_ptr. * cont.c (rb_fiberptr_thread_ptr): removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* `th` -> `ec` for some functions.ko12017-10-281-1/+1
| | | | | | | | | * vm.c (rb_vm_get_binding_creatable_next_cfp): accepts `ec` instead of `th`. * vm.c (rb_vm_stack_to_heap): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* `th` -> `ec` for block related functions.ko12017-10-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * vm.c: the following functions accept `ec` instead of `th`. * invoke_block * invoke_bmethod * invoke_iseq_block_from_c * invoke_block_from_c_bh * check_block_handler * vm_yield_with_cref * vm_yield * vm_yield_with_block * vm_yield_force_blockarg * invoke_block_from_c_proc * vm_invoke_proc * vm_invoke_bmethod * rb_vm_invoke_proc * vm_insnhelper.c: ditto. * vm_yield_with_cfunc * vm_yield_with_symbol * vm_callee_setup_block_arg * vm_yield_setup_args * vm_invoke_iseq_block * vm_invoke_symbol_block * vm_invoke_ifunc_block * vm_invoke_block git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* make root fiber at switching.ko12017-10-261-1/+7
| | | | | | | | | | * cont.c (fiber_switch): make sure the root fiber object is available before the first switching. * test/ruby/test_fiber.rb: remove "skip". git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fix freeing `th->ec` bugs.ko12017-10-261-1/+19
| | | | | | | | | | | | | | * vm.c (thread_free): simply call rb_threadptr_root_fiber_release(). * cont.c (rb_threadptr_root_fiber_release): release th->ec (ec->fiber) iff root_fiber is NULL. If root_fiber is available, then ignore it and root fiber object will free th->ec too. * cont.c (rb_threadptr_root_fiber_setup): do not set th->root_fiber. th->root_fiber will be set if a root fiber object is created. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* introduce EC_*_TAG() instead of TH_*_TAG()ko12017-10-261-2/+2
| | | | | | | | | | | | | | | | * eval_intern.h: introduce EC_*_TAG() macros instead of TH_*_TAG() macros. * TH_PUSH_TAG() -> EC_PUSH_TAG() * TH_POP_TAG() -> EC_POP_TAG() * TH_TMPPOP_TAG() -> EC_TMPPOP_TAG() * TH_REPUSH_TAG() -> EC_REPUSH_TAG() * TH_EXEC_TAG() -> EC_EXEC_TAG() * TH_JUMP_TAG() -> EC_JUMP_TAG() rb_threadptr_tag_state() , rb_ec_tag_jump() also accept `ec` instead of `th`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fix commentsko12017-10-261-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60442 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Use rb_execution_context_t instead of rb_thread_tko12017-10-261-127/+248
| | | | | | | | | | | | | | | | | | | | | | | | | to represent execution context [Feature #14038] * vm_core.h (rb_thread_t): rb_thread_t::ec is now a pointer. There are many code using `th` to represent execution context (such as cfp, VM stack and so on). To access `ec`, they need to use `th->ec->...` (adding one indirection) so that we need to replace them by passing `ec` instead of `th`. * vm_core.h (GET_EC()): introduced to access current ec. Also remove `ruby_current_thread` global variable. * cont.c (rb_context_t): introduce rb_context_t::thread_ptr instead of rb_context_t::thread_value. * cont.c (ec_set_vm_stack): added to update vm_stack explicitly. * cont.c (ec_switch): added to switch ec explicitly. * cont.c (rb_fiber_close): added to terminate fibers explicitly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60440 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* cont.c: update comment to match r59776 [ci skip]normal2017-09-121-1/+1
| | | | | | * cont.c (fiber_switch): th->fiber => th->ec.fiber in comment git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* store ec instead of thread in rb_context_t.ko12017-09-101-76/+77
| | | | | | | | | | | | | | | | * cont.c (rb_context_t): introduce saved_ec instaad of saved_thread. We only need to transfer ec data (not all of thread data). Introduce `thread_value` field to point creation thread. To acccess this field, `cont_thread_value()` is introduced. * vm.c (rb_execution_context_mark): remove `static` and use it from cont.c (use this function instead of `rb_thread_mark`). * vm_insnhelper.c (rb_vm_push_frame): accept ec instead of th. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* avoid false positive on fiber_verify().ko12017-09-101-1/+6
| | | | | | | | | | * cont.c (fiber_store): move `cont_save_machine_stack()` timing to avoid `fiber_verify()` false positive on `FIBER_USE_NATIVE == 0` and `GC.stress = true`. This patch is very dirty and it should be removed soon. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* clear `stack_end`.ko12017-09-101-4/+2
| | | | | | | | | | * cont.c (cont_save_thread): clear only `stack_end`. Clearing tells GC mark function to ignore this macine stack (not allocated yet). `stack_start` will be used by machine stack store/restore phase (on FIBER_USE_NATIVE == 0), so that only `stack_end` is cleared. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* cont.c: fix typo [ci skip]nobu2017-09-101-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* move th->machine to ec->machine.ko12017-09-101-33/+32
| | | | | | | | | | | | | | | | | | | | | * vm_core.h: move rb_thread_t::machine to rb_execution_context_t::machine. * vm_core.h, gc.c (rb_gc_mark_machine_stack): accept ec instead of th. it enables to call this func from rb_execution_context_mark() in vm.c. * cont.c (fiber_setcontext): catch up this fix. fiber_restore_thread() restores machine stack information too. * gc.c: catch up structure layout changes. * thread.c: ditto. * thread_pthread.c: ditto. * thread_win32.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fiber: fix machine stack marking when FIBER_USE_NATIVE is 0normal2017-09-081-1/+1
| | | | | | | | | | | | * cont.c (cont_mark): mark Fiber machine stack correctly when FIBER_USE_NATIVE is 0 * test/ruby/test_fiber.rb (test_mark_fiber): new test [Bug #13875] [ruby-core:82681] This bug appears to be introduced with r59557. ("refactoring Fiber status") git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fix up r59776nobu2017-09-081-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* move th->fiber to ec->fiber.ko12017-09-081-20/+20
| | | | | | | | * vm_core.h (rb_thread_t::fiber): move fiber field to rb_execution_context_t::fiber. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* cont.c: fix root fiber to_snobu2017-09-021-1/+8
| | | | | | | * cont.c (fiber_to_s): fix Fiber#to_s on root fibers which have no procs. [ruby-core:82629] [Bug #13859] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* remove debug code.ko12017-08-231-1/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* split out struct cont_saved_vm_stack.ko12017-08-221-27/+33
| | | | | | | | * cont.c: introduce `struct cont_saved_vm_stack` which was part of `struct rb_context_struct`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fix a typo in comment.nagachika2017-08-101-1/+1
| | | | | | * cont.c (typedef struct rb_context_struct): fix a typo in comment. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* use VM_UNREACHABLE() instead of rb_bug().ko12017-08-101-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59566 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* introduce fiber_restore_thread.ko12017-08-101-8/+21
| | | | | | | | | * cont.c (fiber_restore_thread): added (separate from cont_restore_thread). * cont.c (fiber_setcontext): call fiber_restore_thread() directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* rename rb_execution_context_t::stack(_size) to vm_stack(_size).ko12017-08-101-27/+27
| | | | | | | | | * vm_core.h: Ruby processes run with two stacks, a machine stack and a VM stack. To make it clear, this fix renames rb_execution_context_t::stack(_size) to vm_stack(_size). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* cont.c: fix up r59557 for !FIBER_USE_NATIVEnobu2017-08-101-0/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59562 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* constify some variables.ko12017-08-101-6/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59561 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* remove additional newline.ko12017-08-101-1/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59559 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fiber#to_s (#inspect) return richer information.ko12017-08-101-0/+22
| | | | | | | | | | * cont.c (fiber_to_s): return with block and status information. * proc.c (proc_to_s_): removed and introduce rb_block_to_s() function to return block information string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59558 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* refactoring Fiber status.ko12017-08-101-27/+112
| | | | | | | | | | | | | | | | | | | * cont.c: revisit fiber status. "FIBER_RUNNING" status represents fiber is resumed or suspended. This fix separate these two status explicitly. FIBER_CREATED: Just after Fiber.new. Not resumed yet. FIBER_RESUMED (new): Fiber#resumed. Now this fiber is running. FIBER_SUSPENDED (new): Suspended by Fiber.yield. Not running. FIBER_TERMINATED: Terminated. Add sevral assertions to check consistency with these status. * cont.c (fiber_status_set): added to change status. * cont.c (FIBER_xxx_P): added to check fiber status. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fix stack storing for root fibers.ko12017-08-021-5/+5
| | | | | | | | | | | | | | | * cont.c (root_fiber_alloc): this function is called by fiber_current() and fiber_store(). fiber_current() should clear VM stack information in a fiber data because runnning thread knows stack information and has responsibility to manage it. However fiber_store() requires to remain VM stack information in a fiber data because the responsibility to manage VM stack is moved to the Fiber from the Thread (and switch to another fiber). * cont.c (root_fiber_alloc): save thread's fiber and root_fiber information. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* release VM stack properly.ko12017-08-021-0/+1
| | | | | | | | | | | | | | | | | | | * cont.c: r55766 change the handling method of Fiber's VM stack. Resumed Fiber points NULL as VM stack and running Thread has responsibility to manage it (marking and releasing). However, thread_start_func_2()@thread.c and thread_free()@vm.c doesn't free the VM stack if corresponding root Fiber is exist. This causes memory leak. [Bug #13772] * cont.c (root_fiber_alloc): fib->cont.saved_thread.ec.stack should be NULL because running thread has responsibility to manage this stack. * vm.c (rb_thread_recycle_stack_release): assert given stack is not NULL (callers should care it). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* introduce rb_fiber_t::first_proc.ko12017-06-281-6/+5
| | | | | | | | | | | * cont.c (rb_fiber_t): add rb_fiber_t::first_proc and do not use rb_thread_t::first_proc which should be thread local. [Bug #13689] * test/ruby/test_thread.rb: test for [Bug #13689]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59200 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* move fields to ec.ko12017-06-281-15/+7
| | | | | | | | | | * vm_core.h (rb_thread.h): move errinfo and trace_arg to rb_execution_context_t. * cont.c (fiber_switch, rb_cont_call): do not restore "trace_arg" here. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* move fields to ec.ko12017-06-281-11/+8
| | | | | | | | * vm_core.h (rb_thread_t): move root_lep, root_svar and ensure_list to rb_execution_context_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* introduce rb_thread_ptr() to replace GetThreadPtr().ko12017-06-281-4/+3
| | | | | | | | | | * vm_core.h (rb_thread_ptr): added to replace GetThreadPtr() macro. * thread.c (in some functions: use "target_th" instead of "th" to make clear that it is not a current thread. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* move storages to ec.ko12017-06-281-18/+12
| | | | | | | * vm_core.h (rb_thread_t): move storages to rb_execution_context_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* move several fields from rb_thread_t to rb_execution_context_t.ko12017-06-261-12/+9
| | | | | | | | * vm_core.h (rb_thread_t): move several fields which are copied at cont.c to rb_execution_context_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* copy ec on Fiber.ko12017-06-261-4/+8
| | | | | | | * cont.c (cont_restore_thread): on Fiber we only need to copy ec struct. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59176 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* add "FIBER_" prefix.ko12017-06-261-13/+13
| | | | | | | * cont.c (enum fiber_status): add "FIBER_" prefix for all names. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Do not store/restore Thread#status on fiber switching.ko12017-06-261-2/+2
| | | | | | | | | | * cont.c (cont_restore_thread): On Fiber switching, thread status shold be THREAD_RUNNABLE so that we don't need to store/restore this field. * cont.c (cont_save_thread): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59174 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* move "state" to rb_vm_tag.ko12017-06-231-2/+0
| | | | | | | | * vm_core.h (rb_thread_t::tag_state): move to "rb_vm_tag::state". Lifetime of "state" should be same as current tag. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* rename th->state to th->tag_state.ko12017-06-231-2/+2
| | | | | | | | * vm_core.h (rb_thread_t): rename rb_thread_t::state to tag_state to make it clear. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* use "enum ruby_tag_type" and TAG_NONE.ko12017-06-231-2/+2
| | | | | | | | | | | | | | | Return value of EXEC_TAG() is saved by "int state". Instead of "int", use "enum ruby_tag_type". First EXEC_TAG() value should be 0, so that define TAG_NONE (= 0) and use it. Some code used "status" instead of "state". To make them clear, rename them to state. We can change variable name from "state" to "tag_state", but this ticket doesn't contain it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* rb_execution_context_t: move stack, stack_size and cfp from rb_thread_tnormal2017-05-091-30/+30
| | | | | | | | | | The goal is to reduce rb_context_t and rb_fiber_t size by removing the need to store the entire rb_thread_t in there. [ruby-core:81045] Work-in-progress: soon, we will move more fields here. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* remove branches in dmark and dfree GC callbacksnormal2017-03-171-44/+41
| | | | | | | | | | | | | | | | | dmark and dfree callbacks are never called in gc.c for NULL DATA_PTR values, not even for zombie objects. * compile.c (ibf_loader_mark): remove branch for pointer validity * compile.c (ibf_loader_free): ditto * cont.c (cont_free): ditto * cont.c (fiber_free): ditto * dir.c (dir_free): ditto * ext/stringio/stringio.c (strio_mark): ditto * proc.c (binding_free): ditto * thread_sync.c (mutex_free): ditto * vm.c (thread_free): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fiber also has same issue. [Bug #13313]ko12017-03-141-1/+1
| | | | | | | | | * thread.c (rb_vm_proc_local_ep): added. * cont.c (rb_fiber_start): use rb_vm_proc_local_ep(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e