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

971 Коммитов

Автор SHA1 Сообщение Дата
ko1 5cd2fb2ebb * gc.c (gc_lazy_sweep): remove heap_increment() here because heap_inc
may be 0.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42561 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-15 08:46:53 +00:00
tarui da3d79d203 * gc.c (gc_marks_test): inhibit gc for st's operation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-12 14:09:34 +00:00
akr 25336fa7c1 * bignum.c (rb_big_realloc): Use VALGRIND_MAKE_MEM_UNDEFINED to
declare undefined memory area.
  (bignew_1): Ditto.

* internal.h (VALGRIND_MAKE_MEM_DEFINED): Moved from gc.c
  (VALGRIND_MAKE_MEM_UNDEFINED): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42392 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-06 03:26:34 +00:00
ko1 33ebcb0538 * array.c, gc.c: move ary_unprotect_logging() into
rb_gc_unprotect_logging() which is general version
* include/ruby/ruby.h: add USE_RGENGC_LOGGING_WB_UNPROTECT
  to enable.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42151 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-24 09:42:43 +00:00
ko1 3742192919 * gc.c (gc_before_sweep): fix spacing.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42132 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-23 07:15:34 +00:00
ko1 511e155e24 * gc.c (heap_get_freeobj): clear slot->freelist here.
This means that this slot doesn't have any free objects.
  And store this slot with objspace->heap.using_slot.
* gc.c (gc_before_sweep): restore objspace->freelist
  into objspace->heap.using_slot->freelist.
  This means that using_slot has free objects which are
  pointed from objspace->freelist.
* gc.c (gc_slot_sweep): do not need to clear slot->freelist.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-23 07:02:44 +00:00
ko1 4132ac3762 * gc.c (gc_slot_sweep): need to add empty RVALUE as freeobj.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-22 01:10:46 +00:00
nobu db16068ce0 gc.c: suppress warning
* gc.c (heap_assign_slot): suppress implicit conversion warning.
  delta is not greater than sizeof(RVALUE).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42074 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-19 13:31:03 +00:00
ko1 79d557ffcd * gc.c: declare type_name() at the beggining of file.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-19 13:00:23 +00:00
ko1 344835a754 * gc.c, internal.h (rb_gc_writebarrier_remember_promoted): add a new
function to remember an specified object. This api is only
  experimental (strongly depend on WB/rgengc strategy).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42062 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-19 06:11:09 +00:00
ko1 5c088cf703 * gc.c: rename gc related functions with prefix "gc_".
* before_gc_sweep() -> gc_before_sweep().
* after_gc_sweep()  -> gc_after_sweep().
* lazy_sweep()      -> gc_lazy_sweep().
* rest_sweep()      -> gc_rest_sweep().
* slot_sweep()      -> gc_slot_sweep().
* gc.c: rename a heap management function with prefix "heap_".
* get_freeobj() -> heap_get_freeobj().
* gc.c: rename markable_object_p() to is_markable_object().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-17 23:19:38 +00:00
ko1 a3b6aeba68 * gc.c: rename heap management functions with prefix "heap_".
* allocate_sorted_array() -> heap_allocate_sorted_array().
* slot_add_freeobj()      -> heap_slot_add_freeobj().
* assign_heap_slot()      -> heap_assign_slot().
* add_heap_slots()        -> heap_add_slots().
* init_heap()             -> heap_init().
* set_heap_increment()    -> heap_set_increment().
* gc.c (initial_expand_heap): inlined in rb_gc_set_params().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42026 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-17 08:25:11 +00:00
ko1 caa14925cc * gc.c: catch up last changes for debugging/checking mode.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-17 07:01:19 +00:00
ko1 9860c846d0 * gc.c (rb_objspace_free): free slot itself.
* gc.c (objspace_each_objects): fix condition.
  Use slot->body instead of slot.
* gc.c (count_objects): use "slot" variable.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-17 06:52:13 +00:00
ko1 fa014681d5 * gc.c (unlink_heap_slot): fix memory leak.
free slot itself at free_heap_slot().
  Reproduce-able code is here:
  N1 = 100_000; N2 = 1_000_000
  N1.times{ary = []; N2.times{ary << ''}}
  Maybe this problem is remaining in Ruby 2.0.0.
* gc.c (unlink_heap_slot): remove not working code.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-17 06:24:22 +00:00
ko1 79d9c8ac72 * gc.c: re-design the heap structure.
(1) The heap is consists of a set of slots.
  (2) Each "slot" has a "slot_body".
  slot::start and slot::limit specify RVALUE beginning address
  and number of RVALUE in a "slot_body".
  (3) "slot_body" contains a pointer to slot (slot_body::header::slot)
  and an array of RVALUE.
  (4) heap::sorted is an array of "slots", sorted by an address of
  slot::body.
  See https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/GC_design
  for more details (figure).
* gc.c: Avoid "heaps" terminology. It is ambiguous.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-17 05:55:39 +00:00
ko1 fd92050515 * gc.c: fix heaps_header and heaps_slot to reduce memory consumption.
(1) move heaps_header::start and limit to  heaps_slot.
  (2) remove heaps_header::end which can be calculated by start+limit.
* gc.c: catch up above change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-17 04:34:57 +00:00
ko1 a97c3b7585 * gc.c: slim a path of newobj_of().
* gc.c (objspace): add a new field objspace::freelist, which contains
  available RVALUEs.
* gc.c (newobj_of): simply call new function `get_freeobj()'.
  get_freeobj() returns objspace::freelist. If  objspace::freelist
  is not available, refill objspace::freelist with a slot pointed by
  objspace::heap::free_slots.
* gc.c (before_gc_sweep): clear objspace::freelist.
* gc.c (slot_sweep): clear slot::freelist.
* gc.c (heaps_prepare_freeslot): renamed to heaps_prepare_freeslot.
* gc.c (unlink_free_heap_slot): remove unused function.
* gc.c (rb_free_const_table): remove unused function.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-16 10:29:31 +00:00
ko1 ed621c001e * gc.c (link_free_heap_slot): removed.
* gc.c (slot_sweep): use `heaps_add_freeslot' instead of
  `link_free_heap_slot'.
* gc.c (assign_heap_slot): use local variable `slot' instead of
  `heaps'.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42000 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-16 08:46:15 +00:00
ko1 73ee1676b0 * gc.c (assign_heap_slot): refactoring variable names.
* gc.c (slot_add_freeobj): added.
* gc.c (heaps_add_freeslot): added.
* gc.c (finalize_list, rb_gc_force_recycle, slot_sweep): use
  `slot_add_freeobj' instead of modifying linked list directly.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-16 08:32:32 +00:00
ko1 e8ee0a24dc * gc.c (lazy_sweep): refactoring.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-16 07:33:48 +00:00
ko1 53bdcbed86 revert last commit because it fails test-all.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-16 06:10:56 +00:00
ko1 3cd6fe3254 * gc.c (after_gc_sweep): refactoring code.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41995 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-16 06:00:55 +00:00
kou 7b52f3a722 * gc.c (is_before_sweep): Add a missing space before a parenthesis.
* gc.c (rb_gc_force_recycle): Add a missing space around a parenthesis.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41660 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-26 14:13:20 +00:00
tarui b0993c733f * gc.c (is_before_sweep): Add new helper function that check the object
is before sweep?
	* gc.c (rb_gc_force_recycle): Have to clear mark bit if object's slot
	  already ready to mainor sweep.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41633 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25 16:20:39 +00:00
ko1 ab0a003183 * gc.c: fix oldgen/remembered_shady counting algorithm.
* gc.c (rgengc_check_shady): increment
  `objspace->rgengc.remembered_shady_object_count' here.
* gc.c (rgengc_remember): return FALSE if obj is already remembered.
* gc.c (rgengc_rememberset_mark): make it void.
* gc.c (gc_mark_children): fix to double counting oldgen_object_count
  at minor GC.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25 03:24:07 +00:00
nobu 5ac5740733 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-24 16:01:06 +00:00
tarui 606d2d354d * gc.c (typedef struct rb_objspace): Change members for monitor objects.
* gc.c (gc_marks_test): Check all WriteBarrier Errors and track them in obj-tree.
	* gc.c (rgengc_check_shady): Ditto.
	* gc.c (gc_marks): Move 2 funtion calls to gc_marks_test for test initialize.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-24 15:57:16 +00:00
nobu 5332d81283 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-23 23:01:06 +00:00
tarui 9694416c06 * gc.c (after_gc_sweep): Have to record malloc info before reset.
* gc.c (gc_prof_timer_start): Pick out part of new record creation as gc_prof_setup_new_record.
	* gc.c (gc_prof_set_malloc_info): Move point of recording allocation size to front of mark.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-23 22:58:01 +00:00
ko1 982fee4fcc * include/ruby/ruby.h, gc.c: rename macros and functions:
OBJ_WB_GIVEUP() -> OBJ_WB_UNPROTECT(),
  rb_obj_wb_giveup() -> rb_obj_wb_unprotect(),
  rb_gc_giveup_promoted_writebarrier() ->
  rb_gc_writebarrier_unprotect_promoted(),
* class.c, eval.c, hash.c: use OBJ_WB_UNPROTECT().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41582 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-22 21:54:10 +00:00
ko1 d73b9320cc * gc.c (rgengc_check_shady): add new WB miss checking
on RGENGC_CHECK_MODE >= 2.

    (1) Save bitmaps before marking
    (2) Run full marking
    (3) On each traceable object,
      (a) object        was not oldgen (== newly or shady object) &&
      (b) parent object was     oldgen &&
      (c) parent object was not remembered &&
      (d) object        was not rememberd
      then, it should be WB miss.

  This idea of this checker is by Masaya Tarui <tarui@ruby-lang.org>.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-22 06:43:30 +00:00
ko1 a59e629868 * gc.c (gc_prof_set_heap_info, after_gc_sweep): call
gc_prof_set_heap_info() just after sweeping to calculate
  live object number correctly.
  (live object number = total generated number (before marking) -
                        total freed number (after sweeping))
* gc.c (gc_marks): record `oldgen_object_count' into current profile`
  record directly.
* gc.c (rgengc_rememberset_mark): same for remembered_normal_objects
  and remembered_shady_objects.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 22:29:09 +00:00
ko1 dbd8f3ac03 * gc.c (rb_objspace::profile): rename rb_objspace::profile::record to
records (because it points a set of records) and add a field
  rb_objspace::profile::current_record to point a current profiling
  record.
* gc.c: use above fields.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 21:51:41 +00:00
ko1 b4f907ea29 * gc.c (rb_gc_giveup_promoted_writebarrier): remove `rest_sweep()'
because all of remembered objects are called for gc_mark_children().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41550 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 21:08:38 +00:00
ko1 7396fbb0b5 * gc.c (rgengc_rememberset_mark): call gc_mark_children() for
remembered objects directly instead of pushing on the mark stack.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 20:10:03 +00:00
ko1 671c196384 * gc.c (slot_sweep_body): rename to slot_sweep().
No need to separate major/minor GC.
* gc.c (gc_setup_mark_bits): remove gc_clear_mark_bits() and unify to
  this function.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 19:42:04 +00:00
ko1 a27c48f69e * gc.c (check_bitmap_consistency): add to check flag and bitmap consistency.
Use this function in several places.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 19:36:48 +00:00
nobu 15c4b821a1 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41540 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 12:36:06 +00:00
tarui 913e65448d * gc.c (typedef enum): Introdule flags of major gc reason.
* gc.c (garbage_collect_body): Ditto.
	* gc.c (gc_profile_flags): Ditto.
	* gc.c (gc_profile_dump_on): Ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 12:31:13 +00:00
ko1 79d3385e9d * gc.c (allocate_sorted_heaps): remove unused variable `add'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 12:12:57 +00:00
ko1 508b255b9a * include/ruby/ruby.h: constify RArray::as::ary and RArray::heap::ptr.
Use RARRAY_ASET() or RARRAY_PTR_USE() to modify Array objects.
* array.c, gc.c: catch up above changes.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 11:53:33 +00:00
ko1 6a1101f23e * include/ruby/ruby.h: support write barrier protection for T_STRUCT.
Introduce the following C APIs:
  * RSTRUCT_RAWPTR(st) returns pointer (do WB on your risk).
    The type of returned pointer is (const VALUE *).
  * RSTRUCT_GET(st, idx) returns idx-th value of struct.
  * RSTRUCT_SET(st, idx, v) set idx-th value by v with WB.
  And
  * RSTRUCT_PTR(st) returns pointer with shady operation.
    The type of returned pointer is (VALUE *).
* struct.c, re.c, gc.c, marshal.c: rewrite with above APIs.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 11:22:18 +00:00
ko1 ab084f4063 * gc.c (gc_sweep): profile sweep time correctly when LAZY_SWEEP is
disabled.
* gc.c (gc_marks_test): store oldgen count and shady count
  before test marking and restore them after marking.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 06:29:30 +00:00
ko1 ac9413893a * gc.c: enable lazy sweep (commit miss).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41523 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 06:08:07 +00:00
ko1 dfc4cc0196 revert last commit (operation miss).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 06:04:29 +00:00
ko1 8398719020 * gc.c: fix to use total_allocated_object_num and heaps_used
at the GC time for profiler.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41521 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 05:55:05 +00:00
ko1 e35f127403 * gc.c: fix to use total_allocated_object_num and heaps_used
at the GC time for profiler.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 05:17:40 +00:00
ko1 4a113cd3cb * gc.c: RGENGC_CHECK_MODE should be 0.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 03:36:40 +00:00
ko1 b21bf8f94b * gc.c (gc_marks_body): fix to get `th' in this function.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41516 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 02:20:10 +00:00
ko1 7986e98394 * gc.c (heaps_header/heaps_slot): embed bitmaps into heaps_slot.
no need to maintain allocation/free bitmaps.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 01:26:50 +00:00
ko1 caf923fa6a * gc.c (slot_sweep_body): add counters at a time.
* gc.c (gc_profile_dump_on): fix line break position.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 00:24:14 +00:00
tarui 4b18db6a2f * gc.c: refactoring bitmaps. introduce bits_t type and some Consts.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41512 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-20 23:15:18 +00:00
ko1 8b80ce3a53 * gc.c: fix to support USE_RGENGC == 0 (disable RGenGC).
If USE_RGENGC==0, it caused compilation error.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-20 23:10:34 +00:00
tarui fcd5cc93c9 * gc.c (lazy_sweep): Use is_lazy_sweeping()
* gc.c (rest_sweep): Ditto.
	* gc.c (gc_prepare_free_objects): Ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-20 23:08:30 +00:00
nobu 2c79a46764 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-20 22:41:07 +00:00
ko1 8ab7d0e4c3 * gc.c (gc_profile_record::oldgen_objects): added.
* gc.c (gc_profile_dump_on): print the following infomation:
* Living object counts
* Free object counts
  If RGENGC_PROFILE > 0 then
* Oldgen object counts
* Remembered normal object counts
* Remembered shady object counts



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-20 22:38:08 +00:00
ko1 d1c518d416 * gc.c (gc_prof_sweep_timer_stop): accumulate sweep time only when
record->gc_time > 0.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-20 20:39:20 +00:00
ko1 bf017de1f3 * gc.c (rgengc_rememberset_mark): record
(1) normal objects count in remember set
  (2) shady objects count in remember set
  each GC timing.
* gc.c (gc_profile_record_get): enable to access above information
  and REMOVING_OBJECTS, EMPTY_OBJECTS.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-20 12:20:27 +00:00
nobu 16f36b6322 gc.c: adjust indent
* gc.c (gc_marks): adjust indent.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-20 00:29:13 +00:00
tarui 88927b04ae * gc.c (rb_gc_writebarrier): give up rescan A and register B directly
if A has huge number of children.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 22:48:03 +00:00
ko1 65ad154e2a * gc.c (gc_profile_total_time): check objspace->profile.next_index > 0.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41456 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 21:21:16 +00:00
ko1 efc53c496e * gc.c (gc_prof_sweep_timer_start): fix merge miss.
* gc.c (GC_PROFILE_MORE_DETAIL): set it 0.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 20:49:28 +00:00
ko1 6622ab2049 * gc.c: Accumulate sweep time to GC time.
Now [GC time] is [mark time] + [sweep time] + [misc].
  ([GC time] >= [mark time] + [sweep time])
* gc.c (gc_prof_sweep_slot_timer_start/stop): rename to
  gc_prof_sweep_timer_start/stop and locate at lazy_sweep().
* gc.c (elapsed_time_from): add a utility function.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 20:43:33 +00:00
ko1 21b0705c18 * gc.c (gc_marks): fix wrong option. FALSE means major/full GC.
It should be TRUE (minor marking).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 20:09:59 +00:00
nobu a30d9f9e1e gc.c: refine macros
* gc.c (MARKED_IN_BITMAP, FL_TEST2): return boolean value since always
  used as boolean value.
* gc.c (MARK_IN_BITMAP, CLEAR_IN_BITMAP): evaluate bits once.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 16:07:41 +00:00
nobu 67edbe19ee gc.c: gc_stress is a VALUE
* gc.c (ruby_initial_gc_stress_ptr): now gc_stress is a VALUE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 16:01:16 +00:00
nagachika 291c1bc314 * gc.c (gc_free_stored_bitmaps): fix indent.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41440 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 15:27:58 +00:00
ko1 ce7c13ef4d * gc.c (RVALUE_PROMOTED): fix type.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41437 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 15:06:27 +00:00
ko1 50214475a9 * gc.c (garbage_collect_test): rewrite checking code.
When RGENGC_CHECK_MODE >= 2, all minor marking, run normal minor
  marking *and* major/full marking. After that, compare the results
  and shows BUG if a object living with major/full marking but dead
  with minor marking.
  After detecting bugs, print references information.
  (RGENGC_CHECK_MODE == 2, show references to dead object)
  (RGENGC_CHECK_MODE == 3, show all references)



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41436 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 14:59:35 +00:00
ko1 745263abb9 * gc.c (RVALUE_PROMOTED): check consistency between oldgen flag and
oldgen bitmap if RGENGC_CHECK_MODE > 0.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 14:34:11 +00:00
ko1 a1acb395a2 * gc.c (rb_gc_force_recycle): clear oldgen bitmap, too.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 14:30:13 +00:00
kazu 28945ea146 * gc.c (gc_stress_get): GC.stress can be Fixnum.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 11:53:07 +00:00
ko1 9b47ec04a8 * include/ruby/ruby.h (struct rb_data_type_struct), gc.c: add
rb_data_type_struct::flags. Now, this flags is passed
  at T_DATA object creation. You can specify FL_WB_PROTECTED
  on this flag.
* iseq.c: making non-shady iseq objects.
* class.c, compile.c, proc.c, vm.c: add WB for iseq objects.
* vm_core.h, iseq.h: constify fields to detect WB insertion.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41412 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 06:26:01 +00:00
nobu 541bdd29ba gc.c: more info
* gc.c (gc_mark_children): show more info for broken object.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41410 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 06:11:15 +00:00
ko1 97dd259df5 * gc.c (garbage_collect_body): use FIX2INT for ruby_gc_stress.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-18 22:49:19 +00:00
ko1 bfac961bed * gc.c (rb_objspace::gc_stress): int -> VALUE to store Fixnum object.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-18 22:45:41 +00:00
ko1 d879849b6e * gc.c (make_deferred): clear flags to T_ZOMBIE.
* gc.c (slot_sweep_body): fix indent.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-18 22:26:57 +00:00
ko1 54d04073d7 * gc.c (rgengc_remember): fix output level.
* gc.c (rgengc_rememberset_mark): fix to output clear count.
  (shady_object_count + clear_count = count of remembered objects)



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41403 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-18 22:12:39 +00:00
ko1 65791846a6 * gc.c (rgengc_remember): check T_NONE and T_ZOMBIE
if RGENGC_CHECK_MODE > 0.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41402 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-18 22:07:09 +00:00
ko1 5455b7e72e * gc.c (RGENGC_CHECK_MODE): add new check mode `3'.
In this mode, show all references if there is
  a miss-corrected object.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-18 22:04:30 +00:00
ko1 81ed2d3c4a * gc.c (gc_stress_set): add special option of GC.stress.
`GC.stress=(flag)' accepts integer to control behavior of GC.
  See code for details. Of course, this feature is only for MRI.
  You can debug RGenGC (WB) using `GC.stress = 1'.
  Using this option, do minor marking at all possible places.
  GC::STRESS_MINOR_MARK = 1 and GC::STRESS_LAZY_SWEEP = 2
  seem good to add.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-18 21:35:40 +00:00
tarui 0a3f79310f * gc.c (gc_profile_record_flag): reason seems like one-hot encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-18 13:37:09 +00:00
zzak 62de1e66f7 * gc.c: Rename rb_mObSpace -> rb_mObjSpace
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-18 12:59:02 +00:00
ko1 1d7966f5b4 * gc.c (gc_stat): add `generated_normal_object_count_types' for
RGENGC_PROFILE >= 2.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41373 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-18 02:27:37 +00:00
ko1 17cd5ac4af * gc.c (gc_mark_maybe): check to skip T_NONE.
* gc.c (markable_object_p): do not need to check (flags == 0) here.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-18 02:17:59 +00:00
ko1 7a460d2d1d * gc.c (gc_mark_children): don't need to care about T_ZOMBIE here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41367 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-17 19:21:36 +00:00
eregon 089dd1a1ca * gc.c (ObjectSpace): is a module not a class.
* ext/objspace/objspace.c: try to include overview in rdoc,
  see #8537.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-17 08:44:56 +00:00
eregon abfcded30c * gc.c: fix example of ObjectSpace.define_finalizer in overview
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-17 08:39:39 +00:00
ko1 17be9e9719 * gc.c (gc_mark_maybe): added. check `is_pointer_to_heap()' and
type is not T_ZOMBE.
* gc.c: use `gc_mark_maybe()'. T_ZOMBIE objects should not be pushed
  to the mark stack.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-17 02:54:25 +00:00
tarui 3a0a69fec4 * gc.c: Fixup around GC by MALLOC.
Add allocate size to malloc_increase before GC 
	  for updating limit in after_gc_sweep.
	  Reset malloc_increase into garbage_collect() 
	  for preventing GC again soon.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41325 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-15 20:53:01 +00:00
tarui 994ed8dbd5 * gc.c : add some colums to more detail profile.
new colums: Allocated size, Prepare Time, Removing Objects, Empty Objects


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41324 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-15 20:18:11 +00:00
tarui 6477616c3b * gc.c (gc_prof_timer_stop): Merge function codes of GC_PROFILE_MORE_DETAIL and !GC_PROFILE_MORE_DETAIL.
* gc.c (gc_prof_mark_timer_start): Ditto. 
	* gc.c (gc_prof_mark_timer_stop): Ditto.
	* gc.c (gc_prof_sweep_slot_timer_start): Ditto.
	* gc.c (gc_prof_sweep_slot_timer_stop): Ditto.
	* gc.c (gc_prof_set_malloc_info): Ditto.
	* gc.c (gc_prof_set_heap_info): Ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-15 17:06:15 +00:00
shugo 1f828497d1 * safe.c (rb_set_safe_level, safe_setter): raise an ArgumentError
when $SAFE is set to 4.  $SAFE=4 is now obsolete.
  [ruby-core:55222] [Feature #8468]

* object.c (rb_obj_untrusted, rb_obj_untrust, rb_obj_trust):
  Kernel#untrusted?, untrust, and trust are now deprecated.
  Their behavior is same as tainted?, taint, and untaint,
  respectively.

* include/ruby/ruby.h (OBJ_UNTRUSTED, OBJ_UNTRUST): OBJ_UNTRUSTED()
  and OBJ_UNTRUST() are aliases of OBJ_TAINTED() and OBJ_TAINT(),
  respectively.

* array.c, class.c, debug.c, dir.c, encoding.c, error.c, eval.c,
  ext/curses/curses.c, ext/dbm/dbm.c, ext/dl/cfunc.c,
  ext/dl/cptr.c, ext/dl/dl.c, ext/etc/etc.c, ext/fiddle/fiddle.c,
  ext/fiddle/pointer.c, ext/gdbm/gdbm.c, ext/readline/readline.c,
  ext/sdbm/init.c, ext/socket/ancdata.c, ext/socket/basicsocket.c,
  ext/socket/socket.c, ext/socket/udpsocket.c,
  ext/stringio/stringio.c, ext/syslog/syslog.c, ext/tk/tcltklib.c,
  ext/win32ole/win32ole.c, file.c, gc.c, hash.c, io.c, iseq.c,
  load.c, marshal.c, object.c, proc.c, process.c, random.c, re.c,
  safe.c, string.c, thread.c, transcode.c, variable.c,
  vm_insnhelper.c, vm_method.c, vm_trace.c: remove code for
  $SAFE=4.

* test/dl/test_dl2.rb, test/erb/test_erb.rb,
  test/readline/test_readline.rb,
  test/readline/test_readline_history.rb, test/ruby/test_alias.rb,
  test/ruby/test_array.rb, test/ruby/test_dir.rb,
  test/ruby/test_encoding.rb, test/ruby/test_env.rb,
  test/ruby/test_eval.rb, test/ruby/test_exception.rb,
  test/ruby/test_file_exhaustive.rb, test/ruby/test_hash.rb,
  test/ruby/test_io.rb, test/ruby/test_method.rb,
  test/ruby/test_module.rb, test/ruby/test_object.rb,
  test/ruby/test_pack.rb, test/ruby/test_rand.rb,
  test/ruby/test_regexp.rb, test/ruby/test_settracefunc.rb,
  test/ruby/test_struct.rb, test/ruby/test_thread.rb,
  test/ruby/test_time.rb: remove tests for $SAFE=4.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-12 14:20:51 +00:00
ko1 a8aaf13392 * gc.c (rgengc_remember): permit promoted object.
(rb_gc_writebarrier -> remember)



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-10 08:21:08 +00:00
ko1 a03ac78b2c * gc.c (RVALUE_PROMOTE): fix parameter name (`x' to `obj')
and make it inline function (like RVALUE_PROMOTE).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-10 08:15:31 +00:00
ko1 dd96561f76 * gc.c (wmap_mark): check allocation of `w->obj2wmap'.
(no-allocation `w->obj2wmap' will be NULL pointer reference)



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41207 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-10 07:12:14 +00:00
akr bd15d4ca78 * internal.h (numberof): Gathered from various files.
* array.c, math.c, thread_pthread.c, iseq.c, enum.c, string.c, io.c,
  load.c, compile.c, struct.c, eval.c, gc.c, parse.y, process.c,
  error.c, ruby.c: Remove the definitions of numberof.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 10:01:19 +00:00
naruse b309a3698d * gc.c (before_gc_sweep): noinline can also avoid the segv instead of
-O0 of r41084. this way is expected less slow.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41134 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 04:25:20 +00:00
nobu 83db393e48 adjust style
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41133 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 02:52:42 +00:00
nobu 0b87f8d4cf * gc.c (gc_clear_slot_bits): used only if no RGenGC.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 02:49:53 +00:00
nobu 432321d780 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 02:36:07 +00:00
tarui f37d0629af * gc.c: use oldgen bitmap as initial mark bitmap when mijor gc.
so can skip oldgen bitmap check around mark & sweep.
	* gc.c (slot_sweep_body): change scan algorithm for performance:
	  from object's pointer base to bitmap one.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 02:32:57 +00:00
tarui 1f23dca967 * gc.c: introduce oldgen bitmap for preparing performance tuning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 02:28:03 +00:00
tarui 5a06ae3bf9 * gc.c (MARKED_IN_BITMAP, MARK_IN_BITMAP, CLEAR_IN_BITMAP): bring
bitmap macros in one place, and introduce BITMAP_BIT.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 02:25:19 +00:00
ko1 e7dfa869c0 * gc.c: remove "Sunny" terminology.
"Sunny" doesn't mean antonym of "Shady" (questionable, doubtful, etc).
  Instead of "Suuny", use "non-shady" or "normal".



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 01:17:19 +00:00
tarui 3a17a592da * gc.c (gc_mark): get rid of pushing useless objests.
* gc.c (rgengc_rememberset_mark): bypass gc_mark() in order to push
	  sunny old object at minor gc.
	* gc.c (gc_mark_children): move sunny old check to gc_mark().
	* gc.c (rgengc_check_shady): remove DEMOTE that already unnecessary.
	* gc.c (rb_gc_writebarrier): ditto.
	  
	  change sunny old check point in order to save mark stack and
	  remove unnatural rest_sweep & demote.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-05 16:15:26 +00:00
nobu 2b78c32561 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-05 16:01:05 +00:00
tarui 5d10f35142 * gc.c (rgengc_rememberset_mark): change scan algorithm for performance:
from object's pointer base to bitmap one.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-05 15:57:12 +00:00
nobu 3fb267e501 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-05 06:36:06 +00:00
naruse c0089b4d10 use attribute is more simple way for r41083
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41084 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-05 06:31:43 +00:00
naruse 77857bfc87 * gc.c (before_gc_sweep): don't optimize it to avoid segv on Ubuntu
10.04 gcc 4.4.
  http://u32.rubyci.org/~chkbuild/ruby-trunk/log/20130527T190301Z.diff.html.gz

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-05 06:27:43 +00:00
ko1 6e19585ac7 * gc.c (gc_profile_enable): rest_sweep() to finish last GC.
Profiling record is allocated at first of marking phase.
  Enable at lazy sweeping may cause an error (SEGV).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-29 15:10:28 +00:00
ko1 b01c4ddfce * gc.c (gc_stat): remove wrong rest_sweep().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40969 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-27 17:57:08 +00:00
ko1 8a81b54a2b * gc.c (garbage_collect_body): fix GC_ENABLE_LAZY_SWEEP condition.
* gc.c (GC_NOTIFY): move debug print location and use stderr instead
  of stdout.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-27 17:46:20 +00:00
ko1 e4c58251b7 * include/ruby/ruby.h, gc.c: add new internal event
RUBY_INTERNAL_EVENT_GC_END. This event invokes at the end of
  after_sweep().
  Time chart with lazy sweep is here:
  (1) Kick RUBY_INTERNAL_EVENT_GC_START
  (2) [gc_marks()]
  (3) [lazy_sweep()]
  (4) [... run Ruby program (mutator) with lazy_sweep() ...]
  (5) [after_sweep()]
  (6) Kick RUBY_INTERNAL_EVENT_GC_END
  (7) [... run Ruby program (mutator), and go to (1) ...]
* ext/-test-/tracepoint/tracepoint.c,
  test/-ext-/tracepoint/test_tracepoint.rb: modify a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40963 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-27 15:40:27 +00:00
ko1 f0b6cb6fc7 * include/ruby/ruby.h: rename RUBY_INTERNAL_EVENT_FREE to
RUBY_INTERNAL_EVENT_FREEOBJ.
* ext/-test-/tracepoint/tracepoint.c,
  ext/objspace/object_tracing.c,
  gc.c, vm_trace.c: catch up this change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-27 10:28:25 +00:00
ko1 050dd10d6f * ext/objspace/objspace.c: support ObjectSpace.trace_object_allocations.
Read the following test to know HOWTO.
  This feature is a sample of RUBY_INTERNAL_EVENT.
* test/objspace/test_objspace.rb: add a test.
* ext/objspace/object_tracing.c: ditto.
* gc.c (rb_gc_count): add. THis function returns GC count.
* internal.h: add decl. of rb_gc_count(). Same as `GC.count'.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-27 10:01:45 +00:00
ko1 680f0b5ba4 * include/ruby/ruby.h, gc.c, vm_trace.c: add internal events.
* RUBY_INTERNAL_EVENT_NEWOBJ: object created.
* RUBY_INTERNAL_EVENT_FREE: object freeed.
* RUBY_INTERNAL_EVENT_GC_START: GC started.
  And rename `RUBY_EVENT_SWITCH' to `RUBY_INTERNAL_EVENT_SWITCH'.
  Internal events can not invoke any Ruby program because the tracing
  timing may be critical (under huge restriction).
  These events can be hooked only by C-extensions.
  We recommend to use rb_potponed_job_register() API to call Ruby
  program safely.
  This change is mostly written by Aman Gupta (tmm1).
  https://bugs.ruby-lang.org/issues/8107#note-12
  [Feature #8107]
* include/ruby/debug.h, vm_trace.c: added two new APIs.
* rb_tracearg_event_flag() returns rb_event_flag_t of this event.
* rb_tracearg_object() returns created/freeed object.
* ext/-test-/tracepoint/extconf.rb,
  ext/-test-/tracepoint/tracepoint.c,
  test/-ext-/tracepoint/test_tracepoint.rb: add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40946 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-27 00:21:02 +00:00
ko1 e2793a908e * include/ruby/debug.h, vm_trace.c: add rb_postponed_job API.
Postponed jobs are registered with this API. Registered jobs
  are invoked at `ruby-running-safe-point' as soon as possible.
  This timing is completely same as finalizer timing.
  There are two APIs:
* rb_postponed_job_register(flags, func, data): register a
  postponed job with data. flags are reserved.
* rb_postponed_job_register_one(flags, func, data): same as
  `rb_postponed_job_register', but only one `func' job is
  registered (skip if `func' is already registered).
  This change is mostly written by Aman Gupta (tmm1).
  https://bugs.ruby-lang.org/issues/8107#note-15
  [Feature #8107]
* gc.c: use postponed job API for finalizer.
* common.mk: add dependency from vm_trace.c to debug.h.
* ext/-test-/postponed_job/extconf.rb, postponed_job.c,
  test/-ext-/postponed_job/test_postponed_job.rb: add a test.
* thread.c: implement postponed API.
* vm_core.h: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40940 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-26 21:30:44 +00:00
ko1 767debf92e * gc.c (gc_stat): collect promote_operation_count and
types (RGENGC_PROFILE >= 2).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40939 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-26 17:27:42 +00:00
ko1 ca2ca7d32b * gc.c (gc_stat): collect shade_operation_count,
remembered_sunny_object_count and remembered_shady_object_count
  for each types when RGENGC_PROFILE >= 2.
  They are informative for optimization.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-26 16:43:21 +00:00
ko1 c4c821a7d7 * hash.c (rb_hash_tbl_raw), internal.h: added.
Returns st_table without shading hash.
* array.c: use rb_hash_tbl_raw() for read-only purpose.
* compile.c (iseq_compile_each): ditto.
* gc.c (count_objects): ditto.
* insns.def: ditto.
* process.c: ditto.
* thread.c (clear_coverage): ditto.
* vm_insnhelper.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-26 16:19:04 +00:00
ko1 7b5a42f0fa * gc.c (after_gc_sweep): reduce full GC timing.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40924 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-25 08:11:04 +00:00
ko1 f38a063090 * gc.c: do major/full GC when:
* number of oldgen object is biggger than twice of
  number of oldgen object at last full GC.
* number of remembered shady object is bigger than twice of
  number of remembered shady object at last full GC.
* number of oldgen object and remembered shady object is bigger
  than half of total object space.
  (please fix my English!)



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-24 10:21:04 +00:00
ko1 b84f7fda07 * gc.c (after_gc_sweep, garbage_collect_body): do major GC (full GC)
before extending heaps.
  TODO: do major GC when there are many old (promoted) objects.
* gc.c (after_gc_sweep): remove TODO comments.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-24 06:52:38 +00:00
nobu 699e06a884 gc.c: revert r40898
* gc.c (gc_profile_dump_on): revert r40898.  ok to show the record
  accumulating while lazy_sweep().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-23 08:22:05 +00:00
nobu 95170c704c * gc.c: do not dump the last record
* gc.c (gc_profile_dump_on): do not dump the last record, for some
  reason.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40898 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-23 07:58:06 +00:00
nobu 11650a6ab9 gc.c: use size_t and no header if next_index == 0
* gc.c (gc_profile_dump_on): use size_t to get rid of overflow and
  show the header when next_index > 0, instead of next_index != 1.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-22 07:50:20 +00:00
ko1 5aece50163 * gc.c (gc_prepare_free_objects, rest_sweep, lazy_sweep): fix position
of `during_gc' setting.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40886 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-22 05:21:06 +00:00
ko1 9e64703ec8 * gc.c (garbage_collect): all GC is start from garbage_collect()
(or garbage_collect_body()). `garbage_collect()' accept additional
  two parameters `full_mark' and `immediate_sweep'.
  If `full_mark' is TRUE, then force it full gc (major gc), otherwise,
  it depends on status of object space. Now, it will be minor gc.
  If `immediate_sweep' is TRUE, then disable lazy sweep.
  To allocate free memory, `full_mark' and `immediate_sweep' should be
  TRUE. Otherwise, they should be FALSE.
* gc.c (gc_prepare_free_objects): use `garbage_collect_body()'.
* gc.c (slot_sweep, before_gc_sweep, after_gc_sweep): add logging code.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-21 23:09:22 +00:00
ko1 51d586c64e * gc.c: remove gc_profile_record::is_marked. always true.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40878 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-21 08:21:59 +00:00
ko1 9578bb7831 * gc.c: fix to collect additional information for GC::Profiler.
* major/minor GC
* trigger reason of GC
* gc.c (gc_profile_dump_on): change reporting format with
  added information.
* gc.c (gc_profile_record_get): return added information by
  :GC_FLAGS => array.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-21 08:19:07 +00:00
ko1 2e011442e5 * gc.c: GC::Profiler's sweeping time is accumulated all slot
sweeping time. At lazy GC, GC::Profiler makes new record entry
  for each lazy_sweep(). In this change, accumulating all
  slot_sweep() time.
  And change indentation.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-21 07:52:03 +00:00
ko1 3f2cb86ef3 * gc.c (gc_profile_dump_on): `count' should be (int) because it
can be negative number.
  And use pointer for `record' (don't copy).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-21 07:27:32 +00:00
nobu baa65ad108 gc.c: rb_gc_guarded_ptr
* gc.c (rb_gc_guarded_ptr): unoptimize on other compilers than gcc and
  msvc.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-17 08:35:26 +00:00
ko1 e213a7228f * gc.c (rb_node_newnode): use newobj_of() instead of rb_newobj().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-15 18:07:12 +00:00
ko1 f1ccdf98ca * gc.c (newobj): rename to `newobj_of' and accept additional
three parameters v1, v2, v3. newobj_of() do OBJSETUP() and
  fill values with v1, v2, v3.
* gc.c (rb_data_object_alloc, rb_data_typed_object_alloc):
  use newobj_of().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-15 10:26:22 +00:00
ko1 4a9ec30601 * gc.c: add an additional RGENGC_PROFILE mode (2).
Profiling result can be check by GC.stat.
* gc.c (type_name): separate from obj_type_name().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-15 08:07:30 +00:00
nobu bb5212d395 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-14 01:54:48 +00:00
ko1 4f401816ff * gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
  check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
  you want to access raw pointers. If you modify the contents which
  pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
  and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
  barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
  generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
  FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
  move flag bits.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
ko1 7958c71ee5 * gc.c: remove rb_objspace_t::marked_num.
We can use `objspace_live_num()' instead of removed `marked_num'
  if it is after `after_gc_sweep()' function call.
* gc.c (after_gc_sweep): use objspace_live_num() instead of removed
  rb_objspace_t::marked_num.
* gc.c (gc_mark_ptr, gc_marks): remove rb_objspace_t::marked_num code.
* gc.c (gc_prepare_free_objects): do not call set_heaps_increment()
  with checking objspace->heap.marked_num. At this point, we only
  need to check availability of free-cell.
* gc.c (gc_prepare_free_objects):
* gc.c (lazy_sweep): call after_gc_sweep() if there are no sweep_able entry.
* gc.c (rest_sweep, gc_prepare_free_objects): remove after_gc_sweep() call.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40702 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 17:02:50 +00:00
ko1 b597df707e * gc.c: disable GC_PROFILE_MORE_DETAIL (fix last commit).
* gc.c (gc_prof_set_malloc_info): fix "objspace->heap.live_num" to
  "objspace_live_num(objspace)". There is no such member variable.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 16:52:49 +00:00
ko1 7d0a90e9b4 * gc.c: refactoring GC::Profiler.
* gc.c (gc_prof_sweep_timer_start/stop): removed because
  they doesn't support lazy sweep.
* gc.c (gc_prof_sweep_slot_timer_start/stop): added.
  redefine `sweeping time' to accumulated time of all of
  slot_sweep().
* gc.c (rb_objspace_t::profile::count): renamed to
  rb_objspace_t::profile::next_index. `counter' seems ambiguous.
  increment it when next record is acquired.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 16:34:25 +00:00
ko1 83aba04862 * include/ruby/ruby.h: constify RBasic::klass and add
RBASIC_CLASS(obj) macro which returns a class of `obj'.
  This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
* object.c: add new function rb_obj_reveal().
  This function reveal interal (hidden) object by rb_obj_hide().
  Note that do not change class before and after hiding.
  Only permitted example is:
  klass = RBASIC_CLASS(obj);
  rb_obj_hide(obj);
  ....
  rb_obj_reveal(obj, klass);
  TODO: API design. rb_obj_reveal() should be replaced with others.
  TODO: modify constified variables using cast may be harmful for
  compiler's analysis and optimizaton.
  Any idea to prohibt inserting RBasic::klass directly?
  If rename RBasic::klass and force to use RBASIC_CLASS(obj),
  then all codes such as `RBASIC(obj)->klass' will be
  compilation error. Is it acceptable? (We have similar
  experience at Ruby 1.9,
  for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
* internal.h: add some macros.
* RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
  object.
* RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
* RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
  without write barrier (planned).
* RCLASS_SET_SUPER(a, b) set super class of a.
* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
  file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
  parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
  string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
  Use above macros and functions to access RBasic::klass.
* ext/coverage/coverage.c, ext/readline/readline.c,
  ext/socket/ancdata.c, ext/socket/init.c,
* ext/zlib/zlib.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 10:49:11 +00:00
ko1 aacd771046 * *.c, parse.y, insns.def: use RARRAY_AREF/ASET macro
instead of using RARRAY_PTR().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 09:56:22 +00:00
ko1 8ac05ae500 * gc.c (rb_data_object_alloc): check klass only if klass is not 0.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 06:25:33 +00:00
ko1 925c936bb1 * gc.c (rb_data_object_alloc, rb_data_typed_object_alloc):
use NEWOBJ_OF() instead of NEWOBJ().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 06:03:00 +00:00
nobu ae422dda78 gc.c: _aligned_malloc
* gc.c (aligned_malloc): declare _aligned_malloc() prototype for old VC.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-30 21:08:30 +00:00
nobu b4a2e268ea gc.c: fix compile error
* gc.c (gc_prepare_free_objects): fix compile error.  there should be
  free objects when new slot is added.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39902 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-24 05:13:54 +00:00
nari e54daddac4 * gc.c (GC_ENABLE_LAZY_SWEEP): new macro to switch lazy sweeping
for debugging. [Feature #8024] [ruby-dev:47135]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39901 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-24 04:53:44 +00:00
nari 3ad60679e3 * gc.c: We have no chance to expand the heap when lazy sweeping is
restricted. So collecting is often invoked if there is not
  enough free space in the heap. Try to expand heap when this is
  the case.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39900 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-24 04:20:32 +00:00
nari 80329d3a66 * gc.c: Improve accuracy of objspace_live_num() and
allocated/freed counters. patched by tmm1(Aman Gupta).
  [Bug #8092] [ruby-core:53392]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-18 15:30:02 +00:00
nari 1bc93a1591 * gc.c: Avoid unnecessary heap growth. patched by tmm1(Aman Gupta).
[Bug #8093] [ruby-core:53393]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-18 12:44:55 +00:00
nari 03c7f0ca43 * gc.c: Fix unlimited memory growth with large values of
RUBY_FREE_MIN. patched by tmm1(Aman Gupta).
  [Bug #8095] [ruby-core:53405]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-18 09:03:07 +00:00
nari 2f7ca893a3 * gc.c: allow to tune growth of heap by environment variable
RUBY_HEAP_SLOTS_GROWTH_FACTOR. patched by tmm1(Aman Gupta).
  [Feature #8015] [ruby-core:53131]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39746 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-13 14:52:00 +00:00
zzak a14f02f0e0 * vm.c: Typo in ObjectSpace::WeakMap overview
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-23 07:06:10 +00:00
kosaki 03f7f9ea40 * gc.c (vm_xrealloc): add a few comment why we avoid realloc(ptr,0).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-04 20:05:42 +00:00
nobu be7bf5aa0c adjust style
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-29 12:22:04 +00:00
shirosaki ca2fce0cf2 * gc.c (obj_id_to_ref): add a macro to treat Bignum object id.
This follows the change r38493.

* gc.c (id2ref): fix for working fine with Bignum object id on x64
  Windows.
* gc.c (wmap_finalize): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-22 04:25:18 +00:00
usa 94f42d6d79 * gc.c (nonspecial_obj_id): VALUE is not compatible with Fixnum on
LLP64 platform, such as 64bit Windows.
  reporeted by Heesob Park at [ruby-core:50255] [Bug #7454], and the
  fix is suggested by akr.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-20 07:43:54 +00:00
kosaki aff9dff46d * signal.c (rb_sigaltstack_size): new. calculate stack size for
sigsegv handler. enlarge value when x86 or x86_64 on Linux.
  Linux has very small MINSIGSTKSZ size (2048 bytes) and
  our sigsegv routine need 5KiB at least. [Bug #7141]
* internal.h: add declaration of rb_sigaltstack_size().
* vm_core.h: remove ALT_STACK_SIZE definition.

* signal.c (rb_register_sigaltstack): replace ALT_STACK_SIZE with
  rb_sigaltstack_size();
* gc.c (Init_heap): ditto.
* vm.c (th_init): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-15 14:20:12 +00:00
shugo 60d6038dda * revised r37993 to avoid SEGV/ILL in tests. In r37993, a method
entry with VM_METHOD_TYPE_REFINED holds only the original method
  definition, so ci->me is set to a method entry allocated in the
  stack, and it causes SEGV/ILL.  In this commit, a method entry
  with VM_METHOD_TYPE_REFINED holds the whole original method entry.
  Furthermore, rb_thread_mark() is changed to mark cfp->klass to
  avoid GC for iclasses created by copy_refinement_iclass().

* vm_method.c (rb_method_entry_make): add a method entry with
  VM_METHOD_TYPE_REFINED to the class refined by the refinement if
  the target module is a refinement.  When a method entry with
  VM_METHOD_TYPE_UNDEF is invoked by vm_call_method(), a method with
  the same name is searched in refinements.  If such a method is
  found, the method is invoked.  Otherwise, the original method in
  the refined class (rb_method_definition_t::body.orig_me) is
  invoked.  This change is made to simplify the normal method lookup
  and to improve the performance of normal method calls.

* vm_method.c (EXPR1, search_method, rb_method_entry),
  vm_eval.c (rb_call0, rb_search_method_entry): do not use
  refinements for method lookup.

* vm_insnhelper.c (vm_call_method): search methods in refinements if
  ci->me is VM_METHOD_TYPE_REFINED.  If the method is called by
  super (i.e., ci->call == vm_call_super_method), skip the same
  method entry as the current method to avoid infinite call of the
  same method.

* class.c (include_modules_at): add a refined method entry for each
  method defined in a module included in a refinement.

* class.c (rb_prepend_module): set an empty table to
  RCLASS_M_TBL(klass) to add refined method entries, because
  refinements should have priority over prepended modules.

* proc.c (mnew): use rb_method_entry_with_refinements() to get
  a refined method.

* vm.c (rb_thread_mark): mark cfp->klass for iclasses created by
  copy_refinement_iclass().

* vm.c (Init_VM), cont.c (fiber_init): initialize th->cfp->klass.

* test/ruby/test_refinement.rb (test_inline_method_cache): do not skip
  the test because it should pass successfully.

* test/ruby/test_refinement.rb (test_redefine_refined_method): new
  test for the case a refined method is redefined.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-06 13:08:41 +00:00
nari ab012bda4a * gc.c (getrusage_time): uses clock_gettime() with
CLOCK_PROCESS_CPUTIME_ID when available, which provides a 1ns
  precision on linux. [ruby-core:50495] [Bug #7500]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-05 14:53:16 +00:00
zzak 5c4e025f6f * gc.c (WeakMap): Add doc for internal reference, use lib/weakref.rb
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38138 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-02 07:45:17 +00:00
nobu 018d8261ce gc.c: suppress warnings
* gc.c (add_slot_local_freelist, slot_sweep, mark_locations_array):
  suppress unused-value warnings, even with valgrind enabled.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38116 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-01 09:30:24 +00:00
shugo 9e44974874 * revert r37993 to avoid SEGV in tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30 02:11:59 +00:00
nari a22bb18e3e * gc.c : remove a unused function.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29 23:10:36 +00:00
nari 59770bf960 * gc.c (rb_objspace_call_finalizer): finalize_deferred may free up
a object which is reachable from a part after this function,
  e.g. ruby_vm_destruct(). [ruby-dev:46647] [Bug #7452]

* test/ruby/test_gc.rb (test_finalizing_main_thread): add a test
  for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38010 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29 22:56:02 +00:00
shugo 421314cf4e * vm_method.c (rb_method_entry_make): add a method entry with
VM_METHOD_TYPE_REFINED to the class refined by the refinement if
  the target module is a refinement.  When a method entry with
  VM_METHOD_TYPE_UNDEF is invoked by vm_call_method(), a method with
  the same name is searched in refinements.  If such a method is
  found, the method is invoked.  Otherwise, the original method in
  the refined class (rb_method_definition_t::body.orig_def) is
  invoked.  This change is made to simplify the normal method lookup
  and to improve the performance of normal method calls.

* vm_method.c (EXPR1, search_method, rb_method_entry),
  vm_eval.c (rb_call0, rb_search_method_entry): do not use
  refinements for method lookup.

* vm_insnhelper.c (vm_call_method): search methods in refinements if
  ci->me is VM_METHOD_TYPE_REFINED.  If the method is called by
  super (i.e., ci->call == vm_call_super_method), skip the same
  method entry as the current method to avoid infinite call of the
  same method.

* class.c (include_modules_at): add a refined method entry for each
  method defined in a module included in a refinement.

* class.c (rb_prepend_module): set an empty table to
  RCLASS_M_TBL(klass) to add refined method entries, because
  refinements should have priority over prepended modules.

* proc.c (mnew): use rb_method_entry_with_refinements() to get
  a refined method.

* test/ruby/test_refinement.rb (test_inline_method_cache): do not skip
  the test because it should pass successfully.

* test/ruby/test_refinement.rb (test_redefine_refined_method): new
  test for the case a refined method is redefined.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29 12:50:10 +00:00
zzak 8baab38ad2 * gc.c: Documentation for GC, GC::Profiler, ObjectSpace, and
ObjectSpace::WeakMap [ruby-core:50245] [Bug #7449]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29 08:15:53 +00:00
ko1 502ab126ac * gc.c (gc_stat): prepre Symbol objects at first time
to make it fast.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29 05:29:22 +00:00
ko1 c512d6acf9 * gc.c (gc_stat): GC.stat supports new information
* total_allocated_object: total allocated object number.
* total_freed_object: total freed object number.
  Above two numbers are only accumulated and they will
  overflow (return to 0). Please use them as a hint.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29 05:05:19 +00:00
shirosaki 56132b1346 array.c: refactoring of rb_ary_delete_same()
* array.c (ary_resize_smaller): new function to resize array.

* array.c (rb_ary_delete): refactoring to extract a function.

* array.c (rb_ary_delete_same): refactoring.
  It renames function, reduces duplicated code and removes unused
  code.

* gc.c (wmap_final_func): follow the above change.

* internal.h (rb_ary_delete_same): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-25 13:39:26 +00:00
shirosaki 7b298723b0 gc.c: refactoring to rename variables
* gc.c (wmap_final_func): rename variables to clarify the meaning.
  In wmap2obj the key is WeakRef and the value is referenced object.
  In obj2wmap the key is referenced object and the value is an array
  of WeakRef.

* gc.c (wmap_finalize): ditto.
  [ruby-core:49044] [Bug #7304]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37835 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-24 12:26:57 +00:00
shirosaki 1cdeab5cdd Fix WeakRef finalize
* array.c (rb_ary_delete_same_obj): new function for WeakRef.
  This deletes same objects as item argument in the array.

* internal.h (rb_ary_delete_same_obj): add a declaration.

* gc.c (wmap_final_func): remove WeakRef object reference from the
  array. rb_ary_delete() is not usable because it uses rb_equal() to
  compare object references.

* gc.c (wmap_finalize): remove recycled object references from weak
  map hash properly. How to get object reference from object id was
  wrong. st_delete() doesn't work properly if key and value arguments
  are same. The key of obj2wmap is referenced object and the value of
  obj2wmap is WeakRef array.

* gc.c (wmap_aset): obj2wmap should contain WeakRef array in the
  definition.

* test/test_weakref.rb
  (TestWeakRef#test_not_reference_different_object,
   TestWeakRef#test_weakref_finalize): add tests for above.
  [ruby-core:49044] [Bug #7304]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-24 12:26:54 +00:00
naruse 757413f6bb Rvert r37827 and r37828
Revert "Fix finalize of WeakRef"
This causes segv on rubyspec.
http://u64.rubyci.org/~chkbuild/ruby-trunk/log/20121124T050101Z.log.html.gz

you can reproduce by
 make test-rubyspec MSPECOPT='-V library/weakref'

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-24 07:43:13 +00:00
shirosaki 3fac4abc7b wmap_finalize: refactoring to rename variables
* gc.c (wmap_final_func): rename variables to clarify the meaning.
  In wmap2obj the key is WeakRef and the value is referenced object.
  In obj2wmap the key is referenced object and the value is an array
  of WeakRef.

* gc.c (wmap_finalize): ditto.
  [ruby-core:49044] [Bug #7304]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-24 04:01:37 +00:00
shirosaki 82cac33ecb Fix finalize of WeakRef
* gc.c (wmap_final_func): remove WeakRef object reference from the
  array.

* gc.c (wmap_finalize): remove recycled object references from weak
  map hash properly. How to get object reference from object id was
  wrong. st_delete() doesn't work properly if key and value arguments
  are same. The key of obj2wmap is referenced object and the value of
  obj2wmap is WeakRef array.

* gc.c (wmap_aset): obj2wmap should contain WeakRef array in the
  definition.

* test/test_weakref.rb
  (TestWeakRef#test_not_reference_different_object): add a test for
  above.
  [ruby-core:49044] [Bug #7304]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-24 04:01:33 +00:00
nari 66db637a9f * gc.c (is_swept_object): extract from is_dead_object().
* gc.c (rb_gcdebug_print_obj_condition): add the function for debug.
  This function shows some conditions of given object (e.g.,
  marked, in heap, swept).

* gc.c (rb_gcdebug_sentinel): add the function for debug.
  This function allow check to inadvertently free up an object.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-22 15:03:46 +00:00
nari 7d0cabb8f8 * gc.c (garbage_collect): remove a duplicative probe.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-21 13:31:06 +00:00
nari fe9fc6df01 * gc.c (gc_profile_clear): realloc profile records if its size is
higher than the threshold, GC_PROFILE_RECORD_DEFAULT_SIZE * 2.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-21 13:15:10 +00:00
tenderlove 4c740bae97 * probes.d: add DTrace probe declarations. [ruby-core:27448]
* array.c (empty_ary_alloc, ary_new): added array create DTrace probe.

* compile.c (rb_insns_name): allowing DTrace probes to access
  instruction sequence name.

* Makefile.in: translate probes.d file to appropriate header file.

* common.mk: declare dependencies on the DTrace header.

* configure.in: add a test for existence of DTrace.

* eval.c (setup_exception): add a probe for when an exception is
  raised.

* gc.c: Add DTrace probes for mark begin and end, and sweep begin and
  end.

* hash.c (empty_hash_alloc): Add a probe for hash allocation.

* insns.def: Add probes for function entry and return.

* internal.h: function declaration for compile.c change.

* load.c (rb_f_load): add probes for `load` entry and exit, require
  entry and exit, and wrapping search_required for load path search.

* object.c (rb_obj_alloc): added a probe for general object creation.

* parse.y (yycompile0): added a probe around parse and compile phase.

* string.c (empty_str_alloc, str_new): DTrace probes for string
  allocation.

* test/dtrace/*: tests for DTrace probes.

* vm.c (vm_invoke_proc): add probes for function return on exception
  raise, hash create, and instruction sequence execution.

* vm_core.h: add probe declarations for function entry and exit.

* vm_dump.c: add probes header file.

* vm_eval.c (vm_call0_cfunc, vm_call0_cfunc_with_frame): add probe on
  function entry and return.

* vm_exec.c: expose instruction number to instruction name function.

* vm_insnshelper.c: add function entry and exit probes for cfunc
  methods.

* vm_insnhelper.h: vm usage information is always collected, so
  uncomment the functions.

12 19:14:50 2012  Akinori MUSHA  <knu@iDaemons.org>

* configure.in (isinf, isnan): isinf() and isnan() are macros on
  DragonFly which cannot be found by AC_REPLACE_FUNCS().  This
  workaround enforces the fact that they exist on DragonFly.

12 15:59:38 2012  Shugo Maeda  <shugo@ruby-lang.org>

* vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo),
  vm_insnhelper.c (vm_search_method): revert r37616 because it's too
  slow.  [ruby-dev:46477]

* test/ruby/test_refinement.rb (test_inline_method_cache): skip
  the test until the bug is fixed efficiently.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-12 21:52:12 +00:00
nari 8a9097e83c * gc.c: move immutable fields from struct heaps_slot and struct
sorted_heaps_slot into struct heaps_header.
  Based on a patch from Sokolov Yura [Feature #6199][ruby-core:43592]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-10 15:04:27 +00:00
ngoto 05a05cc62b * ruby_atomic.h: renamed from atomic.h to avoid header file name conflict
on Solaris 10. [ruby-dev:46414] [Bug #7287]
* gc.c, signal.c, vm_core.h, common.mk: reflect the rename from atomic.h
  to ruby_atomic.h.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-09 16:05:07 +00:00
knu 1c0323adbc Fix build when gcc is used and the platform's libc lacks alloca().
* include/ruby/ruby.h (alloca), eval_intern.h (alloca), gc.c
  (alloca): Make alloca() globally available by moving the
  ultimate ifdef's to ruby/ruby.h.  Gcc hides its builtin alloca()
  when compiling with -ansi, and linking thus fails on platforms
  that lack their own alloca() implementation in libc, which
  include OpenBSD and some ports of NetBSD.  We use alloca()
  everywhere including from within third party C extentions, so
  alloca() must be made globally available. [Bug #7307]

* addr2line.c (alloca): Replace the alloca() part with the
  ultimate ifdef's. [Bug #7307]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37571 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-09 03:34:08 +00:00
nari 25a973e84b * gc.c (gc_profile_record): don't define unused variables when
GC_PROFILE_MORE_DETAIL is 0.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-31 09:22:37 +00:00
nari 9fd08911c0 * gc.c (gc_prof_mark_timer_stop): count is not initialized.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-31 09:22:35 +00:00
nobu 78625e5852 gc.c: PRIuSIZE
* gc.c (gc_profile_dump_on): use PRIuSIZE instead of 'zu'.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-29 03:19:38 +00:00
eregon 1fe5783104 * gc.c (gc_profile_result, gc_profile_report): use internal structures
to avoid allocations and progressively print the output for #report.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-27 14:36:22 +00:00
nari a4ba41a29d rename it to a more fitting name
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-24 04:29:53 +00:00
nari bda726223f fix the function name which is not grammatically correct.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-24 04:14:22 +00:00
nari f0a435c187 * gc.c (free_object_aquire): rename to match the behavior of this
function.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-24 03:55:46 +00:00
ko1 aab12ec054 * gc.c (garbage_collect, gc_marks): move the location of
clear and restore rb_objspace_t::mark_func_data
  from garbage_collect() to gc_marks().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-24 01:39:45 +00:00
ko1 6c6dece7f1 * ext/objspace/objspace.c (ObjectSpace.reachable_objects_from):
internal object support.
  If given object `obj' has references to internal objects
  (such as T_NODE objects), then this method returns instances of
  `ObjectSpace::InternalObjectWrapper' instead of that internal objects.
  This instance contains a refereance to an internal object and you can
  check the type of internal object using
  `ObjectSpace::InternalObjectWrapper#type' method.
  Rdoc of `InternalObjectWrapper' is not prepared yet.
* gc.c (rb_objspace_reachable_objects_from), gc.h: change
  an interface of 'rb_objspace_reachable_objects_from()'
* gc.c, gc.h: add two APIs
  - rb_objspace_markable_object_p(obj): check markable or not.
  - rb_objspace_internal_object_p(obj): check internal or not.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-24 00:04:56 +00:00
eregon 0ef8222e63 * gc.c: fix typos in documentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37276 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-20 11:36:46 +00:00
nari c3a46d6aca * include/ruby/ruby.h: add C APIs.
VALUE rb_newobj_of(VALUE klass, VALUE flags)
  #define NEWOBJ_OF(obj,type,klass,flags)
  These allow to change a allocation strategy depending on klass
  or flags.

* gc.c: ditto

* array.c: use new C API.
* bignum.c: ditto
* class.c: ditto
* complex.c: ditto
* ext/socket/ancdata.c: ditto
* ext/socket/option.c: ditto
* hash.c: ditto
* io.c: ditto
* marshal.c: ditto
* numeric.c: ditto
* object.c: ditto
* random.c: ditto
* range.c: ditto
* rational.c: ditto
* re.c: ditto
* string.c: ditto
* struct.c: ditto
  [Feature #7177][Feature #7047]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-20 06:57:51 +00:00
shugo e028d3d905 * eval.c, gc.c, iseq.c, node.h, vm_insnhelper.c, vm_insnhelper.h,
vm_method.c: rename omod and overlaid modules to refinements.

* eval.c (hidden_identity_hash_new): renamed from identity_hash_new.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-08 14:02:46 +00:00
nobu b1058ef46c gc.c: use markable_object_p
* gc.c (gc_mark_children): use markable_object_p() and reduce
  duplicated code.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37103 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-06 00:50:12 +00:00
nari 3376ea81f9 fix comments
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-05 09:21:41 +00:00