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

63522 Коммитов

Автор SHA1 Сообщение Дата
Kenta Murata f754b42285
numeric.c, range.c: prohibit zero step
* numeric.c: prohibit zero step in Numeric#step

* range.c: prohibit zero step in Range#step

* Fix ruby-spec

[Feature #15573]
2020-10-23 15:26:51 +09:00
Takashi Kokubun 40bad72f31
Assert in_gc >= 0 instead of guarding it (#3687) 2020-10-22 21:59:13 -07:00
卜部昌平 7cf34cfaa3 .github/workflows/spec_guards.yml add
Translate a part of .travis.yml into GitHub Actions workflow.
2020-10-23 10:38:34 +09:00
Alan Wu 196eada8c6 mutete -> mutate 2020-10-22 18:20:35 -04:00
Andrew Kerr ef3c25888e Fix small typo in comment in lib/irb.c 2020-10-22 10:56:35 -07:00
git b9193df971 * 2020-10-23 [ci skip] 2020-10-23 01:52:32 +09:00
Aaron Patterson 9a6720a15d
Revert "Add assertions when inline caches are copied to MJIT"
This reverts commit 6cb6d5abc3.
This reverts commit 1484b786ae.

I think we don't need these assertions anymore.  I believe the problem
is solved by abf678a439
2020-10-22 09:52:05 -07:00
Aaron Patterson abf678a439 Use a lock level for a less granular lock.
We are seeing an error where code that is generated with MJIT contains
references to objects that have been moved.  I believe this is due to a
race condition in the compaction function.

`gc_compact` has two steps:

1. Run a full GC to pin objects
2. Compact / update references

Step one is executed with `garbage_collect`.  `garbage_collect` calls
`gc_enter` / `gc_exit`, these functions acquire a JIT lock and release a
JIT lock.  So a lock is held for the duration of step 1.

Step two is executed by `gc_compact_after_gc`.  It also holds a JIT
lock.

I believe the problem is that the JIT is free to execute between step 1
and step 2.  It copies call cache values, but doesn't pin them when it
copies them.  So the compactor thinks it's OK to move the call cache
even though it is not safe.

We need to hold a lock for the duration of `garbage_collect` *and*
`gc_compact_after_gc`.  This patch introduces a lock level which
increments and decrements.  The compaction function can increment and
decrement the lock level and prevent MJIT from executing during both
steps.
2020-10-22 07:59:06 -07:00
Kenta Murata d23d5c3130
rational.c: try converting by to_int in Rational() (#3684)
[Bug #12485]
2020-10-22 17:59:52 +09:00
Koichi Sasada 603fb940c0 refactoring obj_traverse_i 2020-10-22 00:43:44 +09:00
Koichi Sasada 0c0d0752f1 allow to access ivars of frozen shareable objects
Accessing a shareable object is prohibitted because it can cause
race condition, but if the shareable object is frozen, there is no
problem to access ivars.
2020-10-22 00:43:44 +09:00
git 9629378477 * 2020-10-22 [ci skip] 2020-10-22 00:07:02 +09:00
Koichi Sasada 3a97d36157 refactoring frozen_shareable_p 2020-10-21 23:57:44 +09:00
Koichi Sasada 89f6644de7 refactoring rb_obj_traverse()
* create rec check hash lazily
* do not pass *data pointer for enter/leave function because
  it is not used.
2020-10-21 23:52:11 +09:00
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 #16812: Allow slicing arrays with ArithmeticSequence (#3241)
* 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 #16812]
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 #17271]
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 #17270]
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 #17268]

```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. #3665
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