summaryrefslogtreecommitdiff
path: root/test/-ext-
Commit message (Collapse)AuthorAgeFilesLines
* [Feature #19579] Remove !USE_RVARGC code (#7655)Peter Zhu2023-04-041-5/+1
| | | | | | | | | | | Remove !USE_RVARGC code [Feature #19579] The Variable Width Allocation feature was turned on by default in Ruby 3.2. Since then, we haven't received bug reports or backports to the non-Variable Width Allocation code paths, so we assume that nobody is using it. We also don't plan on maintaining the non-Variable Width Allocation code, so we are going to remove it.
* Fix small issues concerning namespacing in test-all suitelukeg2023-03-171-0/+2
| | | | | * Fix temporary methods on Object leaking across test cases. * Remove temporary classes/modules leaking across test cases.
* s/mjit/rjit/Takashi Kokubun2023-03-061-1/+1
|
* s/MJIT/RJIT/Takashi Kokubun2023-03-061-1/+1
|
* Remove Encoding#replicateBenoit Daloze2023-01-111-0/+15
|
* Remove `require 'io/wait'` where it's no longer necessary. (#6932)Samuel Williams2022-12-151-1/+0
| | | | | | | * Remove `require 'io/wait'` as it's part of core now. * Update ruby specs using version gates. * Add note about why it's conditional.
* Transition shape when object's capacity changesJemma Issroff2022-11-101-1/+5
| | | | | | | | | | | | | | | | This commit adds a `capacity` field to shapes, and adds shape transitions whenever an object's capacity changes. Objects which are allocated out of a bigger size pool will also make a transition from the root shape to the shape with the correct capacity for their size pool when they are allocated. This commit will allow us to remove numiv from objects completely, and will also mean we can guarantee that if two objects share shapes, their IVs are in the same positions (an embedded and extended object cannot share shapes). This will enable us to implement ivar sets in YJIT using object shapes. Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
* Add version to the interface of Random extensionsNobuyoshi Nakada2022-11-101-4/+22
|
* Unmark Internal IV test as pendingJemma Issroff2022-10-201-1/+0
| | | | Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
* Revert "Revert "This commit implements the Object Shapes technique in CRuby.""Jemma Issroff2022-10-111-0/+1
| | | | This reverts commit 9a6803c90b817f70389cae10d60b50ad752da48f.
* Revert "This commit implements the Object Shapes technique in CRuby."Aaron Patterson2022-09-301-1/+0
| | | | This reverts commit 68bc9e2e97d12f80df0d113e284864e225f771c2.
* This commit implements the Object Shapes technique in CRuby.Jemma Issroff2022-09-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Revert this until we can figure out WB issues or remove shapes from GCAaron Patterson2022-09-261-1/+0
| | | | | | | | | | Revert "* expand tabs. [ci skip]" This reverts commit 830b5b5c351c5c6efa5ad461ae4ec5085e5f0275. Revert "This commit implements the Object Shapes technique in CRuby." This reverts commit 9ddfd2ca004d1952be79cf1b84c52c79a55978f4.
* This commit implements the Object Shapes technique in CRuby.Jemma Issroff2022-09-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* test/-ext-/eval/test_eval.rb: Prevent "assigned but unused variable"Yusuke Endoh2022-08-241-2/+2
|
* [Bug #18964] Add test for `rb_econv_append`Nobuyoshi Nakada2022-08-201-0/+23
|
* Stop defining `RUBY_ABI_VERSION` if released versionsNobuyoshi Nakada2022-08-121-0/+2
| | | | | | As commented in include/ruby/internal/abi.h, since teeny versions of Ruby should guarantee ABI compatibility, `RUBY_ABI_VERSION` has no role in released versions of Ruby.
* Fix Array#[] with ArithmeticSequence with negative steps (#5739)Jeremy Evans2022-08-111-0/+52
| | | | | | | | | | | | | | | | | | | | | | * Fix Array#[] with ArithmeticSequence with negative steps Previously, Array#[] when called with an ArithmeticSequence with a negative step did not handle all cases correctly, especially cases involving infinite ranges, inverted ranges, and/or exclusive ends. Fixes [Bug #18247] * Add Array#slice tests for ArithmeticSequence with negative step to test_array Add tests of rb_arithmetic_sequence_beg_len_step C-API function. * Fix ext/-test-/arith_seq/beg_len_step/depend * Rename local variables * Fix a variable name Co-authored-by: Kenta Murata <3959+mrkn@users.noreply.github.com>
* respect current frame of `rb_eval_string`Koichi Sasada2022-08-011-0/+12
| | | | | | | `self` is nearest Ruby method's `self`. If there is no ruby frame, use toplevel `self` (`main`). https://bugs.ruby-lang.org/issues/18780
* Fix `rb_profile_frames` output includes dummy main thread frameIvo Anjo2022-07-261-0/+24
| | | | | | | | | | | | | | | | | | | | The `rb_profile_frames` API did not skip the two dummy frames that each thread has at its beginning. This was unlike `backtrace_each` and `rb_ec_parcial_backtrace_object`, which do skip them. This does not seem to be a problem for non-main thread frames, because both `VM_FRAME_RUBYFRAME_P(cfp)` and `rb_vm_frame_method_entry(cfp)` are NULL for them. BUT, on the main thread `VM_FRAME_RUBYFRAME_P(cfp)` was true and thus the dummy thread was still included in the output of `rb_profile_frames`. I've now made `rb_profile_frames` skip this extra frame (like `backtrace_each` and friends), as well as add a test that asserts the size and contents of `rb_profile_frames`. Fixes [Bug #18907] (<https://bugs.ruby-lang.org/issues/18907>)
* Match +YJIT in Ruby desc when testing segv (#6141)Noah Gibbs2022-07-201-0/+5
| | | | | | In test_bug_reporter and test_rubyoptions we intentionally test child processes that cause SEGV. We run them with YJIT if the parent uses YJIT so that the text description matches the parent RUBY_DESCRIPTION.
* [Bug #18905] Check symbol name types more strictlyNobuyoshi Nakada2022-07-201-5/+4
|
* Fix tests for ABI incompatible binary error messagsNobuyoshi Nakada2022-07-171-2/+4
|
* GVL Instrumentation: remove the EXITED count assertionJean Boussier2022-07-131-1/+0
| | | | | It's very flaky for some unknown reason. Something we have an extra EXITED event. I suspect some other test is causing this.
* thread/test_instrumentation_api: cleanup all existing threads in setupJean Boussier2022-07-131-0/+9
| | | | | | | | | | We saw the following failure: ``` TestThreadInstrumentation#test_thread_instrumentation [/tmp/ruby/v3/src/trunk-random3/test/-ext-/thread/test_instrumentation_api.rb:25]: Expected 0..3 to include 4. ``` Which shouldn't happen unless somehow there was a leaked thread.
* Refactor tests for ThreadInstrumentation countersNobuyoshi Nakada2022-07-121-15/+16
| | | | | * Extracted some assertions. * Assert counter values should be positive.
* Use `IO.popen` to fork and exit the child process without cleanupNobuyoshi Nakada2022-07-121-16/+12
|
* Fix #5872 for MJIT GitHub ActionsTakashi Kokubun2022-07-101-0/+2
| | | | | If you run tests with RUN_OPTS=--mjit, the test fixes in https://github.com/ruby/ruby/pull/5872 don't work.
* Relax assertion condition for thread local countersNobuyoshi Nakada2022-07-081-1/+3
| | | | | | | | | | | | | Recently `TestThreadInstrumentation#test_join_counters` often fails as ``` <[1, 1, 1]> expected but was <[2, 2, 2]>. ``` Probably it seems that the thread is suspended more than once. There may be no guarantee that the subject thread never be suspended more than once.
* thread_pthread.c: call SUSPENDED event when entering native_sleepJean Boussier2022-07-071-48/+54
| | | | | | | | | [Bug #18900] Thread#join and a few other codepaths are using native sleep as a way to suspend the current thread. So we should call the relevant hook when this happen, otherwise some thread may transition directly from `RESUMED` to `READY`.
* Include JIT information in crash reportsChris Seaton2022-06-201-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | Since enabling YJIT or MJIT drastically changes what could go wrong at runtime, it's good to be front and center about whether they are enabled when dumping a crash report. Previously, `RUBY_DESCRIPTION` and the description printed when crashing can be different when a JIT is on. Introduce a new internal data global, `rb_dynamic_description`, and set it to be the same as `RUBY_DESCRIPTION` during initialization; use it when crashing. * version.c: Init_ruby_description(): Initialize and use `rb_dynamic_description`. * error.c: Change crash reports to use `rb_dynamic_description`. * ruby.c: Call `Init_ruby_description()` earlier. Slightly more work for when we exit right after printing the description but that was deemed acceptable. * include/ruby/version.h: Talk about how JIT info is not in `ruby_description`. * test/-ext-/bug_reporter/test_bug_reporter.rb: Remove handling for crash description being different from `RUBY_DESCRIPTION`. * test/ruby/test_rubyoptions.rb: ditto Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> Co-authored-by: Alan Wu <alanwu@ruby-lang.org>
* test_instrumentation_api.rb: Allow one less exitJean Boussier2022-06-201-7/+5
| | | | | I suspect that sometimes on CI the last thread is prempted before eaching the exit hook causing the test to flake. I can't find a good way to force it to run.
* Scale the time to wait native threads to run hookNobuyoshi Nakada2022-06-191-2/+6
|
* Debug TestThreadInstrumentationJean Boussier2022-06-171-4/+14
| | | | | | | | | | | | | | | It previously failed with: ``` 1) Failure: TestThreadInstrumentation#test_thread_instrumentation_fork_safe [/home/runner/work/ruby/ruby/src/test/-ext-/thread/test_instrumentation_api.rb:50]: <5> expected but was <4>. ``` Suggesting one `EXIT` event wasn't fired or processed. Adding an assetion on `Thead#status` may help figure out what is wrong.
* GVL Instrumentation API: add STARTED and EXITED eventsJean Boussier2022-06-171-1/+3
| | | | | | | | [Feature #18339] After experimenting with the initial version of the API I figured there is a need for an exit event to cleanup instrumentation data. e.g. if you record data in a {thread_id -> data} table, you need to free associated data when a thread goes away.
* Refactor TestThreadInstrumentation to investigate CI flakinessJean Boussier2022-06-071-10/+24
| | | | | | | | | | `test_thread_instrumentation_fork_safe` has been failing occasionaly on Ubuntu and Arch. At this stage we're not sure why, all we know is that the child exit with status 1. I suspect that something entirely unrelated cause the forked children to fail on exit, so by using `exit!(0)` and doing assertions in the parent I hope to be resilient to that.
* Use `sleep 0.5` for tests of GVL instrumentation APIYusuke Endoh2022-06-061-2/+2
| | | | | | | | | | | | | The tests fail randomly on some platforms. http://rubyci.s3.amazonaws.com/ubuntu/ruby-master/log/20220605T213004Z.fail.html.gz http://rubyci.s3.amazonaws.com/arch/ruby-master/log/20220605T210003Z.fail.html.gz ``` [15737/21701] TestThreadInstrumentation#test_thread_instrumentation_fork_safe/home/chkbuild/chkbuild/tmp/build/20220605T213004Z/ruby/tool/lib/test/unit/assertions.rb:109:in `assert': Expected 0 to be nonzero?. (Test::Unit::AssertionFailedError) ``` The failures seem to depend on context switches. I suspect `sleep 0.05` is too short, so this change tries to extend the wait time.
* [Feature #18339] GVL Instrumentation APIJean Boussier2022-06-031-0/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ref: https://bugs.ruby-lang.org/issues/18339 Design: - This tries to minimize the overhead when no hook is registered. It should only incur an extra unsynchronized boolean check. - The hook list is protected with a read-write lock as to cause contention when some hooks are registered. - The hooks MUST be thread safe, and MUST NOT call into Ruby as they are executed outside the GVL. - It's simply a noop on Windows. API: ``` rb_internal_thread_event_hook_t * rb_internal_thread_add_event_hook(rb_internal_thread_event_callback callback, rb_event_flag_t internal_event, void *user_data); bool rb_internal_thread_remove_event_hook(rb_internal_thread_event_hook_t * hook); ``` You can subscribe to 3 events: - READY: called right before attempting to acquire the GVL - RESUMED: called right after successfully acquiring the GVL - SUSPENDED: called right after releasing the GVL. The hooks MUST be threadsafe, as they are executed outside of the GVL, they also MUST NOT call any Ruby API.
* Avoid defining the same test class in multiple filesJeremy Evans2022-04-228-548/+529
| | | | | | | | | Should fix issues with parallel testing sometimes not running all tests. This should be viewed skipping whitespace changes. Fixes [Bug #18731]
* [Feature #18249] Implement ABI checkingPeter Zhu2022-02-221-0/+43
| | | | | | | | | | | | | | | | | | | | Header file include/ruby/internal/abi.h contains RUBY_ABI_VERSION which is the ABI version. This value should be bumped whenever an ABI incompatible change is introduced. When loading dynamic libraries, Ruby will compare its own `ruby_abi_version` and the `ruby_abi_version` of the loaded library. If these two values don't match it will raise a `LoadError`. This feature can also be turned off by setting the environment variable `RUBY_RUBY_ABI_CHECK=0`. This feature will prevent cases where previously installed native gems fail in unexpected ways due to incompatibility of changes in header files. This will force the developer to recompile their gems to use the same header files as the built Ruby. In Ruby, the ABI version is exposed through `RbConfig::CONFIG["ruby_abi_version"]`.
* Decouple GC slot sizes from RVALUEPeter Zhu2022-02-022-7/+10
| | | | | | | | | Add a new macro BASE_SLOT_SIZE that determines the slot size. For Variable Width Allocation (compiled with USE_RVARGC=1), all slot sizes are powers-of-2 multiples of BASE_SLOT_SIZE. For USE_RVARGC=0, BASE_SLOT_SIZE is set to sizeof(RVALUE).
* Remove assert_equal that will never be runPeter Zhu2022-01-281-1/+1
| | | | `@s1.set_len(3)` will raise so the `assert_equal` will never be ran.
* Do not create core file if it is intentional abortKoichi Sasada2022-01-191-1/+2
| | | | | | | Two tests abort intentionally and they create core files if possible. In these case, we don't need to see core files so disable by `"Process.setrlimit(Process::RLIMIT_CORE, 0)` for those cases.
* Make embedded string length a long for VWAPeter Zhu2022-01-121-1/+1
| | | | | A short (2 bytes) will cause unaligned struct accesses when strings are used as a buffer to directly store binary data.
* Use omit instead of skip: test/-ext-/**/*.rbHiroshi SHIBATA2021-12-284-6/+6
|
* Remove tainted and trusted featuresNobuyoshi Nakada2021-12-261-14/+0
| | | | Already these had been announced to be removed in 3.2.
* Prepare for removing RubyVM::JIT (#5262)Takashi Kokubun2021-12-131-1/+1
|
* Rename --jit to --mjit (#5248)Takashi Kokubun2021-12-131-1/+1
| | | | | | | | | | | | | | | * Rename --jit to --mjit [Feature #18349] * Fix a few more --jit references * Fix MJIT Actions * More s/jit/mjit/ and re-introduce --disable-jit * Update NEWS.md * Fix test_bug_reporter_add
* Avoid assert failure when NULL EC is expectedAlan Wu2021-11-221-0/+7
| | | | | | | | | | | | | | | | | | | After 5680c38c75aeb5cbd219aafa8eb48c315f287d97, postponed job APIs now expect to be called on native threads not managed by Ruby and handles getting a NULL execution context. However, in debug builds the change runs into an assertion failure with GET_EC() which asserts that EC is non-NULL. Avoid the assertion failure by passing `false` for `expect_ec` instead as the intention is to handle when there is no EC. Add a test from John Crepezzi and John Hawthorn to exercise this situation. See GH-4108 See GH-5094 [Bug #17573] Co-authored-by: John Hawthorn <john@hawthorn.email> Co-authored-by: John Crepezzi <john.crepezzi@gmail.com>
* Rename ::YJIT to RubyVM::YJITAlan Wu2021-10-281-1/+1
| | | | | Since the YJIT Ruby module is CRuby specific and not meant for general use, it should live under RubyVM instead of at top level.