summaryrefslogtreecommitdiff
path: root/vm.c
AgeCommit message (Collapse)Author
2018-01-05node.h: remove NODE_PRELUDEmame
NODE_PRELUDE contains a `BEGIN` node, a main node, and compile_option. This node is assumed that it must be located immediately under the root NODE_SCOPE, but this strange assumption is not so good, IMO. This change removes the assumtion; it integrates the former two nodes by block_append, and moves compile_option into rb_ast_body_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-05make rb_iseq_new* accept rb_ast_body_t instead of NODE*mame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-02explicit cast to void* required for %pshyouhei
These functions take variadic arguments so no automatic type promotion is expected. You have to do it by hand. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61542 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-28`$SAFE` as a process global state. [Feature #14250]ko1
* vm_core.h (rb_vm_t): move `rb_execution_context_t::safe_level` to `rb_vm_t::safe_level_` because `$SAFE` is a process (VM) global state. * vm_core.h (rb_proc_t): remove `rb_proc_t::safe_level` because `Proc` objects don't need to keep `$SAFE` at the creation. Also make `is_from_method` and `is_lambda` as 1 bit fields. * cont.c (cont_restore_thread): no need to keep `$SAFE` for Continuation. * eval.c (ruby_cleanup): use `rb_set_safe_level_force()` instead of access `vm->safe_level_` directly. * eval_jump.c: End procs `END{}` doesn't keep `$SAFE`. * proc.c (proc_dup): removed and introduce `rb_proc_dup` in vm.c. * safe.c (rb_set_safe_level): don't check `$SAFE` 1 -> 0 changes. * safe.c (safe_setter): use `rb_set_safe_level()`. * thread.c (rb_thread_safe_level): `Thread#safe_level` returns `$SAFE`. It should be obsolete. * transcode.c (load_transcoder_entry): `rb_safe_level()` only returns 0 or 1 so that this check is not needed. * vm.c (vm_proc_create_from_captured): don't need to keep `$SAFE` for Proc. * vm.c (rb_proc_create): renamed to `proc_create`. * vm.c (rb_proc_dup): moved from proc.c. * vm.c (vm_invoke_proc): do not need to set and restore `$SAFE` for `Proc#call`. * vm_eval.c (rb_eval_cmd): rename a local variable to represent clearer meaning. * lib/drb/drb.rb: restore `$SAFE`. * lib/erb.rb: restore `$SAFE`, too. * test/lib/leakchecker.rb: check `$SAFE == 0` at the end of tests. * test/rubygems/test_gem.rb: do not set `$SAFE = 1`. * bootstraptest/test_proc.rb: catch up this change. * spec/ruby/optional/capi/string_spec.rb: ditto. * test/bigdecimal/test_bigdecimal.rb: ditto. * test/fiddle/test_func.rb: ditto. * test/fiddle/test_handle.rb: ditto. * test/net/imap/test_imap_response_parser.rb: ditto. * test/pathname/test_pathname.rb: ditto. * test/readline/test_readline.rb: ditto. * test/ruby/test_file.rb: ditto. * test/ruby/test_optimization.rb: ditto. * test/ruby/test_proc.rb: ditto. * test/ruby/test_require.rb: ditto. * test/ruby/test_thread.rb: ditto. * test/rubygems/test_gem_specification.rb: ditto. * test/test_tempfile.rb: ditto. * test/test_tmpdir.rb: ditto. * test/win32ole/test_win32ole.rb: ditto. * test/win32ole/test_win32ole_event.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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