Граф коммитов

1727 Коммитов

Автор SHA1 Сообщение Дата
Nobuyoshi Nakada cbbe198c89
Fix potential memory leaks by `rb_imemo_tmpbuf_auto_free_pointer`
This function has been used wrongly always at first, "allocate a
buffer then wrap it with tmpbuf".  This order can cause a memory
leak, as tmpbuf creation also can raise a NoMemoryError exception.
The right order is "create a tmpbuf then allocate&wrap a buffer".
So the argument of this function is rather harmful than just
useless.

TODO:
* Rename this function to more proper name, as it is not used
  "temporary" (function local) purpose.
* Allocate and wrap at once safely, like `ALLOCV`.
2019-10-05 03:02:09 +09:00
卜部昌平 eb92159d72 Revert https://github.com/ruby/ruby/pull/2486
This reverts commits: 10d6a3aca7 8ba48c1b85 fba8627dc1 dd883de5ba
6c6a25feca 167e6b48f1 7cb96d41a5 3207979278 595b3c4fdd 1521f7cf89
c11c5e69ac cf33608203 3632a812c0 f56506be0d 86427a3219 .

The reason for the revert is that we observe ABA problem around
inline method cache.  When a cache misshits, we search for a
method entry.  And if the entry is identical to what was cached
before, we reuse the cache.  But the commits we are reverting here
introduced situations where a method entry is freed, then the
identical memory region is used for another method entry.  An
inline method cache cannot detect that ABA.

Here is a code that reproduce such situation:

```ruby
require 'prime'

class << Integer
  alias org_sqrt sqrt
  def sqrt(n)
    raise
  end

  GC.stress = true
  Prime.each(7*37){} rescue nil # <- Here we populate CC
  class << Object.new; end

  # These adjacent remove-then-alias maneuver
  # frees a method entry, then immediately
  # reuses it for another.
  remove_method :sqrt
  alias sqrt org_sqrt
end

Prime.each(7*37).to_a # <- SEGV
```
2019-10-03 12:45:24 +09:00
卜部昌平 dd883de5ba refactor constify most of rb_method_entry_t
Now that we have eliminated most destructive operations over the
rb_method_entry_t / rb_callable_method_entry_t, let's make them
mostly immutabe and mark them const.

One exception is rb_export_method(), which destructively modifies
visibilities of method entries.  I have left that operation as is
because I suspect that destructiveness is the nature of that
function.
2019-09-30 10:26:38 +09:00
卜部昌平 cf33608203 refactor constify most of rb_method_definition_t
Most (if not all) of the fields of rb_method_definition_t are never
meant to be modified once after they are stored.  Marking them const
makes it possible for compilers to warn on unintended modifications.
2019-09-30 10:26:38 +09:00
Nobuyoshi Nakada 8d0ff88727
Adjusted spaces [ci skip] 2019-09-27 14:06:07 +09:00
Aaron Patterson 293c6c8cc3
Add compaction support to `rb_ast_t`
This commit adds compaction support to `rb_ast_t`.
2019-09-26 15:41:46 -07:00
Jean Boussier a4a19b114b Allow non-finalizable objects in ObjectSpace::WeakMap
[feature #16035]

This goes one step farther than what nobu did in [feature #13498]

With this patch, special objects such as static symbols, integers, etc can be used as either key or values inside WeakMap. They simply don't have a finalizer defined on them.

This is useful if you need to deduplicate value objects
2019-08-29 20:40:52 +09:00
卜部昌平 3df37259d8 drop-in type check for rb_define_singleton_method
We can check the function pointer passed to
rb_define_singleton_method like how we do so in rb_define_method.
Doing so revealed many arity mismatches.
2019-08-29 18:34:09 +09:00
卜部昌平 6dd60cf114 st_foreach now free from ANYARGS
After 5e86b005c0, 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 b0af0592fd, which added extra
parameter to st_foreach callbacks.
2019-08-27 15:52:26 +09:00
卜部昌平 bc3e7924bc rb_proc_new / rb_fiber_new now free from ANYARGS
After 5e86b005c0, I now think ANYARGS is
dangerous and should be extinct.  This commit deletes ANYARGS from
rb_proc_new / rb_fiber_new, and applies RB_BLOCK_CALL_FUNC_ARGLIST
wherever necessary.
2019-08-27 15:52:26 +09:00
卜部昌平 703783324c rb_ensure now free from ANYARGS
After 5e86b005c0, I now think ANYARGS is
dangerous and should be extinct.  This commit deletes ANYARGS from
rb_ensure, which also revealed many arity / type mismatches.
2019-08-27 15:52:26 +09:00
Aaron Patterson 9f0f777173
this iv table should also use the new update function 2019-08-26 13:42:16 -07:00
Aaron Patterson 09d8e06b33
Try only updating hash value references
I'm afraid the keys to this hash are just integers, and those integers
may look like VALUE pointers when they are not.  Since we don't mark the
keys to this hash, it's probably safe to say that none of them have
moved, so we shouldn't try to update the references either.
2019-08-26 11:31:52 -07:00
Aaron Patterson d9bfbe363d
Make `gc_update_table_refs` match `mark_tbl_no_pin` a little more closely
This commit just makes `gc_update_table_refs` match `mark_tbl_no_pin`
more closely.
2019-08-26 11:14:03 -07:00
Koichi Sasada 88b1f2dac4
`rp(obj)` shows func, file and line. (#2394)
rp() macro for debug also shows file location and function name
such as:

  [OBJ_INFO:rb_call_inits@inits.c:73] 0x000056147741b248 ...
2019-08-21 01:04:08 +09:00
Masataka Pocke Kuwabara 6b42b0c60c Fix document of `GC.start` (#2382) 2019-08-18 15:39:19 +09:00
git f78916e3c1 * expand tabs. 2019-08-13 11:20:39 +09:00
Nobuyoshi Nakada c215a6f282
Removed non-VM_OBJSPACE code
It has not been used for 4 years, since r60856,
e33b1690d0.
2019-08-13 11:03:54 +09:00
Nobuyoshi Nakada 2f744f53c1
Refactored `objspace_each_objects`
As `rb_objspace_each_objects_without_setup` doesn't reset and
restore `dont_incremental` flag, renamed the bare iterator as
`objspace_each_objects_without_setup`.  `objspace_each_objects`
calls it when called with the flag disabled, wrap the arguments
otherwise only.
2019-08-13 10:56:21 +09:00
Nobuyoshi Nakada 0c1c42c43a
Move rb_objspace_t* in objspace_reachable_objects_from_root to an argument 2019-08-13 10:33:19 +09:00
git aec93417f0 * expand tabs. 2019-08-13 09:50:34 +09:00
Nobuyoshi Nakada ac656bc2bd
Hoisted out GPR_DEFAULT_REASON 2019-08-13 09:47:08 +09:00
Nobuyoshi Nakada 917d766508
Move rb_objspace_t* in gc_verify_internal_consistency to an argument 2019-08-13 09:47:08 +09:00
Nobuyoshi Nakada 0c2d81dada
Renamed ruby_finalize_{0,1}
And pass rb_execution_context_t as an argument.
2019-08-13 09:47:08 +09:00
Aaron Patterson aac4d9d6c7
Rename rb_gc_mark_no_pin -> rb_gc_mark_movable
Renaming this function.  "No pin" leaks some implementation details.  We
just want users to know that if they mark this object, the reference may
move and they'll need to update the reference accordingly.
2019-08-12 16:44:54 -04:00
Aaron Patterson 6749682f82
also unpin `final` on weak maps 2019-08-12 12:34:09 -04:00
Yusuke Endoh 3ddbba84b5 gc.c: Double STACKFRAME_FOR_CALL_CFUNC (1024->2048)
ef64ab917e didn't fix the issue, so the
size seems not enough yet.

https://rubyci.org/logs/rubyci.s3.amazonaws.com/osx1014/ruby-master/log/20190809T114503Z.fail.html.gz
2019-08-09 22:48:20 +09:00
Yusuke Endoh ef64ab917e gc.c: Increase STACKFRAME_FOR_CALL_CFUNC
On macOS Mojave, the child process invoked in TestFiber#test_stack_size
gets stuck because the stack overflow detection is too late.
(ko1 figured out the mechanism of the failure.)

This change attempts to detect stack overflow earlier.
2019-08-09 17:31:19 +09:00
Nobuyoshi Nakada a04e3585d3
Extracted wmap_live_p 2019-08-06 23:00:29 +09:00
Aaron Patterson 81252c5ccd
Let prev EP move again
The last time we committed this, we were asking the VM to write to the
ep.  But VM assertions check if the ENV data is the correct type, which
if it's a T_MOVED pointer it's not the correct type.  So the vm
assertions would fail.  This time we just directly write to it from the
GC and that bypasses the vm assertion checks.
2019-08-05 13:31:58 -07:00
git c9192ef2e8 * expand tabs. 2019-08-06 00:56:05 +09:00
Aaron Patterson 33d7a58ffb
add compaction support to weak maps 2019-08-05 08:55:34 -07:00
Koichi Sasada e03b3b4ae0 add debug_counters to check details.
add debug_counters to check the Hash object statistics.
2019-08-02 15:59:47 +09:00
Nobuyoshi Nakada 8b162ce9d1
Fix assertion failure when VM_CHECK_MODE
Some VM frames (dummy and top pushed by `rb_vm_call_cfunc`) has
iseq but has no pc.
2019-08-01 20:55:03 +09:00
卜部昌平 5d33f78716 fix tracepoint + backtrace SEGV
PC modification in gc_event_hook_body was careless.  There are (so
to say) abnormal iseqs stored in the cfp.  We have to check sanity
before we touch the PC.

This has not been fixed because there was no way to (ab)use the
setup from pure-Ruby.  However by using our official C APIs it is
possible to touch such frame(s), resulting in SEGV.

Fixes [Bug #14834].
2019-08-01 16:00:59 +09:00
Aaron Patterson 5ad2dfd8dc
Revert "Let prev EP move"
This reverts commit e352445863.

This is breaking CI and I'm not sure why yet, so I'll revert for now.
2019-07-31 10:34:23 -07:00
Aaron Patterson e352445863
Let prev EP move
This commit allows the previos EP pointer to move, then updates its
location
2019-07-31 09:42:43 -07:00
Koichi Sasada 82b02c131e pass to obj_info().
obj_info() has a routine to show SPECIAL_CONST_P() objects so
we don't need to check it here.
2019-07-26 11:45:25 +09:00
Lourens Naudé 90c4bd2d2b
Let memory sizes of the various IMEMO object types be reflected correctly
[Feature #15805]

Closes: https://github.com/ruby/ruby/pull/2140
2019-07-23 16:22:34 +09:00
Jeremy Evans 01995df645 Document BasicObject does not implement #object_id and #send [ci skip]
Fixes [Bug #10422]
2019-07-22 15:07:22 -07:00
Koichi Sasada f75561b8d4 constify RHash::ifnone.
RHash::ifnone should be protected by write-barriers so this field
should be const. However, to introduce GC.compact, the const was
removed. This commit revert this removing `const` and modify
gc.c `TYPED_UPDATE_IF_MOVED` to remove `const` forcely by a type cast.
2019-07-22 17:01:31 +09:00
Aaron Patterson d304f77c58
Only disable GC around reference updating
This is the only place that can change the size of the object id tables
and cause a GC.
2019-07-19 15:12:50 -07:00
Koichi Sasada fba3e76e3f fix debug counter for Hash counts.
Change debug_counters for Hash object counts:

* obj_hash_under4 (1-3) -> obj_hash_1_4 (1-4)
* obj_hash_ge4 (4-7)    -> obj_hash_5_8 (5-8)
* obj_hash_ge8 (>=8)    -> obj_hash_g8  (> 8)

For example on rdoc benchmark:

[RUBY_DEBUG_COUNTER]    obj_hash_empty                         554,900
[RUBY_DEBUG_COUNTER]    obj_hash_under4                        572,998
[RUBY_DEBUG_COUNTER]    obj_hash_ge4                             1,825
[RUBY_DEBUG_COUNTER]    obj_hash_ge8                             2,344
[RUBY_DEBUG_COUNTER]    obj_hash_empty                         553,097
[RUBY_DEBUG_COUNTER]    obj_hash_1_4                           571,880
[RUBY_DEBUG_COUNTER]    obj_hash_5_8                               982
[RUBY_DEBUG_COUNTER]    obj_hash_g8                              2,189
2019-07-19 16:24:14 +09:00
Koichi Sasada 182ae1407b fix shared array terminology.
Shared arrays created by Array#dup and so on points
a shared_root object to manage lifetime of Array buffer.
However, sometimes shared_root is called only shared so
it is confusing. So I fixed these wording "shared" to "shared_root".

* RArray::heap::aux::shared -> RArray::heap::aux::shared_root
* ARY_SHARED() -> ARY_SHARED_ROOT()
* ARY_SHARED_NUM() -> ARY_SHARED_ROOT_REFCNT()

Also, add some debug_counters to count shared array objects.

* ary_shared_create: shared ary by Array#dup and so on.
* ary_shared: finished in shard.
* ary_shared_root_occupied: shared_root but has only 1 refcnt.
  The number (ary_shared - ary_shared_root_occupied) is meaningful.
2019-07-19 13:07:59 +09:00
Koichi Sasada f326b4f4af simplify around GC_ASSERT() 2019-07-15 10:39:57 +09:00
Samuel Williams 5c8061a9e2
Make `stack_check` slightly easier to use in debugger. 2019-07-12 11:56:51 +12:00
Nobuyoshi Nakada 26d674fdc7
Suppress warning on x64-mingw 2019-07-11 11:58:35 +09:00
Aaron Patterson 12762b76cb
Don't manipulate GC flags directly
We need to disable the GC around compaction (for now) because object id
book keeping can cause malloc to happen and that can trigger GC.
2019-07-10 11:12:28 -05:00
Nobuyoshi Nakada 23c92b6f82
Revert self-referencing finalizer warning [Feature #15974]
It has caused CI failures.

* d0cd0866d8

  Disable GC during rb_objspace_reachable_object_p

* 89cef1c56b

  Version guard for [Feature #15974]

* 796eeb6339.

  Fix up [Feature #15974]

* 928260c2a6.

  Warn in verbose mode on defining a finalizer that captures the object
2019-07-04 04:01:06 +09:00
git c62aac1086 * expand tabs. 2019-07-04 01:04:44 +09:00
Nobuyoshi Nakada d0cd0866d8
Disable GC during rb_objspace_reachable_object_p
Try to fix CI breakage by [Feature #15974].
2019-07-04 00:58:52 +09:00
Nobuyoshi Nakada 9f1d67a68f
Renamed to rb_objspace_reachable_object_p 2019-07-03 23:52:52 +09:00
Aaron Patterson 6bd49b33c8
Ensure that GC is disabled during compaction
Various things can cause GC to occur when compaction is running, for
example resizing the object identity map:

```
    frame #24: 0x000000010c784a10 ruby`gc_grey [inlined] push_mark_stack(stack=<unavailable>, data=<unavailable>) at gc.c:4311:42
    frame #25: 0x000000010c7849ff ruby`gc_grey(objspace=0x00007fc56c804400, obj=140485906037400) at gc.c:4907
    frame #26: 0x000000010c78f881 ruby`gc_start at gc.c:6464:8
    frame #27: 0x000000010c78f5d1 ruby`gc_start [inlined] gc_marks_start(objspace=0x00007fc56c804400, full_mark=<unavailable>) at gc.c:6009
    frame #28: 0x000000010c78f3c0 ruby`gc_start at gc.c:6291
    frame #29: 0x000000010c78f399 ruby`gc_start(objspace=0x00007fc56c804400, reason=<unavailable>) at gc.c:7104
    frame #30: 0x000000010c78930c ruby`objspace_xmalloc0 [inlined] objspace_malloc_fixup(objspace=<unavailable>, mem=0x000000011372a000, size=<unavailable>) at gc.c:9665:5
    frame #31: 0x000000010c7892f5 ruby`objspace_xmalloc0(objspace=0x00007fc56c804400, size=12582912) at gc.c:9707
    frame #32: 0x000000010c89bc13 ruby`st_init_table_with_size(type=<unavailable>, size=<unavailable>) at st.c:605:39
    frame #33: 0x000000010c89c5e2 ruby`rebuild_table_if_necessary [inlined] rebuild_table(tab=0x00007fc56c40b250) at st.c:780:19
    frame #34: 0x000000010c89c5ac ruby`rebuild_table_if_necessary(tab=0x00007fc56c40b250) at st.c:1142
    frame #35: 0x000000010c89c379 ruby`st_insert(tab=0x00007fc56c40b250, key=140486132605040, value=140485922918920) at st.c:1161:5
    frame #36: 0x000000010c794a16 ruby`gc_compact_heap [inlined] gc_move(objspace=0x00007fc56c804400, scan=<unavailable>, free=<unavailable>, moved_list=140485922918960) at gc.c:7441:9
    frame #37: 0x000000010c794917 ruby`gc_compact_heap(objspace=0x00007fc56c804400, comparator=<unavailable>) at gc.c:7695
    frame #38: 0x000000010c79410d ruby`gc_compact [inlined] gc_compact_after_gc(objspace=0x00007fc56c804400, use_toward_empty=1, use_double_pages=<unavailable>, use_verifier=1) at gc.c:0:22
```

We *definitely* need the heap to be in a consistent state during
compaction, so this commit sets the current state to "during_gc" so that
nothing will trigger a GC until the heap finishes compacting.

This fixes the bug we saw when running the tests for https://github.com/ruby/ruby/pull/2264
2019-07-03 14:45:50 +01:00
git 9f26242411 * expand tabs. 2019-07-03 04:26:53 +09:00
Nobuyoshi Nakada 796eeb6339
Fix up [Feature #15974]
* Fixed warning condition
* Fixed function signature
* Use ident hash
2019-07-03 04:22:41 +09:00
Chris Seaton 928260c2a6
Warn in verbose mode on defining a finalizer that captures the object
[Feature #15974]

Closes: https://github.com/ruby/ruby/pull/2264
2019-07-03 04:05:22 +09:00
Nobuyoshi Nakada f3c81b4e90
Frozen objects in WeakMap
* gc.c (wmap_aset): bypass check for frozen and allow frozen
  object in WeakMap.  [Bug #13498]
2019-06-23 00:31:16 +09:00
Nobuyoshi Nakada ab6d8d0b65
Adjust indent 2019-06-19 20:40:49 +09:00
Samuel Williams d17344cfc5 Remove IA64 support. 2019-06-19 23:30:04 +12:00
Samuel Williams 3e5b885cd2 Rework debug conditional. 2019-06-19 20:39:10 +12:00
Samuel Williams b24603adff Move vm stack init into thread. 2019-06-19 20:39:10 +12:00
Nobuyoshi Nakada 09a2189c1b
Adjust indent 2019-06-07 01:56:31 +09:00
Aaron Patterson c9b74f9fd9
Pin keys in "compare by identity" hashes
Hashes that compare by identity care about the location of the object in
memory.  Since they care about the memory location, we can't let them
move.
2019-06-03 15:15:48 -07:00
Aaron Patterson 790a1b1790
object id is stable now for all objects, so we can let hash keys move 2019-06-03 13:38:47 -07:00
Aaron Patterson 2de3d92844
allow objects in imemo envs to move 2019-06-03 13:38:47 -07:00
NAKAMURA Usaku ca22cccc14
get rid of a warning of VC++ 2019-06-04 03:52:53 +09:00
Koichi Sasada c280519256 remove `rb_objspace_pinned_object_p()`
Nobody uses this function other than gc.c. We only need
RVALUE_PINNED().
2019-06-03 15:40:38 +09:00
git 106843d839 * expand tabs. 2019-05-30 17:12:53 +09:00
Koichi Sasada 5fc9f0008f reorder bitmap clearing. 2019-05-30 17:12:26 +09:00
Koichi Sasada dd63d7da61 move pinned_bits[] position in struct heap_page.
pinned_bits are not used frequently (only GC.compact use it) so
move it at the end of struct heap_page.
2019-05-30 09:10:17 +01:00
Koichi Sasada e15de86583 introduce `during_compacting` flag.
Usually PINNED_BITS are not needed (only for GC.compact need it)
so skip updating PINNED_BITS if the marking is not by GC.compact.
2019-05-30 16:52:42 +09:00
Takashi Kokubun 797d7efde1
Prevent MJIT compilation from running while moving
pointers.

Instead of 4fe908c164, just locking the MJIT
worker may be fine for this case. And also we might have the same issue
in all `gc_compact_after_gc` calls.
2019-05-29 08:56:27 +09:00
Takashi Kokubun 462a63c39e
Drop MJIT debug code from GC.compact
As ko1 added some improvements on GC.compact, I want to check if it
solved the problem too.
2019-05-29 05:10:12 +09:00
Koichi Sasada 8a2b497e3b remove obsolete rb_gc_finalize_deferred().
rb_gc_finalize_deferred() is remained for compatibility with
C-extensions. However, this function is no longer working
from Ruby 2.4 (crash with SEGV immediately).
So remove it completely.
2019-05-28 15:57:20 +09:00
Koichi Sasada f3bddc103d use malloc() instead of calloc().
Here malloc() is enough because all elements of the page_list
will be overwrite.
2019-05-28 11:44:08 +09:00
Koichi Sasada f9401d5d44 should skip T_ZOMBIE here. 2019-05-28 11:44:08 +09:00
Koichi Sasada 2229acaa54 should use heap_eden->total_pages.
The size of page_list is heap_eden->total_pages, but
init_cursors() assumes the size of page_list is `heap_allocated_pages`.
This patch fix it.
2019-05-28 11:44:08 +09:00
Koichi Sasada 7f211bfe6c use only eden_heaps on GC.compact.
`heap_pages_sorted` includes eden and tomb pages, so we should not
use tomb pages for GC.compact (or we should move all of tomb pages
into eden pages). Now, I choose only eden pages. If we allow to
move Zombie objects (objects waiting for finalizers), we should
use both type of pages (TODO).
2019-05-28 10:31:02 +09:00
Koichi Sasada cfd839c140 Suppress warning (uninitialized variable). 2019-05-28 10:31:02 +09:00
Koichi Sasada b3602f1d20 check the object is in tomb_heap. 2019-05-27 08:19:30 +01:00
Koichi Sasada 35146c4368 add a space between type and others 2019-05-27 08:12:30 +01:00
Koichi Sasada b3a6469e46 add a line break for each error message 2019-05-27 08:09:47 +01:00
Koichi Sasada 6c1a07555c fix GC.verify_internal_consistency.
Fix debug output to dump more useful information on GC.compact
debugging.

check_rvalue_consistency_force() now accepts `terminate` flag
to terminate a program with rb_bug() or only print error message.
GC.verify_internal_consistency use this flag (== FALSE) to dump
all of debug output.
2019-05-27 14:53:38 +09:00
Koichi Sasada 61da57c76a is_pointer_to_heap() checks also tomb or not.
is_pointer_to_heap(obj) checks this obj belong to a heap page.
However, this function returns TRUE even if the page is tomb page.
This is re-commit of [712c027524].

heap_page_add_freeobj() should not use is_pointer_to_heap(), but
should check more explicitly.
2019-05-27 14:53:37 +09:00
git a4da223c9a * expand tabs. 2019-05-24 19:00:50 +09:00
Kazuhiro NISHIYAMA 6ae9d5c85f
Revert "check it in eden or tomb."
This reverts commit 712c027524.
2019-05-24 18:59:58 +09:00
Koichi Sasada b0a4d81fc3 check RVALUE on verifier.
GC.verify_internal_consistency() checks health of each RVALUE with
check_rvalue_consistency(). However, this function is enabled
only on debug environment (RGENGC_CHECK_MODE>1). So introduce
new function check_rvalue_consistency_force() and use it
in GC.verify_internal_consistency.
2019-05-24 17:52:58 +09:00
Koichi Sasada 712c027524 check it in eden or tomb.
is_pointer_to_heap() checks if it is in valid pointer to the
RVALUE in any heap_page_body. However, it returns true if it
points tomb pages. This patch check it points to eden pages.
2019-05-24 17:35:22 +09:00
Koichi Sasada 10927b5925 add separation char on rb_obj_info(imemo obj) 2019-05-24 17:08:15 +09:00
Takashi Kokubun 4fe908c164
gc.c: Try pausing MJIT worker during GC.verify_compaction_references
for debugging
http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/2048247
2019-05-23 07:53:42 -07:00
Koichi Sasada dc95b57a68 add verifier before compact 2019-05-23 17:31:14 +09:00
Urabe, Shyouhei 763989c6c5 prefix ASAN related inline functions asan_
requested by Ko1.
2019-05-23 17:24:53 +09:00
Koichi Sasada 6be0ab73c3 gc_pin() doesn't check is_markable_object().
Caller of gc_pin() should check it is a mark-able object.
So gc_pin() doesn't need to check it. With this fix,
we can refactoring around it.
2019-05-23 16:58:21 +09:00
Koichi Sasada 4814f17361 skip zombies.
rb_gc() no longer invokes finalizers, so there are T_ZOMBE objects.
2019-05-23 13:21:40 +09:00
Koichi Sasada 02973d3ba8 pin `maybe` pointers.
Objects pointed by "maybe" pointers because of conservative marking
should be pinned down.
2019-05-23 11:42:15 +09:00
Koichi Sasada 136ae55892 Do not kick finalizers on rb_gc().
rb_gc() kicks gc_finalize_deferred(), which invokes finalizers.
This means that any Ruby program can be run this point and
it may be thread switching points and so on.

However, it is difficult to think it invokes any Ruby programs.
For example, `GC.compact` use `rb_gc()` to implement it, howver,
any Ruby program must not be run on this timing.

For this reason (it is difficult to image it run any Ruby program),
I removed `gc_finalize_deferred()` line in rb_gc().

This patch solves GC.compact issue.
[Bug #15809] and re-enable GC.compact test.
2019-05-23 11:26:33 +09:00
git 2fb69b3296 * expand tabs. 2019-05-22 16:54:47 +09:00
Nobuyoshi Nakada 32dd1a798a
gc.c: revert b00f280d4b "Eagerly name modules and classes"
* gc.c (rb_raw_obj_info): new string objects cannot allocate to
  create new class path name during GC.
2019-05-22 16:52:19 +09:00
Alan Wu b00f280d4b
Eagerly name modules and classes
* variable.c: make the hidden ivars `classpath` and `tmp_classpath` the source
  of truth for module and constant names. Assign to them when modules are bind
  to constants.

* variable.c: remove references to module name cache, as what used to be the cache
  is now the source of truth. Remove rb_class_path_no_cache().

* variable.c: remove the hidden ivar `classid`. This existed for the purposes of
  module name search, which is now replaced. Also, remove the associated
  rb_name_class().

* class.c: use rb_set_class_path_string to set the name of Object during boot.
  Must use a fstring as this runs before rb_cString is initialized and
  creating a normal string leads to a VALUE without a class.

* spec/ruby/core/module/name_spec.rb: add a few specs to specify what happens
  to Module#name across multiple operations. These specs pass without other
  code changes in this commit.

[Feature #15765]
2019-05-22 15:46:47 +09:00
Koichi Sasada 7ff4abe650 unify normal and verify ver. 2019-05-21 07:45:21 +01:00