* vm_trace.c: before this patch, deleted hooks are remvoed at
*the beggining* of hooks (exec_hooks_precheck).
This patch cleanup deleted hooks at
(1) just after hook is deleted (TracePoint#disable and so on)
(2) just after executing hooks (exec_hooks_postcheck)
Most of time (1) is enough, but if some threads running hooks,
we need to wait cleaning up deleted hooks until threads finish
running the hooks. This is why (2) is introduced (and this is
why current impl cleanup deleted hooks at the beggining of hooks).
* test/lib/tracepointchecker.rb: check also the number of delete
waiting hooks.
* cont.c (cont_restore_thread): fix VM->trace_running count.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* 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
* vm_trace.c (update_global_event_hook): rewrite ISeqs only when
effective events are changed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* tool/instruction.rb: create `trace_` prefix instructions.
* compile.c (ADD_TRACE): do not add `trace` instructions but add
TRACE link elements. TRACE elements will be unified with a next
instruction as instruction information.
* vm_trace.c (update_global_event_hook): modify all ISeqs when
hooks are enabled.
* iseq.c (rb_iseq_trace_set): added to toggle `trace_` instructions.
* vm_insnhelper.c (vm_trace): added.
This function is a body of `trace_` prefix instructions.
* vm_insnhelper.h (JUMP): save PC to a control frame.
* insns.def (trace): removed.
* vm_exec.h (INSN_ENTRY_SIG): add debug output (disabled).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_trace.c (rb_postponed_job_t): remove `th` field because it is not used.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60678 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_trace.c (rb_threadptr_exec_event_hooks_orig): prepare local variables
`th` and `vm` instead of using rb_ec_... functions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* 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
[ci skip]
`TracePoint` doesn't have the `line` method.
Therefore, this example will raise `NoMethodError`.
But since it does not seem to be the intended error, use the existing `lineno`
method instead.
Patch by: yuuji.yaginuma <yuuji.yaginuma@gmail.com>
https://github.com/ruby/ruby/pull/1731
[Fix GH-1731]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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
* array.c (rb_to_array_type): make public to share common code
internally.
* hash.c (rb_to_hash_type): make public to share common code
internally.
* symbol.c (rb_to_symbol_type): make public to share common code
internally.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* 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
* 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
* 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
* 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
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
* 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
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
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
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
instead of setting rb_thread_t::cfp directly.
* vm_insnhelper.c (vm_pop_frame): return the result of
finish frame or not.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_eval.c (rb_eval_cmd, rb_catch_obj): use TH_JUMP_TAG with the
same rb_thread_t used for TH_PUSH_TAG, instead of JUMP_TAG with
the current thread global variable.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_trace.c (recalc_remove_ruby_vm_event_flags): Add a cast to
avoid signed integer overflow.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
to clean-up unused hooks.
* vm_trace.c (list->need_clean): use as boolean value.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
maintain trace_running counter on internal events.
This patch is made by Takashi Kokubun <takashikkbn@gmail.com>.
[Bug #11603] https://github.com/ruby/ruby/pull/1059
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
fiber_switch. We need more discussion about this feature
so that I don't write it on NEWS.
[Feature #11348]
* test/ruby/test_settracefunc.rb: add tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
All contents of previous rb_iseq_t is in rb_iseq_t::body.
Remove rb_iseq_t::self because rb_iseq_t is an object.
RubyVM::InstructionSequence is wrapper object points T_IMEMO/iseq.
So RubyVM::ISeq.of(something) method returns different wrapper
objects but they point the same T_IMEMO/iseq object.
This patch is big, but most of difference is replacement of
iseq->xxx to iseq->body->xxx.
(previous) rb_iseq_t::compile_data is also located to
rb_iseq_t::compile_data.
It was moved from rb_iseq_body::compile_data.
Now rb_iseq_t has empty two pointers.
I will split rb_iseq_body data into static data and dynamic data.
* compile.c: rename some functions/macros.
Now, we don't need to separate iseq and iseqval (only VALUE).
* eval.c (ruby_exec_internal): `n' is rb_iseq_t (T_IMEMO/iseq).
* ext/objspace/objspace.c (count_imemo_objects): count T_IMEMO/iseq.
* gc.c: check T_IMEMO/iseq.
* internal.h: add imemo_type::imemo_iseq.
* iseq.c: define RubyVM::InstructionSequnce as T_OBJECT.
Methods are implemented by functions named iseqw_....
* load.c (rb_load_internal0): rb_iseq_new_top() returns
rb_iseq_t (T_IMEMO/iesq).
* method.h (rb_add_method_iseq): accept rb_iseq_t (T_IMEMO/iseq).
* vm_core.h (GetISeqPtr): removed because it is not T_DATA now.
* vm_core.h (struct rb_iseq_body): remove padding for
[Bug #10037][ruby-core:63721].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e