summaryrefslogtreecommitdiff
path: root/object.c
AgeCommit message (Collapse)Author
2020-07-13inline Primitive.cexpr!卜部昌平
We can obtain the verbatim source code of Primitive.cexpr!. Why not paste that content into the JITed program. Notes: Merged: https://github.com/ruby/ruby/pull/3305
2020-07-03Make Kernel#then, #yield_self, #frozen? builtin (#3283)Takashi Kokubun
* Make Kernel#then, #yield_self, #frozen? builtin * Fix test_jit Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2020-07-03Rewrite Kernel#tap with Ruby (#3281)Takashi Kokubun
* Rewrite Kernel#tap with Ruby This was good for VM too, but of course my intention is to unblock JIT's inlining of a block over yield (inlining invokeyield has not been committed though). * Fix test_settracefunc About the :tap deletions, the :tap events are actually traced (we already have a TracePoint test for builtin methods), but it's filtered out by tp.path == "xyzzy" (it became "<internal:kernel>"). We could trace tp.path == "<internal:kernel>" cases too, but the lineno is impacted by kernel.rb changes and I didn't want to make it fragile for kernel.rb lineno changes. Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2020-06-29add UNREACHABLE_RETURN卜部昌平
Not every compilers understand that rb_raise does not return. When a function does not end with a return statement, such compilers can issue warnings. We would better tell them about reachabilities. Notes: Merged: https://github.com/ruby/ruby/pull/3247
2020-06-29rb_cstr_to_dbl_raise: do not goto into a branch卜部昌平
I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor. Notes: Merged: https://github.com/ruby/ruby/pull/3247
2020-06-29rb_convert_to_integer: do not goto into a branch卜部昌平
I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor. Notes: Merged: https://github.com/ruby/ruby/pull/3247
2020-06-29rb_mod_const_location: do not goto into a branch卜部昌平
I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor. Notes: Merged: https://github.com/ruby/ruby/pull/3247
2020-06-29rb_mod_const_defined: do not goto into a branch卜部昌平
I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor. Notes: Merged: https://github.com/ruby/ruby/pull/3247
2020-06-29rb_mod_const_get: do not goto into a branch卜部昌平
I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor. Notes: Merged: https://github.com/ruby/ruby/pull/3247
2020-06-29class_or_module_required: do not goto into a branch卜部昌平
I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor. Notes: Merged: https://github.com/ruby/ruby/pull/3247
2020-06-23Annotate Kernel#class as inline (#3250)Takashi Kokubun
``` $ benchmark-driver -v --rbenv 'before;after;before --jit;after --jit' benchmark/mjit_class.yml --repeat-count=4 before: ruby 2.8.0dev (2020-06-23T07:09:54Z master 37a2e48d76) [x86_64-linux] after: ruby 2.8.0dev (2020-06-23T17:29:56Z inline-class 0ff147c007) [x86_64-linux] before --jit: ruby 2.8.0dev (2020-06-23T07:09:54Z master 37a2e48d76) +JIT [x86_64-linux] after --jit: ruby 2.8.0dev (2020-06-23T17:29:56Z inline-class 0ff147c007) +JIT [x86_64-linux] Calculating ------------------------------------- before after before --jit after --jit mjit_class(self) 39.219M 40.060M 53.502M 69.202M i/s - 40.000M times in 1.019915s 0.998495s 0.747631s 0.578021s mjit_class(1) 39.567M 41.242M 52.100M 68.895M i/s - 40.000M times in 1.010935s 0.969885s 0.767749s 0.580591s Comparison: mjit_class(self) after --jit: 69201690.7 i/s before --jit: 53502336.4 i/s - 1.29x slower after: 40060289.1 i/s - 1.73x slower before: 39218939.2 i/s - 1.76x slower mjit_class(1) after --jit: 68895358.6 i/s before --jit: 52100353.0 i/s - 1.32x slower after: 41241993.6 i/s - 1.67x slower before: 39567314.0 i/s - 1.74x slower ``` Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2020-06-10Fix a typo in instance_variable_set documentationJean byroot Boussier
Notes: Merged: https://github.com/ruby/ruby/pull/3207
2020-06-10Change language used in instance_variable_set documentation [ci skip]Jeremy Evans
This uses less harsh language recommended by duerst. Fixes [Misc #15265] Fixes [Misc #15748]
2020-05-11sed -i 's|ruby/impl|ruby/internal|'卜部昌平
To fix build failures. Notes: Merged: https://github.com/ruby/ruby/pull/3079
2020-05-11sed -i s|ruby/3|ruby/impl|g卜部昌平
This shall fix compile errors. Notes: Merged: https://github.com/ruby/ruby/pull/3079
2020-05-08Classes made from Struct should have default `new` singleton method.Marc-Andre Lafortune
[Bug #16465] [Bug #16801] [Fix GH-2795] [Fix GH-2944] [Fix GH-3045] [Fix GH-3093] Note: Backporting shouldn't modify object.h and instead can use struct_new_kw which is basically a duplicate implementation of rb_class_new_instance_pass_kw Co-authored-by: Yusuke Endoh <mame@ruby-lang.org> Co-authored-by: John Hawthorn <john@hawthorn.email> Co-authored-by: Adam Hess <HParker@github.com> Co-authored-by: Jose Cortinas <jacortinas@gmail.com> Co-authored-by: Jean Boussier <jean.boussier@gmail.com> Notes: Merged: https://github.com/ruby/ruby/pull/3093
2020-05-07Share logically equivalent functionsNobuyoshi Nakada
2020-05-06[DOC] Removed no longer meaningful part [ci skip]Nobuyoshi Nakada
As now `Object#===` document is separated from `rb_equal`, this note no longer makes sense.
2020-05-06Removed unnecessary duplicate codeNobuyoshi Nakada
`rb_equal` may be inlined in `case_equal` and actually same code is generated twice.
2020-05-06Generalize the explanation of the side effect of the rb_equal() optimizationBenoit Daloze
2020-05-06Document rb_equal() and clarify the relation with Kernel#===Benoit Daloze
* Multiple times people have been confused and believed rb_equal() called #=== but it does not, it calls #==. * This optimization has a subtle side effect for Float::NAN, which is now documented.
2020-05-06Remove redundant check in rb_obj_cmp()Benoit Daloze
* rb_equal() already checks using `obj1 == obj2`.
2020-04-22support builtin for Kernel#FloatS.H
# Iteration per second (i/s) | |compare-ruby|built-ruby| |:------------|-----------:|---------:| |float | 30.395M| 38.314M| | | -| 1.26x| |float_true | 3.833M| 27.322M| | | -| 7.13x| |float_false | 4.182M| 24.938M| | | -| 5.96x| Notes: Merged: https://github.com/ruby/ruby/pull/3048 Merged-By: nobu <nobu@ruby-lang.org>
2020-04-17Removed NIL/TRUE/FALSENobuyoshi Nakada
Deprerecated constants which had been warned since 2.4.
2020-04-08Suppress -Wswitch warningsNobuyoshi Nakada
2020-04-08Merge pull request #2991 from shyouhei/ruby.h卜部昌平
Split ruby.h Notes: Merged-By: shyouhei <shyouhei@ruby-lang.org>
2020-03-22Support obj.clone(freeze: true) for freezing cloneJeremy Evans
This freezes the clone even if the receiver is not frozen. It is only for consistency with freeze: false not freezing the clone even if the receiver is frozen. Because Object#clone is now partially implemented in Ruby and not fully implemented in C, freeze: nil must be supported to provide the default behavior of only freezing the clone if the receiver is frozen. This requires modifying delegate and set, to set freeze: nil instead of freeze: true as the keyword parameter for initialize_clone. Those are the two libraries in stdlib that override initialize_clone. Implements [Feature #16175] Notes: Merged: https://github.com/ruby/ruby/pull/2969
2020-03-17Check if `freeze` option is givenNobuyoshi Nakada
2020-03-17support builtin for Kernel#cloneS.H
Notes: Merged: https://github.com/ruby/ruby/pull/2954 Merged-By: nobu <nobu@ruby-lang.org>
2020-03-12Pass keyword argument by RB_PASS_KEYWORDSNobuyoshi Nakada
To pass `false` as `freeze:` keyword argument, `kw_splat` argument should be true. Also `rb_keyword_given_p()` should return true here as `false` has been given as a keyword argument.
2020-01-24[DOC] fixed line numbers [ci skip]Nobuyoshi Nakada
Fix up the example of const_source_location at 2bde7919a0a8302c344e9bb9ddc217958fcbd3c7.
2020-01-23Clarify const_source_location docszverok
Notes: Merged: https://github.com/ruby/ruby/pull/2850
2020-01-23Added rb_warn_deprecated_to_removeNobuyoshi Nakada
Warn the deprecation and future removal, with obeying the warning flag.
2020-01-22Make taint warnings non-verbose instead of verboseJeremy Evans
Notes: Merged: https://github.com/ruby/ruby/pull/2856
2020-01-03Call initialize_clone with freeze: false if clone called with freeze: falseJeremy Evans
This makes it possible to initialize_clone to correctly not freeze internal state if the freeze: false keyword is passed to clone. If clone is called with freeze: true or no keyword, do not pass a second argument to initialize_clone to keep backwards compatibility. This makes it so that external libraries that override initialize_clone but do not support the freeze keyword will fail with ArgumentError if passing freeze: false to clone. I think that is better than the current behavior, which succeeds but results in an unfrozen object with frozen internals. Fix related issues in set and delegate in stdlib. Fixes [Bug #14266] Notes: Merged: https://github.com/ruby/ruby/pull/2816
2020-01-02Fully separate positional arguments and keyword argumentsJeremy Evans
This removes the warnings added in 2.7, and changes the behavior so that a final positional hash is not treated as keywords or vice-versa. To handle the arg_setup_block splat case correctly with keyword arguments, we need to check if we are taking a keyword hash. That case didn't have a test, but it affects real-world code, so add a test for it. This removes rb_empty_keyword_given_p() and related code, as that is not needed in Ruby 3. The empty keyword case is the same as the no keyword case in Ruby 3. This changes rb_scan_args to implement keyword argument separation for C functions when the : character is used. For backwards compatibility, it returns a duped hash. This is a bad idea for performance, but not duping the hash breaks at least Enumerator::ArithmeticSequence#inspect. Instead of having RB_PASS_CALLED_KEYWORDS be a number, simplify the code by just making it be rb_keyword_given_p(). Notes: Merged: https://github.com/ruby/ruby/pull/2794
2019-12-31Fix Object#inspect documentationJoao Fernandes
Starting from ruby 2.7.0, there's no longer a connection between the hexadecimal number that #inspect shows and the object's ID. Notes: Merged: https://github.com/ruby/ruby/pull/2797
2019-12-27Use the more popular word [ci skip]Nobuyoshi Nakada
[Bug #16437]
2019-12-26decouple internal.h headers卜部昌平
Saves comitters' daily life by avoid #include-ing everything from internal.h to make each file do so instead. This would significantly speed up incremental builds. We take the following inclusion order in this changeset: 1. "ruby/config.h", where _GNU_SOURCE is defined (must be the very first thing among everything). 2. RUBY_EXTCONF_H if any. 3. Standard C headers, sorted alphabetically. 4. Other system headers, maybe guarded by #ifdef 5. Everything else, sorted alphabetically. Exceptions are those win32-related headers, which tend not be self- containing (headers have inclusion order dependencies). Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-12-24`Object#=~` warning also obeys `Warning[:deprecated]`Nobuyoshi Nakada
2019-12-23Document Module#const_source_locationzverok
Notes: Merged: https://github.com/ruby/ruby/pull/2750
2019-11-18Deprecate taint/trust and related methods, and make the methods no-opsJeremy Evans
This removes the related tests, and puts the related specs behind version guards. This affects all code in lib, including some libraries that may want to support older versions of Ruby. Notes: Merged: https://github.com/ruby/ruby/pull/2476
2019-11-06Prohibit calling undefined allocator [Bug #16297]Nobuyoshi Nakada
2019-09-27[EXPERIMENTAL] Make NilClass#to_s, TrueClass#to_s and FalseClass#to_s return ↵Jean Boussier
a frozen String * Always the same frozen String for each of these values. * Avoids extra allocations whenever calling these 3 methods. * See [Feature #16150] Notes: Merged: https://github.com/ruby/ruby/pull/2492
2019-09-20Make passing empty keywords to dig pass empty keywords to next dig methodJeremy Evans
If defined in Ruby, dig would be defined as def dig(arg, *rest) end, it would not use keywords. If the last dig argument was an empty hash, it could be treated as keyword arguments by the next dig method. Allow dig to pass along the empty keyword flag if called with an empty keyword, to suppress the previous behavior and force treating the hash as a positional argument and not keywords. Also handle the case where dig calls method_missing, passing the empty keyword flag to that as well. This requires adding rb_check_funcall_with_hook_kw functions, so that dig can specify how arguments are treated. It also adds kw_splat arguments to a couple static functions.
2019-09-14Only set RB_PASS_CALLED_KEYWORDS in C functions called directly from RubyJeremy Evans
It is not safe to set this in C functions that can be called from other C functions, as in the non argument-delegation case, you can end up calling a Ruby method with a flag indicating keywords are set without passing keywords. Introduce some new *_kw functions that take a kw_splat flag and use these functions to set RB_PASS_CALLED_KEYWORDS in places where we know we are delegating methods (e.g. Class#new, Method#call)
2019-08-29drop-in type check for rb_define_private_method卜部昌平
We can check the function pointer passed to rb_define_private_method like how we do so in rb_define_method. Doing so revealed some problematic usages of rb_obj_dummy. They had to be split according to their arity.
2019-08-29move docs around [ci skip]卜部昌平
To properly generate documents.
2019-08-29drop-in type check for rb_define_global_function卜部昌平
We can check the function pointer passed to rb_define_global_function like we do so in rb_define_method. It turns out that almost anybody is misunderstanding the API.
2019-08-24Minor documentation fixes [ci skip]Jeremy Evans
From zverok (Victor Shepelev) Fixes [Misc #16126]