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

681 Коммитов

Автор SHA1 Сообщение Дата
nobu 6a169a499b vm.c: unused function
* vm.c (rb_vm_jump_tag_but_local_jump): no longer used since
  r51292.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-25 21:52:00 +00:00
nobu d352d0a0a7 vm.c: fetch retval iff necessary
* vm.c (rb_vm_make_jump_tag_but_local_jump): get rid of fetching
  retval when it is not used.  it is necessary for local jump
  state only.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-25 21:51:56 +00:00
ktsj 698f2db224 vm.c: fix `cfp consistency error' which occurs
when raising exception in bmethod call event

* vm.c (invoke_bmethod): set FINISH flag just before calling vm_exec.
  [ruby-dev:50162] [Bug #13705]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59956 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-18 08:21:08 +00:00
ko1 b53b37758d store ec instead of thread in rb_context_t.
* 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-10 19:00:08 +00:00
ko1 4f0c9a5cc4 move th->machine to ec->machine.
* 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-10 15:49:45 +00:00
ko1 8e03791373 move th->fiber to ec->fiber.
* 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-08 06:21:30 +00:00
ko1 7119de47c7 accept ec instead of th.
* vm.c: VM_EP_IN_HEAP_P() and vm_ep_in_heap_p_() only requires ec
  pointed from th.

* vm.c (rb_execution_context_mark): GET_THREAD() returns current
  running thread and we need to use marking thread here. Pass marking
  thread's ec instead of current thread.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-06 03:39:26 +00:00
ko1 e413909516 th is not defined
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-06 03:18:19 +00:00
ko1 366157d32e rb_execution_context_mark.
* vm.c (rb_execution_context_mark): separate from thread_mark().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-06 02:46:59 +00:00
shyouhei 0eb7359cc7 add rb_hash_new_with_size()
Sometimes, size of a hash can be calcluated a priori.  By providing
such info to the constructor we can avoid unnecessary internal re-
allocations.  This can boost for instance creation of hash literals.
[Bug #13861]

Signed-off-by: Urabe, Shyouhei <shyouhei@ruby-lang.org>


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-05 04:48:19 +00:00
nobu 9c927f8c8b prevent stack overflow
* gc.c: enable PREVENT_STACK_OVERFLOW.

* vm.c (invoke_iseq_block_from_c): prevent stack overflow.

* vm_eval.c (stack_check): raise preallocated exception instance.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-21 14:15:31 +00:00
nobu 0afc8db914 vm_insnhelper.c: cfp error at stack overflow
* vm_insnhelper.c (threadptr_stack_overflow): set stack overflow
  flag until handling execptions, to get rid of cfp consistency
  error when exec tag was rewound.  [ruby-core:80618] [Bug #13412]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59606 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-16 07:18:45 +00:00
naruse 026979e7cf Partially revert "suppress warning: assigned but unused variable - line"
revert unexpected changes

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59605 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-15 21:39:38 +00:00
naruse e999899e4e suppress warning: assigned but unused variable - line
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-15 21:36:16 +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
ko1 46085e913a fix stack storing for root fibers.
* cont.c (root_fiber_alloc): this function is called by fiber_current()
  and fiber_store(). fiber_current() should clear VM stack information
  in a fiber data because runnning thread knows stack information and has
  responsibility to manage it. However fiber_store() requires to remain
  VM stack information in a fiber data because the responsibility to manage
  VM stack is moved to the Fiber from the Thread (and switch to another
  fiber).

* cont.c (root_fiber_alloc): save thread's fiber and root_fiber information.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-02 21:48:51 +00:00
ko1 92f7813ae2 release VM stack properly.
* cont.c: r55766 change the handling method of Fiber's VM stack.
  Resumed Fiber points NULL as VM stack and running Thread has
  responsibility to manage it (marking and releasing).

  However, thread_start_func_2()@thread.c and thread_free()@vm.c
  doesn't free the VM stack if corresponding root Fiber is exist.
  This causes memory leak. [Bug #13772]

* cont.c (root_fiber_alloc): fib->cont.saved_thread.ec.stack should be NULL
  because running thread has responsibility to manage this stack.

* vm.c (rb_thread_recycle_stack_release): assert given stack is not NULL
  (callers should care it).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-02 00:50:42 +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
ktsj 0ff27c4604 Symbol#== should be able to be redefined
* vm.c (vm_init_redefined_flag): set redefinition flag for Symbol#==.
  The bug was introduced in r58895.

* test/ruby/test_symbol.rb: test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-02 10:38:38 +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 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
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 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 3b405a8912 add a comment for rb_thread_mark()
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59069 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-12 07:58:23 +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 1a6e648075 revert r59017 it fails ruby/test_lambda.rb
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59018 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-05 07:03:27 +00:00
ko1 424b4ffe30 do not inform ``is_lambda".
* vm_eval.c (yield_under): do not inform Proc is lambda or not.
  After that invoke_block_from_c_bh() checks it.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-05 06:57:20 +00:00
ko1 ff18933b72 rename functions and clean parameters.
* internal.h (rb_yield_lambda): rename to rb_yield_force_blockarg()
  because this function prohibt lambda arg setup (strict setup).

* vm.c (invoke_iseq_block_from_c): remove splattable argument because
  it is not used.

* vm.c (invoke_block_from_c_splattable): rename to invoke_block_from_c_bh()
  because `splattable` doesn't make sense on current this function.

  Also accept `force_blockarg' parameter instead of `splattable` parameter.
  It is more clear.

* vm.c (invoke_block_from_c_unsplattable): rename to
  invoke_block_from_c_proc() and accept `proc` instead of `block'.
  This function is used only by proc block invocation.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59016 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-05 06:15:28 +00:00
ko1 1dc7906b17 remove arg_setup_lambda.
* vm_args.c (enum arg_setup_type): remove arg_setup_lambda because it is
  same as arg_setup_method.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-05 05:43:58 +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
watson1978 d0015e4ac6 Improve performance of implicit type conversion
To convert the object implicitly, it has had two parts in convert_type() which are
  1. lookink up the method's id
  2. calling the method

Seems that strncmp() and strcmp() in convert_type() are slightly heavy to look up
the method's id for type conversion.

This patch will add and use internal APIs (rb_convert_type_with_id, rb_check_convert_type_with_id)
to call the method without looking up the method's id when convert the object.

Array#flatten -> 19 % up
Array#+       ->  3 % up

[ruby-dev:50024] [Bug #13341] [Fix GH-1537]

### Before
       Array#flatten    104.119k (± 1.1%) i/s -    525.690k in   5.049517s
             Array#+      1.993M (± 1.8%) i/s -     10.010M in   5.024258s

### After
       Array#flatten    124.005k (± 1.0%) i/s -    624.240k in   5.034477s
             Array#+      2.058M (± 4.8%) i/s -     10.302M in   5.019328s

### Test Code
require 'benchmark/ips'

class Foo
  def to_ary
    [1,2,3]
  end
end

Benchmark.ips do |x|

  ary = []
  100.times { |i| ary << i }
  array = [ary]

  x.report "Array#flatten" do |i|
    i.times { array.flatten }
  end

  x.report "Array#+" do |i|
    obj = Foo.new
    i.times { array + obj }
  end

end

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58978 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-31 12:30:57 +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
nobu 66f79104e6 vm.c: free by ruby_xfree
* vm.c (ruby_vm_run_at_exit_hooks): should free by `ruby_xfree`
  memories allocated by `ALLOC`.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-12 06:19:00 +00:00
normal 7469699dce fixup r58614 for raspi3 and maybe other systems with odd compile
[ruby-core:81048]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58615 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-09 06:17:01 +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
shyouhei 29ca20de2d refactor newhash (revision 58463 another try) [fix GH-1600]
* st.c (rb_hash_bulk_insert): new API to bulk insert entries
	  into a hash. Given arguments are first inserted into the
	  table at once, then reindexed. This is faster than inserting
	  things using rb_hash_aset() one by one.

	  This arrangement (rb_ prefixed function placed in st.c) is
	  unavoidable because it both touches table internal and write
	  barrier at once.

	* internal.h: delcare the new function.

	* hash.c (rb_hash_s_create): use the new function.

	* vm.c (core_hash_merge): ditto.

	* insns.def (newhash): ditto.

	* test/ruby/test_hash.rb: more coverage on hash creation.

	* test/ruby/test_literal.rb: ditto.

-----------------------------------------------------------
benchmark results:
minimum results in each 7 measurements.
Execution time (sec)
name    before  after
loop_whileloop2  0.136  0.137
vm2_bighash*     1.249  0.623

Speedup ratio: compare with the result of `before' (greater is better)
name    after
loop_whileloop2 0.996
vm2_bighash*    2.004



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-27 04:21:04 +00:00
shyouhei a15fd1d9f2 revert newhash refactoring
We need to fix GC bug before merging this.  Revert revisions
58452, 58435, 58434, 58428, 58427 in this order.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-24 01:40:51 +00:00
shyouhei 4ee09d914d refactor hash literal
Same as rb_ary_tmp_new_from_values(), it reduces vm_exec_core binary
size from 26,176 bytes to 26,080 bytes.  But this time, also with a
bit of optimizations:

  - Because we are allocating a new hash and no back references are
    introduced at all, we can safely skip write barriers.

  - Also, the iteration never recurs.  We can avoid complicated
    function callbacks by using st_insert instead of st_update.

----

	* hash.c (rb_hash_new_from_values): refactor
          extract the bulk insert into a function.

	* hash.c (rb_hash_new_from_object): also refactor.

	* hash.c (rb_hash_s_create): use the new functions.

	* insns.def (newhash): ditto.

	* vm.c (core_hash_from_ary): ditto.

	* iternal.h: export the new function.

-----------------------------------------------------------
benchmark results:
minimum results in each 7 measurements.
Execution time (sec)
name    before  after
loop_whileloop2  0.135  0.134
vm2_bighash*     1.236  0.687

Speedup ratio: compare with the result of `before' (greater is better)
name    after
loop_whileloop2 1.008
vm2_bighash*    1.798


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-21 04:21:14 +00:00
ko1 c50afaa1c9 disable rewind hooks.
* vm.c (hook_before_rewind): skip rewind hooks if err is SystemStackError
  because rewind hooks can cause stack overflow again and again.

* thread.c (ruby_thread_stack_overflow): do not disable all hooks.
  Additionally, clearing ruby_vm_event_flags is not suitable way
  to disable hooks.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58349 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-14 07:46:11 +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