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

73845 Коммитов

Автор SHA1 Сообщение Дата
Jeremy Evans b39690df3a Rename method name in keyword test from y to yo
Kernel#y is defined by psych/yaml, which causes occasional
nondeterministic problems with this test when doing parallel testing.
2022-09-27 04:00:40 +09:00
Peter Zhu aa2a428cfb Refactor str_substr and str_subseq
This commit extracts common code between str_substr and rb_str_subseq
into a function called str_subseq.

This commit also applies optimizations in commit 2e88bca to
rb_str_subseq.
2022-09-26 14:54:32 -04:00
git 830b5b5c35 * expand tabs. [ci skip]
Tabs were expanded because the file did not have any tab indentation in unedited lines.
Please update your editor config, and use misc/expand_tabs.rb in the pre-commit hook.
2022-09-27 01:21:58 +09:00
Jemma Issroff 9ddfd2ca00 This commit implements the Object Shapes technique in CRuby.
Object Shapes is used for accessing instance variables and representing the
"frozenness" of objects.  Object instances have a "shape" and the shape
represents some attributes of the object (currently which instance variables are
set and the "frozenness").  Shapes form a tree data structure, and when a new
instance variable is set on an object, that object "transitions" to a new shape
in the shape tree.  Each shape has an ID that is used for caching. The shape
structure is independent of class, so objects of different types can have the
same shape.

For example:

```ruby
class Foo
  def initialize
    # Starts with shape id 0
    @a = 1 # transitions to shape id 1
    @b = 1 # transitions to shape id 2
  end
end

class Bar
  def initialize
    # Starts with shape id 0
    @a = 1 # transitions to shape id 1
    @b = 1 # transitions to shape id 2
  end
end

foo = Foo.new # `foo` has shape id 2
bar = Bar.new # `bar` has shape id 2
```

Both `foo` and `bar` instances have the same shape because they both set
instance variables of the same name in the same order.

This technique can help to improve inline cache hits as well as generate more
efficient machine code in JIT compilers.

This commit also adds some methods for debugging shapes on objects.  See
`RubyVM::Shape` for more details.

For more context on Object Shapes, see [Feature: #18776]

Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
Co-Authored-By: Eileen M. Uchitelle <eileencodes@gmail.com>
Co-Authored-By: John Hawthorn <john@hawthorn.email>
2022-09-26 09:21:30 -07:00
Jean Boussier 2e88bca24f string.c: don't create a frozen copy for str_new_shared
str_new_shared already has all the necessary logic to do this
and is also smart enough to skip this step if the source string
is already a shared string itself.

This saves a useless String allocation on each call.
2022-09-26 13:41:17 +02:00
Kazuki Yamaguchi 5b0396473b Fix coderange calculation in String#b
Leave the new coderange unknown if the original encoding is not
ASCII-compatible. Non-ASCII-compatible encoding strings with valid or
broken coderange can end up as ascii-only.

Fixes 9a8f6e392f ("Cheaply derive code range for String#b return
value", 2022-07-25).
2022-09-26 16:44:46 +09:00
Samuel Williams 1c14e406d3 Fix `io/buffer.h` header guard. 2022-09-26 20:10:15 +13:00
Samuel Williams 411d0eec11
Update `IO::Buffer` read/write to use rb_thread_io_blocking_region. (#6438) 2022-09-26 19:37:28 +13:00
Shugo Maeda a8ad22d926
Suppress a warning on clang
The following warning appears without this fix:

```
parse.y:78:1: warning: unknown warning group '-Wpsabi', ignored
      [-Wunknown-warning-option]
RBIMPL_WARNING_IGNORED(-Wpsabi)
^
./include/ruby/internal/warning_push.h:103:39: note: expanded from macro
      'RBIMPL_WARNING_IGNORED'
                                      ^
./include/ruby/internal/warning_push.h:99:39: note: expanded from macro
      'RBIMPL_WARNING_PRAGMA2'
                                      ^
./include/ruby/internal/warning_push.h:98:39: note: expanded from macro
      'RBIMPL_WARNING_PRAGMA1'
                                      ^
./include/ruby/internal/warning_push.h:97:39: note: expanded from macro
      'RBIMPL_WARNING_PRAGMA0'
                                      ^
<scratch space>:49:27: note: expanded from here
 clang diagnostic ignored "-Wpsabi"
                          ^
1 warning generated.
```
2022-09-26 14:44:54 +09:00
Samuel Williams 025b8701c0
Add several new methods for getting and setting buffer contents. (#6434) 2022-09-26 18:06:12 +13:00
Nobuyoshi Nakada ecffc6a203 Generate the revision.h before Makefile
Except for GNU make which updates makefiles automatically, repeating
configure in the same directory causes `make` to stop whenever pulled
a new commit.  This is unexpected in CIs.
2022-09-26 13:03:23 +09:00
John Hawthorn b361bdc200 [Bug #19021] Fix safe call w/ conditional assign
As of fbaac837cf, when we were performing
a safe call (`o&.x=`) with a conditional assign (`||= 1`) and discarding
the result the stack would end up in a bad state due to a missing pop.

This commit fixes that by adjusting the target label of the branchnil to
be before a pop in that case (as was previously done in the
non-conditional assignment case).
2022-09-25 20:44:54 -07:00
Yuta Saito e3cc1a6cae Initialize Objective-C classes before fork() for macOS 13
Since macOS 13, CFString family API used in
`rb_str_append_normalized_ospath` may internally use Objective-C classes
(`NSTaggedPointerString` and `NSPlaceholderMutableString`) for small strings.

On the other hand, Objective-C classes should not be used for the first
time in a `fork()`'ed but not `exec()`'ed process. Violations for this rule
can result deadlock during class initialization, so Objective-C runtime
conservatively crashes on such cases by default.

Therefore, we need to use CFString API to initialize Objective-C classes
used internally *before* `fork()`.

For more details, see https://bugs.ruby-lang.org/issues/18912
2022-09-26 12:03:40 +09:00
Yuichiro Kaneko d89f8a0467 [ruby/rdoc] Fix ruby script in "test_parse_method_bracket" (https://github.com/ruby/rdoc/pull/927)
Because it's syntax error.

https://github.com/ruby/rdoc/commit/993f2532ff
2022-09-26 09:38:40 +09:00
Nobuyoshi Nakada 1481e6828c
Avoid type limits (#6435) 2022-09-26 09:21:05 +09:00
Nobuyoshi Nakada dc7d929e54
Extract `RUBY_RELEASE_DATE` from also revision.h
This make variable is very useful for daily build.
2022-09-25 22:40:05 +09:00
Samuel Williams 85cc0ce5c8 Use `int first_lineno` for binary format. 2022-09-26 00:41:16 +13:00
Samuel Williams 22af2e9084 Rework vm_core to use `int first_lineno` struct member. 2022-09-26 00:41:16 +13:00
Samuel Williams 75cf29f60d Rework `first_lineno` to be `int`. 2022-09-26 00:41:16 +13:00
Samuel Williams a95b741a97 [ruby/bigdecimal] Remove trailing whitespace.
https://github.com/ruby/bigdecimal/commit/223d193f01
2022-09-25 19:34:27 +09:00
Maciek Rząsa 8e2c425183 [ruby/bigdecimal] Improve documentation of BigDecimal#sign
Fixes https://github.com/ruby/bigdecimal/issues/78 by describing behaviour for positive and negative zero in the docs.

https://github.com/ruby/bigdecimal/commit/5415b120ab
2022-09-25 16:51:17 +09:00
Samuel Williams 81b919ce5c Add news for eval coverage. 2022-09-25 20:35:47 +13:00
Samuel Williams 09ea4f3a9f Extract common code for coverage setup. 2022-09-25 20:35:47 +13:00
S-H-GAMELINKS 205c252ec7 Reuse rb_method_call_kw function 2022-09-25 11:11:06 +13:00
Takashi Kokubun 08476c4579
Remove unneeded semicolons 2022-09-23 23:13:43 -07:00
Takashi Kokubun b0e3ee454d
Suppress -Wtype-limits warnings on mjit_c.rb 2022-09-23 23:07:30 -07:00
Chris Salzberg 82ac4a2399 Support using at toplevel in wrapped script
Allow refinements to be used at the toplevel within a script that is
loaded under a module.

Fixes [Bug #18960]
2022-09-24 09:41:15 +09:00
John Hawthorn a74f4cded2 Remove reference to __classid__
This used to be used for module names but its uses were removed in
b00f280d4b.
2022-09-23 15:57:02 -07:00
Takashi Kokubun 912ea8257a
YJIT: Support Rust 1.58.1 for --yjit-stats on Arm (#6410)
* YJIT: Test Rust 1.58.1 as well on Cirrus

* YJIT: Avoid using a Rust 1.60.0 feature

* YJIT: Use autoconf to detect support

* YJIT: We actually need to run it

for checking it properly

* YJIT: Try cfg!(target_feature = "lse")

* Revert "YJIT: Try cfg!(target_feature = "lse")"

This reverts commit 4e2a9ca9a9c83052c23b5e205c91bdf79e88342e.

* YJIT: Add --features stats only when it works

* Update configure.ac

Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
2022-09-23 16:17:54 -04:00
Takashi Kokubun 7588f21851
Allow changing conversion macro in MJIT bindgen
This is necessary for object shapes.
2022-09-24 00:02:21 +09:00
Burdette Lamar 3ddab3a84e
[DOC] Housekeeping in iostreams doc (#6420)
Write some method names in linkable form; make some capitalization consistent.
2022-09-23 09:41:21 -05:00
Yusuke Endoh a78c733cc3 Revert "Revert "error.c: Let Exception#inspect inspect its message""
This reverts commit b9f030954a.

[Bug #18170]
2022-09-23 16:40:59 +09:00
Nobuyoshi Nakada 6e46bf1e54
Just a star [ci skip] 2022-09-23 08:52:15 +09:00
Maxime Chevalier-Boisvert 4e40fdbcee
YJIT: add chain guards in `guard_two_fixnums` (#6422)
* Add chain guards in guard_two_fixnums, opt_eq with symbols

* Remove symbol comparison in gen_equality_specialized
2022-09-22 17:47:54 -04:00
John Hawthorn 4b97f1e525
YJIT: Refactor into gen_push_frame (#6412)
This refactors the "push frame" operation common to both gen_send_iseq
and gen_send_cfunc into its own method. This allows that logic to live
in one place.
2022-09-22 17:47:26 -04:00
Takashi Kokubun 0c9dc01a2a Skip struct fields whose output differs
across different environments
2022-09-23 06:44:28 +09:00
Takashi Kokubun dfc311c0b3 Swap the positions of offsetof and type 2022-09-23 06:44:28 +09:00
Takashi Kokubun dc5b536468 Bindgen offsetof struct and union with builtin
except for bit fields.

I made a risky assumption on leading bit fields and just gave up
non-leading bit fields for now. I'll change it to let C code access bit
fields later.
2022-09-23 06:44:28 +09:00
Takashi Kokubun 2ce1460c65 Bindgen sizeof struct and union with builtin 2022-09-23 06:44:28 +09:00
Takashi Kokubun 4c6e1556b1 Bindgen immediate types with builtin 2022-09-23 06:44:28 +09:00
Takashi Kokubun 280ff1707e Drop c_64 and c_32 2022-09-23 06:44:28 +09:00
Takashi Kokubun 5cda5938f8 Bindgen enum with builtin 2022-09-23 06:44:28 +09:00
Takashi Kokubun 2f5b37533e Builtin needs to be baseruby-compatible 2022-09-23 06:44:28 +09:00
Takashi Kokubun 591c3c7a1a Automatically setup bundler of bindgen.rb
to easily use it with `tool/mjit/bindgen.rb BUILDDIR` instead of using
`make mjit-bindgen`.
2022-09-23 06:44:28 +09:00
Takashi Kokubun 4e0db2f753 mjit_c.rb doesn't need to be an erb 2022-09-23 06:44:28 +09:00
Takashi Kokubun 334b8bd459 Mix manual and auto-generated C APIs 2022-09-23 06:44:28 +09:00
Takashi Kokubun 00c441ce7a Bindgen macro with builtin 2022-09-23 06:44:28 +09:00
Takashi Kokubun e81a612413 Auto-generate mjit_c.rb.erb 2022-09-23 06:44:28 +09:00
Takashi Kokubun f2bea691cd Builtin RubyVM::MJIT::C 2022-09-23 06:44:28 +09:00
Jeremy Evans 88bf8ad6e9 Allow --enable-yjit on OpenBSD
yjit uses _Unwind_* functions from libunwind.  These functions
are available in libc++abi (which requires libpthread), so
add those to LDFLAGS if enabling yjit on OpenBSD.
2022-09-23 05:51:34 +09:00