Граф коммитов

463 Коммитов

Автор SHA1 Сообщение Дата
nobu b54f535506 vm_core.h: ruby_error_stackfatal
* 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-21 06:46:46 +00:00
nobu a7bccb20f8 vm_insnhelper.c: raise ruby_error_sysstack_gc
* 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-18 12:17:59 +00:00
nobu 1f5bf61c6e vm_core.h: unreachable VM_UNREACHABLE
* 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-10 11:40:49 +00:00
ko1 6881279149 rename rb_execution_context_t::stack(_size) to vm_stack(_size).
* 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-10 04:55:12 +00:00
nobu 26aed9c577 splat keyword hash
* 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-05 06:58:44 +00:00
nobu d11dfab569 vm_core.h: vm_call_flag_bits
* 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-08-05 06:51:08 +00:00
nobu 083a25f903 vm_core.h: shrink trap_list size
* 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-27 12:17:56 +00:00
normal 0493b1ce3a revert r59359, r59356, r59355, r59354
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-19 01:35:04 +00:00
normal d04c085b3c hash: keep fstrings of tainted strings for string keys
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-18 02:29:59 +00:00
kazu b25b9d4531 Fix indent [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59317 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-12 15:02:09 +00:00
ko1 8dd9c12c58 move fields to ec.
* 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-28 14:27:49 +00:00
ko1 957d1ccdf9 move fields to ec.
* 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-28 06:09:06 +00:00
ko1 3462dd3609 fix to check thread type
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-28 04:57:02 +00:00
ko1 249790802d introduce rb_thread_ptr() to replace GetThreadPtr().
* 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-28 04:49:30 +00:00
ko1 d98afe3ae2 move storages to ec.
* 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-28 02:50:56 +00:00
ko1 1939d097e6 move several fields from rb_thread_t to rb_execution_context_t.
* 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-26 07:56:44 +00:00
nobu f61e8084bb vm_core.h: sandwich jmpbuf
* 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-23 11:15:26 +00:00
ko1 4a4627fb0d move "state" to rb_vm_tag.
* 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-23 09:43:52 +00:00
ko1 a64801c1e9 rename th->state to th->tag_state.
* 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-23 08:48:41 +00:00
ko1 a90c696b8b rb_catch_protect() accepts enum ruby_tag_type *.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-23 08:24:54 +00:00
ko1 2108e55c0b use "enum ruby_tag_type" and TAG_NONE.
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-23 07:25:52 +00:00
ko1 d7e7f051e4 remove OPT_CALL_CFUNC_WITHOUT_FRAME.
* 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-14 02:26:18 +00:00
ko1 6c3f1461cd remove ruby_kill() introduced for [Bug #7951].
* 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-12 04:52:25 +00:00
ko1 269b795556 vm_block_handler_verify() should not return any value.
* 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-08 05:22:49 +00:00
ko1 e9c440815e revert r59023 because it contans unrelated developping code
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-06 07:10:19 +00:00
ko1 b0c9215f72 revert r59020 because it may fail some tests sometimes on some environment (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-06 06:58:54 +00:00
ko1 26864584d2 * vm_core.h: remove VM_FRAME_MAGIC_LAMBDA and introduce
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-03 10:07:44 +00:00
ko1 9301ef5d0e make Binding object WB protected.
* 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-01 15:12:14 +00:00
ko1 478003f6df rename absolute_path to realpath internally and introduce pathobj.
* 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-06-01 00:05:33 +00:00
ko1 492c88dc3b add parameter names.
* 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-30 07:05:58 +00:00
normal 508091d9cc speed up IO#close with many threads
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-20 09:47:14 +00:00
normal 9d09240d9e rb_execution_context_t: move stack, stack_size and cfp from rb_thread_t
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-09 05:06:41 +00:00
normal 95f135960f vm_core.h (rb_thread_t): use 32-bit running_time_us
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-05-07 08:06:02 +00:00
nobu dce00119c6 special exception messages are static
* 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-09 04:01:07 +00:00
nobu 301143273a vm_core.h: ruby_error_stream_closed
* 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-09 02:34:49 +00:00
ko1 7519688ed8 introduce imemo_type_p(v, imemo_type)
* 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-04-07 06:41:32 +00:00
normal 669a55dfed fix redefinition optimization for -"literal string" (UMinus)
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-27 06:12:37 +00:00
ko1 3651c0aa00 Fiber also has same issue. [Bug #13313]
* 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-14 06:52:44 +00:00
nobu a7d6470f35 vm_core.h: assertions for Proc
* 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-03-14 04:03:48 +00:00
ko1 ccc388d806 use rb_iseq_check() for USE_LAZY_LOAD, too.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-16 09:15:26 +00:00
ko1 950d15bc97 TRUE is not defined here...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57558 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-07 04:24:44 +00:00
ko1 361edea73d remove compare with enum value.
* 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
2017-02-07 04:14:25 +00:00
nobu 1407e52ba4 constify
* 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-14 08:06:55 +00:00
shugo 472959f9c2 Add clang volatile fixes from FreeBSD and NetBSD.
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
2016-12-07 23:27:51 +00:00
nobu d71b5394ac Make `trace_running` an integer flag again
* vm_core.h (rb_vm_struct): trace_running should be a counter but
  not a bit flag.  [ruby-core:78514] [Bug #13011]

Author: David Rodríguez <deivid.rodriguez@gmail.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57002 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-06 13:57:23 +00:00
ktsj 9cbd6ee097 * vm_trace.c (tracepoint_attr_callee_id, rb_tracearg_callee_id):
add TracePoint#callee_id. [ruby-core:77241] [Feature #12747]

* cont.c, eval.c, gc.c, include/ruby/intern.h, insns.def, thread.c,
  vm.c, vm_backtrace.c, vm_core.h, vm_eval.c, vm_insnhelper.c, vm_trace.c: ditto.

* test/ruby/test_settracefunc.rb: tests for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-05 13:15:27 +00:00
nobu 8459ceb860 vm_core.h: stringify in VM_ASSERT
* vm_core.h (VM_ASSERT): stringify expr here before expansion in
  RUBY_ASSERT_WHEN.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56378 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-09 02:37:21 +00:00
ko1 03cad83593 * vm_core.h: introduce VM_FRAME_RUBYFRAME_P()
and VM_FRAME_CFRAME_P().
  Most of case, RUBY_VM_NORMAL_ISEQ_P() is no
  longer needed.

* vm_core.h: introduce rb_obj_is_iseq().

* cont.c, vm.c: VM_FRAME_MAGIC_DUMMY with
  VM_FRAME_FLAG_CFRAME.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55804 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-03 01:50:50 +00:00
ko1 0cd7f5fe87 * vm_core.h: rename macros and make them inline functions.
* rename VM_FRAME_TYPE_FINISH_P() to VM_FRAME_FINISHED_P().
  * rename VM_FRAME_TYPE_BMETHOD_P() to VM_FRAME_BMETHOD_P().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-03 00:28:12 +00:00
ko1 e3120e1a99 * vm_core.h: introduce VM_FRAME_FLAG_CFRAME to represent cfp->iseq
type.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-03 00:16:34 +00:00