summaryrefslogtreecommitdiff
path: root/iseq.c
Commit message (Collapse)AuthorAgeFilesLines
* Move `catch_except_p` to `compile_data`eileencodes2023-04-111-1/+0
| | | | | | | | | | | | | | The `catch_except_p` flag is used for communicating between parent and child iseq's that a throw instruction was emitted. So for example if a child iseq has a throw in it and the parent wants to catch the throw, we use this flag to communicate to the parent iseq that a throw instruction was emitted. This flag is only useful at compile time, it only impacts the compilation process so it seems to be fine to move it from the iseq body to the compile_data struct. Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
* Remove unused VM_CALL_BLOCKISEQ flagTakashi Kokubun2023-04-011-1/+0
|
* `vm_call_single_noarg_inline_builtin`Koichi Sasada2023-03-231-8/+47
| | | | | | | | If the iseq only contains `opt_invokebuiltin_delegate_leave` insn and the builtin-function (bf) is inline-able, the caller doesn't need to build a method frame. `vm_call_single_noarg_inline_builtin` is fast path for such cases.
* Remove obsoleted functions in rjit.cTakashi Kokubun2023-03-071-1/+1
|
* s/mjit/rjit/Takashi Kokubun2023-03-061-4/+4
|
* s/MJIT/RJIT/Takashi Kokubun2023-03-061-3/+3
|
* Stop exporting symbols for MJITTakashi Kokubun2023-03-061-1/+1
|
* Store MJIT blocks on each ISEQTakashi Kokubun2023-03-051-2/+2
|
* Invalidate everything on GC.compactTakashi Kokubun2023-03-051-1/+1
|
* Fix spelling (#7389)John Bampton2023-02-271-1/+1
|
* Merge gc.h and internal/gc.hMatt Valentine-House2023-02-091-1/+1
| | | | [Feature #19425]
* Rename iseq_mark_and_update to iseq_mark_and_movePeter Zhu2023-02-081-2/+2
| | | | The new name is more consistent.
* Pass through `line_offset` argument correctly (but it was always 0). (#7177)Samuel Williams2023-01-271-1/+1
|
* Ensure main file has default coverage if required. (#7169)Samuel Williams2023-01-221-2/+11
| | | * Extract common code for coverage setup.
* Make all of the references of iseq movablePeter Zhu2023-01-201-20/+15
|
* Combine code paths for marking ccPeter Zhu2023-01-191-7/+19
| | | | | This commit avoids a separate code path for marking and moving the callcache of the iseq.
* Add rb_gc_mark_and_move and implement on iseqPeter Zhu2023-01-191-161/+72
| | | | | | | | | | This commit adds rb_gc_mark_and_move which takes a pointer to an object and marks it during marking phase and updates references during compaction. This allows for marking and reference updating to be combined into a single function, which reduces code duplication and prevents bugs if marking and reference updating goes out of sync. This commit also implements rb_gc_mark_and_move on iseq as an example.
* ci in iseq can only be object or nullPeter Zhu2023-01-191-2/+2
| | | | | It looks like rb_callinfo in iseq can only be either a Ruby object or null, since it cannot be allocated on the stack.
* Set max_iv_count (used for object shapes) based on inline cachesJemma Issroff2022-12-061-19/+6
| | | | | | | | | | | | | | | | With this change, we're storing the iv name on an inline cache on setinstancevariable instructions. This allows us to check the inline cache to count instance variables set in initialize and give us an estimate of iv capacity for an object. For the purpose of estimating the number of instance variables required for an object, we're assuming that all initialize methods will call `super`. This change allows us to estimate the number of instance variables required without disassembling instruction sequences. Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
* Fix crash when RGENGC_CHECK_MODE=2Peter Zhu2022-12-041-8/+10
| | | | | | Commit dba61f4 fixes a crash when GC'ing a iseq that failed to compile. However, if we turn on RGENGC_CHECK_MODE then rb_iseq_memsize crashes since it cannot handle an iseq without is_entries.
* return early if there is no is_entries bufferAaron Patterson2022-12-031-0/+8
| | | | | | | | If there is a compilation error, is_entries may not be allocated, but ic_size could be greater than 0. If we don't have a buffer to iterate over, just return early. Otherwise GC could segv [Bug #19173]
* Use consistent style [ci skip]Nobuyoshi Nakada2022-12-021-1/+2
|
* Free the IV table after estimationAaron Patterson2022-11-221-0/+2
| | | | | We need to make sure the name table is freed otherwise we have a memory leak.
* Increment max_iv_count on class based on number of set_iv in initialize (#6788)Jemma Issroff2022-11-221-0/+39
| | | | | | We can loosely predict the number of ivar sets on a class based on the number of iv set instructions in the initialize method. This should give us a more accurate estimate to use for initial size pool allocation, which should in turn give us more cache hits.
* Using UNDEF_P macroS-H-GAMELINKS2022-11-161-2/+2
|
* push dummy frame for loading processKoichi Sasada2022-10-201-0/+6
| | | | | | | | | | | | | This patch pushes dummy frames when loading code for the profiling purpose. The following methods push a dummy frame: * `Kernel#require` * `Kernel#load` * `RubyVM::InstructionSequence.compile_file` * `RubyVM::InstructionSequence.load_from_binary` https://bugs.ruby-lang.org/issues/18559
* Revert "Revert "This commit implements the Object Shapes technique in CRuby.""Jemma Issroff2022-10-111-12/+2
| | | | This reverts commit 9a6803c90b817f70389cae10d60b50ad752da48f.
* Revert "This commit implements the Object Shapes technique in CRuby."Aaron Patterson2022-09-301-2/+12
| | | | This reverts commit 68bc9e2e97d12f80df0d113e284864e225f771c2.
* Add `eval: true/false` flag to `Coverage.setup`.Samuel Williams2022-09-291-3/+5
|
* This commit implements the Object Shapes technique in CRuby.Jemma Issroff2022-09-281-12/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Object Shapes is used for accessing instance variables and representing the "frozenness" of objects. Object instances have a "shape" and the shape represents some attributes of the object (currently which instance variables are set and the "frozenness"). Shapes form a tree data structure, and when a new instance variable is set on an object, that object "transitions" to a new shape in the shape tree. Each shape has an ID that is used for caching. The shape structure is independent of class, so objects of different types can have the same shape. For example: ```ruby class Foo def initialize # Starts with shape id 0 @a = 1 # transitions to shape id 1 @b = 1 # transitions to shape id 2 end end class Bar def initialize # Starts with shape id 0 @a = 1 # transitions to shape id 1 @b = 1 # transitions to shape id 2 end end foo = Foo.new # `foo` has shape id 2 bar = Bar.new # `bar` has shape id 2 ``` Both `foo` and `bar` instances have the same shape because they both set instance variables of the same name in the same order. This technique can help to improve inline cache hits as well as generate more efficient machine code in JIT compilers. This commit also adds some methods for debugging shapes on objects. See `RubyVM::Shape` for more details. For more context on Object Shapes, see [Feature: #18776] Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org> Co-Authored-By: Eileen M. Uchitelle <eileencodes@gmail.com> Co-Authored-By: John Hawthorn <john@hawthorn.email>
* Revert this until we can figure out WB issues or remove shapes from GCAaron Patterson2022-09-261-9/+7
| | | | | | | | | | Revert "* expand tabs. [ci skip]" This reverts commit 830b5b5c351c5c6efa5ad461ae4ec5085e5f0275. Revert "This commit implements the Object Shapes technique in CRuby." This reverts commit 9ddfd2ca004d1952be79cf1b84c52c79a55978f4.
* This commit implements the Object Shapes technique in CRuby.Jemma Issroff2022-09-261-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Object Shapes is used for accessing instance variables and representing the "frozenness" of objects. Object instances have a "shape" and the shape represents some attributes of the object (currently which instance variables are set and the "frozenness"). Shapes form a tree data structure, and when a new instance variable is set on an object, that object "transitions" to a new shape in the shape tree. Each shape has an ID that is used for caching. The shape structure is independent of class, so objects of different types can have the same shape. For example: ```ruby class Foo def initialize # Starts with shape id 0 @a = 1 # transitions to shape id 1 @b = 1 # transitions to shape id 2 end end class Bar def initialize # Starts with shape id 0 @a = 1 # transitions to shape id 1 @b = 1 # transitions to shape id 2 end end foo = Foo.new # `foo` has shape id 2 bar = Bar.new # `bar` has shape id 2 ``` Both `foo` and `bar` instances have the same shape because they both set instance variables of the same name in the same order. This technique can help to improve inline cache hits as well as generate more efficient machine code in JIT compilers. This commit also adds some methods for debugging shapes on objects. See `RubyVM::Shape` for more details. For more context on Object Shapes, see [Feature: #18776] Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org> Co-Authored-By: Eileen M. Uchitelle <eileencodes@gmail.com> Co-Authored-By: John Hawthorn <john@hawthorn.email>
* Rework vm_core to use `int first_lineno` struct member.Samuel Williams2022-09-261-3/+3
|
* Rework `first_lineno` to be `int`.Samuel Williams2022-09-261-16/+15
|
* Extract common code for coverage setup.Samuel Williams2022-09-251-13/+19
|
* Enable coverage for eval.Samuel Williams2022-09-221-1/+12
|
* Remove rb_iseq_eachJohn Hawthorn2022-09-011-33/+0
|
* New constant caching insn: opt_getconstant_pathJohn Hawthorn2022-09-011-77/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously YARV bytecode implemented constant caching by having a pair of instructions, opt_getinlinecache and opt_setinlinecache, wrapping a series of getconstant calls (with putobject providing supporting arguments). This commit replaces that pattern with a new instruction, opt_getconstant_path, handling both getting/setting the inline cache and fetching the constant on a cache miss. This is implemented by storing the full constant path as a null-terminated array of IDs inside of the IC structure. idNULL is used to signal an absolute constant reference. $ ./miniruby --dump=insns -e '::Foo::Bar::Baz' == disasm: #<ISeq:<main>@-e:1 (1,0)-(1,13)> (catch: FALSE) 0000 opt_getconstant_path <ic:0 ::Foo::Bar::Baz> ( 1)[Li] 0002 leave The motivation for this is that we had increasingly found the need to disassemble the instructions between the opt_getinlinecache and opt_setinlinecache in order to determine the constant we are fetching, or otherwise store metadata. This disassembly was done: * In opt_setinlinecache, to register the IC against the constant names it is using for granular invalidation. * In rb_iseq_free, to unregister the IC from the invalidation table. * In YJIT to find the position of a opt_getinlinecache instruction to invalidate it when the cache is populated * In YJIT to register the constant names being used for invalidation. With this change we no longe need disassemly for these (in fact rb_iseq_each is now unused), as the list of constant names being referenced is held in the IC. This should also make it possible to make more optimizations in the future. This may also reduce the size of iseqs, as previously each segment required 32 bytes (on 64-bit platforms) for each constant segment. This implementation only stores one ID per-segment. There should be no significant performance change between this and the previous implementation. Previously opt_getinlinecache was a "leaf" instruction, but it included a jump (almost always to a separate cache line). Now opt_getconstant_path is a non-leaf (it may raise/autoload/call const_missing) but it does not jump. These seem to even out.
* Convert catch_except_t to stdboolTakashi Kokubun2022-08-251-1/+1
| | | | | | | catch_excep_t is a field that exists for MJIT. In the process of rewriting MJIT in Ruby, I added API to convert 1/0 of _Bool to true/false, and it seemed confusing and hard to maintain if you don't use _Bool for *_p fields.
* Simplify around `USE_YJIT` macro (#6240)Nobuyoshi Nakada2022-08-151-3/+3
| | | | | | | | * Simplify around `USE_YJIT` macro - Use `USE_YJIT` macro only instead of `YJIT_BUILD`. - An intermediate macro `YJIT_SUPPORTED_P` is no longer used. * Bail out if YJIT is enabled on unsupported platforms
* Rename rb_ary_tmp_new to rb_ary_hidden_newPeter Zhu2022-07-261-2/+2
| | | | | | rb_ary_tmp_new suggests that the array is temporary in some way, but that's not true, it just creates an array that's hidden and not on the transient heap. This commit renames it to rb_ary_hidden_new.
* Add "rb_" prefixes to toplevel enum definitionsYusuke Endoh2022-07-221-10/+10
| | | | ... as per ko1's request.
* Expand tabs [ci skip]Takashi Kokubun2022-07-211-757/+757
| | | | [Misc #18891]
* Separate TS_IVC and TS_ICVARC in is_entries buffersJemma Issroff2022-07-181-4/+15
| | | | This allows us to treat cvar caches differently than ivar caches.
* Simplify BLSR codeNobuyoshi Nakada2022-07-081-1/+1
| | | | And suppress unary minus operator to unsigned type warnings by VC.
* Remove ISEQ_MARKABLE_ISEQ flagAaron Patterson2022-07-071-41/+41
| | | | | We don't need this flag anymore. We have all the info we need via the bitmap and the is_entries list.
* Use iseq bitmap when updating referencesAaron Patterson2022-06-291-88/+12
| | | | | This allows us to delete the disassembly code path for reference updating.
* Move function to `static inline` so we don't have leaked globalsAaron Patterson2022-06-291-20/+0
| | | | | This function shouldn't leak and is only needed during instruction assembly
* Fix ISeq dump / load in array casesAaron Patterson2022-06-291-2/+24
| | | | | | | | | | | We need to dump relative offsets for inline storage entries so that loading iseqs as an array works as well. This commit also has some minor refactoring to make computing relative ISE information easier. This should fix the iseq dump / load as array tests we're seeing fail in CI. Co-Authored-By: John Hawthorn <john@hawthorn.email>
* iseq.c: Use ntz_intptr for faster bitmap scanJean Boussier2022-06-251-16/+12
|