aboutsummaryrefslogtreecommitdiffstats
path: root/gc.c
Commit message (Collapse)AuthorAgeFilesLines
* Allow global variables to moveAaron Patterson2020-05-071-0/+1
| | | | | | | | | | This patch allows global variables that have been assigned in Ruby to move. I added a new function for the GC to call that will update global references and introduced a new callback in the global variable struct for updating references. Only pure Ruby global variables are supported right now, other references will be pinned.
* `T_MOVED` should never be pushed on the mark stackAaron Patterson2020-05-071-0/+1
| | | | | | | No objects should ever reference a `T_MOVED` slot. If they do, it's absolutely a bug. If we kill the process when `T_MOVED` is pushed on the mark stack it will make it easier to identify which object holds a reference that hasn't been updated.
* Output compaction stats in one loop / eliminate 0 countsAaron Patterson2020-05-041-4/+6
| | | | | | | | We only need to loop `T_MASK` times once. Also, not every value between 0 and `T_MASK` is an actual Ruby type. Before this change, some integers were being added to the result hash even though they aren't actual types. This patch omits considered / moved entries that total 0, cleaning up the result hash and eliminating these "fake types".
* Rename arguments for ObjectSpace::WeakMap#[]= for clarityBenoit Daloze2020-05-021-8/+8
|
* Fix ObjectSpace::WeakMap#key? to work if the value is nilBenoit Daloze2020-05-021-4/+12
| | | | * Fixes [Bug #16826]
* Mark ruby_memerror as NORETURNNobuyoshi Nakada2020-04-291-1/+2
|
* Remove debugging code from gc.cYusuke Endoh2020-04-291-4/+1
| | | | | | | Partially revert adab82b9a71f60ad1c7f4f8c134a5ae9198ab32a and c63b5c6179d700ceacf5cae8d3ee86da1294c781. The issue that these commits attempt to address was maybe fixed with 1c7f5a57125001447dc6173847dc68aa50bd8e93.
* Fix a typo [ci skip]Kazuhiro NISHIYAMA2020-04-271-1/+1
|
* Assert that typed data is distinguished from non-typedNobuyoshi Nakada2020-04-251-0/+2
|
* rb_memerror: abort immediately卜部昌平2020-04-211-0/+3
| | | | | Ditto for adab82b9a71f60ad1c7f4f8c134a5ae9198ab32a. TRY_WITH_GC was found innocent.
* Fixed a typo [ci skip]Nobuyoshi Nakada2020-04-211-1/+1
|
* TRY_WITH_GC: abort immediately卜部昌平2020-04-211-4/+36
| | | | | NoMemoryError is observed on icc but I fail to reproduce so far. Let me see the backtrace on CI.
* Moved noreturn call to end of noreturn functionNobuyoshi Nakada2020-04-161-1/+1
|
* Suppress -Wswitch warningsNobuyoshi Nakada2020-04-081-0/+12
|
* Merge pull request #2991 from shyouhei/ruby.h卜部昌平2020-04-081-113/+63
| | | Split ruby.h
* Bail out before pushing unexpected objectNobuyoshi Nakada2020-04-031-0/+12
|
* fix type castKoichi Sasada2020-03-111-1/+1
|
* show method entry with iseq detailsKoichi Sasada2020-03-111-1/+2
|
* fix compile error w/ -DCALC_EXACT_MALLOC_SIZE卜部昌平2020-03-041-4/+0
|
* kill USE_RGENGC=0卜部昌平2020-02-261-136/+2
| | | | | | This compile-time option has been broken for years (at least since commit 49369ef17316cd5d5819b038f286e1d951972b52, according to git bisect). Let's delete codes that no longer works.
* avoid #if inside of rb_str_new_cstr卜部昌平2020-02-261-2/+3
| | | | | | | | | ISO/IEC 9899:1999 section 6.10.3 paragraph 11 explicitly states that "If there are sequences of preprocessing tokens within the list of arguments that would otherwise act as preprocessing directives, the behavior is undefined." rb_str_new_cstr is in fact a macro. We cannot do this.
* Introduce disposable call-cache.Koichi Sasada2020-02-221-6/+198
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-2/+23
| | | | | | | | | | | | | | | | | | | | 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.
* TestTime#test_memsize: skip when on GC_DEBUG卜部昌平2020-02-201-0/+1
| | | | | GC_DEBUG=1 makes this test fail because it changes the size of struct RVALUE. I don't think the test is useful then. Let's just skip.
* Revert "gc.c: make the stack overflow detection earlier under s390x"Yusuke Endoh2020-02-101-7/+0
| | | | | | | This reverts commit a28c166f787710227c6aac54befd72778f041485. This change didn't help. According to odaira, the issue was fixed by increasing `ulimit -s`.
* Disable GC until VM objects get initialized [Bug #16616]Nobuyoshi Nakada2020-02-091-0/+1
|
* Separate objspace argument for rb_gc_disable and rb_gc_enableNobuyoshi Nakada2020-02-091-6/+24
|
* gc.c: make the stack overflow detection earlier under s390xYusuke Endoh2020-02-091-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On s390x, TestFiber#test_stack_size fails with SEGV. https://rubyci.org/logs/rubyci.s3.amazonaws.com/rhel_zlinux/ruby-master/log/20200205T223421Z.fail.html.gz ``` TestFiber#test_stack_size [/home/chkbuild/build/20200205T223421Z/ruby/test/ruby/test_fiber.rb:356]: pid 23844 killed by SIGABRT (signal 6) (core dumped) | -e:1:in `times': stack level too deep (SystemStackError) | from -e:1:in `rec' | from -e:1:in `block (3 levels) in rec' | from -e:1:in `times' | from -e:1:in `block (2 levels) in rec' | from -e:1:in `times' | from -e:1:in `block in rec' | from -e:1:in `times' | from -e:1:in `rec' | ... 172 levels... | from -e:1:in `block in rec' | from -e:1:in `times' | from -e:1:in `rec' | from -e:1:in `block in <main>' | -e: [BUG] Segmentation fault at 0x0000000000000000 ``` This change tries a similar fix with ef64ab917eec02491f6bf7233a4031a8c35385e3 and 3ddbba84b5b1f001cd575a48cec56d7ce8e5fbb2.
* Removed type-punning pointer casts around `st_data_t`Nobuyoshi Nakada2020-01-311-12/+13
|
* Moved `GC.verify_compaction_references` to gc.rbNobuyoshi Nakada2020-01-271-45/+5
| | | | | And fixed a segfault by coercion of `Qundef`, when any keyword argument without `toward:` option is given.
* Fix syntax error in obj_free with hash size debug counter when ↵Lourens Naudé2020-01-131-1/+1
| | | | USE_DEBUG_COUNTER is enabled
* Introduce BIGNUM_EMBED_P to check BIGNUM_EMBED_FLAG (#2802)Kenta Murata2019-12-311-1/+1
| | | | | | * bignum.h: Add BIGNUM_EMBED_P * bignum.c: Use macros for handling BIGNUM_EMBED_FLAG
* Separate builtin initialization callsNobuyoshi Nakada2019-12-291-1/+0
|
* decouple internal.h headers卜部昌平2019-12-261-40/+65
| | | | | | | | | | | | | | | | | | 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).
* split internal.h into files卜部昌平2019-12-261-0/+6
| | | | | | | | | One day, I could not resist the way it was written. I finally started to make the code clean. This changeset is the beginning of a series of housekeeping commits. It is a simple refactoring; split internal.h into files, so that we can divide and concur in the upcoming commits. No lines of codes are either added or removed, except the obvious file headers/footers. The generated binary is identical to the one before.
* fix wmap_finalize.Koichi Sasada2019-12-231-2/+16
| | | | | | wmap_finalize expects id2ref() returns a corresponding object even if the object is dead. Make id2ref_obj_tbl() for this purpose.
* add more debug counters to count numeric objects.Koichi Sasada2019-12-231-0/+8
|
* ObjectSpace._id2ref should check liveness.Koichi Sasada2019-12-231-1/+2
| | | | | objspace->id_to_obj_tbl can contain died objects because of lazy sweep, so that it should check liveness.
* Fixed misspellingsNobuyoshi Nakada2019-12-201-1/+1
| | | | Fixed misspellings reported at [Bug #16437], only in ruby and rubyspec.
* Refactor free page insertionAaron Patterson2019-12-181-7/+7
| | | | | | | | | | | I am trying to fix this error: http://ci.rvm.jp/results/trunk-gc_compact@silicon-docker/2491596 Somehow we have a page in the `free_pages` list that is full. This commit refactors the code so that any time we add a page to the `free_pages` list, we do it via `heap_add_freepage`. That function then asserts that the free slots on that page are not 0.
* proper initialization of struct RVALUE卜部昌平2019-12-121-5/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset makes no difference unless GC_DEBUG is on. When that flag is set, struct RVALUE is bigger than struct RObject. We have to take care of the additional fields. Otherwise we get a SIGSEGV like shown below. The way obj is initialized in this patch works for both GC_DEBUG is on and off. See also ISO/IEC 9899:1999 section 6.7.8 paragraph #21. ``` Program received signal SIGSEGV, Segmentation fault. __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:62 62 ../sysdeps/x86_64/multiarch/strlen-avx2.S: No such file or directory (gdb) bt #0 __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:62 #1 0x00005555557dd9a7 in BSD_vfprintf (fp=0x7fffffff6be0, fmt0=0x5555558f3059 "@%s:%d", ap=0x7fffffff6dd0) at vsnprintf.c:1027 #2 0x00005555557db6f5 in ruby_do_vsnprintf (str=0x555555bfc58d <obj_info_buffers+1325> "", n=211, fmt=0x5555558f3059 "@%s:%d", ap=0x7fffffff6dd0) at sprintf.c:1022 #3 0x00005555557db909 in ruby_snprintf (str=0x555555bfc58d <obj_info_buffers+1325> "", n=211, fmt=0x5555558f3059 "@%s:%d") at sprintf.c:1040 #4 0x0000555555661ef4 in rb_raw_obj_info (buff=0x555555bfc560 <obj_info_buffers+1280> "0x0000555555d2bfa0 [0 ] T_STRING (String)", buff_size=256, obj=93825000456096) at gc.c:11449 #5 0x000055555565baaf in obj_info (obj=93825000456096) at gc.c:11612 #6 0x000055555565bae1 in rgengc_remembered (objspace=0x555555c0a1c0, obj=93825000456096) at gc.c:6618 #7 0x0000555555666987 in newobj_init (klass=93824999964192, flags=5, v1=0, v2=0, v3=0, wb_protected=1, objspace=0x555555c0a1c0, obj=93825000456096) at gc.c:2134 #8 0x0000555555666e49 in newobj_slowpath (klass=93824999964192, flags=5, v1=0, v2=0, v3=0, objspace=0x555555c0a1c0, wb_protected=1) at gc.c:2209 #9 0x0000555555666b94 in newobj_slowpath_wb_protected (klass=93824999964192, flags=5, v1=0, v2=0, v3=0, objspace=0x555555c0a1c0) at gc.c:2220 #10 0x000055555565751b in newobj_of (klass=93824999964192, flags=5, v1=0, v2=0, v3=0, wb_protected=1) at gc.c:2256 #11 0x00005555556575ca in rb_wb_protected_newobj_of (klass=93824999964192, flags=5) at gc.c:2272 #12 0x00005555557f36ea in str_alloc (klass=93824999964192) at string.c:728 #13 0x00005555557f2128 in rb_str_buf_new (capa=0) at string.c:1317 #14 0x000055555578c66d in rb_reg_preprocess (p=0x555555cc8148 "^-(.)(.+)?", end=0x555555cc8152 "", enc=0x555555cc7c80, fixed_enc=0x7fffffff74e8, err=0x7fffffff75f0 "") at re.c:2682 #15 0x000055555578ea13 in rb_reg_initialize (obj=93825000046736, s=0x555555cc8148 "^-(.)(.+)?", len=10, enc=0x555555cc7c80, options=0, err=0x7fffffff75f0 "", sourcefile=0x555555d1a5c0 "lib/optparse.rb", sourceline=1460) at re.c:2808 #16 0x000055555578e285 in rb_reg_initialize_str (obj=93825000046736, str=93825000046904, options=0, err=0x7fffffff75f0 "", sourcefile=0x555555d1a5c0 "lib/optparse.rb", sourceline=1460) at re.c:2869 #17 0x000055555578ee02 in rb_reg_compile (str=93825000046904, options=0, sourcefile=0x555555d1a5c0 "lib/optparse.rb", sourceline=1460) at re.c:2958 #18 0x0000555555748dfb in rb_parser_reg_compile (p=0x555555d1f760, str=93825000046904, options=0) at parse.y:12157 #19 0x00005555557581c3 in parser_reg_compile (p=0x555555d1f760, str=93825000046904, options=0) at parse.y:12151 #20 0x00005555557580ac in reg_compile (p=0x555555d1f760, str=93825000046904, options=0) at parse.y:12167 #21 0x0000555555746ebb in new_regexp (p=0x555555d1f760, node=0x555555dece68, options=0, loc=0x7fffffff89e8) at parse.y:10072 #22 0x000055555573d1f5 in ruby_yyparse (p=0x555555d1f760) at parse.y:4395 #23 0x000055555574a582 in yycompile0 (arg=93825000404832) at parse.y:5945 #24 0x00005555558c6898 in rb_suppress_tracing (func=0x55555574a470 <yycompile0>, arg=93825000404832) at vm_trace.c:427 #25 0x0000555555748290 in yycompile (vparser=93824999283456, p=0x555555d1f760, fname=93824999283624, line=1) at parse.y:5994 #26 0x00005555557481ae in rb_parser_compile_file_path (vparser=93824999283456, fname=93824999283624, file=93824999283400, start=1) at parse.y:6098 #27 0x00005555557cdd35 in load_file_internal (argp_v=140737488331760) at ruby.c:2023 #28 0x00005555556438c5 in rb_ensure (b_proc=0x5555557cd610 <load_file_internal>, data1=140737488331760, e_proc=0x5555557cddd0 <restore_load_file>, data2=140737488331760) at eval.c:1128 #29 0x00005555557cb68b in load_file (parser=93824999283456, fname=93824999283624, f=93824999283400, script=0, opt=0x7fffffffa468) at ruby.c:2142 #30 0x00005555557cb339 in rb_parser_load_file (parser=93824999283456, fname_v=93824999283624) at ruby.c:2164 #31 0x00005555556ba3e1 in load_iseq_eval (ec=0x555555c0a650, fname=93824999283624) at load.c:579 #32 0x00005555556b857a in require_internal (ec=0x555555c0a650, fname=93824999284352, exception=1) at load.c:1016 #33 0x00005555556b7967 in rb_require_string (fname=93824999284464) at load.c:1105 #34 0x00005555556b7939 in rb_f_require (obj=93824999994824, fname=93824999284464) at load.c:811 #35 0x00005555558b7ae0 in call_cfunc_1 (recv=93824999994824, argc=1, argv=0x7ffff7ecd0a8, func=0x5555556b7920 <rb_f_require>) at vm_insnhelper.c:2348 #36 0x00005555558a8889 in vm_call_cfunc_with_frame (ec=0x555555c0a650, reg_cfp=0x7ffff7fccfa0, calling=0x7fffffffaab0, cd=0x555555d76a10, empty_kw_splat=0) at vm_insnhelper.c:2513 #37 0x000055555589fb5c in vm_call_cfunc (ec=0x555555c0a650, reg_cfp=0x7ffff7fccfa0, calling=0x7fffffffaab0, cd=0x555555d76a10) at vm_insnhelper.c:2538 #38 0x000055555589f22e in vm_call_method_each_type (ec=0x555555c0a650, cfp=0x7ffff7fccfa0, calling=0x7fffffffaab0, cd=0x555555d76a10) at vm_insnhelper.c:2924 #39 0x000055555589ef47 in vm_call_method (ec=0x555555c0a650, cfp=0x7ffff7fccfa0, calling=0x7fffffffaab0, cd=0x555555d76a10) at vm_insnhelper.c:3038 #40 0x0000555555866dbd in vm_call_general (ec=0x555555c0a650, reg_cfp=0x7ffff7fccfa0, calling=0x7fffffffaab0, cd=0x555555d76a10) at vm_insnhelper.c:3075 #41 0x00005555558ae557 in vm_sendish (ec=0x555555c0a650, reg_cfp=0x7ffff7fccfa0, cd=0x555555d76a10, block_handler=0, method_explorer=0x5555558ae5d0 <vm_search_method_wrap>) at vm_insnhelper.c:4021 #42 0x000055555587745b in vm_exec_core (ec=0x555555c0a650, initial=0) at insns.def:801 #43 0x0000555555899b9c in rb_vm_exec (ec=0x555555c0a650, mjit_enable_p=1) at vm.c:1907 #44 0x000055555589aaf0 in rb_iseq_eval_main (iseq=0x555555c1da80) at vm.c:2166 #45 0x0000555555641f0b in rb_ec_exec_node (ec=0x555555c0a650, n=0x555555c1da80) at eval.c:277 #46 0x0000555555641d62 in ruby_run_node (n=0x555555c1da80) at eval.c:335 #47 0x000055555557a188 in main (argc=11, argv=0x7fffffffc848) at main.c:50 (gdb) fr 7 #7 0x0000555555666987 in newobj_init (klass=93824999964192, flags=5, v1=0, v2=0, v3=0, wb_protected=1, objspace=0x555555c0a1c0, obj=93825000456096) at gc.c:2134 2134 if (rgengc_remembered(objspace, (VALUE)obj)) rb_bug("newobj: %s is remembered.", obj_info(obj)); (gdb) p ((struct RVALUE*)obj)->file $1 = 0x65a5992b0fb25ce7 <error: Cannot access memory at address 0x65a5992b0fb25ce7> (gdb) ```
* fix arity mismatch卜部昌平2019-12-121-1/+1
| | | | | I missed this in bc3e7924bc66d3ef77b219c72f3e59cc154550a3 because the function is inside of a #ifdef.
* Update method tables only if there is a class ext pointerAaron Patterson2019-12-111-4/+2
| | | | | This makes reference updating look similar to marking, and may avoid dereferencing a wrong pointer.
* add additional CF info for CI envKoichi Sasada2019-12-051-4/+4
| | | | | | | | | Introduce new RUBY_DEBUG option 'ci' to inform Ruby interpreter that an interpreter is running on CI environment. With this option, `rb_bug()` shows more information includes method entry information, local variables information for each control frame.
* prefer class_serial over m_tbl卜部昌平2019-11-271-4/+4
| | | | | | | | | | | | | | | | | | | Decades ago, among all the data that a class has, its method table was no doubt the most frequently accessed data. Previous data structures were based on that assumption. Today that is no longer true. The most frequently accessed field moved to class_serial. That field is not always as wide as VALUE but if it is, let us swap m_tbl and class_serial. Calculating ------------------------------------- ours trunk Optcarrot Lan_Master.nes 47.363 46.630 fps Comparison: Optcarrot Lan_Master.nes ours: 47.4 fps trunk: 46.6 fps - 1.02x slower
* Count pinned slots using only bitmapJohn Hawthorn2019-11-221-24/+4
| | | | | | | | | | | This is significantly faster than checking BUILTIN_TYPEs because we access significantly less memory. We also use popcount to count entire words at a time. The only functional difference from the previous implementation is that T_ZOMBIE objects will no longer be counted. However those are temporary objects which should be small in number, and this method has always been an estimate.
* Optimize pinned page sortingJohn Hawthorn2019-11-221-3/+9
| | | | | | | Previously we would count the pinned objects on each comparison. Since sorting is O(N log N) and we calculated this on both left and right pages on each comparison this resulted in a extra iterations over the slots.
* Use value of use_verifier in gc_compactJohn Hawthorn2019-11-221-1/+1
|
* make functions static卜部昌平2019-11-191-2/+4
| | | | | | | These functions are used from within a compilation unit so we can make them static, for better binary size. This changeset reduces the size of generated ruby binary from 26,590,128 bytes to 26,584,472 bytes on my macihne.
* Deprecate taint/trust and related methods, and make the methods no-opsJeremy Evans2019-11-181-5/+0
| | | | | | This removes the related tests, and puts the related specs behind version guards. This affects all code in lib, including some libraries that may want to support older versions of Ruby.