summaryrefslogtreecommitdiff
path: root/test/ruby
AgeCommit message (Collapse)Author
2023-11-27Guard match from GC when scanning stringPeter Zhu
We need to guard match from GC because otherwise it could end up being reclaimed or moved in compaction.
2023-11-27[PRISM] Small fixes to parameters ordering and methodsJemma Issroff
2023-11-27[PRISM] Compile IndexOperatorWriteNodeJemma Issroff
2023-11-27[PRISM] Compile IndexAndWriteNodeJemma Issroff
2023-11-27[PRISM] Compile IndexOrWriteNodeJemma Issroff
2023-11-27[PRISM] Fix compilation for SplatNodes within ArrayNodesJemma Issroff
SplatNodes within ArrayNodes (e.g. [*1..2, 3]) need to be special cased in the compiler because they use a combination of concatarray and newarray instructions to treat each sequence of splat or non-splat elements as independent arrays which get concatenated. This commit implements those cases.
2023-11-27[PRISM] Don't pop several args related nodesJemma Issroff
2023-11-27Fix compaction during ary_make_partialPeter Zhu
The ary_make_shared call may allocate, which can trigger a GC compaction. This can cause the array to be embedded because it has a length of 0.
2023-11-27Fix flaky "Expected 499 to be >= 500" assertion in test_gc_compact.rbKJ Tsanaktsidis
There have been some sproradically flaky tests related to GC compaction, which fail with: 1) Failure: TestGCCompact#test_moving_hashes_down_size_pools [/test/ruby/test_gc_compact.rb:442]: Expected 499 to be >= 500. What's happening here, is that, _sometimes_, depending on very unlucky combinations of machine things, one of the expected-to-be-moved hashes might be found on the machine stack during GC, and thus pinned. One factor which seems to make this _more_ likely is that GCC 11 on Ubuntu 22.04 seems to want to allocate 440 bytes of stack space for `gc_start`, which is much more than it actually uses on the common code path. The result is that there are some 50-odd VALUE-sized cells "live" on the stack which may well contain valid heap pointers from previous function calls, and will need to be pinned. This is, of course, totally normal and expected; Ruby's GC is conservative and if there is the possibility that a VALUE might be live on the machine stack, it can't be moved. However, it does make these tests flaky. This commit "fixes" the tests by performing the work in a fiber; the fiber goes out of scope and should be collected by the call to verify_compaction_references, so there should be no references to the to-be-moved objects floating around on the machine stack. Fixes [#20021]
2023-11-26Fix portability of bignum in ISeq Binary FormatNobuyoshi Nakada
- Unless `sizeof(BDIGIT) == 4`, (8-byte integer not available), the size to be loaded was wrong. - Since `BDIGIT`s are dumped as raw binary, the loaded byte order was inverted unless little-endian.
2023-11-24Switch shape test to use exhaust_shapesPeter Zhu
2023-11-24[DOC] State timezone info in the string wins `in:` keywordNobuyoshi Nakada
2023-11-23Add tests for compaction during evacuation of ivarsPeter Zhu
Extracted from PR #8932. Co-Authored-By: Jean Boussier <byroot@ruby-lang.org>
2023-11-22Speedup test_shape.rbJean Boussier
Many tests start by exhausting all shapes, which is a slow process. By exposing a method to directly move the bump allocator forward we cut test runtime in half. Before: ``` Finished tests in 1.544756s ``` After: ``` Finished tests in 0.759733s, ```
2023-11-21Remove string concat node in prismKevin Newton
2023-11-21Fix memory leak when evacuating generic ivarsPeter Zhu
The lookup in the table is using the wrong key when converting generic instance variables to too complex, which means that it never looks up the entry which leaks memory when the entry is overwritten.
2023-11-21Do not change hash type in Hash#assocNobuyoshi Nakada
2023-11-21Raise an exception when Hash#compare_by_identity during its iterationYusuke Endoh
2023-11-21Add a testTSUYUSATO Kitsune
2023-11-21[Bug #11183] Fix rb_complex_pow for special anglesKouhei Yanagita
Add a special treatment for when the argument of self is an integral multiple of 45 degrees. 1i ** (10 ** 100) #=> 1+0i 1i ** (10 ** 100 + 1) #=> 0+1i (1+1i) ** (10 ** 100) # warning: in a**b, b may be too big #=> (Infinity+0.0i) (1+1i) ** (10 ** 100 + 1) # warning: in a**b, b may be too big #=> (Infinity+Infinity*i)
2023-11-20Fix crash when evacuating generic ivarPeter Zhu
When transitioning generic instance variable objects to too complex, we set the shape first before performing inserting the new gen_ivtbl. The st_insert for the new gen_ivtbl could allocate and cause a GC. If that happens, then it will crash because the object will have a too complex shape but not yet be backed by a st_table. This commit changes the order so that the insert happens first before the new shape is set. The following script reproduces the issue: ``` o = [] o.instance_variable_set(:@a, 1) i = 0 o = Object.new while RubyVM::Shape.shapes_available > 0 o.instance_variable_set(:"@i#{i}", 1) i += 1 end ary = 1_000.times.map { [] } GC.stress = true ary.each do |o| o.instance_variable_set(:@a, 1) o.instance_variable_set(:@b, 1) end ```
2023-11-20[PRISM] Updated LocalVariableTargetNodes tooJemma Issroff
2023-11-20[PRISM] Fix LocalVariableWriteNodes within blocksJemma Issroff
Prior to this commit, we weren't recursing up scopes to look for the local definition. With this commit, we do so, fixing local writes within blocks
2023-11-20[PRISM] Implement once node for interpolated regexeileencodes
This PR implements the once node on interpolated regexes. There is a bug in Prism where the interpolated regex with the once flag only works when there is not a local variable so the test uses a "1". We'll need to fix that.
2023-11-20[PRISM] Don't pop args to YieldNodeJemma Issroff
2023-11-20Fix crash when iterating over generic ivarsPeter Zhu
2023-11-18Ensure keyword splat method argument is hashJeremy Evans
Commit e87d0882910001ef3b0c2ccd43bf00cee8c34a0c introduced a regression where the keyword splat object passed by the caller would be directly used by callee as keyword splat parameters, if it implemented #to_hash. The return value of #to_hash would be ignored in this case.
2023-11-17Fix corruption when out of shape during ivar removePeter Zhu
Reproduction script: ``` o = Object.new 10.times { |i| o.instance_variable_set(:"@a#{i}", i) } i = 0 a = Object.new while RubyVM::Shape.shapes_available > 2 a.instance_variable_set(:"@i#{i}", 1) i += 1 end o.remove_instance_variable(:@a0) puts o.instance_variable_get(:@a1) ``` Before this patch, it would incorrectly output `2` and now it correctly outputs `1`.
2023-11-17Skip test_ForwardingArgumentsNodeYusuke Endoh
due to a failure on a CI http://ci.rvm.jp/results/trunk-iseq_binary@ruby-sp2-docker/4779277 ``` expected: == disasm: #<ISeq:prism_test_forwarding_arguments_node1@<compiled>:2 (2,8)-(4,11)> local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: 1]) [ 1] "..."@0 0000 putself ( 3) 0001 getlocal_WC_0 ?@-2 0003 splatarray false 0005 getblockparamproxy ?@-1, 0 0008 send <calldata!mid:prism_test_forwarding_arguments_node, argc:1, ARGS_SPLAT|ARGS_BLOCKARG|FCALL>, nil 0011 leave ( 2) actual: == disasm: #<ISeq:prism_test_forwarding_arguments_node1@<compiled>:2 (2,8)-(4,11)> local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: 1]) [ 1] "..."@0 0000 putself ( 3) 0001 getlocal_WC_0 ?@-2 0003 splatarray false 0005 getblockparamproxy "!"@-1, 0 0008 send <calldata!mid:prism_test_forwarding_arguments_node, argc:1, ARGS_SPLAT|ARGS_BLOCKARG|FCALL>, nil 0011 leave ( 2) /tmp/ruby/src/trunk-iseq_binary/tool/lib/iseq_loader_checker.rb:36:in `exit': exit (SystemExit) ```
2023-11-15No need to save `$VERBOSE`Nobuyoshi Nakada
2023-11-15Separate tests for Hash only from tests for Hash and its subclassesNobuyoshi Nakada
2023-11-15test: Follow-up fix for #8916Yuta Saito
`test_thread_trace` is also flaky due to the same reason as #8916. https://rubyci.s3.amazonaws.com/centos7/ruby-master/log/20231114T213002Z.fail.html.gz https://rubyci.s3.amazonaws.com/wsl2/ruby-master/log/20231114T090003Z.fail.html.gz
2023-11-14test: Assert only events originated from the test_settracefunc.rb test fileYuta Saito
This test suite is flaky on CI, because the test asserts events from finalizers also. Tracing events from finalizers is not deterministic and is not a part of test interests, so this commit changes the test to assert only events originated from the test file itself.
2023-11-13Don't overwrite shape capacity when removing ivarPeter Zhu
Other objects may be using the shape, so we can't change the capacity otherwise the other objects may have a buffer overflow.
2023-11-14test: Check file name in test_thread_add_trace_func alsoYuta Saito
For better assert failure diagnostics.
2023-11-11[Bug #19969] Compact st_table after deleted if possibleNobuyoshi Nakada
2023-11-09[PRISM] Implement compilation for ForwardingArgumentssNodeJemma Issroff
2023-11-09String#force_encoding don't clear coderange if encoding is unchangedJean Boussier
Some code out there blind calls `force_encoding` without checking what the original encoding was, which clears the coderange uselessly. If the String is big, it can be a rather costly mistake. For instance the `rack-utf8_sanitizer` gem does this on request bodies.
2023-11-08[PRISM] Add tests for OptionalKeywordParameterNodeJemma Issroff
This commit adds tests for the compilation of the OptionalKeywordParameterNode, and fixes cases on the RequiredKeywordParameterNode
2023-11-08[PRISM] Added tests for ForwardingParameterNode, KeywordRestParameterNodeJemma Issroff
2023-11-08[PRISM] Add tests for several parameters nodesJemma Issroff
This commit adds tests for BlockParameterNode, RequiredParameterNode, RequiredKeywordParameterNode and RestParameterNode
2023-11-08YJIT: Disable code GC (#8865)Takashi Kokubun
Co-authored-by: Alan Wu <alansi.xingwu@shopify.com> Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>
2023-11-08Improve error and memory handlingAdam Hess
Apply Nobu's suggestions which improve style, memory handling and error correction. Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2023-11-07Use embedded TypedData for Time objectsPeter Zhu
This drops the total size of a Time object from 86 bytes to 80 bytes. Running the benchmark benchmark/time_now.yml, this commit improves performance of Time.now by about 30%: ``` Time.now Branch: 13159405.4 i/s Master: 10036908.7 i/s - 1.31x slower Time.now(in: "+09:00") Branch: 2712172.6 i/s Master: 2138637.9 i/s - 1.27x slower ``` It also decreases memory usage by about 20%: ``` ary = 10_000_000.times.map { Time.now } puts `ps -o rss= -p #{$$}` ``` Branch: 961792 Master: 1196544 Co-Authored-By: Jean Boussier <byroot@ruby-lang.org>
2023-11-07[PRISM] Implement compilation for different parametersJemma Issroff
This commit compiles most parameter types, setting appropriate values on the ISEQ_BODY. It also adds tests for callers and callees of methods, using many versions of tests from bootstraptest
2023-11-07[PRISM] CompileEnsureNodeMatt Valentine-House
2023-11-06[PRISM] Implement compilation for MultiWriteNodes, fix MultiTargetNodesJemma Issroff
Compilation now works for MultiWriteNodes and MultiTargetNodes, with nesting on MultiWrites. See the tests added in this commit for example behavior.
2023-11-06generic_ivar_set: properly check for TOO_COMPLEX on capacity transitionJean Boussier
2023-11-06[Bug #19985] Raise LoadError with the converted feature nameNobuyoshi Nakada
`Kernel#require` converts feature name objects that have the `to_path` method such as `Pathname`, but had used the original object on error and had resulted in an unexpected `TypeError`.
2023-11-05ast.rb: Fix bug for source of multibyte charactersalpaca-tc
first_column and last_column return byte positions, but existing implementations did not consider multibyte.