aboutsummaryrefslogtreecommitdiffstats
path: root/eval.c
Commit message (Collapse)AuthorAgeFilesLines
* M:N thread scheduler for RactorsKoichi Sasada2023-10-121-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch introduce M:N thread scheduler for Ractor system. In general, M:N thread scheduler employs N native threads (OS threads) to manage M user-level threads (Ruby threads in this case). On the Ruby interpreter, 1 native thread is provided for 1 Ractor and all Ruby threads are managed by the native thread. From Ruby 1.9, the interpreter uses 1:1 thread scheduler which means 1 Ruby thread has 1 native thread. M:N scheduler change this strategy. Because of compatibility issue (and stableness issue of the implementation) main Ractor doesn't use M:N scheduler on default. On the other words, threads on the main Ractor will be managed with 1:1 thread scheduler. There are additional settings by environment variables: `RUBY_MN_THREADS=1` enables M:N thread scheduler on the main ractor. Note that non-main ractors use the M:N scheduler without this configuration. With this configuration, single ractor applications run threads on M:1 thread scheduler (green threads, user-level threads). `RUBY_MAX_CPU=n` specifies maximum number of native threads for M:N scheduler (default: 8). This patch will be reverted soon if non-easy issues are found. [Bug #19842]
* Add Refinement#target and deprecate Refinement#refined_classShugo Maeda2023-07-311-3/+17
| | | | [Feature #19714]
* use inline cache for refinementsKoichi Sasada2023-07-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From Ruby 3.0, refined method invocations are slow because resolved methods are not cached by inline cache because of conservertive strategy. However, `using` clears all caches so that it seems safe to cache resolved method entries. This patch caches resolved method entries in inline cache and clear all of inline method caches when `using` is called. fix [Bug #18572] ```ruby # without refinements class C def foo = :C end N = 1_000_000 obj = C.new require 'benchmark' Benchmark.bm{|x| x.report{N.times{ obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; }} } _END__ user system total real master 0.362859 0.002544 0.365403 ( 0.365424) modified 0.357251 0.000000 0.357251 ( 0.357258) ``` ```ruby # with refinment but without using class C def foo = :C end module R refine C do def foo = :R end end N = 1_000_000 obj = C.new require 'benchmark' Benchmark.bm{|x| x.report{N.times{ obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; }} } __END__ user system total real master 0.957182 0.000000 0.957182 ( 0.957212) modified 0.359228 0.000000 0.359228 ( 0.359238) ``` ```ruby # with using class C def foo = :C end module R refine C do def foo = :R end end N = 1_000_000 using R obj = C.new require 'benchmark' Benchmark.bm{|x| x.report{N.times{ obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; obj.foo; }} }
* Ensure throw data is not set as causePeter Zhu2023-04-131-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | [Bug #19593] rb_ec_setup_exception did not check if errinfo is a throw_data. This can cause crashes in code since it is assumed that id_cause is an object. We saw a crash in show_cause due to id_cause of errinfo being a throw_data. It crashes on rb_obj_is_kind_of since it cannot be called on T_IMEMO objects. Unfortunately, we couldn't find a reproduction script, however we debugged the core dump and rb_ec_setup_exception is the only place where id_cause is assigned from errinfo without checking if it is a throw_data. ``` 0x0000556c5708e6dd in sigsegv (sig=11, info=0x7f301befa3f0, ctx=0x7f301befa2c0) at signal.c:964 0x00007f301d046420 in <signal handler called> () at /lib/x86_64-linux-gnu/libpthread.so.0 class_search_class_ancestor (c=139844586301760, cl=<optimized out>) at object.c:810 rb_obj_is_kind_of (obj=obj@entry=139839221734880, c=139844586301760) at object.c:861 0x0000556c56f2f00f in show_cause (errinfo=errinfo@entry=139838840645160, str=str@entry=139839221730520, opt=139839221730480, highlight=0, reverse=reverse@entry=0, backtrace_limit=backtrace_limit@entry=-1, shown_causes=0x7ffe9d1a2d68) at ./include/ruby/internal/special_consts.h:175 ``` Co-Authored-By: Jean Boussier <byroot@ruby-lang.org>
* Remove obsoleted functions in rjit.cTakashi Kokubun2023-03-071-2/+0
|
* s/mjit/rjit/Takashi Kokubun2023-03-061-2/+2
|
* Encapsulate RCLASS_ATTACHED_OBJECTJean Boussier2023-02-151-1/+1
| | | | | | | | | 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.
* Merge gc.h and internal/gc.hMatt Valentine-House2023-02-091-1/+1
| | | | [Feature #19425]
* [Bug #19242] Prohibit circular causes to be loadedNobuyoshi Nakada2022-12-201-0/+4
|
* The mode flags may be clobbered by tag jumpsNobuyoshi Nakada2022-11-251-1/+1
|
* [Bug #19016] re-order error handling at cleanupNobuyoshi Nakada2022-11-221-46/+51
| | | | | Build and store the error message with `#detailed_message` before terminating all Ractors, then show the message later.
* [Bug #19016] Handle syntax error in main script like other errorsNobuyoshi Nakada2022-11-201-1/+2
| | | | | So that `SyntaxError#detailed_message` will be used also in the case exiting by such syntax error.
* Use `enum ruby_tag_type` over `int`Nobuyoshi Nakada2022-11-201-4/+4
|
* Using UNDEF_P macroS-H-GAMELINKS2022-11-161-8/+8
|
* MJIT: Stop using the VM barrier for jit_contTakashi Kokubun2022-10-191-1/+2
| | | | | | | | | | | | | | | | This solves multiple problems. First, RB_VM_LOCK_ENTER/LEAVE is a barrier. We could at least use the _NO_BARRIER variant. Second, this doesn't need to interfere with GC or other GVL users when multiple Ractors are used. This needs to be used in very few places, so the benefit of fine-grained locking would outweigh its small maintenance cost. Third, it fixes a crash for YJIT. Because YJIT is never disabled until a process exits unlike MJIT that finishes earlier, we could call jit_cont_free when EC no longer exists, which crashes RB_VM_LOCK_ENTER.
* Make mjit_cont sharable with YJIT (#6556)Takashi Kokubun2022-10-171-1/+3
| | | | | | | * Make mjit_cont sharable with YJIT * Update dependencies * Update YJIT binding
* Support using at toplevel in wrapped scriptChris Salzberg2022-09-241-2/+4
| | | | | | | Allow refinements to be used at the toplevel within a script that is loaded under a module. Fixes [Bug #18960]
* Expand tabs [ci skip]Takashi Kokubun2022-07-211-350/+350
| | | | [Misc #18891]
* Remove unnecessary module flag, add module assertions to other module flagsJemma Issroff2022-05-231-8/+5
|
* Add ISEQ_BODY macroPeter Zhu2022-03-241-2/+2
| | | | | | 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.
* A positional Hash is not keyword arguments [Bug #18632]Nobuyoshi Nakada2022-03-181-4/+5
|
* Remove Refinement#{extend_object,append_features,prepend_features}Jeremy Evans2022-01-051-3/+18
| | | | | | | Also make include, prepend, and extend raise a TypeError if one of the modules is a refinement. Implements [Feature #18270]
* Add Module#refinements and Refinement#refined_class [Feature #12737]Shugo Maeda2022-01-051-1/+43
|
* Add Module.used_refinementsShugo Maeda2022-01-051-0/+53
|
* Remove Refinement#include and Refinement#prependNobuyoshi Nakada2021-12-261-2/+2
|
* Add docs for Refinement classzverok2021-12-241-6/+1
|
* Clarify the error message when trying to import C methods [Bug #18385]Shugo Maeda2021-12-061-1/+1
|
* Deprecate include/prepend in refinements and add Refinement#import_methods ↵Shugo Maeda2021-10-211-1/+67
| | | | | | | | | | instead Refinement#import_methods imports methods from modules. Unlike Module#include, it copies methods and adds them into the refinement, so the refinement is activated in the imported methods. [Bug #17429] [ruby-core:101639]
* Consider modified modules initialized [Bug #18185]Nobuyoshi Nakada2021-09-241-0/+3
|
* include/ruby/internal/intern/eval.h: add doxygen卜部昌平2021-09-101-65/+0
| | | | Must not be a bad idea to improve documents. [ci skip]
* include/ruby/internal/intern/proc.h: add doxygen卜部昌平2021-09-101-17/+0
| | | | Must not be a bad idea to improve documents. [ci skip]
* include/ruby/internal/error.h: add doxygen卜部昌平2021-09-101-14/+0
| | | | Must not be a bad idea to improve documents.
* include/ruby/internal/interpreter.h: add doxygen卜部昌平2021-09-101-55/+0
| | | | | | | | Must not be a bad idea to improve documents. [ci skip] In fact many functions declared in the header file are already documented more or less. They were just copy & pasted, with applying some style updates.
* include/ruby/internal/iterator.h: add doxygen卜部昌平2021-09-101-64/+0
| | | | Must not be a bad idea to improve documents. [ci skip]
* include/ruby/internal/module.h: add doxygen卜部昌平2021-09-101-6/+0
| | | | | | | | Must not be a bad idea to improve documents. [ci skip] In fact many functions declared in the header file are already documented more or less. They were just copy & pasted, with applying some style updates.
* Remove root_jmpbuf in rb_thread_structNobuyoshi Nakada2021-08-101-3/+0
| | | | It has not been used since 1b82c877dfa72e8505ded149fd0e3ba956529d3f.
* Suppress a clobbered warningNobuyoshi Nakada2021-08-091-4/+3
|
* Suppress warnings in C++2aNobuyoshi Nakada2021-08-091-3/+4
| | | | | | | | | * bitwise operation between different enumeration types ('ruby_value_type' and 'ruby_fl_type') is deprecated [-Wdeprecated-enum-enum-conversion] * volatile-qualified parameter type 'volatile int' is deprecated [-Wdeprecated-volatile]
* Replace copy coroutine with pthread implementation.Samuel Williams2021-07-011-5/+0
|
* Refactor rb_obj_call_init and rb_obj_call_init_kw (#4351)S.H2021-04-041-2/+1
|
* Add rb_exc_exception functionS.H2021-03-271-8/+13
| | | | | `rb_exc_raise` and `rb_fatal` func have similar code(in `eval.c`). I think that better cut out and replace these code like `rb_exc_exception` function.
* Make a few functions staticAlan Wu2021-03-181-7/+4
|
* Expose scheduler as public interface & bug fixes. (#3945)Samuel Williams2021-02-091-4/+4
| | | | | | | | | * Rename `rb_scheduler` to `rb_fiber_scheduler`. * Use public interface if available. * Use `rb_check_funcall` where possible. * Don't use `unblock` unless the fiber was non-blocking.
* Copy va_list of exception classesNobuyoshi Nakada2021-02-091-1/+5
| | | | | The list is reused when an exception raised again after retrying in the rescue procedure.
* Also `eclass` loop can raise in `rb_obj_is_kind_of`Nobuyoshi Nakada2021-02-091-1/+1
|
* Assign TAG_NONE to ruby_tag_type instead of 0Nobuyoshi Nakada2021-02-091-2/+2
|
* [DOC] Fix grammar: "is same as" -> "is the same as"Marcus Stollsteimer2021-01-051-1/+1
|
* Remove obsoleted internal/mjit.h inclusionTakashi Kokubun2020-11-221-1/+0
| | | | :bow:
* fix public interfaceKoichi Sasada2020-11-181-1/+1
| | | | | | | | | | | | | | | | | | To make some kind of Ractor related extensions, some functions should be exposed. * include/ruby/thread_native.h * rb_native_mutex_* * rb_native_cond_* * include/ruby/ractor.h * RB_OBJ_SHAREABLE_P(obj) * rb_ractor_shareable_p(obj) * rb_ractor_std*() * rb_cRactor and rm ractor_pub.h and rename srcdir/ractor.h to srcdir/ractor_core.h (to avoid conflict with include/ruby/ractor.h)
* Rename to `Fiber#set_scheduler`.Samuel Williams2020-11-071-2/+2
|