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

971 Коммитов

Автор SHA1 Сообщение Дата
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
nari 4c0f022f45 revert r37091
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-05 09:19:49 +00:00
ko1 e03d6d9eb8 * ext/objspace/objspace.c: add ObjectSpace#reachable_objects_from.
This method returns an array of objects referenced by given object.
  If given object is special objects such as true/false/nil/Fixnum etc
  then it returns nil. See rdoc for details.
  [ruby-core:39772]
* test/objspace/test_objspace.rb: add a test for this method.
* gc.c: add rb_objspace_reachable_objects_from().
  To make this function, add several member `mark_func_data'
  to rb_objspace_t.  If mark_func_data is not null, then
  gc_mark() calls mark_func_data::mark_func.
* gc.h: export rb_objspace_reachable_objects_from().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-05 08:14:09 +00:00
nari 271f069c7f * gc.c (chain_finalized_object): remove to check a mark flag and
marking since all objects are certainly unmarked with rest_sweep.

* gc.c (rb_objspace_call_finalizer): remove to mark finalizable
  objects. The sweeping doesn't push T_ZOMBIE objects to the
  freelist.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37091 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-05 07:20:49 +00:00
nari ec62e30196 * gc.c (init_heap): call init_mark_stack before to allocate
altstack. This change avoid the stack overflow at the signal
  handler on 32bit, but I don't understand reason... [Feature #7095]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37088 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-04 14:48:02 +00:00
nari 2f9f17ac98 * gc.c (rb_objspace_call_finalizer): call gc_mark_stacked_objects
at suitable point.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-04 08:34:20 +00:00
nobu 6aa2aabd8b gc.c: self-referencing finalizers
* gc.c (rb_objspace_call_finalizer): mark self-referencing finalizers
  before run finalizers, to fix SEGV from btest on 32bit.
* gc.c (gc_mark_stacked_objects): extract from gc_marks().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-04 07:31:31 +00:00
nobu 6fa2980e53 * gc.c: use enum for debugging.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-04 07:23:41 +00:00
nobu 4336caf204 gc.c: unused function
* gc.c (free_stack_chunks): it is used only when per-VM object space
  is enabled.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-03 13:23:30 +00:00
nari 8d53a08ed8 * gc.c: Use the non-recursive marking instead of recursion. The
recursion marking of CRuby needs checking stack overflow and the
  fail-safe system, but these systems not good at partial points,
  for example, marking deep tree structures. [ruby-dev:46184]
  [Feature #7095]

* configure.in (GC_MARK_STACKFRAME_WORD): removed. It's used by
  checking stack overflow of marking.

* win32/Makefile.sub (GC_MARK_STACKFRAME_WORD): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37075 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-03 12:30:21 +00:00
ko1 e3990633cb * insns.def (opt_checkenv): remove unused instruction `opt_checkenv'.
* compile.c (iseq_compile_each): ditto.
* node.h: remove unused node `NODE_OPTBLOCK'.
* ext/objspace/objspace.c, gc.c (gc_mark_children): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37045 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-28 06:44:24 +00:00
ko1 b3b5e626ad * include/ruby/ruby.h: introduce flonum technique for
64bit CPU environment (sizeof(double) == sizeof(VALUE)).
  flonum technique enables to avoid double object creation
  if the double value d is in range about between
  1.72723e-77 < |d| <= 1.15792e+77 or 0.0.
  flonum Float value is immediate and their lowest two bits
  are b10.
  If flonum is activated, then USE_FLONUM macro is 1.
  I'll write detailed in this technique on
  https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/Flonum_tech
* benchmark/bmx_temp.rb: add an benchmark for simple
  Float calculation.
* gc.c (id2ref, rb_obj_id): add flonum Float support.
* include/ruby/intern.h: move decl of rb_float_new(double)
  to include/ruby/ruby.h.
* insns.def, vm.c, vm_insnhelper.c: add flonum optimization
  and simplify source code.
* vm_insnhelper.h (FLONUM_2_P): added.
* marshal.c: support flonum output.
* numeric.c (rb_float_new_in_heap): added.
* parse.y: support flonum.
* random.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-23 07:22:40 +00:00
drbrain 33a63355a7 * gc.c (gc_malloc_allocated_size): RDoc does not process macros, so
mention this method is only available when ruby is built with
	  CALC_EXACT_MALLOC_SIZE
	* gc.c (gc_malloc_allocations):  ditto


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-09 23:42:01 +00:00
nari 8f1c81c610 * gc.c : if ENABLE_VM_OBJSPACE is 1, rest_sweep is not defined.
remove unused declarations.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-05 12:12:45 +00:00
nari dd124a0f84 * gc.c: just move functions and so on. I don't touch any internal
implementation.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36626 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-05 10:39:37 +00:00
nari de0c788bb4 * gc.c: use inline functions instead of macros, and close up
related codes for the profiler.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-04 14:12:12 +00:00
nari d7a3331682 * gc.c (gc_mark_children): use gc_mark_ptr instead of marking
a object directly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-04 11:40:59 +00:00
shugo 19ddfc2483 * eval.c (rb_mod_using): new method Module#using. [experimental]
* eval.c (rb_mod_refine): new method Module#refine. [experimental]

* eval.c (f_using): new method Kernel#using. [experimental]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-02 11:34:19 +00:00
nari b79bf14ff2 * gc.c: return true or false. Patch by Dirkjan Bussink. [Bug #6821]
* test/ruby/test_gc.rb: add test-case for this bug.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-02 02:47:12 +00:00
nari 631b6d5aad * gc.c: remove unused initialization.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-28 15:34:44 +00:00
nobu c51a826764 rb_thread_call_without_gvl
* include/ruby/thread.h: new header file for thread stuff.
* thread.c (rb_thread_call_without_gvl): export.  [Feature#4328]
  returns void* instead of VALUE.  [Feature #5543]
* thread.c (rb_thread_blocking_region): deprecate.  [ruby-core:46295]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-10 13:57:11 +00:00
ngoto 87c25d897b * gc.c, atomic.h (ATOMIC_SIZE_*): moved from gc.c to atomic.h [ruby-dev:45909]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-04 13:02:03 +00:00
usa 38ca5cca00 * gc.c (ATOMIC_SIZE_*): 64bit Windows support.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-04 02:53:20 +00:00
ngoto 1e972da39c * gc.c (ATOMIC_SIZE_EXCHANGE): fix function name on Solaris [Bug #6689]
[ruby-dev:45904]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36290 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-03 14:25:32 +00:00
nobu a7c6f0afae gc.c: atomic operations for malloc_params
* gc.c (vm_malloc_fixup, vm_xrealloc, vm_xfree, after_gc_sweep): use
  atomic operations to update malloc_params.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36284 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-03 07:07:57 +00:00
nobu c7c397f917 fix allocated_size
* gc.c (vm_xrealloc): fix allocated_size update, should not ignore old
  size.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36282 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-03 05:37:29 +00:00
nobu 82cd48d7ee gc.c: simplified
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35875 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-02 21:34:14 +00:00
nobu 960660353f adjust indent
* gc.c (os_obj_of_i): adjust indent.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35853 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-31 14:59:03 +00:00
nari e2f4f34467 * gc.c (obj_free): doesn't free a method table if it doesn't
exits. [ruby-dev:44436]
* test/ruby/test_gc.rb (class TestGc): added the test case for
  this issue.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-28 03:12:33 +00:00
yugui 76bc2d1ed7 Imports Ruby's port to NativeClient (a.k.a NaCl).
Patch by Google Inc. [ruby-core:45073].

* configure.in (RUBY_NACL): New M4 func to configure variables for
  NaCl.
  (RUBY_NACL_CHECK_PEPPER_TYPES): New M4 func to check the old names
  of Pepper interface types.
  (BTESTRUBY): New variable to specify which ruby should be run on
  "make btest". NaCl can run the built binary by sel_ldr, but it need
  rbconfig.rb. So this variable is distinguished from $MINIRUBY.
  
* thread_pthread.c: Disabled some features on NaCl.

* io.c: ditto.

* process.c: ditto.

* signal.c: ditto.

* file.c: ditto.

* missing/flock.c: ditto.

* nacl/pepper_main.c: An example implementation of Pepper application
  that embeds Ruby.

* nacl/example.html: An example of web page that uses the Pepper
  application.

* nacl/nacl-config.rb: Detects variants of NaCl SDK.

* nacl/GNUmakefile.in: Makefile template for NaCl specific build
  process.

* nacl/package.rb: script for packaging a NaCl-Ruby embedding
  application. 

* nacl/reate_nmf.rb: Wrapper script of create_nmf.py

* dln.c (dln_load): Added a hack to call on NaCl.

* util.c (ruby_getcwd): Path to the current directort is not available
  on NaCl.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-17 02:48:59 +00:00
nobu bb8446205f * gc.c (obj_free): show entire flags too.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-13 02:51:40 +00:00
nobu 871cd27c8d * gc.c (GET_HEAP_HEADER, NUM_IN_SLOT): parenthesise macro parameters.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35310 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-12 06:10:33 +00:00
nobu 28cc4f7543 * st.c (st_update): pass pointer to key to the callback function.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35172 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-29 14:50:20 +00:00
nobu 30cea65767 * st.c (st_update): add existing parameter to the callback function.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35170 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-29 07:36:12 +00:00
nobu e30dbb3671 fix condition for free
* gc.c (aligned_free): fix condition for free.  memalign() and
  posix_memalign() are not defined together normally.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35084 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-18 14:21:31 +00:00
yugui 1d006f353d * gc.c (aligned_malloc, aligned_free): added fallback implementations
for platforms like OSX Leopard.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-18 11:15:50 +00:00
nobu 2555f3f5bf * gc.c (free_method_entry_i): method entry may be in
unlinked_method_entry_list.  [ruby-core:43383][Bug #6171]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35080 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-18 08:17:39 +00:00
nobu df058ea0e3 Bug #5350
* gc.c: add ObjectSpace::WeakMap.  [ruby-dev:44565][Bug #5350]
* lib/weakref.rb: use WeakMap instead of _id2ref.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34995 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-13 03:37:06 +00:00
nari 0d44bf83da * gc.c : remove gc_clear_mark_on_sweep_slots() and use
rest_sweep() instead of it, because some dead objects might be
  marked in next the mark phase by false pointers.
  [ruby-core:42672]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34719 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-21 09:35:07 +00:00
nari 87a15a6981 revert r34691 and r34689
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-19 10:18:16 +00:00
nari f0e9fa3cb1 * gc.c (gc_clear_mark_on_sweep_slots): remove a unused variable.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-19 04:11:19 +00:00
nari 55e6e9e384 * gc.c (gc_clear_mark_on_sweep_slots): uses slot_sweep() for
unsweeped slots, because some dead objects might be marked in
  next the mark phase by false pointers.  [ruby-core:42672]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34689 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-19 03:07:59 +00:00
nagachika 2910f6736e * cont.c (rb_fiber_reset_root_local_storage): add a new function to
restore rb_thread_t::local_storage.

* cont.c (rb_obj_is_fiber): add a new function to tell finalizer to
  prevent fibers from destroy.

* gc.c (rb_objspace_call_finalizer): don't sweep fibers at finalizing
  objspace.

* internal.h (rb_fiber_reset_root_local_storage, rb_obj_is_fiber):
  add prototypes.

* vm.c (ruby_vm_destruct): reset main thread's local_storage before
  free main thread. rb_thread_t::local_storage is replaced by fiber's
  local storage when forked from fiber, and it should be already freed
  when the fiber was destroyed.

* test/ruby/test_fiber.rb (test_fork_from_fiber): add test for fork
  from fiber.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34629 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-15 14:00:11 +00:00
nari 8b4b4032f7 * gc.c (HEAP_BITMAP_LIMIT): HEAP_BITMAP_LIMIT is computed on the
basis of HEAP_SIZE because it must covers a whole heap block.
  [ruby-trunk - Bug #6006]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-15 02:09:44 +00:00
nari 0da31416f1 * gc.c (CEILDIV): rename to a appropriate name.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34599 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-14 11:26:24 +00:00
nari 64e7aedcee * gc.c (assign_heap_slot): SEGV happens cause on 64-bit platform
sometime there should be `objs-=2` instead of `objs--`.
  patched by Sokolov Yura. https://github.com/ruby/ruby/pull/92

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-14 09:11:24 +00:00
nari 261400e7a9 * gc.c (HEAP_OBJ_LIMIT, HEAP_BITMAP_LIMIT): HEAP_OBJ_LIMIT used
`sizeof(struct heaps_slot)` while heap is currently allocated
  with `struct heaps_header`.
  HEAP_BITMAP_LIMIT were calculated from
  `HEAP_OBJ_LIMIT/sizeof(uintptr_t)` - one Byte for each object,
  not one Bit. [Bug #6006]
  patched by Sokolov Yura. https://github.com/ruby/ruby/pull/92

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34581 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-13 12:57:16 +00:00
nari a42cc41ba1 * configure.in (HEAP_ALIGN_LOG): HEAP_ALIGN_LOG should be page
size in OpenBSD. [ruby-core:42158][Bug #5901]

* gc.c : avoid to redefine.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34404 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-31 12:36:50 +00:00
nobu a92dd46dd5 * gc.c (HEAP_ALIGN, HEAP_ALIGN_MASK): DRY, let compiler calculate
from HEAP_ALIGN_LOG.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34381 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-27 07:31:50 +00:00
nobu e87c0e6574 * gc.c (aligned_malloc, aligned_free): covered missing defined
operators and fixes for cygwin.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-17 03:32:50 +00:00
nagachika 28d28e844e * gc.c (ruby_mimmalloc): don't set allocated size to header.
ruby_mimmalloc() doesn't increment allocated_size/allocations and
  decrement them in ruby_xfree() cause inconsistency.

* gc.c (ruby_xfree): don't decrement allocated_size/allocations if
  allocated size record is 0.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-11 14:09:10 +00:00
nobu a54832714d * gc.c (HEAP_OBJ_LIMIT): suppress narrowing down warning from gcc 4.2.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-10 06:52:24 +00:00
naruse 931459d974 * gc.c: in fact, i686-linux doesn't need to define _XOPEN_SOURCE 600.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34258 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-10 03:50:23 +00:00
naruse 56dc6f5acc * gc.c (ruby_mimmalloc): defined for objects need not rb_objspace,
but should return pointer suitable for ruby_xfree;
  main vm and main thread.
  patched by Sokolov Yura. https://github.com/ruby/ruby/pull/79

* internal.h: ditto.

* vm.c (Init_BareVM): use ruby_mimmalloc.

* ext/dl/cfunc.c: #include <ruby/util.h>.

* ext/syslog/syslog.c: use xfree because it is allocated by
  ruby_strdup.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34257 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-10 03:49:10 +00:00
nagachika fcb05d8683 * gc.c (run_finalizer): clear rb_thread_t::errinfo when ignore
an exception under rb_protect(). [ruby-dev:45113]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-09 15:35:06 +00:00
nari b78bddee35 * gc.c : don't embed struct heaps_slot to a heap block because it
can causes copy-on-write of memory page on heap block when its
  free_next is rewirted.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34247 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-09 11:58:12 +00:00
nari 2cf2416ea0 * gc.c: free_slots is changed Singly linked list. clear
free_slots before sweep.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-09 06:02:01 +00:00
naruse 471394f647 * gc.c: i686-linux needs to define _XOPEN_SOURCE 600 for posix_memalign.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-08 22:50:59 +00:00
naruse 88b16cebc8 * gc.c (rb_objspace_free): global_List is allocated with xmalloc.
patched by Sokolov Yura.  https://github.com/ruby/ruby/pull/78

* dln_find.c: remove useless replacement of free.

* ext/readline/readline.c (readline_attempted_completion_function):
  strings for readline must allocated with malloc.

* process.c (run_exec_dup2): use free; see also r20950.

* re.c (onig_new_with_source): use malloc for oniguruma.

* vm.c (ruby_vm_destruct): use free for VMs.

* vm.c (thread_free): use free for threads.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-08 21:02:08 +00:00
nari 5393622dad * gc.c : consider header bytes which are used by malloc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-08 11:55:04 +00:00
nari cd73f29465 * gc.c (aligned_free): support MinGW. Patch by Hiroshi Shirosaki.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-08 02:59:04 +00:00
nari 94fd32b80a * gc.c (slot_sweep): add a assertion instead of a debug print.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34233 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-08 02:46:19 +00:00
kosaki e3b0732050 * gc.c: get rid of implicit narrowing conversion.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34230 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-07 15:47:45 +00:00
naruse 411fa36c73 * configure.in: check posix_memalign(3) and menalign(3).
* gc.c (aligned_malloc): use configure's result instead of
  _POSIX_C_SOURCE and _XOPEN_SOURCE because they can't be used
  to check availability at least on FreeBSD.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34226 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-07 15:13:37 +00:00
nari 50675fdba1 * gc.c: use Bitmap Marking algorithm to avoid copy-on-write of
memory pages. See [ruby-dev:45085] [Feature #5839]
  [ruby-core:41916].

* include/ruby/ruby.h : FL_MARK rename to FL_RESERVED1.

* node.h : ditto.

* debug.c : ditto.

* object.c (rb_obj_clone): FL_MARK move to a bitmap.

* class.c (rb_singleton_class_clone): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-07 14:02:23 +00:00
mame 1ab3974b0e * node.h, node.c, parse.y: implement a parser part for keyword arguments. This is a preparation for keyword argument (see [ruby-core:40290]).
* gc.c (gc_mark_children): bookkeeping.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34135 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-26 14:20:03 +00:00
mame afb10c62c2 * node.h, parse.y (new_args_gen), compile.c (iseq_set_arguments): use struct rb_args_info instead of NODEs. This is a preparation for keyword argument (see [ruby-core:40290]).
* node.c (dump_node), gc.c (gc_mark_children, obj_free): bookkeeping.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34134 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-26 14:19:58 +00:00
nobu b526738c3b * bignum.c (big_rshift), compile.c (validate_label,
iseq_build_from_ary_exception), cont.c (cont_capture), dir.c
  (dir_open_dir), gc.c (objspace_each_objects), io.c (pipe_open)
  (rb_io_advise), parse.y (parser_compile_string)
  (rb_parser_compile_file), proc.c (binding_free), process.c
  (rb_proc_exec_n, rb_seteuid_core, proc_setegid, rb_setegid_core)
  (p_uid_exchange, p_gid_exchange), regparse.c (strdup_with_null),
  signal.c (sig_dfl), vm.c (rb_iseq_eval, rb_iseq_eval_main),
  vm_insnhelper.c (vm_expandarray): suppress
  unused-but-set-variable warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33951 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-05 09:57:00 +00:00
usa 2d0c17d4fb * gc.c (initial_params): static. it seems to be forgetten at r33501.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33882 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-28 03:38:52 +00:00
nobu cb2a69d883 * gc.c (initial_params): pack in a struct.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-21 13:02:19 +00:00
nobu fd807aa2ea * gc.c (rb_gc_set_params): set parameters always.
[ruby-dev:44648] [Bug #5467]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-21 13:01:37 +00:00
nobu c180eabf8f * gc.c (rb_gc_finalize_deferred, rb_objspace_call_finalizer):
should use ATOMIC_EXCHANGE() to check the previous value.
  [ruby-dev:44596] [Bug #5439]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-13 09:04:29 +00:00
nobu 92a05ea2cf * class.c (class_alloc): allocate extra memory after containing
object setup to get rid of rare-but-potential memory leak.
* gc.c (gc_mark_children): skip marking extended members if ptr is
  NULL.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-04 12:10:09 +00:00
naruse 356c7cbfb6 * gc.c (rb_gc_set_params): ruby_verbose can be Qnil, so use RTEST.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-04 02:44:55 +00:00
nagachika 3973e70d92 * gc.c (rb_gc_set_params): output GC parameter change messages only
if -w/-v options are specified. these messages are output to stderr,
  not to stdout. [ruby-core:39795] [Bug #5380]

* test/ruby/test_gc.rb (test_gc_parameter): add test for it.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-03 15:02:58 +00:00
nagachika 3d2451d996 * gc.c (add_heap_slots, init_heap): reset heaps_inc zero when
heap slots are expanded by environment variable RUBY_HEAP_MIN_SLOTS.
  [ruby-core:39777] [Bug #5380]

* test/ruby/test_gc.rb (test_gc_parameter): add test for it.

* test/ruby/envutil.rb (assert_normal_exit): add :child_env option to
  enable pass environemnt variables to child process.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33368 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-01 01:00:40 +00:00
nobu a73b88ae43 * gc.c (slot_sweep, rb_gc_finalize_deferred)
(rb_objspace_call_finalizer, rb_gc): run finalizers
  sequencially.  [ruby-dev:44562]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-29 16:54:14 +00:00
nobu 71d1102525 * gc.c (is_id_value, is_live_object): extract from id2ref().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-29 11:10:46 +00:00
nobu b2658a7604 * gc.c (run_finalizer): use object instead of object id.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33358 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-29 11:09:48 +00:00
nobu 8e6e8e6288 * use RB_TYPE_P which is optimized for constant types, instead of
comparison with TYPE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-29 11:07:45 +00:00
nobu 62dfc45bb2 suppress warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33326 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-25 07:42:38 +00:00
nobu 89e490f1de * gc.c (mark_entry, mark_key, mark_keyvalue): adjust callback
argument types.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-15 02:39:49 +00:00
ko1 49042ae821 * gc.c (GC_PROFILE_MORE_DETAIL, CALC_EXACT_MALLOC_SIZE):
define macros only if they are not defined.
  fixes: [Ruby 1.9 - Feature #5291]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-09 23:34:05 +00:00
nari 599071b700 * gc.c (Init_GC): defined GC::Profiler.raw_data. based on the
patch by Eric Hodel. [ruby-core:37857] [Bug #4991]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33224 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-08 03:57:41 +00:00
nobu ac6ad66d0b * gc.c (id2ref): objects which are unmarked but not in sweep_slots
are not dead.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-08 00:02:55 +00:00
nobu 4fe51cb330 * gc.c (id2ref): unmarked object is already dead while lazy
sweeping, and to it cannot come back since other objects
  referred from it might have been freed already.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33219 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-07 22:33:14 +00:00
nobu bc2a1f2a98 * variable.c (rb_const_set): show the previous definition
location.  [EXPERIMENTAL]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-03 15:11:53 +00:00
nari e26cead1e9 * gc.c (gc_lazy_sweep): if sweep target slots are not found, we
try heap_increment() because it might be able to expand the
  heap. [Bug #5127] [ruby-dev:44285]

* gc.c (gc_clear_mark_on_sweep_slots): if a sweeping was
  interrupted, we expand the heap if at all possible.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-09 04:26:15 +00:00
naruse ae1bccf7a4 Refix r32815.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32821 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-02 15:39:10 +00:00
naruse 027a15e958 * gc.c (init_heap): allocate sigaltstack after heaps are allocated.
[ruby-dev:44315] [Bug #5139]

* vm.c (thread_free): use free because objspace is not ready.

* vm.c (th_init): use malloc because objspace is not ready.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32815 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-02 13:08:45 +00:00
mame 9a27239558 * proc.c (struct METHOD), gc.c (gc_marks), vm_method.c
(rb_gc_mark_unlinked_live_method_entries): fix SEGV bug.
  rb_method_entry_t was free'd even when the method is still on the
  stack if it is BMETHOD (i.e., Method#call).  This is because
  rb_method_entry_t is embedded in struct METHOD.  This commit
  separates them and marks the live method entries.
  See [ruby-core:38449] in detail.  fix [Bug #5047] [ruby-core:38171]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-25 14:29:28 +00:00
drbrain 50b64ee7de * gc.c: Improve documentation
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-08 00:18:39 +00:00
nari 17bb77fd77 * gc.c: change water_mark value value that may call
gc_mark(lev <= GC_LEVEL_MAX) in gc_mark().
  In ruby_stack_check(), water_mark is a value that may call some
  C function. Fixes Bug #3781

* configure.in: define GC_MARK_STACKFRAME_WORD that approximate
  size of gc_mark() and gc_mark_children() stackframes.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-07 14:59:09 +00:00
akr e7996eb3cc * internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.

* iseq.h: declare rb_iseq_t dependent internal functions here.

* vm_core.h: declare rb_thread_t dependent internal functions here.

* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
  enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
  iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
  proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
  thread.c, time.c, transcode.c, variable.c, vm.c,
  tool/compile_prelude.rb: don't declare internal functions declared
  in above headers.  include above headers if required.

  Note that rb_thread_mark() was declared as
  void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
  void rb_thread_mark(void *ptr) in vm.c.  Now it is declared as
  the later in internal.h.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 22:43:38 +00:00
kosaki 3c23284734 * thread.c (rb_thread_schedule_rec): fix {UN,}LIKELY macro misuse.
* gc.c (rb_newobj): ditto.
* vm_insnhelper.c (vm_method_search): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-16 14:42:02 +00:00
kosaki 8923ba1ec9 * gc.c: fix a regression by r31690 on AIX because AIX malloc
return NULL if it's passed 0. But some caller don't expect it.
  patch by Yutaka Kanemoto.
(vm_malloc_prepare): return calculated size.
(vm_xmalloc): use above result.
(vm_xcalloc): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32103 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-15 14:35:46 +00:00
nari b6135f1cd7 * gc.c (rb_gc_set_params): call initial_expand_heap if
initial_heap_min_slots is set.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-14 02:13:52 +00:00
nari 8c79b8b6b8 * gc.c: use size_t.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-14 02:13:51 +00:00
nobu df3e3768e9 * atomic.h (ATOMIC_OR): _InterlockedOr is not available on migw.
* gc.c (rb_gc_set_params): VM_OBJSPACE is disabled on mignw.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32018 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-12 00:32:32 +00:00
nari 11c43f7ae9 * gc.c: expand heap if initial_heap_min_slots is bigger than
HEAP_MIN_SLOTS.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-11 10:51:51 +00:00
nagachika 5aee85cef1 * gc.c: remove an unused declaration.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-09 15:31:02 +00:00
nagachika 1fdbe0f437 * gc.c (rb_objspace_call_finalizer): use rb_typeddata_is_kind_of() for
type check to get rid of a double free when main Thread has singleton
  class. [ruby-core:36741] [Bug #4828]
* thread.c (rb_obj_is_mutex): add a new utility function.
* vm.c (rb_obj_is_thread): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-09 14:45:56 +00:00
nobu 70b4b6dc8b * gc.c (vm_xcalloc): use calloc provided by platforms.
fixes #4754

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-22 09:26:46 +00:00
iwamatsu e6a51e8f8c * gc.c: Fix build on m68k by 'error: too few arguments to
function 'mark_locations_array''.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-20 06:05:54 +00:00
nobu 52f5f410e4 * internal.h: add for internal use only.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-18 13:41:54 +00:00
naruse 436d5dc6eb * gc.c (rb_objspace): an initializer must be a constant.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31054 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-07 16:17:27 +00:00
matz eb807d42ec * gc.c (rb_gc_set_params): allow GC parameter configuration by
environment variables.  based on a patch from funny-falcon at
  https://gist.github.com/856296, but honors safe level.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-07 08:39:39 +00:00
akr fd2f238560 * vm.c (thread_free): reset ruby_current_thread if it points the
thread to free.
* gc.c (slot_sweep): don't call RUBY_VM_SET_FINALIZER_INTERRUPT if
  there is no current thread.
  [ruby-dev:43000]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-12 10:35:36 +00:00
matz 049cdff0eb * gc.c (Init_GC): move back object_id to Kernel. [ruby-dev:42840]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30291 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-22 05:38:41 +00:00
matz 591ae37a59 * gc.c (Init_GC): move #__id__ and #object_id to BasicObject.
[ruby-dev:42778]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30240 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-17 13:25:19 +00:00
akr 8c757a3268 * gc.c: parenthesize macro arguments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30209 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-14 11:32:59 +00:00
shyouhei 9d3ba342c9 * gc.c (rb_objspace_free): With our "lazy-sweep" GC engine, it is
possible for an object to survive until its surrounding object
  space is about to be freed.  Those objects, if any, remains not
  leaked for the rest of a process life.  This is problematic
  because for instance a T_DATA object may have its own destructor
  to terminate something.

* vm.c (ruby_vm_destruct): ruby_current_vm termination should be
  somewhere after rb_objspace_free for above reason.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30065 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-03 03:53:21 +00:00
mame 4c17014bf3 * gc.c (assign_heap_slot): fix fear of memory leak and memory
violation.  Coverity Scan found this bug.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-11-15 15:09:40 +00:00
nobu 6f4bfdc115 * gc.c (after_gc_sweep): remove unused variable.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-11-09 12:57:51 +00:00
ko1 71603f3f01 * gc.c (rb_newobj): force garbage_collect() if GC.stress == true.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-11-04 12:06:08 +00:00
ko1 ad3427002c * gc.c (run_final): do not need argument obj.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-11-04 11:48:01 +00:00
ko1 e95b72a1f1 * gc.c (run_final): do not need argument obj.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29687 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-11-04 11:46:26 +00:00
ko1 ba0143b591 * gc.c (before_gc_sweep): fix commit miss.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-11-04 11:27:09 +00:00
ko1 3ff23bf926 * gc.c (after_gc_sweep, before_gc_sweep):
invoke rb_sweep_method_entry() as soon as possilbe.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-11-04 11:21:44 +00:00
ko1 08db452620 * gc.c (after_gc_sweep, slot_sweep): finalizers should be invoked
as soon as possible.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-11-04 11:15:36 +00:00
ko1 f6b2490fdb * gc.c, vm.c, vm_core.h: remove USE_VALUE_CACHE option.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29675 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-11-03 01:01:12 +00:00
ko1 7b0d48c1fa * gc.c (finalizer_table, objspace->final.table):
Create finalizer_table at Init_heap().
  Remove all null checks of finalizer_table.
* gc.c (mark_tbl): skip if no table entries.
* gc.c (slot_swee): remove useless need_call_final check.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-31 15:41:14 +00:00
nobu 5eced07cd7 * gc.c (rb_objspace_free): finalizers should be called separately
from freeing objspace.  [ruby-dev:42479]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-31 13:32:13 +00:00
ko1 87c0b99446 * gc.c (before_gc_sweep, run_final): fix decrement timing of final_num.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-28 14:34:06 +00:00
ko1 492d120877 * gc.c (GC.stat): added. [ruby-dev:38607]
* test/ruby/test_gc.rb: add a test for above.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-27 19:02:24 +00:00
mame a115768161 * class.c, constant.h, gc.c, method.h, object.c, variable.c,
vm_insnhelper.c: use struct rb_constant_entry_t as entry of
  RCLASS_CONST_TBL.  RCLASS_CONST_TBL has contained VALUE of constant
  directly.  Now instead rb_const_entry_t is contained in
  RCLASS_CONST_TBL,  rb_const_entry_t is managed by malloc, and
  have not only the value itself but also visibility flag.
  This is another preparation for private constant (see
  [ruby-dev:39685][ruby-core:32698]).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-26 17:27:32 +00:00
mame 2285a8d813 * class.c, gc.c, object.c, variable.c, vm_insnhelper.c,
include/ruby/ruby.h: separate RCLASS_CONST_TBL from RCLASS_IV_TBL.
  RCLASS_IV_TBL has contained not only instance variable table but
  also constant table.  Now the two table are separated to
  RCLASS_CONST_TBL and RCLASS_IV_TBL.  This is a preparation for
  private constant (see [ruby-dev:39685][ruby-core:32698]).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29600 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-26 17:27:21 +00:00
nobu 23e8deaf0d * array.c, gc.c, hash.c, object.c, string.c, struct.c,
transcode.c, variable.c, vm.c, vm_insnhelper.c, vm_method.c:
  replace calls to rb_error_frozen() with rb_check_frozen().  a
  patch from Run Paint Run Run at [ruby-core:32014]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-24 08:14:05 +00:00
ko1 e923b67707 * gc.c (gc_lazy_sweep): Variable declarations should be at
the head of block.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-21 15:03:56 +00:00
nobu e5db83ec65 * gc.c (objspace_each_objects, rb_objspace_each_objects): use
struct.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29550 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-21 14:56:55 +00:00
nobu 48b4512f76 * gc.c (objspace_each_objects): fix return with no value.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-21 14:52:02 +00:00
nari a29dc56764 * gc.c (rb_objspace_each_objects): don't lazy sweep in
rb_objspace_each_objects. [Bug #3940] [ruby-dev:42369]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-21 04:18:09 +00:00
nobu 671b498070 Commit miss.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-19 03:25:29 +00:00
nobu 12cbb58819 * test/ruby/test_sprintf.rb: fix ML ref. [ruby-core:32848]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29533 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-19 03:22:03 +00:00
nobu 7735e63593 * array.c (rb_ary_and, rb_ary_or), class.c (rb_mod_init_copy),
gc.c (undefine_final), time.c (time_mload): get rid of
  type-punning casts.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-13 22:22:18 +00:00
nobu d410639a6d * compile.c (iseq_build_body), error.c (set_syserr, get_syserr),
(syserr_initialize), gc.c (define_final, rb_gc_copy_finalizer),
  (run_final), hash.c (rb_hash_aref, rb_hash_lookup2),
  (rb_hash_fetch_m, rb_hash_clear, rb_hash_aset, eql_i),
  iseq.c (iseq_load, iseq_data_to_ary), marshal.c (r_symlink),
  thread.c (rb_thread_local_aref),
  variable.c (generic_ivar_remove, ivar_get, rb_const_get_0),
  (rb_cvar_get), vm.c (rb_vm_check_redefinition_opt_method),
  vm_insnhelper.c (vm_get_ev_const), vm_method.c (remove_method),
  ext/iconv/iconv.c (map_charset): use st_data_t.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-12 14:47:23 +00:00
nobu 3c24bea4b5 * gc.c (obj_free, rb_objspace_call_finalizer): fix truncating
cast.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-12 14:09:27 +00:00
nobu 0172f3181f * gc.c (mark_current_machine_context): suppress warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-12 14:03:24 +00:00
nari 66c25e4ca1 * gc.c (gc_profile_result): Index begins with 1.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-16 11:31:58 +00:00
nari a5207399bd * gc.c (gc_profile_result): use size_t. based on patches from
Tomoaki NISHIYAMA <tomoakin@kenroku.kanazawa-u.ac.jp> at
[ruby-dev:42042].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-16 11:31:54 +00:00
nobu f214490d90 * thread.c (rb_gc_mark_threads): deprecated.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-14 12:04:31 +00:00
nari e573186407 * test/objspace/test_objspace.rb: added test for objspace.
* ext/objspace/objspace.c: considers T_ZOMBIE by lazy sweep GC.

* gc.c: considers that dsize was 0. [ruby-dev:42022]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-14 09:01:12 +00:00
nari 81cc3b2655 * gc.c: don't call after_gc_sweep() after when garbage_collect()
was called, because rb_sweep_method_entry() free live unlinked
  method entries. [ruby-core:31169]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28689 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-20 06:14:40 +00:00
nobu 25b9eb5e57 * include/ruby/ruby.h (rb_data_type_t): restructured. [ruby-dev:41862]
add parent member.

* error.c (rb_typeddata_inherited_p): new function.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-18 07:31:54 +00:00
nobu ad654fe58e * gc.c (rb_objspace_each_objects): adjust indent.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28675 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-18 03:23:10 +00:00
nari 12b76ec890 * gc.c (unlink_heap_slot, slot_sweep): unlink heaps_slot of
heaps_slot linked list if heaps_slot is empty at slot_sweep.
  fixed [ruby-dev:41543], [ruby-core:24894].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-06-29 03:11:05 +00:00
naruse da3cdd2ddf * gc.c (gc_lazy_sweep): clean a warning.
"suggest parentheses around assignment used as truth value"

* transcode_data.h (getGB4bt1): clean a warning.
  "suggest parentheses around arithmetic in operand of |"

* transcode_data.h (getGB4bt3): ditto.

* vm.c (thread_free): clean a warning. "format 'p' expects type
  'void *', but argument 3 has type 'struct rb_mutex_struct *'"

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-06-18 01:44:52 +00:00
nobu 550532d902 * gc.c (rb_obj_id): trivial optimization.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-06-07 18:30:42 +00:00
nari 28754d0aa9 * gc.c: set_heaps_increment is not
called before gc_makrs of lazy sweeping because live_num not
  contain finalize objects. So call set_heaps_increment after lazy
  sweeping if free_num are not enough. And move free_min to struct
  rb_objspace for above.  [ruby-dev:41499]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28185 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-06-06 04:12:20 +00:00
usa 408f0a92ef * gc.c (gc_sweep): suppress a warning on VC, again.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28154 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-06-04 00:37:36 +00:00
nari a8cd15c96c * gc.c (gc_mark_all_clear): don't call obj_free() in
gc_mark_all_clear(), because obj_free() may make T_ZOMBIE
  objects.

* gc.c (gc_clear_mark_on_sweep_slots): renamed.

* gc.c (rb_objspace_call_finalizer): call
  gc_clear_mark_on_sweep_slots() before calling mark_tbl().
  [ruby-dev:41459]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28087 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-30 06:42:12 +00:00
tarui 12a99794b4 * thread.c (RB_GC_SAVE_MACHINE_CONTEXT), gc.c (ruby_gc_stress_start):
revert r28078.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-29 17:26:01 +00:00
tarui d0914b3552 * thread.c (RB_GC_SAVE_MACHINE_CONTEXT): start GC
by switching the thread if gc_stress == true 

* gc.c (ruby_gc_stress_start): dotto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-29 16:32:59 +00:00
mame 264f490012 * gc.c (force_chain_object, rb_objspace_call_finalizer): delete
finalizer entry after corresponding finalizer is executed.
  This caused SEGV when test/cgi is executed with GC.stress = true.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-29 15:10:01 +00:00
nobu 790abc5991 * gc.c (GC_PROF_TIMER_STOP): regularize `marked' to suppress
warnings.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-29 01:12:38 +00:00
nobu 21fbc8f6d3 * gc.c (allocate_sorted_heaps, before_gc_sweep, gc_sweep): removed
unused variables.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28056 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-28 23:46:44 +00:00
nari ca64478089 * gc.c : use simple lazy sweep algorithm for response performance
gain. See [ruby-dev:41067].

* object.c: FL_MARK of some objects by lazy sweep is copied when
  RVALUE is cloned. These objects are not marked in the mark phase.
  So delete FL_MARK.

* class.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-28 11:13:42 +00:00
usa ccba83feff * gc.c (gc_sweep): suppres a warning on VC.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-24 00:21:33 +00:00
nobu 87af442f94 * suppress warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27944 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-21 09:10:23 +00:00
marcandre 7729de4d91 * array.c: Documentation: change => in call-seq to ->.
Harmonize "#=>" in examples. [ruby-core:30206]

* bignum.c: ditto

* class.c: ditto

* compar.c: ditto

* cont.c: ditto

* dir.c: ditto

* encoding.c: ditto

* enum.c: ditto

* enumerator.c: ditto

* error.c: ditto

* eval.c: ditto

* file.c: ditto

* gc.c: ditto

* io.c: ditto

* load.c: ditto

* marshal.c: ditto

* math.c: ditto

* numeric.c: ditto

* object.c: ditto

* pack.c: ditto

* proc.c: ditto

* process.c: ditto

* random.c: ditto

* range.c: ditto

* re.c: ditto

* ruby.c: ditto

* signal.c: ditto

* sprintf.c: ditto

* string.c: ditto

* struct.c: ditto

* thread.c: ditto

* time.c: ditto

* transcode.c: ditto

* variable.c: ditto

* vm_eval.c: ditto

* vm_method.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-17 21:07:33 +00:00
marcandre 4afa9ed041 * array.c: Harmonize documentation, in particular regarding:
- methods returning enumerators
    - array methods and argument naming (array -> ary, an_array -> new_ary)
    - minor improvements, typo fixed and styling issues

  Other documentation errors fixed:
    - return value was self instead of a new array (or vice-versa) for
      Array#{pop,shift,permutation,repeated_permutation,keep_if}
    - Array#rindex was missing the form with a block.

* dir.c: ditto.

* enum.c: ditto. Modified Enumerable#reverse_each' documentation to clarify
  that #each will be finish before any element is yielded.

* error.c: ditto.

* gc.c: ditto.

* hash.c: ditto.

* io.c: ditto. IO#{codepoints,each_codepoint} fixed as per [ruby-core:23948]

* numeric.c: ditto.

* range.c: ditto.

* string.c: ditto.

* struct.c: ditto.

* vm_eval.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-13 05:49:55 +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
nobu 62d7a30a76 * gc.c (rb_mark_method_entry): renamed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27622 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-04 22:27:18 +00:00
nobu 95c52c8e6c * gc.c (GET_STACK_BOUNDS): fixed macro argument names. a patch from
Satoshi Shiba <shiba AT rvm.jp> at [ruby-dev:40973].

* gc.h (ruby_get_stack_grow_direction): fixed prototype.

* thread_pthread.c (get_stack, ruby_stack_overflowed_p): both side
  should be same type.  [Bug #3145]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27338 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-14 07:29:04 +00:00
wanabe c46f71399a * proc.c (rb_method_location): return attr's location if it is setup.
[Feature #2084]

* NEWS: follow above.

* vm_method.c (rb_add_method): save attr's location.

* gc.c (mark_method_entry): mark attr's location.

* method.h (rb_method_definition_t): add member to save attr's location.

* vm_eval.c (vm_call0): follow above.

* vm_insnhelper.c (vm_call_method): ditto.

* vm_method.c (rb_method_definition_eq): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27016 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-22 11:44:01 +00:00
wanabe 4d8d6d9d63 * gc.c (gc_profile_total_time): add GC::Profiler.total_time.
* NEWS: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-04 04:51:43 +00:00
matz 7e5f20c842 * gc.c (gc_mark_children): lost comment added.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-24 14:28:18 +00:00
mame a9f6a95530 * gc.c (chain_finalized_object): fix precedence.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-16 13:10:39 +00:00
mame 2236f6a682 * gc.c (rb_objspace_call_finalizer): always run finalizer at exit,
before object is free'd.  [ruby-dev:40382]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-16 12:34:09 +00:00
wanabe bcbfa7a97b * gc.c (obj_free): free rb_classext_t of eigenclass. [Bug #1392]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-01-31 04:33:33 +00:00
yugui 295bc2fe25 removes the dtrace support. reverts r26239, r26238 and r26235.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-01-05 05:59:23 +00:00
yugui b80814c339 * gc.c: added UNLIKELY to probes for optimization.
* vm.c: ditto.

* thread.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-01-04 12:36:46 +00:00
yugui 72b199940d * trace.h: new file. wraps tracing mechanisms.
* defs/dtrace.d: new file. defined a dtrace provider "ruby".

* include/ruby/ruby.h (LIKELY): moved from vm.c.
  (UNLIKELY): ditto.
  (OBJSETUP): probe "object-create".
  (RUBY_EVENT_RESCUE): new event.

* vm_exec.c (DEBUG_ENTER_INSN): embeded a probe insn-entry into it.
  (DEBUG_END_INSN): insn-return.

* vm.c (LIKELY): moved into ruby.h.
  (UNLIKELY): ditto.
  (Init_BareVM): embeded a probe "raise" into it.

* variable.c (rb_class2name_without_alloc): new utility function.

* tool/rbinstall.rb (install?(:ext, :arch, :'ext-arch')): installs 
  dtrace.d if necessary.

* thread_pthread.c (add_signal_thread_list): probe "raise".
  (rb_thread_create_timer_thread): ditto.

* thread.c (rb_thread_schedule_rec): probes "thread-enter" and
  "thread-leave",
  (thread_start_func_2): ditto.
  (thread_cleanup_func): probe "thread-term"

* lib/mkmf.rb: supports dtrace postprocessor on making an extension.

* iseq.c (rb_vm_insn_name): new utility function.
  (rb_vm_insn_len): ditto.

* insns.def (hook): probes "method-etnry", "method-return", "line",
  and "rescue".

* compile.c (iseq_compile_each): adds a trace op for "rescue" probe.

* gc.c (garbage_collect): probes "gc-begin" and "gc-end".
  (obj_free): probe "object-free"
  (garbage_collect_with_gvl): probe "raise"
  (negative_size_allocation_error): ditto.
  (rb_memerror): ditto.

* eval.c (rb_rescue2): probe "rescue"
  (rb_longjmp): probe "raise"

* ext/probe/probe.c: new extension for application defined probes.

* ext/probe/extconf.rb: ditto.

* configure.in (--with-tracing-model): new option to choose a tracing
  mechanism.
  (DTRACE): new substitution. name of dtrace(1).
  (RUBY_TRACING_MODEL): new substitution.
  (DTRACE_OBJ): ditto.
  (MINIDTRACE_OBJ): ditto.
  (GOLFDTRACE_OBJ): ditto.
  (LIBRUBY_DTRACE_OBJ): ditto.
  (RUBY_DTRACE_POSTPROCESS): new macro. checks whether the dtrace on 
  the system needs postprocessing.
  (RUBY_DTRACE_BSD_BROKEN): new macro. checks whether the dtrace
  supports USDT.

* Makefile.in: 
  (DTRACE): new variable. name of dtrace(1).
  (TRACING_MODEL): new variable. name of the chosen tracing mechanism.
  (DTRACE_OBJ): same as the one in configure.in.
  (MINIDTRACE_OBJ): ditto.
  (GOLFDTRACE_OBJ): ditto.
  (LIBRUBY_DTRACE_OBJ): ditto.
  (CPPOUTFILE): new substitution. necessary for generating dtrace.d
  (trace_none.h): new target for TRACING_MODEL=none
  (RUBY_H_INCLUDES): appended a header for tracing.
  (distclean-local): also removes preprocessed version of dtrace.d
  ($(LIBRUBY_A)): needs $(LIBRUBY_DTRACE_OBJ) if dtrace needs 
  postprocessing.
  ($(PROGRAM)): ditto.
  (golf): ditto.
  (miniruby): ditto.
  ($(arch_hdrdir)/ruby/dtrace.d): new target. preprocessed verson 
  of defs/dtrace.d. generated if necessary.
  ($(arch_hdrdir)/ruby/trace_dtrace.h): new target.
  definition of probes.
  ($(LIBRUBY_DTRACE_OBJ)): new target. generated if dtrace needs 
  postprocessing.
  ($(DTRACE_OBJ)): ditto.
  ($(MINIDTRACE_OBJ)): ditto.
  ($(GOLFDTRACE_OBJ)): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-01-03 15:36:17 +00:00
nobu 4d786d21e3 * removed spaces just before tabs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25930 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-26 05:25:08 +00:00
mame 4a761c3209 * class.c (rb_mod_init_copy): fix memory leak of Class#dup.
[ruby-dev:39687]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-14 12:56:16 +00:00
nobu 29f982738e * gc.c (vm_xrealloc): use the given object space.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25746 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-13 02:09: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
nobu 0243c024f8 * gc.c (GET_STACK_BOUNDS): refactored common code. based on a
patch from Suraj N. Kurapati <sunaku AT gmail.com> in
  [ruby-core:26443].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-31 23:17:52 +00:00
matz 33c5abbefa * gc.c (garbage_collect_with_gvl): do not garbage_collect when
dont_gc flag turned on.  [ruby-core:26327]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-26 23:06:39 +00:00
nobu 2e5e8fd895 * configure.in (warnflags): use -Wextra instead of -Wall.
* gc.c (mark_current_machine_context): get rid of warning.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25437 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-22 22:28:52 +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 d36c76dc71 * common.mk (eval.o): needs vm.h.
* eval.c (ruby_cleanup): destruct current VM before exit.

* gc.c (rb_objspace_free): free object space.

* vm.c (ruby_vm_destruct): destruct and free VM struct.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25000 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-18 07:29:17 +00:00
nobu 0cb17717fe * gc.c (vm_xrealloc): free as like standard free if size is zero.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-17 09:34:20 +00:00
ko1 a4b94c4443 * gc.c (obj_free): fix to free method table (fix memory leak).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24735 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-02 02:37:46 +00:00
nobu fcf88c1b8d * method.h (rb_method_definition_t): split from rb_method_entry_t
to deal aliases.  [ruby-dev:39165]

* proc.c (struct METHOD): contains rb_method_entry_t copy.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-28 02:45:41 +00:00
nobu 0c86e8b70b * method.c (rb_method_entry_t): body.proc should be marked.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-26 06:26:08 +00:00
nari de5f15bbe4 * gc.c: reject unused longlife gc.
* debug.c: ditto.

* include/ruby/intern.h: ditto.

* include/ruby/ruby.h: ditto.

* iseq.c: ditto.

* node.h: ditto.

* vm_insnhelper.c: ditto.

* vm_insnhelper.h: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-10 02:40:34 +00:00
nobu 9009b471da * gc.c (rb_gc_enable, rb_gc_disable): should return Qtrue/Qfalse.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-21 03:45:37 +00:00
nobu e07cb859cc * suppressed shorten-64-to-32 warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-18 08:05:32 +00:00
ko1 c330876d7c * method.h, vm_core.h: add rb_method_entry_t. Remove nodes around
method management.  This change affect some VM control stack structure.
* vm.c, vm_insnhelper.c, vm_method.c, vm_eval.c: ditto.  and make some
  refactoring.
* insns.def, class.c, eval.c, proc.c, vm_dump.c : ditto.
* vm_core.h, compile.c (iseq_specialized_instruction): remove
  VM_CALL_SEND_BIT.  use another optimization tech for Kernel#send.
* node.h: remove unused node types.
* ext/objspace/objspace.c (count_nodes): ditto.
* gc.c: add mark/free functions for method entry.
* include/ruby/intern.h: remove decl of
  rb_define_notimplement_method_id().  nobody can use it
  because noex is not opend.
* iseq.c (iseq_mark): fix to check ic_method is available.
* iseq.c (rb_iseq_disasm): fix to use rb_method_get_iseq().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-15 14:59:41 +00:00
ko1 9e60743008 * include/ruby/ruby.h:
rename
  "...TypeStruct" and "typed_struct" to
  "TypedData..." and "typeddata", respectively.
  rename
  rb_data_type_t#name to
  rb_data_type_t#wrap_struct_name.
* error.c, gc.c, iseq.c, vm.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-07 20:28:27 +00:00
nobu 649237de8f * gc.c (rb_gc_call_finalizer_at_exit): deal with typed struct like
as obj_free().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-07 08:00:44 +00:00
nobu 450f784216 * gc.c (GC_PROF_SET_MALLOC_INFO, GC_PROF_SET_HEAP_INFO): simplified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23977 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-07 02:56:57 +00:00
mame 5be8596447 * gc.c: remove the definition of GC_DEBUG (debugging macro).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-23 11:34:03 +00:00
ko1 dfb0fa0ca6 fix indent.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23711 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-16 21:40:42 +00:00
ko1 a74d12dc28 * include/ruby/ruby.h: New structure RTypedData, added.
This structure incldues more explicit type information for
  T_DATA objects.  If RData(obj)->dfree is immediate value `1' on
  T_DATA object obj, obj is needed to be accessed with RTYPEDDATA(obj)
  instead of RDATA(obj).  A RTypedData structure points the structure
  rb_typed_data_t.  rb_typed_data_t includes information such as the
  type name of this data, mark and free function what RData includes,
  and memsize function show how data consuming the memory size.
  Note that you do not need any change existing T_DATA objects.
  If you use RDataType instead of RData on T_DATA object,
  you can specify explicit type information.
* gc.c (rb_data_typed_object_alloc, rb_objspace_data_type_memsize,
  rb_objspace_data_type_name): added.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-16 21:36:50 +00:00
ko1 a0e0fafa0c * gc.c: fix indent.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-16 21:15:15 +00:00
ko1 06f833e6d5 * gc.c (rb_objspace_each_objects): New C API, added.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-16 21:07:26 +00:00
matz 50e7cb3b38 * gc.c (os_obj_of): invoke garbage collection before iteration, to
avoid accessing half recycled object references.  [ruby-dev:38613]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-15 09:06:16 +00:00
nobu 3898e7b8ee * gc.c: fixed types.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-26 05:24:19 +00:00
nari 57b83a5191 * gc.c: add longlife garbage collection. [ruby-dev:38423]
(NORMAL_HEAPS_USED): new macro.
  (LONGLIFE_ALLOCATE_HEAPS_MIN): ditto.
  (add_longlife_heaps_slot): new function.
  (rb_newobj_from_longlife_heap): ditto.
  (rb_newobj_longlife): ditto.
  (rb_node_newnode_longlife): ditto.
  (rb_gc_write_barrier): ditto.
  (remembered_set_recycle): ditto.
  (rb_gc_mark_remembered_set): ditto.
  (clear_mark_longlife_heaps): ditto.
  (gc_sweep_for_longlife): ditto.
  (assign_heap_slot): new argumnent to longlife heaps slot.
  (add_freelist): ditto.
  (gc_sweep): avoid lonlife heap slot. set longlife_collection
   flag at add heap.
  (rb_gc_force_recycle): avoid mark object and remembered_set
   object.
  (garbage_collect): add longlife collection.
  (rb_gc_start): invoke longlife collection.
  (gc_profile_record_get): for longlife collction profile.
  (gc_profile_result): ditto.

* include/ruby/intern.h (rb_gc_write_barrier): declared.

* include/ruby/ruby.h (FL_REMEMBERED_SET): renamed from FL_RESERVED.

* debug.c (FL_REMEMBERED_SET): ditto.

* insns.def (setinlinecache): insert write barrier.

* vm_insnhelper.c (vm_method_search): ditto.

* set_relation (set_relation): use longlife object.

* vm.c (vm_define_method): ditto.

* vm_core.h (NEW_INLINE_CACHE_ENTRY): ditto.

* vm_method.c (rb_add_method): ditto.

* class.c (rb_add_method): ditto.

* node.h (NEW_NODE_LONGLIFE): new macro.
  (rb_node_newnode_longlife): declared.
					    


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23421 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-13 14:08:26 +00:00