summaryrefslogtreecommitdiff
path: root/compile.c
AgeCommit message (Collapse)Author
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
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 <nobu@ruby-lang.org>
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 <peter@peterzhu.ca>
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
2023-09-30Remove not used fields from argument nodesyui-knk
2023-09-29Merge RNode_OP_ASGN2 and RNode_OP_ASGN22yui-knk
2023-09-28Move CRuby-specific prism files to top levelKevin Newton
2023-09-28Change RNode structure from union to structyui-knk
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.
2023-09-27Use new constant pool layout for prismKevin Newton
2023-09-27Rename YARP symbols to prismKevin Newton
2023-09-14Don't call malloc with 0Aaron Patterson
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. Notes: Merged: https://github.com/ruby/ruby/pull/8442
2023-09-13[Bug #19862] Skip compiled result of never reachable expressionNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/8381
2023-09-10Refactor to use same logic with other assignment nodesyui-knk
Notes: Merged: https://github.com/ruby/ruby/pull/8400
2023-09-06Fix missing write barrier in iseq instruction listPeter Zhu
There's a missing write barrier for operands in the iseq instruction list, which can cause crashes. It can be reproduced when Ruby is compiled with `-DRUBY_DEBUG_ENV=1`. Using the following command: ``` RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=0 RUBY_DEBUG=gc_stress ruby -w --disable=gems -Itool/lib -W0 test.rb ``` The following script crashes: ``` require "test/unit" ``` Notes: Merged: https://github.com/ruby/ruby/pull/8385
2023-09-04Revert "Don't reset line coverage for evaled code. (#8330)"Yusuke Endoh
This reverts commit 7e0f5df2f99693267d61636d23da47f79924e9d5. https://bugs.ruby-lang.org/issues/19857#note-7
2023-09-04Don't reset line coverage for evaled code. (#8330)Samuel Williams
* Add failing test. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-08-30Update YARP APIs to handle uint8_tKevin Newton
2023-08-29[YARP] Compile basic types (#8311)Jemma Issroff
* Add a compile_context arg to yp_compile_node The compile_context will allow us to pass around the parser, and the constants and lookup table (to be used in future commits). * Compile yp_program_node_t and yp_statements_node_t Add the compilation for program and statements node so that we can successfully compile an empty program with YARP. * Helper functions for parsing numbers, strings, and symbols * Compile basic numeric / boolean node types in YARP * Compile StringNode and SymbolNodes in YARP * Compile several basic node types in YARP * Added error return for missing node Notes: Merged-By: jemmaissroff
2023-08-28Add yarp/yarp_compiler.c (#8042)Jemma Issroff
* Add yarp/yarp_compiler.c as stencil for compiling YARP This commit adds yarp/yarp_compiler.c, and changes the sync script to ensure that yarp/yarp_compiler.c will not get overwritten * [Misc #119772] Create and expose RubyVM::InstructionSequence.compile_yarp This commit creates the stencil for a compile_yarp function, which we will continue to fill out. It allows us to check the output of compiled YARP code against compiled code without using YARP. Notes: Merged-By: jemmaissroff
2023-08-23Remove nd_entry from NODE_GASGN and NODE_GVARyui-knk
After a0f12a0258e4020bd657ee80b7d8f22bd33ea223 NODE_GASGN and NODE_GVAR hold same value on both nd_vid and nd_entry. This commit stops setting value to nd_entry and makes to use only nd_vid. Notes: Merged: https://github.com/ruby/ruby/pull/8261
2023-08-16Move the PC regardless of the leaf flag (#8232)Takashi Kokubun
Co-authored-by: Alan Wu <alansi.xingwu@shopify.com> Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2023-08-01support `rescue` event for TracePointKoichi Sasada
fix [Feature #19572] Notes: Merged: https://github.com/ruby/ruby/pull/8150
2023-07-27Clean up OPT_STACK_CACHING (#8132)Takashi Kokubun
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2023-07-13Remove RARRAY_CONST_PTR_TRANSIENTPeter Zhu
RARRAY_CONST_PTR now does the same things as RARRAY_CONST_PTR_TRANSIENT. Notes: Merged: https://github.com/ruby/ruby/pull/8071
2023-06-30Compile code for lazy ISeq loding alwaysNobuyoshi Nakada
2023-06-17Replace parser & node compile_option from Hash to bit fieldyui-knk
This commit reduces dependency to CRuby object. Notes: Merged: https://github.com/ruby/ruby/pull/7950
2023-05-24Rename `rb_node_name` to the original nameyui-knk
98637d421dbe8bcf86cc2effae5e26bb96a6a4da changes the name of the function. However this function is exported as global, then change the name to origin one for keeping compatibility. Notes: Merged: https://github.com/ruby/ruby/pull/7852
2023-05-23Move `ruby_node_name` to node.c and rename prefix of the functionyui-knk
Notes: Merged: https://github.com/ruby/ruby/pull/7844
2023-04-27[Bug #19611] Remove never-reachable branch in logical expressionNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/7754
2023-04-19Adjust indent [ci skip]Nobuyoshi Nakada
2023-04-19* expand tabs. [ci skip]git
Please consider using misc/expand_tabs.rb as a pre-commit hook.
2023-04-18Emit special instruction for array literal + .(hash|min|max)Aaron Patterson
This commit introduces a new instruction `opt_newarray_send` which is used when there is an array literal followed by either the `hash`, `min`, or `max` method. ``` [a, b, c].hash ``` Will emit an `opt_newarray_send` instruction. This instruction falls back to a method call if the "interested" method has been monkey patched. Here are some examples of the instructions generated: ``` $ ./miniruby --dump=insns -e '[@a, @b].max' == disasm: #<ISeq:<main>@-e:1 (1,0)-(1,12)> (catch: FALSE) 0000 getinstancevariable :@a, <is:0> ( 1)[Li] 0003 getinstancevariable :@b, <is:1> 0006 opt_newarray_send 2, :max 0009 leave $ ./miniruby --dump=insns -e '[@a, @b].min' == disasm: #<ISeq:<main>@-e:1 (1,0)-(1,12)> (catch: FALSE) 0000 getinstancevariable :@a, <is:0> ( 1)[Li] 0003 getinstancevariable :@b, <is:1> 0006 opt_newarray_send 2, :min 0009 leave $ ./miniruby --dump=insns -e '[@a, @b].hash' == disasm: #<ISeq:<main>@-e:1 (1,0)-(1,13)> (catch: FALSE) 0000 getinstancevariable :@a, <is:0> ( 1)[Li] 0003 getinstancevariable :@b, <is:1> 0006 opt_newarray_send 2, :hash 0009 leave ``` [Feature #18897] [ruby-core:109147] Co-authored-by: John Hawthorn <jhawthorn@github.com> Notes: Merged: https://github.com/ruby/ruby/pull/6090