aboutsummaryrefslogtreecommitdiffstats
path: root/compile.c
Commit message (Collapse)AuthorAgeFilesLines
* Eliminate array allocation for f(1, *a, &arg), f(*a, **kw, &arg), and f(*a, ↵Jeremy Evans2023-12-071-7/+34
| | | | | | | | | | | 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.
* Eliminate array allocation for f(*a, kw: 1, &lvar) and f(*a, kw: 1, &@iv)Jeremy Evans2023-12-071-0/+26
| | | | | Similar to the previous commit, but this handles the block pass case.
* Eliminate array allocation for f(*a, kw: 1)Jeremy Evans2023-12-071-0/+23
| | | | | | 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.
* Eliminate array allocation for f(*a, **lvar, &lvar) and f(*a, **@iv, &@iv)Jeremy Evans2023-12-071-0/+24
| | | | | | | | 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.
* Eliminate array allocation for f(*a, **lvar) and f(*a, **@iv)Jeremy Evans2023-12-071-0/+15
| | | | | | 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.
* Eliminate array allocation for f(1, *a, &lvar) and f(1, *a, &@iv)Jeremy Evans2023-12-071-0/+24
| | | | | | | | | | | 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).
* Eliminate array allocation for f(1, *a)Jeremy Evans2023-12-071-0/+21
| | | | | | | | | | 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.
* Pin instruction storagePeter Zhu2023-12-021-8/+8
| | | | | | | 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.
* [Bug #20033] Dynamic regexp should not assign capturesNobuyoshi Nakada2023-12-021-8/+20
|
* GC guard catch_table_ary in iseq_set_exception_tablePeter Zhu2023-11-291-3/+7
| | | | | | 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.
* Fix portability of bignum in ISeq Binary FormatNobuyoshi Nakada2023-11-261-2/+6
| | | | | | | - 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.
* Embed ibf_dump objectsJean Boussier2023-11-211-5/+2
|
* Get rid of useless dsize functionsJean Boussier2023-11-211-7/+5
| | | | | If we always return 0, we might as well not define the function at all.
* compile.c: make pinned_list embedableJean Boussier2023-11-201-19/+7
| | | | This saves some malloc churn for small pin lists.
* Stabilize outer variable listNobuyoshi Nakada2023-11-111-10/+43
| | | | Sort outer variables by names to make dumped binary data stable.
* Finer granularity IBF dependendencyNobuyoshi Nakada2023-11-091-3/+17
| | | | | It depends on only `VALUE` definition. Check for endianness and word size instead of the platform name.
* Use `uint32_t` instead of `unsigned int` for the exact sizeNobuyoshi Nakada2023-11-091-7/+7
|
* [PRISM] CompileEnsureNodeMatt Valentine-House2023-11-071-2/+2
|
* [PRISM] Implement compilation for MultiWriteNodes, fix MultiTargetNodesJemma Issroff2023-11-061-5/+1
| | | | | | Compilation now works for MultiWriteNodes and MultiTargetNodes, with nesting on MultiWrites. See the tests added in this commit for example behavior.
* Move constant indexing into rb_translate_prismMatt Valentine-House2023-10-301-19/+2
|
* [Prism] Compile ForNodeMatt Valentine-House2023-10-301-1/+7
| | | | Fixes ruby/prism#1648
* Embed `rb_args_info` in `rb_node_args_t`Nobuyoshi Nakada2023-10-301-2/+2
|
* [PRISM] ScopeNode doesn't need void * anymoreJemma Issroff2023-10-251-1/+1
|
* [PRISM] Move scope_node itself to CRuby, create prism_compile.hJemma Issroff2023-10-251-1/+1
|
* Expand OP_ASGN1 nd_args to nd_index and nd_rvalueyui-knk2023-10-201-4/+4
| | | | | | 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.
* Extract a local variableNobuyoshi Nakada2023-10-191-12/+13
|
* Address PR commentsJemma Issroff2023-10-181-3/+3
|
* Remove pm_compile_context_t, move the context onto ScopeNodeJemma Issroff2023-10-181-15/+4
| | | | | | | 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.
* YJIT: Add a live ISeq counter Alan Wu2023-10-181-0/+6
| | | | | | | 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>
* Remove unnecessary and misleading castsNobuyoshi Nakada2023-10-181-3/+3
|
* Adjust indent [ci skip]Nobuyoshi Nakada2023-10-111-77/+77
|
* Extract NODE_FL_NEWLINE access to macroyui-knk2023-10-111-1/+1
|
* Fix cast node typeyui-knk2023-10-091-1/+1
|
* Correctly casting node for accessing nd_value and nd_vid in compile.cyui-knk2023-10-071-3/+34
|
* Remove not used fields from MATCH3yui-knk2023-10-061-1/+1
|
* Remove `NODE_VALUES`Nobuyoshi Nakada2023-10-061-12/+0
| | | | | | 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.
* Correctly casting node for accessing COLON node nd_mid in compile.cyui-knk2023-10-051-14/+27
|
* Check the result of get_nd_recv before node type check for safetyYuichiro Kaneko2023-10-021-3/+3
| | | Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
* Correctly casting node for accessing nd_recv, nd_mid and nd_args in compile.cyui-knk2023-10-021-29/+96
|
* Use reference counting to avoid memory leak in kwargsHParker2023-10-011-0/+4
| | | | | | | | Tracks other callinfo that references the same kwargs and frees them when all references are cleared. [bug #19906] Co-authored-by: Peter Zhu <peter@peterzhu.ca>
* Use rb_node_args_t and rb_node_args_aux_t instead of NODEyui-knk2023-10-011-2/+2
|
* Use rb_node_opt_arg_t and rb_node_kw_arg_t instead of NODEyui-knk2023-10-011-9/+9
|
* Expand pattern_info struct into ARYPTN Node and FNDPTN Nodeyui-knk2023-09-301-19/+17
|
* Remove not used fields from argument nodesyui-knk2023-09-301-2/+0
|
* Merge RNode_OP_ASGN2 and RNode_OP_ASGN22yui-knk2023-09-291-3/+3
|
* Move CRuby-specific prism files to top levelKevin Newton2023-09-281-1/+1
|
* Change RNode structure from union to structyui-knk2023-09-281-456/+462
| | | | | | | | | | | | | | | | | | | | | | | All kind of AST nodes use same struct RNode, which has u1, u2, u3 union members for holding different kind of data. This has two problems. 1. Low flexibility of data structure Some nodes, for example NODE_TRUE, don’t use u1, u2, u3. On the other hand, NODE_OP_ASGN2 needs more than three union members. However they use same structure definition, need to allocate three union members for NODE_TRUE and need to separate NODE_OP_ASGN2 into another node. This change removes the restriction so make it possible to change data structure by each node type. 2. No compile time check for union member access It’s developer’s responsibility for using correct member for each node type when it’s union. This change clarifies which node has which type of fields and enables compile time check. This commit also changes node_buffer_elem_struct buf management to handle different size data with alignment.
* Use new constant pool layout for prismKevin Newton2023-09-271-6/+3
|
* Rename YARP symbols to prismKevin Newton2023-09-271-11/+11
|
* Don't call malloc with 0Aaron Patterson2023-09-141-3/+14
| | | | | | | | | | It seems not-uncommon for methods to have no IV, ISE, or ICVARC caches. Calling malloc with 0 will actually allocate something, so if there aren't any caches (`ISEQ_IS_SIZE(body) == 0`), then we can avoid allocating memory by not calling malloc. If there are no caches, then theoretically nobody should be reading from the buffer anyway. This saves about 1MB on Lobsters benchmark.