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

375 Коммитов

Автор SHA1 Сообщение Дата
nobu bdcb8fd07e * gc.c (STACK_LEVEL_MAX, ruby_stack_length): returns size_t.
[ruby-core:18207]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-09 23:56:17 +00:00
nobu d8353d6b6e * gc.c (run_final): runs finalizers with the object terminated.
* gc.c (rb_gc_call_finalizer_at_exit): keeps finalized objects from
  linking to freelist.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-06 20:06:05 +00:00
nobu 7d072e2ba4 * gc.c (chain_finalized_object): deletes finalizers to be invoked from
finalizer_table.

* gc.c (rb_gc_call_finalizer_at_exit): warns when could not invoke
  finalizers.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18394 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-06 12:25:47 +00:00
nobu faf2541c2b * gc.c (rb_gc_call_finalizer_at_exit): self-referencing finalizers
cannot be invoked.  [ruby-dev:35681]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-06 11:48:30 +00:00
mame 57b9e18d71 * gc.c (allocate_heaps, assign_heap_slot, rb_newobj_from_heap):
reset during_gc before raising NoMemoryError.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-01 12:36:39 +00:00
ko1 845e5766dc * gc.c (gc_mark_children, obj_free): T_DEFERRED should not be appear.
* gc.c (gc_sweep, finalize_list): fix to decrement heap_slot#limit
  after executing finalizer.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-27 13:08:02 +00:00
ko1 60be3dc560 * include/ruby/ruby.h: add a type T_DEFERRED.
* gc.c: fix deferred finalizer system.  finalize processes of
  T_DATA and T_FILE are executed after gc process.
  And fix to use BUILTIN_TYPE() instead of seeing flag.
* thread.c, vm_core.h: add RUBY_VM_SET_FINALIZER_INTERRUPT()
  and check intterupt_flag at rb_thread_execute_interrupts().
* thread.c (mutex_mark): fix to mark next_mutex.
* vm.c (rb_thread_mark): fix to mark keeping_mutexes.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18231 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-27 05:59:32 +00:00
nobu f421f68484 * gc.c (gc_sweep, obj_free, run_final): defer finalizers of IO and
Data.  [ruby-dev:35578]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-25 14:48:12 +00:00
nari 52f780c07f * gc.c: revert. before lazy sweep.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-05 07:15:41 +00:00
nari 5b72919469 * gc.c (garbage_collect_force): sweep is completely ended.
* gc.c (os_obj_of): invoke garbage_collect_force() when freelist none.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17867 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-04 02:18:17 +00:00
nobu bb350b04e5 * eval.c (Init_eval), gc.c (Init_GC), proc.c (Init_Proc): freeze
messages of preallocated special exceptions also.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-02 22:02:58 +00:00
nobu 7f637ab96f * gc.c (rb_during_gc): VALUE cache is irrelevant.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-02 19:39:33 +00:00
suke 8519afcb41 * gc.c: add rb_during_gc(). based on a patch from arton <artonx AT
yahoo.co.jp> at [ruby-dev:35313].   

* include/ruby/intern.h: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-02 15:18:44 +00:00
nari 8bccb5f266 *gc.c (gc_lazy_sweep) : use lazy sweep algorithm for response performance gain.
(garbage_collect_force) : mark and lazysweep invoke, after erasing all mark.
 (GC_NOT_LAZY_SWEEP) : not lazy sweep flag. for debug.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17788 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-02 00:49:10 +00:00
nobu 01a025d2d7 * gc.c (rb_newobj): abort GC phase before rb_bug.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-30 15:49:13 +00:00
nobu ac388541c4 * gc.c (chain_finalized_object): should not delete from finalizer
table until run.

* gc.c (rb_gc_call_finalizer_at_exit): deferred_final_list may be
  empty first.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17737 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-30 13:12:49 +00:00
nobu d0f211f394 * gc.c (gc_finalize_deferred): allow object allocation in finalizers.
* gc.c (rb_gc_call_finalizer_at_exit): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-30 09:57:07 +00:00
usa eedb3dc3a3 * gc.c (rb_newobj): prohibit call of rb_newobj() during gc when
USE_VALUE_CACHE is not defined (normal case).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17730 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-30 05:42:34 +00:00
akr 340cd503a7 * include/ruby/ruby.h (struct RRegexp): new field usecnt. replace
str and len by src.

* gc.c (gc_mark_children): mark src field of regexp.
  (obj_free): don't free str field.

* re.c (REG_BUSY): removed.
  (rb_reg_initialize): prohibit re-initialize regexp.
  (rb_reg_search): use usecnt to prevent freeing regexp currently
  using.  this prevents SEGV by:
    r = /\A((a.)*(a.)*)*b/
    r =~ "ab" + "\xc2\xa1".force_encoding("euc-jp")
    t = Thread.new { r =~ "ab"*8 + "\xc2\xa1".force_encoding("utf-8")}
    sleep 0.2
    r =~ "ab"*8 + "\xc2\xa1".force_encoding("euc-jp")



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-28 12:25:45 +00:00
shyouhei 87d053f000 * gc.c (rb_newobj): prohibit call of rb_newobj() during gc.
a patch from Sylvain Joyeux in [ruby-core:12099].



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17419 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-18 14:09:33 +00:00
nobu 9b45b336ee * vm_core.h (rb_vm_t), vm.c (rb_vm_mark): moved preallocated special
exceptions.

* eval.c (Init_eval), gc.c (Init_GC), proc.c (Init_Proc): freeze
  preallocated special exceptions.

* eval.c (rb_longjmp): duplicate the thrown exception to set backtrace
  if it was frozen.

* gc.c (rb_memerror): raise nomem_error without backtrace if failed to
  make backtrace.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-15 09:17:06 +00:00
nobu fc3c60f608 * gc.h (STACK_UPPER): moved from gc.c
* thread.c, thread_{pthread,win32}.c (ruby_init_stack,
  ruby_thread_init_stack): moved stack initialization from gc.c.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-14 02:59:19 +00:00
akr 436b02b332 * gc.c (ruby_initial_gc_stress): defined.
(ruby_initial_gc_stress_ptr): defined.

* debug.c (set_debug_option): use ruby_initial_gc_stress_ptr for
  gc_stress option.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17154 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-13 22:57:41 +00:00
nobu 4641b80166 * gc.c (ruby_gc_stress): moved to rb_objspace_t.
* gc.c (gc_stress_get, gc_stress_set): VM local attribute.

* signal.c (sigsegv): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17153 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-13 15:09:22 +00:00
nobu 32ef17fe7b * gc.c (rb_memerror): exit with EXIT_FAILURE instead of magic number.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-13 05:24:40 +00:00
nobu 8477860694 * gc.c (ruby_stack_check): STACK_LENGTH should be less than
STACK_LEVEL_MAX.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-13 05:19:01 +00:00
nobu 10bfa5d49f * include/ruby/intern.h (Init_stack): make to call ruby_init_stack.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17036 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-09 00:54:23 +00:00
ko1 a99140631c * gc.c: add a build option "CALC_EXACT_MALLOC_SIZE".
This option enables to calculate exact size of current
  allocated size by malloc().  You can access these information
  with GC.malloc_allocated_size and GC.malloc_allocations.
  This option consume additional memory as a header of each memory
  object.  This option also helps to find out xmalloc()/xfree()
  consistency.  If you get trouble with this option, some extension
  using "free()" instead of "xfree()".
  This options is disabled by default.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17018 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-08 10:27:06 +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
akr f6ec71fc4c * gc.c (count_objects): clear hash after counting objects.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16853 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-06 06:05:44 +00:00
mame 5e9b9ff9cb * gc.c (rb_objspace_alloc): this function is needed only when
ENABLE_VM_OBJSPACE macro is defined.

* vm.c: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-05 14:41:41 +00:00
akr 18d4c1f044 * gc.c (os_obj_of): heaps may be modified in yield.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-05 13:52:02 +00:00
akr fa58f951cf * gc.c (count_objects): clear given hash.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-31 14:03:23 +00:00
nobu 0343750b62 * include/ruby/ruby.h (PRI[diouxX]VALUE): printf format for VALUE.
* gc.c (assign_heap_slot): suppress a warning.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16487 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-20 02:36:09 +00:00
ko1 385f0e8af6 * vm.c, insns.def, eval.c, vm_insnhelper.c: fix CREF handling.
VM value stack frame of block contains cref information.
  (dfp[-1] points CREF)
* compile.c, eval_intern.h, eval_method.c, load.c, proc.c,
  vm_dump.h, vm_core.h: ditto.
* include/ruby/ruby.h, gc.c: remove T_VALUES because of above
  changes.
* bootstraptest/test_eval.rb, test_knownbug.rb: move solved test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-19 03:08:50 +00:00
akr 430cabfad8 * gc.c (ruby_vm_xmalloc): increase malloc_increase only if malloc
succeeds.  failed malloc size can be huge.  it may increase
  malloc_limit too big which cause less GC and memory full.
  (ruby_vm_xrealloc): ditto.
  (rb_objspace): make params.limit and params.increase size_t.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-12 06:28:43 +00:00
akr 2c012e01db * gc.c (assign_heap_slot): fix condition for number of objects in
a heap.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16375 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-12 03:30:34 +00:00
yugui 7c104f88eb * gc.c (assign_heap_slot): put the binary-search routine in order.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-12 02:15:55 +00:00
akr e389ce0676 * include/ruby/ruby.h (SIZET2NUM): new macro.
(NUM2SIZET): new macro.

* gc.c (struct rb_objspace): use size_t for increment, length and
  used for 64bit.
  (allocate_heaps): ditto.
  (assign_heap_slot): ditto.
  (set_heaps_increment): ditto.
  (gc_mark_all): ditto.
  (is_pointer_to_heap): ditto.
  (free_unused_heaps): ditto.
  (gc_sweep): ditto.
  (os_obj_of): ditto.
  (rb_gc_call_finalizer_at_exit): ditto.
  (count_objects): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16356 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-11 05:44:36 +00:00
yugui e45b87f282 * gc.c (gc_count): rdoc corrected.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-10 23:02:30 +00:00
akr 3e8e963837 * gc.c (set_heaps_increment): fix memory allocation strategy by
determining heaps_inc from heaps_used, not objects_delta.
  (struct rb_objspace): delta removed.  change increment, length and
  used to long for LP64.
  (objects_delta): removed.
  (allocate_heaps): add next_heaps_length argument.
  (init_heap): renamed from add_heap.
  (garbage_collect): use heaps_increment in dont_gc.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16289 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-04 17:25:38 +00:00
ko1 3de80833a2 * gc.c (gc_count): add a GC.count method. This method returns
a GC invoking count.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-27 06:28:08 +00:00
nobu 09007ccbaa * vm_core.h (rb_vm_t), gc.c (rb_objspace, rb_newobj), vm.c
(Init_BareVM): per-VM object space support, which is disabled now.

* gc.c (rb_objspace_alloc), vm.c (Init_BareVM): should not use ruby
  malloc here.

* gc.c (garbage_collect, etc): performance improvement by passing the
  reference instead of refering the global variable in each functions.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-27 03:20:35 +00:00
nobu c7451eb725 * error.c (builtin_types), gc.c (count_objects): added Complex and
Rational.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16203 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-26 08:42:34 +00:00
ko1 9d0a5d8e96 * include/ruby/ruby.h, gc.c: remove T_BLOCK.
* include/ruby/ruby.h: re-number T_xxx.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-26 08:32:23 +00:00
matz 4d93af26df * gc.c (free_unused_heaps): preserve last used heap segment to
reduce malloc() call.

* gc.c (HEAP_SIZE): use smaller heap segment (2K) for more chance
  to be freed.  based on patch from authorNari <authornari at gmail.com>.

* gc.c (rb_newobj_from_heap): eventually allocate heap segments.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16194 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-25 09:03:32 +00:00
usa fd8734a64d * gc.c (ruby_xmalloc): use size_t for malloc argument instead of long.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-20 23:55:09 +00:00
nobu 6b5e24a61a * gc.c (rb_gc_mark_locations): get rid of underflow.
* gc.c (mark_current_machine_context): check if the main thread stack
  position may shink under the intialized position.  [ruby-core:16436]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-18 08:37:50 +00:00
nobu b2dde8243b * gc.c (Init_stack): use ruby_init_stack. [ruby-dev:34350]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-14 03:52:27 +00:00
nobu 01f468d138 * gc.c (rb_objspace_t): packed globals. [ruby-dev:34348]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15995 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-14 03:47:04 +00:00