summaryrefslogtreecommitdiff
path: root/vm_eval.c
Commit message (Collapse)AuthorAgeFilesLines
* Introduce rb_vm_call_with_refinements to DRY up a few callsJeremy Evans2021-10-011-0/+14
|
* Refactor rb_call_super functionS-H-GAMELINKS2021-09-251-3/+1
|
* Add gvl and fiber assertions to scheduler interface to catch invalid usage.Samuel Williams2021-09-201-0/+2
|
* Extract hook macro for attributesNobuyoshi Nakada2021-09-191-20/+6
|
* include/ruby/internal/intern/vm.h: add doxygen卜部昌平2021-09-101-8/+0
| | | | Must not be a bad idea to improve documents. [ci skip]
* include/ruby/internal/eval.h: add doxygen卜部昌平2021-09-101-58/+1
| | | | Must not be a bad idea to improve documents. [ci skip]
* Support tracing of attr_reader and attr_writerJeremy Evans2021-08-291-2/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | In vm_call_method_each_type, check for c_call and c_return events before dispatching to vm_call_ivar and vm_call_attrset. With this approach, the call cache will still dispatch directly to those functions, so this change will only decrease performance for the first (uncached) call, and even then, the performance decrease is very minimal. This approach requires that we clear the call caches when tracing is enabled or disabled. The approach currently switches all vm_call_ivar and vm_call_attrset call caches to vm_call_general any time tracing is enabled or disabled. So it could theoretically result in a slowdown for code that constantly enables or disables tracing. This approach does not handle targeted tracepoints, but from my testing, c_call and c_return events are not supported for targeted tracepoints, so that shouldn't matter. This includes a benchmark showing the performance decrease is minimal if detectable at all. Fixes [Bug #16383] Fixes [Bug #10470] Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
* [Feature #18045] Remove T_PAYLOADPeter Zhu2021-08-251-1/+0
| | | | | | | This commit removes T_PAYLOAD since the new VWA implementation no longer requires T_PAYLOAD types. Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
* Revert "[Feature #18045] Implement size classes for GC"Peter Zhu2021-08-231-0/+1
| | | | | | This reverts commits 48ff7a9f3e47bffb3e4d067a12ba9b936261caa0 and b2e2cf2dedd104acad8610721db5e4d341f135ef because it is causing crashes in SPARC solaris and i386 debian.
* [Feature #18045] Remove T_PAYLOADPeter Zhu2021-08-231-1/+0
| | | | | | | This commit removes T_PAYLOAD since the new VWA implementation no longer requires T_PAYLOAD types. Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
* Get rid of type-punning pointer casts [Bug #18062]Nobuyoshi Nakada2021-08-111-1/+3
|
* Using RBOOL macroS.H2021-08-021-6/+1
|
* Make RubyVM::AbstractSyntaxTree.of raise for method/proc created in evalJeremy Evans2021-07-291-4/+21
| | | | | | | | | | | This changes Thread::Location::Backtrace#absolute_path to return nil for methods/procs defined in eval. If the realpath of an iseq is nil, that indicates it was defined in eval, in which case you cannot use RubyVM::AbstractSyntaxTree.of. Fixes [Bug #16983] Co-authored-by: Koichi Sasada <ko1@atdot.net>
* Emit deprecatation warnings for rb_iterate()Benoit Daloze2021-07-161-5/+12
| | | | | | * It is obsolete since 1.9, see https://github.com/ruby/ruby/blob/master/doc/extension.rdoc#label-Control+Structure and [Misc #18025]
* Add debug assertion in `rb_funcall*` that the current thread has the gvl.Samuel Williams2021-07-161-0/+4
|
* Refactor rb_block_call functionS.H2021-06-131-8/+3
| | | | rb_block_call and rb_block_call_kw have similar code. So, using rb_block_kw function in rb_block_call function for refactoring.
* Allow newobj_of0 and newobj_slowpath to allocate into multiple heap slotsMatt Valentine-House2021-05-061-0/+1
|
* Removed unnecessary parentheses at `case` [ci skip]Nobuyoshi Nakada2021-02-081-3/+3
|
* use goto intead of recursion on vm_call0_body()Koichi Sasada2021-02-031-1/+16
| | | | | | | | | | | "alias" type method entries can chain another aliased method so that machine stack can be overflow on nested alias chain. http://ci.rvm.jp/results/trunk-repeat20@phosphorus-docker/3344209 This patch fix this issue by use goto instead of recursion if possible. TODO: Essentially, the alias method should not points another aliased method entry. Try to fix it later.
* refactoring rb_method_call_status()Koichi Sasada2021-01-291-29/+26
|
* global call-cache cache table for rb_funcall*Koichi Sasada2021-01-291-69/+219
| | | | | | | | | | | | | | | | | | | | | | | | | rb_funcall* (rb_funcall(), rb_funcallv(), ...) functions invokes Ruby's method with given receiver. Ruby 2.7 introduced inline method cache with static memory area. However, Ruby 3.0 reimplemented the method cache data structures and the inline cache was removed. Without inline cache, rb_funcall* searched methods everytime. Most of cases per-Class Method Cache (pCMC) will be helped but pCMC requires VM-wide locking and it hurts performance on multi-Ractor execution, especially all Ractors calls methods with rb_funcall*. This patch introduced Global Call-Cache Cache Table (gccct) for rb_funcall*. Call-Cache was introduced from Ruby 3.0 to manage method cache entry atomically and gccct enables method-caching without VM-wide locking. This table solves the performance issue on multi-ractor execution. [Bug #17497] Ruby-level method invocation does not use gccct because it has inline-method-cache and the table size is limited. Basically rb_funcall* is not used frequently, so 1023 entries can be enough. We will revisit the table size if it is not enough.
* Check stack overflow in recursive glob_helper [Bug #17162]Nobuyoshi Nakada2021-01-131-0/+10
|
* [DOC] Fix grammar: "is same as" -> "is the same as"Marcus Stollsteimer2021-01-051-1/+1
|
* Optimize calls to `Kernel#hash` (#3987)Marc-André Lafortune2020-12-251-0/+28
| | | | This avoids recursive checks when the `hash` method of an object isn't specialized.
* Prefer stdbool in vm_execTakashi Kokubun2020-12-211-4/+4
| | | | Make the code a bit modern and consistent with some other places.
* add several debug countersKoichi Sasada2020-12-151-0/+2
| | | | | | | add cc_found_in_ccs (renamed from cc_found_ccs), cc_not_found_in_ccs, call0_public, call0_other debug counters to measure more details. also it contains several modification.
* fix inline method cache sync bugKoichi Sasada2020-12-151-18/+16
| | | | | | | | | `cd` is passed to method call functions to method invocation functions, but `cd` can be manipulated by other ractors simultaneously so it contains thread-safety issue. To solve this issue, this patch stores `ci` and found `cc` to `calling` and stops to pass `cd`.
* use method cache on Object#respond_to?Koichi Sasada2020-12-141-2/+2
| | | | | rb_method_boundp (method_boundp) searches method_entry, but this search did not use pCMC, so change to use it.
* Add description __send__ is saferNARUSE, Yui2020-11-051-2/+4
|
* check isolated Proc more strictlyKoichi Sasada2020-10-291-4/+21
| | | | | Isolated Proc prohibit to access outer local variables, but it was violated by binding and so on, so they should be error.
* Deprecate iterator? methodNobuyoshi Nakada2020-08-311-3/+15
| | | | [Feature #15547] [Fix GH-2071]
* Run method_missing in the same execution contextNobuyoshi Nakada2020-07-061-7/+6
|
* add UNREACHABLE_RETURN卜部昌平2020-06-291-0/+1
| | | | | | 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.
* method_missing: do not goto into a branch卜部昌平2020-06-291-2/+3
| | | | | I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor.
* rb_method_call_status: do not goto into a branch卜部昌平2020-06-291-2/+3
| | | | | I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor.
* eliminate C99 compound literals卜部昌平2020-06-091-14/+12
| | | | | Ko1 prefers variables be assgined, instead of bare literals in function arguments.
* rb_vm_call0: on-stack call info卜部昌平2020-06-091-6/+14
| | | | | This changeset reduces the generated binary of rb_vm_call0 from 281 bytes to 211 bytes on my machine. Should reduce GC pressure as well.
* drop varargs.h support卜部昌平2020-05-111-2/+2
| | | | | This header file is simply out of date (for decades since at least 1989). It's the 21st century. Just stop using it.
* Introduce disposable call-cache.Koichi Sasada2020-02-221-24/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch contains several ideas: (1) Disposable inline method cache (IMC) for race-free inline method cache * Making call-cache (CC) as a RVALUE (GC target object) and allocate new CC on cache miss. * This technique allows race-free access from parallel processing elements like RCU. (2) Introduce per-Class method cache (pCMC) * Instead of fixed-size global method cache (GMC), pCMC allows flexible cache size. * Caching CCs reduces CC allocation and allow sharing CC's fast-path between same call-info (CI) call-sites. (3) Invalidate an inline method cache by invalidating corresponding method entries (MEs) * Instead of using class serials, we set "invalidated" flag for method entry itself to represent cache invalidation. * Compare with using class serials, the impact of method modification (add/overwrite/delete) is small. * Updating class serials invalidate all method caches of the class and sub-classes. * Proposed approach only invalidate the method cache of only one ME. See [Feature #16614] for more details.
* VALUE size packed callinfo (ci).Koichi Sasada2020-02-221-46/+9
| | | | | | | | | | | | | | | | | | | | Now, rb_call_info contains how to call the method with tuple of (mid, orig_argc, flags, kwarg). Most of cases, kwarg == NULL and mid+argc+flags only requires 64bits. So this patch packed rb_call_info to VALUE (1 word) on such cases. If we can not represent it in VALUE, then use imemo_callinfo which contains conventional callinfo (rb_callinfo, renamed from rb_call_info). iseq->body->ci_kw_size is removed because all of callinfo is VALUE size (packed ci or a pointer to imemo_callinfo). To access ci information, we need to use these functions: vm_ci_mid(ci), _flag(ci), _argc(ci), _kwarg(ci). struct rb_call_info_kw_arg is renamed to rb_callinfo_kwarg. rb_funcallv_with_cc() and rb_method_basic_definition_p_with_cc() is temporary removed because cd->ci should be marked.
* Remove rb_eval_cmdJeremy Evans2020-02-111-7/+0
| | | | | This was related to $SAFE, and was deprecated in 2.7. I missed it earlier when removing the other $SAFE-related code.
* script_compiled event on compile error.Koichi Sasada2020-01-061-6/+8
| | | | | | script_compiled event for TracePoint should not be invoked on compile error (SyntaxError) because it is not "compiled". [Bug #16459]
* Make eval(code, binding) use (eval) as __FILE__ and 1 as __LINE__Jeremy Evans2020-01-031-6/+0
| | | | | | | | | This removes the warning that was added in 3802fb92ff8c83eed3e867db20f72c53932f542d, and switches the behavior so that the eval does not use the binding's __FILE__ and __LINE__ implicitly. Fixes [Bug #4352]
* Fully separate positional arguments and keyword argumentsJeremy Evans2020-01-021-89/+17
| | | | | | | | | | | | | | | | | | | | | | | | 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().
* Reword keyword arguments warning messages to convey these are deprecation ↵Marc-Andre Lafortune2019-12-231-1/+1
| | | | warnings
* delete rb_vm_call()卜部昌平2019-12-181-6/+0
| | | | Nobody uses it any longer.
* per-method serial number卜部昌平2019-12-181-1/+1
| | | | | | | | | | | | | | | | | Methods and their definitions can be allocated/deallocated on-the-fly. One pathological situation is when a method is deallocated then another one is allocated immediately after that. Address of those old/new method entries/definitions can be the same then, depending on underlying malloc/free implementation. So pointer comparison is insufficient. We have to check the contents. To do so we introduce def->method_serial, which is an integer unique to that specific method definition. PS: Note that method_serial being uintptr_t rather than rb_serial_t is intentional. This is because rb_serial_t can be bigger than a pointer on a 32bit system (rb_serial_t is at least 64bit). In order to preserve old packing of struct rb_call_cache, rb_serial_t is inappropriate.
* ensure cc->def == cc->me->def卜部昌平2019-12-161-9/+12
| | | | | | | The equation shall hold for every call cache. However prior to this changeset cc->me could be updated without also updating cc->def. Let's make it sure by introducing new macro named CC_SET_ME which sets cc->me and cc->def at once.
* Make rb_eval_string_wrap specify a cref so constant setting works correctlyJeremy Evans2019-12-051-1/+21
| | | | Fixes [Bug #10466]
* make functions static卜部昌平2019-11-191-1/+3
| | | | | | | These functions are used from within a compilation unit so we can make them static, for better binary size. This changeset reduces the size of generated ruby binary from 26,590,128 bytes to 26,584,472 bytes on my macihne.