Граф коммитов

89 Коммитов

Автор SHA1 Сообщение Дата
Jean Boussier e3afc212ec shape.h: Make attr_index_t uint8_t
Given `SHAPE_MAX_NUM_IVS 80`, we transition to TOO_COMPLEX
way before we could overflow a 8bit counter.

This reduce the size of `rb_shape_t` from 32B to 24B.

If we decide to raise `SHAPE_MAX_NUM_IVS` we can always increase
that type again.
2023-10-11 08:33:09 +02:00
Jean Boussier 5cc44f48c5 Refactor rb_shape_transition_shape_capa to not accept capacity
This way the groth factor is encapsulated, which allows
rb_shape_transition_shape_capa to be smarter about ideal sizes.
2023-10-10 14:47:54 +02:00
HParker c74dc8b4af Use reference counting to avoid memory leak in kwargs
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-01 10:55:19 -04:00
Adam Hess 8b236e0c66 [Bug #19896]
fix memory leak in vm_method

This introduces a unified reference_count to clarify who is referencing a method.
This also allows us to treat the refinement method as the def owner since it counts itself as a reference

Co-authored-by: Peter Zhu <peter@peterzhu.ca>
2023-09-22 09:44:58 -04:00
Takashi Kokubun cd8d20cd1f
YJIT: Compile exception handlers (#8171)
Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
2023-08-08 16:06:22 -07:00
Alan Wu f302e725e1
Remove __bp__ and speed-up bmethod calls (#8060)
Remove rb_control_frame_t::__bp__ and optimize bmethod calls

This commit removes the __bp__ field from rb_control_frame_t. It was
introduced to help MJIT, but since MJIT was replaced by RJIT, we can use
vm_base_ptr() to compute it from the SP of the previous control frame
instead. Removing the field avoids needing to set it up when pushing new
frames.

Simply removing __bp__ would cause crashes since RJIT and YJIT used a
slightly different stack layout for bmethod calls than the interpreter.
At the moment of the call, the two layouts looked as follows:

                   ┌────────────┐    ┌────────────┐
                   │ frame_base │    │ frame_base │
                   ├────────────┤    ├────────────┤
                   │    ...     │    │    ...     │
                   ├────────────┤    ├────────────┤
                   │    args    │    │    args    │
                   ├────────────┤    └────────────┘<─prev_frame_sp
                   │  receiver  │
    prev_frame_sp─>└────────────┘
                     RJIT & YJIT      interpreter

Essentially, vm_base_ptr() needs to compute the address to frame_base
given prev_frame_sp in the diagrams. The presence of the receiver
created an off-by-one situation.

Make the interpreter use the layout the JITs use for iseq-to-iseq
bmethod calls. Doing so removes unnecessary argument shifting and
vm_exec_core() re-entry from the interpreter, yielding a speed
improvement visible through `benchmark/vm_defined_method.yml`:

     patched:   7578743.1 i/s
      master:   4796596.3 i/s - 1.58x  slower

C-to-iseq bmethod calls now store one more VALUE than before, but that
should have negligible impact on overall performance.

Note that re-entering vm_exec_core() used to be necessary for firing
TracePoint events, but that's no longer the case since
9121e57a5f.

Closes ruby/ruby#6428
2023-07-17 13:57:58 -04:00
Aaron Patterson 7ce6bcaf8b Expose rb_hash_resurrect
This is for implementing the `duphash` instruction
2023-06-23 11:46:21 -07:00
Peter Zhu 7577c101ed
Unify length field for embedded and heap strings (#7908)
* Unify length field for embedded and heap strings

The length field is of the same type and position in RString for both
embedded and heap allocated strings, so we can unify it.

* Remove RSTRING_EMBED_LEN
2023-06-06 10:19:20 -04:00
Aaron Patterson bdffcd6df3 Update RJIT to support newarray_send
This also adds max / hash support
2023-04-18 17:16:22 -07:00
eileencodes ce99e50ede Move `catch_except_p` to `compile_data`
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>
2023-04-11 10:47:58 -07:00
Aaron Patterson a9bfb64153 Expose rb_sym_to_proc via RJIT
This is needed for getblockparamproxy
2023-04-07 09:49:15 -07:00
Peter Zhu 1da2e7fca3
[Feature #19579] Remove !USE_RVARGC code (#7655)
Remove !USE_RVARGC code

[Feature #19579]

The Variable Width Allocation feature was turned on by default in Ruby
3.2. Since then, we haven't received bug reports or backports to the
non-Variable Width Allocation code paths, so we assume that nobody is
using it. We also don't plan on maintaining the non-Variable Width
Allocation code, so we are going to remove it.
2023-04-04 17:30:06 -04:00
Takashi Kokubun 19506650ef RJIT: Add --rjit-verify-ctx option 2023-04-04 00:35:29 -07:00
Takashi Kokubun d546f8c518 RJIT: Store type information in Context 2023-04-02 22:32:16 -07:00
Takashi Kokubun 6002b12611 RJIT: Support entry with different PCs 2023-04-02 15:27:40 -07:00
Takashi Kokubun 4fc336127e RJIT: Support has_opt ISEQs 2023-04-02 14:47:23 -07:00
Takashi Kokubun 66f8efc342 RJIT: Simplify cfunc implementation 2023-04-02 13:58:39 -07:00
Takashi Kokubun bf7587748d RJIT: Simplify invokesuper implementation 2023-04-02 11:42:16 -07:00
Takashi Kokubun 5cc644b147 RJIT: Group blockarg exit reasons 2023-04-02 11:01:23 -07:00
Takashi Kokubun cd1cd8030c RJIT: Support splat args 2023-04-02 10:55:03 -07:00
Takashi Kokubun 62188c8584 RJIT: Update exit reasons 2023-04-02 10:27:17 -07:00
Takashi Kokubun 1b475fcd10 Remove an unneeded function copy 2023-04-01 23:09:05 -07:00
Takashi Kokubun a077b7e36b RJIT: Support rest args 2023-04-01 23:00:36 -07:00
Takashi Kokubun bf2617b8a6 RJIT: Fix has_rest exit conditions 2023-04-01 21:47:28 -07:00
Takashi Kokubun 249fe18e8f RJIT: Remove unused counters 2023-04-01 17:24:45 -07:00
Takashi Kokubun 0973b93e49 RJIT: Start moving away from VM-like ISEQ handling 2023-04-01 16:56:05 -07:00
Takashi Kokubun 3352e76441 RJIT: Implement leaf builtin call 2023-03-26 19:25:17 -07:00
Takashi Kokubun dc270fc632 RJIT: Implement attr_writer 2023-03-26 18:02:25 -07:00
Takashi Kokubun ddb77dd11e RJIT: Put a guard for splat w/ var-arg cfunc 2023-03-25 22:14:07 -07:00
Takashi Kokubun 9bc2dbd33c RJIT: Support optional params on splat 2023-03-25 01:17:05 -07:00
Takashi Kokubun 85a55d3e75 RJIT: Remove send_iseq_complex_splat exit 2023-03-25 00:59:47 -07:00
Takashi Kokubun 1dd65f7c55 RJIT: Initial support of splat 2023-03-25 00:31:11 -07:00
Koichi Sasada c9fd81b860 `vm_call_single_noarg_inline_builtin`
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.
2023-03-23 14:03:12 +09:00
Takashi Kokubun cb45809454 RJIT: Update binding 2023-03-21 22:28:39 -07:00
Takashi Kokubun 38946209a7 RJIT: Split has_rest_or_post exit reasons 2023-03-21 22:01:55 -07:00
Takashi Kokubun c44367265d RJIT: Fix invokesuper 2023-03-21 00:10:14 -07:00
Takashi Kokubun 70ea58bd5b RJIT: Break up RJIT send_iseq_complex exit reasons 2023-03-19 23:58:14 -07:00
Takashi Kokubun 59b86da82c RJIT: Implement ifunc invokeblock 2023-03-19 23:32:07 -07:00
Takashi Kokubun e3dc25acae RJIT: Fix ISeq invokeblock 2023-03-19 21:52:25 -07:00
Takashi Kokubun 2d8ecfcc9a RJIT: Implement invokeblock with ISeq 2023-03-19 20:56:37 -07:00
Takashi Kokubun 83ad1cac81 RJIT: Optimize Kernel#respond_to? 2023-03-19 14:04:58 -07:00
Takashi Kokubun cd5a8d0160 RJIT: Optimize String#+@ 2023-03-19 13:36:26 -07:00
Takashi Kokubun 2121282753 RJIT: Optimize String#<< 2023-03-19 13:25:41 -07:00
Takashi Kokubun 9654a28cc5 RJIT: Drop duplicated obj_is_kind_of 2023-03-19 00:06:03 -07:00
Takashi Kokubun c4e2718763 RJIT: Workaround USE_RVARGC=0 CI 2023-03-18 23:42:58 -07:00
Takashi Kokubun 32e0c97dfa RJIT: Optimize String#bytesize 2023-03-18 23:35:42 -07:00
Takashi Kokubun 106cca5111 RJIT: Optimize String#empty? 2023-03-18 23:24:57 -07:00
Takashi Kokubun ca9355e173 RJIT: Optimize Kernel#instance_of? 2023-03-18 23:13:25 -07:00
Takashi Kokubun 824cf88969 RJIT: Optimize Kernel#is_a? 2023-03-18 22:59:46 -07:00
Takashi Kokubun cc9330f8c0 RJIT: Reorder opt_case_dispatch branches 2023-03-18 22:32:27 -07:00