summaryrefslogtreecommitdiff
path: root/compile.c
AgeCommit message (Collapse)Author
2023-12-28Check node type before castyui-knk
2023-12-27[Bug #20094] Distinguish `begin` and parenthesesNobuyoshi Nakada
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 <[email protected]>
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 <[email protected]> Co-authored-by: Takashi Kokubun <[email protected]>
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
2023-10-07Correctly casting node for accessing nd_value and nd_vid in compile.cyui-knk
2023-10-06Remove not used fields from MATCH3yui-knk
2023-10-06Remove `NODE_VALUES`Nobuyoshi Nakada
This node type was added for the multi-value experiment back in 2004. The feature itself was removed after a few years, but this is its remnant.
2023-10-05Correctly casting node for accessing COLON node nd_mid in compile.cyui-knk
2023-10-02Check the result of get_nd_recv before node type check for safetyYuichiro Kaneko
Co-authored-by: Nobuyoshi Nakada <[email protected]>
2023-10-02Correctly casting node for accessing nd_recv, nd_mid and nd_args in compile.cyui-knk
2023-10-01Use reference counting to avoid memory leak in kwargsHParker
Tracks other callinfo that references the same kwargs and frees them when all references are cleared. [bug #19906] Co-authored-by: Peter Zhu <[email protected]>
2023-10-01Use rb_node_args_t and rb_node_args_aux_t instead of NODEyui-knk
2023-10-01Use rb_node_opt_arg_t and rb_node_kw_arg_t instead of NODEyui-knk
2023-09-30Expand pattern_info struct into ARYPTN Node and FNDPTN Nodeyui-knk