summaryrefslogtreecommitdiff
path: root/vm_eval.c
AgeCommit message (Collapse)Author
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-05node.h: define rb_ast_body_t and restructure rb_ast_tmame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61608 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-27vm_eval.c: expanded eval_stringnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-27vm_eval.c: split eval_string_with_crefnobu
* vm_eval.c (eval_string_with_cref): split into cref and scope modes, which are exclusive. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-27vm_eval.c: refactor eval_make_iseqnobu
* vm_eval.c (eval_make_iseq): moved preparations of location and debug print. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-26parse.y: warning for locationsnobu
* parse.y (gettable_gen): warn for __FILE__/__LINE__ when eval with binding only. promote use of Binding#source_location instead. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-26vm_eval.c: strange message in evalnobu
* vm_eval.c (eval_string_with_cref): remove unnecessary location from exception backtrace in eval. [ruby-core:84434] [Bug #14229] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-13iseq.c: dump type of branchiftype on disasmk0kubun
This makes easier to debug scripts related to r59950. * before $ ./ruby --dump=insns -e '"#{a}"' == disasm: #<ISeq:<main>@-e>============================================ 0000 putobject "" ( 1)[Li] 0002 putself 0003 opt_send_without_block <callinfo!mid:a, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache> 0006 dup 0007 branchiftype 5, 15 0010 dup 0011 opt_send_without_block <callinfo!mid:to_s, argc:0, FCALL|ARGS_SIMPLE>, <callcache> 0014 tostring 0015 concatstrings 2 0017 leave * after $ ./ruby --dump=insns -e '"#{a}"' == disasm: #<ISeq:<main>@-e>============================================ 0000 putobject "" ( 1)[Li] 0002 putself 0003 opt_send_without_block <callinfo!mid:a, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache> 0006 dup 0007 branchiftype T_STRING, 15 0010 dup 0011 opt_send_without_block <callinfo!mid:to_s, argc:0, FCALL|ARGS_SIMPLE>, <callcache> 0014 tostring 0015 concatstrings 2 0017 leave git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61217 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-16make a func static.ko1
* vm_eval.c (rb_f_block_given_p): make it static. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-16make a func static.ko1
* vm_eval.c (rb_f_public_send): make it static. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60802 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-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* vm_eval.c (rescue_funcall_args): th->ecko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60686 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-07move `rb_thread_t::method_missing_reason` to ec.ko1
* vm_core.h (rb_thread_t): move method_missing_reason to rb_execution_context_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60679 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-06move rb_thread_t::interrupt_flag and maskko1
to rb_execution_context_t. * vm_core.h (rb_thread_t): move `rb_thread_t::interrupt_flag` and `rb_thread_t::interrupt_mask` to rb_execution_context_t. RUBY_VM_CHECK_INTS() accepts `ec` instead of `th`. * cont.c (rb_fiber_terminate): to propagate interrupt information, add new parameter `need_interrupt`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29* vm_eval.c (current_vm_stack_arg): accepts `ec`.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60561 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29* vm_eval.c (vm_catch_protect): accepts `ec` instead of `th`.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29use `GET_EC()`.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60554 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29use `GET_EC()`.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60553 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29`th` -> `ec` for `rb_iterate0`.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60552 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-29`rb_call0()` accepts `ec`.ko1
* vm_eval.c (rb_call0): accepts `ec`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60550 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29* vm_eval.c (rb_current_receiver): use `GET_EC()`.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29`th` -> `ec` for vm_call_super().ko1
* vm_eval.c (vm_call_super): accepts `ec` instead of `th`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60548 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-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 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 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_call()ko1
* vm_eval.c (rb_vm_call): accepts `ec` instead of `th`. * proc.c: catch up this fix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60520 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-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-27`vm_call_handler` and related functions accept `ec` instead of `th`.ko1
* vm_core.h (vm_call_handler): fix to accept `ec` instead of `th`. * vm_args.c: the following functions accept `ec` instead of `th`. * raise_argument_error * argument_arity_error * argument_kw_error * setup_parameters_complex * vm_eval.c: ditto. * vm_call0 * vm_call0_cfunc_with_frame * vm_call0_cfunc * vm_call0_body * vm_insnhelper.c: ditto * vm_call_iseq_setup_tailcall_0start * vm_call_iseq_setup_normal_0start * vm_callee_setup_arg * vm_call_iseq_setup * vm_call_iseq_setup_2 * vm_call_iseq_setup_normal * vm_call_iseq_setup_tailcall * vm_cfp_consistent_p * vm_call_cfunc_with_frame * vm_call_cfunc * vm_call_ivar * vm_call_attrset * vm_call_bmethod_body * vm_call_bmethod * vm_call_opt_send * vm_call_opt_call * vm_call_method_missing * vm_call_zsuper * current_method_entry * vm_call_method_each_type * vm_call_method_nome * vm_call_method * vm_call_general * vm_call_super_method * tool/mk_call_iseq_optimized.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27ec->th for vm_cref_push() and constify.ko1
* vm_insnhelper.c (vm_cref_push): accepts `ec` instead of `th`. * vm_insnhelper.c: consitfy the first parameter (ec): * lep_svar * lep_svar_write * lep_svar_get * lep_svar_set * vm_getspecial and added vm_cref_push. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27refactoring (rb_|)threadptr_stack_overflow.ko1
* vm_insnhelper.c (ec_stack_overflow): renamed from threadptr_stack_overflow and also rb_ec_stack_overflow is from rb_threadptr_stack_overflow because they accept `ec` instead of `th`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60464 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-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-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-24vm_eval.c: all value type casesnobu
* vm_eval.c (rb_type_str): ensure all value types are covered. missed types would be warned by -Wswitch option of gcc. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-24vm_eval.c: uncallable_objectnobu
* vm_eval.c (uncallable_object): extract error case as a no-return function. split successive ?-marks not to get confused with a trigraph. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60392 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-02Revert "vm_eval.c: add rb_yield_assoc_or_values()"glass
This reverts commit r60095 to prevent performance degradation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-02vm_eval.c: add rb_yield_assoc_or_values()glass
The new function rb_yield_assoc_or_values() will reduce branching. * vm_eval.c: add rb_yield_assoc_or_values() * internal.h: ditto * hash.c: use rb_yield_assoc_or_values() * struct.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e