summaryrefslogtreecommitdiff
path: root/compile.c
AgeCommit message (Collapse)Author
2025-03-16Silently ignore keyword args for attr-asign method to cease segmentation fault.nagachika
2025-01-14merge revision(s) e0d600ec190c64aff76cfcbd6009cffb927da166: [Backport #21012]Takashi Kokubun
Avoid opt_aset_with optimization inside multiple assignment Previously, since the opt_aset_with optimization was introduced, use of the opt_aset_with optimization inside multiple assignment would result in a segfault or incorrect instructions. Fixes [Bug #21012] Co-authored-by: Nobuyoshi Nakada <nobu.nakada@gmail.com>
2024-09-02merge revision(s) a3562c2a0abf1c2bdd1d50377b4f929580782594: [Backport #20701]Takashi Kokubun
Remove incorrect setting of KW_SPLAT_MUT flag Fixes [Bug #20701] Co-authored-by: Pablo Herrero <pablodherrero@gmail.com>
2024-09-02merge revision(s) 992596fb7af18a7f472589a607d0eb3fbb03b49a: [Backport #20344]Takashi Kokubun
Fix next inside block argument stack underflow [Bug #20344] Fix compile_next adding removable adjust label
2024-09-02merge revision(s) 1870505f478cc75993b296b7144a45137ace6937: [Backport #20651]Takashi Kokubun
Fix wrong unreachable chunk remove when jump destination label is unremovable
2024-07-08merge revision(s) 2dd46bb82ffc4dff01d7ea70922f0e407acafb4e: [Backport #20468]Takashi Kokubun
[Bug #20468] Fix safe navigation in `for` variable
2024-06-11[3.3 backport] compile.c: use putspecialobject for RubyVM::FrozenCore (#10962)Jean byroot Boussier
compile.c: use putspecialobject for RubyVM::FrozenCore [Bug #20569] `putobject RubyVM::FrozenCore`, is not serializable, we have to use `putspecialobject VM_SPECIAL_OBJECT_VMCORE`. Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2024-06-10Fix inconsistent evaluation of keyword splat (#10959)Peter Zhu
[Bug #20180] Backports #9624.
2024-05-29merge revision(s) bc002971b6ad483dbf69b8a275c44412bb6ab954: [Backport #20094]Takashi Kokubun
[Bug #20094] Distinguish `begin` and parentheses
2024-03-20merge revision(s) 771a2f039b9a059a73e8f111d1d46590fa697f63: [Backport ↵NARUSE, Yui
#20213] (#10297) Fix incorrect use of VM_CALL_KW_SPLAT_MUT in zsuper with keyword splat For zsuper calls with a keyword splat but no actual keywords, the keyword splat is passed directly, so it cannot be mutable, because if the callee accepts a keyword splat, changes to the keyword splat by the callee would be reflected in the caller. While here, simplify the logic when the method supports literal keywords. I don't think it is possible for a method with has_kw param flags to not have keywords, so add an assertion for that, and set VM_CALL_KW_SPLAT_MUT in a single place.
2024-01-30Revert "merge revision(s) bc002971b6ad483dbf69b8a275c44412bb6ab954: ↵NARUSE, Yui
[Backport #20094]" This reverts commit d4b780e84e9a6b858d0f6c6a44b22da0d2f5835e.
2024-01-30merge revision(s) bc002971b6ad483dbf69b8a275c44412bb6ab954: [Backport #20094]NARUSE, Yui
[Bug #20094] Distinguish `begin` and parentheses --- compile.c | 1 + parse.y | 36 +++++++++++++++++++++--------------- test/ruby/test_whileuntil.rb | 18 ++++++++++++++++++ 3 files changed, 40 insertions(+), 15 deletions(-)
2023-12-15Introduce --parser runtime flagHParker
Introduce runtime flag for specifying the parser, ``` ruby --parser=prism ``` also update the description: ``` $ ruby --parser=prism --version ruby 3.3.0dev (2023-12-08T04:47:14Z add-parser-runtime.. 0616384c9f) +PRISM [x86_64-darwin23] ``` [Bug #20044]
2023-12-14Fix op asgn method calls passing mutable keyword splatsJeremy Evans
When passing the keyword splat to [], it cannot be mutable, because mutating the keyword splat inside [] would result in changes to the keyword splat passed to []=.
2023-12-12Fix op asgn calls with keywordsJeremy Evans
Examples of such calls: ```ruby obj[kw: 1] += fo obj[**kw] &&= bar ``` Before this patch, literal keywords would segfault in the compiler, and keyword splat usage would result in TypeError. This handles all cases I can think of: * literal keywords * keyword splats * combined with positional arguments * combined with regular splats * both with and without blocks * both popped and non-popped cases This also makes sure that to_hash is only called once on the keyword splat argument, instead of twice, and make sure it is called before calling to_proc on a passed block. Fixes [Bug #20051] Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2023-12-09Ensure super(**kw, &block) calls kw.to_hash before block.to_procJeremy Evans
Similar as previous commit, but handles the super case with explicit arguments.
2023-12-09Ensure f(**kw, &block) calls kw.to_hash before block.to_procJeremy Evans
Previously, block.to_proc was called first, by vm_caller_setup_arg_block. kw.to_hash was called later inside CALLER_SETUP_ARG or setup_parameters_complex. This adds a splatkw instruction that is inserted before sends with ARGS_BLOCKARG and KW_SPLAT and without KW_SPLAT_MUT. This is not needed in the KW_SPLAT_MUT case, because then you know the value is a hash, and you don't need to call to_hash on it. The splatkw instruction checks whether the second to top block is a hash, and if not, replaces it with the value of calling to_hash on it (using rb_to_hash_type). As it is always before a send with ARGS_BLOCKARG and KW_SPLAT, second to top is the keyword splat, and top is the passed block.
2023-12-07Eliminate array allocation for f(1, *a, &arg), f(*a, **kw, &arg), and f(*a, ↵Jeremy Evans
kw: 1, &arg) These are similar to the f(1, *a, &lvar), f(*a, **kw, &lvar) and f(*a, kw: 1, &lvar) optimizations, but they use getblockparamproxy instruction instead of getlocal. This also fixes the else style to be more similar to the surrounding code.
2023-12-07Eliminate array allocation for f(*a, kw: 1, &lvar) and f(*a, kw: 1, &@iv)Jeremy Evans
Similar to the previous commit, but this handles the block pass case.
2023-12-07Eliminate array allocation for f(*a, kw: 1)Jeremy Evans
In cases where the compiler can detect the hash is static, it would use duphash for the hash part. As the hash is static, there is no need to allocate an array.
2023-12-07Eliminate array allocation for f(*a, **lvar, &lvar) and f(*a, **@iv, &@iv)Jeremy Evans
The compiler already eliminates the array allocation for f(*a, &lvar) and f(*a, &@iv). If that is safe, then eliminating it for f(*a, **lvar) and f(*a, **@iv) as the last commit did is as safe, and eliminating it for f(*a, **lvar, &lvar) and f(*a, **@iv, &@iv) is also as safe.
2023-12-07Eliminate array allocation for f(*a, **lvar) and f(*a, **@iv)Jeremy Evans
The compiler already eliminates the array allocation for f(*a, &lvar) and f(*a, &@iv), and eliminating the array allocation for keyword splat is as safe as eliminating it for block passes.
2023-12-07Eliminate array allocation for f(1, *a, &lvar) and f(1, *a, &@iv)Jeremy Evans
Due to how the compiler works, while f(*a, &lvar) and f(*a, &@iv) do not allocate an array, but f(1, *a, &lvar) and f(1, *a, &@iv) do. It's probably possible to fix this in the compiler, but seems easiest to fix this in the peephole optimizer. Eliminating this array allocation is as safe as the current elimination of the array allocation for f(*a, &lvar) and f(*a, &@iv).
2023-12-07Eliminate array allocation for f(1, *a)Jeremy Evans
Due to how the compiler works, while f(*a) does not allocate an array f(1, *a) does. This is possible to fix in the compiler, but the change is much more complex. This attempts to fix the issue in a simpler way using the peephole optimizer. Eliminating this array allocation is safe, since just as in the f(*a) case, nothing else on the caller side can modify the array.
2023-12-02Pin instruction storagePeter Zhu
The operands in each instruction needs to be pinned because if auto-compaction runs in iseq_set_sequence, then the objects could exist on the generated_iseq buffer, which would not be reference updated which can lead to T_MOVED (and subsequently T_NONE) objects on the iseq.
2023-12-02[Bug #20033] Dynamic regexp should not assign capturesNobuyoshi Nakada
2023-11-29GC guard catch_table_ary in iseq_set_exception_tablePeter Zhu
The function iseq_set_exception_table allocates memory which can cause a GC compaction to run. Since catch_table_ary is not on the stack, it can be moved, which would make tptr incorrect.
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-21Embed ibf_dump objectsJean Boussier
2023-11-21Get rid of useless dsize functionsJean Boussier
If we always return 0, we might as well not define the function at all.
2023-11-20compile.c: make pinned_list embedableJean Boussier
This saves some malloc churn for small pin lists.
2023-11-11Stabilize outer variable listNobuyoshi Nakada
Sort outer variables by names to make dumped binary data stable.
2023-11-09Finer granularity IBF dependendencyNobuyoshi Nakada
It depends on only `VALUE` definition. Check for endianness and word size instead of the platform name.
2023-11-09Use `uint32_t` instead of `unsigned int` for the exact sizeNobuyoshi Nakada
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-10-30Move constant indexing into rb_translate_prismMatt Valentine-House
2023-10-30[Prism] Compile ForNodeMatt Valentine-House
Fixes ruby/prism#1648
2023-10-30Embed `rb_args_info` in `rb_node_args_t`Nobuyoshi Nakada
2023-10-25[PRISM] ScopeNode doesn't need void * anymoreJemma Issroff
2023-10-25[PRISM] Move scope_node itself to CRuby, create prism_compile.hJemma Issroff
2023-10-20Expand OP_ASGN1 nd_args to nd_index and nd_rvalueyui-knk
ARGSCAT has been used for nd_args to hold index and rvalue, because there was limitation on the number of members for Node. We can easily change structure of node now, let's expand it.
2023-10-19Extract a local variableNobuyoshi Nakada
2023-10-18Address PR commentsJemma Issroff
2023-10-18Remove pm_compile_context_t, move the context onto ScopeNodeJemma Issroff
We changed ScopeNodes to point to their parent (previous) ScopeNodes. Accordingly, we can remove pm_compile_context_t, and store all necessary context in ScopeNodes, allowing us to access locals from outer scopes.
2023-10-18YJIT: Add a live ISeq counter Alan Wu
It's an estimator for application size and could be used as a compilation heuristic later. Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2023-10-18Remove unnecessary and misleading castsNobuyoshi Nakada
2023-10-11Adjust indent [ci skip]Nobuyoshi Nakada
2023-10-11Extract NODE_FL_NEWLINE access to macroyui-knk
2023-10-09Fix cast node typeyui-knk