summaryrefslogtreecommitdiff
path: root/vm_core.h
AgeCommit message (Collapse)Author
2017-09-11suppress unused argument warningnaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59837 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-10store ec instead of thread in rb_context_t.ko1
* cont.c (rb_context_t): introduce saved_ec instaad of saved_thread. We only need to transfer ec data (not all of thread data). Introduce `thread_value` field to point creation thread. To acccess this field, `cont_thread_value()` is introduced. * vm.c (rb_execution_context_mark): remove `static` and use it from cont.c (use this function instead of `rb_thread_mark`). * vm_insnhelper.c (rb_vm_push_frame): accept ec instead of th. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-10move th->machine to ec->machine.ko1
* vm_core.h: move rb_thread_t::machine to rb_execution_context_t::machine. * vm_core.h, gc.c (rb_gc_mark_machine_stack): accept ec instead of th. it enables to call this func from rb_execution_context_mark() in vm.c. * cont.c (fiber_setcontext): catch up this fix. fiber_restore_thread() restores machine stack information too. * gc.c: catch up structure layout changes. * thread.c: ditto. * thread_pthread.c: ditto. * thread_win32.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-08move th->fiber to ec->fiber.ko1
* vm_core.h (rb_thread_t::fiber): move fiber field to rb_execution_context_t::fiber. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-06thread_context -> execution_contextko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-03Refactor the internal data format for coverage measurementmame
To prepare new measuring targets: branch and method coverages. So far, iseq->coverage was an array of counts executed for line coverage. Now, it is a three-element array for each measuring target, whose first element is an array for line coverage. The second element is planned for branch coverage, and the third will be for method coverage. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-21vm_core.h: ruby_error_stackfatalnobu
* vm_core.h (ruby_special_exceptions): rename sysstack_gc as stackfatal. * eval.c (Init_eval): modified the message for stackfatal error as "critical region". git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-18vm_insnhelper.c: raise ruby_error_sysstack_gcnobu
* vm_insnhelper.c (rb_threadptr_stack_overflow): rb_fatal is not available during GC. raise the preallocated fatal error. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-10vm_core.h: unreachable VM_UNREACHABLEnobu
* vm_core.h (VM_UNREACHABLE): tell unreachable if possible. suppress an invalid-noreturn warning at rb_fiber_start. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-10rename rb_execution_context_t::stack(_size) to vm_stack(_size).ko1
* vm_core.h: Ruby processes run with two stacks, a machine stack and a VM stack. To make it clear, this fix renames rb_execution_context_t::stack(_size) to vm_stack(_size). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-05splat keyword hashnobu
* compile.c (compile_array_keyword_arg): set keyword splat flag if explicitly splatted. [ruby-core:68124] [Bug #10856] * vm_args.c (setup_parameters_complex): try keyword hash splat if given. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-05vm_core.h: vm_call_flag_bitsnobu
* vm_core.h (vm_call_flag_bits): define VM_CALL flags by using enum constants. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-27vm_core.h: shrink trap_list sizenobu
* vm_core.h (rb_vm_struct): separate trap_list cmd and safe to each arrays, to shrink the size. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59434 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-19revert r59359, r59356, r59355, r59354normal
These caused numerous CI failures I haven't been able to reproduce [ruby-core:82102] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-18hash: keep fstrings of tainted strings for string keysnormal
The same hash keys may be loaded from tainted data sources frequently (e.g. parsing headers from socket or loading YAML data from a file). If a non-tainted fstring already exists (because the application expects the hash key), cache and deduplicate the tainted version in the new tainted_frozen_strings table. For non-embedded strings, this also allows sharing with the underlying malloc-ed data. * vm_core.h (rb_vm_struct): add tainted_frozen_strings * vm.c (ruby_vm_destruct): free tainted_frozen_strings (Init_vm_objects): initialize tainted_frozen_strings (rb_vm_tfstring_table): accessor for tainted_frozen_strings * internal.h: declare rb_fstring_existing, rb_vm_tfstring_table * hash.c (fstring_existing_str): remove (moved to string.c) (hash_aset_str): use rb_fstring_existing * string.c (rb_fstring_existing): new, based on fstring_existing_str (tainted_fstr_update): new (rb_fstring_existing0): new, based on fstring_existing_str (rb_tainted_fstring_existing): new, special case for tainted strings (rb_str_free): delete from tainted_frozen_strings table * test/ruby/test_optimization.rb (test_hash_reuse_fstring): new test [ruby-core:82012] [Bug #13737] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-12Fix indent [ci skip]kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59317 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-28move fields to ec.ko1
* vm_core.h (rb_thread.h): move errinfo and trace_arg to rb_execution_context_t. * cont.c (fiber_switch, rb_cont_call): do not restore "trace_arg" here. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-28move fields to ec.ko1
* vm_core.h (rb_thread_t): move root_lep, root_svar and ensure_list to rb_execution_context_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-28fix to check thread typeko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-28introduce rb_thread_ptr() to replace GetThreadPtr().ko1
* vm_core.h (rb_thread_ptr): added to replace GetThreadPtr() macro. * thread.c (in some functions: use "target_th" instead of "th" to make clear that it is not a current thread. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-28move storages to ec.ko1
* vm_core.h (rb_thread_t): move storages to rb_execution_context_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59190 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-23vm_core.h: sandwich jmpbufnobu
* vm_core.h (rb_vm_tag): move jmpbuf which should be stored at the last in TH_PUSH_TAG, between tag and state so ensure to be accessible. reapplied r40806. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59160 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-23rb_catch_protect() accepts enum ruby_tag_type *.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59157 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-14remove OPT_CALL_CFUNC_WITHOUT_FRAME.ko1
* vm_core.h (OPT_CALL_CFUNC_WITHOUT_FRAME): removed because nobody use it. This optimization tries to call C-methods without pushing VM frames, however no big improvements compare with this complexity. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-12remove ruby_kill() introduced for [Bug #7951].ko1
* thread.c (rbuy_kill): removed. This function is used with SIGSEGV, SIGBUS, SIGKILL, SIGILL, SIGFPE and SIGSTOP and these signals are affect immediately. So that `kill(2)' is enough for them. * signal.c (rb_f_kill): ditto. * vm_core.h (rb_thread_t::interrupt_cond): removed because only `ruby_kill()' uses this field. * test/ruby/test_signal.rb: Without this patch sending SIGSTOP to own process wait another interrupt even if another process sends SIGCONT. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59066 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-06-06revert r59023 because it contans unrelated developping codeko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-06revert r59020 because it may fail some tests sometimes on some environment ↵ko1
(http://ci.rvm.jp/). This revert is to check the reason of failures. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-03* vm_core.h: remove VM_FRAME_MAGIC_LAMBDA and introduceko1
VM_FRAME_FLAG_LAMBDA. So that lambda block frame is VM_FRAME_MAGIC_BLOCK | VM_FRAME_FLAG_LAMBDA. * vm_core.h: remvoe VM_FRAME_MAGIC_PROC because nobody uses it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-01make Binding object WB protected.ko1
* proc.c (ruby_binding_data_type): set RUBY_TYPED_WB_PROTECTED. Insert write barriers (WBs) to all of writes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-01rename absolute_path to realpath internally and introduce pathobj.ko1
* vm_core.h: rename absolute_path to realpath because it is expected name. external APIs (#absolute_path methods) are remained. * vm_core.h: remove rb_iseq_location_struct::path and rb_iseq_location_struct::absolute_path and introduce pathobj. if given path equals to given absolute_path (and most of case it is true), pathobj is simply given path String. If it is not same, pathobj is Array and pathobj[0] is path and pathobj[1] is realpath. This size optimization reduce 8 bytes and sizeof(struct rb_iseq_constant_body) is 200 bytes -> 192 bytes on 64bit CPU. To support this change, the following functions are introduced: * pathobj_path() (defined in vm_core.h) * pathobj_realpath() (ditto) * rb_iseq_path() (decl. in vm_core.h) * rb_iseq_realpath() (ditto) * rb_iseq_pathobj_new() (ditto) * rb_iseq_pathobj_set() (ditto) * vm_core.h (rb_binding_t): use pathobj instead of path. If binding is given at eval methods, realpath (absolute_path) was caller's realpath. However, they should use binding's realpath. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-30add parameter names.ko1
* vm_core.h: add parameter names for rb_iseq_new*. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58967 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20speed up IO#close with many threadsnormal
Today, it increases IO#close performance with many threads: Execution time (sec) name trunk after vm_thread_close 4.276 3.018 Speedup ratio: compare with the result of `trunk' (greater is better) name after vm_thread_close 1.417 This speedup comes because rb_notify_fd_close only scans threads inside rb_thread_io_blocking_region, not all threads in the VM. In the future, this type data structure may allow us to notify waiters of multiple FDs on a single thread (when using Fibers). * thread.c (struct waiting_fd): declare (rb_thread_io_blocking_region): use on-stack list waiter (rb_notify_fd_close): walk vm->waiting_fds instead (call_without_gvl): remove old field setting (th_init): ditto * vm_core.h (typedef struct rb_vm_struct): add waiting_fds list * (typedef struct rb_thread_struct): remove waiting_fd field (rb_vm_living_threads_init): initialize waiting_fds list I am now kicking myself for not thinking about this 3 years ago when I introduced ccan/list in [Feature #9632] to optimize this same function :< git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58812 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-05-07vm_core.h (rb_thread_t): use 32-bit running_time_usnormal
The current range based current values of: TIME_QUANTUM_USEC=100000 RUBY_THREAD_PRIORITY_MAX=3 RUBY_THREAD_PRIORITY_MIN=-3 Gives a range of 12500..800000, plenty enough for a 32-bit integer. Clamping this also reduces potential implementation bugs between 32-bit and 64-bit platforms. I may consider a further reduction to uint16_t in the future for M:N threading, but some users may want slightly larger time quantums. * vm_core.h (rb_thread_t): use 32-bit running_time_us git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-09special exception messages are staticnobu
* vm_core.h (rb_vm_register_special_exception): make the contents of special exception messages static. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-09vm_core.h: ruby_error_stream_closednobu
* vm_core.h (ruby_special_exceptions): renamed ruby_error_closed_stream as ruby_error_stream_closed, like the message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58284 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-07introduce imemo_type_p(v, imemo_type)ko1
* internal.h: introduce imemo_type_p() which checks the given value is T_IMEMO and imemo_type() == given imemo_type. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-27fix redefinition optimization for -"literal string" (UMinus)normal
Unfortunately this enlarges insns.def by yet another instruction. However, it is much prettier than opt_str_freeze in use, and maybe we can avoid having so many instructions in the future. [ruby-core:80368] * insns.def (DEFINE_INSN): new instruction: opt_str_uminus (maybe temporary) * compile.c (iseq_compile_each0): split instructions * test/ruby/test_optimization.rb (test_string_uminus): new test * vm.c (vm_init_redefined_flag): set redefinintion flag for uminus * vm_core.h (enum ruby_basic_operators): add BOP_UMINUS git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-14Fiber also has same issue. [Bug #13313]ko1
* thread.c (rb_vm_proc_local_ep): added. * cont.c (rb_fiber_start): use rb_vm_proc_local_ep(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-14vm_core.h: assertions for Procnobu
* vm_core.h (vm_proc_block): assert before accessing. * vm_core.h (vm_proc_iseq): remove duplicate assertion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57966 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-16use rb_iseq_check() for USE_LAZY_LOAD, too.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-07TRUE is not defined here...ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57558 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-07remove compare with enum value.ko1
* vm_core.h (vm_block_handler_verify): some compilers warn about comparison with enum value and 0. Real assertion is in vm_block_handler_type() so we only need to call vm_block_handler_type() and the value should be TRUE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-14constifynobu
* vm_dump.c (rb_vmdebug_debug_print_pre): constify pc argument for VMDEBUG. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-07Add clang volatile fixes from FreeBSD and NetBSD.shugo
Use volatile instead of optnone to avoid optimization which causes segmentation faults. Patch by Dimitry Andric. [ruby-core:78531] [Bug #13014] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e