summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2022-09-26This commit implements the Object Shapes technique in CRuby.Jemma Issroff
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> Notes: Merged: https://github.com/ruby/ruby/pull/6386
2022-09-26string.c: don't create a frozen copy for str_new_sharedJean Boussier
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. Notes: Merged: https://github.com/ruby/ruby/pull/6443
2022-09-26Fix coderange calculation in String#bKazuki Yamaguchi
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 9a8f6e392fbd ("Cheaply derive code range for String#b return value", 2022-07-25).
2022-09-26Fix `io/buffer.h` header guard.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/6439
2022-09-26Update `IO::Buffer` read/write to use rb_thread_io_blocking_region. (#6438)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-09-26Suppress a warning on clangShugo Maeda
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-26Add several new methods for getting and setting buffer contents. (#6434)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-09-26Generate the revision.h before MakefileNobuyoshi Nakada
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. Notes: Merged: https://github.com/ruby/ruby/pull/6436
2022-09-25[Bug #19021] Fix safe call w/ conditional assignJohn Hawthorn
As of fbaac837cfba23a9d34dc7ee144d7940248222a2, 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). Notes: Merged: https://github.com/ruby/ruby/pull/6437
2022-09-26Initialize Objective-C classes before fork() for macOS 13Yuta Saito
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 Notes: Merged: https://github.com/ruby/ruby/pull/6426
2022-09-26[ruby/rdoc] Fix ruby script in "test_parse_method_bracket" ↵Yuichiro Kaneko
(https://github.com/ruby/rdoc/pull/927) Because it's syntax error. https://github.com/ruby/rdoc/commit/993f2532ff
2022-09-26Avoid type limits (#6435)Nobuyoshi Nakada
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2022-09-25Extract `RUBY_RELEASE_DATE` from also revision.hNobuyoshi Nakada
This make variable is very useful for daily build. Notes: Merged: https://github.com/ruby/ruby/pull/6433 Merged-By: nobu <nobu@ruby-lang.org>
2022-09-26Use `int first_lineno` for binary format.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/6430
2022-09-26Rework vm_core to use `int first_lineno` struct member.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/6430
2022-09-26Rework `first_lineno` to be `int`.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/6430
2022-09-25[ruby/bigdecimal] Remove trailing whitespace.Samuel Williams
https://github.com/ruby/bigdecimal/commit/223d193f01
2022-09-25[ruby/bigdecimal] Improve documentation of BigDecimal#sign Maciek Rząsa
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-25Add news for eval coverage.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/6425
2022-09-25Extract common code for coverage setup.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/6425
2022-09-25Reuse rb_method_call_kw functionS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/6429
2022-09-23Remove unneeded semicolonsTakashi Kokubun
2022-09-23Suppress -Wtype-limits warnings on mjit_c.rbTakashi Kokubun
2022-09-24Support using at toplevel in wrapped scriptChris Salzberg
Allow refinements to be used at the toplevel within a script that is loaded under a module. Fixes [Bug #18960] Notes: Merged: https://github.com/ruby/ruby/pull/6226
2022-09-23Remove reference to __classid__John Hawthorn
This used to be used for module names but its uses were removed in b00f280d4b9569e7153365d7e1c522b3d6b3c6cf. Notes: Merged: https://github.com/ruby/ruby/pull/6427
2022-09-23YJIT: Support Rust 1.58.1 for --yjit-stats on Arm (#6410)Takashi Kokubun
* 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> Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2022-09-24Allow changing conversion macro in MJIT bindgenTakashi Kokubun
This is necessary for object shapes.
2022-09-23[DOC] Housekeeping in iostreams doc (#6420)Burdette Lamar
Write some method names in linkable form; make some capitalization consistent. Notes: Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
2022-09-23Revert "Revert "error.c: Let Exception#inspect inspect its message""Yusuke Endoh
This reverts commit b9f030954a8a1572032f3548b39c5b8ac35792ce. [Bug #18170]
2022-09-23Just a star [ci skip]Nobuyoshi Nakada
2022-09-22YJIT: add chain guards in `guard_two_fixnums` (#6422)Maxime Chevalier-Boisvert
* Add chain guards in guard_two_fixnums, opt_eq with symbols * Remove symbol comparison in gen_equality_specialized Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2022-09-22YJIT: Refactor into gen_push_frame (#6412)John Hawthorn
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. Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2022-09-23Skip struct fields whose output differsTakashi Kokubun
across different environments Notes: Merged: https://github.com/ruby/ruby/pull/6418
2022-09-23Swap the positions of offsetof and typeTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/6418
2022-09-23Bindgen offsetof struct and union with builtinTakashi Kokubun
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. Notes: Merged: https://github.com/ruby/ruby/pull/6418
2022-09-23Bindgen sizeof struct and union with builtinTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/6418
2022-09-23Bindgen immediate types with builtinTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/6418
2022-09-23Drop c_64 and c_32Takashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/6418
2022-09-23Bindgen enum with builtinTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/6418
2022-09-23Builtin needs to be baseruby-compatibleTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/6418
2022-09-23Automatically setup bundler of bindgen.rbTakashi Kokubun
to easily use it with `tool/mjit/bindgen.rb BUILDDIR` instead of using `make mjit-bindgen`. Notes: Merged: https://github.com/ruby/ruby/pull/6418
2022-09-23mjit_c.rb doesn't need to be an erbTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/6418
2022-09-23Mix manual and auto-generated C APIsTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/6418
2022-09-23Bindgen macro with builtinTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/6418
2022-09-23Auto-generate mjit_c.rb.erbTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/6418
2022-09-23Builtin RubyVM::MJIT::CTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/6418
2022-09-23Allow --enable-yjit on OpenBSDJeremy Evans
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. Notes: Merged: https://github.com/ruby/ruby/pull/6421
2022-09-22Adds a benchmark to measure freezing objectsJemma Issroff
Notes: Merged: https://github.com/ruby/ruby/pull/6419
2022-09-22avoid extra dup and pop in compile_op_asgn2HParker
Co-authored-by: John Hawthorn <jhawthorn@github.com> Notes: Merged: https://github.com/ruby/ruby/pull/6414
2022-09-22avoid extra dup and pop in compile_op_logHParker
Co-authored-by: John Hawthorn <jhawthorn@github.com> Notes: Merged: https://github.com/ruby/ruby/pull/6414