* vm_insnhelper.c (comparable_by_identity): extract the condition
where comparable by identity. currently both are same types,
Fixnum, Flonum, or Symbol.
* vm_insnhelper.c (opt_eql_func): support Symbol too.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_insnhelper.c (rb_eql_opt): should call #eql? on Float and
String, not #==.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58882 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This improvement is similar with https://github.com/ruby/ruby/pull/1552
internal.h: add declaration of rb_eql_opt() API.
vm_insnhelper.c (rb_eql_opt): add rb_eql_opt() API which provides optimized
path for #eql? method such as rb_equal_opt().
object.c (rb_eql): optimize using rb_eql_opt() such as rb_equal().
Array#eql? and some methods have used rb_eql() and Array#eql? will be faster
around 20%.
[ruby-core:80761] [Bug #13447] [Fix GH-#1589]
### Before
user system total real
1.570000 0.000000 1.570000 ( 1.569754)
### After
user system total real
1.300000 0.000000 1.300000 ( 1.303624)
### Test code
require 'benchmark'
Benchmark.bmbm do |x|
ary1 = Array.new(1000) { rand(1000) }
ary2 = Array.new(1000) { rand(1000) }
x.report do
5000000.times do
ary1.eql?(ary2)
end
end
end
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58881 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
* vm_insnhelper.c (vm_once_dispatch): no guarantee that tail call
is always optimized away.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Those opt_something instructions are worth refactoring. They tend to
have similar ways of executions. By extracting the common part,
generated vm_exec_core function shrinks from 26,816 bytes to 26,256
bytes (according to nm(1)).
This changeset introduces negligible performance impact. 3 repeated
runs of optcarrot benchmark on my machine resulted in:
before this: 28.813363684823557, 27.523907198440366, 27.292766121965400
after this: 28.174038497265080, 28.999513875020405, 29.621399800428065
in fps (greater==faster).
----
* vm_insnhelper.c (vm_opt_binop_dispatch): new function.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58402 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_insnhelper.c (rb_threadptr_stack_overflow): move from
thread.c and integrate with vm_stackoverflow.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_eval.c (rb_yield_lambda): new function which yields an array
to a proc and splat to a lambda. mainly for Enumerable only.
* vm_args.c (setup_parameters_complex): remove special lambda
splatting for [Bug #9605]. [ruby-core:77065] [Bug #12705]
* vm_insnhelper.c (vm_callee_setup_block_arg): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm.c (invoke_iseq_block_from_c): guard arguments on stack, not
to be clobbered during splatting.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_insnhelper.c (opt_eq_func): method to dispatch is resolved by
only the receiver's class, not including the argument class.
even if basic operation is redefined, other class conditions
never meet. optimize Float and non-Float case, delegate to
rb_float_equal directly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* How to enable this feature?
* define USE_DEBUG_COUNTER as 1.
* you can disable to output the result with
RUBY_DEBUG_COUNTER_DISABLE environment variable
even if USE_DEBUG_COUNTER == 1.
* How to add new counter?
* add COUNTER(<name>) line on debug_counter.h.
* include "debug_counter.h"
* insert RB_DEBUG_COUNTER_INC(<name>) line on your favorite place.
* counter output example:
[RUBY_DEBUG_COUNTER] mc_inline_hit 999
[RUBY_DEBUG_COUNTER] mc_inline_miss 3
[RUBY_DEBUG_COUNTER] mc_global_hit 23
[RUBY_DEBUG_COUNTER] mc_global_miss 273
[RUBY_DEBUG_COUNTER] mc_global_state_miss 3
[RUBY_DEBUG_COUNTER] mc_class_serial_miss 0
[RUBY_DEBUG_COUNTER] mc_cme_complement 0
[RUBY_DEBUG_COUNTER] mc_cme_complement_hit 0
[RUBY_DEBUG_COUNTER] mc_search_super 1384
[RUBY_DEBUG_COUNTER] ivar_get_hit 0
[RUBY_DEBUG_COUNTER] ivar_get_miss 0
[RUBY_DEBUG_COUNTER] ivar_set_hit 0
[RUBY_DEBUG_COUNTER] ivar_set_miss 0
[RUBY_DEBUG_COUNTER] ivar_get 431
[RUBY_DEBUG_COUNTER] ivar_set 465
* mc_... is related to method caching.
* ivar_... is related to instance variable accesses.
* compare with dtrace/system tap features, there are completely
no performacne penalties when it is disabled.
* This feature is supported only on __GNUC__ compilers.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_insnhelper.c (vm_call_zsuper): method defined in module in
refinement is not callable as-is. dispatch again.
[ruby-core:79588] [Bug #13227]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* eval.c (setup_exception): make unfrozen copy of special
exception before setting up a cause.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_insnhelper.c (vm_call_iseq_setup_tailcall): check interrupts
after set up the new frame, not the passed block to be clobbered
by invoked finalizers and so on. [ruby-core:78981] [Bug #13107]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57293 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_insnhelper.c (callable_class_p): update assertion as callable
class may be T_MODULE or I_ICLASS which refines a module since
r56213. [Feature #12534]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56381 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_insnhelper.c (CHECK): remove extra semicolon and fold too
long line.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55806 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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
* *.c: rename rb_funcall2 to rb_funcallv, except for extensions
which are/will be/may be gems. [Fix GH-1406]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
are imemo objects (imemo_env).
* NEWS: describe this change. I believe nobody touch these objects
because there are no method defined.
* vm_core.h: remove the following definitions.
* rb_cEnv decl.
* GetEnvPtr() because Env is no longer T_DATA object.
* vm_core.h (rb_env_t): fix layout for imemo values.
* vm_core.h (vm_assert_env): added.
* vm_core.h (vm_env_new): added.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
[Bug #12628]
This patch introduce many changes.
* Introduce concept of "Block Handler (BH)" to represent
passed blocks.
* move rb_control_frame_t::flag to ep[0] (as a special local
variable). This flags represents not only frame type, but also
env flags such as escaped.
* rename `rb_block_t` to `struct rb_block`.
* Make Proc, Binding and RubyVM::Env objects wb-protected.
Check [Bug #12628] for more details.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55766 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_insnhelper.c (vm_throw_start): check if the iseq is symbol
proc, class definition should not be a symbol proc.
[ruby-core:75856] [Bug #12462]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55297 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [Feature #12005] Unify Fixnum and Bignum into Integer
* include/ruby/ruby.h (rb_class_of): Return rb_cInteger for fixnums.
* insns.def (INTEGER_REDEFINED_OP_FLAG): Unified from
FIXNUM_REDEFINED_OP_FLAG and BIGNUM_REDEFINED_OP_FLAG.
* vm_core.h: Ditto.
* vm_insnhelper.c (opt_eq_func): Use INTEGER_REDEFINED_OP_FLAG instead
of FIXNUM_REDEFINED_OP_FLAG.
* vm.c (vm_redefinition_check_flag): Use rb_cInteger instead of
rb_cFixnum and rb_cBignum.
(C): Use Integer instead of Fixnum and Bignum.
* numeric.c (fix_succ): Removed.
(Init_Numeric): Define Fixnum as Integer.
* bignum.c (bignew): Use rb_cInteger instead of Rb_cBignum.
(rb_int_coerce): replaced from rb_big_coerce and return fixnums
as-is.
(Init_Bignum): Define Bignum as Integer.
Don't define ===.
* error.c (builtin_class_name): Return "Integer" for fixnums.
* sprintf.c (ruby__sfvextra): Use rb_cInteger instead of rb_cFixnum.
* ext/-test-/testutil: New directory to test.
Currently it provides utilities for fixnum and bignum.
* ext/json/generator/generator.c: Define mInteger_to_json.
* lib/mathn.rb (Fixnum#/): Redefinition removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_insnhelper.c (vm_get_ev_const): warn deprecated constant even
in the class context. [ruby-core:75505] [Bug #12382]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e