summaryrefslogtreecommitdiff
path: root/gc.c
AgeCommit message (Collapse)Author
2017-11-07* eval_intern.h: rename macros rb_thread_raised_* toko1
rb_ec_raised_*. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-07use GET_VM()ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-04gc.c: UNEXPECTED_NODEnobu
* gc.c (UNEXPECTED_NODE): extract rb_bug for T_NODE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-04gc.c (rb_free_tmp_buffer): stop accessing imemo_alloc as NODEmame
The fields of imemo_alloc were accessed via RNODE() cast, since the imemo was NODE_ALLOCA traditionally. This was refactored at r60239, so now the fields should be accessed as imemo_alloc. This prevented change of NODE structure. Yuichiro Kaneko pointed out this inconsistency. Thanks! git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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-04Remove NODE-related pieces of code from GCmame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-04Revert "Revert "Replace NODE_STRTERM and NODE_HEREDOC with imemo_strterm""mame
Retry r60634 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-04Revert "Replace NODE_STRTERM and NODE_HEREDOC with imemo_strterm"mame
Due to build failure on mswin and mingw. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-04Replace NODE_STRTERM and NODE_HEREDOC with imemo_strtermmame
Just refactoring. NODE_STRTERM and NODE_HEREDOC are not an internal node of AST, but a temporary storage for managing termination of string literals and heredocs. Instead of NODE abuse, I want to use imemo for the storage in order to avoid (my) confusion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29* node.h (ast_t): renamed to `rb_ast_t`.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29remove rb_threadptr_during_gc().ko1
* gc.c (rb_threadptr_during_gc): removed because nobody use it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29use `GET_EC()`.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29rb_ec_stack_check()ko1
* gc.c (rb_ec_stack_check): renamed from rb_threadptr_stack_check() and it accepts `ec`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60542 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29use `GET_EC()` directly.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60541 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29EXEC_EVENT_HOOK(ec, ...)ko1
* vm_core.h (EXEC_EVENT_HOOK): accepts `ec` instead of `th`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27Revert "Revert "Manage AST NODEs out of GC""mame
This re-introduces r60485. This reverts commit 5a176b75b1187cbd3861c387bde65ff66396a07c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60488 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27Revert "Manage AST NODEs out of GC"mame
This reverts commit 620ba74778bfdbdc34ffbb142d49ce84a0ef58e9. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60486 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27Manage AST NODEs out of GCmame
NODEs in AST are no longer objects managed by GC. This change will remove the restriction imposed by the GC. For example, a NODE can use more than five words (this is my primary purpose; we want to store the position data for each NODE, for coverage library), or even a NODE can have variable length (some kinds of NODEs have unused fields). To do this, however, we need more work, since Ripper still uses T_NODE objects managed by the GC. The life time of NODEs is more obvious than other kinds of objects; they are created at parsing, and they become disused immediately after compilation. This change releases all NODEs by a few `xfree`s after compilation, so performance will be improved a bit. In extreme example, `eval("x=1;" * 10000000)` runs much faster (40 sec. -> 7.8 sec. on my machine). The most important part of this change is `ast_t` struct, which has three contents: (1) NODE buffer (malloc'ed memory), (2) a reference to the root NODE, and (3) an array that contains objects that must be marked during parsing (such as literal objects). Some functions that had received `NODE*` arguments, must now receive `ast_t*`. * node.c, node.h: defines `ast_t` struct and related operations. * gc.c, internal.h: defines `imemo_ast`. * parse.y: makes `parser_params` struct have a reference to `ast_t`. Instead of `rb_node_newnode`, use `rb_ast_newnode` to create a NODE. * iseq.c, load.c, ruby.c, template/prelude.c.tmpl: modifies some functions to handle `ast_t*` instead of `NODE*`. * test/ruby/test_gc.rb: ad-hoc fix for a failed test. The test assumes GC eden is increased at startup by NODE object creation. However, this change now create no NODE object, so GC eden is not necessarily increased. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26replace `GET_THREAD()->ec` to `GET_EC()`.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26introduce EC_*_TAG() instead of TH_*_TAG()ko1
* eval_intern.h: introduce EC_*_TAG() macros instead of TH_*_TAG() macros. * TH_PUSH_TAG() -> EC_PUSH_TAG() * TH_POP_TAG() -> EC_POP_TAG() * TH_TMPPOP_TAG() -> EC_TMPPOP_TAG() * TH_REPUSH_TAG() -> EC_REPUSH_TAG() * TH_EXEC_TAG() -> EC_EXEC_TAG() * TH_JUMP_TAG() -> EC_JUMP_TAG() rb_threadptr_tag_state() , rb_ec_tag_jump() also accept `ec` instead of `th`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26Expand the definition of rb_imemo_new in rb_imemo_alloc_newmame
per ko1's comment git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60443 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26Use rb_execution_context_t instead of rb_thread_tko1
to represent execution context [Feature #14038] * vm_core.h (rb_thread_t): rb_thread_t::ec is now a pointer. There are many code using `th` to represent execution context (such as cfp, VM stack and so on). To access `ec`, they need to use `th->ec->...` (adding one indirection) so that we need to replace them by passing `ec` instead of `th`. * vm_core.h (GET_EC()): introduced to access current ec. Also remove `ruby_current_thread` global variable. * cont.c (rb_context_t): introduce rb_context_t::thread_ptr instead of rb_context_t::thread_value. * cont.c (ec_set_vm_stack): added to update vm_stack explicitly. * cont.c (ec_switch): added to switch ec explicitly. * cont.c (rb_fiber_close): added to terminate fibers explicitly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60440 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-25Refactoring by adding `rb_imemo_alloc_new` to create imemo_alloc buffermame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-25Make imemo_alloc writebarrier-unprotectedmame
imemo_alloc provides a memory buffer whose contents are marked by GC. C code can access imemo_alloc buffer freely, so imemo_alloc must be considered writebarrier-unprotected. But T_IMEMO is writebarrier- protected by default, which caused a GC bug. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-23Drop to support NaCl platform.hsbt
Because NaCl and PNaCl are already sunset status. see https://bugs.chromium.org/p/chromium/issues/detail?id=239656#c160 configure.ac: Patch for this file was provided by @nobu. [Feature #14041][ruby-core:83497][fix GH-1726] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21gc.c (rb_raw_obj_info): suppress a warningnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21gc.c (rb_raw_obj_info): adjust indentnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60258 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21do not need to clear by NULL because of last commitko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60251 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-21fix up imemo_allocnobu
* internal.h (rb_imemo_alloc_struct), gc.c (gc_mark_imemo): turned next into the pointer to chain. * parse.y (NEWHEAP): needs a cast. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60244 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-10-18Get rid of shadowing local variablesnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-02use rb_hash_new_with_size()nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60101 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-10move th->machine to ec->machine.ko1
* vm_core.h: move rb_thread_t::machine to rb_execution_context_t::machine. * vm_core.h, gc.c (rb_gc_mark_machine_stack): accept ec instead of th. it enables to call this func from rb_execution_context_mark() in vm.c. * cont.c (fiber_setcontext): catch up this fix. fiber_restore_thread() restores machine stack information too. * gc.c: catch up structure layout changes. * thread.c: ditto. * thread_pthread.c: ditto. * thread_win32.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-04gc.c: fix typo: nubmer -> numberkazu
Signed-off-by: Antonio Terceiro <terceiro@softwarelivre.org> [Bug #13862] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59739 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-28Increase STACKFRAME_FOR_CALL_CFUNCnaruse
On below env, miniruby requires 568 and ruby requires 838 to pass. * ruby -v: ruby 2.5.0dev (2017-08-28 trunk 59670) [x86_64-freebsd10.3] * gcc8 (FreeBSD Ports Collection) 8.0.0 20170828 (experimental) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-23gc.c: restore cfp at finalizernobu
* gc.c (run_finalizer): restore cfp for the case an exception raised in a finalizer. [ruby-core:82432] [Bug #13832] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-23gc.c: run all finalizersnobu
* gc.c (run_finalizer): revert r59155 partially. finalizing loop should continue even after an exception is rescued. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-21prevent stack overflownobu
* gc.c: enable PREVENT_STACK_OVERFLOW. * vm.c (invoke_iseq_block_from_c): prevent stack overflow. * vm_eval.c (stack_check): raise preallocated exception instance. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-12disable r59314 on mswinnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59315 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-12gc.c: restrict RGENGC_DEBUGnobu
* gc.c (RGENGC_DEBUG_ENABLED): restrict runtime ruby_rgengc_debug level up to -RGENGC_DEBUG, to reduce runtime branches in inner loops. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59314 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-28move fields to ec.ko1
* vm_core.h (rb_thread.h): move errinfo and trace_arg to rb_execution_context_t. * cont.c (fiber_switch, rb_cont_call): do not restore "trace_arg" here. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-23use "enum ruby_tag_type" and TAG_NONE.ko1
Return value of EXEC_TAG() is saved by "int state". Instead of "int", use "enum ruby_tag_type". First EXEC_TAG() value should be 0, so that define TAG_NONE (= 0) and use it. Some code used "status" instead of "state". To make them clear, rename them to state. We can change variable name from "state" to "tag_state", but this ticket doesn't contain it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-22* remove trailing spaces.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-22introduce heap_allocatable_pages_set().ko1
* gc.c (heap_allocatable_pages_set): added. This function set heap_allocatable_pages and sorted_list atomically. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-22introduce GC_ASSERT().ko1
* gc.c (GC_ASSERT()): added. GC_ASSERT() is similar to VM_ASSERT in vm_core.h but turn on by RGENGC_CHECK_MODE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59138 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-22gc.c: expand sorted pagesnobu
* gc.c (heap_page_allocate): expand sorted pages before inserting allocated new page. [Bug #12670] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-21gc.c: FL_CHECK2nobu
* gc.c (FL_TEST2, FL_SET2, FL_UNSET2): make error messages consitent. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59135 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-21RUBY_DEVEL flagnobu
* configure.in: define RUBY_DEVEL only in the trunk. * gc.c: enable runtime rgengc debug if RUBY_DEVEL * ruby.c (debug_option): enable RUBY_DEBUG in --debug option only if RUBY_DEVEL. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-20gc.c: add newline to report [ci skip]nobu
* gc.c (gc_sweep_finish): gc_report format should end with a newline, as gc_report_body does not append it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e