summaryrefslogtreecommitdiff
path: root/test/ruby
AgeCommit message (Collapse)Author
2023-12-06[PRISM] Fix ReturnNodesJemma Issroff
This code is almost exactly the same (fixed variable names) as what exists already in compile.c
2023-12-06Re-embed when removing Object instance variablesPeter Zhu
Objects with the same shape must always have the same "embeddedness" (either embedded or heap allocated) because YJIT assumes so. However, using remove_instance_variable, it's possible that some objects are embedded and some are heap allocated because it does not re-embed heap allocated objects. This commit changes remove_instance_variable to re-embed Object instance variables when it becomes small enough.
2023-12-06[PRISM] Account for nil parent in Call{Operator,And,Or}PathWriteNodesJemma Issroff
Prior to this commit, we were not accounting for the case of a nil parent in a CallXPathWriteNode, for example ::A ||= 1. This commit checks if the parent exists, and if not, uses Object as the inferred parent
2023-12-06[PRISM] Implement `PM_MATCH_PREDICATE_NODE` for `defined?`eileencodes
Ruby code: ```ruby defined? 1 in 1 ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,16)> 0000 putobject "expression" 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,16)> 0000 putobject "expression" 0002 leave ```
2023-12-06[PRISM] Implement `PM_KEYWORD_HASH_NODE` for `defined?`eileencodes
Ruby code: ```ruby defined? [a: [:b, :c]] ``` Instructions (without optimizations): ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,23)> == catch table | catch type: rescue st: 0001 ed: 0007 sp: 0000 cont: 0009 | == disasm: #<ISeq:defined guard in <compiled>@<compiled>:0 (0,0)-(-1,-1)> | local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1]) | [ 1] "$!"@0 | 0000 putnil | 0001 leave |------------------------------------------------------------------------ 0000 putnil 0001 putobject true 0003 branchunless 9 0005 putobject "expression" 0007 swap 0008 pop 0009 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,23)> == catch table | catch type: rescue st: 0000 ed: 0009 sp: 0000 cont: 0009 | == disasm: #<ISeq:defined guard in <compiled>@<compiled>:0 (0,0)-(-1,-1)> | local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1]) | [ 1] "$!"@0 | 0000 putnil | 0001 leave |------------------------------------------------------------------------ 0000 putnil 0001 putobject true 0003 branchunless 9 0005 putobject "expression" 0007 swap 0008 pop 0009 leave ``` Instructions (with optimizations): ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,23)> == catch table | catch type: rescue st: 0001 ed: 0003 sp: 0000 cont: 0005 | == disasm: #<ISeq:defined guard in <compiled>@<compiled>:0 (0,0)-(-1,-1)> | local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1]) | [ 1] "$!"@0 | 0000 putnil | 0001 leave |------------------------------------------------------------------------ 0000 putnil 0001 putobject "expression" 0003 swap 0004 pop 0005 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,23)> == catch table | catch type: rescue st: 0000 ed: 0005 sp: 0000 cont: 0005 | == disasm: #<ISeq:defined guard in <compiled>@<compiled>:0 (0,0)-(-1,-1)> | local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1]) | [ 1] "$!"@0 | 0000 putnil | 0001 leave |------------------------------------------------------------------------ 0000 putnil 0001 putobject "expression" 0003 swap 0004 pop 0005 leave ```
2023-12-06[PRISM] Implement `PM_SPLAT_NODE` for `defined?`eileencodes
In an array for `defined?` we need to check if there is a `contains_splat` flag, if so bail early. Ruby code: ```ruby defined?([[*1..2], 3, *4..5]) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,29)> 0000 putobject "expression" 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,29)> 0000 putobject "expression" 0002 leave ```
2023-12-06[PRISM] Implement `PM_SOURCE_LINE_NODE` for `defined?`eileencodes
Ruby code: ```ruby defined?(__LINE__) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,18)> 0000 putobject "expression" 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,18)> 0000 putobject "expression" 0002 leave ```
2023-12-06[PRISM] Implement `PM_SOURCE_FILE_NODE` for `defined?`eileencodes
Ruby code: ```ruby defined?(__FILE__) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,18)> 0000 putobject "expression" 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,18)> 0000 putobject "expression" 0002 leave ```
2023-12-06[PRISM] Implement `PM_SOURCE_ENCODING_NODE` for `defined?eileencodes
Ruby code: ```ruby defined?(__ENCODING__) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,22)> 0000 putobject "expression" 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,22)> 0000 putobject "expression" 0002 leave ```
2023-12-06[PRISM] Implement `PM_IMAGINARY_NODE` for `defined?`eileencodes
Ruby Code: ``` defined?(1i) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,12)> 0000 putobject "expression" 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,12)> 0000 putobject "expression" 0002 leave ```
2023-12-06[PRISM] Compile Rescue Modifier nodesMatt Valentine-House
2023-12-05[PRISM] Implement Retry node.Matt Valentine-House
2023-12-04[PRISM] Fixed redo nodeJemma Issroff
2023-12-04[PRISM] Handle percent literals for `defined?`eileencodes
Tests all the possible percent literal with `defined?`. Implements the missing `PM_X_STRING_NODE` for the `%x` literal. Code: ```ruby defined?(%x[1,2,3]) ``` ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,19)> 0000 putobject "expression" 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,19)> 0000 putobject "expression" 0002 leave ```
2023-12-04[PRISM] Implement `PM_INTERPOLATED_REGULAR_EXPRESSION_NODE`eileencodes
Implements `PM_INTERPOLATED_REGULAR_EXPRESSION_NODE` for `defined?` Code: ```ruby defined?(/#{1}/) ``` ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,16)> 0000 putobject "expression" 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,16)> 0000 putobject "expression" 0002 leave ```
2023-12-04[PRISM] Implement `PM_INTERPOLATED_STRING_NODE`eileencodes
Implements `PM_INTERPOLATED_STRING_NODE` for `defined?` Code: ```ruby defined?("#{expr}") ``` ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,19)> 0000 putobject "expression" 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,19)> 0000 putobject "expression" 0002 leave ```
2023-12-04[PRISM] Fix `PM_PARENTHESES_NODE`eileencodes
In #9101 I only accounted for an empty paren. This change implements the `PM_PARENTHESES_NODE` for when it's `nil` and when it's an expression. Code: ```ruby defined?(("a")) ``` ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,15)> 0000 putobject "expression" 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,15)> 0000 putobject "expression" 0002 leave ```
2023-12-04[Prism] Implement backref and numbered reference for `defined?`eileencodes
This PR implements `PM_BACK_REFERENCE_READ_NODE` and `PM_NUMBERED_REFERENCE_READ_NODE` for `defined?`. The following now works: * `PM_NUMBERED_REFERENCE_READ_NODE` ``` defined? $1 defined? $2 ``` Instructions: ``` "********* RUBY *************" == disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,12)> 0000 putnil 0001 defined ref, :$1, "global-variable" 0005 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,12)> 0000 putnil 0001 defined ref, :$1, "global-variable" 0005 leave ``` * `PM_BACK_REFERENCE_READ_NODE` ``` defined? $' defined? $` defined? $& ``` Instructions: ``` "********* RUBY *************" == disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,12)> 0000 putnil 0001 defined ref, :$`, "global-variable" 0005 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,12)> 0000 putnil 0001 defined ref, :$`, "global-variable" 0005 leave ```
2023-12-04[PRISM] Fix compilation for NextNodeJemma Issroff
This code was almost enitrely the same as the existing compiler's code for its NextNode.
2023-12-01Implement paren node for `defined?`eileencodes
Implements and adds a test for passing a parentheses node to `defined?`.
2023-12-01Implements missing literals for `defined?`eileencodes
This PR implements the following literals: - String - Symbols - Integers - Floats - Regexs - Ranges - Lambdas - Hashes and tests for them.
2023-12-01Make String#undump compaction safePeter Zhu
2023-12-02[Bug #20033] Dynamic regexp should not assign capturesNobuyoshi Nakada
2023-12-01[PRISM] Account for RescueNodes with no statementsJemma Issroff
We need a PUTNIL if a RescueNode has no statements.
2023-12-01[PRISM] Fix behavior of BlockParameters with only one parameterJemma Issroff
This commit sets the ambiguous param flag if there is only one parameter on a block node. It also fixes a small bug with a trailing comma on params.
2023-12-01[PRISM] Restructure parametersJemma Issroff
Prior to this commit, we weren't accounting for hidden variables on the locals table, so we would have inconsistencies on the stack. This commit fixes params, and introduces a hidden_variable_count on the scope, both of which fix parameters.
2023-12-01[PRISM] Compile RescueNodeMatt Valentine-House
2023-12-01[Bug #20030] dispatch invalid escaped character without ignoring itNobuyoshi Nakada
2023-11-30YJIT: Cancel on-stack jit_return on invalidation (#9086)Takashi Kokubun
* YJIT: Cancel on-stack jit_return on invalidation Co-authored-by: Alan Wu <alansi.xingwu@shopify.com> * Use RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P --------- Co-authored-by: Alan Wu <alansi.xingwu@shopify.com>
2023-11-30YJIT: Use `stats[:live_page_count]`, renamed from :compiled_page_countAlan Wu
Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2023-11-30[Prism] Fix local variable access for POST_EXECUTION_NODEMatt Valentine-House
2023-11-30Store depth offset inside the scope node.Matt Valentine-House
Instead of incrementing the depth using call by reference as we're recursing up the stack we could instead store an offset for each known scope where we know the depth is going to represented differently in the Prism ast.
2023-11-30Add a rescue for `defined?(A::B::C)`Aaron Patterson
It's possible for `defined?(A::B::C)` to raise an exception. `defined?` must swallow the exception and return nil, so this commit adds a rescue entry for `defined?` expressions on constant paths
2023-11-30[Bug #19877] Assign captures for direct regexp literal onlyNobuyoshi Nakada
2023-11-30Add some test cases to Data testOKURA Masafumi
I noticed that `deconstruct` and `hash` don't have enough coverage. The behavior of `hash` is documented so I copied it.
2023-11-29Guard match from GC in String#gsubPeter Zhu
We need to guard match from GC because otherwise it could end up being reclaimed or moved in compaction.
2023-11-29[PRISM] Implement CallNodes with splat followed by argsJemma Issroff
2023-11-29[PRISM] Account for ImplicitRestNodeJemma Issroff
Prism introduced a new ImplicitRestNode. This adds tests for the ImplicitRestNode cases, and changes one assert which is no longer accurate.
2023-11-29[PRISM] Fix EnsureNode, pass depth to get localsJemma Issroff
This commit fixes a bug with locals in ensure nodes by setting the local tables correctly. It also changes accessing locals to look at local tables in parent scopes, and account for this correctly on depths of get or setlocals.
2023-11-29Add missing assertion in test_use_all_shapes_then_freezePeter Zhu
2023-11-29[Bug #17037] Improve accuracy of division near precision limitsNobuyoshi Nakada
When dividing near the precision limit of `double`, use Bignum division to get rid of rounding errors.
2023-11-29Array#rassoc should try to convert to array implicitly. Fixes #20003Tema Bolshakov
2023-11-28Fix Ractor sharing for too complex ObjectsPeter Zhu
2023-11-28Fix Ractor sharing for too complex generic ivarsPeter Zhu
2023-11-28[PRISM] Don't calculate params size based on localsJemma Issroff
Prior to this commit, we were conflating the size of the locals list with the number of parameters. This commit distinguishes the two, and fixes a related bug which would occur if we set a local that was not a parameter
2023-11-28[PRISM] Implement more compilation of SplatNodesJemma Issroff
There was a bug with the rest argument in SplatNodes, this commit fixes it, and adds more tests illustrating the behavior of SplatNodes
2023-11-28[PRISM] Compile YieldNode with different argumentsJemma Issroff
2023-11-28Fix cache incoherency for ME resolved through VM_METHOD_TYPE_REFINEDAlan Wu
Previously, we didn't invalidate the method entry wrapped by VM_METHOD_TYPE_REFINED method entries which could cause calls to land in the wrong method like it did in the included test. Do the invalidation, and adjust rb_method_entry_clone() to accommodate this new invalidation vector. Fix: cfd7729ce7a31c8b6ec5dd0e99c67b2932de4732 See-also: e201b81f79828c30500947fe8c8ea3c515e3d112
2023-11-28[PRISM] Run test setting global constant separatelyAlan Wu
This impacted other tests. Please mind the commons. /home/runner/work/ruby/ruby/src/test/ruby/test_compile_prism.rb:394: warning: already initialized constant Bar /tmp/test_reline_config_60145/bazbarbob.rb:6: warning: previous definition of Bar was here 1) Failure: TestModule#test_const_get_evaled [/home/runner/work/ruby/ruby/src/test/ruby/test_module.rb:1239]: NameError expected but nothing was raised.
2023-11-28Make Range#reverse_each raise TypeError if endlessKouhei Yanagita