1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
Commit graph

63458 commits

Author SHA1 Message Date
Koichi Sasada
af2471365f refactoring rb_ractor_confirm_belonging()
rb_ractor_belonging() returns 0 only if it has sharable flag.
rb_ractor_confirm_belonging() checks rb_ractor_shareable_p()
if the belonging ractor id is different from current ractor id.
2020-10-21 23:52:11 +09:00
Koichi Sasada
631eaa8510 check main-ractor or not first
On non-multi-ractor-mode, the cost of rb_ractor_main_p() is low
so check it first.
2020-10-21 23:52:11 +09:00
Yusuke Endoh
762be87759 test/json/json_parser_test.rb: suppress warnings
http://rubyci.s3.amazonaws.com/ubuntu/ruby-master/log/20201021T123003Z.log.html.gz
```
/home/chkbuild/chkbuild/tmp/build/20201021T123003Z/ruby/test/json/json_parser_test.rb:227: warning: ambiguous first argument; put parentheses or a space even after `-' operator
/home/chkbuild/chkbuild/tmp/build/20201021T123003Z/ruby/test/json/json_parser_test.rb:228: warning: ambiguous first argument; put parentheses or a space even after `-' operator
```
2020-10-21 23:37:42 +09:00
Koichi Sasada
4414031735 extend timeout of rbs test on rbs tests 2020-10-21 17:59:03 +09:00
Koichi Sasada
b59077eecf Ractor-safe rb_objspace_reachable_objects_from
rb_objspace_reachable_objects_from(obj) is used to traverse all
reachable objects from obj. This function modify objspace but it
is not ractor-safe (thread-safe). This patch fix the problem.

Strategy:
(1) call GC mark process during_gc
(2) call Ractor-local custom mark func when !during_gc
2020-10-21 16:15:22 +09:00
Nobuyoshi Nakada
4640c4ea8a
Removed more unnecessary ID caches
```
find . -name \*.o -exec nm {} + |&
grep -e 'InitVM_.*\.rbimpl_id' -e 'Init_.*\.rbimpl_id' |
sed 's/^.* b //;s/\.[1-9][0-9]*$//;s/\.rbimpl_id$//' |
uniq
```
should be empty.
2020-10-21 13:04:20 +09:00
Nobuyoshi Nakada
5a77e90fe8
Use rb_intern_const instead of rb_intern in Init functions
```
find . -name \*.o -exec nm {} + |&
sed '/Init_.*\.rbimpl_id/!d;s/^.* b //;s/\.[1-9][0-9]*$//;s/\.rbimpl_id$//' |
uniq
```
should be empty.
2020-10-21 12:46:53 +09:00
Stefan Stüben
8c2e5bbf58 Don't redefine #rb_intern over and over again 2020-10-21 12:45:18 +09:00
Nobuyoshi Nakada
d497436d07
Update dependencies for macOS 2020-10-21 12:31:45 +09:00
Nobuyoshi Nakada
640b340583
Check dependencies on macOS too 2020-10-21 12:31:38 +09:00
Jacob Matthews
73834b5fc9 Calculate transient heap block usable size at compile time 2020-10-21 11:44:10 +09:00
卜部昌平
da25affdac .github: reduce copy&paste
Found that we can set default working directory for github actions.
2020-10-21 09:24:47 +09:00
卜部昌平
1c5f44cd72 .travis.yml: reduce redundant tests
These tests are (more or less) covered by github actions now.
2020-10-21 09:24:47 +09:00
Koichi Sasada
2f50936cb9 Ractor.make_shareable(obj)
Introduce new method Ractor.make_shareable(obj) which tries to make
obj shareable object. Protocol is here.

(1) If obj is shareable, it is shareable.
(2) If obj is not a shareable object and if obj can be shareable
    object if it is frozen, then freeze obj. If obj has reachable
    objects (rs), do rs.each{|o| Ractor.make_shareable(o)}
    recursively (recursion is not Ruby-level, but C-level).
(3) Otherwise, raise Ractor::Error. Now T_DATA is not a shareable
    object even if the object is frozen.

If the method finished without error, given obj is marked as
a sharable object.

To allow makng a shareable frozen T_DATA object, then set
`RUBY_TYPED_FROZEN_SHAREABLE` as type->flags. On default,
this flag is not set. It means user defined T_DATA objects are
not allowed to become shareable objects when it is frozen.

You can make any object  shareable by setting FL_SHAREABLE flag,
so if you know that the T_DATA object is shareable (== thread-safe),
set this flag, at creation time for example. `Ractor` object is one
example, which is not a frozen, but a shareable object.
2020-10-21 07:59:24 +09:00
git
587feb0b6e * 2020-10-21 [ci skip] 2020-10-21 02:40:38 +09:00
Kenta Murata
a6a8576e87
Feature : Allow slicing arrays with ArithmeticSequence ()
* Support ArithmeticSequence in Array#slice

* Extract rb_range_component_beg_len

* Use rb_range_values to check Range object

* Fix ary_make_partial_step

* Fix for negative step cases

* range.c: Describe the role of err argument in rb_range_component_beg_len

* Raise a RangeError when an arithmetic sequence refers the outside of an array

[Feature ]
2020-10-21 02:40:18 +09:00
Nobuyoshi Nakada
081cc4eb28
Dump FrozenCore specially 2020-10-20 23:52:19 +09:00
Nobuyoshi Nakada
d915e7ee00
strip trailing spaces [ci skip] 2020-10-20 23:52:19 +09:00
Koichi Sasada
512752ba19 fix condition 2020-10-20 23:48:20 +09:00
Yusuke Endoh
a3ae90b8c5 NEWS.md: mention TypeProf 2020-10-20 22:48:35 +09:00
Chris Seaton
451836f582
Fix an issue with generate_pretty and empty objects in the Ruby and Java implementations 2020-10-20 21:46:54 +09:00
Jean Boussier
520e0916af
Implement a freeze: parser option
If set to true all parsed objects will be
immediately frozen, and strings will be
deduplicated if the Ruby implementation
allows it.
2020-10-20 21:40:25 +09:00
Hiroshi SHIBATA
f6680c9ad1
Added rbs and typeprof to doc/* 2020-10-20 21:33:02 +09:00
Koichi Sasada
67c25a34a7 skip echo foo on Solaris
On Solaris, it seems to access ENV in ``, so skip it now.

```
stderr output is not empty
   Exception `NameError' at bootstraptest.tmp.rb:7 - can not access non-sharable objects in constant Object::ENV by non-main Ractor.
   #<Thread:0x0044cdf0 run> terminated with exception (report_on_exception is true):
   bootstraptest.tmp.rb:7:in ``': can not access non-sharable objects in constant Object::ENV by non-main Ractor. (NameError)
   Exception `Ractor::RemoteError' at <internal:ractor>:130 - thrown by remote Ractor.
   <internal:ractor>:130:in `take': thrown by remote Ractor. (Ractor::RemoteError)
           from bootstraptest.tmp.rb:55:in `<main>'
   bootstraptest.tmp.rb:7:in ``': can not access non-sharable objects in constant Object::ENV by non-main Ractor. (NameError)
           from bootstraptest.tmp.rb:7:in `ractor_local_globals'
           from bootstraptest.tmp.rb:54:in `block in <main>'
```
2020-10-20 17:57:20 +09:00
Kenta Murata
18cecda46e
range.c: Fix an exception message in rb_range_beg_len
[Bug ]
2020-10-20 16:01:57 +09:00
Koichi Sasada
ade411465d ObjectSpace.each_object with Ractors
Unshareable objects should not be touched from multiple ractors
so ObjectSpace.each_object should be restricted. On multi-ractor
mode, ObjectSpace.each_object only iterates shareable objects.
[Feature ]
2020-10-20 15:39:37 +09:00
Koichi Sasada
2bdbdc1580 add Ractor.shareable?(obj)
This method returns obj is shareable or not.
2020-10-20 15:39:37 +09:00
Koichi Sasada
99310e3eb5 Some global variables can be accessed from ractors
Some global variables should be used from non-main Ractors.
[Bug ]

```ruby
     # ractor-local (derived from created ractor): debug
     '$DEBUG' => $DEBUG,
     '$-d' => $-d,

     # ractor-local (derived from created ractor): verbose
     '$VERBOSE' => $VERBOSE,
     '$-w' => $-w,
     '$-W' => $-W,
     '$-v' => $-v,

     # process-local (readonly): other commandline parameters
     '$-p' => $-p,
     '$-l' => $-l,
     '$-a' => $-a,

     # process-local (readonly): getpid
     '$$'  => $$,

     # thread local: process result
     '$?'  => $?,

     # scope local: match
     '$~'  => $~.inspect,
     '$&'  => $&,
     '$`'  => $`,
     '$\''  => $',
     '$+'  => $+,
     '$1'  => $1,

     # scope local: last line
     '$_' => $_,

     # scope local: last backtrace
     '$@' => $@,
     '$!' => $!,

     # ractor local: stdin, out, err
     '$stdin'  => $stdin.inspect,
     '$stdout' => $stdout.inspect,
     '$stderr' => $stderr.inspect,
```
2020-10-20 15:38:54 +09:00
Koichi Sasada
9ced5fae6d add a NEWS for Fiber#transfer 2020-10-20 15:36:57 +09:00
Yusuke Endoh
c05e41035c Bundle typeprof gem as bundled gems 2020-10-20 13:03:11 +09:00
Takashi Kokubun
4a7dccf44f
Add a Ripper.lex test of :on_embexpr_end
This is a weird use case of Ripper.lex which I'm not sure is supposed to
be maintained, so I'm adding this test so that we can easily notice such
changes.

If we change the behavior, this will break the behavior of hamlit.gem v1
and code like https://github.com/haml/haml/pull/1043.
2020-10-19 20:56:09 -07:00
Koichi Sasada
a76a30724d Revert "reduce lock for encoding"
This reverts commit de17e2dea1.

This patch can introduce race condition because of conflicting
read/write access for enc_table::default_list. Maybe we need to
freeze default_list at the end of Init_encdb() in enc/encdb.c.
2020-10-20 01:34:17 +09:00
git
dac3677469 * 2020-10-20 [ci skip] 2020-10-20 01:05:27 +09:00
Koichi Sasada
319afed20f Use language TLS specifier if it is possible.
To access TLS, it is faster to use language TLS specifier instead
of using pthread_get/setspecific functions.

Original proposal is: Use native thread locals. 
2020-10-20 01:05:06 +09:00
Hiroshi SHIBATA
3f97940252
Followed up with 708413807a
* Added sync task for digest
  * Update doc/* for default gems
  * Update the latest version of gemspec
2020-10-19 18:56:19 +09:00
Hiroshi SHIBATA
708413807a
Revisit to promote digest to default gems.
This reverts commit f39021be7e.
2020-10-19 18:38:09 +09:00
Koichi Sasada
de17e2dea1 reduce lock for encoding
To reduce the number of locking for encoding manipulation,
enc_table::list is splited to ::default_list and ::additional_list.
::default_list is pre-allocated and no need locking to access to
the ::default_list. If additional encoding space is needed, use
::additional_list and this list need to use locking.
However, most of case, ::default_list is enough.
2020-10-19 14:06:40 +09:00
git
f1f8f38079 * 2020-10-19 [ci skip] 2020-10-19 13:21:08 +09:00
Kazuhiro NISHIYAMA
ce62850334
Fix typos [ci skip] 2020-10-19 13:20:34 +09:00
Yusuke Endoh
09dd9d8e5d Revert "test/rinda/test_rinda.rb: try debugging TestRingServer#test_do_reply"
This reverts commit de5e8d0e3b.

Remove the debugging code that is no longer needed
2020-10-17 15:32:40 +09:00
Yusuke Endoh
6a9e09824b Revert "test/rinda/test_rinda.rb: Add more debugging code"
This reverts commit ac803ab55d.

Remove debugging code that is no longer needed
2020-10-17 15:32:19 +09:00
Yusuke Endoh
5c003b4bcd test/rinda/test_rinda.rb: Prevent a callback Proc from being GC'ed
According to the log of ac803ab55d, I
found that a thread terminates silently due to "recycled object" of
id2ref:

```
"/home/chkbuild/chkbuild/tmp/build/20201017T033002Z/ruby/lib/drb/drb.rb:366:in `_id2ref'"
"/home/chkbuild/chkbuild/tmp/build/20201017T033002Z/ruby/lib/drb/drb.rb:366:in `to_obj'"
"/home/chkbuild/chkbuild/tmp/build/20201017T033002Z/ruby/lib/drb/drb.rb:1528:in `to_obj'"
"/home/chkbuild/chkbuild/tmp/build/20201017T033002Z/ruby/lib/drb/drb.rb:1847:in `to_obj'"
"/home/chkbuild/chkbuild/tmp/build/20201017T033002Z/ruby/lib/drb/drb.rb:1136:in `method_missing'"
"/home/chkbuild/chkbuild/tmp/build/20201017T033002Z/ruby/test/rinda/test_rinda.rb:652:in `block in do_reply'"
```
https://rubyci.org/logs/rubyci.s3.amazonaws.com/rhel8/ruby-master/log/20201017T033002Z.log.html.gz

I believe that this unintentional thread termination has caused
intermittent timeout failure of `TestRingServer#test_do_reply`.

The root cause of the "recycled object" issue is a bug of
`TestRingServer#test_do_reply`.  It creates a callback Proc object but
does not hold the reference to the object:

```
callback = DRb::DRbObject.new callback
```

The original "callback" object is GC'ed unintentionally.
I could consistently reproduce this issue on my machine by adding
`GC.stress = true` at the first of `_test_do_reply` method body.

This change uses another local variable name, "callback_orig", to keep
the original Proc object.
2020-10-17 15:17:55 +09:00
Koichi Sasada
f6661f5085 sync RClass::ext::iv_index_tbl
iv_index_tbl manages instance variable indexes (ID -> index).
This data structure should be synchronized with other ractors
so introduce some VM locks.

This patch also introduced atomic ivar cache used by
set/getinlinecache instructions. To make updating ivar cache (IVC),
we changed iv_index_tbl data structure to manage (ID -> entry)
and an entry points serial and index. IVC points to this entry so
that cache update becomes atomically.
2020-10-17 08:18:04 +09:00
Koichi Sasada
91ec5f9e39 remove rb_obj_iv_index_tbl
(1) nobody uses it (gem-codesearch)
(2) the data strucuture will be changed.
2020-10-17 08:18:04 +09:00
Aaron Patterson
ff9dc10966
keep proc on the stack so it does not move 2020-10-16 11:28:52 -07:00
git
26e8db6b93 * 2020-10-17 [ci skip] 2020-10-17 00:08:33 +09:00
Yusuke Endoh
ac803ab55d test/rinda/test_rinda.rb: Add more debugging code
in addition to de5e8d0e3b
2020-10-17 00:07:35 +09:00
Alan Wu
0d17cdd0ac Abort on system stack overflow during GC
Buggy native extensions could have mark functions that cause stack
overflow. When a stack overflow happens during GC, Ruby used to recover
by raising an exception, which runs the interpreter. It's not safe to
run the interpreter during GC since the GC is in an inconsistent state.
This could cause object allocation during GC, for example.

Instead of running the interpreter and potentially causing a crash down
the line, fail fast and abort.
2020-10-16 10:24:12 -04:00
Yusuke Endoh
de5e8d0e3b test/rinda/test_rinda.rb: try debugging TestRingServer#test_do_reply
https://rubyci.org/logs/rubyci.s3.amazonaws.com/rhel8/ruby-master/log/20201016T063003Z.fail.html.gz
```
  1) Error:
Rinda::TestRingServer#test_do_reply:
Timeout::Error: timeout
    /home/chkbuild/chkbuild/tmp/build/20201016T063003Z/ruby/test/rinda/test_rinda.rb:837:in `sleep'
    /home/chkbuild/chkbuild/tmp/build/20201016T063003Z/ruby/test/rinda/test_rinda.rb:837:in `wait_for'
    /home/chkbuild/chkbuild/tmp/build/20201016T063003Z/ruby/test/rinda/test_rinda.rb:659:in `_test_do_reply'
    /home/chkbuild/chkbuild/tmp/build/20201016T063003Z/ruby/test/rinda/test_rinda.rb:643:in `block in test_do_reply'
    /home/chkbuild/chkbuild/tmp/build/20201016T063003Z/ruby/test/rinda/test_rinda.rb:807:in `with_timeout'
    /home/chkbuild/chkbuild/tmp/build/20201016T063003Z/ruby/test/rinda/test_rinda.rb:643:in `test_do_reply'
```
2020-10-16 16:51:33 +09:00
Yusuke Endoh
1cbb1f1720 test/ruby/test_syntax.rb: avoid "warning: assigned but unused variable" 2020-10-16 11:10:58 +09:00