summaryrefslogtreecommitdiff
path: root/proc.c
AgeCommit message (Collapse)Author
2023-03-06Stop exporting symbols for MJITTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/7459
2023-02-19[DOC] Improve Kernel#binding docszverok
* Add links to Binding class * Make examples practical * Extend possible usages description Notes: Merged: https://github.com/ruby/ruby/pull/7316
2023-02-15Encapsulate RCLASS_ATTACHED_OBJECTJean Boussier
Right now the attached object is stored as an instance variable and all the call sites that either get or set it have to know how it's stored. It's preferable to hide this implementation detail behind accessors so that it is easier to change how it's stored. Notes: Merged: https://github.com/ruby/ruby/pull/7308
2023-02-10use correct svar even if env is escapedKoichi Sasada
This patch is follo-up of 0a82bfe. Without this patch, if env is escaped (Proc'ed), strange svar can be touched. This patch tracks escaped env and use it. Notes: Merged: https://github.com/ruby/ruby/pull/7282
2023-02-09Merge gc.h and internal/gc.hMatt Valentine-House
[Feature #19425] Notes: Merged: https://github.com/ruby/ruby/pull/7273
2023-02-07Use rb_gc_mark_and_move for method objectsPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/7245
2023-02-07Use rb_gc_mark_and_move for proc and bindingPeter Zhu
Also makes VM_ENV_ENVVAL movable. Notes: Merged: https://github.com/ruby/ruby/pull/7245
2023-02-03Mark "method" objects as protected by write barrierJean Boussier
All its reference are set with RB_OBJ_WRITE, so they can be marked as WB protected. Notes: Merged: https://github.com/ruby/ruby/pull/7237
2023-02-01use correct svar (#7225)Koichi Sasada
* use correct svar Without this patch, svar location is used "nearest Ruby frame". It is almost correct but it doesn't correct when the `each` method is written in Ruby. ```ruby class C include Enumerable def each %w(bar baz).each{|e| yield e} end end C.new.grep(/(b.)/){|e| p [$1, e]} ``` This patch fix this issue by traversing ifunc's cfp. Note that if cfp doesn't specify this Thread's cfp stack, reserved svar location (`ec->root_svar`) is used. * make yjit-bindgen --------- Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com> Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2022-12-23Docs: Separate documentation for UnboundMethod#==zverok
Notes: Merged: https://github.com/ruby/ruby/pull/6985
2022-12-03UnboundMethod only refer defined_classKoichi Sasada
UnboundMethod records caller's class, like `D` or `E` on the following case: ```ruby class C def foo = :foo end class D < C end class E < C end d = D.instance_method(:foo) e = E.instance_method(:foo) ``` But `d` and `e` only refers `C#foo` so that UnboundMethod doesn't record `D` or `E`. This behavior changes the following methods: * `UnboundMethod#inspect` (doesn't show caller's class) * `UnboundMethod#==` (`d == e` for example) fix https://bugs.ruby-lang.org/issues/18798 Notes: Merged: https://github.com/ruby/ruby/pull/6855
2022-11-16Using UNDEF_P macroS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/6721
2022-11-04Use RTEST to to check return valuePeter Zhu
rb_obj_is_kind_of returns a Ruby Qtrue or Qfalse. We should use RTEST rather than assuming that Qfalse is 0.
2022-11-04Remove unnecessary branch in `UnboundMethod#bind`Alexander Momchilov
Co-authored-by: Michael Herold <michael.herold@shopify.com> Notes: Merged: https://github.com/ruby/ruby/pull/6670
2022-10-03Mark struct METHOD->owner for the GCBenoit Daloze
* Fixes https://github.com/ruby/ruby/commit/6b7d32a5e5 * See [Bug #18729]
2022-09-29Reduce diff to proc.c @ b0b9f7201acab05c2a3ad92c3043a1f01df3e17fBenoit Daloze
* So it's easy to review https://github.com/ruby/ruby/pull/6242 + https://github.com/ruby/ruby/pull/6467 and there are less changes overall.
2022-09-29Resolve zsuper method during lookup but preserve owner separatelyBenoit Daloze
* See https://bugs.ruby-lang.org/issues/18729#note-34 * See [Bug #18729] Notes: Merged: https://github.com/ruby/ruby/pull/6467
2022-09-29Fix {Method,UnboundMethod}#super_method for zsuper methodsBenoit Daloze
* We need to resolve the zsuper method first, and then look the super method of that. Notes: Merged: https://github.com/ruby/ruby/pull/6467
2022-09-26Rework vm_core to use `int first_lineno` struct member.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/6430
2022-09-25Reuse rb_method_call_kw functionS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/6429
2022-09-02Adjust styles [ci skip]Nobuyoshi Nakada
2022-08-20Consider resolved-through-zsuper methods equal for compatibilityBenoit Daloze
* Fixes https://bugs.ruby-lang.org/issues/18751 Notes: Merged: https://github.com/ruby/ruby/pull/6242
2022-08-20Make Object#method and Module#instance_method not skip ZSUPER methodsJeremy Evans
Based on https://github.com/jeremyevans/ruby/commit/c95e7e5329140f640b6497905485761f3336d967 Among other things, this fixes calling visibility methods (public?, protected?, and private?) on them. It also fixes #owner to show the class the zsuper method entry is defined in, instead of the original class it references. For some backwards compatibility, adjust #parameters and #source_location, to show the parameters and source location of the method originally defined. Also have the parameters and source location still be shown by #inspect. Clarify documentation of {Method,UnboundMethod}#owner. Add tests based on the description of https://bugs.ruby-lang.org/issues/18435 and based on https://github.com/ruby/ruby/pull/5356#issuecomment-1005298809 Fixes [Bug #18435] [Bug #18729] Co-authored-by: Benoit Daloze <eregontp@gmail.com> Notes: Merged: https://github.com/ruby/ruby/pull/6242
2022-08-15Do not clone method entries when bind_call is usedPenelope Phippen
I noticed that this site unconditionally clones the method entry, which means that `bind_call` always allocates a `T_IMEMO`. While this clone is necessary for `bind`, it is not necessary for `bind_call`. I work at Stripe, and the sorbet_runtime gem uses bind call as part of it's [call validation](https://github.com/sorbet/sorbet/blob/master/gems/sorbet-runtime/lib/types/private/methods/call_validation.rb#L157) so this can save us a lot of allocations. This patch adds a `clone` parameter to `convert_umethod_to_method_components`, which then controls whether or not we do this cloning. This patch passed Stripe CI and works in our QA environment. I reviewed it with @tenderlove to talk about correctness also. Notes: Merged: https://github.com/ruby/ruby/pull/6244
2022-08-10Revert "Add {Method,UnboundMethod}#{public?,private?,protected?}"Jeremy Evans
This reverts commit 27278150685e738f84105d09843d3ba371146c7a and 58dc8bf8f15df9a33d191074e8a5d4946a3d59d5. Visibility is an attribute of the method entry in a class, not an attribute of the Method object. Fixes [#18729] Fixes [#18751] Fixes [#18435] Notes: Merged: https://github.com/ruby/ruby/pull/5974
2022-07-26Rename rb_ary_tmp_new to rb_ary_hidden_newPeter Zhu
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. Notes: Merged: https://github.com/ruby/ruby/pull/6180
2022-07-21Expand tabs [ci skip]Takashi Kokubun
[Misc #18891] Notes: Merged: https://github.com/ruby/ruby/pull/6094
2022-04-24Reuse `rb_proc_arity`S.H
Notes: Merged: https://github.com/ruby/ruby/pull/5823 Merged-By: jeremyevans <code@jeremyevans.net>
2022-04-14[DOC] Move the documentations of moved Symbol methodsNobuyoshi Nakada
2022-04-06Fix a typo [ci skip]Kazuhiro NISHIYAMA
2022-03-29Make define_singleton_method always define a public methodJeremy Evans
In very unlikely cases, it could previously define a non-public method starting in Ruby 2.1. Fixes [Bug #18561] Notes: Merged: https://github.com/ruby/ruby/pull/5636
2022-03-24Add ISEQ_BODY macroPeter Zhu
Use ISEQ_BODY macro to get the rb_iseq_constant_body of the ISeq. Using this macro will make it easier for us to change the allocation strategy of rb_iseq_constant_body when using Variable Width Allocation. Notes: Merged: https://github.com/ruby/ruby/pull/5698
2022-03-17Encourage arity argument in Proc#curry documentation for procs with variable ↵Jeremy Evans
arguments This uses similar language to that used in Method#curry.
2022-03-17Make Proc#parameters support lambda keyword for returning parameters as if ↵Jeremy Evans
lambda This makes it easier to use Proc#parameters to build wrappers. Implements [Feature #15357] Notes: Merged: https://github.com/ruby/ruby/pull/5677
2022-02-08[DOC] Fix broken links to literals.rdocNobuyoshi Nakada
2022-01-14Fix {Method,UnboundMethod}#{public?,private?,protected?} for ZSUPER methodsJeremy Evans
Add a visibility member to struct METHOD storing the original method visibility, and use that, instead of taking the visibility from the stored method entry (which may have different visibility for ZSUPER methods). Consider Method/UnboundMethod objects different if they have different visibilities. Fixes [Bug #18435] Notes: Merged: https://github.com/ruby/ruby/pull/5356
2022-01-01Negative RBOOL usageNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5385
2021-12-30Add support for anonymous rest and keyword rest argument forwardingJeremy Evans
This allows for the following syntax: ```ruby def foo(*) bar(*) end def baz(**) quux(**) end ``` This is a natural addition after the introduction of anonymous block forwarding. Anonymous rest and keyword rest arguments were already supported in method parameters, this just allows them to be used as arguments to other methods. The same advantages of anonymous block forwarding apply to rest and keyword rest argument forwarding. This has some minor changes to #parameters output. Now, instead of `[:rest], [:keyrest]`, you get `[:rest, :*], [:keyrest, :**]`. These were already used for `...` forwarding, so I think it makes it more consistent to include them in other cases. If we want to use `[:rest], [:keyrest]` in both cases, that is also possible. I don't think the previous behavior of `[:rest], [:keyrest]` in the non-... case and `[:rest, :*], [:keyrest, :**]` in the ... case makes sense, but if we did want that behavior, we'll have to make more substantial changes, such as using a different ID in the ... forwarding case. Implements [Feature #18351] Notes: Merged: https://github.com/ruby/ruby/pull/5148
2021-12-21Fix typosKazuhiro NISHIYAMA
2021-12-13fix Struct's setter arityKoichi Sasada
https://github.com/ruby/ruby/pull/5131/files#diff-b2553d23e6b1fe76e20608d06c25f6acca06279100f1a9c24febcd79a82fac3cR2689 Notes: Merged: https://github.com/ruby/ruby/pull/5252
2021-12-13Struct setter's parameters == `[:req, :_]`Koichi Sasada
fix [Bug #18405] Note that the parameter name `_` is not a spec, so we shouldn't rely on this behavior. Notes: Merged: https://github.com/ruby/ruby/pull/5252
2021-12-13add `method_def_aritry()`Koichi Sasada
Notes: Merged: https://github.com/ruby/ruby/pull/5252
2021-12-09Add {Method,UnboundMethod}#{public?,private?,protected?}Jeremy Evans
These methods allow for checking whether the method has that visibility. Implements [Feature #11689] Notes: Merged: https://github.com/ruby/ruby/pull/5040
2021-12-03Adding links to literals and Kernel (#5192)Burdette Lamar
* Adding links to literals and Kernel Notes: Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
2021-11-19optimize `Struct` getter/setterKoichi Sasada
Introduce new optimized method type `OPTIMIZED_METHOD_TYPE_STRUCT_AREF/ASET` with index information. Notes: Merged: https://github.com/ruby/ruby/pull/5131
2021-11-19`rb_method_optimized_t` for further extensionKoichi Sasada
Now `rb_method_optimized_t optimized` field is added to represent optimized method type. Notes: Merged: https://github.com/ruby/ruby/pull/5131
2021-10-20Cleanup diff against upstream. Add commentsAlan Wu
I did a `git diff --stat` against upstream and looked at all the files that are outside of YJIT to come up with these minor changes.
2021-10-20Collect statistics about binding allocations / local variable setAaron Patterson
This commit collects statistics about how many binding objects are allocated as well as the number of local variables set on bindings. Statistics are output along with other YJIT stats. Here is an example of the output: ``` ***YJIT: Printing runtime counters from yjit.rb*** Number of Bindings Allocated: 195 Number of locals modified through binding: 0 opt_send_without_block exit reasons: ivar_get_method 7515891 (40.4%) se_cc_klass_differ 3081330 (16.6%) iseq_argc_mismatch 1564578 ( 8.4%) se_receiver_not_heap 1557663 ( 8.4%) ic_empty 1407064 ( 7.6%) optimized_method 995823 ( 5.4%) iseq_not_simple 819413 ( 4.4%) alias_method 706972 ( 3.8%) bmethod 685253 ( 3.7%) callsite_not_simple 225983 ( 1.2%) kw_splat 25999 ( 0.1%) ivar_set_method 902 ( 0.0%) cfunc_toomany_args 394 ( 0.0%) refined_method 42 ( 0.0%) cfunc_ruby_array_varg 29 ( 0.0%) invalid_cme 4 ( 0.0%) leave exit reasons: se_finish_frame 4067107 (100.0%) se_interrupt 24 ( 0.0%) getinstancevariable exit reasons: undef 121177 (100.0%) idx_out_of_range 5 ( 0.0%) opt_aref exit reasons: (all relevant counters are zero) compiled_iseq_count: 3944 main_block_code_size: 1.1 MiB side_block_code_size: 0.6 MiB vm_insns_count: 1137268516 yjit_exec_insns_count: 414015644 ratio_in_yjit: 26.7% avg_len_in_yjit: 7.5 total_exit_count: 55491789 most frequent exit op: opt_send_without_block: 18587628 (33.5%) opt_getinlinecache: 11075822 (20.0%) send: 4949300 (8.9%) leave: 4067131 (7.3%) defined: 3975196 (7.2%) setinstancevariable: 3567315 (6.4%) invokesuper: 2982163 (5.4%) getblockparamproxy: 2168852 (3.9%) opt_nil_p: 2104524 (3.8%) opt_aref: 2013858 (3.6%) ``` Running RailsBench allocates 195 binding objects but doesn't set any local variables.
2021-10-10Refactor rb_proc_call functionS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/4897
2021-09-01Assert not to be UNDEF visibilityNobuyoshi Nakada
Any defined methods, bound to any classes/modules and not being UNDEFINED_METHOD_ENTRY_P, should not be METHOD_VISI_UNDEF.