summaryrefslogtreecommitdiff
path: root/eval_intern.h
AgeCommit message (Collapse)Author
2022-01-19`rb_fiber_terminate` must not return [Bug #18497]Nobuyoshi Nakada
In a forked process from a fiber, the fiber becomes the only fiber, `fiber_switch` does nothing as there is no other fibers, `rb_fiber_terminate` does not terminate the fiber. In that case, reaches the end of `fiber_entry` finaly, which is declared as "COROUTINE" and should never return. Notes: Merged: https://github.com/ruby/ruby/pull/5468
2022-01-19[wasm] eval_inter.h gc.c vm_core.h: include wasm/setjmp.h instead of sysroot ↵Yuta Saito
header Notes: Merged: https://github.com/ruby/ruby/pull/5407
2021-12-24Adjust styles [ci skip]Nobuyoshi Nakada
2021-12-02Lazily create singletons on instance_{exec,eval} (#5146)John Hawthorn
* Lazily create singletons on instance_{exec,eval} Previously when instance_exec or instance_eval was called on an object, that object would be given a singleton class so that method definitions inside the block would be added to the object rather than its class. This commit aims to improve performance by delaying the creation of the singleton class unless/until one is needed for method definition. Most of the time instance_eval is used without any method definition. This was implemented by adding a flag to the cref indicating that it represents a singleton of the object rather than a class itself. In this case CREF_CLASS returns the object's existing class, but in cases that we are defining a method (either via definemethod or VM_SPECIAL_OBJECT_CBASE which is used for undef and alias). This also happens to fix what I believe is a bug. Previously instance_eval behaved differently with regards to constant access for true/false/nil than for all other objects. I don't think this was intentional. String::Foo = "foo" "".instance_eval("Foo") # => "foo" Integer::Foo = "foo" 123.instance_eval("Foo") # => "foo" TrueClass::Foo = "foo" true.instance_eval("Foo") # NameError: uninitialized constant Foo This also slightly changes the error message when trying to define a method through instance_eval on an object which can't have a singleton class. Before: $ ruby -e '123.instance_eval { def foo; end }' -e:1:in `block in <main>': no class/module to add method (TypeError) After: $ ./ruby -e '123.instance_eval { def foo; end }' -e:1:in `block in <main>': can't define singleton (TypeError) IMO this error is a small improvement on the original and better matches the (both old and new) message when definging a method using `def self.` $ ruby -e '123.instance_eval{ def self.foo; end }' -e:1:in `block in <main>': can't define singleton (TypeError) Co-authored-by: Matthew Draper <matthew@trebex.net> * Remove "under" argument from yield_under * Move CREF_SINGLETON_SET into vm_cref_new * Simplify vm_get_const_base * Fix leaf VM_SPECIAL_OBJECT_CONST_BASE Co-authored-by: Matthew Draper <matthew@trebex.net> Notes: Merged-By: jhawthorn <john@hawthorn.email>
2021-08-10Remove root_jmpbuf in rb_thread_structNobuyoshi Nakada
It has not been used since 1b82c877dfa72e8505ded149fd0e3ba956529d3f. Notes: Merged: https://github.com/ruby/ruby/pull/4725
2021-07-01Replace copy coroutine with pthread implementation.Samuel Williams
2021-05-04Fix trivial -Wundef warningsBenoit Daloze
* See [Feature #17752] Co-authored-by: xtkoba (Tee KOBAYASHI) <xtkoba+ruby@gmail.com> Notes: Merged: https://github.com/ruby/ruby/pull/4428
2021-04-08Make the return type of rb_char_next the same as CharNextNobuyoshi Nakada
2021-03-19Fix infinite loop at illegal sequence [Bug #17729]Nobuyoshi Nakada
As mblen returns -1 on failure, skip the first byte and try the succeeding bytes in that case. Close https://github.com/ruby/ruby/pull/4281 Notes: Merged: https://github.com/ruby/ruby/pull/4284
2020-11-11Threads in a ractor will be killed with the ractorKoichi Sasada
If a terminating ractor has child threads, then kill all child threads. Notes: Merged: https://github.com/ruby/ruby/pull/3754
2020-10-26Ignore <internal: entries from core library methods for Kernel#warn(message, ↵Benoit Daloze
uplevel: n) * Fixes [Bug #17259] Notes: Merged: https://github.com/ruby/ruby/pull/3647
2020-10-14fix releasing timing.Koichi Sasada
(1) recorded_lock_rec > current_lock_rec should not be occurred on rb_ec_vm_lock_rec_release(). (2) should be release VM lock at EXEC_TAG(), not POP_TAG(). (3) some refactoring. Notes: Merged: https://github.com/ruby/ruby/pull/3655
2020-10-14support exception when lock_rec > 0Koichi Sasada
If a ractor getting a VM lock (monitor) raises an exception, unlock can be skipped. To release VM lock correctly on exception (or other jumps with JUMP_TAG), EC_POP_TAG() releases VM lock. Notes: Merged: https://github.com/ruby/ruby/pull/3654
2019-12-13Create backtrace location array directlyNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/2739
2019-11-14delete unused functions卜部昌平
Looking at the list of symbols inside of libruby-static.a, I found hundreds of functions that are defined, but used from nowhere. There can be reasons for each of them (e.g. some functions are specific to some platform, some are useful when debugging, etc). However it seems the functions deleted here exist for no reason. This changeset reduces the size of ruby binary from 26,671,456 bytes to 26,592,864 bytes on my machine. Notes: Merged: https://github.com/ruby/ruby/pull/2677
2019-08-08solve "duplicate :raise event" [Bug #15877]Koichi Sasada
Without this patch, "raise" event invoked twice when raise an exception in "load"ed script. This patch by danielwaterworth (Daniel Waterworth). [Bug #15877]
2019-05-31Use UNALIGNED_MEMBER_PTRNobuyoshi Nakada
* internal.h (UNALIGNED_MEMBER_ACCESS, UNALIGNED_MEMBER_PTR): moved from eval_intern.h. * compile.c iseq.c, vm.c: use UNALIGNED_MEMBER_PTR for `entries` in `struct iseq_catch_table`. * vm_eval.c, vm_insnhelper.c: use UNALIGNED_MEMBER_PTR for `body` in `rb_method_definition_t`.
2019-05-31Also GCC 9 provides -Waddress-of-packed-memberNobuyoshi Nakada
2018-07-30reduce copy & pasteshyouhei
We see several occurrence of "diagnostic push/pop" so why not make them macros. Tested on GCC8 / Clang 6. Note that ruby.h is intentionally left untouched because we don't want to introduce new public macros. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-18eval_intern.h: duplicate checknobu
* eval_intern.h (pass_passed_block_handler): remove duplicate check. vm_block_handler_verify() is called in the successive function call. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-06eval_intern.h: fix a typomame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-06eval_intern.h: prevent core dump with clang and make test-allmame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-06remove `PUSH_TAG`/`EXEC_AG`/`POP_TAG`/`JUMO_TAG`.ko1
* eval_intern.h: remove non-`EC_` prefix *_TAG() macros. Use `EC_` prefix macros explicitly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-16make a func static.ko1
* vm_backtrace.c (rb_ec_backtrace_location_ary): make it static and remove `rb_` prefix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-16make a func static.ko1
* vm_eval.c (rb_raise_method_missing): make this func static and renmae with vm_ prefix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-07`rb_execution_context_t *` should not be `th`ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-07fix commentko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-07* eval_intern.h (rb_threadptr_tag_state): rename to rb_ec_tag_state.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60687 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-07* eval_intern.h: rename macros rb_thread_raised_* toko1
rb_ec_raised_*. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-07rename to rb_ec_set_raised().ko1
* thread.c (rb_threadptr_set_raised): rename to rb_ec_set_raised and accepts `ec` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-07th->ec: rb_threadptr_reset_raised()ko1
* thread.c (rb_threadptr_reset_raised): rename to `rb_ec_reset_raised` and accepts `ec`. * vm_trace.c: the following functions accept `ec` instead of `th` * exec_hooks_body * exec_hooks_precheck * exec_hooks_unprotected * exec_hooks_protected git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29`th` -> `ec` for rb_raise_method_missing().ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29rb_ec_stack_check()ko1
* gc.c (rb_ec_stack_check): renamed from rb_threadptr_stack_check() and it accepts `ec`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60542 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-28`th` -> `ec` for backtrace functions.ko1
* vm_backtrace.c: accept `ec` and rename `threadptr` to `ec`. * rb_threadptr_backtrace_object -> rb_ec_backtrace_object * rb_threadptr_backtrace_str_ary -> rb_ec_backtrace_str_ar * rb_threadptr_backtrace_location_ary -> rb_ec_backtrace_location_ary * threadptr_backtrace_to_ary -> ec_backtrace_to_ary * vm_eval.c (adjust_backtrace_in_eval): accepts `ec`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-28`th` -> `ec` for rb_longjmp() and related functions.ko1
* eval.c: `th` -> `ec` for the following functions: * rb_longjmp * exc_setup_message * setup_exception * errinfo_place * eval.c (get_thread_errinfo): rename to get_ec_errinfo() and accepts `ec`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-28move fields from `th` to `ec`.ko1
* vm_core.h: move rb_thread_t::passed_block_handler to rb_execution_context_t::passed_block_handler. Also move rb_thread_t::passed_bmethod_me to rb_execution_context_t::passed_bmethod_me. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26introduce EC_*_TAG() instead of TH_*_TAG()ko1
* eval_intern.h: introduce EC_*_TAG() macros instead of TH_*_TAG() macros. * TH_PUSH_TAG() -> EC_PUSH_TAG() * TH_POP_TAG() -> EC_POP_TAG() * TH_TMPPOP_TAG() -> EC_TMPPOP_TAG() * TH_REPUSH_TAG() -> EC_REPUSH_TAG() * TH_EXEC_TAG() -> EC_EXEC_TAG() * TH_JUMP_TAG() -> EC_JUMP_TAG() rb_threadptr_tag_state() , rb_ec_tag_jump() also accept `ec` instead of `th`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26Use rb_execution_context_t instead of rb_thread_tko1
to represent execution context [Feature #14038] * vm_core.h (rb_thread_t): rb_thread_t::ec is now a pointer. There are many code using `th` to represent execution context (such as cfp, VM stack and so on). To access `ec`, they need to use `th->ec->...` (adding one indirection) so that we need to replace them by passing `ec` instead of `th`. * vm_core.h (GET_EC()): introduced to access current ec. Also remove `ruby_current_thread` global variable. * cont.c (rb_context_t): introduce rb_context_t::thread_ptr instead of rb_context_t::thread_value. * cont.c (ec_set_vm_stack): added to update vm_stack explicitly. * cont.c (ec_switch): added to switch ec explicitly. * cont.c (rb_fiber_close): added to terminate fibers explicitly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60440 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-25vm.c: unused functionnobu
* vm.c (rb_vm_jump_tag_but_local_jump): no longer used since r51292. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-30UNALIGNED_MEMBER_ACCESS only for clangnobu
* eval_intern.h (UNALIGNED_MEMBER_ACCESS): enable only on clang. gcc does not complain about pointers to member of unaligned struct. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-30UNALIGNED_MEMBER_ACCESSnobu
* eval_intern.h (UNALIGNED_MEMBER_ACCESS): suppress address-of-packed-member warnings by clang 4.0. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-26move several fields from rb_thread_t to rb_execution_context_t.ko1
* vm_core.h (rb_thread_t): move several fields which are copied at cont.c to rb_execution_context_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-23move "state" to rb_vm_tag.ko1
* vm_core.h (rb_thread_t::tag_state): move to "rb_vm_tag::state". Lifetime of "state" should be same as current tag. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-23rename th->state to th->tag_state.ko1
* vm_core.h (rb_thread_t): rename rb_thread_t::state to tag_state to make it clear. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-23use "enum ruby_tag_type" and TAG_NONE.ko1
Return value of EXEC_TAG() is saved by "int state". Instead of "int", use "enum ruby_tag_type". First EXEC_TAG() value should be 0, so that define TAG_NONE (= 0) and use it. Some code used "status" instead of "state". To make them clear, rename them to state. We can change variable name from "state" to "tag_state", but this ticket doesn't contain it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-08vm_block_handler_verify() should not return any value.ko1
* vm_core.h (vm_block_handler_verify): this function only checks the given block handler with VM_ASSERT(). No need to return any value. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59045 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-09rb_execution_context_t: move stack, stack_size and cfp from rb_thread_tnormal
The goal is to reduce rb_context_t and rb_fiber_t size by removing the need to store the entire rb_thread_t in there. [ruby-core:81045] Work-in-progress: soon, we will move more fields here. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-17vm_backtrace.c: backtrace functions per threadsnobu
* vm_backtrace.c (rb_threadptr_backtrace_object): rename and extern. * vm_backtrace.c (rb_threadptr_backtrace_str_ary): rename as threadptr since the parameter is rb_thread_t*. * vm_backtrace.c (rb_threadptr_backtrace_location_ary): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58377 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-17gc.c: rb_threadptr_stack_checknobu
* gc.c (rb_threadptr_stack_check): check probability of stack overflow for the given thread, not the current thread. * vm_eval.c (stack_check): check the given thread, not the current thread. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58375 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-26eval_intern.h: make TH_PUSH_TAG() initialize rb_vm_tag::tag with Qundefrhe
* eval_intern.h (TH_PUSH_TAG): Initialize struct rb_vm_tag::tag with Qundef rather than 0 which is equal to Qfalse. Since Kernel#throw(obj) searches a tag with rb_vm_tag::tag == obj, throw(false) can accidentally find an unrelated tag which is not created by Kernel#catch. [ruby-core:77229] [Bug #12743] * test/ruby/test_exception.rb (test_throw_false): Add a test case for this. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e