summaryrefslogtreecommitdiff
path: root/gc.c
AgeCommit message (Collapse)Author
2015-05-20ruby.h: warn old namesnobu
* include/ruby/ruby.h (rb_data_typed_object_alloc), (rb_data_object_alloc): warn use of old names. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50558 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-19ruby.h: add old namesnobu
* include/ruby/ruby.h (rb_data_typed_object_alloc), (rb_data_object_alloc): add old names for source level backward compatibilities. * gc.c (rb_data_object_alloc, rb_data_typed_object_alloc): add aliases for binary level backward compatibilities. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-18gc.c: remove ifdefnobu
* gc.c (obj_info): remove needless ifdef, and adjust indent. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-16gc.c: rename alloc as wrapnobu
* gc.c (rb_data_object_wrap, rb_data_typed_object_wrap): rename alloc as wrap. these functions do not allocate data pointers but just wrap the given pointers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50506 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-10ruby.h: fix possible memory leaknobu
* include/ruby/ruby.h (Data_Make_Struct, TypedData_Make_Struct): allocate wrapper data object before allocating DATA_PTR to get rid of possible memory leak when the former failed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50464 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-10gc.c: never call dmark for NULLnobu
* gc.c (gc_mark_children): call dmark function for non-NULL pointers only, so that DATA_PTR can be NULL safely now. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-26gc.c: event hook thread argumentnobu
* gc.c (gc_event_hook_body): move th to an argument. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-23* gc.c (gc_mark_roots): fox to work PRINT_ROOT_TICKS.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-15* doc/contributors.rdoc: fix a typo. Patch by @davydovantonhsbt
[fix GH-872][ci skip] * doc/syntax/methods.rdoc: ditto. * ext/digest/sha2/sha2.c: ditto. * ext/socket/ipsocket.c: ditto. * ext/tk/*: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-14* gc.c: [DOC] Improve documentation for ObjectSpace.count_objectszzak
with regards to `:TOTAL` key, with patch by @schneems [Fixes GH-871] https://github.com/ruby/ruby/pull/871 [Bug #11067] [ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-12* gc.c: Document require name for ObjectSpace methods.hsbt
[ci skip][fix GH-860] Patch by @schneems git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50258 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-29* gc.c (objspace_allrefs_destruct_i): fix a typo.hsbt
[Bug #11013] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50114 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-27internal.h: rb_imemo_new_debugnobu
* internal.h (rb_imemo_new_debug): pretend rb_imemo_new. * gc.c (rb_imemo_new_debug): share with rb_imemo_new. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50101 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-24* gc.c (gc_writebarrier_generational): fix messages for rb_bug().ko1
Remove `rb_' prefix. * gc.c (gc_writebarrier_incremental): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-20* gc.c (obj_info): obj_info() can receive internal objects.ko1
* gc.c (check_rvalue_consistency): obj_info() returns const char *. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50033 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-20revert r50031 because it includes unexpected patchko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50032 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-20* gc.c (obj_info): obj_info() can receive internal objects.ko1
* gc.c (check_rvalue_consistency): obj_info() returns const char *. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50031 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-20* gc.c (obj_info): show class name and T_DATA type_name.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-19* gc.c (rb_copy_wb_protected_attribute): `dest' can be WB unprotected.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-19* gc.c (rb_copy_wb_protected_attribute): demote `dest' object.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-19* gc.c, internal.h: export rb_gc_verify_internal_consistency().ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50026 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-19* gc.c (obj_info): show allocation site if GC_DEBUG is not 0.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-19* gc.c (newobj_of): fix RGENGC_OLD_NEWOBJ_CHECK logics.ko1
* skip on incremental marking because not sure what happen :p * rb_gc_writebarrier_remember() is enough to mark children. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-19* gc.c (rb_copy_wb_protected_attribute): need demote for old objects.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-18* internal.h (IMEMO_DEBUG): added.ko1
* internal.h: remove unused FL_IMEMO_MARK_V[0-3]. * gc.c (rb_imemo_new_debug): added. * gc.c (obj_info): show imemo type name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-18* gc.c (RGENGC_OLD_NEWOBJ_CHECK): add check mechanism.ko1
If RGENGC_OLD_NEWOBJ_CHECK > 0, then create old objects (not new objects) periodically. Create one old objects per RGENGC_OLD_NEWOBJ_CHECK objects are created. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-18* gc.c (check_rvalue_consistency): refactoring.ko1
* not inline on RGENGC_CHECK_MODE > 0. * check SPECIAL_CONST_P(obj) first. * add a check that remembered_bit is only TRUE when old (age == 3). * gc.c (RVALUE_DEMOTE): should clear RVALUE_REMEMBERED bit. remembered_bit should be TRUE only for old (age == 3) objects. Actually there are no effect because demoted objects will be uncollectible WB unprotected objects (marked at the begginig of every minor GC). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50011 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-18* gc.c: rename terminologies.ko1
* long_lived -> uncollectible: because this bitmap does not mean "long lived objects in past", but means "prohibit collection thse objects until next major GC". Uncollectible objects consist of two types objects, one is old objects (WB protected objects which age == 3) and another is uncollectible WB unprotected objects which are referred from old objects * remembered_wb_unprotected_objects -> uncollectible_wb_unprotected_objects: because uncollectible objects does not mean remembered objects. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-18* gc.c (gc_writebarrier_generational): add an alternative writeko1
barrier (WB) implementation. When finding reference from [Old obj] to [New obj] by WB, current implementation marks [Old obj] as remembered old objects and marks chilldren of [Old obj] at the beggining of marking. Added (but disabled) code changes current behaviour. This fix promote [New obj] to old and marks as a remembered old object. We can assume "new objects referred from old objects are maybe long-lived old objects". Disadvantage of added algorithm is we may promote unwilling short-lived objects. For example, consider many new objects push and pop to an old stack object. All of new objects (short-lived objects) promote to old objects unexpectedly. To compare these behaviour, I add this new code (but disabled it). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-18* gc.c (RVALUE_PROMOTE_RAW): rename to RVALUE_OLD_LONG_LIVED_SET()ko1
to make clear. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-18* gc.c (check_rvalue_consistency): do not need to check is_sweeping().ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-17* include/ruby/ruby.h: use rb_gc_writebrrier() simply.ko1
For incremental GC, we need to get a pointer to the objspace. We can share this pointer for the following WB process. And considering icache hit ratio, prcess in the GC. * gc.c (rb_gc_writebarrier): added. * gc.c (gc_writebarrier_generational, gc_writebarrier_incremental): make them NOINLINE because inlining them into rb_gc_writebarrier() makes a prologue code of rb_gc_writebarrier() longer (storing callee save registers). This patch improve the performance of WB on micro-benchmarks. name ruby 2.1 trunk modified vm1_gc_wb_ary* 0.511 0.632 0.532 vm1_gc_wb_ary_promoted* 0.578 0.701 0.674 vm1_gc_wb_obj* 0.419 0.575 0.492 vm1_gc_wb_obj_promoted* 0.537 0.664 0.618 (sec) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-11* gc.c: RGENGC_CHECK_MODE should be 0.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-11* internal.h: use T_IMEMO to represent `struct MEMO' value.ko1
memo->v1 and memo->v2 is WB protected values. So use MEMO_V1/V2_SET() macros to set these values. memo->u3 is ambiguous (sometimes a VALUE, sometimes an integer value), so use gc_mark_maybe() in gc.c to mark it. Rename NEW_MEMO() to MEMO_NEW(). Move MEMO_FOR and NEW_MEMO_FOF macros from node.h. Export a rb_imemo_new() function for ext/ripper. * node.h: remove NODE_MEMO. * enum.c: catch up these change. * enumerator.c: ditto. * load.c: ditto. * ext/objspace/objspace.c (count_nodes): ditto. * gc.c (gc_mark_children): mark imemo_memo type. * parse.y (new_args_gen): use T_IMEMO. (I'm not sure it is working correctly...) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-11* node.h: remove NODE_IFUNC, NEW_IFUNC.ko1
* internal.h: use T_IMEMO for IFUNC. rename `struct IFUNC' to `struct vm_ifunc' and move the definition from vm_insnhelper.h. Add imemo_ifunc. * gc.c (gc_mark_children): mark imemo_ifunc type T_IMEMO object. * compile.c: catch up these changes. * proc.c: ditto. * vm_core.h (RUBY_VM_IFUNC_P): ditto. * vm_eval.c (rb_iterate): ditto. * vm_insnhelper.c: ditto. * ext/objspace/objspace.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-11* vm_insnhelper.h: use T_IMEMO to create THROW_DATA.ko1
Add THROW_DATA_NEW(). * internal.h: move defnition of `struct THROW_DATA' from vm_insnhelper.h to internal.h. Rename `THROW_DATA' to `vm_throw_data'. * eval_intern.h (THROW_DATA_P): move to internal.h. THROW_DATA is no longer T_NODE, so check T_IMEMO. * gc.c (gc_mark_children): mark THROW_DATA. * vm.c: catch up these changes. * vm_eval.c: ditto. * vm_insnhelper.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49936 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-11* vm_insnhelper.c: use T_IMEMO to create SVAR.ko1
* internal.h, vm_insnhelper.h: move definition `struct SVAR' from vm_insnhelper.h to internal.h. And rename it to strcut vm_svar. new imemo_type imemo_svar is added. * gc.c (gc_mark_children): mark imemo_svar. * node.c (rb_gc_mark_node): remove useless marking. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-11* include/ruby/ruby.h: introduce new type T_IMEMO.ko1
T_IMEMO is Internal Memo type, internal use only. T_IMEMO has same purpose of NODE_MEMO. To insert T_IMEMO, type numbers are modified a little. * internal.h: define struct RIMemo. Each RIMemo objects has imemo_type. We can observe it by the imemo_type() function. * gc.c (rb_imemo_new): added. * node.h: remove NODE_CREF and NEW_CREF(). * node.c (rb_gc_mark_node): ditto. * vm.c (vm_cref_new): use rb_imem_new(). * vm_eval.c: ditto. * vm_eval.c (eval_string_with_cref): * vm_eval.c (rb_type_str): * vm_insnhelper.c: use RIMemo objects for CREF. * ext/objspace/objspace.c: support T_IMEMO. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49932 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-11* gc.c: fix memory leak by prepend method.ko1
It is easy to reproduce with such script: module M; def bar; end; end loop{ Class.new do def foo; end prepend M end } * gc.c (obj_free): free T_ICLASS::m_tbl if it is created by prepend. To recognize it, check RICLASS_IS_ORIGIN flag. * gc.c (gc_mark_children): T_ICLASS objects only need to mark T_ICLASS::m_tbl if RICLASS_IS_ORIGIN is set. * gc.c (obj_memsize_of): count T_ICLASS if RICLASS_IS_ORIGIN is set. * internal.h (RCLASS_SET_ORIGIN): add to set RCLASS_SET_ORIGIN. TODO: The word `origin' seems not good name. We need to invent another good name. * class.c: use RCLASS_SET_ORIGIN(). * class.c (class_alloc): zero clear rb_classext_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49931 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-06* fix namespace issue on singleton class expressions. [Bug #10943]ko1
* vm_core.h, method.h: remove rb_iseq_t::cref_stack. CREF is stored to rb_method_definition_t::body.iseq_body.cref. * vm_insnhelper.c: modify SVAR usage. When calling ISEQ type method, push CREF information onto method frame, SVAR located place. Before this fix, SVAR is simply nil. After this patch, CREF (or NULL == Qfalse for not iseq methods) is stored at the method invocation. When SVAR is requierd, then put NODE_IF onto SVAR location, and NDOE_IF::nd_reserved points CREF itself. * vm.c (vm_cref_new, vm_cref_dump, vm_cref_new_toplevel): added. * vm_insnhelper.c (vm_push_frame): accept CREF. * method.h, vm_method.c (rb_add_method_iseq): added. This function accepts iseq and CREF. * class.c (clone_method): use rb_add_method_iseq(). * gc.c (mark_method_entry): mark method_entry::body.iseq_body.cref. * iseq.c: remove CREF related codes. * insns.def (getinlinecache/setinlinecache): CREF should be cache key because a different CREF has a different namespace. * node.c (rb_gc_mark_node): mark NODE_IF::nd_reserved for SVAR. * proc.c: catch up changes. * struct.c: ditto. * insns.def: ditto. * vm_args.c (raise_argument_error): ditto. * vm_eval.c: ditto. * test/ruby/test_class.rb: add a test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-05* gc.c (obj_info): show node name too.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49864 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-05* internal.h: remove struct method_table_wrapper.ko1
struct method_table_wrapper was introduced to avoid duplicate marking for method tables. For example, `module M1; def foo; end; end` make one method table (mtbl) contains a method `foo`. M1 (T_MODULE) points mtbl. Classes C1 and C2 includes M1, then two T_ICLASS objects are created and they points mtbl too. In this case, three objects (one T_MODULE and two T_ICLASS objects) points same mtbl. On marking phase, these three objects mark same mtbl. To avoid such duplication, struct method_table_wrapper was introduced. However, created two T_ICLASS objects have same or shorter lifetime than M1 (T_MODULE) object. So that we only need to mark mtbl from M1, not from T_ICLASS objects. This patch tries marking only from M1. Note that one `Module#prepend` call creates two T_ICLASS objects. One for refering to a prepending Module object, same as `Module#include`. We don't nedd to care this T_ICLASS. One for moving original mtbl from a prepending class. We need to mark such mtbl from this T_ICLASS object. To mark the mtbl, we need to use `RCLASS_ORIGIN(klass)` on marking from a prepended class `klass`. * class.c: ditto. * eval.c (rb_using_refinement): ditto. * gc.c: ditto. * include/ruby/ruby.h: define m_tbl directly. The definition of struct RClass should be moved to (srcdir)/internal.h. * method.h: remove decl of rb_free_m_tbl_wrapper(). * object.c: use RCLASS_M_TBL() directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-01gc.c: hide internal objectsnobu
* gc.c (id2ref): prohibit from accessing internal objects. [ruby-core:68348] [Bug #10918] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-22* gc.c (rb_objspace_call_finalizer): control GC execution duringko1
force firnalizations at the end of interpreter process. [Bug #10768] 1) Prohibit incremental GC while running Ruby-level finalizers to avoid any danger. 2) Prohibit GC while invoking T_DATA/T_FILE data structure because these operations break object relations consistency. This patch can introduce another memory consuming issue because Ruby-level finalizers can run after (2), GC is disabled. However, basically object consistency was broken at (2) as I described above. So that running Ruby-level finalizers contains danger originally. Because of this point, I need to suggest to remove these 3 lines (invoking remaining finalizers). And add a rule to add that finalizers should not add new finalizers, or say there is no guarantee to invoke finalizers that added by another finalizer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-08gc.c: disable lazy sweeping checknobu
* gc.c (rb_objspace_free): disable provisionally lazy sweeping check. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49545 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-08gc.c: disable gc_rest after finalizationnobu
* gc.c (rb_objspace_call_finalizer): disable provisionally gc_rest as it breaks RVALUE consistency. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49541 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-02gc.c: ensure GC state is consistent during VM shutdowntmm1
* gc.c (rb_objspace_free): cause rb_bug if lazy sweep is in progress during rb_objspace_free. Adds extra protection for r46340. Patch by Vicent Marti. [Bug #10768] [ruby-core:67734] * gc.c (rb_objspace_call_finalizer): Ensure GC is completed after finalizers have run. We already call gc_rest() before invoking finalizers, but finalizer can allocate new objects and start new GC cycle, so we call gc_rest() again after finalizers are complete. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-25* gc.c (wmap_final_func): fix memory size shortage when realloc wmap.ngoto
Fix SEGV during finilize of WeakRef on Solaris (though the SEGV could occur on all OS/platforms). [ruby-dev:48779] [Bug #10646] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-24* gc.c: remove unused rb_objspace_t::rgengc::old_objects_at_gc_start.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-15GC documentation updatenormal
* gc.c (GC_HEAP_FREE_SLOTS): move definition to match use order (RUBY_GC_HEAP_GROWTH_SLOTS): s/factor/number of slots/ * man/ruby.1: add section for GC environment variables [Feature #10197] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48855 b2dd03c8-39d4-4d8f-98ff-823fe69b080e