aboutsummaryrefslogtreecommitdiffstats
path: root/ext/objspace
Commit message (Collapse)AuthorAgeFilesLines
* ext/objspace/lib/objspace/trace.rb: Remove the original Kernel#pYusuke Endoh2021-05-141-0/+1
| | | | | | | | | | | | | ... to disable a "method redefined" warning. http://rubyci.s3.amazonaws.com/solaris11-gcc/ruby-master/log/20210514T050008Z.fail.html.gz ``` 1) Failure: TestObjSpace#test_objspace_trace [/export/home/chkbuild/chkbuild-gcc/tmp/build/20210514T050008Z/ruby/test/objspace/test_objspace.rb:621]: <["objspace/trace is enabled"]> expected but was <["/export/home/chkbuild/chkbuild-gcc/tmp/build/20210514T050008Z/ruby/.ext/common/objspace/trace.rb:29: warning: method redefined; discarding old p", "objspace/trace is enabled"]>. ```
* ext/objspace/lib/objspace/trace.rb: AddedYusuke Endoh2021-05-141-0/+44
| | | | | | | | | This file, when require'ed, starts tracing the object allocations, and redefines `Kernel#p` to show the allocation site. This commit is experimental; the library name and APIs may change. [Feature #17762]
* Allow newobj_of0 and newobj_slowpath to allocate into multiple heap slotsMatt Valentine-House2021-05-061-0/+2
|
* Fix compiler warnings in objspace_dump.c when assertions are turned onPeter Zhu2021-04-261-5/+5
| | | | | | | | | | | | | | | Example: ``` In file included from ../../../include/ruby/defines.h:72, from ../../../include/ruby/ruby.h:23, from ../../../gc.h:3, from ../../../ext/objspace/objspace_dump.c:15: ../../../ext/objspace/objspace_dump.c: In function ‘dump_append_ld’: ../../../ext/objspace/objspace_dump.c:95:26: warning: comparison of integer expressions of different signedness: ‘long unsigned int’ and ‘int’ [-Wsign-compare] 95 | RUBY_ASSERT(required <= width); | ^~ ```
* dependency updates卜部昌平2021-04-131-3/+0
|
* objspace_dump.c: tag singleton classes and reference the superclassJean Boussier2021-02-041-0/+23
|
* objspace_dump.c: Handle allocation path and line missingJean Boussier2021-01-201-4/+9
|
* enable constant cache on ractorsKoichi Sasada2021-01-051-0/+1
| | | | | | | | | | | | | | | | constant cache `IC` is accessed by non-atomic manner and there are thread-safety issues, so Ruby 3.0 disables to use const cache on non-main ractors. This patch enables it by introducing `imemo_constcache` and allocates it by every re-fill of const cache like `imemo_callcache`. [Bug #17510] Now `IC` only has one entry `IC::entry` and it points to `iseq_inline_constant_cache_entry`, managed by T_IMEMO object. `IC` is atomic data structure so `rb_mjit_before_vm_ic_update()` and `rb_mjit_after_vm_ic_update()` is not needed.
* Expose atomic operation macros with RUBY prefixNobuyoshi Nakada2020-12-241-0/+1
| | | | | Now we need atomic operations, which are lighter than mutex, more widely for extension libraries because of Ractor.
* Prevent objects from moving while iterating the heapAaron Patterson2020-10-061-6/+8
| | | | | | This iterator uses an st_table, but if objects move the references in the st table won't be updated. This patch just changes the st table to an identity hash.
* Fix ObjectSpace.dump(obj, output: :stdout)Kazuhiro NISHIYAMA2020-10-031-2/+6
| | | | | | | RDoc says `ObjectSpace.dump(obj, output: :stdout) # => nil`, but it returns STDOUT since fbba6bd4e3dff7a61965208fecae908f10c4edbe. I think it is unintentional change.
* Fix up dependencies on internal/sanitizers.hNobuyoshi Nakada2020-09-291-0/+2
|
* Refactor common heap iteration codeAaron Patterson2020-09-281-125/+94
| | | | | We have code common to all heap iteration paths in this file. Refactor such that we keep ASAN checks and flags checks in one place
* Fix ASAN support when invalidating CCsAaron Patterson2020-09-281-2/+2
| | | | | Again, this code is walking the heap. Empty slots can be poisoned, so we need to unpoison before checking the type
* Make ext/objspace ASAN friendlyAaron Patterson2020-09-282-0/+44
| | | | | ext/objspace iterates over the heap, but some slots in the heap are poisoned, so we need to take care of that when running with ASAN
* Return nil when argument to ObjectSpace.internal_class_of is T_IMEMOAlan Wu2020-09-251-2/+7
| | | | | | | The added test case crashes the interpreter because it makes ObjectSpace.internal_class_of return the second VALUE slot of an AST imemo object. The second VALUE slot of `struct rb_ast_struct` is not a VALUE and not a pointer to a Ruby object.
* Parse ObjectSpace.dump_all / dump arguments in Ruby to avoid allocation noiseJean Boussier2020-09-152-118/+115
| | | | | | | | | | | | [Feature #17045] ObjectSpace.dump_all should allocate as little as possible in the GC heap Up until this commit ObjectSpace.dump_all allocates two Hash because of `rb_scan_args`. It also can allocate a `File` because of `rb_io_get_write_io`. These allocations are problematic because `dump_all` dumps the Ruby heap, so it should try modify as little as possible what it is observing.
* Add missing breakKazuhiro NISHIYAMA2020-09-111-0/+1
| | | | pointed out by Coverity Scan
* Optimize ObjectSpace.dump_allJean Boussier2020-09-092-210/+388
| | | | | | | | | | | | | | | | | | The two main optimization are: - buffer writes for improved performance - avoid formatting functions when possible ``` | |compare-ruby|built-ruby| |:------------------|-----------:|---------:| |dump_all_string | 1.038| 195.925| | | -| 188.77x| |dump_all_file | 33.453| 139.645| | | -| 4.17x| |dump_all_dev_null | 44.030| 278.552| | | -| 6.33x| ```
* Add a :since option to dump_allJean Boussier2020-09-091-6/+37
| | | | | | | | | | | | | | | | | This is useful to see what a block of code allocated, e.g. ``` GC.start GC.disable ObjectSpace.trace_object_allocations do # run some code end gc_gen = GC.count allocations = ObjectSpace.dump_all(output: :file, since: gc_gen) GC.enable GC.start retentions = ObjectSpace.dump_all(output: :file, since: gc_gen) ```
* sed -i '/rmodule.h/d'卜部昌平2020-08-271-3/+0
|
* sed -i '/r_cast.h/d'卜部昌平2020-08-271-3/+0
|
* sed -i '\,2/extern.h,d'卜部昌平2020-08-271-3/+0
|
* Fix ObjectSpace.trace_object_allocations_stop to not raise if the tracepoint ↵Jean Boussier2020-08-191-2/+6
| | | | were not initialized
* RHASH_TBL: is now ext-only卜部昌平2020-08-191-1/+2
| | | | | It seems almost no internal codes use RHASH_TBL any longer. Why not just eliminate it entirely, so that the macro can be purely ext-only.
* Update references when tracing allocationsAaron Patterson2020-08-181-3/+77
| | | | | | | | | | The allocation tracing code keeps essentially a weak reference to objects that have been allocated (storing the allocation information along with the weak ref). Compacting the heap would break references in this weak map, so the wrong values could be returned. This commit just updates the values in the weak ref in order to fix the allocation tracing book keeping
* Fix method name escaping in ObjectSpace.dumpJohn Hawthorn2020-08-171-1/+2
| | | | | | | | It's possible to define methods with any name, even if the parser doesn't support it and it can only be used with ex. send. This fixes an issue where invalid JSON was output from ObjectSpace.dump when a method name needed escaping.
* Also escape DEL codeNobuyoshi Nakada2020-08-171-0/+3
|
* Fixed the radix for control charsNobuyoshi Nakada2020-08-171-1/+1
|
* [DOC] Clarify ObjectSpace return values are in bytes [ci skip]Simon Perepelitsa2020-07-281-2/+2
|
* Avoid allocating a string when dumping an anonymous module or classJean Boussier2020-07-231-2/+5
|
* Fix missing imemo cases in objspace_dump by refactoringAlan Wu2020-07-101-23/+1
| | | | | | imemo_callcache and imemo_callinfo were not handled by the `objspace` module and were showing up as "unknown" in the dump. Extract the code for naming imemos and use that in both the GC and the `objspace` module.
* Introduce find pattern [Feature #16828]Kazuki Tsujimoto2020-06-141-0/+1
|
* sed -i 's|ruby/impl|ruby/internal|'卜部昌平2020-05-111-421/+421
| | | | To fix build failures.
* sed -i s|ruby/3|ruby/impl|g卜部昌平2020-05-111-421/+421
| | | | This shall fix compile errors.
* Fix indentationKazuki Tsujimoto2020-05-041-4/+4
|
* Suppress -Wswitch warningsNobuyoshi Nakada2020-04-081-0/+4
|
* Merge pull request #2991 from shyouhei/ruby.h卜部昌平2020-04-081-2/+457
| | | Split ruby.h
* should not expose hidden object.Koichi Sasada2020-02-291-7/+8
| | | | | | Hidden object (T_CLASS) can be exposed (BUG). Also rename rb_mInternalObjectWrapper to rb_cInternalObjectWrapper because it is a class.
* Introduce disposable call-cache.Koichi Sasada2020-02-221-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch contains several ideas: (1) Disposable inline method cache (IMC) for race-free inline method cache * Making call-cache (CC) as a RVALUE (GC target object) and allocate new CC on cache miss. * This technique allows race-free access from parallel processing elements like RCU. (2) Introduce per-Class method cache (pCMC) * Instead of fixed-size global method cache (GMC), pCMC allows flexible cache size. * Caching CCs reduces CC allocation and allow sharing CC's fast-path between same call-info (CI) call-sites. (3) Invalidate an inline method cache by invalidating corresponding method entries (MEs) * Instead of using class serials, we set "invalidated" flag for method entry itself to represent cache invalidation. * Compare with using class serials, the impact of method modification (add/overwrite/delete) is small. * Updating class serials invalidate all method caches of the class and sub-classes. * Proposed approach only invalidate the method cache of only one ME. See [Feature #16614] for more details.
* VALUE size packed callinfo (ci).Koichi Sasada2020-02-221-0/+1
| | | | | | | | | | | | | | | | | | | | Now, rb_call_info contains how to call the method with tuple of (mid, orig_argc, flags, kwarg). Most of cases, kwarg == NULL and mid+argc+flags only requires 64bits. So this patch packed rb_call_info to VALUE (1 word) on such cases. If we can not represent it in VALUE, then use imemo_callinfo which contains conventional callinfo (rb_callinfo, renamed from rb_call_info). iseq->body->ci_kw_size is removed because all of callinfo is VALUE size (packed ci or a pointer to imemo_callinfo). To access ci information, we need to use these functions: vm_ci_mid(ci), _flag(ci), _argc(ci), _kwarg(ci). struct rb_call_info_kw_arg is renamed to rb_callinfo_kwarg. rb_funcallv_with_cc() and rb_method_basic_definition_p_with_cc() is temporary removed because cd->ci should be marked.
* Updated dependencies on internal/warnings.hNobuyoshi Nakada2019-12-311-0/+2
| | | | | Needed for `UNALIGNED_MEMBER_ACCESS` using `COMPILER_WARNING_`* macros.
* update dependencies卜部昌平2019-12-261-0/+20
|
* decouple internal.h headers卜部昌平2019-12-262-8/+14
| | | | | | | | | | | | | | | | | | Saves comitters' daily life by avoid #include-ing everything from internal.h to make each file do so instead. This would significantly speed up incremental builds. We take the following inclusion order in this changeset: 1. "ruby/config.h", where _GNU_SOURCE is defined (must be the very first thing among everything). 2. RUBY_EXTCONF_H if any. 3. Standard C headers, sorted alphabetically. 4. Other system headers, maybe guarded by #ifdef 5. Everything else, sorted alphabetically. Exceptions are those win32-related headers, which tend not be self- containing (headers have inclusion order dependencies).
* Update dependenciesNobuyoshi Nakada2019-11-181-5/+0
|
* Revert "Method reference operator"Nobuyoshi Nakada2019-11-121-1/+0
| | | | | This reverts commit 67c574736912003c377218153f9d3b9c0c96a17b. [Feature #16275]
* Rename NODE_ARRAY to NODE_LIST to reflect its actual use casesYusuke Endoh2019-09-071-2/+2
| | | | | | | | | | and NODE_ZARRAY to NODE_ZLIST. NODE_ARRAY is used not only by an Array literal, but also the contents of Hash literals, method call arguments, dynamic string literals, etc. In addition, the structure of NODE_ARRAY is a linked list, not an array. This is very confusing, so I believe `NODE_LIST` is a better name.
* st_foreach now free from ANYARGS卜部昌平2019-08-271-2/+2
| | | | | | | | After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. This commit deletes ANYARGS from st_foreach. I strongly believe that this commit should have had come with b0af0592fdd9e9d4e4b863fde006d67ccefeac21, which added extra parameter to st_foreach callbacks.
* * expand tabs.git2019-07-311-1/+1
|
* Use 1 byte hint for ar_table [Feature #15602]Koichi Sasada2019-07-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On ar_table, Do not keep a full-length hash value (FLHV, 8 bytes) but keep a 1 byte hint from a FLHV (lowest byte of FLHV). An ar_table only contains at least 8 entries, so hints consumes 8 bytes at most. We can store hints in RHash::ar_hint. On 32bit CPU, we use 4 entries ar_table. The advantages: * We don't need to keep FLHV so ar_table only consumes 16 bytes (VALUEs of key and value) * 8 entries = 128 bytes. * We don't need to scan ar_table, but only need to check hints in many cases. Especially we don't need to access ar_table if there is no match entries (in many cases). It will increase memory cache locality. The disadvantages: * This technique can increase `#eql?` time because hints can conflicts (in theory, it conflicts once in 256 times). It can introduce incompatibility if there is a object x where x.eql? returns true even if hash values are different. I believe we don't need to care such irregular case. * We need to re-calculate FLHV if we need to switch from ar_table to st_table (e.g. exceeds 8 entries). It also can introduce incompatibility, on mutating key objects. I believe we don't need to care such irregular case too. Add new debug counters to measure the performance: * artable_hint_hit - hint is matched and eql?#=>true * artable_hint_miss - hint is not matched but eql?#=>false * artable_hint_notfound - lookup counts