summaryrefslogtreecommitdiff
path: root/ext/objspace/objspace.c
AgeCommit message (Collapse)Author
2017-11-04Rename imemo_strterm to imemo_parser_strtermmame
Per ko1's request. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60642 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-04ext/objspace/objspace.c: add imemo_strtermmame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-31Use NODE_CASE2 if case expressions don't existyui-knk
When NODE_WHEN is compiled by iseq_compile_each0, the node passed to compile_when is NODE_WHEN (not NODE_CASE). So we can not handle the location of NODE_CASE of case statements which don't have case expressions. e.g. : ``` case; when 1; foo; when 2; bar; else baz; end ``` This commit adds NODE_CASE2, and compiles it by iseq_compile_each0. * compile.c (compile_case): Does not call COMPILE_ when NODE_CASE does not have case expressions. * compile.c (compile_case2): Compile NODE_CASE2 by compile_case2. * compile.c (compile_when): Delete an obsoleted function. * compile.c (iseq_compile_each0): Compile NODE_CASE2. * ext/objspace/objspace.c (count_nodes): Add NODE_CASE2 case. * node.c (dump_node, rb_gc_mark_node): Add NODE_CASE2 case. * node.h (node_type): Add NODE_CASE2. * node.h (NEW_CASE2): Add a macro which generates NODE_CASE2. * parse.y: Generate NODE_CASE2 if case expressions don't exist. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-24Removed NODE_OPT_Nnobu
* node.h (NODE_OPT_N): removed. * parse.y (parser_append_options): expand -n option loop to while gets loop. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60394 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22objspace.c: missing typesnobu
* ext/objspace/objspace.c (count_nodes): added recently added node types that were missing. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60348 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22remove NODE_DREGX_ONCEnobu
* node.h (enum node_type): remove NODE_DREGX_ONCE which is not used anymore. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60347 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22Remove not used node_type NODE_BMETHODyui-knk
* ext/objspace/objspace.c (count_nodes): This node_type has not been used since r24128. * node.c (dump_node): ditto * node.h (node_type, NEW_BMETHOD): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22Remove not used node_type NODE_BLOCK_ARGyui-knk
* ext/objspace/objspace.c (count_nodes): This node_type has not been used since r11840. * node.c (dump_node, rb_gc_mark_node): ditto * node.h (node_type, NEW_BLOCK_ARG): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22Remove not used node_type NODE_TO_ARYyui-knk
* ext/objspace/objspace.c (count_nodes): This node_type has not been used since r13236. * node.c (dump_node, rb_gc_mark_node): ditto * node.h (node_type, NEW_TO_ARY): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21Remove not used node_type NODE_CVDECLyui-knk
* compile.c (defined_expr0): This node_type has not been used since r11614. * ext/objspace/objspace.c (count_nodes): ditto * node.c (dump_node): ditto * node.h (node_type, NEW_CVDECL): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21Remove not used node_type NODE_IASGN2yui-knk
* compile.c (compile_massign_opt, iseq_compile_each0): This node_type has not been used since r11813. * ext/objspace/objspace.c (count_nodes): ditto * node.c (dump_node, rb_gc_mark_node): ditto * node.h (node_type, NEW_IASGN2): ditto * parse.y (node_assign_gen): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21imemo_mask (enum) -> IMEMO_MASK (immediate value).ko1
* internal.h: imemo_mask is not a valid imemo type but switch statements show warnings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21Replace NODE_ALLOCA with T_IMEMO (imemo_alloc)mame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-17ext/objspace/objspace.c: remove unneeded code clones.mame
`setup_hash` have already performed nil check and empty check. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-18objspace.c:: indent [ci skip]yui-knk
* ext/objspace/objspace.c (memsize_of_m): adjust indent of comments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-28internal.h: RB_OBJ_BUILTIN_TYPEnobu
* internal.h (RB_OBJ_BUILTIN_TYPE): special-const safe BUILTIN_TYPE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-21* ext/objspace/objspace.c: add a new method ObjectSpace.count_symbols.ko1
[Feature #11158] * symbol.c (rb_sym_immortal_count): added to count immortal symbols. * symbol.h: ditto. * test/objspace/test_objspace.rb: add a test for this method. * NEWS: describe about this method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-10objspace.c: use rb_ident_hash_newnobu
* ext/objspace/objspace.c (reachable_objects_from_root): use rb_ident_hash_new instead of funcall Hash#compare_by_id. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-21* make rb_iseq_t T_IMEMO object (type is imemo_iseq).ko1
All contents of previous rb_iseq_t is in rb_iseq_t::body. Remove rb_iseq_t::self because rb_iseq_t is an object. RubyVM::InstructionSequence is wrapper object points T_IMEMO/iseq. So RubyVM::ISeq.of(something) method returns different wrapper objects but they point the same T_IMEMO/iseq object. This patch is big, but most of difference is replacement of iseq->xxx to iseq->body->xxx. (previous) rb_iseq_t::compile_data is also located to rb_iseq_t::compile_data. It was moved from rb_iseq_body::compile_data. Now rb_iseq_t has empty two pointers. I will split rb_iseq_body data into static data and dynamic data. * compile.c: rename some functions/macros. Now, we don't need to separate iseq and iseqval (only VALUE). * eval.c (ruby_exec_internal): `n' is rb_iseq_t (T_IMEMO/iseq). * ext/objspace/objspace.c (count_imemo_objects): count T_IMEMO/iseq. * gc.c: check T_IMEMO/iseq. * internal.h: add imemo_type::imemo_iseq. * iseq.c: define RubyVM::InstructionSequnce as T_OBJECT. Methods are implemented by functions named iseqw_.... * load.c (rb_load_internal0): rb_iseq_new_top() returns rb_iseq_t (T_IMEMO/iesq). * method.h (rb_add_method_iseq): accept rb_iseq_t (T_IMEMO/iseq). * vm_core.h (GetISeqPtr): removed because it is not T_DATA now. * vm_core.h (struct rb_iseq_body): remove padding for [Bug #10037][ruby-core:63721]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-21* ext/objspace/objspace.c (total_i): no need to skip singleton classes.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51326 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-18* ext/objspace/objspace.c (count_imemo_objects): support imemo_ment.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-28* ext/objspace/objspace.c: add two methods to debug internals.ko1
* ObjectSpace.internal_class_of: return RBASIC_CLASS(obj). * ObjectSpace.internal_super_of: return RCLASS_SUPER(cls). * NEWS: add information about both methods. * test/objspace/test_objspace.rb: add tests for both methods. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50662 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-04-10* ext/objspace/objspace.c: add ObjectSpace.count_imemo_objects methodko1
to count imemo objects for each type. * test/objspace/test_objspace.rb: add a test. * NEWS: describe about this addition. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-10* ext/objspace/objspace.c (setup_hash): unify common routine.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50208 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* 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
2014-12-15* ext/objspace/objspace.c: ObjectSpace.memsize_of(obj) returnsko1
with sizeof(RVALUE). [Bug #8984] * gc.c (obj_memsize_of): ditto. * NEWS: add a NEWS entry. * test/objspace/test_objspace.rb: catch up this fix. * test/ruby/test_file_exhaustive.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-01use 0 for reservednobu
use 0 for rb_data_type_t::reserved instead of NULL, since its type may be changed in the future and possibly not a pointer type. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15* internal.h: Include ruby.h and ruby/encoding.h to beakr
includable without prior inclusion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-03ext: get rid of inadvertent ID creationnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-16* ext/objspace/objspace.c (reachable_object_from_root_i): useko1
compare_by_identity hash to avoid hash modify problem during iteration. [Bug #9252] * ext/objspace/objspace.c (reachable_objects_from_root): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44241 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-15* ext/objspace/objspace.c (reachable_object_from_root_i):ko1
reachable objects should not include categories and category_objects because it is noisy information. In fact, objects created after calling ObjectSpace.reachable_objects_from_root should not be included as a returning hash objects. Currently, mswin64 platform has a problem because of this behaviour. Should we trace new objects? git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-05ext/objspace: remove OS.after_gc_start_hook= and move internal testtmm1
* ext/objspace/gc_hook.c: remove this file * ext/-test-/tracepoint/gc_hook.c: new filename for above * ext/objspace/objspace.c: remove ObjectSpace.after_gc_start_hook= * test/objspace/test_objspace.rb: remove test * test/-ext-/tracepoint/test_tracepoint.rb: add above test for tracepoint re-entry git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-09* ext/objspace/object_tracing.c: use declarations in internal.h.nari
* ext/objspace/objspace.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-08* ext/objspace/object_tracing.c: Add experimental methods to dumptmm1
objectspace as json: ObjectSpace.dump_all and ObjectSpace.dump(obj). These methods are useful for debugging reference leaks and memory growth in large ruby applications. [Bug #9026] [ruby-core:57893] [Fixes GH-423] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-05* gc.c: add support to estimate increase of oldspace memory usage.ko1
This is another approach to solve an issue discussed at r43530. This feature is diabled as default. This feature measures an increment of memory consuption by oldgen objects. It measures memory consumption for each objects when the object is promoted. However, measurement of memory consumption is not accurate now. So that this measurement is `estimation'. To implement this feature, move memsize_of() function from ext/objspace/objspace.c and expose rb_obj_memsize_of(). Some memsize() functions for T_DATA (T_TYPEDDATA) have problem to measure memory size, so that we ignores T_DATA objects now. For example, some functions skip NULL check for pointer. The macro RGENGC_ESTIMATE_OLDSPACE enables/disables this feature, and turned off as default. We need to compare 3gen GC and this feature carefully. (it is possible to enable both feature) We need a help to compare them. * internal.h: expose rb_obj_memsize_of(). * ext/objspace/objspace.c: use rb_obj_memsize_of() function. * cont.c (fiber_memsize): fix to check NULL. * variable.c (autoload_memsize): ditto. * vm.c (vm_memsize): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-29* add RUBY_TYPED_FREE_IMMEDIATELY to data types which only useko1
safe functions during garbage collection such as xfree(). On default, T_DATA objects are freed at same points as fianlizers. This approach protects issues such as reported by [ruby-dev:35578]. However, freeing T_DATA objects immediately helps heap usage. Most of T_DATA (in other words, most of dfree functions) are safe. However, we turned off RUBY_TYPED_FREE_IMMEDIATELY by default for safety. * cont.c: ditto. * dir.c: ditto. * encoding.c: ditto. * enumerator.c: ditto. * error.c: ditto. * file.c: ditto. * gc.c: ditto. * io.c: ditto. * iseq.c: ditto. * marshal.c: ditto. * parse.y: ditto. * proc.c: ditto. * process.c: ditto. * random.c: ditto. * thread.c: ditto. * time.c: ditto. * transcode.c: ditto. * variable.c: ditto. * vm.c: ditto. * vm_backtrace.c: ditto. * vm_trace.c: ditto. * ext/bigdecimal/bigdecimal.c: ditto. * ext/objspace/objspace.c: ditto. * ext/stringio/stringio.c: ditto. * ext/strscan/strscan.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-16* ext/objspace/objspace.c: add a new method `reachable_objects_from_root'.ko1
ObjectSpace.reachable_objects_from_root returns all objects refered from root (called "root objects"). This feature is for deep object analysis. * test/objspace/test_objspace.rb: add a test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43301 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-30* ext/objspace/objspace.c: [DOC] Cleaned up many rdoc formattingzzak
issues and several duplicate grammar bugs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-18* ext/objspace/objspace.c: Document ObjectSpace::InternalObjectWrapper.zzak
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-18* ext/objspace/objspace.c: rdoc on require to overview from r41355zzak
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-17* ext/objspace/objspace.c: let rdoc know about objspace methods.eregon
Specify 'objspace' should be required. See #8537. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-17* gc.c (ObjectSpace): is a module not a class.eregon
* ext/objspace/objspace.c: try to include overview in rdoc, see #8537. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-04* ext/objspace/objspace.c: improve wording and remove duplicated comment.eregon
Based on a patch by Dave Goodchild. [Fixes GH-299] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-27* ext/objspace/gc_hook.c, ext/objspace/objspace.c: add new methods toko1
hook GC invocation. * ObjectSpace.after_gc_start_hook=(proc) * ObjectSpace.after_gc_end_hook=(proc) Note that hooks are not kicked immediately. Procs are kicked at postponed_job. This feature is a sample of new internal event and rb_postponed_job API. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-27* ext/objspace/objspace.c: support ObjectSpace.trace_object_allocations.ko1
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-03-19* ext/objspace/objspace.c: Fix typo in doc. Patch by Sho Hashimoto.sorah
[Bug #8116] [ruby-dev:47177] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-05objspace.c: newly added nodesnobu
* ext/objspace/objspace.c (count_nodes): count also newly added nodes, and fix key for unknown node. patch by tmm1 (Aman Gupta) in [ruby-core:53130] [Bug #8014] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e