Граф коммитов

138 Коммитов

Автор SHA1 Сообщение Дата
nobu df54a2e6be * cont.c (fiber_set_stack_location), iseq.c (prepare_iseq_build),
node.c (dump_node): suppress warnings.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-16 02:46:16 +00:00
mame b664caeb78 * cont.c (fiber_switch): raise FiberError when returning to dead
fiber.  [ruby-dev:40833]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-09 17:32:45 +00:00
nobu d4fb3227f9 * cont.c (fiber_initialize_machine_stack_context): try to release
unnecessary fibers and retry to create.  based on a patch from
  masaya tarui at [ruby-dev:41230].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-09 07:28:17 +00:00
nobu 89cc2aef81 * cont.c (stackgrowdirection): removed duplicated code, use
STACK_UPPER macro instead.

* gc.h (STACK_DIR_UPPER): moved from thread_pthread.c.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-08 16:15:20 +00:00
marcandre 1dee5e34a3 * error.c: RDoc for subclasses of Exception. [ruby-core:28394]
* cont.c: ditto

* enumerator.c: ditto

* io.c: ditto

* math.c: ditto

* numeric.c: ditto

* proc.c: ditto

* re.c: ditto

* thread.c: ditto

* transcode.c: ditto. Thanks to Run Paint for some of the documentation.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-08 04:50:09 +00:00
usa 8db2aa1216 * cont.c: define FIBER_USE_NATIVE only when _WIN32_WINNT >= 0x0400
on Windows because Fiber APIs are supported only such building
  (and running) environments.
  [ruby-dev:41192]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-06 13:21:42 +00:00
nobu 106e2cc619 * cont.c (Init_Cont): th is used only when FIBER_USE_NATIVE.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-06 09:31:28 +00:00
ko1 26c48195af * cont.c (fiber_setcontext): Fix last commit.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27642 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-06 09:13:54 +00:00
ko1 c462c50d63 * cont.c: apply FIBER_USE_NATIVE patch. This patch improve
Fiber context switching cost using system APIs.  Detail comments
  are written in cont.c.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-05 18:37:37 +00:00
ko1 833cade2dc * vm_method.c (rb_unlink_method_entry, rb_sweep_method_entry):
added.  Unlinked method entries are collected to
  vm->unlinked_method_entry_list.  On the GC timing, mark all method
  entries which are on all living threads.  Only non-marked method
  entries are collected.  This hack prevents releasing living method
  entry.
  [Performance Consideration] Since this Method Entry GC (MEGC)
  doesn't occuer frequently, MEGC will not be a performance bottleneck.
  However, to traverse living method entries, every control frame push
  needs to clear cfp->me field.  This will be a performance issue
  (because pushing control frame is occurred frequently).
  Bug #2777 [ruby-dev:40457]
* cont.c (fiber_init): init cfp->me.
* gc.c (garbage_collect): kick rb_sweep_method_entry().
* method.h (rb_method_entry_t): add a mark field.
* vm.c (invoke_block_from_c): set passed me.
* vm.c (rb_thread_mark): mark cfp->me.
* vm_core.h (rb_thread_t): add a field passed_me.
* vm_core.h (rb_vm_t): add a field unlinked_method_entry_list.
* vm_insnhelper.c (vm_push_frame): clear cfp->me at all times.
* vm_insnhelper.c (vm_call_bmethod): pass me.
* bootstraptest/test_method.rb: add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-05 17:51:21 +00:00
mame f53d825447 * cont.c, vm_core.h, eval.c: because rb_protect must not be jumped by
callcc, revert r26407.  And rename trap_tag to protect_tag and
  change exception message (across trap -> across stack rewinding
  barrier).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-01-25 18:22:58 +00:00
mame 24f5161c39 * cont.c (rb_cont_call, cont_restore_1): remove trap_tag check because
it seems not to make sense.  [ruby-dev:40121]

* vm_core.h, eval.c (rb_protect): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-01-25 13:22:16 +00:00
nobu fec2ed5f4d * cont.c (rb_fiber_start): fixed unconditional test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-03 23:19:33 +00:00
akr b9e0294eda fix typos.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-03 17:46:28 +00:00
wanabe 2c2fb9c5ec * cont.c (fiber_free): don't free unallocated local_storage. see #1325.
* cont.c (cont_init): clear local_storage not to use current thread's.

* cont.c (fiber_t_alloc, root_fiber_alloc): link itself always for
  a case that fiber_link_remove() is called before fiber_link_join().

* cont.c (fiber_init): clear cont->vm_stack and th->stack before
  root_fiber_alloc() in rb_fiber_current().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-02 09:35:43 +00:00
wanabe 71f0685fe3 revert r25623
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25625 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-02 01:04:31 +00:00
wanabe b23461b5dc * cont.c (fiber_free): don't free unallocated local_storage. see #1325.
* cont.c (cont_init): clear local_storage not to use current thread's.

* cont.c (fiber_t_alloc, root_fiber_alloc): link itself always for
  a case that fiber_link_remove() is called before fiber_link_join().

* cont.c (fiber_init): don't join half-baked fiber.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-01 23:27:12 +00:00
nobu fe1ce93f52 * compile.c, cont.c, gc.c, insns.def, iseq.c, iseq.h, process.c,
thread.c, vm.c, vm_core.h, vm_dump.c, vm_eval.c,
  vm_insnhelper.c, vm_method.c, template/insns_info.inc.tmpl,
  tool/instruction.rb: fixed types.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-21 20:58:26 +00:00
nobu 2d8a79fa47 * cont.c, proc.c: added rdoc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25016 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-21 11:06:32 +00:00
nobu 3a7c1e25c4 * cont.c (cont_new, cont_capture, fiber_t_alloc): needs already
running thread.  cf. [ruby-core:25681]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-21 01:13:24 +00:00
nobu af4a989a98 * cont.c (cont_memsize, fiber_memsize): constified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-09 02:26:06 +00:00
nobu cd4fc5be39 * include/ruby/ruby.h (rb_data_type_struct): constified dsize.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24802 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-09 02:22:08 +00:00
nobu 85cc4ff62a * cont.c (cont_memsize): fixed wrong expression on IA64.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24800 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-09 02:07:50 +00:00
nobu f7f3f9bf76 * cont.c (cont_restore_1, rb_cont_call): should be Fiber.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24799 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-09 01:51:49 +00:00
nobu 055fb06700 * cont.c (cont_data_type, fiber_data_type): typed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-08 15:27:31 +00:00
nobu 6c743b0e5a * cont.c (cont_capture, fiber_store): reraise transferred error.
* cont.c (fiber_switch): transfers dead fiber error to the previouse
  or root fiber if the current fiber is dead.  [ruby-core:23651]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-01 02:21:31 +00:00
nobu 99945ed664 * cont.c: fixed types.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-01 01:11:04 +00:00
nobu 12d2c8ba41 stripped trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-22 14:23:33 +00:00
ko1 c5d7d78dae * cont.c (rb_fiber_alive_p): fix to return true instead of 1.
[ruby-dev:37991]
* test/ruby/test_fiber.rb: add a test for Fiber#alive?



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22274 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-13 06:04:25 +00:00
mame 495293a136 * cont.c (cont_mark, cont_capture, cont_restore_1): use #else instead
of #elif.  a patch from NISHIMATSU Takeshi <t_nissie at yahoo.co.jp>
  in [ruby-list:45856].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-05 16:13:54 +00:00
nobu 845103b751 * cont.c (rb_fiber_current), dln.c (dln_print_undef, dln_undefined),
eval.c (rb_iterator_p, rb_need_block), load.c: (Init_load), ruby.c
  (uscore_get, rb_f_chop), st.c (stat_col), signal.c
  (rb_signal_buff_size, ruby_sig_finalize), thread.c
  (rb_thread_sleep_forever, rb_thread_sleep_deadly, rb_thread_alone):
  protoized.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21929 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-01 12:51:44 +00:00
nobu 11c00acf8e * cont.c (ruby_Init_{Continuation_body,Fiber_as_Coroutine}): prefixed
with ruby_ to export.

* ext/continuation/continuation.c, ext/fiber/fiber.c: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-20 07:17:28 +00:00
ko1 cf23d0f0f0 * vm.c: add a prefix "rb_" to exposed functions
vm_get_ruby_level_next_cfp(), rb_vm_make_env_object(),
  vm_stack_to_heap(), vm_make_proc(), vm_invoke_proc(),
  vm_get_sourceline(), vm_cref(), vm_localjump_error(),
  vm_make_jump_tag_but_local_jump(), vm_jump_tag_but_local_jump().
  This changes may affect only core because most of renamed functions
  require a pointer of not-exposed struct such as rb_thread_t or NODE.
  In short, they are core functions.
* cont.c, eval.c, eval_intern.h, load.c, proc.c, thread.c,
  vm_core.h, vm_dump.c, vm_eval.c, vm_exec.c, vm_insnhelper.c:
  ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-19 02:38:11 +00:00
nobu 8ae8afa649 * cont.c (cont_restore_0): padding size doesn't need to be large
if alloca is used.  suppress warnings.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-17 02:11:38 +00:00
takano32 aa87e280ea * cont.c: fix prototype declare of register_stack_extend
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-14 05:43:49 +00:00
ko1 d46fcaf485 * cont.c (cont_restore_1): should not be inlined.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21414 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-10 10:07:21 +00:00
nobu 53716bfce7 * cont.c (cont_restore_0): streamlined to ensure O(1) time. based on
a patch by Brent Roman <brent AT mbari.org>.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-06 10:09:54 +00:00
matz 1487d9743b * cont.c: small RDoc fix mentioned from <radek.bulat at gmail.com>
in [ruby-core:20921].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21145 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-28 22:16:19 +00:00
yugui 5736312715 * cont.c: rdoc for Fiber. patch by Muhammad Ali.
[ruby-core:20894]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-27 00:25:47 +00:00
nobu fe867f47ac * cont.c (fiber_status), template/insns.inc.tmpl (ruby_vminsn_type),
vm_insnhelper.h (BOP): ISO C forbids comma at end of enumerator
  list.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-09 04:25:54 +00:00
nobu a918afe05e * cont.c (rb_fiber_start): calls with exact argument number.
[ruby-core:20088]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-01 03:00:48 +00:00
matz 776af67b28 * cont.c (fiber_alloc): separate allocation and initialization.
allow subclass to override #initialize.   [ruby-core:20086]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-28 15:23:09 +00:00
mame 5ecc2ee022 * cont.c (cont_mark, cont_capture, cont_restore_1): speed up
continuation by copying only valid YARV stack.  [ruby-dev:37106]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-18 16:19:37 +00:00
ko1 8a0d53ac2b * cont.c: separate data structure between rb_fiber_t and
rb_context_t (rb_fiber_t includes rb_context_t).
  rb_fiber_t has double linked list of fibers in same threads.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-22 15:12:07 +00:00
shyouhei 3e69e83a62 * include/ruby/ruby.h (enum ruby_special_consts): ISO C forbids
comma at end of enumerator list

 	* include/ruby/ruby.h (enum ruby_value_type): ditto.

	* eval_intern.h (enum): ditto.

	* vm_core.h (enum rb_thread_status): ditto.

	* parse.y (enum lex_state_e): ditto.

	* parse.y (enum string_type): ditto.

	* process.c (enum): ditto.

	* ruby.c (enum dump_flag_bits): ditto.

	* ruby.c (enum disable_flag_bits): ditto.

	* compile.c (iseq_link_element): ditto

	* debug.c (union): ditto.

	* cont.c (enum context_type): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-01 08:27:58 +00:00
ko1 72ba13aa8e * array.c, bignum.c, cont.c, dir.c, dln.c, encoding.c, enumerator.c,
enumerator.c (enumerator_allocate), eval_jump.c, file.c, hash.c,
  io.c, load.c, pack.c, proc.c, random.c, re.c, ruby.c, st.c,
  string.c, thread.c, thread_pthread.c, time.c, util.c, variable.c,
  vm.c, gc.c:
  allocated memory objects by xmalloc (ruby_xmalloc) should be
  freed by xfree (ruby_xfree).
* ext/curses/curses.c, ext/dbm/dbm.c, ext/digest/digest.c,
  ext/gdbm/gdbm.c, ext/json/ext/parser/parser.c,
  ext/json/ext/parser/unicode.c, ext/openssl/ossl_cipher.c,
  ext/openssl/ossl_hmac.c, ext/openssl/ossl_pkey_ec.c,
  ext/sdbm/init.c, ext/strscan/strscan.c, ext/zlib/zlib.c:
  ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-08 10:01:40 +00:00
matz 1165304a5d * cont.c (cont_restore_0): dynamic stack direction code should be
consistent with static one.  [ruby-talk:301152]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-08 22:48:38 +00:00
nobu 2bbf4707f7 * cont.c (cont_restore_0): fixed typo. [ruby-core:15821]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-07 11:30:07 +00:00
akr 6cdef2dc7e * $Date$ keyword removed to avoid inclusion of locale dependent
string.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-06 15:49:38 +00:00
ko1 5f0b8afb97 * vm_core.h, thread.c, cont.c: add RUBY_VM_SET_INTERRUPT(),
RUBY_VM_SET_TIMER_INTERRUPT(), RUBY_VM_INTERRUPTED().
* thread.c, thread_pthread.c, thread_win32.c: fix to ignore time slice
  event until sleep.
* bootstraptest/test_thread.rb: add a test for time limited join test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-25 04:16:06 +00:00
ko1 9f34b73009 * cont.c, vm.h: fix to support sparc machine.
a patch from Yusuke ENDOH <mame AT tsg.ne.jp>



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14550 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-23 19:03:23 +00:00
ko1 314bef7ef1 * insnhelper.ci, vm.c, vm_core.h: change interface of
vm_invoke_block() to specify block ptr.  [ruby-talk:266422]
* cont.c, eval_jump.ci, insns.def, proc.c, signal.c, thread.c:
  apply above change.
* bootstraptest/test_knownbug.rb: move fixed bug.
* bootstraptest/test_block.rb: ditto. and add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14356 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-20 07:07:35 +00:00
ko1 9f6de20f58 * cont.c: add rb_context_t#type.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-09 01:11:49 +00:00
ko1 68bcdf4c7e * cont.c (cont_free): check Fiber or Continuation.
* bootstraptest/test_knownbug.rb: remove a fixed test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13644 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-06 07:30:02 +00:00
ko1 534d057e58 * cont.c: Thread local storage should be fiber local.
* bootstraptest/test_knownbug.rb, test/ruby/test_fiber.rb:
  move a fixed test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-28 19:04:45 +00:00
ko1 e826eec433 * cont.c: Fiber as SemiCoroutine on default. [ruby-core:12146]
* ext/fiber/fiber.c: enable Fiber#transfer.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-26 10:26:35 +00:00
ko1 d55c0f5382 * cont.c: fix to remove Fiber.new until fiber.so is not loaded.
* test/ruby/test_continuation.rb: fix to use resume.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-26 03:31:20 +00:00
ko1 c2a734ea99 * cont.c: rename FIBER_STACK_SIZE to FIBER_VM_STACK_SIZE.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13270 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-25 08:51:59 +00:00
ko1 977d66ec99 * cont.c: separate Continuation and Fiber from core.
* ext/continuation/*, ext/fiber/*: ditto.
* include/ruby/ruby.h: remove rb_cFiber.
* include/ruby/intern.h: add the rb_fiber_new() declaration.
* enumerator.c (next_init): fix to use rb_fiber_new().
* test/ruby/test_enumerator.rb: remove next? tests.
* test/ruby/test_continuation.rb: add a require 'continuation'.
* test/ruby/test_fiber.rb: add a require 'fiber'.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-25 02:03:44 +00:00
nobu 4af553f1e7 * cont.c (rb_cont_call, fiber_switch, rb_fiber_resume, rb_fiber_yield):
suppress warnings.

* cont.c (rb_fiber_start): change on non-volatile variable between
  setjmp and longjmp may not has an effect.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-23 07:55:37 +00:00
ko1 c5e4cd0638 * cont.c: add Fiber#resume and Fiber.yield.
and Fiber::Core class to realize Coroutine.
* include/ruby/intern.h: declare rb_fiber_yield(), rb_fiber_resume(),
* enumerator.c: use above api.
* test/ruby/test_fiber.rb: fix and add tests for above changes.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13130 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-21 18:51:39 +00:00
ko1 3efcb087a3 * cont.c (rb_fiber_m_yield): added. use this function
for Fiber#yield instead of rb_fiber_yield.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12946 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-15 17:56:22 +00:00
matz 57b0b6c7b1 * cont.c (rb_fiber_yield): change argument ordering. export.
* cont.c (rb_fiber_current): export

* include/ruby/intern.h: export several functions from cont.c.

* enumerator.c (enumerator_next): new method to implement external
  iterator (generator) using fiber.

* enumerator.c (enumerator_next_p): new method to check whether
  any element is left in the generator sequence.

* enumerator.c (enumerator_rewind): a new method to rewind the
  generator sequence.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12891 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-06 16:41:17 +00:00
akr 0886a4d8a0 * configure.in: add --enable-valgrind.
* gc.h (SET_MACHINE_STACK_END): new macro to replace
  rb_gc_set_stack_end.  it find out accurate stack boundary by
  asm using gcc on x86.

* thread.c (rb_gc_set_stack_end): don't define if asm-version
  SET_MACHINE_STACK_END is available.

* gc.c (mark_current_thread): extracted from garbage_collect.
  it use SET_MACHINE_STACK_END to not scan out of stack area.
  it notify conservative GC information to valgrind if
  --enable-valgrind.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-14 07:19:59 +00:00
ko1 6b6bf4dd48 * blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
  use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
  rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
  from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 04:25:46 +00:00
usa a6ae274c3b * cont.c (cont_restore_1): workaround for x64-mswin64's SEH.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12725 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-08 17:19:01 +00:00
ko1 0d0ef6eccc * yarvcore.h: rename rb_control_frame_t#magic to flag.
* vm.h: add VM_FRAME_TYPE() and VM_FRAME_FLAG().
* cont.c, insnhelper.ci, insns.def, vm.c, vm_dump.c,
  vm_evalbody.ci, yarvcore.c: apply above changes.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 10:49:45 +00:00
ko1 0e5360b2e4 * cont.c (cont_save_machine_stack): clear saved_thread.machine_stack*.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-03 04:53:05 +00:00
ko1 9315740101 * cont.c (rb_fiber_s_new): revert initializing VM stack.
* yarvcore.c (th_init2): ditto.
* vm.c, vm.h: fix to stop using Qundef on VM stack.  According to
  this change, VM stack should not include Qundef value.
* insns.def (putundef): removed.
* compile.c (iseq_compile_each): ditto.
* eval.c (eval): fix spacing.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-26 06:14:44 +00:00
ko1 1a49d91fdd * cont.c (rb_fiber_s_new): fix to clear rb_thread_t#tag.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-25 18:47:03 +00:00
ko1 702e431f1b * cont.c (rb_fiber_s_new), yarvcore.c (th_init2): fix to clear
VM stack ([ruby-dev:31046]).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-25 18:39:23 +00:00
ko1 4bdb5ced9a * gc.h: add RUBY_ prefix to debug macros.
* cont.c, proc.c, yarvcore.c,
* gc.c: define ruby_gc_debug_indent variable to debug mark/free.
* vm.c, insnhelper.ci: rename some functions to vm_* or rb_vm_*.
  move some functions, definitions, declarations to suitable files.
* eval.c, yarvcore.h, eval_error.ci, insnhelper.ci: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-25 02:44:20 +00:00
ko1 97ba019c94 * vm.c: some refactoring.
* rename th_* to vm_*.
  * remove unused variables functions.
  * add prototypes.
* blockinlining.c, compile.c, cont.c, eval.c, eval_intern.h,
  eval_jump.h, eval_load.c, inits.c, insns.def, iseq.c, parse.y,
  proc.c, process.c, signal.c, thread.c, vm.c, vm_dump.c,
  vm_evalbody.ci, yarvcore.c, yarvcore.h: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-24 15:42:41 +00:00
ko1 31ac946975 * cont.c (rb_cont_call): forbid cross fiber continuation call.
* test/ruby/test_fiber.rb: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12542 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-15 03:20:13 +00:00
akr 3cd5af52e9 * eval_load.c (Init_load): delay allocating an array for rb_load_path
to avoid GC problem in very early stage.
  (RUBY_GC_STRESS causes GC in such stage.)

* variable.c (rb_gc_mark_global_tbl): rb_global_tbl may be 0 in
  very early stage.

* thread.c (thread_cleanup_func) [IA64]: clear register stack position.
  (thread_start_func_2) [IA64]: record the beginning of register
  stack using extra argument.
  (rb_gc_save_machine_context) [IA64]: record the end of register
  stack.

* gc.c [IA64] (SET_STACK_END): record the end of register stack.
  (garbage_collect) [IA64]: use recorded register stack area for
  GC marking.
  (yarv_machine_stack_mark) [IA64]: GC mark from the register stack
  area.

* yarvcore.c [IA64] (rb_gc_register_stack_start): defined.
  (Init_VM): store th->self on stack to fix GC problem.
  (Init_yarv) [IA64]: initialize the beginning of register stack.

* yarvcore.h (struct rb_thread_struct) [IA64]: new members for
  register stack area.

* thread_pthread.ci (thread_start_func_1) [IA64]: call
  thread_start_func_2 with the end of register stack.

* cont.c (struct rb_context_struct) [IA64]: new members for register
  stack area.
  (cont_mark) [IA64]: GC mark from register stack area.
  (cont_free) [IA64]: free saved register stack.
  (cont_save_machine_stack) [IA64]: record the position and contents
  of the register stack.
  (cont_capture): store cont->self on stack to fix GC problem.
  (cont_restore_1) [IA64]: restore the register stack.
  [IA64] (register_stack_extend): new function.
  (cont_restore_0) [IA64]: call register_stack_extend instead of
  cont_restore_1.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-14 08:35:20 +00:00
nobu 2b592580bf * include/ruby: moved public headers.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-10 03:06:15 +00:00
ko1 8620de6b04 * cont.c (cont_restore_1): fix to check root fiber [ruby-dev:30911].
* test/ruby/test_fiber.rb: add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-07 03:48:13 +00:00
ko1 d80e7373cf * cont.c (cont_new): add debug message.
* cont.c (cont_restore_1): copy stack information from fiber.
* cont.c (rb_fiber_s_new): fix to mark created fiber.
* test/ruby/test_fiber.rb: add some tests around Thread and Fiber.
* yarvcore.c (thread_free): fix to skip freeing stack if root fiber
  is available.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-06 18:19:42 +00:00
ko1 ed88975237 * eval_intern.h, eval.c (ruby_init): remove POP_TAG_INIT().
* cont.c (rb_fiber_start): remove zero-clearing tag.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-06 16:04:02 +00:00
ko1 15b31b0d80 * cont.c (rb_cont_call): forbid calling dead fiber with
Cotinuation#call.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-06 01:55:09 +00:00
ko1 64ffdb4440 * cont.c (rb_fiber_start): clear th->tag and check error to fix
[ruby-dev:30888] and [ruby-dev:30889].
* eval_intern.h: fix rb_fiber_start() prototype.
* test/ruby/test_fiber.rb: add tests for above.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12443 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 17:55:07 +00:00
ko1 6b3ef2249c * cont.c (Fiber#pass): rename to Fiber#yield. Block parameter
of fiber body receive first yield values.
  e.g.: Fiber.new{|x| p x}.yield(:ok) #=> :ok
* cont.c: rename rb_context_t#retval to rb_context_t#value.
* test/ruby/test_fiber.rb: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12425 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-02 07:48:29 +00:00
ko1 284565992f * cont.c (cont_capture): store all local variables in heap
([ruby-dev:30832]).
* vm.c (th_stack_to_heap): added.
* test/ruby/test_continuation.rb: add a test for above.
* eval_intern.h (th_get_ruby_level_cfp): fix to clean code.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-05-30 05:56:13 +00:00
ko1 d64609463f * cont.c: fix bug around Continuation and Fiber.
* test/ruby/test_continuation.rb: add tests for Continuation.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-05-29 01:59:53 +00:00
nobu 7f41ff0ff6 * cont.c: fixed a function name.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-05-28 01:25:55 +00:00
ko1 57062d91b9 * cont.c: support Fiber. Check test/ruby/test_fiber.rb for detail.
Fiber is known as "Micro Thread", "Coroutine", and other terms.
  At this time, only Fiber#pass is supported to change context.
  I want to know more suitable method name/API for Fiber (... do you
  know more suitable class name instead of Fiber?) as "suspend/resume",
  "call", "yield", "start/kick/stop/restart", ....
* eval.c, eval_intern.h, thread.c, yarvcore.c, yarvcore.h: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-05-27 19:12:43 +00:00
ko1 e4aa7208e5 * cont.c: check across trap violation.
* eval.c, yarvcore.h: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12382 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-05-24 03:08:13 +00:00
ko1 7c4ff2d332 * cont.c: support callcc which everyone love.
incomplete. please give me bug reports.
* common.mk, inits.c, thread.c: ditto.
* yarvcore.c: export thread_mark().
* yarvcore.h: disable value cache option.
* eval_intern.h: set th_get_ruby_level_cfp to inline.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-05-23 22:52:19 +00:00