summaryrefslogtreecommitdiff
path: root/test/ruby
AgeCommit message (Collapse)Author
2024-01-23Memory leak with TracePoint on bmethodPeter Zhu
[Bug #20194] When disabling the TracePoint on bmethod, the hooks list is not freed. For example: obj = Object.new obj.define_singleton_method(:foo) {} bmethod = obj.method(:foo) tp = TracePoint.new(:return) {} 10.times do 100_000.times do tp.enable(target: bmethod) {} end puts `ps -o rss= -p #{$$}` end Before: 18208 22832 26528 29728 34000 37776 40864 44400 47680 51504 After: 16688 17168 17168 17248 17696 17760 17824 17824 17856 17920
2024-01-22Handle trailing commas on blocksAaron Patterson
We need to set a special flag on block iseqs when there is a trailing comma. Fixes: https://github.com/ruby/prism/issues/2244
2024-01-22Check keyword parameters correctlyAaron Patterson
We weren't checking the right offsets when compiling methods with keyword parameters that had complex code. Fixes: https://github.com/ruby/prism/issues/2228
2024-01-22[PRISM] Fix keyword arguments in IndexOrWriteNodePeter Zhu
Fixes ruby/prism#2236.
2024-01-22[PRISM] Fix splat and block in asetPeter Zhu
2024-01-22[PRISM] Fix block in asetPeter Zhu
Fixes ruby/prism#2223.
2024-01-22Fix compiling rescue + ensureAaron Patterson
When we're compiling begin / rescue / ensure nodes, we need to "wrap" the code in the begin statements correctly. The wrapping is like this: (ensure code (rescue code (begin code))) This patch pulls the each leg in to its own function, then calls the appropriate wrapping function depending on whether there are ensure / rescue legs. Fixes: https://github.com/ruby/prism/issues/2221
2024-01-22[PRISM] Fix keyword splat in IndexAndWriteNode and IndexOrWriteNodePeter Zhu
Fixes ruby/prism#2232 and ruby/prism#2234.
2024-01-22[PRISM] Fix keywords arguments in IndexAndWriteNodePeter Zhu
Fixes ruby/prism#2233.
2024-01-22[PRISM] Fix incorrect ordering of MultiTargetNodePeter Zhu
Fixes ruby/prism#2218.
2024-01-20More testsBurdetteLamar
2024-01-19[PRISM] Fix ensure code running twiceeileencodes
Fixes: ruby/prism#2212
2024-01-19Fix kwarg orderingAaron Patterson
Required keyword arguments need to come first. Fixes: https://github.com/ruby/prism/issues/2158 Co-authored-by: Kevin Newton <kddnewton@gmail.com>
2024-01-19Fix ensure code when running break in a while loopAaron Patterson
We need to run ensure code when breaking from a while loop Co-authored-by: John Hawthorn <jhawthorn@github.com> Co-authored-by: Kevin Newton <kddnewton@gmail.com>
2024-01-18[PRISM] Fix case splat with no predicateMatt Valentine-House
2024-01-17[Prism] Implement defined? for PM_UNLESS_NODEeileencodes
Ruby code: ```ruby defined?(unless true; 1; end) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,16)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,16)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_UNTIL_NODEeileencodes
Ruby code: ```ruby defined?(until a == 1; end) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,16)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,16)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_WHILE_NODEeileencodes
Ruby code: ```ruby defined?(while a != 1; end) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,16)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,16)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_SINGLETON_CLASS_NODEeileencodes
Ruby code: ```ruby defined?(class << self; end) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,16)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,16)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_RATIONAL_NODEeileencodes
Ruby code: ```ruby defined?(1.2r) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,16)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,16)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_MODULE_NODEeileencodes
Ruby code: ```ruby defined?(module M; end) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,16)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,16)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_MATCH_REQUIRED_NODEeileencodes
Ruby code: ```ruby defined?(1 => 1) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,16)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,16)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_MATCH_WRITE_NODEeileencodes
Ruby code: ```ruby defined?(/(?<foo>bar)/ =~ 'barbar') ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,35)> local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1]) [ 1] foo@0 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,35)> local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1]) [ 1] foo@0 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_IF_NODEeileencodes
Ruby code: ```ruby defined?(if true; 1; end) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,43)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,43)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_FOR_NODEeileencodes
Ruby code: ```ruby defined?(for i in [1,2] do; i; end) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,43)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,43)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_DEF_NODEeileencodes
Ruby code: ```ruby defined?(def prism_test_def_node; end) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,43)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,43)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_CLASS_NODEeileencodes
Ruby code: ```ruby defined?(class PrismClassA; end) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,43)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,43)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_CASE_MATCH_NODEeileencodes
Ruby code: ```ruby defined?(case [1, 2, 3]; in [1, 2, 3]; 4; end) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,43)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,43)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_CASE_NODEeileencodes
Ruby code: ```ruby defined?(case :a; when :a; 1; else; 2; end) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,43)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,43)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[PRISM] Fix test spelling `RescueModifer` -> `RescueModifier`eileencodes
`RescueModifier` was spelled wrong. Not a big deal, but it meant I didn't immediately find the test when I was searching for it while working on implementing `defined?` nodes.
2024-01-17[Prism] Implement defined? for PM_INDEX_OR_WRITE_NODEeileencodes
Ruby code: ```ruby defined?([0][0] ||= 1) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,58)> 0000 putobject "assignment" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,58)> 0000 putobject "assignment" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_INDEX_OPERATOR_WRITE_NODEeileencodes
Ruby code: ```ruby defined?([0][0] += 1) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,58)> 0000 putobject "assignment" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,58)> 0000 putobject "assignment" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_INDEX_AND_WRITE_NODEeileencodes
Ruby code: ```ruby defined?([0][0] &&= 1) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,58)> 0000 putobject "assignment" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,58)> 0000 putobject "assignment" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_CONSTANT_PATH_WRITE_NODEeileencodes
Ruby code: ```ruby defined?(Prism::CPWN = 1) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,58)> 0000 putobject "assignment" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,58)> 0000 putobject "assignment" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_CONSTANT_PATH_OR_WRITE_NODEeileencodes
Ruby code: ```ruby defined?(Prism::CPOrWN ||= 1) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,58)> 0000 putobject "assignment" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,58)> 0000 putobject "assignment" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_CONSTANT_PATH_OPERATOR_WRITE_NODEeileencodes
Ruby code: ```ruby defined?(Prism::CPOWN += 1) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,58)> 0000 putobject "assignment" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,58)> 0000 putobject "assignment" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_CONSTANT_PATH_AND_WRITE_NODEeileencodes
Ruby code: ```ruby defined?(Prism::CPAWN &&= 1) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,58)> 0000 putobject "assignment" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,58)> 0000 putobject "assignment" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_CALL_OR_WRITE_NODEeileencodes
Ruby code: ```ruby defined?(PrismTestSubclass.test_call_or_write_node ||= 1) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,58)> 0000 putobject "assignment" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,58)> 0000 putobject "assignment" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_CALL_OPERATOR_WRITE_NODEeileencodes
Ruby code: ```ruby defined?(PrismTestSubclass.test_call_operator_write_node += 1) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,58)> 0000 putobject "assignment" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,58)> 0000 putobject "assignment" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_CALL_AND_WRITE_NODEeileencodes
Ruby code: ```ruby defined?(PrismTestSubclass.test_call_and_write_node &&= 1) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,58)> 0000 putobject "assignment" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,58)> 0000 putobject "assignment" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[PRISM] Fix crash in compile_prismPeter Zhu
If the argument is not a file or a string, it assumes it's a string which will crash because RSTRING_PTR and RSTRING_LEN assumes it's a string.
2024-01-17[PRISM] Fix fallthrough for PM_ENSURE_NODEPeter Zhu
This caused it to fall into PM_ELSE_NODE which caused ensure nodes to be compiled twice. Fixes ruby/prism#2176.
2024-01-17[Prism] Fix more method call argumnentseileencodes
In #2087 it was noted that there was a bug in the number of arguments in `SplatNode` and `KeywordHashNode`. I looked into this with Aaron before the linked PR was merged and we found a bunch of cases that weren't working quite right. This PR aims to fix some of those cases, but there may be more. A splat argument followed by a positional argument will concat the array until the end or unless the argument is a kwarg or splat kwarg. For example ``` foo(a, *b, c, *d, e) ``` Will have an `argc` of 2, because `b`, `c`, `d`, and `e` will be concatenated together. ``` foo(a, *b, c, *d, **e) ``` Will have an `argc` of 3, because `b`, `c`, and `d` will be concatenated together and `e` is a separate argument.
2024-01-17YJIT: Support empty splat and some block_arg calls to ivar getters (#9567)Alan Wu
These seem odd at first glance, but they're used with `...` calls with `Module#delegate` from Active Support. These account for ~3% of fallback reasons in the `lobsters` benchmark.
2024-01-17[Prism] Fix return testeileencodes
This test didn't work as is because it causes a SyntaxError. Instead we need to put the `defined?(return)` into a method and call that. I double checked that on the `master` branch this returns an Unsupported node error.
2024-01-17[Prism] Implement defined? for PM_BEGIN_NODEeileencodes
Ruby code: ```ruby defined?(begin; 1; end) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,23)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,23)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_RETRY_NODEeileencodes
Ruby code: ```ruby defined?(retry) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,15)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,15)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_RETURN_NODEeileencodes
Ruby code: ```ruby defined?(return) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,16)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,16)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_REDO_NODEeileencodes
Ruby code: ```ruby defined?(redo) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,14)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,14)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_INTERPOLATED_X_STRING_NODEeileencodes
Ruby code: ```ruby defined?(`echo #{1}`) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,21)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,21)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188