aboutsummaryrefslogtreecommitdiffstats
path: root/mjit_c.rb
Commit message (Collapse)AuthorAgeFilesLines
* Stop transitioning to UNDEF when undefining an instance variableAaron Patterson2022-12-071-4/+0
| | | | | | | | | | | | | | | | | | | | | | | Cases like this: ```ruby obj = Object.new loop do obj.instance_variable_set(:@foo, 1) obj.remove_instance_variable(:@foo) end ``` can cause us to use many more shapes than we want (and even run out). This commit changes the code such that when an instance variable is removed, we'll walk up the shape tree, find the shape, then rebuild any child nodes that happened to be below the "targetted for removal" IV. This also requires moving any instance variables so that indexes derived from the shape tree will work correctly. Co-Authored-By: Jemma Issroff <jemmaissroff@gmail.com> Co-authored-by: John Hawthorn <jhawthorn@github.com>
* Set max_iv_count (used for object shapes) based on inline cachesJemma Issroff2022-12-061-0/+1
| | | | | | | | | | | | | | | | 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>
* Improve packing of iseq_constant_body structJohn Hawthorn2022-12-011-2/+2
| | | | | | | | By moving the two bools into a packing gap above the mark_bits pointer/union we can save 8 bytes in the struct and avoid an extra cache line (328 bytes vs 320 bytes). Co-authored-by: Adam Hess <HParker@github.com>
* Introduce `Fiber#storage` for inheritable fiber-scoped variables. (#6612)Samuel Williams2022-12-011-0/+1
|
* Fix unused variable warningsTakashi Kokubun2022-11-291-10/+10
| | | | builtin seems to be not handling this correctly.
* MJIT: Move Primitive helpers to mjit_c.rbTakashi Kokubun2022-11-291-9/+35
|
* MJIT: Self-contain extern declarationsTakashi Kokubun2022-11-291-2/+8
| | | | I'm trying to get rid of mjit_compiler.c, and this helps that migration.
* MJIT: Refactor CDHASH handlingTakashi Kokubun2022-11-291-2/+2
| | | | | Converting a CDHASH into a safe Hash is a lot of work, but retrieving just values is much easier.
* MJIT: Merge exivar guards as wellTakashi Kokubun2022-11-281-1/+0
| | | | obviating status->merge_ivar_guards_p as refactoring
* MJIT: Remove an unused fieldTakashi Kokubun2022-11-281-1/+0
| | | | This has not been used since recent shape-related changes.
* MJIT: Get rid of is_entries copyTakashi Kokubun2022-11-281-11/+0
| | | | MJIT worker no longer exists, so we don't need this safeguard anymore.
* MJIT: Make it parsable by Solargraph (#6827)Takashi Kokubun2022-11-281-3/+1
| | | | | | | * Revert "Revert "MJIT: Make it parsable by Solargraph"" This reverts commit 8e18761da1932df88bfb6505acbda4740e1b2930. * Call rb_gc_register_mark_object
* Revert "MJIT: Make it parsable by Solargraph"Takashi Kokubun2022-11-281-1/+3
| | | | | | | | | | | This reverts commit ccd8dd6ad395bbd9f5290e0fcb7929e5e5d36767. Revert "MJIT: Fix miniruby with MJIT_FORCE_ENABLE" This reverts commit b033775ed9d9226ba73c1d4a197e55ba89575142. GitHub Actions is failing. I ran out of time today to investigate it. will try it again tomorrow.
* MJIT: Fix miniruby with MJIT_FORCE_ENABLETakashi Kokubun2022-11-271-1/+1
|
* MJIT: Make it parsable by SolargraphTakashi Kokubun2022-11-271-2/+0
|
* MJIT: Get rid of C.fprintfTakashi Kokubun2022-11-271-8/+0
| | | | Faster code generation and cleaner code.
* rename SHAPE_BITS to SHAPE_ID_NUM_BITSAaron Patterson2022-11-181-4/+4
|
* MJIT: Fix vm_cc_cme(cc).def.type to use bit fieldTakashi Kokubun2022-11-151-1/+1
| | | | | | | | | access properly. Because the libclang node had two children, it wasn't handled well by the pattern matching for the bit field case. In addition to that, this bit field has a non-1 width. Because we're returning true/false for a width-1 bit field, I added another behavior that works like a char value for bit fields with width 2-8.
* MJIT: Remove reference to ROBJECT_EMBED_LEN_MAXTakashi Kokubun2022-11-141-4/+0
| | | | maybe not used since some shape changes?
* Rename --mjit-min-calls to --mjit-call-threshold (#6731)Takashi Kokubun2022-11-141-1/+1
| | | for consistency with YJIT
* Remove USE_RVARGC codeAaron Patterson2022-11-141-4/+0
| | | | We don't need this constant to be exposed anymore, so remove it
* Import shape constants with mjit-bindgenTakashi Kokubun2022-11-141-34/+34
|
* Import class constants with mjit-bindgenTakashi Kokubun2022-11-141-7/+26
|
* Transition shape when object's capacity changesJemma Issroff2022-11-101-0/+26
| | | | | | | | | | | | | | | | This commit adds a `capacity` field to shapes, and adds shape transitions whenever an object's capacity changes. Objects which are allocated out of a bigger size pool will also make a transition from the root shape to the shape with the correct capacity for their size pool when they are allocated. This commit will allow us to remove numiv from objects completely, and will also mean we can guarantee that if two objects share shapes, their IVs are in the same positions (an embedded and extended object cannot share shapes). This will enable us to implement ivar sets in YJIT using object shapes. Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
* Remove iv_index_tbl_entryJohn Hawthorn2022-10-241-9/+0
|
* Rename `iv_count` on shapes to `next_iv_index`Jemma Issroff2022-10-211-1/+1
| | | | | | `iv_count` is a misleading name because when IVs are unset, the new shape doesn't decrement this value. `next_iv_count` is an accurate, and more descriptive name.
* Only expose Ruby Shape API if VM_CHECK_MODE is enabledAaron Patterson2022-10-131-2/+23
|
* Make inline cache reads / writes atomic with object shapesJemma Issroff2022-10-111-5/+6
| | | | | | | | | | | | | | Prior to this commit, we were reading and writing ivar index and shape ID in inline caches in two separate instructions when getting and setting ivars. This meant there was a race condition with ractors and these caches where one ractor could change a value in the cache while another was still reading from it. This commit instead reads and writes shape ID and ivar index to inline caches atomically so there is no longer a race condition. Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org> Co-Authored-By: John Hawthorn <john@hawthorn.email>
* Revert "Revert "This commit implements the Object Shapes technique in CRuby.""Jemma Issroff2022-10-111-5/+30
| | | | This reverts commit 9a6803c90b817f70389cae10d60b50ad752da48f.
* Revert "This commit implements the Object Shapes technique in CRuby."Aaron Patterson2022-09-301-30/+5
| | | | This reverts commit 68bc9e2e97d12f80df0d113e284864e225f771c2.
* This commit implements the Object Shapes technique in CRuby.Jemma Issroff2022-09-281-5/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-31/+6
| | | | | | | | | | 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-6/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-1/+6
|
* Skip struct fields whose output differsTakashi Kokubun2022-09-231-3/+0
| | | | across different environments
* Swap the positions of offsetof and typeTakashi Kokubun2022-09-231-203/+203
|
* Bindgen offsetof struct and union with builtinTakashi Kokubun2022-09-231-183/+183
| | | | | | | | except for bit fields. I made a risky assumption on leading bit fields and just gave up non-leading bit fields for now. I'll change it to let C code access bit fields later.
* Bindgen sizeof struct and union with builtinTakashi Kokubun2022-09-231-32/+32
|
* Bindgen immediate types with builtinTakashi Kokubun2022-09-231-55/+56
|
* Drop c_64 and c_32Takashi Kokubun2022-09-231-0/+539
|
* Bindgen enum with builtinTakashi Kokubun2022-09-231-4/+20
|
* Builtin needs to be baseruby-compatibleTakashi Kokubun2022-09-231-5/+15
|
* mjit_c.rb doesn't need to be an erbTakashi Kokubun2022-09-231-0/+137