summaryrefslogtreecommitdiff
path: root/vm.c
AgeCommit message (Collapse)Author
2017-12-16vm.c: always export rb_frame_method_id_and_classk0kubun
Functions declared in include/ruby/backward.h is exported only when the condition `!defined RUBY_EXPORT && !defined RUBY_NO_OLD_COMPATIBILITY` is met (i.e. included by include/ruby/ruby.h). So if it is not the case when ruby is built, this will not be exported. This was not intentional at r60994. [Bug #14192] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61296 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-14The main Thread should have report_on_exception=true for consistencyeregon
* Adapt test and add specs. * See [Feature #14143] [ruby-core:84227] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12Set Thread.report_on_exception=true by default to report exceptions in Threadseregon
* [Feature #14143] [ruby-core:83979] * vm.c (vm_init2): Set Thread.report_on_exception to true. * thread.c (thread_start_func_2): Add indication the message is caused by report_on_exception = true. * spec/ruby: Specify the new behavior. * test/ruby/test_thread.rb: Adapt and improve tests for Thread.report_on_exception and Thread#report_on_exception. * test/ruby/test_thread.rb, test/ruby/test_exception.rb: Unset report_on_exception for tests expecting no extra output. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-11do not disable `trace_` prefix insns.ko1
* vm.c: introduce `ruby_vm_event_enabled_flags` which represents which event flags are enabled before. * vm_trace.c: do not turn off `trace_` prefix instructions because turn on overhead is a matter if a program repeats turn on and turn off frequently. * iseq.c (finish_iseq_build): respect `ruby_vm_event_enabled_flags`. * vm_insnhelper.c (vm_trace): check `ruby_vm_event_flags` and disable lazy trace-off technique (do not disable traces). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61122 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-12-01vm.c: partially revert r60558k0kubun
because it was actually used in https://github.com/tmm1/rbtrace/blob/v0.4.8/ext/rbtrace.c#L329 and deprecated in r60579 AFTER removal in r60558. ko1 agreed that we should keep just deprecated in Ruby 2.5 and remove it later, and I'm commiting this because I want to make rbtrace.gem installation successful. backward.h: modify r60579 to make rb_frame_method_id_and_class() compilable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-16Refactoring out the direct accesses of NODE's u1, u2, and u3mame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-16make a func static.ko1
* vm.c (rb_proc_create_from_captured): make this func static and renmae with vm_ prefix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60800 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-16make it static.ko1
* vm.c (rb_thread_mark): now file local. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60797 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-16provide rb_vm_make_proc/lambda().ko1
* vm.c (rb_vm_make_proc): removed. * vm_core.h: provide utility inline functions * rb_vm_make_proc() * rb_vm_make_lambda() to call rb_vm_make_proc_lambda(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-16`rb_source_loc` -> `rb_source_location_cstr`ko1
* vm.c (rb_source_loc): rename to rb_source_location_cstr() to make behavior clear compare with rb_source_location(). * error.c (warning_string): use rb_source_location_cstr() directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-16fix r60789.ko1
* vm.c (rb_source_loc): fix condition. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60791 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-16rb_source_location() may return nil.ko1
* vm.c (rb_source_location): return nil if path is not found. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-16remove an unused function.ko1
* vm.c (rb_sourcefilename): removed because nobody use it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60788 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-16add `ec` as first parameter.ko1
* vm.c (vm_svar_get): accepts `ec` as first parameter. * vm.c (vm_svar_set): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60787 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-15remove rb_thread_t::event_hooks.ko1
* vm_core.h (rb_thread_t): remove rb_thread_t::event_hooks. * vm_trace.c: all hooks are connected to vm->event_hooks and add rb_event_hook_t::filter::th to filter invoke thread. It will simplify invoking hooks code. * thread.c (thread_start_func_2): clear thread specific trace_func. * test/ruby/test_settracefunc.rb: add a test for Thread#add_trace_func. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-07th->ec: dtraceko1
* vm.c (ruby_th_dtrace_setup): rename to rb_dtrace_setup() and accept `ec`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60696 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-06renmae ec::fiber to ec::fiber_ptr.ko1
* vm_core.h (rb_execution_context_t): renmae ec::fiber to ec::fiber_ptr make consistent with ec::thread_ptr. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29remove unused functions.ko1
* vm.c (rb_frame_method_id_and_class): removed because nobody use it. * vm.c (rb_thread_current_status): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60558 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29EXEC_EVENT_HOOK(ec, ...)ko1
* vm_core.h (EXEC_EVENT_HOOK): accepts `ec` instead of `th`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-28`th` -> `ec` for method management functions.ko1
* vm_eval.c: `th` -> `ec` for the following functions: * check_funcall_respond_to * check_funcall_callable * check_funcall_missing * rb_method_call_status * vm_method.c: ditto. * call_method_entry * basic_obj_respond_to_missing * basic_obj_respond_to * vm_respond_to * vm_eval.c (stack_check): accepts `ec` instead of `th`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60521 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-28`th` -> `ec` for rb_vm_make_binding().ko1
* vm.c (rb_vm_make_binding): accepts (const) `ec` instead of `th`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-28rename a function.ko1
* vm.c (rb_thread_method_id_and_class): rename to rb_ec_frame_method_id_and_class() and accepts `ec` instead of `th`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-28* vm.c (vm_define_method): don't use `th` any more.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60512 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-28* vm.c (REWIND_CFP): use `ec` directly.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-28`th` -> `ec` for vm_iter_break().ko1
* vm.c (vm_iter_break): accepts `ec` instead of `th`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-28`th` -> `ec` for some functions.ko1
* vm.c: `th` -> `ec` for the following functions: * vm_normal_frame * vm_cfp_svar_get * vm_cfp_svar_set git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-28`th` -> `ec` for some functions.ko1
* vm.c (rb_vm_get_binding_creatable_next_cfp): accepts `ec` instead of `th`. * vm.c (rb_vm_stack_to_heap): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-28`th` -> `ec` for rb_vm_rewind_cfp.ko1
* vm.c (rb_vm_rewind_cfp): accepts `ec` instead of `th`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-28`th` -> `ec` for vm_exec().ko1
* vm.c (vm_exec): accepts `ec` instead of `th`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60506 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-28`th` -> `ec` for vm_set_*_stack.ko1
* vm.c: `th` -> `ec` for the following functions: * vm_set_top_stack * vm_set_eval_stack * vm_set_main_stack * vm_cref_new_toplevel git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60504 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-28skip machine stack marking for current ec.ko1
* vm.c (rb_execution_context_mark): At the beggining of GC marking, mark_current_machine_context() marks running machine stack so that rb_execution_context_mark() should not mark machine stack if it is current ec. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27vm_exec_core() accepts `ec` instead of `th`.ko1
* vm_exec.c (vm_exec_core): accepts `ec` instead of `th`. * vm_args.c (vm_caller_setup_arg_block): also accepts `ec`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27`th` -> `ec` for block related functions.ko1
* vm.c: the following functions accept `ec` instead of `th`. * invoke_block * invoke_bmethod * invoke_iseq_block_from_c * invoke_block_from_c_bh * check_block_handler * vm_yield_with_cref * vm_yield * vm_yield_with_block * vm_yield_force_blockarg * invoke_block_from_c_proc * vm_invoke_proc * vm_invoke_bmethod * rb_vm_invoke_proc * vm_insnhelper.c: ditto. * vm_yield_with_cfunc * vm_yield_with_symbol * vm_callee_setup_block_arg * vm_yield_setup_args * vm_invoke_iseq_block * vm_invoke_symbol_block * vm_invoke_ifunc_block * vm_invoke_block git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27Some functions accept `ec` instead of `th`.ko1
* vm_insnhelper.c: The following functions accept `ec` instead of `th`. * lep_svar * lep_svar_write * lep_svar_get * lep_svar_set * vm_getspecial git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27vm_get_ruby_level_caller_cfp() accepts `ec` instead of `th`.ko1
* vm.c (vm_get_ruby_level_caller_cfp): accepts `ec` instead of `th`. * vm.c (vm_collect_local_variables_in_heap): don't need `th` anymore. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26replace `GET_THREAD()->ec` to `GET_EC()`.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26fix freeing `th->ec` bugs.ko1
* vm.c (thread_free): simply call rb_threadptr_root_fiber_release(). * cont.c (rb_threadptr_root_fiber_release): release th->ec (ec->fiber) iff root_fiber is NULL. If root_fiber is available, then ignore it and root fiber object will free th->ec too. * cont.c (rb_threadptr_root_fiber_setup): do not set th->root_fiber. th->root_fiber will be set if a root fiber object is created. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60451 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-26vm_pop_frame() accepts `ec` instead of `th`.ko1
* vm_insnhelper.c (vm_pop_frame): accepts `ec` instead of `th`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26vm_push_frame() accepts `ec` instead of `th`.ko1
* vm_insnhelper.c (vm_push_frame): accepts `ec` instead of `th`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26use GET_EC()ko1
* vm.c (vm_ep_in_heap_p_): use GET_EC() instead of GET_THREAD(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60446 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26A function accepts `ec` instead of `th`.ko1
* vm.c (VM_CFP_IN_HEAP_P): accepts `ec` instead of `th`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26A function accepts `ec` instead of `th`.ko1
* vm.c (rb_vm_search_cf_from_ep): accept `ec` instead of `th`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26some functions accept `ec` instead of `th`.ko1
* vm.c (vm_make_env_object): accepts `ec`. * vm.c (rb_vm_get_ruby_level_next_cfp): ditto. * vm.c (rb_vm_make_proc): ditto. * vm.c (rb_vm_make_proc_lambda): ditto. * vm_core.h: some macros accept ec instead of th (and make them inline functions): * RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW * RUBY_VM_END_CONTROL_FRAME * RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P * eval.c (frame_func_id): constify for the first parameter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60441 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-10-26common conversion functionsnobu
* array.c (rb_to_array_type): make public to share common code internally. * hash.c (rb_to_hash_type): make public to share common code internally. * symbol.c (rb_to_symbol_type): make public to share common code internally. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-24Remove dynamic NODE allocation out of parsermame
A temporary NODE object was allocated to create iseq. Instead, this patch allocates a dummy NODE as auto variable, and discard it soon. This change is intended as a preparation to manage AST NODEs out of GC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e